Fraxinus  16.5.0-fx-rc9
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxViewContainerItem.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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #ifndef CXVIEWCONTAINERITEM_H_
34 #define CXVIEWCONTAINERITEM_H_
35 
36 #include "cxConfig.h"
37 #include <boost/shared_ptr.hpp>
38 #include "vtkForwardDeclarations.h"
39 #include "cxIndent.h"
40 #include <QLayoutItem>
41 #include <QWidget>
42 #include "cxTransform3D.h"
43 #include "cxViewRepCollection.h"
44 
45 class QGridLayout;
46 
47 namespace cx
48 {
49 class DoubleBoundingBox3D;
50 typedef boost::shared_ptr<class Rep> RepPtr;
51 
59 class ViewItem : public QObject, public QLayoutItem
60 {
61 Q_OBJECT
62 
63 public:
64  ViewRepCollectionPtr getView() { return mView; }
65 
66  ViewItem(QString uid, QString name, QWidget *parent, vtkRenderWindowPtr renderWindow, QRect rect);
67  virtual ~ViewItem();
68 
69  virtual vtkRenderWindowPtr getRenderWindow() { return this->getView()->getRenderWindow(); }
70  virtual vtkRendererPtr getRenderer() { return this->getView()->getRenderer(); }
71  virtual QSize size() const { return mGeometry.size(); }
72  virtual void setZoomFactor(double factor);
73 
74  virtual double getZoomFactor() const { return mZoomFactor; }
75  virtual Transform3D get_vpMs() const;
76  virtual DoubleBoundingBox3D getViewport() const;
77  virtual DoubleBoundingBox3D getViewport_s() const;
78  virtual void setModified() { return this->getView()->setModified(); }
79 
80  // Implementing QLayoutItem's pure virtuals
81  virtual Qt::Orientations expandingDirections() const { return Qt::Vertical | Qt::Horizontal; }
82  virtual QRect geometry() const { return mGeometry; }
83  virtual bool isEmpty() const { return false; }
84  virtual QSize maximumSize() const { return mParent->size(); }
85  virtual QSize minimumSize() const { return QSize(100, 100); }
86  virtual void setGeometry(const QRect &r);
87  virtual QSize sizeHint() const { return this->size(); }
88  // end QLayoutItem virtuals
89 
90  // Force signal output
91  void mouseMoveSlot(int x, int y, Qt::MouseButtons buttons) { emit mouseMove(x, y, buttons); }
92  void mousePressSlot(int x, int y, Qt::MouseButtons buttons) { emit mousePress(x, y, buttons); }
93  void mouseReleaseSlot(int x, int y, Qt::MouseButtons buttons) { emit mouseRelease(x, y, buttons); }
94  void mouseWheelSlot(int x, int y, int delta, int orientation, Qt::MouseButtons buttons) { emit mouseWheel(x, y, delta, orientation, buttons); }
95  void resizedSlot(QSize size) { emit resized(size); }
97 
98 signals:
99  void resized(QSize size);
100  void mouseMove(int x, int y, Qt::MouseButtons buttons);
101  void mousePress(int x, int y, Qt::MouseButtons buttons);
102  void mouseRelease(int x, int y, Qt::MouseButtons buttons);
103  void mouseWheel(int x, int y, int delta, int orientation, Qt::MouseButtons buttons);
104  void shown();
105  void focusChange(bool gotFocus, Qt::FocusReason reason);
106  void customContextMenuRequestedInGlobalPos(const QPoint&);
107 
108 private:
109  double mmPerPix() const;
110 
111  QRect mGeometry;
112  QWidget* mParent;
113  double mZoomFactor;
114  boost::shared_ptr<class ViewRepCollection> mView;
115 };
116 
117 } /* namespace cx */
118 #endif /* CXVIEWCONTAINERITEM_H_ */
virtual QSize sizeHint() const
void mouseWheelSlot(int x, int y, int delta, int orientation, Qt::MouseButtons buttons)
void mouseMove(int x, int y, Qt::MouseButtons buttons)
virtual void setModified()
virtual DoubleBoundingBox3D getViewport_s() const
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
void mouseRelease(int x, int y, Qt::MouseButtons buttons)
void mousePress(int x, int y, Qt::MouseButtons buttons)
virtual void setGeometry(const QRect &r)
vtkSmartPointer< class vtkRenderWindow > vtkRenderWindowPtr
virtual void setZoomFactor(double factor)
virtual QSize maximumSize() const
virtual bool isEmpty() const
void mouseReleaseSlot(int x, int y, Qt::MouseButtons buttons)
virtual Qt::Orientations expandingDirections() const
void mousePressSlot(int x, int y, Qt::MouseButtons buttons)
void focusChange(bool gotFocus, Qt::FocusReason reason)
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
ViewItem(QString uid, QString name, QWidget *parent, vtkRenderWindowPtr renderWindow, QRect rect)
void mouseWheel(int x, int y, int delta, int orientation, Qt::MouseButtons buttons)
virtual vtkRendererPtr getRenderer()
void mouseMoveSlot(int x, int y, Qt::MouseButtons buttons)
virtual QSize minimumSize() const
boost::shared_ptr< class ViewRepCollection > ViewRepCollectionPtr
virtual DoubleBoundingBox3D getViewport() const
virtual Transform3D get_vpMs() const
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.
void resized(QSize size)
void customContextMenuRequestedInGlobalPos(const QPoint &)
virtual vtkRenderWindowPtr getRenderWindow()
void resizedSlot(QSize size)
void customContextMenuRequestedGlobalSlot(const QPoint &point)
virtual double getZoomFactor() const
boost::shared_ptr< class Rep > RepPtr
Definition: cxRepManager.h:45
ViewRepCollectionPtr getView()
virtual QSize size() const
virtual QRect geometry() const