Commit 547aa8fb authored by Will Schroeder's avatar Will Schroeder
Browse files

BUG: vtkLabeledDataMapper was never converted to new pipeline

parent cfb44079
......@@ -20,12 +20,12 @@ vtkVolume16Reader v16
v16 SetImageRange 45 45
v16 SetDataSpacing 3.2 3.2 1.5
vtkContourFilter iso
iso SetInput [v16 GetOutput]
iso SetInputConnection [v16 GetOutputPort]
iso GenerateValues 6 500 1150
iso Update
set numPts [[iso GetOutput] GetNumberOfPoints]
vtkPolyDataMapper isoMapper
isoMapper SetInput [iso GetOutput]
isoMapper SetInputConnection [iso GetOutputPort]
isoMapper ScalarVisibilityOn
eval isoMapper SetScalarRange [[iso GetOutput] GetScalarRange]
vtkActor isoActor
......@@ -33,17 +33,17 @@ vtkActor isoActor
# Subsample the points and label them
vtkMaskPoints mask
mask SetInput [iso GetOutput]
mask SetInputConnection [iso GetOutputPort]
mask SetOnRatio [expr $numPts / 50]
mask SetMaximumNumberOfPoints 50
mask RandomModeOn
# Create labels for points - only show visible points
vtkSelectVisiblePoints visPts
visPts SetInput [mask GetOutput]
visPts SetInputConnection [mask GetOutputPort]
visPts SetRenderer ren1
vtkLabeledDataMapper ldm
ldm SetInput [mask GetOutput]
ldm SetInputConnection [mask GetOutputPort]
ldm SetLabelFormat "%g"
ldm SetLabelModeToLabelScalars
set tprop [ldm GetLabelTextProperty]
......
......@@ -14,6 +14,8 @@
=========================================================================*/
#include "vtkLabeledDataMapper.h"
#include "vtkExecutive.h"
#include "vtkInformation.h"
#include "vtkActor2D.h"
#include "vtkDataArray.h"
#include "vtkDataSet.h"
......@@ -22,10 +24,9 @@
#include "vtkTextMapper.h"
#include "vtkTextProperty.h"
vtkCxxRevisionMacro(vtkLabeledDataMapper, "1.39");
vtkCxxRevisionMacro(vtkLabeledDataMapper, "1.40");
vtkStandardNewMacro(vtkLabeledDataMapper);
vtkCxxSetObjectMacro(vtkLabeledDataMapper,Input, vtkDataSet);
vtkCxxSetObjectMacro(vtkLabeledDataMapper,LabelTextProperty,vtkTextProperty);
//----------------------------------------------------------------------------
......@@ -76,15 +77,33 @@ vtkLabeledDataMapper::~vtkLabeledDataMapper()
delete [] this->TextMappers;
}
this->SetInput(NULL);
this->SetLabelTextProperty(NULL);
}
//----------------------------------------------------------------------------
// Release any graphics resources that are being consumed by this actor.
// The parameter window could be used to determine which graphic
// resources to release.
void vtkLabeledDataMapper::SetInput(vtkDataSet *input)
{
if (input)
{
this->SetInputConnection(0, input->GetProducerPort());
}
else
{
// Setting a NULL input removes the connection.
this->SetInputConnection(0, 0);
}
}
//----------------------------------------------------------------------------
// Specify the input data or filter.
vtkDataSet *vtkLabeledDataMapper::GetInput()
{
return vtkDataSet::SafeDownCast(
this->GetExecutive()->GetInputData(0, 0));
}
//----------------------------------------------------------------------------
// Release any graphics resources that are being consumed by this mapper.
void vtkLabeledDataMapper::ReleaseGraphicsResources(vtkWindow *win)
{
if (this->TextMappers != NULL )
......@@ -111,7 +130,7 @@ void vtkLabeledDataMapper::RenderOverlay(vtkViewport *viewport,
}
for (i=0; i<this->NumberOfLabels; i++)
{
this->Input->GetPoint(i,x);
input->GetPoint(i,x);
actor->GetPositionCoordinate()->SetCoordinateSystemToWorld();
actor->GetPositionCoordinate()->SetValue(x);
this->TextMappers[i]->RenderOverlay(viewport, actor);
......@@ -218,7 +237,7 @@ void vtkLabeledDataMapper::RenderOpaqueGeometry(vtkViewport *viewport,
return;
}
this->NumberOfLabels = this->Input->GetNumberOfPoints();
this->NumberOfLabels = input->GetNumberOfPoints();
if ( this->NumberOfLabels > this->NumberOfLabelsAllocated )
{
// delete old stuff
......@@ -247,18 +266,21 @@ void vtkLabeledDataMapper::RenderOpaqueGeometry(vtkViewport *viewport,
{
if ( numComp == 1)
{
if (data->GetDataType() == VTK_CHAR)
if (data->GetDataType() == VTK_CHAR)
{
if (strcmp(this->LabelFormat,"%c") != 0)
{
if (strcmp(this->LabelFormat,"%c") != 0) {
vtkErrorMacro(<<"Label format must be %c to use with char");
return;
}
sprintf(string, this->LabelFormat,
(char)data->GetComponent(i, activeComp));
} else {
sprintf(string, this->LabelFormat,
data->GetComponent(i, activeComp));
vtkErrorMacro(<<"Label format must be %c to use with char");
return;
}
sprintf(string, this->LabelFormat,
(char)data->GetComponent(i, activeComp));
}
else
{
sprintf(string, this->LabelFormat,
data->GetComponent(i, activeComp));
}
}
else
{
......@@ -282,13 +304,21 @@ void vtkLabeledDataMapper::RenderOpaqueGeometry(vtkViewport *viewport,
for (i=0; i<this->NumberOfLabels; i++)
{
this->Input->GetPoint(i,x);
input->GetPoint(i,x);
actor->GetPositionCoordinate()->SetCoordinateSystemToWorld();
actor->GetPositionCoordinate()->SetValue(x);
this->TextMappers[i]->RenderOpaqueGeometry(viewport, actor);
}
}
//----------------------------------------------------------------------------
int vtkLabeledDataMapper::FillInputPortInformation(
int vtkNotUsed( port ), vtkInformation* info)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
return 1;
}
//----------------------------------------------------------------------------
void vtkLabeledDataMapper::PrintSelf(ostream& os, vtkIndent indent)
{
......
......@@ -94,9 +94,9 @@ public:
vtkGetMacro(FieldDataArray,int);
// Description:
// Set the input dataset to the mapper.
// Set the input dataset to the mapper. This mapper handles any type of data.
virtual void SetInput(vtkDataSet*);
vtkGetObjectMacro(Input, vtkDataSet);
vtkDataSet *GetInput();
// Description:
// Specify which data to plot: scalars, vectors, normals, texture coords,
......@@ -125,8 +125,6 @@ public:
// Description:
// Release any graphics resources that are being consumed by this actor.
// The parameter window could be used to determine which graphic
// resources to release.
virtual void ReleaseGraphicsResources(vtkWindow *);
protected:
......@@ -148,6 +146,8 @@ private:
int NumberOfLabelsAllocated;
vtkTextMapper **TextMappers;
virtual int FillInputPortInformation(int, vtkInformation*);
private:
vtkLabeledDataMapper(const vtkLabeledDataMapper&); // Not implemented.
void operator=(const vtkLabeledDataMapper&); // Not implemented.
......
Supports Markdown
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