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