13 #include <QVBoxLayout>
15 #include <QTouchEvent>
18 #include <QRadialGradient>
19 #include "vtkRenderer.h"
20 #include "vtkCamera.h"
21 #include "vtkSmartPointer.h"
37 BaseWidget(parent,
"track_pad_widget",
"Camera Control"),
38 mViewService(viewService)
40 this->setToolTip(
"Track pad camera control");
41 mCameraControl = viewService->getCameraControl();
43 mMinPadSize = QSize(50,50);
44 mMinBarSize = QSize(20,50);
46 mTopLayout =
new QVBoxLayout(
this);
48 this->createStandard3DViewActions();
49 this->definePanLayout();
50 this->defineRotateLayout();
53 void TrackPadWidget::createStandard3DViewActions()
57 CX_LOG_WARNING() <<
"TrackPadWidget::createStandard3DViewActions: Got no mCameraControl";
61 QActionGroup* group = mCameraControl->createStandard3DViewActions();
63 QToolBar* toolBar =
new QToolBar(
this);
64 mTopLayout->addWidget(toolBar);
65 toolBar->addActions(group->actions());
66 toolBar->addSeparator();
69 void TrackPadWidget::defineRotateLayout()
71 QGroupBox* group =
new QGroupBox(
"rotate",
this);
73 mTopLayout->addWidget(group);
75 QHBoxLayout* layout =
new QHBoxLayout;
77 group->setLayout(layout);
79 MousePadWidget* rotateWidget =
new MousePadWidget(
this, mMinPadSize);
80 connect(rotateWidget, SIGNAL(mouseMoved(QPointF)),
this, SLOT(
rotateXZSlot(QPointF)));
81 layout->addWidget(rotateWidget, 4);
83 MousePadWidget* rotateYWidget =
new MousePadWidget(
this, mMinBarSize);
84 rotateYWidget->setFixedXPos(
true);
85 connect(rotateYWidget, SIGNAL(mouseMoved(QPointF)),
this, SLOT(
rotateYSlot(QPointF)));
86 layout->addWidget(rotateYWidget, 1);
90 void TrackPadWidget::definePanLayout()
92 QGroupBox* group =
new QGroupBox(
"pan",
this);
94 mTopLayout->addWidget(group);
96 QHBoxLayout* panLayout =
new QHBoxLayout;
97 panLayout->setMargin(4);
98 group->setLayout(panLayout);
100 MousePadWidget* panWidget =
new MousePadWidget(
this, mMinPadSize);
101 connect(panWidget, SIGNAL(mouseMoved(QPointF)),
this, SLOT(
panXZSlot(QPointF)));
102 panLayout->addWidget(panWidget, 4);
104 MousePadWidget* dollyWidget =
new MousePadWidget(
this, mMinBarSize);
105 dollyWidget->setFixedXPos(
true);
106 connect(dollyWidget, SIGNAL(mouseMoved(QPointF)),
this, SLOT(
dollySlot(QPointF)));
107 panLayout->addWidget(dollyWidget, 1);
112 return mViewService->get3DView()->getRenderer()->GetActiveCamera();
118 double factor = scale * delta.y();
120 this->getCamera()->Roll(factor);
128 camera->Azimuth(-scale * delta.x());
129 camera->Elevation(scale * delta.y());
130 camera->OrthogonalizeViewUp();
135 double factor = 1 + delta.y();
136 this->getCamera()->Dolly(factor);
137 mViewService->get3DView()->getRenderer()->ResetCameraClippingRange();
143 Vector3D position(camera->GetPosition());
144 Vector3D focus(camera->GetFocalPoint());
150 DoubleBoundingBox3D bb(mViewService->get3DView()->getRenderer()->ComputeVisiblePropBounds());
152 double volSize = bb.
range().length() / pow(3, 1.0/3.0);
153 double scale = volSize;
154 Vector3D t = scale * (-delta.x() * e_x + delta.y() * e_y);
159 camera->SetPosition(position.begin());
160 camera->SetFocalPoint(focus.begin());
169 QWidget::showEvent(event);
174 QWidget::closeEvent(event);