CustusX  15.3.4-beta
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 #include "cxLegacySingletons.h"
61 
62 class QVBoxLayout;
63 class QTableWidget;
64 class QPushButton;
65 
71 class cxGui_EXPORT CXNoBorderToolButton : public QToolButton
72 {
73  Q_OBJECT
74 public:
75  CXNoBorderToolButton(QWidget* parent=0) : QToolButton(parent) {}
76 };
77 
78 namespace cx
79 {
80 typedef boost::shared_ptr<class MetricManager> MetricManagerPtr;
81 
82 
87 class cxGui_EXPORT MetricWidget : public BaseWidget
88 {
89  Q_OBJECT
90 
91 public:
92  MetricWidget(VisualizationServicePtr visualizationService, PatientModelServicePtr patientModelService, QWidget* parent);
93  virtual ~MetricWidget();
94 
95  virtual QString defaultWhatsThis() const;
96 
97 signals:
98 
99  public slots:
100  virtual void setModified();
101 
102 protected slots:
103  void itemSelectionChanged();
104 
105  void removeButtonClickedSlot();
106 
107  void loadReferencePointsSlot();
108  void addPointButtonClickedSlot();
109  void addFrameButtonClickedSlot();
110  void addToolButtonClickedSlot();
111  void addPlaneButtonClickedSlot();
112  void addAngleButtonClickedSlot();
113  void addDistanceButtonClickedSlot();
114  void addSphereButtonClickedSlot();
115  void addDonutButtonClickedSlot();
116 
117  void cellChangedSlot(int row, int col);
118  virtual void cellClickedSlot(int row, int column);
119  void exportMetricsButtonClickedSlot();
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  MetricBasePtr createMetricWrapper(VisualizationServicePtr visualizationService, PatientModelServicePtr patientModelService, DataPtr data);
135  std::vector<MetricBasePtr> createMetricWrappers(VisualizationServicePtr visualizationService, PatientModelServicePtr patientModelService);
136  virtual void prePaintEvent();
137  std::set<QString> getSelectedUids();
138  void createActions(QActionGroup* group);
139  bool checkEqual(const std::vector<MetricBasePtr>& a, const std::vector<MetricBasePtr>& b) const;
140  void resetWrappersAndEditWidgets(std::vector<MetricBasePtr> wrappers);
141  void initializeTable();
142  void updateTableContents();
143  void expensizeColumnResize();
144  void updateMetricWrappers();
145 
146  QAction* createAction(QActionGroup* group, QString iconName, QString text, QString tip, const char* slot);
147 
148  QVBoxLayout* mVerticalLayout;
149  QTableWidget* mTable;
150 
151  std::vector<MetricBasePtr> mMetrics;
152 
153  QAction* mRemoveAction;
154  QAction* mLoadReferencePointsAction;
155  QStackedWidget* mEditWidgets;
156  MetricManagerPtr mMetricManager;
157  int mModifiedCount;
158  int mPaintCount;
159  QTimer* mDelayedUpdateTimer;
160  bool mLocalModified;
161 };
162 
163 }//end namespace cx
164 
165 #endif /* CXMETRICWIDGET_H_ */
CXNoBorderToolButton(QWidget *parent=0)
QAction * mFrameMetricAction
PatientModelServicePtr mPatientModelService
QAction * mExportFramesAction
VisualizationServicePtr mVisualizationService
boost::shared_ptr< class Data > DataPtr
boost::shared_ptr< class MetricBase > MetricBasePtr
boost::shared_ptr< class VisualizationService > VisualizationServicePtr
Definition: cxRegServices.h:43
boost::shared_ptr< class MetricManager > MetricManagerPtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:108
QAction * mPointMetricAction
QAction * mToolMetricAction