13 #include <QVBoxLayout> 14 #include <QPushButton> 18 #include <vtkImageData.h> 41 mPatientModelService(patientModelService),
42 mViewService(viewService)
48 void CroppingWidget::setupUI()
50 if (mInteractiveCropper)
53 mInteractiveCropper = mViewService->getCropper();
55 if (!mInteractiveCropper)
58 connect(mInteractiveCropper.get(), SIGNAL(changed()),
this, SLOT(cropperChangedSlot()));
60 QVBoxLayout* layout =
new QVBoxLayout(
this);
62 this->setToolTip(
"Interactive volume cropping");
64 QGroupBox* activeGroupBox =
new QGroupBox(
"Interactive cropper");
65 activeGroupBox->setToolTip(this->toolTip());
66 layout->addWidget(activeGroupBox);
67 QVBoxLayout* activeLayout =
new QVBoxLayout(activeGroupBox);
69 mUseCropperCheckBox =
new QCheckBox(
"Use Cropper");
70 mUseCropperCheckBox->setToolTip(
"Turn on cropping for the active volume.");
71 connect(mUseCropperCheckBox, SIGNAL(toggled(
bool)), mInteractiveCropper.get(), SLOT(useCropping(
bool)));
72 activeLayout->addWidget(mUseCropperCheckBox);
74 mShowBoxCheckBox =
new QCheckBox(
"Show box");
75 mShowBoxCheckBox->setToolTip(
"Show crop box in 3D view. This also turns on cropping for convenience.");
76 connect(mShowBoxCheckBox, SIGNAL(toggled(
bool)), mInteractiveCropper.get(), SLOT(showBoxWidget(
bool)));
77 activeLayout->addWidget(mShowBoxCheckBox);
79 mBoundingBoxDimensions =
new QLabel(
"?, ?, ?");
80 mBoundingBoxDimensions->setToolTip(
"The dimensions of the croppers boundingbox.");
81 activeLayout->addWidget(mBoundingBoxDimensions);
84 layout->addWidget(mBBWidget);
85 connect(mBBWidget, SIGNAL(changed()),
this, SLOT(boxValuesChanged()));
87 QPushButton* cropClipButton =
new QPushButton(
"Create new cropped volume");
88 cropClipButton->setToolTip(
"Create a new volume containing only the volume inside the crop box.");
89 connect(cropClipButton, SIGNAL(clicked()),
this, SLOT(cropClipButtonClickedSlot()));
90 layout->addWidget(cropClipButton);
94 this->cropperChangedSlot();
97 void CroppingWidget::boxValuesChanged()
99 mInteractiveCropper->setBoundingBox(mBBWidget->
getValue());
102 void CroppingWidget::cropperChangedSlot()
104 std::vector<int> dims = mInteractiveCropper->getDimensions();
109 mBoundingBoxDimensions->setText(dimensionText);
110 mUseCropperCheckBox->setChecked(mInteractiveCropper->getUseCropping());
111 mShowBoxCheckBox->setChecked(mInteractiveCropper->getShowBoxWidget());
113 mBBWidget->
setValue(mInteractiveCropper->getBoundingBox(), mInteractiveCropper->getMaxBoundingBox());
116 ImagePtr CroppingWidget::cropClipButtonClickedSlot()
118 ActiveDataPtr activeData = mPatientModelService->getActiveData();
122 mPatientModelService->insertData(retval);
124 this->hideOldAndShowNewVolume(image, retval);
129 void CroppingWidget::hideOldAndShowNewVolume(
ImagePtr oldImage,
ImagePtr newImage)
137 reportWarning(QString(
"CroppingWidget: Hide old and show new volume failed. Can't get view group %1.").arg(groupNr));
140 if(!viewGroup->removeData(oldImage->getUid()))
141 reportWarning(QString(
"CroppingWidget: Hide old and show new volume failed. Can't remove image %1 from view group %2").arg(oldImage->getUid()).arg(groupNr));
143 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
Namespace for all CustusX production code.