1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "ATOMICGUI_Data.h"
23 int ATOMICGUI_AtomicMolecule::myMaxId = 0;
24 int ATOMICGUI_AtomicMolecule::Atom::myMaxId = 0;
26 /*! Constructor of Atom */
27 ATOMICGUI_AtomicMolecule::Atom::Atom()
28 : myName( QString::null ), myX( 0. ), myY( 0. ), myZ( 0. )
33 /*! Constructor of Atom */
34 ATOMICGUI_AtomicMolecule::Atom::Atom( const QString& name,
38 : myName( name ), myX( x ), myY( y ), myZ( z )
43 /*! Constructor of Molecule */
44 ATOMICGUI_AtomicMolecule::ATOMICGUI_AtomicMolecule( const QString& name )
47 myName = name.isEmpty() ? QObject::tr( "ATOMICGUI_NONAME" ) : name;
50 /*! Destructor of Molecule */
51 ATOMICGUI_AtomicMolecule::~ATOMICGUI_AtomicMolecule()
55 /*! Adds an atom to the molecule */
56 void ATOMICGUI_AtomicMolecule::addAtom( const QString& atom,
61 myAtoms.append( Atom( atom, x, y, z ) );
64 /*! Removes an atom from molecule by index */
65 void ATOMICGUI_AtomicMolecule::deleteAtom( const int index )
67 if ( index >= 0 && index < myAtoms.count() )
68 myAtoms.removeAt( index );
71 /*! Gets an atom id by index */
72 int ATOMICGUI_AtomicMolecule::atomId( const int index ) const
74 if ( index >= 0 && index < myAtoms.count() )
75 return myAtoms[ index ].id();
79 /*! Gets an atom name by index */
80 QString ATOMICGUI_AtomicMolecule::atomName( const int index ) const
83 if ( index >= 0 && index < myAtoms.count() )
84 n = myAtoms[ index ].name();
88 /*! Gets an atom x coordinate by index */
89 double ATOMICGUI_AtomicMolecule::atomX( const int index ) const
91 if ( index >= 0 && index < myAtoms.count() )
92 return myAtoms[ index ].x();
96 /*! Gets an atom y coordinate by index */
97 double ATOMICGUI_AtomicMolecule::atomY( const int index ) const
99 if ( index >= 0 && index < myAtoms.count() )
100 return myAtoms[ index ].y();
104 /*! Gets an atom z coordinate by index */
105 double ATOMICGUI_AtomicMolecule::atomZ( const int index ) const
107 if ( index >= 0 && index < myAtoms.count() )
108 return myAtoms[ index ].z();
112 /*! Sets a name to the molecule or atom */
113 void ATOMICGUI_AtomicMolecule::setName( const QString& name, const int index )
117 else if ( index >= 0 && index < myAtoms.count() )
118 myAtoms[ index ].myName = name;