34 #include <QVBoxLayout>
35 #include <QPushButton>
39 #include <vtkImageData.h>
62 mPatientModelService(patientModelService),
63 mViewService(viewService)
69 void CroppingWidget::setupUI()
71 if (mInteractiveCropper)
76 if (!mInteractiveCropper)
79 connect(mInteractiveCropper.get(), SIGNAL(changed()),
this, SLOT(cropperChangedSlot()));
81 QVBoxLayout* layout =
new QVBoxLayout(
this);
83 this->setToolTip(
"Interactive volume cropping");
85 QGroupBox* activeGroupBox =
new QGroupBox(
"Interactive cropper");
86 activeGroupBox->setToolTip(this->toolTip());
87 layout->addWidget(activeGroupBox);
88 QVBoxLayout* activeLayout =
new QVBoxLayout(activeGroupBox);
90 mUseCropperCheckBox =
new QCheckBox(
"Use Cropper");
91 mUseCropperCheckBox->setToolTip(
"Turn on cropping for the active volume.");
92 connect(mUseCropperCheckBox, SIGNAL(toggled(
bool)), mInteractiveCropper.get(), SLOT(useCropping(
bool)));
93 activeLayout->addWidget(mUseCropperCheckBox);
95 mShowBoxCheckBox =
new QCheckBox(
"Show box");
96 mShowBoxCheckBox->setToolTip(
"Show crop box in 3D view. This also turns on cropping for convenience.");
97 connect(mShowBoxCheckBox, SIGNAL(toggled(
bool)), mInteractiveCropper.get(), SLOT(showBoxWidget(
bool)));
98 activeLayout->addWidget(mShowBoxCheckBox);
100 mBoundingBoxDimensions =
new QLabel(
"?, ?, ?");
101 mBoundingBoxDimensions->setToolTip(
"The dimensions of the croppers boundingbox.");
102 activeLayout->addWidget(mBoundingBoxDimensions);
105 layout->addWidget(mBBWidget);
106 connect(mBBWidget, SIGNAL(changed()),
this, SLOT(boxValuesChanged()));
108 QPushButton* cropClipButton =
new QPushButton(
"Create new cropped volume");
109 cropClipButton->setToolTip(
"Create a new volume containing only the volume inside the crop box.");
110 connect(cropClipButton, SIGNAL(clicked()),
this, SLOT(cropClipButtonClickedSlot()));
111 layout->addWidget(cropClipButton);
113 layout->addStretch();
115 this->cropperChangedSlot();
118 void CroppingWidget::boxValuesChanged()
120 mInteractiveCropper->setBoundingBox(mBBWidget->
getValue());
123 void CroppingWidget::cropperChangedSlot()
125 std::vector<int> dims = mInteractiveCropper->getDimensions();
130 mBoundingBoxDimensions->setText(dimensionText);
131 mUseCropperCheckBox->setChecked(mInteractiveCropper->getUseCropping());
132 mShowBoxCheckBox->setChecked(mInteractiveCropper->getShowBoxWidget());
134 mBBWidget->
setValue(mInteractiveCropper->getBoundingBox(), mInteractiveCropper->getMaxBoundingBox());
137 ImagePtr CroppingWidget::cropClipButtonClickedSlot()
139 ActiveDataPtr activeData = mPatientModelService->getActiveData();
140 ImagePtr image = activeData->getActive<Image>();
143 mPatientModelService->insertData(retval);
145 this->hideOldAndShowNewVolume(image, retval);
150 void CroppingWidget::hideOldAndShowNewVolume(
ImagePtr oldImage,
ImagePtr newImage)
158 reportWarning(QString(
"CroppingWidget: Hide old and show new volume failed. Can't get view group %1.").arg(groupNr));
161 if(!viewGroup->removeData(oldImage->getUid()))
162 reportWarning(QString(
"CroppingWidget: Hide old and show new volume failed. Can't remove image %1 from view group %2").arg(oldImage->getUid()).arg(groupNr));
164 viewGroup->addData(newImage->getUid());
QString qstring_cast(const T &val)
boost::shared_ptr< class ViewGroupData > ViewGroupDataPtr
vtkImageDataPtr cropImage(vtkImageDataPtr input, IntBoundingBox3D cropbox)
boost::shared_ptr< class Image > ImagePtr
boost::shared_ptr< class ActiveData > ActiveDataPtr
void reportWarning(QString msg)
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
void activeLayoutChanged()
emitted when the active layout changes
cxLogicManager_EXPORT ViewServicePtr viewService()
cxLogicManager_EXPORT PatientModelServicePtr patientService()