Fraxinus  17.12
An IGT application
cxDataMetricWrappers.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 #ifndef CXDATAMETRICWRAPPERS_H_
33 #define CXDATAMETRICWRAPPERS_H_
34 
35 #include "cxGuiExport.h"
36 
37 #include <vector>
38 #include <QtWidgets>
39 
40 #include "cxForwardDeclarations.h"
41 #include "cxLandmark.h"
42 #include "cxPointMetric.h"
43 #include "cxDistanceMetric.h"
44 #include "cxAngleMetric.h"
45 #include "cxPlaneMetric.h"
46 #include "cxSphereMetric.h"
48 #include "cxShapedMetric.h"
49 #include "cxCustomMetric.h"
50 #include "cxStringProperty.h"
51 #include "cxVector3DProperty.h"
52 #include "cxColorProperty.h"
53 #include "cxDoubleProperty.h"
54 #include "cxSpaceProperty.h"
55 #include "cxFilePathProperty.h"
56 #include "cxStringListProperty.h"
58 
59 class QVBoxLayout;
60 class QTableWidget;
61 class QPushButton;
62 
63 namespace cx
64 {
65 
72 typedef boost::shared_ptr<class MetricBase> MetricBasePtr;
73 
74 class cxGui_EXPORT MetricBase : public QObject
75 {
76  Q_OBJECT
77 public:
78  MetricBase(VisServicesPtr services);
79  virtual ~MetricBase() {}
80  virtual QWidget* createWidget() = 0;
81  virtual QString getValue() const;
82  virtual DataMetricPtr getData() const = 0;
83  virtual QString getArguments() const = 0;
84  virtual QString getType() const = 0;
85  virtual void update() = 0;
86 
87 private slots:
88  void colorSelected();
89 protected:
91  void addColorWidget(QVBoxLayout* layout);
92  QWidget* newWidget(QString objectName);
94 
95 };
96 
100 class cxGui_EXPORT MetricReferenceArgumentListGui : public QObject
101 {
102  Q_OBJECT
103 public:
105  void setArguments(MetricReferenceArgumentListPtr arguments);
106  void addWidgets(QBoxLayout* layout);
107  QString getAsString() const;
108  void update();
109 //public:
110 // void argumentsChanged();
111 private slots:
112  void pointSelected();
113  void dataChangedSlot();
114 private:
116  std::vector<StringPropertyPtr> mPSelector;
117  bool mInternalUpdate;
118  bool mModified;
119  VisServicesPtr mServices;
120 
121  void getAvailableArgumentMetrics(QStringList* uid, std::map<QString,QString>* namemap);
122 };
123 
124 class cxGui_EXPORT PointMetricWrapper : public MetricBase
125 {
126  Q_OBJECT
127 public:
128  explicit PointMetricWrapper(VisServicesPtr services, PointMetricPtr data);
129  virtual ~PointMetricWrapper();
130  virtual QWidget* createWidget();
131  virtual DataMetricPtr getData() const;
132  virtual QString getArguments() const;
133  virtual QString getType() const;
134  virtual void update();
135 
136 private slots:
137  void moveToToolPosition();
138  void spaceSelected();
139  void coordinateChanged();
140 // void dataChangedSlot();
141 private:
142  QWidget* createSampleButton(QWidget* parent) const;
143  SpacePropertyPtr createSpaceSelector() const;
144  Vector3DPropertyPtr createCoordinateSelector() const;
145  PointMetricPtr mData;
146  SpacePropertyPtr mSpaceSelector;
147  Vector3DPropertyPtr mCoordinate;
148  bool mInternalUpdate;
149 };
150 
151 class cxGui_EXPORT PlaneMetricWrapper : public MetricBase
152 {
153  Q_OBJECT
154 public:
155  explicit PlaneMetricWrapper(VisServicesPtr services, PlaneMetricPtr data);
156  virtual ~PlaneMetricWrapper();
157  virtual QWidget* createWidget();
158  virtual DataMetricPtr getData() const;
159  virtual QString getArguments() const;
160  virtual QString getType() const;
161  virtual void update();
162 
163 private slots:
164  void dataChangedSlot();
165 private:
166  PlaneMetricPtr mData;
168  bool mInternalUpdate;
169 };
170 
171 class cxGui_EXPORT DistanceMetricWrapper : public MetricBase
172 {
173  Q_OBJECT
174 public:
175  explicit DistanceMetricWrapper(VisServicesPtr services, DistanceMetricPtr data);
177  virtual QWidget* createWidget();
178  virtual DataMetricPtr getData() const;
179  virtual QString getArguments() const;
180  virtual QString getType() const;
181  virtual void update();
182 
183 private slots:
184  void dataChangedSlot();
185 
186 private:
187  DistanceMetricPtr mData;
188  bool mInternalUpdate;
190 };
191 
192 class cxGui_EXPORT AngleMetricWrapper : public MetricBase
193 {
194  Q_OBJECT
195 public:
196  explicit AngleMetricWrapper(VisServicesPtr services, AngleMetricPtr data);
197  virtual ~AngleMetricWrapper();
198  virtual QWidget* createWidget();
199  virtual DataMetricPtr getData() const;
200  virtual QString getArguments() const;
201  virtual QString getType() const;
202  virtual void update();
203 
204 private slots:
205  void dataChangedSlot();
206  void guiChanged();
207 
208 private:
209  AngleMetricPtr mData;
211  BoolPropertyPtr mUseSimpleVisualization;
212  bool mInternalUpdate;
213  BoolPropertyPtr createUseSimpleVisualizationSelector() const;
214 
215 };
216 
217 class cxGui_EXPORT DonutMetricWrapper : public MetricBase
218 {
219  Q_OBJECT
220 public:
221  explicit DonutMetricWrapper(VisServicesPtr services, DonutMetricPtr data);
222  virtual ~DonutMetricWrapper() {}
223  virtual QWidget* createWidget();
224 // virtual QString getValue() const;
225  virtual DataMetricPtr getData() const;
226  virtual QString getArguments() const;
227  virtual QString getType() const;
228  virtual void update();
229 
230 private slots:
231  void dataChangedSlot();
232  void guiChanged();
233 
234 private:
235  DoublePropertyPtr createRadiusSelector() const;
236  DoublePropertyPtr createThicknessSelector() const;
237  DoublePropertyPtr createHeightSelector() const;
238  BoolPropertyPtr createFlatSelector() const;
239 
240  DonutMetricPtr mData;
241  DoublePropertyPtr mRadius;
242  DoublePropertyPtr mThickness;
243  DoublePropertyPtr mHeight;
244  BoolPropertyPtr mFlat;
245  bool mInternalUpdate;
247 };
248 
249 class cxGui_EXPORT CustomMetricWrapper : public MetricBase
250 {
251  Q_OBJECT
252 public:
253  explicit CustomMetricWrapper(VisServicesPtr services, CustomMetricPtr data);
254  virtual ~CustomMetricWrapper() {}
255  virtual QWidget* createWidget();
256 // virtual QString getValue() const;
257  virtual DataMetricPtr getData() const;
258  virtual QString getArguments() const;
259  virtual QString getType() const;
260  virtual void update();
261 
262 private slots:
263  void dataChangedSlot();
264  void guiChanged();
265 
266 private:
267  StringPropertyPtr createDefineVectorUpMethodSelector() const;
268  DoublePropertyPtr createOffsetFromP0() const;
269  DoublePropertyPtr createOffsetFromP1() const;
270  DoublePropertyPtr createRepeatDistance() const;
271  BoolPropertyPtr createScaletoP1() const;
272  BoolPropertyPtr createShowDistanceMarkers() const;
273  DoublePropertyPtr createDistanceMarkerVisibility() const;
274  StringPropertySelectDataPtr createModelSelector() const;
275  BoolPropertyPtr createTranslationOnly() const;
276  BoolPropertyPtr createTextureFollowTool() const;
277 
278  CustomMetricPtr mData;
279  StringPropertyPtr mDefineVectorUpMethod;
280  BoolPropertyPtr mScaleToP1;
281  QWidget* mScaleToP1Widget;
282  BoolPropertyPtr mShowDistanceMarkers;
283  BoolPropertyPtr mTranslationOnly;
284  BoolPropertyPtr mTextureFollowTool;
285  DoublePropertyPtr mOffsetFromP0;
286  DoublePropertyPtr mOffsetFromP1;
287  DoublePropertyPtr mRepeatDistance;
288  DoublePropertyPtr mDistanceMarkerVisibility;
289  QWidget* mDistanceMarkerVisibilityWidget;
291  bool mInternalUpdate;
293 };
294 
295 class cxGui_EXPORT SphereMetricWrapper : public MetricBase
296 {
297  Q_OBJECT
298 public:
299  explicit SphereMetricWrapper(VisServicesPtr services, SphereMetricPtr data);
300  virtual ~SphereMetricWrapper() {}
301  virtual QWidget* createWidget();
302 // virtual QString getValue() const;
303  virtual DataMetricPtr getData() const;
304  virtual QString getArguments() const;
305  virtual QString getType() const;
306  virtual void update();
307 
308 private slots:
309  void dataChangedSlot();
310  void guiChanged();
311 
312 private:
313  DoublePropertyPtr createRadiusSelector() const;
314 
315  SphereMetricPtr mData;
316  DoublePropertyPtr mRadius;
317  bool mInternalUpdate;
319 };
320 
321 class cxGui_EXPORT RegionOfInterestMetricWrapper : public MetricBase
322 {
323  Q_OBJECT
324 public:
327  virtual QWidget* createWidget();
328  virtual DataMetricPtr getData() const;
329  virtual QString getArguments() const;
330  virtual QString getType() const;
331  virtual void update();
332 
333 private slots:
334  void dataChangedSlot();
335  void guiChanged();
336 
337 private:
338  StringListPropertyPtr mDataListProperty;
339  BoolPropertyPtr mUseActiveTooltipProperty;
340  StringPropertyPtr mMaxBoundsDataProperty;
341  DoublePropertyPtr mMarginProperty;
342 
344  bool mInternalUpdate;
345 
346  DoublePropertyPtr createMarginSelector() const;
347  StringListPropertyPtr createDataListProperty();
348  BoolPropertyPtr createUseActiveTooltipSelector() const;
349  StringPropertyPtr createMaxBoundsDataSelector();
350 };
351 
352 
353 
357 }
358 
359 #endif /* CXDATAMETRICWRAPPERS_H_ */
boost::shared_ptr< class DistanceMetric > DistanceMetricPtr
boost::shared_ptr< class ColorProperty > ColorPropertyPtr
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:61
boost::shared_ptr< class DonutMetric > DonutMetricPtr
boost::shared_ptr< DataMetric > DataMetricPtr
Definition: cxDataMetric.h:94
boost::shared_ptr< class SpaceProperty > SpacePropertyPtr
boost::shared_ptr< class SphereMetric > SphereMetricPtr
boost::shared_ptr< class AngleMetric > AngleMetricPtr
Definition: cxAngleMetric.h:54
ColorPropertyPtr mColorSelector
boost::shared_ptr< class PlaneMetric > PlaneMetricPtr
Definition: cxPlaneMetric.h:55
boost::shared_ptr< class StringProperty > StringPropertyPtr
boost::shared_ptr< class MetricBase > MetricBasePtr
boost::shared_ptr< class MetricReferenceArgumentList > MetricReferenceArgumentListPtr
boost::shared_ptr< class RegionOfInterestMetric > RegionOfInterestMetricPtr
boost::shared_ptr< class DoubleProperty > DoublePropertyPtr
boost::shared_ptr< class StringListProperty > StringListPropertyPtr
boost::shared_ptr< class Vector3DProperty > Vector3DPropertyPtr
VisServicesPtr mServices
boost::shared_ptr< class StringPropertySelectData > StringPropertySelectDataPtr
boost::shared_ptr< class BoolProperty > BoolPropertyPtr
boost::shared_ptr< class CustomMetric > CustomMetricPtr
Namespace for all CustusX production code.
boost::shared_ptr< class PointMetric > PointMetricPtr