Fraxinus  17.12
An IGT application
cxMetricWidget.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 /*
34  * cxMetricWidget.h
35  *
36  * \date Jul 5, 2011
37  * \author christiana
38  */
39 
40 #ifndef CXMETRICWIDGET_H_
41 #define CXMETRICWIDGET_H_
42 
43 #include "cxGuiExport.h"
44 
45 #include "cxBaseWidget.h"
46 
47 #include <vector>
48 #include <QtWidgets>
49 
50 #include "cxForwardDeclarations.h"
51 #include "cxLandmark.h"
52 #include "cxPointMetric.h"
53 #include "cxDistanceMetric.h"
54 #include "cxAngleMetric.h"
55 #include "cxPlaneMetric.h"
56 #include "cxStringProperty.h"
57 #include "cxVector3DProperty.h"
58 #include "cxDataMetricWrappers.h"
59 #include "cxFrameMetric.h"
60 
61 class QVBoxLayout;
62 class QTableWidget;
63 class QPushButton;
64 
70 class cxGui_EXPORT CXNoBorderToolButton : public QToolButton
71 {
72  Q_OBJECT
73 public:
74  CXNoBorderToolButton(QWidget* parent=0) : QToolButton(parent) {}
75 };
76 
77 namespace cx
78 {
79 typedef boost::shared_ptr<class MetricManager> MetricManagerPtr;
80 
81 
86 class cxGui_EXPORT MetricWidget : public BaseWidget
87 {
88  Q_OBJECT
89 
90 public:
91  MetricWidget(VisServicesPtr services, QWidget* parent);
92  virtual ~MetricWidget();
93 
94 signals:
95 
96  public slots:
97  virtual void setModified();
98 
99 protected slots:
100  void itemSelectionChanged();
101 
102  void removeButtonClickedSlot();
103 
104  void loadReferencePointsSlot();
105  void addPointButtonClickedSlot();
106  void addFrameButtonClickedSlot();
107  void addToolButtonClickedSlot();
108  void addPlaneButtonClickedSlot();
109  void addAngleButtonClickedSlot();
110  void addDistanceButtonClickedSlot();
111  void addROIButtonClickedSlot();
112  void addSphereButtonClickedSlot();
113  void addDonutButtonClickedSlot();
114  void addCustomButtonClickedSlot();
115 
116  void cellChangedSlot(int row, int col);
117  virtual void cellClickedSlot(int row, int column);
118  void exportMetricsButtonClickedSlot();
119  void importMetricsButtonClickedSlot();
120  void delayedUpdate();
121 
122 protected:
129 
130 private:
131  virtual void showEvent(QShowEvent* event);
132  virtual void hideEvent(QHideEvent* event);
133  void enablebuttons();
134  virtual void prePaintEvent();
135  std::set<QString> getSelectedUids();
136  void createActions(QActionGroup* group);
137  bool checkEqual(const std::vector<MetricBasePtr>& a, const std::vector<MetricBasePtr>& b) const;
138  void resetWrappersAndEditWidgets(std::vector<MetricBasePtr> wrappers);
139  void initializeTable();
140  void updateTableContents();
141  void expensizeColumnResize();
142  void updateMetricWrappers();
143 
144  QAction* createAction(QActionGroup* group, QString iconName, QString text, QString tip, const char* slot);
145 
146  QVBoxLayout* mVerticalLayout;
147  QTableWidget* mTable;
148 
149  std::vector<MetricBasePtr> mMetrics;
150 
151  QAction* mRemoveAction;
152  QAction* mLoadReferencePointsAction;
153  QStackedWidget* mEditWidgets;
154  MetricManagerPtr mMetricManager;
155  int mModifiedCount;
156  int mPaintCount;
157  QTimer* mDelayedUpdateTimer;
158  bool mLocalModified;
159 };
160 
161 }//end namespace cx
162 
163 #endif /* CXMETRICWIDGET_H_ */
CXNoBorderToolButton(QWidget *parent=0)
QAction * mFrameMetricAction
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:61
QAction * mExportFramesAction
boost::shared_ptr< class MetricManager > MetricManagerPtr
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:109
QAction * mImportFramesAction
VisServicesPtr mServices
QAction * mPointMetricAction
QAction * mToolMetricAction
Namespace for all CustusX production code.