Fraxinus  16.5.0-fx-rc9
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxViewWidget.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 CXVIEWWIDGET_H_
34 #define CXVIEWWIDGET_H_
35 
36 #include "QVTKWidget.h"
37 
38 #include "cxTransform3D.h"
39 #include "cxView.h"
40 #include "cxViewRepCollection.h"
41 
42 namespace cx
43 {
44 
49 class ViewWidget : public QVTKWidget
50 {
51 Q_OBJECT
52  typedef QVTKWidget inherited;
53 
54 public:
56 
57  ViewWidget(const QString& uid="", const QString& name = "", QWidget *parent = NULL, Qt::WindowFlags f = 0);
58  virtual ~ViewWidget();
59 
60  virtual vtkRenderWindowPtr getRenderWindow() { return this->getView()->getRenderWindow(); }
61  virtual QSize size() const { return inherited::size(); }
62  virtual void setZoomFactor(double factor);
63  virtual vtkRendererPtr getRenderer();
64  virtual double getZoomFactor() const;
65  virtual Transform3D get_vpMs() const;
66  virtual double mmPerPix() const;
67  virtual DoubleBoundingBox3D getViewport() const;
68  virtual DoubleBoundingBox3D getViewport_s() const;
69 
70  virtual void setModified() { mView->setModified(); }
71  void render();
72 
73 signals:
74  void resized(QSize size);
75  void mouseMove(int x, int y, Qt::MouseButtons buttons);
76  void mousePress(int x, int y, Qt::MouseButtons buttons);
77  void mouseRelease(int x, int y, Qt::MouseButtons buttons);
78  void mouseWheel(int x, int y, int delta, int orientation, Qt::MouseButtons buttons);
79  void shown();
80  void focusChange(bool gotFocus, Qt::FocusReason reason);
81  void customContextMenuRequestedInGlobalPos(const QPoint&);
82 
83 private slots:
84  void customContextMenuRequestedSlot(const QPoint& point);
85 private:
86  virtual void showEvent(QShowEvent* event);
87  virtual void wheelEvent(QWheelEvent*);
88  virtual void mouseMoveEvent(QMouseEvent *event);
89  virtual void mousePressEvent(QMouseEvent *event);
90  virtual void mouseReleaseEvent(QMouseEvent *event);
91  virtual void focusInEvent(QFocusEvent* event);
92  virtual void resizeEvent(QResizeEvent *event);
93  virtual void paintEvent(QPaintEvent *event);
94 
95  double mZoomFactor;
96  boost::shared_ptr<class ViewRepCollection> mView;
97  unsigned long mMTimeHash;
98 };
99 
100 } // namespace cx
101 
102 #endif /* CXVIEWWIDGET_H_ */
void mousePress(int x, int y, Qt::MouseButtons buttons)
virtual vtkRenderWindowPtr getRenderWindow()
Get the vtkRenderWindow used by this View.
Definition: cxViewWidget.h:60
void focusChange(bool gotFocus, Qt::FocusReason reason)
void mouseMove(int x, int y, Qt::MouseButtons buttons)
virtual QSize size() const
Definition: cxViewWidget.h:61
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
vtkSmartPointer< class vtkRenderWindow > vtkRenderWindowPtr
virtual Transform3D get_vpMs() const
virtual vtkRendererPtr getRenderer()
Get the renderer used by this View.
void mouseWheel(int x, int y, int delta, int orientation, Qt::MouseButtons buttons)
ViewWidget(const QString &uid="", const QString &name="", QWidget *parent=NULL, Qt::WindowFlags f=0)
constructor
void resized(QSize size)
virtual DoubleBoundingBox3D getViewport() const
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
virtual double getZoomFactor() const
ViewRepCollectionPtr getView()
void mouseRelease(int x, int y, Qt::MouseButtons buttons)
void customContextMenuRequestedInGlobalPos(const QPoint &)
boost::shared_ptr< class ViewRepCollection > ViewRepCollectionPtr
virtual ~ViewWidget()
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.
virtual DoubleBoundingBox3D getViewport_s() const
virtual double mmPerPix() const
virtual void setModified()
Definition: cxViewWidget.h:70
virtual void setZoomFactor(double factor)