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();
214 mMapper->SetInputData(
mData);
230 mMapper = vtkSmartPointer<vtkGlyph3DMapper>::New();
231 vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New();
232 mMapper->SetSourceConnection(arrowSource->GetOutputPort());
233 mMapper->ScalarVisibilityOn();
234 mMapper->SetUseLookupTableScalarRange(1);
235 mMapper->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);
236 mActor->SetMapper(mMapper);
246 mMapper->SetInputData(
mData);
251 mMapper->SetOrientationArray(orientationArray);
256 if(strlen(colorArray)>0)
263 mMapper->SelectColorArray(colorArray);
269 vtkSmartPointer<vtkColorSeries> colorSeries = vtkSmartPointer<vtkColorSeries>::New();
270 vtkSmartPointer<vtkLookupTable> table = vtkLookupTable::New();
271 colorSeries->SetColorSchemeByName(lut);
272 colorSeries->BuildLookupTable(table , vtkColorSeries::ORDINAL);
273 mMapper->SetLookupTable(table);
279 if(scaleFactor<=0)
return;
280 mMapper->SetScaleFactor(scaleFactor);
295 source = vtkSphereSourcePtr::New();
296 source->SetRadius(4);
301 source->SetThetaResolution(16);
302 source->SetPhiResolution(12);
303 source->LatLongTessellationOn();
306 normals->SetInputConnection(source->GetOutputPort());
309 mapper = vtkPolyDataMapperPtr::New();
310 mapper->SetInputConnection(normals->GetOutputPort());
312 actor = vtkActorPtr::New();
313 actor->SetMapper(mapper);
327 mRenderer->RemoveActor(actor);
330 mRenderer = renderer;
334 mRenderer->AddActor(actor);
340 source->SetRadius(radius);
350 actor->SetPosition(point.begin());
355 return Vector3D(actor->GetPosition());
365 return source->GetOutput();
374 mRenderer = renderer;
375 source = vtkLineSourcePtr::New();
376 mapper = vtkPolyDataMapperPtr::New() ;
377 actor = vtkActorPtr::New() ;
379 mapper->SetInputConnection( source->GetOutputPort() );
380 actor->SetMapper (mapper );
393 mRenderer->RemoveActor(actor);
396 mRenderer = renderer;
400 mRenderer->AddActor(actor);
411 source->SetPoint1(point1.begin());
412 source->SetPoint2(point2.begin());
417 actor->GetProperty()->SetLineStipplePattern(stipple);
431 mRenderer = renderer;
432 source = vtkArcSourcePtr::New();
433 source->SetResolution(20);
434 mapper = vtkPolyDataMapperPtr::New() ;
435 actor = vtkActorPtr::New() ;
437 mapper->SetInputConnection( source->GetOutputPort() );
438 actor->SetMapper (mapper );
440 mRenderer->AddActor(actor);
446 mRenderer->RemoveActor(actor);
456 source->SetPoint1(point1.begin());
457 source->SetPoint2(point2.begin());
458 source->SetCenter(center.begin());
463 actor->GetProperty()->SetLineStipplePattern(stipple);
477 mRenderer = renderer;
478 source = vtkArrowSourcePtr::New();
479 source->SetTipResolution(24);
480 source->SetShaftResolution(24);
481 mapper = vtkPolyDataMapperPtr::New() ;
482 actor = vtkActorPtr::New() ;
484 mapper->SetInputConnection( source->GetOutputPort() );
485 actor->SetMapper (mapper );
487 mRenderer->AddActor(actor);
493 mRenderer->RemoveActor(actor);
517 source->SetTipLength(0.35);
518 source->SetTipRadius(0.1*(length));
519 source->SetShaftRadius(0.03*(length));
520 actor->SetUserMatrix(M.getVtkMatrix());
529 mRenderer = renderer;
530 mapper = vtkPolyDataMapperPtr::New();
531 actor = vtkActorPtr::New();
533 actor->SetMapper(mapper);
535 mRenderer->AddActor(actor);
537 mPolyData = vtkPolyDataPtr::New();
538 mPoints = vtkPointsPtr::New();
539 mSide = vtkCellArrayPtr::New();
541 vtkIdType cells[5] = { 0,1,2,3,0 };
542 mSide->InsertNextCell(5, cells);
544 mPolyData->SetPoints(mPoints);
545 mapper->SetInputData(mPolyData);
552 mPolyData->SetLines(mSide);
553 actor->GetProperty()->SetLineWidth(width);
557 mPolyData->SetLines(NULL);
565 mPolyData->SetPolys(mSide);
566 actor->GetProperty()->SetOpacity(1.0);
570 mPolyData->SetPolys(NULL);
577 mRenderer->RemoveActor(actor);
587 mPoints = vtkPointsPtr::New();
588 mPoints->InsertPoint(0, M.coord(bb.
corner(0,0,0)).
begin());
589 mPoints->InsertPoint(1, M.coord(bb.
corner(0,1,0)).
begin());
590 mPoints->InsertPoint(2, M.coord(bb.
corner(1,1,0)).
begin());
591 mPoints->InsertPoint(3, M.coord(bb.
corner(1,0,0)).
begin());
592 mPolyData->SetPoints(mPoints);
601 mText = vtkVectorTextPtr::New();
603 mapper->SetInputConnection(mText->GetOutputPort());
604 mFollower = vtkFollowerPtr::New();
605 mFollower->SetMapper(mapper);
607 mFollower->SetScale(mTextScale.begin());
617 mRenderer->RemoveActor(mFollower);
618 mViewportListener->stopListen();
621 mRenderer = renderer;
625 mRenderer->AddActor(mFollower);
626 mFollower->SetCamera(mRenderer->GetActiveCamera());
627 if (mViewportListener)
628 mViewportListener->startListen(mRenderer);
635 mRenderer->RemoveActor(mFollower);
648 if (!mViewportListener)
656 mViewportListener.reset();
674 mFollower->SetPosition(pos.begin());
690 if (!mViewportListener || !mViewportListener->isListening())
696 double size = mViewportListener->getVpnZoom();
698 double scale = mSize/size;
700 Vector3D mTextScale(scale,scale,scale);
702 mFollower->SetScale(mTextScale.begin());
711 mText = vtkCaptionActor2DPtr::New();
715 mText->GetCaptionTextProperty()->BoldOff();
716 mText->GetCaptionTextProperty()->ItalicOff();
717 mText->GetCaptionTextProperty()->ShadowOff();
719 mText->SetHeight(0.03);
728 mRenderer->RemoveActor(mText);
731 mRenderer = renderer;
735 mRenderer->AddActor(mText);
742 mRenderer->RemoveActor(mText);
747 mText->SetHeight(val);
762 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)