34 #include <QVBoxLayout>
35 #include <QPushButton>
39 #include <vtkImageData.h>
61 mPatientModelService(patientModelService),
62 mVisualizationService(visualizationService)
68 void CroppingWidget::setupUI()
70 if (mInteractiveCropper)
75 if (!mInteractiveCropper)
78 connect(mInteractiveCropper.get(), SIGNAL(changed()),
this, SLOT(cropperChangedSlot()));
80 QVBoxLayout* layout =
new QVBoxLayout(
this);
82 this->setToolTip(
"Interactive volume cropping");
84 QGroupBox* activeGroupBox =
new QGroupBox(
"Interactive cropper");
85 activeGroupBox->setToolTip(this->toolTip());
86 layout->addWidget(activeGroupBox);
87 QVBoxLayout* activeLayout =
new QVBoxLayout(activeGroupBox);
89 mUseCropperCheckBox =
new QCheckBox(
"Use Cropper");
90 mUseCropperCheckBox->setToolTip(
"Turn on cropping for the active volume.");
91 connect(mUseCropperCheckBox, SIGNAL(toggled(
bool)), mInteractiveCropper.get(), SLOT(useCropping(
bool)));
92 activeLayout->addWidget(mUseCropperCheckBox);
94 mShowBoxCheckBox =
new QCheckBox(
"Show box");
95 mShowBoxCheckBox->setToolTip(
"Show crop box in 3D view. This also turns on cropping for convenience.");
96 connect(mShowBoxCheckBox, SIGNAL(toggled(
bool)), mInteractiveCropper.get(), SLOT(showBoxWidget(
bool)));
97 activeLayout->addWidget(mShowBoxCheckBox);
99 mBoundingBoxDimensions =
new QLabel(
"?, ?, ?");
100 mBoundingBoxDimensions->setToolTip(
"The dimensions of the croppers boundingbox.");
101 activeLayout->addWidget(mBoundingBoxDimensions);
104 layout->addWidget(mBBWidget);
105 connect(mBBWidget, SIGNAL(changed()),
this, SLOT(boxValuesChanged()));
107 QPushButton* cropClipButton =
new QPushButton(
"Create new cropped volume");
108 cropClipButton->setToolTip(
"Create a new volume containing only the volume inside the crop box.");
109 connect(cropClipButton, SIGNAL(clicked()),
this, SLOT(cropClipButtonClickedSlot()));
110 layout->addWidget(cropClipButton);
112 layout->addStretch();
114 this->cropperChangedSlot();
117 void CroppingWidget::boxValuesChanged()
119 mInteractiveCropper->setBoundingBox(mBBWidget->
getValue());
122 void CroppingWidget::cropperChangedSlot()
124 std::vector<int> dims = mInteractiveCropper->getDimensions();
129 mBoundingBoxDimensions->setText(dimensionText);
130 mUseCropperCheckBox->setChecked(mInteractiveCropper->getUseCropping());
131 mShowBoxCheckBox->setChecked(mInteractiveCropper->getShowBoxWidget());
133 mBBWidget->
setValue(mInteractiveCropper->getBoundingBox(), mInteractiveCropper->getMaxBoundingBox());
136 ImagePtr CroppingWidget::cropClipButtonClickedSlot()
138 ImagePtr image = mPatientModelService->getActiveImage();
141 mPatientModelService->insertData(retval);
143 this->hideOldAndShowNewVolume(image, retval);
148 void CroppingWidget::hideOldAndShowNewVolume(
ImagePtr oldImage,
ImagePtr newImage)
156 reportWarning(QString(
"CroppingWidget: Hide old and show new volume failed. Can't get view group %1.").arg(groupNr));
159 if(!viewGroup->removeData(oldImage->getUid()))
160 reportWarning(QString(
"CroppingWidget: Hide old and show new volume failed. Can't remove image %1 from view group %2").arg(oldImage->getUid()).arg(groupNr));
162 viewGroup->addData(newImage->getUid());
QString qstring_cast(const T &val)
boost::shared_ptr< class ViewGroupData > ViewGroupDataPtr
void activeLayoutChanged()
emitted when the active layout changes
vtkImageDataPtr cropImage(vtkImageDataPtr input, IntBoundingBox3D cropbox)
boost::shared_ptr< class Image > ImagePtr
void reportWarning(QString msg)
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
cxLogicManager_EXPORT ViewServicePtr viewService()
cxLogicManager_EXPORT PatientModelServicePtr patientService()