Commit ffd2444c authored by Gregory P. Johnson's avatar Gregory P. Johnson Committed by Marcus D. Hanwell

Render stacked plots as separate colors in legend

Modified a test to verify functionality, and fixed the PaintLegend
method to use the appropriate color for the separate series in the
stacked plot.

Change-Id: I2d38aaa93b33e329736266bcbb90b44b273f49e7
parent 0acca442
......@@ -105,6 +105,8 @@ int TestStackedPlot(int , char * [])
chart->GetAxis(1)->SetRange(0, 11);
chart->GetAxis(1)->SetBehavior(vtkAxis::FIXED);
chart->SetShowLegend(true);
// Add multiple line plots, setting the colors etc
vtkPlotStacked *stack = 0;
......
......@@ -32,6 +32,7 @@
#include "vtkObjectFactory.h"
#include "vtkColorSeries.h"
#include "vtkSmartPointer.h"
#include "vtkNew.h"
#include <vector>
#include <algorithm>
......@@ -658,10 +659,22 @@ bool vtkPlotStacked::Paint(vtkContext2D *painter)
//-----------------------------------------------------------------------------
bool vtkPlotStacked::PaintLegend(vtkContext2D *painter, const vtkRectf& rect,
int)
int legendIndex)
{
painter->ApplyPen(this->Pen);
painter->ApplyBrush(this->Brush);
if (this->ColorSeries)
{
vtkNew<vtkPen> pen;
vtkNew<vtkBrush> brush;
pen->SetColor(this->ColorSeries->GetColorRepeating(legendIndex).GetData());
brush->SetColor(pen->GetColor());
painter->ApplyPen(pen.GetPointer());
painter->ApplyBrush(brush.GetPointer());
}
else
{
painter->ApplyPen(this->Pen);
painter->ApplyBrush(this->Brush);
}
painter->DrawRect(rect[0], rect[1], rect[2], rect[3]);
return true;
}
......
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