35 #include <QStringList>
53 object->mSelf = retval;
54 retval->initProbeXmlConfigParser(xml);
55 retval->initConfigId();
67 for (std::map<QString, VideoSourcePtr>::iterator iter=mSource.begin(); iter!=mSource.end(); ++iter)
68 retval << iter->first;
78 if (mSource.count(uid))
79 return mSource.find(uid)->second;
80 return mSource.begin()->second;
89 if (mProbeDefinition.count(uid))
90 retval = mProbeDefinition.find(uid)->second;
91 else if (mProbeDefinition.count(
"default"))
92 retval = mProbeDefinition.find(
"default")->second;
94 retval = mProbeDefinition.begin()->second;
110 QDomDocument doc = dataNode.ownerDocument();
111 dataNode.toElement().setAttribute(
"config", mConfigurationId);
116 if (dataNode.isNull())
118 QString cfg = dataNode.toElement().attribute(
"config");
126 if (!this->hasRtSource())
127 return QStringList();
130 QStringList configIdList;
131 QStringList rtSourceList = mXml->getRtSourceList(this->getInstrumentScannerId(), this->getInstrumentId());
132 for (
int i = 0; i < rtSourceList.size(); ++i)
133 configIdList << mXml->getConfigIdList(this->getInstrumentScannerId(), this->getInstrumentId(), rtSourceList[i]);
148 return mConfigurationId;
153 if (!this->hasRtSource())
157 return retval.join(
":");
162 this->setConfigId(uid);
167 void ProbeImpl::applyConfig()
169 this->updateProbeSector();
170 this->updateTemporalCalibration();
177 mOverrideTemporalCalibration =
true;
178 mTemporalCalibration = val;
179 for (std::map<QString, ProbeDefinition>::iterator iter=mProbeDefinition.begin(); iter!=mProbeDefinition.end(); ++iter)
180 iter->second.setTemporalCalibration(mTemporalCalibration);
185 if(
similar(mSoundSpeedCompensationFactor, factor))
187 mSoundSpeedCompensationFactor = factor;
188 for (std::map<QString, ProbeDefinition>::iterator iter=mProbeDefinition.begin(); iter!=mProbeDefinition.end(); ++iter)
189 iter->second.applySoundSpeedCompensationFactor(mSoundSpeedCompensationFactor);
195 if (probeDefinition.
getUid().isEmpty())
196 probeDefinition.
setUid(mActiveUid);
198 mProbeDefinition[probeDefinition.
getUid()] = probeDefinition;
209 if (mSource.count(source->getUid()))
216 if (oldAdapter && (source==oldAdapter->getBaseSource()))
221 mSource[source->getUid()].reset(
new ProbeAdapterRTSource(source->getUid(), mSelf.lock(), source));
231 if (!mSource.count(source->getUid()))
234 mSource.erase(source->getUid());
235 mProbeDefinition.erase(source->getUid());
275 mXml->saveCurrentConfig(config);
281 QString configId = configurationId;
282 if (configId.isEmpty())
283 configId = mConfigurationId;
285 return this->findRtSource(configId);
288 QString ProbeImpl::findRtSource(QString configId)
const
290 QStringList rtSourceList = mXml->getRtSourceList(this->getInstrumentScannerId(), this->getInstrumentId());
293 if(configId.isEmpty() && !rtSourceList.empty())
294 return rtSourceList.at(0);
298 for (
int i = 0; i < rtSourceList.size(); ++i)
300 QStringList configIdList;
301 configIdList << mXml->getConfigIdList(this->getInstrumentScannerId(), this->getInstrumentId(), rtSourceList[i]);
302 if(configIdList.contains(configId))
304 if(!retval.isEmpty())
305 reportWarning(QString(
"Config id is not unique: %1. Scanner %2, probe: %3. Occurring in RT source: %4 and %5").
306 arg(configId).arg(this->getInstrumentScannerId()).arg(this->getInstrumentId()).arg(rtSourceList[i]).arg(retval));
307 retval = rtSourceList[i];
313 ProbeImpl::ProbeImpl(QString instrumentUid, QString scannerUid) :
314 mInstrumentUid(instrumentUid),
315 mScannerUid(scannerUid),
316 mSoundSpeedCompensationFactor(1.0),
317 mOverrideTemporalCalibration(false),
318 mTemporalCalibration(0.0)
320 ProbeDefinition probeDefinition;
321 mProbeDefinition[probeDefinition.getUid()] = probeDefinition;
322 mActiveUid = probeDefinition.getUid();
335 void ProbeImpl::initConfigId()
338 if (!configs.isEmpty())
343 "scanner=[%1] instrument=[%2].\n"
344 "Check that your %3 file contains entries\n"
345 "<USScanner> <Name>%1</Name> ... <USProbe> <Name>%2</Name>").arg(mScannerUid).arg(mInstrumentUid).arg(mXml->getFileName()));
351 if (mConfig.
mConfigId != this->getConfigId())
363 if(this->hasRtSource())
364 config = mXml->getConfiguration(mScannerUid, mInstrumentUid, this->
getRtSourceName(uid), uid);
370 QString ProbeImpl::getInstrumentId()
const
372 return mInstrumentUid;
375 QString ProbeImpl::getInstrumentScannerId()
const
380 bool ProbeImpl::hasRtSource()
const
385 void ProbeImpl::setConfigId(QString uid)
387 mConfigurationId = uid;
390 void ProbeImpl::updateProbeSector()
394 ProbeDefinition probeSector = this->createProbeSector();
399 bool ProbeImpl::isValidConfigId()
405 ProbeDefinition ProbeImpl::createProbeSector()
409 probeSector.setUid(mActiveUid);
413 void ProbeImpl::updateTemporalCalibration()
415 if (mOverrideTemporalCalibration)
< a easy-to-work-with struct for a specific xml configuration
ProbeXmlConfigParser::Configuration getConfiguration()
virtual void saveCurrentConfig(QString uid, QString name)
save current config to disk under ids (uid,name).
virtual ProbeDefinition getProbeDefinition(QString uid="active") const
Return a ProbeDefinition for the given uid. Use 'active' to get the default.
#define CX_ASSERT(statement)
virtual void removeCurrentConfig()
remove the current config from disk
virtual void setActiveStream(QString uid)
virtual VideoSourcePtr getRTSource(QString uid="active") const
Return a VideoSource for the given uid. Use 'active' to get the default stream.
QString mRtSource
realtime source
VideoSource that applies the parameters from a Probe to the VideoSource.
QString getRtSourceName(QString configurationId="") const
virtual QString getConfigName(QString uid)
virtual void setTemporalCalibration(double val)
virtual QString getActiveStream() const
virtual void parseXml(QDomNode &dataNode)
virtual QString getConfigurationPath() const
virtual ProbeSectorPtr getSector(QString uid="active")
virtual void removeRTSource(VideoSourcePtr source)
bool similar(const DoubleBoundingBox3D &a, const DoubleBoundingBox3D &b, double tol)
void videoSourceAdded(VideoSourcePtr source)
virtual void applyNewConfigurationWithId(QString uid)
void reportWarning(QString msg)
QString mConfigId
config id
Implementation of abstract interface ProbeXmlConfigParser Interface to ProbeCalibConfigs.xml.
boost::shared_ptr< class VideoSource > VideoSourcePtr
boost::shared_ptr< ProbeXmlConfigParser > ProbeXmlConfigParserPtr
void sectorChanged()
< Return a ProbeSectorPtr for the given uid. Use 'active' to get the default.
virtual QString getConfigId() const
QString mUsScanner
scanner
boost::shared_ptr< class ProbeSector > ProbeSectorPtr
Definition of characteristics for an Ultrasound Probe Sector.
void activeConfigChanged()
static QString getRootConfigPath()
return path to root config folder. May be replaced with getExistingConfigPath()
virtual void setSoundSpeedCompensationFactor(double val)
boost::shared_ptr< class ProbeImpl > ProbeImplPtr
virtual QStringList getAvailableVideoSources()
Return a list of all available video source. The default is one with uid=='active'.
static ProbeImplPtr New(QString instrumentUid, QString scannerUid, ProbeXmlConfigParserPtr xml=ProbeXmlConfigParserPtr())
QString mName
Name of config set.
virtual QStringList getConfigIdList() const
virtual bool isValid() const
virtual void addXml(QDomNode &dataNode)
Utility functions for drawing an US Probe sector.
virtual void setProbeDefinition(ProbeDefinition probeDefinition)
boost::shared_ptr< ProbeAdapterRTSource > ProbeAdapterRTSourcePtr
ProbeDefinition createProbeDefinitionFromConfiguration(ProbeXmlConfigParser::Configuration config)
ProbeXmlConfigParser::Configuration createConfigurationFromProbeDefinition(ProbeXmlConfigParser::Configuration basis, ProbeDefinition data)
virtual void setRTSource(VideoSourcePtr source)