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() +
"/";
166 if (toolNode.isNull())
170 +
", this is not a tool file, skipping.");
174 QDomElement toolTypeElement = toolNode.firstChildElement(
mToolTypeTag);
175 QString toolTypeText = toolTypeElement.text();
177 internalStructure.
mIsReference = toolTypeText.contains(
"reference", Qt::CaseInsensitive);
178 internalStructure.
mIsPointer = toolTypeText.contains(
"pointer", Qt::CaseInsensitive);
179 internalStructure.
mIsProbe = toolTypeText.contains(
"usprobe", Qt::CaseInsensitive);
195 QDomElement toolIdElement = toolNode.firstChildElement(
mToolIdTag);
196 QString toolIdText = toolIdElement.text();
197 internalStructure.
mUid = toolIdText;
199 QDomElement toolNameElement = toolNode.firstChildElement(
mToolNameTag);
200 QString toolNameText = toolNameElement.text();
201 internalStructure.
mName = toolNameText;
204 QString toolClinicalAppText = toolClinicalAppElement.text();
205 QStringList applicationList = toolClinicalAppText.split(
" ");
206 foreach(QString
string, applicationList)
208 if (
string.isEmpty())
210 string =
string.toLower();
214 QDomElement toolGeofileElement = toolNode.firstChildElement(
mToolGeoFileTag);
215 QString toolGeofileText = toolGeofileElement.text();
216 if (!toolGeofileText.isEmpty())
217 toolGeofileText = toolFolderAbsolutePath + toolGeofileText;
220 QDomElement toolPicfileElement = toolNode.firstChildElement(
mToolPicFileTag);
221 QString toolPicfileText = toolPicfileElement.text();
222 if (!toolPicfileText.isEmpty())
223 toolPicfileText = toolFolderAbsolutePath + toolPicfileText;
227 if (toolInstrumentElement.isNull())
230 "Could not find the <instrument> tag under the <tool> tag. Aborting this tool.");
233 QDomElement toolInstrumentIdElement = toolInstrumentElement.firstChildElement(
mToolInstrumentIdTag);
234 QString toolInstrumentIdText = toolInstrumentIdElement.text();
238 QString toolInstrumentScannerIdText = toolInstrumentScannerIdElement.text();
241 QDomElement toolSensorElement = toolNode.firstChildElement(
mToolSensorTag);
242 if (toolSensorElement.isNull())
244 reportError(
"Could not find the <sensor> tag under the <tool> tag. Aborting this tool.");
247 QDomElement toolSensorTypeElement = toolSensorElement.firstChildElement(
mToolSensorTypeTag);
248 QString toolSensorTypeText = toolSensorTypeElement.text();
249 internalStructure.
mTrackerType = string2enum<TRACKING_SYSTEM>(toolSensorTypeText);
252 QString toolSensorWirelessText = toolSensorWirelessElement.text();
253 if (toolSensorWirelessText.contains(
"yes", Qt::CaseInsensitive))
255 else if (toolSensorWirelessText.contains(
"no", Qt::CaseInsensitive))
258 QDomElement toolSensorDOFElement = toolSensorElement.firstChildElement(
mToolSensorDOFTag);
259 QString toolSensorDOFText = toolSensorDOFElement.text();
260 if (toolSensorDOFText.contains(
"5", Qt::CaseInsensitive))
261 internalStructure.
m5DOF =
true;
262 else if (toolSensorDOFText.contains(
"6", Qt::CaseInsensitive))
263 internalStructure.
m5DOF =
false;
266 QString toolSensorPortnumberText = toolSensorPortnumberElement.text();
267 internalStructure.
mPortNumber = toolSensorPortnumberText.toInt();
270 QString toolSensorChannelnumberText = toolSensorChannelnumberElement.text();
271 internalStructure.
mChannelNumber = toolSensorChannelnumberText.toInt();
274 for (
int j = 0; j < toolSensorReferencePointList.count(); j++)
276 QDomNode node = toolSensorReferencePointList.item(j);
277 if (!node.hasAttributes())
279 reportWarning(
"Found reference point without id attribute. Skipping.");
283 int id = node.toElement().attribute(
"id").toInt(&ok);
286 reportWarning(
"Attribute id of a reference point was not an int. Skipping.");
289 QString toolSensorReferencePointText = node.toElement().text();
290 Vector3D vector = Vector3D::fromString(toolSensorReferencePointText);
295 QString toolSensorRomFileText = toolSensorRomFileElement.text();
296 if (!toolSensorRomFileText.isEmpty())
297 toolSensorRomFileText = toolFolderAbsolutePath + toolSensorRomFileText;
301 if (toolCalibrationElement.isNull())
304 "Could not find the <calibration> tag under the <tool> tag. Aborting this tool.");
308 QString toolCalibrationFileText = toolCalibrationFileElement.text();
309 if (!toolCalibrationFileText.isEmpty())
310 toolCalibrationFileText = toolFolderAbsolutePath + toolCalibrationFileText;
316 retval = internalStructure;
324 QFile toolFile(toolAbsoluteFilePath);
325 if (!
mToolDoc.setContent(&toolFile))
327 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.