Salome HOME
To provide a way to customize VISU::ScalarMap_i::Build method
[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     /*!
128      *  \brief Works like SameAs() method, but keep myIteration value unchanged.
129      *
130      *  Is used in VISU_TimeAnimation class implementation.
131      */
132     void SameAsParams (const ScalarMap_i* theOrigin);
133
134   protected:
135     Storable* Build(int theRestoring);
136     virtual void DoSetInput(Result_i* theResult);
137     virtual void DoHook();
138
139     VISU_ScalarMapPL* myScalarMapPL;
140     PField myField;
141
142     // std::string myMeshName; move it to Prs3d_i
143     TEntity myEntity;
144     std::string myFieldName;
145     int myIteration;
146
147     bool myIsFixedRange;
148
149     std::string myTitle;
150     int myNumberOfLabels;
151     float myPosition[2], myWidth, myHeight;
152     VISU::ScalarMap::Orientation myOrientation;
153
154     //Font management
155     bool myIsBoldTitle;
156     bool myIsItalicTitle;
157     bool myIsShadowTitle;
158     int  myTitFontType;
159     float myTitleColor[3];
160
161     bool myIsBoldLabel;
162     bool myIsItalicLabel;
163     bool myIsShadowLabel;
164     int  myLblFontType;
165     float myLabelColor[3];
166
167   public:
168     static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity,
169                           const char* theFieldName, int theIteration, int isMemoryCheck = true);
170     virtual Storable* Create(const char* theMeshName, VISU::Entity theEntity,
171                              const char* theFieldName, int theIteration);
172
173     const std::string& GetMeshName() const { return myMeshName;}
174     VISU::Entity GetEntity() const { return VISU::Entity(myEntity);}
175     const string& GetFieldName() const { return myFieldName;}
176     int GetIteration() const { return myIteration;}
177
178     virtual void ToStream(std::ostringstream& theStr);
179
180     static const std::string myComment;
181     virtual const char* GetComment() const;
182     virtual QString GenerateName();
183
184     virtual Storable* Restore(const Storable::TRestoringMap& theMap);
185
186     static Storable* Restore(SALOMEDS::SObject_ptr theSObject,
187                              const std::string& thePrefix, const Storable::TRestoringMap& theMap);
188
189     virtual void Update() ;
190     virtual void SetMapScale(double theMapScale = 1.0);
191
192     const VISU::PField GetField() const { return myField;}
193
194     virtual bool IsRangeFixed() { return myIsFixedRange; }
195     virtual void SetSourceRange();
196
197     virtual int GetIteration() { return myIteration; }
198
199     virtual VISU_Actor* CreateActor(const Handle(SALOME_InteractiveObject)& theIO = NULL);
200
201     virtual void UpdateActor(VISU_Actor* theActor) ;
202   };
203 }
204
205 #endif