35 #include <QResizeEvent>
36 #include <QApplication>
37 #include <QDesktopWidget>
38 #include "vtkRenderWindow.h"
52 this->setContextMenuPolicy(Qt::CustomContextMenu);
56 connect(
this, SIGNAL(customContextMenuRequested(
const QPoint &)),
this, SLOT(customContextMenuRequestedSlot(
const QPoint &)));
57 this->SetRenderWindow(mView->getRenderWindow());
58 mView->getRenderWindow()->GetInteractor()->EnableRenderOff();
60 disableGLHiDPI(this->winId());
63 void ViewWidget::customContextMenuRequestedSlot(
const QPoint& point)
65 QWidget* sender =
dynamic_cast<QWidget*
>(this->sender());
66 QPoint pointGlobal = sender->mapToGlobal(point);
82 return this->
getView()->getRenderer();
89 unsigned long hash = mView->computeTotalMTime();
91 if (hash != mMTimeHash)
96 QString msg(
"During rendering of view: " + this->
getView()->getName());
101 void ViewWidget::resizeEvent(QResizeEvent * event)
103 inherited::resizeEvent(event);
104 QSize
size =
event->size();
105 vtkRenderWindowInteractor* iren = mView->getRenderWindow()->GetInteractor();
107 iren->UpdateSize(size.width(), size.height());
111 void ViewWidget::mouseMoveEvent(QMouseEvent* event)
113 inherited::mouseMoveEvent(event);
114 emit
mouseMove(event->x(),
event->y(),
event->buttons());
117 void ViewWidget::mousePressEvent(QMouseEvent* event)
122 if ((this->contextMenuPolicy() == Qt::CustomContextMenu) && event->buttons().testFlag(Qt::RightButton))
125 inherited::mousePressEvent(event);
126 emit
mousePress(event->x(),
event->y(),
event->buttons());
129 void ViewWidget::mouseReleaseEvent(QMouseEvent* event)
131 inherited::mouseReleaseEvent(event);
132 emit
mouseRelease(event->x(),
event->y(),
event->buttons());
135 void ViewWidget::focusInEvent(QFocusEvent* event)
137 inherited::focusInEvent(event);
138 emit
focusChange(event->gotFocus(),
event->reason());
141 void ViewWidget::wheelEvent(QWheelEvent* event)
143 inherited::wheelEvent(event);
144 emit
mouseWheel(event->x(),
event->y(),
event->delta(),
event->orientation(),
event->buttons());
147 void ViewWidget::showEvent(QShowEvent* event)
149 inherited::showEvent(event);
153 void ViewWidget::paintEvent(QPaintEvent* event)
155 mView->setModified();
156 inherited::paintEvent(event);
161 if (
similar(factor, mZoomFactor))
165 mZoomFactor = factor;
182 double scale = mZoomFactor / this->
mmPerPix();
200 QDesktopWidget* desktop =
dynamic_cast<QApplication*
>(QApplication::instance())->desktop();
201 QWidget* screen = desktop->screen(desktop->screenNumber(
this));
202 double r_h = (double) screen->heightMM() / (double) screen->geometry().height();
203 double r_w = (double) screen->widthMM() / (double) screen->geometry().width();
204 double retval = (r_h + r_w) / 2.0;
DoubleBoundingBox3D transform(const Transform3D &m, const DoubleBoundingBox3D &bb)
Transform3D createTransformScale(const Vector3D &scale_)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
vtkSmartPointer< class vtkRenderWindow > vtkRenderWindowPtr
cstring_cast_Placeholder cstring_cast(const T &val)
#define report_gl_error_text(text)
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
Transform3D createTransformTranslate(const Vector3D &translation)
boost::shared_ptr< class ViewRepCollection > ViewRepCollectionPtr
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.
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)