35 #include <QResizeEvent> 36 #include "vtkRenderWindow.h" 37 #include "vtkRenderer.h" 38 #include <QGridLayout> 51 mRenderWindowFactory(factory),
52 QVTKWidget(parent, f),
53 mMouseEventTarget(NULL),
56 mOffScreenRendering =
false;
57 this->setContextMenuPolicy(Qt::CustomContextMenu);
58 connect(
this, SIGNAL(customContextMenuRequested(
const QPoint &)),
this, SLOT(customContextMenuRequestedSlot(
const QPoint &)));
61 this->setLayout(
new QGridLayout);
62 disableGLHiDPI(this->winId());
90 return dynamic_cast<QGridLayout*
>(layout());
93 void ViewContainer::paintEvent(QPaintEvent* event)
95 inherited_widget::paintEvent(event);
122 this->initializeRenderWindow();
138 mOffScreenRendering = on;
143 return mOffScreenRendering;
146 void ViewContainer::initializeRenderWindow()
151 QString uid = QString(
"rw_oscr=%1").arg(mOffScreenRendering);
153 bool renderWindowExists = mRenderWindowFactory->renderWindowExists(uid);
155 mRenderWindow = mRenderWindowFactory->getRenderWindow(uid, mOffScreenRendering);
156 if(!renderWindowExists)
184 rw->AddRenderer(renderer);
185 renderer->SetViewport(0,0,1,1);
186 QColor background = palette().color(QPalette::Background);
187 renderer->SetBackground(background.redF(), background.greenF(), background.blueF());
190 void ViewContainer::customContextMenuRequestedSlot(
const QPoint& point)
192 ViewItem* item = this->findViewItem(point);
196 QWidget* sender =
dynamic_cast<QWidget*
>(this->sender());
197 QPoint pointGlobal = sender->mapToGlobal(point);
202 void ViewContainer::mouseMoveEvent(QMouseEvent* event)
204 inherited_widget::mouseMoveEvent(event);
213 void ViewContainer::mousePressEvent(QMouseEvent* event)
219 if ((this->contextMenuPolicy() == Qt::CustomContextMenu) && event->buttons().testFlag(Qt::RightButton))
222 inherited_widget::mousePressEvent(event);
232 QPoint ViewContainer::convertToItemSpace(
const QPoint &pos,
ViewItem* item)
const 235 QPoint retval(pos.x() - r.left(), pos.y() - r.top());
239 ViewItem* ViewContainer::findViewItem(
const QPoint &pos)
251 void ViewContainer::mouseReleaseEvent(QMouseEvent* event)
253 inherited_widget::mouseReleaseEvent(event);
263 void ViewContainer::focusInEvent(QFocusEvent* event)
265 inherited_widget::focusInEvent(event);
268 void ViewContainer::wheelEvent(QWheelEvent* event)
270 inherited_widget::wheelEvent(event);
272 ViewItem *item = this->findViewItem(event->pos());
275 QPoint p = this->convertToItemSpace(event->pos(), item);
277 event->delta(),
event->orientation(),
event->buttons());
281 void ViewContainer::showEvent(QShowEvent* event)
283 inherited_widget::showEvent(event);
293 hash += item->
getView()->computeTotalMTime();
301 QString msg(
"During rendering of ViewContainer");
313 void ViewContainer::resizeEvent( QResizeEvent *event)
315 inherited_widget::resizeEvent(event);
void mouseWheelSlot(int x, int y, int delta, int orientation, Qt::MouseButtons buttons)
vtkSmartPointer< class vtkRenderWindow > vtkRenderWindowPtr
cstring_cast_Placeholder cstring_cast(const T &val)
ViewContainer(RenderWindowFactoryPtr factory, QWidget *parent=NULL, Qt::WindowFlags f=0)
LayoutPosition span
size of region
void mouseReleaseSlot(int x, int y, Qt::MouseButtons buttons)
#define report_gl_error_text(text)
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.
static const int MaxGridSize
LayoutPosition pos
start position of region
virtual void setOffScreenRenderingAndClear(bool on)
boost::shared_ptr< class RenderWindowFactory > RenderWindowFactoryPtr
virtual QGridLayout * getGridLayout()
void customContextMenuRequestedGlobalSlot(const QPoint &point)
ViewRepCollectionPtr getView()
virtual QRect geometry() const
virtual bool getOffScreenRendering() const
vtkRenderWindowPtr mRenderWindow
Namespace for all CustusX production code.
ViewItem * mMouseEventTarget