Salome HOME
Copyright update: 2016
[modules/smesh.git] / src / SMESH_I / SMESH_NoteBook.hxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
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 // File      : SMESH_NoteBook.hxx
21 // Author    : Roman NIKOLAEV ()
22 //
23 #ifndef SMESH_NoteBook_HeaderFile
24 #define SMESH_NoteBook_HeaderFile
25
26 // All this stuff is obsolete since issue 0021308:
27 // "Remove hard-coded dependency of the external mesh plugins from the SMESH module"
28 // is implemented (Mar 2012). It is kept for backward compatibility only.
29
30 #include <TCollection_AsciiString.hxx>
31 #include <Resource_DataMapOfAsciiStringAsciiString.hxx>
32  
33 class _pyCommand;
34
35 #include <vector>
36 #include <string>
37
38 typedef std::vector<TCollection_AsciiString>  TState;
39 typedef std::vector<TState>                   TAllStates;
40 typedef TCollection_AsciiString               _pyID;
41
42 class SMESH_ObjectStates{
43   
44 public:
45   
46   SMESH_ObjectStates(TCollection_AsciiString theType);
47   virtual ~SMESH_ObjectStates();
48
49   void AddState(const TState &theState);
50
51   TState GetCurrectState() const;
52   TAllStates GetAllStates() const;
53   void IncrementState();
54   TCollection_AsciiString GetObjectType() const;
55
56   
57
58 private:
59   TCollection_AsciiString                   _type;
60   TAllStates                                _states;
61   int                                       _dumpstate;
62 };
63
64 class LayerDistributionStates : public SMESH_ObjectStates
65 {
66 public:
67   typedef std::map<TCollection_AsciiString,TCollection_AsciiString> TDistributionMap;
68   LayerDistributionStates();
69   virtual ~LayerDistributionStates();
70
71   void AddDistribution(const TCollection_AsciiString& theDistribution);
72   bool HasDistribution(const TCollection_AsciiString& theDistribution) const;
73
74   bool SetDistributionType(const TCollection_AsciiString& theDistribution,
75                            const TCollection_AsciiString& theType);
76   TCollection_AsciiString GetDistributionType(const TCollection_AsciiString& theDistribution) const;
77   
78 private:
79   
80   TDistributionMap _distributions;
81 };
82
83
84 class SMESH_NoteBook
85 {
86 public:
87
88   SMESH_NoteBook();
89   ~SMESH_NoteBook();
90   void ReplaceVariables();
91   
92   void AddCommand(const TCollection_AsciiString& theString);
93   TCollection_AsciiString GetResultScript() const;
94   void GetResultLines(std::list< TCollection_AsciiString >& lines) const;
95
96 private:
97
98   void InitObjectMap();
99   void ProcessLayerDistribution();
100
101   bool GetReal(const TCollection_AsciiString& theVarName, double& theValue);
102   
103 private:
104   
105   typedef std::map<TCollection_AsciiString,SMESH_ObjectStates*>         TVariablesMap;
106   typedef std::map<TCollection_AsciiString,TCollection_AsciiString>     TMeshEditorMap;
107   typedef std::map<TCollection_AsciiString,std::vector< std::string > > TEntry2VarVecMap;
108
109   TVariablesMap                   _objectMap; // old approach - full states are kept
110   TEntry2VarVecMap                _entry2VarsMap; // new approach - only var names are kept
111   std::vector<Handle(_pyCommand)> _commands;
112   TMeshEditorMap                  _meshEditors;
113 };
114
115 #endif //SMESH_NoteBook_HeaderFile