Salome HOME
608f5dfe0f13b59673eb2ed7183f3f2c3d1988b5
[modules/visu.git] / src / VISU_I / VISU_Table_i.hh
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //  File   : VISU_Table_i.hh
24 //  Author : Vadim SANDLER
25 //  Module : VISU
26
27 #ifndef VISU_Table_i_HeaderFile
28 #define VISU_Table_i_HeaderFile
29
30 #include "VISU_PrsObject_i.hh"
31
32 #include <qstringlist.h>
33
34 class SPlot2d_Curve;
35
36 namespace VISU{
37   //==============================================================================
38   class Table_i : public virtual POA_VISU::Table,
39                   public virtual PrsObject_i
40   {
41     static int myNbPresent;
42     Table_i();
43     Table_i( const Table_i& );
44   public:
45     Table_i( SALOMEDS::Study_ptr theStudy, const char* theObject );
46     virtual ~Table_i();
47     virtual VISU::VISUType GetType() { return VISU::TTABLE;};
48
49     virtual void SetTitle( const char* theName ) { SetName( theName ); }
50     virtual char* GetTitle() { return CORBA::string_dup( GetName() ); }
51
52     virtual void SetOrientation( VISU::Table::Orientation theOrientation ) { myOrientation = theOrientation; }
53     virtual VISU::Table::Orientation GetOrientation() { return myOrientation; }
54
55     virtual CORBA::Long GetNbRows();
56     virtual CORBA::Long GetNbColumns();
57
58     virtual void RemoveFromStudy();
59
60   protected:
61     Storable* Build(int theRestoring);
62
63   protected:
64     VISU::Table::Orientation myOrientation;
65     std::string myTitle;
66     SALOMEDS::SObject_var mySObj;
67
68   public:
69     virtual Storable* Create();
70     SALOMEDS::SObject_var GetSObject() const { return mySObj;}
71
72     virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO);
73     static Storable* Restore(SALOMEDS::SObject_ptr theSObject,
74                              const std::string& thePrefix,
75                              const Storable::TRestoringMap& theMap);
76     virtual void ToStream( std::ostringstream& theStr );
77     static const std::string myComment;
78     virtual const char* GetComment() const;
79     virtual const char* GenerateName();
80     virtual const char* GetTableTitle();
81
82     virtual char* GetObjectEntry() { return CORBA::string_dup( mySObj->GetID() ); }
83   };
84   SALOMEDS::SObject_var ImportTables(const char* theFileName, SALOMEDS::Study_ptr theStudy);
85   bool ExportTableToFile(SALOMEDS::SObject_ptr theTable, const char* theFileName);
86   //==============================================================================
87   class Curve_i : public virtual POA_VISU::Curve,
88                   public virtual PrsObject_i
89   {
90     static int myNbPresent;
91     Curve_i();
92     Curve_i( const Curve_i& );
93   public:
94     Curve_i( SALOMEDS::Study_ptr theStudy, Table_i* theTable, CORBA::Long theHRow, CORBA::Long theVRow );
95     virtual ~Curve_i();
96     virtual VISU::VISUType GetType() { return VISU::TCURVE;};
97
98     virtual void SetTitle( const char* theName ) { SetName( theName ); }
99     virtual char* GetTitle() { return CORBA::string_dup( GetName() ); }
100
101     virtual void SetColor( const SALOMEDS::Color& theColor ) { myColor = theColor; myAuto = false; }
102     virtual SALOMEDS::Color GetColor() { return myColor; }
103
104     virtual void SetMarker( VISU::Curve::MarkerType theType ) { myMarker = theType; myAuto = false; }
105     virtual VISU::Curve::MarkerType GetMarker() { return myMarker; }
106
107     virtual void SetLine( VISU::Curve::LineType theType, CORBA::Long theWidth )
108                                                 { myLine = theType; myLineWidth = theWidth; myAuto = false; }
109     virtual VISU::Curve::LineType GetLine() { return myLine; }
110     virtual CORBA::Long GetLineWidth() { return myLineWidth; }
111
112     virtual void RemoveFromStudy();
113
114     virtual SALOMEDS::SObject_var GetSObject();
115
116   protected:
117     Storable* Build(int theRestoring);
118
119   protected:
120     Table_i*                myTable;
121     int                     myHRow;
122     int                     myVRow;
123     struct SALOMEDS::Color  myColor;
124     VISU::Curve::MarkerType myMarker;
125     VISU::Curve::LineType   myLine;
126     int                     myLineWidth;
127     std::string             myTitle;
128     bool                    myAuto;
129     SALOMEDS::SObject_var   mySObj;
130
131   public:
132     virtual Storable* Create();
133
134     int GetHRow() const { return myHRow;}
135     int GetVRow() const { return myVRow;}
136
137     virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr theSO);
138
139     static Storable* Restore(SALOMEDS::SObject_ptr theSObject,
140                              const std::string& thePrefix,
141                              const Storable::TRestoringMap& theMap);
142
143     virtual void ToStream( std::ostringstream& theStr );
144     static const std::string myComment;
145     virtual const char* GetComment() const;
146     virtual const char* GenerateName();
147     virtual const char* GetTableID();
148
149     virtual CORBA::Boolean IsAuto() { return myAuto; }
150     virtual CORBA::Boolean IsValid();
151     virtual std::string GetHorTitle();
152     virtual std::string GetVerTitle();
153     virtual std::string GetHorUnits();
154     virtual std::string GetVerUnits();
155     virtual int    GetData( double*& theHorList, double*& theVerList );
156
157     virtual SPlot2d_Curve* CreatePresentation();
158   };
159
160   //==============================================================================
161   class Container_i : public virtual POA_VISU::Container,
162                       public virtual PrsObject_i
163   {
164     static int myNbPresent;
165     Container_i();
166     Container_i( const Container_i& );
167   public:
168     Container_i(SALOMEDS::Study_ptr theStudy);
169     virtual ~Container_i();
170     virtual VISU::VISUType GetType() { return VISU::TCONTAINER;};
171
172     virtual void AddCurve( Curve_ptr theCurve );
173     virtual void RemoveCurve( Curve_ptr theCurve );
174
175     virtual CORBA::Long GetNbCurves();
176     virtual void Clear();
177
178     virtual void RemoveFromStudy();
179
180     virtual SALOMEDS::SObject_var GetSObject();
181
182   protected:
183     Storable* Build(int theRestoring);
184
185   protected:
186     QStringList myCurves;
187     SALOMEDS::SObject_var mySObj;
188
189   public:
190     virtual Storable* Create();
191     virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr SO );
192
193     static Storable* Restore(SALOMEDS::SObject_ptr theSObject,
194                              const std::string& thePrefix,
195                              const Storable::TRestoringMap& theMap);
196
197     virtual void ToStream( std::ostringstream& theStr );
198     static const std::string myComment;
199     virtual const char* GetComment() const;
200     virtual const char* GenerateName();
201
202     void Update();
203     VISU::Curve_i* GetCurve( CORBA::Long theIndex );
204
205   };
206 }
207
208 #endif