35 #include "boost/bind.hpp"
36 #include <vtkSphereSource.h>
37 #include <vtkLineSource.h>
38 #include <vtkArcSource.h>
39 #include <vtkPolyDataMapper.h>
41 #include <vtkCellArray.h>
42 #include <vtkProperty.h>
43 #include <vtkRenderer.h>
44 #include <vtkCommand.h>
45 #include <vtkFollower.h>
46 #include <vtkVectorText.h>
47 #include <vtkCamera.h>
50 #include "vtkArrowSource.h"
51 #include "vtkMatrix4x4.h"
52 #include "vtkCaptionActor2D.h"
53 #include "vtkTextProperty.h"
55 #include "vtkPolyDataNormals.h"
64 mActor = vtkActorPtr::New();
97 mActor->SetVisibility(visible);
103 mActor->GetProperty()->SetBackfaceCulling(val);
108 mActor->GetProperty()->SetFrontfaceCulling(val);
113 mActor->GetProperty()->SetRepresentationToSurface();
118 mActor->GetProperty()->SetColor(red, green, blue);
123 mActor->GetProperty()->SetColor(color.begin());
128 mActor->SetPosition(point.begin());
133 mActor->GetProperty()->SetOpacity(val);
138 mActor->SetUserMatrix(matrix);
143 if(pointSize<=0)
return;
188 mMapper = vtkPolyDataMapperPtr::New();
189 mIsWireFrame =
false;
191 mActor->SetMapper(mMapper);
204 mActor->GetProperty()->SetRepresentationToWireframe();
206 mActor->GetProperty()->SetRepresentationToSurface();
215 mMapper->SetInputData(
mData);
231 mMapper = vtkSmartPointer<vtkGlyph3DMapper>::New();
232 vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New();
233 mMapper->SetSourceConnection(arrowSource->GetOutputPort());
234 mMapper->ScalarVisibilityOn();
235 mMapper->SetUseLookupTableScalarRange(1);
236 mMapper->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);
237 mActor->SetMapper(mMapper);
247 mMapper->SetInputData(
mData);
252 mMapper->SetOrientationArray(orientationArray);
257 if(strlen(colorArray)>0)
264 mMapper->SelectColorArray(colorArray);
270 vtkSmartPointer<vtkColorSeries> colorSeries = vtkSmartPointer<vtkColorSeries>::New();
271 vtkSmartPointer<vtkLookupTable> table = vtkLookupTable::New();
272 colorSeries->SetColorSchemeByName(lut);
273 colorSeries->BuildLookupTable(table , vtkColorSeries::ORDINAL);
274 mMapper->SetLookupTable(table);
280 if(scaleFactor<=0)
return;
281 mMapper->SetScaleFactor(scaleFactor);
296 source = vtkSphereSourcePtr::New();
297 source->SetRadius(4);
302 source->SetThetaResolution(16);
303 source->SetPhiResolution(12);
304 source->LatLongTessellationOn();
307 normals->SetInputConnection(source->GetOutputPort());
310 mapper = vtkPolyDataMapperPtr::New();
311 mapper->SetInputConnection(normals->GetOutputPort());
313 actor = vtkActorPtr::New();
314 actor->SetMapper(mapper);
328 mRenderer->RemoveActor(actor);
331 mRenderer = renderer;
335 mRenderer->AddActor(actor);
341 source->SetRadius(radius);
351 actor->SetPosition(point.begin());
356 return Vector3D(actor->GetPosition());
366 return source->GetOutput();
375 mRenderer = renderer;
376 source = vtkLineSourcePtr::New();
377 mapper = vtkPolyDataMapperPtr::New() ;
378 actor = vtkActorPtr::New() ;
380 mapper->SetInputConnection( source->GetOutputPort() );
381 actor->SetMapper (mapper );
394 mRenderer->RemoveActor(actor);
397 mRenderer = renderer;
401 mRenderer->AddActor(actor);
412 source->SetPoint1(point1.begin());
413 source->SetPoint2(point2.begin());
418 actor->GetProperty()->SetLineStipplePattern(stipple);
432 mRenderer = renderer;
433 source = vtkArcSourcePtr::New();
434 source->SetResolution(20);
435 mapper = vtkPolyDataMapperPtr::New() ;
436 actor = vtkActorPtr::New() ;
438 mapper->SetInputConnection( source->GetOutputPort() );
439 actor->SetMapper (mapper );
441 mRenderer->AddActor(actor);
447 mRenderer->RemoveActor(actor);
457 source->SetPoint1(point1.begin());
458 source->SetPoint2(point2.begin());
459 source->SetCenter(center.begin());
464 actor->GetProperty()->SetLineStipplePattern(stipple);
478 mRenderer = renderer;
479 source = vtkArrowSourcePtr::New();
480 source->SetTipResolution(24);
481 source->SetShaftResolution(24);
482 mapper = vtkPolyDataMapperPtr::New() ;
483 actor = vtkActorPtr::New() ;
485 mapper->SetInputConnection( source->GetOutputPort() );
486 actor->SetMapper (mapper );
488 mRenderer->AddActor(actor);
494 mRenderer->RemoveActor(actor);
518 source->SetTipLength(0.35);
519 source->SetTipRadius(0.1*(length));
520 source->SetShaftRadius(0.03*(length));
521 actor->SetUserMatrix(M.getVtkMatrix());
530 mRenderer = renderer;
531 mapper = vtkPolyDataMapperPtr::New();
532 actor = vtkActorPtr::New();
534 actor->SetMapper(mapper);
536 mRenderer->AddActor(actor);
538 mPolyData = vtkPolyDataPtr::New();
539 mPoints = vtkPointsPtr::New();
540 mSide = vtkCellArrayPtr::New();
542 vtkIdType cells[5] = { 0,1,2,3,0 };
543 mSide->InsertNextCell(5, cells);
545 mPolyData->SetPoints(mPoints);
546 mapper->SetInputData(mPolyData);
553 mPolyData->SetLines(mSide);
554 actor->GetProperty()->SetLineWidth(width);
558 mPolyData->SetLines(NULL);
566 mPolyData->SetPolys(mSide);
567 actor->GetProperty()->SetOpacity(1.0);
571 mPolyData->SetPolys(NULL);
578 mRenderer->RemoveActor(actor);
588 mPoints = vtkPointsPtr::New();
589 mPoints->InsertPoint(0, M.coord(bb.
corner(0,0,0)).
begin());
590 mPoints->InsertPoint(1, M.coord(bb.
corner(0,1,0)).
begin());
591 mPoints->InsertPoint(2, M.coord(bb.
corner(1,1,0)).
begin());
592 mPoints->InsertPoint(3, M.coord(bb.
corner(1,0,0)).
begin());
593 mPolyData->SetPoints(mPoints);
602 mText = vtkVectorTextPtr::New();
604 mapper->SetInputConnection(mText->GetOutputPort());
605 mFollower = vtkFollowerPtr::New();
606 mFollower->SetMapper(mapper);
608 mFollower->SetScale(mTextScale.begin());
618 mRenderer->RemoveActor(mFollower);
619 mViewportListener->stopListen();
622 mRenderer = renderer;
626 mRenderer->AddActor(mFollower);
627 mFollower->SetCamera(mRenderer->GetActiveCamera());
628 if (mViewportListener)
629 mViewportListener->startListen(mRenderer);
636 mRenderer->RemoveActor(mFollower);
649 if (!mViewportListener)
657 mViewportListener.reset();
675 mFollower->SetPosition(pos.begin());
691 if (!mViewportListener || !mViewportListener->isListening())
697 double size = mViewportListener->getVpnZoom();
699 double scale = mSize/size;
701 Vector3D mTextScale(scale,scale,scale);
703 mFollower->SetScale(mTextScale.begin());
712 mText = vtkCaptionActor2DPtr::New();
716 mText->GetCaptionTextProperty()->BoldOff();
717 mText->GetCaptionTextProperty()->ItalicOff();
718 mText->GetCaptionTextProperty()->ShadowOff();
720 mText->SetHeight(0.03);
729 mRenderer->RemoveActor(mText);
732 mRenderer = renderer;
736 mRenderer->AddActor(mText);
743 mRenderer->RemoveActor(mText);
748 mText->SetHeight(val);
763 mText->SetAttachmentPoint(pos.begin());
vtkPolyDataAlgorithmPtr getSource()
void setStipple(int stipple)
void setColor(QColor color)
vtkSmartPointer< class vtkActor > vtkActorPtr
Vector3D corner(int x, int y, int z) const
Vector3D getColorAsVector3D(QColor color)
virtual vtkMapperPtr getMapper()=0
PlainObject normal() const
void setScalarVisibility(bool show)
vtkSmartPointer< class vtkPolyDataMapper > vtkPolyDataMapperPtr
FollowerText3D(vtkRendererPtr renderer=vtkRendererPtr())
~GraphicalGeometricBase()
void setRenderer(vtkRendererPtr renderer=vtkRendererPtr())
Transform3D createTransformScale(const Vector3D &scale_)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
void setVisibility(bool visible)
GraphicalGeometricBase(vtkPolyDataAlgorithmPtr source=vtkPolyDataAlgorithmPtr(), vtkRendererPtr renderer=vtkRendererPtr())
void scaleText()
internal method
void setRenderer(vtkRendererPtr renderer=vtkRendererPtr())
void setColor(double red, double green, double blue)
cstring_cast_Placeholder cstring_cast(const T &val)
void setText(QString text)
void setUserMatrix(vtkMatrix4x4 *matrix)
void setValue(Vector3D base, Vector3D normal, double length)
void setBackfaceCulling(bool val)
void setColor(QColor color)
void setData(vtkPolyDataPtr data)
void setColor(QColor color)
bool similar(const DoubleBoundingBox3D &a, const DoubleBoundingBox3D &b, double tol)
Listens to changes in viewport and camera matrix.
Vector3D cross(const Vector3D &a, const Vector3D &b)
compute cross product of a and b.
void setLUT(const char *lut)
void setPosition(Vector3D pos)
GraphicalPoint3D(vtkRendererPtr renderer=vtkRendererPtr())
GraphicalGlyph3DData(vtkPolyDataAlgorithmPtr source=vtkPolyDataAlgorithmPtr(), vtkRendererPtr renderer=vtkRendererPtr())
void setRenderer(vtkRendererPtr renderer=vtkRendererPtr())
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
GraphicalArrow3D(vtkRendererPtr renderer=vtkRendererPtr())
void setPosition(Vector3D point)
Transform3D createTransformIJC(const Vector3D &ivec, const Vector3D &jvec, const Vector3D ¢er)
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
vtkSmartPointer< class vtkFollower > vtkFollowerPtr
void setOpacity(double val)
vtkSmartPointer< class vtkMapper > vtkMapperPtr
void setData(vtkPolyDataPtr data)
vtkPolyDataPtr getPolyData()
void setSizeInNormalizedViewport(bool on, double size)
void setLine(bool on, int width)
void setPosition(Vector3D pos)
void setText(QString text)
vtkSmartPointer< class vtkPolyDataNormals > vtkPolyDataNormalsPtr
Rect3D(vtkRendererPtr renderer, QColor color)
Vector3D getValue() const
void setValue(Vector3D point1, Vector3D point2)
void setRenderer(vtkRendererPtr renderer=vtkRendererPtr())
vtkSmartPointer< class vtkCaptionActor2D > vtkCaptionActor2DPtr
void setIsWireFrame(bool val)
void setColor(QColor color)
void setRenderer(vtkRendererPtr renderer=vtkRendererPtr())
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
void setColor(QColor color)
void setPointSize(int pointSize)
vtkFollowerPtr getActor()
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
GraphicalLine3D(vtkRendererPtr renderer=vtkRendererPtr())
void setRadius(double radius)
void setValue(Vector3D point1, Vector3D point2, Vector3D center)
CaptionText3D(vtkRendererPtr renderer=vtkRendererPtr())
GraphicalPolyData3D(vtkPolyDataAlgorithmPtr source=vtkPolyDataAlgorithmPtr(), vtkRendererPtr renderer=vtkRendererPtr())
vtkSmartPointer< class vtkPolyDataAlgorithm > vtkPolyDataAlgorithmPtr
void setOrientationArray(const char *orientationArray)
vtkPolyDataPtr getPolyData()
RealScalar length() const
vtkCaptionActor2DPtr getActor()
void setFrontfaceCulling(bool val)
void setColorArray(const char *colorArray)
void setSource(vtkPolyDataAlgorithmPtr source)
vtkPolyDataAlgorithmPtr mSource
void updatePosition(const DoubleBoundingBox3D bb, const Transform3D &M)
GraphicalArc3D(vtkRendererPtr renderer=vtkRendererPtr())
void setStipple(int stipple)
void setColor(QColor color)
void setScaleFactor(double scaleFactor)
void setColorAndOpacity(vtkPropertyPtr property, QColor color)
void setColor(QColor color)
Vector3D getPosition() const
void setValue(Vector3D point)