Commit 96db5108 authored by Joachim Pouderoux's avatar Joachim Pouderoux Committed by Code Review

Merge topic 'plotbar_improvement' into master

1dcc3d96 Add functions to get data bounds and number of plotted bars.
parents f7bf6158 1dcc3d96
......@@ -1105,3 +1105,36 @@ vtkStdString vtkPlotBar::GetTooltipLabel(const vtkVector2d &plotPos,
}
return tooltipLabel;
}
//-----------------------------------------------------------------------------
int vtkPlotBar::GetBarsCount()
{
vtkTable *table = this->Data->GetInput();
if (!table)
{
vtkWarningMacro(<< "GetBarsCount called with no input table set.");
return 0;
}
vtkDataArray* x = this->Data->GetInputArrayToProcess(0, table);
return x ? x->GetNumberOfTuples() : 0;
}
//-----------------------------------------------------------------------------
void vtkPlotBar::GetDataBounds(double bounds[2])
{
assert(bounds);
// Get the x and y arrays (index 0 and 1 respectively)
vtkTable *table = this->Data->GetInput();
if (!table)
{
vtkWarningMacro(<< "GetDataBounds called with no input table set.");
bounds[0] = VTK_DOUBLE_MAX;
bounds[1] = VTK_DOUBLE_MIN;
return;
}
vtkDataArray* x = this->Data->GetInputArrayToProcess(0, table);
if (x)
{
x->GetRange(bounds);
}
}
......@@ -192,6 +192,14 @@ public:
vtkVector2f* location,
vtkIdType* segmentIndex);
// Description:
// Get amount of plotted bars.
int GetBarsCount();
// Description:
// Get the data bounds for this mapper as (Xmin,Xmax).
void GetDataBounds(double bounds[2]);
protected:
vtkPlotBar();
~vtkPlotBar();
......
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