Salome HOME
5672caae7e77b8b157d9ea39df0d236c43a0de02
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI_DataModel.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3
4 #ifndef SHAPERGUI_DATAMODEL_H
5 #define SHAPERGUI_DATAMODEL_H
6
7 #include "SHAPER_SHAPERGUI.h"
8 #include <LightApp_DataModel.h>
9
10 class SHAPERGUI;
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 SHAPERGUI_EXPORT SHAPERGUI_DataModel : public LightApp_DataModel
17 {
18   Q_OBJECT
19  public:
20    /// Constructor
21    /// \param theModule a module instance
22   SHAPERGUI_DataModel(SHAPERGUI* theModule);
23   virtual ~SHAPERGUI_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   /// Redefinition of virtual method: include the module dump in the common SALOME dump
65   virtual bool dumpPython( const QString&, CAM_Study*, bool,  QStringList& );
66
67 protected:
68   /**
69    * Removes the directory with content if it exists
70    * \param theDirectoryName a directory name
71    */
72   static void removeDirectory(const QString& theDirectoryName);
73
74  private:
75    /// Pat to a study file
76   QString myStudyPath;
77
78   /// a path to the temporary directory, created by opening a document file
79   QString myTmpDirectory; 
80
81   /// it should be created because the files reading is postponed in the module. The directory
82   // should be removed after the model document is closed.
83   SHAPERGUI* myModule;
84 };
85
86 #endif