1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISU_Table_i.hh
25 // Author : Vadim SANDLER
28 #ifndef VISU_Table_i_HeaderFile
29 #define VISU_Table_i_HeaderFile
31 #include "VISU_PrsObject_i.hh"
33 #include <QStringList>
40 typedef enum {NoneDvtn = 0,
41 AbsoluteDvtn, // min, max
42 PercentageDvtn, // min%, max%
43 ErrorDvtn, // errmin, errmax
44 ErrorPercentageDvtn, // errmin%, errmax%
45 SimpleErrorDvtn, // error
46 SimpleErrorPercentageDvtn // error%
49 class VISU_I_EXPORT DeviationData {
52 _minRow = -1;_maxRow = -1;
53 _minType = NoneDvtn;_maxType = NoneDvtn;
55 DeviationData(const int minC, const int maxC,
56 const DeviationType minT, const DeviationType maxT) {
57 _minRow = minC; _maxRow = maxC;
58 _minType = minT ; _maxType = maxT;
60 int minRow() const {return _minRow;}
61 int maxRow() const {return _maxRow;}
62 DeviationType minDeviation() const {return _minType;}
63 DeviationType maxDeviation() const {return _maxType;}
68 DeviationType _minType;
69 DeviationType _maxType;
72 typedef QMap<int, DeviationData> DeviationMap;
74 //==============================================================================
75 class VISU_I_EXPORT Table_i : public virtual POA_VISU::Table,
76 public virtual PrsObject_i
78 static int myNbPresent;
79 Table_i( const Table_i& );
81 Table_i( SALOMEDS::Study_ptr theStudy, const char* theObject );
83 virtual VISU::VISUType GetType() { return VISU::TTABLE;};
85 virtual void SetTitle( const char* theTitle );
86 virtual char* GetTitle();
88 virtual void SetOrientation( VISU::Table::Orientation theOrientation );
89 virtual VISU::Table::Orientation GetOrientation();
91 virtual CORBA::Long GetNbRows();
92 virtual CORBA::Long GetNbColumns();
94 virtual void SortRow(CORBA::Long theRow, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
95 virtual void SortColumn(CORBA::Long theColumn, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
96 virtual void SortByRow(CORBA::Long theRow, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
97 virtual void SortByColumn(CORBA::Long theColumn, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
99 virtual bool hasDeviationData(const int);
100 virtual bool isDeviationRow(const int);
101 virtual DeviationData* getDeviationInfo(const int);
102 virtual void RemoveFromStudy();
105 Storable* Build(int theRestoring);
106 void UpdateCurves(std::map<int, int> theMixData);
107 void BuildDeviationMap();
110 VISU::Table::Orientation myOrientation;
112 SALOMEDS::SObject_var mySObj;
113 DeviationMap myDeviationMap;
116 virtual Storable* Create();
117 SALOMEDS::SObject_var GetSObject() const;
119 virtual Storable* Restore( const Storable::TRestoringMap& theMap,
120 SALOMEDS::SObject_ptr SO);
122 static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject,
123 const Storable::TRestoringMap& theMap,
124 const std::string& thePrefix,
125 CORBA::Boolean theIsMultiFile);
127 static bool parseTitle(const QString theTitle,
128 QString& theOutTitle,
129 DeviationType& theType,
132 static double calculateDeviation(DeviationType theType, double value,double deviationValue, bool isMin);
134 static QString deviationLabel(DeviationData* );
136 virtual void ToStream( std::ostringstream& theStr );
137 static const std::string myComment;
138 virtual const char* GetComment() const;
139 virtual QString GenerateName();
140 virtual QString GetTableTitle();
142 virtual std::string GetObjectEntry();
144 SALOMEDS::SObject_var ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy,
145 bool theFirstStrAsTitle = false);
146 bool ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName);
147 //==============================================================================
149 typedef QSet<QString> ContainerSet;
151 class VISU_I_EXPORT Curve_i : public virtual POA_VISU::Curve,
152 public virtual PrsObject_i
154 static int myNbPresent;
156 Curve_i( const Curve_i& );
158 Curve_i( SALOMEDS::Study_ptr theStudy, Table_i* theTable,
159 CORBA::Long theHRow, CORBA::Long theVRow, CORBA::Long theZRow,
160 CORBA::Boolean theIsV2 );
162 virtual VISU::VISUType GetType() { return VISU::TCURVE;};
164 virtual void SetTitle( const char* theTitle );
165 virtual char* GetTitle();
167 virtual void SetColor( const SALOMEDS::Color& theColor );
168 virtual SALOMEDS::Color GetColor();
170 virtual void SetMarker( VISU::Curve::MarkerType theType );
171 virtual VISU::Curve::MarkerType GetMarker();
173 virtual void SetLine( VISU::Curve::LineType theType, CORBA::Long theWidth );
174 virtual VISU::Curve::LineType GetLine();
175 virtual CORBA::Long GetLineWidth();
177 virtual void SetScale( CORBA::Double theCoef );
178 virtual CORBA::Double GetScale();
179 virtual void RemoveScale();
181 virtual void addContainer(const QString& id);
182 virtual void removeContainer(const QString& id);
183 virtual ContainerSet getContainers() const;
185 virtual void RemoveFromStudy();
187 virtual SALOMEDS::SObject_var GetSObject();
189 virtual void ShowDeviation(CORBA::Boolean);
190 virtual bool isDeviationShown();
191 virtual bool hasDeviation();
194 Storable* Build(int theRestoring);
203 struct SALOMEDS::Color myColor;
204 VISU::Curve::MarkerType myMarker;
205 VISU::Curve::LineType myLine;
209 SALOMEDS::SObject_var mySObj;
210 ContainerSet myContainers;
211 bool myDeviationEnabled;
214 virtual Storable* Create();
216 Table_i* getTable() const {return myTable;}
218 int GetHRow() const { return myHRow; }
219 void SetHRow( const int theHRow ) { myHRow = theHRow; }
221 int GetVRow() const { return myVRow; }
222 void SetVRow( const int theVRow ) { myVRow = theVRow; }
224 int GetZRow() const { return myZRow; }
225 void SetZRow( const int theZRow ) { myZRow = theZRow; }
227 int GetIsV2() const { return myIsV2; }
228 void SetIsV2( const int theIsV2 ) { myIsV2 = theIsV2; }
230 virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr theSO);
232 static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject,
233 const Storable::TRestoringMap& theMap,
234 const std::string& thePrefix,
235 CORBA::Boolean theIsMultiFile);
237 virtual void ToStream( std::ostringstream& theStr );
238 static const std::string myComment;
239 virtual const char* GetComment() const;
240 virtual QString GenerateName();
241 virtual std::string GetTableID();
243 virtual CORBA::Boolean IsAuto() { return myAuto; }
244 virtual CORBA::Boolean IsValid();
245 virtual std::string GetHorTitle();
246 virtual std::string GetVerTitle();
247 virtual std::string GetHorUnits();
248 virtual std::string GetVerUnits();
249 virtual int GetData( double*& theHorList, double*& theVerList, QStringList& );
250 virtual int GetDeviationData( double*& theMin, double*& theMax, QList<int>& );
252 virtual SPlot2d_Curve* CreatePresentation();
255 //==============================================================================
256 class VISU_I_EXPORT Container_i : public virtual POA_VISU::Container,
257 public virtual PrsObject_i
259 static int myNbPresent;
261 Container_i( const Container_i& );
263 Container_i(SALOMEDS::Study_ptr theStudy);
264 virtual ~Container_i();
265 virtual VISU::VISUType GetType() { return VISU::TCONTAINER;};
267 virtual void AddCurve( Curve_ptr theCurve );
268 virtual void RemoveCurve( Curve_ptr theCurve );
270 virtual CORBA::Long GetNbCurves();
271 virtual void Clear();
273 virtual void RemoveFromStudy();
275 virtual SALOMEDS::SObject_var GetSObject();
278 Storable* Build(int theRestoring);
281 QStringList myCurves;
282 SALOMEDS::SObject_var mySObj;
285 virtual Storable* Create();
286 virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO );
288 static Storable* StorableEngine(SALOMEDS::SObject_ptr theSObject,
289 const Storable::TRestoringMap& theMap,
290 const std::string& thePrefix,
291 CORBA::Boolean theIsMultiFile);
293 virtual void ToStream( std::ostringstream& theStr );
294 static const std::string myComment;
295 virtual const char* GetComment() const;
296 virtual QString GenerateName();
299 VISU::Curve_i* GetCurve( CORBA::Long theIndex );