Commit 28e805b9 authored by Marcus D. Hanwell's avatar Marcus D. Hanwell

ENH: Added API to store, set and retrieve the active plot.

This allows users of the scatter plot matrix to store, set and retrieve
the large active plot in the top-right of the scatter plot matrix.

Change-Id: I4d1056e92e3ff6f398ec018337d116000e9a652d
parent f6934e02
......@@ -45,7 +45,7 @@ vtkChartMatrix::vtkChartMatrix() : Gutter(15.0, 15.0)
this->Private = new PIMPL;
this->Borders[vtkAxis::LEFT] = 50;
this->Borders[vtkAxis::BOTTOM] = 40;
this->Borders[vtkAxis::RIGHT] = 20;
this->Borders[vtkAxis::RIGHT] = 50;
this->Borders[vtkAxis::TOP] = 40;
}
......
......@@ -30,7 +30,7 @@
class vtkScatterPlotMatrix::PIMPL
{
public:
PIMPL() : VisibleColumnsModified(true)
PIMPL() : VisibleColumnsModified(true), BigChart(NULL)
{
}
......@@ -40,6 +40,7 @@ public:
vtkNew<vtkTable> Histogram;
bool VisibleColumnsModified;
vtkChart* BigChart;
};
namespace
......@@ -141,6 +142,43 @@ bool vtkScatterPlotMatrix::Paint(vtkContext2D *painter)
return Superclass::Paint(painter);
}
bool vtkScatterPlotMatrix::SetActivePlot(const vtkVector2i &pos)
{
if (pos.X() + pos.Y() + 1 < this->Size.X() && pos.X() < this->Size.X() &&
pos.Y() < this->Size.Y())
{
// The supplied index is valid (in the lower quadrant).
this->ActivePlot = pos;
if (this->Private->BigChart)
{
vtkPlot *plot = this->Private->BigChart->GetPlot(0);
if (!plot)
{
plot = this->Private->BigChart->AddPlot(vtkChart::POINTS);
vtkChartXY *xy = vtkChartXY::SafeDownCast(this->Private->BigChart);
if (xy)
{
xy->SetPlotCorner(plot, 2);
}
}
plot->SetInput(this->Input.GetPointer(),
this->VisibleColumns->GetValue(pos.X()),
this->VisibleColumns->GetValue(this->Size.X() -
pos.Y() - 1));
}
return true;
}
else
{
return false;
}
}
vtkVector2i vtkScatterPlotMatrix::GetActivePlot()
{
return this->ActivePlot;
}
void vtkScatterPlotMatrix::SetInput(vtkTable *table)
{
if (this->Input != table)
......@@ -292,14 +330,9 @@ void vtkScatterPlotMatrix::UpdateLayout()
else if (i == static_cast<int>(n / 2.0) + n % 2 && i == j)
{
// This big plot in the top-right
vtkPlot *plot = this->GetChart(pos)->AddPlot(vtkChart::POINTS);
plot->SetInput(this->Input.GetPointer(), i, n - j - 1);
this->SetChartSpan(pos, vtkVector2i(n - i, n - i));
vtkChartXY *xy = vtkChartXY::SafeDownCast(this->GetChart(pos));
if (xy)
{
xy->SetPlotCorner(plot, 2);
}
this->Private->BigChart = this->GetChart(pos);
this->SetChartSpan(pos, vtkVector2i(n - i, n - j));
this->SetActivePlot(vtkVector2i(0, n - 2));
}
// Only show bottom axis label for bottom plots
if (j > 0)
......
......@@ -49,6 +49,16 @@ public:
// Paint event for the chart matrix.
virtual bool Paint(vtkContext2D *painter);
// Description:
// Set the active plot, the one that will be displayed in the top-right.
// This defaults to (0, n-2), the plot below the first histogram on the left.
// \return false is the position specified is not valid.
virtual bool SetActivePlot(const vtkVector2i& position);
// Description:
// Get the position of the active plot.
virtual vtkVector2i GetActivePlot();
// Description:
// Set the input table for the scatter plot matrix. This will cause all
// columns to be plotted against each other - a square scatter plot matrix.
......@@ -87,6 +97,9 @@ protected:
class PIMPL;
PIMPL *Private;
// The position of the active plot (defaults to 0, 1).
vtkVector2i ActivePlot;
// Weakly owned input data for the scatter plot matrix.
vtkSmartPointer<vtkTable> Input;
// Strongly owned internal data for the column visibility.
......
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