Commit 48bfc231 authored by Purves, Murray's avatar Purves, Murray
Browse files

#20 WIP Initial working with nicer look/feel

parent 0a7432f3
Pipeline #15627 passed with stages
in 10 minutes and 46 seconds
......@@ -226,25 +226,7 @@ bool vtkPlotPointsErrorBars::Paint(vtkContext2D *painter)
// Draw lines for error bars (if needed)
if (this->PlotErrorBars)
{
float *data = static_cast<float *>(this->Points->GetVoidPointer(0));
for (int i = 0; i < this->Points->GetNumberOfPoints(); ++i)
{
float thisX = data[2 * i], thisY = data[2 * i + 1];
if (XErrors && XErrors->GetNumberOfValues() > i)
{
painter->DrawLine(thisX, thisY, thisX - XErrors->GetValue(i),
thisY);
painter->DrawLine(thisX, thisY, thisX + XErrors->GetValue(i),
thisY);
}
if (YErrors && YErrors->GetNumberOfValues() > i)
{
painter->DrawLine(thisX, thisY, thisX,
thisY - YErrors->GetValue(i));
painter->DrawLine(thisX, thisY, thisX,
thisY + YErrors->GetValue(i));
}
}
// TODO: Fill this in
}
// Draw markers for points
......@@ -262,25 +244,47 @@ bool vtkPlotPointsErrorBars::Paint(vtkContext2D *painter)
// Draw lines for error bars (if needed)
if (this->PlotErrorBars)
{
float *data = static_cast<float *>(this->Points->GetVoidPointer(0));
// Set temporary pen to use for error bars
vtkNew<vtkPen> oldPen;
oldPen->SetColor(painter->GetPen()->GetColor());
oldPen->SetWidth(painter->GetPen()->GetWidth());
oldPen->SetLineType(painter->GetPen()->GetLineType());
oldPen->SetOpacity(painter->GetPen()->GetOpacity());
vtkNew<vtkPen> errorPen;
errorPen->SetColor(0.0, 0.0, 0.0);
errorPen->SetWidth(1.0);
painter->ApplyPen(errorPen);
for (int i = 0; i < this->Points->GetNumberOfPoints(); ++i)
{
float thisX = data[2 * i], thisY = data[2 * i + 1];
float thisX = points[2 * i], thisY = points[2 * i + 1];
float size = this->GetWidth() / 100.0;
if (XErrors && XErrors->GetNumberOfValues() > i)
{
painter->DrawLine(thisX, thisY, thisX - XErrors->GetValue(i),
thisY);
painter->DrawLine(thisX, thisY, thisX + XErrors->GetValue(i),
thisY);
float thisError = XErrors->GetValue(i);
painter->DrawLine(thisX, thisY, thisX - thisError, thisY);
painter->DrawLine(thisX - thisError, thisY - size,
thisX - thisError, thisY + size);
painter->DrawLine(thisX, thisY, thisX + thisError, thisY);
painter->DrawLine(thisX + thisError, thisY - size,
thisX + thisError, thisY + size);
}
if (YErrors && YErrors->GetNumberOfValues() > i)
{
painter->DrawLine(thisX, thisY, thisX,
thisY - YErrors->GetValue(i));
painter->DrawLine(thisX, thisY, thisX,
thisY + YErrors->GetValue(i));
float thisError = YErrors->GetValue(i);
painter->DrawLine(thisX, thisY, thisX, thisY - thisError);
painter->DrawLine(thisX - size, thisY - thisError, thisX + size,
thisY - thisError);
painter->DrawLine(thisX, thisY, thisX, thisY + thisError);
painter->DrawLine(thisX - size, thisY + thisError, thisX + size,
thisY + thisError);
}
}
// Reset pen
painter->ApplyPen(oldPen);
}
// Draw markers for points
......
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