31 if (!filename.isEmpty() && QFile::exists(filename))
40 filename.append(
".cal");
65 report(
"Replaced calibration in " + filename);
71 QString verificationError(
"Internal verification of tool " +
mUid +
" failed! REASON: ");
77 +
" Tag <tool>::<type> is invalid, must be one one of pointer/probe/reference ");
82 reportError(verificationError +
" Tag <tool>::<uid> is empty. Give tool a unique id.");
88 verificationError +
" Tag <sensor>::<type> is invalid [" 90 +
"]. Valid types: [polaris, spectra, vicra, aurora, micron (NOT SUPPORTED YET)]");
96 verificationError +
" Tag <sensor>::<portnumber> is invalid [" 98 +
"]. Valid numbers: [0, 1, 2, 3]");
104 verificationError +
" Tag <sensor>::<channelnumber> is invalid [" 112 verificationError +
" Tag <sensor>::<rom_file> is invalid [" +
mSROMFilename 113 +
"]. Valid path: relative path to existing rom file.");
119 verificationError +
" Tag <calibration>::<cal_file> is invalid [" 121 +
"]. Valid path: relative path to existing calibration file.");
126 reportError(verificationError +
" Logging folder is invalid. Contact programmer! :)");
131 reportError(verificationError +
" Logging folder is invalid. Contact programmer! :)");
164 QString toolFolderAbsolutePath = QFileInfo(toolFile).dir().absolutePath() +
"/";
168 if (toolNode.isNull())
172 +
", this is not a tool file, skipping.");
176 QDomElement toolTypeElement = toolNode.firstChildElement(
mToolTypeTag);
177 QString toolTypeText = toolTypeElement.text();
179 internalStructure->mIsReference = toolTypeText.contains(
"reference", Qt::CaseInsensitive);
180 internalStructure->mIsPointer = toolTypeText.contains(
"pointer", Qt::CaseInsensitive);
181 internalStructure->mIsProbe = toolTypeText.contains(
"usprobe", Qt::CaseInsensitive);
197 QDomElement toolIdElement = toolNode.firstChildElement(
mToolIdTag);
198 QString toolIdText = toolIdElement.text();
199 internalStructure->mUid = toolIdText;
201 QDomElement toolNameElement = toolNode.firstChildElement(
mToolNameTag);
202 QString toolNameText = toolNameElement.text();
203 internalStructure->mName = toolNameText;
206 QString toolClinicalAppText = toolClinicalAppElement.text();
207 QStringList applicationList = toolClinicalAppText.split(
" ");
208 foreach(QString
string, applicationList)
210 if (
string.isEmpty())
212 string =
string.toLower();
213 internalStructure->mClinicalApplications.push_back(
string);
216 QDomElement toolGeofileElement = toolNode.firstChildElement(
mToolGeoFileTag);
217 QString toolGeofileText = toolGeofileElement.text();
218 if (!toolGeofileText.isEmpty())
219 toolGeofileText = toolFolderAbsolutePath + toolGeofileText;
220 internalStructure->mGraphicsFileName = toolGeofileText;
222 QDomElement toolPicfileElement = toolNode.firstChildElement(
mToolPicFileTag);
223 QString toolPicfileText = toolPicfileElement.text();
224 if (!toolPicfileText.isEmpty())
225 toolPicfileText = toolFolderAbsolutePath + toolPicfileText;
226 internalStructure->mPictureFileName = toolPicfileText;
229 QString toolImageIdfileText = toolImageIdfileElement.text();
230 internalStructure->mOpenigtlinkImageId = toolImageIdfileText;
233 QString toolTransformIdfileText = toolTransformIdfileElement.text();
234 internalStructure->mOpenigtlinkTransformId = toolTransformIdfileText;
237 if (toolInstrumentElement.isNull())
240 "Could not find the <instrument> tag under the <tool> tag. Aborting this tool.");
243 QDomElement toolInstrumentIdElement = toolInstrumentElement.firstChildElement(
mToolInstrumentIdTag);
244 QString toolInstrumentIdText = toolInstrumentIdElement.text();
245 internalStructure->mInstrumentId = toolInstrumentIdText;
248 QString toolInstrumentScannerIdText = toolInstrumentScannerIdElement.text();
249 internalStructure->mInstrumentScannerId = toolInstrumentScannerIdText;
251 QDomElement toolSensorElement = toolNode.firstChildElement(
mToolSensorTag);
252 if (toolSensorElement.isNull())
254 reportError(
"Could not find the <sensor> tag under the <tool> tag. Aborting this tool.");
257 QDomElement toolSensorTypeElement = toolSensorElement.firstChildElement(
mToolSensorTypeTag);
258 QString toolSensorTypeText = toolSensorTypeElement.text();
259 internalStructure->mTrackerType = string2enum<TRACKING_SYSTEM>(toolSensorTypeText);
262 QString toolSensorWirelessText = toolSensorWirelessElement.text();
263 if (toolSensorWirelessText.contains(
"yes", Qt::CaseInsensitive))
264 internalStructure->mWireless =
true;
265 else if (toolSensorWirelessText.contains(
"no", Qt::CaseInsensitive))
266 internalStructure->mWireless =
false;
268 QDomElement toolSensorDOFElement = toolSensorElement.firstChildElement(
mToolSensorDOFTag);
269 QString toolSensorDOFText = toolSensorDOFElement.text();
270 if (toolSensorDOFText.contains(
"5", Qt::CaseInsensitive))
271 internalStructure->m5DOF =
true;
272 else if (toolSensorDOFText.contains(
"6", Qt::CaseInsensitive))
273 internalStructure->m5DOF =
false;
276 QString toolSensorPortnumberText = toolSensorPortnumberElement.text();
277 internalStructure->mPortNumber = toolSensorPortnumberText.toUInt();
280 QString toolSensorChannelnumberText = toolSensorChannelnumberElement.text();
281 internalStructure->mChannelNumber = toolSensorChannelnumberText.toUInt();
284 for (
int j = 0; j < toolSensorReferencePointList.count(); j++)
286 QDomNode node = toolSensorReferencePointList.item(j);
287 if (!node.hasAttributes())
289 reportWarning(
"Found reference point without id attribute. Skipping.");
292 QString
id = node.toElement().attribute(
"id");
293 QString toolSensorReferencePointText = node.toElement().text();
294 Vector3D vector = Vector3D::fromString(toolSensorReferencePointText);
295 internalStructure->mReferencePoints[id] = vector;
299 QString toolSensorRomFileText = toolSensorRomFileElement.text();
300 if (!toolSensorRomFileText.isEmpty())
301 toolSensorRomFileText = toolFolderAbsolutePath + toolSensorRomFileText;
302 internalStructure->mSROMFilename = toolSensorRomFileText;
305 if (toolCalibrationElement.isNull())
308 "Could not find the <calibration> tag under the <tool> tag. Aborting this tool.");
312 QString toolCalibrationFileText = toolCalibrationFileElement.text();
313 if (!toolCalibrationFileText.isEmpty())
314 toolCalibrationFileText = toolFolderAbsolutePath + toolCalibrationFileText;
315 internalStructure->mCalibrationFilename = toolCalibrationFileText;
316 internalStructure->mCalibration = this->
readCalibrationFile(internalStructure->mCalibrationFilename);
320 retval = internalStructure;
328 QFile toolFile(toolAbsoluteFilePath);
329 if (!
mToolDoc.setContent(&toolFile))
331 reportError(
"Could not set the xml content of the tool file " + toolAbsoluteFilePath);
QString qstring_cast(const T &val)
void reportError(QString msg)
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Transform3D transform() const
void reportWarning(QString msg)
static Frame3D create(const Transform3D &transform)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
tsAURORA
NDIs Aurora tracker.
Namespace for all CustusX production code.