35 #include <QResizeEvent>
36 #include "vtkRenderWindow.h"
37 #include "vtkRenderer.h"
38 #include <QGridLayout>
49 QVTKWidget(parent, f),
50 mMouseEventTarget(NULL),
53 this->setContextMenuPolicy(Qt::CustomContextMenu);
54 connect(
this, SIGNAL(customContextMenuRequested(
const QPoint &)),
this, SLOT(customContextMenuRequestedSlot(
const QPoint &)));
57 this->setLayout(
new QGridLayout);
58 disableGLHiDPI(this->winId());
86 return dynamic_cast<QGridLayout*
>(layout());
89 void ViewContainer::paintEvent(QPaintEvent* event)
91 inherited_widget::paintEvent(event);
118 this->initializeRenderWindow();
131 void ViewContainer::initializeRenderWindow()
140 this->addBackgroundRenderer();
143 void ViewContainer::addBackgroundRenderer()
147 renderer->SetViewport(0,0,1,1);
148 QColor background = palette().color(QPalette::Background);
149 renderer->SetBackground(background.redF(), background.greenF(), background.blueF());
152 void ViewContainer::customContextMenuRequestedSlot(
const QPoint& point)
154 ViewItem* item = this->findViewItem(point);
158 QWidget* sender =
dynamic_cast<QWidget*
>(this->sender());
159 QPoint pointGlobal = sender->mapToGlobal(point);
161 item->customContextMenuRequestedGlobalSlot(pointGlobal);
164 void ViewContainer::mouseMoveEvent(QMouseEvent* event)
166 inherited_widget::mouseMoveEvent(event);
175 void ViewContainer::mousePressEvent(QMouseEvent* event)
181 if ((this->contextMenuPolicy() == Qt::CustomContextMenu) && event->buttons().testFlag(Qt::RightButton))
184 inherited_widget::mousePressEvent(event);
194 QPoint ViewContainer::convertToItemSpace(
const QPoint &pos, ViewItem* item)
const
196 QRect r = item->geometry();
197 QPoint retval(pos.x() - r.left(), pos.y() - r.top());
201 ViewItem* ViewContainer::findViewItem(
const QPoint &pos)
206 QRect r = item->geometry();
213 void ViewContainer::mouseReleaseEvent(QMouseEvent* event)
215 inherited_widget::mouseReleaseEvent(event);
225 void ViewContainer::focusInEvent(QFocusEvent* event)
227 inherited_widget::focusInEvent(event);
230 void ViewContainer::wheelEvent(QWheelEvent* event)
232 inherited_widget::wheelEvent(event);
234 ViewItem *item = this->findViewItem(event->pos());
237 QPoint p = this->convertToItemSpace(event->pos(), item);
238 item->mouseWheelSlot(p.x(), p.y(),
239 event->delta(),
event->orientation(),
event->buttons());
243 void ViewContainer::showEvent(QShowEvent* event)
245 inherited_widget::showEvent(event);
255 hash += item->
getView()->computeTotalMTime();
263 QString msg(
"During rendering of ViewContainer");
273 void ViewContainer::resizeEvent( QResizeEvent *event)
275 inherited_widget::resizeEvent(event);
cstring_cast_Placeholder cstring_cast(const T &val)
LayoutPosition span
size of region
void mouseReleaseSlot(int x, int y, Qt::MouseButtons buttons)
#define report_gl_error_text(text)
ViewContainer(QWidget *parent=NULL, Qt::WindowFlags f=0)
ViewItem * addView(QString uid, LayoutRegion region, QString name="")
void mousePressSlot(int x, int y, Qt::MouseButtons buttons)
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
ViewItem * getViewItem(int index)
vtkRenderWindowPtr getRenderWindow()
unsigned long mMTimeHash
sum of all MTimes in objects rendered
void mouseMoveSlot(int x, int y, Qt::MouseButtons buttons)
void setStretchFactors(QGridLayout *layout, LayoutRegion region, int stretchFactor)
virtual void setModified()
void renderAll()
Use this function to render all views at once. Do not call render on each view.
LayoutPosition pos
start position of region
virtual QGridLayout * getGridLayout()
ViewRepCollectionPtr getView()
vtkRenderWindowPtr mRenderWindow
ViewItem * mMouseEventTarget