Fraxinus  17.12
An IGT application
cxGraphicalBox.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 CXGRAPHICALBOX_H
34 #define CXGRAPHICALBOX_H
35 
36 #include "cxResourceVisualizationExport.h"
37 
38 #include <QObject>
39 #include <QPointer>
40 #include <vtkSmartPointer.h>
41 #include "cxBoundingBox3D.h"
42 #include "cxForwardDeclarations.h"
43 #include "vtkForwardDeclarations.h"
44 #include "cxTransform3D.h"
45 
46 
47 namespace cx
48 {
49 typedef vtkSmartPointer<class GraphicalBoxCallback> GraphicalBoxCallbackPtr;
50 typedef vtkSmartPointer<class GraphicalBoxEnableCallback> GraphicalBoxEnableCallbackPtr;
51 typedef boost::shared_ptr<class ActiveImageProxy> ActiveImageProxyPtr;
52 
64 class cxResourceVisualization_EXPORT GraphicalBox: public QObject
65 {
66 Q_OBJECT
67 public:
68  explicit GraphicalBox();
69  virtual ~GraphicalBox();
70  void setRenderWindow(vtkRenderWindowPtr renderWindow);
71 
72  DoubleBoundingBox3D getBoundingBox();
73  void setBoundingBox(const DoubleBoundingBox3D& bb_d);
74  void setMaxBoundingBox(const DoubleBoundingBox3D& bb_d);
75  void setPosition(const Transform3D& rMd);
76 // void resetBoundingBox(); ///< set bounding box back to initial size (entire volume)
77  DoubleBoundingBox3D getMaxBoundingBox();
78 
79  bool getInteractive() const; // interactive on/off
80  void setInteractive(bool on);
81  bool getVisible() const; // display on/off
82  void setVisible(bool on);
83 // std::vector<int> getDimensions();
84 signals:
85  void changed(); // any internal state is changed.
86 public slots:
87 // void showBoxWidget(bool on);
88 // void useCropping(bool on);
89 private slots:
90  void updateBoxFromWidget();
91  void updateWidgetFromBox();
92 
93 // void imageCropChangedSlot();
94 // void imageChangedSlot();
95 
96 private:
97 // void boxWasShown(bool val);
98  friend class GraphicalBoxCallback;
100 
101  DoubleBoundingBox3D getCurrentBoxWidgetSize();
102  void setBoxWidgetSize(const DoubleBoundingBox3D &bb_d, Transform3D rMd);
103  void updateBoxWidgetInteractor();
104  void initialize();
105 
106  Transform3D getBoxTransform();
107  void setBoxTransform(const Transform3D& M);
108 
109  vtkRenderWindowPtr mRenderWindow;
110  vtkBoxWidgetPtr mBoxWidget;
111  GraphicalBoxCallbackPtr mGraphicalBoxCallback;
112  GraphicalBoxEnableCallbackPtr mGraphicalBoxEnableCallback;
113  GraphicalBoxEnableCallbackPtr mGraphicalBoxDisableCallback;
114 
115 // bool mShowBoxWidget;
116  DoubleBoundingBox3D mBox;
117  DoubleBoundingBox3D mMaxBox;
118  Transform3D m_rMd; // position of box in r/world space
119  bool mInteractive;
120  bool mVisible;
121 };
122 
123 typedef boost::shared_ptr<GraphicalBox> GraphicalBoxPtr;
124 
128 } // namespace cx
129 
130 
131 #endif // CXGRAPHICALBOX_H
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class ActiveImageProxy > ActiveImageProxyPtr
vtkSmartPointer< class vtkRenderWindow > vtkRenderWindowPtr
boost::shared_ptr< GraphicalBox > GraphicalBoxPtr
vtkSmartPointer< class GraphicalBoxEnableCallback > GraphicalBoxEnableCallbackPtr
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.
vtkSmartPointer< class vtkBoxWidget > vtkBoxWidgetPtr
vtkSmartPointer< class GraphicalBoxCallback > GraphicalBoxCallbackPtr
Namespace for all CustusX production code.