17 #include <vtkTransform.h>
18 #include <vtkAbstractVolumeMapper.h>
19 #include <vtkVolumeMapper.h>
20 #include <vtkRenderWindow.h>
21 #include <vtkRenderer.h>
22 #include <vtkImageData.h>
23 #include <vtkCommand.h>
24 #include <vtkBoxWidget2.h>
25 #include <vtkBoxWidget.h>
53 virtual void Execute(vtkObject* caller,
unsigned long,
void*)
75 virtual void Execute(vtkObject* caller,
unsigned long,
void*)
94 m_rMd = Transform3D::Identity();
101 mBoxWidget->SetInteractor(NULL);
107 mRenderWindow = renderWindow;
108 this->updateBoxWidgetInteractor();
124 this->updateWidgetFromBox();
134 this->updateWidgetFromBox();
143 this->updateWidgetFromBox();
154 if (mInteractive==on)
157 this->updateWidgetFromBox();
174 void GraphicalBox::updateWidgetFromBox()
176 this->updateBoxWidgetInteractor();
177 this->setBoxWidgetSize(mBox, m_rMd);
180 void GraphicalBox::updateBoxFromWidget()
182 DoubleBoundingBox3D bb_d = this->getCurrentBoxWidgetSize();
187 void GraphicalBox::initialize()
192 mBoxWidget = vtkBoxWidgetPtr::New();
193 mBoxWidget->RotationEnabledOff();
196 { -1, 1, -1, 1, -1, 1 };
197 mBoxWidget->PlaceWidget(bb_hard);
199 mGraphicalBoxCallback = GraphicalBoxCallbackPtr::New();
200 mGraphicalBoxCallback->SetCropper(
this);
201 mGraphicalBoxEnableCallback = GraphicalBoxEnableCallbackPtr::New();
202 mGraphicalBoxEnableCallback->SetCropper(
true,
this);
203 mGraphicalBoxDisableCallback = GraphicalBoxEnableCallbackPtr::New();
204 mGraphicalBoxDisableCallback->SetCropper(
false,
this);
206 mBoxWidget->SetInteractor(mRenderWindow->GetInteractor());
208 mBoxWidget->SetEnabled(mVisible);
211 void GraphicalBox::updateBoxWidgetInteractor()
218 mBoxWidget->SetInteractor(mRenderWindow->GetInteractor());
222 mBoxWidget->AddObserver(vtkCommand::InteractionEvent, mGraphicalBoxCallback);
223 mBoxWidget->AddObserver(vtkCommand::EnableEvent, mGraphicalBoxEnableCallback);
224 mBoxWidget->AddObserver(vtkCommand::DisableEvent, mGraphicalBoxDisableCallback);
229 mBoxWidget->RemoveObserver(vtkCommand::InteractionEvent);
230 mBoxWidget->RemoveObserver(vtkCommand::EnableEvent);
231 mBoxWidget->RemoveObserver(vtkCommand::DisableEvent);
234 mBoxWidget->SetScalingEnabled(mInteractive);
235 mBoxWidget->SetTranslationEnabled(mInteractive);
237 mBoxWidget->SetOutlineFaceWires(mInteractive);
238 mBoxWidget->SetOutlineCursorWires(mInteractive);
240 mBoxWidget->HandlesOn();
242 mBoxWidget->HandlesOff();
244 mBoxWidget->SetEnabled(mVisible);
249 void GraphicalBox::setBoxWidgetSize(
const DoubleBoundingBox3D& bb_d,
Transform3D rMd)
254 double bb_hard[6] = { -0.5, 0.5, -0.5, 0.5, -0.5, 0.5 };
255 DoubleBoundingBox3D bb_unit(bb_hard);
259 if (
similar(M, this->getBoxTransform()))
262 this->setBoxTransform(M);
272 void GraphicalBox::setBoxTransform(
const Transform3D& M)
281 DoubleBoundingBox3D GraphicalBox::getCurrentBoxWidgetSize()
289 { -0.5, 0.5, -0.5, 0.5, -0.5, 0.5 };
290 DoubleBoundingBox3D bb_unit(bb_hard);