14 #include "boost/bind.hpp"
15 #include <vtkSphereSource.h>
16 #include <vtkLineSource.h>
17 #include <vtkArcSource.h>
18 #include <vtkPolyDataMapper.h>
20 #include <vtkCellArray.h>
21 #include <vtkProperty.h>
22 #include <vtkRenderer.h>
23 #include <vtkCommand.h>
24 #include <vtkFollower.h>
25 #include <vtkVectorText.h>
26 #include <vtkCamera.h>
29 #include "vtkArrowSource.h"
30 #include "vtkMatrix4x4.h"
31 #include "vtkCaptionActor2D.h"
32 #include "vtkTextProperty.h"
34 #include "vtkPolyDataNormals.h"
43 mActor = vtkActorPtr::New();
76 mActor->SetVisibility(visible);
82 mActor->GetProperty()->SetBackfaceCulling(val);
87 mActor->GetProperty()->SetFrontfaceCulling(val);
92 mActor->GetProperty()->SetColor(red, green, blue);
97 mActor->GetProperty()->SetColor(color.begin());
102 mActor->SetPosition(point.begin());
107 mActor->GetProperty()->SetOpacity(val);
112 mActor->SetUserMatrix(matrix);
129 getMapper()->SetScalarModeToUseCellData();
167 mMapper = vtkPolyDataMapperPtr::New();
169 mActor->SetMapper(mMapper);
176 mActor->GetProperty()->SetRepresentationToWireframe();
184 mMapper->SetInputData(
mData);
189 mActor->SetTexture(texture);
205 mMapper = vtkSmartPointer<vtkGlyph3DMapper>::New();
206 vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New();
207 mMapper->SetSourceConnection(arrowSource->GetOutputPort());
208 mMapper->ScalarVisibilityOn();
209 mMapper->SetUseLookupTableScalarRange(1);
210 mMapper->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);
211 mActor->SetMapper(mMapper);
221 mMapper->SetInputData(
mData);
226 mMapper->SetOrientationArray(orientationArray);
231 if(strlen(colorArray)>0)
238 mMapper->SelectColorArray(colorArray);
244 vtkSmartPointer<vtkColorSeries> colorSeries = vtkSmartPointer<vtkColorSeries>::New();
245 vtkSmartPointer<vtkLookupTable> table = vtkLookupTable::New();
246 colorSeries->SetColorSchemeByName(lut);
247 colorSeries->BuildLookupTable(table , vtkColorSeries::ORDINAL);
248 mMapper->SetLookupTable(table);
254 if(scaleFactor<=0)
return;
255 mMapper->SetScaleFactor(scaleFactor);
270 source = vtkSphereSourcePtr::New();
271 source->SetRadius(4);
276 source->SetThetaResolution(16);
277 source->SetPhiResolution(12);
278 source->LatLongTessellationOn();
281 normals->SetInputConnection(source->GetOutputPort());
284 mapper = vtkPolyDataMapperPtr::New();
285 mapper->SetInputConnection(normals->GetOutputPort());
287 actor = vtkActorPtr::New();
288 actor->SetMapper(mapper);
302 mRenderer->RemoveActor(actor);
305 mRenderer = renderer;
309 mRenderer->AddActor(actor);
315 source->SetRadius(radius);
325 actor->SetPosition(point.begin());
330 return Vector3D(actor->GetPosition());
340 return source->GetOutput();
349 mRenderer = renderer;
350 source = vtkLineSourcePtr::New();
351 mapper = vtkPolyDataMapperPtr::New() ;
352 actor = vtkActorPtr::New() ;
354 mapper->SetInputConnection( source->GetOutputPort() );
355 actor->SetMapper (mapper );
368 mRenderer->RemoveActor(actor);
371 mRenderer = renderer;
375 mRenderer->AddActor(actor);
386 source->SetPoint1(point1.begin());
387 source->SetPoint2(point2.begin());
392 actor->GetProperty()->SetLineStipplePattern(stipple);
406 mRenderer = renderer;
407 source = vtkArcSourcePtr::New();
408 source->SetResolution(20);
409 mapper = vtkPolyDataMapperPtr::New() ;
410 actor = vtkActorPtr::New() ;
412 mapper->SetInputConnection( source->GetOutputPort() );
413 actor->SetMapper (mapper );
415 mRenderer->AddActor(actor);
421 mRenderer->RemoveActor(actor);
431 source->SetPoint1(point1.begin());
432 source->SetPoint2(point2.begin());
433 source->SetCenter(center.begin());
438 actor->GetProperty()->SetLineStipplePattern(stipple);
452 mRenderer = renderer;
453 source = vtkArrowSourcePtr::New();
454 source->SetTipResolution(24);
455 source->SetShaftResolution(24);
456 mapper = vtkPolyDataMapperPtr::New() ;
457 actor = vtkActorPtr::New() ;
459 mapper->SetInputConnection( source->GetOutputPort() );
460 actor->SetMapper (mapper );
462 mRenderer->AddActor(actor);
468 mRenderer->RemoveActor(actor);
492 source->SetTipLength(0.35);
493 source->SetTipRadius(0.1*(
length));
494 source->SetShaftRadius(0.03*(
length));
495 actor->SetUserMatrix(M.getVtkMatrix());
504 mRenderer = renderer;
505 mapper = vtkPolyDataMapperPtr::New();
506 actor = vtkActorPtr::New();
508 actor->SetMapper(mapper);
510 mRenderer->AddActor(actor);
512 mPolyData = vtkPolyDataPtr::New();
513 mPoints = vtkPointsPtr::New();
514 mSide = vtkCellArrayPtr::New();
516 vtkIdType cells[5] = { 0,1,2,3,0 };
517 mSide->InsertNextCell(5, cells);
519 mPolyData->SetPoints(mPoints);
520 mapper->SetInputData(mPolyData);
527 mPolyData->SetLines(mSide);
528 actor->GetProperty()->SetLineWidth(width);
532 mPolyData->SetLines(NULL);
540 mPolyData->SetPolys(mSide);
541 actor->GetProperty()->SetOpacity(1.0);
545 mPolyData->SetPolys(NULL);
552 mRenderer->RemoveActor(actor);
562 mPoints = vtkPointsPtr::New();
563 mPoints->InsertPoint(0, M.coord(bb.
corner(0,0,0)).begin());
564 mPoints->InsertPoint(1, M.coord(bb.
corner(0,1,0)).begin());
565 mPoints->InsertPoint(2, M.coord(bb.
corner(1,1,0)).begin());
566 mPoints->InsertPoint(3, M.coord(bb.
corner(1,0,0)).begin());
567 mPolyData->SetPoints(mPoints);
576 mText = vtkVectorTextPtr::New();
578 mapper->SetInputConnection(mText->GetOutputPort());
579 mFollower = vtkFollowerPtr::New();
580 mFollower->SetMapper(mapper);
582 mFollower->SetScale(mTextScale.begin());
592 mRenderer->RemoveActor(mFollower);
593 mViewportListener->stopListen();
596 mRenderer = renderer;
600 mRenderer->AddActor(mFollower);
601 mFollower->SetCamera(mRenderer->GetActiveCamera());
602 if (mViewportListener)
603 mViewportListener->startListen(mRenderer);
610 mRenderer->RemoveActor(mFollower);
623 if (!mViewportListener)
631 mViewportListener.reset();
649 mFollower->SetPosition(pos.begin());
665 if (!mViewportListener || !mViewportListener->isListening())
671 double size = mViewportListener->getVpnZoom(
Vector3D(mFollower->GetPosition()));
673 double scale = mSize/size;
675 Vector3D mTextScale(scale,scale,scale);
677 mFollower->SetScale(mTextScale.begin());
686 mText = vtkCaptionActor2DPtr::New();
690 mText->GetCaptionTextProperty()->BoldOff();
691 mText->GetCaptionTextProperty()->ItalicOff();
692 mText->GetCaptionTextProperty()->ShadowOff();
694 mText->SetHeight(0.03);
701 mText->SetPosition(-15, -30);
702 mText->SetPosition2(15, -10);
707 mText->SetPosition(-15, 2);
712 mText->SetVisibility(visible);
719 mRenderer->RemoveActor(mText);
722 mRenderer = renderer;
726 mRenderer->AddActor(mText);
733 mRenderer->RemoveActor(mText);
738 mText->SetHeight(val);
754 mText->SetAttachmentPoint(pos.begin());