Commit 009e965c authored by Marcus Hanwell's avatar Marcus Hanwell
Browse files

ENH: Added DeepCopy to vtkPen, used in ApplyPen.

The Context2D has an ApplyPen member function that allows you to copy
your pen. The use of this new API is demonstrated in vtkPlotLine and
vtkPlotPoints. The plots can contain a vtkPen with their settings, and
apply this before painting.
parent debdfab0
......@@ -27,7 +27,7 @@
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
vtkCxxRevisionMacro(vtkContext2D, "1.15");
vtkCxxRevisionMacro(vtkContext2D, "1.16");
vtkCxxSetObjectMacro(vtkContext2D, Brush, vtkBrush);
vtkCxxSetObjectMacro(vtkContext2D, TextProp, vtkTextProperty);
......@@ -356,7 +356,7 @@ unsigned int vtkContext2D::AddPointSprite(vtkImageData *image)
//-----------------------------------------------------------------------------
void vtkContext2D::ApplyPen(vtkPen *pen)
{
this->Pen->DeepCopy(pen);
}
//-----------------------------------------------------------------------------
......
......@@ -19,7 +19,7 @@
#include "vtkVector.h"
//-----------------------------------------------------------------------------
vtkCxxRevisionMacro(vtkPen, "1.4");
vtkCxxRevisionMacro(vtkPen, "1.5");
//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkPen);
......@@ -143,6 +143,14 @@ unsigned char vtkPen::GetOpacity()
return this->Color[3];
}
//-----------------------------------------------------------------------------
void vtkPen::DeepCopy(vtkPen *pen)
{
*(this->PenColor) = *(pen->PenColor);
this->Width = pen->Width;
this->LineType = pen->LineType;
}
//-----------------------------------------------------------------------------
void vtkPen::PrintSelf(ostream &os, vtkIndent indent)
{
......
......@@ -121,6 +121,10 @@ public:
vtkSetMacro(Width, float);
vtkGetMacro(Width, float);
// Description:
// Make a deep copy of the supplied pen.
void DeepCopy(vtkPen *pen);
//BTX
protected:
vtkPen();
......
......@@ -29,7 +29,7 @@
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkPlotLine, "1.8");
vtkCxxRevisionMacro(vtkPlotLine, "1.9");
//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkPlotLine);
......@@ -83,8 +83,8 @@ bool vtkPlotLine::Paint(vtkContext2D *painter)
vtkDebugMacro(<<"Selection set " << this->Selection->GetNumberOfTuples());
for (int i = 0; i < this->Selection->GetNumberOfTuples(); ++i)
{
painter->ApplyPen(this->Pen);
painter->GetPen()->SetWidth(this->Pen->GetWidth()*15.0);
painter->GetPen()->SetColor(this->Pen->GetColor());
vtkIdType id = 0;
this->Selection->GetTupleValue(i, &id);
if (id < this->Points->GetNumberOfPoints())
......@@ -102,10 +102,7 @@ bool vtkPlotLine::Paint(vtkContext2D *painter)
// Now to plot the points
if (this->Points)
{
painter->GetPen()->SetColor(this->Pen->GetColor());
painter->GetPen()->SetOpacity(this->Pen->GetOpacity());
painter->GetPen()->SetWidth(this->Pen->GetWidth());
painter->GetPen()->SetLineType(this->Pen->GetLineType());
painter->ApplyPen(this->Pen);
painter->DrawPoly(this->Points);
painter->GetPen()->SetLineType(vtkPen::SOLID_LINE);
}
......
......@@ -30,7 +30,7 @@
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkPlotPoints, "1.3");
vtkCxxRevisionMacro(vtkPlotPoints, "1.4");
//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkPlotPoints);
......@@ -93,9 +93,7 @@ bool vtkPlotPoints::Paint(vtkContext2D *painter)
// Now to plot the points
if (this->Points)
{
painter->GetPen()->SetColor(this->Pen->GetColor());
painter->GetPen()->SetOpacity(this->Pen->GetOpacity());
painter->GetPen()->SetWidth(this->Pen->GetWidth());
painter->ApplyPen(this->Pen);
painter->DrawPoints(this->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