Version: 6.3.1

src/PIPELINE/VISU_ScalarBarActor.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  VISU OBJECT : interactive object for VISU entities implementation
00024 // File:    VISU_PipeLine.hxx
00025 // Author:  Alexey PETROV
00026 // Module : VISU
00027 //
00028 #ifndef VISU_ScalarBarActor_HeaderFile
00029 #define VISU_ScalarBarActor_HeaderFile
00030 
00031 #include "VISUPipeline.hxx"
00032 #include "VISU_LookupTable.hxx"
00033 #include "VISU_XYPlotActor.hxx"
00034 
00035 #include <vtkActor2D.h>
00036 #include <vtkDoubleArray.h> // RKV
00037 
00038 class vtkPolyData;
00039 class vtkPolyDataMapper2D;
00040 class vtkScalarsToColors;
00041 class vtkTextMapper;
00042 class vtkTextProperty;
00043 
00044 #ifndef VTK_ORIENT_HORIZONTAL
00045 #define VTK_ORIENT_HORIZONTAL 0
00046 #endif
00047 
00048 #ifndef VTK_ORIENT_VERTICAL
00049 #define VTK_ORIENT_VERTICAL 1
00050 #endif
00051 
00052 class VISU_PIPELINE_EXPORT VISU_ScalarBarActor : public vtkActor2D
00053 {
00054 public:
00055   vtkTypeRevisionMacro(VISU_ScalarBarActor,vtkActor2D);
00056   void PrintSelf(ostream& os, vtkIndent indent);
00057 
00058   // Description:
00059   // Instantiate object with 64 maximum colors; 5 labels; %%-#6.3g label
00060   // format, no title, and vertical orientation. The initial scalar bar
00061   // size is (0.05 x 0.8) of the viewport size.
00062   static VISU_ScalarBarActor *New();
00063 
00064   // Description:
00065   // Draw the scalar bar and annotation text to the screen.
00066   int RenderOpaqueGeometry(vtkViewport* viewport);
00067   int RenderTranslucentGeometry(vtkViewport*) { return 0; };
00068   int RenderOverlay(vtkViewport* viewport);
00069 
00070   // Description:
00071   // Release any graphics resources that are being consumed by this actor.
00072   // The parameter window could be used to determine which graphic
00073   // resources to release.
00074   virtual void ReleaseGraphicsResources(vtkWindow *);
00075 
00076   // Description:
00077   // Set/Get the vtkLookupTable to use. The lookup table specifies the number
00078   // of colors to use in the table (if not overridden), as well as the scalar
00079   // range.
00080   virtual void SetLookupTable(VISU_LookupTable*);
00081   vtkGetObjectMacro(LookupTable,VISU_LookupTable);
00082 
00083   // Description:
00084   // Set/Get the maximum number of scalar bar segments to show. This may
00085   // differ from the number of colors in the lookup table, in which case
00086   // the colors are samples from the lookup table.
00087   vtkSetClampMacro(MaximumNumberOfColors, int, 2, VTK_LARGE_INTEGER);
00088   vtkGetMacro(MaximumNumberOfColors, int);
00089   
00090   // Description:
00091   // Set/Get the number of annotation labels to show.
00092   vtkSetClampMacro(NumberOfLabels, int, 0, 64);
00093   vtkGetMacro(NumberOfLabels, int);
00094   
00095   // Description:
00096   // Control the orientation of the scalar bar.
00097   vtkSetClampMacro(Orientation,int,VTK_ORIENT_HORIZONTAL, VTK_ORIENT_VERTICAL);
00098   vtkGetMacro(Orientation, int);
00099   void SetOrientationToHorizontal()
00100        {this->SetOrientation(VTK_ORIENT_HORIZONTAL);};
00101   void SetOrientationToVertical() {this->SetOrientation(VTK_ORIENT_VERTICAL);};
00102 
00103   // Description:
00104   // Set/Get the title text property.
00105   virtual void SetTitleTextProperty(vtkTextProperty *p);
00106   vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
00107   
00108   // Description:
00109   // Set/Get the labels text property.
00110   virtual void SetLabelTextProperty(vtkTextProperty *p);
00111   vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
00112 
00113 // RKV : Begin
00114   // Description:
00115   // Set/Get the values distribution array
00116   virtual void SetDistribution(vtkDoubleArray *d);
00117   vtkGetObjectMacro(Distribution,vtkDoubleArray);
00118   
00119   // Description:
00120   // Set/Get the flag of distribution plot visibility
00121   void SetDistributionVisibility(int v);
00122   vtkGetMacro(DistributionVisibility, int);
00123   void DistributionVisibilityOn()
00124        {this->SetDistributionVisibility(1);};
00125   void DistributionVisibilityOff() {this->SetDistributionVisibility(0);};
00126 
00127   void DebugOn();
00128   void DebugOff();
00129 // RKV : End
00130     
00131   // Description:
00132   // Set/Get the scalar bar dimention properties in persents.
00133   // 0 <= ration <= 100
00134   void SetRatios(int titleRatioSize,int labelRatioWidth,
00135                  int barRatioWidth, int barRatioHeight);
00136   void GetRatios(int& titleRatioSize, int& labelRatioWidth,
00137                  int& barRatioWidth, int& barRatioHeight);
00138 
00139   // Description:
00140   // Set/Get the format with which to print the labels on the scalar
00141   // bar.
00142   vtkSetStringMacro(LabelFormat);
00143   vtkGetStringMacro(LabelFormat);
00144 
00145   // Description:
00146   // Set/Get the title of the scalar bar actor,
00147   vtkSetStringMacro(Title);
00148   vtkGetStringMacro(Title);
00149 
00150   // Description:
00151   // Shallow copy of a scalar bar actor. Overloads the virtual vtkProp method.
00152   void ShallowCopy(vtkProp *prop);
00153 
00154 protected:
00155   VISU_ScalarBarActor();
00156   ~VISU_ScalarBarActor();
00157 
00158   VISU_LookupTable *LookupTable;
00159   vtkTextProperty *TitleTextProperty;
00160   vtkTextProperty *LabelTextProperty;
00161   
00165   vtkDoubleArray     *Distribution; // RKV
00167   int             DistributionVisibility; // RKV
00168 
00169   int   MaximumNumberOfColors;
00170   int   NumberOfLabels;
00171   int   NumberOfLabelsBuilt;
00172   int   Orientation;
00173   char  *Title;
00174   char  *LabelFormat;
00175   int   TitleRatioSize;
00176   int   LabelRatioWidth;
00177   int   BarRatioWidth;
00178   int   BarRatioHeight;
00179 
00180   vtkTextMapper **TextMappers;
00181   virtual void AllocateAndSizeLabels(int *labelSize, int *size,
00182                                      vtkViewport *viewport, vtkFloatingPointType *range);
00183 
00184 private:
00185   vtkTextMapper *TitleMapper;
00186   vtkActor2D    *TitleActor;
00187 
00188   vtkActor2D    **TextActors;
00189 
00190   vtkPolyData         *ScalarBar;
00191   vtkPolyDataMapper2D *ScalarBarMapper;
00192   vtkActor2D          *ScalarBarActor;
00193 
00194   vtkDataObject       *DistributionObj; // RKV
00195   VISU_XYPlotActor    *DistributionActor; // RKV
00196 
00197   vtkTimeStamp  BuildTime;
00198   int LastSize[2];
00199   int LastOrigin[2];
00200 
00201   void SizeTitle(int *titleSize, int *size, vtkViewport *viewport);
00202 
00203   void SizeBar(int& barSizeWidth, int& barSizeHeight, int *size,
00204                vtkViewport *viewport, vtkFloatingPointType *range);
00205                
00208   void PlaceDistribution(vtkViewport *viewport, const int barWidth, const int barHeight);
00209 
00210 private:
00211   VISU_ScalarBarActor(const VISU_ScalarBarActor&);  // Not implemented.
00212   void operator=(const VISU_ScalarBarActor&);  // Not implemented.
00213 };
00214 
00215 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS