42 #include <vtkOrientationMarkerWidget.h>
43 #include <vtkAnnotatedCubeActor.h>
44 #include <vtkProperty.h>
45 #include <vtkAxesActor.h>
46 #include <vtkTextProperty.h>
47 #include <vtkCaptionActor2D.h>
48 #include <vtkPropAssembly.h>
49 #include <vtkRenderWindow.h>
51 #include "vtkSTLReader.h"
52 #include "vtkSTLWriter.h"
53 #include "vtkPolyDataMapper.h"
54 #include "vtkPolyData.h"
56 #include "vtkProperty.h"
57 #include <vtkImageShrink3D.h>
58 #include <vtkMarchingCubes.h>
59 #include <vtkWindowedSincPolyDataFilter.h>
60 #include <vtkTriangleFilter.h>
61 #include <vtkDecimatePro.h>
62 #include <vtkPolyDataNormals.h>
63 #include <vtkQuadricDecimation.h>
69 #include <vtkRenderWindowInteractor.h>
85 RepImpl(), mSize(0.2), mColor(1, 0.5, 0.5)
102 this->rebuild(view->getRenderWindow()->GetInteractor());
107 mMarker->SetInteractor(NULL);
112 return mMarker->GetEnabled();
117 mMarker->SetEnabled(on);
123 this->rebuild(mMarker->GetInteractor());
131 enable = mMarker->GetEnabled();
132 mMarker->SetInteractor(NULL);
135 mMarker = vtkOrientationMarkerWidgetPtr::New();
136 mMarker->SetOutlineColor(mColor[0], mColor[1], mColor[2]);
137 mMarker->SetViewport(0.0, 1.0 - mSize, mSize, 1.0);
138 mMarker->SetOrientationMarker(mMarkerCache.second);
142 mMarker->KeyPressActivationOff();
143 mMarker->SetInteractor(interactor);
144 mMarker->SetEnabled(
true);
145 mMarker->InteractiveOff();
146 mMarker->SetEnabled(enable);
153 if (!mMarkerCache.second || (mMarkerCache.first != filename))
155 mMarkerCache.first = filename;
157 mMarkerCache.second = this->readMarkerFromFile(filename);
160 this->rebuild(mMarker->GetInteractor());
163 vtkPropPtr OrientationAnnotation3DRep::readMarkerFromFile(
const QString filename)
165 if (filename.isEmpty() || !QFileInfo(filename).exists() || QFileInfo(filename).isDir())
167 return this->createCube();
178 normals->SetInputConnection(STLReader->GetOutputPort());
183 polyDataMapper->SetInputConnection(normals->GetOutputPort());
184 polyDataMapper->Update();
187 actor->SetMapper(polyDataMapper);
188 actor->GetProperty()->SetColor(0.5, 1, 1);
189 actor->GetProperty()->SetSpecularPower(15);
190 actor->GetProperty()->SetSpecular(0.3);
199 cube->SetXPlusFaceText(
"L");
200 cube->SetXMinusFaceText(
"R");
201 cube->SetYPlusFaceText(
"P");
202 cube->SetYMinusFaceText(
"A");
203 cube->SetZPlusFaceText(
"S");
204 cube->SetZMinusFaceText(
"I");
205 cube->SetZFaceTextRotation(-90);
206 cube->SetFaceTextScale(0.65);
214 property = cube->GetCubeProperty();
215 property->SetColor(0.5, 1, 1);
216 property = cube->GetTextEdgesProperty();
217 property->SetLineWidth(1);
218 property->SetDiffuse(0);
219 property->SetAmbient(1);
220 property->SetColor(0.18, 0.28, 0.23);
222 property = cube->GetXPlusFaceProperty();
223 property->SetColor(red.begin());
224 property->SetInterpolationToFlat();
225 property = cube->GetXMinusFaceProperty();
226 property->SetColor(red.begin());
227 property->SetInterpolationToFlat();
229 property = cube->GetYPlusFaceProperty();
230 property->SetColor(green.begin());
231 property->SetInterpolationToFlat();
232 property = cube->GetYMinusFaceProperty();
233 property->SetColor(green.begin());
234 property->SetInterpolationToFlat();
236 property = cube->GetZPlusFaceProperty();
237 property->SetColor(blue.begin());
238 property->SetInterpolationToFlat();
239 property = cube->GetZMinusFaceProperty();
240 property->SetColor(blue.begin());
241 property->SetInterpolationToFlat();
249 axes->SetShaftTypeToCylinder();
250 axes->SetXAxisLabelText(
"x");
251 axes->SetYAxisLabelText(
"y");
252 axes->SetZAxisLabelText(
"z");
253 axes->SetTotalLength(1.5, 1.5, 1.5);
257 tprop->SetFontFamilyToTimes();
258 axes->GetXAxisCaptionActor2D()->SetCaptionTextProperty(tprop);
260 tprop2->ShallowCopy(tprop);
261 axes->GetYAxisCaptionActor2D()->SetCaptionTextProperty(tprop2);
263 tprop3->ShallowCopy(tprop);
264 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