15 #include "boost/bind.hpp" 17 #include <vtkProperty.h> 18 #include <vtkPolyDataMapper.h> 19 #include <vtkPolyDataNormals.h> 20 #include <vtkMatrix4x4.h> 21 #include <vtkRenderer.h> 22 #include <vtkRibbonFilter.h> 35 mPolyDataMapper = vtkPolyDataMapperPtr::New();
36 mProperty = vtkPropertyPtr::New();
40 mActor = vtkActorPtr::New();
42 mActor->SetMapper(mPolyDataMapper);
43 mActor->SetProperty(mProperty);
57 return "FiberBundleRep";
68 std::cout <<
"New fiber bundle assigned" << std::endl;
72 disconnect(mBundle.get(), SIGNAL(transformChanged()),
this, SLOT(bundleTransformChanged()));
73 disconnect(mBundle.get(), SIGNAL(meshChanged()),
this, SLOT(bundleChanged()));
80 connect(mBundle.get(), SIGNAL(transformChanged()),
this, SLOT(bundleTransformChanged()));
81 connect(mBundle.get(), SIGNAL(meshChanged()),
this, SLOT(bundleChanged()));
85 this->bundleTransformChanged();
93 view->getRenderer()->AddActor(mActor);
95 if (mViewportListener)
96 mViewportListener->startListen(view->getRenderer());
104 view->getRenderer()->RemoveActor(mActor);
106 if (mViewportListener)
107 mViewportListener->stopListen();
111 void FiberBundleRep::bundleChanged()
117 QColor color = mBundle->getColor();
118 mActor->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
119 mActor->GetProperty()->SetOpacity(color.alphaF());
121 if (!mBundle->getIsWireframe())
126 vtkSmartPointer<vtkRibbonFilter> ribbonFilter = vtkSmartPointer<vtkRibbonFilter>::New();
127 ribbonFilter->SetInputData(model);
128 ribbonFilter->SetWidth(mFiberWidth);
129 ribbonFilter->SetWidthFactor(3);
131 mPolyDataMapper->SetInputConnection(ribbonFilter->GetOutputPort());
137 normals->SetInputData(model);
139 model = normals->GetOutput();
141 mPolyDataMapper->SetInputData(model);
142 mActor->SetMapper(mPolyDataMapper);
145 mPolyDataMapper->ScalarVisibilityOn();
146 mPolyDataMapper->SetScalarModeToUsePointFieldData();
153 void FiberBundleRep::bundleTransformChanged()
155 if (!mBundle)
return;
157 mActor->SetUserMatrix(mBundle->get_rMd().getVtkMatrix());
boost::shared_ptr< class FiberBundleRep > FiberBundleRepPtr
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
virtual void setBundle(MeshPtr bundle)
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
static FiberBundleRepPtr New(const QString &uid="")
boost::shared_ptr< class View > ViewPtr
virtual bool hasBundle(MeshPtr bundle) const
virtual QString getType() const
vtkSmartPointer< class vtkPolyDataNormals > vtkPolyDataNormalsPtr
virtual void addRepActorsToViewRenderer(ViewPtr view)
Default implementation of Rep.
vtkSmartPointer< vtkPolyData > vtkPolyDataPtr
boost::shared_ptr< class Mesh > MeshPtr
Namespace for all CustusX production code.