13 #include <QVBoxLayout> 14 #include <QPushButton> 18 #include <vtkImageData.h> 40 mPatientModelService(patientModelService),
41 mViewService(viewService)
47 void CroppingWidget::setupUI()
49 if (mInteractiveCropper)
52 mInteractiveCropper = mViewService->getCropper();
54 if (!mInteractiveCropper)
57 connect(mInteractiveCropper.get(), SIGNAL(changed()),
this, SLOT(cropperChangedSlot()));
59 QVBoxLayout* layout =
new QVBoxLayout(
this);
61 this->setToolTip(
"Interactive volume cropping");
63 QGroupBox* activeGroupBox =
new QGroupBox(
"Interactive cropper");
64 activeGroupBox->setToolTip(this->toolTip());
65 layout->addWidget(activeGroupBox);
66 QVBoxLayout* activeLayout =
new QVBoxLayout(activeGroupBox);
68 mUseCropperCheckBox =
new QCheckBox(
"Use Cropper");
69 mUseCropperCheckBox->setToolTip(
"Turn on cropping for the active volume.");
70 connect(mUseCropperCheckBox, SIGNAL(toggled(
bool)), mInteractiveCropper.get(), SLOT(useCropping(
bool)));
71 activeLayout->addWidget(mUseCropperCheckBox);
73 mShowBoxCheckBox =
new QCheckBox(
"Show box");
74 mShowBoxCheckBox->setToolTip(
"Show crop box in 3D view. This also turns on cropping for convenience.");
75 connect(mShowBoxCheckBox, SIGNAL(toggled(
bool)), mInteractiveCropper.get(), SLOT(showBoxWidget(
bool)));
76 activeLayout->addWidget(mShowBoxCheckBox);
78 mBoundingBoxDimensions =
new QLabel(
"?, ?, ?");
79 mBoundingBoxDimensions->setToolTip(
"The dimensions of the croppers boundingbox.");
80 activeLayout->addWidget(mBoundingBoxDimensions);
83 layout->addWidget(mBBWidget);
84 connect(mBBWidget, SIGNAL(changed()),
this, SLOT(boxValuesChanged()));
86 QPushButton* cropClipButton =
new QPushButton(
"Create new cropped volume");
87 cropClipButton->setToolTip(
"Create a new volume containing only the volume inside the crop box.");
88 connect(cropClipButton, SIGNAL(clicked()),
this, SLOT(cropClipButtonClickedSlot()));
89 layout->addWidget(cropClipButton);
93 this->cropperChangedSlot();
96 void CroppingWidget::boxValuesChanged()
98 mInteractiveCropper->setBoundingBox(mBBWidget->
getValue());
101 void CroppingWidget::cropperChangedSlot()
103 std::vector<int> dims = mInteractiveCropper->getDimensions();
108 mBoundingBoxDimensions->setText(dimensionText);
109 mUseCropperCheckBox->setChecked(mInteractiveCropper->getUseCropping());
110 mShowBoxCheckBox->setChecked(mInteractiveCropper->getShowBoxWidget());
112 mBBWidget->
setValue(mInteractiveCropper->getBoundingBox(), mInteractiveCropper->getMaxBoundingBox());
115 ImagePtr CroppingWidget::cropClipButtonClickedSlot()
117 ActiveDataPtr activeData = mPatientModelService->getActiveData();
121 mPatientModelService->insertData(retval);
123 this->hideOldAndShowNewVolume(image, retval);
128 void CroppingWidget::hideOldAndShowNewVolume(
ImagePtr oldImage,
ImagePtr newImage)
136 reportWarning(QString(
"CroppingWidget: Hide old and show new volume failed. Can't get view group %1.").arg(groupNr));
139 if(!viewGroup->removeData(oldImage->getUid()))
140 reportWarning(QString(
"CroppingWidget: Hide old and show new volume failed. Can't remove image %1 from view group %2").arg(oldImage->getUid()).arg(groupNr));
142 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.