34 #include <QVBoxLayout> 36 #include <QTouchEvent> 39 #include <QRadialGradient> 40 #include "vtkRenderer.h" 41 #include "vtkCamera.h" 42 #include "vtkSmartPointer.h" 58 BaseWidget(parent,
"track_pad_widget",
"Camera Control"),
59 mViewService(viewService)
61 this->setToolTip(
"Track pad camera control");
62 mCameraControl = viewService->getCameraControl();
64 mMinPadSize = QSize(50,50);
65 mMinBarSize = QSize(20,50);
67 mTopLayout =
new QVBoxLayout(
this);
69 this->createStandard3DViewActions();
70 this->definePanLayout();
71 this->defineRotateLayout();
74 void TrackPadWidget::createStandard3DViewActions()
78 CX_LOG_WARNING() <<
"TrackPadWidget::createStandard3DViewActions: Got no mCameraControl";
82 QActionGroup* group = mCameraControl->createStandard3DViewActions();
84 QToolBar* toolBar =
new QToolBar(
this);
85 mTopLayout->addWidget(toolBar);
86 toolBar->addActions(group->actions());
87 toolBar->addSeparator();
90 void TrackPadWidget::defineRotateLayout()
92 QGroupBox* group =
new QGroupBox(
"rotate",
this);
94 mTopLayout->addWidget(group);
96 QHBoxLayout* layout =
new QHBoxLayout;
98 group->setLayout(layout);
101 connect(rotateWidget, SIGNAL(mouseMoved(QPointF)),
this, SLOT(
rotateXZSlot(QPointF)));
102 layout->addWidget(rotateWidget, 4);
106 connect(rotateYWidget, SIGNAL(mouseMoved(QPointF)),
this, SLOT(
rotateYSlot(QPointF)));
107 layout->addWidget(rotateYWidget, 1);
111 void TrackPadWidget::definePanLayout()
113 QGroupBox* group =
new QGroupBox(
"pan",
this);
114 group->setFlat(
true);
115 mTopLayout->addWidget(group);
117 QHBoxLayout* panLayout =
new QHBoxLayout;
118 panLayout->setMargin(4);
119 group->setLayout(panLayout);
122 connect(panWidget, SIGNAL(mouseMoved(QPointF)),
this, SLOT(
panXZSlot(QPointF)));
123 panLayout->addWidget(panWidget, 4);
127 connect(dollyWidget, SIGNAL(mouseMoved(QPointF)),
this, SLOT(
dollySlot(QPointF)));
128 panLayout->addWidget(dollyWidget, 1);
133 return mViewService->get3DView()->getRenderer()->GetActiveCamera();
139 double factor = scale * delta.y();
141 this->getCamera()->Roll(factor);
149 camera->Azimuth(-scale * delta.x());
150 camera->Elevation(scale * delta.y());
151 camera->OrthogonalizeViewUp();
156 double factor = 1 + delta.y();
157 this->getCamera()->Dolly(factor);
158 mViewService->get3DView()->getRenderer()->ResetCameraClippingRange();
164 Vector3D position(camera->GetPosition());
165 Vector3D focus(camera->GetFocalPoint());
171 DoubleBoundingBox3D bb(mViewService->get3DView()->getRenderer()->ComputeVisiblePropBounds());
173 double volSize = bb.
range().length() / pow(3, 1.0/3.0);
174 double scale = volSize;
175 Vector3D t = scale * (-delta.x() * e_x + delta.y() * e_y);
180 camera->SetPosition(position.begin());
181 camera->SetFocalPoint(focus.begin());
190 QWidget::showEvent(event);
195 QWidget::closeEvent(event);
Vector3D cross(const Vector3D &a, const Vector3D &b)
compute cross product of a and b.
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
vtkSmartPointer< class vtkCamera > vtkCameraPtr
Namespace for all CustusX production code.