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