21 #include <vtkOrientationMarkerWidget.h> 22 #include <vtkAnnotatedCubeActor.h> 23 #include <vtkProperty.h> 24 #include <vtkAxesActor.h> 25 #include <vtkTextProperty.h> 26 #include <vtkCaptionActor2D.h> 27 #include <vtkPropAssembly.h> 28 #include <vtkRenderWindow.h> 30 #include "vtkSTLReader.h" 31 #include "vtkSTLWriter.h" 32 #include "vtkPolyDataMapper.h" 33 #include "vtkPolyData.h" 35 #include "vtkProperty.h" 36 #include <vtkImageShrink3D.h> 37 #include <vtkMarchingCubes.h> 38 #include <vtkWindowedSincPolyDataFilter.h> 39 #include <vtkTriangleFilter.h> 40 #include <vtkDecimatePro.h> 41 #include <vtkPolyDataNormals.h> 42 #include <vtkQuadricDecimation.h> 48 #include <vtkRenderWindowInteractor.h> 64 RepImpl(), mSize(0.2), mColor(1, 0.5, 0.5)
81 this->rebuild(view->getRenderWindow()->GetInteractor());
86 mMarker->SetInteractor(NULL);
91 return mMarker->GetEnabled();
98 mMarker->SetEnabled(on);
104 this->rebuild(mMarker->GetInteractor());
112 enable = mMarker->GetEnabled();
113 mMarker->SetInteractor(NULL);
116 mMarker = vtkOrientationMarkerWidgetPtr::New();
117 mMarker->SetOutlineColor(mColor[0], mColor[1], mColor[2]);
118 mMarker->SetViewport(0.0, 1.0 - mSize, mSize, 1.0);
119 mMarker->SetOrientationMarker(mMarkerCache.second);
123 mMarker->KeyPressActivationOff();
124 mMarker->SetInteractor(interactor);
125 mMarker->SetEnabled(
true);
126 mMarker->InteractiveOff();
127 mMarker->SetEnabled(enable);
134 if (!mMarkerCache.second || (mMarkerCache.first != filename))
136 mMarkerCache.first = filename;
138 mMarkerCache.second = this->readMarkerFromFile(filename);
141 this->rebuild(mMarker->GetInteractor());
144 vtkPropPtr OrientationAnnotation3DRep::readMarkerFromFile(
const QString filename)
146 if (filename.isEmpty() || !QFileInfo(filename).exists() || QFileInfo(filename).isDir())
148 return this->createCube();
159 normals->SetInputConnection(STLReader->GetOutputPort());
164 polyDataMapper->SetInputConnection(normals->GetOutputPort());
165 polyDataMapper->Update();
168 actor->SetMapper(polyDataMapper);
169 actor->GetProperty()->SetColor(0.5, 1, 1);
170 actor->GetProperty()->SetSpecularPower(15);
171 actor->GetProperty()->SetSpecular(0.3);
180 cube->SetXPlusFaceText(
"L");
181 cube->SetXMinusFaceText(
"R");
182 cube->SetYPlusFaceText(
"P");
183 cube->SetYMinusFaceText(
"A");
184 cube->SetZPlusFaceText(
"S");
185 cube->SetZMinusFaceText(
"I");
186 cube->SetZFaceTextRotation(-90);
187 cube->SetFaceTextScale(0.65);
195 property = cube->GetCubeProperty();
196 property->SetColor(0.5, 1, 1);
197 property = cube->GetTextEdgesProperty();
198 property->SetLineWidth(1);
199 property->SetDiffuse(0);
200 property->SetAmbient(1);
201 property->SetColor(0.18, 0.28, 0.23);
203 property = cube->GetXPlusFaceProperty();
204 property->SetColor(red.begin());
205 property->SetInterpolationToFlat();
206 property = cube->GetXMinusFaceProperty();
207 property->SetColor(red.begin());
208 property->SetInterpolationToFlat();
210 property = cube->GetYPlusFaceProperty();
211 property->SetColor(green.begin());
212 property->SetInterpolationToFlat();
213 property = cube->GetYMinusFaceProperty();
214 property->SetColor(green.begin());
215 property->SetInterpolationToFlat();
217 property = cube->GetZPlusFaceProperty();
218 property->SetColor(blue.begin());
219 property->SetInterpolationToFlat();
220 property = cube->GetZMinusFaceProperty();
221 property->SetColor(blue.begin());
222 property->SetInterpolationToFlat();
230 axes->SetShaftTypeToCylinder();
231 axes->SetXAxisLabelText(
"x");
232 axes->SetYAxisLabelText(
"y");
233 axes->SetZAxisLabelText(
"z");
234 axes->SetTotalLength(1.5, 1.5, 1.5);
238 tprop->SetFontFamilyToTimes();
239 axes->GetXAxisCaptionActor2D()->SetCaptionTextProperty(tprop);
241 tprop2->ShallowCopy(tprop);
242 axes->GetYAxisCaptionActor2D()->SetCaptionTextProperty(tprop2);
244 tprop3->ShallowCopy(tprop);
245 axes->GetZAxisCaptionActor2D()->SetCaptionTextProperty(tprop3);
vtkSmartPointer< class vtkActor > vtkActorPtr
vtkSmartPointer< class vtkAxesActor > vtkAxesActorPtr
vtkSmartPointer< class vtkPolyDataMapper > vtkPolyDataMapperPtr
vtkSmartPointer< class vtkProperty > vtkPropertyPtr
vtkSmartPointer< class vtkRenderWindowInteractor > vtkRenderWindowInteractorPtr
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
cstring_cast_Placeholder cstring_cast(const T &val)
boost::shared_ptr< class View > ViewPtr
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
virtual ~OrientationAnnotation3DRep()
void setSize(double size)
fraction of viewport to use
vtkSmartPointer< class vtkSTLReader > vtkSTLReaderPtr
vtkSmartPointer< class vtkPolyDataNormals > vtkPolyDataNormalsPtr
vtkSmartPointer< vtkPropAssembly > vtkPropAssemblyPtr
OrientationAnnotation3DRep()
Default implementation of Rep.
vtkSmartPointer< vtkSTLWriter > vtkSTLWriterPtr
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
boost::shared_ptr< class OrientationAnnotation3DRep > OrientationAnnotation3DRepPtr
void setMarkerFilename(const QString filename)
empty and default means a cube
static OrientationAnnotation3DRepPtr New(const QString &uid="")
vtkSmartPointer< vtkAxesActor > vtkAxesActorPtr
virtual void addRepActorsToViewRenderer(ViewPtr view)
vtkSmartPointer< vtkTextProperty > vtkTextPropertyPtr
vtkSmartPointer< vtkQuadricDecimation > vtkQuadricDecimationPtr
vtkSmartPointer< class vtkProp > vtkPropPtr
vtkSmartPointer< class vtkAnnotatedCubeActor > vtkAnnotatedCubeActorPtr
Namespace for all CustusX production code.