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();
61 void ViewWidget::customContextMenuRequestedSlot(
const QPoint& point)
63 QWidget* sender =
dynamic_cast<QWidget*
>(this->sender());
64 QPoint pointGlobal = sender->mapToGlobal(point);
80 return this->
getView()->getRenderer();
87 unsigned long hash = mView->computeTotalMTime();
89 if (hash != mMTimeHash)
94 QString msg(
"During rendering of view: " + this->
getView()->getName());
99 void ViewWidget::resizeEvent(QResizeEvent * event)
101 inherited::resizeEvent(event);
102 QSize
size =
event->size();
103 vtkRenderWindowInteractor* iren = mView->getRenderWindow()->GetInteractor();
105 iren->UpdateSize(size.width(), size.height());
109 void ViewWidget::mouseMoveEvent(QMouseEvent* event)
111 inherited::mouseMoveEvent(event);
112 emit
mouseMove(event->x(),
event->y(),
event->buttons());
115 void ViewWidget::mousePressEvent(QMouseEvent* event)
120 if ((this->contextMenuPolicy() == Qt::CustomContextMenu) && event->buttons().testFlag(Qt::RightButton))
123 inherited::mousePressEvent(event);
124 emit
mousePress(event->x(),
event->y(),
event->buttons());
127 void ViewWidget::mouseReleaseEvent(QMouseEvent* event)
129 inherited::mouseReleaseEvent(event);
130 emit
mouseRelease(event->x(),
event->y(),
event->buttons());
133 void ViewWidget::focusInEvent(QFocusEvent* event)
135 inherited::focusInEvent(event);
136 emit
focusChange(event->gotFocus(),
event->reason());
139 void ViewWidget::wheelEvent(QWheelEvent* event)
141 inherited::wheelEvent(event);
142 emit
mouseWheel(event->x(),
event->y(),
event->delta(),
event->orientation(),
event->buttons());
145 void ViewWidget::showEvent(QShowEvent* event)
147 inherited::showEvent(event);
151 void ViewWidget::paintEvent(QPaintEvent* event)
153 mView->setModified();
154 inherited::paintEvent(event);
159 if (
similar(factor, mZoomFactor))
163 mZoomFactor = factor;
180 double scale = mZoomFactor / this->
mmPerPix();
198 QDesktopWidget* desktop =
dynamic_cast<QApplication*
>(QApplication::instance())->desktop();
199 QWidget* screen = desktop->screen(desktop->screenNumber(
this));
200 double r_h = (double) screen->heightMM() / (double) screen->geometry().height();
201 double r_w = (double) screen->widthMM() / (double) screen->geometry().width();
202 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.