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();
119 mMarker->SetEnabled(on);
125 this->rebuild(mMarker->GetInteractor());
133 enable = mMarker->GetEnabled();
134 mMarker->SetInteractor(NULL);
137 mMarker = vtkOrientationMarkerWidgetPtr::New();
138 mMarker->SetOutlineColor(mColor[0], mColor[1], mColor[2]);
139 mMarker->SetViewport(0.0, 1.0 - mSize, mSize, 1.0);
140 mMarker->SetOrientationMarker(mMarkerCache.second);
144 mMarker->KeyPressActivationOff();
145 mMarker->SetInteractor(interactor);
146 mMarker->SetEnabled(
true);
147 mMarker->InteractiveOff();
148 mMarker->SetEnabled(enable);
155 if (!mMarkerCache.second || (mMarkerCache.first != filename))
157 mMarkerCache.first = filename;
159 mMarkerCache.second = this->readMarkerFromFile(filename);
162 this->rebuild(mMarker->GetInteractor());
165 vtkPropPtr OrientationAnnotation3DRep::readMarkerFromFile(
const QString filename)
167 if (filename.isEmpty() || !QFileInfo(filename).exists() || QFileInfo(filename).isDir())
169 return this->createCube();
180 normals->SetInputConnection(STLReader->GetOutputPort());
185 polyDataMapper->SetInputConnection(normals->GetOutputPort());
186 polyDataMapper->Update();
189 actor->SetMapper(polyDataMapper);
190 actor->GetProperty()->SetColor(0.5, 1, 1);
191 actor->GetProperty()->SetSpecularPower(15);
192 actor->GetProperty()->SetSpecular(0.3);
201 cube->SetXPlusFaceText(
"L");
202 cube->SetXMinusFaceText(
"R");
203 cube->SetYPlusFaceText(
"P");
204 cube->SetYMinusFaceText(
"A");
205 cube->SetZPlusFaceText(
"S");
206 cube->SetZMinusFaceText(
"I");
207 cube->SetZFaceTextRotation(-90);
208 cube->SetFaceTextScale(0.65);
216 property = cube->GetCubeProperty();
217 property->SetColor(0.5, 1, 1);
218 property = cube->GetTextEdgesProperty();
219 property->SetLineWidth(1);
220 property->SetDiffuse(0);
221 property->SetAmbient(1);
222 property->SetColor(0.18, 0.28, 0.23);
224 property = cube->GetXPlusFaceProperty();
225 property->SetColor(red.begin());
226 property->SetInterpolationToFlat();
227 property = cube->GetXMinusFaceProperty();
228 property->SetColor(red.begin());
229 property->SetInterpolationToFlat();
231 property = cube->GetYPlusFaceProperty();
232 property->SetColor(green.begin());
233 property->SetInterpolationToFlat();
234 property = cube->GetYMinusFaceProperty();
235 property->SetColor(green.begin());
236 property->SetInterpolationToFlat();
238 property = cube->GetZPlusFaceProperty();
239 property->SetColor(blue.begin());
240 property->SetInterpolationToFlat();
241 property = cube->GetZMinusFaceProperty();
242 property->SetColor(blue.begin());
243 property->SetInterpolationToFlat();
251 axes->SetShaftTypeToCylinder();
252 axes->SetXAxisLabelText(
"x");
253 axes->SetYAxisLabelText(
"y");
254 axes->SetZAxisLabelText(
"z");
255 axes->SetTotalLength(1.5, 1.5, 1.5);
259 tprop->SetFontFamilyToTimes();
260 axes->GetXAxisCaptionActor2D()->SetCaptionTextProperty(tprop);
262 tprop2->ShallowCopy(tprop);
263 axes->GetYAxisCaptionActor2D()->SetCaptionTextProperty(tprop2);
265 tprop3->ShallowCopy(tprop);
266 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.