Salome HOME
e553f8cccda533b43e45d0778cd7ab09196e0df2
[modules/shaper.git] / src / NewGeom / NewGeom_DataModel.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3
4 #ifndef NEWGEOM_DATAMODEL_H
5 #define NEWGEOM_DATAMODEL_H
6
7 #include "NewGeom.h"
8 #include <LightApp_DataModel.h>
9
10 class NewGeom_Module;
11
12 /**
13 * \ingroup Salome
14 * A Data Model class provides a connection of SALOME data structure and OpenParts application data model
15 */
16 class NewGeom_EXPORT NewGeom_DataModel : public LightApp_DataModel
17 {
18   Q_OBJECT
19  public:
20    /// Constructor
21    /// \param theModule a module instance
22   NewGeom_DataModel(NewGeom_Module* theModule);
23   virtual ~NewGeom_DataModel();
24
25   /// Open a data file
26   /// \param thePath a path to the directory
27   /// \param theStudy a current study
28   /// \param theFiles a list of files to open
29   virtual bool open(const QString& thePath, CAM_Study* theStudy, QStringList theFiles);
30
31   /// Save module data to file
32   /// \param theFiles list of created files
33   virtual bool save(QStringList& theFiles);
34
35   /// Save module data to a file
36   /// \param thePath a path to the directory
37   /// \param theStudy a current study
38   /// \param theFiles a list of files to open
39   virtual bool saveAs(const QString& thePath, CAM_Study* theStudy, QStringList& theFiles);
40
41   /// Close data structure
42   virtual bool close();
43
44   /// Create data structure
45   /// \param theStudy a current study
46   virtual bool create(CAM_Study* theStudy);
47
48   /// Returns True if the data structure has been modified
49   virtual bool isModified() const;
50
51   /// Returns True if the data structure is already saved
52   virtual bool isSaved() const;
53
54   /// Creates a module root object if it has not been created yet
55   /// and append it to the active study. It is necessary for correct persistent
56   /// of the model.
57   void initRootObject();
58
59   /// Update data object
60   /// \param theObj an data object
61   /// \param theStudy a current study
62   virtual void update(LightApp_DataObject* theObj = 0, LightApp_Study* theStudy = 0);
63
64 protected:
65   /**
66    * Removes the directory with content if it exists
67    * \param theDirectoryName a directory name
68    */
69   static void removeDirectory(const QString& theDirectoryName);
70
71  private:
72    /// Pat to a study file
73   QString myStudyPath;
74
75   /// a path to the temporary directory, created by opening a document file
76   QString myTmpDirectory; 
77
78   /// it should be created because the files reading is postponed in the module. The directory
79   // should be removed after the model document is closed.
80   NewGeom_Module* myModule;
81 };
82
83 #endif