35 #include <QResizeEvent>
36 #include <QApplication>
37 #include <QDesktopWidget>
38 #include "vtkRenderWindow.h"
52 this->setContextMenuPolicy(Qt::CustomContextMenu);
55 connect(
this, SIGNAL(customContextMenuRequested(
const QPoint &)),
this, SLOT(customContextMenuRequestedSlot(
const QPoint &)));
56 this->SetRenderWindow(mView->getRenderWindow());
57 mView->getRenderWindow()->GetInteractor()->EnableRenderOff();
59 disableGLHiDPI(this->winId());
62 void ViewWidget::customContextMenuRequestedSlot(
const QPoint& point)
64 QWidget* sender =
dynamic_cast<QWidget*
>(this->sender());
65 QPoint pointGlobal = sender->mapToGlobal(point);
81 return this->
getView()->getRenderer();
88 unsigned long hash = mView->computeTotalMTime();
90 if (hash != mMTimeHash)
95 QString msg(
"During rendering of view: " + this->
getView()->getName());
100 void ViewWidget::resizeEvent(QResizeEvent * event)
102 inherited::resizeEvent(event);
103 QSize
size =
event->size();
104 vtkRenderWindowInteractor* iren = mView->getRenderWindow()->GetInteractor();
106 iren->UpdateSize(size.width(), size.height());
110 void ViewWidget::mouseMoveEvent(QMouseEvent* event)
112 inherited::mouseMoveEvent(event);
113 emit
mouseMove(event->x(),
event->y(),
event->buttons());
116 void ViewWidget::mousePressEvent(QMouseEvent* event)
121 if ((this->contextMenuPolicy() == Qt::CustomContextMenu) && event->buttons().testFlag(Qt::RightButton))
124 inherited::mousePressEvent(event);
125 emit
mousePress(event->x(),
event->y(),
event->buttons());
128 void ViewWidget::mouseReleaseEvent(QMouseEvent* event)
130 inherited::mouseReleaseEvent(event);
131 emit
mouseRelease(event->x(),
event->y(),
event->buttons());
134 void ViewWidget::focusInEvent(QFocusEvent* event)
136 inherited::focusInEvent(event);
137 emit
focusChange(event->gotFocus(),
event->reason());
140 void ViewWidget::wheelEvent(QWheelEvent* event)
142 inherited::wheelEvent(event);
143 emit
mouseWheel(event->x(),
event->y(),
event->delta(),
event->orientation(),
event->buttons());
146 void ViewWidget::showEvent(QShowEvent* event)
148 inherited::showEvent(event);
152 void ViewWidget::paintEvent(QPaintEvent* event)
154 mView->setModified();
155 inherited::paintEvent(event);
160 if (
similar(factor, mZoomFactor))
164 mZoomFactor = factor;
181 double scale = mZoomFactor / this->
mmPerPix();
199 QDesktopWidget* desktop =
dynamic_cast<QApplication*
>(QApplication::instance())->desktop();
200 QWidget* screen = desktop->screen(desktop->screenNumber(
this));
201 double r_h = (double) screen->heightMM() / (double) screen->geometry().height();
202 double r_w = (double) screen->widthMM() / (double) screen->geometry().width();
203 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.
cstring_cast_Placeholder cstring_cast(const T &val)
#define report_gl_error_text(text)
bool similar(const DoubleBoundingBox3D &a, const DoubleBoundingBox3D &b, double tol)
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.