38 #include <visp3/ustk_core/usImagePostScan3D.h>
39 #include <visp3/ustk_gui/us3DSceneSlicing.h>
40 #include <visp3/ustk_gui/usVTKConverter.h>
42 #ifdef USTK_HAVE_VTK_QT
44 #include <vtkAbstractTransform.h>
46 #include <vtkActor2D.h>
47 #include <vtkBoundedPlanePointPlacer.h>
48 #include <vtkCamera.h>
49 #include <vtkCellPicker.h>
50 #include <vtkCommand.h>
51 #include <vtkDistanceRepresentation.h>
52 #include <vtkDistanceRepresentation2D.h>
53 #include <vtkDistanceWidget.h>
54 #include <vtkHandleRepresentation.h>
55 #include <vtkImageActor.h>
56 #include <vtkImageData.h>
57 #include <vtkImageMapToWindowLevelColors.h>
58 #include <vtkImageSlabReslice.h>
59 #include <vtkInteractorStyleImage.h>
60 #include <vtkLookupTable.h>
61 #include <vtkMapper.h>
62 #include <vtkMatrix4x4.h>
63 #include <vtkMetaImageReader.h>
65 #include <vtkPlaneSource.h>
66 #include <vtkPointHandleRepresentation2D.h>
67 #include <vtkPointHandleRepresentation3D.h>
68 #include <vtkProperty.h>
69 #include <vtkRenderWindow.h>
70 #include <vtkRenderer.h>
71 #include <vtkRendererCollection.h>
72 #include <vtkResliceCursor.h>
73 #include <vtkResliceCursorActor.h>
74 #include <vtkResliceCursorLineRepresentation.h>
75 #include <vtkResliceCursorPolyDataAlgorithm.h>
76 #include <vtkResliceCursorThickLineRepresentation.h>
77 #include <vtkResliceCursorWidget.h>
78 #include <vtkResliceImageViewer.h>
79 #include <vtkResliceImageViewerMeasurements.h>
81 #include <vtkHomogeneousTransform.h>
83 #include <QDesktopWidget>
84 #include <QResizeEvent>
98 vtkImage->GetDimensions(imageDims);
99 vtkImage->GetSpacing(spacing);
101 plane1 = vtkPlane::New();
102 plane1->SetOrigin(imageDims[0] * spacing[0] / 2, 0, 0);
103 plane1->SetNormal(1, 0, 0);
105 plane2 = vtkPlane::New();
106 plane2->SetNormal(0, 1, 0);
107 plane2->SetOrigin(0, imageDims[1] * spacing[1] / 2, 0);
109 plane3 = vtkPlane::New();
110 plane3->SetNormal(0, 0, 1);
111 plane3->SetOrigin(0, 0, imageDims[2] * spacing[2] / 2);
114 this->view->
setPlanes(plane1, plane2, plane3);
117 sliderXplane1->setMaximum(imageDims[0] * spacing[0] * 1000);
118 sliderXplane1->setSliderPosition(imageDims[0] * spacing[0] * 1000 / 2);
119 sliderYplane1->setMaximum(imageDims[1] * spacing[1] * 1000);
120 sliderYplane1->setSliderPosition(imageDims[1] * spacing[1] * 1000 / 2);
121 sliderZplane1->setMaximum(imageDims[2] * spacing[2] * 1000);
122 sliderZplane1->setSliderPosition(imageDims[2] * spacing[2] * 1000 / 2);
125 connect(this->sliderXplane1, SIGNAL(valueChanged(
int)),
this, SLOT(
updateX(
int)));
126 connect(this->sliderYplane1, SIGNAL(valueChanged(
int)),
this, SLOT(
updateY(
int)));
127 connect(this->sliderZplane1, SIGNAL(valueChanged(
int)),
this, SLOT(
updateZ(
int)));
129 connect(this->rotXplane1, SIGNAL(valueChanged(
int)),
this, SLOT(
updateRotX(
int)));
130 connect(this->rotYplane1, SIGNAL(valueChanged(
int)),
this, SLOT(
updateRotY(
int)));
131 connect(this->rotZplane1, SIGNAL(valueChanged(
int)),
this, SLOT(
updateRotZ(
int)));
151 #if USTK_HAVE_VTK_VERSION < 0x090000
152 this->view->GetRenderWindow()->Render();
154 this->view->renderWindow()->Render();
157 this->view->update();
163 void us3DSceneSlicing::setupUi()
165 this->setMinimumSize(640, 480);
166 QRect screenRect = QApplication::desktop()->screenGeometry();
167 this->resize(screenRect.size());
169 gridLayoutWidget =
new QWidget(
this);
170 gridLayoutWidget->setObjectName(QString::fromUtf8(
"gridLayoutWidget"));
171 gridLayoutWidget->setGeometry(QRect(10, 10, screenRect.width() - 200, screenRect.height() - 40));
172 gridLayout_2 =
new QGridLayout(gridLayoutWidget);
173 gridLayout_2->setObjectName(QString::fromUtf8(
"gridLayout_2"));
174 gridLayout_2->setContentsMargins(0, 0, 0, 0);
176 view->setObjectName(QString::fromUtf8(
"view"));
178 gridLayout_2->addWidget(view, 0, 0, 1, 1);
180 sliderXplane1 =
new QSlider(
this);
181 sliderXplane1->setObjectName(QString::fromUtf8(
"sliderX"));
182 sliderXplane1->setMinimum(0);
183 sliderXplane1->setMaximum(100);
184 sliderXplane1->setGeometry(QRect(screenRect.width() - 180, 30, 20, 200));
186 sliderYplane1 =
new QSlider(
this);
187 sliderYplane1->setObjectName(QString::fromUtf8(
"sliderY"));
188 sliderYplane1->setMinimum(0);
189 sliderYplane1->setMaximum(100);
190 sliderYplane1->setGeometry(QRect(screenRect.width() - 140, 30, 20, 200));
192 sliderZplane1 =
new QSlider(
this);
193 sliderZplane1->setObjectName(QString::fromUtf8(
"sliderZ"));
194 sliderZplane1->setMinimum(0);
195 sliderZplane1->setMaximum(100);
196 sliderZplane1->setGeometry(QRect(screenRect.width() - 100, 30, 20, 200));
198 rotXplane1 =
new QSlider(
this);
199 rotXplane1->setObjectName(QString::fromUtf8(
"rotX"));
200 rotXplane1->setMinimum(0);
201 rotXplane1->setMaximum(100);
202 rotXplane1->setGeometry(QRect(screenRect.width() - 180, 250, 20, 200));
204 rotYplane1 =
new QSlider(
this);
205 rotYplane1->setObjectName(QString::fromUtf8(
"rotY"));
206 rotYplane1->setMinimum(0);
207 rotYplane1->setMaximum(100);
208 rotYplane1->setGeometry(QRect(screenRect.width() - 140, 250, 20, 200));
210 rotZplane1 =
new QSlider(
this);
211 rotZplane1->setObjectName(QString::fromUtf8(
"rotZ"));
212 rotZplane1->setMinimum(0);
213 rotZplane1->setMaximum(100);
214 rotZplane1->setGeometry(QRect(screenRect.width() - 100, 250, 20, 200));
223 if (event->size().width() >= 640 && event->size().height() >= 480) {
224 QMainWindow::resizeEvent(event);
225 gridLayoutWidget->setGeometry(QRect(10, 10, event->size().width() - 220, event->size().height() - 20));
226 sliderXplane1->setGeometry(QRect(event->size().width() - 180, 30, 20, 200));
227 sliderYplane1->setGeometry(QRect(event->size().width() - 140, 30, 20, 200));
228 sliderZplane1->setGeometry(QRect(event->size().width() - 100, 30, 20, 200));
229 rotXplane1->setGeometry(QRect(event->size().width() - 180, 250, 20, 200));
230 rotYplane1->setGeometry(QRect(event->size().width() - 140, 250, 20, 200));
231 rotZplane1->setGeometry(QRect(event->size().width() - 100, 250, 20, 200));
241 plane1->GetOrigin(origin);
242 origin[0] = x / 1000.0;
243 plane1->SetOrigin(origin);
253 plane1->GetOrigin(origin);
254 origin[1] = y / 1000.0;
255 plane1->SetOrigin(origin);
265 plane1->GetOrigin(origin);
266 origin[2] = z / 1000.0;
267 plane1->SetOrigin(origin);
277 plane1->GetNormal(normal);
278 normal[0] = x / 100.0 - 0.5;
279 plane1->SetNormal(normal);
289 plane1->GetNormal(normal);
290 normal[1] = y / 100.0 - 0.50;
291 plane1->SetNormal(normal);
301 plane1->GetNormal(normal);
302 normal[2] = z / 100.0 - 0.50;
303 plane1->SetNormal(normal);
305 plane1->GetOrigin(origin);
void resizeEvent(QResizeEvent *event)
us3DSceneSlicing(std::string imageFileName)
virtual void ResetViews()
static void read(usImageRF2D< short int > &imageRf2D, const std::string &headerFileName)
static void convert(const usImagePostScan3D< unsigned char > &postScanImage, vtkSmartPointer< vtkImageData > &vtkPostScanImage, vtkSmartPointer< vtkImageImport > importer=NULL)