14 #include <QStringList> 32 object->mSelf = retval;
33 retval->initProbeXmlConfigParser(xml);
34 retval->initConfigId();
46 for (std::map<QString, VideoSourcePtr>::iterator iter=mSource.begin(); iter!=mSource.end(); ++iter)
47 retval << iter->first;
57 if (mSource.count(uid))
58 return mSource.find(uid)->second;
59 return mSource.begin()->second;
68 if (mProbeDefinition.count(uid))
69 retval = mProbeDefinition.find(uid)->second;
70 else if (mProbeDefinition.count(
"default"))
71 retval = mProbeDefinition.find(
"default")->second;
73 retval = mProbeDefinition.begin()->second;
89 QDomDocument doc = dataNode.ownerDocument();
90 dataNode.toElement().setAttribute(
"config", mConfigurationId);
95 if (dataNode.isNull())
97 QString cfg = dataNode.toElement().attribute(
"config");
105 if (!this->hasRtSource())
106 return QStringList();
109 QStringList configIdList;
110 QStringList rtSourceList = mXml->getRtSourceList(this->getInstrumentScannerId(), this->getInstrumentId());
111 for (
int i = 0; i < rtSourceList.size(); ++i)
112 configIdList << mXml->getConfigIdList(this->getInstrumentScannerId(), this->getInstrumentId(), rtSourceList[i]);
127 return mConfigurationId;
132 if (!this->hasRtSource())
136 return retval.join(
":");
141 this->setConfigId(uid);
146 void ProbeImpl::applyConfig()
148 this->updateProbeSector();
149 this->updateTemporalCalibration();
156 mOverrideTemporalCalibration =
true;
157 mTemporalCalibration = val;
158 for (std::map<QString, ProbeDefinition>::iterator iter=mProbeDefinition.begin(); iter!=mProbeDefinition.end(); ++iter)
159 iter->second.setTemporalCalibration(mTemporalCalibration);
164 if(
similar(mSoundSpeedCompensationFactor, factor))
166 mSoundSpeedCompensationFactor = factor;
167 for (std::map<QString, ProbeDefinition>::iterator iter=mProbeDefinition.begin(); iter!=mProbeDefinition.end(); ++iter)
168 iter->second.applySoundSpeedCompensationFactor(mSoundSpeedCompensationFactor);
174 if (probeDefinition.
getUid().isEmpty())
175 probeDefinition.
setUid(mActiveUid);
177 mProbeDefinition[probeDefinition.
getUid()] = probeDefinition;
188 if (mSource.count(source->getUid()))
195 if (oldAdapter && (source==oldAdapter->getBaseSource()))
200 mSource[source->getUid()].reset(
new ProbeAdapterRTSource(source->getUid(), mSelf.lock(), source));
210 if (!mSource.count(source->getUid()))
213 mSource.erase(source->getUid());
214 mProbeDefinition.erase(source->getUid());
254 mXml->saveCurrentConfig(config);
260 QString configId = configurationId;
261 if (configId.isEmpty())
262 configId = mConfigurationId;
264 return this->findRtSource(configId);
267 QString ProbeImpl::findRtSource(QString configId)
const 269 QStringList rtSourceList = mXml->getRtSourceList(this->getInstrumentScannerId(), this->getInstrumentId());
272 if(configId.isEmpty() && !rtSourceList.empty())
273 return rtSourceList.at(0);
277 for (
int i = 0; i < rtSourceList.size(); ++i)
279 QStringList configIdList;
280 configIdList << mXml->getConfigIdList(this->getInstrumentScannerId(), this->getInstrumentId(), rtSourceList[i]);
281 if(configIdList.contains(configId))
283 if(!retval.isEmpty())
284 reportWarning(QString(
"Config id is not unique: %1. Scanner %2, probe: %3. Occurring in RT source: %4 and %5").
285 arg(configId).arg(this->getInstrumentScannerId()).arg(this->getInstrumentId()).arg(rtSourceList[i]).arg(retval));
286 retval = rtSourceList[i];
292 ProbeImpl::ProbeImpl(QString instrumentUid, QString scannerUid) :
293 mInstrumentUid(instrumentUid),
294 mScannerUid(scannerUid),
295 mSoundSpeedCompensationFactor(1.0),
296 mOverrideTemporalCalibration(
false),
297 mTemporalCalibration(0.0)
300 mProbeDefinition[probeDefinition.
getUid()] = probeDefinition;
301 mActiveUid = probeDefinition.
getUid();
314 void ProbeImpl::initConfigId()
317 if (!configs.isEmpty())
322 "scanner=[%1] instrument=[%2].\n" 323 "Check that your %3 file contains entries\n" 324 "<USScanner> <Name>%1</Name> ... <USProbe> <Name>%2</Name>").arg(mScannerUid).arg(mInstrumentUid).arg(mXml->getFileName()));
330 if (mConfig.
mConfigId != this->getConfigId())
342 if(this->hasRtSource())
343 config = mXml->getConfiguration(mScannerUid, mInstrumentUid, this->
getRtSourceName(uid), uid);
349 QString ProbeImpl::getInstrumentId()
const 351 return mInstrumentUid;
354 QString ProbeImpl::getInstrumentScannerId()
const 359 bool ProbeImpl::hasRtSource()
const 364 void ProbeImpl::setConfigId(QString uid)
366 mConfigurationId = uid;
369 void ProbeImpl::updateProbeSector()
378 bool ProbeImpl::isValidConfigId()
388 probeSector.
setUid(mActiveUid);
392 void ProbeImpl::updateTemporalCalibration()
394 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)
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
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
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)
Namespace for all CustusX production code.