Salome HOME
29a30b9ced8a01cf6834848f6747137039795037
[modules/visu.git] / src / VISU_I / VISU_Table_i.hh
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  VISU OBJECT : interactive object for VISU entities implementation
24 //  File   : VISU_Table_i.hh
25 //  Author : Vadim SANDLER
26 //  Module : VISU
27 //
28 #ifndef VISU_Table_i_HeaderFile
29 #define VISU_Table_i_HeaderFile
30
31 #include "VISU_PrsObject_i.hh"
32
33 #include <QStringList>
34 #include <QSet>
35
36 class SPlot2d_Curve;
37
38 namespace VISU{
39   //==============================================================================
40   class VISU_I_EXPORT Table_i : public virtual POA_VISU::Table,
41                   public virtual PrsObject_i
42   {
43     static int myNbPresent;
44     Table_i( const Table_i& );
45   public:
46     Table_i( SALOMEDS::Study_ptr theStudy, const char* theObject );
47     virtual ~Table_i();
48     virtual VISU::VISUType GetType() { return VISU::TTABLE;};
49
50     virtual void SetTitle( const char* theTitle );
51     virtual char* GetTitle();
52
53     virtual void SetOrientation( VISU::Table::Orientation theOrientation );
54     virtual VISU::Table::Orientation GetOrientation();
55
56     virtual CORBA::Long GetNbRows();
57     virtual CORBA::Long GetNbColumns();
58
59     virtual void SortRow(CORBA::Long theRow, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
60     virtual void SortColumn(CORBA::Long theColumn, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
61     virtual void SortByRow(CORBA::Long theRow, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
62     virtual void SortByColumn(CORBA::Long theColumn, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
63
64     virtual void RemoveFromStudy();
65
66   protected:
67     Storable* Build(int theRestoring);
68     void      UpdateCurves(std::map<int, int> theMixData);
69
70   protected:
71     VISU::Table::Orientation myOrientation;
72     std::string myTitle;
73     SALOMEDS::SObject_var mySObj;
74
75   public:
76     virtual Storable* Create();
77     SALOMEDS::SObject_var GetSObject() const;
78
79     virtual Storable* Restore( const Storable::TRestoringMap& theMap,
80                                SALOMEDS::SObject_ptr SO);
81
82     static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject,
83                                     const Storable::TRestoringMap& theMap,
84                                     const std::string& thePrefix,
85                                     CORBA::Boolean theIsMultiFile);
86
87     virtual void ToStream( std::ostringstream& theStr );
88     static const std::string myComment;
89     virtual const char* GetComment() const;
90     virtual QString GenerateName();
91     virtual QString GetTableTitle();
92
93     virtual std::string GetObjectEntry();
94   };
95   SALOMEDS::SObject_var ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy,
96                                      bool theFirstStrAsTitle = false);
97   bool ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName);
98   //==============================================================================
99
100   typedef QSet<QString> ContainerSet;
101
102   class VISU_I_EXPORT Curve_i : public virtual POA_VISU::Curve,
103                   public virtual PrsObject_i
104   {
105     static int myNbPresent;
106     Curve_i();
107     Curve_i( const Curve_i& );
108   public:
109     Curve_i( SALOMEDS::Study_ptr theStudy, Table_i* theTable,
110              CORBA::Long theHRow, CORBA::Long theVRow, CORBA::Long theZRow,
111              CORBA::Boolean theIsV2 );
112     virtual ~Curve_i();
113     virtual VISU::VISUType GetType() { return VISU::TCURVE;};
114
115     virtual void SetTitle( const char* theTitle );
116     virtual char* GetTitle();
117
118     virtual void SetColor( const SALOMEDS::Color& theColor );
119     virtual SALOMEDS::Color GetColor();
120
121     virtual void SetMarker( VISU::Curve::MarkerType theType );
122     virtual VISU::Curve::MarkerType GetMarker();
123
124     virtual void SetLine( VISU::Curve::LineType theType, CORBA::Long theWidth );
125     virtual VISU::Curve::LineType GetLine();
126     virtual CORBA::Long GetLineWidth();
127
128     virtual void addContainer(const QString& id);
129     virtual void removeContainer(const QString& id);
130     virtual ContainerSet getContainers() const;
131
132     virtual void RemoveFromStudy();
133
134     virtual SALOMEDS::SObject_var GetSObject();
135
136   protected:
137     Storable* Build(int theRestoring);
138
139   protected:
140     Table_i*                myTable;
141     int                     myHRow;
142     int                     myVRow;
143     int                     myZRow;
144     bool                    myIsV2;
145     struct SALOMEDS::Color  myColor;
146     VISU::Curve::MarkerType myMarker;
147     VISU::Curve::LineType   myLine;
148     int                     myLineWidth;
149     std::string             myTitle;
150     bool                    myAuto;
151     SALOMEDS::SObject_var   mySObj;
152     ContainerSet            myContainers;
153
154   public:
155     virtual Storable* Create();
156     
157     Table_i* getTable() const {return myTable;}
158
159     int  GetHRow() const { return myHRow; }
160     void SetHRow( const int theHRow ) { myHRow = theHRow; }
161
162     int  GetVRow() const { return myVRow; }
163     void SetVRow( const int theVRow ) { myVRow = theVRow; }
164
165     int  GetZRow() const { return myZRow; }
166     void SetZRow( const int theZRow ) { myZRow = theZRow; }
167
168     int  GetIsV2() const { return myIsV2; }
169     void SetIsV2( const int theIsV2 ) { myIsV2 = theIsV2; }
170
171     virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr theSO);
172
173     static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject,
174                                     const Storable::TRestoringMap& theMap,
175                                     const std::string& thePrefix,
176                                     CORBA::Boolean theIsMultiFile);
177
178     virtual void ToStream( std::ostringstream& theStr );
179     static const std::string myComment;
180     virtual const char* GetComment() const;
181     virtual QString GenerateName();
182     virtual std::string GetTableID();
183
184     virtual CORBA::Boolean IsAuto() { return myAuto; }
185     virtual CORBA::Boolean IsValid();
186     virtual std::string GetHorTitle();
187     virtual std::string GetVerTitle();
188     virtual std::string GetHorUnits();
189     virtual std::string GetVerUnits();
190     virtual int GetData( double*& theHorList, double*& theVerList, QStringList& );
191
192     virtual SPlot2d_Curve* CreatePresentation();
193   };
194
195   //==============================================================================
196   class VISU_I_EXPORT Container_i : public virtual POA_VISU::Container,
197                       public virtual PrsObject_i
198   {
199     static int myNbPresent;
200     Container_i();
201     Container_i( const Container_i& );
202   public:
203     Container_i(SALOMEDS::Study_ptr theStudy);
204     virtual ~Container_i();
205     virtual VISU::VISUType GetType() { return VISU::TCONTAINER;};
206
207     virtual void AddCurve( Curve_ptr theCurve );
208     virtual void RemoveCurve( Curve_ptr theCurve );
209
210     virtual CORBA::Long GetNbCurves();
211     virtual void Clear();
212
213     virtual void RemoveFromStudy();
214
215     virtual SALOMEDS::SObject_var GetSObject();
216
217   protected:
218     Storable* Build(int theRestoring);
219
220   protected:
221     QStringList myCurves;
222     SALOMEDS::SObject_var mySObj;
223
224   public:
225     virtual Storable* Create();
226     virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO );
227
228     static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject,
229                                     const Storable::TRestoringMap& theMap,
230                                     const std::string& thePrefix,
231                                     CORBA::Boolean theIsMultiFile);
232
233     virtual void ToStream( std::ostringstream& theStr );
234     static const std::string myComment;
235     virtual const char* GetComment() const;
236     virtual QString GenerateName();
237
238     void Update();
239     VISU::Curve_i* GetCurve( CORBA::Long theIndex );
240
241   };
242 }
243
244 #endif