Salome HOME
SMH: 3.0.0 preparation - merged and adopted version (POLYWORK+HEAD)
[modules/visu.git] / src / VISU_I / VISU_ScalarMap_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_PrsObject_i.hxx
24 //  Author : Alexey PETROV
25 //  Module : VISU
26
27 #ifndef VISU_ScalarMap_i_HeaderFile
28 #define VISU_ScalarMap_i_HeaderFile
29
30 #include "VISU_Prs3d_i.hh"
31
32 class VISU_ScalarMapPL;
33
34 namespace VISU{
35   class ScalarMap_i : public virtual POA_VISU::ScalarMap,
36                       public virtual Prs3d_i
37   {
38     static int myNbPresent;
39     ScalarMap_i();
40     ScalarMap_i(const ScalarMap_i&);
41
42   public:
43     explicit
44     ScalarMap_i(Result_i* theResult,
45                 bool theAddToStudy);
46     explicit
47     ScalarMap_i(Result_i* theResult,
48                 SALOMEDS::SObject_ptr theSObject);
49     virtual void SameAs(const ScalarMap_i* theOrigin);
50     virtual ~ScalarMap_i();
51     virtual void RemoveFromStudy();
52
53     virtual VISU::VISUType GetType() { return VISU::TSCALARMAP;};
54
55     virtual CORBA::Long GetScalarMode();
56     virtual void SetScalarMode(CORBA::Long theScalarMode);
57
58     virtual VISU::Scaling GetScaling();
59     virtual void SetScaling(VISU::Scaling theScaling);
60
61     virtual void SetRange(CORBA::Double theMin, CORBA::Double theMax);
62     virtual CORBA::Double GetMin();
63     virtual CORBA::Double GetMax();
64
65     virtual void SetNbColors(CORBA::Long theNbColors);
66     virtual CORBA::Long GetNbColors();
67
68     virtual void SetBarOrientation(VISU::ScalarMap::Orientation theOrientation){ 
69       myOrientation = theOrientation;
70     }
71     virtual VISU::ScalarMap::Orientation GetBarOrientation() { return myOrientation;}
72
73     virtual void SetPosition(CORBA::Double X, CORBA::Double Y) { myPosition[0] = X; myPosition[1] = Y;}
74     virtual CORBA::Double GetPosX() { return myPosition[0];} 
75     virtual CORBA::Double GetPosY() { return myPosition[1];}
76       
77     virtual void SetSize(CORBA::Double theWidth, CORBA::Double theHeight) { 
78       myWidth = theWidth; myHeight = theHeight;
79     }
80     virtual CORBA::Double GetWidth() { return myWidth;}  
81     virtual CORBA::Double GetHeight() { return myHeight;}
82
83     virtual void SetLabels(CORBA::Long theNbLabels) { myNumberOfLabels = theNbLabels;}
84     virtual CORBA::Long GetLabels() { return myNumberOfLabels;}
85     
86     virtual void SetTitle(const char* theName) { myTitle = theName;}
87     virtual char* GetTitle() { return CORBA::string_dup(myTitle.c_str());}
88
89     virtual bool IsBoldTitle() { return myIsBoldTitle;}
90     virtual void SetBoldTitle(bool isBold) { myIsBoldTitle = isBold;}
91
92     virtual bool IsItalicTitle() { return myIsItalicTitle;}
93     virtual void SetItalicTitle(bool isItalic) { myIsItalicTitle = isItalic;}
94
95     virtual bool IsShadowTitle() { return myIsShadowTitle;}
96     virtual void SetShadowTitle(bool isShadow) { myIsShadowTitle = isShadow;}
97
98     virtual int GetTitFontType() { return myTitFontType;}
99     virtual void SetTitFontType(int theType) { myTitFontType = theType;}
100
101     virtual void GetTitleColor(float* theR, float* theG, float* theB) 
102     {*theR = myTitleColor[0]; *theG = myTitleColor[1]; *theB = myTitleColor[2];}
103     virtual void SetTitleColor(float theR, float theG, float theB) 
104     {myTitleColor[0] = theR; myTitleColor[1] = theG; myTitleColor[2] = theB; }
105
106     /////
107     virtual bool IsBoldLabel() { return myIsBoldLabel;}
108     virtual void SetBoldLabel(bool isBold) { myIsBoldLabel = isBold;}
109
110     virtual bool IsItalicLabel() { return myIsItalicLabel;}
111     virtual void SetItalicLabel(bool isItalic) { myIsItalicLabel = isItalic;}
112
113     virtual bool IsShadowLabel() { return myIsShadowLabel;}
114     virtual void SetShadowLabel(bool isShadow) {myIsShadowLabel = isShadow;}
115
116     virtual int GetLblFontType() { return myLblFontType;}
117     virtual void SetLblFontType(int theType) { myLblFontType = theType;}
118
119     virtual void GetLabelColor(float* theR, float* theG, float* theB) 
120     {*theR = myLabelColor[0]; *theG = myLabelColor[1]; *theB = myLabelColor[2];}
121     virtual void SetLabelColor(float theR, float theG, float theB) 
122     {myLabelColor[0] = theR; myLabelColor[1] = theG; myLabelColor[2] = theB; }
123
124     typedef VISU::ScalarMap TInterface;
125     VISU_ScalarMapPL* GetScalarMapPL(){ return myScalarMapPL;}
126
127   protected:
128     Storable* Build(int theRestoring);
129     virtual void DoHook();
130
131     VISU_ScalarMapPL* myScalarMapPL;
132     PField myField;
133
134     string myMeshName;
135     TEntity myEntity;
136     string myFieldName;
137     int myIteration;
138
139     bool myIsFixedRange;
140     
141     std::string myTitle;
142     int myNumberOfLabels;
143     float myPosition[2], myWidth, myHeight;
144     VISU::ScalarMap::Orientation myOrientation;
145
146     //Font management
147     bool myIsBoldTitle;
148     bool myIsItalicTitle;
149     bool myIsShadowTitle;
150     int  myTitFontType;
151     float myTitleColor[3];
152
153     bool myIsBoldLabel;
154     bool myIsItalicLabel;
155     bool myIsShadowLabel;
156     int  myLblFontType;
157     float myLabelColor[3];
158
159   public:
160     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, 
161                           const char* theFieldName, int theIteration, int isMemoryCheck = true);
162     virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity, 
163                              const char* theFieldName, int theIteration);
164
165     const std::string& GetMeshName() const { return myMeshName;}
166     VISU::Entity GetEntity() const { return VISU::Entity(myEntity);}
167     const string& GetFieldName() const { return myFieldName;}
168     int GetIteration() const { return myIteration;}
169     
170     virtual void ToStream(std::ostringstream& theStr);
171
172     static const string myComment;
173     virtual const char* GetComment() const;
174     virtual QString GenerateName();
175
176     virtual Storable* Restore(const Storable::TRestoringMap& theMap);
177
178     static Storable* Restore(SALOMEDS::SObject_ptr theSObject, 
179                              const string& thePrefix, const Storable::TRestoringMap& theMap);
180
181     virtual void Update() ;
182     virtual void SetMapScale(double theMapScale = 1.0);
183
184     const VISU::PField GetField() const { return myField;}
185
186     virtual bool IsRangeFixed() { return myIsFixedRange; }
187     virtual void SetSourceRange();
188
189     virtual int GetIteration() { return myIteration; }
190
191     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
192
193     virtual void UpdateActor(VISU_Actor* theActor) ;
194   };
195 }
196
197 #endif