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()))
193 oldAdapter = boost::dynamic_pointer_cast<ProbeAdapterRTSource>(old);
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)
299 ProbeDefinition probeDefinition;
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()
373 ProbeDefinition probeSector = this->createProbeSector();
378 bool ProbeImpl::isValidConfigId()
384 ProbeDefinition ProbeImpl::createProbeSector()
388 probeSector.setUid(mActiveUid);
392 void ProbeImpl::updateTemporalCalibration()
394 if (mOverrideTemporalCalibration)