32 if (!filename.isEmpty() && QFile::exists(filename))
41 filename.append(
".cal");
66 report(
"Replaced calibration in " + filename);
72 QString verificationError(
"Internal verification of tool " +
mUid +
" failed! REASON: ");
78 +
" Tag <tool>::<type> is invalid, must be one one of pointer/probe/reference ");
83 reportError(verificationError +
" Tag <tool>::<uid> is empty. Give tool a unique id.");
89 verificationError +
" Tag <sensor>::<type> is invalid [" 91 +
"]. Valid types: [polaris, spectra, vicra, aurora, micron (NOT SUPPORTED YET)]");
97 verificationError +
" Tag <sensor>::<portnumber> is invalid [" 99 +
"]. Valid numbers: [0, 1, 2, 3]");
105 verificationError +
" Tag <sensor>::<channelnumber> is invalid [" 113 verificationError +
" Tag <sensor>::<rom_file> is invalid [" +
mSROMFilename 114 +
"]. Valid path: relative path to existing rom file.");
120 verificationError +
" Tag <calibration>::<cal_file> is invalid [" 122 +
"]. Valid path: relative path to existing calibration file.");
127 reportError(verificationError +
" Logging folder is invalid. Contact programmer! :)");
132 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 if (toolInstrumentElement.isNull())
232 "Could not find the <instrument> tag under the <tool> tag. Aborting this tool.");
235 QDomElement toolInstrumentIdElement = toolInstrumentElement.firstChildElement(
mToolInstrumentIdTag);
236 QString toolInstrumentIdText = toolInstrumentIdElement.text();
237 internalStructure->mInstrumentId = toolInstrumentIdText;
240 QString toolInstrumentScannerIdText = toolInstrumentScannerIdElement.text();
241 internalStructure->mInstrumentScannerId = toolInstrumentScannerIdText;
243 QDomElement toolSensorElement = toolNode.firstChildElement(
mToolSensorTag);
244 if (toolSensorElement.isNull())
246 reportError(
"Could not find the <sensor> tag under the <tool> tag. Aborting this tool.");
249 QDomElement toolSensorTypeElement = toolSensorElement.firstChildElement(
mToolSensorTypeTag);
250 QString toolSensorTypeText = toolSensorTypeElement.text();
251 internalStructure->mTrackerType = string2enum<TRACKING_SYSTEM>(toolSensorTypeText);
254 QString toolSensorWirelessText = toolSensorWirelessElement.text();
255 if (toolSensorWirelessText.contains(
"yes", Qt::CaseInsensitive))
256 internalStructure->mWireless =
true;
257 else if (toolSensorWirelessText.contains(
"no", Qt::CaseInsensitive))
258 internalStructure->mWireless =
false;
260 QDomElement toolSensorDOFElement = toolSensorElement.firstChildElement(
mToolSensorDOFTag);
261 QString toolSensorDOFText = toolSensorDOFElement.text();
262 if (toolSensorDOFText.contains(
"5", Qt::CaseInsensitive))
263 internalStructure->m5DOF =
true;
264 else if (toolSensorDOFText.contains(
"6", Qt::CaseInsensitive))
265 internalStructure->m5DOF =
false;
268 QString toolSensorPortnumberText = toolSensorPortnumberElement.text();
269 internalStructure->mPortNumber = toolSensorPortnumberText.toUInt();
272 QString toolSensorChannelnumberText = toolSensorChannelnumberElement.text();
273 internalStructure->mChannelNumber = toolSensorChannelnumberText.toUInt();
276 for (
int j = 0; j < toolSensorReferencePointList.count(); j++)
278 QDomNode node = toolSensorReferencePointList.item(j);
279 if (!node.hasAttributes())
281 reportWarning(
"Found reference point without id attribute. Skipping.");
285 int id = node.toElement().attribute(
"id").toInt(&ok);
288 reportWarning(
"Attribute id of a reference point was not an int. Skipping.");
291 QString toolSensorReferencePointText = node.toElement().text();
292 Vector3D vector = Vector3D::fromString(toolSensorReferencePointText);
293 internalStructure->mReferencePoints[id] = vector;
297 QString toolSensorRomFileText = toolSensorRomFileElement.text();
298 if (!toolSensorRomFileText.isEmpty())
299 toolSensorRomFileText = toolFolderAbsolutePath + toolSensorRomFileText;
300 internalStructure->mSROMFilename = toolSensorRomFileText;
303 if (toolCalibrationElement.isNull())
306 "Could not find the <calibration> tag under the <tool> tag. Aborting this tool.");
310 QString toolCalibrationFileText = toolCalibrationFileElement.text();
311 if (!toolCalibrationFileText.isEmpty())
312 toolCalibrationFileText = toolFolderAbsolutePath + toolCalibrationFileText;
313 internalStructure->mCalibrationFilename = toolCalibrationFileText;
314 internalStructure->mCalibration = this->
readCalibrationFile(internalStructure->mCalibrationFilename);
318 retval = internalStructure;
326 QFile toolFile(toolAbsoluteFilePath);
327 if (!
mToolDoc.setContent(&toolFile))
329 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.