Commit b025350e authored by Marcus D. Hanwell's avatar Marcus D. Hanwell
Browse files

ENH: Just fill the lower triangle with charts.

Still need to get the histograms in the diagonal, and handle layout
issues. Also handled the case where the input is being set to null. This
may require some special handling to remove all charts.

Change-Id: Ie5c71cd730fe7fe08432c0f861a35824a3d59f1b
parent ee2b08d0
......@@ -36,21 +36,21 @@ int TestScatterPlotMatrix(int, char * [])
// Create a table with some points in it...
vtkNew<vtkTable> table;
vtkNew<vtkFloatArray> arrX;
arrX->SetName("X Axis");
arrX->SetName("x");
table->AddColumn(arrX.GetPointer());
vtkNew<vtkFloatArray> arrC;
arrC->SetName("Cosine");
arrC->SetName("cos(x)");
table->AddColumn(arrC.GetPointer());
vtkNew<vtkFloatArray> arrS;
arrS->SetName("Sine");
arrS->SetName("sin(x)");
table->AddColumn(arrS.GetPointer());
vtkNew<vtkFloatArray> arrS2;
arrS2->SetName("Sine2");
arrS2->SetName("sin(x + 0.5)");
table->AddColumn(arrS2.GetPointer());
vtkNew<vtkFloatArray> tangent;
tangent->SetName("Tangent");
tangent->SetName("tan(x)");
table->AddColumn(tangent.GetPointer());
// Test charting with a few more points...
// Test the chart scatter plot matrix
int numPoints = 42;
float inc = 7.5 / (numPoints-1);
table->SetNumberOfRows(numPoints);
......@@ -63,6 +63,7 @@ int TestScatterPlotMatrix(int, char * [])
table->SetValue(i, 4, tan(i * inc));
}
// Set the scatter plot matrix up to analyze all columns in the table.
matrix->SetInput(table.GetPointer());
//Finally render the scene and compare the image to a reference image
......
......@@ -51,12 +51,19 @@ void vtkScatterPlotMatrix::SetInput(vtkTable *table)
{
if (this->Input != table)
{
// Set the input, then update the size of the scatter plot matrix, set their
// inputs and all the other stuff needed.
// Set the input, then update the size of the scatter plot matrix, set
// their inputs and all the other stuff needed.
this->Input = table;
this->Modified();
if (table == NULL)
{
this->SetSize(vtkVector2i(0, 0));
return;
}
this->SetSize(vtkVector2i(this->Input->GetNumberOfColumns(),
this->Input->GetNumberOfColumns()));
int n = static_cast<int>(this->Input->GetNumberOfColumns());
this->SetSize(vtkVector2i(n, n));
// We want scatter plots on the lower-left triangle, then histograms along
// the diagonal and a big plot in the top-right. The basic layout is,
//
......@@ -68,15 +75,21 @@ void vtkScatterPlotMatrix::SetInput(vtkTable *table)
//
// Where the indices are those of the columns. The indices of the charts
// originate in the bottom-left.
for (int i = 0; i < this->Size.X(); ++i)
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < this->Size.Y(); ++j)
for (int j = 0; j < n; ++j)
{
vtkVector2i pos(i, j);
if (this->Size.X() - j > 0)
if (i + j + 1 < n)
{
vtkPlot *plot = this->GetChart(pos)->AddPlot(vtkChart::POINTS);
plot->SetInput(table, i, this->Size.X() - j - 1);
plot->SetInput(table, i, n - j - 1);
}
else if (i == n - j - 1)
{
// We are on the diagonal - need a histogram plot.
vtkPlot *plot = this->GetChart(pos)->AddPlot(vtkChart::LINE);
plot->SetInput(table, i, n - j - 1);
}
// Only show bottom axis label for bottom plots
if (j > 0)
......@@ -85,6 +98,11 @@ void vtkScatterPlotMatrix::SetInput(vtkTable *table)
axis->SetTitle("");
axis->SetLabelsVisible(false);
}
else
{
vtkAxis *axis = this->GetChart(pos)->GetAxis(vtkAxis::BOTTOM);
axis->SetTitle(table->GetColumnName(i));
}
// Only show the left axis labels for left-most plots
if (i > 0)
{
......@@ -92,10 +110,13 @@ void vtkScatterPlotMatrix::SetInput(vtkTable *table)
axis->SetTitle("");
axis->SetLabelsVisible(false);
}
else
{
vtkAxis *axis = this->GetChart(pos)->GetAxis(vtkAxis::LEFT);
axis->SetTitle(table->GetColumnName(n - j - 1));
}
}
}
this->Modified();
}
}
......
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