36 #include "vtkCamera.h"
48 #include "boost/bind.hpp"
62 retval.mVolume3D =
true;
63 retval.mSlice3D =
false;
64 retval.mSlice2D =
true;
70 retval.mVolume3D =
true;
71 retval.mSlice3D =
true;
72 retval.mSlice2D =
true;
79 retval.mVolume3D =
true;
80 retval.mSlice3D =
false;
81 retval.mSlice2D =
false;
88 retval.mVolume3D =
false;
89 retval.mSlice3D =
true;
90 retval.mSlice2D =
false;
97 retval.mVolume3D =
false;
98 retval.mSlice3D =
false;
99 retval.mSlice2D =
true;
106 retval.mVolume3D =
true;
107 retval.mSlice3D =
true;
108 retval.mSlice2D =
false;
115 QDomElement elem = dataNode.toElement();
116 elem.setAttribute(
"volume3D", mVolume3D);
117 elem.setAttribute(
"slice3D", mSlice3D);
118 elem.setAttribute(
"slice2D", mSlice2D);
123 QDomElement elem = dataNode.toElement();
124 mVolume3D = elem.attribute(
"volume3D", QString::number(mVolume3D)).toInt();
125 mSlice3D = elem.attribute(
"slice3D", QString::number(mSlice3D)).toInt();
126 mSlice2D = elem.attribute(
"slice2D", QString::number(mSlice2D)).toInt();
131 return !(mVolume3D || mSlice3D || mSlice2D);
137 retval.mSlice2D = mSlice2D || rhs.mSlice2D;
138 retval.mSlice3D = mSlice3D || rhs.mSlice3D;
139 retval.mVolume3D = mVolume3D || rhs.mVolume3D;
146 retval.mSlice2D = mSlice2D && !rhs.mSlice2D;
147 retval.mSlice3D = mSlice3D && !rhs.mSlice3D;
148 retval.mVolume3D = mVolume3D && !rhs.mVolume3D;
154 if (required.mSlice2D && mSlice2D)
return true;
155 if (required.mSlice3D && mSlice3D)
return true;
156 if (required.mVolume3D && mVolume3D)
return true;
173 if (data->getType()==
"mesh")
182 if (image->getModality().toUpper().contains(
"US"))
184 if (image->getImageType().toUpper().contains(
"B-MODE"))
189 else if (image->getModality().toUpper().contains(
"MR"))
194 else if (image->getModality().toUpper().contains(
"CT"))
213 mShowLandmarks(false), mShowPointPickerProbe(false),
214 mPickerGlyph(new
Mesh(
"PickerGlyph"))
224 mVideoSource =
"active";
226 mGlobal2DZoom = mGroup2DZoom;
228 this->createSliceDefinitionProperty();
232 void ViewGroupData::purgeDataNotExistingInPatientModelService()
235 for (
unsigned i = 0; i < mData.size(); )
237 QString uid = mData[i].first;
238 if (!mServices->patient()->getData(uid))
240 if (this->contains(uid))
243 mData.erase(std::find_if(mData.begin(), mData.end(), data_equals(uid)));
250 for(
unsigned i = 0; i < purged.size(); ++i)
269 if (this->contains(uid))
273 DataAndViewProperties item(uid, properties);
275 for (
int i=
int(mData.size())-1; i>=0; --i)
279 mData.insert(mData.begin()+i+1, item);
283 if (!this->contains(uid))
284 mData.insert(mData.begin(), item);
290 if (this->contains(uid))
291 return std::find_if(mData.begin(), mData.end(), data_equals(uid))->second;
300 if (properties.
empty())
306 if (!this->contains(uid))
308 DataAndViewProperties item(uid, properties);
309 mData.push_back(item);
313 std::find_if(mData.begin(), mData.end(), data_equals(uid))->second = properties;
319 bool ViewGroupData::contains(QString uid)
const
321 return std::count_if(mData.begin(), mData.end(), data_equals(uid));
326 if (!this->contains(uid))
328 mData.erase(std::find_if(mData.begin(), mData.end(), data_equals(uid)));
335 while (!mData.empty())
339 mGroup2DZoom->set(1.0);
340 mGlobal2DZoom->set(1.0);
345 DataPtr data = mServices->patient()->getData(uid);
348 reportError(
"Couldn't find the data: [" + uid +
"] in the datamanager.");
356 if (mVideoSource==uid)
369 return this->getDataOfType<Data>(properties);
372 template<
class DATA_TYPE>
373 std::vector<boost::shared_ptr<DATA_TYPE> > ViewGroupData::getDataOfType(
DataViewProperties requiredProperties)
const
375 typedef boost::shared_ptr<DATA_TYPE> DATA_PTR;
376 std::vector<DATA_PTR> retval;
377 for (
unsigned i = 0; i < mData.size(); ++i)
379 DATA_PTR data = boost::dynamic_pointer_cast<DATA_TYPE>(this->
getData(mData[i].first));
385 retval.push_back(data);
392 return this->getDataOfType<Image>(properties);
397 return this->getDataOfType<Mesh>(properties);
402 return this->getDataOfType<TrackedStream>(properties);
408 std::vector<TrackedStreamPtr> retval;
410 for(
int i = 0; i < streams.size(); ++i)
412 if(streams[i]->is2D() )
413 retval.push_back(streams[i]);
420 std::vector<ImagePtr> images = this->
getImages(properties);
423 for(
int i = 0; i < streams.size(); ++i)
425 ImagePtr changingImage = streams[i]->getChangingImage();
426 if(streams[i]->is3D())
427 images.push_back(changingImage);
428 if(include2D && streams[i]->is2D())
429 images.push_back(changingImage);
456 return mGlobal2DZoom;
459 void ViewGroupData::createSliceDefinitionProperty()
461 QStringList slicedefs;
462 for (
int i=0; i<ptCOUNT; ++i)
464 QStringList slicedefaults;
468 "Select slice planes to view in 3D",
476 QStringList val = mSliceDefinitionProperty->getValue();
482 QStringList val_list = val.
toString().split(
"/");
483 mSliceDefinitionProperty->setValue(val_list);
488 return mSliceDefinitionProperty;
495 for (
unsigned i = 0; i < mData.size(); ++i)
499 mData[i].second.addXml(elem);
514 for (
unsigned i=0; i<dataElems.size(); ++i)
516 QDomElement elem = dataElems[i];
517 QString uid = elem.text();
540 if (mode == rsPATIENT_REGISTRATED)
int getPriority(DataPtr data)
static DataViewProperties createSlice3D()
ptCORONAL
a slice seen from the front of the patient
void reportError(QString msg)
void initializeGlobal2DZoom(SyncedValuePtr val)
CameraDataPtr getCamera3D()
void addXml(QDomNode &dataNode)
static DataViewProperties createDefault()
void dataAddedOrRemoved()
PlaneTypeCollection getSliceDefinitions()
boost::shared_ptr< DataMetric > DataMetricPtr
void parseXml(QDomNode dataNode)
std::vector< QDomElement > getDuplicateElements(QString name)
boost::shared_ptr< class Image > ImagePtr
std::vector< ImagePtr > getImagesAndChangingImagesFromTrackedStreams(DataViewProperties properties, bool include2D=false) const
SyncedValuePtr getGroup2DZoom()
void parseXml(QDomNode dataNode)
SyncedValuePtr getGlobal2DZoom()
DataViewProperties getProperties(QString uid)
ptAXIAL
a slice seen from the top of the patient
void setProperties(QString uid, DataViewProperties properties)
static DataViewProperties createSlice2D()
static StringListPropertyPtr initialize(const QString &uid, QString name, QString help, QStringList value, QStringList range, QDomNode root=QDomNode())
void addObjectToElement(QString name, T object)
static DataViewProperties create3D()
boost::shared_ptr< class Data > DataPtr
std::vector< MeshPtr > getMeshes(DataViewProperties properties) const
ptSAGITTAL
a slice seen from the side of the patient
static PlaneTypeCollection fromString(QString input, PlaneTypeCollection defVal=PlaneTypeCollection())
void addData(QString uid)
void addDataSorted(QString uid)
add data in a predefined ordering: CT/MR/SC/US/USA/Mesh/Metrics
std::vector< TrackedStreamPtr > getTracked2DStreams(DataViewProperties properties) const
static SyncedValuePtr create(QVariant val=QVariant())
QDomElement addTextToElement(QString name, QString text)
Options getOptions() const
void addXml(QDomNode &dataNode)
bool containsAnyFlagsIn(DataViewProperties required) const
static DataViewProperties createFull()
std::vector< ImagePtr > getImages(DataViewProperties properties) const
std::vector< TrackedStreamPtr > getTrackedStreams(DataViewProperties properties) const
void dataViewPropertiesChanged(QString uid)
void changed()
emit when the underlying data value is changed: The user interface will be updated.
static DataViewProperties createVolume3D()
bool dataTypeSort(const DataPtr data1, const DataPtr data2)
bool removeData(QString uid)
boost::shared_ptr< class StringListProperty > StringListPropertyPtr
QString parseTextFromElement(QString name)
void setVideoSource(QString uid)
boost::shared_ptr< class CoreServices > CoreServicesPtr
DataViewProperties removeFlagsIn(DataViewProperties rhs) const
void parseObjectFromElement(QString name, T object)
DataViewProperties addFlagsIn(DataViewProperties rhs) const
void videoSourceChanged(QString uid)
boost::shared_ptr< class SyncedValue > SyncedValuePtr
void setRegistrationMode(REGISTRATION_STATUS mode)
StringListPropertyPtr getSliceDefinitionProperty()
ViewGroupData(CoreServicesPtr services)
std::vector< DataPtr > getData(DataViewProperties properties=DataViewProperties::createFull()) const
Base class for all Data Metrics.
void setSliceDefinitions(PlaneTypeCollection val)
bool mShowPointPickerProbe
QString enum2string(const ENUM &val)
QString getVideoSource() const
void setOptions(Options options)