Commit f6934e02 authored by Marcus D. Hanwell's avatar Marcus D. Hanwell

ENH: Added chart spans to the chart matrix.

Added the concept of a chart span to the chart matrix. This defaults to
1x1 charts with the expected behavior but allows for larger charts to be
defined.

Change-Id: Ic0e9ebe6089c225c66c6749a7240aef257535177
parent 4474c18e
......@@ -31,7 +31,10 @@ public:
PIMPL() {}
~PIMPL() {}
// Container for the vtkChart objects that make up the matrix.
std::vector< vtkSmartPointer<vtkChart> > Charts;
// Spans of the charts in the matrix, default is 1x1.
std::vector< vtkVector2i > Spans;
vtkVector2i Geometry;
};
......@@ -99,9 +102,12 @@ bool vtkChartMatrix::Paint(vtkContext2D *painter)
if (this->Private->Charts[index])
{
vtkChart *chart = this->Private->Charts[index];
vtkVector2i &span = this->Private->Spans[index];
chart->SetSize(vtkRectf(x, y,
increments.X(),
increments.Y()));
increments.X() * span.X() +
(span.X() - 1) * this->Gutter.X(),
increments.Y() * span.Y() +
(span.Y() - 1) * this->Gutter.Y()));
}
}
}
......@@ -124,6 +130,7 @@ void vtkChartMatrix::SetSize(const vtkVector2i &size)
}
}
this->Private->Charts.resize(size.X() * size.Y());
this->Private->Spans.resize(size.X() * size.Y(), vtkVector2i(1, 1));
}
}
......@@ -177,6 +184,34 @@ vtkChart* vtkChartMatrix::GetChart(const vtkVector2i &position)
}
}
bool vtkChartMatrix::SetChartSpan(const vtkVector2i& position,
const vtkVector2i& span)
{
if (this->Size.X() - position.X() - span.X() < 0 ||
this->Size.Y() - position.Y() - span.Y() < 0)
{
return false;
}
else
{
this->Private->Spans[position.Y() * this->Size.X() + position.X()] = span;
return true;
}
}
vtkVector2i vtkChartMatrix::GetChartSpan(const vtkVector2i& position)
{
size_t index = position.Y() * this->Size.X() + position.X();
if (position.X() < this->Size.X() && position.Y() < this->Size.Y())
{
return this->Private->Spans[index];
}
else
{
return vtkVector2i(0, 0);
}
}
void vtkChartMatrix::PrintSelf(ostream &os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
......
......@@ -81,6 +81,17 @@ public:
// this point.
virtual vtkChart* GetChart(const vtkVector2i& position);
// Description:
// Set the span of a chart in the matrix. This defaults to 1x1, and cannot
// exceed the remaining space in x or y.
// \return false If the span is not possible.
virtual bool SetChartSpan(const vtkVector2i& position,
const vtkVector2i& span);
// Description:
// Get the span of the specified chart.
virtual vtkVector2i GetChartSpan(const vtkVector2i& position);
protected:
vtkChartMatrix();
~vtkChartMatrix();
......
......@@ -294,6 +294,12 @@ void vtkScatterPlotMatrix::UpdateLayout()
// 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);
}
}
// Only show bottom axis label for bottom plots
if (j > 0)
......
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