Fraxinus  18.10
An IGT application
cxDataInterface.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 #include "cxDataInterface.h"
12 #include "cxImage.h"
13 #include <QSet>
14 #include "cxMesh.h"
15 #include "cxImageLUT2D.h"
16 #include "cxTrackingService.h"
17 #include "cxTypeConversions.h"
18 #include "cxDefinitionStrings.h"
19 #include "cxTool.h"
20 #include "cxImageAlgorithms.h"
22 #include "cxLogger.h"
23 #include "cxActiveImageProxy.h"
24 #include "cxVideoSource.h"
25 #include "cxVideoService.h"
26 #include "cxPatientModelService.h"
27 #include "cxActiveToolProxy.h"
28 #include "cxActiveData.h"
29 
30 namespace cx
31 {
33  mActiveTool(activeTool)
34 {
36 }
37 
39 {
40  return mActiveTool->getTool()->getTooltipOffset();
41 }
42 
44 {
45  mActiveTool->getTool()->setTooltipOffset(val);
46  return true;
47 }
48 
50 {
51  double range = 200;
52  return DoubleRange(0,range,1);
53 }
54 
55 //---------------------------------------------------------
56 //---------------------------------------------------------
57 //---------------------------------------------------------
58 
60  mTool(tool)
61 {
62  this->setTool(tool);
63 }
64 
66 {
67  if (mTool)
68  disconnect(mTool.get(), &Tool::tooltipOffset, this, &Property::changed);
69  mTool = tool;
70  if (mTool)
71  connect(mTool.get(), &Tool::tooltipOffset, this, &Property::changed);
72  emit changed();
73 }
74 
76 {
77  return mTool->getTooltipOffset();
78 }
79 
81 {
82  mTool->setTooltipOffset(val);
83  return true;
84 }
85 
87 {
88  double range = 200;
89  return DoubleRange(0,range,1);
90 }
91 
92 
93 //---------------------------------------------------------
94 //---------------------------------------------------------
95 //---------------------------------------------------------
96 
98  mActiveData(activeData)
99 {
101  connect(mActiveImageProxy.get(), &ActiveImageProxy::activeImageChanged, this, &DoublePropertyActiveImageBase::activeImageChanged);
103 }
104 void DoublePropertyActiveImageBase::activeImageChanged()
105 {
106  mImage = mActiveData->getActive<Image>();
107  emit changed();
108 }
110 {
111  if (!mImage)
112  return 0.0;
113  return getValueInternal();
114 }
116 {
117  if (!mImage)
118  return false;
119  setValueInternal(val);
120  return true;
121 }
122 
123 //---------------------------------------------------------
124 //---------------------------------------------------------
125 
127 {
128  return mImage->getLookupTable2D()->getWindow();
129 }
131 {
132  mImage->getLookupTable2D()->setWindow(val);
133 }
135 {
136  if (!mImage)
137  return DoubleRange();
138  double range = mImage->getRange();
139  return DoubleRange(1,range,range/1000.0);
140 }
141 
142 //---------------------------------------------------------
143 //---------------------------------------------------------
144 
146 {
147  return mImage->getLookupTable2D()->getLevel();
148 }
150 {
151  mImage->getLookupTable2D()->setLevel(val);
152 }
154 {
155  if (!mImage)
156  return DoubleRange();
157 
158  double max = mImage->getMax();
159  return DoubleRange(1,max,max/1000.0);
160 }
161 
162 
163 //---------------------------------------------------------
164 //---------------------------------------------------------
165 //---------------------------------------------------------
166 
167 
169  mPatientModelService(patientModelService)
170 {
172 }
173 
175 {
176  if (mData)
177  disconnect(mData.get(), &Data::transformChanged, this, &Property::changed);
178  mData = data;
179  if (mData)
180  connect(mData.get(), &Data::transformChanged, this, &Property::changed);
181  emit changed();
182 }
183 
185 {
187 }
188 
190 {
191  return "Parent Frame";
192 }
193 
194 bool StringPropertyParentFrame::setValue(const QString& value)
195 {
196  if (!mData)
197  return false;
198  mData->get_rMd_History()->addParentSpace(value);
199  return true;
200 }
201 
203 {
204  if (!mData)
205  return "";
206  return qstring_cast(mData->getParentSpace());
207 }
208 
210 {
211  if (!mData)
212  return "";
213  return "Select the parent frame for " + qstring_cast(mData->getName()) + ".";
214 }
215 
217 {
218  QStringList retval;
219  retval << "";
220 
221  std::map<QString, DataPtr> allData = mPatientModelService->getDatas();
222  for (std::map<QString, DataPtr>::iterator iter=allData.begin(); iter!=allData.end(); ++iter)
223  {
224  if (mData && (mData->getUid() == iter->first))
225  continue;
226 
227  retval << qstring_cast(iter->first);
228  }
229  return retval;
230 }
231 
233 {
234  DataPtr data = mPatientModelService->getData(internal);
235  if (!data)
236  return "<no data>";
237  return qstring_cast(data->getName());
238 }
239 
240 //---------------------------------------------------------
241 //---------------------------------------------------------
242 //---------------------------------------------------------
243 
245  StringPropertyParentFrame(patientModelService)
246 {
247 }
248 
249 bool StringPropertySetParentFrame::setValue(const QString& value)
250 {
251  if (!mData)
252  return false;
253  mData->get_rMd_History()->setParentSpace(value);
254  return true;
255 }
256 
257 //---------------------------------------------------------
258 //---------------------------------------------------------
259 //---------------------------------------------------------
260 
262 {
263 }
264 
266 {
267  return "Name";
268 }
269 
271 {
272  if (!mData)
273  return false;
274  mData->setName(value);
275  return true;
276 }
277 
279 {
280  if (mData)
281  return mData->getName();
282  return "";
283 }
284 
286 {
287  mData = data;
288  emit changed();
289 }
290 
291 //---------------------------------------------------------
292 //---------------------------------------------------------
293 //---------------------------------------------------------
294 
296 {
297 }
298 
300 {
301  return "Uid";
302 }
303 
304 bool StringPropertyDataUidEditable::setValue(const QString& value)
305 {
306  return false;
307 }
308 
310 {
311  if (mData)
312  return mData->getUid();
313  return "";
314 }
315 
317 {
318  mData = data;
319  emit changed();
320 }
321 
322 //---------------------------------------------------------
323 //---------------------------------------------------------
324 //---------------------------------------------------------
325 
327  mPatientModelService(patientModelService)
328 {
330 }
331 
333 {
335 }
336 
338 {
339  if (mData)
340  disconnect(mData.get(), &Data::propertiesChanged, this, &Property::changed);
341  mData = data;
342  if (mData)
343  connect(mData.get(), &Data::propertiesChanged, this, &Property::changed);
344  emit changed();
345 }
346 
348 {
349  return "Modality";
350 }
351 
352 bool StringPropertyDataModality::setValue(const QString& value)
353 {
354  if (!mData)
355  return false;
356  mData->setModality(value);
357  return true;
358 }
359 
361 {
362  if (!mData)
363  return "";
364  return mData->getModality();
365 }
366 
368 {
369  if (!mData)
370  return "";
371  return "Select the modality for " + qstring_cast(mData->getName()) + ".";
372 }
373 
375 {
376  QStringList retval;
377  retval << "";
378  if (mData)
379  retval << mData->getModality();
380  retval << "CT" << "MR" << "US";
381  return QStringList::fromSet(QSet<QString>::fromList(retval));
382 }
383 
384 //---------------------------------------------------------
385 //---------------------------------------------------------
386 //---------------------------------------------------------
387 
389  mPatientModelService(patientModelService)
390 {
392 }
393 
395 {
396  if (mData)
397  disconnect(mData.get(), &Data::propertiesChanged, this, &Property::changed);
398  mData = data;
399  if (mData)
400  connect(mData.get(), &Data::propertiesChanged, this, &Property::changed);
401  emit changed();
402 }
403 
405 {
407 }
408 
410 {
411  return "Image Type";
412 }
413 
414 bool StringPropertyImageType::setValue(const QString& value)
415 {
416  if (!mData)
417  return false;
418  mData->setImageType(value);
419  return true;
420 }
421 
423 {
424  if (!mData)
425  return "";
426  return mData->getImageType();
427 }
428 
430 {
431  if (!mData)
432  return "";
433  return "Select the image type for " + qstring_cast(mData->getName()) + ".";
434 }
435 
437 {
438  QStringList retval;
439  retval << "";
440  if (mData)
441  {
442  retval << mData->getImageType();
443  if (mData->getModality()=="CT")
444  retval << "";
445  if (mData->getModality()=="MR")
446  retval << "T1" << "T2" << "ANGIO";
447  if (mData->getModality()=="US")
448  retval << "B-Mode" << "Angio";
449  }
450  return QStringList::fromSet(QSet<QString>::fromList(retval));
451 }
452 
453 //---------------------------------------------------------
454 //---------------------------------------------------------
455 //---------------------------------------------------------
456 
458  mPatientModelService(patientModelService)
459 {
461 }
462 
464 {
466 }
467 
469 {
470  if (mData)
471  disconnect(mData.get(), &Data::propertiesChanged, this, &Property::changed);
472  mData = data;
473  if (mData)
474  connect(mData.get(), &Data::propertiesChanged, this, &Property::changed);
475  emit changed();
476 }
477 
479 {
480  return "Set glyph orientation array";
481 }
482 
484 {
485  if (!mData)
486  return false;
487  mData->setOrientationArray(value.toStdString().c_str());
488  return true;
489 }
490 
492 {
493  if (!mData)
494  return "";
495  return mData->getOrientationArray();
496 }
497 
499 {
500  if (!mData)
501  return "";
502  return "Select which array to use for orientation of the glyphs.";
503 }
504 
506 {
507  if (!mData)
508  {
509  QStringList retval;
510  retval << "";
511  return retval;
512  }
513  return mData->getOrientationArrayList();
514 }
515 //---------------------------------------------------------
516 //---------------------------------------------------------
517 //---------------------------------------------------------
518 
520  mPatientModelService(patientModelService)
521 {
523 }
524 
526 {
528 }
529 
531 {
532  if (mData)
533  disconnect(mData.get(), &Data::propertiesChanged, this, &Property::changed);
534  mData = data;
535  if (mData)
536  connect(mData.get(), &Data::propertiesChanged, this, &Property::changed);
537  emit changed();
538 }
539 
541 {
542  return "Set glyph color array";
543 }
544 
545 bool StringPropertyGlyphColorArray::setValue(const QString& value)
546 {
547  if (!mData)
548  return false;
549  mData->setColorArray(value.toStdString().c_str());
550  return true;
551 }
552 
554 {
555  if (!mData)
556  return "";
557  return mData->getColorArray();
558 }
559 
561 {
562  if (!mData)
563  return "";
564  return "Select which array to use for coloring the glyphs.";
565 }
566 
568 {
569  if (!mData)
570  {
571  QStringList retval;
572  retval << "";
573  return retval;
574  }
575  return mData->getColorArrayList();
576 }
577 
578 //---------------------------------------------------------
579 //---------------------------------------------------------
580 //---------------------------------------------------------
581 
583  mPatientModelService(patientModelService)
584 {
586 }
587 
589 {
591 }
592 
594 {
595  if (mData)
596  disconnect(mData.get(), &Data::propertiesChanged, this, &Property::changed);
597  mData = data;
598  if (mData)
599  connect(mData.get(), &Data::propertiesChanged, this, &Property::changed);
600  emit changed();
601 }
602 
604 {
605  return "Set glyph color LUT";
606 }
607 
608 bool StringPropertyGlyphLUT::setValue(const QString& value)
609 {
610  if (!mData)
611  return false;
612  mData->setGlyphLUT(value.toStdString().c_str());
613  return true;
614 }
615 
617 {
618  if (!mData)
619  return "";
620  return mData->getGlyphLUT();
621 }
622 
624 {
625  if (!mData)
626  return "";
627  return "Select which color LUT to use for coloring the glyphs.";
628 }
629 
631 {
632  QStringList retval;
633 
634  retval <<
635  "Spectrum"<<
636  "Warm"<<
637  "Cool"<<
638  "Blues"<<
639  "Wild Flower"<<
640  "Citrus"<<
641 
642  "Brewer Diverging Purple-Orange"<<
643  "Brewer Diverging Spectral"<<
644  "Brewer Diverging Brown-Blue-Green"<<
645 
646  "Brewer Sequential Blue-Green"<<
647  "Brewer Sequential Yellow-Orange-Brown"<<
648  "Brewer Sequential Blue-Purple"<<
649 
650  "Brewer Qualitative Accent"<<
651  "Brewer Qualitative Dark2"<<
652  "Brewer Qualitative Set2"<<
653  "Brewer Qualitative Pastel2"<<
654  "Brewer Qualitative Pastel1"<<
655  "Brewer Qualitative Set1"<<
656  "Brewer Qualitative Paired"<<
657  "Brewer Qualitative Set3";
658 
659  return retval;
660 }
661 
662 
663 } // namespace cx
664 
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
QString qstring_cast(const T &val)
StringPropertyParentFrame(PatientModelServicePtr patientModelService)
StringPropertyGlyphOrientationArray(PatientModelServicePtr patientModelService)
virtual QString getDisplayName() const
name of data entity. Used for display to user.
virtual void setValueInternal(double val)
virtual QStringList getValueRange() const
virtual QString getDisplayName() const
name of data entity. Used for display to user.
virtual QString getValue() const
get the data value.
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
virtual double getValue() const
get the data value.
virtual DoubleRange getValueRange() const
virtual bool setValue(const QString &value)
set the data value.
virtual bool setValue(const QString &value)
set the data value.
virtual QString getValue() const
get the data value.
StringPropertyDataModality(PatientModelServicePtr patientModelService)
virtual bool setValue(const QString &value)
set the data value.
void propertiesChanged()
emitted when one of the metadata properties (uid, name etc) changes
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
void transformChanged()
emitted when transform is changed
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:27
virtual QString getDisplayName() const
name of data entity. Used for display to user.
boost::shared_ptr< class ActiveData > ActiveDataPtr
Definition: cxColorWidget.h:21
virtual bool setValue(const QString &value)
set the data value.
virtual double getValueInternal() const =0
StringPropertyGlyphLUT(PatientModelServicePtr patientModelService)
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
DoublePropertyActiveImageBase(ActiveDataPtr activeData)
virtual QString getValue() const
get the data value.
void transferFunctionsChanged()
virtual bool setValue(const QString &value)
set the data value.
virtual void setValueInternal(double val)=0
virtual QString getDisplayName() const
name of data entity. Used for display to user.
virtual bool setValue(const QString &value)
set the data value.
virtual QString getDisplayName() const
name of data entity. Used for display to user.
boost::shared_ptr< class Data > DataPtr
virtual double getValueInternal() const
Adapter that selects the parent frame of the given Data.
virtual bool setValue(double val)
set the data value.
static ActiveImageProxyPtr New(ActiveDataPtr activeData)
void tooltipOffset(double offset)
A volumetric data set.
Definition: cxImage.h:45
virtual QString getValue() const
get the data value.
virtual double getValueInternal() const
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
void tooltipOffset(double offset)
DoubleRange getValueRange() const
virtual QString getValue() const
get the data value.
virtual bool setValue(const QString &value)
set the data value.
virtual QString getValue() const
get the data value.
virtual QString getDisplayName() const
name of data entity. Used for display to user.
boost::shared_ptr< class ActiveToolProxy > ActiveToolProxyPtr
Definition: cxStatusBar.h:32
virtual void setData(DataPtr data)
virtual QString getDisplayName() const
name of data entity. Used for display to user.
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
void changed()
emit when the underlying data value is changed: The user interface will be updated.
virtual QStringList getValueRange() const
virtual QStringList getValueRange() const
virtual QString getValue() const
get the data value.
virtual QStringList getValueRange() const
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
DoublePropertyActiveToolOffset(ActiveToolProxyPtr activeTool)
virtual QStringList getValueRange() const
StringPropertyGlyphColorArray(PatientModelServicePtr patientModelService)
virtual double getValue() const
get the data value.
StringPropertyImageType(PatientModelServicePtr patientModelService)
PatientModelServicePtr mPatientModelService
PatientModelServicePtr mPatientModelService
virtual double getValue() const
get the data value.
PatientModelServicePtr mPatientModelService
PatientModelServicePtr mPatientModelService
virtual QString convertInternal2Display(QString internal)
range of value. Use if data is constrained to a set.
virtual bool setValue(double val)
set the data value.
StringPropertySetParentFrame(PatientModelServicePtr patientModelService)
virtual QStringList getValueRange() const
virtual QString getDisplayName() const
name of data entity. Used for display to user.
virtual bool setValue(const QString &value)
set the data value.
PatientModelServicePtr mPatientModelService
void activeImageChanged(const QString &uid)
The original image changed signal from DataManager.
boost::shared_ptr< class Mesh > MeshPtr
virtual void setData(DataPtr data)
ActiveImageProxyPtr mActiveImageProxy
virtual DoubleRange getValueRange() const
virtual bool setValue(double val)
set the data value.
virtual void setValueInternal(double val)
PatientModelServicePtr mPatientModelService
virtual bool setValue(const QString &value)
set the data value.
virtual QString getValue() const
get the data value.
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr