Commit ab66fa57 authored by Karthik Krishnan's avatar Karthik Krishnan
Browse files

ENH: Set/Get the maximum width and height in pixels. Specifying the size as

    a relative fraction of the viewport can sometimes undersirably strech
    the size of the actor too much. These methods allow the user to set
    bounds on the maximum size of the scalar bar in pixels along any
    direction. Defaults to unbounded.
parent cf72ea0b
......@@ -32,7 +32,7 @@
#include "vtkRenderer.h"
#include "vtkProperty2D.h"
vtkCxxRevisionMacro(vtkScalarBarActor, "1.63");
vtkCxxRevisionMacro(vtkScalarBarActor, "1.64");
vtkStandardNewMacro(vtkScalarBarActor);
vtkCxxSetObjectMacro(vtkScalarBarActor,LookupTable,vtkScalarsToColors);
......@@ -155,6 +155,9 @@ vtkScalarBarActor::vtkScalarBarActor()
// Default text position : Above scalar bar if orientation is horizontal
// Right of scalar bar if orientation is vertical
this->TextPosition = SucceedScalarBar;
this->MaximumWidthInPixels = VTK_INT_MAX;
this->MaximumHeightInPixels = VTK_INT_MAX;
}
//----------------------------------------------------------------------------
......@@ -290,6 +293,13 @@ int vtkScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport)
size[1] =
this->Position2Coordinate->GetComputedViewportValue(viewport)[1] -
barOrigin[1];
// Check if we have bounds on the maximum size
size[0] = size[0] > this->MaximumWidthInPixels
? this->MaximumWidthInPixels : size[0];
size[1] = size[1] > this->MaximumHeightInPixels
? this->MaximumHeightInPixels : size[1];
if (this->LastSize[0] != size[0] ||
this->LastSize[1] != size[1] ||
this->LastOrigin[0] != barOrigin[0] ||
......@@ -357,6 +367,13 @@ int vtkScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport)
size[1] =
this->Position2Coordinate->GetComputedViewportValue(viewport)[1] -
barOrigin[1];
// Check if we have bounds on the maximum size
size[0] = size[0] > this->MaximumWidthInPixels
? this->MaximumWidthInPixels : size[0];
size[1] = size[1] > this->MaximumHeightInPixels
? this->MaximumHeightInPixels : size[1];
this->LastOrigin[0] = barOrigin[0];
this->LastOrigin[1] = barOrigin[1];
this->LastSize[0] = size[0];
......
......@@ -180,6 +180,17 @@ public:
virtual void SetTextPositionToSucceedScalarBar()
{ this->SetTextPosition( vtkScalarBarActor::SucceedScalarBar ); }
// Description:
// Set/Get the maximum width and height in pixels. Specifying the size as
// a relative fraction of the viewport can sometimes undersirably strech
// the size of the actor too much. These methods allow the user to set
// bounds on the maximum size of the scalar bar in pixels along any
// direction. Defaults to unbounded.
vtkSetMacro( MaximumWidthInPixels, int );
vtkGetMacro( MaximumWidthInPixels, int );
vtkSetMacro( MaximumHeightInPixels, int );
vtkGetMacro( MaximumHeightInPixels, int );
protected:
vtkScalarBarActor();
~vtkScalarBarActor();
......@@ -219,6 +230,8 @@ protected:
int LastSize[2];
int LastOrigin[2];
int MaximumWidthInPixels;
int MaximumHeightInPixels;
private:
vtkScalarBarActor(const vtkScalarBarActor&); // Not implemented.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment