Commit 549c3c5a authored by Philippe Pébay's avatar Philippe Pébay
Browse files

Now drawing background and frame -- and testing them.

Note that this does not break the existing tests, thanks to an
EnhancedMode iVar which is turned off by default. Note also that
as a result, when drawing a frame or a background without this
enhanced mode, the result is not visually pleasing.

Change-Id: I08003b229391197202321619d0a9a2ba7cc5c8ec
parent 5bd5f4f7
......@@ -18,6 +18,7 @@
#include "vtkCamera.h"
#include "vtkPLOT3DReader.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty2D.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
......@@ -82,7 +83,11 @@ int TestScalarBar( int argc, char *argv[] )
scalarBar1->SetHeight(0.5);
scalarBar1->SetTextPositionToPrecedeScalarBar();
scalarBar1->SetEnhancedMode(1);
scalarBar1->SetDrawFrame(1);
scalarBar1->GetFrameProperty()->SetColor(0., 0., 0.);
scalarBar1->SetDrawBackground(1);
scalarBar1->GetBackgroundProperty()->SetColor(1., 1., 1.);
vtkSmartPointer<vtkScalarBarActor> scalarBar2 =
vtkSmartPointer<vtkScalarBarActor>::New();
scalarBar2->SetTitle("Temperature");
......@@ -93,6 +98,11 @@ int TestScalarBar( int argc, char *argv[] )
scalarBar2->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
scalarBar2->GetPositionCoordinate()->SetValue(0.05, 0.05);
scalarBar2->SetTextPositionToPrecedeScalarBar();
scalarBar2->SetEnhancedMode(1);
scalarBar2->SetDrawFrame(1);
scalarBar2->GetFrameProperty()->SetColor(1., 0., 0.);
scalarBar2->SetDrawBackground(1);
scalarBar2->GetBackgroundProperty()->SetColor(.5, .5, .5);
vtkSmartPointer<vtkScalarBarActor> scalarBar3 =
vtkSmartPointer<vtkScalarBarActor>::New();
......@@ -102,6 +112,10 @@ int TestScalarBar( int argc, char *argv[] )
scalarBar3->GetPositionCoordinate()->SetValue(0.8, 0.1);
scalarBar3->SetHeight(0.5);
scalarBar3->SetTextPositionToPrecedeScalarBar();
scalarBar3->SetEnhancedMode(1);
scalarBar3->SetDrawFrame(1);
scalarBar3->GetFrameProperty()->SetColor(0., 0., 0.);
scalarBar3->SetDrawBackground(0);
ren1->AddActor(outlineActor);
ren1->AddActor(scalarBar1);
......
......@@ -646,21 +646,21 @@ int vtkScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport)
{
if (this->NumberOfLabels > 1)
{
val = static_cast<double>(i)/(this->NumberOfLabels-1) *barHeight;
val = static_cast<double>(i)/(this->NumberOfLabels-1) *barHeight + barY;
}
else
{
val = 0.5*barHeight;
val = 0.5*(barHeight + barY);
}
this->TextMappers[i]->GetSize(viewport,sizeTextData);
this->TextMappers[i]->GetTextProperty()->SetJustificationToLeft();
if (this->TextPosition == vtkScalarBarActor::PrecedeScalarBar)
{
this->TextActors[i]->SetPosition(0.0, val - sizeTextData[1]/2);
this->TextActors[i]->SetPosition(barX, val - sizeTextData[1]/2);
}
else
{
this->TextActors[i]->SetPosition(barWidth + 3,
this->TextActors[i]->SetPosition(barX + barWidth + 3,
val - sizeTextData[1]/2);
}
}
......@@ -669,12 +669,12 @@ int vtkScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport)
{
if (this->TextPosition == vtkScalarBarActor::PrecedeScalarBar)
{
this->TitleActor->SetPosition(size[0]/2, 0.0);
this->TitleActor->SetPosition(size[0]/2, barY);
}
else
{
this->TitleActor->SetPosition(size[0]/2,
barHeight + labelSize[1] + 0.1*size[1]);
barHeight + labelSize[1] + 0.1*size[1]);
}
for (i=0; i < this->NumberOfLabels; i++)
{
......@@ -682,11 +682,11 @@ int vtkScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport)
this->TextMappers[i]->GetTextProperty()->SetJustificationToCentered();
if (this->NumberOfLabels > 1)
{
val = static_cast<double>(i)/(this->NumberOfLabels-1) * barWidth;
val = static_cast<double>(i)/(this->NumberOfLabels-1) * barWidth + barX;
}
else
{
val = 0.5*barWidth;
val = 0.5*(barWidth+barY);
}
if (this->TextPosition == vtkScalarBarActor::PrecedeScalarBar)
{
......@@ -694,7 +694,7 @@ int vtkScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport)
}
else
{
this->TextActors[i]->SetPosition(val, barHeight + 0.05*size[1]);
this->TextActors[i]->SetPosition(val, barY + barHeight + 0.05*size[1]);
}
}
}
......@@ -710,16 +710,16 @@ int vtkScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport)
if (this->Orientation == VTK_ORIENT_VERTICAL)
{
p1[0] = (this->TextPosition == vtkScalarBarActor::PrecedeScalarBar)
? (size[0] - barWidth) : 0.0;
p1[1] = 0.0;
? (size[0] - barWidth - barX) : barX;
p1[1] = barY;
p2[0] = p1[0] + barWidth;
p2[1] = barHeight;
p2[1] = p1[1] + barHeight;
}
else
{
p1[0] = 0.0;
p1[0] = barX;
p1[1] = (this->TextPosition == vtkScalarBarActor::PrecedeScalarBar)
? (size[1] - barHeight) : 0.0;
? (size[1] - barHeight - barY) : barY;
p2[0] = p1[0] + barWidth;
p2[1] = p1[1] + barHeight;
}
......@@ -733,12 +733,13 @@ int vtkScalarBarActor::RenderOpaqueGeometry(vtkViewport *viewport)
vtkDataArray * tc = this->TexturePolyData->GetPointData()->GetTCoords();
tc->SetTuple2(1, barWidth / this->TextureGridWidth, 0.0);
tc->SetTuple2(2, barWidth / this->TextureGridWidth,
barHeight / this->TextureGridWidth);
barHeight / this->TextureGridWidth);
tc->SetTuple2(3, 0.0, barHeight / this->TextureGridWidth);
this->BuildTime.Modified();
}
// Everything is built, just have to render
if (this->Title != NULL)
{
......
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