/** * @brief SaveDialog save options into file after change in dialog. */ void VToolSpline::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog); SCASSERT(dialogTool != nullptr); VPointF point1 = *VAbstractTool::data.GeometricObject<const VPointF *>(dialogTool->getP1()); VPointF point4 = *VAbstractTool::data.GeometricObject<const VPointF *>(dialogTool->getP4()); VSpline spl = VSpline (point1, point4, dialogTool->getAngle1(), dialogTool->getAngle2(), dialogTool->getKAsm1(), dialogTool->getKAsm2(), dialogTool->getKCurve()); disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this, &VToolSpline::ControlPointChangePosition); disconnect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this, &VToolSpline::ControlPointChangePosition); controlPoints[0]->setPos(spl.GetP2()); controlPoints[1]->setPos(spl.GetP3()); connect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this, &VToolSpline::ControlPointChangePosition); connect(controlPoints[1], &VControlPointSpline::ControlPointChangePosition, this, &VToolSpline::ControlPointChangePosition); spl = VSpline (point1, controlPoints[0]->pos(), controlPoints[1]->pos(), point4, dialogTool->getKCurve()); doc->SetAttribute(domElement, AttrPoint1, spl.GetP1().id()); doc->SetAttribute(domElement, AttrPoint4, spl.GetP4().id()); doc->SetAttribute(domElement, AttrAngle1, spl.GetAngle1()); doc->SetAttribute(domElement, AttrAngle2, spl.GetAngle2()); doc->SetAttribute(domElement, AttrKAsm1, spl.GetKasm1()); doc->SetAttribute(domElement, AttrKAsm2, spl.GetKasm2()); doc->SetAttribute(domElement, AttrKCurve, spl.GetKcurve()); }
/** * @brief setDialog set dialog when user want change tool option. */ void VToolDetail::setDialog() { SCASSERT(dialog != nullptr); DialogDetail *dialogTool = qobject_cast<DialogDetail*>(dialog); SCASSERT(dialogTool != nullptr); VDetail detail = VAbstractTool::data.GetDetail(id); dialogTool->setDetails(detail); }
/** * @brief SaveDialog save options into file after change in dialog. */ void VToolCutSpline::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); DialogCutSpline *dialogTool = qobject_cast<DialogCutSpline*>(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); doc->SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId())); }
/** * @brief setDialog set dialog when user want change tool option. */ void VToolCutSpline::setDialog() { SCASSERT(dialog != nullptr); DialogCutSpline *dialogTool = qobject_cast<DialogCutSpline*>(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id); dialogTool->setFormula(formula); dialogTool->setSplineId(curveCutId); dialogTool->setPointName(point->name()); }
//cppcheck-suppress unusedFunction void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node) { QHash<quint32, VDataTool*>* tools = doc->getTools(); SCASSERT(tools != nullptr); Tool *tool = qobject_cast<Tool*>(tools->value(node.getId())); SCASSERT(tool != nullptr); connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); tool->setParentItem(this); doc->IncrementReferens(node.getId()); }
/** * @brief SaveDialog save options into file after change in dialog. */ void VToolAlongLine::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); DialogAlongLine *dialogTool = qobject_cast<DialogAlongLine*>(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); doc->SetAttribute(domElement, AttrFirstPoint, dialogTool->getFirstPointId()); doc->SetAttribute(domElement, AttrSecondPoint, dialogTool->getSecondPointId()); }
/** * @brief SaveDialog save options into file after change in dialog. */ void VToolShoulderPoint::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); DialogShoulderPoint *dialogTool = qobject_cast<DialogShoulderPoint*>(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getP1Line())); doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2Line())); doc->SetAttribute(domElement, AttrPShoulder, QString().setNum(dialogTool->getP3())); }
/** * @brief SaveDialog save options into file after change in dialog. */ void VToolBisector::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); DialogBisector *dialogTool = qobject_cast<DialogBisector*>(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); doc->SetAttribute(domElement, AttrThirdPoint, QString().setNum(dialogTool->getThirdPointId())); }
/** * @brief setDialog set dialog when user want change tool option. */ void VToolAlongLine::setDialog() { SCASSERT(dialog != nullptr); DialogAlongLine *dialogTool = qobject_cast<DialogAlongLine*>(dialog); SCASSERT(dialogTool != nullptr); const VPointF *p = VAbstractTool::data.GeometricObject<const VPointF *>(id); dialogTool->setTypeLine(typeLine); dialogTool->setFormula(formula); dialogTool->setFirstPointId(basePointId, id); dialogTool->setSecondPointId(secondPointId, id); dialogTool->setPointName(p->name()); }
/** * @brief setDialog set dialog when user want change tool option. */ void VToolShoulderPoint::setDialog() { SCASSERT(dialog != nullptr); DialogShoulderPoint *dialogTool = qobject_cast<DialogShoulderPoint*>(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id); dialogTool->setTypeLine(typeLine); dialogTool->setFormula(formulaLength); dialogTool->setP1Line(basePointId); dialogTool->setP2Line(p2Line); dialogTool->setP3(pShoulder); dialogTool->setPointName(p->name()); }
/** * @brief setDialog set dialog when user want change tool option. */ void VToolSpline::setDialog() { SCASSERT(dialog != nullptr); DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog); SCASSERT(dialogTool != nullptr); const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(id); dialogTool->setP1(spl->GetP1().id()); dialogTool->setP4(spl->GetP4().id()); dialogTool->setAngle1(spl->GetAngle1()); dialogTool->setAngle2(spl->GetAngle2()); dialogTool->setKAsm1(spl->GetKasm1()); dialogTool->setKAsm2(spl->GetKasm2()); dialogTool->setKCurve(spl->GetKcurve()); }
/** * @brief Create help create tool from GUI. * @param dialog dialog. * @param scene pointer to scene. * @param doc dom document container. * @param data container with variables. */ void VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog); SCASSERT(dialogTool != nullptr); const quint32 p1 = dialogTool->getP1(); const quint32 p4 = dialogTool->getP4(); const qreal kAsm1 = dialogTool->getKAsm1(); const qreal kAsm2 = dialogTool->getKAsm2(); const qreal angle1 = dialogTool->getAngle1(); const qreal angle2 = dialogTool->getAngle2(); const qreal kCurve = dialogTool->getKCurve(); Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, doc, data, Document::FullParse, Source::FromGui); }
/** * @brief Create help create tool from GUI. * @param dialog dialog. * @param scene pointer to scene. * @param doc dom document container. * @param data container with variables. */ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); DialogDetail *dialogTool = qobject_cast<DialogDetail*>(dialog); SCASSERT(dialogTool != nullptr); VDetail detail = dialogTool->getDetails(); VDetail det; qApp->getUndoStack()->beginMacro("add detail"); for (ptrdiff_t i = 0; i< detail.CountNode(); ++i) { quint32 id = 0; switch (detail.at(i).getTypeTool()) { case (Tool::NodePoint): { id = CreateNode<VPointF>(data, detail.at(i).getId()); VNodePoint::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Source::FromGui); } break; case (Tool::NodeArc): { id = CreateNode<VArc>(data, detail.at(i).getId()); VNodeArc::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Source::FromGui); } break; case (Tool::NodeSpline): { id = CreateNode<VSpline>(data, detail.at(i).getId()); VNodeSpline::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Source::FromGui); } break; case (Tool::NodeSplinePath): { id = CreateNode<VSplinePath>(data, detail.at(i).getId()); VNodeSplinePath::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Source::FromGui); } break; default: qDebug()<<"May be wrong tool type!!! Ignoring."<<Q_FUNC_INFO; break; } VNodeDetail node(id, detail.at(i).getTypeTool(), NodeDetail::Contour); det.append(node); } det.setName(detail.getName()); det.setWidth(detail.getWidth()); Create(0, det, scene, doc, data, Document::FullParse, Source::FromGui); }
//--------------------------------------------------------------------------------------------------------------------- QGroupBox *PatternPage::UserGroup() { QSettings *settings = qApp->getSettings(); SCASSERT(settings != nullptr); QGroupBox *userGroup = new QGroupBox(tr("User")); QLabel *nameLabel = new QLabel(tr("User name")); userName = new QLineEdit; #ifdef Q_OS_WIN QString user = settings->value("pattern/user", QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString(); #else QString user = settings->value("pattern/user", QString::fromLocal8Bit(qgetenv("USER").constData())).toString(); #endif userName->setText(user); QHBoxLayout *nameLayout = new QHBoxLayout; nameLayout->addWidget(nameLabel); nameLayout->addWidget(userName); QVBoxLayout *userLayout = new QVBoxLayout; userLayout->addLayout(nameLayout); userGroup->setLayout(userLayout); return userGroup; }
/** * @brief FillTable fill table */ void DialogHistory::FillTable() { ui->tableWidget->clear(); const QVector<VToolRecord> *history = doc->getHistory(); SCASSERT(history != nullptr); qint32 currentRow = -1; qint32 count = 0; ui->tableWidget->setRowCount(history->size()); for (qint32 i = 0; i< history->size(); ++i) { const VToolRecord tool = history->at(i); if (tool.getNameDraw() != doc->GetNameActivDraw()) { continue; } const QString historyRecord = Record(tool); if (historyRecord.isEmpty() ==false) { currentRow++; { QTableWidgetItem *item = new QTableWidgetItem(QString()); item->setTextAlignment(Qt::AlignHCenter); item->setData(Qt::UserRole, tool.getId()); ui->tableWidget->setItem(currentRow, 0, item); } QTableWidgetItem *item = new QTableWidgetItem(historyRecord); item->setFont(QFont("Times", 12, QFont::Bold)); item->setFlags(item->flags() ^ Qt::ItemIsEditable); ui->tableWidget->setItem(currentRow, 1, item); ++count; } } ui->tableWidget->setRowCount(count); if (history->size()>0) { cursorRow = currentRow; QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); SCASSERT(item != nullptr); item->setIcon(QIcon("://icon/32x32/put_after.png")); } ui->tableWidget->resizeColumnsToContents(); ui->tableWidget->resizeRowsToContents(); ui->tableWidget->verticalHeader()->setDefaultSectionSize(20); }
//cppcheck-suppress unusedFunction void DoubleSpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { qreal value = index.model()->data(index, Qt::EditRole).toDouble(); QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(editor); SCASSERT(spinBox != nullptr); spinBox->setValue(value); }
/** * @brief FullUpdateFromGuiOk refresh tool data after change in options. * @param result keep result working dialog. */ void VToolDetail::FullUpdateFromGuiOk(int result) { if (result == QDialog::Accepted) { SCASSERT(dialog != nullptr); DialogDetail *dialogTool = qobject_cast<DialogDetail*>(dialog); SCASSERT(dialogTool != nullptr); VDetail newDet = dialogTool->getDetails(); VDetail oldDet = VAbstractTool::data.GetDetail(id); SaveDetailOptions *saveCommand = new SaveDetailOptions(oldDet, newDet, doc, id, this->scene()); connect(saveCommand, &SaveDetailOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree); qApp->getUndoStack()->push(saveCommand); } delete dialog; dialog = nullptr; }
/** * @brief Create help create tool from GUI. * @param dialog dialog. * @param doc dom document container. * @param data container with variables. */ VToolUnionDetails* VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); DialogUnionDetails *dialogTool = qobject_cast<DialogUnionDetails*>(dialog); SCASSERT(dialogTool != nullptr); VDetail d1 = data->GetDetail(dialogTool->getD1()); VDetail d2 = data->GetDetail(dialogTool->getD2()); quint32 indexD1 = static_cast<quint32>(dialogTool->getIndexD1()); quint32 indexD2 = static_cast<quint32>(dialogTool->getIndexD2()); qApp->getUndoStack()->beginMacro("union details"); VToolUnionDetails* tool = nullptr; tool = Create(0, d1, d2, dialogTool->getD1(), dialogTool->getD2(), indexD1, indexD2, scene, doc, data, Document::FullParse, Source::FromGui); qApp->getUndoStack()->endMacro(); return tool; }
/** * @brief Create help create tool from GUI. * @param dialog dialog. * @param scene pointer to scene. * @param doc dom document container. * @param data container with variables. */ VToolCutSpline* VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); DialogCutSpline *dialogTool = qobject_cast<DialogCutSpline*>(dialog); SCASSERT(dialogTool != nullptr); const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->getFormula(); const quint32 splineId = dialogTool->getSplineId(); VToolCutSpline* point = nullptr; point = Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; } return point; }
/** * @brief VAbstractTool container. * @param doc dom document container. * @param data container with data. * @param id object id in container. * @param parent parent object. */ VAbstractTool::VAbstractTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent) :VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), currentColor(Qt::black), typeLine(TypeLineLine), vis(nullptr) { SCASSERT(doc != nullptr); connect(this, &VAbstractTool::toolhaveChange, this->doc, &VPattern::haveLiteChange); connect(this->doc, &VPattern::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile); connect(this, &VAbstractTool::LiteUpdateTree, this->doc, &VPattern::LiteParseTree); }
//cppcheck-suppress unusedFunction void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(editor); SCASSERT(spinBox != nullptr); spinBox->interpretText(); qreal value = spinBox->value(); model->setData(index, value, Qt::EditRole); }
/** * @brief Create help create tool from GUI. * @param dialog dialog. * @param scene pointer to scene. * @param doc dom document container. * @param data container with variables. * @return the created tool */ VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); DialogShoulderPoint *dialogTool = qobject_cast<DialogShoulderPoint*>(dialog); SCASSERT(dialogTool); QString formula = dialogTool->getFormula(); const quint32 p1Line = dialogTool->getP1Line(); const quint32 p2Line = dialogTool->getP2Line(); const quint32 pShoulder = dialogTool->getP3(); const QString typeLine = dialogTool->getTypeLine(); const QString pointName = dialogTool->getPointName(); VToolShoulderPoint * point = nullptr; point=Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; } return point; }
/** * @brief commitAndCloseEditor commit value if changed. */ void DoubleSpinBoxDelegate::commitAndCloseEditor() { QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox*>(sender()); SCASSERT(spinBox != nullptr); qreal value = spinBox->value(); if (qFuzzyCompare ( lastValue, value ) == false) { lastValue = value; emit commitData(spinBox); } emit closeEditor(spinBox); }
/** * @brief Create help create tool form GUI. * @param dialog dialog. * @param scene pointer to scene. * @param doc dom document container. * @param data container with variables. */ VToolBisector* VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); DialogBisector *dialogTool = qobject_cast<DialogBisector*>(dialog); SCASSERT(dialogTool != nullptr); QString formula = dialogTool->getFormula(); const quint32 firstPointId = dialogTool->getFirstPointId(); const quint32 secondPointId = dialogTool->getSecondPointId(); const quint32 thirdPointId = dialogTool->getThirdPointId(); const QString typeLine = dialogTool->getTypeLine(); const QString pointName = dialogTool->getPointName(); VToolBisector *point = nullptr; point=Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; } return point; }
//--------------------------------------------------------------------------------------------------------------------- void VToolCutSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) { QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj); SCASSERT(point.isNull() == false); doc->SetAttribute(tag, VDomDocument::AttrId, id); doc->SetAttribute(tag, AttrType, ToolType); doc->SetAttribute(tag, AttrName, point->name()); doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrLength, formula); doc->SetAttribute(tag, AttrSpline, curveCutId); }
//--------------------------------------------------------------------------------------------------------------------- // cppcheck-suppress unusedFunction bool MoveDetail::mergeWith(const QUndoCommand *command) { const MoveDetail *moveCommand = static_cast<const MoveDetail *>(command); SCASSERT(moveCommand != nullptr); const quint32 id = moveCommand->getDetId(); if (id != detId) { return false; } newX = moveCommand->getNewX(); newY = moveCommand->getNewY(); return true; }
//--------------------------------------------------------------------------------------------------------------------- QGroupBox *CommunityPage::ServerGroup() { QSettings *settings = qApp->getSettings(); SCASSERT(settings != nullptr); QGroupBox *ServerGroup = new QGroupBox(tr("Server")); QFormLayout *serverLayout = new QFormLayout; CommunityPage::add_lineedit(&this->server, serverLayout, settings->value("community/server", "community.valentina-project.org").toString(), tr("Server name/IP")); CommunityPage::add_checkbox(&this->secureComm, serverLayout, settings->value("community/serverSecure", 0).toBool(), tr("Secure connection")); ServerGroup->setLayout(serverLayout); return ServerGroup; }
//--------------------------------------------------------------------------------------------------------------------- void VToolShoulderPoint::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) { QSharedPointer<VPointF> point = qSharedPointerDynamicCast<VPointF>(obj); SCASSERT(point.isNull() == false); doc->SetAttribute(tag, VDomDocument::AttrId, id); doc->SetAttribute(tag, AttrType, ToolType); doc->SetAttribute(tag, AttrName, point->name()); doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrTypeLine, typeLine); doc->SetAttribute(tag, AttrLength, formulaLength); doc->SetAttribute(tag, AttrP1Line, basePointId); doc->SetAttribute(tag, AttrP2Line, p2Line); doc->SetAttribute(tag, AttrPShoulder, pShoulder); }
//--------------------------------------------------------------------------------------------------------------------- MoveSPoint::MoveSPoint(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent) : QObject(), QUndoCommand(parent), doc(doc), oldX(0.0), oldY(0.0), newX(x), newY(y), sPointId(id), scene(scene) { setText(tr("Move single point")); SCASSERT(scene != nullptr); QDomElement domElement = doc->elementById(QString().setNum(id)); if (domElement.isElement()) { oldX = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrX, "0.0")); oldY = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrY, "0.0")); } else { qDebug()<<"Can't find spoint with id ="<< sPointId << Q_FUNC_INFO; return; } }
/** * @brief Record return description for record * @param tool record data * @return description */ QString DialogHistory::Record(const VToolRecord &tool) { const QDomElement domElement = doc->elementById(QString().setNum(tool.getId())); if (domElement.isElement() == false) { qDebug()<<"Can't find element by id"<<Q_FUNC_INFO; return QString(tr("Can't create record.")); } try { switch ( tool.getTypeTool() ) { case Tool::ArrowTool: Q_UNREACHABLE(); break; case Tool::SinglePointTool: { const QString name = data->GeometricObject<const VPointF *>(tool.getId())->name(); return QString(tr("%1 - Base point")).arg(name); } case Tool::EndLineTool: { const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0"); const QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name(); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name(); return QString(tr("%1_%2 - Line from point %1 to point %2")).arg(basePointIdName, toolIdName); } case Tool::LineTool: { const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name(); const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name(); return QString(tr("%1_%2 - Line from point %1 to point %2")).arg(firstPointIdName, secondPointIdName); } case Tool::AlongLineTool: { const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name(); const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name(); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name(); return QString(tr("%3 - Point along line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName); } case Tool::ShoulderPointTool: { const QString name = data->GeometricObject<const VPointF *>(tool.getId())->name(); return QString(tr("%1 - Point of shoulder")).arg(name); } case Tool::NormalTool: { const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name(); const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name(); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name(); return QString(tr("%3 - normal to line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName); } case Tool::BisectorTool: { const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const quint32 thirdPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, "0"); const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name(); const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name(); const QString thirdPointIdName = data->GeometricObject<const VPointF *>(thirdPointId)->name(); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name(); return QString(tr("%4 - bisector of angle %1_%2_%3")).arg(firstPointIdName, secondPointIdName, thirdPointIdName, toolIdName); } case Tool::LineIntersectTool: { const quint32 p1Line1 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, "0"); const quint32 p2Line1 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, "0"); const quint32 p1Line2 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line2, "0"); const quint32 p2Line2 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line2, "0"); const QString p1Line1Name = data->GeometricObject<const VPointF *>(p1Line1)->name(); const QString p2Line1Name = data->GeometricObject<const VPointF *>(p2Line1)->name(); const QString p1Line2Name = data->GeometricObject<const VPointF *>(p1Line2)->name(); const QString p2Line2Name = data->GeometricObject<const VPointF *>(p2Line2)->name(); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name(); return QString(tr("%5 - intersection of lines %1_%2 and %3_%4")).arg(p1Line1Name, p2Line1Name, p1Line2Name, p2Line2Name, toolIdName); } case Tool::SplineTool: { const VSpline *spl = data->GeometricObject<const VSpline *>(tool.getId()); SCASSERT(spl != nullptr); const QString splP1Name = data->GeometricObject<const VPointF *>(spl->GetP1().id())->name(); const QString splP4Name = data->GeometricObject<const VPointF *>(spl->GetP4().id())->name(); return QString(tr("Curve %1_%2")).arg(splP1Name, splP4Name); } case Tool::ArcTool: { const VArc *arc = data->GeometricObject<const VArc *>(tool.getId()); SCASSERT(arc != nullptr); const QString arcCenterName = data->GeometricObject<const VArc *>(arc->GetCenter().id())->name(); return QString(tr("Arc with center in point %1")).arg(arcCenterName); } case Tool::SplinePathTool: { const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(tool.getId()); SCASSERT(splPath != nullptr); const QVector<VSplinePoint> points = splPath->GetSplinePath(); QString record; if (points.size() != 0 ) { const QString pName = data->GeometricObject<const VPointF *>(points.at(0).P().id())->name(); record = QString(tr("Curve point %1")).arg(pName); if (points.size() > 1) { const QString pName = data->GeometricObject<const VPointF *>(points.last().P().id())->name(); record.append(QString("_%1").arg(pName)); } } else { qDebug()<<"Not enough points in splinepath"<<Q_FUNC_INFO; return QString(tr("Can't create record.")); } return record; } case Tool::PointOfContact: { const quint32 center = doc->GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0"); const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name(); const QString centerName = data->GeometricObject<const VPointF *>(center)->name(); const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name(); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name(); return QString(tr("%4 - point of contact of arc with the center in point %1 and line %2_%3")).arg( centerName, firstPointIdName, secondPointIdName, toolIdName); } case Tool::Height: { const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0"); const quint32 p1LineId = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0"); const quint32 p2LineId = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0"); const QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name(); const QString p1LineIdName = data->GeometricObject<const VPointF *>(p1LineId)->name(); const QString p2LineIdName = data->GeometricObject<const VPointF *>(p2LineId)->name(); return QString(tr("Point of perpendicular from point %1 to line %2_%3")).arg(basePointIdName, p1LineIdName, p2LineIdName); } case Tool::Triangle: { const quint32 axisP1Id = doc->GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, "0"); const quint32 axisP2Id = doc->GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, "0"); const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const QString axisP1IdName = data->GeometricObject<const VPointF *>(axisP1Id)->name(); const QString axisP2IdName = data->GeometricObject<const VPointF *>(axisP2Id)->name(); const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name(); const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name(); return QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg(axisP1IdName, axisP2IdName, firstPointIdName, secondPointIdName); } case Tool::PointOfIntersection: { const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name(); const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name(); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name(); return QString(tr("%1 - point of intersection %2 and %3")).arg(toolIdName, firstPointIdName, secondPointIdName); } case Tool::CutArcTool: { const quint32 arcId = doc->GetParametrUInt(domElement, VToolCutArc::AttrArc, "0"); const VArc *arc = data->GeometricObject<const VArc *>(arcId); SCASSERT(arc != nullptr); const QString arcCenterName = data->GeometricObject<const VArc *>(arc->GetCenter().id())->name(); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name(); return QString(tr("%1 - cut arc with center %2")).arg(toolIdName, arcCenterName); } case Tool::CutSplineTool: { const quint32 splineId = doc->GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0"); const VSpline *spl = data->GeometricObject<const VSpline *>(splineId); SCASSERT(spl != nullptr); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name(); const QString splP1Name = data->GeometricObject<const VPointF *>(spl->GetP1().id())->name(); const QString splP4Name = data->GeometricObject<const VPointF *>(spl->GetP4().id())->name(); return QString(tr("%1 - cut curve %2_%3")).arg(toolIdName, splP1Name, splP4Name); } case Tool::CutSplinePathTool: { const quint32 splinePathId = doc->GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0"); const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(splinePathId); SCASSERT(splPath != nullptr); const QVector<VSplinePoint> points = splPath->GetSplinePath(); QString record; if (points.size() != 0 ) { const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name(); const QString pName = data->GeometricObject<const VPointF *>(points.at(0).P().id())->name(); record = QString(tr("%1 - cut curve path %2")).arg(toolIdName, pName); if (points.size() > 1) { const QString pName = data->GeometricObject<const VPointF *>(points.last().P().id())->name(); const QString name = QString("_%1").arg(pName); record.append(name); } } else { qDebug()<<"Not enough points in splinepath"<<Q_FUNC_INFO; return QString(tr("Can't create record.")); } return record; } //Because "history" not only show history of pattern, but help restore current data for each pattern's //piece, we need add record about details and nodes, but don't show them. case Tool::DetailTool: break; case Tool::UnionDetails: break; case Tool::NodeArc: break; case Tool::NodePoint: break; case Tool::NodeSpline: break; case Tool::NodeSplinePath: break; default: qDebug()<<"Got wrong tool type. Ignore."; break; } } catch (const VExceptionBadId &e) { qDebug()<<e.ErrorMessage()<<Q_FUNC_INFO; return QString(tr("Can't create record.")); } return QString(); }