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);
315 source->SetRadius(radius);
325 actor->SetPosition(point.begin());
330 return Vector3D(actor->GetPosition());
340 return source->GetOutput();
350 source = vtkLineSourcePtr::New();
351 mapper = vtkPolyDataMapperPtr::New() ;
352 actor = vtkActorPtr::New() ;
354 mapper->SetInputConnection( source->GetOutputPort() );
355 actor->SetMapper (mapper );
386 source->SetPoint1(point1.begin());
387 source->SetPoint2(point2.begin());
392 actor->GetProperty()->SetLineStipplePattern(stipple);
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 );
431 source->SetPoint1(point1.begin());
432 source->SetPoint2(point2.begin());
433 source->SetCenter(center.begin());
438 actor->GetProperty()->SetLineStipplePattern(stipple);
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 );
492 source->SetTipLength(0.35);
493 source->SetTipRadius(0.1*(length));
494 source->SetShaftRadius(0.03*(length));
495 actor->SetUserMatrix(M.getVtkMatrix());
505 mapper = vtkPolyDataMapperPtr::New();
506 actor = vtkActorPtr::New();
508 actor->SetMapper(mapper);
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);
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());
584 this->setSizeInNormalizedViewport(
true, 0.025);
593 mViewportListener->stopListen();
601 mFollower->SetCamera(
mRenderer->GetActiveCamera());
602 if (mViewportListener)
603 mViewportListener->startListen(
mRenderer);
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);
738 mText->SetHeight(val);
754 mText->SetAttachmentPoint(pos.begin());
void setRenderer(vtkRendererPtr renderer=vtkRendererPtr())
void setScaleFactor(double scaleFactor)
vtkSmartPointer< class vtkTexture > vtkTexturePtr
void setValue(Vector3D point1, Vector3D point2, Vector3D center)
void setPointSize(int pointSize)
CaptionText3D(vtkRendererPtr renderer=vtkRendererPtr())
GraphicalGlyph3DData(vtkPolyDataAlgorithmPtr source=vtkPolyDataAlgorithmPtr(), vtkRendererPtr renderer=vtkRendererPtr())
vtkSmartPointer< class vtkActor > vtkActorPtr
vtkPropertyPtr getProperty()
void setRenderer(vtkRendererPtr renderer=vtkRendererPtr())
Vector3D corner(int x, int y, int z) const
void setRenderer(vtkRendererPtr renderer=vtkRendererPtr())
Vector3D getColorAsVector3D(QColor color)
PlainObject normal() const
void setData(vtkPolyDataPtr data)
void setPosition(Vector3D point)
vtkSmartPointer< class vtkPolyDataMapper > vtkPolyDataMapperPtr
void setValue(Vector3D point)
Vector3D getPosition() const
GraphicalPoint3D(vtkRendererPtr renderer=vtkRendererPtr())
vtkCaptionActor2DPtr getActor()
Transform3D createTransformScale(const Vector3D &scale_)
vtkSmartPointer< class vtkProperty > vtkPropertyPtr
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
void setIsWireFrame(bool val)
void setOrientationArray(const char *orientationArray)
void setPosition(Vector3D pos)
void setColor(QColor color)
void setText(QString text)
GraphicalArc3D(vtkRendererPtr renderer=vtkRendererPtr())
Vector3D getPosition() const
void setColor(QColor color)
cstring_cast_Placeholder cstring_cast(const T &val)
Vector3D getValue() const
void setOpacity(double val)
virtual vtkMapperPtr getMapper()=0
Rect3D(vtkRendererPtr renderer, QColor color)
vtkFollowerPtr getActor()
void setColorArray(const char *colorArray)
void setScalarVisibility(bool show)
GraphicalLine3D(vtkRendererPtr renderer=vtkRendererPtr())
void setData(vtkPolyDataPtr data)
Listens to changes in viewport and camera matrix.
Vector3D cross(const Vector3D &a, const Vector3D &b)
compute cross product of a and b.
void setStipple(int stipple)
GraphicalGeometricBase(vtkPolyDataAlgorithmPtr source=vtkPolyDataAlgorithmPtr(), vtkRendererPtr renderer=vtkRendererPtr())
void setScalarModeToUseCellData()
void setRenderer(vtkRendererPtr renderer=vtkRendererPtr())
void setTexture(vtkTexturePtr texture)
Transform3D createTransformIJC(const Vector3D &ivec, const Vector3D &jvec, const Vector3D ¢er)
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
vtkSmartPointer< class vtkFollower > vtkFollowerPtr
void setColor(double red, double green, double blue)
void scaleText()
internal method
vtkSmartPointer< class vtkMapper > vtkMapperPtr
void setPosition(Vector3D pos)
vtkPolyDataPtr getPolyData()
void setLine(bool on, int width)
GraphicalPolyData3D(vtkPolyDataAlgorithmPtr source=vtkPolyDataAlgorithmPtr(), vtkRendererPtr renderer=vtkRendererPtr())
vtkSmartPointer< class vtkPolyDataNormals > vtkPolyDataNormalsPtr
FollowerText3D(vtkRendererPtr renderer=vtkRendererPtr())
void setRenderer(vtkRendererPtr renderer=vtkRendererPtr())
void setColor(QColor color)
void setUserMatrix(vtkMatrix4x4 *matrix)
vtkSmartPointer< class vtkCaptionActor2D > vtkCaptionActor2DPtr
void setColor(QColor color)
void setBackfaceCulling(bool val)
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 setSizeInNormalizedViewport(bool on, double size)
vtkPolyDataAlgorithmPtr getSource()
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
void updatePosition(const DoubleBoundingBox3D bb, const Transform3D &M)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
void setFrontfaceCulling(bool val)
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
vtkSmartPointer< class vtkPolyDataAlgorithm > vtkPolyDataAlgorithmPtr
vtkPolyDataPtr getPolyData()
RealScalar length() const
void setVisibility(bool visible)
void setSource(vtkPolyDataAlgorithmPtr source)
void setStipple(int stipple)
void setColor(QColor color)
void setValue(Vector3D base, Vector3D normal, double length)
GraphicalArrow3D(vtkRendererPtr renderer=vtkRendererPtr())
void setRadius(double radius)
void setVisibility(bool visible)
void setLUT(const char *lut)
void setColor(QColor color)
void setColor(QColor color)
void setText(QString text)
vtkPolyDataAlgorithmPtr mSource
void setValue(Vector3D point1, Vector3D point2)
void setColorAndOpacity(vtkPropertyOrProperty2DPtr property, QColor color)
~GraphicalGeometricBase()
Namespace for all CustusX production code.