From: nri Date: Thu, 10 Jul 2003 17:18:28 +0000 (+0000) Subject: NRI : Merge from V1_2. X-Git-Tag: V_02092003~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8fc8e4037c5e7c4a4bb5394185bc7a65207ae0d8;p=modules%2Fvisu.git NRI : Merge from V1_2. --- diff --git a/src/VISU_I/VISU_LookupTable.cxx b/src/VISU_I/VISU_LookupTable.cxx deleted file mode 100644 index af543757..00000000 --- a/src/VISU_I/VISU_LookupTable.cxx +++ /dev/null @@ -1,79 +0,0 @@ -using namespace std; -// File : VISU_LookupTable.cxx -// Created : UI team, 18.02.03 -// Descr : Scaling values of vtkLookupTable -// Author : Vitaliy Smetannikov -// Project : SALOME -// Module : OBJECT -// Copyright : Open CASCADE 2003 - - -#include "VISU_LookupTable.hxx" -#include "vtkObjectFactory.h" - - -VISU_LookupTable *VISU_LookupTable::New() { - vtkObject* ret = vtkObjectFactory::CreateInstance("VISU_LookupTable"); - if(ret) { - return (VISU_LookupTable*)ret; - } - // If the factory was unable to create the object, then create it here. - return new VISU_LookupTable; -} - -VISU_LookupTable::VISU_LookupTable(int sze, int ext) - : vtkLogLookupTable(sze, ext), myScale(1.), myIsLog(0) -{} - -int VISU_LookupTable::ComputeLogRange(float inRange[2], float outRange[2]){ - if(inRange[0] >= inRange[1]){ - //vtkErrorMacro (<<"Minimum value must be less than maximum value"); - return -1; - } - if(0.0 <= inRange[0] && 0.0 < inRange[1]){ - if (inRange[0] == 0.0) inRange[0] = 1.0e-06 * (inRange[1] - inRange[0]); - outRange[0] = log10((double)inRange[0]); - outRange[1] = log10((double)inRange[1]); - return 0; - }else if(inRange[0] < 0.0 && inRange[1] <= 0.0){ - outRange[0] = log10((double)-inRange[0]); - outRange[1] = log10((double)-inRange[1]); - return 1; - }else{ - //vtkErrorMacro(<<"Can't use logarithmic table on mixed negative/positive values"); - return -1; - } -} - -void VISU_LookupTable::SetTableRange(float min, float max){ - this->TableRange[0] = min; - this->TableRange[1] = max; - this->UseAbsoluteValue = ComputeLogRange(this->TableRange,this->myLogRange); - if(this->UseAbsoluteValue < 0) return; - this->LogMinRange = this->myLogRange[0]; - this->LogMaxRange = this->myLogRange[1]; -} - -unsigned char* VISU_LookupTable::MapValue(float v) { - v = this->TableRange[0] + (v - this->TableRange[0])*myScale; - if(myIsLog) { - v = pow((float)10.0,v)*myScale; - //v = pow(10.0, (this->LogMinRange + (v - this->LogMinRange)))*myScale; - return vtkLogLookupTable::MapValue(v); - }else{ - //v *= myScale; - return vtkLookupTable::MapValue(v); - } -} - - - - - - - - - - - - diff --git a/src/VISU_I/VISU_LookupTable.hxx b/src/VISU_I/VISU_LookupTable.hxx deleted file mode 100644 index a690fb63..00000000 --- a/src/VISU_I/VISU_LookupTable.hxx +++ /dev/null @@ -1,41 +0,0 @@ -// File : VISU_LookupTable.h -// Created : UI team, 18.02.03 -// Descr : Scaling values of vtkLookupTable -// Author : Vitaliy Smetannikov -// Project : SALOME -// Module : OBJECT -// Copyright : Open CASCADE 2003 - - -#ifndef VISU_LookupTable_H -#define VISU_LookupTable_H - -//#include -#include - -class VISU_LookupTable: public vtkLogLookupTable { - public: - vtkTypeMacro(VISU_LookupTable,vtkLogLookupTable); - - static VISU_LookupTable *New(); - - void SetTableRange(float min, float max); - static int ComputeLogRange(float inRange[2], float outRange[2]); - float* GetLogRange() { return myLogRange;} - unsigned char *MapValue(float v); - - float GetMapScale() { return myScale; } - void SetMapScale(float theScale) { myScale = theScale; Modified(); } - - int IsLog() { return myIsLog; } - void SetLog(int theLog) { myIsLog = theLog; Modified(); } - - protected: - VISU_LookupTable(int sze=256, int ext=256); - ~VISU_LookupTable() {}; - - float myScale; - int myIsLog; - float myLogRange[2]; -}; -#endif // VISU_LookupTable_H diff --git a/src/VISU_I/VISU_ScalarBarActor.cxx b/src/VISU_I/VISU_ScalarBarActor.cxx deleted file mode 100644 index 754779ca..00000000 --- a/src/VISU_I/VISU_ScalarBarActor.cxx +++ /dev/null @@ -1,600 +0,0 @@ -using namespace std; -// File: VISU_ScalarBarActor.cxx -// Created: Wed Feb 26 10:34:56 2003 -// Author: Alexey PETROV -// - - -#include "VISU_ScalarBarActor.hxx" -#include "VISU_LookupTable.hxx" -#include - -//------------------------------------------------------------------------------ -VISU_ScalarBarActor* VISU_ScalarBarActor::New(){ - vtkObject* ret = vtkObjectFactory::CreateInstance("VISU_ScalarBarActor"); - if(ret) - return (VISU_ScalarBarActor*)ret; - return new VISU_ScalarBarActor; -} - -VISU_ScalarBarActor::VISU_ScalarBarActor() -{ - this->myLookupTable = NULL; - this->Position2Coordinate->SetValue(0.17, 0.8); - - this->PositionCoordinate->SetCoordinateSystemToNormalizedViewport(); - this->PositionCoordinate->SetValue(0.82,0.1); - - this->MaximumNumberOfColors = 64; - this->NumberOfLabels = 5; - this->NumberOfLabelsBuilt = 0; - this->Orientation = VTK_ORIENT_VERTICAL; - this->Title = NULL; - - this->Bold = 1; - this->Italic = 1; - this->Shadow = 1; - this->FontFamily = VTK_ARIAL; - this->LabelFormat = new char[8]; - sprintf(this->LabelFormat,"%s","%-#6.3g"); - - this->TitleMapper = vtkTextMapper::New(); - this->TitleMapper->SetJustificationToCentered(); - this->TitleActor = vtkActor2D::New(); - this->TitleActor->SetMapper(this->TitleMapper); - this->TitleActor->GetPositionCoordinate()-> - SetReferenceCoordinate(this->PositionCoordinate); - - this->TextMappers = NULL; - this->TextActors = NULL; - - this->ScalarBar = vtkPolyData::New(); - this->ScalarBarMapper = vtkPolyDataMapper2D::New(); - this->ScalarBarMapper->SetInput(this->ScalarBar); - this->ScalarBarActor = vtkActor2D::New(); - this->ScalarBarActor->SetMapper(this->ScalarBarMapper); - this->ScalarBarActor->GetPositionCoordinate()-> - SetReferenceCoordinate(this->PositionCoordinate); - this->LastOrigin[0] = 0; - this->LastOrigin[1] = 0; - this->LastSize[0] = 0; - this->LastSize[1] = 0; -} - -void VISU_ScalarBarActor::ReleaseGraphicsResources(vtkWindow *win) -{ - this->TitleActor->ReleaseGraphicsResources(win); - if (this->TextMappers != NULL ) - { - for (int i=0; i < this->NumberOfLabelsBuilt; i++) - { - this->TextActors[i]->ReleaseGraphicsResources(win); - } - } - this->ScalarBarActor->ReleaseGraphicsResources(win); -} - -VISU_ScalarBarActor::~VISU_ScalarBarActor() -{ - if (this->LabelFormat) - { - delete [] this->LabelFormat; - this->LabelFormat = NULL; - } - - this->TitleMapper->Delete(); - this->TitleActor->Delete(); - - if (this->TextMappers != NULL ) - { - for (int i=0; i < this->NumberOfLabelsBuilt; i++) - { - this->TextMappers[i]->Delete(); - this->TextActors[i]->Delete(); - } - delete [] this->TextMappers; - delete [] this->TextActors; - } - - this->ScalarBar->Delete(); - this->ScalarBarMapper->Delete(); - this->ScalarBarActor->Delete(); - - if (this->Title) - { - delete [] this->Title; - this->Title = NULL; - } - - this->SetLookupTable(NULL); -} - -void VISU_ScalarBarActor::SetLookupTable(vtkScalarsToColors* theLookupTable){ - //this->myLookupTable = dynamic_cast(theLookupTable); - if(this->myLookupTable != NULL) this->myLookupTable->UnRegister(this); - this->myLookupTable = VISU_LookupTable::SafeDownCast(theLookupTable); - this->myLookupTable->Register(this); -} - -vtkScalarsToColors* VISU_ScalarBarActor::GetLookupTable(){ - cout<<"VISU_ScalarBarActor::GetLookupTable = "<myLookupTable; - return this->myLookupTable; -} - -int VISU_ScalarBarActor::RenderOverlay(vtkViewport *viewport) -{ - int renderedSomething = 0; - int i; - - // Everything is built, just have to render - if (this->Title != NULL) - { - renderedSomething += this->TitleActor->RenderOverlay(viewport); - } - this->ScalarBarActor->RenderOverlay(viewport); - if( this->TextActors == NULL) - { - vtkWarningMacro(<<"Need a mapper to render a scalar bar"); - return renderedSomething; - } - - for (i=0; iNumberOfLabels; i++) - { - renderedSomething += this->TextActors[i]->RenderOverlay(viewport); - } - - renderedSomething = (renderedSomething > 0)?(1):(0); - - return renderedSomething; -} - -int VISU_ScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport) -{ - int renderedSomething = 0; - int i; - int size[2]; - - if ( ! this->myLookupTable ) - { - vtkWarningMacro(<<"Need a mapper to render a scalar bar"); - return 0; - } - - // Check to see whether we have to rebuild everything - if ( viewport->GetMTime() > this->BuildTime || - ( viewport->GetVTKWindow() && - viewport->GetVTKWindow()->GetMTime() > this->BuildTime ) ) - { - // if the viewport has changed we may - or may not need - // to rebuild, it depends on if the projected coords chage - int *barOrigin; - barOrigin = this->PositionCoordinate->GetComputedViewportValue(viewport); - size[0] = - this->Position2Coordinate->GetComputedViewportValue(viewport)[0] - - barOrigin[0]; - size[1] = - this->Position2Coordinate->GetComputedViewportValue(viewport)[1] - - barOrigin[1]; - if (this->LastSize[0] != size[0] || this->LastSize[1] != size[1] || - this->LastOrigin[0] != barOrigin[0] || - this->LastOrigin[1] != barOrigin[1]) - { - this->Modified(); - } - } - - // Check to see whether we have to rebuild everything - if ( this->GetMTime() > this->BuildTime || - this->myLookupTable->GetMTime() > this->BuildTime ) - { - vtkDebugMacro(<<"Rebuilding subobjects"); - - // Delete previously constructed objects - // - if (this->TextMappers != NULL ) - { - for (i=0; i < this->NumberOfLabelsBuilt; i++) - { - this->TextMappers[i]->Delete(); - this->TextActors[i]->Delete(); - } - delete [] this->TextMappers; - delete [] this->TextActors; - } - - // Build scalar bar object - // - VISU_LookupTable *lut = this->myLookupTable; //VISU specific - // we hard code how many steps to display - int numColors = this->MaximumNumberOfColors; - float *range = lut->GetRange(); - - int numPts = 2*(numColors + 1); - vtkPoints *pts = vtkPoints::New(); - pts->SetNumberOfPoints(numPts); - vtkCellArray *polys = vtkCellArray::New(); - polys->Allocate(polys->EstimateSize(numColors,4)); - vtkScalars *colors = vtkScalars::New(VTK_UNSIGNED_CHAR,3); - colors->SetNumberOfScalars(numColors); - vtkUnsignedCharArray *colorData = (vtkUnsignedCharArray *)colors->GetData(); - - this->ScalarBarActor->SetProperty(this->GetProperty()); - this->ScalarBar->Initialize(); - this->ScalarBar->SetPoints(pts); - this->ScalarBar->SetPolys(polys); - this->ScalarBar->GetCellData()->SetScalars(colors); - pts->Delete(); polys->Delete(); colors->Delete(); - - // get the viewport size in display coordinates - int *barOrigin, barWidth, barHeight; - barOrigin = this->PositionCoordinate->GetComputedViewportValue(viewport); - size[0] = - this->Position2Coordinate->GetComputedViewportValue(viewport)[0] - - barOrigin[0]; - size[1] = - this->Position2Coordinate->GetComputedViewportValue(viewport)[1] - - barOrigin[1]; - this->LastOrigin[0] = barOrigin[0]; - this->LastOrigin[1] = barOrigin[1]; - this->LastSize[0] = size[0]; - this->LastSize[1] = size[1]; - - // Update all the composing objects - // - if (this->Title == NULL ) - { - this->TitleActor->VisibilityOff(); - } - this->TitleActor->VisibilityOn(); - this->TitleActor->SetProperty(this->GetProperty()); - this->TitleMapper->SetInput(this->Title); - this->TitleMapper->SetBold(this->Bold); - this->TitleMapper->SetItalic(this->Italic); - this->TitleMapper->SetShadow(this->Shadow); - this->TitleMapper->SetFontFamily(this->FontFamily); - - - // find the best size for the title font - int titleSize[2]; - this->SizeTitle(titleSize, size, viewport); - - // find the best size for the ticks - int labelSize[2]; - this->AllocateAndSizeLabels(labelSize, size, viewport,range); - this->NumberOfLabelsBuilt = this->NumberOfLabels; - - // generate points - float x[3]; x[2] = 0.0; - float delta; - if ( this->Orientation == VTK_ORIENT_VERTICAL ) - { - barWidth = size[0] - 4 - labelSize[0]; - barHeight = (int)(0.86*size[1]); - delta=(float)barHeight/numColors; - for (i=0; iSetPoint(2*i,x); - x[0] = barWidth; - pts->SetPoint(2*i+1,x); - } - } - else - { - barWidth = size[0]; - barHeight = (int)(0.4*size[1]); - delta=(float)barWidth/numColors; - for (i=0; iSetPoint(2*i,x); - x[1] = 0; - pts->SetPoint(2*i+1,x); - } - } - - //polygons & cell colors - unsigned char *rgba, *rgb; - int ptIds[4]; - float val, *aLogRange = this->myLookupTable->GetLogRange(); - for (i=0; iInsertNextCell(4,ptIds); - rgba = lut->MapValue(range[0] + (range[1] - range[0])*((float)i /(numColors-1.0))); - if(this->myLookupTable->IsLog()){ // SALOME specific - val = aLogRange[0] + (float)i/(numColors-1.0) * (aLogRange[1]-aLogRange[0]); - rgba = lut->MapValue(val); - } - rgb = colorData->GetPointer(3*i); //write into array directly - rgb[0] = rgba[0]; - rgb[1] = rgba[1]; - rgb[2] = rgba[2]; - } - - // Now position everything properly - // - if (this->Orientation == VTK_ORIENT_VERTICAL) - { - int sizeTextData[2]; - - // center the title - this->TitleActor->SetPosition(size[0]/2, 0.9*size[1]); - - for (i=0; i < this->NumberOfLabels; i++) - { - val = (float)i/(this->NumberOfLabels-1) *barHeight; - this->TextMappers[i]->SetJustificationToLeft(); - this->TextMappers[i]->GetSize(viewport,sizeTextData); - this->TextActors[i]->SetPosition(barWidth+3, - val - sizeTextData[1]/2); - } - } - else - { - this->TitleActor->SetPosition(size[0]/2, - barHeight + labelSize[1] + 0.1*size[1]); - for (i=0; i < this->NumberOfLabels; i++) - { - val = (float)i/(this->NumberOfLabels-1) * barWidth; - this->TextMappers[i]->SetJustificationToCentered(); - this->TextActors[i]->SetPosition(val, barHeight + 0.05*size[1]); - } - } - - this->BuildTime.Modified(); - } - - // Everything is built, just have to render - if (this->Title != NULL) - { - renderedSomething += this->TitleActor->RenderOpaqueGeometry(viewport); - } - this->ScalarBarActor->RenderOpaqueGeometry(viewport); - for (i=0; iNumberOfLabels; i++) - { - renderedSomething += this->TextActors[i]->RenderOpaqueGeometry(viewport); - } - - renderedSomething = (renderedSomething > 0)?(1):(0); - - return renderedSomething; -} - -void VISU_ScalarBarActor::PrintSelf(ostream& os, vtkIndent indent) -{ - vtkActor2D::PrintSelf(os,indent); - - if ( this->myLookupTable ) - { - os << indent << "Lookup Table:\n"; - this->myLookupTable->PrintSelf(os,indent.GetNextIndent()); - } - else - { - os << indent << "Lookup Table: (none)\n"; - } - - os << indent << "Title: " << (this->Title ? this->Title : "(none)") << "\n"; - os << indent << "Maximum Number Of Colors: " - << this->MaximumNumberOfColors << "\n"; - os << indent << "Number Of Labels: " << this->NumberOfLabels << "\n"; - os << indent << "Number Of Labels Built: " << this->NumberOfLabelsBuilt << "\n"; - - os << indent << "Orientation: "; - if ( this->Orientation == VTK_ORIENT_HORIZONTAL ) - { - os << "Horizontal\n"; - } - else - { - os << "Vertical\n"; - } - - os << indent << "Font Family: "; - if ( this->FontFamily == VTK_ARIAL ) - { - os << "Arial\n"; - } - else if ( this->FontFamily == VTK_COURIER ) - { - os << "Courier\n"; - } - else - { - os << "Times\n"; - } - - os << indent << "Bold: " << (this->Bold ? "On\n" : "Off\n"); - os << indent << "Italic: " << (this->Italic ? "On\n" : "Off\n"); - os << indent << "Shadow: " << (this->Shadow ? "On\n" : "Off\n"); - os << indent << "Label Format: " << this->LabelFormat << "\n"; -} - -void VISU_ScalarBarActor::ShallowCopy(vtkProp *prop) -{ - VISU_ScalarBarActor *a = VISU_ScalarBarActor::SafeDownCast(prop); - if ( a != NULL ) - { - this->SetPosition2(a->GetPosition2()); - this->SetLookupTable(a->GetLookupTable()); - this->SetMaximumNumberOfColors(a->GetMaximumNumberOfColors()); - this->SetOrientation(a->GetOrientation()); - this->SetBold(a->GetBold()); - this->SetItalic(a->GetItalic()); - this->SetShadow(a->GetShadow()); - this->SetFontFamily(a->GetFontFamily()); - this->SetLabelFormat(a->GetLabelFormat()); - this->SetTitle(a->GetTitle()); - - this->GetPositionCoordinate()->SetCoordinateSystem( - a->GetPositionCoordinate()->GetCoordinateSystem()); - this->GetPositionCoordinate()->SetValue( - a->GetPositionCoordinate()->GetValue()); - this->GetPosition2Coordinate()->SetCoordinateSystem( - a->GetPosition2Coordinate()->GetCoordinateSystem()); - this->GetPosition2Coordinate()->SetValue( - a->GetPosition2Coordinate()->GetValue()); - } - - // Now do superclass - this->vtkActor2D::ShallowCopy(prop); -} - -void VISU_ScalarBarActor::AllocateAndSizeLabels(int *labelSize, int *size, - vtkViewport *viewport, - float *range) -{ - labelSize[0] = 0; - labelSize[1] = 0; - int fontSize; - int tempi[2]; - - this->TextMappers = new vtkTextMapper * [this->NumberOfLabels]; - this->TextActors = new vtkActor2D * [this->NumberOfLabels]; - char string[512]; - float val, *aLogRange = this->myLookupTable->GetLogRange(); - int targetWidth, targetHeight; - int i; - - for (i=0; i < this->NumberOfLabels; i++) - { - this->TextMappers[i] = vtkTextMapper::New(); - val = range[0] + (float)i/(this->NumberOfLabels-1) * (range[1]-range[0]); - if(0 < i && i < this->NumberOfLabels - 1) // SALOME specific - if(this->myLookupTable->IsLog()){ - val = aLogRange[0] + (float)i/(this->NumberOfLabels-1) * (aLogRange[1]-aLogRange[0]); - val = pow((float)10.0,val); - } - sprintf(string, this->LabelFormat, val); - this->TextMappers[i]->SetInput(string); - this->TextMappers[i]->SetBold(this->Bold); - this->TextMappers[i]->SetItalic(this->Italic); - this->TextMappers[i]->SetShadow(this->Shadow); - this->TextMappers[i]->SetFontFamily(this->FontFamily); - this->TextActors[i] = vtkActor2D::New(); - this->TextActors[i]->SetMapper(this->TextMappers[i]); - this->TextActors[i]->SetProperty(this->GetProperty()); - this->TextActors[i]->GetPositionCoordinate()-> - SetReferenceCoordinate(this->PositionCoordinate); - } - if (this->NumberOfLabels) - { - if ( this->Orientation == VTK_ORIENT_VERTICAL ) - { - targetWidth = (int)(0.6*size[0]); - targetHeight = (int)(0.86*size[1]/this->NumberOfLabels); - } - else - { - targetWidth = (int)(size[0]*0.8/this->NumberOfLabels); - targetHeight = (int)(0.25*size[1]); - } - fontSize = targetWidth; - for (i=0; i < this->NumberOfLabels; i++) - { - this->TextMappers[i]->SetFontSize(fontSize); - this->TextMappers[i]->GetSize(viewport,tempi); - if (labelSize[0] < tempi[0]) - { - labelSize[0] = tempi[0]; - } - if (labelSize[1] < tempi[1]) - { - labelSize[1] = tempi[1]; - } - } - - while (labelSize[0] < targetWidth && labelSize[1] < targetHeight && - fontSize < 100 ) - { - fontSize++; - labelSize[0] = 0; - labelSize[1] = 0; - for (i=0; i < this->NumberOfLabels; i++) - { - this->TextMappers[i]->SetFontSize(fontSize); - this->TextMappers[i]->GetSize(viewport,tempi); - if (labelSize[0] < tempi[0]) - { - labelSize[0] = tempi[0]; - } - if (labelSize[1] < tempi[1]) - { - labelSize[1] = tempi[1]; - } - } - } - - while ((labelSize[0] > targetWidth || - labelSize[1] > targetHeight) && fontSize > 0 ) - { - fontSize--; - labelSize[0] = 0; - labelSize[1] = 0; - for (i=0; i < this->NumberOfLabels; i++) - { - this->TextMappers[i]->SetFontSize(fontSize); - this->TextMappers[i]->GetSize(viewport,tempi); - if (labelSize[0] < tempi[0]) - { - labelSize[0] = tempi[0]; - } - if (labelSize[1] < tempi[1]) - { - labelSize[1] = tempi[1]; - } - } - } - } -} - -void VISU_ScalarBarActor::SizeTitle(int *titleSize, int *size, - vtkViewport *viewport) -{ - int targetWidth, targetHeight; - titleSize[0] = 0; - titleSize[1] = 0; - int fontSize; - int tempi[2]; - - if (this->Title != NULL && (strlen(this->Title) != 0)) - { - if ( this->Orientation == VTK_ORIENT_VERTICAL ) - { - targetWidth = size[0]; - targetHeight = (int)(0.1*size[1]); - } - else - { - targetWidth = size[0]; - targetHeight = (int)(0.25*size[1]); - } - fontSize = targetWidth; - this->TitleMapper->SetFontSize(fontSize); - this->TitleMapper->GetSize(viewport,tempi); - - while (tempi[1] < targetHeight && tempi[0] < targetWidth - && fontSize < 100 ) - { - fontSize++; - this->TitleMapper->SetFontSize(fontSize); - this->TitleMapper->GetSize(viewport,tempi); - } - - while ((tempi[1] > targetHeight || tempi[0] > targetWidth ) - && fontSize > 0 ) - { - fontSize--; - this->TitleMapper->SetFontSize(fontSize); - this->TitleMapper->GetSize(viewport,tempi); - } - titleSize[0] = tempi[0]; - titleSize[1] = tempi[1]; - } -} diff --git a/src/VISU_I/VISU_ScalarBarActor.hxx b/src/VISU_I/VISU_ScalarBarActor.hxx deleted file mode 100644 index 9e4ed8bc..00000000 --- a/src/VISU_I/VISU_ScalarBarActor.hxx +++ /dev/null @@ -1,116 +0,0 @@ -// File: VISU_ScalarBarActor.hxx -// Created: Wed Feb 26 10:13:15 2003 -// Author: Alexey PETROV -// - - -#ifndef VISU_ScalarBarActor_HeaderFile -#define VISU_ScalarBarActor_HeaderFile - -#include -#include -#include -#include -#include - -class VISU_LookupTable; - -#define VTK_ORIENT_HORIZONTAL 0 -#define VTK_ORIENT_VERTICAL 1 - -class VTK_EXPORT VISU_ScalarBarActor : public vtkActor2D -{ -public: - vtkTypeMacro(VISU_ScalarBarActor,vtkActor2D); - void PrintSelf(ostream& os, vtkIndent indent); - - static VISU_ScalarBarActor *New(); - - int RenderOpaqueGeometry(vtkViewport* viewport); - int RenderTranslucentGeometry(vtkViewport*) { return 0; }; - int RenderOverlay(vtkViewport* viewport); - - virtual void ReleaseGraphicsResources(vtkWindow *); - - void SetLookupTable(vtkScalarsToColors*); - vtkScalarsToColors* GetLookupTable(); - - vtkSetClampMacro(MaximumNumberOfColors, int, 2, VTK_LARGE_INTEGER); - vtkGetMacro(MaximumNumberOfColors, int); - - vtkSetClampMacro(NumberOfLabels, int, 0, 64); - vtkGetMacro(NumberOfLabels, int); - - vtkSetClampMacro(Orientation,int,VTK_ORIENT_HORIZONTAL, VTK_ORIENT_VERTICAL); - vtkGetMacro(Orientation, int); - void SetOrientationToHorizontal() - {this->SetOrientation(VTK_ORIENT_HORIZONTAL);}; - void SetOrientationToVertical() {this->SetOrientation(VTK_ORIENT_VERTICAL);}; - - vtkSetMacro(Bold, int); - vtkGetMacro(Bold, int); - vtkBooleanMacro(Bold, int); - - vtkSetMacro(Italic, int); - vtkGetMacro(Italic, int); - vtkBooleanMacro(Italic, int); - - vtkSetMacro(Shadow, int); - vtkGetMacro(Shadow, int); - vtkBooleanMacro(Shadow, int); - - vtkSetMacro(FontFamily, int); - vtkGetMacro(FontFamily, int); - void SetFontFamilyToArial() {this->SetFontFamily(VTK_ARIAL);}; - void SetFontFamilyToCourier() {this->SetFontFamily(VTK_COURIER);}; - void SetFontFamilyToTimes() {this->SetFontFamily(VTK_TIMES);}; - - vtkSetStringMacro(LabelFormat); - vtkGetStringMacro(LabelFormat); - - vtkSetStringMacro(Title); - vtkGetStringMacro(Title); - - void ShallowCopy(vtkProp *prop); - -protected: - VISU_ScalarBarActor(); - ~VISU_ScalarBarActor(); - VISU_ScalarBarActor(const VISU_ScalarBarActor&); - void operator=(const VISU_ScalarBarActor&); - - VISU_LookupTable* myLookupTable; -private: - int MaximumNumberOfColors; - int NumberOfLabels; - int NumberOfLabelsBuilt; - int Orientation; - char *Title; - - int Bold; - int Italic; - int Shadow; - int FontFamily; - char *LabelFormat; - -private: - vtkTextMapper *TitleMapper; - vtkActor2D *TitleActor; - - vtkTextMapper **TextMappers; - vtkActor2D **TextActors; - - vtkPolyData *ScalarBar; - vtkPolyDataMapper2D *ScalarBarMapper; - vtkActor2D *ScalarBarActor; - - vtkTimeStamp BuildTime; - int LastSize[2]; - int LastOrigin[2]; - - void SizeTitle(int *titleSize, int *size, vtkViewport *viewport); - void AllocateAndSizeLabels(int *labelSize, int *size, - vtkViewport *viewport, float *range); -}; - -#endif