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! :)");
163 QString toolFolderAbsolutePath = QFileInfo(toolFile).dir().absolutePath() +
"/";
167 if (toolNode.isNull())
171 +
", this is not a tool file, skipping.");
175 QDomElement toolTypeElement = toolNode.firstChildElement(
mToolTypeTag);
176 QString toolTypeText = toolTypeElement.text();
178 internalStructure->mIsReference = toolTypeText.contains(
"reference", Qt::CaseInsensitive);
179 internalStructure->mIsPointer = toolTypeText.contains(
"pointer", Qt::CaseInsensitive);
180 internalStructure->mIsProbe = toolTypeText.contains(
"usprobe", Qt::CaseInsensitive);
196 QDomElement toolIdElement = toolNode.firstChildElement(
mToolIdTag);
197 QString toolIdText = toolIdElement.text();
198 internalStructure->mUid = toolIdText;
200 QDomElement toolNameElement = toolNode.firstChildElement(
mToolNameTag);
201 QString toolNameText = toolNameElement.text();
202 internalStructure->mName = toolNameText;
205 QString toolClinicalAppText = toolClinicalAppElement.text();
206 QStringList applicationList = toolClinicalAppText.split(
" ");
207 foreach(QString
string, applicationList)
209 if (
string.isEmpty())
211 string =
string.toLower();
212 internalStructure->mClinicalApplications.push_back(
string);
215 QDomElement toolGeofileElement = toolNode.firstChildElement(
mToolGeoFileTag);
216 QString toolGeofileText = toolGeofileElement.text();
217 if (!toolGeofileText.isEmpty())
218 toolGeofileText = toolFolderAbsolutePath + toolGeofileText;
219 internalStructure->mGraphicsFileName = toolGeofileText;
221 QDomElement toolPicfileElement = toolNode.firstChildElement(
mToolPicFileTag);
222 QString toolPicfileText = toolPicfileElement.text();
223 if (!toolPicfileText.isEmpty())
224 toolPicfileText = toolFolderAbsolutePath + toolPicfileText;
225 internalStructure->mPictureFileName = toolPicfileText;
228 if (toolInstrumentElement.isNull())
231 "Could not find the <instrument> tag under the <tool> tag. Aborting this tool.");
234 QDomElement toolInstrumentIdElement = toolInstrumentElement.firstChildElement(
mToolInstrumentIdTag);
235 QString toolInstrumentIdText = toolInstrumentIdElement.text();
236 internalStructure->mInstrumentId = toolInstrumentIdText;
239 QString toolInstrumentScannerIdText = toolInstrumentScannerIdElement.text();
240 internalStructure->mInstrumentScannerId = toolInstrumentScannerIdText;
242 QDomElement toolSensorElement = toolNode.firstChildElement(
mToolSensorTag);
243 if (toolSensorElement.isNull())
245 reportError(
"Could not find the <sensor> tag under the <tool> tag. Aborting this tool.");
248 QDomElement toolSensorTypeElement = toolSensorElement.firstChildElement(
mToolSensorTypeTag);
249 QString toolSensorTypeText = toolSensorTypeElement.text();
250 internalStructure->mTrackerType = string2enum<TRACKING_SYSTEM>(toolSensorTypeText);
253 QString toolSensorWirelessText = toolSensorWirelessElement.text();
254 if (toolSensorWirelessText.contains(
"yes", Qt::CaseInsensitive))
255 internalStructure->mWireless =
true;
256 else if (toolSensorWirelessText.contains(
"no", Qt::CaseInsensitive))
257 internalStructure->mWireless =
false;
259 QDomElement toolSensorDOFElement = toolSensorElement.firstChildElement(
mToolSensorDOFTag);
260 QString toolSensorDOFText = toolSensorDOFElement.text();
261 if (toolSensorDOFText.contains(
"5", Qt::CaseInsensitive))
262 internalStructure->m5DOF =
true;
263 else if (toolSensorDOFText.contains(
"6", Qt::CaseInsensitive))
264 internalStructure->m5DOF =
false;
267 QString toolSensorPortnumberText = toolSensorPortnumberElement.text();
268 internalStructure->mPortNumber = toolSensorPortnumberText.toUInt();
271 QString toolSensorChannelnumberText = toolSensorChannelnumberElement.text();
272 internalStructure->mChannelNumber = toolSensorChannelnumberText.toUInt();
275 for (
int j = 0; j < toolSensorReferencePointList.count(); j++)
277 QDomNode node = toolSensorReferencePointList.item(j);
278 if (!node.hasAttributes())
280 reportWarning(
"Found reference point without id attribute. Skipping.");
284 int id = node.toElement().attribute(
"id").toInt(&ok);
287 reportWarning(
"Attribute id of a reference point was not an int. Skipping.");
290 QString toolSensorReferencePointText = node.toElement().text();
291 Vector3D vector = Vector3D::fromString(toolSensorReferencePointText);
292 internalStructure->mReferencePoints[id] = vector;
296 QString toolSensorRomFileText = toolSensorRomFileElement.text();
297 if (!toolSensorRomFileText.isEmpty())
298 toolSensorRomFileText = toolFolderAbsolutePath + toolSensorRomFileText;
299 internalStructure->mSROMFilename = toolSensorRomFileText;
302 if (toolCalibrationElement.isNull())
305 "Could not find the <calibration> tag under the <tool> tag. Aborting this tool.");
309 QString toolCalibrationFileText = toolCalibrationFileElement.text();
310 if (!toolCalibrationFileText.isEmpty())
311 toolCalibrationFileText = toolFolderAbsolutePath + toolCalibrationFileText;
312 internalStructure->mCalibrationFilename = toolCalibrationFileText;
313 internalStructure->mCalibration = this->
readCalibrationFile(internalStructure->mCalibrationFilename);
317 retval = internalStructure;
325 QFile toolFile(toolAbsoluteFilePath);
326 if (!
mToolDoc.setContent(&toolFile))
328 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.