34 #include <QVBoxLayout>
36 #include <QTouchEvent>
39 #include <QRadialGradient>
40 #include "vtkRenderer.h"
41 #include "vtkCamera.h"
42 #include "vtkSmartPointer.h"
60 BaseWidget(parent,
"TrackPadWidget",
"Camera Control")
62 this->setToolTip(
"Track pad camera control");
65 mMinPadSize = QSize(50,50);
66 mMinBarSize = QSize(20,50);
68 mTopLayout =
new QVBoxLayout(
this);
70 this->createStandard3DViewActions();
71 this->definePanLayout();
72 this->defineRotateLayout();
75 void TrackPadWidget::createStandard3DViewActions()
77 QActionGroup* group = mCameraControl->createStandard3DViewActions();
79 QToolBar* toolBar =
new QToolBar(
this);
80 mTopLayout->addWidget(toolBar);
81 toolBar->addActions(group->actions());
82 toolBar->addSeparator();
85 void TrackPadWidget::defineRotateLayout()
87 QGroupBox* group =
new QGroupBox(
"rotate",
this);
89 mTopLayout->addWidget(group);
91 QHBoxLayout* layout =
new QHBoxLayout;
93 group->setLayout(layout);
95 MousePadWidget* rotateWidget =
new MousePadWidget(
this, mMinPadSize);
96 connect(rotateWidget, SIGNAL(mouseMoved(QPointF)),
this, SLOT(
rotateXZSlot(QPointF)));
97 layout->addWidget(rotateWidget, 4);
99 MousePadWidget* rotateYWidget =
new MousePadWidget(
this, mMinBarSize);
100 rotateYWidget->setFixedXPos(
true);
101 connect(rotateYWidget, SIGNAL(mouseMoved(QPointF)),
this, SLOT(
rotateYSlot(QPointF)));
102 layout->addWidget(rotateYWidget, 1);
106 void TrackPadWidget::definePanLayout()
108 QGroupBox* group =
new QGroupBox(
"pan",
this);
109 group->setFlat(
true);
110 mTopLayout->addWidget(group);
112 QHBoxLayout* panLayout =
new QHBoxLayout;
113 panLayout->setMargin(4);
114 group->setLayout(panLayout);
116 MousePadWidget* panWidget =
new MousePadWidget(
this, mMinPadSize);
117 connect(panWidget, SIGNAL(mouseMoved(QPointF)),
this, SLOT(
panXZSlot(QPointF)));
118 panLayout->addWidget(panWidget, 4);
120 MousePadWidget* dollyWidget =
new MousePadWidget(
this, mMinBarSize);
121 dollyWidget->setFixedXPos(
true);
122 connect(dollyWidget, SIGNAL(mouseMoved(QPointF)),
this, SLOT(
dollySlot(QPointF)));
123 panLayout->addWidget(dollyWidget, 1);
128 return viewService()->get3DView()->getRenderer()->GetActiveCamera();
134 double factor = scale * delta.y();
136 this->getCamera()->Roll(factor);
144 camera->Azimuth(-scale * delta.x());
145 camera->Elevation(scale * delta.y());
146 camera->OrthogonalizeViewUp();
151 double factor = 1 + delta.y();
152 this->getCamera()->Dolly(factor);
153 viewService()->get3DView()->getRenderer()->ResetCameraClippingRange();
159 Vector3D position(camera->GetPosition());
160 Vector3D focus(camera->GetFocalPoint());
168 double volSize = bb.
range().length() / pow(3, 1.0/3.0);
169 double scale = volSize;
170 Vector3D t = scale * (-delta.x() * e_x + delta.y() * e_y);
175 camera->SetPosition(position.begin());
176 camera->SetFocalPoint(focus.begin());
185 QWidget::showEvent(event);
190 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.
cxLogicManager_EXPORT ViewServicePtr viewService()
vtkSmartPointer< class vtkCamera > vtkCameraPtr