Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/gui.git] / src / CAM / CAM_DataModel.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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/
18 //
19 #ifndef CAM_DATAMODEL_H
20 #define CAM_DATAMODEL_H
21
22 #include "CAM.h"
23
24 #include <qobject.h>
25 #include <qstringlist.h>
26
27 class CAM_Module;
28 class CAM_DataObject;
29 class CAM_Study;
30 class SUIT_DataObject;
31
32 /*!
33   \class CAM_DataModel
34   Base class for all data models used in CAM-based applications.
35   Represents data model of CAM module. Provides necessary interface (default implementation is empty)
36 */
37 class CAM_EXPORT CAM_DataModel : public QObject
38 {
39   Q_OBJECT
40
41 public:
42   CAM_DataModel( CAM_Module* );
43   virtual ~CAM_DataModel();
44
45   virtual void     initialize();
46
47   CAM_DataObject*  root() const;
48   CAM_Module*      module() const;
49
50   /** @name These methods should be redefined in successors.*/
51   //@{
52   virtual bool     open( const QString&, CAM_Study*, QStringList ) { return true; }//!< return true
53   virtual bool     save( QStringList& ) { return true; };
54   virtual bool     saveAs( const QString&, CAM_Study*, QStringList&  ) { return true; };
55   virtual bool     close() { return true; };
56   virtual bool     create( CAM_Study* ) { return true; }
57   //@}
58
59 protected:
60   /*! setRoot() should be used to specify custom root object instance.\n
61    * Such an object can be created in several ways, depending on application or module needs:\n
62    * \li by initialize()
63    * \li while the model is being loaded
64    * \li when the model is updated and becomes non-empty 
65    */
66   virtual void     setRoot( const CAM_DataObject* );
67
68 private slots:
69   void             onDestroyed( SUIT_DataObject* );
70
71 signals:
72   void             rootChanged( const CAM_DataModel* );
73
74 private:
75   CAM_DataObject*  myRoot;
76   CAM_Module*      myModule;
77 };
78
79 #endif