Salome HOME
Use compressing for saving SHAPER files
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI_DataModel.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF 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, 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef SHAPERGUI_DATAMODEL_H
22 #define SHAPERGUI_DATAMODEL_H
23
24 #include "SHAPER_SHAPERGUI.h"
25 #include <LightApp_DataModel.h>
26
27 class SHAPERGUI;
28
29 /**
30 * \ingroup Salome
31 * A Data Model class provides a connection of SALOME data structure and OpenParts application data model
32 */
33 class SHAPERGUI_EXPORT SHAPERGUI_DataModel : public LightApp_DataModel
34 {
35   Q_OBJECT
36  public:
37    /// Constructor
38    /// \param theModule a module instance
39   SHAPERGUI_DataModel(SHAPERGUI* theModule);
40   virtual ~SHAPERGUI_DataModel();
41
42   /// Open a data file
43   /// \param thePath a path to the directory
44   /// \param theStudy a current study
45   /// \param theFiles a list of files to open
46   virtual bool open(const QString& thePath, CAM_Study* theStudy, QStringList theFiles);
47
48   /// Save module data to file
49   /// \param theFiles list of created files
50   virtual bool save(QStringList& theFiles);
51
52   /// Save module data to a file
53   /// \param thePath a path to the directory
54   /// \param theStudy a current study
55   /// \param theFiles a list of files to open
56   virtual bool saveAs(const QString& thePath, CAM_Study* theStudy, QStringList& theFiles);
57
58   /// Close data structure
59   virtual bool close();
60
61   /// Create data structure
62   /// \param theStudy a current study
63   virtual bool create(CAM_Study* theStudy);
64
65   /// Returns True if the data structure has been modified
66   virtual bool isModified() const;
67
68   /// Returns True if the data structure is already saved
69   virtual bool isSaved() const;
70
71   /// Creates a module root object if it has not been created yet
72   /// and append it to the active study. It is necessary for correct persistent
73   /// of the model.
74   void initRootObject();
75
76   /// Update data object
77   /// \param theObj an data object
78   /// \param theStudy a current study
79   virtual void update(LightApp_DataObject* theObj = 0, LightApp_Study* theStudy = 0);
80
81   /// Redefinition of virtual method: include the module dump in the common SALOME dump
82   virtual bool dumpPython( const QString&, CAM_Study*, bool,  QStringList& );
83
84 protected:
85   /**
86    * Removes the directory with content if it exists
87    * \param theDirectoryName a directory name
88    */
89   static void removeDirectory(const QString& theDirectoryName);
90
91  private:
92    /// Pat to a study file
93   QString myStudyPath;
94
95   /// a path to the temporary directory, created by opening a document file
96   //QString myTmpDirectory;
97
98   /// it should be created because the files reading is postponed in the module. The directory
99   // should be removed after the model document is closed.
100   SHAPERGUI* myModule;
101 };
102
103 #endif