Salome HOME
1081c71597221938364b4f53ca91104d9cbc7221
[samples/atomic.git] / src / ATOMICGUI / ATOMICGUI_Data.h
1 // Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #if !defined(ATOMICGUI_DATA_H)
21 #define ATOMICGUI_DATA_H
22
23 #include "ATOMICGUI_ATOMICGUI.hxx"
24
25 #include <qlist.h>
26 #include <qstring.h>
27
28 /*!
29  * Class       : ATOMICGUI_AtomicMolecule, ATOMICGUI_AtomicMolecule::Atom
30  * Description : Core classes for data of ATOMIC component
31  */
32 class ATOMICGUI_EXPORT ATOMICGUI_AtomicMolecule
33 {
34 private:
35
36   class Atom
37   {
38   public:
39     Atom();
40     Atom( const QString& name, const double x, const double y, const double z );
41     QString name() const { return myName; }
42     double  x()    const { return myX;    }
43     double  y()    const { return myY;    }
44     double  z()    const { return myZ;    }
45     
46     int     id ()  const { return myId;   }
47     
48   private:
49     QString    myName;
50     double     myX;
51     double     myY;
52     double     myZ;
53     int        myId;
54     static int myMaxId;
55
56     friend class ATOMICGUI_AtomicMolecule;
57   };
58
59 public:
60   ATOMICGUI_AtomicMolecule( const QString& name = QString::null );
61   virtual ~ATOMICGUI_AtomicMolecule();
62
63   void addAtom( const QString& atom, const double x, const double y, const double z );
64   void deleteAtom( const int index );
65   
66   int         id     () const { return myId; }
67   QString     name   () const { return myName; }
68   int         count  () const { return myAtoms.count(); }
69
70   int         atomId   ( const int index ) const;
71   QString     atomName ( const int index ) const;
72   double      atomX    ( const int index ) const;
73   double      atomY    ( const int index ) const;
74   double      atomZ    ( const int index ) const;
75
76   void        setName( const QString& name, const int index = -1 );
77
78 private:
79   QString          myName;
80   QList<Atom> myAtoms;
81   int              myId;
82   static int       myMaxId;
83 };
84
85 #endif // ATOMICGUI_DATA_H