Salome HOME
Add test function : QApplication::postEvent(SALOME_Event)
[modules/visu.git] / src / PIPELINE / VISU_ScalarBarActor.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_PipeLine.hxx
24 // Author:  Alexey PETROV
25 // Module : VISU
26
27 #ifndef VISU_ScalarBarActor_HeaderFile
28 #define VISU_ScalarBarActor_HeaderFile
29
30 #include "VISU_LookupTable.hxx"
31
32 #include <vtkActor2D.h>
33
34 class vtkPolyData;
35 class vtkPolyDataMapper2D;
36 class vtkScalarsToColors;
37 class vtkTextMapper;
38 class vtkTextProperty;
39
40 #ifndef VTK_ORIENT_HORIZONTAL
41 #define VTK_ORIENT_HORIZONTAL 0
42 #endif
43
44 #ifndef VTK_ORIENT_VERTICAL
45 #define VTK_ORIENT_VERTICAL 1
46 #endif
47
48 class VISU_ScalarBarActor : public vtkActor2D
49 {
50 public:
51   vtkTypeRevisionMacro(VISU_ScalarBarActor,vtkActor2D);
52   void PrintSelf(ostream& os, vtkIndent indent);
53
54   // Description:
55   // Instantiate object with 64 maximum colors; 5 labels; %%-#6.3g label
56   // format, no title, and vertical orientation. The initial scalar bar
57   // size is (0.05 x 0.8) of the viewport size.
58   static VISU_ScalarBarActor *New();
59
60   // Description:
61   // Draw the scalar bar and annotation text to the screen.
62   int RenderOpaqueGeometry(vtkViewport* viewport);
63   int RenderTranslucentGeometry(vtkViewport*) { return 0; };
64   int RenderOverlay(vtkViewport* viewport);
65
66   // Description:
67   // Release any graphics resources that are being consumed by this actor.
68   // The parameter window could be used to determine which graphic
69   // resources to release.
70   virtual void ReleaseGraphicsResources(vtkWindow *);
71
72   // Description:
73   // Set/Get the vtkLookupTable to use. The lookup table specifies the number
74   // of colors to use in the table (if not overridden), as well as the scalar
75   // range.
76   virtual void SetLookupTable(VISU_LookupTable*);
77   vtkGetObjectMacro(LookupTable,VISU_LookupTable);
78
79   // Description:
80   // Set/Get the maximum number of scalar bar segments to show. This may
81   // differ from the number of colors in the lookup table, in which case
82   // the colors are samples from the lookup table.
83   vtkSetClampMacro(MaximumNumberOfColors, int, 2, VTK_LARGE_INTEGER);
84   vtkGetMacro(MaximumNumberOfColors, int);
85   
86   // Description:
87   // Set/Get the number of annotation labels to show.
88   vtkSetClampMacro(NumberOfLabels, int, 0, 64);
89   vtkGetMacro(NumberOfLabels, int);
90   
91   // Description:
92   // Control the orientation of the scalar bar.
93   vtkSetClampMacro(Orientation,int,VTK_ORIENT_HORIZONTAL, VTK_ORIENT_VERTICAL);
94   vtkGetMacro(Orientation, int);
95   void SetOrientationToHorizontal()
96        {this->SetOrientation(VTK_ORIENT_HORIZONTAL);};
97   void SetOrientationToVertical() {this->SetOrientation(VTK_ORIENT_VERTICAL);};
98
99   // Description:
100   // Set/Get the title text property.
101   virtual void SetTitleTextProperty(vtkTextProperty *p);
102   vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
103   
104   // Description:
105   // Set/Get the labels text property.
106   virtual void SetLabelTextProperty(vtkTextProperty *p);
107   vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
108     
109   // Description:
110   // Set/Get the format with which to print the labels on the scalar
111   // bar.
112   vtkSetStringMacro(LabelFormat);
113   vtkGetStringMacro(LabelFormat);
114
115   // Description:
116   // Set/Get the title of the scalar bar actor,
117   vtkSetStringMacro(Title);
118   vtkGetStringMacro(Title);
119
120   // Description:
121   // Shallow copy of a scalar bar actor. Overloads the virtual vtkProp method.
122   void ShallowCopy(vtkProp *prop);
123
124 protected:
125   VISU_ScalarBarActor();
126   ~VISU_ScalarBarActor();
127
128   VISU_LookupTable *LookupTable;
129   vtkTextProperty *TitleTextProperty;
130   vtkTextProperty *LabelTextProperty;
131
132   int   MaximumNumberOfColors;
133   int   NumberOfLabels;
134   int   NumberOfLabelsBuilt;
135   int   Orientation;
136   char  *Title;
137   char  *LabelFormat;
138
139   vtkTextMapper **TextMappers;
140   virtual void AllocateAndSizeLabels(int *labelSize, int *size,
141                                      vtkViewport *viewport, float *range);
142
143 private:
144   vtkTextMapper *TitleMapper;
145   vtkActor2D    *TitleActor;
146
147   vtkActor2D    **TextActors;
148
149   vtkPolyData         *ScalarBar;
150   vtkPolyDataMapper2D *ScalarBarMapper;
151   vtkActor2D          *ScalarBarActor;
152
153   vtkTimeStamp  BuildTime;
154   int LastSize[2];
155   int LastOrigin[2];
156
157   void SizeTitle(int *titleSize, int *size, vtkViewport *viewport);
158
159 private:
160   VISU_ScalarBarActor(const VISU_ScalarBarActor&);  // Not implemented.
161   void operator=(const VISU_ScalarBarActor&);  // Not implemented.
162 };
163
164 #endif