Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / PIPELINE / VISU_ScalarBarCtrl.hxx
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_ScalarBarCtrl.hxx
24 // Author:  Peter KURNEV
25 // Module : VISU
26
27 #ifndef VISU_ScalarBarCtrl_HeaderFile
28 #define VISU_ScalarBarCtrl_HeaderFile
29
30 #include <vtkObject.h>
31
32 class vtkRenderer;
33 class vtkLookupTable;
34 class vtkScalarBarActor;
35
36 class VISU_ScalarBarCtrl :  public vtkObject
37 {
38 public:
39   vtkTypeMacro(VISU_ScalarBarCtrl, vtkObject);
40   static VISU_ScalarBarCtrl* New();
41
42   enum EMode {eSimple, eGlobal, eLocal};
43
44   // Mode
45   void SetMode(EMode theMode);
46   EMode GetMode() const;
47
48   // Ranges
49   void SetRangeGlobal(float theMin,
50                       float theMax);
51   void SetRangeGlobal(float *theRange);
52
53   void SetGlobalRangeIsDefined(bool theIsDefined);
54   
55   void SetRangeLocal(float theMin,
56                      float theMax);
57   void SetRangeLocal(float *theRange);
58   
59   // Selectors
60   vtkScalarBarActor* GetLocalBar();
61   vtkLookupTable* GetLocalTable();
62
63   vtkScalarBarActor* GetGlobalBar();
64   vtkLookupTable* GetGlobalTable();
65   //
66   // Renderer
67   void AddToRender(vtkRenderer* theRenderer); 
68   void RemoveFromRender(vtkRenderer* theRenderer);
69   //
70   // Visibility
71   void SetVisibility(int theFlag);
72   int  GetVisibility() const;
73   //
74   // Visibility
75   void SetCtrlVisibility(int theFlag);
76   int GetCtrlVisibility() const;
77   //
78   // Build
79   void Update();
80   //
81   // Position
82   void  SetWidth(const float theWidth);
83   float GetWidth()const;
84   void  SetHeight(const float theHeight);
85   float GetHeight()const;
86   void  SetPosition(const float* thePosition);
87   const float* GetPosition()const;
88   //
89   // Spacing
90   void  SetSpacing(const float theSpacing);
91   float GetSpacing()const;
92   //
93   // Rainbow/bicolor
94   bool  GetBicolor() const;
95   void  SetBicolor(const bool theBicolor);
96   //
97   // Misc
98   void  SetMarkValue (const float theValue);
99   float GetMarkValue  ()const;
100   void  SetIsMarked(const bool theFlag);
101   bool  GetIsMarked()const;
102   //
103 protected:
104   VISU_ScalarBarCtrl();
105   virtual ~VISU_ScalarBarCtrl();
106   
107   void UpdateForBicolor();
108   void UpdateForColor();
109   void UpdateMarkValue();
110   void PrepareTables();
111   
112   void PrepareTables(vtkScalarBarActor* theScalarBarActor,
113                      vtkLookupTable *theLookupTable,
114                      vtkIdType theId);
115   
116 protected:
117   EMode myMode;
118   bool myGlobalRangeIsDefined;
119
120   float myDistance;
121   float myPosition[2];
122   bool  myBicolor;
123   int   myCtrlVisibility;
124
125   unsigned char myBlack[3];
126   unsigned char myGrey[3];
127   //
128   bool  myMarked;
129   float myMarkedValue;
130   //
131   vtkScalarBarActor *myGlobalScalarBar;
132   vtkLookupTable *myGlobalLookupTable; 
133
134   vtkScalarBarActor *myLocalScalarBar;
135   vtkLookupTable *myLocalLookupTable; 
136 };
137
138 #endif