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)
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;
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)
boost::shared_ptr< class RenderWindowFactory > RenderWindowFactoryPtr
Namespace for all CustusX production code.