CustusX  16.5.0-rc9
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxSelectDataStringProperty.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) 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 
34 
35 #include "cxImage.h"
36 #include "cxMesh.h"
37 #include "cxTrackedStream.h"
38 #include "cxTypeConversions.h"
40 #include "cxActiveData.h"
41 
42 namespace cx
43 {
44 
46  SelectDataStringPropertyBase(patientModelService, typeRegexp)
47 {
48  mValueName = "Active Data";
49  mHelp = "Select the active data obejct";
50 
51  mActiveData = mPatientModelService->getActiveData();
54 }
55 
56 bool StringPropertyActiveData::setValue(const QString& value)
57 {
58  DataPtr newData = mPatientModelService->getData(value);
59  if (newData == mActiveData->getActive())
60  return false;
61  mActiveData->setActive(newData);
62  return true;
63 }
64 
66 {
67  QString retval = "";
68  DataPtr activeData = mActiveData->getActiveUsingRegexp(mTypeRegexp);
69 
70  if(activeData)
71  retval = activeData->getUid();
72  return retval;
73 }
74 
76  SelectDataStringPropertyBase(patientModelService, "image")
77 {
78  mValueName = "Active Volume";
79  mHelp = "Select the active volume";
80 
81  mActiveData = mPatientModelService->getActiveData();
84 }
85 
86 bool StringPropertyActiveImage::setValue(const QString& value)
87 {
88  ImagePtr newImage = mPatientModelService->getData<Image>(value);
89  if (newImage==mActiveData->getActive<Image>())
90  return false;
91  mActiveData->setActive(newImage);
92  return true;
93 }
94 
96 {
97  return mActiveData->getActiveImageUid();
98 }
99 
100 //---------------------------------------------------------
101 //---------------------------------------------------------
102 //---------------------------------------------------------
103 
105  SelectDataStringPropertyBase(patientModelService, "image")
106 {
107  mValueName = "Select volume";
108  mHelp = "Select a volume";
109 }
110 
111 bool StringPropertySelectImage::setValue(const QString& value)
112 {
113  if (value==mImageUid)
114  return false;
115  mImageUid = value;
116  emit changed();
117  emit dataChanged(mImageUid);
118  return true;
119 }
120 
122 {
123  return mImageUid;
124 }
125 
127 {
128  return mPatientModelService->getData<Image>(mImageUid);
129 }
130 
131 //---------------------------------------------------------
132 //---------------------------------------------------------
133 //---------------------------------------------------------
134 
135 
137  SelectDataStringPropertyBase(patientModelService, typeRegexp)
138 {
139 }
140 
141 bool StringPropertySelectData::setValue(const QString& value)
142 {
143  if (value==mUid)
144  return false;
145 
146  mUid = "";
147  if (mPatientModelService->getData(value))
148  mUid = value;
149 
150  emit changed();
151  emit dataChanged(this->getValue());
152  return true;
153 }
154 
156 {
157  return mUid;
158 // if(!mData)
159 // return "<no data>";
160 // return mData->getUid();
161 }
162 
164 {
165  return mPatientModelService->getData(mUid);
166 // return mData;
167 }
168 
169 //---------------------------------------------------------
170 //---------------------------------------------------------
171 //---------------------------------------------------------
172 
174  SelectDataStringPropertyBase(patientModelService, "mesh")
175 {
176  mValueName = "Select mesh";
177  mHelp = "Select a mesh";
178 }
179 
180 bool StringPropertySelectMesh::setValue(const QString& value)
181 {
182  if (value==mMeshUid)
183  return false;
184  mMeshUid = value;
185  emit changed();
186  emit dataChanged(mMeshUid);
187  return true;
188 }
189 
191 {
192  return mMeshUid;
193 }
194 
196 {
197  return mPatientModelService->getData<Mesh>(mMeshUid);
198 }
199 
200 //---------------------------------------------------------
201 //---------------------------------------------------------
202 //---------------------------------------------------------
203 
205  SelectDataStringPropertyBase(patientModelService, "trackedStream")
206 {
207  mValueName = "Select stream";
208  mHelp = "Select a tracked stream";
209 }
210 
212 {
213  if (value==mStreamUid)
214  return false;
215  mStreamUid = value;
216  emit changed();
217  emit dataChanged(mStreamUid);
218  return true;
219 }
220 
222 {
223  return mStreamUid;
224 }
225 
227 {
228  return mPatientModelService->getData<TrackedStream>(mStreamUid);
229 }
230 
231 //---------------------------------------------------------
232 //---------------------------------------------------------
233 //---------------------------------------------------------
234 
235 } // namespace cx
236 
A mesh data set.
Definition: cxMesh.h:61
virtual bool setValue(const QString &value)
set the data value.
boost::shared_ptr< class TrackedStream > TrackedStreamPtr
virtual QString getValue() const
get the data value.
virtual QString getValue() const
get the data value.
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:48
StringPropertyActiveData(PatientModelServicePtr patientModelService, QString typeRegexp=".*")
virtual bool setValue(const QString &value)
set the data value.
A data set for video streams (2D/3D).
virtual QString getValue() const
get the data value.
StringPropertyActiveImage(PatientModelServicePtr patientModelService)
boost::shared_ptr< class Data > DataPtr
StringPropertySelectImage(PatientModelServicePtr patientModelService)
virtual bool setValue(const QString &value)
set the data value.
void activeDataChanged(const QString &uId)
A volumetric data set.
Definition: cxImage.h:66
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
StringPropertySelectTrackedStream(PatientModelServicePtr patientModelService)
virtual QString getValue() const
get the data value.
virtual QString getValue() const
get the data value.
void changed()
emit when the underlying data value is changed: The user interface will be updated.
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.
boost::shared_ptr< class Mesh > MeshPtr
virtual bool setValue(const QString &value)
set the data value.
StringPropertySelectData(PatientModelServicePtr patientModelService, QString typeRegexp=".*")
StringPropertySelectMesh(PatientModelServicePtr patientModelService)
void activeImageChanged(const QString &uId)