void ViewWrapper2D::appendToContextMenu(QMenu& contextMenu) { QAction* obliqueAction = new QAction("Oblique", &contextMenu); obliqueAction->setCheckable(true); obliqueAction->setData(qstring_cast(otOBLIQUE)); obliqueAction->setChecked(getOrientationType() == otOBLIQUE); connect(obliqueAction, SIGNAL(triggered()), this, SLOT(orientationActionSlot())); QAction* ortogonalAction = new QAction("Ortogonal", &contextMenu); ortogonalAction->setCheckable(true); ortogonalAction->setData(qstring_cast(otORTHOGONAL)); ortogonalAction->setChecked(getOrientationType() == otORTHOGONAL); connect(ortogonalAction, SIGNAL(triggered()), this, SLOT(orientationActionSlot())); //TODO remove actiongroups? mOrientationActionGroup->addAction(obliqueAction); mOrientationActionGroup->addAction(ortogonalAction); contextMenu.addSeparator(); contextMenu.addAction(obliqueAction); contextMenu.addAction(ortogonalAction); contextMenu.addSeparator(); mZoom2D->addActionsToMenu(&contextMenu); }
void SphereSyntheticVolume::printInfo() const { std::cout << QString("Volume: Sphere, bounds=[%1], C=[%2], R=[%3]") .arg(qstring_cast(mBounds)) .arg(qstring_cast(mCenter)) .arg(mRadius) << std::endl; }
void DonutMetric::parseXml(QDomNode& dataNode) { DataMetric::parseXml(dataNode); mArguments->parseXml(dataNode, mDataManager->getData()); mRadius = dataNode.toElement().attribute("radius", qstring_cast(mRadius)).toDouble(); mThickness = dataNode.toElement().attribute("thickness", qstring_cast(mThickness)).toDouble(); mHeight = dataNode.toElement().attribute("height", qstring_cast(mHeight)).toDouble(); mFlat = dataNode.toElement().attribute("flat", qstring_cast(mFlat)).toInt(); }
void Image::addXml(QDomNode& dataNode) { Data::addXml(dataNode); QDomNode imageNode = dataNode; QDomDocument doc = dataNode.ownerDocument(); QDomElement tf3DNode = doc.createElement("transferfunctions"); this->getUnmodifiedTransferFunctions3D()->addXml(tf3DNode); imageNode.appendChild(tf3DNode); QDomElement lut2DNode = doc.createElement("lookuptable2D"); this->getUnmodifiedLookupTable2D()->addXml(lut2DNode); imageNode.appendChild(lut2DNode); QDomElement shadingNode = doc.createElement("shading"); mShading.addXml(shadingNode); imageNode.appendChild(shadingNode); // QDomElement landmarksNode = doc.createElement("landmarks"); // mLandmarks->addXml(landmarksNode); // imageNode.appendChild(landmarksNode); QDomElement cropNode = doc.createElement("crop"); cropNode.setAttribute("use", mUseCropping); cropNode.appendChild(doc.createTextNode(qstring_cast(mCroppingBox_d))); imageNode.appendChild(cropNode); QDomElement clipNode = doc.createElement("clip"); for (unsigned i = 0; i < mPersistentClipPlanes.size(); ++i) { QDomElement planeNode = doc.createElement("plane"); Vector3D normal(mPersistentClipPlanes[i]->GetNormal()); Vector3D origin(mPersistentClipPlanes[i]->GetOrigin()); planeNode.setAttribute("normal", qstring_cast(normal)); planeNode.setAttribute("origin", qstring_cast(origin)); clipNode.appendChild(planeNode); } imageNode.appendChild(clipNode); QDomElement modalityNode = doc.createElement("modality"); modalityNode.appendChild(doc.createTextNode(mModality)); imageNode.appendChild(modalityNode); QDomElement imageTypeNode = doc.createElement("imageType"); imageTypeNode.appendChild(doc.createTextNode(mImageType)); imageNode.appendChild(imageTypeNode); QDomElement interpolationNode = doc.createElement("vtk_interpolation"); interpolationNode.setAttribute("type", mInterpolationType); imageNode.appendChild(interpolationNode); QDomElement initialWindowNode = doc.createElement("initialWindow"); initialWindowNode.setAttribute("width", mInitialWindowWidth); initialWindowNode.setAttribute("level", mInitialWindowLevel); }
QString LayoutRepository::generateUid() const { int count = 0; for (LayoutDataVector::const_iterator iter = mLayouts.begin(); iter != mLayouts.end(); ++iter) { if (iter->getUid() == qstring_cast(count)) count = iter->getUid().toInt() + 1; } return qstring_cast(count); }
void check(QString frame, QString parentFrame_expected, cx::Transform3D rMd_expected) { cx::DataPtr data = mData[frame]; INFO(QString("Checking %1").arg(frame)); REQUIRE(data.get()); INFO(QString("parent=%1, expected %2").arg(data->getParentSpace()).arg(parentFrame_expected)); CHECK(data->getParentSpace() == parentFrame_expected); INFO(QString("rMd=\n%1\n, expected\n%2") .arg(qstring_cast(data->get_rMd())) .arg(qstring_cast(rMd_expected))); CHECK(cx::similar(data->get_rMd(), rMd_expected)); }
QString DataManagerImpl::addLandmark() { int max = 0; std::map<QString, LandmarkProperty>::iterator iter; for (iter = mLandmarkProperties.begin(); iter != mLandmarkProperties.end(); ++iter) { //max = std::max(max, qstring_cast(iter->second.getName()).toInt()); max = std::max(max, qstring_cast(iter->first).toInt()); } QString uid = qstring_cast(max + 1); mLandmarkProperties[uid] = LandmarkProperty(uid); emit landmarkPropertiesChanged(); return uid; }
void RegistrationImplService::doPatientRegistration() { DataPtr fixedImage = this->getFixedData(); if(!fixedImage) { reportError("The fixed data is not set, cannot do patient registration!"); return; } LandmarkMap fixedLandmarks = fixedImage->getLandmarks()->getLandmarks(); LandmarkMap toolLandmarks = mPatientModelService->getPatientLandmarks()->getLandmarks(); this->writePreLandmarkRegistration(fixedImage->getName(), fixedImage->getLandmarks()->getLandmarks()); this->writePreLandmarkRegistration("physical", toolLandmarks); std::vector<QString> landmarks = this->getUsableLandmarks(fixedLandmarks, toolLandmarks); vtkPointsPtr p_ref = this->convertTovtkPoints(landmarks, fixedLandmarks, fixedImage->get_rMd()); vtkPointsPtr p_pr = this->convertTovtkPoints(landmarks, toolLandmarks, Transform3D::Identity()); // ignore if too few data. if (p_ref->GetNumberOfPoints() < 3) return; bool ok = false; Transform3D rMpr = this->performLandmarkRegistration(p_pr, p_ref, &ok); if (!ok) { reportError("P-I Landmark registration: Failed to register: [" + qstring_cast(p_pr->GetNumberOfPoints()) + "p]"); return; } this->applyPatientRegistration(rMpr, "Patient Landmark"); }
void PointMetric::addXml(QDomNode& dataNode) { DataMetric::addXml(dataNode); dataNode.toElement().setAttribute("space", mSpace.toString()); dataNode.toElement().setAttribute("coord", qstring_cast(mCoordinate)); }
void ToolTipCalibrateWidget::calibrateSlot() { ToolPtr refTool = mTools->getTool(); //Todo, we only allow the reference point with id 1 to be used to calibrate //this could be done more dynamic. if(!refTool || !refTool->hasReferencePointWithId(1)) return; ToolPtr tool = mServices->tracking()->getActiveTool(); CoordinateSystem to = mServices->spaceProvider()->getT(tool); Vector3D P_t = mServices->spaceProvider()->getActiveToolTipPoint(to); ToolTipCalibrationCalculator calc(mServices->spaceProvider(), tool, refTool, P_t); Transform3D calibration = calc.get_calibration_sMt(); QMessageBox msgBox; msgBox.setText("Do you want to overwrite "+tool->getName()+"s calibration file?"); msgBox.setInformativeText("This cannot be undone."); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Ok); int ret = msgBox.exec(); if(ret == QMessageBox::Ok) { tool->setCalibration_sMt(calibration); mCalibrationLabel->setText("Calibration:\n"+qstring_cast(calibration)); } }
void PointMetric::parseXml(QDomNode& dataNode) { DataMetric::parseXml(dataNode); this->setSpace(CoordinateSystem::fromString(dataNode.toElement().attribute("space", mSpace.toString()))); this->setCoordinate(Vector3D::fromString(dataNode.toElement().attribute("coord", qstring_cast(mCoordinate)))); }
QString PointMetric::getAsSingleLineString() const { return QString("%1 \"%2\" %3") .arg(this->getSingleLineHeader()) .arg(mSpace.toString()) .arg(qstring_cast(this->getCoordinate())); }
void Transform3DWidget::prePaintEvent() { QString M = qstring_cast(this->getMatrixInternal()); mTextEdit->blockSignals(true); int textPos = mTextEdit->textCursor().position(); mTextEdit->setText(M); QTextCursor cursor = mTextEdit->textCursor(); cursor.setPosition(textPos); mTextEdit->setTextCursor(cursor); mTextEdit->blockSignals(false); Vector3D xyz = mDecomposition.getAngles(); mBlockChanges = true; mAngleAdapter[0]->setValue(wrapAngle(xyz[0])); mAngleAdapter[1]->setValue(wrapAngle(xyz[1])); mAngleAdapter[2]->setValue(wrapAngle(xyz[2])); Vector3D t = mDecomposition.getPosition(); mTranslationAdapter[0]->setValue(t[0]); mTranslationAdapter[1]->setValue(t[1]); mTranslationAdapter[2]->setValue(t[2]); this->updateInvertAction(); mBlockChanges = false; }
void ToolTipCalibrateWidget::testCalibrationSlot() { ToolPtr selectedTool = mTools->getTool(); if(!selectedTool || !selectedTool->hasReferencePointWithId(1)) return; CoordinateSystem to = mServices->spaceProvider()->getT(mServices->tracking()->getActiveTool()); Vector3D sampledPoint = mServices->spaceProvider()->getActiveToolTipPoint(to); ToolTipCalibrationCalculator calc(mServices->spaceProvider(), mServices->tracking()->getActiveTool(), selectedTool, sampledPoint); Vector3D delta_selectedTool = calc.get_delta_ref(); mDeltaLabel->setText("<b>Delta:</b> "+qstring_cast(delta_selectedTool)+" <br> <b>Length:</b> "+qstring_cast(delta_selectedTool.length())); report("Delta: "+qstring_cast(delta_selectedTool)+" Length: "+qstring_cast(delta_selectedTool.length())); }
void DataManagerImpl::addXml(QDomNode& parentNode) { QDomDocument doc = parentNode.ownerDocument(); QDomElement dataManagerNode = doc.createElement("datamanager"); parentNode.appendChild(dataManagerNode); m_rMpr_History->addXml(dataManagerNode); QDomElement landmarkPropsNode = doc.createElement("landmarkprops"); LandmarkPropertyMap::iterator it = mLandmarkProperties.begin(); for (; it != mLandmarkProperties.end(); ++it) { QDomElement landmarkPropNode = doc.createElement("landmarkprop"); it->second.addXml(landmarkPropNode); landmarkPropsNode.appendChild(landmarkPropNode); } dataManagerNode.appendChild(landmarkPropsNode); QDomElement landmarksNode = doc.createElement("landmarks"); mPatientLandmarks->addXml(landmarksNode); dataManagerNode.appendChild(landmarksNode); QDomElement centerNode = doc.createElement("center"); centerNode.appendChild(doc.createTextNode(qstring_cast(mCenter))); dataManagerNode.appendChild(centerNode); for (DataMap::const_iterator iter = mData.begin(); iter != mData.end(); ++iter) { QDomElement dataNode = doc.createElement("data"); dataManagerNode.appendChild(dataNode); iter->second->addXml(dataNode); } }
QString StringPropertyRegistrationMovingImage::getValue() const { DataPtr image = mRegistrationService->getMovingData(); if (!image) return ""; return qstring_cast(image->getUid()); }
void ImportDataDialog::importDataSlot() { QString infoText; mData = mPatientModelService->importData(mFilename, infoText); if (!infoText.isEmpty()) { infoText += "<font color=red><br>If these warnings are not expected the import have probably failed.</font>"; if(infoText.contains("File already exists", Qt::CaseInsensitive)) infoText += "<font color=red><br>Importing two different volumes with the same name will lead to undesired effects.</font>"; mErrorLabel->setText(infoText); } if (!mData) { mUidLabel->setText(mFilename); mNameLabel->setText("Import failed"); mOkButton->setText("Exit"); return; } mUidLabel->setText("Data uid: " + qstring_cast(mData->getUid())); mNameLabel->setText("Data name: " + qstring_cast(mData->getName())); ImagePtr image = boost::dynamic_pointer_cast<Image>(mData); mModalityAdapter->setData(image); mModalityCombo->setEnabled(image!=0); mImageTypeAdapter->setData(image); mImageTypeCombo->setEnabled(image!=0); this->setInitialGuessForParentFrame(); mParentFrameAdapter->setData(mData); mParentFrameCombo->setEnabled(mPatientModelService->getData().size()>1); // enable nifti imiport only for meshes. (as this is the only case we have seen) mNiftiFormatCheckBox->setEnabled(mPatientModelService->getData<Mesh>(mData->getUid())!=0); mConvertToUnsignedCheckBox->setEnabled(false); if (image && image->getBaseVtkImageData()) { // vtkImageDataPtr img = image->getBaseVtkImageData(); // std::cout << "type " << img->GetScalarTypeAsString() << " -- " << img->GetScalarType() << std::endl; // std::cout << "range " << img->GetScalarTypeMin() << " -- " << img->GetScalarTypeMax() << std::endl; mConvertToUnsignedCheckBox->setEnabled( (image!=0) && (image->getBaseVtkImageData()->GetScalarTypeMin()<0) ); } }
int DataManagerImpl::findUniqueUidNumber(QString uidBase) const { if (!uidBase.contains("%")) return -1; // Find an uid that is not used before size_t numMatches = 1; int recNumber = 0; if (numMatches != 0) { while (numMatches != 0) { QString newId = qstring_cast(uidBase).arg(++recNumber); numMatches = mData.count(qstring_cast(newId)); } } return recNumber; }
QString StringPropertySelectTool::convertInternal2Display(QString internal) { ToolPtr tool = mTrackingService->getTool(internal); if (!tool) { return "<no tool>"; } return qstring_cast(tool->getName()); }
bool UsReconstructionFileMaker::writeTimestamps(QString filename, std::vector<TimedPosition> ts, QString type, TimeStampType timeStampType) { bool success = false; QFile file(filename); if(!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { reportError("Cannot open "+file.fileName()); return success; } QTextStream stream(&file); for (unsigned i=0; i<ts.size(); ++i) { switch(timeStampType) { case Modified: stream << qstring_cast(ts[i].mTimeInfo.getAcquisitionTime()); break; case SoftwareArrive: stream << qstring_cast(ts[i].mTimeInfo.getSoftwareAcquisitionTime()); break; case Scanner: stream << qstring_cast(ts[i].mTimeInfo.getScannerAcquisitionTime()); break; default: stream << qstring_cast(ts[i].mTime); // Is the same as mTimeInfo.getAcquisitionTime() break; } stream << endl; } file.close(); success = true; QFileInfo info(file); mReport << QString("%1, %2 bytes, %3 %4.") .arg(info.fileName()) .arg(info.size()) .arg(ts.size()) .arg(type); // mReport << info.fileName()+", "+qstring_cast(info.size())+" bytes, "+qstring_cast(ts.size())+" frame timestamps."; return success; }
void DataManagerImpl::setLandmarkNames(std::vector<QString> names) { mLandmarkProperties.clear(); for (unsigned i = 0; i < names.size(); ++i) { LandmarkProperty prop(qstring_cast(i + 1), names[i]); // generate 1-indexed uids (keep users happy) mLandmarkProperties[prop.getUid()] = prop; } emit landmarkPropertiesChanged(); }
void ToolUsingIGSTK::addXml(QDomNode& dataNode) { QDomDocument doc = dataNode.ownerDocument(); dataNode.toElement().setAttribute("uid", qstring_cast(this->getUid())); if (mProbe && mProbe->isValid()) { QDomElement probeNode = doc.createElement("probe"); mProbe->addXml(probeNode); dataNode.appendChild(probeNode); } }
QSize sizeHint() const { Transform3D M = createTransformRotateX(M_PI_4) * createTransformRotateZ(M_PI_4) * createTransformTranslate(Vector3D(1,2,M_PI)); QString text = qstring_cast(M).split("\n")[0]; QRect rect = QFontMetrics(this->font()).boundingRect(text); QSize s(rect.width()*1.0+5, 4*rect.height()*1.2+5); return s; }
void CustomMetric::parseXml(QDomNode& dataNode) { DataMetric::parseXml(dataNode); mArguments->parseXml(dataNode, mDataManager->getDatas()); QDomElement elem = dataNode.toElement(); mDefineVectorUpMethod = elem.attribute("definevectorup", qstring_cast(mDefineVectorUpMethod)); mModelUid = elem.attribute("meshUid", qstring_cast(mModelUid)); mScaleToP1 = elem.attribute("scaleToP1", QString::number(mScaleToP1)).toInt(); mOffsetFromP0 = elem.attribute("offsetFromP0", QString::number(mOffsetFromP0)).toDouble(); mOffsetFromP1 = elem.attribute("offsetFromP1", QString::number(mOffsetFromP1)).toDouble(); mRepeatDistance = elem.attribute("repeatDistance", QString::number(mRepeatDistance)).toDouble(); mShowDistanceMarkers = elem.attribute("showDistance", QString::number(mShowDistanceMarkers)).toInt(); mDistanceMarkerVisibility = elem.attribute("distanceMarkerVisibility", QString::number(mDistanceMarkerVisibility)).toDouble(); mTranslationOnly = elem.attribute("translationOnly", QString::number(mTranslationOnly)).toInt(); mTextureFollowTool = elem.attribute("textureFollowTool", QString::number(mTextureFollowTool)).toInt(); this->onPropertiesChanged(); }
/** Use heuristics to guess a parent frame, * based on similarities in name. */ void ImportDataDialog::setInitialGuessForParentFrame() { if(!mData) return; QString base = qstring_cast(mData->getName()).split(".")[0]; std::map<QString, DataPtr> all = mPatientModelService->getData(); for (std::map<QString, DataPtr>::iterator iter=all.begin(); iter!=all.end(); ++iter) { if (iter->second==mData) continue; QString current = qstring_cast(iter->second->getName()).split(".")[0]; if (base.indexOf(current)>=0) { mData->get_rMd_History()->setParentSpace(iter->first); break; } } }
void IgstkTool::updateCalibration(const Transform3D& cal) { //apply the calibration mInternalStructure.mCalibration = cal; this->setCalibrationTransform(mInternalStructure.mCalibration); Transform3D sMt = mInternalStructure.getCalibrationAsSSC(); report("Set " + mInternalStructure.mName + "s calibration to \n" + qstring_cast(sMt)); //write to file mInternalStructure.saveCalibrationToFile(); }
void PatientLandMarksWidget::updateToolSampleButton() { ToolPtr tool = mServices->tracking()->getActiveTool(); bool enabled = tool && tool->getVisible() && (!tool->hasType(Tool::TOOL_MANUAL) || settings()->value("giveManualToolPhysicalProperties").toBool()); // enable only for non-manual tools. mToolSampleButton->setEnabled(enabled); if (mServices->tracking()->getActiveTool()) mToolSampleButton->setText("Sample " + qstring_cast(tool->getName())); else mToolSampleButton->setText("No tool"); }
/** Make sure one given option exists witin root. * If not present, fill inn the input defaults. */ Vector3DPropertyPtr Vector3DProperty::initialize(const QString& uid, QString name, QString help, Vector3D value, DoubleRange range, int decimals, QDomNode root) { Vector3DPropertyPtr retval(new Vector3DProperty()); retval->mUid = uid; retval->mName = name.isEmpty() ? uid : name; retval->mHelp = help; retval->mRange = range; retval->mStore = XmlOptionItem(uid, root.toElement()); retval->mValue = Vector3D::fromString(retval->mStore.readValue(qstring_cast(Vector3D(0, 0, 0)))); retval->mDecimals = decimals; return retval; }
bool UsReconstructionFileMaker::writeTransforms(QString filename, std::vector<TimedPosition> ts, QString type) { bool success = false; QFile file(filename); if(!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { reportError("Cannot open "+file.fileName()); return success; } QTextStream stream(&file); for (unsigned i=0; i<ts.size(); ++i) { Transform3D transform = ts[i].mPos; stream << transform(0,0) << " "; stream << transform(0,1) << " "; stream << transform(0,2) << " "; stream << transform(0,3); stream << endl; stream << transform(1,0) << " "; stream << transform(1,1) << " "; stream << transform(1,2) << " "; stream << transform(1,3); stream << endl; stream << transform(2,0) << " "; stream << transform(2,1) << " "; stream << transform(2,2) << " "; stream << transform(2,3); stream << endl; } file.close(); success = true; QFileInfo info(file); mReport << info.fileName()+", "+qstring_cast(info.size())+" bytes, "+qstring_cast(ts.size())+" " + type + "."; return success; }
bool UsReconstructionFileMaker::writeMetadata(QString filename, const std::map<double, ToolPositionMetadata>& ts, QString type) { bool success = false; QFile file(filename); if(!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { reportError("Cannot open "+file.fileName()); return success; } QTextStream stream(&file); for (std::map<double, ToolPositionMetadata>::const_iterator i=ts.begin(); i!=ts.end(); ++i) { stream << i->second.toString() << endl; } file.close(); success = true; QFileInfo info(file); mReport << info.fileName()+", "+qstring_cast(info.size())+" bytes, "+qstring_cast(ts.size())+" " + type + "."; return success; }