1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
22 #include "ATOMICGUI_Data.h"
25 int ATOMICGUI_AtomicMolecule::myMaxId = 0;
26 int ATOMICGUI_AtomicMolecule::Atom::myMaxId = 0;
28 /*! Constructor of Atom */
29 ATOMICGUI_AtomicMolecule::Atom::Atom()
30 : myName( QString::null ), myX( 0. ), myY( 0. ), myZ( 0. )
35 /*! Constructor of Atom */
36 ATOMICGUI_AtomicMolecule::Atom::Atom( const QString& name,
40 : myName( name ), myX( x ), myY( y ), myZ( z )
45 /*! Constructor of Molecule */
46 ATOMICGUI_AtomicMolecule::ATOMICGUI_AtomicMolecule( const QString& name )
49 myName = name.isEmpty() ? QObject::tr( "ATOMICGUI_NONAME" ) : name;
52 /*! Destructor of Molecule */
53 ATOMICGUI_AtomicMolecule::~ATOMICGUI_AtomicMolecule()
57 /*! Adds an atom to the molecule */
58 void ATOMICGUI_AtomicMolecule::addAtom( const QString& atom,
63 myAtoms.append( Atom( atom, x, y, z ) );
66 /*! Removes an atom from molecule by index */
67 void ATOMICGUI_AtomicMolecule::deleteAtom( const int index )
69 if ( index >= 0 and index < myAtoms.count() )
70 myAtoms.removeAt( index );
73 /*! Gets an atom id by index */
74 int ATOMICGUI_AtomicMolecule::atomId( const int index ) const
76 if ( index >= 0 and index < myAtoms.count() )
77 return myAtoms[ index ].id();
81 /*! Gets an atom name by index */
82 QString ATOMICGUI_AtomicMolecule::atomName( const int index ) const
85 if ( index >= 0 and index < myAtoms.count() )
86 n = myAtoms[ index ].name();
90 /*! Gets an atom x coordinate by index */
91 double ATOMICGUI_AtomicMolecule::atomX( const int index ) const
93 if ( index >= 0 and index < myAtoms.count() )
94 return myAtoms[ index ].x();
98 /*! Gets an atom y coordinate by index */
99 double ATOMICGUI_AtomicMolecule::atomY( const int index ) const
101 if ( index >= 0 and index < myAtoms.count() )
102 return myAtoms[ index ].y();
106 /*! Gets an atom z coordinate by index */
107 double ATOMICGUI_AtomicMolecule::atomZ( const int index ) const
109 if ( index >= 0 and index < myAtoms.count() )
110 return myAtoms[ index ].z();
114 /*! Sets a name to the molecule or atom */
115 void ATOMICGUI_AtomicMolecule::setName( const QString& name, const int index )
119 else if ( index >= 0 and index < myAtoms.count() )
120 myAtoms[ index ].myName = name;