1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
23 // File: VISU_PipeLine.hxx
24 // Author: Alexey PETROV
27 #ifndef VISU_ScalarBarActor_HeaderFile
28 #define VISU_ScalarBarActor_HeaderFile
30 #include "VISU_LookupTable.hxx"
32 #include <vtkActor2D.h>
35 class vtkPolyDataMapper2D;
36 class vtkScalarsToColors;
38 class vtkTextProperty;
40 #ifndef VTK_ORIENT_HORIZONTAL
41 #define VTK_ORIENT_HORIZONTAL 0
44 #ifndef VTK_ORIENT_VERTICAL
45 #define VTK_ORIENT_VERTICAL 1
48 class VISU_ScalarBarActor : public vtkActor2D
51 vtkTypeRevisionMacro(VISU_ScalarBarActor,vtkActor2D);
52 void PrintSelf(ostream& os, vtkIndent indent);
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();
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);
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 *);
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
76 virtual void SetLookupTable(VISU_LookupTable*);
77 vtkGetObjectMacro(LookupTable,VISU_LookupTable);
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);
87 // Set/Get the number of annotation labels to show.
88 vtkSetClampMacro(NumberOfLabels, int, 0, 64);
89 vtkGetMacro(NumberOfLabels, int);
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);};
100 // Set/Get the title text property.
101 virtual void SetTitleTextProperty(vtkTextProperty *p);
102 vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
105 // Set/Get the labels text property.
106 virtual void SetLabelTextProperty(vtkTextProperty *p);
107 vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
110 // Set/Get the format with which to print the labels on the scalar
112 vtkSetStringMacro(LabelFormat);
113 vtkGetStringMacro(LabelFormat);
116 // Set/Get the title of the scalar bar actor,
117 vtkSetStringMacro(Title);
118 vtkGetStringMacro(Title);
121 // Shallow copy of a scalar bar actor. Overloads the virtual vtkProp method.
122 void ShallowCopy(vtkProp *prop);
125 VISU_ScalarBarActor();
126 ~VISU_ScalarBarActor();
128 VISU_LookupTable *LookupTable;
129 vtkTextProperty *TitleTextProperty;
130 vtkTextProperty *LabelTextProperty;
132 int MaximumNumberOfColors;
134 int NumberOfLabelsBuilt;
139 vtkTextMapper **TextMappers;
140 virtual void AllocateAndSizeLabels(int *labelSize, int *size,
141 vtkViewport *viewport, float *range);
144 vtkTextMapper *TitleMapper;
145 vtkActor2D *TitleActor;
147 vtkActor2D **TextActors;
149 vtkPolyData *ScalarBar;
150 vtkPolyDataMapper2D *ScalarBarMapper;
151 vtkActor2D *ScalarBarActor;
153 vtkTimeStamp BuildTime;
157 void SizeTitle(int *titleSize, int *size, vtkViewport *viewport);
160 VISU_ScalarBarActor(const VISU_ScalarBarActor&); // Not implemented.
161 void operator=(const VISU_ScalarBarActor&); // Not implemented.