7 #include "PlusConfigure.h" 11 #include "vtkSmartPointer.h" 13 #include "vtkCaptionActor2D.h" 14 #include "vtkConeSource.h" 15 #include "vtkLineSource.h" 16 #include "vtkObject.h" 17 #include "vtkObjectFactory.h" 18 #include "vtkPolyData.h" 19 #include "vtkPolyDataMapper.h" 20 #include "vtkPropCollection.h" 21 #include "vtkProperty.h" 22 #include "vtkRenderer.h" 23 #include "vtkRenderWindow.h" 24 #include "vtkTextProperty.h" 25 #include "vtkTransform.h" 26 #include "vtkTextActor.h" 27 #include "vtkTubeFilter.h" 28 #include "vtkAppendPolyData.h" 38 vtkSmartPointer<vtkPolyDataMapper> mapper=vtkSmartPointer<vtkPolyDataMapper>::New();
51 vtkSmartPointer<vtkAppendPolyData> appendFilter = vtkSmartPointer<vtkAppendPolyData>::New();
52 appendFilter->AddInputConnection(this->
TubeFilter->GetOutputPort());
55 mapper->SetInputConnection(appendFilter->GetOutputPort());
63 vtkTextProperty* textprop = this->
LabelActor->GetTextActor()->GetTextProperty();
64 textprop->ItalicOff();
65 textprop->SetJustificationToLeft();
66 textprop->SetVerticalJustificationToCentered();
72 if (this->ArrowShaftActor)
74 this->ArrowShaftActor->Delete();
75 this->ArrowShaftActor=NULL;
80 this->TubeFilter->Delete();
81 this->TubeFilter=NULL;
84 if (this->ArrowShaftLineSource)
86 this->ArrowShaftLineSource->Delete();
87 this->ArrowShaftLineSource=NULL;
90 if (this->ArrowTipConeSource)
92 this->ArrowTipConeSource->Delete();
93 this->ArrowTipConeSource=NULL;
98 this->LabelActor->Delete();
99 this->LabelActor=NULL;
106 this->ArrowShaftActor->ReleaseGraphicsResources( win );
107 this->LabelActor->ReleaseGraphicsResources( win );
127 vtkTextProperty* textprop = this->
NameLabelActor->GetTextActor()->GetTextProperty();
128 textprop->ItalicOff();
129 textprop->SetJustificationToLeft();
130 textprop->SetVerticalJustificationToCentered();
151 ac->AddItem(this->
Axes[0].ArrowShaftActor);
152 ac->AddItem(this->
Axes[1].ArrowShaftActor);
153 ac->AddItem(this->
Axes[2].ArrowShaftActor);
157 ac->AddItem(this->
Axes[0].LabelActor);
158 ac->AddItem(this->
Axes[1].LabelActor);
159 ac->AddItem(this->
Axes[2].LabelActor);
171 int renderedSomething = 0;
181 renderedSomething += this->
Axes[0].
LabelActor->RenderOpaqueGeometry( vp );
182 renderedSomething += this->
Axes[1].
LabelActor->RenderOpaqueGeometry( vp );
183 renderedSomething += this->
Axes[2].
LabelActor->RenderOpaqueGeometry( vp );
188 renderedSomething += this->
NameLabelActor->RenderOpaqueGeometry( vp );
191 renderedSomething = (renderedSomething > 0)?(1):(0);
192 return renderedSomething;
198 int renderedSomething = 0;
202 renderedSomething += this->
Axes[0].
ArrowShaftActor->RenderTranslucentPolygonalGeometry( vp );
203 renderedSomething += this->
Axes[1].
ArrowShaftActor->RenderTranslucentPolygonalGeometry( vp );
204 renderedSomething += this->
Axes[2].
ArrowShaftActor->RenderTranslucentPolygonalGeometry( vp );
208 renderedSomething += this->
Axes[0].
LabelActor->RenderTranslucentPolygonalGeometry( vp );
209 renderedSomething += this->
Axes[1].
LabelActor->RenderTranslucentPolygonalGeometry( vp );
210 renderedSomething += this->
Axes[2].
LabelActor->RenderTranslucentPolygonalGeometry( vp );
215 renderedSomething += this->
NameLabelActor->RenderTranslucentPolygonalGeometry( vp );
218 renderedSomething = (renderedSomething > 0)?(1):(0);
219 return renderedSomething;
237 result |= this->
Axes[0].
LabelActor->HasTranslucentPolygonalGeometry();
238 result |= this->
Axes[1].
LabelActor->HasTranslucentPolygonalGeometry();
239 result |= this->
Axes[2].
LabelActor->HasTranslucentPolygonalGeometry();
244 result |= this->
NameLabelActor->HasTranslucentPolygonalGeometry();
253 int renderedSomething = 0;
259 renderedSomething += this->
Axes[0].
LabelActor->RenderOverlay( vp );
260 renderedSomething += this->
Axes[1].
LabelActor->RenderOverlay( vp );
261 renderedSomething += this->
Axes[2].
LabelActor->RenderOverlay( vp );
269 return (renderedSomething > 0)?(1):(0);
297 double thisActorsBounds[6]={0};
298 actor->GetBounds(thisActorsBounds);
299 for (
int i = 0;
i < 3; ++
i )
301 if (thisActorsBounds[2*
i]<bounds[2*
i])
303 bounds[2*
i] = thisActorsBounds[2*
i];
305 if (thisActorsBounds[2*
i+1]>bounds[2*
i+1])
307 bounds[2*
i+1] = thisActorsBounds[2*
i+1];
326 vtkMTimeType mTime = this->Superclass::GetMTime();
333 vtkMTimeType mTime = this->
GetMTime();
341 if ( vtkTransform::SafeDownCast(this->GetUserTransform())==NULL )
343 vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
344 this->SetUserTransform(transform);
346 vtkTransform* toolToWorldTransform=vtkTransform::SafeDownCast(this->GetUserTransform());
347 if (toolToWorldTransform==NULL)
349 LOG_ERROR(
"vtkPlusToolAxesActor UserTransform is invalid");
354 double origin_Tool[4]={0,0,0,1};
355 double origin_World[4]={0,0,0,1};
356 toolToWorldTransform->MultiplyPoint(origin_Tool,origin_World);
358 double shaftTip0_Tool[4]={this->
ShaftLength,0,0,1};
359 double shaftTip0_World[4]={0,0,0,1};
360 toolToWorldTransform->MultiplyPoint(shaftTip0_Tool,shaftTip0_World);
362 double shaftTip1_Tool[4]={0,this->
ShaftLength,0,1};
363 double shaftTip1_World[4]={0,0,0,1};
364 toolToWorldTransform->MultiplyPoint(shaftTip1_Tool,shaftTip1_World);
366 double shaftTip2_Tool[4]={0,0,this->
ShaftLength,1};
367 double shaftTip2_World[4]={0,0,0,1};
368 toolToWorldTransform->MultiplyPoint(shaftTip2_Tool,shaftTip2_World);
382 this->
Axes[0].
ArrowTipConeSource->SetDirection(shaftTip0_World[0]-origin_World[0], shaftTip0_World[1]-origin_World[1], shaftTip0_World[2]-origin_World[2]);
383 this->
Axes[1].
ArrowTipConeSource->SetDirection(shaftTip1_World[0]-origin_World[0], shaftTip1_World[1]-origin_World[1], shaftTip1_World[2]-origin_World[2]);
384 this->
Axes[2].
ArrowTipConeSource->SetDirection(shaftTip2_World[0]-origin_World[0], shaftTip2_World[1]-origin_World[1], shaftTip2_World[2]-origin_World[2]);
404 this->Superclass::PrintSelf(os,indent);
406 os << indent <<
"Name: " << this->
NameLabelActor->GetCaption() << endl;
407 os << indent <<
"ShaftLength: " << this->
ShaftLength << endl;