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);
162 mMapper = vtkPolyDataMapperPtr::New();
164 mActor->SetMapper(mMapper);
171 mActor->GetProperty()->SetRepresentationToWireframe();
179 mMapper->SetInputData(
mData);
184 mActor->SetTexture(texture);
200 mMapper = vtkSmartPointer<vtkGlyph3DMapper>::New();
201 vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New();
202 mMapper->SetSourceConnection(arrowSource->GetOutputPort());
203 mMapper->ScalarVisibilityOn();
204 mMapper->SetUseLookupTableScalarRange(1);
205 mMapper->SetScalarMode(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA);
206 mActor->SetMapper(mMapper);
216 mMapper->SetInputData(
mData);
221 mMapper->SetOrientationArray(orientationArray);
226 if(strlen(colorArray)>0)
233 mMapper->SelectColorArray(colorArray);
239 vtkSmartPointer<vtkColorSeries> colorSeries = vtkSmartPointer<vtkColorSeries>::New();
240 vtkSmartPointer<vtkLookupTable> table = vtkLookupTable::New();
241 colorSeries->SetColorSchemeByName(lut);
242 colorSeries->BuildLookupTable(table , vtkColorSeries::ORDINAL);
243 mMapper->SetLookupTable(table);
249 if(scaleFactor<=0)
return;
250 mMapper->SetScaleFactor(scaleFactor);
265 source = vtkSphereSourcePtr::New();
266 source->SetRadius(4);
271 source->SetThetaResolution(16);
272 source->SetPhiResolution(12);
273 source->LatLongTessellationOn();
276 normals->SetInputConnection(source->GetOutputPort());
279 mapper = vtkPolyDataMapperPtr::New();
280 mapper->SetInputConnection(normals->GetOutputPort());
282 actor = vtkActorPtr::New();
283 actor->SetMapper(mapper);
310 source->SetRadius(radius);
320 actor->SetPosition(point.begin());
325 return Vector3D(actor->GetPosition());
335 return source->GetOutput();
345 source = vtkLineSourcePtr::New();
346 mapper = vtkPolyDataMapperPtr::New() ;
347 actor = vtkActorPtr::New() ;
349 mapper->SetInputConnection( source->GetOutputPort() );
350 actor->SetMapper (mapper );
381 source->SetPoint1(point1.begin());
382 source->SetPoint2(point2.begin());
387 actor->GetProperty()->SetLineStipplePattern(stipple);
402 source = vtkArcSourcePtr::New();
403 source->SetResolution(20);
404 mapper = vtkPolyDataMapperPtr::New() ;
405 actor = vtkActorPtr::New() ;
407 mapper->SetInputConnection( source->GetOutputPort() );
408 actor->SetMapper (mapper );
426 source->SetPoint1(point1.begin());
427 source->SetPoint2(point2.begin());
428 source->SetCenter(center.begin());
433 actor->GetProperty()->SetLineStipplePattern(stipple);
448 source = vtkArrowSourcePtr::New();
449 source->SetTipResolution(24);
450 source->SetShaftResolution(24);
451 mapper = vtkPolyDataMapperPtr::New() ;
452 actor = vtkActorPtr::New() ;
454 mapper->SetInputConnection( source->GetOutputPort() );
455 actor->SetMapper (mapper );
487 source->SetTipLength(0.35);
488 source->SetTipRadius(0.1*(length));
489 source->SetShaftRadius(0.03*(length));
490 actor->SetUserMatrix(M.getVtkMatrix());
500 mapper = vtkPolyDataMapperPtr::New();
501 actor = vtkActorPtr::New();
503 actor->SetMapper(mapper);
507 mPolyData = vtkPolyDataPtr::New();
508 mPoints = vtkPointsPtr::New();
509 mSide = vtkCellArrayPtr::New();
511 vtkIdType cells[5] = { 0,1,2,3,0 };
512 mSide->InsertNextCell(5, cells);
514 mPolyData->SetPoints(mPoints);
515 mapper->SetInputData(mPolyData);
522 mPolyData->SetLines(mSide);
523 actor->GetProperty()->SetLineWidth(width);
527 mPolyData->SetLines(NULL);
535 mPolyData->SetPolys(mSide);
536 actor->GetProperty()->SetOpacity(1.0);
540 mPolyData->SetPolys(NULL);
557 mPoints = vtkPointsPtr::New();
558 mPoints->InsertPoint(0, M.coord(bb.
corner(0,0,0)).
begin());
559 mPoints->InsertPoint(1, M.coord(bb.
corner(0,1,0)).
begin());
560 mPoints->InsertPoint(2, M.coord(bb.
corner(1,1,0)).
begin());
561 mPoints->InsertPoint(3, M.coord(bb.
corner(1,0,0)).
begin());
562 mPolyData->SetPoints(mPoints);
571 mText = vtkVectorTextPtr::New();
573 mapper->SetInputConnection(mText->GetOutputPort());
574 mFollower = vtkFollowerPtr::New();
575 mFollower->SetMapper(mapper);
577 mFollower->SetScale(mTextScale.begin());
579 this->setSizeInNormalizedViewport(
true, 0.025);
588 mViewportListener->stopListen();
596 mFollower->SetCamera(
mRenderer->GetActiveCamera());
597 if (mViewportListener)
598 mViewportListener->startListen(
mRenderer);
618 if (!mViewportListener)
626 mViewportListener.reset();
644 mFollower->SetPosition(pos.begin());
660 if (!mViewportListener || !mViewportListener->isListening())
666 double size = mViewportListener->getVpnZoom(
Vector3D(mFollower->GetPosition()));
668 double scale = mSize/size;
670 Vector3D mTextScale(scale,scale,scale);
672 mFollower->SetScale(mTextScale.begin());
681 mText = vtkCaptionActor2DPtr::New();
685 mText->GetCaptionTextProperty()->BoldOff();
686 mText->GetCaptionTextProperty()->ItalicOff();
687 mText->GetCaptionTextProperty()->ShadowOff();
689 mText->SetHeight(0.03);
696 mText->SetPosition(-15, -30);
697 mText->SetPosition2(15, -10);
702 mText->SetPosition(-15, 2);
707 mText->SetVisibility(visible);
733 mText->SetHeight(val);
749 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 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.