36 #include "boost/bind.hpp"
38 #include <vtkProperty.h>
39 #include <vtkPolyDataMapper.h>
40 #include <vtkPolyDataNormals.h>
41 #include <vtkMatrix4x4.h>
42 #include <vtkRenderer.h>
43 #include <vtkRibbonFilter.h>
56 mPolyDataMapper = vtkPolyDataMapperPtr::New();
57 mProperty = vtkPropertyPtr::New();
61 mActor = vtkActorPtr::New();
63 mActor->SetMapper(mPolyDataMapper);
64 mActor->SetProperty(mProperty);
78 return "FiberBundleRep";
89 std::cout <<
"New fiber bundle assigned" << std::endl;
93 disconnect(mBundle.get(), SIGNAL(transformChanged()),
this, SLOT(bundleTransformChanged()));
94 disconnect(mBundle.get(), SIGNAL(meshChanged()),
this, SLOT(bundleChanged()));
101 connect(mBundle.get(), SIGNAL(transformChanged()),
this, SLOT(bundleTransformChanged()));
102 connect(mBundle.get(), SIGNAL(meshChanged()),
this, SLOT(bundleChanged()));
106 this->bundleTransformChanged();
114 view->getRenderer()->AddActor(mActor);
116 if (mViewportListener)
117 mViewportListener->startListen(view->getRenderer());
125 view->getRenderer()->RemoveActor(mActor);
127 if (mViewportListener)
128 mViewportListener->stopListen();
132 void FiberBundleRep::bundleChanged()
138 QColor color = mBundle->getColor();
139 mActor->GetProperty()->SetColor(color.redF(), color.greenF(), color.blueF());
140 mActor->GetProperty()->SetOpacity(color.alphaF());
142 if (!mBundle->getIsWireframe())
147 vtkSmartPointer<vtkRibbonFilter> ribbonFilter = vtkSmartPointer<vtkRibbonFilter>::New();
148 ribbonFilter->SetInputData(model);
149 ribbonFilter->SetWidth(mFiberWidth);
150 ribbonFilter->SetWidthFactor(3);
152 mPolyDataMapper->SetInputConnection(ribbonFilter->GetOutputPort());
158 normals->SetInputData(model);
160 model = normals->GetOutput();
162 mPolyDataMapper->SetInputData(model);
163 mActor->SetMapper(mPolyDataMapper);
166 mPolyDataMapper->ScalarVisibilityOn();
167 mPolyDataMapper->SetScalarModeToUsePointFieldData();
174 void FiberBundleRep::bundleTransformChanged()
176 if (!mBundle)
return;
178 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
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
virtual QString getType() const
vtkSmartPointer< class vtkPolyDataNormals > vtkPolyDataNormalsPtr
virtual void addRepActorsToViewRenderer(ViewPtr view)
Default implementation of Rep.
boost::shared_ptr< class Mesh > MeshPtr