NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxViewContainer.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXVIEWCONTAINER_H_
13 #define CXVIEWCONTAINER_H_
14 
15 #include "cxResourceVisualizationExport.h"
16 
17 #include "cxConfig.h"
18 #include <boost/shared_ptr.hpp>
19 #include "vtkForwardDeclarations.h"
20 #include "QVTKWidget.h"
21 #include "cxLayoutData.h"
22 #include "cxViewService.h"
23 
24 class QGridLayout;
25 
26 namespace cx
27 {
28 class ViewItem;
29 typedef boost::shared_ptr<class MultiViewCache> MultiViewCachePtr;
30 
39 class cxResourceVisualization_EXPORT ViewContainer : public QVTKWidget
40 {
41  Q_OBJECT
42  typedef QVTKWidget inherited_widget;
43 
44 public:
45  ViewContainer(RenderWindowFactoryPtr factory, QWidget *parent = NULL, Qt::WindowFlags f = 0);
46  virtual ~ViewContainer();
47 
48  ViewItem *addView(QString uid, LayoutRegion region, QString name = "");
49  virtual void clear();
50  void renderAll();
51 
52  virtual void setOffScreenRenderingAndClear(bool on);
53  virtual bool getOffScreenRendering() const;
54 
55  vtkRenderWindowPtr getRenderWindow() { return mRenderWindow; }
56  virtual void setModified();
57 
58  virtual QGridLayout *getGridLayout();
59 
60 private:
61  virtual void paintEvent(QPaintEvent *event);
62  virtual void showEvent(QShowEvent* event);
63  virtual void wheelEvent(QWheelEvent*);
64  virtual void mouseMoveEvent(QMouseEvent *event);
65  virtual void mousePressEvent(QMouseEvent *event);
66  virtual void mouseReleaseEvent(QMouseEvent *event);
67  virtual void focusInEvent(QFocusEvent* event);
68 private slots:
69  void customContextMenuRequestedSlot(const QPoint& point);
70 
71 protected:
74  unsigned long mMTimeHash;
75  virtual void doRender();
76  ViewItem* getViewItem(int index);
77 
78 private:
79  virtual void resizeEvent( QResizeEvent *event);
80  void initializeRenderWindow();
81  void addBackgroundRenderer(vtkRenderWindowPtr rw);
82  QPoint convertToItemSpace(const QPoint &pos, ViewItem* item) const;
83  ViewItem* findViewItem(const QPoint &pos);
84 
85 // std::map<QString, vtkRenderWindowPtr> mCachedRenderWindows; // swap between off/onscreen rw's, but dont delete them.
86  bool mOffScreenRendering;
87  RenderWindowFactoryPtr mRenderWindowFactory;
88 };
89 typedef boost::shared_ptr<ViewContainer> ViewContainerPtr;
90 
91 
92 } /* namespace cx */
93 
94 #endif /* CXVIEWCONTAINER_H_ */
cx::MultiViewCachePtr
boost::shared_ptr< class MultiViewCache > MultiViewCachePtr
Definition: cxViewContainer.h:28
vtkRenderWindowPtr
vtkSmartPointer< class vtkRenderWindow > vtkRenderWindowPtr
Definition: vtkForwardDeclarations.h:124
cx::ViewContainer::mMouseEventTarget
ViewItem * mMouseEventTarget
Definition: cxViewContainer.h:72
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::ViewItem
Definition: cxViewContainerItem.h:38
cx::RenderWindowFactoryPtr
boost::shared_ptr< class RenderWindowFactory > RenderWindowFactoryPtr
Definition: cxForwardDeclarations.h:163
cx::ViewContainerPtr
boost::shared_ptr< ViewContainer > ViewContainerPtr
Definition: cxViewContainer.h:89
cxViewService.h
cx::ViewContainer::mRenderWindow
vtkRenderWindowPtr mRenderWindow
Definition: cxViewContainer.h:73
vtkForwardDeclarations.h
cx::ViewContainer::mMTimeHash
unsigned long mMTimeHash
sum of all MTimes in objects rendered
Definition: cxViewContainer.h:74
cx::LayoutRegion
Definition: cxLayoutData.h:40
cx::ViewContainer
Definition: cxViewContainer.h:39
cx::ViewContainer::getRenderWindow
vtkRenderWindowPtr getRenderWindow()
Definition: cxViewContainer.h:55
cxLayoutData.h