14 #include <QResizeEvent>
15 #include <QApplication>
16 #include <QDesktopWidget>
17 #include "vtkRenderWindow.h"
32 this->setContextMenuPolicy(Qt::CustomContextMenu);
36 connect(
this, SIGNAL(customContextMenuRequested(
const QPoint &)),
this, SLOT(customContextMenuRequestedSlot(
const QPoint &)));
38 this->SetRenderWindow(renderWindow);
39 mView->getRenderWindow()->GetInteractor()->EnableRenderOff();
41 disableGLHiDPI(this->winId());
44 void ViewWidget::customContextMenuRequestedSlot(
const QPoint& point)
46 QWidget* sender =
dynamic_cast<QWidget*
>(this->sender());
47 QPoint pointGlobal = sender->mapToGlobal(point);
63 return this->
getView()->getRenderer();
70 unsigned long hash = mView->computeTotalMTime();
72 if (hash != mMTimeHash)
74 this->getRenderWindow()->Render();
77 QString msg(
"During rendering of view: " + this->
getView()->getName());
82 void ViewWidget::resizeEvent(QResizeEvent * event)
84 inherited::resizeEvent(event);
85 QSize
size =
event->size();
86 vtkRenderWindowInteractor* iren = mView->getRenderWindow()->GetInteractor();
88 iren->UpdateSize(
size.width(),
size.height());
92 void ViewWidget::mouseMoveEvent(QMouseEvent* event)
94 inherited::mouseMoveEvent(event);
95 emit
mouseMove(event->x(), event->y(), event->buttons());
98 void ViewWidget::mousePressEvent(QMouseEvent* event)
103 if ((this->contextMenuPolicy() == Qt::CustomContextMenu) && event->buttons().testFlag(Qt::RightButton))
106 inherited::mousePressEvent(event);
107 emit
mousePress(event->x(), event->y(), event->buttons());
110 void ViewWidget::mouseReleaseEvent(QMouseEvent* event)
112 inherited::mouseReleaseEvent(event);
113 emit
mouseRelease(event->x(), event->y(), event->buttons());
116 void ViewWidget::focusInEvent(QFocusEvent* event)
118 inherited::focusInEvent(event);
119 emit
focusChange(event->gotFocus(), event->reason());
122 void ViewWidget::wheelEvent(QWheelEvent* event)
124 inherited::wheelEvent(event);
125 emit
mouseWheel(event->x(), event->y(), event->delta(), event->orientation(), event->buttons());
128 void ViewWidget::showEvent(QShowEvent* event)
130 inherited::showEvent(event);
134 void ViewWidget::paintEvent(QPaintEvent* event)
136 mView->setModified();
137 inherited::paintEvent(event);
142 if (
similar(factor, mZoomFactor))
146 mZoomFactor = factor;
163 double scale = mZoomFactor / this->
mmPerPix();
181 QDesktopWidget* desktop =
dynamic_cast<QApplication*
>(QApplication::instance())->desktop();
182 QWidget* screen = desktop->screen(desktop->screenNumber(
this));
183 double r_h = (double) screen->heightMM() / (double) screen->geometry().height();
184 double r_w = (double) screen->widthMM() / (double) screen->geometry().width();
185 double retval = (r_h + r_w) / 2.0;