Salome HOME
Merge from V5_1_main 10/06/2010
[modules/visu.git] / src / PIPELINE / VISU_ScalarBarCtrl.hxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  VISU OBJECT : interactive object for VISU entities implementation
24 // File:    VISU_ScalarBarCtrl.hxx
25 // Author:  Peter KURNEV
26 // Module : VISU
27 //
28 #ifndef VISU_ScalarBarCtrl_HeaderFile
29 #define VISU_ScalarBarCtrl_HeaderFile
30
31 #include "VISUPipeline.hxx"
32
33 #include <vtkObject.h>
34
35 #include "VTKViewer.h"
36
37 class vtkRenderer;
38 class VISU_LookupTable;
39 class VISU_ScalarBarActor;
40
41 class VISU_PIPELINE_EXPORT VISU_ScalarBarCtrl :  public vtkObject
42 {
43 public:
44   vtkTypeMacro(VISU_ScalarBarCtrl, vtkObject);
45   static
46   VISU_ScalarBarCtrl* 
47   New();
48
49   enum EMode {eSimple, eGlobal, eLocal};
50
51   // Mode
52   void
53   SetMode(EMode theMode);
54
55   EMode 
56   GetMode() const;
57
58   // Ranges
59   void
60   SetRangeGlobal(vtkFloatingPointType theMin,
61                  vtkFloatingPointType theMax);
62   void 
63   SetRangeGlobal(vtkFloatingPointType *theRange);
64
65   void
66   SetGlobalRangeIsDefined(bool theIsDefined);
67   
68   void
69   SetRangeLocal(vtkFloatingPointType theMin,
70                 vtkFloatingPointType theMax);
71   void 
72   SetRangeLocal(vtkFloatingPointType *theRange);
73   
74   // Selectors
75   VISU_ScalarBarActor* 
76   GetLocalBar();
77
78   VISU_LookupTable* 
79   GetLocalTable();
80
81   VISU_ScalarBarActor* 
82   GetGlobalBar();
83
84   VISU_LookupTable* 
85   GetGlobalTable();
86   //
87   // Renderer
88   void
89   AddToRender(vtkRenderer* theRenderer); 
90
91   void
92   RemoveFromRender(vtkRenderer* theRenderer);
93   //
94   // Visibility
95   void
96   SetVisibility(int theFlag);
97
98   int
99   GetVisibility() const;
100
101   // Visibility
102   void
103   SetCtrlVisibility(int theFlag);
104
105   int
106   GetCtrlVisibility() const;
107
108   // Build
109   void Update();
110
111   // Position
112   void
113   SetWidth(const vtkFloatingPointType theWidth);
114
115   vtkFloatingPointType
116   GetWidth() const;
117
118   void  
119   SetHeight(const vtkFloatingPointType theHeight);
120
121   vtkFloatingPointType
122   GetHeight() const;
123
124   void
125   SetPosition(const vtkFloatingPointType* thePosition);
126   
127   const vtkFloatingPointType* 
128   GetPosition() const;
129   //
130   // Spacing
131   void
132   SetSpacing(const vtkFloatingPointType theSpacing);
133
134   vtkFloatingPointType
135   GetSpacing() const;
136   //
137   // Rainbow/bicolor
138   bool
139   GetBicolor() const;
140
141   void
142   SetBicolor(const bool theBicolor);
143   //
144   // Misc
145   void  
146   SetMarkValue(const vtkFloatingPointType theValue);
147
148   vtkFloatingPointType
149   GetMarkValue() const;
150
151   void
152   SetIsMarked(const bool theFlag);
153
154   bool
155   GetIsMarked()const;
156   //
157 protected:
158   VISU_ScalarBarCtrl();
159
160   virtual
161   ~VISU_ScalarBarCtrl();
162   
163   void
164   UpdateForBicolor();
165
166   void
167   UpdateForColor();
168
169   void
170   UpdateMarkValue();
171
172   void
173   PrepareTables();
174   
175   void
176   PrepareTables(VISU_ScalarBarActor* theScalarBarActor,
177                 VISU_LookupTable *theLookupTable,
178                 vtkIdType theId);
179   
180 protected:
181   EMode myMode;
182   bool myGlobalRangeIsDefined;
183
184   vtkFloatingPointType myDistance;
185   vtkFloatingPointType myPosition[2];
186   bool  myBicolor;
187   int   myCtrlVisibility;
188
189   unsigned char myBlack[3];
190   unsigned char myGrey[3];
191   //
192   bool  myMarked;
193   vtkFloatingPointType myMarkedValue;
194   //
195   VISU_ScalarBarActor *myGlobalScalarBar;
196   VISU_LookupTable *myGlobalLookupTable; 
197
198   VISU_ScalarBarActor *myLocalScalarBar;
199   VISU_LookupTable *myLocalLookupTable; 
200 };
201
202 #endif