Fraxinus  16.5.0-fx-rc9
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(ViewServicePtr viewService, PatientModelServicePtr patientModelService, QWidget* parent);
93  virtual ~MetricWidget();
94 
95 signals:
96 
97  public slots:
98  virtual void setModified();
99 
100 protected slots:
101  void itemSelectionChanged();
102 
103  void removeButtonClickedSlot();
104 
105  void loadReferencePointsSlot();
106  void addPointButtonClickedSlot();
107  void addFrameButtonClickedSlot();
108  void addToolButtonClickedSlot();
109  void addPlaneButtonClickedSlot();
110  void addAngleButtonClickedSlot();
111  void addDistanceButtonClickedSlot();
112  void addSphereButtonClickedSlot();
113  void addDonutButtonClickedSlot();
114 
115  void cellChangedSlot(int row, int col);
116  virtual void cellClickedSlot(int row, int column);
117  void exportMetricsButtonClickedSlot();
118  void delayedUpdate();
119 
120 protected:
127 
128 private:
129  virtual void showEvent(QShowEvent* event);
130  virtual void hideEvent(QHideEvent* event);
131  void enablebuttons();
132  MetricBasePtr createMetricWrapper(ViewServicePtr viewService, PatientModelServicePtr patientModelService, DataPtr data);
133  std::vector<MetricBasePtr> createMetricWrappers(ViewServicePtr viewService, PatientModelServicePtr patientModelService);
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
PatientModelServicePtr mPatientModelService
boost::shared_ptr< class ViewService > ViewServicePtr
QAction * mExportFramesAction
boost::shared_ptr< class Data > DataPtr
boost::shared_ptr< class MetricBase > MetricBasePtr
boost::shared_ptr< class MetricManager > MetricManagerPtr
ViewServicePtr mViewService
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Interface for QWidget which handles widgets uniformly for the system.
Definition: cxBaseWidget.h:108
cxLogicManager_EXPORT ViewServicePtr viewService()
QAction * mPointMetricAction
QAction * mToolMetricAction