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