36 return QList<DataPtr>();
62 virtual void remove(
DataPtr dataToBeRemoved)
83 mStorage(new
PatientStorage(sessionStorageService,
"ActiveData", true)),
84 mPatientModelService(patientModelService)
86 mStorage->storeVariable(
"activeUids",
87 boost::bind(&ActiveData::getStringToSave,
this),
88 boost::bind(&ActiveData::loadFromString,
this, _1));
91 QString ActiveData::getStringToSave()
const 93 return this->getActiveDataStringList().join(
" ");
96 QStringList ActiveData::getActiveDataStringList()
const 99 if(!mActiveData.isEmpty())
100 for(
int i = 0; i < mActiveData.size(); ++i)
101 retval << mActiveData.at(i)->getUid();
105 void ActiveData::loadFromString(
const QString activeDatas)
108 QStringList activeDataList = activeDatas.split(
" ");
109 for(
int i = 0; i < activeDataList.size(); ++i)
111 DataPtr data = mPatientModelService->getData(activeDataList.at(i));
123 if(mActiveData.isEmpty())
125 return mActiveData.last();
133 if(!activeDatas.isEmpty())
134 activeData = activeDatas.last();
147 retval = boost::dynamic_pointer_cast<
Image>(activeData);
153 QRegExp reg(typeRegexp);
155 QList<DataPtr> retval;
157 for(
int i = 0; i < active.size(); ++i)
160 if(current->getType().contains(reg))
161 retval.push_back(current);
171 if (!mActiveData.empty() && mActiveData.last() == activeData)
174 mActiveData.removeAll(activeData);
175 mActiveData.append(activeData);
177 this->emitSignals(activeData);
182 DataPtr dataToSet = mPatientModelService->getData(uid);
188 ImagePtr image = this->getActive<Image>();
190 return image->getUid();
195 void ActiveData::emitSignals(
DataPtr activeData)
197 this->emitActiveDataChanged();
199 this->emitActiveImageChanged();
202 void ActiveData::emitActiveImageChanged()
204 DataPtr activeData = ActiveData::getActive<Image>();
205 QString uid = getChangedUid(activeData);
209 void ActiveData::emitActiveDataChanged()
212 QString uid = getChangedUid(activeData);
216 QString ActiveData::getChangedUid(
DataPtr activeData)
const 220 uid = activeData->getUid();
228 if(!mActiveData.contains(dataToBeRemoved))
231 bool resendActiveImage =
false;
232 bool resendActiveData =
false;
233 if (this->getActive<Image>() == dataToBeRemoved)
234 resendActiveImage =
true;
236 resendActiveData =
true;
238 mActiveData.removeAll(dataToBeRemoved);
240 if(resendActiveImage)
241 emitActiveImageChanged();
243 emitActiveDataChanged();
virtual ImagePtr getDerivedActiveImage() const
In addition to returning Image this also provides derived (changing) images from TrackedStream.
virtual QList< DataPtr > getActiveDataHistory() const
virtual ImagePtr getDerivedActiveImage() const
In addition to returning Image this also provides derived (changing) images from TrackedStream.
virtual DataPtr getActiveUsingRegexp(QString typeRegexp) const
boost::shared_ptr< class TrackedStream > TrackedStreamPtr
Helper class for storing variables in the patient file.
Provides the last active data of warious types.
boost::shared_ptr< class Image > ImagePtr
boost::shared_ptr< class ActiveData > ActiveDataPtr
A data set for video streams (2D/3D).
static ActiveDataPtr getNullObject()
virtual void remove(DataPtr dataToBeRemoved)
ActiveData(PatientModelServicePtr patientModelService, SessionStorageServicePtr sessionStorageService)
boost::shared_ptr< class Data > DataPtr
virtual bool isNull() const
virtual DataPtr getActive() const
virtual void setActive(DataPtr activeData)
void reportWarning(QString msg)
void activeDataChanged(const QString &uId)
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
static QString getTypeName()
ImagePtr getChangingImage()
virtual DataPtr getActiveUsingRegexp(QString typeRegexp) const
virtual QString getActiveImageUid()
virtual QList< DataPtr > getActiveDataHistory() const
void printWarning(QString warning="") const
virtual DataPtr getActive() const
static ActiveDataPtr getNullObject()
virtual QString getActiveImageUid()
virtual void setActive(DataPtr activeData)
boost::shared_ptr< class SessionStorageService > SessionStorageServicePtr
void activeImageChanged(const QString &uId)
Namespace for all CustusX production code.