diff --git a/src/app/app.pro b/src/app/app.pro index 27519ff73..40ba0d1a0 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -41,6 +41,7 @@ include(geometry/geometry.pri) include(tools/tools.pri) include(widgets/widgets.pri) include(xml/xml.pri) +include(undocommands/undocommands.pri) SOURCES += \ main.cpp \ diff --git a/src/app/container/calculator.cpp b/src/app/container/calculator.cpp index ec8c82358..80684ef1c 100644 --- a/src/app/container/calculator.cpp +++ b/src/app/container/calculator.cpp @@ -30,6 +30,7 @@ #include #include #include "../widgets/vapplication.h" +#include "vcontainer.h" using namespace qmu; @@ -150,7 +151,7 @@ qreal Calculator::EvalFormula(const QString &formula) void Calculator::InitVariables(const VContainer *data) { int num = 0; - if (qApp->patternType() == Pattern::Standard) + if (qApp->patternType() == MeasurementsType::Standard) { num +=2; } @@ -176,7 +177,7 @@ void Calculator::InitVariables(const VContainer *data) vVarVal = new qreal[num]; int j = 0; - if (qApp->patternType() == Pattern::Standard) + if (qApp->patternType() == MeasurementsType::Standard) { vVarVal[j] = data->size(); DefineVar(data->SizeName(), &vVarVal[j]); @@ -235,7 +236,7 @@ void Calculator::InitVariables(const VContainer *data) QHash::const_iterator i = measurements->constBegin(); while (i != measurements->constEnd()) { - if (qApp->patternType() == Pattern::Standard) + if (qApp->patternType() == MeasurementsType::Standard) { vVarVal[j] = i.value().GetValue(data->size(), data->height()); } @@ -253,7 +254,7 @@ void Calculator::InitVariables(const VContainer *data) QHash::const_iterator i = increments->constBegin(); while (i != increments->constEnd()) { - if (qApp->patternType() == Pattern::Standard) + if (qApp->patternType() == MeasurementsType::Standard) { vVarVal[j] = i.value().GetValue(data->size(), data->height()); } @@ -293,12 +294,12 @@ qreal Calculator::CmUnit(qreal val) qreal unit = val; switch(qApp->patternUnit()) { - case Valentina::Mm: + case Unit::Mm: unit = val * 10.0; break; - case Valentina::Cm: + case Unit::Cm: break; - case Valentina::Inch: + case Unit::Inch: unit = val / 2.54; break; default: @@ -314,12 +315,12 @@ qreal Calculator::MmUnit(qreal val) qreal unit = val; switch(qApp->patternUnit()) { - case Valentina::Mm: + case Unit::Mm: break; - case Valentina::Cm: + case Unit::Cm: unit = val / 10.0; break; - case Valentina::Inch: + case Unit::Inch: unit = val / 25.4; break; default: @@ -335,13 +336,13 @@ qreal Calculator::InchUnit(qreal val) qreal unit = val; switch(qApp->patternUnit()) { - case Valentina::Mm: + case Unit::Mm: unit = val * 25.4; break; - case Valentina::Cm: + case Unit::Cm: unit = val * 2.54; break; - case Valentina::Inch: + case Unit::Inch: break; default: break; diff --git a/src/app/container/calculator.h b/src/app/container/calculator.h index 39fb1a520..1d0b62e0e 100644 --- a/src/app/container/calculator.h +++ b/src/app/container/calculator.h @@ -29,10 +29,10 @@ #ifndef CALCULATOR_H #define CALCULATOR_H -#include "vcontainer.h" - #include "../../libs/qmuparser/qmuparser.h" +class VContainer; + /** * @brief The Calculator class for calculation formula. * diff --git a/src/app/container/vcontainer.cpp b/src/app/container/vcontainer.cpp index 8ecedcae0..ad74f2ae2 100644 --- a/src/app/container/vcontainer.cpp +++ b/src/app/container/vcontainer.cpp @@ -27,10 +27,10 @@ *************************************************************************/ #include "vcontainer.h" - #include -#include #include "../widgets/vapplication.h" +#include "../geometry/varc.h" +#include "../geometry/vsplinepath.h" quint32 VContainer::_id = 0; @@ -100,16 +100,16 @@ void VContainer::setData(const VContainer &data) i.next(); switch (i.value()->getType()) { - case (GObject::Arc): + case (GOType::Arc): CopyGObject(data, i.key()); break; - case (GObject::Point): + case (GOType::Point): CopyGObject(data, i.key()); break; - case (GObject::Spline): + case (GOType::Spline): CopyGObject(data, i.key()); break; - case (GObject::SplinePath): + case (GOType::SplinePath): CopyGObject(data, i.key()); break; default: @@ -386,7 +386,7 @@ void VContainer::AddLineAngle(const QString &name, const qreal &value) qreal VContainer::GetValueStandardTableRow(const QString& name) const { const VMeasurement m = GetMeasurement(name); - if (qApp->patternType() == Pattern::Individual) + if (qApp->patternType() == MeasurementsType::Individual) { return m.GetValue(); } @@ -405,7 +405,7 @@ qreal VContainer::GetValueStandardTableRow(const QString& name) const qreal VContainer::GetValueIncrementTableRow(const QString& name) const { const VIncrement icr = GetIncrement(name); - if (qApp->patternType() == Pattern::Individual) + if (qApp->patternType() == MeasurementsType::Individual) { return icr.GetValue(); } @@ -454,7 +454,7 @@ void VContainer::ClearCalculationGObjects() while (i.hasNext()) { i.next(); - if (i.value()->getMode() == Valentina::Calculation) + if (i.value()->getMode() == Draw::Calculation) { delete i.value(); gObjects.remove(i.key()); diff --git a/src/app/container/vcontainer.h b/src/app/container/vcontainer.h index 75d69e75a..fd9652895 100644 --- a/src/app/container/vcontainer.h +++ b/src/app/container/vcontainer.h @@ -31,10 +31,7 @@ #include "vmeasurement.h" #include "vincrement.h" -#include "../geometry/varc.h" -#include "../geometry/vsplinepath.h" #include "../geometry/vdetail.h" -#include "../widgets/vitem.h" #include "../geometry/vgobject.h" #include "../exception/vexceptionbadid.h" diff --git a/src/app/container/vincrement.cpp b/src/app/container/vincrement.cpp index 865e7d00e..97d4aa2b9 100644 --- a/src/app/container/vincrement.cpp +++ b/src/app/container/vincrement.cpp @@ -49,6 +49,23 @@ VIncrement::VIncrement(quint32 id, qreal base, qreal ksize, qreal kheight, QStri :id(id), base(base), ksize(ksize), kheight(kheight), description(description) {} +//--------------------------------------------------------------------------------------------------------------------- +VIncrement::VIncrement(const VIncrement &incr) + :id(incr.getId()), base(incr.getBase()), ksize(incr.getKsize()), kheight(incr.getKheight()), + description(incr.getDescription()) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VIncrement &VIncrement::operator=(const VIncrement &incr) +{ + this->id = incr.getId(); + this->base = incr.getBase(); + this->ksize = incr.getKsize(); + this->kheight = incr.getKheight(); + this->description = incr.getDescription(); + return *this; +} + //--------------------------------------------------------------------------------------------------------------------- qreal VIncrement::GetValue() const { diff --git a/src/app/container/vincrement.h b/src/app/container/vincrement.h index bc787e6bc..4a31efe06 100644 --- a/src/app/container/vincrement.h +++ b/src/app/container/vincrement.h @@ -39,6 +39,8 @@ class VIncrement public: VIncrement(); VIncrement(quint32 id, qreal base, qreal ksize, qreal kheight, QString description = QString()); + VIncrement(const VIncrement &incr); + VIncrement &operator=(const VIncrement &incr); quint32 getId() const; void setId(const quint32 &value); qreal getBase() const; diff --git a/src/app/dialogs/app/configdialog.h b/src/app/dialogs/app/configdialog.h index 3af959906..19fe29611 100644 --- a/src/app/dialogs/app/configdialog.h +++ b/src/app/dialogs/app/configdialog.h @@ -30,11 +30,11 @@ #define CONFIGDIALOG_H #include -#include #include "pages.h" class QListWidgetItem; class QStackedWidget; +class QListWidget; class ConfigDialog : public QDialog { diff --git a/src/app/dialogs/app/dialoghistory.cpp b/src/app/dialogs/app/dialoghistory.cpp index 65c170e12..304b3f5a1 100644 --- a/src/app/dialogs/app/dialoghistory.cpp +++ b/src/app/dialogs/app/dialoghistory.cpp @@ -29,14 +29,13 @@ #include "dialoghistory.h" #include "ui_dialoghistory.h" #include "../../geometry/varc.h" -#include "../../geometry/vspline.h" #include "../../geometry/vsplinepath.h" +#include "../../geometry/vpointf.h" #include "../../tools/vabstracttool.h" #include "../../tools/drawTools/vtoolcutspline.h" #include "../../tools/drawTools/vtoolcutsplinepath.h" #include "../../tools/drawTools/vtoolcutarc.h" -#include -#include +#include "../../xml/vpattern.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -58,7 +57,7 @@ DialogHistory::DialogHistory(VContainer *data, VPattern *doc, QWidget *parent) connect(this, &DialogHistory::ShowHistoryTool, doc, &VPattern::ShowHistoryTool); connect(doc, &VPattern::ChangedCursor, this, &DialogHistory::ChangedCursor); connect(doc, &VPattern::patternChanged, this, &DialogHistory::UpdateHistory); - connect(doc, &VPattern::ChangedActivDraw, this, &DialogHistory::UpdateHistory); + connect(doc, &VPattern::ChangedActivPP, this, &DialogHistory::UpdateHistory); ShowPoint(); } @@ -214,22 +213,22 @@ QString DialogHistory::Record(const VToolRecord &tool) { switch ( tool.getTypeTool() ) { - case Valentina::ArrowTool: + case Tool::ArrowTool: Q_UNREACHABLE(); break; - case Valentina::SinglePointTool: + case Tool::SinglePointTool: { const QString name = data->GeometricObject(tool.getId())->name(); return QString(tr("%1 - Base point")).arg(name); } - case Valentina::EndLineTool: + case Tool::EndLineTool: { const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0"); const QString basePointIdName = data->GeometricObject(basePointId)->name(); const QString toolIdName = data->GeometricObject(tool.getId())->name(); return QString(tr("%1_%2 - Line from point %1 to point %2")).arg(basePointIdName, toolIdName); } - case Valentina::LineTool: + case Tool::LineTool: { const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); @@ -237,7 +236,7 @@ QString DialogHistory::Record(const VToolRecord &tool) const QString secondPointIdName = data->GeometricObject(secondPointId)->name(); return QString(tr("%1_%2 - Line from point %1 to point %2")).arg(firstPointIdName, secondPointIdName); } - case Valentina::AlongLineTool: + case Tool::AlongLineTool: { const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); @@ -246,12 +245,12 @@ QString DialogHistory::Record(const VToolRecord &tool) const QString toolIdName = data->GeometricObject(tool.getId())->name(); return QString(tr("%3 - Point along line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName); } - case Valentina::ShoulderPointTool: + case Tool::ShoulderPointTool: { const QString name = data->GeometricObject(tool.getId())->name(); return QString(tr("%1 - Point of shoulder")).arg(name); } - case Valentina::NormalTool: + case Tool::NormalTool: { const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); @@ -260,7 +259,7 @@ QString DialogHistory::Record(const VToolRecord &tool) const QString toolIdName = data->GeometricObject(tool.getId())->name(); return QString(tr("%3 - normal to line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName); } - case Valentina::BisectorTool: + case Tool::BisectorTool: { const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); @@ -272,7 +271,7 @@ QString DialogHistory::Record(const VToolRecord &tool) return QString(tr("%4 - bisector of angle %1_%2_%3")).arg(firstPointIdName, secondPointIdName, thirdPointIdName, toolIdName); } - case Valentina::LineIntersectTool: + case Tool::LineIntersectTool: { const quint32 p1Line1 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, "0"); const quint32 p2Line1 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, "0"); @@ -287,7 +286,7 @@ QString DialogHistory::Record(const VToolRecord &tool) p1Line2Name, p2Line2Name, toolIdName); } - case Valentina::SplineTool: + case Tool::SplineTool: { const VSpline *spl = data->GeometricObject(tool.getId()); SCASSERT(spl != nullptr); @@ -295,14 +294,14 @@ QString DialogHistory::Record(const VToolRecord &tool) const QString splP4Name = data->GeometricObject(spl->GetP4().id())->name(); return QString(tr("Curve %1_%2")).arg(splP1Name, splP4Name); } - case Valentina::ArcTool: + case Tool::ArcTool: { const VArc *arc = data->GeometricObject(tool.getId()); SCASSERT(arc != nullptr); const QString arcCenterName = data->GeometricObject(arc->GetCenter().id())->name(); return QString(tr("Arc with center in point %1")).arg(arcCenterName); } - case Valentina::SplinePathTool: + case Tool::SplinePathTool: { const VSplinePath *splPath = data->GeometricObject(tool.getId()); SCASSERT(splPath != nullptr); @@ -325,7 +324,7 @@ QString DialogHistory::Record(const VToolRecord &tool) } return record; } - case Valentina::PointOfContact: + case Tool::PointOfContact: { const quint32 center = doc->GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0"); const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); @@ -337,7 +336,7 @@ QString DialogHistory::Record(const VToolRecord &tool) 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 Valentina::Height: + case Tool::Height: { const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0"); const quint32 p1LineId = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0"); @@ -349,7 +348,7 @@ QString DialogHistory::Record(const VToolRecord &tool) p1LineIdName, p2LineIdName); } - case Valentina::Triangle: + case Tool::Triangle: { const quint32 axisP1Id = doc->GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, "0"); const quint32 axisP2Id = doc->GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, "0"); @@ -362,7 +361,7 @@ QString DialogHistory::Record(const VToolRecord &tool) return QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg(axisP1IdName, axisP2IdName, firstPointIdName, secondPointIdName); } - case Valentina::PointOfIntersection: + case Tool::PointOfIntersection: { const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); @@ -372,7 +371,7 @@ QString DialogHistory::Record(const VToolRecord &tool) return QString(tr("%1 - point of intersection %2 and %3")).arg(toolIdName, firstPointIdName, secondPointIdName); } - case Valentina::CutArcTool: + case Tool::CutArcTool: { const quint32 arcId = doc->GetParametrUInt(domElement, VToolCutArc::AttrArc, "0"); const VArc *arc = data->GeometricObject(arcId); @@ -381,7 +380,7 @@ QString DialogHistory::Record(const VToolRecord &tool) const QString toolIdName = data->GeometricObject(tool.getId())->name(); return QString(tr("%1 - cut arc with center %2")).arg(toolIdName, arcCenterName); } - case Valentina::CutSplineTool: + case Tool::CutSplineTool: { const quint32 splineId = doc->GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0"); const VSpline *spl = data->GeometricObject(splineId); @@ -391,7 +390,7 @@ QString DialogHistory::Record(const VToolRecord &tool) const QString splP4Name = data->GeometricObject(spl->GetP4().id())->name(); return QString(tr("%1 - cut curve %2_%3")).arg(toolIdName, splP1Name, splP4Name); } - case Valentina::CutSplinePathTool: + case Tool::CutSplinePathTool: { const quint32 splinePathId = doc->GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0"); const VSplinePath *splPath = data->GeometricObject(splinePathId); @@ -419,17 +418,17 @@ QString DialogHistory::Record(const VToolRecord &tool) } //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 Valentina::DetailTool: + case Tool::DetailTool: break; - case Valentina::UnionDetails: + case Tool::UnionDetails: break; - case Valentina::NodeArc: + case Tool::NodeArc: break; - case Valentina::NodePoint: + case Tool::NodePoint: break; - case Valentina::NodeSpline: + case Tool::NodeSpline: break; - case Valentina::NodeSplinePath: + case Tool::NodeSplinePath: break; default: qDebug()<<"Got wrong tool type. Ignore."; diff --git a/src/app/dialogs/app/dialoghistory.h b/src/app/dialogs/app/dialoghistory.h index 7c8fbb2c7..499da0556 100644 --- a/src/app/dialogs/app/dialoghistory.h +++ b/src/app/dialogs/app/dialoghistory.h @@ -30,7 +30,9 @@ #define DIALOGHISTORY_H #include "../tools/dialogtool.h" -#include "../../xml/vpattern.h" + +class VPattern; +class VToolRecord; namespace Ui { diff --git a/src/app/dialogs/app/dialogincrements.cpp b/src/app/dialogs/app/dialogincrements.cpp index ceb1a37e6..076d83878 100644 --- a/src/app/dialogs/app/dialogincrements.cpp +++ b/src/app/dialogs/app/dialogincrements.cpp @@ -30,15 +30,13 @@ #include "ui_dialogincrements.h" #include "../../widgets/doubledelegate.h" #include "../../widgets/textdelegate.h" -#include "../../exception/vexception.h" #include "../../xml/vstandardmeasurements.h" +#include "../../xml/vpattern.h" +#include "../../xml/vindividualmeasurements.h" -#include -#include #include #include #include -#include //--------------------------------------------------------------------------------------------------------------------- /** @@ -52,7 +50,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par { ui->setupUi(this); - if (qApp->patternType() == Pattern::Individual) + if (qApp->patternType() == MeasurementsType::Individual) { const QString filePath = doc->MPath(); try @@ -84,7 +82,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par FillLengthSplines(); FillLengthArcs(); - if (qApp->patternType() == Pattern::Standard) + if (qApp->patternType() == MeasurementsType::Standard) { ui->pagePersonalInformation->setVisible(false); } @@ -108,8 +106,8 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par ui->lineEditGivenName->setText(m->GivenName()); ui->lineEditFamilyName->setText(m->FamilyName()); - ui->comboBoxSex->addItem(tr("male"), QVariant(m->GenderToStr(VIndividualMeasurements::Male))); - ui->comboBoxSex->addItem(tr("female"), QVariant(m->GenderToStr(VIndividualMeasurements::Female))); + ui->comboBoxSex->addItem(tr("male"), QVariant(m->GenderToStr(SexType::Male))); + ui->comboBoxSex->addItem(tr("female"), QVariant(m->GenderToStr(SexType::Female))); qint32 index = ui->comboBoxSex->findData(m->GenderToStr(m->Sex())); if (index != -1) { @@ -133,7 +131,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par connect(ui->toolButtonAdd, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonAdd); connect(ui->toolButtonRemove, &QPushButton::clicked, this, &DialogIncrements::clickedToolButtonRemove); - connect(this, &DialogIncrements::FullUpdateTree, this->doc, &VPattern::FullUpdateTree); + connect(this, &DialogIncrements::FullUpdateTree, this->doc, &VPattern::LiteParseTree); connect(this, &DialogIncrements::haveLiteChange, this->doc, &VPattern::haveLiteChange); connect(this->doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); @@ -177,7 +175,7 @@ void DialogIncrements::FillMeasurements() item->setTextAlignment(Qt::AlignLeft); ui->tableWidgetMeasurements->setItem(currentRow, 0, item); - if (qApp->patternType() == Pattern::Standard) + if (qApp->patternType() == MeasurementsType::Standard) { QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(data->GetValueStandardTableRow(iMap.key()))); item->setTextAlignment(Qt::AlignHCenter); @@ -192,7 +190,7 @@ void DialogIncrements::FillMeasurements() item->setTextAlignment(Qt::AlignHCenter); ui->tableWidgetMeasurements->setItem(currentRow, 2, item); - if (qApp->patternType() == Pattern::Standard) + if (qApp->patternType() == MeasurementsType::Standard) { QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(m.GetKsize())); item->setTextAlignment(Qt::AlignHCenter); @@ -257,7 +255,7 @@ void DialogIncrements::FillIncrements() item->setData(Qt::UserRole, incr.getId()); ui->tableWidgetIncrement->setItem(currentRow, 0, item); - if (qApp->patternType() == Pattern::Standard) + if (qApp->patternType() == MeasurementsType::Standard) { item = new QTableWidgetItem(QString().setNum(data->GetValueIncrementTableRow(iMap.value()))); item->setTextAlignment(Qt::AlignHCenter); @@ -272,7 +270,7 @@ void DialogIncrements::FillIncrements() item->setTextAlignment(Qt::AlignHCenter); ui->tableWidgetIncrement->setItem(currentRow, 2, item); - if (qApp->patternType() == Pattern::Standard) + if (qApp->patternType() == MeasurementsType::Standard) { item = new QTableWidgetItem(QString().setNum(incr.getKsize())); item->setTextAlignment(Qt::AlignHCenter); @@ -495,7 +493,7 @@ void DialogIncrements::OpenTable() { QString text = tr("Measurements use different units than pattern. This pattern required measurements in %1") .arg(doc->UnitsToStr(qApp->patternUnit())); - if (qApp->patternType() == Pattern::Individual) + if (qApp->patternType() == MeasurementsType::Individual) { const QString filter(tr("Individual measurements (*.vit)")); const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter); @@ -519,7 +517,7 @@ void DialogIncrements::OpenTable() emit DialogClosed(QDialog::Rejected); return; } - Valentina::Units mUnit = m1->Unit(); + Unit mUnit = m1->MUnit(); if (qApp->patternUnit() != mUnit) { QMessageBox::critical(this, tr("Wrong units."), text); @@ -551,7 +549,7 @@ void DialogIncrements::OpenTable() m1 = new VStandardMeasurements(data); m1->setContent(filePath); - Valentina::Units mUnit = m1->Unit(); + Unit mUnit = m1->MUnit(); if (qApp->patternUnit() != mUnit) { QMessageBox::critical(this, tr("Wrong units."), text); diff --git a/src/app/dialogs/app/dialogincrements.h b/src/app/dialogs/app/dialogincrements.h index d53aab35d..2b4d18e03 100644 --- a/src/app/dialogs/app/dialogincrements.h +++ b/src/app/dialogs/app/dialogincrements.h @@ -30,8 +30,9 @@ #define DIALOGINCREMENTS_H #include "../tools/dialogtool.h" -#include "../../xml/vpattern.h" -#include "../../xml/vindividualmeasurements.h" + +class VPattern; +class VIndividualMeasurements; namespace Ui { diff --git a/src/app/dialogs/app/dialogindividualmeasurements.cpp b/src/app/dialogs/app/dialogindividualmeasurements.cpp index 73c48818f..abcbfee3d 100644 --- a/src/app/dialogs/app/dialogindividualmeasurements.cpp +++ b/src/app/dialogs/app/dialogindividualmeasurements.cpp @@ -28,13 +28,11 @@ #include "dialogindividualmeasurements.h" #include "ui_dialogindividualmeasurements.h" -#include #include "../../xml/vindividualmeasurements.h" -#include #include #include #include "../../widgets/vapplication.h" -#include +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- DialogIndividualMeasurements::DialogIndividualMeasurements(VContainer *data, const QString &patternPieceName, @@ -105,9 +103,9 @@ void DialogIndividualMeasurements::DialogAccepted() VIndividualMeasurements m(data); m.setContent(_tablePath); const qint32 index = ui->comboBoxUnits->currentIndex(); - Valentina::Units unit = VDomDocument::StrToUnits(ui->comboBoxUnits->itemData(index).toString()); + Unit unit = VDomDocument::StrToUnits(ui->comboBoxUnits->itemData(index).toString()); m.setUnit(unit); - qApp->setPatternUnit( m.Unit()); + qApp->setPatternUnit( m.MUnit()); QFile iMeasur(_tablePath); if (iMeasur.open(QIODevice::WriteOnly| QIODevice::Truncate)) { @@ -238,6 +236,6 @@ void DialogIndividualMeasurements::NewTable() //--------------------------------------------------------------------------------------------------------------------- void DialogIndividualMeasurements::InitUnits() { - ui->comboBoxUnits->addItem(tr("centimeter"), QVariant(VDomDocument::UnitsToStr(Valentina::Cm))); - ui->comboBoxUnits->addItem(tr("inch"), QVariant(VDomDocument::UnitsToStr(Valentina::Inch))); + ui->comboBoxUnits->addItem(tr("centimeter"), QVariant(VDomDocument::UnitsToStr(Unit::Cm))); + ui->comboBoxUnits->addItem(tr("inch"), QVariant(VDomDocument::UnitsToStr(Unit::Inch))); } diff --git a/src/app/dialogs/app/dialogindividualmeasurements.h b/src/app/dialogs/app/dialogindividualmeasurements.h index f41edf414..c133c4799 100644 --- a/src/app/dialogs/app/dialogindividualmeasurements.h +++ b/src/app/dialogs/app/dialogindividualmeasurements.h @@ -30,7 +30,8 @@ #define DIALOGINDIVIDUALMEASUREMENTS_H #include -#include "../../container/vcontainer.h" + +class VContainer; namespace Ui { diff --git a/src/app/dialogs/app/dialogmeasurements.cpp b/src/app/dialogs/app/dialogmeasurements.cpp index 30b7d2967..af84fc440 100644 --- a/src/app/dialogs/app/dialogmeasurements.cpp +++ b/src/app/dialogs/app/dialogmeasurements.cpp @@ -31,7 +31,7 @@ //--------------------------------------------------------------------------------------------------------------------- DialogMeasurements::DialogMeasurements(QWidget *parent) : - QDialog(parent), ui(new Ui::DialogMeasurements), result(Measurements::Individual) + QDialog(parent), ui(new Ui::DialogMeasurements), result(MeasurementsType::Individual) { ui->setupUi(this); connect(ui->toolButtonStandard, &QToolButton::clicked, this, &DialogMeasurements::StandardMeasurements); @@ -45,7 +45,7 @@ DialogMeasurements::~DialogMeasurements() } //--------------------------------------------------------------------------------------------------------------------- -Measurements::Type DialogMeasurements::type() const +MeasurementsType DialogMeasurements::type() const { return result; } @@ -53,13 +53,13 @@ Measurements::Type DialogMeasurements::type() const //--------------------------------------------------------------------------------------------------------------------- void DialogMeasurements::StandardMeasurements() { - result = Measurements::Standard; + result = MeasurementsType::Standard; accept(); } //--------------------------------------------------------------------------------------------------------------------- void DialogMeasurements::IndividualMeasurements() { - result = Measurements::Individual; + result = MeasurementsType::Individual; accept(); } diff --git a/src/app/dialogs/app/dialogmeasurements.h b/src/app/dialogs/app/dialogmeasurements.h index 82d2b9429..6b4bc3941 100644 --- a/src/app/dialogs/app/dialogmeasurements.h +++ b/src/app/dialogs/app/dialogmeasurements.h @@ -30,33 +30,24 @@ #define DIALOGMEASUREMENTS_H #include +#include "../../options.h" namespace Ui { class DialogMeasurements; } -namespace Measurements -{ - /** - * @brief The Type enum pattern measurements. - */ - enum Type { Standard, Individual }; - Q_DECLARE_FLAGS(Types, Type) -} -Q_DECLARE_OPERATORS_FOR_FLAGS( Measurements::Types ) - class DialogMeasurements : public QDialog { Q_OBJECT public: explicit DialogMeasurements(QWidget *parent = nullptr); ~DialogMeasurements(); - Measurements::Type type() const; + MeasurementsType type() const; private: Q_DISABLE_COPY(DialogMeasurements) Ui::DialogMeasurements *ui; - Measurements::Type result; + MeasurementsType result; void StandardMeasurements(); void IndividualMeasurements(); }; diff --git a/src/app/dialogs/app/dialogpatternproperties.cpp b/src/app/dialogs/app/dialogpatternproperties.cpp index e047c8e0d..39b7e1f4e 100644 --- a/src/app/dialogs/app/dialogpatternproperties.cpp +++ b/src/app/dialogs/app/dialogpatternproperties.cpp @@ -29,7 +29,7 @@ #include "dialogpatternproperties.h" #include "ui_dialogpatternproperties.h" #include -#include +#include "../../xml/vpattern.h" //--------------------------------------------------------------------------------------------------------------------- DialogPatternProperties::DialogPatternProperties(VPattern *doc, QWidget *parent) : diff --git a/src/app/dialogs/app/dialogpatternproperties.h b/src/app/dialogs/app/dialogpatternproperties.h index d24ca735a..c099058a5 100644 --- a/src/app/dialogs/app/dialogpatternproperties.h +++ b/src/app/dialogs/app/dialogpatternproperties.h @@ -30,7 +30,8 @@ #define DIALOGPATTERNPROPERTIES_H #include -#include "../../xml/vpattern.h" + +class VPattern; namespace Ui { diff --git a/src/app/dialogs/app/dialogpatternxmledit.cpp b/src/app/dialogs/app/dialogpatternxmledit.cpp index 87ef3a882..cc1e92174 100644 --- a/src/app/dialogs/app/dialogpatternxmledit.cpp +++ b/src/app/dialogs/app/dialogpatternxmledit.cpp @@ -563,7 +563,7 @@ void DialogPatternXmlEdit::ButtonApplyChangesClicked() QMessageBox::warning(this, "Error in changes", message); return; } - this->doc->FullUpdateTree(); + this->doc->LiteParseTree(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/app/dialogstandardmeasurements.cpp b/src/app/dialogs/app/dialogstandardmeasurements.cpp index 3cce31782..6af2a7ce1 100644 --- a/src/app/dialogs/app/dialogstandardmeasurements.cpp +++ b/src/app/dialogs/app/dialogstandardmeasurements.cpp @@ -31,7 +31,7 @@ #include #include "../../xml/vstandardmeasurements.h" #include "../../widgets/vapplication.h" -#include +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- DialogStandardMeasurements::DialogStandardMeasurements(VContainer *data, const QString &patternPieceName, @@ -89,7 +89,7 @@ void DialogStandardMeasurements::DialogAccepted() VDomDocument::ValidateXML("://schema/standard_measurements.xsd", _tablePath); VStandardMeasurements m(data); m.setContent(_tablePath); - qApp->setPatternUnit(m.Unit()); + qApp->setPatternUnit(m.MUnit()); } catch (VException &e) { diff --git a/src/app/dialogs/app/dialogstandardmeasurements.h b/src/app/dialogs/app/dialogstandardmeasurements.h index 864c8c798..59d8c33e2 100644 --- a/src/app/dialogs/app/dialogstandardmeasurements.h +++ b/src/app/dialogs/app/dialogstandardmeasurements.h @@ -30,7 +30,8 @@ #define DIALOGSTANDARDMEASUREMENTS_H #include -#include "../../container/vcontainer.h" + +class VContainer; namespace Ui { diff --git a/src/app/dialogs/app/pages.cpp b/src/app/dialogs/app/pages.cpp index 1e17fd272..458d242cb 100644 --- a/src/app/dialogs/app/pages.cpp +++ b/src/app/dialogs/app/pages.cpp @@ -29,6 +29,7 @@ #include "pages.h" #include "../../options.h" #include "../../widgets/vapplication.h" +#include "../../widgets/vmaingraphicsview.h" //--------------------------------------------------------------------------------------------------------------------- ConfigurationPage::ConfigurationPage(QWidget *parent): @@ -51,7 +52,21 @@ void ConfigurationPage::Apply() QApplication::applicationName()); settings.setValue("configuration/autosave/state", autoSaveCheck->isChecked()); settings.setValue("configuration/autosave/time", autoTime->value()); + + QTimer *autoSaveTimer = qApp->getAutoSaveTimer(); + SCASSERT(autoSaveTimer); + + if (autoSaveCheck->isChecked()) + { + autoSaveTimer->start(autoTime->value()*60000); + } + else + { + autoSaveTimer->stop(); + } + settings.setValue("configuration/osSeparator", osOptionCheck->isChecked()); + if (langChanged) { QString locale = qvariant_cast(langCombo->itemData(langCombo->currentIndex())); @@ -128,7 +143,7 @@ QGroupBox *ConfigurationPage::LangGroup() { // get locale extracted by filename QString locale; - locale = fileNames[i]; // "valentina_de.qm" + locale = fileNames.at(i); // "valentina_de.qm" locale.truncate(locale.lastIndexOf('.')); // "valentina_de" locale.remove(0, locale.indexOf('_') + 1); // "de" @@ -174,16 +189,16 @@ QGroupBox *ConfigurationPage::LangGroup() //--------------------------------------------------------------------------------------------------------------------- PatternPage::PatternPage(QWidget *parent): - QWidget(parent), userName(0), graphOutputCheck(0), undoneCount(0) + QWidget(parent), userName(0), graphOutputCheck(0), undoCount(0) { QGroupBox *userGroup = UserGroup(); QGroupBox *graphOutputGroup = GraphOutputGroup(); - QGroupBox *undoneGroup = UndoneGroup(); + QGroupBox *undoGroup = UndoGroup(); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(userGroup); mainLayout->addWidget(graphOutputGroup); - mainLayout->addWidget(undoneGroup); + mainLayout->addWidget(undoGroup); mainLayout->addStretch(1); setLayout(mainLayout); } @@ -194,8 +209,16 @@ void PatternPage::Apply() QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), QApplication::applicationName()); settings.setValue("pattern/user", userName->text()); - //settings.setValue("pattern/graphicalOutput", graphOutputCheck->isChecked()); - settings.setValue("pattern/undone", undoneCount->value()); + + // Scene antialiasing + settings.setValue("pattern/graphicalOutput", graphOutputCheck->isChecked()); + qApp->getSceneView()->setRenderHint(QPainter::Antialiasing, graphOutputCheck->isChecked()); + qApp->getSceneView()->setRenderHint(QPainter::SmoothPixmapTransform, graphOutputCheck->isChecked()); + + /* Maximum number of commands in undo stack may only be set when the undo stack is empty, since setting it on a + * non-empty stack might delete the command at the current index. Calling setUndoLimit() on a non-empty stack + * prints a warning and does nothing.*/ + settings.setValue("pattern/undo", undoCount->value()); } //--------------------------------------------------------------------------------------------------------------------- @@ -228,15 +251,14 @@ QGroupBox *PatternPage::UserGroup() //--------------------------------------------------------------------------------------------------------------------- QGroupBox *PatternPage::GraphOutputGroup() { -// QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), -// QApplication::applicationName()); + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); QGroupBox *graphOutputGroup = new QGroupBox(tr("Graphical output")); graphOutputCheck = new QCheckBox(tr("Use antialiasing")); - //bool graphOutputValue = settings.value("pattern/graphicalOutput", 1).toBool(); - //graphOutputCheck->setChecked(graphOutputValue); - graphOutputCheck->setEnabled(false); + bool graphOutputValue = settings.value("pattern/graphicalOutput", 1).toBool(); + graphOutputCheck->setChecked(graphOutputValue); QHBoxLayout *graphLayout = new QHBoxLayout; graphLayout->addWidget(graphOutputCheck); @@ -248,29 +270,29 @@ QGroupBox *PatternPage::GraphOutputGroup() } //--------------------------------------------------------------------------------------------------------------------- -QGroupBox *PatternPage::UndoneGroup() +QGroupBox *PatternPage::UndoGroup() { - // QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), - // QApplication::applicationName()); + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), + QApplication::applicationName()); - QGroupBox *undoneGroup = new QGroupBox(tr("Undone")); - QLabel *undoneLabel = new QLabel(tr("Count steps")); - undoneCount = new QSpinBox; -// bool ok = true; -// qint32 count = settings.value("pattern/undone", 100).toInt(&ok); -// if (ok == false) -// { -// count = 100; -// } -// undoneCount->setValue(count); - undoneCount->setEnabled(false); + QGroupBox *undoGroup = new QGroupBox(tr("Undo")); + QLabel *undoLabel = new QLabel(tr("Count steps (0 - no limit)")); + undoCount = new QSpinBox; + undoCount->setMinimum(0); + bool ok = true; + qint32 count = settings.value("pattern/undo", 0).toInt(&ok); + if (ok == false) + { + count = 0; + } + undoCount->setValue(count); QHBoxLayout *countLayout = new QHBoxLayout; - countLayout->addWidget(undoneLabel); - countLayout->addWidget(undoneCount); + countLayout->addWidget(undoLabel); + countLayout->addWidget(undoCount); - QVBoxLayout *undoneLayout = new QVBoxLayout; - undoneLayout->addLayout(countLayout); - undoneGroup->setLayout(undoneLayout); - return undoneGroup; + QVBoxLayout *undoLayout = new QVBoxLayout; + undoLayout->addLayout(countLayout); + undoGroup->setLayout(undoLayout); + return undoGroup; } diff --git a/src/app/dialogs/app/pages.h b/src/app/dialogs/app/pages.h index f709d6c79..0ed86761a 100644 --- a/src/app/dialogs/app/pages.h +++ b/src/app/dialogs/app/pages.h @@ -29,7 +29,13 @@ #ifndef PAGES_H #define PAGES_H -#include +#include + +class QCheckBox; +class QSpinBox; +class QComboBox; +class QGroupBox; +class QLineEdit; class ConfigurationPage : public QWidget { @@ -60,10 +66,10 @@ private: Q_DISABLE_COPY(PatternPage) QLineEdit *userName; QCheckBox *graphOutputCheck; - QSpinBox *undoneCount; + QSpinBox *undoCount; QGroupBox *UserGroup(); QGroupBox *GraphOutputGroup(); - QGroupBox *UndoneGroup(); + QGroupBox *UndoGroup(); }; #endif // PAGES_H diff --git a/src/app/dialogs/tools/dialogalongline.cpp b/src/app/dialogs/tools/dialogalongline.cpp index f5491a0d8..681f30d69 100644 --- a/src/app/dialogs/tools/dialogalongline.cpp +++ b/src/app/dialogs/tools/dialogalongline.cpp @@ -108,9 +108,9 @@ DialogAlongLine::~DialogAlongLine() * @param id id of point or detail * @param type type of object */ -void DialogAlongLine::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogAlongLine::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Point) + if (type == SceneObject::Point) { if (number == 0) { diff --git a/src/app/dialogs/tools/dialogalongline.h b/src/app/dialogs/tools/dialogalongline.h index 708fca0c2..581d67269 100644 --- a/src/app/dialogs/tools/dialogalongline.h +++ b/src/app/dialogs/tools/dialogalongline.h @@ -61,7 +61,7 @@ public: quint32 getSecondPointId() const; void setSecondPointId(const quint32 &value, const quint32 &id); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialogarc.cpp b/src/app/dialogs/tools/dialogarc.cpp index 725a5b917..44a030866 100644 --- a/src/app/dialogs/tools/dialogarc.cpp +++ b/src/app/dialogs/tools/dialogarc.cpp @@ -30,7 +30,9 @@ #include "ui_dialogarc.h" #include -#include + +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -161,9 +163,9 @@ void DialogArc::SetRadius(const QString &value) * @param id id of point or detail * @param type type of object */ -void DialogArc::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogArc::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Point) + if (type == SceneObject::Point) { const VPointF *point = data->GeometricObject(id); diff --git a/src/app/dialogs/tools/dialogarc.h b/src/app/dialogs/tools/dialogarc.h index 361c8d695..411e46f4a 100644 --- a/src/app/dialogs/tools/dialogarc.h +++ b/src/app/dialogs/tools/dialogarc.h @@ -59,7 +59,7 @@ public: QString GetF2() const; void SetF2(const QString &value); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** TODO ISSUE 79 : create real function * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialogbisector.cpp b/src/app/dialogs/tools/dialogbisector.cpp index 70caa9363..9de20034c 100644 --- a/src/app/dialogs/tools/dialogbisector.cpp +++ b/src/app/dialogs/tools/dialogbisector.cpp @@ -29,7 +29,8 @@ #include "dialogbisector.h" #include "ui_dialogbisector.h" -#include +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -109,9 +110,9 @@ DialogBisector::~DialogBisector() * @param id id of point or detail * @param type type of object */ -void DialogBisector::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogBisector::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Point) + if (type == SceneObject::Point) { const VPointF *point = data->GeometricObject(id); if (number == 0) diff --git a/src/app/dialogs/tools/dialogbisector.h b/src/app/dialogs/tools/dialogbisector.h index 974a94e31..700f48c18 100644 --- a/src/app/dialogs/tools/dialogbisector.h +++ b/src/app/dialogs/tools/dialogbisector.h @@ -66,7 +66,7 @@ public: quint32 getThirdPointId() const; void setThirdPointId(const quint32 &value, const quint32 &id); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialogcutarc.cpp b/src/app/dialogs/tools/dialogcutarc.cpp index 337c8aadd..5da56bc8c 100644 --- a/src/app/dialogs/tools/dialogcutarc.cpp +++ b/src/app/dialogs/tools/dialogcutarc.cpp @@ -29,6 +29,9 @@ #include "dialogcutarc.h" #include "ui_dialogcutarc.h" +#include "../../geometry/varc.h" +#include "../../container/vcontainer.h" + //--------------------------------------------------------------------------------------------------------------------- /** * @brief DialogCutArc create dialog. @@ -103,9 +106,9 @@ DialogCutArc::~DialogCutArc() * @param id id of point or detail * @param type type of object */ -void DialogCutArc::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogCutArc::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Arc) + if (type == SceneObject::Arc) { const VArc *arc = data->GeometricObject(id); ChangeCurrentText(ui->comboBoxArc, arc->name()); @@ -147,7 +150,7 @@ void DialogCutArc::SaveData() */ void DialogCutArc::setArcId(const quint32 &value, const quint32 &id) { - setCurrentArcId(ui->comboBoxArc, arcId, value, id, ComboMode::CutArc); + setCurrentArcId(ui->comboBoxArc, arcId, value, id, ComboBoxCutArc::CutArc); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogcutarc.h b/src/app/dialogs/tools/dialogcutarc.h index 9fceca34d..f4a6b6a13 100644 --- a/src/app/dialogs/tools/dialogcutarc.h +++ b/src/app/dialogs/tools/dialogcutarc.h @@ -57,7 +57,7 @@ public: quint32 getArcId() const; void setArcId(const quint32 &value, const quint32 &id); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialogcutspline.cpp b/src/app/dialogs/tools/dialogcutspline.cpp index 4c035ba60..979c3d34f 100644 --- a/src/app/dialogs/tools/dialogcutspline.cpp +++ b/src/app/dialogs/tools/dialogcutspline.cpp @@ -29,6 +29,9 @@ #include "dialogcutspline.h" #include "ui_dialogcutspline.h" +#include "../../geometry/vspline.h" +#include "../../container/vcontainer.h" + //--------------------------------------------------------------------------------------------------------------------- /** * @brief DialogCutSpline create dialog. @@ -95,7 +98,7 @@ void DialogCutSpline::setFormula(const QString &value) */ void DialogCutSpline::setSplineId(const quint32 &value, const quint32 &id) { - setCurrentSplineId(ui->comboBoxSpline, splineId, value, id, ComboMode::CutSpline); + setCurrentSplineId(ui->comboBoxSpline, splineId, value, id, ComboBoxCutSpline::CutSpline); } //--------------------------------------------------------------------------------------------------------------------- @@ -104,9 +107,9 @@ void DialogCutSpline::setSplineId(const quint32 &value, const quint32 &id) * @param id id of point or detail * @param type type of object */ -void DialogCutSpline::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogCutSpline::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Spline) + if (type == SceneObject::Spline) { const VSpline *spl = data->GeometricObject(id); ChangeCurrentText(ui->comboBoxSpline, spl->name()); diff --git a/src/app/dialogs/tools/dialogcutspline.h b/src/app/dialogs/tools/dialogcutspline.h index 20ef63fa0..03be441cb 100644 --- a/src/app/dialogs/tools/dialogcutspline.h +++ b/src/app/dialogs/tools/dialogcutspline.h @@ -55,7 +55,7 @@ public: quint32 getSplineId() const; void setSplineId(const quint32 &value, const quint32 &id); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** TODO ISSUE 79 : create real function * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialogcutsplinepath.cpp b/src/app/dialogs/tools/dialogcutsplinepath.cpp index 803d75738..725c1ef62 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/app/dialogs/tools/dialogcutsplinepath.cpp @@ -29,6 +29,9 @@ #include "dialogcutsplinepath.h" #include "ui_dialogcutsplinepath.h" +#include "../../geometry/vsplinepath.h" +#include "../../container/vcontainer.h" + //--------------------------------------------------------------------------------------------------------------------- /** * @brief DialogCutSplinePath create dialog. @@ -96,7 +99,7 @@ void DialogCutSplinePath::setFormula(const QString &value) */ void DialogCutSplinePath::setSplinePathId(const quint32 &value, const quint32 &id) { - setCurrentSplinePathId(ui->comboBoxSplinePath, splinePathId, value, id, ComboMode::CutSpline); + setCurrentSplinePathId(ui->comboBoxSplinePath, splinePathId, value, id, ComboBoxCutSpline::CutSpline); } //--------------------------------------------------------------------------------------------------------------------- @@ -105,9 +108,9 @@ void DialogCutSplinePath::setSplinePathId(const quint32 &value, const quint32 &i * @param id id of point or detail * @param type type of object */ -void DialogCutSplinePath::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogCutSplinePath::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::SplinePath) + if (type == SceneObject::SplinePath) { const VSplinePath *splPath = data->GeometricObject(id); ChangeCurrentText(ui->comboBoxSplinePath, splPath->name()); diff --git a/src/app/dialogs/tools/dialogcutsplinepath.h b/src/app/dialogs/tools/dialogcutsplinepath.h index a93c2c2bc..0dd7d421f 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.h +++ b/src/app/dialogs/tools/dialogcutsplinepath.h @@ -55,7 +55,7 @@ public: quint32 getSplinePathId() const; void setSplinePathId(const quint32 &value, const quint32 &id); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** TODO ISSUE 79 : create real function * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialogdetail.cpp b/src/app/dialogs/tools/dialogdetail.cpp index 23b1c3dd7..f4e210540 100644 --- a/src/app/dialogs/tools/dialogdetail.cpp +++ b/src/app/dialogs/tools/dialogdetail.cpp @@ -28,9 +28,14 @@ #include "dialogdetail.h" -#include #include +#include "../../geometry/varc.h" +#include "../../geometry/vpointf.h" +#include "../../geometry/vsplinepath.h" +#include "../../container/vcontainer.h" +#include "../../xml/vdomdocument.h" + //--------------------------------------------------------------------------------------------------------------------- /** * @brief DialogDetail create dialog @@ -42,6 +47,9 @@ DialogDetail::DialogDetail(const VContainer *data, QWidget *parent) { ui.setupUi(this); labelEditNamePoint = ui.labelEditNameDetail; + ui.labelUnit->setText( VDomDocument::UnitsToStr(qApp->patternUnit(), true)); + ui.labelUnitX->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); + ui.labelUnitY->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); bOk = ui.buttonBox->button(QDialogButtonBox::Ok); SCASSERT(bOk != nullptr); @@ -57,9 +65,9 @@ DialogDetail::DialogDetail(const VContainer *data, QWidget *parent) CheckState(); connect(ui.listWidget, &QListWidget::currentRowChanged, this, &DialogDetail::ObjectChanged); - connect(ui.spinBoxBiasX, static_cast(&QSpinBox::valueChanged), + connect(ui.doubleSpinBoxBiasX, static_cast(&QDoubleSpinBox::valueChanged), this, &DialogDetail::BiasXChanged); - connect(ui.spinBoxBiasY, static_cast(&QSpinBox::valueChanged), + connect(ui.doubleSpinBoxBiasY, static_cast(&QDoubleSpinBox::valueChanged), this, &DialogDetail::BiasYChanged); connect(ui.checkBoxSeams, &QCheckBox::clicked, this, &DialogDetail::ClickedSeams); connect(ui.checkBoxClosed, &QCheckBox::clicked, this, &DialogDetail::ClickedClosed); @@ -74,24 +82,26 @@ DialogDetail::DialogDetail(const VContainer *data, QWidget *parent) * @param id id of objects (points, arcs, splines, spline paths) * @param type type of object */ -void DialogDetail::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogDetail::ChoosedObject(quint32 id, const SceneObject &type) { - if (type != Valentina::Line && type != Valentina::Detail) + if (type != SceneObject::Line && type != SceneObject::Detail) { switch (type) { - case (Valentina::Arc): - NewItem(id, Valentina::NodeArc, NodeDetail::Contour); + case (SceneObject::Arc): + NewItem(id, Tool::NodeArc, NodeDetail::Contour); break; - case (Valentina::Point): - NewItem(id, Valentina::NodePoint, NodeDetail::Contour); + case (SceneObject::Point): + NewItem(id, Tool::NodePoint, NodeDetail::Contour); break; - case (Valentina::Spline): - NewItem(id, Valentina::NodeSpline, NodeDetail::Contour); + case (SceneObject::Spline): + NewItem(id, Tool::NodeSpline, NodeDetail::Contour); break; - case (Valentina::SplinePath): - NewItem(id, Valentina::NodeSplinePath, NodeDetail::Contour); + case (SceneObject::SplinePath): + NewItem(id, Tool::NodeSplinePath, NodeDetail::Contour); break; + case (SceneObject::Line): + case (SceneObject::Detail): default: qDebug()<item(i); details.append( qvariant_cast(item->data(Qt::UserRole))); } - details.setWidth(ui.spinBoxSeams->value()); + details.setWidth(ui.doubleSpinBoxSeams->value()); details.setName(ui.lineEditNameDetail->text()); details.setSeamAllowance(supplement); details.setClosed(closed); @@ -130,36 +140,57 @@ void DialogDetail::DialogAccepted() * @param mx offset respect to x * @param my offset respect to y */ -void DialogDetail::NewItem(quint32 id, const Valentina::Tools &typeTool, const NodeDetail::NodeDetails &typeNode, +void DialogDetail::NewItem(quint32 id, const Tool &typeTool, const NodeDetail &typeNode, qreal mx, qreal my) { QString name; switch (typeTool) { - case (Valentina::NodePoint): + case (Tool::NodePoint): { const VPointF *point = data->GeometricObject(id); name = point->name(); break; } - case (Valentina::NodeArc): + case (Tool::NodeArc): { const VArc *arc = data->GeometricObject(id); name = arc->name(); break; } - case (Valentina::NodeSpline): + case (Tool::NodeSpline): { const VSpline *spl = data->GeometricObject(id); name = spl->name(); break; } - case (Valentina::NodeSplinePath): + case (Tool::NodeSplinePath): { const VSplinePath *splPath = data->GeometricObject(id); name = splPath->name(); break; } + case (Tool::ArrowTool): + case (Tool::SinglePointTool): + case (Tool::EndLineTool): + case (Tool::LineTool): + case (Tool::AlongLineTool): + case (Tool::ShoulderPointTool): + case (Tool::NormalTool): + case (Tool::BisectorTool): + case (Tool::LineIntersectTool): + case (Tool::SplineTool): + case (Tool::CutSplineTool): + case (Tool::CutArcTool): + case (Tool::ArcTool): + case (Tool::SplinePathTool): + case (Tool::CutSplinePathTool): + case (Tool::PointOfContact): + case (Tool::DetailTool): + case (Tool::Height): + case (Tool::Triangle): + case (Tool::PointOfIntersection): + case (Tool::UnionDetails): default: qDebug()<<"Got wrong tools. Ignore."; break; @@ -171,15 +202,15 @@ void DialogDetail::NewItem(quint32 id, const Valentina::Tools &typeTool, const N item->setData(Qt::UserRole, QVariant::fromValue(node)); ui.listWidget->addItem(item); ui.listWidget->setCurrentRow(ui.listWidget->count()-1); - disconnect(ui.spinBoxBiasX, static_cast(&QSpinBox::valueChanged), + disconnect(ui.doubleSpinBoxBiasX, static_cast(&QDoubleSpinBox::valueChanged), this, &DialogDetail::BiasXChanged); - disconnect(ui.spinBoxBiasY, static_cast(&QSpinBox::valueChanged), + disconnect(ui.doubleSpinBoxBiasY, static_cast(&QDoubleSpinBox::valueChanged), this, &DialogDetail::BiasYChanged); - ui.spinBoxBiasX->setValue(static_cast(qApp->fromPixel(node.getMx()))); - ui.spinBoxBiasY->setValue(static_cast(qApp->fromPixel(node.getMy()))); - connect(ui.spinBoxBiasX, static_cast(&QSpinBox::valueChanged), + ui.doubleSpinBoxBiasX->setValue(qApp->fromPixel(node.getMx())); + ui.doubleSpinBoxBiasY->setValue(qApp->fromPixel(node.getMy())); + connect(ui.doubleSpinBoxBiasX, static_cast(&QDoubleSpinBox::valueChanged), this, &DialogDetail::BiasXChanged); - connect(ui.spinBoxBiasY, static_cast(&QSpinBox::valueChanged), + connect(ui.doubleSpinBoxBiasY, static_cast(&QDoubleSpinBox::valueChanged), this, &DialogDetail::BiasYChanged); } @@ -194,15 +225,15 @@ void DialogDetail::setDetails(const VDetail &value) ui.listWidget->clear(); for (ptrdiff_t i = 0; i < details.CountNode(); ++i) { - NewItem(details[i].getId(), details[i].getTypeTool(), details[i].getTypeNode(), details[i].getMx(), - details[i].getMy()); + NewItem(details.at(i).getId(), details.at(i).getTypeTool(), details.at(i).getTypeNode(), details.at(i).getMx(), + details.at(i).getMy()); } ui.lineEditNameDetail->setText(details.getName()); ui.checkBoxSeams->setChecked(details.getSeamAllowance()); ui.checkBoxClosed->setChecked(details.getClosed()); ClickedClosed(details.getClosed()); ClickedSeams(details.getSeamAllowance()); - ui.spinBoxSeams->setValue(static_cast(details.getWidth())); + ui.doubleSpinBoxSeams->setValue(details.getWidth()); ui.listWidget->setCurrentRow(0); ui.listWidget->setFocus(Qt::OtherFocusReason); ui.toolButtonDelete->setEnabled(true); @@ -247,7 +278,7 @@ void DialogDetail::ClickedSeams(bool checked) { supplement = checked; ui.checkBoxClosed->setEnabled(checked); - ui.spinBoxSeams->setEnabled(checked); + ui.doubleSpinBoxSeams->setEnabled(checked); } //--------------------------------------------------------------------------------------------------------------------- @@ -273,8 +304,8 @@ void DialogDetail::ObjectChanged(int row) } QListWidgetItem *item = ui.listWidget->item( row ); VNodeDetail node = qvariant_cast(item->data(Qt::UserRole)); - ui.spinBoxBiasX->setValue(static_cast(qApp->fromPixel(node.getMx()))); - ui.spinBoxBiasY->setValue(static_cast(qApp->fromPixel(node.getMy()))); + ui.doubleSpinBoxBiasX->setValue(qApp->fromPixel(node.getMx())); + ui.doubleSpinBoxBiasY->setValue(qApp->fromPixel(node.getMy())); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogdetail.h b/src/app/dialogs/tools/dialogdetail.h index 227fda868..ac35e7d15 100644 --- a/src/app/dialogs/tools/dialogdetail.h +++ b/src/app/dialogs/tools/dialogdetail.h @@ -31,6 +31,7 @@ #include "ui_dialogdetail.h" #include "dialogtool.h" +#include "../../geometry/vdetail.h" /** * @brief The DialogDetail class dialog for ToolDetai. Help create detail and edit option. @@ -44,7 +45,7 @@ public: VDetail getDetails() const; void setDetails(const VDetail &value); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** TODO ISSUE 79 : create real function * @brief DialogApply apply data and emit signal about applied dialog. @@ -70,7 +71,7 @@ private: /** @brief closed keep option about equdistant (closed or not) */ bool closed; - void NewItem(quint32 id, const Valentina::Tools &typeTool, const NodeDetail::NodeDetails &typeNode, + void NewItem(quint32 id, const Tool &typeTool, const NodeDetail &typeNode, qreal mx = 0, qreal my = 0); }; diff --git a/src/app/dialogs/tools/dialogdetail.ui b/src/app/dialogs/tools/dialogdetail.ui index 9140a148c..959c21672 100644 --- a/src/app/dialogs/tools/dialogdetail.ui +++ b/src/app/dialogs/tools/dialogdetail.ui @@ -41,18 +41,37 @@ + + + 1 + 0 + + Bias X - - - -3000 + + + + 1 + 0 + - 3000 + 900.990000000000009 + + + 0.100000000000000 + + + + + + + cm @@ -64,7 +83,7 @@ - 0 + 1 0 @@ -74,12 +93,25 @@ - - - -3000 + + + + 1 + 0 + - 3000 + 900.990000000000009 + + + 0.100000000000000 + + + + + + + cm @@ -177,7 +209,7 @@ - 0 + 1 0 @@ -190,9 +222,31 @@ - + + + + 1 + 0 + + - 3000 + 900.990000000000009 + + + 0.100000000000000 + + + + + + + + 0 + 0 + + + + cm diff --git a/src/app/dialogs/tools/dialogeditwrongformula.cpp b/src/app/dialogs/tools/dialogeditwrongformula.cpp index 71d20c0c3..c303e8895 100644 --- a/src/app/dialogs/tools/dialogeditwrongformula.cpp +++ b/src/app/dialogs/tools/dialogeditwrongformula.cpp @@ -29,8 +29,6 @@ #include "dialogeditwrongformula.h" #include "ui_dialogeditwrongformula.h" -#include - //--------------------------------------------------------------------------------------------------------------------- DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, QWidget *parent) :DialogTool(data, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()) diff --git a/src/app/dialogs/tools/dialogendline.cpp b/src/app/dialogs/tools/dialogendline.cpp index ff79155c8..5ad7150ad 100644 --- a/src/app/dialogs/tools/dialogendline.cpp +++ b/src/app/dialogs/tools/dialogendline.cpp @@ -29,7 +29,8 @@ #include "dialogendline.h" #include "ui_dialogendline.h" -#include +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -103,9 +104,9 @@ void DialogEndLine::DeployFormulaTextEdit() * @param id id of point or detail * @param type type of object */ -void DialogEndLine::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogEndLine::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Point) + if (type == SceneObject::Point) { const VPointF *point = data->GeometricObject(id); ChangeCurrentText(ui->comboBoxBasePoint, point->name()); diff --git a/src/app/dialogs/tools/dialogendline.h b/src/app/dialogs/tools/dialogendline.h index 7cba81c13..9f755b7d7 100644 --- a/src/app/dialogs/tools/dialogendline.h +++ b/src/app/dialogs/tools/dialogendline.h @@ -63,7 +63,7 @@ public: quint32 getBasePointId() const; void setBasePointId(const quint32 &value, const quint32 &id); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialogheight.cpp b/src/app/dialogs/tools/dialogheight.cpp index 0cfe458a8..6703d2a25 100644 --- a/src/app/dialogs/tools/dialogheight.cpp +++ b/src/app/dialogs/tools/dialogheight.cpp @@ -29,7 +29,8 @@ #include "dialogheight.h" #include "ui_dialogheight.h" -#include +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -124,9 +125,9 @@ void DialogHeight::setP2LineId(const quint32 &value, const quint32 &id) * @param id id of point or detail * @param type type of object */ -void DialogHeight::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogHeight::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Point) + if (type == SceneObject::Point) { const VPointF *point = data->GeometricObject(id); switch (number) diff --git a/src/app/dialogs/tools/dialogheight.h b/src/app/dialogs/tools/dialogheight.h index 25f443cf0..15a814a79 100644 --- a/src/app/dialogs/tools/dialogheight.h +++ b/src/app/dialogs/tools/dialogheight.h @@ -61,7 +61,7 @@ public: quint32 getP2LineId() const; void setP2LineId(const quint32 &value, const quint32 &id); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** TODO ISSUE 79 : create real function * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialogline.cpp b/src/app/dialogs/tools/dialogline.cpp index c87b5a912..d62167e77 100644 --- a/src/app/dialogs/tools/dialogline.cpp +++ b/src/app/dialogs/tools/dialogline.cpp @@ -29,7 +29,8 @@ #include "dialogline.h" #include "ui_dialogline.h" -#include +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -119,9 +120,9 @@ void DialogLine::DialogAccepted() * @param id id of point or detail * @param type type of object */ -void DialogLine::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogLine::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Point) + if (type == SceneObject::Point) { const VPointF *point = data->GeometricObject(id); if (number == 0) diff --git a/src/app/dialogs/tools/dialogline.h b/src/app/dialogs/tools/dialogline.h index 62b61d918..4de61cfbb 100644 --- a/src/app/dialogs/tools/dialogline.h +++ b/src/app/dialogs/tools/dialogline.h @@ -55,7 +55,7 @@ public: QString getTypeLine() const; void setTypeLine(const QString &value); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** TODO ISSUE 79 : create real function * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialoglineintersect.cpp b/src/app/dialogs/tools/dialoglineintersect.cpp index 469467efb..c460e0610 100644 --- a/src/app/dialogs/tools/dialoglineintersect.cpp +++ b/src/app/dialogs/tools/dialoglineintersect.cpp @@ -29,7 +29,8 @@ #include "dialoglineintersect.h" #include "ui_dialoglineintersect.h" -#include +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -67,9 +68,9 @@ DialogLineIntersect::~DialogLineIntersect() * @param id id of point or detail * @param type type of object */ -void DialogLineIntersect::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogLineIntersect::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Point) + if (type == SceneObject::Point) { const VPointF *point = data->GeometricObject(id); if (number == 0) diff --git a/src/app/dialogs/tools/dialoglineintersect.h b/src/app/dialogs/tools/dialoglineintersect.h index be7f400f6..8c02428bf 100644 --- a/src/app/dialogs/tools/dialoglineintersect.h +++ b/src/app/dialogs/tools/dialoglineintersect.h @@ -61,7 +61,7 @@ public: QString getPointName() const; void setPointName(const QString &value); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** TODO ISSUE 79 : create real function * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialognormal.cpp b/src/app/dialogs/tools/dialognormal.cpp index 00d83ef1e..dd4558879 100644 --- a/src/app/dialogs/tools/dialognormal.cpp +++ b/src/app/dialogs/tools/dialognormal.cpp @@ -29,8 +29,6 @@ #include "dialognormal.h" #include "ui_dialognormal.h" -#include - //--------------------------------------------------------------------------------------------------------------------- /** * @brief DialogNormal create dialog @@ -107,9 +105,9 @@ DialogNormal::~DialogNormal() * @param id id of point or detail * @param type type of object */ -void DialogNormal::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogNormal::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Point) + if (type == SceneObject::Point) { if (number == 0) { diff --git a/src/app/dialogs/tools/dialognormal.h b/src/app/dialogs/tools/dialognormal.h index a2e8f7336..2fdcbb6cc 100644 --- a/src/app/dialogs/tools/dialognormal.h +++ b/src/app/dialogs/tools/dialognormal.h @@ -65,7 +65,7 @@ public: quint32 getSecondPointId() const; void setSecondPointId(const quint32 &value, const quint32 &id); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialogpointofcontact.cpp b/src/app/dialogs/tools/dialogpointofcontact.cpp index 123f491f3..45526a6a7 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.cpp +++ b/src/app/dialogs/tools/dialogpointofcontact.cpp @@ -28,7 +28,8 @@ #include "dialogpointofcontact.h" -#include +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -77,7 +78,7 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, QWidget *pare connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogPointOfContact::PutVal); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogPointOfContact::ValChenged); - if (qApp->patternType() == Pattern::Standard) + if (qApp->patternType() == MeasurementsType::Standard) { SizeHeight(); connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogTool::SizeHeight); @@ -132,9 +133,9 @@ void DialogPointOfContact::DeployFormulaTextEdit() * @param id id of point or detail * @param type type of object */ -void DialogPointOfContact::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogPointOfContact::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Point) + if (type == SceneObject::Point) { const VPointF *point = data->GeometricObject(id); if (number == 0) diff --git a/src/app/dialogs/tools/dialogpointofcontact.h b/src/app/dialogs/tools/dialogpointofcontact.h index cc96ef85c..d0517dd2f 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.h +++ b/src/app/dialogs/tools/dialogpointofcontact.h @@ -61,7 +61,7 @@ public: quint32 getSecondPoint() const; void setSecondPoint(const quint32 &value, const quint32 &id); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialogpointofintersection.cpp b/src/app/dialogs/tools/dialogpointofintersection.cpp index 2f1f2545c..58b058cdb 100644 --- a/src/app/dialogs/tools/dialogpointofintersection.cpp +++ b/src/app/dialogs/tools/dialogpointofintersection.cpp @@ -29,7 +29,8 @@ #include "dialogpointofintersection.h" #include "ui_dialogpointofintersection.h" -#include +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -77,9 +78,9 @@ void DialogPointOfIntersection::setSecondPointId(const quint32 &value, const qui * @param id id of point or detail * @param type type of object */ -void DialogPointOfIntersection::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogPointOfIntersection::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Point) + if (type == SceneObject::Point) { const VPointF *point = data->GeometricObject(id); if (number == 0) diff --git a/src/app/dialogs/tools/dialogpointofintersection.h b/src/app/dialogs/tools/dialogpointofintersection.h index 326c5fe91..dad79fa31 100644 --- a/src/app/dialogs/tools/dialogpointofintersection.h +++ b/src/app/dialogs/tools/dialogpointofintersection.h @@ -55,7 +55,7 @@ public: quint32 getSecondPointId() const; void setSecondPointId(const quint32 &value, const quint32 &id); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** TODO ISSUE 79 : create real function * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialogshoulderpoint.cpp b/src/app/dialogs/tools/dialogshoulderpoint.cpp index 1f349d0cf..61ca75e58 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/app/dialogs/tools/dialogshoulderpoint.cpp @@ -29,7 +29,8 @@ #include "dialogshoulderpoint.h" #include "ui_dialogshoulderpoint.h" -#include +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -109,9 +110,9 @@ DialogShoulderPoint::~DialogShoulderPoint() * @param id id of point or detail * @param type type of object */ -void DialogShoulderPoint::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogShoulderPoint::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Point) + if (type == SceneObject::Point) { const VPointF *point = data->GeometricObject(id); if (number == 0) diff --git a/src/app/dialogs/tools/dialogshoulderpoint.h b/src/app/dialogs/tools/dialogshoulderpoint.h index 6e7e947fc..3b7a389a8 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.h +++ b/src/app/dialogs/tools/dialogshoulderpoint.h @@ -65,7 +65,7 @@ public: quint32 getPShoulder() const; void setPShoulder(const quint32 &value, const quint32 &id); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialogsinglepoint.cpp b/src/app/dialogs/tools/dialogsinglepoint.cpp index 9a303c335..e7caa1d34 100644 --- a/src/app/dialogs/tools/dialogsinglepoint.cpp +++ b/src/app/dialogs/tools/dialogsinglepoint.cpp @@ -29,8 +29,6 @@ #include "dialogsinglepoint.h" #include "ui_dialogsinglepoint.h" -#include - //--------------------------------------------------------------------------------------------------------------------- /** * @brief DialogSinglePoint create dialog diff --git a/src/app/dialogs/tools/dialogspline.cpp b/src/app/dialogs/tools/dialogspline.cpp index c18f7a233..bf5a8df41 100644 --- a/src/app/dialogs/tools/dialogspline.cpp +++ b/src/app/dialogs/tools/dialogspline.cpp @@ -29,7 +29,8 @@ #include "dialogspline.h" #include "ui_dialogspline.h" -#include +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -70,9 +71,9 @@ quint32 DialogSpline::getP1() const * @param id id of point or detail * @param type type of object */ -void DialogSpline::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogSpline::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Point) + if (type == SceneObject::Point) { const VPointF *point = data->GeometricObject(id); if (number == 0) diff --git a/src/app/dialogs/tools/dialogspline.h b/src/app/dialogs/tools/dialogspline.h index 8d6cd84ca..d90cd2990 100644 --- a/src/app/dialogs/tools/dialogspline.h +++ b/src/app/dialogs/tools/dialogspline.h @@ -67,7 +67,7 @@ public: qreal getKCurve() const; void setKCurve(const qreal &value); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** TODO ISSUE 79 : create real function * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialogsplinepath.cpp b/src/app/dialogs/tools/dialogsplinepath.cpp index a40ae2f40..95e8980bc 100644 --- a/src/app/dialogs/tools/dialogsplinepath.cpp +++ b/src/app/dialogs/tools/dialogsplinepath.cpp @@ -29,8 +29,7 @@ #include "dialogsplinepath.h" #include "ui_dialogsplinepath.h" #include "../../geometry/vsplinepoint.h" - -#include +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -77,7 +76,7 @@ void DialogSplinePath::SetPath(const VSplinePath &value) ui->listWidget->clear(); for (qint32 i = 0; i < path.CountPoint(); ++i) { - NewItem(path[i].P().id(), path[i].KAsm1(), path[i].Angle1(), path[i].KAsm2(), path[i].Angle2()); + NewItem(path.at(i).P().id(), path.at(i).KAsm1(), path.at(i).Angle1(), path.at(i).KAsm2(), path.at(i).Angle2()); } ui->listWidget->setFocus(Qt::OtherFocusReason); ui->doubleSpinBoxKcurve->setValue(path.getKCurve()); @@ -89,9 +88,9 @@ void DialogSplinePath::SetPath(const VSplinePath &value) * @param id id of point or detail * @param type don't show this id in list */ -void DialogSplinePath::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogSplinePath::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Point) + if (type == SceneObject::Point) { NewItem(id, 1, 0, 1, 180); emit ToolTip(tr("Select point of curve path")); diff --git a/src/app/dialogs/tools/dialogsplinepath.h b/src/app/dialogs/tools/dialogsplinepath.h index 41bf0282c..631ce5478 100644 --- a/src/app/dialogs/tools/dialogsplinepath.h +++ b/src/app/dialogs/tools/dialogsplinepath.h @@ -50,7 +50,7 @@ public: VSplinePath GetPath() const; void SetPath(const VSplinePath &value); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** TODO ISSUE 79 : create real function * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index 3f7772386..1707ece65 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -28,11 +28,14 @@ #include "dialogtool.h" #include "../../container/calculator.h" -#include "../../geometry/vgobject.h" +#include "../../container/vcontainer.h" +#include "../../geometry/varc.h" +#include "../../geometry/vpointf.h" +#include "../../geometry/vsplinepath.h" #include "../../tools/vabstracttool.h" - -#include #include "../../../libs/qmuparser/qmuparsererror.h" +#include "../../widgets/vapplication.h" +#include "../../xml/vdomdocument.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -106,7 +109,7 @@ void DialogTool::FillComboBoxPoints(QComboBox *box, const quint32 &id) const if (i.key() != id) { VGObject *obj = i.value(); - if (obj->getType() == GObject::Point && obj->getMode() == Valentina::Calculation) + if (obj->getType() == GOType::Point && obj->getMode() == Draw::Calculation) { const VPointF *point = data->GeometricObject(i.key()); list[point->name()] = i.key(); @@ -117,7 +120,7 @@ void DialogTool::FillComboBoxPoints(QComboBox *box, const quint32 &id) const } //--------------------------------------------------------------------------------------------------------------------- -void DialogTool::FillComboBoxArcs(QComboBox *box, const quint32 &id, ComboMode::ComboBoxCutArc cut) const +void DialogTool::FillComboBoxArcs(QComboBox *box, const quint32 &id, ComboBoxCutArc cut) const { SCASSERT(box != nullptr); const QHash *objs = data->DataGObjects(); @@ -126,12 +129,12 @@ void DialogTool::FillComboBoxArcs(QComboBox *box, const quint32 &id, ComboMode:: while (i.hasNext()) { i.next(); - if (cut == ComboMode::CutArc) + if (cut == ComboBoxCutArc::CutArc) { if (i.key() != id + 1 && i.key() != id + 2) { VGObject *obj = i.value(); - if (obj->getType() == GObject::Arc && obj->getMode() == Valentina::Calculation) + if (obj->getType() == GOType::Arc && obj->getMode() == Draw::Calculation) { const VArc *arc = data->GeometricObject(i.key()); list[arc->name()] = i.key(); @@ -143,7 +146,7 @@ void DialogTool::FillComboBoxArcs(QComboBox *box, const quint32 &id, ComboMode:: if (i.key() != id) { VGObject *obj = i.value(); - if (obj->getType() == GObject::Arc && obj->getMode() == Valentina::Calculation) + if (obj->getType() == GOType::Arc && obj->getMode() == Draw::Calculation) { const VArc *arc = data->GeometricObject(i.key()); list[arc->name()] = i.key(); @@ -161,7 +164,7 @@ void DialogTool::FillComboBoxArcs(QComboBox *box, const quint32 &id, ComboMode:: * @param id don't show id in list * @param cut if set to ComboMode::CutSpline don't show id+1 and id+2 */ -void DialogTool::FillComboBoxSplines(QComboBox *box, const quint32 &id, ComboMode::ComboBoxCutSpline cut) const +void DialogTool::FillComboBoxSplines(QComboBox *box, const quint32 &id, ComboBoxCutSpline cut) const { SCASSERT(box != nullptr); const QHash *objs = data->DataGObjects(); @@ -170,12 +173,12 @@ void DialogTool::FillComboBoxSplines(QComboBox *box, const quint32 &id, ComboMod while (i.hasNext()) { i.next(); - if (cut == ComboMode::CutSpline) + if (cut == ComboBoxCutSpline::CutSpline) { if (i.key() != id + 1 && i.key() != id + 2) { VGObject *obj = i.value(); - if (obj->getType() == GObject::Spline && obj->getMode() == Valentina::Calculation) + if (obj->getType() == GOType::Spline && obj->getMode() == Draw::Calculation) { const VSpline *spl = data->GeometricObject(i.key()); list[spl->name()] = i.key(); @@ -187,7 +190,7 @@ void DialogTool::FillComboBoxSplines(QComboBox *box, const quint32 &id, ComboMod if (i.key() != id) { VGObject *obj = i.value(); - if (obj->getType() == GObject::Spline && obj->getMode() == Valentina::Calculation) + if (obj->getType() == GOType::Spline && obj->getMode() == Draw::Calculation) { const VSpline *spl = data->GeometricObject(i.key()); list[spl->name()] = i.key(); @@ -205,7 +208,7 @@ void DialogTool::FillComboBoxSplines(QComboBox *box, const quint32 &id, ComboMod * @param id don't show id in list * @param cut if set to ComboMode::CutSpline don't show id+1 and id+2 */ -void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const quint32 &id, ComboMode::ComboBoxCutSpline cut) const +void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const quint32 &id, ComboBoxCutSpline cut) const { SCASSERT(box != nullptr); const QHash *objs = data->DataGObjects(); @@ -214,12 +217,12 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const quint32 &id, Comb while (i.hasNext()) { i.next(); - if (cut == ComboMode::CutSpline) + if (cut == ComboBoxCutSpline::CutSpline) { if (i.key() != id + 1 && i.key() != id + 2) { VGObject *obj = i.value(); - if (obj->getType() == GObject::SplinePath && obj->getMode() == Valentina::Calculation) + if (obj->getType() == GOType::SplinePath && obj->getMode() == Draw::Calculation) { const VSplinePath *splPath = data->GeometricObject(i.key()); list[splPath->name()] = i.key(); @@ -231,7 +234,7 @@ void DialogTool::FillComboBoxSplinesPath(QComboBox *box, const quint32 &id, Comb if (i.key() != id) { VGObject *obj = i.value(); - if (obj->getType() == GObject::SplinePath && obj->getMode() == Valentina::Calculation) + if (obj->getType() == GOType::SplinePath && obj->getMode() == Draw::Calculation) { const VSplinePath *splPath = data->GeometricObject(i.key()); list[splPath->name()] = i.key(); @@ -453,12 +456,12 @@ void DialogTool::Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label) if (osSeparatorValue) { QLocale loc = QLocale::system(); - label->setText(loc.toString(result)); + label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true)); } else { QLocale loc = QLocale(QLocale::C); - label->setText(loc.toString(result)); + label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true)); } flag = true; palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76)); @@ -514,12 +517,12 @@ void DialogTool::Eval(QPlainTextEdit *edit, bool &flag, QTimer *timer, QLabel *l if (osSeparatorValue) { QLocale loc = QLocale::system(); - label->setText(loc.toString(result)); + label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true)); } else { QLocale loc = QLocale(QLocale::C); - label->setText(loc.toString(result)); + label->setText(loc.toString(result) + VDomDocument::UnitsToStr(qApp->patternUnit(), true)); } flag = true; palette.setColor(labelEditFormula->foregroundRole(), QColor(76, 76, 76)); @@ -562,7 +565,7 @@ void DialogTool::setCurrentPointId(QComboBox *box, quint32 &pointId, const quint * @param cut if set to ComboMode::CutSpline don't show id+1 and id+2 */ void DialogTool::setCurrentSplineId(QComboBox *box, quint32 &splineId, const quint32 &value, const quint32 &id, - ComboMode::ComboBoxCutSpline cut) const + ComboBoxCutSpline cut) const { SCASSERT(box != nullptr); FillComboBoxSplines(box, id, cut); @@ -580,7 +583,7 @@ void DialogTool::setCurrentSplineId(QComboBox *box, quint32 &splineId, const qui * @param cut if set to ComboMode::CutArc don't show id+1 and id+2 */ void DialogTool::setCurrentArcId(QComboBox *box, quint32 &arcId, const quint32 &value, const quint32 &id, - ComboMode::ComboBoxCutArc cut) const + ComboBoxCutArc cut) const { SCASSERT(box != nullptr); FillComboBoxArcs(box, id, cut); @@ -598,7 +601,7 @@ void DialogTool::setCurrentArcId(QComboBox *box, quint32 &arcId, const quint32 & * @param cut if set to ComboMode::CutSpline don't show id+1 and id+2 */ void DialogTool::setCurrentSplinePathId(QComboBox *box, quint32 &splinePathId, const quint32 &value, - const quint32 &id, ComboMode::ComboBoxCutSpline cut) const + const quint32 &id, ComboBoxCutSpline cut) const { SCASSERT(box != nullptr); FillComboBoxSplinesPath(box, id, cut); @@ -683,7 +686,7 @@ void DialogTool::CheckState() * @param id id of point or detail * @param type type of object */ -void DialogTool::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogTool::ChoosedObject(quint32 id, const SceneObject &type) { Q_UNUSED(id); Q_UNUSED(type); diff --git a/src/app/dialogs/tools/dialogtool.h b/src/app/dialogs/tools/dialogtool.h index fcbe0a5f3..87f308401 100644 --- a/src/app/dialogs/tools/dialogtool.h +++ b/src/app/dialogs/tools/dialogtool.h @@ -29,32 +29,23 @@ #ifndef DIALOGTOOL_H #define DIALOGTOOL_H -#include #include -#include -#include -#include -#include #include -#include -#include -#include "../../container/vcontainer.h" #include "../../widgets/vapplication.h" -#include "../../tools/vabstracttool.h" -namespace ComboMode -{ - /** - * @brief The ComboBoxCutSpline enum - */ - enum ComboBoxCutSpline { CutSpline, NoCutSpline }; - Q_DECLARE_FLAGS(ComboBoxCutSplines, ComboBoxCutSpline) +class QDoubleSpinBox; +class QLabel; +class QRadioButton; +class QComboBox; +class QListWidgetItem; +class QLineEdit; +class QListWidget; +class VContainer; +class QPlainTextEdit; +class VAbstractTool; - enum ComboBoxCutArc { CutArc, NoCutArc}; - Q_DECLARE_FLAGS(ComboBoxCutArcs, ComboBoxCutArc) -} -Q_DECLARE_OPERATORS_FOR_FLAGS( ComboMode::ComboBoxCutSplines ) -Q_DECLARE_OPERATORS_FOR_FLAGS( ComboMode::ComboBoxCutArcs ) +enum class ComboBoxCutSpline : char { CutSpline, NoCutSpline }; +enum class ComboBoxCutArc : char { CutArc, NoCutArc}; /** * @brief The DialogTool class parent for all dialog of tools. @@ -65,14 +56,8 @@ class DialogTool : public QDialog public: DialogTool(const VContainer *data, QWidget *parent = nullptr); virtual ~DialogTool() {} - inline VAbstractTool* GetAssociatedTool() - { - return this->associatedTool; - } - inline void SetAssociatedTool(VAbstractTool* tool) - { - this->associatedTool=tool; - } + VAbstractTool* GetAssociatedTool(); + void SetAssociatedTool(VAbstractTool* tool); signals: /** * @brief DialogClosed signal dialog closed @@ -89,7 +74,7 @@ signals: */ void ToolTip(const QString &toolTip); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); void NamePointChanged(); virtual void DialogAccepted(); /** @@ -191,11 +176,11 @@ protected: virtual void showEvent( QShowEvent *event ); void FillComboBoxPoints(QComboBox *box, const quint32 &id = 0)const; void FillComboBoxArcs(QComboBox *box, const quint32 &id = 0, - ComboMode::ComboBoxCutArc cut = ComboMode::NoCutArc)const; + ComboBoxCutArc cut = ComboBoxCutArc::NoCutArc)const; void FillComboBoxSplines(QComboBox *box, const quint32 &id = 0, - ComboMode::ComboBoxCutSpline cut = ComboMode::NoCutSpline)const; + ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const; void FillComboBoxSplinesPath(QComboBox *box, const quint32 &id = 0, - ComboMode::ComboBoxCutSpline cut = ComboMode::NoCutSpline)const; + ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const; void FillComboBoxTypeLine(QComboBox *box) const; virtual void CheckState(); QString GetTypeLine(const QComboBox *box)const; @@ -212,12 +197,12 @@ protected: void Eval(QLineEdit *edit, bool &flag, QTimer *timer, QLabel *label); void setCurrentPointId(QComboBox *box, quint32 &pointId, const quint32 &value, const quint32 &id) const; void setCurrentSplineId(QComboBox *box, quint32 &splineId, const quint32 &value, const quint32 &id, - ComboMode::ComboBoxCutSpline cut = ComboMode::NoCutSpline) const; + ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const; void setCurrentArcId(QComboBox *box, quint32 &arcId, const quint32 &value, const quint32 &id, - ComboMode::ComboBoxCutArc cut = ComboMode::NoCutArc) const; + ComboBoxCutArc cut = ComboBoxCutArc::NoCutArc) const; void setCurrentSplinePathId(QComboBox *box, quint32 &splinePathId, const quint32 &value, const quint32 &id, - ComboMode::ComboBoxCutSpline cut = ComboMode::NoCutSpline) const; + ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const; quint32 getCurrentObjectId(QComboBox *box) const; bool ChoosedPoint(const quint32 &id, QComboBox *box, const QString &toolTip); template @@ -248,7 +233,7 @@ protected: connect(listWidget, &QListWidget::currentRowChanged, this, &DialogTool::ValChenged); - if (qApp->patternType() == Pattern::Standard) + if (qApp->patternType() == MeasurementsType::Standard) { SizeHeight(); connect(radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogTool::SizeHeight); @@ -300,4 +285,16 @@ private: void FillList(QComboBox *box, const QMap &list)const; }; +//--------------------------------------------------------------------------------------------------------------------- +inline VAbstractTool *DialogTool::GetAssociatedTool() +{ + return this->associatedTool; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void DialogTool::SetAssociatedTool(VAbstractTool *tool) +{ + this->associatedTool=tool; +} + #endif // DIALOGTOOL_H diff --git a/src/app/dialogs/tools/dialogtriangle.cpp b/src/app/dialogs/tools/dialogtriangle.cpp index f551487aa..b421253fc 100644 --- a/src/app/dialogs/tools/dialogtriangle.cpp +++ b/src/app/dialogs/tools/dialogtriangle.cpp @@ -28,8 +28,8 @@ #include "dialogtriangle.h" #include "ui_dialogtriangle.h" - -#include +#include "../../geometry/vpointf.h" +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -67,9 +67,9 @@ DialogTriangle::~DialogTriangle() * @param id id of point or detail * @param type type of object */ -void DialogTriangle::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogTriangle::ChoosedObject(quint32 id, const SceneObject &type) { - if (type == Valentina::Point) + if (type == SceneObject::Point) { const VPointF *point = data->GeometricObject(id); switch (number) diff --git a/src/app/dialogs/tools/dialogtriangle.h b/src/app/dialogs/tools/dialogtriangle.h index 0281b1f2e..4c648f6b4 100644 --- a/src/app/dialogs/tools/dialogtriangle.h +++ b/src/app/dialogs/tools/dialogtriangle.h @@ -61,7 +61,7 @@ public: QString getPointName() const; void setPointName(const QString &value); public slots: - virtual void ChoosedObject(quint32 id, const Valentina::Scenes &type); + virtual void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** TODO ISSUE 79 : create real function * @brief DialogApply apply data and emit signal about applied dialog. diff --git a/src/app/dialogs/tools/dialoguniondetails.cpp b/src/app/dialogs/tools/dialoguniondetails.cpp index 9e459d71a..c0f7cfd6d 100644 --- a/src/app/dialogs/tools/dialoguniondetails.cpp +++ b/src/app/dialogs/tools/dialoguniondetails.cpp @@ -28,6 +28,8 @@ #include "dialoguniondetails.h" #include "ui_dialoguniondetails.h" +#include "../../geometry/vdetail.h" +#include "../../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- /** @@ -55,7 +57,7 @@ DialogUnionDetails::~DialogUnionDetails() * @param id id of point or detail * @param type type of object */ -void DialogUnionDetails::ChoosedObject(quint32 id, const Valentina::Scenes &type) +void DialogUnionDetails::ChoosedObject(quint32 id, const SceneObject &type) { if (numberD == 0) { @@ -101,12 +103,12 @@ bool DialogUnionDetails::CheckObject(const quint32 &id, const quint32 &idDetail) * @param idDetail id detail * @param index index of edge */ -void DialogUnionDetails::ChoosedDetail(const quint32 &id, const Valentina::Scenes &type, quint32 &idDetail, +void DialogUnionDetails::ChoosedDetail(const quint32 &id, const SceneObject &type, quint32 &idDetail, ptrdiff_t &index) { if (idDetail == 0) { - if (type == Valentina::Detail) + if (type == SceneObject::Detail) { idDetail = id; emit ToolTip(tr("Select first point")); @@ -117,7 +119,7 @@ void DialogUnionDetails::ChoosedDetail(const quint32 &id, const Valentina::Scene { return; } - if (type == Valentina::Point) + if (type == SceneObject::Point) { if (numberP == 0) { diff --git a/src/app/dialogs/tools/dialoguniondetails.h b/src/app/dialogs/tools/dialoguniondetails.h index 4e72252cd..6ef21a3a4 100644 --- a/src/app/dialogs/tools/dialoguniondetails.h +++ b/src/app/dialogs/tools/dialoguniondetails.h @@ -51,7 +51,7 @@ public: ptrdiff_t getIndexD1() const; ptrdiff_t getIndexD2() const; public slots: - void ChoosedObject(quint32 id, const Valentina::Scenes &type); + void ChoosedObject(quint32 id, const SceneObject &type); virtual void DialogAccepted(); /** TODO ISSUE 79 : create real function * @brief DialogApply apply data and emit signal about applied dialog. @@ -88,7 +88,7 @@ private: quint32 p2; bool CheckObject(const quint32 &id, const quint32 &idDetail) const; - void ChoosedDetail(const quint32 &id, const Valentina::Scenes &type, quint32 &idDetail, + void ChoosedDetail(const quint32 &id, const SceneObject &type, quint32 &idDetail, ptrdiff_t &index); }; diff --git a/src/app/dialogs/tools/dialoguniondetails.ui b/src/app/dialogs/tools/dialoguniondetails.ui index 529030b1c..536409c1f 100644 --- a/src/app/dialogs/tools/dialoguniondetails.ui +++ b/src/app/dialogs/tools/dialoguniondetails.ui @@ -6,42 +6,32 @@ 0 0 - 473 + 244 78 Union details - - - - 120 - 40 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 10 - 20 - 451 - 17 - - - - Do you really want union details? This operation can't be undone. - - + + + + + <html><head/><body><p>Do you really want union details?</p></body></html> + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + diff --git a/src/app/exception/vexception.cpp b/src/app/exception/vexception.cpp index e5d63c59c..5722e1f16 100644 --- a/src/app/exception/vexception.cpp +++ b/src/app/exception/vexception.cpp @@ -28,10 +28,10 @@ #include "vexception.h" #include -#include -#include #include "../options.h" -#include + +class QSpacerItem; +class QGridLayout; //--------------------------------------------------------------------------------------------------------------------- /** diff --git a/src/app/exception/vexception.h b/src/app/exception/vexception.h index d6b18deb4..f524ee751 100644 --- a/src/app/exception/vexception.h +++ b/src/app/exception/vexception.h @@ -32,8 +32,8 @@ #include #include -#include -#include + +class QWidget; /** * @brief The VException class parent for all exception. Could be use for abstract exception diff --git a/src/app/exception/vexceptionemptyparameter.cpp b/src/app/exception/vexceptionemptyparameter.cpp index df8ce5051..b9d63e056 100644 --- a/src/app/exception/vexceptionemptyparameter.cpp +++ b/src/app/exception/vexceptionemptyparameter.cpp @@ -27,8 +27,7 @@ *************************************************************************/ #include "vexceptionemptyparameter.h" - -#include +#include //--------------------------------------------------------------------------------------------------------------------- /** diff --git a/src/app/exception/vexceptionemptyparameter.h b/src/app/exception/vexceptionemptyparameter.h index f7fd2df2b..fbb61a2a2 100644 --- a/src/app/exception/vexceptionemptyparameter.h +++ b/src/app/exception/vexceptionemptyparameter.h @@ -31,7 +31,7 @@ #include "vexception.h" -#include +class QDomElement; /** * @brief The VExceptionEmptyParameter class for exception empty parameter diff --git a/src/app/exception/vexceptionobjecterror.cpp b/src/app/exception/vexceptionobjecterror.cpp index 5db24a2f1..b97257ddd 100644 --- a/src/app/exception/vexceptionobjecterror.cpp +++ b/src/app/exception/vexceptionobjecterror.cpp @@ -28,6 +28,7 @@ #include "vexceptionobjecterror.h" #include +#include //--------------------------------------------------------------------------------------------------------------------- /** diff --git a/src/app/exception/vexceptionobjecterror.h b/src/app/exception/vexceptionobjecterror.h index 95570d11b..3e0759c53 100644 --- a/src/app/exception/vexceptionobjecterror.h +++ b/src/app/exception/vexceptionobjecterror.h @@ -31,7 +31,7 @@ #include "vexception.h" -#include +class QDomElement; /** * @brief The VExceptionObjectError class for exception object error diff --git a/src/app/exception/vexceptionwrongid.cpp b/src/app/exception/vexceptionwrongid.cpp index e058fd5dd..edc4c989e 100644 --- a/src/app/exception/vexceptionwrongid.cpp +++ b/src/app/exception/vexceptionwrongid.cpp @@ -28,6 +28,7 @@ #include "vexceptionwrongid.h" #include +#include //--------------------------------------------------------------------------------------------------------------------- /** diff --git a/src/app/exception/vexceptionwrongid.h b/src/app/exception/vexceptionwrongid.h index 12e85bcd3..4f4bb0aad 100644 --- a/src/app/exception/vexceptionwrongid.h +++ b/src/app/exception/vexceptionwrongid.h @@ -31,7 +31,7 @@ #include "vexception.h" -#include +class QDomElement; /** * @brief The VExceptionWrongId class for exception wrong id diff --git a/src/app/geometry/varc.cpp b/src/app/geometry/varc.cpp index ef7805b7c..facf84354 100644 --- a/src/app/geometry/varc.cpp +++ b/src/app/geometry/varc.cpp @@ -27,19 +27,19 @@ *************************************************************************/ #include "varc.h" -#include "vspline.h" -#include "../exception/vexception.h" #include -#include -class QRectF; +#ifdef Q_OS_WIN32 +# include // for M_PI on Windows +#endif /*Q_OS_WIN32*/ + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VArc default constructor. */ VArc::VArc () - :VGObject(GObject::Arc), f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), + :VGObject(GOType::Arc), f1(0), formulaF1(QString()), f2(0), formulaF2(QString()), radius(0), formulaRadius(QString()), center(VPointF()) {} @@ -52,8 +52,8 @@ VArc::VArc () * @param f2 end angle (degree). */ VArc::VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2, - QString formulaF2, quint32 idObject, Valentina::Draws mode) - : VGObject(GObject::Arc, idObject, mode), f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), + QString formulaF2, quint32 idObject, Draw mode) + : VGObject(GOType::Arc, idObject, mode), f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius), center(center) { _name = QString (arc_+"%1").arg(this->GetCenter().name()); @@ -139,8 +139,8 @@ QPainterPath VArc::GetPath() const { for (qint32 i = 0; i < points.count()-1; ++i) { - path.moveTo(points[i]); - path.lineTo(points[i+1]); + path.moveTo(points.at(i)); + path.lineTo(points.at(i+1)); } } else diff --git a/src/app/geometry/varc.h b/src/app/geometry/varc.h index fdaa8cbeb..1aa18aa4a 100644 --- a/src/app/geometry/varc.h +++ b/src/app/geometry/varc.h @@ -30,11 +30,8 @@ #define VARC_H #include "vgobject.h" -#include -#include "../options.h" #include "vpointf.h" -class QString; -class QLineF; + class QPainterPath; /** @@ -46,7 +43,7 @@ class VArc: public VGObject public: VArc (); VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2, - QString formulaF2, quint32 idObject = 0, Valentina::Draws mode = Valentina::Calculation); + QString formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation); VArc(const VArc &arc); VArc& operator= (const VArc &arc); QString GetFormulaF1 () const; diff --git a/src/app/geometry/vdetail.cpp b/src/app/geometry/vdetail.cpp index bfa7f346f..6af182008 100644 --- a/src/app/geometry/vdetail.cpp +++ b/src/app/geometry/vdetail.cpp @@ -28,17 +28,18 @@ #include "vdetail.h" #include +#include //--------------------------------------------------------------------------------------------------------------------- VDetail::VDetail() :_id(0), nodes(QVector()), name(QString()), mx(0), my(0), seamAllowance(true), closed(true), - width(10) + width(0) {} //--------------------------------------------------------------------------------------------------------------------- VDetail::VDetail(const QString &name, const QVector &nodes) :_id(0), nodes(QVector()), name(name), mx(0), my(0), seamAllowance(true), closed(true), - width(10) + width(0) { this->nodes = nodes; } @@ -72,7 +73,7 @@ void VDetail::Clear() my = 0; seamAllowance = true; closed = true; - width = 10; + width = 0; } //--------------------------------------------------------------------------------------------------------------------- @@ -86,7 +87,7 @@ bool VDetail::Containes(const quint32 &id) const { for (ptrdiff_t i = 0; i < nodes.size(); ++i) { - VNodeDetail node = nodes[i]; + VNodeDetail node = nodes.at(i); if (node.getId() == id) { return true; @@ -104,7 +105,7 @@ VNodeDetail &VDetail::operator [](ptrdiff_t indx) //--------------------------------------------------------------------------------------------------------------------- const VNodeDetail &VDetail::at(ptrdiff_t indx) const { - return nodes[indx]; + return nodes.at(indx); } //--------------------------------------------------------------------------------------------------------------------- @@ -254,25 +255,26 @@ VDetail VDetail::RemoveEdge(const quint32 &index) const //--------------------------------------------------------------------------------------------------------------------- QList VDetail::Missing(const VDetail &det) const { - QList list; if (nodes.size() == det.CountNode()) { - return list; + return QList(); } - qint32 j = 0; + QSet set1; for (qint32 i = 0; i < nodes.size(); ++i) { - if (nodes[i].getId() == det.at(j).getId()) - { - ++j; - } - else - { - list.append(nodes[i].getId()); - } + set1.insert(nodes.at(i).getId()); } - return list; + + QSet set2; + for (qint32 j = 0; j < det.CountNode(); ++j) + { + set2.insert(det.at(j).getId()); + } + + QSet set3 = set1.subtract(set2); + + return set3.toList(); } //--------------------------------------------------------------------------------------------------------------------- @@ -281,9 +283,9 @@ QVector VDetail::listNodePoint() const QVector list; for (ptrdiff_t i = 0; i < nodes.size(); ++i) { - if (nodes[i].getTypeTool() == Valentina::NodePoint) + if (nodes.at(i).getTypeTool() == Tool::NodePoint) { - list.append(nodes[i]); + list.append(nodes.at(i)); } } return list; @@ -294,7 +296,7 @@ ptrdiff_t VDetail::indexOfNode(const QVector &list, const quint32 & { for (ptrdiff_t i = 0; i < list.size(); ++i) { - if (list[i].getId() == id) + if (list.at(i).getId() == id) { return i; } diff --git a/src/app/geometry/vdetail.h b/src/app/geometry/vdetail.h index 373a50cbf..efcf6f7f5 100644 --- a/src/app/geometry/vdetail.h +++ b/src/app/geometry/vdetail.h @@ -30,28 +30,12 @@ #define VDETAIL_H #include "vnodedetail.h" - -#include #include -namespace Detail -{ - /** - * @brief The Contour enum OpenContour - first and last points contour don't match, - * CloseContour - first and last points contour match. - */ - enum Contour { OpenContour, CloseContour }; - Q_DECLARE_FLAGS(Contours, Contour) +class QString; - /** - * @brief The Equidistant enum OpenEquidistant - first and last points equidistant don't match, - * CloseEquidistant - first and last points equidistant match. - */ - enum Equidistant { OpenEquidistant, CloseEquidistant }; - Q_DECLARE_FLAGS(Equidistants, Equidistant) -} -Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Contours) -Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Equidistants) +enum class Contour : char { OpenContour, CloseContour }; +enum class EquidistantType : char { OpenEquidistant, CloseEquidistant }; /** * @brief The VDetail class for path of object (points, arcs, splines). diff --git a/src/app/geometry/vequidistant.cpp b/src/app/geometry/vequidistant.cpp index e44b05ead..cab6b2223 100644 --- a/src/app/geometry/vequidistant.cpp +++ b/src/app/geometry/vequidistant.cpp @@ -26,9 +26,15 @@ ** *************************************************************************/ +#include "varc.h" #include "vequidistant.h" +#include "vpointf.h" +#include "vspline.h" +#include "vsplinepath.h" #include "../widgets/vapplication.h" #include +#include +#include "../container/vcontainer.h" //--------------------------------------------------------------------------------------------------------------------- QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer *data) const @@ -41,7 +47,7 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer { switch (detail.at(i).getTypeTool()) { - case (Valentina::NodePoint): + case (Tool::NodePoint): { const VPointF *point = data->GeometricObject(detail.at(i).getId()); points.append(point->toQPointF()); @@ -54,7 +60,7 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer } } break; - case (Valentina::NodeArc): + case (Tool::NodeArc): { const VArc *arc = data->GeometricObject(detail.at(i).getId()); qreal len1 = GetLengthContour(points, arc->GetPoints()); @@ -78,7 +84,7 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer } } break; - case (Valentina::NodeSpline): + case (Tool::NodeSpline): { const VSpline *spline = data->GeometricObject(detail.at(i).getId()); qreal len1 = GetLengthContour(points, spline->GetPoints()); @@ -102,7 +108,7 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer } } break; - case (Valentina::NodeSplinePath): + case (Tool::NodeSplinePath): { const VSplinePath *splinePath = data->GeometricObject(detail.at(i).getId()); qreal len1 = GetLengthContour(points, splinePath->GetPathPoints()); @@ -126,8 +132,29 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer } } break; + case (Tool::ArrowTool): + case (Tool::SinglePointTool): + case (Tool::EndLineTool): + case (Tool::LineTool): + case (Tool::AlongLineTool): + case (Tool::ShoulderPointTool): + case (Tool::NormalTool): + case (Tool::BisectorTool): + case (Tool::LineIntersectTool): + case (Tool::SplineTool): + case (Tool::CutSplineTool): + case (Tool::CutArcTool): + case (Tool::ArcTool): + case (Tool::SplinePathTool): + case (Tool::CutSplinePathTool): + case (Tool::PointOfContact): + case (Tool::DetailTool): + case (Tool::Height): + case (Tool::Triangle): + case (Tool::PointOfIntersection): + case (Tool::UnionDetails): default: - qDebug()<<"Get wrong tool type. Ignore."<(detail.at(i).getTypeTool()); break; } } @@ -136,9 +163,9 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer path.moveTo(points[0]); for (qint32 i = 1; i < points.count(); ++i) { - path.lineTo(points[i]); + path.lineTo(points.at(i)); } - path.lineTo(points[0]); + path.lineTo(points.at(0)); pointsEkv = CorrectEquidistantPoints(pointsEkv); pointsEkv = CheckLoops(pointsEkv); @@ -148,11 +175,11 @@ QPainterPath VEquidistant::ContourPath(const quint32 &idDetail, const VContainer QPainterPath ekv; if (detail.getClosed() == true) { - ekv = Equidistant(pointsEkv, Detail::CloseEquidistant, qApp->toPixel(detail.getWidth())); + ekv = Equidistant(pointsEkv, EquidistantType::CloseEquidistant, qApp->toPixel(detail.getWidth())); } else { - ekv = Equidistant(pointsEkv, Detail::OpenEquidistant, qApp->toPixel(detail.getWidth())); + ekv = Equidistant(pointsEkv, EquidistantType::OpenEquidistant, qApp->toPixel(detail.getWidth())); } path.addPath(ekv); path.setFillRule(Qt::WindingFill); @@ -223,8 +250,8 @@ QVector VEquidistant::CorrectEquidistantPoints(const QVector & QPointF point; for (qint32 i = 1; i VEquidistant::CorrectEquidistantPoints(const QVector & } //--------------------------------------------------------------------------------------------------------------------- -QPainterPath VEquidistant::Equidistant(QVector points, const Detail::Equidistant &eqv, - const qreal &width) +QPainterPath VEquidistant::Equidistant(QVector points, const EquidistantType &eqv, const qreal &width) { QPainterPath ekv; QVector ekvPoints; @@ -245,59 +271,64 @@ QPainterPath VEquidistant::Equidistant(QVector points, const Detail::Eq qDebug()<<"Not enough points for building the equidistant.\n"; return ekv; } + if (width <= 0) + { + qDebug()<<"Width <= 0.\n"; + return ekv; + } for (qint32 i = 0; i < points.size(); ++i ) { if (i != points.size()-1) { - if (points[i] == points[i+1]) + if (points.at(i) == points.at(i+1)) { points.remove(i+1); } } else { - if (points[i] == points[0]) + if (points.at(i) == points.at(0)) { points.remove(i); } } } - if (eqv == Detail::CloseEquidistant) + if (eqv == EquidistantType::CloseEquidistant) { points.append(points.at(0)); } for (qint32 i = 0; i < points.size(); ++i ) { - if ( i == 0 && eqv == Detail::CloseEquidistant) + if ( i == 0 && eqv == EquidistantType::CloseEquidistant) {//first point, polyline closed - ekvPoints< -#include "../container/vcontainer.h" +#include "vdetail.h" + +class QPainterPath; +class VContainer; +class QPointF; +class QLineF; /** * @brief The VEquidistant class calculate equidistant for detail. @@ -74,7 +78,7 @@ private: * @param width width of equidistant. * @return return painter path of equidistant. */ - static QPainterPath Equidistant(QVector points, const Detail::Equidistant &eqv, const qreal &width); + static QPainterPath Equidistant(QVector points, const EquidistantType &eqv, const qreal &width); /** * @brief CheckLoops seek and delete loops in equidistant. * @param points vector of points of equidistant. diff --git a/src/app/geometry/vgobject.cpp b/src/app/geometry/vgobject.cpp index 4ec61a1c3..17bb1b859 100644 --- a/src/app/geometry/vgobject.cpp +++ b/src/app/geometry/vgobject.cpp @@ -33,7 +33,7 @@ * @brief VGObject default constructor. */ VGObject::VGObject() - :_id(0), type(GObject::Point), idObject(0), _name(QString()), mode(Valentina::Calculation) + :_id(0), type(GOType::Point), idObject(0), _name(QString()), mode(Draw::Calculation) {} //--------------------------------------------------------------------------------------------------------------------- @@ -43,7 +43,7 @@ VGObject::VGObject() * @param idObject id parent object. * @param mode mode creation. Used in modeling mode. */ -VGObject::VGObject(const GObject::Type &type, const quint32 &idObject, const Valentina::Draws &mode) +VGObject::VGObject(const GOType &type, const quint32 &idObject, const Draw &mode) :_id(0), type(type), idObject(idObject), _name(QString()), mode(mode) {} @@ -117,7 +117,7 @@ void VGObject::setName(const QString &name) * @brief getMode return mode creation. * @return mode. */ -Valentina::Draws VGObject::getMode() const +Draw VGObject::getMode() const { return mode; } @@ -127,7 +127,7 @@ Valentina::Draws VGObject::getMode() const * @brief setMode set mode creation. * @param value mode. */ -void VGObject::setMode(const Valentina::Draws &value) +void VGObject::setMode(const Draw &value) { mode = value; } @@ -137,7 +137,7 @@ void VGObject::setMode(const Valentina::Draws &value) * @brief getType return object type. * @return type. */ -GObject::Type VGObject::getType() const +GOType VGObject::getType() const { return type; } diff --git a/src/app/geometry/vgobject.h b/src/app/geometry/vgobject.h index 29a6d71ad..e6e86f96c 100644 --- a/src/app/geometry/vgobject.h +++ b/src/app/geometry/vgobject.h @@ -30,20 +30,8 @@ #define VGOBJECT_H #include "../options.h" -#include "../exception/vexception.h" -#include -#include - -namespace GObject -{ - /** - * @brief The NodeDetail enum type of graphical objects. - */ - enum Type { Point, Arc, Spline, SplinePath }; - Q_DECLARE_FLAGS(Types, Type) -} -Q_DECLARE_OPERATORS_FOR_FLAGS(GObject::Types) +enum class GOType : char { Point, Arc, Spline, SplinePath }; /** * @brief The VGObject class keep information graphical objects. @@ -52,8 +40,7 @@ class VGObject { public: VGObject(); - VGObject(const GObject::Type &type, const quint32 &idObject = 0, - const Valentina::Draws &mode = Valentina::Calculation); + VGObject(const GOType &type, const quint32 &idObject = 0, const Draw &mode = Draw::Calculation); VGObject(const VGObject &obj); VGObject& operator= (const VGObject &obj); virtual ~VGObject(){} @@ -61,9 +48,9 @@ public: void setIdObject(const quint32 &value); virtual QString name() const; void setName(const QString &name); - Valentina::Draws getMode() const; - void setMode(const Valentina::Draws &value); - GObject::Type getType() const; + Draw getMode() const; + void setMode(const Draw &value); + GOType getType() const; quint32 id() const; virtual void setId(const quint32 &id); protected: @@ -71,7 +58,7 @@ protected: quint32 _id; /** @brief type type of graphical object */ - GObject::Type type; + GOType type; /** @brief idObject id of parent object. Only for modeling. All another return 0. */ quint32 idObject; @@ -80,7 +67,7 @@ protected: QString _name; /** @brief mode object created in calculation or drawing mode */ - Valentina::Draws mode; + Draw mode; }; #endif // VGOBJECT_H diff --git a/src/app/geometry/vnodedetail.cpp b/src/app/geometry/vnodedetail.cpp index 02159fb4d..4db005d90 100644 --- a/src/app/geometry/vnodedetail.cpp +++ b/src/app/geometry/vnodedetail.cpp @@ -30,11 +30,11 @@ //--------------------------------------------------------------------------------------------------------------------- VNodeDetail::VNodeDetail() - :id(0), typeTool(Valentina::NodePoint), typeNode(NodeDetail::Contour), mx(0), my(0) + :id(0), typeTool(Tool::NodePoint), typeNode(NodeDetail::Contour), mx(0), my(0) {} //--------------------------------------------------------------------------------------------------------------------- -VNodeDetail::VNodeDetail(quint32 id, Valentina::Tools typeTool, NodeDetail::NodeDetails typeNode, qreal mx, qreal my) +VNodeDetail::VNodeDetail(quint32 id, Tool typeTool, NodeDetail typeNode, qreal mx, qreal my) :id(id), typeTool(typeTool), typeNode(typeNode), mx(mx), my(my) {} diff --git a/src/app/geometry/vnodedetail.h b/src/app/geometry/vnodedetail.h index 72b11d893..936e06d52 100644 --- a/src/app/geometry/vnodedetail.h +++ b/src/app/geometry/vnodedetail.h @@ -29,18 +29,9 @@ #ifndef VNODEDETAIL_H #define VNODEDETAIL_H -#include #include "../options.h" -namespace NodeDetail -{ - /** - * @brief The NodeDetail enum node can be node of contour or node modeling. - */ - enum NodeDetail { Contour, Modeling }; - Q_DECLARE_FLAGS(NodeDetails, NodeDetail) -} -Q_DECLARE_OPERATORS_FOR_FLAGS(NodeDetail::NodeDetails) +enum class NodeDetail : char { Contour, Modeling }; /** * @brief The VNodeDetail class keep information about detail node. @@ -60,8 +51,7 @@ public: * @param mx object bias x axis * @param my object bias y axis */ - VNodeDetail(quint32 id, Valentina::Tools typeTool, NodeDetail::NodeDetails typeNode, qreal mx = 0, - qreal my = 0); + VNodeDetail(quint32 id, Tool typeTool, NodeDetail typeNode, qreal mx = 0, qreal my = 0); /** * @brief VNodeDetail copy constructor * @param node node @@ -87,22 +77,22 @@ public: * @brief getTypeTool return tool type. * @return tool type. */ - Valentina::Tools getTypeTool() const; + Tool getTypeTool() const; /** * @brief setTypeTool set tool type. * @param value tool type. */ - void setTypeTool(const Valentina::Tools &value); + void setTypeTool(const Tool &value); /** * @brief getTypeNode return node type. * @return node type. */ - NodeDetail::NodeDetails getTypeNode() const; + NodeDetail getTypeNode() const; /** * @brief setTypeNode set node type. * @param value node type. */ - void setTypeNode(const NodeDetail::NodeDetails &value); + void setTypeNode(const NodeDetail &value); /** * @brief getMx return object bias x axis. * @return bias x axis. @@ -131,11 +121,11 @@ private: /** * @brief typeTool type of tool */ - Valentina::Tools typeTool; + Tool typeTool; /** * @brief typeNode node type. */ - NodeDetail::NodeDetails typeNode; + NodeDetail typeNode; /** * @brief mx bias x axis. */ @@ -156,22 +146,22 @@ inline void VNodeDetail::setId(const quint32 &value) id = value; } -inline Valentina::Tools VNodeDetail::getTypeTool() const +inline Tool VNodeDetail::getTypeTool() const { return typeTool; } -inline void VNodeDetail::setTypeTool(const Valentina::Tools &value) +inline void VNodeDetail::setTypeTool(const Tool &value) { typeTool = value; } -inline NodeDetail::NodeDetails VNodeDetail::getTypeNode() const +inline NodeDetail VNodeDetail::getTypeNode() const { return typeNode; } -inline void VNodeDetail::setTypeNode(const NodeDetail::NodeDetails &value) +inline void VNodeDetail::setTypeNode(const NodeDetail &value) { typeNode = value; } diff --git a/src/app/geometry/vpointf.cpp b/src/app/geometry/vpointf.cpp index 76889fa04..dfc80a326 100644 --- a/src/app/geometry/vpointf.cpp +++ b/src/app/geometry/vpointf.cpp @@ -27,6 +27,8 @@ *************************************************************************/ #include "vpointf.h" +#include +#include //--------------------------------------------------------------------------------------------------------------------- /** @@ -36,8 +38,8 @@ * @param mx offset name respect to x * @param my offset name respect to y */ -VPointF::VPointF(qreal x, qreal y, QString name, qreal mx, qreal my, quint32 idObject, Valentina::Draws mode) - :VGObject(GObject::Point, idObject, mode), _mx(mx), _my(my), _x(x), _y(y) +VPointF::VPointF(qreal x, qreal y, QString name, qreal mx, qreal my, quint32 idObject, Draw mode) + :VGObject(GOType::Point, idObject, mode), _mx(mx), _my(my), _x(x), _y(y) { this->_name = name; } @@ -46,7 +48,7 @@ VPointF::VPointF(qreal x, qreal y, QString name, qreal mx, qreal my, quint32 idO /** * @brief VPointF creat empty point */ -VPointF::VPointF() :VGObject(GObject::Point, 0, Valentina::Calculation), _mx(0), _my(0), _x(0), _y(0) +VPointF::VPointF() :VGObject(GOType::Point, 0, Draw::Calculation), _mx(0), _my(0), _x(0), _y(0) {} //--------------------------------------------------------------------------------------------------------------------- @@ -78,3 +80,13 @@ QString VPointF::name() const { return _name; } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief toQPointF convert to QPointF + * @return QPointF point + */ +QPointF VPointF::toQPointF() const +{ + return QPointF(_x, _y); +} diff --git a/src/app/geometry/vpointf.h b/src/app/geometry/vpointf.h index 04955e1ee..942525ae9 100644 --- a/src/app/geometry/vpointf.h +++ b/src/app/geometry/vpointf.h @@ -29,11 +29,11 @@ #ifndef VPOINTF_H #define VPOINTF_H -#include -#include -#include "../options.h" #include "vgobject.h" +class QPointF; +class QString; + /** * @brief The VPointF class keep data of point. */ @@ -44,7 +44,7 @@ public: VPointF (const VPointF &point ); VPointF (const QPointF &point ); VPointF ( qreal x, qreal y, QString name, qreal mx, qreal my, quint32 idObject = 0, - Valentina::Draws mode = Valentina::Calculation); + Draw mode = Draw::Calculation); virtual ~VPointF(){} VPointF &operator=(const VPointF &point); qreal mx() const; @@ -111,16 +111,6 @@ inline void VPointF::setMy(qreal my) _my = my; } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief toQPointF convert to QPointF - * @return QPointF point - */ -inline QPointF VPointF::toQPointF() const -{ - return QPointF(_x, _y); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief x return x coordinate diff --git a/src/app/geometry/vspline.cpp b/src/app/geometry/vspline.cpp index 1289ad14b..ffd837bb5 100644 --- a/src/app/geometry/vspline.cpp +++ b/src/app/geometry/vspline.cpp @@ -27,16 +27,18 @@ *************************************************************************/ #include "vspline.h" -#include #include -#include + +#ifdef Q_OS_WIN32 +# include // for M_PI on Windows +#endif /*Q_OS_WIN32*/ //--------------------------------------------------------------------------------------------------------------------- /** * @brief VSpline default constructor */ VSpline::VSpline() - :VGObject(GObject::Spline), p1(VPointF()), p2(QPointF()), p3(QPointF()), p4(VPointF()), angle1(0), angle2(0), + :VGObject(GOType::Spline), p1(VPointF()), p2(QPointF()), p3(QPointF()), p4(VPointF()), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1) {} @@ -63,8 +65,8 @@ VSpline::VSpline ( const VSpline & spline ) * @param kAsm2 coefficient of length second control line. */ VSpline::VSpline (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve, - quint32 idObject, Valentina::Draws mode) - :VGObject(GObject::Spline, idObject, mode), p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1), + quint32 idObject, Draw mode) + :VGObject(GOType::Spline, idObject, mode), p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), kCurve(kCurve) { CreateName(); @@ -98,8 +100,8 @@ VSpline::VSpline (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm * @param p3 second control point. * @param p4 second point spline. */ -VSpline::VSpline (VPointF p1, QPointF p2, QPointF p3, VPointF p4, qreal kCurve, quint32 idObject, Valentina::Draws mode) - :VGObject(GObject::Spline, idObject, mode), p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), +VSpline::VSpline (VPointF p1, QPointF p2, QPointF p3, VPointF p4, qreal kCurve, quint32 idObject, Draw mode) + :VGObject(GOType::Spline, idObject, mode), p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1) { CreateName(); @@ -168,8 +170,8 @@ QLineF::IntersectType VSpline::CrossingSplLine ( const QLineF &line, QPointF *in QLineF::IntersectType type = QLineF::NoIntersection; for ( i = 0; i < px.count()-1; ++i ) { - type = line.intersect(QLineF ( QPointF ( px[i], py[i] ), - QPointF ( px[i+1], py[i+1] )), &crosPoint); + type = line.intersect(QLineF ( QPointF ( px.at(i), py.at(i) ), + QPointF ( px.at(i+1), py.at(i+1) )), &crosPoint); if ( type == QLineF::BoundedIntersection ) { *intersectionPoint = crosPoint; @@ -318,7 +320,7 @@ QVector VSpline::GetPoints (const QPointF &p1, const QPointF &p2, const y.append ( p4.y () ); for ( qint32 i = 0; i < x.count(); ++i ) { - pvector.append( QPointF ( x[i], y[i] ) ); + pvector.append( QPointF ( x.at(i), y.at(i)) ); } return pvector; } @@ -336,10 +338,10 @@ qreal VSpline::LengthBezier ( const QPointF &p1, const QPointF &p2, const QPoint { QPainterPath splinePath; QVector points = GetPoints (p1, p2, p3, p4); - splinePath.moveTo(points[0]); + splinePath.moveTo(points.at(0)); for (qint32 i = 1; i < points.count(); ++i) { - splinePath.lineTo(points[i]); + splinePath.lineTo(points.at(i)); } return splinePath.length(); } @@ -675,8 +677,8 @@ QPainterPath VSpline::GetPath() const { for (qint32 i = 0; i < points.count()-1; ++i) { - splinePath.moveTo(points[i]); - splinePath.lineTo(points[i+1]); + splinePath.moveTo(points.at(i)); + splinePath.lineTo(points.at(i+1)); } } else diff --git a/src/app/geometry/vspline.h b/src/app/geometry/vspline.h index 5fb8f1659..e749f0863 100644 --- a/src/app/geometry/vspline.h +++ b/src/app/geometry/vspline.h @@ -32,11 +32,8 @@ #include "vpointf.h" #include "vgobject.h" -#include -#include -#include - -class QString; +class QLineF; +class QPainterPath; #define M_2PI 6.28318530717958647692528676655900576 @@ -49,9 +46,10 @@ public: VSpline(); VSpline (const VSpline &spline ); VSpline (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve, - quint32 idObject = 0, Valentina::Draws mode = Valentina::Calculation); + quint32 idObject = 0, Draw mode = Draw::Calculation); VSpline (VPointF p1, QPointF p2, QPointF p3, VPointF p4, qreal kCurve, quint32 idObject = 0, - Valentina::Draws mode = Valentina::Calculation); + Draw mode = Draw::Calculation); + VSpline &operator=(const VSpline &spl); VPointF GetP1 () const; QPointF GetP2 () const; QPointF GetP3 () const; @@ -72,7 +70,6 @@ public: // cppcheck-suppress unusedFunction static QVector SplinePoints(const QPointF &p1, const QPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve); - VSpline &operator=(const VSpline &spl); protected: static QVector GetPoints (const QPointF &p1, const QPointF &p2, const QPointF &p3, const QPointF &p4 ); private: diff --git a/src/app/geometry/vsplinepath.cpp b/src/app/geometry/vsplinepath.cpp index b403fc283..003d7ea90 100644 --- a/src/app/geometry/vsplinepath.cpp +++ b/src/app/geometry/vsplinepath.cpp @@ -30,8 +30,8 @@ #include "../exception/vexception.h" //--------------------------------------------------------------------------------------------------------------------- -VSplinePath::VSplinePath(qreal kCurve, quint32 idObject, Valentina::Draws mode) - : VGObject(GObject::SplinePath, idObject, mode), path(QVector()), kCurve(kCurve), maxCountPoints(0) +VSplinePath::VSplinePath(qreal kCurve, quint32 idObject, Draw mode) + : VGObject(GOType::SplinePath, idObject, mode), path(QVector()), kCurve(kCurve), maxCountPoints(0) {} //--------------------------------------------------------------------------------------------------------------------- @@ -76,8 +76,8 @@ VSpline VSplinePath::GetSpline(qint32 index) const { throw VException(tr("This spline does not exist.")); } - VSpline spl(path[index-1].P(), path[index].P(), path[index-1].Angle2(), path[index].Angle1(), - path[index-1].KAsm2(), path[index].KAsm1(), this->kCurve); + VSpline spl(path.at(index-1).P(), path.at(index).P(), path.at(index-1).Angle2(), path.at(index).Angle1(), + path.at(index-1).KAsm2(), path.at(index).KAsm1(), this->kCurve); return spl; } @@ -87,8 +87,8 @@ QPainterPath VSplinePath::GetPath() const QPainterPath painterPath; for (qint32 i = 1; i <= Count(); ++i) { - VSpline spl(path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), - path[i-1].KAsm2(), path[i].KAsm1(), this->kCurve); + VSpline spl(path.at(i-1).P(), path.at(i).P(), path.at(i-1).Angle2(), path.at(i).Angle1(), + path.at(i-1).KAsm2(), path.at(i).KAsm1(), this->kCurve); painterPath.addPath(spl.GetPath()); } return painterPath; @@ -100,8 +100,8 @@ QVector VSplinePath::GetPathPoints() const QVector pathPoints; for (qint32 i = 1; i <= Count(); ++i) { - VSpline spl(path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), - path[i-1].KAsm2(), path[i].KAsm1(), this->kCurve); + VSpline spl(path.at(i-1).P(), path.at(i).P(), path.at(i-1).Angle2(), path.at(i).Angle1(), + path.at(i-1).KAsm2(), path.at(i).KAsm1(), this->kCurve); pathPoints += spl.GetPoints(); } return pathPoints; @@ -113,21 +113,21 @@ qreal VSplinePath::GetLength() const qreal length = 0; for (qint32 i = 1; i <= Count(); ++i) { - VSpline spl(path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(), - path[i].KAsm1(), kCurve); + VSpline spl(path.at(i-1).P(), path.at(i).P(), path.at(i-1).Angle2(), path.at(i).Angle1(), path.at(i-1).KAsm2(), + path.at(i).KAsm1(), kCurve); length += spl.GetLength(); } return length; } //--------------------------------------------------------------------------------------------------------------------- -void VSplinePath::UpdatePoint(qint32 indexSpline, const SplinePoint::Position &pos, const VSplinePoint &point) +void VSplinePath::UpdatePoint(qint32 indexSpline, const SplinePointPosition &pos, const VSplinePoint &point) { if (indexSpline < 1 || indexSpline > Count()) { throw VException(tr("This spline does not exist.")); } - if (pos == SplinePoint::FirstPoint) + if (pos == SplinePointPosition::FirstPoint) { path[indexSpline-1] = point; } @@ -138,13 +138,13 @@ void VSplinePath::UpdatePoint(qint32 indexSpline, const SplinePoint::Position &p } //--------------------------------------------------------------------------------------------------------------------- -VSplinePoint VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const +VSplinePoint VSplinePath::GetSplinePoint(qint32 indexSpline, SplinePointPosition pos) const { if (indexSpline < 1 || indexSpline > Count()) { throw VException(tr("This spline does not exist.")); } - if (pos == SplinePoint::FirstPoint) + if (pos == SplinePointPosition::FirstPoint) { return path.at(indexSpline-1); } @@ -199,8 +199,8 @@ QPointF VSplinePath::CutSplinePath(qreal length, qint32 &p1, qint32 &p2, QPointF fullLength = 0; for (qint32 i = 1; i <= Count(); ++i) { - VSpline spl = VSpline(path[i-1].P(), path[i].P(), path[i-1].Angle2(), path[i].Angle1(), path[i-1].KAsm2(), - path[i].KAsm1(), kCurve); + VSpline spl = VSpline(path.at(i-1).P(), path.at(i).P(), path.at(i-1).Angle2(), path.at(i).Angle1(), + path.at(i-1).KAsm2(), path.at(i).KAsm1(), kCurve); fullLength += spl.GetLength(); if (fullLength > length) { diff --git a/src/app/geometry/vsplinepath.h b/src/app/geometry/vsplinepath.h index f162da02a..991799401 100644 --- a/src/app/geometry/vsplinepath.h +++ b/src/app/geometry/vsplinepath.h @@ -29,22 +29,11 @@ #ifndef VSPLINEPATH_H #define VSPLINEPATH_H -#include "vsplinepoint.h" -#include "vpointf.h" -#include "vspline.h" #include "vgobject.h" -#include -#include "../container/vcontainer.h" +#include "vspline.h" +#include "vsplinepoint.h" -namespace SplinePoint -{ - /** - * @brief The Position enum position in spline. - */ - enum Position { FirstPoint, LastPoint }; - Q_DECLARE_FLAGS(Positions, Position) -} -Q_DECLARE_OPERATORS_FOR_FLAGS( SplinePoint::Positions ) +enum class SplinePointPosition : char { FirstPoint, LastPoint }; /** * @brief The VSplinePath class keep information about splinePath. @@ -59,7 +48,7 @@ public: * @param idObject parent id. * @param mode mode creation spline path. */ - VSplinePath(qreal kCurve = 1, quint32 idObject = 0, Valentina::Draws mode = Valentina::Calculation); + VSplinePath(qreal kCurve = 1, quint32 idObject = 0, Draw mode = Draw::Calculation); /** * @brief VSplinePath copy constructor. * @param splPath spline path. @@ -112,14 +101,14 @@ public: * @param pos position point in spline. * @param point point. */ - void UpdatePoint(qint32 indexSpline, const SplinePoint::Position &pos, const VSplinePoint &point); + void UpdatePoint(qint32 indexSpline, const SplinePointPosition &pos, const VSplinePoint &point); /** * @brief GetSplinePoint return spline point from list. * @param indexSpline spline index in list. * @param pos position point in spline. * @return spline point. */ - VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePoint::Position pos) const; + VSplinePoint GetSplinePoint(qint32 indexSpline, SplinePointPosition pos) const; /** * @brief Clear clear list of points. */ diff --git a/src/app/geometry/vsplinepoint.h b/src/app/geometry/vsplinepoint.h index 95a07a911..f19826c5e 100644 --- a/src/app/geometry/vsplinepoint.h +++ b/src/app/geometry/vsplinepoint.h @@ -29,7 +29,6 @@ #ifndef VSPLINEPOINT_H #define VSPLINEPOINT_H -#include #include "vpointf.h" /** diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 88442fed0..4583238f2 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -36,6 +36,8 @@ #include "exception/vexceptionwrongid.h" #include "version.h" #include "xml/vstandardmeasurements.h" +#include "xml/vindividualmeasurements.h" +#include "widgets/vapplication.h" #include #include @@ -52,10 +54,10 @@ * @param parent parent widget. */ MainWindow::MainWindow(QWidget *parent) - :QMainWindow(parent), ui(new Ui::MainWindow), pattern(nullptr), doc(nullptr), tool(Valentina::ArrowTool), + :QMainWindow(parent), ui(new Ui::MainWindow), pattern(nullptr), doc(nullptr), tool(Tool::ArrowTool), currentScene(nullptr), sceneDraw(nullptr), sceneDetails(nullptr), mouseCoordinate(nullptr), helpLabel(nullptr), view(nullptr), isInitialized(false), dialogTable(0), dialogTool(nullptr), dialogHistory(nullptr), - comboBoxDraws(nullptr), curFile(QString()), mode(Valentina::Calculation), currentDrawIndex(0), + comboBoxDraws(nullptr), curFile(QString()), mode(Draw::Calculation), currentDrawIndex(0), currentToolBoxIndex(0), drawMode(true), recentFileActs{0, 0, 0, 0, 0}, separatorAct(nullptr), autoSaveTimer(nullptr) { @@ -82,6 +84,7 @@ MainWindow::MainWindow(QWidget *parent) QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); policy.setHorizontalStretch(12); view->setSizePolicy(policy); + qApp->setSceneView(view); helpLabel = new QLabel(QObject::tr("Create new pattern piece to start working.")); ui->statusBar->addWidget(helpLabel); @@ -89,9 +92,11 @@ MainWindow::MainWindow(QWidget *parent) pattern = new VContainer(); - doc = new VPattern(pattern, comboBoxDraws, &mode); - connect(doc, &VPattern::patternChanged, this, &MainWindow::PatternWasModified); + doc = new VPattern(pattern, &mode, sceneDraw, sceneDetails); connect(doc, &VPattern::ClearMainWindow, this, &MainWindow::Clear); + connect(doc, &VPattern::UndoCommand, this, &MainWindow::FullParseFile); + + connect(qApp->getUndoStack(), &QUndoStack::cleanChanged, this, &MainWindow::PatternWasModified); InitAutoSave(); @@ -104,19 +109,22 @@ MainWindow::MainWindow(QWidget *parent) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief ActionNewDraw add to scene new pattern peace. + * @brief ActionNewPP add to scene new pattern piece. */ -void MainWindow::ActionNewDraw() +void MainWindow::ActionNewPP() { QString patternPieceName = QString(tr("Pattern piece %1")).arg(comboBoxDraws->count()+1); + QString path; if (comboBoxDraws->count() == 0) { - QString path; DialogMeasurements measurements(this); - measurements.exec(); - if (measurements.type() == Measurements::Standard) + if (measurements.exec() == QDialog::Rejected) { - qApp->setPatternType(Pattern::Standard); + return; + } + if (measurements.type() == MeasurementsType::Standard) + { + qApp->setPatternType(MeasurementsType::Standard); DialogStandardMeasurements stMeasurements(pattern, patternPieceName, this); if (stMeasurements.exec() == QDialog::Accepted) { @@ -135,7 +143,7 @@ void MainWindow::ActionNewDraw() } else { - qApp->setPatternType(Pattern::Individual); + qApp->setPatternType(MeasurementsType::Individual); DialogIndividualMeasurements indMeasurements(pattern, patternPieceName, this); if (indMeasurements.exec() == QDialog::Accepted) { @@ -150,7 +158,6 @@ void MainWindow::ActionNewDraw() return; } } - doc->CreateEmptyFile(path); } else { @@ -159,10 +166,11 @@ void MainWindow::ActionNewDraw() { return; } + path = doc->MPath(); } - if (doc->appendDraw(patternPieceName) == false) + if (doc->appendPP(patternPieceName) == false) { - qDebug()<<"Error creating pattern with the name "<(&QComboBox::currentIndexChanged), @@ -173,14 +181,14 @@ void MainWindow::ActionNewDraw() //Create single point const quint32 id = pattern->AddGObject(new VPointF(qApp->toPixel((10+comboBoxDraws->count()*5)), qApp->toPixel(10), "А", 5, 10)); - VToolSinglePoint *spoint = new VToolSinglePoint(doc, pattern, id, Valentina::FromGui); + VToolSinglePoint *spoint = new VToolSinglePoint(doc, pattern, id, Source::FromGui, patternPieceName, path); sceneDraw->addItem(spoint); connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem); connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor); QHash* tools = doc->getTools(); SCASSERT(tools != nullptr); tools->insert(id, spoint); - VDrawTool::AddRecord(id, Valentina::SinglePointTool, doc); + VDrawTool::AddRecord(id, Tool::SinglePointTool, doc); SetEnableTool(true); SetEnableWidgets(true); @@ -188,7 +196,10 @@ void MainWindow::ActionNewDraw() if ( index != -1 ) { // -1 for not found comboBoxDraws->setCurrentIndex(index); - currentDrawChanged( index ); + } + else + { + comboBoxDraws->setCurrentIndex(0); } connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), this, &MainWindow::currentDrawChanged); @@ -226,7 +237,7 @@ void MainWindow::OptionDraw() * @param closeDialogSlot function what handle after close dialog. */ template -void MainWindow::SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, +void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, const QString &toolTip, Func closeDialogSlot) { if (checked) @@ -264,7 +275,7 @@ template * @param closeDialogSlot function to handle close of dialog. * @param applyDialogSlot function to handle apply in dialog. */ -void MainWindow::SetToolButtonWithApply(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, +void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cursor, const QString &toolTip, Func closeDialogSlot, Func2 applyDialogSlot) { if (checked) @@ -367,7 +378,7 @@ void MainWindow::ApplyDialog() */ void MainWindow::ToolEndLine(bool checked) { - SetToolButtonWithApply(checked, Valentina::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"), + SetToolButtonWithApply(checked, Tool::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"), &MainWindow::ClosedDialogEndLine,&MainWindow::ApplyDialogEndLine); } @@ -397,7 +408,7 @@ void MainWindow::ClosedDialogEndLine(int result) */ void MainWindow::ToolLine(bool checked) { - SetToolButton(checked, Valentina::LineTool, ":/cursor/line_cursor.png", tr("Select first point"), + SetToolButton(checked, Tool::LineTool, ":/cursor/line_cursor.png", tr("Select first point"), &MainWindow::ClosedDialogLine); } @@ -418,7 +429,7 @@ void MainWindow::ClosedDialogLine(int result) */ void MainWindow::ToolAlongLine(bool checked) { - SetToolButtonWithApply(checked, Valentina::AlongLineTool, ":/cursor/alongline_cursor.png", + SetToolButtonWithApply(checked, Tool::AlongLineTool, ":/cursor/alongline_cursor.png", tr("Select point"), &MainWindow::ClosedDialogAlongLine, &MainWindow::ApplyDialogAlongLine); } @@ -448,7 +459,7 @@ void MainWindow::ClosedDialogAlongLine(int result) */ void MainWindow::ToolShoulderPoint(bool checked) { - SetToolButtonWithApply(checked, Valentina::ShoulderPointTool, ":/cursor/shoulder_cursor.png", + SetToolButtonWithApply(checked, Tool::ShoulderPointTool, ":/cursor/shoulder_cursor.png", tr("Select first point of line"), &MainWindow::ClosedDialogShoulderPoint, &MainWindow::ApplyDialogShoulderPoint); } @@ -479,7 +490,7 @@ void MainWindow::ClosedDialogShoulderPoint(int result) */ void MainWindow::ToolNormal(bool checked) { - SetToolButtonWithApply(checked, Valentina::NormalTool, ":/cursor/normal_cursor.png", + SetToolButtonWithApply(checked, Tool::NormalTool, ":/cursor/normal_cursor.png", tr("Select first point of line"), &MainWindow::ClosedDialogNormal, &MainWindow::ApplyDialogNormal); } @@ -510,7 +521,7 @@ void MainWindow::ClosedDialogNormal(int result) */ void MainWindow::ToolBisector(bool checked) { - SetToolButtonWithApply(checked, Valentina::BisectorTool, ":/cursor/bisector_cursor.png", + SetToolButtonWithApply(checked, Tool::BisectorTool, ":/cursor/bisector_cursor.png", tr("Select first point of angle"), &MainWindow::ClosedDialogBisector, &MainWindow::ApplyDialogBisector); } @@ -541,7 +552,7 @@ void MainWindow::ClosedDialogBisector(int result) */ void MainWindow::ToolLineIntersect(bool checked) { - SetToolButton(checked, Valentina::LineIntersectTool, ":/cursor/intersect_cursor.png", + SetToolButton(checked, Tool::LineIntersectTool, ":/cursor/intersect_cursor.png", tr("Select first point of first line"), &MainWindow::ClosedDialogLineIntersect); } @@ -562,7 +573,7 @@ void MainWindow::ClosedDialogLineIntersect(int result) */ void MainWindow::ToolSpline(bool checked) { - SetToolButton(checked, Valentina::SplineTool, ":/cursor/spline_cursor.png", + SetToolButton(checked, Tool::SplineTool, ":/cursor/spline_cursor.png", tr("Select first point curve"), &MainWindow::ClosedDialogSpline); } @@ -583,7 +594,7 @@ void MainWindow::ClosedDialogSpline(int result) */ void MainWindow::ToolCutSpline(bool checked) { - SetToolButton(checked, Valentina::CutSplineTool, ":/cursor/spline_cut_point_cursor.png", + SetToolButton(checked, Tool::CutSplineTool, ":/cursor/spline_cut_point_cursor.png", tr("Select simple curve"), &MainWindow::ClosedDialogCutSpline); } @@ -604,7 +615,7 @@ void MainWindow::ClosedDialogCutSpline(int result) */ void MainWindow::ToolArc(bool checked) { - SetToolButtonWithApply(checked, Valentina::ArcTool, ":/cursor/arc_cursor.png", + SetToolButtonWithApply(checked, Tool::ArcTool, ":/cursor/arc_cursor.png", tr("Select point of center of arc"), &MainWindow::ClosedDialogArc, &MainWindow::ApplyDialogArc); } @@ -635,7 +646,7 @@ void MainWindow::ClosedDialogArc(int result) */ void MainWindow::ToolSplinePath(bool checked) { - SetToolButton(checked, Valentina::SplinePathTool, ":/cursor/splinepath_cursor.png", + SetToolButton(checked, Tool::SplinePathTool, ":/cursor/splinepath_cursor.png", tr("Select point of curve path"), &MainWindow::ClosedDialogSplinePath); } @@ -656,7 +667,7 @@ void MainWindow::ClosedDialogSplinePath(int result) */ void MainWindow::ToolCutSplinePath(bool checked) { - SetToolButton(checked, Valentina::CutSplinePathTool, + SetToolButton(checked, Tool::CutSplinePathTool, ":/cursor/splinepath_cut_point_cursor.png", tr("Select curve path"), &MainWindow::ClosedDialogCutSplinePath); } @@ -678,7 +689,7 @@ void MainWindow::ClosedDialogCutSplinePath(int result) */ void MainWindow::ToolPointOfContact(bool checked) { - SetToolButtonWithApply(checked, Valentina::PointOfContact, ":/cursor/pointcontact_cursor.png", + SetToolButtonWithApply(checked, Tool::PointOfContact, ":/cursor/pointcontact_cursor.png", tr("Select first point of line"), &MainWindow::ClosedDialogPointOfContact, &MainWindow::ApplyDialogPointOfContact); } @@ -709,7 +720,7 @@ void MainWindow::ClosedDialogPointOfContact(int result) */ void MainWindow::ToolDetail(bool checked) { - SetToolButton(checked, Valentina::DetailTool, "://cursor/new_detail_cursor.png", + SetToolButton(checked, Tool::DetailTool, "://cursor/new_detail_cursor.png", tr("Select points, arcs, curves clockwise."), &MainWindow::ClosedDialogDetail); } @@ -725,7 +736,7 @@ void MainWindow::ClosedDialogDetail(int result) VToolDetail::Create(dialogTool, sceneDetails, doc, pattern); } ArrowTool(); - doc->FullUpdateTree(); + doc->LiteParseTree(); } //--------------------------------------------------------------------------------------------------------------------- @@ -735,7 +746,7 @@ void MainWindow::ClosedDialogDetail(int result) */ void MainWindow::ToolHeight(bool checked) { - SetToolButton(checked, Valentina::Height, ":/cursor/height_cursor.png", tr("Select base point"), + SetToolButton(checked, Tool::Height, ":/cursor/height_cursor.png", tr("Select base point"), &MainWindow::ClosedDialogHeight); } @@ -756,7 +767,7 @@ void MainWindow::ClosedDialogHeight(int result) */ void MainWindow::ToolTriangle(bool checked) { - SetToolButton(checked, Valentina::Triangle, ":/cursor/triangle_cursor.png", + SetToolButton(checked, Tool::Triangle, ":/cursor/triangle_cursor.png", tr("Select first point of axis"), &MainWindow::ClosedDialogTriangle); } @@ -777,7 +788,7 @@ void MainWindow::ClosedDialogTriangle(int result) */ void MainWindow::ToolPointOfIntersection(bool checked) { - SetToolButton(checked, Valentina::PointOfIntersection, + SetToolButton(checked, Tool::PointOfIntersection, ":/cursor/pointofintersect_cursor.png", tr("Select point vertically"), &MainWindow::ClosedDialogPointOfIntersection); } @@ -799,7 +810,7 @@ void MainWindow::ClosedDialogPointOfIntersection(int result) */ void MainWindow::ToolUnionDetails(bool checked) { - SetToolButton(checked, Valentina::UnionDetails, ":/cursor/union_cursor.png", + SetToolButton(checked, Tool::UnionDetails, ":/cursor/union_cursor.png", tr("Select detail"), &MainWindow::ClosedDialogUnionDetails); //Must disconnect this signal here. disconnect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogTool::UpdateList); @@ -813,7 +824,7 @@ void MainWindow::ToolUnionDetails(bool checked) void MainWindow::ClosedDialogUnionDetails(int result) { ClosedDialog(result); - doc->FullUpdateTree(); + doc->LiteParseTree(); } //--------------------------------------------------------------------------------------------------------------------- @@ -823,7 +834,7 @@ void MainWindow::ClosedDialogUnionDetails(int result) */ void MainWindow::ToolCutArc(bool checked) { - SetToolButtonWithApply(checked, Valentina::CutArcTool, ":/cursor/arc_cut_cursor.png", + SetToolButtonWithApply(checked, Tool::CutArcTool, ":/cursor/arc_cut_cursor.png", tr("Select arc"), &MainWindow::ClosedDialogCutArc, &MainWindow::ApplyDialogCutArc); } @@ -946,6 +957,7 @@ void MainWindow::closeEvent(QCloseEvent *event) { WriteSettings(); event->accept(); + qApp->closeAllWindows(); } else { @@ -959,7 +971,7 @@ void MainWindow::closeEvent(QCloseEvent *event) */ void MainWindow::ToolBarOption() { - if (qApp->patternType() == Pattern::Standard) + if (qApp->patternType() == MeasurementsType::Standard) { ui->toolBarOption->addWidget(new QLabel(tr("Height: "))); @@ -1072,8 +1084,8 @@ void MainWindow::currentDrawChanged( int index ) { if (index != -1) { + doc->ChangeActivPP(comboBoxDraws->itemText(index)); doc->setCurrentData(); - doc->ChangeActivDraw(comboBoxDraws->itemText(index)); if (drawMode) { ArrowTool(); @@ -1112,107 +1124,111 @@ void MainWindow::CancelTool() dialogTool = nullptr; switch ( tool ) { - case Valentina::ArrowTool: + case Tool::ArrowTool: ui->actionArrowTool->setChecked(false); helpLabel->setText(""); break; - case Valentina::SinglePointTool: + case Tool::SinglePointTool: Q_UNREACHABLE(); //Nothing to do here because we can't create this tool from main window. break; - case Valentina::EndLineTool: + case Tool::EndLineTool: ui->toolButtonEndLine->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::LineTool: + case Tool::LineTool: ui->toolButtonLine->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearFocus(); break; - case Valentina::AlongLineTool: + case Tool::AlongLineTool: ui->toolButtonAlongLine->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::ShoulderPointTool: + case Tool::ShoulderPointTool: ui->toolButtonShoulderPoint->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::NormalTool: + case Tool::NormalTool: ui->toolButtonNormal->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::BisectorTool: + case Tool::BisectorTool: ui->toolButtonBisector->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::LineIntersectTool: + case Tool::LineIntersectTool: ui->toolButtonLineIntersect->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::SplineTool: + case Tool::SplineTool: ui->toolButtonSpline->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::ArcTool: + case Tool::ArcTool: ui->toolButtonArc->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::SplinePathTool: + case Tool::SplinePathTool: ui->toolButtonSplinePath->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::PointOfContact: + case Tool::PointOfContact: ui->toolButtonPointOfContact->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::DetailTool: + case Tool::DetailTool: ui->toolButtonNewDetail->setChecked(false); break; - case Valentina::Height: + case Tool::Height: ui->toolButtonHeight->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::Triangle: + case Tool::Triangle: ui->toolButtonTriangle->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::PointOfIntersection: + case Tool::PointOfIntersection: ui->toolButtonPointOfIntersection->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::CutSplineTool: + case Tool::CutSplineTool: ui->toolButtonSplineCutPoint->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::CutSplinePathTool: + case Tool::CutSplinePathTool: ui->toolButtonSplinePathCutPoint->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::UnionDetails: + case Tool::UnionDetails: ui->toolButtonUnionDetails->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; - case Valentina::CutArcTool: + case Tool::CutArcTool: ui->toolButtonArcCutPoint->setChecked(false); currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; + case Tool::NodePoint: + case Tool::NodeArc: + case Tool::NodeSpline: + case Tool::NodeSplinePath: default: qDebug()<<"Got wrong tool type. Ignored."; break; @@ -1227,7 +1243,7 @@ void MainWindow::ArrowTool() { CancelTool(); ui->actionArrowTool->setChecked(true); - tool = Valentina::ArrowTool; + tool = Tool::ArrowTool; QCursor cur(Qt::ArrowCursor); view->setCursor(cur); helpLabel->setText(""); @@ -1307,7 +1323,7 @@ void MainWindow::ActionDraw(bool checked) connect(view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor); RestoreCurrentScene(); - mode = Valentina::Calculation; + mode = Draw::Calculation; comboBoxDraws->setEnabled(true); comboBoxDraws->setCurrentIndex(currentDrawIndex);//restore current pattern peace drawMode = true; @@ -1350,7 +1366,7 @@ void MainWindow::ActionDetails(bool checked) comboBoxDraws->setEnabled(false); - mode = Valentina::Modeling; + mode = Draw::Modeling; SetEnableTool(true); currentToolBoxIndex = ui->toolBox->currentIndex(); ui->toolBox->setCurrentIndex(4); @@ -1488,7 +1504,6 @@ void MainWindow::Clear() setCurrentFile(""); pattern->Clear(); doc->clear(); - doc->setPatternModified(false); sceneDraw->clear(); sceneDetails->clear(); CancelTool(); @@ -1499,21 +1514,111 @@ void MainWindow::Clear() ui->actionZoomIn->setEnabled(false); ui->actionZoomOut->setEnabled(false); SetEnableTool(false); - qApp->setPatternUnit(Valentina::Cm); - qApp->setPatternType(Pattern::Individual); + qApp->setPatternUnit(Unit::Cm); + qApp->setPatternType(MeasurementsType::Individual); ui->toolBarOption->clear(); #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif } +void MainWindow::FullParseFile() +{ + try + { + doc->Parse(Document::FullParse); + } + catch (const VExceptionObjectError &e) + { + e.CriticalMessageBox(tr("Error parsing file."), this); + Clear(); + return; + } + catch (const VExceptionConversionError &e) + { + e.CriticalMessageBox(tr("Error can't convert value."), this); + Clear(); + return; + } + catch (const VExceptionEmptyParameter &e) + { + e.CriticalMessageBox(tr("Error empty parameter."), this); + Clear(); + return; + } + catch (const VExceptionWrongId &e) + { + e.CriticalMessageBox(tr("Error wrong id."), this); + Clear(); + return; + } + catch (VException &e) + { + e.CriticalMessageBox(tr("Error parsing file."), this); + Clear(); + return; + } + catch (const std::bad_alloc &) + { +#ifndef QT_NO_CURSOR + QApplication::restoreOverrideCursor(); +#endif + QMessageBox msgBox; + msgBox.setWindowTitle(tr("Error!")); + msgBox.setText(tr("Error parsing file.")); + msgBox.setInformativeText("std::bad_alloc"); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); +#ifndef QT_NO_CURSOR + QApplication::setOverrideCursor(Qt::WaitCursor); +#endif + Clear(); + return; + } + + QString patternPiece = QString(); + if (comboBoxDraws->currentIndex() != -1) + { + patternPiece = comboBoxDraws->itemText(comboBoxDraws->currentIndex()); + } + disconnect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), + this, &MainWindow::currentDrawChanged); + comboBoxDraws->clear(); + comboBoxDraws->addItems(doc->getPatternPieces()); + connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), + this, &MainWindow::currentDrawChanged); + ui->actionPattern_properties->setEnabled(true); + + qint32 index = comboBoxDraws->findText(patternPiece); + if ( index != -1 ) + { // -1 for not found + currentDrawChanged(index); + } + else + { + currentDrawChanged(0); + } + + if (comboBoxDraws->count() > 0) + { + SetEnableTool(true); + } + else + { + SetEnableTool(false); + } + SetEnableWidgets(true); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief NewPattern create new empty pattern. */ void MainWindow::NewPattern() { - if (doc->isPatternModified() || curFile.isEmpty() == false) + if (this->isWindowModified() || curFile.isEmpty() == false) { QProcess *v = new QProcess(this); v->startDetached(QCoreApplication::applicationFilePath ()); @@ -1525,10 +1630,10 @@ void MainWindow::NewPattern() /** * @brief haveChange enable action save if we have unsaved change. */ -void MainWindow::PatternWasModified() +void MainWindow::PatternWasModified(bool saved) { - setWindowModified(doc->isPatternModified()); - ui->actionSave->setEnabled(true); + setWindowModified(!saved); + ui->actionSave->setEnabled(!saved); } //--------------------------------------------------------------------------------------------------------------------- @@ -1540,7 +1645,7 @@ void MainWindow::ChangedSize(const QString & text) { qint32 size = text.toInt(); pattern->SetSize(size); - doc->FullUpdateTree(); + doc->LiteParseTree(); } //--------------------------------------------------------------------------------------------------------------------- @@ -1552,7 +1657,7 @@ void MainWindow::ChangedHeight(const QString &text) { qint32 growth = text.toInt(); pattern->SetHeight(growth); - doc->FullUpdateTree(); + doc->LiteParseTree(); } //--------------------------------------------------------------------------------------------------------------------- @@ -1574,7 +1679,7 @@ void MainWindow::SetEnableWidgets(bool enable) ui->actionHistory->setEnabled(enable); ui->actionPattern_properties->setEnabled(enable); ui->actionEdit_pattern_code->setEnabled(enable); - ui->actionZoomIn->setEnabled(enable); + ui->actionZoomIn->setEnabled(enable); ui->actionZoomOut->setEnabled(enable); } @@ -1671,7 +1776,7 @@ void MainWindow::SetEnableTool(bool enable) { bool drawTools = false; bool modelingTools = false; - if (mode == Valentina::Calculation) + if (mode == Draw::Calculation) { drawTools = enable; } @@ -1731,6 +1836,7 @@ bool MainWindow::SavePattern(const QString &fileName) { setCurrentFile(fileName); helpLabel->setText(tr("File saved")); + qApp->getUndoStack()->clear(); } } return result; @@ -1742,7 +1848,7 @@ bool MainWindow::SavePattern(const QString &fileName) */ void MainWindow::AutoSavePattern() { - if (curFile.isEmpty() == false && doc->isPatternModified() == true) + if (curFile.isEmpty() == false && this->isWindowModified() == true) { QString autofile = curFile +".autosave"; if (SavePattern(autofile) == false) @@ -1761,7 +1867,6 @@ void MainWindow::AutoSavePattern() void MainWindow::setCurrentFile(const QString &fileName) { curFile = fileName; - doc->setPatternModified(false); setWindowModified(false); QString shownName = strippedName(curFile); @@ -1811,6 +1916,20 @@ void MainWindow::ReadSettings() QSize size = settings.value("size", QSize(1000, 800)).toSize(); resize(size); move(pos); + + // Scene antialiasing + bool graphOutputValue = settings.value("pattern/graphicalOutput", 1).toBool(); + view->setRenderHint(QPainter::Antialiasing, graphOutputValue); + view->setRenderHint(QPainter::SmoothPixmapTransform, graphOutputValue); + + // Stack limit + bool ok = true; + qint32 count = settings.value("pattern/undo", 0).toInt(&ok); + if (ok == false) + { + count = 0; + } + qApp->getUndoStack()->setUndoLimit(count); } //--------------------------------------------------------------------------------------------------------------------- @@ -1832,7 +1951,7 @@ void MainWindow::WriteSettings() */ bool MainWindow::MaybeSave() { - if (doc->isPatternModified()) + if (this->isWindowModified()) { QMessageBox::StandardButton ret; ret = QMessageBox::warning(this, tr("Unsaved change"), tr("The pattern has been modified.\n" @@ -1861,9 +1980,9 @@ void MainWindow::UpdateRecentFileActions() for (int i = 0; i < numRecentFiles; ++i) { - QString text = QString("&%1 %2").arg(i + 1).arg(strippedName(files[i])); + QString text = QString("&%1 %2").arg(i + 1).arg(strippedName(files.at(i))); recentFileActs[i]->setText(text); - recentFileActs[i]->setData(files[i]); + recentFileActs[i]->setData(files.at(i)); recentFileActs[i]->setVisible(true); } for (int j = numRecentFiles; j < MaxRecentFiles; ++j) @@ -1885,6 +2004,21 @@ void MainWindow::CreateMenus() separatorAct->setSeparator(true); ui->menuFile->insertAction(ui->actionPreferences, separatorAct); UpdateRecentFileActions(); + + //Add Undo/Redo actions. + QAction *undoAction = qApp->getUndoStack()->createUndoAction(this, tr("&Undo")); + undoAction->setShortcuts(QKeySequence::Undo); + undoAction->setIcon(QIcon::fromTheme("edit-undo")); + ui->menuDrawing->insertAction(ui->actionPattern_properties, undoAction); + + QAction *redoAction = qApp->getUndoStack()->createRedoAction(this, tr("&Redo")); + redoAction->setShortcuts(QKeySequence::Redo); + redoAction->setIcon(QIcon::fromTheme("edit-redo")); + ui->menuDrawing->insertAction(ui->actionPattern_properties, redoAction); + + separatorAct = new QAction(this); + separatorAct->setSeparator(true); + ui->menuDrawing->insertAction(ui->actionPattern_properties, separatorAct); } //--------------------------------------------------------------------------------------------------------------------- @@ -1895,7 +2029,7 @@ void MainWindow::CreateActions() connect(ui->actionArrowTool, &QAction::triggered, this, &MainWindow::ActionAroowTool); connect(ui->actionDraw, &QAction::triggered, this, &MainWindow::ActionDraw); connect(ui->actionDetails, &QAction::triggered, this, &MainWindow::ActionDetails); - connect(ui->actionNewDraw, &QAction::triggered, this, &MainWindow::ActionNewDraw); + connect(ui->actionNewDraw, &QAction::triggered, this, &MainWindow::ActionNewPP); connect(ui->actionOptionDraw, &QAction::triggered, this, &MainWindow::OptionDraw); connect(ui->actionSaveAs, &QAction::triggered, this, &MainWindow::SaveAs); connect(ui->actionSave, &QAction::triggered, this, &MainWindow::Save); @@ -1927,6 +2061,11 @@ void MainWindow::InitAutoSave() delete autoSaveTimer; autoSaveTimer = nullptr; + autoSaveTimer = new QTimer(this); + autoSaveTimer->setTimerType(Qt::VeryCoarseTimer); + connect(autoSaveTimer, &QTimer::timeout, this, &MainWindow::AutoSavePattern); + autoSaveTimer->stop(); + QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), QApplication::applicationName()); bool autoSave = settings.value("configuration/autosave/state", 1).toBool(); @@ -1938,12 +2077,10 @@ void MainWindow::InitAutoSave() { autoTime = 5; } - - autoSaveTimer = new QTimer(this); - autoSaveTimer->setTimerType(Qt::VeryCoarseTimer); - connect(autoSaveTimer, &QTimer::timeout, this, &MainWindow::AutoSavePattern); autoSaveTimer->start(autoTime*60000); + } + qApp->setAutoSaveTimer(autoSaveTimer); } //--------------------------------------------------------------------------------------------------------------------- @@ -2012,11 +2149,11 @@ void MainWindow::LoadPattern(const QString &fileName) QString text = tr("Measurements use different units than pattern. This pattern required measurements in %1") .arg(doc->UnitsToStr(qApp->patternUnit())); - if (qApp->patternType() == Pattern::Standard) + if (qApp->patternType() == MeasurementsType::Standard) { VStandardMeasurements m(pattern); m.setContent(path); - Valentina::Units mUnit = m.Unit(); + Unit mUnit = m.MUnit(); if (qApp->patternUnit() != mUnit) { QMessageBox::critical(this, tr("Wrong units."), text); @@ -2031,7 +2168,7 @@ void MainWindow::LoadPattern(const QString &fileName) { VIndividualMeasurements m(pattern); m.setContent(path); - Valentina::Units mUnit = m.Unit(); + Unit mUnit = m.MUnit(); if (qApp->patternUnit() != mUnit) { QMessageBox::critical(this, tr("Wrong units."), text); @@ -2047,101 +2184,20 @@ void MainWindow::LoadPattern(const QString &fileName) return; } - disconnect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), - this, &MainWindow::currentDrawChanged); - try - { - #ifndef QT_NO_CURSOR - QApplication::setOverrideCursor(Qt::WaitCursor); - #endif + FullParseFile(); - doc->Parse(Document::FullParse, sceneDraw, sceneDetails); - - #ifndef QT_NO_CURSOR - QApplication::restoreOverrideCursor(); - #endif - ui->actionPattern_properties->setEnabled(true); - } - catch (const VExceptionObjectError &e) - { - e.CriticalMessageBox(tr("Error parsing file."), this); - Clear(); - return; - } - catch (const VExceptionConversionError &e) - { - e.CriticalMessageBox(tr("Error can't convert value."), this); - Clear(); - return; - } - catch (const VExceptionEmptyParameter &e) - { - e.CriticalMessageBox(tr("Error empty parameter."), this); - Clear(); - return; - } - catch (const VExceptionWrongId &e) - { - e.CriticalMessageBox(tr("Error wrong id."), this); - Clear(); - return; - } - catch (VException &e) - { - e.CriticalMessageBox(tr("Error parsing file."), this); - Clear(); - return; - } - catch (const std::bad_alloc &) - { -#ifndef QT_NO_CURSOR - QApplication::restoreOverrideCursor(); -#endif - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error parsing file.")); - msgBox.setInformativeText("std::bad_alloc"); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); -#ifndef QT_NO_CURSOR - QApplication::setOverrideCursor(Qt::WaitCursor); -#endif - Clear(); - return; - } - connect(comboBoxDraws, static_cast(&QComboBox::currentIndexChanged), - this, &MainWindow::currentDrawChanged); - QString nameDraw = doc->GetNameActivDraw(); - qint32 index = comboBoxDraws->findText(nameDraw); - if ( index != -1 ) - { // -1 for not found - comboBoxDraws->setCurrentIndex(index); - } - if (comboBoxDraws->count() > 0) - { - SetEnableTool(true); - } - else - { - SetEnableTool(false); - } - SetEnableWidgets(true); - - bool patternModified = doc->isPatternModified(); + bool patternModified = this->isWindowModified(); setCurrentFile(fileName); if (patternModified) { //For situation where was fixed wrong formula need return for document status was modified. - doc->setPatternModified(patternModified); - PatternWasModified(); + PatternWasModified(patternModified); } helpLabel->setText(tr("File loaded")); } //--------------------------------------------------------------------------------------------------------------------- -QString MainWindow::CheckPathToMeasurements(const QString &path, const Pattern::Measurements &patternType) +QString MainWindow::CheckPathToMeasurements(const QString &path, const MeasurementsType &patternType) { QFile table(path); if (table.exists() == false) @@ -2158,7 +2214,7 @@ QString MainWindow::CheckPathToMeasurements(const QString &path, const Pattern:: else { QString filter; - if (patternType == Pattern::Standard) + if (patternType == MeasurementsType::Standard) { filter = tr("Standard measurements (*.vst)"); } @@ -2174,7 +2230,7 @@ QString MainWindow::CheckPathToMeasurements(const QString &path, const Pattern:: } else { - if (patternType == Pattern::Standard) + if (patternType == MeasurementsType::Standard) { VDomDocument::ValidateXML("://schema/standard_measurements.xsd", mPath); } diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index d9904ffae..7f16894c8 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -60,7 +60,7 @@ public slots: void ActionAroowTool(); void ActionDraw(bool checked); void ActionDetails(bool checked); - void ActionNewDraw(); + void ActionNewPP(); void ActionLayout(bool checked); void ActionTable(bool checked); void ActionHistory(bool checked); @@ -80,7 +80,7 @@ public slots: void ChangedSize(const QString &text); void ChangedHeight(const QString & text); - void PatternWasModified(); + void PatternWasModified(bool saved); void ToolEndLine(bool checked); void ToolLine(bool checked); @@ -137,10 +137,11 @@ public slots: void ShowToolTip(const QString &toolTip); void OpenRecentFile(); void Clear(); - /** + /** * @brief Edit XML code of pattern */ void EditPatternCode(); + void FullParseFile(); signals: /** * @brief ModelChosen emit after calculation all details. @@ -164,7 +165,7 @@ private: VPattern *doc; /** @brief tool current tool */ - Valentina::Tools tool; + Tool tool; /** @brief currentScene pointer to current scene. */ VMainGraphicsScene *currentScene; @@ -198,7 +199,7 @@ private: QString curFile; /** @brief mode keep current draw mode. */ - Valentina::Draws mode; + Draw mode; /** @brief currentDrawIndex save current selected pattern peace. */ qint32 currentDrawIndex; @@ -226,10 +227,10 @@ private: void MinimumScrollBar(); template - void SetToolButton(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, + void SetToolButton(bool checked, Tool t, const QString &cursor, const QString &toolTip, Func closeDialogSlot); template - void SetToolButtonWithApply(bool checked, Valentina::Tools t, const QString &cursor, const QString &toolTip, + void SetToolButtonWithApply(bool checked, Tool t, const QString &cursor, const QString &toolTip, Func closeDialogSlot, Func2 applyDialogSlot); template void ClosedDialog(int result); @@ -249,7 +250,7 @@ private: void CreateActions(); void InitAutoSave(); QString PatternPieceName(const QString &text); - QString CheckPathToMeasurements(const QString &path, const Pattern::Measurements &patternType); + QString CheckPathToMeasurements(const QString &path, const MeasurementsType &patternType); }; #endif // MAINWINDOW_H diff --git a/src/app/options.cpp b/src/app/options.cpp index 0cd5de7f8..06a2adb8e 100644 --- a/src/app/options.cpp +++ b/src/app/options.cpp @@ -27,6 +27,7 @@ *************************************************************************/ #include "options.h" +#include // Keep synchronize all names with initialization in VApllication class. //measurements diff --git a/src/app/options.h b/src/app/options.h index 2b99ea490..46a4011b1 100644 --- a/src/app/options.h +++ b/src/app/options.h @@ -29,93 +29,50 @@ #ifndef OPTIONS_H #define OPTIONS_H -#include -#include -#include -#include #include #ifdef Q_OS_WIN32 -#include +# include #endif /*Q_OS_WIN32*/ +class QString; + #define SceneSize 50000 -namespace Valentina +enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail }; +enum class Tool : char { - /** - * @brief The Scene enum - */ - enum Scene { Point, Line, Spline, Arc, SplinePath, Detail }; - Q_DECLARE_FLAGS(Scenes, Scene) + ArrowTool, + SinglePointTool, + EndLineTool, + LineTool, + AlongLineTool, + ShoulderPointTool, + NormalTool, + BisectorTool, + LineIntersectTool, + SplineTool, + CutSplineTool, + CutArcTool, + ArcTool, + SplinePathTool, + CutSplinePathTool, + PointOfContact, + DetailTool, + NodePoint, + NodeArc, + NodeSpline, + NodeSplinePath, + Height, + Triangle, + PointOfIntersection, + UnionDetails +}; - /** - * @brief The Tool enum - */ - enum Tool - { - ArrowTool, - SinglePointTool, - EndLineTool, - LineTool, - AlongLineTool, - ShoulderPointTool, - NormalTool, - BisectorTool, - LineIntersectTool, - SplineTool, - CutSplineTool, - CutArcTool, - ArcTool, - SplinePathTool, - CutSplinePathTool, - PointOfContact, - DetailTool, - NodePoint, - NodeArc, - NodeSpline, - NodeSplinePath, - Height, - Triangle, - PointOfIntersection, - UnionDetails - }; - Q_DECLARE_FLAGS(Tools, Tool) - - /** - * @brief The Source enum - */ - enum Source { FromGui, FromFile, FromTool }; - Q_DECLARE_FLAGS(Sources, Source) - - /** - * @brief The Draw enum - */ - enum Draw { Calculation, Modeling }; - Q_DECLARE_FLAGS(Draws, Draw) - - /** - * @brief The Unit enum - */ - enum Unit { Mm, Cm, Inch }; - Q_DECLARE_FLAGS(Units, Unit) -} -Q_DECLARE_OPERATORS_FOR_FLAGS( Valentina::Scenes ) -Q_DECLARE_OPERATORS_FOR_FLAGS( Valentina::Tools ) -Q_DECLARE_OPERATORS_FOR_FLAGS( Valentina::Sources ) -Q_DECLARE_OPERATORS_FOR_FLAGS( Valentina::Draws ) -Q_DECLARE_OPERATORS_FOR_FLAGS( Valentina::Units ) -Q_DECLARE_METATYPE(Valentina::Unit) - -namespace Pattern -{ - /** - * @brief The Scene enum - */ - enum Measurement { Standard, Individual }; - Q_DECLARE_FLAGS(Measurements, Measurement) -} -Q_DECLARE_OPERATORS_FOR_FLAGS( Pattern::Measurements ) +enum class Source : char { FromGui, FromFile, FromTool }; +enum class Draw : char { Calculation, Modeling }; +enum class Unit : char { Mm, Cm, Inch }; +enum class MeasurementsType : char { Standard, Individual }; // measurements extern const QString headGirth_M; diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-redo.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-redo.png new file mode 100644 index 000000000..0bf5159f6 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-redo.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-undo.png b/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-undo.png new file mode 100644 index 000000000..c6ddff49d Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/16x16/actions/edit-undo.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-redo.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-redo.png new file mode 100755 index 000000000..6bac7ca71 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-redo.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-undo.png b/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-undo.png new file mode 100755 index 000000000..c30db971d Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/24x24/actions/edit-undo.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-redo.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-redo.png new file mode 100644 index 000000000..353989137 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-redo.png differ diff --git a/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-undo.png b/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-undo.png new file mode 100644 index 000000000..938acb0d4 Binary files /dev/null and b/src/app/share/resources/icons/win.icon.theme/32x32/actions/edit-undo.png differ diff --git a/src/app/share/resources/theme.qrc b/src/app/share/resources/theme.qrc index ae7c42bb5..cd91162f3 100644 --- a/src/app/share/resources/theme.qrc +++ b/src/app/share/resources/theme.qrc @@ -34,8 +34,11 @@ icons/win.icon.theme/24x24/actions/list-add.png icons/win.icon.theme/32x32/actions/list-remove.png icons/win.icon.theme/32x32/actions/list-add.png - icons/win.icon.theme/16x16/actions/go-down.png - icons/win.icon.theme/24x24/actions/go-down.png - icons/win.icon.theme/32x32/actions/go-down.png + icons/win.icon.theme/16x16/actions/edit-redo.png + icons/win.icon.theme/16x16/actions/edit-undo.png + icons/win.icon.theme/24x24/actions/edit-undo.png + icons/win.icon.theme/24x24/actions/edit-redo.png + icons/win.icon.theme/32x32/actions/edit-redo.png + icons/win.icon.theme/32x32/actions/edit-undo.png diff --git a/src/app/stable.h b/src/app/stable.h index d5ecc8150..b41aa249f 100644 --- a/src/app/stable.h +++ b/src/app/stable.h @@ -35,6 +35,7 @@ #endif /* Add C includes here */ +#include #if defined __cplusplus /* Add C++ includes here */ diff --git a/src/app/tablewindow.cpp b/src/app/tablewindow.cpp index a71eaa79e..100052979 100644 --- a/src/app/tablewindow.cpp +++ b/src/app/tablewindow.cpp @@ -34,6 +34,10 @@ #include "widgets/vapplication.h" //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief TableWindow constructor. + * @param parent parent widget. + */ TableWindow::TableWindow(QWidget *parent) :QMainWindow(parent), numberDetal(nullptr), colission(nullptr), ui(new Ui::TableWindow), listDetails(QVector()), outItems(false), collidingItems(false), tableScene(nullptr), @@ -76,6 +80,9 @@ TableWindow::~TableWindow() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddPaper add to the scene paper and shadow. + */ void TableWindow::AddPaper() { qreal x1, y1, x2, y2; @@ -91,6 +98,9 @@ void TableWindow::AddPaper() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddDetail show on scene next detail. + */ void TableWindow::AddDetail() { if (indexDetail listDetails, const QString &fileNa } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief closeEvent handle after close window. + * @param event close event. + */ void TableWindow::closeEvent(QCloseEvent *event) { event->ignore(); @@ -155,6 +174,9 @@ void TableWindow::closeEvent(QCloseEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief moveToCenter move screen to the center of window. + */ void TableWindow::moveToCenter() { QRect rect = frameGeometry(); @@ -163,6 +185,10 @@ void TableWindow::moveToCenter() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief showEvent handle after show window. + * @param event show event. + */ void TableWindow::showEvent ( QShowEvent * event ) { QMainWindow::showEvent(event); @@ -170,6 +196,9 @@ void TableWindow::showEvent ( QShowEvent * event ) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief StopTable stop creation layout. + */ void TableWindow::StopTable() { hide(); @@ -182,6 +211,9 @@ void TableWindow::StopTable() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief saveScene save created layout. + */ void TableWindow::saveScene() { QMap extByMessage; @@ -261,6 +293,10 @@ void TableWindow::saveScene() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChect turn off rotation button if don't selected detail. + * @param flag true - enable button. + */ void TableWindow::itemChect(bool flag) { ui->actionTurn->setDisabled(flag); @@ -268,6 +304,9 @@ void TableWindow::itemChect(bool flag) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief checkNext disable next detail button if exist colission or out details. + */ void TableWindow::checkNext() { if (outItems == true && collidingItems == true) @@ -293,6 +332,11 @@ void TableWindow::checkNext() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemOut handled if detail moved out paper sheet. + * @param number Number detail in list. + * @param flag set state of detail. True if detail moved out paper sheet. + */ void TableWindow::itemOut(int number, bool flag) { listOutItems->setBit(number, flag); @@ -311,6 +355,11 @@ void TableWindow::itemOut(int number, bool flag) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemColliding handled if we have colission details. + * @param list list of colission details. + * @param number 0 - include to list of colission dcetails, 1 - exclude from list. + */ void TableWindow::itemColliding(QList list, int number) { //qDebug()<<"number="< list, int number) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetNextDetail put next detail on table. + */ void TableWindow::GetNextDetail() { AddDetail(); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddLength Add length paper sheet.Збільшує довжину листа на певне значення за один раз. + */ void TableWindow::AddLength() { QRectF rect = tableScene->sceneRect(); @@ -400,6 +455,9 @@ void TableWindow::AddLength() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveLength reduce the length of paper sheet. You can reduce to the minimal value only. + */ void TableWindow::RemoveLength() { if (sceneRect.height() <= tableScene->sceneRect().height() - 100) @@ -426,6 +484,10 @@ void TableWindow::RemoveLength() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyPressEvent handle key press events. + * @param event key event. + */ void TableWindow::keyPressEvent ( QKeyEvent * event ) { if ( event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return ) @@ -440,6 +502,10 @@ void TableWindow::keyPressEvent ( QKeyEvent * event ) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SvgFile save layout to svg file. + * @param name name layout file. + */ void TableWindow::SvgFile(const QString &name) const { QSvgGenerator generator; @@ -460,6 +526,10 @@ void TableWindow::SvgFile(const QString &name) const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PngFile save layout to png file. + * @param name name layout file. + */ void TableWindow::PngFile(const QString &name) const { QRectF r = paper->rect(); @@ -478,6 +548,10 @@ void TableWindow::PngFile(const QString &name) const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PdfFile save layout to pdf file. + * @param name name layout file. + */ void TableWindow::PdfFile(const QString &name) const { QPrinter printer; @@ -503,6 +577,10 @@ void TableWindow::PdfFile(const QString &name) const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief EpsFile save layout to eps file. + * @param name name layout file. + */ void TableWindow::EpsFile(const QString &name) const { QTemporaryFile tmp; @@ -515,6 +593,10 @@ void TableWindow::EpsFile(const QString &name) const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PsFile save layout to ps file. + * @param name name layout file. + */ void TableWindow::PsFile(const QString &name) const { QTemporaryFile tmp; @@ -527,6 +609,11 @@ void TableWindow::PsFile(const QString &name) const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief PdfToPs use external tool "pdftops" for converting pdf too eps or ps format. + * @param params string with parameter for tool. Parameters have format: "-eps input_file out_file". Use -eps when + * need create eps file. + */ void TableWindow::PdfToPs(const QStringList ¶ms) const { #ifndef QT_NO_CURSOR diff --git a/src/app/tablewindow.h b/src/app/tablewindow.h index f36342fc8..b08c7e4e4 100644 --- a/src/app/tablewindow.h +++ b/src/app/tablewindow.h @@ -45,63 +45,32 @@ class TableWindow : public QMainWindow { Q_OBJECT public: - /** - * @brief numberDetal show count details, what need placed. - */ + /** @brief numberDetal show count details, what need placed. */ QLabel* numberDetal; - /** - * @brief colission show if exist colissions. - */ + + /** @brief colission show if exist colissions. */ QLabel* colission; - /** - * @brief TableWindow constructor. - * @param parent parent widget. - */ - explicit TableWindow(QWidget *parent = nullptr); + + explicit TableWindow(QWidget *parent = nullptr); ~TableWindow(); public slots: - /** - * @brief ModelChosen show window when user want create new layout. - * @param listDetails list of details. - * @param description pattern description. - */ + void ModelChosen(QVector listDetails, const QString &fileName, const QString &description); - /** - * @brief StopTable stop creation layout. - */ + void StopTable(); - /** - * @brief saveScene save created layout. - */ + void saveScene(); - /** - * @brief GetNextDetail put next detail on table. - */ + void GetNextDetail(); - /** - * @brief itemChect turn off rotation button if don't selected detail. - * @param flag true - enable button. - */ + void itemChect(bool flag); - /** - * @brief itemOut handled if detail moved out paper sheet. - * @param number Number detail in list. - * @param flag set state of detail. True if detail moved out paper sheet. - */ + void itemOut(int number, bool flag); - /** - * @brief itemColliding handled if we have colission details. - * @param list list of colission details. - * @param number 0 - include to list of colission dcetails, 1 - exclude from list. - */ + void itemColliding(QList list, int number); - /** - * @brief AddLength Add length paper sheet.Збільшує довжину листа на певне значення за один раз. - */ + void AddLength(); - /** - * @brief RemoveLength reduce the length of paper sheet. You can reduce to the minimal value only. - */ + void RemoveLength(); signals: /** @@ -113,122 +82,64 @@ signals: */ void LengthChanged(); protected: - /** - * @brief closeEvent handle after close window. - * @param event close event. - */ + void closeEvent(QCloseEvent *event); - /** - * @brief moveToCenter move screen to the center of window. - */ + void moveToCenter(); - /** - * @brief showEvent handle after show window. - * @param event show event. - */ + void showEvent ( QShowEvent * event ); - /** - * @brief keyPressEvent handle key press events. - * @param event key event. - */ + void keyPressEvent ( QKeyEvent * event ); private: Q_DISABLE_COPY(TableWindow) - /** - * @brief ui keeps information about user interface Змінна для доступу до об'єктів вікна. - */ + /** @brief ui keeps information about user interface */ Ui::TableWindow* ui; - /** - * @brief listDetails list of details. - */ + + /** @brief listDetails list of details. */ QVector listDetails; - /** - * @brief outItems true if we have details out paper sheet. - */ + + /** @brief outItems true if we have details out paper sheet. */ bool outItems; - /** - * @brief collidingItems true if we have colission details. - */ + + /** @brief collidingItems true if we have colission details. */ bool collidingItems; - /** - * @brief currentScene pointer to scene. - */ + + /** @brief currentScene pointer to scene. */ QGraphicsScene* tableScene; - /** - * @brief paper paper sheet. - */ + + /** @brief paper paper sheet. */ QGraphicsRectItem* paper; - /** - * @brief shadowPaper paper sheet shadow. - */ + + /** @brief shadowPaper paper sheet shadow. */ QGraphicsRectItem* shadowPaper; - /** - * @brief checkNext disable next detail button if exist colission or out details. - */ - void checkNext(); - /** - * @brief listOutItems list state out each detail. - */ + + /** @brief listOutItems list state out each detail. */ QBitArray* listOutItems; - /** - * @brief listCollidingItems list colissed details. - */ + + /** @brief listCollidingItems list colissed details. */ QList listCollidingItems; - /** - * @brief AddPaper add to the scene paper and shadow. - */ - void AddPaper(); - /** - * @brief AddDetail show on scene next detail. - */ - void AddDetail(); - /** - * @brief indexDetail index next detail in list what will be shown. - */ + + /** @brief indexDetail index next detail in list what will be shown. */ qint32 indexDetail; - /** - * @brief sceneRect minimal size of a paper. - */ + + /** @brief sceneRect minimal size of a paper. */ QRectF sceneRect; - /** - * @brief fileName keep name of pattern file. - */ + + /** @brief fileName keep name of pattern file. */ QString fileName; - /** - * @brief description pattern description - */ + + /** @brief description pattern description */ QString description; - /** - * @brief SvgFile save layout to svg file. - * @param name name layout file. - */ - void SvgFile(const QString &name)const; - /** - * @brief PngFile save layout to png file. - * @param name name layout file. - */ - void PngFile(const QString &name)const; - /** - * @brief PdfFile save layout to pdf file. - * @param name name layout file. - */ - void PdfFile(const QString &name)const; - /** - * @brief EpsFile save layout to eps file. - * @param name name layout file. - */ - void EpsFile(const QString &name)const; - /** - * @brief PsFile save layout to ps file. - * @param name name layout file. - */ - void PsFile(const QString &name)const; - /** - * @brief PdfToPs use external tool "pdftops" for converting pdf too eps or ps format. - * @param params string with parameter for tool. Parameters have format: "-eps input_file out_file". Use -eps when - * need create eps file. - */ - void PdfToPs(const QStringList ¶ms)const; + + void checkNext(); + void AddPaper(); + void AddDetail(); + void SvgFile(const QString &name)const; + void PngFile(const QString &name)const; + void PdfFile(const QString &name)const; + void EpsFile(const QString &name)const; + void PsFile(const QString &name)const; + void PdfToPs(const QStringList ¶ms)const; }; #endif // TABLEWINDOW_H diff --git a/src/app/tools/drawTools/vabstractspline.cpp b/src/app/tools/drawTools/vabstractspline.cpp index d8ecc259c..b1705a21a 100644 --- a/src/app/tools/drawTools/vabstractspline.cpp +++ b/src/app/tools/drawTools/vabstractspline.cpp @@ -39,12 +39,19 @@ VAbstractSpline::VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QG } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VAbstractSpline::FullUpdateFromFile() { RefreshGeometry(); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ void VAbstractSpline::ChangedActivDraw(const QString &newName) { bool selectable = false; @@ -66,12 +73,22 @@ void VAbstractSpline::ChangedActivDraw(const QString &newName) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowTool highlight tool. + * @param id object id in container + * @param color highlight color. + * @param enable enable or disable highlight. + */ void VAbstractSpline::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) { ShowItem(this, id, color, enable); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ void VAbstractSpline::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); @@ -79,6 +96,10 @@ void VAbstractSpline::SetFactor(qreal factor) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ // cppcheck-suppress unusedFunction void VAbstractSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { @@ -87,6 +108,10 @@ void VAbstractSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ // cppcheck-suppress unusedFunction void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { @@ -95,6 +120,12 @@ void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange hadle item change. + * @param change change. + * @param value value. + * @return value. + */ QVariant VAbstractSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) { if (change == QGraphicsItem::ItemSelectedChange) @@ -114,6 +145,10 @@ QVariant VAbstractSpline::itemChange(QGraphicsItem::GraphicsItemChange change, c } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyReleaseEvent handle key release events. + * @param event key release event. + */ void VAbstractSpline::keyReleaseEvent(QKeyEvent *event) { switch (event->key()) diff --git a/src/app/tools/drawTools/vabstractspline.h b/src/app/tools/drawTools/vabstractspline.h index ac0424831..a9dc13a99 100644 --- a/src/app/tools/drawTools/vabstractspline.h +++ b/src/app/tools/drawTools/vabstractspline.h @@ -40,9 +40,6 @@ public: VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr); static const QString TagName; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile (); signals: /** @@ -52,7 +49,7 @@ signals: * @param controlPoint new position control point. * @param splinePoint new position spline point. */ - void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos, + void RefreshLine(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint, const QPointF &splinePoint); /** * @brief setEnabledPoint disable control points. @@ -68,44 +65,12 @@ protected: * @brief RefreshGeometry refresh item on scene. */ virtual void RefreshGeometry ()=0; - /** - * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. - * @param newName new name active pattern peace. - */ virtual void ChangedActivDraw ( const QString &newName ); - /** - * @brief ShowTool highlight tool. - * @param id object id in container - * @param color highlight color. - * @param enable enable or disable highlight. - */ virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); - /** - * @brief SetFactor set current scale factor of scene. - * @param factor scene scale factor. - */ virtual void SetFactor(qreal factor); - /** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief itemChange hadle item change. - * @param change change. - * @param value value. - * @return value. - */ virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); - /** - * @brief keyReleaseEvent handle key release events. - * @param event key release event. - */ virtual void keyReleaseEvent(QKeyEvent * event); }; diff --git a/src/app/tools/drawTools/vdrawtool.cpp b/src/app/tools/drawTools/vdrawtool.cpp index d121327c7..fc72a46a3 100644 --- a/src/app/tools/drawTools/vdrawtool.cpp +++ b/src/app/tools/drawTools/vdrawtool.cpp @@ -29,10 +29,10 @@ #include "vdrawtool.h" #include - -#include - -#include +#include "dialogs/tools/dialogeditwrongformula.h" +#include "container/calculator.h" +#include "../../undocommands/addtocalc.h" +#include "../../undocommands/savetooloptions.h" qreal VDrawTool::factor = 1; @@ -47,7 +47,7 @@ VDrawTool::VDrawTool(VPattern *doc, VContainer *data, quint32 id) :VAbstractTool(doc, data, id), ignoreContextMenuEvent(false), ignoreFullUpdate(false), nameActivDraw(doc->GetNameActivDraw()), dialog(nullptr) { - connect(this->doc, &VPattern::ChangedActivDraw, this, &VDrawTool::ChangedActivDraw); + connect(this->doc, &VPattern::ChangedActivPP, this, &VDrawTool::ChangedActivDraw); connect(this->doc, &VPattern::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw); connect(this->doc, &VPattern::ShowTool, this, &VDrawTool::ShowTool); } @@ -105,40 +105,51 @@ void VDrawTool::ChangedNameDraw(const QString &oldName, const QString &newName) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief FullUpdateFromGui refresh tool data after change in options. + * @brief FullUpdateFromGuiOk refresh tool data after change in options. * @param result keep result working dialog. */ -void VDrawTool::FullUpdateFromGui(int result) +void VDrawTool::FullUpdateFromGuiOk(int result) { if (result == QDialog::Accepted) { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - SaveDialog(domElement); - - emit FullUpdateTree(); - emit toolhaveChange(); - } + SaveDialogChange(); } delete dialog; - dialog = nullptr; + dialog=nullptr; } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromGuiApply refresh tool data after change in options but do not delete dialog + */ void VDrawTool::FullUpdateFromGuiApply() { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - SaveDialog(domElement); + SaveDialogChange(); +} - emit FullUpdateTree(); - emit toolhaveChange(); +//--------------------------------------------------------------------------------------------------------------------- +void VDrawTool::SaveDialogChange() +{ + QDomElement oldDomElement = doc->elementById(QString().setNum(id)); + if (oldDomElement.isElement()) + { + QDomElement newDomElement = oldDomElement.cloneNode().toElement(); + SaveDialog(newDomElement); + + SaveToolOptions *saveOptions = new SaveToolOptions(oldDomElement, newDomElement, doc, id); + connect(saveOptions, &SaveToolOptions::NeedLiteParsing, doc, &VPattern::LiteParseTree); + qApp->getUndoStack()->push(saveOptions); + } + else + { + qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO; } } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DialogLinkDestroy removes dialog pointer + */ void VDrawTool::DialogLinkDestroy() { this->dialog=nullptr; @@ -210,32 +221,7 @@ qreal VDrawTool::CheckFormula(QString &formula, VContainer *data) */ void VDrawTool::AddToCalculation(const QDomElement &domElement) { - QDomElement calcElement; - bool ok = doc->GetActivNodeElement(VPattern::TagCalculation, calcElement); - if (ok) - { - quint32 id = doc->getCursor(); - if (id <= 0) - { - calcElement.appendChild(domElement); - } - else - { - QDomElement refElement = doc->elementById(QString().setNum(doc->getCursor())); - if (refElement.isElement()) - { - calcElement.insertAfter(domElement, refElement); - doc->setCursor(0); - } - else - { - qCritical()<getUndoStack()->push(addToCal); } diff --git a/src/app/tools/drawTools/vdrawtool.h b/src/app/tools/drawTools/vdrawtool.h index 4dbaefeaf..ec15a3987 100644 --- a/src/app/tools/drawTools/vdrawtool.h +++ b/src/app/tools/drawTools/vdrawtool.h @@ -34,6 +34,8 @@ #include #include #include "../../dialogs/tools/dialogtool.h" +#include "../../widgets/vmaingraphicsscene.h" +#include "../../xml/vpattern.h" /** * @brief The VDrawTool abstract class for all draw tool. @@ -48,21 +50,14 @@ public: /** @brief setDialog set dialog when user want change tool option. */ virtual void setDialog() {} - /** - * @brief DialogLinkDestroy removes dialog pointer - */ virtual void DialogLinkDestroy(); - void ignoreContextMenu(bool enable); static qreal CheckFormula(QString &formula, VContainer *data); public slots: virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); virtual void ChangedActivDraw(const QString &newName); void ChangedNameDraw(const QString &oldName, const QString &newName); - virtual void FullUpdateFromGui(int result); - /** - * @brief FullUpdateFromGuiApply refresh tool data after change in options but do not delete dialog - */ + virtual void FullUpdateFromGuiOk(int result); virtual void FullUpdateFromGuiApply(); virtual void SetFactor(qreal factor); protected: @@ -85,6 +80,7 @@ protected: /** @brief SaveDialog save options into file after change in dialog. */ virtual void SaveDialog(QDomElement &domElement)=0; + void SaveDialogChange(); template /** @@ -102,9 +98,9 @@ protected: QMenu menu; QAction *actionOption = menu.addAction(tr("Options")); QAction *actionRemove = nullptr; + actionRemove = menu.addAction(tr("Delete")); if (showRemove) { - actionRemove = menu.addAction(tr("Delete")); if (_referens > 1) { actionRemove->setEnabled(false); @@ -114,6 +110,11 @@ protected: actionRemove->setEnabled(true); } } + else + { + actionRemove->setEnabled(false); + } + QAction *selectedAction = menu.exec(event->screenPos()); if (selectedAction == actionOption) { @@ -123,7 +124,7 @@ protected: connect(qobject_cast< VMainGraphicsScene * >(tool->scene()), &VMainGraphicsScene::ChoosedObject, dialog, &DialogTool::ChoosedObject); - connect(dialog, &DialogTool::DialogClosed, tool, &Tool::FullUpdateFromGui); + connect(dialog, &DialogTool::DialogClosed, tool, &Tool::FullUpdateFromGuiOk); connect(dialog, &DialogTool::DialogApplied, tool, &Tool::FullUpdateFromGuiApply); if (ignoreFullUpdate == false) { @@ -134,12 +135,9 @@ protected: dialog->show(); } - if (showRemove) + if (selectedAction == actionRemove) { - if (selectedAction == actionRemove) - { - DeleteTool(tool); - } + DeleteTool(); } } } diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp index 19f1f703e..0009ac2ce 100644 --- a/src/app/tools/drawTools/vtoolalongline.cpp +++ b/src/app/tools/drawTools/vtoolalongline.cpp @@ -29,20 +29,32 @@ #include "vtoolalongline.h" #include "../../container/calculator.h" #include "../../dialogs/tools/dialogalongline.h" - +#include "../../geometry/vpointf.h" #include "exception/vexceptionobjecterror.h" const QString VToolAlongLine::ToolType = QStringLiteral("alongLine"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolAlongLine constuctor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param formula string with length formula. + * @param firstPointId id first point of line. + * @param secondPointId id second point of line. + * @param typeLine line type. line type. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolAlongLine::VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, - const QString &typeLine, const Valentina::Sources &typeCreation, + const QString &typeLine, const Source &typeCreation, QGraphicsItem *parent) :VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId) { - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -53,6 +65,9 @@ VToolAlongLine::VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, cons } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolAlongLine::FullUpdateFromFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -67,6 +82,10 @@ void VToolAlongLine::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ void VToolAlongLine::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); @@ -74,6 +93,10 @@ void VToolAlongLine::SetFactor(qreal factor) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. handle context menu event. + * @param event context menu event. + */ //cppcheck-suppress unusedFunction void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { @@ -81,12 +104,19 @@ void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu handle context menu event. + * @param event context menu event. + */ void VToolAlongLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolAlongLine::AddToFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -107,6 +137,9 @@ void VToolAlongLine::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolAlongLine::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -124,6 +157,9 @@ void VToolAlongLine::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ void VToolAlongLine::RemoveReferens() { doc->DecrementReferens(secondPointId); @@ -131,6 +167,9 @@ void VToolAlongLine::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolAlongLine::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); @@ -144,6 +183,9 @@ void VToolAlongLine::SaveDialog(QDomElement &domElement) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolAlongLine::setDialog() { SCASSERT(dialog != nullptr); @@ -158,6 +200,13 @@ void VToolAlongLine::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool form GUI. + * @param dialog dialog options. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + */ VToolAlongLine* VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); @@ -170,7 +219,7 @@ VToolAlongLine* VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *s const QString pointName = dialogTool->getPointName(); VToolAlongLine *point=nullptr; point = Create(0, pointName, typeLine, formula, firstPointId, secondPointId, 5, 10, scene, doc, data, - Document::FullParse, Valentina::FromGui); + Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -179,10 +228,26 @@ VToolAlongLine* VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *s } //--------------------------------------------------------------------------------------------------------------------- -VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, QString &formula, - const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation) +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. point name. + * @param typeLine line type. + * @param formula string with length formula. + * @param firstPointId id first point of line. + * @param secondPointId id second point of line. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ +VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, + QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation) { const VPointF *firstPoint = data->GeometricObject(firstPointId); const VPointF *secondPoint = data->GeometricObject(secondPointId); @@ -191,7 +256,7 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa line.setLength(qApp->toPixel(CheckFormula(formula, data))); quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->AddGObject( new VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); data->AddLine(firstPointId, id); @@ -207,7 +272,7 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::AlongLineTool, doc); + VDrawTool::AddRecord(id, Tool::AlongLineTool, doc); if (parse == Document::FullParse) { VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId, diff --git a/src/app/tools/drawTools/vtoolalongline.h b/src/app/tools/drawTools/vtoolalongline.h index a5f9795bb..1b2218604 100644 --- a/src/app/tools/drawTools/vtoolalongline.h +++ b/src/app/tools/drawTools/vtoolalongline.h @@ -38,95 +38,29 @@ class VToolAlongLine : public VToolLinePoint { Q_OBJECT public: - /** - * @brief VToolAlongLine constuctor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param formula string with length formula. - * @param firstPointId id first point of line. - * @param secondPointId id second point of line. - * @param typeLine line type. line type. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, const QString &formula, - const quint32 &firstPointId, const quint32 &secondPointId, const QString &typeLine, - const Valentina::Sources &typeCreation, QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ + + VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, const QString &formula, const quint32 &firstPointId, + const quint32 &secondPointId, const QString &typeLine, const Source &typeCreation, + QGraphicsItem * parent = nullptr); virtual void setDialog(); - /** - * @brief Create help create tool form GUI. - * @param dialog dialog options. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - */ static VToolAlongLine* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param pointName point name. point name. - * @param typeLine line type. - * @param formula string with length formula. - * @param firstPointId id first point of line. - * @param secondPointId id second point of line. - * @param mx label bias x axis. - * @param my label bias y axis. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ - static VToolAlongLine* Create(const quint32 _id, const QString &pointName, const QString &typeLine, QString &formula, - const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation); + static VToolAlongLine* Create(const quint32 _id, const QString &pointName, const QString &typeLine, + QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief SetFactor set current scale factor of scene. - * @param factor scene scale factor. - */ virtual void SetFactor(qreal factor); - /** - * @brief ShowContextMenu handle context menu event. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief contextMenuEvent handle context menu events. handle context menu event. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief RemoveReferens decrement value of reference. - */ virtual void RemoveReferens(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ virtual void SaveDialog(QDomElement &domElement); private: - /** - * @brief secondPointId id second point of line. - */ + /** @brief secondPointId id second point of line. */ quint32 secondPointId; }; diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp index b486e6660..6612affdd 100644 --- a/src/app/tools/drawTools/vtoolarc.cpp +++ b/src/app/tools/drawTools/vtoolarc.cpp @@ -30,12 +30,21 @@ #include "../../container/calculator.h" #include "../../dialogs/tools/dialogarc.h" #include +#include "../../geometry/varc.h" const QString VToolArc::TagName = QStringLiteral("arc"); const QString VToolArc::ToolType = QStringLiteral("simple"); //--------------------------------------------------------------------------------------------------------------------- -VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Valentina::Sources &typeCreation, +/** + * @brief VToolArc constuctor. + * @param doc dom document container + * @param data container with variables + * @param id object id in container + * @param typeCreation way we create this tool. + * @param parent parent object + */ +VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem *parent) :VDrawTool(doc, data, id), QGraphicsPathItem(parent) { @@ -49,7 +58,7 @@ VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Valentina: this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -60,6 +69,9 @@ VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Valentina: } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolArc::setDialog() { SCASSERT(dialog != nullptr); @@ -73,6 +85,13 @@ void VToolArc::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool + * @param dialog dialog options. + * @param scene pointer to scene. + * @param doc dom document container + * @param data container with variables + */ VToolArc* VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); @@ -83,7 +102,7 @@ VToolArc* VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatte QString f1 = dialogTool->GetF1(); QString f2 = dialogTool->GetF2(); VToolArc* point = nullptr; - point=Create(0, center, radius, f1, f2, scene, doc, data, Document::FullParse, Valentina::FromGui); + point=Create(0, center, radius, f1, f2, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -92,9 +111,22 @@ VToolArc* VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatte } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool form GUI. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param center id arc center point. + * @param radius arc radius. + * @param f1 start angle of arc. + * @param f2 end angle of arc. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, - const Valentina::Sources &typeCreation) + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation) { qreal calcRadius = 0, calcF1 = 0, calcF2 = 0; @@ -106,7 +138,7 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &ra VPointF c = *data->GeometricObject(center); VArc *arc = new VArc(c, calcRadius, radius, calcF1, f1, calcF2, f2 ); quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->AddGObject(arc); } @@ -119,7 +151,7 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &ra } } data->AddLengthArc(id); - VDrawTool::AddRecord(id, Valentina::ArcTool, doc); + VDrawTool::AddRecord(id, Tool::ArcTool, doc); if (parse == Document::FullParse) { VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation); @@ -133,12 +165,19 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &ra } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolArc::FullUpdateFromFile() { RefreshGeometry(); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ void VToolArc::ChangedActivDraw(const QString &newName) { bool selectable = false; @@ -159,12 +198,22 @@ void VToolArc::ChangedActivDraw(const QString &newName) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowTool highlight tool. + * @param id object id in container + * @param color highlight color. + * @param enable enable or disable highlight. + */ void VToolArc::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) { ShowItem(this, id, color, enable); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ void VToolArc::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); @@ -172,12 +221,19 @@ void VToolArc::SetFactor(qreal factor) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolArc::AddToFile() { const VArc *arc = VAbstractTool::data.GeometricObject(id); @@ -194,6 +250,9 @@ void VToolArc::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolArc::RefreshDataInFile() { const VArc *arc = VAbstractTool::data.GeometricObject(id); @@ -208,16 +267,24 @@ void VToolArc::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { - emit ChoosedTool(id, Valentina::Arc); + emit ChoosedTool(id, SceneObject::Arc); } QGraphicsItem::mouseReleaseEvent(event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ //cppcheck-suppress unusedFunction void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { @@ -226,6 +293,10 @@ void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ //cppcheck-suppress unusedFunction void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { @@ -234,6 +305,9 @@ void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ void VToolArc::RemoveReferens() { const VArc *arc = VAbstractTool::data.GeometricObject(id); @@ -241,6 +315,12 @@ void VToolArc::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange handle tool change. + * @param change change. + * @param value value. + * @return value. + */ QVariant VToolArc::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) { if (change == QGraphicsItem::ItemSelectedChange) @@ -260,6 +340,10 @@ QVariant VToolArc::itemChange(QGraphicsItem::GraphicsItemChange change, const QV } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyReleaseEvent handle key release events. + * @param event key release event. + */ void VToolArc::keyReleaseEvent(QKeyEvent *event) { switch (event->key()) @@ -274,6 +358,9 @@ void VToolArc::keyReleaseEvent(QKeyEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolArc::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); @@ -286,6 +373,9 @@ void VToolArc::SaveDialog(QDomElement &domElement) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ void VToolArc::RefreshGeometry() { this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); diff --git a/src/app/tools/drawTools/vtoolarc.h b/src/app/tools/drawTools/vtoolarc.h index 88e3ef809..764688a0e 100644 --- a/src/app/tools/drawTools/vtoolarc.h +++ b/src/app/tools/drawTools/vtoolarc.h @@ -40,121 +40,31 @@ class VToolArc :public VDrawTool, public QGraphicsPathItem { Q_OBJECT public: - /** - * @brief VToolArc constuctor. - * @param doc dom document container - * @param data container with variables - * @param id object id in container - * @param typeCreation way we create this tool. - * @param parent parent object - */ - VToolArc(VPattern *doc, VContainer *data, quint32 id, const Valentina::Sources &typeCreation, - QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ - virtual void setDialog(); - /** - * @brief Create help create tool - * @param dialog dialog options. - * @param scene pointer to scene. - * @param doc dom document container - * @param data container with variables - */ - static VToolArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool form GUI. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param center id arc center point. - * @param radius arc radius. - * @param f1 start angle of arc. - * @param f2 end angle of arc. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ - static VToolArc* Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse, - const Valentina::Sources &typeCreation); + VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem * parent = nullptr); + virtual void setDialog(); + static VToolArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolArc* Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); static const QString TagName; static const QString ToolType; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. - * @param newName new name active pattern peace. - */ virtual void ChangedActivDraw(const QString &newName); - /** - * @brief ShowTool highlight tool. - * @param id object id in container - * @param color highlight color. - * @param enable enable or disable highlight. - */ virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); - /** - * @brief SetFactor set current scale factor of scene. - * @param factor scene scale factor. - */ virtual void SetFactor(qreal factor); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief mouseReleaseEvent handle mouse release events. - * @param event mouse release event. - */ virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief RemoveReferens decrement value of reference. - */ virtual void RemoveReferens(); - /** - * @brief itemChange handle tool change. - * @param change change. - * @param value value. - * @return value. - */ virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); - /** - * @brief keyReleaseEvent handle key release events. - * @param event key release event. - */ virtual void keyReleaseEvent(QKeyEvent * event); - /** - * @brief SaveDialog save options into file after change in dialog. - */ virtual void SaveDialog(QDomElement &domElement); private: - /** - * @brief RefreshGeometry refresh item on scene. - */ void RefreshGeometry(); }; diff --git a/src/app/tools/drawTools/vtoolbisector.cpp b/src/app/tools/drawTools/vtoolbisector.cpp index f4b5b371b..95834c66d 100644 --- a/src/app/tools/drawTools/vtoolbisector.cpp +++ b/src/app/tools/drawTools/vtoolbisector.cpp @@ -29,19 +29,33 @@ #include "vtoolbisector.h" #include "../../container/calculator.h" #include "../../dialogs/tools/dialogbisector.h" +#include "../../geometry/vpointf.h" const QString VToolBisector::ToolType = QStringLiteral("bisector"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolBisector constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeLine line type. + * @param formula string with formula length of bisector. + * @param firstPointId id first point of angle. + * @param secondPointId id second point of angle. + * @param thirdPointId id third point of angle. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolBisector::VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, - const quint32 &thirdPointId, const Valentina::Sources &typeCreation, QGraphicsItem *parent) + const quint32 &thirdPointId, const Source &typeCreation, QGraphicsItem *parent) :VToolLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent), firstPointId(0), thirdPointId(0) { this->firstPointId = firstPointId; this->thirdPointId = thirdPointId; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -52,6 +66,14 @@ VToolBisector::VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FindPoint find bisector point. + * @param firstPoint first point of angle. + * @param secondPoint second point of angle. + * @param thirdPoint third point of angle. + * @param length bisector length. + * @return bisector point. + */ QPointF VToolBisector::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint, const qreal &length) { @@ -72,6 +94,9 @@ QPointF VToolBisector::FindPoint(const QPointF &firstPoint, const QPointF &secon } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolBisector::setDialog() { SCASSERT(dialog != nullptr); @@ -87,6 +112,13 @@ void VToolBisector::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @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) { @@ -101,7 +133,7 @@ VToolBisector* VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *sce const QString pointName = dialogTool->getPointName(); VToolBisector *point = nullptr; point=Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, scene, doc, data, - Document::FullParse, Valentina::FromGui); + Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -110,11 +142,28 @@ VToolBisector* VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *sce } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param formula string with formula. + * @param firstPointId id first point of angle. + * @param secondPointId id second point of angle. + * @param thirdPointId id third point of angle. + * @param typeLine line type. + * @param pointName point name. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation) + const Document &parse, const Source &typeCreation) { const VPointF *firstPoint = data->GeometricObject(firstPointId); const VPointF *secondPoint = data->GeometricObject(secondPointId); @@ -125,7 +174,7 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const QPointF fPoint = VToolBisector::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(), thirdPoint->toQPointF(), qApp->toPixel(result)); quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->AddLine(firstPointId, id); @@ -139,7 +188,7 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::BisectorTool, doc); + VDrawTool::AddRecord(id, Tool::BisectorTool, doc); if (parse == Document::FullParse) { VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId, @@ -157,6 +206,9 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolBisector::FullUpdateFromFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -172,6 +224,10 @@ void VToolBisector::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ void VToolBisector::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); @@ -179,18 +235,29 @@ void VToolBisector::SetFactor(qreal factor) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ void VToolBisector::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolBisector::AddToFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -212,6 +279,9 @@ void VToolBisector::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolBisector::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -230,6 +300,9 @@ void VToolBisector::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ void VToolBisector::RemoveReferens() { doc->DecrementReferens(firstPointId); @@ -238,6 +311,9 @@ void VToolBisector::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolBisector::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); diff --git a/src/app/tools/drawTools/vtoolbisector.h b/src/app/tools/drawTools/vtoolbisector.h index 1640da520..4660ce323 100644 --- a/src/app/tools/drawTools/vtoolbisector.h +++ b/src/app/tools/drawTools/vtoolbisector.h @@ -37,113 +37,35 @@ class VToolBisector : public VToolLinePoint { public: - /** - * @brief VToolBisector constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param typeLine line type. - * @param formula string with formula length of bisector. - * @param firstPointId id first point of angle. - * @param secondPointId id second point of angle. - * @param thirdPointId id third point of angle. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, - const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, - const quint32 &thirdPointId, const Valentina::Sources &typeCreation, - QGraphicsItem * parent = nullptr); - /** - * @brief FindPoint find bisector point. - * @param firstPoint first point of angle. - * @param secondPoint second point of angle. - * @param thirdPoint third point of angle. - * @param length bisector length. - * @return bisector point. - */ + + VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, + const quint32 &firstPointId, const quint32 &secondPointId, const quint32 &thirdPointId, + const Source &typeCreation, QGraphicsItem * parent = nullptr); static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint, const qreal& length); - /** - * @brief setDialog set dialog when user want change tool option. - */ virtual void setDialog(); - /** - * @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. - */ static VToolBisector* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param formula string with formula. - * @param firstPointId id first point of angle. - * @param secondPointId id second point of angle. - * @param thirdPointId id third point of angle. - * @param typeLine line type. - * @param pointName point name. - * @param mx label bias x axis. - * @param my label bias y axis. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ static VToolBisector* Create(const quint32 _id, QString &formula, const quint32 &firstPointId, - const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, - const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document::Documents &parse, - const Valentina::Sources &typeCreation); + const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, + const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); static const QString ToolType; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief SetFactor set current scale factor of scene. - * @param factor scene scale factor. - */ virtual void SetFactor(qreal factor); - /** - * @brief ShowContextMenu show context menu. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ - virtual void RefreshDataInFile(); - /** - * @brief RemoveReferens decrement value of reference. - */ + virtual void RefreshDataInFile(); virtual void RemoveReferens(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ virtual void SaveDialog(QDomElement &domElement); private: - /** - * @brief firstPointId id first point of angle. - */ + /** @brief firstPointId id first point of angle. */ quint32 firstPointId; - /** - * @brief thirdPointId id third point of angle. - */ + + /** @brief thirdPointId id third point of angle. */ quint32 thirdPointId; }; diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp index b46a7c7ab..b9fbdbbfc 100644 --- a/src/app/tools/drawTools/vtoolcutarc.cpp +++ b/src/app/tools/drawTools/vtoolcutarc.cpp @@ -29,14 +29,28 @@ #include "vtoolcutarc.h" #include "../../container/calculator.h" #include "../../dialogs/tools/dialogcutarc.h" +#include "../../geometry/vpointf.h" +#include "../../geometry/varc.h" const QString VToolCutArc::ToolType = QStringLiteral("cutArc"); const QString VToolCutArc::AttrArc = QStringLiteral("arc"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolCutArc constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param formula string with formula length first arc. + * @param arcId id arc in data container. + * @param arc1id id first cutting arc. + * @param arc2id id second cutting arc. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolCutArc::VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &arcId, const quint32 &arc1id, const quint32 &arc2id, - const Valentina::Sources &typeCreation, QGraphicsItem * parent) + const Source &typeCreation, QGraphicsItem * parent) :VToolPoint(doc, data, id, parent), formula(formula), arcId(arcId), firstArc(), secondArc(), arc1id(arc1id), arc2id(arc2id) { @@ -45,16 +59,16 @@ VToolCutArc::VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, con Q_ASSERT_X(arc2id > 0, Q_FUNC_INFO, "arc2id <= 0"); firstArc = new VSimpleArc(arc1id, ¤tColor, &factor); - RefreshArc(firstArc, arc1id, SimpleArc::ForthPoint); + RefreshArc(firstArc, arc1id, SimpleArcPoint::ForthPoint); firstArc->setParentItem(this); connect(firstArc, &VSimpleArc::Choosed, this, &VToolCutArc::ArcChoosed); secondArc = new VSimpleArc(arc2id, ¤tColor, &factor); - RefreshArc(secondArc, arc2id, SimpleArc::FirstPoint); + RefreshArc(secondArc, arc2id, SimpleArcPoint::FirstPoint); secondArc->setParentItem(this); connect(secondArc, &VSimpleArc::Choosed, this, &VToolCutArc::ArcChoosed); - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -65,6 +79,9 @@ VToolCutArc::VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, con } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolCutArc::setDialog() { SCASSERT(dialog != nullptr); @@ -77,8 +94,14 @@ void VToolCutArc::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -VToolCutArc* VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data) +/** + * @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. + */ +VToolCutArc* VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); DialogCutArc *dialogTool = qobject_cast(dialog); @@ -87,7 +110,7 @@ VToolCutArc* VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, QString formula = dialogTool->getFormula(); const quint32 arcId = dialogTool->getArcId(); VToolCutArc* point = nullptr; - point=Create(0, pointName, formula, arcId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); + point=Create(0, pointName, formula, arcId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -96,9 +119,23 @@ VToolCutArc* VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. + * @param formula string with formula length first arc. + * @param arcId id arc in data container. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation) + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation) { const VArc *arc = data->GeometricObject(arcId); @@ -111,7 +148,7 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS quint32 id = _id; quint32 arc1id = 0; quint32 arc2id = 0; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my); id = data->AddGObject(p); @@ -144,7 +181,7 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS data->AddLengthArc(arc1id); data->AddLengthArc(arc2id); - VDrawTool::AddRecord(id, Valentina::CutArcTool, doc); + VDrawTool::AddRecord(id, Tool::CutArcTool, doc); if (parse == Document::FullParse) { VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, arc1id, arc2id, typeCreation); @@ -161,6 +198,9 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolCutArc::FullUpdateFromFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -173,12 +213,20 @@ void VToolCutArc::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ArcChoosed send signal about selection from cutted arc. + * @param id object id in container. + */ void VToolCutArc::ArcChoosed(quint32 id) { - emit ChoosedTool(id, Valentina::Arc); + emit ChoosedTool(id, SceneObject::Arc); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ void VToolCutArc::ChangedActivDraw(const QString &newName) { if (nameActivDraw == newName) @@ -203,18 +251,29 @@ void VToolCutArc::ChangedActivDraw(const QString &newName) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ void VToolCutArc::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolCutArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolCutArc::AddToFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -233,6 +292,9 @@ void VToolCutArc::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolCutArc::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -248,14 +310,20 @@ void VToolCutArc::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ void VToolCutArc::RefreshGeometry() { - RefreshArc(firstArc, arc1id, SimpleArc::ForthPoint); - RefreshArc(secondArc, arc2id, SimpleArc::FirstPoint); + RefreshArc(firstArc, arc1id, SimpleArcPoint::ForthPoint); + RefreshArc(secondArc, arc2id, SimpleArcPoint::FirstPoint); VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolCutArc::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); @@ -267,13 +335,19 @@ void VToolCutArc::SaveDialog(QDomElement &domElement) } //--------------------------------------------------------------------------------------------------------------------- -void VToolCutArc::RefreshArc(VSimpleArc *sArc, quint32 arcid, SimpleArc::Translation tr) +/** + * @brief RefreshArc refresh arc on scene. + * @param sArc arc. + * @param arcid arc id. + * @param tr arc type. + */ +void VToolCutArc::RefreshArc(VSimpleArc *sArc, quint32 arcid, SimpleArcPoint tr) { const VArc *arc = VAbstractTool::data.GeometricObject(arcid); QPainterPath path; path.addPath(arc->GetPath()); path.setFillRule( Qt::WindingFill ); - if (tr == SimpleArc::FirstPoint) + if (tr == SimpleArcPoint::FirstPoint) { path.translate(-arc->GetP1().x(), -arc->GetP1().y()); } diff --git a/src/app/tools/drawTools/vtoolcutarc.h b/src/app/tools/drawTools/vtoolcutarc.h index f53e64523..978ce5a74 100644 --- a/src/app/tools/drawTools/vtoolcutarc.h +++ b/src/app/tools/drawTools/vtoolcutarc.h @@ -39,127 +39,48 @@ class VToolCutArc : public VToolPoint { Q_OBJECT public: - /** - * @brief VToolCutArc constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param formula string with formula length first arc. - * @param arcId id arc in data container. - * @param arc1id id first cutting arc. - * @param arc2id id second cutting arc. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, - const quint32 &arcId, const quint32 &arc1id, const quint32 &arc2id, - const Valentina::Sources &typeCreation, QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ + VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &arcId, + const quint32 &arc1id, const quint32 &arc2id, const Source &typeCreation, + QGraphicsItem * parent = nullptr); virtual void setDialog(); - /** - * @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. - */ static VToolCutArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param pointName point name. - * @param formula string with formula length first arc. - * @param arcId id arc in data container. - * @param mx label bias x axis. - * @param my label bias y axis. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ static VToolCutArc* Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation); + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; static const QString AttrArc; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief ArcChoosed send signal about selection from cutted arc. - * @param id object id in container. - */ void ArcChoosed(quint32 id); - /** - * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. - * @param newName new name active pattern peace. - */ virtual void ChangedActivDraw(const QString &newName); - /** - * @brief ShowContextMenu show context menu. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief RefreshGeometry refresh item on scene. - */ void RefreshGeometry(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ virtual void SaveDialog(QDomElement &domElement); private: Q_DISABLE_COPY(VToolCutArc) - /** - * @brief formula keep formula of length - */ + + /** @brief formula keep formula of length */ QString formula; - /** - * @brief arcId keep id of arc - */ + + /** @brief arcId keep id of arc */ quint32 arcId; - /** - * @brief firstArc first arc after cutting. - */ + + /** @brief firstArc first arc after cutting. */ VSimpleArc *firstArc; - /** - * @brief secondArc second arc after cutting. - */ + + /** @brief secondArc second arc after cutting. */ VSimpleArc *secondArc; - /** - * @brief arc1id id first arc after cutting. - */ + + /** @brief arc1id id first arc after cutting. */ const quint32 arc1id; - /** - * @brief arc2id id second arc after cutting. - */ + + /** @brief arc2id id second arc after cutting. */ const quint32 arc2id; - /** - * @brief RefreshArc refresh arc on scene. - * @param sArc arc. - * @param arcid arc id. - * @param tr arc type. - */ - void RefreshArc(VSimpleArc *sArc, quint32 arcid, SimpleArc::Translation tr); + void RefreshArc(VSimpleArc *sArc, quint32 arcid, SimpleArcPoint tr); }; #endif // VTOOLCUTARC_H diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp index fac3d1e96..909870e16 100644 --- a/src/app/tools/drawTools/vtoolcutspline.cpp +++ b/src/app/tools/drawTools/vtoolcutspline.cpp @@ -29,14 +29,27 @@ #include "vtoolcutspline.h" #include "../../container/calculator.h" #include "../../dialogs/tools/dialogcutspline.h" +#include "../../geometry/vpointf.h" + +#include const QString VToolCutSpline::ToolType = QStringLiteral("cutSpline"); const QString VToolCutSpline::AttrSpline = QStringLiteral("spline"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolCutSpline constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param formula string with formula length first spline. + * @param splineId id spline in data container. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolCutSpline::VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id, - const Valentina::Sources &typeCreation, QGraphicsItem *parent) + const Source &typeCreation, QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), formula(formula), splineId(splineId), firstSpline(), secondSpline(), spl1id(spl1id), spl2id(spl2id) { @@ -45,16 +58,16 @@ VToolCutSpline::VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &i Q_ASSERT_X(spl2id > 0, Q_FUNC_INFO, "spl2id <= 0"); firstSpline = new VSimpleSpline(spl1id, ¤tColor, &factor); - RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint); + RefreshSpline(firstSpline, spl1id, SimpleSplinePoint::ForthPoint); firstSpline->setParentItem(this); connect(firstSpline, &VSimpleSpline::Choosed, this, &VToolCutSpline::SplineChoosed); secondSpline = new VSimpleSpline(spl2id, ¤tColor, &factor); - RefreshSpline(secondSpline, spl2id, SimpleSpline::FirstPoint); + RefreshSpline(secondSpline, spl2id, SimpleSplinePoint::FirstPoint); secondSpline->setParentItem(this); connect(secondSpline, &VSimpleSpline::Choosed, this, &VToolCutSpline::SplineChoosed); - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -65,6 +78,9 @@ VToolCutSpline::VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &i } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolCutSpline::setDialog() { SCASSERT(dialog != nullptr); @@ -77,6 +93,13 @@ void VToolCutSpline::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @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 VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { @@ -86,13 +109,27 @@ void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->getFormula(); const quint32 splineId = dialogTool->getSplineId(); - Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); + Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. + * @param formula string with formula length first spline. + * @param splineId id spline in data container. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation) + VContainer *data, const Document &parse, const Source &typeCreation) { const VSpline *spl = data->GeometricObject(splineId); @@ -104,7 +141,7 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString quint32 id = _id; quint32 spl1id = 0; quint32 spl2id = 0; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my); id = data->AddGObject(p); @@ -138,7 +175,7 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::CutSplineTool, doc); + VDrawTool::AddRecord(id, Tool::CutSplineTool, doc); if (parse == Document::FullParse) { VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, typeCreation); @@ -153,6 +190,9 @@ void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolCutSpline::FullUpdateFromFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -165,12 +205,20 @@ void VToolCutSpline::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SplineChoosed send signal about selection from spline. + * @param id object id in container. + */ void VToolCutSpline::SplineChoosed(quint32 id) { - emit ChoosedTool(id, Valentina::Spline); + emit ChoosedTool(id, SceneObject::Spline); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ void VToolCutSpline::ChangedActivDraw(const QString &newName) { bool flag = true; @@ -190,18 +238,29 @@ void VToolCutSpline::ChangedActivDraw(const QString &newName) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ void VToolCutSpline::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolCutSpline::AddToFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -220,6 +279,9 @@ void VToolCutSpline::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolCutSpline::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -235,20 +297,29 @@ void VToolCutSpline::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ void VToolCutSpline::RefreshGeometry() { - RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint); - RefreshSpline(secondSpline, spl2id, SimpleSpline::FirstPoint); + RefreshSpline(firstSpline, spl1id, SimpleSplinePoint::ForthPoint); + RefreshSpline(secondSpline, spl2id, SimpleSplinePoint::FirstPoint); VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement referens value for used objects. + */ void VToolCutSpline::RemoveReferens() { doc->DecrementReferens(splineId); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolCutSpline::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); @@ -260,13 +331,19 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement) } //--------------------------------------------------------------------------------------------------------------------- -void VToolCutSpline::RefreshSpline(VSimpleSpline *spline, quint32 splid, SimpleSpline::Translation tr) +/** + * @brief RefreshSpline refresh spline on scene. + * @param spline spline. + * @param splid spline id. + * @param tr spline type. + */ +void VToolCutSpline::RefreshSpline(VSimpleSpline *spline, quint32 splid, SimpleSplinePoint tr) { const VSpline *spl = VAbstractTool::data.GeometricObject(splid); QPainterPath path; path.addPath(spl->GetPath()); path.setFillRule( Qt::WindingFill ); - if (tr == SimpleSpline::FirstPoint) + if (tr == SimpleSplinePoint::FirstPoint) { path.translate(-spl->GetP1().toQPointF().x(), -spl->GetP1().toQPointF().y()); } diff --git a/src/app/tools/drawTools/vtoolcutspline.h b/src/app/tools/drawTools/vtoolcutspline.h index b5cae8641..350ed6a35 100644 --- a/src/app/tools/drawTools/vtoolcutspline.h +++ b/src/app/tools/drawTools/vtoolcutspline.h @@ -39,129 +39,51 @@ class VToolCutSpline : public VToolPoint { Q_OBJECT public: - /** - * @brief VToolCutSpline constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param formula string with formula length first spline. - * @param splineId id spline in data container. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ + VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id, - const Valentina::Sources &typeCreation, QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ + const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); - /** - * @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. - */ static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param pointName point name. - * @param formula string with formula length first spline. - * @param splineId id spline in data container. - * @param mx label bias x axis. - * @param my label bias y axis. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation); + const Document &parse, const Source &typeCreation); static const QString ToolType; static const QString AttrSpline; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief SplineChoosed send signal about selection from spline. - * @param id object id in container. - */ void SplineChoosed(quint32 id); - /** - * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. - * @param newName new name active pattern peace. - */ virtual void ChangedActivDraw(const QString &newName); - /** - * @brief ShowContextMenu show context menu. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief RefreshGeometry refresh item on scene. - */ void RefreshGeometry(); - /** - * @brief RemoveReferens decrement referens value for used objects. - */ virtual void RemoveReferens(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ virtual void SaveDialog(QDomElement &domElement); private: Q_DISABLE_COPY(VToolCutSpline) - /** - * @brief formula keep formula of length. - */ + + /** @brief formula keep formula of length. */ QString formula; - /** - * @brief splineId keep id of spline. - */ + + /** @brief splineId keep id of spline. */ quint32 splineId; - /** - * @brief firstSpline first spline after cutting. - */ + + /** @brief firstSpline first spline after cutting. */ VSimpleSpline *firstSpline; - /** - * @brief secondSpline second spline after cutting. - */ + + /** @brief secondSpline second spline after cutting. */ VSimpleSpline *secondSpline; - /** - * @brief spl1id id first spline after cutting. - */ + + /** @brief spl1id id first spline after cutting. */ const quint32 spl1id; - /** - * @brief spl2id id second spline after cutting. - */ + + /** @brief spl2id id second spline after cutting. */ const quint32 spl2id; - /** - * @brief RefreshSpline refresh spline on scene. - * @param spline spline. - * @param splid spline id. - * @param tr spline type. - */ - void RefreshSpline(VSimpleSpline *spline, quint32 splid, SimpleSpline::Translation tr); + + void RefreshSpline(VSimpleSpline *spline, quint32 splid, SimpleSplinePoint tr); }; #endif // VTOOLCUTSPLINE_H diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp index 800ef0334..1c862bf64 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp @@ -29,15 +29,30 @@ #include "vtoolcutsplinepath.h" #include "../../container/calculator.h" #include "../../dialogs/tools/dialogcutsplinepath.h" +#include "../../geometry/vpointf.h" + +#include "../../geometry/vsplinepath.h" const QString VToolCutSplinePath::ToolType = QStringLiteral("cutSplinePath"); const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolCutSplinePath constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param formula string with formula length first splinePath. + * @param splinePathId id splinePath (we cut this splinePath) in data container. + * @param splPath1id id first splinePath after cutting. + * @param splPath2id id second splinePath after cutting. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolCutSplinePath::VToolCutSplinePath(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &splinePathId, const quint32 &splPath1id, const quint32 &splPath2id, - const Valentina::Sources &typeCreation, QGraphicsItem *parent) + const Source &typeCreation, QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), formula(formula), splinePathId(splinePathId), firstSpline(), secondSpline(), splPath1id (splPath1id), splPath2id(splPath2id) { @@ -46,16 +61,16 @@ VToolCutSplinePath::VToolCutSplinePath(VPattern *doc, VContainer *data, const qu Q_ASSERT_X(splPath2id > 0, Q_FUNC_INFO, "spl2id <= 0"); firstSpline = new VSimpleSpline(splPath1id, ¤tColor, &factor); - RefreshSpline(firstSpline, splPath1id, SimpleSpline::ForthPoint); + RefreshSpline(firstSpline, splPath1id, SimpleSplinePoint::ForthPoint); firstSpline->setParentItem(this); connect(firstSpline, &VSimpleSpline::Choosed, this, &VToolCutSplinePath::SplineChoosed); secondSpline = new VSimpleSpline(splPath2id, ¤tColor, &factor); - RefreshSpline(secondSpline, splPath2id, SimpleSpline::FirstPoint); + RefreshSpline(secondSpline, splPath2id, SimpleSplinePoint::FirstPoint); secondSpline->setParentItem(this); connect(secondSpline, &VSimpleSpline::Choosed, this, &VToolCutSplinePath::SplineChoosed); - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -66,6 +81,9 @@ VToolCutSplinePath::VToolCutSplinePath(VPattern *doc, VContainer *data, const qu } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolCutSplinePath::setDialog() { SCASSERT(dialog != nullptr); @@ -78,6 +96,13 @@ void VToolCutSplinePath::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @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. + */ void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); @@ -86,14 +111,28 @@ void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, V const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->getFormula(); const quint32 splinePathId = dialogTool->getSplinePathId(); - Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); + Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. + * @param formula string with formula length first splinePath. + * @param splinePathId id of splinePath in data container. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula, - const quint32 &splinePathId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation) + const quint32 &splinePathId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) { const VSplinePath *splPath = data->GeometricObject(splinePathId); SCASSERT(splPath != nullptr); @@ -106,7 +145,7 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt const QPointF point = splPath->CutSplinePath(qApp->toPixel(result), p1, p2, spl1p2, spl1p3, spl2p2, spl2p3); VPointF *p = new VPointF(point.x(), point.y(), pointName, mx, my); - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->AddGObject(p); } @@ -125,7 +164,7 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt VSplinePath *splPath1 = new VSplinePath(); VSplinePath *splPath2 = new VSplinePath(); - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { for (qint32 i = 0; i < splPath->CountPoint(); i++) { @@ -212,7 +251,7 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::CutSplinePathTool, doc); + VDrawTool::AddRecord(id, Tool::CutSplinePathTool, doc); if (parse == Document::FullParse) { VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, splPath1id, @@ -228,6 +267,9 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QSt } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolCutSplinePath::FullUpdateFromFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -240,12 +282,20 @@ void VToolCutSplinePath::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SplineChoosed send signal about selection splinePath. + * @param id object id in container. + */ void VToolCutSplinePath::SplineChoosed(quint32 id) { - emit ChoosedTool(id, Valentina::SplinePath); + emit ChoosedTool(id, SceneObject::SplinePath); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ void VToolCutSplinePath::ChangedActivDraw(const QString &newName) { bool flag = true; @@ -265,18 +315,29 @@ void VToolCutSplinePath::ChangedActivDraw(const QString &newName) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ void VToolCutSplinePath::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolCutSplinePath::AddToFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -295,6 +356,9 @@ void VToolCutSplinePath::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolCutSplinePath::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -310,20 +374,29 @@ void VToolCutSplinePath::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ void VToolCutSplinePath::RefreshGeometry() { - RefreshSpline(firstSpline, splPath1id, SimpleSpline::ForthPoint); - RefreshSpline(secondSpline, splPath2id, SimpleSpline::FirstPoint); + RefreshSpline(firstSpline, splPath1id, SimpleSplinePoint::ForthPoint); + RefreshSpline(secondSpline, splPath2id, SimpleSplinePoint::FirstPoint); VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement referens value for used objects. + */ void VToolCutSplinePath::RemoveReferens() { doc->DecrementReferens(splinePathId); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolCutSplinePath::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); @@ -335,13 +408,19 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement) } //--------------------------------------------------------------------------------------------------------------------- -void VToolCutSplinePath::RefreshSpline(VSimpleSpline *spline, quint32 splPathid, SimpleSpline::Translation tr) +/** + * @brief RefreshSpline refresh splinePath on scene. + * @param spline splinePath. + * @param splPathid splinePath id. + * @param tr splineType type. + */ +void VToolCutSplinePath::RefreshSpline(VSimpleSpline *spline, quint32 splPathid, SimpleSplinePoint tr) { const VSplinePath *splPath = VAbstractTool::data.GeometricObject(splPathid); QPainterPath path; path.addPath(splPath->GetPath()); path.setFillRule( Qt::WindingFill ); - if (tr == SimpleSpline::FirstPoint) + if (tr == SimpleSplinePoint::FirstPoint) { VSpline spl = splPath->GetSpline(1); path.translate(-spl.GetP1().toQPointF().x(), -spl.GetP1().toQPointF().y()); diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.h b/src/app/tools/drawTools/vtoolcutsplinepath.h index 34f5007f2..72f1c17c5 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.h +++ b/src/app/tools/drawTools/vtoolcutsplinepath.h @@ -40,131 +40,51 @@ class VToolCutSplinePath : public VToolPoint { Q_OBJECT public: - /** - * @brief VToolCutSplinePath constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param formula string with formula length first splinePath. - * @param splinePathId id splinePath (we cut this splinePath) in data container. - * @param splPath1id id first splinePath after cutting. - * @param splPath2id id second splinePath after cutting. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ + VToolCutSplinePath(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &splinePathId, const quint32 &splPath1id, const quint32 &splPath2id, - const Valentina::Sources &typeCreation, QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ + const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); - /** - * @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. - */ static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param pointName point name. - * @param formula string with formula length first splinePath. - * @param splinePathId id of splinePath in data container. - * @param mx label bias x axis. - * @param my label bias y axis. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splinePathId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation); + const Document &parse, const Source &typeCreation); static const QString ToolType; static const QString AttrSplinePath; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief SplineChoosed send signal about selection splinePath. - * @param id object id in container. - */ void SplineChoosed(quint32 id); - /** - * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. - * @param newName new name active pattern peace. - */ virtual void ChangedActivDraw(const QString &newName); - /** - * @brief ShowContextMenu show context menu. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief RefreshGeometry refresh item on scene. - */ void RefreshGeometry(); - /** - * @brief RemoveReferens decrement referens value for used objects. - */ virtual void RemoveReferens(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ virtual void SaveDialog(QDomElement &domElement); private: Q_DISABLE_COPY(VToolCutSplinePath) - /** - * @brief formula keep formula of length - */ + + /** @brief formula keep formula of length */ QString formula; - /** - * @brief splineId keep id of spline. - */ + + /** @brief splineId keep id of spline. */ quint32 splinePathId; - /** - * @brief firstSpline first splinePath after cutting. - */ + + /** @brief firstSpline first splinePath after cutting. */ VSimpleSpline *firstSpline; - /** - * @brief secondSpline second splinePath after cutting. - */ + + /** @brief secondSpline second splinePath after cutting. */ VSimpleSpline *secondSpline; - /** - * @brief splPath1id id first splinePath after cutting. - */ + + /** @brief splPath1id id first splinePath after cutting. */ const quint32 splPath1id; - /** - * @brief splPath2id id second splinePath after cutting. - */ + + /** @brief splPath2id id second splinePath after cutting. */ const quint32 splPath2id; - /** - * @brief RefreshSpline refresh splinePath on scene. - * @param spline splinePath. - * @param splPathid splinePath id. - * @param tr splineType type. - */ - void RefreshSpline(VSimpleSpline *spline, quint32 splPathid, SimpleSpline::Translation tr); + + void RefreshSpline(VSimpleSpline *spline, quint32 splPathid, SimpleSplinePoint tr); }; #endif // VTOOLCUTSPLINEPATH_H diff --git a/src/app/tools/drawTools/vtoolendline.cpp b/src/app/tools/drawTools/vtoolendline.cpp index 8bd8509b1..c6aa1f66f 100644 --- a/src/app/tools/drawTools/vtoolendline.cpp +++ b/src/app/tools/drawTools/vtoolendline.cpp @@ -30,17 +30,31 @@ #include "../../widgets/vmaingraphicsscene.h" #include "../../container/calculator.h" #include "../../dialogs/tools/dialogendline.h" +#include "../../dialogs/tools/dialogeditwrongformula.h" +#include "../../geometry/vpointf.h" const QString VToolEndLine::ToolType = QStringLiteral("endLine"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolEndLine constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeLine line type. + * @param formula string with formula length of line. + * @param angle angle of line. + * @param basePointId id first point of line. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolEndLine::VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, const qreal &angle, const quint32 &basePointId, - const Valentina::Sources &typeCreation, QGraphicsItem *parent) + const Source &typeCreation, QGraphicsItem *parent) :VToolLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent) { - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -51,6 +65,9 @@ VToolEndLine::VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolEndLine::setDialog() { SCASSERT(dialog != nullptr); @@ -65,8 +82,15 @@ void VToolEndLine::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data) +/** + * @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 + */ +VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); DialogEndLine *dialogTool = qobject_cast(dialog); @@ -79,7 +103,7 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene VToolEndLine *point = nullptr; point=Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse, - Valentina::FromGui); + Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -88,10 +112,27 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. + * @param typeLine line type. + * @param formula string with formula length of line. + * @param angle angle of line. + * @param basePointId id first point of line. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @return the created tool + */ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, QString &formula, const qreal &angle, const quint32 &basePointId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation) + VContainer *data, const Document &parse, const Source &typeCreation) { const VPointF *basePoint = data->GeometricObject(basePointId); QLineF line = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y())); @@ -99,7 +140,7 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, line.setLength(qApp->toPixel(CheckFormula(formula, data))); line.setAngle(angle); quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->AddGObject(new VPointF(line.p2().x(), line.p2().y(), pointName, mx, my)); data->AddLine(basePointId, id); @@ -113,7 +154,7 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::EndLineTool, doc); + VDrawTool::AddRecord(id, Tool::EndLineTool, doc); if (parse == Document::FullParse) { VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formula, angle, @@ -129,6 +170,9 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolEndLine::FullUpdateFromFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -143,18 +187,29 @@ void VToolEndLine::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ void VToolEndLine::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolEndLine::AddToFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -175,6 +230,9 @@ void VToolEndLine::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolEndLine::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -192,6 +250,9 @@ void VToolEndLine::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolEndLine::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); diff --git a/src/app/tools/drawTools/vtoolendline.h b/src/app/tools/drawTools/vtoolendline.h index 2e65d6e89..77b84a60c 100644 --- a/src/app/tools/drawTools/vtoolendline.h +++ b/src/app/tools/drawTools/vtoolendline.h @@ -38,83 +38,24 @@ class VToolEndLine : public VToolLinePoint { Q_OBJECT public: - /** - * @brief VToolEndLine constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param typeLine line type. - * @param formula string with formula length of line. - * @param angle angle of line. - * @param basePointId id first point of line. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, - const QString &formula, const qreal &angle, const quint32 &basePointId, - const Valentina::Sources &typeCreation, QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ + + VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, + const qreal &angle, const quint32 &basePointId, const Source &typeCreation, + QGraphicsItem * parent = nullptr); virtual void setDialog(); - /** - * @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 - */ static VToolEndLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param pointName point name. - * @param typeLine line type. - * @param formula string with formula length of line. - * @param angle angle of line. - * @param basePointId id first point of line. - * @param mx label bias x axis. - * @param my label bias y axis. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - * @return the created tool - */ - static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine, - QString &formula, const qreal &angle, const quint32 &basePointId, const qreal &mx, - const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation); + static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine, QString &formula, + const qreal &angle, const quint32 &basePointId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); static const QString ToolType; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief ShowContextMenu show context menu. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ virtual void SaveDialog(QDomElement &domElement); }; diff --git a/src/app/tools/drawTools/vtoolheight.cpp b/src/app/tools/drawTools/vtoolheight.cpp index d934d4ef3..f43811317 100644 --- a/src/app/tools/drawTools/vtoolheight.cpp +++ b/src/app/tools/drawTools/vtoolheight.cpp @@ -28,17 +28,30 @@ #include "vtoolheight.h" #include "../../dialogs/tools/dialogheight.h" +#include "../../geometry/vpointf.h" const QString VToolHeight::ToolType = QStringLiteral("height"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolHeight constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeLine line type. + * @param basePointId id base point of projection. + * @param p1LineId id first point of line. + * @param p2LineId id second point of line. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolHeight::VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, - const Valentina::Sources &typeCreation, QGraphicsItem * parent) + const Source &typeCreation, QGraphicsItem * parent) :VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), p1LineId(p1LineId), p2LineId(p2LineId) { ignoreFullUpdate = true; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -49,6 +62,9 @@ VToolHeight::VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, con } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolHeight::setDialog() { SCASSERT(dialog != nullptr); @@ -63,6 +79,13 @@ void VToolHeight::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @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 VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { @@ -76,14 +99,30 @@ void VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern const quint32 p1LineId = dialogTool->getP1LineId(); const quint32 p2LineId = dialogTool->getP2LineId(); Create(0, pointName, typeLine, basePointId, p1LineId, p2LineId, 5, 10, scene, doc, data, - Document::FullParse, Valentina::FromGui); + Document::FullParse, Source::FromGui); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. + * @param typeLine line type. + * @param basePointId id base point of projection. + * @param p1LineId id first point of line. + * @param p2LineId id second point of line. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ void VToolHeight::Create(const quint32 _id, const QString &pointName, const QString &typeLine, const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation) + VContainer *data, const Document &parse, const Source &typeCreation) { const VPointF *basePoint = data->GeometricObject(basePointId); const VPointF *p1Line = data->GeometricObject(p1LineId); @@ -91,7 +130,7 @@ void VToolHeight::Create(const quint32 _id, const QString &pointName, const QStr QPointF pHeight = FindPoint(QLineF(p1Line->toQPointF(), p2Line->toQPointF()), basePoint->toQPointF()); quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->AddGObject(new VPointF(pHeight.x(), pHeight.y(), pointName, mx, my)); data->AddLine(basePointId, id); @@ -109,7 +148,7 @@ void VToolHeight::Create(const quint32 _id, const QString &pointName, const QStr doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::Height, doc); + VDrawTool::AddRecord(id, Tool::Height, doc); if (parse == Document::FullParse) { VToolHeight *point = new VToolHeight(doc, data, id, typeLine, basePointId, p1LineId, p2LineId, @@ -125,12 +164,21 @@ void VToolHeight::Create(const quint32 _id, const QString &pointName, const QStr } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FindPoint find projection base point onto line. + * @param line line + * @param point base point. + * @return point onto line. + */ QPointF VToolHeight::FindPoint(const QLineF &line, const QPointF &point) { return VAbstractTool::ClosestPoint(line, point); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolHeight::FullUpdateFromFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -146,18 +194,29 @@ void VToolHeight::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ void VToolHeight::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolHeight::AddToFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -179,6 +238,9 @@ void VToolHeight::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolHeight::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -196,6 +258,9 @@ void VToolHeight::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolHeight::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); diff --git a/src/app/tools/drawTools/vtoolheight.h b/src/app/tools/drawTools/vtoolheight.h index 56d2160e1..e4abb087d 100644 --- a/src/app/tools/drawTools/vtoolheight.h +++ b/src/app/tools/drawTools/vtoolheight.h @@ -38,97 +38,31 @@ class VToolHeight: public VToolLinePoint { Q_OBJECT public: - /** - * @brief VToolHeight constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param typeLine line type. - * @param basePointId id base point of projection. - * @param p1LineId id first point of line. - * @param p2LineId id second point of line. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, - const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, - const Valentina::Sources &typeCreation, QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ + + VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const quint32 &basePointId, + const quint32 &p1LineId, const quint32 &p2LineId, const Source &typeCreation, + QGraphicsItem * parent = nullptr); virtual void setDialog(); - /** - * @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. - */ static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool - * @param _id tool id, 0 if tool doesn't exist yet. - * @param pointName point name. - * @param typeLine line type. - * @param basePointId id base point of projection. - * @param p1LineId id first point of line. - * @param p2LineId id second point of line. - * @param mx label bias x axis. - * @param my label bias y axis. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ static void Create(const quint32 _id, const QString &pointName, const QString &typeLine, const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation); - /** - * @brief FindPoint find projection base point onto line. - * @param line line - * @param point base point. - * @return point onto line. - */ + VContainer *data, const Document &parse, const Source &typeCreation); static QPointF FindPoint(const QLineF &line, const QPointF &point); static const QString ToolType; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief ShowContextMenu show context menu. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ virtual void SaveDialog(QDomElement &domElement); private: - /** - * @brief p1LineId id first point of line. - */ + /** @brief p1LineId id first point of line. */ quint32 p1LineId; - /** - * @brief p2LineId id second point of line. - */ + + /** @brief p2LineId id second point of line. */ quint32 p2LineId; }; diff --git a/src/app/tools/drawTools/vtoolline.cpp b/src/app/tools/drawTools/vtoolline.cpp index b05acb829..b210a8458 100644 --- a/src/app/tools/drawTools/vtoolline.cpp +++ b/src/app/tools/drawTools/vtoolline.cpp @@ -29,12 +29,25 @@ #include "vtoolline.h" #include "../../dialogs/tools/dialogline.h" #include +#include "../../geometry/vpointf.h" +#include "../../dialogs/tools/dialogline.h" const QString VToolLine::TagName = QStringLiteral("line"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolLine constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param firstPoint id first line point. + * @param secondPoint id second line point. + * @param typeLine line type. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint, - const QString &typeLine, const Valentina::Sources &typeCreation, QGraphicsItem *parent) + const QString &typeLine, const Source &typeCreation, QGraphicsItem *parent) :VDrawTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint) { this->typeLine = typeLine; @@ -49,7 +62,7 @@ VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstP this->setAcceptHoverEvents(true); this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle())); - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -60,6 +73,9 @@ VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstP } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolLine::setDialog() { SCASSERT(dialog != nullptr); @@ -71,6 +87,13 @@ void VToolLine::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @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. + */ void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); @@ -79,19 +102,31 @@ void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern * const quint32 firstPoint = dialogTool->getFirstPoint(); const quint32 secondPoint = dialogTool->getSecondPoint(); const QString typeLine = dialogTool->getTypeLine(); - Create(0, firstPoint, secondPoint, typeLine, scene, doc, data, Document::FullParse, Valentina::FromGui); + Create(0, firstPoint, secondPoint, typeLine, scene, doc, data, Document::FullParse, Source::FromGui); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param firstPoint id first line point. + * @param secondPoint id second line point. + * @param typeLine line type. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ void VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint, const QString &typeLine, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation) + const Document &parse, const Source &typeCreation) { SCASSERT(scene != nullptr); SCASSERT(doc != nullptr); SCASSERT(data != nullptr); quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->getNextId(); data->AddLine(firstPoint, secondPoint); @@ -105,7 +140,7 @@ void VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, const quin doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::LineTool, doc); + VDrawTool::AddRecord(id, Tool::LineTool, doc); if (parse == Document::FullParse) { VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeLine, typeCreation); @@ -119,18 +154,31 @@ void VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, const quin } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolLine::FullUpdateFromFile() { RefreshGeometry(); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowTool highlight tool. + * @param id object id in container + * @param color highlight color. + * @param enable enable or disable highlight. + */ void VToolLine::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) { ShowItem(this, id, color, enable); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ void VToolLine::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); @@ -138,6 +186,10 @@ void VToolLine::SetFactor(qreal factor) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ void VToolLine::ChangedActivDraw(const QString &newName) { bool selectable = false; @@ -157,12 +209,19 @@ void VToolLine::ChangedActivDraw(const QString &newName) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolLine::AddToFile() { QDomElement domElement = doc->createElement(TagName); @@ -175,6 +234,9 @@ void VToolLine::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolLine::RefreshDataInFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -187,6 +249,10 @@ void VToolLine::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -194,6 +260,10 @@ void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -201,6 +271,9 @@ void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ void VToolLine::RemoveReferens() { doc->DecrementReferens(firstPoint); @@ -208,6 +281,12 @@ void VToolLine::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange handle item change. + * @param change change. + * @param value value. + * @return value. + */ QVariant VToolLine::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) { if (change == QGraphicsItem::ItemSelectedChange) @@ -227,6 +306,10 @@ QVariant VToolLine::itemChange(QGraphicsItem::GraphicsItemChange change, const Q } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyReleaseEvent handle key realse events. + * @param event key realse event. + */ void VToolLine::keyReleaseEvent(QKeyEvent *event) { switch (event->key()) @@ -241,6 +324,9 @@ void VToolLine::keyReleaseEvent(QKeyEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolLine::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); @@ -252,6 +338,9 @@ void VToolLine::SaveDialog(QDomElement &domElement) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ void VToolLine::RefreshGeometry() { QDomElement domElement = doc->elementById(QString().setNum(id)); diff --git a/src/app/tools/drawTools/vtoolline.h b/src/app/tools/drawTools/vtoolline.h index 6302a26e5..29f313208 100644 --- a/src/app/tools/drawTools/vtoolline.h +++ b/src/app/tools/drawTools/vtoolline.h @@ -31,7 +31,6 @@ #include "vdrawtool.h" #include -#include "../../dialogs/tools/dialogline.h" /** * @brief The VToolLine class tool for creation line. @@ -40,126 +39,36 @@ class VToolLine: public VDrawTool, public QGraphicsLineItem { Q_OBJECT public: - /** - * @brief VToolLine constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param firstPoint id first line point. - * @param secondPoint id second line point. - * @param typeLine line type. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, - quint32 secondPoint, const QString &typeLine, const Valentina::Sources &typeCreation, - QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ + VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint, + const QString &typeLine, const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); - /** - * @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. - */ static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param firstPoint id first line point. - * @param secondPoint id second line point. - * @param typeLine line type. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ static void Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint, const QString &typeLine, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation); + const Document &parse, const Source &typeCreation); static const QString TagName; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. - * @param newName new name active pattern peace. - */ virtual void ChangedActivDraw(const QString &newName); - /** - * @brief ShowTool highlight tool. - * @param id object id in container - * @param color highlight color. - * @param enable enable or disable highlight. - */ virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); - /** - * @brief SetFactor set current scale factor of scene. - * @param factor scene scale factor. - */ virtual void SetFactor(qreal factor); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief RemoveReferens decrement value of reference. - */ virtual void RemoveReferens(); - /** - * @brief itemChange handle item change. - * @param change change. - * @param value value. - * @return value. - */ virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); - /** - * @brief keyReleaseEvent handle key realse events. - * @param event key realse event. - */ virtual void keyReleaseEvent(QKeyEvent * event); - /** - * @brief SaveDialog save options into file after change in dialog. - */ virtual void SaveDialog(QDomElement &domElement); private: - /** - * @brief firstPoint id first line point. - */ + /** @brief firstPoint id first line point. */ quint32 firstPoint; - /** - * @brief secondPoint id second line point. - */ + + /** @brief secondPoint id second line point. */ quint32 secondPoint; - /** - * @brief RefreshGeometry refresh item on scene. - */ + void RefreshGeometry(); }; diff --git a/src/app/tools/drawTools/vtoollineintersect.cpp b/src/app/tools/drawTools/vtoollineintersect.cpp index 9e0df71a5..9cd93fd2e 100644 --- a/src/app/tools/drawTools/vtoollineintersect.cpp +++ b/src/app/tools/drawTools/vtoollineintersect.cpp @@ -28,19 +28,32 @@ #include "vtoollineintersect.h" #include "../../dialogs/tools/dialoglineintersect.h" +#include "../../geometry/vpointf.h" const QString VToolLineIntersect::ToolType = QStringLiteral("lineIntersect"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolLineIntersect constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param p1Line1 id first point first line. + * @param p2Line1 id second point first line. + * @param p1Line2 id first point second line. + * @param p2Line2 id second point second line. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolLineIntersect::VToolLineIntersect(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &p1Line1, const quint32 &p2Line1, const quint32 &p1Line2, - const quint32 &p2Line2, const Valentina::Sources &typeCreation, + const quint32 &p2Line2, const Source &typeCreation, QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2), p2Line2(p2Line2) { ignoreFullUpdate = true; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -51,6 +64,9 @@ VToolLineIntersect::VToolLineIntersect(VPattern *doc, VContainer *data, const qu } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolLineIntersect::setDialog() { SCASSERT(dialog != nullptr); @@ -65,6 +81,13 @@ void VToolLineIntersect::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @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 VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); @@ -76,15 +99,31 @@ void VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, V const quint32 p2Line2Id = dialogTool->getP2Line2(); const QString pointName = dialogTool->getPointName(); Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc, data, - Document::FullParse, Valentina::FromGui); + Document::FullParse, Source::FromGui); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param p1Line1Id id first point first line. + * @param p2Line1Id id second point first line. + * @param p1Line2Id id first point second line. + * @param p2Line2Id id second point second line. + * @param pointName point name. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ void VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id, const quint32 &p1Line2Id, const quint32 &p2Line2Id, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document::Documents &parse, - const Valentina::Sources &typeCreation) + VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation) { const VPointF *p1Line1 = data->GeometricObject(p1Line1Id); const VPointF *p2Line1 = data->GeometricObject(p2Line1Id); @@ -98,7 +137,7 @@ void VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, con if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->AddLine(p1Line1Id, id); @@ -118,7 +157,7 @@ void VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, con doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::LineIntersectTool, doc); + VDrawTool::AddRecord(id, Tool::LineIntersectTool, doc); if (parse == Document::FullParse) { VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id, @@ -136,6 +175,9 @@ void VToolLineIntersect::Create(const quint32 _id, const quint32 &p1Line1Id, con } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolLineIntersect::FullUpdateFromFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -150,6 +192,10 @@ void VToolLineIntersect::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ void VToolLineIntersect::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); @@ -157,18 +203,29 @@ void VToolLineIntersect::SetFactor(qreal factor) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ void VToolLineIntersect::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolLineIntersect::AddToFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -189,6 +246,9 @@ void VToolLineIntersect::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolLineIntersect::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -206,6 +266,9 @@ void VToolLineIntersect::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ void VToolLineIntersect::RemoveReferens() { doc->DecrementReferens(p1Line1); @@ -215,6 +278,9 @@ void VToolLineIntersect::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolLineIntersect::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); diff --git a/src/app/tools/drawTools/vtoollineintersect.h b/src/app/tools/drawTools/vtoollineintersect.h index 572142b36..720da8621 100644 --- a/src/app/tools/drawTools/vtoollineintersect.h +++ b/src/app/tools/drawTools/vtoollineintersect.h @@ -38,107 +38,37 @@ class VToolLineIntersect:public VToolPoint { Q_OBJECT public: - /** - * @brief VToolLineIntersect constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param p1Line1 id first point first line. - * @param p2Line1 id second point first line. - * @param p1Line2 id first point second line. - * @param p2Line2 id second point second line. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolLineIntersect(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &p1Line1, - const quint32 &p2Line1, const quint32 &p1Line2, const quint32 &p2Line2, - const Valentina::Sources &typeCreation, QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ + VToolLineIntersect(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &p1Line1, + const quint32 &p2Line1, const quint32 &p1Line2, const quint32 &p2Line2, + const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); - /** - * @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. - */ static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param p1Line1Id id first point first line. - * @param p2Line1Id id second point first line. - * @param p1Line2Id id first point second line. - * @param p2Line2Id id second point second line. - * @param pointName point name. - * @param mx label bias x axis. - * @param my label bias y axis. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ static void Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id, const quint32 &p1Line2Id, const quint32 &p2Line2Id, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation); + const Document &parse, const Source &typeCreation); static const QString ToolType; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief SetFactor set current scale factor of scene. - * @param factor scene scale factor. - */ virtual void SetFactor(qreal factor); - /** - * @brief ShowContextMenu show context menu. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief RemoveReferens decrement value of reference. - */ virtual void RemoveReferens(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ virtual void SaveDialog(QDomElement &domElement); private: - /** - * @brief p1Line1 id first point first line. - */ + /** @brief p1Line1 id first point first line. */ quint32 p1Line1; - /** - * @brief p2Line1 id second point first line. - */ + + /** @brief p2Line1 id second point first line. */ quint32 p2Line1; - /** - * @brief p1Line2 id first point second line. - */ + + /** @brief p1Line2 id first point second line. */ quint32 p1Line2; - /** - * @brief p2Line2 id second point second line. - */ + + /** @brief p2Line2 id second point second line.*/ quint32 p2Line2; }; diff --git a/src/app/tools/drawTools/vtoollinepoint.cpp b/src/app/tools/drawTools/vtoollinepoint.cpp index c5dc5d5a7..688fda797 100644 --- a/src/app/tools/drawTools/vtoollinepoint.cpp +++ b/src/app/tools/drawTools/vtoollinepoint.cpp @@ -27,8 +27,20 @@ *************************************************************************/ #include "vtoollinepoint.h" +#include "../../geometry/vpointf.h" //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolLinePoint constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeLine line type. + * @param formula string with length formula. + * @param basePointId id base line point. + * @param angle line angle. + * @param parent parent object. + */ VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, const quint32 &basePointId, const qreal &angle, QGraphicsItem *parent) @@ -45,6 +57,10 @@ VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &i } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ void VToolLinePoint::ChangedActivDraw(const QString &newName) { if (nameActivDraw == newName) @@ -60,6 +76,9 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ void VToolLinePoint::RefreshGeometry() { mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyle())); @@ -70,6 +89,19 @@ void VToolLinePoint::RefreshGeometry() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ +void VToolLinePoint::RemoveReferens() +{ + doc->DecrementReferens(basePointId); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ void VToolLinePoint::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); diff --git a/src/app/tools/drawTools/vtoollinepoint.h b/src/app/tools/drawTools/vtoollinepoint.h index 1a242ab6d..10d5f3b46 100644 --- a/src/app/tools/drawTools/vtoollinepoint.h +++ b/src/app/tools/drawTools/vtoollinepoint.h @@ -38,56 +38,26 @@ class VToolLinePoint : public VToolPoint { Q_OBJECT public: - /** - * @brief VToolLinePoint constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param typeLine line type. - * @param formula string with length formula. - * @param basePointId id base line point. - * @param angle line angle. - * @param parent parent object. - */ - VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, - const QString &formula, const quint32 &basePointId, const qreal &angle, - QGraphicsItem * parent = nullptr); + VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, + const quint32 &basePointId, const qreal &angle, QGraphicsItem * parent = nullptr); public slots: - /** - * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. - * @param newName new name active pattern peace. - */ virtual void ChangedActivDraw(const QString &newName); - /** - * @brief SetFactor set current scale factor of scene. - * @param factor scene scale factor. - */ virtual void SetFactor(qreal factor); protected: - /** - * @brief formula string with length formula. - */ + /** @brief formula string with length formula. */ QString formula; - /** - * @brief angle line angle. - */ + + /** @brief angle line angle. */ qreal angle; - /** - * @brief basePointId id base line point. - */ + + /** @brief basePointId id base line point. */ quint32 basePointId; - /** - * @brief mainLine line item. - */ + + /** @brief mainLine line item. */ QGraphicsLineItem *mainLine; - /** - * @brief RefreshGeometry refresh item on scene. - */ + virtual void RefreshGeometry(); - /** - * @brief RemoveReferens decrement value of reference. - */ - virtual void RemoveReferens() {doc->DecrementReferens(basePointId);} + virtual void RemoveReferens(); private: Q_DISABLE_COPY(VToolLinePoint) }; diff --git a/src/app/tools/drawTools/vtoolnormal.cpp b/src/app/tools/drawTools/vtoolnormal.cpp index 453b212b2..49978e3bb 100644 --- a/src/app/tools/drawTools/vtoolnormal.cpp +++ b/src/app/tools/drawTools/vtoolnormal.cpp @@ -29,18 +29,32 @@ #include "vtoolnormal.h" #include "../../container/calculator.h" #include "../../dialogs/tools/dialognormal.h" +#include "../../geometry/vpointf.h" const QString VToolNormal::ToolType = QStringLiteral("normal"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolNormal constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeLine line type. + * @param formula string with formula normal length. + * @param angle additional angle. + * @param firstPointId id first line point. + * @param secondPointId id second line point. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolNormal::VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, const qreal &angle, const quint32 &firstPointId, - const quint32 &secondPointId, const Valentina::Sources &typeCreation, QGraphicsItem *parent) + const quint32 &secondPointId, const Source &typeCreation, QGraphicsItem *parent) :VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent), secondPointId(secondPointId) { - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -51,6 +65,9 @@ VToolNormal::VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, con } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolNormal::setDialog() { SCASSERT(dialog != nullptr); @@ -66,6 +83,13 @@ void VToolNormal::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @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. + */ VToolNormal* VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); @@ -79,7 +103,7 @@ VToolNormal* VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, const qreal angle = dialogTool->getAngle(); VToolNormal *point = nullptr; point=Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, scene, doc, data, - Document::FullParse, Valentina::FromGui); + Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -88,11 +112,28 @@ VToolNormal* VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param formula string with formula normal length. + * @param firstPointId id first line point. + * @param secondPointId id second line point. + * @param typeLine line type. + * @param pointName point name. + * @param angle additional angle. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, const QString &typeLine, const QString &pointName, const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document::Documents &parse, - const Valentina::Sources &typeCreation) + VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation) { const VPointF *firstPoint = data->GeometricObject(firstPointId); const VPointF *secondPoint = data->GeometricObject(secondPointId); @@ -102,7 +143,7 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin QPointF fPoint = VToolNormal::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(), qApp->toPixel(result), angle); quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->AddLine(firstPointId, id); @@ -116,7 +157,7 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::NormalTool, doc); + VDrawTool::AddRecord(id, Tool::NormalTool, doc); if (parse == Document::FullParse) { VToolNormal *point = new VToolNormal(doc, data, id, typeLine, formula, angle, @@ -133,6 +174,14 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FindPoint return normal point. + * @param firstPoint first line point. + * @param secondPoint second line point. + * @param length normal length. + * @param angle additional angle. + * @return normal point. + */ QPointF VToolNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length, const qreal &angle) { @@ -144,6 +193,9 @@ QPointF VToolNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondP } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolNormal::FullUpdateFromFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -159,6 +211,10 @@ void VToolNormal::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ void VToolNormal::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); @@ -166,18 +222,29 @@ void VToolNormal::SetFactor(qreal factor) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ void VToolNormal::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolNormal::AddToFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -199,6 +266,9 @@ void VToolNormal::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolNormal::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -217,6 +287,9 @@ void VToolNormal::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ void VToolNormal::RemoveReferens() { doc->DecrementReferens(secondPointId); @@ -224,6 +297,9 @@ void VToolNormal::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolNormal::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); diff --git a/src/app/tools/drawTools/vtoolnormal.h b/src/app/tools/drawTools/vtoolnormal.h index 16d84e471..e1e65921e 100644 --- a/src/app/tools/drawTools/vtoolnormal.h +++ b/src/app/tools/drawTools/vtoolnormal.h @@ -38,110 +38,31 @@ class VToolNormal : public VToolLinePoint { Q_OBJECT public: - /** - * @brief VToolNormal constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param typeLine line type. - * @param formula string with formula normal length. - * @param angle additional angle. - * @param firstPointId id first line point. - * @param secondPointId id second line point. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, - const QString &formula, const qreal &angle, const quint32 &firstPointId, - const quint32 &secondPointId, const Valentina::Sources &typeCreation, - QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ + VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, + const qreal &angle, const quint32 &firstPointId, const quint32 &secondPointId, + const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); - /** - * @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. - */ - static VToolNormal* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param formula string with formula normal length. - * @param firstPointId id first line point. - * @param secondPointId id second line point. - * @param typeLine line type. - * @param pointName point name. - * @param angle additional angle. - * @param mx label bias x axis. - * @param my label bias y axis. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ - static VToolNormal* Create(const quint32 _id, QString &formula, const quint32 &firstPointId, - const quint32 &secondPointId, const QString &typeLine, const QString &pointName, - const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document::Documents &parse, - const Valentina::Sources &typeCreation); - /** - * @brief FindPoint return normal point. - * @param firstPoint first line point. - * @param secondPoint second line point. - * @param length normal length. - * @param angle additional angle. - * @return normal point. - */ + static VToolNormal* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolNormal* Create(const quint32 _id, QString &formula, const quint32 &firstPointId, + const quint32 &secondPointId, const QString &typeLine, const QString &pointName, + const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length, const qreal &angle = 0); static const QString ToolType; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief SetFactor set current scale factor of scene. - * @param factor scene scale factor. - */ virtual void SetFactor(qreal factor); - /** - * @brief ShowContextMenu show context menu. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief RemoveReferens decrement value of reference. - */ virtual void RemoveReferens(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ virtual void SaveDialog(QDomElement &domElement); private: - /** - * @brief secondPointId id second line point. - */ - quint32 secondPointId; + /** @brief secondPointId id second line point. */ + quint32 secondPointId; }; #endif // VTOOLNORMAL_H diff --git a/src/app/tools/drawTools/vtoolpoint.cpp b/src/app/tools/drawTools/vtoolpoint.cpp index 0cdc7eddf..52815ea12 100644 --- a/src/app/tools/drawTools/vtoolpoint.cpp +++ b/src/app/tools/drawTools/vtoolpoint.cpp @@ -28,12 +28,21 @@ #include "vtoolpoint.h" #include +#include "../../geometry/vpointf.h" +#include "../../widgets/vgraphicssimpletextitem.h" const QString VToolPoint::TagName = QStringLiteral("point"); #define DefRadius 2.0//mm //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolPoint constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param parent parent object. + */ VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent):VDrawTool(doc, data, id), QGraphicsEllipseItem(parent), radius(DefRadius), namePoint(0), lineName(0) { @@ -52,6 +61,10 @@ VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsIte } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief NameChangePosition handle change posion point label. + * @param pos new position. + */ void VToolPoint::NameChangePosition(const QPointF &pos) { VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject(id)); @@ -64,6 +77,11 @@ void VToolPoint::NameChangePosition(const QPointF &pos) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateNamePosition save new position label to the pattern file. + * @param mx label bias x axis. + * @param my label bias y axis. + */ void VToolPoint::UpdateNamePosition(qreal mx, qreal my) { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -76,6 +94,10 @@ void VToolPoint::UpdateNamePosition(qreal mx, qreal my) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ void VToolPoint::ChangedActivDraw(const QString &newName) { bool selectable = false; @@ -102,12 +124,22 @@ void VToolPoint::ChangedActivDraw(const QString &newName) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowTool highlight tool. + * @param id object id in container. + * @param color highlight color. + * @param enable enable or disable highlight. + */ void VToolPoint::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) { ShowItem(this, id, color, enable); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ void VToolPoint::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); @@ -115,22 +147,34 @@ void VToolPoint::SetFactor(qreal factor) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ void VToolPoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { Q_UNUSED(event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { - emit ChoosedTool(id, Valentina::Point); + emit ChoosedTool(id, SceneObject::Point); } QGraphicsItem::mouseReleaseEvent(event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ void VToolPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -138,6 +182,10 @@ void VToolPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -145,13 +193,19 @@ void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshPointGeometry refresh point on scene. + * @param point point. + */ void VToolPoint::RefreshPointGeometry(const VPointF &point) { + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); QRectF rec = QRectF(0, 0, radius*2/factor, radius*2/factor); rec.translate(-rec.center().x(), -rec.center().y()); this->setRect(rec); this->setPos(point.toQPointF()); + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); disconnect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolPoint::NameChangePosition); QFont font = namePoint->font(); font.setPointSize(static_cast(namePoint->FontSize()/factor)); @@ -160,9 +214,13 @@ void VToolPoint::RefreshPointGeometry(const VPointF &point) namePoint->setPos(QPointF(point.mx(), point.my())); connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolPoint::NameChangePosition); RefreshLine(); + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshLine refresh line to label on scene. + */ void VToolPoint::RefreshLine() { QRectF nameRec = namePoint->sceneBoundingRect(); @@ -189,6 +247,12 @@ void VToolPoint::RefreshLine() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange hadle item change. + * @param change change. + * @param value value. + * @return value. + */ QVariant VToolPoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) { if (change == QGraphicsItem::ItemSelectedChange) @@ -208,6 +272,10 @@ QVariant VToolPoint::itemChange(QGraphicsItem::GraphicsItemChange change, const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyReleaseEvent handle key release events. + * @param event key release event. + */ void VToolPoint::keyReleaseEvent(QKeyEvent *event) { switch (event->key()) diff --git a/src/app/tools/drawTools/vtoolpoint.h b/src/app/tools/drawTools/vtoolpoint.h index ab505e14e..a0afcfbf0 100644 --- a/src/app/tools/drawTools/vtoolpoint.h +++ b/src/app/tools/drawTools/vtoolpoint.h @@ -30,7 +30,9 @@ #define VTOOLPOINT_H #include "vdrawtool.h" -#include "../../widgets/vgraphicssimpletextitem.h" + +class VPointF; +class VGraphicsSimpleTextItem; /** * @brief The VToolPoint class parent for all tools what create points. @@ -39,98 +41,32 @@ class VToolPoint: public VDrawTool, public QGraphicsEllipseItem { Q_OBJECT public: - /** - * @brief VToolPoint constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param parent parent object. - */ - VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr); - virtual ~VToolPoint(){} + VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem * parent = nullptr); + virtual ~VToolPoint(){} static const QString TagName; public slots: - /** - * @brief NameChangePosition handle change posion point label. - * @param pos new position. - */ void NameChangePosition(const QPointF &pos); - /** - * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. - * @param newName new name active pattern peace. - */ virtual void ChangedActivDraw(const QString &newName); - /** - * @brief ShowTool highlight tool. - * @param id object id in container. - * @param color highlight color. - * @param enable enable or disable highlight. - */ virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); - /** - * @brief SetFactor set current scale factor of scene. - * @param factor scene scale factor. - */ virtual void SetFactor(qreal factor); - /** - * @brief ShowContextMenu show context menu. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief radius radius circle. - */ + /** @brief radius radius circle. */ qreal radius; - /** - * @brief namePoint point label. - */ + + /** @brief namePoint point label. */ VGraphicsSimpleTextItem *namePoint; - /** - * @brief lineName line what we see if label moved too away from point. - */ + + /** @brief lineName line what we see if label moved too away from point. */ QGraphicsLineItem *lineName; - /** - * @brief UpdateNamePosition save new position label to the pattern file. - * @param mx label bias x axis. - * @param my label bias y axis. - */ + virtual void UpdateNamePosition(qreal mx, qreal my); - /** - * @brief mouseReleaseEvent handle mouse release events. - * @param event mouse release event. - */ virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief RefreshPointGeometry refresh point on scene. - * @param point point. - */ virtual void RefreshPointGeometry(const VPointF &point); - /** - * @brief RefreshLine refresh line to label on scene. - */ void RefreshLine(); - /** - * @brief itemChange hadle item change. - * @param change change. - * @param value value. - * @return value. - */ virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); - /** - * @brief keyReleaseEvent handle key release events. - * @param event key release event. - */ virtual void keyReleaseEvent(QKeyEvent * event); private: Q_DISABLE_COPY(VToolPoint) diff --git a/src/app/tools/drawTools/vtoolpointofcontact.cpp b/src/app/tools/drawTools/vtoolpointofcontact.cpp index 52615b8b2..a61d5ab9d 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.cpp +++ b/src/app/tools/drawTools/vtoolpointofcontact.cpp @@ -29,18 +29,31 @@ #include "vtoolpointofcontact.h" #include "../../container/calculator.h" #include "../../dialogs/tools/dialogpointofcontact.h" +#include "../../geometry/vpointf.h" const QString VToolPointOfContact::ToolType = QStringLiteral("pointOfContact"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolPointOfContact constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param arcRadius string with formula radius arc. + * @param center id center arc point. + * @param firstPointId id first line point. + * @param secondPointId id second line point. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolPointOfContact::VToolPointOfContact(VPattern *doc, VContainer *data, const quint32 &id, const QString &radius, const quint32 ¢er, const quint32 &firstPointId, const quint32 &secondPointId, - const Valentina::Sources &typeCreation, QGraphicsItem *parent) + const Source &typeCreation, QGraphicsItem *parent) : VToolPoint(doc, data, id, parent), arcRadius(radius), center(center), firstPointId(firstPointId), secondPointId(secondPointId) { - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -51,6 +64,9 @@ VToolPointOfContact::VToolPointOfContact(VPattern *doc, VContainer *data, const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolPointOfContact::setDialog() { SCASSERT(dialog != nullptr); @@ -65,6 +81,14 @@ void VToolPointOfContact::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FindPoint return point intersection line and arc. + * @param arcRadius string with formula radius arc. + * @param center center arc point. + * @param firstPoint first line point. + * @param secondPoint second line point. + * @return point intersection. + */ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint, const QPointF &secondPoint) { @@ -92,7 +116,15 @@ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢e } //--------------------------------------------------------------------------------------------------------------------- -VToolPointOfContact* VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +/** + * @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. + */ +VToolPointOfContact* VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data) { SCASSERT(dialog != nullptr); DialogPointOfContact *dialogTool = qobject_cast(dialog); @@ -104,7 +136,7 @@ VToolPointOfContact* VToolPointOfContact::Create(DialogTool *dialog, VMainGraphi const QString pointName = dialogTool->getPointName(); VToolPointOfContact *point = nullptr; point=Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc, data, - Document::FullParse, Valentina::FromGui); + Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -113,10 +145,27 @@ VToolPointOfContact* VToolPointOfContact::Create(DialogTool *dialog, VMainGraphi } //--------------------------------------------------------------------------------------------------------------------- -VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &radius, const quint32 ¢er, const quint32 &firstPointId, - const quint32 &secondPointId, const QString &pointName, const qreal &mx, - const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation) +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param arcRadius string with formula radius arc. + * @param center id center arc point. + * @param firstPointId id first line point. + * @param secondPointId id second line point. + * @param pointName point name. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ +VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &radius, const quint32 ¢er, + const quint32 &firstPointId, const quint32 &secondPointId, + const QString &pointName, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) { const VPointF *centerP = data->GeometricObject(center); const VPointF *firstP = data->GeometricObject(firstPointId); @@ -127,7 +176,7 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad QPointF fPoint = VToolPointOfContact::FindPoint(qApp->toPixel(result), centerP->toQPointF(), firstP->toQPointF(), secondP->toQPointF()); quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->AddLine(firstPointId, id); @@ -145,7 +194,7 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::PointOfContact, doc); + VDrawTool::AddRecord(id, Tool::PointOfContact, doc); if (parse == Document::FullParse) { VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center, @@ -163,6 +212,9 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolPointOfContact::FullUpdateFromFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -177,6 +229,10 @@ void VToolPointOfContact::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ void VToolPointOfContact::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); @@ -184,18 +240,29 @@ void VToolPointOfContact::SetFactor(qreal factor) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ void VToolPointOfContact::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolPointOfContact::AddToFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -216,6 +283,9 @@ void VToolPointOfContact::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolPointOfContact::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -233,6 +303,9 @@ void VToolPointOfContact::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ void VToolPointOfContact::RemoveReferens() { doc->DecrementReferens(center); @@ -241,6 +314,9 @@ void VToolPointOfContact::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolPointOfContact::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); diff --git a/src/app/tools/drawTools/vtoolpointofcontact.h b/src/app/tools/drawTools/vtoolpointofcontact.h index 04670c7e2..941644a0c 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.h +++ b/src/app/tools/drawTools/vtoolpointofcontact.h @@ -37,118 +37,40 @@ class VToolPointOfContact : public VToolPoint { public: - /** - * @brief VToolPointOfContact constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param arcRadius string with formula radius arc. - * @param center id center arc point. - * @param firstPointId id first line point. - * @param secondPointId id second line point. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolPointOfContact(VPattern *doc, VContainer *data, const quint32 &id, - const QString &arcRadius, const quint32 ¢er, - const quint32 &firstPointId, const quint32 &secondPointId, - const Valentina::Sources &typeCreation, QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ + VToolPointOfContact(VPattern *doc, VContainer *data, const quint32 &id, const QString &arcRadius, + const quint32 ¢er, const quint32 &firstPointId, const quint32 &secondPointId, + const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); - /** - * @brief FindPoint return point intersection line and arc. - * @param arcRadius string with formula radius arc. - * @param center center arc point. - * @param firstPoint first line point. - * @param secondPoint second line point. - * @return point intersection. - */ static QPointF FindPoint(const qreal &arcRadius, const QPointF ¢er, const QPointF &firstPoint, const QPointF &secondPoint); - /** - * @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. - */ - static VToolPointOfContact* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param arcRadius string with formula radius arc. - * @param center id center arc point. - * @param firstPointId id first line point. - * @param secondPointId id second line point. - * @param pointName point name. - * @param mx label bias x axis. - * @param my label bias y axis. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ + static VToolPointOfContact* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data); static VToolPointOfContact* Create(const quint32 _id, QString &arcRadius, const quint32 ¢er, const quint32 &firstPointId, const quint32 &secondPointId, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation); + VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief SetFactor set current scale factor of scene. - * @param factor scene scale factor. - */ virtual void SetFactor(qreal factor); - /** - * @brief ShowContextMenu show context menu. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief RemoveReferens decrement value of reference. - */ virtual void RemoveReferens(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ virtual void SaveDialog(QDomElement &domElement); private: - /** - * @brief radius string with formula radius arc. - */ + /** @brief radius string with formula radius arc. */ QString arcRadius; - /** - * @brief center id center arc point. - */ + + /** @brief center id center arc point. */ quint32 center; - /** - * @brief firstPointId id first line point. - */ + + /** @brief firstPointId id first line point. */ quint32 firstPointId; - /** - * @brief secondPointId id second line point. - */ + + /** @brief secondPointId id second line point. */ quint32 secondPointId; }; diff --git a/src/app/tools/drawTools/vtoolpointofintersection.cpp b/src/app/tools/drawTools/vtoolpointofintersection.cpp index 64db28e83..7d724dfd0 100644 --- a/src/app/tools/drawTools/vtoolpointofintersection.cpp +++ b/src/app/tools/drawTools/vtoolpointofintersection.cpp @@ -28,17 +28,28 @@ #include "vtoolpointofintersection.h" #include "../../dialogs/tools/dialogpointofintersection.h" +#include "../../geometry/vpointf.h" const QString VToolPointOfIntersection::ToolType = QStringLiteral("pointOfIntersection"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolPointOfIntersection constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param firstPointId id first line point. + * @param secondPointId id second line point. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolPointOfIntersection::VToolPointOfIntersection(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstPointId, const quint32 &secondPointId, - const Valentina::Sources &typeCreation, QGraphicsItem *parent) + const Source &typeCreation, QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId) { ignoreFullUpdate = true; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -49,6 +60,9 @@ VToolPointOfIntersection::VToolPointOfIntersection(VPattern *doc, VContainer *da } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolPointOfIntersection::setDialog() { SCASSERT(dialog != nullptr); @@ -61,6 +75,13 @@ void VToolPointOfIntersection::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @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 VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { @@ -70,21 +91,35 @@ void VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *sc const quint32 firstPointId = dialogTool->getFirstPointId(); const quint32 secondPointId = dialogTool->getSecondPointId(); const QString pointName = dialogTool->getPointName(); - Create(0, pointName, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui); + Create(0, pointName, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. + * @param firstPointId id first line point. + * @param secondPointId id second line point. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ void VToolPointOfIntersection::Create(const quint32 _id, const QString &pointName, const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation) + const Document &parse, const Source &typeCreation) { const VPointF *firstPoint = data->GeometricObject(firstPointId); const VPointF *secondPoint = data->GeometricObject(secondPointId); QPointF point(firstPoint->x(), secondPoint->y()); quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->AddGObject(new VPointF(point.x(), point.y(), pointName, mx, my)); } @@ -96,7 +131,7 @@ void VToolPointOfIntersection::Create(const quint32 _id, const QString &pointNam doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::PointOfIntersection, doc); + VDrawTool::AddRecord(id, Tool::PointOfIntersection, doc); if (parse == Document::FullParse) { VToolPointOfIntersection *point = new VToolPointOfIntersection(doc, data, id, firstPointId, @@ -111,6 +146,9 @@ void VToolPointOfIntersection::Create(const quint32 _id, const QString &pointNam } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolPointOfIntersection::FullUpdateFromFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -123,12 +161,19 @@ void VToolPointOfIntersection::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ void VToolPointOfIntersection::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ void VToolPointOfIntersection::RemoveReferens() { doc->DecrementReferens(firstPointId); @@ -136,12 +181,19 @@ void VToolPointOfIntersection::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolPointOfIntersection::AddToFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -160,6 +212,9 @@ void VToolPointOfIntersection::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolPointOfIntersection::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -175,6 +230,9 @@ void VToolPointOfIntersection::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolPointOfIntersection::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); diff --git a/src/app/tools/drawTools/vtoolpointofintersection.h b/src/app/tools/drawTools/vtoolpointofintersection.h index 194d09395..74e83a32b 100644 --- a/src/app/tools/drawTools/vtoolpointofintersection.h +++ b/src/app/tools/drawTools/vtoolpointofintersection.h @@ -38,91 +38,31 @@ class VToolPointOfIntersection : public VToolPoint { Q_OBJECT public: - /** - * @brief VToolPointOfIntersection constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param firstPointId id first line point. - * @param secondPointId id second line point. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolPointOfIntersection(VPattern *doc, VContainer *data, const quint32 &id, - const quint32 &firstPointId, const quint32 &secondPointId, - const Valentina::Sources &typeCreation, QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ + VToolPointOfIntersection(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &firstPointId, + const quint32 &secondPointId, const Source &typeCreation, + QGraphicsItem * parent = nullptr); virtual void setDialog(); - /** - * @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. - */ static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param pointName point name. - * @param firstPointId id first line point. - * @param secondPointId id second line point. - * @param mx label bias x axis. - * @param my label bias y axis. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ static void Create(const quint32 _id, const QString &pointName, const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document::Documents &parse, - const Valentina::Sources &typeCreation); + VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); static const QString ToolType; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief ShowContextMenu show context menu. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief RemoveReferens decrement value of reference. - */ virtual void RemoveReferens(); - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ virtual void SaveDialog(QDomElement &domElement); private: Q_DISABLE_COPY(VToolPointOfIntersection) - /** - * @brief firstPointId id first line point. - */ + /** @brief firstPointId id first line point. */ quint32 firstPointId; - /** - * @brief secondPointId id second line point. - */ + + /** @brief secondPointId id second line point. */ quint32 secondPointId; }; diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.cpp b/src/app/tools/drawTools/vtoolshoulderpoint.cpp index b92d0e300..6448d9bda 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.cpp +++ b/src/app/tools/drawTools/vtoolshoulderpoint.cpp @@ -29,17 +29,31 @@ #include "vtoolshoulderpoint.h" #include "../../container/calculator.h" #include "../../dialogs/tools/dialogshoulderpoint.h" +#include "../../geometry/vpointf.h" const QString VToolShoulderPoint::ToolType = QStringLiteral("shoulder"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolShoulderPoint constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeLine line type. + * @param formula string with formula length. + * @param p1Line id first line point. + * @param p2Line id second line point. + * @param pShoulder id shoulder point. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolShoulderPoint::VToolShoulderPoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, const quint32 &p1Line, const quint32 &p2Line, - const quint32 &pShoulder, const Valentina::Sources &typeCreation, + const quint32 &pShoulder, const Source &typeCreation, QGraphicsItem * parent) :VToolLinePoint(doc, data, id, typeLine, formula, p1Line, 0, parent), p2Line(p2Line), pShoulder(pShoulder) { - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -50,6 +64,9 @@ VToolShoulderPoint::VToolShoulderPoint(VPattern *doc, VContainer *data, const qu } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolShoulderPoint::setDialog() { SCASSERT(dialog != nullptr); @@ -65,6 +82,14 @@ void VToolShoulderPoint::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FindPoint find point. + * @param p1Line first line point. + * @param p2Line second line point. + * @param pShoulder shoulder point. + * @param length length form shoulder point to our. + * @return point. + */ //TODO find better way calculate point. QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder, const qreal &length) @@ -94,7 +119,15 @@ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Li } //--------------------------------------------------------------------------------------------------------------------- -VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) +/** + * @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. + */ +VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data) { SCASSERT(dialog != nullptr); DialogShoulderPoint *dialogTool = qobject_cast(dialog); @@ -107,7 +140,7 @@ VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphics const QString pointName = dialogTool->getPointName(); VToolShoulderPoint * point = nullptr; point=Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, scene, doc, data, - Document::FullParse, Valentina::FromGui); + Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -116,11 +149,28 @@ VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphics } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param formula string with formula length. + * @param p1Line id first line point. + * @param p2Line id second line point. + * @param pShoulder id shoulder point. + * @param typeLine line type. + * @param pointName point name. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formula, const quint32 &p1Line, const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation) + const Document &parse, const Source &typeCreation) { const VPointF *firstPoint = data->GeometricObject(p1Line); const VPointF *secondPoint = data->GeometricObject(p2Line); @@ -131,7 +181,7 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(), shoulderPoint->toQPointF(), qApp->toPixel(result)); quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->AddGObject(new VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); data->AddLine(p1Line, id); @@ -147,7 +197,7 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::ShoulderPointTool, doc); + VDrawTool::AddRecord(id, Tool::ShoulderPointTool, doc); if (parse == Document::FullParse) { VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, formula, @@ -166,6 +216,9 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolShoulderPoint::FullUpdateFromFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -181,6 +234,10 @@ void VToolShoulderPoint::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ void VToolShoulderPoint::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); @@ -188,18 +245,29 @@ void VToolShoulderPoint::SetFactor(qreal factor) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ void VToolShoulderPoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolShoulderPoint::AddToFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -221,6 +289,9 @@ void VToolShoulderPoint::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolShoulderPoint::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -239,6 +310,9 @@ void VToolShoulderPoint::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ void VToolShoulderPoint::RemoveReferens() { doc->DecrementReferens(p2Line); @@ -247,6 +321,9 @@ void VToolShoulderPoint::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolShoulderPoint::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.h b/src/app/tools/drawTools/vtoolshoulderpoint.h index e9eec3e8a..2609504dd 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.h +++ b/src/app/tools/drawTools/vtoolshoulderpoint.h @@ -38,112 +38,33 @@ class VToolShoulderPoint : public VToolLinePoint { public: - /** - * @brief VToolShoulderPoint constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param typeLine line type. - * @param formula string with formula length. - * @param p1Line id first line point. - * @param p2Line id second line point. - * @param pShoulder id shoulder point. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolShoulderPoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, - const QString &formula, const quint32 &p1Line, const quint32 &p2Line, - const quint32 &pShoulder, const Valentina::Sources &typeCreation, - QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ + VToolShoulderPoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, + const QString &formula, const quint32 &p1Line, const quint32 &p2Line, const quint32 &pShoulder, + const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); - /** - * @brief FindPoint find point. - * @param p1Line first line point. - * @param p2Line second line point. - * @param pShoulder shoulder point. - * @param length length form shoulder point to our. - * @return point. - */ static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder, const qreal &length); - /** - * @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. - */ - static VToolShoulderPoint* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param formula string with formula length. - * @param p1Line id first line point. - * @param p2Line id second line point. - * @param pShoulder id shoulder point. - * @param typeLine line type. - * @param pointName point name. - * @param mx label bias x axis. - * @param my label bias y axis. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ - static VToolShoulderPoint* Create(const quint32 _id, QString &formula, const quint32 &p1Line, const quint32 &p2Line, - const quint32 &pShoulder, const QString &typeLine, const QString &pointName, const qreal &mx, - const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation); + static VToolShoulderPoint* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); + static VToolShoulderPoint* Create(const quint32 _id, QString &formula, const quint32 &p1Line, const quint32 &p2Line, + const quint32 &pShoulder, const QString &typeLine, const QString &pointName, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief SetFactor set current scale factor of scene. - * @param factor scene scale factor. - */ virtual void SetFactor(qreal factor); - /** - * @brief ShowContextMenu show context menu. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief RemoveReferens decrement value of reference. - */ virtual void RemoveReferens(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ virtual void SaveDialog(QDomElement &domElement); private: - /** - * @brief p2Line id second line point. - */ + /** @brief p2Line id second line point. */ quint32 p2Line; - /** - * @brief pShoulder id shoulder line point. - */ + + /** @brief pShoulder id shoulder line point. */ quint32 pShoulder; }; diff --git a/src/app/tools/drawTools/vtoolsinglepoint.cpp b/src/app/tools/drawTools/vtoolsinglepoint.cpp index 8b6b35ad1..2327502c8 100644 --- a/src/app/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/app/tools/drawTools/vtoolsinglepoint.cpp @@ -28,13 +28,28 @@ #include "vtoolsinglepoint.h" #include "../../dialogs/tools/dialogsinglepoint.h" +#include "../../widgets/vgraphicssimpletextitem.h" +#include "../../undocommands/movespoint.h" +#include "../../undocommands/addpatternpiece.h" +#include "../../undocommands/deletepatternpiece.h" +#include "../../geometry/vpointf.h" + +#include const QString VToolSinglePoint::ToolType = QStringLiteral("single"); //--------------------------------------------------------------------------------------------------------------------- -VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, const Valentina::Sources &typeCreation, - QGraphicsItem * parent ) - :VToolPoint(doc, data, id, parent) +/** + * @brief VToolSinglePoint constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, + const QString &namePP, const QString &mPath, QGraphicsItem * parent ) + :VToolPoint(doc, data, id, parent), namePP(namePP), mPath(mPath) { baseColor = Qt::red; currentColor = baseColor; @@ -44,7 +59,7 @@ VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemIsFocusable, false); setColorLabel(Qt::black); - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -55,6 +70,9 @@ VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolSinglePoint::setDialog() { SCASSERT(dialog != nullptr); @@ -65,23 +83,46 @@ void VToolSinglePoint::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolSinglePoint::AddToFile() { + Q_ASSERT_X(namePP.isEmpty() == false, "AddToFile", "name pattern piece is empty"); + const VPointF *point = VAbstractTool::data.GeometricObject(id); - QDomElement domElement = doc->createElement(TagName); + QDomElement sPoint = doc->createElement(TagName); - doc->SetAttribute(domElement, VDomDocument::AttrId, id); - doc->SetAttribute(domElement, AttrType, ToolType); - doc->SetAttribute(domElement, AttrName, point->name()); - doc->SetAttribute(domElement, AttrX, qApp->fromPixel(point->x())); - doc->SetAttribute(domElement, AttrY, qApp->fromPixel(point->y())); - doc->SetAttribute(domElement, AttrMx, qApp->fromPixel(point->mx())); - doc->SetAttribute(domElement, AttrMy, qApp->fromPixel(point->my())); + // Create SPoint tag + doc->SetAttribute(sPoint, VDomDocument::AttrId, id); + doc->SetAttribute(sPoint, AttrType, ToolType); + doc->SetAttribute(sPoint, AttrName, point->name()); + doc->SetAttribute(sPoint, AttrX, qApp->fromPixel(point->x())); + doc->SetAttribute(sPoint, AttrY, qApp->fromPixel(point->y())); + doc->SetAttribute(sPoint, AttrMx, qApp->fromPixel(point->mx())); + doc->SetAttribute(sPoint, AttrMy, qApp->fromPixel(point->my())); - AddToCalculation(domElement); + //Create pattern piece structure + QDomElement patternPiece = doc->createElement(VPattern::TagDraw); + doc->SetAttribute(patternPiece, AttrName, namePP); + + QDomElement calcElement = doc->createElement(VPattern::TagCalculation); + calcElement.appendChild(sPoint); + + patternPiece.appendChild(calcElement); + patternPiece.appendChild(doc->createElement(VPattern::TagModeling)); + patternPiece.appendChild(doc->createElement(VPattern::TagDetails)); + + AddPatternPiece *addPP = new AddPatternPiece(patternPiece, doc, namePP, mPath); + connect(addPP, &AddPatternPiece::ClearScene, doc, &VPattern::ClearScene); + connect(addPP, &AddPatternPiece::NeedFullParsing, doc, &VPattern::NeedFullParsing); + qApp->getUndoStack()->push(addPP); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolSinglePoint::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -97,6 +138,12 @@ void VToolSinglePoint::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange handle tool change. + * @param change change. + * @param value value. + * @return value. + */ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) { if (change == ItemPositionChange && scene()) @@ -116,24 +163,18 @@ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, { // value - this is new position. QPointF newPos = value.toPointF(); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrX, QString().setNum(qApp->fromPixel(newPos.x()))); - doc->SetAttribute(domElement, AttrY, QString().setNum(qApp->fromPixel(newPos.y()))); - QList list = this->scene()->views(); - VAbstractTool::NewSceneRect(this->scene(), list[0]); - - //I don't now why but signal does not work. - doc->FullUpdateTree(); - emit toolhaveChange(); - } + MoveSPoint *moveSP = new MoveSPoint(doc, newPos.x(), newPos.y(), id, this->scene()); + connect(moveSP, &MoveSPoint::NeedLiteParsing, doc, &VPattern::LiteParseTree); + qApp->getUndoStack()->push(moveSP); } return QGraphicsItem::itemChange(change, value); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief decrementReferens decrement referens parents objects. + */ void VToolSinglePoint::decrementReferens() { if (_referens > 1) @@ -143,6 +184,31 @@ void VToolSinglePoint::decrementReferens() } //--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::DeleteTool(bool ask) +{ + if (ask) + { + QMessageBox msgBox; + msgBox.setText(tr("Confirm the deletion.")); + msgBox.setInformativeText(tr("Do you really want delete?")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.setIcon(QMessageBox::Question); + if (msgBox.exec() == QMessageBox::Cancel) + { + return; + } + } + + DeletePatternPiece *deletePP = new DeletePatternPiece(doc, nameActivDraw); + connect(deletePP, &DeletePatternPiece::NeedFullParsing, doc, &VPattern::NeedFullParsing); + qApp->getUndoStack()->push(deletePP); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolSinglePoint::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); @@ -156,6 +222,10 @@ void VToolSinglePoint::SaveDialog(QDomElement &domElement) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setColorLabel change color for label and label line. + * @param color new color. + */ void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color) { namePoint->setBrush(color); @@ -163,12 +233,26 @@ void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolSinglePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) { - ContextMenu(this, event, false); + if (doc->CountPP() > 1) + { + ContextMenu(this, event); + } + else + { + ContextMenu(this, event, false); + } } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolSinglePoint::FullUpdateFromFile() { VPointF point = *VAbstractTool::data.GeometricObject(id); @@ -176,6 +260,10 @@ void VToolSinglePoint::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. + * @param newName new name active pattern peace. + */ void VToolSinglePoint::ChangedActivDraw(const QString &newName) { if (nameActivDraw == newName) @@ -193,6 +281,10 @@ void VToolSinglePoint::ChangedActivDraw(const QString &newName) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. + */ void VToolSinglePoint::SetFactor(qreal factor) { VDrawTool::SetFactor(factor); @@ -200,7 +292,18 @@ void VToolSinglePoint::SetFactor(qreal factor) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ void VToolSinglePoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { - ContextMenu(this, event, false); + if (doc->CountPP() > 1) + { + ContextMenu(this, event); + } + else + { + ContextMenu(this, event, false); + } } diff --git a/src/app/tools/drawTools/vtoolsinglepoint.h b/src/app/tools/drawTools/vtoolsinglepoint.h index 116734b6f..78b7b0ebd 100644 --- a/src/app/tools/drawTools/vtoolsinglepoint.h +++ b/src/app/tools/drawTools/vtoolsinglepoint.h @@ -39,85 +39,31 @@ class VToolSinglePoint : public VToolPoint { Q_OBJECT public: - /** - * @brief VToolSinglePoint constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, const Valentina::Sources &typeCreation, - QGraphicsItem * parent = nullptr ); - /** - * @brief setDialog set dialog when user want change tool option. - */ + VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, + const QString &namePP, const QString &mPath, QGraphicsItem * parent = nullptr ); virtual void setDialog(); static const QString ToolType; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. - * @param newName new name active pattern peace. - */ virtual void ChangedActivDraw(const QString &newName); - /** - * @brief SetFactor set current scale factor of scene. - * @param factor scene scale factor. - */ virtual void SetFactor(qreal factor); - /** - * @brief ShowContextMenu show context menu. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); signals: /** * @brief FullUpdateTree handle if need update pattern file. */ - void FullUpdateTree(); + void LiteUpdateTree(); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief itemChange handle tool change. - * @param change change. - * @param value value. - * @return value. - */ QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); - /** - * @brief decrementReferens decrement referens parents objects. - */ virtual void decrementReferens(); - /** - * @brief DeleteTool delete tool from file and scene. This tool can't be deleted by now. - * @param tool tool what me delete. - */ - virtual void DeleteTool(QGraphicsItem *tool){Q_UNUSED(tool)} - /** - * @brief SaveDialog save options into file after change in dialog. - */ + virtual void DeleteTool(bool ask = true); virtual void SaveDialog(QDomElement &domElement); private: - /** - * @brief setColorLabel change color for label and label line. - * @param color new color. - */ + QString namePP; + QString mPath; void setColorLabel(const Qt::GlobalColor & color); }; diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp index 5b39462cd..8029c69e4 100644 --- a/src/app/tools/drawTools/vtoolspline.cpp +++ b/src/app/tools/drawTools/vtoolspline.cpp @@ -29,11 +29,20 @@ #include "vtoolspline.h" #include "../../geometry/vspline.h" #include "../../dialogs/tools/dialogspline.h" +#include "../../undocommands/movespline.h" const QString VToolSpline::ToolType = QStringLiteral("simple"); //--------------------------------------------------------------------------------------------------------------------- -VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Valentina::Sources &typeCreation, +/** + * @brief VToolSpline constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem *parent) :VAbstractSpline(doc, data, id, parent) { const VSpline *spl = data->GeometricObject(id); @@ -46,7 +55,7 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Vale this->setFlag(QGraphicsItem::ItemIsFocusable, true); this->setAcceptHoverEvents(true); - VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePoint::FirstPoint, spl->GetP2(), + VControlPointSpline *controlPoint1 = new VControlPointSpline(1, SplinePointPosition::FirstPoint, spl->GetP2(), spl->GetP1().toQPointF(), this); connect(controlPoint1, &VControlPointSpline::ControlPointChangePosition, this, &VToolSpline::ControlPointChangePosition); @@ -54,7 +63,7 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Vale connect(this, &VToolSpline::setEnabledPoint, controlPoint1, &VControlPointSpline::setEnabledPoint); controlPoints.append(controlPoint1); - VControlPointSpline *controlPoint2 = new VControlPointSpline(1, SplinePoint::LastPoint, spl->GetP3(), + VControlPointSpline *controlPoint2 = new VControlPointSpline(1, SplinePointPosition::LastPoint, spl->GetP3(), spl->GetP4().toQPointF(), this); connect(controlPoint2, &VControlPointSpline::ControlPointChangePosition, this, &VToolSpline::ControlPointChangePosition); @@ -62,7 +71,7 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Vale connect(this, &VToolSpline::setEnabledPoint, controlPoint2, &VControlPointSpline::setEnabledPoint); controlPoints.append(controlPoint2); - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -73,6 +82,9 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Vale } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolSpline::setDialog() { SCASSERT(dialog != nullptr); @@ -89,8 +101,14 @@ void VToolSpline::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -void VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data) +/** + * @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(dialog); @@ -103,20 +121,36 @@ void VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern const qreal angle2 = dialogTool->getAngle2(); const qreal kCurve = dialogTool->getKCurve(); Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, doc, data, Document::FullParse, - Valentina::FromGui); + Source::FromGui); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param p1 id first spline point. + * @param p4 id last spline point. + * @param kAsm1 coefficient of length first control line. + * @param kAsm2 coefficient of length second control line. + * @param angle1 angle from first point to first control point. + * @param angle2 angle from second point to second control point. + * @param kCurve coefficient of curvature spline. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ void VToolSpline::Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1, const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation) + const Document &parse, const Source &typeCreation) { VPointF point1 = *data->GeometricObject(p1); VPointF point4 = *data->GeometricObject(p4); VSpline *spline = new VSpline(point1, point4, angle1, angle2, kAsm1, kAsm2, kCurve); quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->AddGObject(spline); data->AddLengthSpline(spline->name(), qApp->fromPixel(spline->GetLength())); @@ -130,7 +164,7 @@ void VToolSpline::Create(const quint32 _id, const quint32 &p1, const quint32 &p4 doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::SplineTool, doc); + VDrawTool::AddRecord(id, Tool::SplineTool, doc); if (parse == Document::FullParse) { VToolSpline *spl = new VToolSpline(doc, data, id, typeCreation); @@ -144,13 +178,19 @@ void VToolSpline::Create(const quint32 _id, const quint32 &p1, const quint32 &p4 } //--------------------------------------------------------------------------------------------------------------------- -void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const SplinePoint::Position &position, +/** + * @brief ControlPointChangePosition handle change position control point. + * @param indexSpline position spline in spline list. + * @param position position point in spline. + * @param pos new position. + */ +void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position, const QPointF &pos) { Q_UNUSED(indexSpline); const VSpline *spline = VAbstractTool::data.GeometricObject(id); VSpline spl; - if (position == SplinePoint::FirstPoint) + if (position == SplinePointPosition::FirstPoint) { spl = VSpline(spline->GetP1(), pos, spline->GetP3(), spline->GetP4(), spline->GetKcurve()); } @@ -158,25 +198,26 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp { spl = VSpline(spline->GetP1(), spline->GetP2(), pos, spline->GetP4(), spline->GetKcurve()); } - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrAngle1, QString().setNum(spl.GetAngle1())); - doc->SetAttribute(domElement, AttrAngle2, QString().setNum(spl.GetAngle2())); - doc->SetAttribute(domElement, AttrKAsm1, QString().setNum(spl.GetKasm1())); - doc->SetAttribute(domElement, AttrKAsm2, QString().setNum(spl.GetKasm2())); - doc->SetAttribute(domElement, AttrKCurve, QString().setNum(spl.GetKcurve())); - emit FullUpdateTree(); - emit toolhaveChange(); - } + + MoveSpline *moveSpl = new MoveSpline(doc, spline, spl, id, this->scene()); + connect(moveSpl, &MoveSpline::NeedLiteParsing, doc, &VPattern::LiteParseTree); + qApp->getUndoStack()->push(moveSpl); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolSpline::AddToFile() { const VSpline *spl = VAbstractTool::data.GeometricObject(id); @@ -196,6 +237,9 @@ void VToolSpline::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolSpline::RefreshDataInFile() { const VSpline *spl = VAbstractTool::data.GeometricObject(id); @@ -213,16 +257,23 @@ void VToolSpline::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event context menu event. + */ void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { - emit ChoosedTool(id, Valentina::Spline); + emit ChoosedTool(id, SceneObject::Spline); } QGraphicsItem::mouseReleaseEvent(event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ void VToolSpline::RemoveReferens() { const VSpline *spl = VAbstractTool::data.GeometricObject(id); @@ -231,6 +282,9 @@ void VToolSpline::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolSpline::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); @@ -265,6 +319,9 @@ void VToolSpline::SaveDialog(QDomElement &domElement) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ void VToolSpline::RefreshGeometry() { this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); @@ -275,10 +332,10 @@ void VToolSpline::RefreshGeometry() this->setPath(path); QPointF splinePoint = VAbstractTool::data.GeometricObject(spl->GetP1().id())->toQPointF(); QPointF controlPoint = spl->GetP2(); - emit RefreshLine(1, SplinePoint::FirstPoint, controlPoint, splinePoint); + emit RefreshLine(1, SplinePointPosition::FirstPoint, controlPoint, splinePoint); splinePoint = VAbstractTool::data.GeometricObject(spl->GetP4().id())->toQPointF(); controlPoint = spl->GetP3(); - emit RefreshLine(1, SplinePoint::LastPoint, controlPoint, splinePoint); + emit RefreshLine(1, SplinePointPosition::LastPoint, controlPoint, splinePoint); disconnect(controlPoints[0], &VControlPointSpline::ControlPointChangePosition, this, &VToolSpline::ControlPointChangePosition); diff --git a/src/app/tools/drawTools/vtoolspline.h b/src/app/tools/drawTools/vtoolspline.h index a13f6655b..a75726a94 100644 --- a/src/app/tools/drawTools/vtoolspline.h +++ b/src/app/tools/drawTools/vtoolspline.h @@ -30,7 +30,6 @@ #define VTOOLSPLINE_H #include "vabstractspline.h" -#include "../../geometry/vsplinepath.h" /** * @brief The VToolSpline class tool for creation spline. I mean bezier curve. @@ -39,90 +38,28 @@ class VToolSpline:public VAbstractSpline { Q_OBJECT public: - /** - * @brief VToolSpline constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolSpline (VPattern *doc, VContainer *data, quint32 id, const Valentina::Sources &typeCreation, + + VToolSpline (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem * parent = nullptr ); - /** - * @brief setDialog set dialog when user want change tool option. - */ virtual void setDialog(); - /** - * @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. - */ static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param p1 id first spline point. - * @param p4 id last spline point. - * @param kAsm1 coefficient of length first control line. - * @param kAsm2 coefficient of length second control line. - * @param angle1 angle from first point to first control point. - * @param angle2 angle from second point to second control point. - * @param kCurve coefficient of curvature spline. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ static void Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1, const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation); + const Document &parse, const Source &typeCreation); static const QString ToolType; public slots: - /** - * @brief ControlPointChangePosition handle change position control point. - * @param indexSpline position spline in spline list. - * @param position position point in spline. - * @param pos new position. - */ - void ControlPointChangePosition (const qint32 &indexSpline, const SplinePoint::Position &position, - const QPointF &pos); + void ControlPointChangePosition (const qint32 &indexSpline, const SplinePointPosition &position, + const QPointF &pos); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ - virtual void AddToFile (); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ - virtual void RefreshDataInFile(); - /** - * @brief mouseReleaseEvent handle mouse release events. - * @param event context menu event. - */ - virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief RemoveReferens decrement value of reference. - */ - virtual void RemoveReferens(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ - virtual void SaveDialog(QDomElement &domElement); + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void AddToFile (); + virtual void RefreshDataInFile(); + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); + virtual void RemoveReferens(); + virtual void SaveDialog(QDomElement &domElement); private: - /** - * @brief RefreshGeometry refresh item on scene. - */ - void RefreshGeometry (); + void RefreshGeometry (); }; #endif // VTOOLSPLINE_H diff --git a/src/app/tools/drawTools/vtoolsplinepath.cpp b/src/app/tools/drawTools/vtoolsplinepath.cpp index 763edef38..d96942684 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolsplinepath.cpp @@ -28,11 +28,20 @@ #include "vtoolsplinepath.h" #include "../../dialogs/tools/dialogsplinepath.h" +#include "../../undocommands/movesplinepath.h" const QString VToolSplinePath::ToolType = QStringLiteral("path"); //--------------------------------------------------------------------------------------------------------------------- -VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, const Valentina::Sources &typeCreation, +/** + * @brief VToolSplinePath constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ +VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem *parent) :VAbstractSpline(doc, data, id, parent) { const VSplinePath *splPath = data->GeometricObject(id); @@ -48,7 +57,7 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co for (qint32 i = 1; i<=splPath->Count(); ++i) { VSpline spl = splPath->GetSpline(i); - VControlPointSpline *controlPoint = new VControlPointSpline(i, SplinePoint::FirstPoint, spl.GetP2(), + VControlPointSpline *controlPoint = new VControlPointSpline(i, SplinePointPosition::FirstPoint, spl.GetP2(), spl.GetP1().toQPointF(), this); connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this, &VToolSplinePath::ControlPointChangePosition); @@ -56,14 +65,15 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co connect(this, &VToolSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint); controlPoints.append(controlPoint); - controlPoint = new VControlPointSpline(i, SplinePoint::LastPoint, spl.GetP3(), spl.GetP4().toQPointF(), this); + controlPoint = new VControlPointSpline(i, SplinePointPosition::LastPoint, spl.GetP3(), spl.GetP4().toQPointF(), + this); connect(controlPoint, &VControlPointSpline::ControlPointChangePosition, this, &VToolSplinePath::ControlPointChangePosition); connect(this, &VToolSplinePath::RefreshLine, controlPoint, &VControlPointSpline::RefreshLine); connect(this, &VToolSplinePath::setEnabledPoint, controlPoint, &VControlPointSpline::setEnabledPoint); controlPoints.append(controlPoint); } - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -74,6 +84,9 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolSplinePath::setDialog() { SCASSERT(dialog != nullptr); @@ -84,6 +97,13 @@ void VToolSplinePath::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @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 VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); @@ -94,16 +114,25 @@ void VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPat { doc->IncrementReferens((*path)[i].P().id()); } - Create(0, path, scene, doc, data, Document::FullParse, Valentina::FromGui); + Create(0, path, scene, doc, data, Document::FullParse, Source::FromGui); } //--------------------------------------------------------------------------------------------------------------------- -void VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document::Documents &parse, - const Valentina::Sources &typeCreation) +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param path spline path. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ +void VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation) { quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->AddGObject(path); data->AddLengthSpline(path->name(), qApp->fromPixel(path->GetLength())); @@ -117,7 +146,7 @@ void VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphics doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::SplinePathTool, doc); + VDrawTool::AddRecord(id, Tool::SplinePathTool, doc); if (parse == Document::FullParse) { VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation); @@ -129,12 +158,19 @@ void VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphics } //--------------------------------------------------------------------------------------------------------------------- -void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, const SplinePoint::Position &position, +/** + * @brief ControlPointChangePosition handle change position control point. + * @param indexSpline position spline in spline list. + * @param position position point in spline. + * @param pos new position. + */ +void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position, const QPointF &pos) { - VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); - VSpline spl = splPath.GetSpline(indexSpline); - if (position == SplinePoint::FirstPoint) + VSplinePath oldSplPath = *VAbstractTool::data.GeometricObject(id); + VSplinePath newSplPath = oldSplPath; + VSpline spl = newSplPath.GetSpline(indexSpline); + if (position == SplinePointPosition::FirstPoint) { spl = VSpline(spl.GetP1(), pos, spl.GetP3(), spl.GetP4(), spl.GetKcurve()); } @@ -143,29 +179,31 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons spl = VSpline(spl.GetP1(), spl.GetP2(), pos, spl.GetP4(), spl.GetKcurve()); } - CorectControlPoints(spl, splPath, indexSpline); - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); - UpdatePathPoint(domElement, splPath); - emit FullUpdateTree(); - emit toolhaveChange(); - } + UpdateControlPoints(spl, newSplPath, indexSpline); + + MoveSplinePath *moveSplPath = new MoveSplinePath(doc, oldSplPath, newSplPath, id, this->scene()); + connect(moveSplPath, &MoveSplinePath::NeedLiteParsing, doc, &VPattern::LiteParseTree); + qApp->getUndoStack()->push(moveSplPath); } //--------------------------------------------------------------------------------------------------------------------- -void VToolSplinePath::CorectControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) +/** + * @brief UpdateControlPoints update position points control points in file. + * @param spl spline what was changed. + * @param splPath spline path. + * @param indexSpline index spline in spline path. + */ +void VToolSplinePath::UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const { - VSplinePoint p = splPath.GetSplinePoint(indexSpline, SplinePoint::FirstPoint); + VSplinePoint p = splPath.GetSplinePoint(indexSpline, SplinePointPosition::FirstPoint); p.SetAngle2(spl.GetAngle1()); p.SetKAsm2(spl.GetKasm1()); - splPath.UpdatePoint(indexSpline, SplinePoint::FirstPoint, p); + splPath.UpdatePoint(indexSpline, SplinePointPosition::FirstPoint, p); - p = splPath.GetSplinePoint(indexSpline, SplinePoint::LastPoint); + p = splPath.GetSplinePoint(indexSpline, SplinePointPosition::LastPoint); p.SetAngle2(spl.GetAngle2()-180); p.SetKAsm1(spl.GetKasm2()); - splPath.UpdatePoint(indexSpline, SplinePoint::LastPoint, p); + splPath.UpdatePoint(indexSpline, SplinePointPosition::LastPoint, p); } //--------------------------------------------------------------------------------------------------------------------- @@ -188,14 +226,20 @@ void VToolSplinePath::RefreshSplinePath(VSplinePath &splPath) spl = VSpline (spl.GetP1(), controlPoints[j-2]->pos(), controlPoints[j-1]->pos(), spl.GetP4(), splPath.getKCurve()); - CorectControlPoints(spl, splPath, i); - CorectControlPoints(spl, splPath, i); + UpdateControlPoints(spl, splPath, i); } } //--------------------------------------------------------------------------------------------------------------------- -void VToolSplinePath::UpdatePathPoint(QDomNode& node, VSplinePath &path) +/** + * @brief UpdatePathPoint update spline path in pattern file. + * @brief doc dom document container. + * @param node tag in file. + * @param path spline path. + */ +void VToolSplinePath::UpdatePathPoint(VPattern *doc, QDomNode& node, const VSplinePath &path) { + SCASSERT(doc != nullptr) QDomNodeList nodeList = node.childNodes(); qint32 num = nodeList.size(); for (qint32 i = 0; i < num; ++i) @@ -203,7 +247,7 @@ void VToolSplinePath::UpdatePathPoint(QDomNode& node, VSplinePath &path) QDomElement domElement = nodeList.at(i).toElement(); if (domElement.isNull() == false) { - VSplinePoint p = path[i]; + VSplinePoint p = path.at(i); doc->SetAttribute(domElement, AttrPSpline, p.P().id()); doc->SetAttribute(domElement, AttrKAsm1, p.KAsm1()); doc->SetAttribute(domElement, AttrKAsm2, p.KAsm2()); @@ -213,12 +257,19 @@ void VToolSplinePath::UpdatePathPoint(QDomNode& node, VSplinePath &path) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolSplinePath::AddToFile() { VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); @@ -230,13 +281,16 @@ void VToolSplinePath::AddToFile() for (qint32 i = 0; i < splPath.CountPoint(); ++i) { - AddPathPoint(domElement, splPath[i]); + AddPathPoint(domElement, splPath.at(i)); } AddToCalculation(domElement); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolSplinePath::RefreshDataInFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -248,10 +302,15 @@ void VToolSplinePath::RefreshDataInFile() VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); RefreshSplinePath(splPath); doc->SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); - UpdatePathPoint(domElement, splPath); + UpdatePathPoint(doc, domElement, splPath); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddPathPoint write path point to pattern file. + * @param domElement dom element. + * @param splPoint spline path point. + */ void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint) { QDomElement pathPoint = doc->createElement(AttrPathPoint); @@ -265,26 +324,36 @@ void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint & } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ void VToolSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { - emit ChoosedTool(id, Valentina::SplinePath); + emit ChoosedTool(id, SceneObject::SplinePath); } QGraphicsItem::mouseReleaseEvent(event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ void VToolSplinePath::RemoveReferens() { VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); for (qint32 i = 0; i < splPath.Count(); ++i) { - doc->DecrementReferens(splPath[i].P().id()); + doc->DecrementReferens(splPath.at(i).P().id()); } } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolSplinePath::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); @@ -294,10 +363,13 @@ void VToolSplinePath::SaveDialog(QDomElement &domElement) VSplinePath splPath = dialogTool->GetPath(); RefreshSplinePath(splPath); doc->SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); - UpdatePathPoint(domElement, splPath); + UpdatePathPoint(doc, domElement, splPath); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ void VToolSplinePath::RefreshGeometry() { this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); @@ -311,10 +383,10 @@ void VToolSplinePath::RefreshGeometry() VSpline spl = splPath->GetSpline(i); QPointF splinePoint = spl.GetP1().toQPointF(); QPointF controlPoint = spl.GetP2(); - emit RefreshLine(i, SplinePoint::FirstPoint, controlPoint, splinePoint); + emit RefreshLine(i, SplinePointPosition::FirstPoint, controlPoint, splinePoint); splinePoint = spl.GetP4().toQPointF(); controlPoint = spl.GetP3(); - emit RefreshLine(i, SplinePoint::LastPoint, controlPoint, splinePoint); + emit RefreshLine(i, SplinePointPosition::LastPoint, controlPoint, splinePoint); qint32 j = i*2; disconnect(controlPoints[j-2], &VControlPointSpline::ControlPointChangePosition, this, diff --git a/src/app/tools/drawTools/vtoolsplinepath.h b/src/app/tools/drawTools/vtoolsplinepath.h index de8406cf3..793bc70fe 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.h +++ b/src/app/tools/drawTools/vtoolsplinepath.h @@ -38,42 +38,14 @@ class VToolSplinePath:public VAbstractSpline { Q_OBJECT public: - /** - * @brief VToolSplinePath constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, const Valentina::Sources &typeCreation, - QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ - virtual void setDialog(); - /** - * @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. - */ + VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, + QGraphicsItem * parent = nullptr); + virtual void setDialog(); static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param path spline path. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ - static void Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document::Documents &parse, - const Valentina::Sources &typeCreation); + static void Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; + static void UpdatePathPoint(VPattern *doc, QDomNode& node, const VSplinePath &path); signals: /** * @brief RefreshLine refresh control line. @@ -82,74 +54,29 @@ signals: * @param controlPoint new position control point. * @param splinePoint new position spline point. */ - void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos, - const QPointF &controlPoint, const QPointF &splinePoint); + void RefreshLine(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint, + const QPointF &splinePoint); /** * @brief setEnabledPoint disable control points. * @param enable enable or diasable points. */ - void setEnabledPoint(bool enable); + void setEnabledPoint(bool enable); public slots: - /** - * @brief ControlPointChangePosition handle change position control point. - * @param indexSpline position spline in spline list. - * @param position position point in spline. - * @param pos new position. - */ - void ControlPointChangePosition(const qint32 &indexSpline, const SplinePoint::Position &position, - const QPointF &pos); + + void ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position, + const QPointF &pos); protected: - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ - virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ - virtual void RefreshDataInFile(); - /** - * @brief mouseReleaseEvent handle mouse release events. - * @param event mouse release event. - */ - virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief RemoveReferens decrement value of reference. - */ - virtual void RemoveReferens(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ - virtual void SaveDialog(QDomElement &domElement); + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void AddToFile(); + virtual void RefreshDataInFile(); + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); + virtual void RemoveReferens(); + virtual void SaveDialog(QDomElement &domElement); private: - /** - * @brief RefreshGeometry refresh item on scene. - */ - void RefreshGeometry(); - /** - * @brief AddPathPoint write path point to pattern file. - * @param domElement dom element. - * @param splPoint spline path point. - */ - void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint); - /** - * @brief UpdatePathPoint update spline path in pattern file. - * @param node tag in file. - * @param path spline path. - */ - void UpdatePathPoint(QDomNode& node, VSplinePath &path); - /** - * @brief CorectControlPoints update position points control points in file. - * @param spl spline what was changed. - * @param splPath spline path. - * @param indexSpline index spline in spline path. - */ - void CorectControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline); - void RefreshSplinePath(VSplinePath &splPath); + void RefreshGeometry(); + void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint); + void UpdateControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline) const; + void RefreshSplinePath(VSplinePath &splPath); }; #endif // VTOOLSPLINEPATH_H diff --git a/src/app/tools/drawTools/vtooltriangle.cpp b/src/app/tools/drawTools/vtooltriangle.cpp index 9c3aa03c0..f9d46f2de 100644 --- a/src/app/tools/drawTools/vtooltriangle.cpp +++ b/src/app/tools/drawTools/vtooltriangle.cpp @@ -28,18 +28,31 @@ #include "vtooltriangle.h" #include "../../dialogs/tools/dialogtriangle.h" +#include "../../geometry/vpointf.h" const QString VToolTriangle::ToolType = QStringLiteral("triangle"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolTriangle constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param axisP1Id id first axis point. + * @param axisP2Id id second axis point. + * @param firstPointId id first triangle point, what lies on the hypotenuse. + * @param secondPointId id second triangle point, what lies on the hypotenuse. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolTriangle::VToolTriangle(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &axisP1Id, const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId, - const Valentina::Sources &typeCreation, QGraphicsItem *parent) + const Source &typeCreation, QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId), secondPointId(secondPointId) { ignoreFullUpdate = true; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -50,6 +63,9 @@ VToolTriangle::VToolTriangle(VPattern *doc, VContainer *data, const quint32 &id, } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolTriangle::setDialog() { SCASSERT(dialog != nullptr); @@ -64,8 +80,14 @@ void VToolTriangle::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -void VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data) +/** + * @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 VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); DialogTriangle *dialogTool = qobject_cast(dialog); @@ -76,14 +98,30 @@ void VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *scene, const quint32 secondPointId = dialogTool->getSecondPointId(); const QString pointName = dialogTool->getPointName(); Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, scene, doc, data, - Document::FullParse, Valentina::FromGui); + Document::FullParse, Source::FromGui); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param pointName point name. + * @param axisP1Id id first axis point. + * @param axisP2Id id second axis point. + * @param firstPointId id first triangle point, what lies on the hypotenuse. + * @param secondPointId id second triangle point, what lies on the hypotenuse. + * @param mx label bias x axis. + * @param my label bias y axis. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ void VToolTriangle::Create(const quint32 _id, const QString &pointName, const quint32 &axisP1Id, const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation) + VContainer *data, const Document &parse, const Source &typeCreation) { const VPointF *axisP1 = data->GeometricObject(axisP1Id); const VPointF *axisP2 = data->GeometricObject(axisP2Id); @@ -93,7 +131,7 @@ void VToolTriangle::Create(const quint32 _id, const QString &pointName, const qu QPointF point = FindPoint(axisP1->toQPointF(), axisP2->toQPointF(), firstPoint->toQPointF(), secondPoint->toQPointF()); quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->AddGObject(new VPointF(point.x(), point.y(), pointName, mx, my)); } @@ -105,7 +143,7 @@ void VToolTriangle::Create(const quint32 _id, const QString &pointName, const qu doc->UpdateToolData(id, data); } } - VDrawTool::AddRecord(id, Valentina::Triangle, doc); + VDrawTool::AddRecord(id, Tool::Triangle, doc); if (parse == Document::FullParse) { VToolTriangle *point = new VToolTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId, @@ -122,6 +160,14 @@ void VToolTriangle::Create(const quint32 _id, const QString &pointName, const qu } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FindPoint find point intersection two foots right triangle. + * @param axisP1 first axis point. + * @param axisP2 second axis point. + * @param firstPoint first triangle point, what lies on the hypotenuse. + * @param secondPoint second triangle point, what lies on the hypotenuse. + * @return point intersection two foots right triangle. + */ QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint, const QPointF &secondPoint) { @@ -164,6 +210,9 @@ QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, c } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolTriangle::FullUpdateFromFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -178,12 +227,19 @@ void VToolTriangle::FullUpdateFromFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowContextMenu show context menu. + * @param event context menu event. + */ void VToolTriangle::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ void VToolTriangle::RemoveReferens() { doc->DecrementReferens(axisP1Id); @@ -193,12 +249,19 @@ void VToolTriangle::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(this, event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolTriangle::AddToFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -219,6 +282,9 @@ void VToolTriangle::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolTriangle::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -236,6 +302,9 @@ void VToolTriangle::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SaveDialog save options into file after change in dialog. + */ void VToolTriangle::SaveDialog(QDomElement &domElement) { SCASSERT(dialog != nullptr); diff --git a/src/app/tools/drawTools/vtooltriangle.h b/src/app/tools/drawTools/vtooltriangle.h index 0a6e12f8a..1300aae3c 100644 --- a/src/app/tools/drawTools/vtooltriangle.h +++ b/src/app/tools/drawTools/vtooltriangle.h @@ -38,114 +38,40 @@ class VToolTriangle : public VToolPoint { Q_OBJECT public: - /** - * @brief VToolTriangle constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param axisP1Id id first axis point. - * @param axisP2Id id second axis point. - * @param firstPointId id first triangle point, what lies on the hypotenuse. - * @param secondPointId id second triangle point, what lies on the hypotenuse. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ - VToolTriangle(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &axisP1Id, - const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId, - const Valentina::Sources &typeCreation, QGraphicsItem * parent = nullptr); - /** - * @brief setDialog set dialog when user want change tool option. - */ + VToolTriangle(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &axisP1Id, const quint32 &axisP2Id, + const quint32 &firstPointId, const quint32 &secondPointId, const Source &typeCreation, + QGraphicsItem * parent = nullptr); virtual void setDialog(); - /** - * @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. - */ static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param pointName point name. - * @param axisP1Id id first axis point. - * @param axisP2Id id second axis point. - * @param firstPointId id first triangle point, what lies on the hypotenuse. - * @param secondPointId id second triangle point, what lies on the hypotenuse. - * @param mx label bias x axis. - * @param my label bias y axis. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ static void Create(const quint32 _id, const QString &pointName, const quint32 &axisP1Id, const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation); - /** - * @brief FindPoint find point intersection two foots right triangle. - * @param axisP1 first axis point. - * @param axisP2 second axis point. - * @param firstPoint first triangle point, what lies on the hypotenuse. - * @param secondPoint second triangle point, what lies on the hypotenuse. - * @return point intersection two foots right triangle. - */ + const Document &parse, const Source &typeCreation); static QPointF FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint, const QPointF &secondPoint); static const QString ToolType; public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief ShowContextMenu show context menu. - * @param event context menu event. - */ virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief RemoveReferens decrement value of reference. - */ virtual void RemoveReferens(); - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ - virtual void RefreshDataInFile(); - /** - * @brief SaveDialog save options into file after change in dialog. - */ - virtual void SaveDialog(QDomElement &domElement); + virtual void RefreshDataInFile(); + virtual void SaveDialog(QDomElement &domElement); private: Q_DISABLE_COPY(VToolTriangle) - /** - * @brief axisP1Id id first axis point. - */ - quint32 axisP1Id; - /** - * @brief axisP2Id id second axis point. - */ - quint32 axisP2Id; - /** - * @brief firstPointId id first triangle point, what lies on the hypotenuse. - */ - quint32 firstPointId; - /** - * @brief secondPointId id second triangle point, what lies on the hypotenuse. - */ - quint32 secondPointId; + /** @brief axisP1Id id first axis point. */ + quint32 axisP1Id; + + /** @brief axisP2Id id second axis point. */ + quint32 axisP2Id; + + /** @brief firstPointId id first triangle point, what lies on the hypotenuse. */ + quint32 firstPointId; + + /** @brief secondPointId id second triangle point, what lies on the hypotenuse. */ + quint32 secondPointId; }; #endif // VTOOLTRIANGLE_H diff --git a/src/app/tools/nodeDetails/vabstractnode.cpp b/src/app/tools/nodeDetails/vabstractnode.cpp index eafadc8b0..09f6e1da8 100644 --- a/src/app/tools/nodeDetails/vabstractnode.cpp +++ b/src/app/tools/nodeDetails/vabstractnode.cpp @@ -28,11 +28,23 @@ #include "vabstractnode.h" #include +#include "../../xml/vpattern.h" +#include "../../undocommands/adddetnode.h" +#include "../../widgets/vapplication.h" const QString VAbstractNode::AttrIdObject = QStringLiteral("idObject"); const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VAbstractNode constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idNode object id in containerNode. + * @param idTool id tool. + * @param parent parent object. + */ VAbstractNode::VAbstractNode(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode, const quint32 &idTool, QObject *parent) : VAbstractTool(doc, data, id, parent), idNode(idNode), idTool(idTool) @@ -45,53 +57,33 @@ void VAbstractNode::DeleteNode() { if (_referens <= 1) { - //remove from xml file - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - QDomNode element = domElement.parentNode(); - if (element.isNull() == false) - { - if (element.isElement()) - { - RemoveReferens();//deincrement referens - element.removeChild(domElement);//remove form file - emit toolhaveChange();//set enabled save button - } - else - { - qDebug()<<"parent isn't element"<getUndoStack()->push(addNode); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief decrementReferens decrement reference for all parent objects. + */ void VAbstractNode::decrementReferens() { if (_referens > 0) @@ -112,3 +104,29 @@ void VAbstractNode::decrementReferens() } } } + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractNode::RemoveReferens() +{ + if (idTool != 0) + { + doc->DecrementReferens(idTool); + } + else + { + doc->DecrementReferens(idNode); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractNode::RestoreReferens() +{ + if (idTool != 0) + { + doc->IncrementReferens(idTool); + } + else + { + doc->IncrementReferens(idNode); + } +} diff --git a/src/app/tools/nodeDetails/vabstractnode.h b/src/app/tools/nodeDetails/vabstractnode.h index c32947a7b..9cca668bf 100644 --- a/src/app/tools/nodeDetails/vabstractnode.h +++ b/src/app/tools/nodeDetails/vabstractnode.h @@ -38,39 +38,24 @@ class VAbstractNode : public VAbstractTool { Q_OBJECT public: - /** - * @brief VAbstractNode constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param idNode object id in containerNode. - * @param idTool id tool. - * @param parent parent object. - */ - VAbstractNode(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode, - const quint32 &idTool, QObject *parent = nullptr); + VAbstractNode(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode, + const quint32 &idTool, QObject *parent = nullptr); virtual ~VAbstractNode() {} static const QString AttrIdObject; static const QString AttrIdTool; virtual void DeleteNode(); + virtual void RestoreNode(); protected: - /** - * @brief idNodenode id. - */ + /** @brief idNodenode id. */ quint32 idNode; - /** - * @brief idTool id tool. - */ + + /** @brief idTool id tool. */ quint32 idTool; - /** - * @brief AddToModeling add tag to modeling tag current pattern peace. - * @param domElement tag. - */ + void AddToModeling(const QDomElement &domElement); - /** - * @brief decrementReferens decrement reference for all parent objects. - */ virtual void decrementReferens(); + virtual void RemoveReferens(); + virtual void RestoreReferens(); }; #endif // VABSTRACTNODE_H diff --git a/src/app/tools/nodeDetails/vnodearc.cpp b/src/app/tools/nodeDetails/vnodearc.cpp index ef409f305..403ac0aaf 100644 --- a/src/app/tools/nodeDetails/vnodearc.cpp +++ b/src/app/tools/nodeDetails/vnodearc.cpp @@ -28,21 +28,32 @@ #include "vnodearc.h" -#include #include "../../widgets/vapplication.h" +#include "../../geometry/varc.h" const QString VNodeArc::TagName = QStringLiteral("arc"); const QString VNodeArc::ToolType = QStringLiteral("modeling"); //--------------------------------------------------------------------------------------------------------------------- -VNodeArc::VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Valentina::Sources &typeCreation, +/** + * @brief VNodeArc constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idArc object id in containerArc. + * @param typeCreation way we create this tool. + * @param idTool tool id. + * @param qoParent QObject parent + * @param parent parent object. + */ +VNodeArc::VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation, const quint32 &idTool, QObject *qoParent, QGraphicsItem *parent) :VAbstractNode(doc, data, id, idArc, idTool, qoParent), QGraphicsPathItem(parent) { RefreshGeometry(); this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine()))); - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -53,10 +64,21 @@ VNodeArc::VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, c } //--------------------------------------------------------------------------------------------------------------------- -void VNodeArc::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document::Documents &parse, - const Valentina::Sources &typeCreation, const quint32 &idTool, QObject *parent) +/** + * @brief Create help create tool. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idArc object id in containerArc. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @param idTool tool id. + * @param parent QObject parent + */ +void VNodeArc::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse, + const Source &typeCreation, const quint32 &idTool, QObject *parent) { - VAbstractTool::AddRecord(id, Valentina::NodeArc, doc); + VAbstractTool::AddRecord(id, Tool::NodeArc, doc); if (parse == Document::FullParse) { VNodeArc *arc = new VNodeArc(doc, data, id, idArc, typeCreation, idTool, parent); @@ -81,6 +103,9 @@ void VNodeArc::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idArc } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DeleteNode delete node from detail. + */ void VNodeArc::DeleteNode() { VAbstractNode::DeleteNode(); @@ -88,12 +113,28 @@ void VNodeArc::DeleteNode() } //--------------------------------------------------------------------------------------------------------------------- +void VNodeArc::RestoreNode() +{ + if (this->isVisible() == false) + { + VAbstractNode::RestoreNode(); + this->setVisible(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VNodeArc::FullUpdateFromFile() { RefreshGeometry(); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VNodeArc::AddToFile() { QDomElement domElement = doc->createElement(TagName); @@ -110,6 +151,9 @@ void VNodeArc::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VNodeArc::RefreshDataInFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -124,16 +168,24 @@ void VNodeArc::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ void VNodeArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { - emit ChoosedTool(id, Valentina::Arc); + emit ChoosedTool(id, SceneObject::Arc); } QGraphicsItem::mouseReleaseEvent(event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ void VNodeArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -141,6 +193,10 @@ void VNodeArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -148,6 +204,9 @@ void VNodeArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ void VNodeArc::RefreshGeometry() { const VArc *arc = VAbstractTool::data.GeometricObject(id); diff --git a/src/app/tools/nodeDetails/vnodearc.h b/src/app/tools/nodeDetails/vnodearc.h index cf22507bf..f0bd899be 100644 --- a/src/app/tools/nodeDetails/vnodearc.h +++ b/src/app/tools/nodeDetails/vnodearc.h @@ -31,6 +31,7 @@ #include "vabstractnode.h" #include +#include "../../xml/vpattern.h" /** * @brief The VNodeArc class arc detail node. @@ -39,72 +40,24 @@ class VNodeArc :public VAbstractNode, public QGraphicsPathItem { Q_OBJECT public: - /** - * @brief VNodeArc constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param idArc object id in containerArc. - * @param typeCreation way we create this tool. - * @param idTool tool id. - * @param qoParent QObject parent - * @param parent parent object. - */ - VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, - const Valentina::Sources &typeCreation, const quint32 &idTool = 0, - QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr); - /** - * @brief Create help create tool. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param idArc object id in containerArc. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - * @param idTool tool id. - * @param parent QObject parent - */ - static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document::Documents &parse, - const Valentina::Sources &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr); + VNodeArc(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Source &typeCreation, + const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr); + + static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idArc, const Document &parse, + const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr); static const QString TagName; static const QString ToolType; - /** - * @brief DeleteNode delete node from detail. - */ virtual void DeleteNode(); + virtual void RestoreNode(); public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); protected: - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief mouseReleaseEvent handle mouse release events. - * @param event mouse release event. - */ virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); private: - /** - * @brief RefreshGeometry refresh item on scene. - */ void RefreshGeometry(); }; diff --git a/src/app/tools/nodeDetails/vnodepoint.cpp b/src/app/tools/nodeDetails/vnodepoint.cpp index 8dd3e1198..199fe3bb8 100644 --- a/src/app/tools/nodeDetails/vnodepoint.cpp +++ b/src/app/tools/nodeDetails/vnodepoint.cpp @@ -28,16 +28,27 @@ #include "vnodepoint.h" -#include #include "../../widgets/vapplication.h" +#include "../../geometry/vpointf.h" +#include "../../widgets/vgraphicssimpletextitem.h" const QString VNodePoint::TagName = QStringLiteral("point"); const QString VNodePoint::ToolType = QStringLiteral("modeling"); //--------------------------------------------------------------------------------------------------------------------- -VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, - const Valentina::Sources &typeCreation, const quint32 &idTool, QObject *qoParent, - QGraphicsItem *parent) +/** + * @brief VNodePoint constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idPoint object id in containerPoint. + * @param typeCreation way we create this tool. + * @param idTool tool id. + * @param qoParent QObject parent + * @param parent parent object. + */ +VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Source &typeCreation, + const quint32 &idTool, QObject *qoParent, QGraphicsItem *parent) :VAbstractNode(doc, data, id, idPoint, idTool, qoParent), QGraphicsEllipseItem(parent), radius(0), namePoint(nullptr), lineName(nullptr) { @@ -51,7 +62,7 @@ VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPo this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setAcceptHoverEvents(true); RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -62,11 +73,21 @@ VNodePoint::VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPo } //--------------------------------------------------------------------------------------------------------------------- -void VNodePoint::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, - const Document::Documents &parse, const Valentina::Sources &typeCreation, const quint32 &idTool, - QObject *parent) +/** + * @brief Create help create tool. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idPoint object id in containerPoint. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @param idTool tool id. + * @param parent QObject parent + */ +void VNodePoint::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Document &parse, + const Source &typeCreation, const quint32 &idTool, QObject *parent) { - VAbstractTool::AddRecord(id, Valentina::NodePoint, doc); + VAbstractTool::AddRecord(id, Tool::NodePoint, doc); if (parse == Document::FullParse) { //TODO Need create garbage collector and remove all nodes, what we don't use. @@ -93,6 +114,9 @@ void VNodePoint::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idP } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DeleteNode delete node from detail. + */ void VNodePoint::DeleteNode() { VAbstractNode::DeleteNode(); @@ -100,12 +124,28 @@ void VNodePoint::DeleteNode() } //--------------------------------------------------------------------------------------------------------------------- +void VNodePoint::RestoreNode() +{ + if (this->isVisible() == false) + { + VAbstractNode::RestoreNode(); + this->setVisible(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VNodePoint::FullUpdateFromFile() { RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VNodePoint::AddToFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -125,6 +165,9 @@ void VNodePoint::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VNodePoint::RefreshDataInFile() { const VPointF *point = VAbstractTool::data.GeometricObject(id); @@ -142,16 +185,24 @@ void VNodePoint::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { - emit ChoosedTool(id, Valentina::Point); + emit ChoosedTool(id, SceneObject::Point); } QGraphicsItem::mouseReleaseEvent(event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ void VNodePoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -159,6 +210,10 @@ void VNodePoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ void VNodePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -166,6 +221,10 @@ void VNodePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief NameChangePosition label change position. + * @param pos new position. + */ void VNodePoint::NameChangePosition(const QPointF &pos) { VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject(id)); @@ -178,6 +237,11 @@ void VNodePoint::NameChangePosition(const QPointF &pos) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateNamePosition update label position in file. + * @param mx label bias x axis. + * @param my label bias y axis. + */ void VNodePoint::UpdateNamePosition(qreal mx, qreal my) { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -190,6 +254,10 @@ void VNodePoint::UpdateNamePosition(qreal mx, qreal my) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshPointGeometry refresh point on scene. + * @param point point position. + */ void VNodePoint::RefreshPointGeometry(const VPointF &point) { QRectF rec = QRectF(0, 0, radius*2, radius*2); @@ -207,6 +275,9 @@ void VNodePoint::RefreshPointGeometry(const VPointF &point) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshLine refresh label line on scene. + */ void VNodePoint::RefreshLine() { QRectF nameRec = namePoint->sceneBoundingRect(); diff --git a/src/app/tools/nodeDetails/vnodepoint.h b/src/app/tools/nodeDetails/vnodepoint.h index e91de3354..2e3a7f535 100644 --- a/src/app/tools/nodeDetails/vnodepoint.h +++ b/src/app/tools/nodeDetails/vnodepoint.h @@ -30,7 +30,13 @@ #define VNODEPOINT_H #include "vabstractnode.h" -#include "../../widgets/vgraphicssimpletextitem.h" +#include "../../xml/vpattern.h" +#include + +class VPointF; +class VGraphicsSimpleTextItem; +class QGraphicsLineItem; +class QGraphicsItem; /** * @brief The VNodePoint class point detail node. @@ -39,98 +45,36 @@ class VNodePoint: public VAbstractNode, public QGraphicsEllipseItem { Q_OBJECT public: - /** - * @brief VNodePoint constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param idPoint object id in containerPoint. - * @param typeCreation way we create this tool. - * @param idTool tool id. - * @param qoParent QObject parent - * @param parent parent object. - */ - VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Valentina::Sources &typeCreation, + + VNodePoint(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Source &typeCreation, const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr ); - /** - * @brief Create help create tool. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param idPoint object id in containerPoint. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - * @param idTool tool id. - * @param parent QObject parent - */ - static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Document::Documents &parse, - const Valentina::Sources &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr); + + static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Document &parse, + const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr); static const QString TagName; static const QString ToolType; - /** - * @brief DeleteNode delete node from detail. - */ virtual void DeleteNode(); + virtual void RestoreNode(); public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); - /** - * @brief NameChangePosition label change position. - * @param pos new position. - */ void NameChangePosition(const QPointF &pos); protected: - /** - * @brief radius radius circle. - */ + /** @brief radius radius circle. */ qreal radius; - /** - * @brief namePoint label name. - */ + + /** @brief namePoint label name. */ VGraphicsSimpleTextItem *namePoint; - /** - * @brief lineName pointer to label line. - */ + + /** @brief lineName pointer to label line. */ QGraphicsLineItem *lineName; - /** - * @brief AddToFile add tag with informations about tool into file. - */ + virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief mouseReleaseEvent handle mouse release events. - * @param event mouse release event. - */ virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief UpdateNamePosition update label position in file. - * @param mx label bias x axis. - * @param my label bias y axis. - */ virtual void UpdateNamePosition(qreal mx, qreal my); - /** - * @brief RefreshPointGeometry refresh point on scene. - * @param point point position. - */ virtual void RefreshPointGeometry(const VPointF &point); - /** - * @brief RefreshLine refresh label line on scene. - */ void RefreshLine(); private: Q_DISABLE_COPY(VNodePoint) diff --git a/src/app/tools/nodeDetails/vnodespline.cpp b/src/app/tools/nodeDetails/vnodespline.cpp index ef4765273..3ed4d22f2 100644 --- a/src/app/tools/nodeDetails/vnodespline.cpp +++ b/src/app/tools/nodeDetails/vnodespline.cpp @@ -28,22 +28,33 @@ #include "vnodespline.h" -#include #include "../../widgets/vapplication.h" +#include "../../geometry/vspline.h" const QString VNodeSpline::TagName = QStringLiteral("spline"); const QString VNodeSpline::ToolType = QStringLiteral("modelingSpline"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VNodeSpline constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idSpline object id in containerSpline. + * @param typeCreation way we create this tool. + * @param idTool id node. + * @param qoParent QObject parent. + * @param parent QGraphicsItem parent. + */ VNodeSpline::VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, - const Valentina::Sources &typeCreation, const quint32 &idTool, QObject *qoParent, + const Source &typeCreation, const quint32 &idTool, QObject *qoParent, QGraphicsItem * parent) :VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent) { RefreshGeometry(); this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine()))); - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -54,11 +65,21 @@ VNodeSpline::VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 id } //--------------------------------------------------------------------------------------------------------------------- -VNodeSpline *VNodeSpline::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, - const Document::Documents &parse, const Valentina::Sources &typeCreation, - const quint32 &idTool, QObject *parent) +/** + * @brief Create help create tool. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idSpline object id in containerSpline. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @param idTool id node. + * @return pointer to node. + */ +VNodeSpline *VNodeSpline::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse, + const Source &typeCreation, const quint32 &idTool, QObject *parent) { - VAbstractTool::AddRecord(id, Valentina::NodeSpline, doc); + VAbstractTool::AddRecord(id, Tool::NodeSpline, doc); VNodeSpline *spl = nullptr; if (parse == Document::FullParse) { @@ -85,6 +106,9 @@ VNodeSpline *VNodeSpline::Create(VPattern *doc, VContainer *data, quint32 id, qu } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DeleteNode delete node from detail. + */ void VNodeSpline::DeleteNode() { VAbstractNode::DeleteNode(); @@ -92,12 +116,28 @@ void VNodeSpline::DeleteNode() } //--------------------------------------------------------------------------------------------------------------------- +void VNodeSpline::RestoreNode() +{ + if (this->isVisible() == false) + { + VAbstractNode::RestoreNode(); + this->setVisible(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VNodeSpline::FullUpdateFromFile() { RefreshGeometry(); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VNodeSpline::AddToFile() { QDomElement domElement = doc->createElement(TagName); @@ -114,6 +154,9 @@ void VNodeSpline::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VNodeSpline::RefreshDataInFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -128,16 +171,24 @@ void VNodeSpline::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ void VNodeSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { - emit ChoosedTool(id, Valentina::Spline); + emit ChoosedTool(id, SceneObject::Spline); } QGraphicsItem::mouseReleaseEvent(event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ void VNodeSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -145,6 +196,10 @@ void VNodeSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -152,6 +207,9 @@ void VNodeSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ void VNodeSpline::RefreshGeometry() { const VSpline *spl = VAbstractTool::data.GeometricObject(id); diff --git a/src/app/tools/nodeDetails/vnodespline.h b/src/app/tools/nodeDetails/vnodespline.h index 39fa1ac38..0492d9381 100644 --- a/src/app/tools/nodeDetails/vnodespline.h +++ b/src/app/tools/nodeDetails/vnodespline.h @@ -31,6 +31,7 @@ #include "vabstractnode.h" #include +#include "../../xml/vpattern.h" /** * @brief The VNodeSpline class spline detail node. @@ -39,72 +40,24 @@ class VNodeSpline:public VAbstractNode, public QGraphicsPathItem { Q_OBJECT public: - /** - * @brief VNodeSpline constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param idSpline object id in containerSpline. - * @param typeCreation way we create this tool. - * @param idTool id node. - * @param qoParent QObject parent. - * @param parent QGraphicsItem parent. - */ - VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Valentina::Sources &typeCreation, + VNodeSpline(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Source &typeCreation, const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr); - /** - * @brief Create help create tool. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param idSpline object id in containerSpline. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - * @param idTool id node. - * @return pointer to node. - */ - static VNodeSpline *Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, - const Document::Documents &parse, const Valentina::Sources &typeCreation, - const quint32 &idTool = 0, QObject *parent = nullptr); + + static VNodeSpline *Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse, + const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr); static const QString TagName; static const QString ToolType; - /** - * @brief DeleteNode delete node from detail. - */ virtual void DeleteNode(); + virtual void RestoreNode(); public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile (); protected: - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile (); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief mouseReleaseEvent handle mouse release events. - * @param event mouse release event. - */ virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); private: - /** - * @brief RefreshGeometry refresh item on scene. - */ void RefreshGeometry (); }; diff --git a/src/app/tools/nodeDetails/vnodesplinepath.cpp b/src/app/tools/nodeDetails/vnodesplinepath.cpp index 857a9177d..aea0047b6 100644 --- a/src/app/tools/nodeDetails/vnodesplinepath.cpp +++ b/src/app/tools/nodeDetails/vnodesplinepath.cpp @@ -28,22 +28,33 @@ #include "vnodesplinepath.h" -#include #include "../../widgets/vapplication.h" +#include "../../geometry/vsplinepath.h" const QString VNodeSplinePath::TagName = QStringLiteral("spline"); const QString VNodeSplinePath::ToolType = QStringLiteral("modelingPath"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VNodeSplinePath constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idSpline object id in containerSpline. + * @param typeCreation way we create this tool. + * @param idTool tool id. + * @param qoParent QObject parent. + * @param parent parent object. + */ VNodeSplinePath::VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, - const Valentina::Sources &typeCreation, const quint32 &idTool, QObject *qoParent, + const Source &typeCreation, const quint32 &idTool, QObject *qoParent, QGraphicsItem * parent) :VAbstractNode(doc, data, id, idSpline, idTool, qoParent), QGraphicsPathItem(parent) { RefreshGeometry(); this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine()))); - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -54,11 +65,21 @@ VNodeSplinePath::VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, qu } //--------------------------------------------------------------------------------------------------------------------- -void VNodeSplinePath::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, - const Document::Documents &parse, const Valentina::Sources &typeCreation, - const quint32 &idTool, QObject *parent) +/** + * @brief Create help create tool. + * @param doc dom document container. + * @param data container with variables. + * @param id object id in container. + * @param idSpline object id in containerSpline. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + * @param idTool tool id. + * @param parent QObject parent. + */ +void VNodeSplinePath::Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse, + const Source &typeCreation, const quint32 &idTool, QObject *parent) { - VAbstractTool::AddRecord(id, Valentina::NodeSplinePath, doc); + VAbstractTool::AddRecord(id, Tool::NodeSplinePath, doc); if (parse == Document::FullParse) { VNodeSplinePath *splPath = new VNodeSplinePath(doc, data, id, idSpline, typeCreation, idTool, parent); @@ -88,6 +109,9 @@ void VNodeSplinePath::Create(VPattern *doc, VContainer *data, quint32 id, quint3 } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DeleteNode delete node from detail. + */ void VNodeSplinePath::DeleteNode() { VAbstractNode::DeleteNode(); @@ -95,12 +119,28 @@ void VNodeSplinePath::DeleteNode() } //--------------------------------------------------------------------------------------------------------------------- +void VNodeSplinePath::RestoreNode() +{ + if (this->isVisible() == false) + { + VAbstractNode::RestoreNode(); + this->setVisible(true); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VNodeSplinePath::FullUpdateFromFile() { RefreshGeometry(); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VNodeSplinePath::AddToFile() { QDomElement domElement = doc->createElement(TagName); @@ -117,6 +157,9 @@ void VNodeSplinePath::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VNodeSplinePath::RefreshDataInFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -131,16 +174,24 @@ void VNodeSplinePath::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ void VNodeSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { - emit ChoosedTool(id, Valentina::SplinePath); + emit ChoosedTool(id, SceneObject::SplinePath); } QGraphicsItem::mouseReleaseEvent(event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ void VNodeSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -148,6 +199,10 @@ void VNodeSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -155,6 +210,9 @@ void VNodeSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshGeometry refresh item on scene. + */ void VNodeSplinePath::RefreshGeometry() { const VSplinePath *splPath = VAbstractTool::data.GeometricObject(id); diff --git a/src/app/tools/nodeDetails/vnodesplinepath.h b/src/app/tools/nodeDetails/vnodesplinepath.h index 3518aef72..91026e642 100644 --- a/src/app/tools/nodeDetails/vnodesplinepath.h +++ b/src/app/tools/nodeDetails/vnodesplinepath.h @@ -31,6 +31,7 @@ #include "vabstractnode.h" #include +#include "../../xml/vpattern.h" /** * @brief The VNodeSplinePath class spline path detail node. @@ -39,72 +40,23 @@ class VNodeSplinePath : public VAbstractNode, public QGraphicsPathItem { Q_OBJECT public: - /** - * @brief VNodeSplinePath constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param idSpline object id in containerSpline. - * @param typeCreation way we create this tool. - * @param idTool tool id. - * @param qoParent QObject parent. - * @param parent parent object. - */ - VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, - const Valentina::Sources &typeCreation, const quint32 &idTool = 0, - QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr); - /** - * @brief Create help create tool. - * @param doc dom document container. - * @param data container with variables. - * @param id object id in container. - * @param idSpline object id in containerSpline. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - * @param idTool tool id. - * @param parent QObject parent. - */ - static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document::Documents &parse, - const Valentina::Sources &typeCreation, const quint32 &idTool = 0, QObject *parent = 0); + VNodeSplinePath(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Source &typeCreation, + const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr); + static void Create(VPattern *doc, VContainer *data, quint32 id, quint32 idSpline, const Document &parse, + const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = 0); static const QString TagName; static const QString ToolType; - /** - * @brief DeleteNode delete node from detail. - */ virtual void DeleteNode(); + virtual void RestoreNode(); public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile(); protected: - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief mouseReleaseEvent handle mouse release events. - * @param event mouse release event. - */ virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); private: - /** - * @brief RefreshGeometry refresh item on scene. - */ void RefreshGeometry(); }; diff --git a/src/app/tools/vabstracttool.cpp b/src/app/tools/vabstracttool.cpp index 23880daf3..2c5fbc37a 100644 --- a/src/app/tools/vabstracttool.cpp +++ b/src/app/tools/vabstracttool.cpp @@ -27,7 +27,11 @@ *************************************************************************/ #include "vabstracttool.h" +#include "../xml/vpattern.h" #include +#include +#include "../undocommands/deltool.h" +#include "../widgets/vapplication.h" const QString VAbstractTool::AttrType = QStringLiteral("type"); const QString VAbstractTool::AttrMx = QStringLiteral("mx"); @@ -71,16 +75,28 @@ const QString VAbstractTool::TypeLineDashDotLine = QStringLiteral("dashDotLin const QString VAbstractTool::TypeLineDashDotDotLine = QStringLiteral("dashDotDotLine"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @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) { SCASSERT(doc != nullptr); connect(this, &VAbstractTool::toolhaveChange, this->doc, &VPattern::haveLiteChange); connect(this->doc, &VPattern::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile); - connect(this, &VAbstractTool::FullUpdateTree, this->doc, &VPattern::FullUpdateTree); + connect(this, &VAbstractTool::LiteUpdateTree, this->doc, &VPattern::LiteParseTree); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view. + * @param sc scene. + * @param view view. + */ void VAbstractTool::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view) { QRectF rect = sc->itemsBoundingRect(); @@ -110,6 +126,12 @@ void VAbstractTool::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LineIntersectRect find point intersection line and rect. + * @param rec rect. + * @param line line. + * @return point intersection. + */ QPointF VAbstractTool::LineIntersectRect(QRectF rec, QLineF line) { qreal x1, y1, x2, y2; @@ -140,6 +162,15 @@ QPointF VAbstractTool::LineIntersectRect(QRectF rec, QLineF line) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LineIntersectCircle find point intersection line and circle. + * @param center arc center. + * @param radius arc radius. + * @param line line + * @param p1 first intersection point. + * @param p2 second intersection point. + * @return 0 - intersection doesn't exist, 1 - one intersection point, 2 - two intersection points. + */ qint32 VAbstractTool::LineIntersectCircle(const QPointF ¢er, qreal radius, const QLineF &line, QPointF &p1, QPointF &p2) { @@ -176,6 +207,11 @@ qint32 VAbstractTool::LineIntersectCircle(const QPointF ¢er, qreal radius, c } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClosestPoint find point projection of point onto line. + * @param line line. + * @return point on line or extended line if origin size too small. + */ QPointF VAbstractTool::ClosestPoint(const QLineF &line, const QPointF &point) { qreal a = 0, b = 0, c = 0; @@ -202,21 +238,13 @@ QPointF VAbstractTool::addVector(const QPointF &p, const QPointF &p1, const QPoi } //--------------------------------------------------------------------------------------------------------------------- -void VAbstractTool::RemoveAllChild(QDomElement &domElement) +/** + * @brief DeleteTool full delete object form scene and file. + * @param tool tool + */ +void VAbstractTool::DeleteTool(bool ask) { - if ( domElement.hasChildNodes() ) - { - while ( domElement.childNodes().length() >= 1 ) - { - domElement.removeChild( domElement.firstChild() ); - } - } -} - -//--------------------------------------------------------------------------------------------------------------------- -void VAbstractTool::DeleteTool(QGraphicsItem *tool) -{ - if (_referens <= 1) + if (ask) { QMessageBox msgBox; msgBox.setText(tr("Confirm the deletion.")); @@ -228,43 +256,17 @@ void VAbstractTool::DeleteTool(QGraphicsItem *tool) { return; } - //remove from xml file - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - QDomNode element = domElement.parentNode(); - if (element.isNull() == false) - { - if (element.isElement()) - { - RemoveReferens();//deincrement referens - element.removeChild(domElement);//remove form file - QGraphicsScene *scene = tool->scene(); - if (scene != 0)//some tools haven't scene - { - scene->removeItem(tool);//remove form scene - } - doc->FullUpdateTree(); - emit toolhaveChange();//set enabled save button - } - else - { - qDebug()<<"parent isn't element"< + +class VPattern; +class QDomElement; +class QLineF; +class QPointF; +class QGraphicsScene; +class QGraphicsView; +class QGraphicsItem; +class QRectF; /** * @brief The VAbstractTool abstract class for all tools. @@ -40,58 +47,15 @@ class VAbstractTool: public VDataTool { Q_OBJECT public: - /** - * @brief VAbstractTool container. - * @param doc dom document container. - * @param data container with data. - * @param id object id in container. - * @param parent parent object. - */ VAbstractTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent = nullptr); virtual ~VAbstractTool(){} - /** - * @brief NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view. - * @param sc scene. - * @param view view. - */ static void NewSceneRect(QGraphicsScene *sc, QGraphicsView *view); - /** - * @brief LineIntersectRect find point intersection line and rect. - * @param rec rect. - * @param line line. - * @return point intersection. - */ static QPointF LineIntersectRect(QRectF rec, QLineF line); - /** - * @brief LineIntersectCircle find point intersection line and circle. - * @param center arc center. - * @param radius arc radius. - * @param line line - * @param p1 first intersection point. - * @param p2 second intersection point. - * @return 0 - intersection doesn't exist, 1 - one intersection point, 2 - two intersection points. - */ static qint32 LineIntersectCircle(const QPointF ¢er, qreal radius, const QLineF &line, QPointF &p1, QPointF &p2); - /** - * @brief ClosestPoint find point projection of point onto line. - * @param line line. - * @return point on line or extended line if origin size too small. - */ static QPointF ClosestPoint(const QLineF &line, const QPointF &point); static QPointF addVector (const QPointF &p, const QPointF &p1, const QPointF &p2, qreal k); - /** - * @brief getId return object id. - * @return id. - */ quint32 getId() const; - /** - * @brief LineCoefficients coefficient for equation of segment. Segment equestion ax+by+c=0. - * @param line line - * @param a a value - * @param b b value - * @param c c value - */ static void LineCoefficients(const QLineF &line, qreal *a, qreal *b, qreal *c); static const QString AttrType; static const QString AttrMx; @@ -132,18 +96,8 @@ public: static const QString TypeLineDotLine; static const QString TypeLineDashDotLine; static const QString TypeLineDashDotDotLine; - /** - * @brief Styles return list of all line styles. - * @return list of all line styles. - */ static const QStringList Styles(); - /** - * @brief AddRecord add record about tool in history. - * @param id object id in container - * @param toolType tool type - * @param doc dom document container - */ - static void AddRecord(const quint32 id, const Valentina::Tools &toolType, VPattern *doc); + static void AddRecord(const quint32 id, const Tool &toolType, VPattern *doc); public slots: /** * @brief FullUpdateFromFile update tool data form file. @@ -159,31 +113,25 @@ signals: * @param id object id in container. * @param type type of scene object. */ - void ChoosedTool(quint32 id, Valentina::Scenes type); + void ChoosedTool(quint32 id, SceneObject type); /** * @brief FullUpdateTree emit if need reparse pattern file. */ - void FullUpdateTree(); + void LiteUpdateTree(); protected: - /** - * @brief doc dom document container - */ + /** @brief doc dom document container */ VPattern *doc; - /** - * @brief id object id. - */ + + /** @brief id object id. */ const quint32 id; - /** - * @brief baseColor base color for tool. - */ + + /** @brief baseColor base color for tool. */ Qt::GlobalColor baseColor; - /** - * @brief currentColor current tool color. - */ + + /** @brief currentColor current tool color. */ Qt::GlobalColor currentColor; - /** - * @brief typeLine line type. - */ + + /** @brief typeLine line type. */ QString typeLine; /** * @brief AddToFile add tag with informations about tool into file. @@ -193,39 +141,32 @@ protected: * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. */ virtual void RefreshDataInFile()=0; - /** - * @brief getData return pointer to data container. - * @return container. - */ const VContainer *getData() const; /** * @brief RemoveReferens decrement value of reference. */ virtual void RemoveReferens(){} - /** - * @brief RemoveAllChild remove all child from file. - * @param domElement tag in xml tree. - */ - void RemoveAllChild(QDomElement &domElement); - /** - * @brief DeleteTool full delete object form scene and file. - * @param tool tool - */ - virtual void DeleteTool(QGraphicsItem *tool); - /** - * @brief LineStyle return pen style for current line style. - * @return pen style. - */ + virtual void DeleteTool(bool ask = true); Qt::PenStyle LineStyle(); private: Q_DISABLE_COPY(VAbstractTool) }; +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getId return object id. + * @return id. + */ inline quint32 VAbstractTool::getId() const { return id; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getData return pointer to data container. + * @return container. + */ inline const VContainer *VAbstractTool::getData() const { return &data; diff --git a/src/app/tools/vdatatool.cpp b/src/app/tools/vdatatool.cpp index 0454badb5..f7dbff9cf 100644 --- a/src/app/tools/vdatatool.cpp +++ b/src/app/tools/vdatatool.cpp @@ -29,20 +29,33 @@ #include "vdatatool.h" //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VDataTool constructor. + * @param data container with variables + * @param parent parent object + */ VDataTool::VDataTool(VContainer *data, QObject *parent): QObject(parent), data(*data), _referens(1) { SCASSERT(data != nullptr); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief operator = assignment operator. + * @param tool tool + * @return tool + */ VDataTool &VDataTool::operator =(const VDataTool &tool) { data = tool.getData(); _referens = tool.referens(); - return *this; + return *this; } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief decrementReferens decrement referens. + */ void VDataTool::decrementReferens() { if (_referens > 0) diff --git a/src/app/tools/vdatatool.h b/src/app/tools/vdatatool.h index ceb185b34..887a74fd2 100644 --- a/src/app/tools/vdatatool.h +++ b/src/app/tools/vdatatool.h @@ -31,6 +31,8 @@ #include "../container/vcontainer.h" +class QObject; + //We need QObject class because we use qobject_cast. /** * @brief The VDataTool class need for getting access to data container of tool. @@ -39,68 +41,56 @@ class VDataTool : public QObject { Q_OBJECT public: - /** - * @brief VDataTool constructor. - * @param data container with variables - * @param parent parent object - */ VDataTool(VContainer *data, QObject *parent = nullptr); virtual ~VDataTool(){} - /** - * @brief operator = assignment operator. - * @param tool tool - * @return tool - */ VDataTool &operator= (const VDataTool &tool); - /** - * @brief getData return data container. - * @return container. - */ VContainer getData() const; - /** - * @brief setData set data container. - * @param value container. - */ void setData(const VContainer *value); - /** - * @brief referens return count of referens. - * @return count count of referens. - */ virtual quint32 referens() const; - /** - * @brief incrementReferens increment referens. - */ virtual void incrementReferens(); - /** - * @brief decrementReferens decrement referens. - */ virtual void decrementReferens(); protected: - /** - * @brief data container with data - */ + /** @brief data container with data */ VContainer data; - /** - * @brief _referens keep count tools what use this tool. If value more than 1 you can't delete tool. - */ + + /** @brief _referens keep count tools what use this tool. If value more than 1 you can't delete tool. */ quint32 _referens; }; +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getData return data container. + * @return container. + */ inline VContainer VDataTool::getData() const { return data; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setData set data container. + * @param value container. + */ inline void VDataTool::setData(const VContainer *value) { data = *value; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief referens return count of referens. + * @return count count of referens. + */ inline quint32 VDataTool::referens() const { return _referens; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief incrementReferens increment referens. + */ inline void VDataTool::incrementReferens() { ++_referens; diff --git a/src/app/tools/vtooldetail.cpp b/src/app/tools/vtooldetail.cpp index f165a5165..e42edb6b7 100644 --- a/src/app/tools/vtooldetail.cpp +++ b/src/app/tools/vtooldetail.cpp @@ -28,11 +28,21 @@ #include "vtooldetail.h" #include "nodeDetails/nodedetails.h" +#include "../geometry/varc.h" +#include "../geometry/vsplinepath.h" #include "../geometry/vequidistant.h" +#include "../widgets/vmaingraphicsscene.h" +#include "../dialogs/tools/dialogtool.h" +#include "../dialogs/tools/dialogdetail.h" #include #include #include #include +#include +#include "../undocommands/savedetailoptions.h" +#include "../undocommands/movedetail.h" +#include "../undocommands/adddet.h" +#include "../undocommands/deletedetail.h" const QString VToolDetail::TagName = QStringLiteral("detail"); const QString VToolDetail::TagNode = QStringLiteral("node"); @@ -52,42 +62,75 @@ const QString VToolDetail::NodeSpline = QStringLiteral("NodeSpline"); const QString VToolDetail::NodeSplinePath = QStringLiteral("NodeSplinePath"); //--------------------------------------------------------------------------------------------------------------------- -VToolDetail::VToolDetail(VPattern *doc, VContainer *data, const quint32 &id, const Valentina::Sources &typeCreation, +/** + * @brief VToolDetail constructor. + * @param doc dom document container + * @param data container with variables + * @param id object id in container + * @param typeCreation way we create this tool. + * @param scene pointer to scene. + * @param parent parent object + */ +VToolDetail::VToolDetail(VPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation, VMainGraphicsScene *scene, QGraphicsItem *parent) :VAbstractTool(doc, data, id), QGraphicsPathItem(parent), dialog(nullptr), sceneDetails(scene) { VDetail detail = data->GetDetail(id); for (ptrdiff_t i = 0; i< detail.CountNode(); ++i) { - switch (detail[i].getTypeTool()) + switch (detail.at(i).getTypeTool()) { - case (Valentina::NodePoint): - InitTool(scene, detail[i]); + case (Tool::NodePoint): + InitTool(scene, detail.at(i)); break; - case (Valentina::NodeArc): - InitTool(scene, detail[i]); + case (Tool::NodeArc): + InitTool(scene, detail.at(i)); break; - case (Valentina::NodeSpline): - InitTool(scene, detail[i]); + case (Tool::NodeSpline): + InitTool(scene, detail.at(i)); break; - case (Valentina::NodeSplinePath): - InitTool(scene, detail[i]); + case (Tool::NodeSplinePath): + InitTool(scene, detail.at(i)); break; + case (Tool::ArrowTool): + case (Tool::SinglePointTool): + case (Tool::EndLineTool): + case (Tool::LineTool): + case (Tool::AlongLineTool): + case (Tool::ShoulderPointTool): + case (Tool::NormalTool): + case (Tool::BisectorTool): + case (Tool::LineIntersectTool): + case (Tool::SplineTool): + case (Tool::CutSplineTool): + case (Tool::CutArcTool): + case (Tool::ArcTool): + case (Tool::SplinePathTool): + case (Tool::CutSplinePathTool): + case (Tool::PointOfContact): + case (Tool::DetailTool): + case (Tool::Height): + case (Tool::Triangle): + case (Tool::PointOfIntersection): + case (Tool::UnionDetails): default: qDebug()<<"Get wrong tool type. Ignore."; break; } - doc->IncrementReferens(detail[i].getId()); + doc->IncrementReferens(detail.at(i).getId()); } this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true); RefreshGeometry(); - this->setPos(detail.getMx(), detail.getMy()); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true); - if (typeCreation == Valentina::FromGui || typeCreation == Valentina::FromTool) + if (typeCreation == Source::FromGui || typeCreation == Source::FromTool) { - AddToFile(); + AddToFile(); + if (typeCreation != Source::FromTool) + { + qApp->getUndoStack()->endMacro(); + } } } @@ -98,6 +141,9 @@ VToolDetail::~VToolDetail() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setDialog set dialog when user want change tool option. + */ void VToolDetail::setDialog() { SCASSERT(dialog != nullptr); @@ -108,6 +154,13 @@ void VToolDetail::setDialog() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @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); @@ -115,52 +168,85 @@ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern 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[i].getTypeTool()) + switch (detail.at(i).getTypeTool()) { - case (Valentina::NodePoint): + case (Tool::NodePoint): { - id = CreateNode(data, detail[i].getId()); - VNodePoint::Create(doc, data, id, detail[i].getId(), Document::FullParse, Valentina::FromGui); + id = CreateNode(data, detail.at(i).getId()); + VNodePoint::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Source::FromGui); } break; - case (Valentina::NodeArc): + case (Tool::NodeArc): { - id = CreateNode(data, detail[i].getId()); - VNodeArc::Create(doc, data, id, detail[i].getId(), Document::FullParse, Valentina::FromGui); + id = CreateNode(data, detail.at(i).getId()); + VNodeArc::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Source::FromGui); } break; - case (Valentina::NodeSpline): + case (Tool::NodeSpline): { - id = CreateNode(data, detail[i].getId()); - VNodeSpline::Create(doc, data, id, detail[i].getId(), Document::FullParse, Valentina::FromGui); + id = CreateNode(data, detail.at(i).getId()); + VNodeSpline::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Source::FromGui); } break; - case (Valentina::NodeSplinePath): + case (Tool::NodeSplinePath): { - id = CreateNode(data, detail[i].getId()); - VNodeSplinePath::Create(doc, data, id, detail[i].getId(), Document::FullParse, Valentina::FromGui); + id = CreateNode(data, detail.at(i).getId()); + VNodeSplinePath::Create(doc, data, id, detail.at(i).getId(), Document::FullParse, Source::FromGui); } break; + case (Tool::ArrowTool): + case (Tool::SinglePointTool): + case (Tool::EndLineTool): + case (Tool::LineTool): + case (Tool::AlongLineTool): + case (Tool::ShoulderPointTool): + case (Tool::NormalTool): + case (Tool::BisectorTool): + case (Tool::LineIntersectTool): + case (Tool::SplineTool): + case (Tool::CutSplineTool): + case (Tool::CutArcTool): + case (Tool::ArcTool): + case (Tool::SplinePathTool): + case (Tool::CutSplinePathTool): + case (Tool::PointOfContact): + case (Tool::DetailTool): + case (Tool::Height): + case (Tool::Triangle): + case (Tool::PointOfIntersection): + case (Tool::UnionDetails): default: qDebug()<<"May be wrong tool type!!! Ignoring."<AddDetail(newDetail); } @@ -172,7 +258,7 @@ void VToolDetail::Create(const quint32 &_id, const VDetail &newDetail, VMainGrap doc->UpdateToolData(id, data); } } - VAbstractTool::AddRecord(id, Valentina::DetailTool, doc); + VAbstractTool::AddRecord(id, Tool::DetailTool, doc); if (parse == Document::FullParse) { VToolDetail *detail = new VToolDetail(doc, data, id, typeCreation, scene); @@ -184,58 +270,50 @@ void VToolDetail::Create(const quint32 &_id, const VDetail &newDetail, VMainGrap } //--------------------------------------------------------------------------------------------------------------------- -void VToolDetail::Remove() +/** + * @brief Remove full delete detail. + */ +void VToolDetail::Remove(bool ask) { - DeleteTool(this); + DeleteTool(ask); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromFile update tool data form file. + */ void VToolDetail::FullUpdateFromFile() { RefreshGeometry(); } //--------------------------------------------------------------------------------------------------------------------- -void VToolDetail::FullUpdateFromGui(int result) +/** + * @brief FullUpdateFromGuiOk refresh tool data after change in options. + * @param result keep result working dialog. + */ +void VToolDetail::FullUpdateFromGuiOk(int result) { if (result == QDialog::Accepted) { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - SCASSERT(dialog != nullptr); - DialogDetail *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr); - VDetail det = dialogTool->getDetails(); - doc->SetAttribute(domElement, AttrName, det.getName()); - doc->SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSeamAllowance())); - doc->SetAttribute(domElement, AttrClosed, QString().setNum(det.getClosed())); - doc->SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth())); - RemoveAllChild(domElement); - for (ptrdiff_t i = 0; i < det.CountNode(); ++i) - { - AddNode(domElement, det[i]); - } - VDetail detail = VAbstractTool::data.GetDetail(id); - QList list = detail.Missing(det); - QHash* tools = doc->getTools(); - if (list.size()>0) - { - for (qint32 i = 0; i < list.size(); ++i) - { - VAbstractNode *node = qobject_cast(tools->value(list[i])); - node->DeleteNode(); - } - } - emit FullUpdateTree(); - emit toolhaveChange(); - } + SCASSERT(dialog != nullptr); + DialogDetail *dialogTool = qobject_cast(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 = 0; + dialog = nullptr; } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolDetail::AddToFile() { VDetail detail = VAbstractTool::data.GetDetail(id); @@ -251,18 +329,18 @@ void VToolDetail::AddToFile() for (ptrdiff_t i = 0; i < detail.CountNode(); ++i) { - AddNode(domElement, detail.at(i)); + AddNode(doc, domElement, detail.at(i)); } - QDomElement element; - bool ok = doc->GetActivNodeElement(VPattern::TagDetails, element); - if (ok) - { - element.appendChild(domElement); - } + AddDet *addDet = new AddDet(domElement, doc); + connect(addDet, &AddDet::NeedFullParsing, doc, &VPattern::NeedFullParsing); + qApp->getUndoStack()->push(addDet); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolDetail::RefreshDataInFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -273,33 +351,31 @@ void VToolDetail::RefreshDataInFile() doc->SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSeamAllowance())); doc->SetAttribute(domElement, AttrClosed, QString().setNum(det.getClosed())); doc->SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth())); - RemoveAllChild(domElement); + doc->RemoveAllChild(domElement); for (ptrdiff_t i = 0; i < det.CountNode(); ++i) { - AddNode(domElement, det.at(i)); + AddNode(doc, domElement, det.at(i)); } } } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange handle detail change. + * @param change change + * @param value value + * @return new value. + */ QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) { if (change == ItemPositionHasChanged && scene()) { // value - this is new position. QPointF newPos = value.toPointF(); - //qDebug()<elementById(QString().setNum(id)); - if (domElement.isElement()) - { - doc->SetAttribute(domElement, AttrMx, QString().setNum(qApp->fromPixel(newPos.x()))); - doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(newPos.y()))); - QList list = this->scene()->views(); - VAbstractTool::NewSceneRect(this->scene(), list[0]); - - doc->haveLiteChange(); - } + MoveDetail *moveDet = new MoveDetail(doc, newPos.x(), newPos.y(), id, this->scene()); + connect(moveDet, &MoveDetail::NeedLiteParsing, doc, &VPattern::LiteParseTree); + qApp->getUndoStack()->push(moveDet); } if (change == QGraphicsItem::ItemSelectedChange) @@ -319,6 +395,10 @@ QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyReleaseEvent handle key release events. + * @param event key release event. + */ void VToolDetail::keyReleaseEvent(QKeyEvent *event) { switch (event->key()) @@ -333,16 +413,24 @@ void VToolDetail::keyReleaseEvent(QKeyEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ void VToolDetail::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { - emit ChoosedTool(id, Valentina::Detail); + emit ChoosedTool(id, SceneObject::Detail); } QGraphicsItem::mouseReleaseEvent(event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { QMenu menu; @@ -364,7 +452,7 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) dialog = new DialogDetail(getData(), list.first()); connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject, dialog, &DialogTool::ChoosedObject); - connect(dialog, &DialogTool::DialogClosed, this, &VToolDetail::FullUpdateFromGui); + connect(dialog, &DialogTool::DialogClosed, this, &VToolDetail::FullUpdateFromGuiOk); setDialog(); dialog->show(); } @@ -375,6 +463,9 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveReferens decrement value of reference. + */ void VToolDetail::RemoveReferens() { VDetail detail = VAbstractTool::data.GetDetail(id); @@ -385,7 +476,13 @@ void VToolDetail::RemoveReferens() } //--------------------------------------------------------------------------------------------------------------------- -void VToolDetail::AddNode(QDomElement &domElement, const VNodeDetail &node) +/** + * @brief AddNode add node to the file. + * @param dom document container + * @param domElement tag in xml tree. + * @param node node of detail. + */ +void VToolDetail::AddNode(VPattern *doc, QDomElement &domElement, const VNodeDetail &node) { QDomElement nod = doc->createElement(TagNode); @@ -402,18 +499,39 @@ void VToolDetail::AddNode(QDomElement &domElement, const VNodeDetail &node) } switch (node.getTypeTool()) { - case (Valentina::NodeArc): + case (Tool::NodeArc): doc->SetAttribute(nod, AttrType, NodeArc); break; - case (Valentina::NodePoint): + case (Tool::NodePoint): doc->SetAttribute(nod, AttrType, NodePoint); break; - case (Valentina::NodeSpline): + case (Tool::NodeSpline): doc->SetAttribute(nod, AttrType, NodeSpline); break; - case (Valentina::NodeSplinePath): + case (Tool::NodeSplinePath): doc->SetAttribute(nod, AttrType, NodeSplinePath); break; + case (Tool::ArrowTool): + case (Tool::SinglePointTool): + case (Tool::EndLineTool): + case (Tool::LineTool): + case (Tool::AlongLineTool): + case (Tool::ShoulderPointTool): + case (Tool::NormalTool): + case (Tool::BisectorTool): + case (Tool::LineIntersectTool): + case (Tool::SplineTool): + case (Tool::CutSplineTool): + case (Tool::CutArcTool): + case (Tool::ArcTool): + case (Tool::SplinePathTool): + case (Tool::CutSplinePathTool): + case (Tool::PointOfContact): + case (Tool::DetailTool): + case (Tool::Height): + case (Tool::Triangle): + case (Tool::PointOfIntersection): + case (Tool::UnionDetails): default: qDebug()<<"May be wrong tool type!!! Ignoring."<setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); QPainterPath path = VEquidistant().ContourPath(id, this->getData()); this->setPath(path); + + VDetail detail = VAbstractTool::data.GetDetail(id); + this->setPos(detail.getMx(), detail.getMy()); + this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); +} + +void VToolDetail::DeleteTool(bool ask) +{ + DeleteDetail *delDet = new DeleteDetail(doc, id); + if (ask) + { + QMessageBox msgBox; + msgBox.setText(tr("Confirm the deletion.")); + msgBox.setInformativeText(tr("Do you really want delete?")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.setIcon(QMessageBox::Question); + if (msgBox.exec() == QMessageBox::Cancel) + { + return; + } + /*Ugly hack. If UnionDetails delete detail no need emit FullParsing */ + connect(delDet, &DeleteDetail::NeedFullParsing, doc, &VPattern::NeedFullParsing); + } + qApp->getUndoStack()->push(delDet); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/vtooldetail.h b/src/app/tools/vtooldetail.h index c6e69eab3..b29b6c969 100644 --- a/src/app/tools/vtooldetail.h +++ b/src/app/tools/vtooldetail.h @@ -31,8 +31,11 @@ #include "vabstracttool.h" #include -#include "../dialogs/tools/dialogdetail.h" -#include "../dialogs/tools/dialogtool.h" +#include "../xml/vpattern.h" + +class VMainGraphicsScene; +class DialogTool; + /** * @brief The VToolDetail class for working with detail. */ @@ -40,21 +43,10 @@ class VToolDetail: public VAbstractTool, public QGraphicsPathItem { Q_OBJECT public: - /** - * @brief VToolDetail constructor. - * @param doc dom document container - * @param data container with variables - * @param id object id in container - * @param typeCreation way we create this tool. - * @param scene pointer to scene. - * @param parent parent object - */ - VToolDetail(VPattern *doc, VContainer *data, const quint32 &id, const Valentina::Sources &typeCreation, + VToolDetail(VPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation, VMainGraphicsScene *scene, QGraphicsItem * parent = nullptr); ~VToolDetail(); - /** - * @brief setDialog set dialog when user want change tool option. - */ + virtual void setDialog(); template /** @@ -67,31 +59,14 @@ public: { //We can't use exist object. Need create new. T *node = new T(*data->GeometricObject(id)); - node->setMode(Valentina::Modeling); + node->setMode(Draw::Modeling); return data->AddGObject(node); } - /** - * @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. - */ static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param newDetail detail what we want show. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ static void Create(const quint32 &_id, const VDetail &newDetail, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document::Documents &parse, - const Valentina::Sources &typeCreation); + VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); static const QString TagName; static const QString TagNode; static const QString AttrSupplement; @@ -105,75 +80,28 @@ public: static const QString NodePoint; static const QString NodeSpline; static const QString NodeSplinePath; - /** - * @brief Remove full delete detail. - */ - void Remove(); + void Remove(bool ask); + static void AddNode(VPattern *doc, QDomElement &domElement, const VNodeDetail &node); public slots: - /** - * @brief FullUpdateFromFile update tool data form file. - */ virtual void FullUpdateFromFile (); - /** - * @brief FullUpdateFromGui refresh tool data after change in options. - * @param result keep result working dialog. - */ - virtual void FullUpdateFromGui(int result); + virtual void FullUpdateFromGuiOk(int result); protected: - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile (); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); - /** - * @brief itemChange handle detail change. - * @param change change - * @param value value - * @return new value. - */ virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); - /** - * @brief mouseReleaseEvent handle mouse release events. - * @param event mouse release event. - */ virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); - /** - * @brief RemoveReferens decrement value of reference. - */ virtual void RemoveReferens(); - /** - * @brief keyReleaseEvent handle key release events. - * @param event key release event. - */ virtual void keyReleaseEvent(QKeyEvent * event); private: Q_DISABLE_COPY(VToolDetail) - /** - * @brief dialog dialog options. - */ + /** @brief dialog dialog options. */ DialogTool *dialog; - /** - * @brief sceneDetails pointer to the scene. - */ + + /** @brief sceneDetails pointer to the scene. */ VMainGraphicsScene *sceneDetails; - /** - * @brief RefreshGeometry refresh item on scene. - */ + void RefreshGeometry (); - /** - * @brief AddNode add node to the file. - * @param domElement tag in xml tree. - * @param node node of detail. - */ - void AddNode(QDomElement &domElement, const VNodeDetail &node); template /** * @brief InitTool initial node item on scene @@ -181,6 +109,7 @@ private: * @param node node of detail. */ void InitTool(VMainGraphicsScene *scene, const VNodeDetail &node); + virtual void DeleteTool(bool ask = true); }; #endif // VTOOLDETAIL_H diff --git a/src/app/tools/vtooluniondetails.cpp b/src/app/tools/vtooluniondetails.cpp index a0929a0b4..b9cd16e9c 100644 --- a/src/app/tools/vtooluniondetails.cpp +++ b/src/app/tools/vtooluniondetails.cpp @@ -29,6 +29,11 @@ #include "vtooluniondetails.h" #include "nodeDetails/nodedetails.h" #include "vtooldetail.h" +#include "../geometry/vpointf.h" +#include "../geometry/varc.h" +#include "../geometry/vsplinepath.h" +#include "../dialogs/tools/dialoguniondetails.h" +#include "../undocommands/adduniondetails.h" const QString VToolUnionDetails::TagName = QStringLiteral("tools"); const QString VToolUnionDetails::ToolType = QStringLiteral("unionDetails"); @@ -42,12 +47,24 @@ const QString VToolUnionDetails::NodeTypeContour = QStringLiteral("Contour"); const QString VToolUnionDetails::NodeTypeModeling = QStringLiteral("Modeling"); //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolUnionDetails costructor. + * @param doc dom document container. + * @param data dom document container. + * @param id object id in container. + * @param d1 first detail. + * @param d2 second detail. + * @param indexD1 index edge in first detail. + * @param indexD2 index edge in second detail. + * @param typeCreation way we create this tool. + * @param parent parent object. + */ VToolUnionDetails::VToolUnionDetails(VPattern *doc, VContainer *data, const quint32 &id, const VDetail &d1, const VDetail &d2, const quint32 &indexD1, const quint32 &indexD2, - const Valentina::Sources &typeCreation, QObject *parent) + const Source &typeCreation, QObject *parent) :VAbstractTool(doc, data, id, parent), d1(d1), d2(d2), indexD1(indexD1), indexD2(indexD2) { - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { AddToFile(); } @@ -58,6 +75,20 @@ VToolUnionDetails::VToolUnionDetails(VPattern *doc, VContainer *data, const quin } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToNewDetail create united detail adding one node per time. + * @param tool tool that make union. + * @param doc dom document container. + * @param data container with variables. + * @param newDetail united detail. + * @param det detail what we union. + * @param i index node in detail. + * @param idTool id tool union details. + * @param dx bias node x axis. + * @param dy bias node y axis. + * @param pRotate point rotation. + * @param angle angle rotation. + */ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer *data, VDetail &newDetail, const VDetail &det, const ptrdiff_t &i, const quint32 &idTool, const qreal &dx, const qreal &dy, const quint32 &pRotate, const qreal &angle) @@ -65,7 +96,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer quint32 id = 0, idObject = 0; switch (det.at(i).getTypeTool()) { - case (Valentina::NodePoint): + case (Tool::NodePoint): { if ( qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && (pRotate == 0)) { @@ -74,18 +105,18 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer else { VPointF *point = new VPointF(*data->GeometricObject(det.at(i).getId())); - point->setMode(Valentina::Modeling); + point->setMode(Draw::Modeling); BiasRotatePoint(point, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); idObject = data->AddGObject(point); VPointF *point1 = new VPointF(*point); - point1->setMode(Valentina::Modeling); + point1->setMode(Draw::Modeling); id = data->AddGObject(point1); - VNodePoint::Create(doc, data, id, idObject, Document::FullParse, Valentina::FromGui, idTool, tool); + VNodePoint::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool, tool); } } break; - case (Valentina::NodeArc): + case (Tool::NodeArc): { if (qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0) { @@ -104,24 +135,24 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer QLineF l1(center->toQPointF(), p1.toQPointF()); QLineF l2(center->toQPointF(), p2.toQPointF()); - center->setMode(Valentina::Modeling); + center->setMode(Draw::Modeling); quint32 idCenter = data->AddGObject(center); Q_UNUSED(idCenter); VArc *arc1 = new VArc(*center, arc->GetRadius(), arc->GetFormulaRadius(), l1.angle(), QString().setNum(l1.angle()), l2.angle(), QString().setNum(l2.angle())); - arc1->setMode(Valentina::Modeling); + arc1->setMode(Draw::Modeling); idObject = data->AddGObject(arc1); VArc *arc2 = new VArc(*arc1); - arc2->setMode(Valentina::Modeling); + arc2->setMode(Draw::Modeling); id = data->AddGObject(arc2); - VNodeArc::Create(doc, data, id, idObject, Document::FullParse, Valentina::FromGui, idTool, tool); + VNodeArc::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool, tool); } } break; - case (Valentina::NodeSpline): + case (Tool::NodeSpline): { if (qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0) { @@ -146,17 +177,17 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer //quint32 idP4 = data->AddGObject(p4); VSpline *spl = new VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline->GetKcurve(), 0, - Valentina::Modeling); + Draw::Modeling); idObject = data->AddGObject(spl); VSpline *spl1 = new VSpline(*spl); - spl1->setMode(Valentina::Modeling); + spl1->setMode(Draw::Modeling); id = data->AddGObject(spl1); - VNodeSpline::Create(doc, data, id, idObject, Document::FullParse, Valentina::FromGui, idTool, tool); + VNodeSpline::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool, tool); } } break; - case (Valentina::NodeSplinePath): + case (Tool::NodeSplinePath): { if (qFuzzyCompare(dx+1, 1) && qFuzzyCompare(dy+1, 1) && pRotate == 0) { @@ -165,7 +196,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer else { VSplinePath *path = new VSplinePath(); - path->setMode(Valentina::Modeling); + path->setMode(Draw::Modeling); const VSplinePath *splinePath = data->GeometricObject(det.at(i).getId()); qint32 k = splinePath->getMaxCountPoints(); for (qint32 i = 1; i <= splinePath->Count(); ++i) @@ -211,12 +242,33 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer idObject = data->AddGObject(path); VSplinePath *path1 = new VSplinePath(*path); - path1->setMode(Valentina::Modeling); + path1->setMode(Draw::Modeling); id = data->AddGObject(path1); - VNodeSplinePath::Create(doc, data, id, idObject, Document::FullParse, Valentina::FromGui, idTool, tool); + VNodeSplinePath::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool, tool); } } break; + case (Tool::ArrowTool): + case (Tool::SinglePointTool): + case (Tool::EndLineTool): + case (Tool::LineTool): + case (Tool::AlongLineTool): + case (Tool::ShoulderPointTool): + case (Tool::NormalTool): + case (Tool::BisectorTool): + case (Tool::LineIntersectTool): + case (Tool::SplineTool): + case (Tool::CutSplineTool): + case (Tool::CutArcTool): + case (Tool::ArcTool): + case (Tool::SplinePathTool): + case (Tool::CutSplinePathTool): + case (Tool::PointOfContact): + case (Tool::DetailTool): + case (Tool::Height): + case (Tool::Triangle): + case (Tool::PointOfIntersection): + case (Tool::UnionDetails): default: qDebug()<<"May be wrong tool type!!! Ignoring."<GeometricObject(det.at(i).getId())); - point->setMode(Valentina::Modeling); + point->setMode(Draw::Modeling); BiasRotatePoint(point, dx, dy, data->GeometricObject(pRotate)->toQPointF(), angle); ++idCount; data->UpdateGObject(idDetail+idCount, point); @@ -245,7 +309,7 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data, } } break; - case (Valentina::NodeArc): + case (Tool::NodeArc): { if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0) { @@ -261,11 +325,11 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data, QLineF l1(center->toQPointF(), p1.toQPointF()); QLineF l2(center->toQPointF(), p2.toQPointF()); ++idCount; - center->setMode(Valentina::Modeling); + center->setMode(Draw::Modeling); data->UpdateGObject(idDetail+idCount, center); VArc *arc1 = new VArc(*center, arc->GetRadius(), arc->GetFormulaRadius(), l1.angle(), QString().setNum(l1.angle()), l2.angle(), QString().setNum(l2.angle())); - arc1->setMode(Valentina::Modeling); + arc1->setMode(Draw::Modeling); ++idCount; data->UpdateGObject(idDetail+idCount, arc1); @@ -273,7 +337,7 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data, } } break; - case (Valentina::NodeSpline): + case (Tool::NodeSpline): { if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0) { @@ -296,7 +360,7 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data, data->UpdateGObject(idDetail+idCount, p4); VSpline *spl = new VSpline(*p1, p2.toQPointF(), p3.toQPointF(), *p4, spline->GetKcurve(), 0, - Valentina::Modeling); + Draw::Modeling); ++idCount; data->UpdateGObject(idDetail+idCount, spl); @@ -305,12 +369,12 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data, } } break; - case (Valentina::NodeSplinePath): + case (Tool::NodeSplinePath): { if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0) { VSplinePath *path = new VSplinePath(); - path->setMode(Valentina::Modeling); + path->setMode(Draw::Modeling); const VSplinePath *splinePath = data->GeometricObject(det.at(i).getId()); SCASSERT(splinePath != nullptr); qint32 k = splinePath->getMaxCountPoints(); @@ -366,6 +430,27 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data, } } break; + case (Tool::ArrowTool): + case (Tool::SinglePointTool): + case (Tool::EndLineTool): + case (Tool::LineTool): + case (Tool::AlongLineTool): + case (Tool::ShoulderPointTool): + case (Tool::NormalTool): + case (Tool::BisectorTool): + case (Tool::LineIntersectTool): + case (Tool::SplineTool): + case (Tool::CutSplineTool): + case (Tool::CutArcTool): + case (Tool::ArcTool): + case (Tool::SplinePathTool): + case (Tool::CutSplinePathTool): + case (Tool::PointOfContact): + case (Tool::DetailTool): + case (Tool::Height): + case (Tool::Triangle): + case (Tool::PointOfIntersection): + case (Tool::UnionDetails): default: qDebug()<<"May be wrong tool type!!! Ignoring."<setX(point->x()+dx); point->setY(point->y()+dy); @@ -385,6 +478,12 @@ void VToolUnionDetails::BiasRotatePoint(VPointF *point, const qreal &dx, const q } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool from GUI. + * @param dialog dialog. + * @param doc dom document container. + * @param data container with variables. + */ void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data) { SCASSERT(dialog != nullptr); @@ -394,19 +493,36 @@ void VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VP VDetail d2 = data->GetDetail(dialogTool->getD2()); quint32 indexD1 = static_cast(dialogTool->getIndexD1()); quint32 indexD2 = static_cast(dialogTool->getIndexD2()); + qApp->getUndoStack()->beginMacro("union details"); Create(0, d1, d2, dialogTool->getD1(), dialogTool->getD2(), indexD1, indexD2, scene, doc, data, Document::FullParse, - Valentina::FromGui); + Source::FromGui); + qApp->getUndoStack()->endMacro(); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Create help create tool. + * @param _id tool id, 0 if tool doesn't exist yet. + * @param d1 first detail. + * @param d2 second detail. + * @param d1id id first detail. + * @param d2id id second detail. + * @param indexD1 index edge in first detail. + * @param indexD2 index edge in second detail. + * @param scene pointer to scene. + * @param doc dom document container. + * @param data container with variables. + * @param parse parser file mode. + * @param typeCreation way we create this tool. + */ void VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDetail &d2, const quint32 &d1id, const quint32 &d2id, const quint32 &indexD1, const quint32 &indexD2, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document::Documents &parse, const Valentina::Sources &typeCreation) + const Document &parse, const Source &typeCreation) { VToolUnionDetails *unionDetails = 0; quint32 id = _id; - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { id = data->getNextId(); } @@ -417,7 +533,7 @@ void VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDeta doc->UpdateToolData(id, data); } } - VAbstractTool::AddRecord(id, Valentina::UnionDetails, doc); + VAbstractTool::AddRecord(id, Tool::UnionDetails, doc); if (parse == Document::FullParse) { //Scene doesn't show this tool, so doc will destroy this object. @@ -460,7 +576,7 @@ void VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDeta point2.toQPointF())); qint32 pointsD2 = 0; //Keeps count points second detail, what we already add. - if (typeCreation == Valentina::FromGui) + if (typeCreation == Source::FromGui) { qint32 j = 0, i = 0; VDetail newDetail; @@ -490,19 +606,22 @@ void VToolUnionDetails::Create(const quint32 _id, const VDetail &d1, const VDeta } while (i < d1.RemoveEdge(indexD1).CountNode()); newDetail.setName("Detail"); - VToolDetail::Create(0, newDetail, scene, doc, data, parse, Valentina::FromTool); + newDetail.setWidth(d1.getWidth()); + VToolDetail::Create(0, newDetail, scene, doc, data, parse, Source::FromTool); QHash* tools = doc->getTools(); SCASSERT(tools != nullptr); { VToolDetail *toolDet = qobject_cast(tools->value(d1id)); SCASSERT(toolDet != nullptr); - toolDet->Remove(); + bool ask = false; + toolDet->Remove(ask); } VToolDetail *toolDet = qobject_cast(tools->value(d2id)); SCASSERT(toolDet != nullptr); - toolDet->Remove(); + bool ask = false; + toolDet->Remove(ask); } else { @@ -565,6 +684,12 @@ void VToolUnionDetails::FindJ(const qint32 &pointsD2, const VDetail &d2, const q } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetDetailFromFile parse detail from file. + * @param doc dom document container. + * @param domElement tag in xml tree. + * @return detail stored in file. + */ QVector VToolUnionDetails::GetDetailFromFile(VPattern *doc, const QDomElement &domElement) { QVector vector; @@ -590,24 +715,24 @@ QVector VToolUnionDetails::GetDetailFromFile(VPattern *doc, const QDomE quint32 id = doc->GetParametrUInt(element, VToolDetail::AttrIdObject, "0"); qreal mx = qApp->toPixel(doc->GetParametrDouble(element, VAbstractTool::AttrMx, "0.0")); qreal my = qApp->toPixel(doc->GetParametrDouble(element, VAbstractTool::AttrMy, "0.0")); - Valentina::Tools tool; - NodeDetail::NodeDetails nodeType = NodeDetail::Contour; + Tool tool; + NodeDetail nodeType = NodeDetail::Contour; QString t = doc->GetParametrString(element, "type", "NodePoint"); if (t == "NodePoint") { - tool = Valentina::NodePoint; + tool = Tool::NodePoint; } else if (t == "NodeArc") { - tool = Valentina::NodeArc; + tool = Tool::NodeArc; } else if (t == "NodeSpline") { - tool = Valentina::NodeSpline; + tool = Tool::NodeSpline; } else if (t == "NodeSplinePath") { - tool = Valentina::NodeSplinePath; + tool = Tool::NodeSplinePath; } d.append(VNodeDetail(id, tool, nodeType, mx, my)); } @@ -621,6 +746,9 @@ QVector VToolUnionDetails::GetDetailFromFile(VPattern *doc, const QDomE } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddToFile add tag with informations about tool into file. + */ void VToolUnionDetails::AddToFile() { QDomElement domElement = doc->createElement(TagName); @@ -637,6 +765,9 @@ void VToolUnionDetails::AddToFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. + */ void VToolUnionDetails::RefreshDataInFile() { QDomElement domElement = doc->elementById(QString().setNum(id)); @@ -652,19 +783,29 @@ void VToolUnionDetails::RefreshDataInFile() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddDetail add detail to xml file. + * @param domElement tag in xml tree. + * @param d detail. + */ void VToolUnionDetails::AddDetail(QDomElement &domElement, VDetail &d) { QDomElement det = doc->createElement(TagDetail); for (ptrdiff_t i = 0; i < d.CountNode(); ++i) { - AddNode(det, d[i]); + AddNode(det, d.at(i)); } domElement.appendChild(det); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddNode add node to xml file. + * @param domElement tag in xml tree. + * @param node node. + */ void VToolUnionDetails::AddNode(QDomElement &domElement, const VNodeDetail &node) { QDomElement nod = doc->createElement(TagNode); @@ -682,18 +823,39 @@ void VToolUnionDetails::AddNode(QDomElement &domElement, const VNodeDetail &node } switch (node.getTypeTool()) { - case (Valentina::NodeArc): + case (Tool::NodeArc): doc->SetAttribute(nod, AttrType, QStringLiteral("NodeArc")); break; - case (Valentina::NodePoint): + case (Tool::NodePoint): doc->SetAttribute(nod, AttrType, QStringLiteral("NodePoint")); break; - case (Valentina::NodeSpline): + case (Tool::NodeSpline): doc->SetAttribute(nod, AttrType, QStringLiteral("NodeSpline")); break; - case (Valentina::NodeSplinePath): + case (Tool::NodeSplinePath): doc->SetAttribute(nod, AttrType, QStringLiteral("NodeSplinePath")); break; + case (Tool::ArrowTool): + case (Tool::SinglePointTool): + case (Tool::EndLineTool): + case (Tool::LineTool): + case (Tool::AlongLineTool): + case (Tool::ShoulderPointTool): + case (Tool::NormalTool): + case (Tool::BisectorTool): + case (Tool::LineIntersectTool): + case (Tool::SplineTool): + case (Tool::CutSplineTool): + case (Tool::CutArcTool): + case (Tool::ArcTool): + case (Tool::SplinePathTool): + case (Tool::CutSplinePathTool): + case (Tool::PointOfContact): + case (Tool::DetailTool): + case (Tool::Height): + case (Tool::Triangle): + case (Tool::PointOfIntersection): + case (Tool::UnionDetails): default: qDebug()<<"May be wrong tool type!!! Ignoring."<GetActivNodeElement(VPattern::TagModeling, modelingElement); - if (ok) - { - modelingElement.appendChild(domElement); - } - else - { - qCritical()<getUndoStack()->push(addUnion); } diff --git a/src/app/tools/vtooluniondetails.h b/src/app/tools/vtooluniondetails.h index be3cbe798..bc610a0c3 100644 --- a/src/app/tools/vtooluniondetails.h +++ b/src/app/tools/vtooluniondetails.h @@ -30,7 +30,11 @@ #define VTOOLUNIONDETAILS_H #include "vabstracttool.h" -#include "../dialogs/tools/dialoguniondetails.h" +#include "../xml/vpattern.h" + +class VPointF; +class VMainGraphicsScene; +class DialogTool; /** * @brief The VToolUnionDetails class tool union details. @@ -39,59 +43,20 @@ class VToolUnionDetails : public VAbstractTool { Q_OBJECT public: - /** - * @brief VToolUnionDetails costructor. - * @param doc dom document container. - * @param data dom document container. - * @param id object id in container. - * @param d1 first detail. - * @param d2 second detail. - * @param indexD1 index edge in first detail. - * @param indexD2 index edge in second detail. - * @param typeCreation way we create this tool. - * @param parent parent object. - */ VToolUnionDetails(VPattern *doc, VContainer *data, const quint32 &id, const VDetail &d1, const VDetail &d2, - const quint32 &indexD1, const quint32 &indexD2, const Valentina::Sources &typeCreation, + const quint32 &indexD1, const quint32 &indexD2, const Source &typeCreation, QObject *parent = nullptr); /** * @brief setDialog set dialog when user want change tool option. */ virtual void setDialog() {} - /** - * @brief Create help create tool from GUI. - * @param dialog dialog. - * @param doc dom document container. - * @param data container with variables. - */ static void Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - /** - * @brief Create help create tool. - * @param _id tool id, 0 if tool doesn't exist yet. - * @param d1 first detail. - * @param d2 second detail. - * @param d1id id first detail. - * @param d2id id second detail. - * @param indexD1 index edge in first detail. - * @param indexD2 index edge in second detail. - * @param scene pointer to scene. - * @param doc dom document container. - * @param data container with variables. - * @param parse parser file mode. - * @param typeCreation way we create this tool. - */ static void Create(const quint32 _id, const VDetail &d1, const VDetail &d2, const quint32 &d1id, const quint32 &d2id, const quint32 &indexD1, const quint32 &indexD2, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document::Documents &parse, - const Valentina::Sources &typeCreation); + VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); static void PointsOnEdge(const VDetail &d, const quint32 &index, VPointF &p1, VPointF &p2, VContainer *data); - static void FindJ(const qint32 &pointsD2, const VDetail &d2, const quint32 &indexD2, qint32 &j); - /** - * @brief GetDetailFromFile parse detail from file. - * @param doc dom document container. - * @param domElement tag in xml tree. - * @return detail stored in file. - */ + static void FindJ(const qint32 &pointsD2, const VDetail &d2, const quint32 &indexD2, qint32 &j); static QVector GetDetailFromFile(VPattern *doc, const QDomElement &domElement); static const QString TagName; static const QString ToolType; @@ -103,103 +68,39 @@ public: static const QString AttrNodeType; static const QString NodeTypeContour; static const QString NodeTypeModeling; - /** - * @brief AddToNewDetail create united detail adding one node per time. - * @param tool tool that make union. - * @param doc dom document container. - * @param data container with variables. - * @param newDetail united detail. - * @param det detail what we union. - * @param i index node in detail. - * @param idTool id tool union details. - * @param dx bias node x axis. - * @param dy bias node y axis. - * @param pRotate point rotation. - * @param angle angle rotation. - */ static void AddToNewDetail(QObject *tool, VPattern *doc, VContainer *data, VDetail &newDetail, const VDetail &det, const ptrdiff_t &i, const quint32 &idTool, const qreal &dx = 0, const qreal &dy = 0, const quint32 &pRotate = 0, const qreal &angle = 0); - /** - * @brief UpdatePoints update data for united details. - * @param idDetail id united detail. - * @param data container with variables. - * @param det detail what we union. - * @param i index node in detail. - * @param idCount count updated or created objects. - * @param dx bias node x axis. - * @param dy bias node y axis. - * @param pRotate point rotation. - * @param angle angle rotation. - */ static void UpdatePoints(const quint32 &idDetail, VContainer *data, const VDetail &det, const ptrdiff_t &i, quint32 &idCount, const qreal &dx = 0, const qreal &dy = 0, const quint32 &pRotate = 0, const qreal &angle = 0); - /** - * @brief BiasRotatePoint bias and rotate point. - * @param point point. - * @param dx bias x axis. - * @param dy bias y axis. - * @param pRotate point rotation. - * @param angle angle rotation. - */ static void BiasRotatePoint(VPointF *point, const qreal &dx, const qreal &dy, const QPointF &pRotate, - const qreal angle); + const qreal &angle); public slots: /** * @brief FullUpdateFromFile update tool data form file. */ virtual void FullUpdateFromFile (){} protected: - /** - * @brief AddToFile add tag with informations about tool into file. - */ virtual void AddToFile(); - /** - * @brief RefreshDataInFile refresh attributes in file. If attributes don't exist create them. - */ virtual void RefreshDataInFile(); private: Q_DISABLE_COPY(VToolUnionDetails) - /** - * @brief d1 first detail. - */ + /** @brief d1 first detail. */ VDetail d1; - /** - * @brief d2 second detail. - */ + + /** @brief d2 second detail. */ VDetail d2; - /** - * @brief indexD1 index edge in first detail. - */ - quint32 indexD1; - /** - * @brief indexD2 index edge in second detail. - */ - quint32 indexD2; - /** - * @brief AddDetail add detail to xml file. - * @param domElement tag in xml tree. - * @param d detail. - */ + + /** @brief indexD1 index edge in first detail. */ + quint32 indexD1; + + /** @brief indexD2 index edge in second detail. */ + quint32 indexD2; + void AddDetail(QDomElement &domElement, VDetail &d); - /** - * @brief AddNode add node to xml file. - * @param domElement tag in xml tree. - * @param node node. - */ void AddNode(QDomElement &domElement, const VNodeDetail &node); - /** - * @brief UpdateDetail update detail in xml tree. - * @param domNode dom node. - * @param d detail. - * @return return next detail tag in xml tree if exist. - */ QDomNode UpdateDetail(const QDomNode &domNode, const VDetail &d); - /** - * @brief AddToModeling add tool to xml tree. - * @param domElement tag in xml tree. - */ void AddToModeling(const QDomElement &domElement); }; diff --git a/src/app/undocommands/adddet.cpp b/src/app/undocommands/adddet.cpp new file mode 100644 index 000000000..d927f3f47 --- /dev/null +++ b/src/app/undocommands/adddet.cpp @@ -0,0 +1,77 @@ +/************************************************************************ + ** + ** @file adddet.cpp + ** @author Roman Telezhynskyi + ** @date 15 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "adddet.h" +#include "../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +AddDet::AddDet(const QDomElement &xml, VPattern *doc, QUndoCommand *parent) + : QObject(), QUndoCommand(parent), xml(xml), doc(doc), redoFlag(false) +{ + setText(tr("Add detail")); +} + +//--------------------------------------------------------------------------------------------------------------------- +AddDet::~AddDet() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void AddDet::undo() +{ + QDomElement element; + if (doc->GetActivNodeElement(VPattern::TagDetails, element)) + { + element.removeChild(xml); + } + else + { + qDebug()<<"Can't find tag"<GetActivNodeElement(VPattern::TagDetails, element)) + { + element.appendChild(xml); + } + else + { + qDebug()<<"Can't find tag"< + ** @date 15 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef ADDDET_H +#define ADDDET_H + +#include +#include + +class VPattern; + +class AddDet : public QObject, public QUndoCommand +{ + Q_OBJECT +public: + AddDet(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0); + virtual ~AddDet(); + virtual void undo(); + virtual void redo(); +signals: + void NeedFullParsing(); +private: + Q_DISABLE_COPY(AddDet) + const QDomElement xml; + VPattern *doc; + bool redoFlag; +}; + +#endif // ADDDET_H diff --git a/src/app/undocommands/adddetnode.cpp b/src/app/undocommands/adddetnode.cpp new file mode 100644 index 000000000..8221162de --- /dev/null +++ b/src/app/undocommands/adddetnode.cpp @@ -0,0 +1,71 @@ +/************************************************************************ + ** + ** @file adddetnode.cpp + ** @author Roman Telezhynskyi + ** @date 15 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "adddetnode.h" +#include "../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +AddDetNode::AddDetNode(const QDomElement &xml, VPattern *doc, QUndoCommand *parent) + : QUndoCommand(parent), xml(xml), doc(doc) +{ + setText(QObject::tr("Add node")); +} + +//--------------------------------------------------------------------------------------------------------------------- +AddDetNode::~AddDetNode() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void AddDetNode::undo() +{ + QDomElement modelingElement; + if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement)) + { + modelingElement.removeChild(xml); + } + else + { + qDebug()<<"Can't find tag"<GetActivNodeElement(VPattern::TagModeling, modelingElement)) + { + modelingElement.appendChild(xml); + } + else + { + qDebug()<<"Can't find tag"< + ** @date 15 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef ADDDETNODE_H +#define ADDDETNODE_H + +#include +#include + +class VPattern; + +class AddDetNode : public QUndoCommand +{ +public: + AddDetNode(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0); + virtual ~AddDetNode(); + virtual void undo(); + virtual void redo(); +private: + Q_DISABLE_COPY(AddDetNode) + const QDomElement xml; + VPattern *doc; +}; + +#endif // ADDDETNODE_H diff --git a/src/app/undocommands/addpatternpiece.cpp b/src/app/undocommands/addpatternpiece.cpp new file mode 100644 index 000000000..915e72b11 --- /dev/null +++ b/src/app/undocommands/addpatternpiece.cpp @@ -0,0 +1,80 @@ +/************************************************************************ + ** + ** @file addpatternpiece.cpp + ** @author Roman Telezhynskyi + ** @date 9 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "addpatternpiece.h" +#include "../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +AddPatternPiece::AddPatternPiece(const QDomElement &xml, VPattern *doc, const QString &namePP, const QString &mPath, + QUndoCommand *parent) + : QObject(), QUndoCommand(parent), xml(xml), doc(doc), namePP(namePP), redoFlag(false), mPath(mPath) +{ + Q_ASSERT(xml.isNull() == false); + Q_ASSERT(namePP.isEmpty() == false); + Q_ASSERT(mPath.isEmpty() == false); + setText(tr("Add pattern piece %1").arg(namePP)); +} + +//--------------------------------------------------------------------------------------------------------------------- +AddPatternPiece::~AddPatternPiece() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void AddPatternPiece::undo() +{ + if (doc->CountPP() <= 1) + { + emit ClearScene(); + } + else + { + QDomElement rootElement = doc->documentElement(); + QDomElement patternPiece = doc->GetPPElement(namePP); + rootElement.removeChild(patternPiece); + emit NeedFullParsing(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void AddPatternPiece::redo() +{ + if (doc->CountPP() == 0 && mPath.isEmpty() == false) + { + doc->CreateEmptyFile(mPath); + } + + QDomElement rootElement = doc->documentElement(); + + rootElement.appendChild(xml); + + if (redoFlag) + { + emit NeedFullParsing(); + } + redoFlag = true; +} diff --git a/src/app/undocommands/addpatternpiece.h b/src/app/undocommands/addpatternpiece.h new file mode 100644 index 000000000..661d7de92 --- /dev/null +++ b/src/app/undocommands/addpatternpiece.h @@ -0,0 +1,58 @@ +/************************************************************************ + ** + ** @file addpatternpiece.h + ** @author Roman Telezhynskyi + ** @date 9 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef ADDPATTERNPIECE_H +#define ADDPATTERNPIECE_H + +#include +#include + +class VPattern; + +class AddPatternPiece : public QObject, public QUndoCommand +{ + Q_OBJECT +public: + AddPatternPiece(const QDomElement &xml, VPattern *doc, const QString &namePP, const QString &mPath, + QUndoCommand *parent = 0); + virtual ~AddPatternPiece(); + virtual void undo(); + virtual void redo(); +signals: + void ClearScene(); + void NeedFullParsing(); +private: + Q_DISABLE_COPY(AddPatternPiece) + const QDomElement xml; + VPattern *doc; + QString namePP; + bool redoFlag; + QString mPath; +}; + +#endif // ADDPATTERNPIECE_H diff --git a/src/app/undocommands/addtocalc.cpp b/src/app/undocommands/addtocalc.cpp new file mode 100644 index 000000000..62baf2062 --- /dev/null +++ b/src/app/undocommands/addtocalc.cpp @@ -0,0 +1,105 @@ +/************************************************************************ + ** + ** @file addtocalc.cpp + ** @author Roman Telezhynskyi + ** @date 9 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "addtocalc.h" +#include "../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +AddToCalc::AddToCalc(const QDomElement &xml, VPattern *doc, QUndoCommand *parent) + : QObject(), QUndoCommand(parent), xml(xml), doc(doc), nameActivDraw(doc->GetNameActivDraw()), + cursor(doc->getCursor()), redoFlag(false) +{ + setText(tr("Add object")); +} + +//--------------------------------------------------------------------------------------------------------------------- +AddToCalc::~AddToCalc() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void AddToCalc::undo() +{ + doc->ChangeActivPP(nameActivDraw); + doc->setCursor(cursor); + + QDomElement calcElement; + if (doc->GetActivNodeElement(VPattern::TagCalculation, calcElement)) + { + calcElement.removeChild(xml); + if (cursor > 0) + { + doc->setCursor(0); + } + } + else + { + qDebug()<<"Can't find tag Calculation"<< Q_FUNC_INFO; + return; + } + emit NeedFullParsing(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void AddToCalc::redo() +{ + doc->ChangeActivPP(nameActivDraw); + doc->setCursor(cursor); + + QDomElement calcElement; + if (doc->GetActivNodeElement(VPattern::TagCalculation, calcElement)) + { + if (cursor <= 0) + { + calcElement.appendChild(xml); + } + else + { + QDomElement refElement = doc->elementById(QString().setNum(cursor)); + if (refElement.isElement()) + { + calcElement.insertAfter(xml, refElement); + doc->setCursor(0); + } + else + { + qDebug()<<"Can not find the element after which you want to insert."<< Q_FUNC_INFO; + return; + } + } + } + else + { + qDebug()<<"Can't find tag Calculation"<< Q_FUNC_INFO; + return; + } + if (redoFlag) + { + emit NeedFullParsing(); + } + redoFlag = true; +} diff --git a/src/app/undocommands/addtocalc.h b/src/app/undocommands/addtocalc.h new file mode 100644 index 000000000..143f19aa4 --- /dev/null +++ b/src/app/undocommands/addtocalc.h @@ -0,0 +1,56 @@ +/************************************************************************ + ** + ** @file addtocalc.h + ** @author Roman Telezhynskyi + ** @date 9 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef ADDTOCALC_H +#define ADDTOCALC_H + +#include +#include + +class VPattern; + +class AddToCalc : public QObject, public QUndoCommand +{ + Q_OBJECT +public: + AddToCalc(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0); + virtual ~AddToCalc(); + virtual void undo(); + virtual void redo(); +signals: + void NeedFullParsing(); +private: + Q_DISABLE_COPY(AddToCalc) + const QDomElement xml; + VPattern *doc; + const QString nameActivDraw; + quint32 cursor; + bool redoFlag; +}; + +#endif // ADDTOCALC_H diff --git a/src/app/undocommands/adduniondetails.cpp b/src/app/undocommands/adduniondetails.cpp new file mode 100644 index 000000000..3dc577bb3 --- /dev/null +++ b/src/app/undocommands/adduniondetails.cpp @@ -0,0 +1,77 @@ +/************************************************************************ + ** + ** @file adduniondetails.cpp + ** @author Roman Telezhynskyi + ** @date 15 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "adduniondetails.h" +#include "../xml/vpattern.h" + +//--------------------------------------------------------------------------------------------------------------------- +AddUnionDetails::AddUnionDetails(const QDomElement &xml, VPattern *doc, QUndoCommand *parent) + : QObject(), QUndoCommand(parent), xml(xml), doc(doc), redoFlag(false) +{ + setText(tr("Add union details")); +} + +//--------------------------------------------------------------------------------------------------------------------- +AddUnionDetails::~AddUnionDetails() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void AddUnionDetails::undo() +{ + QDomElement modelingElement; + if (doc->GetActivNodeElement(VPattern::TagModeling, modelingElement)) + { + modelingElement.removeChild(xml); + } + else + { + qDebug()<<"Can't find tag"<GetActivNodeElement(VPattern::TagModeling, modelingElement)) + { + modelingElement.appendChild(xml); + } + else + { + qDebug()<<"Can't find tag"< + ** @date 15 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef ADDUNIONDETAILS_H +#define ADDUNIONDETAILS_H + +#include +#include + +class VPattern; + +class AddUnionDetails : public QObject, public QUndoCommand +{ + Q_OBJECT +public: + AddUnionDetails(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0); + virtual ~AddUnionDetails(); + virtual void undo(); + virtual void redo(); +signals: + void NeedFullParsing(); +private: + Q_DISABLE_COPY(AddUnionDetails) + const QDomElement xml; + VPattern *doc; + bool redoFlag; +}; + +#endif // ADDUNIONDETAILS_H diff --git a/src/app/undocommands/deletedetail.cpp b/src/app/undocommands/deletedetail.cpp new file mode 100644 index 000000000..f6196604a --- /dev/null +++ b/src/app/undocommands/deletedetail.cpp @@ -0,0 +1,83 @@ +/************************************************************************ + ** + ** @file deletedetail.cpp + ** @author Roman Telezhynskyi + ** @date 16 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "deletedetail.h" +#include "../xml/vpattern.h" +#include "../tools/vtooldetail.h" + +//--------------------------------------------------------------------------------------------------------------------- +DeleteDetail::DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent) + : QObject(), QUndoCommand(parent), xml(QDomElement()), doc(doc), detId(id), parentNode(QDomNode()) +{ + setText(tr("Delete tool")); + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + xml = domElement.cloneNode().toElement(); + parentNode = domElement.parentNode(); + } + else + { + qDebug()<<"Can't get detail by id = "<elementById(QString().setNum(detId)); + if (domElement.isElement()) + { + parentNode.removeChild(domElement); + + QHash* tools = doc->getTools(); + SCASSERT(tools != nullptr); + VToolDetail *toolDet = qobject_cast(tools->value(detId)); + SCASSERT(toolDet != nullptr); + toolDet->hide(); + + emit NeedFullParsing(); + } + else + { + qDebug()<<"Can't get detail by id = "< + ** @date 16 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef DELETEDETAIL_H +#define DELETEDETAIL_H + +#include +#include + +class VPattern; +class QGraphicsItem; + +class DeleteDetail : public QObject, public QUndoCommand +{ + Q_OBJECT +public: + DeleteDetail(VPattern *doc, quint32 id, QUndoCommand *parent = 0); + virtual ~DeleteDetail(); + virtual void undo(); + virtual void redo(); +signals: + void NeedFullParsing(); +private: + Q_DISABLE_COPY(DeleteDetail) + QDomElement xml; + VPattern *doc; + quint32 detId; + QDomNode parentNode; +}; + +#endif // DELETEDETAIL_H diff --git a/src/app/undocommands/deletepatternpiece.cpp b/src/app/undocommands/deletepatternpiece.cpp new file mode 100644 index 000000000..15d55da60 --- /dev/null +++ b/src/app/undocommands/deletepatternpiece.cpp @@ -0,0 +1,68 @@ +/************************************************************************ + ** + ** @file deletepatternpiece.cpp + ** @author Roman Telezhynskyi + ** @date 14 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "deletepatternpiece.h" +#include "../xml/vpattern.h" +#include "addpatternpiece.h" + +//--------------------------------------------------------------------------------------------------------------------- +DeletePatternPiece::DeletePatternPiece(VPattern *doc, const QString &namePP, QUndoCommand *parent) + : QObject(), QUndoCommand(parent), doc(doc), namePP(namePP), patternPiece(QDomElement()), mPath(QString()), + previousNode(QDomNode()) +{ + setText(tr("Delete pattern piece %1").arg(namePP)); + + QDomElement patternP= doc->GetPPElement(namePP); + patternPiece = patternP.cloneNode().toElement(); + mPath = doc->MPath(); + previousNode = patternP.previousSibling();//find previous pattern piece +} + +//--------------------------------------------------------------------------------------------------------------------- +DeletePatternPiece::~DeletePatternPiece() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void DeletePatternPiece::undo() +{ + + QDomElement rootElement = doc->documentElement(); + rootElement.insertAfter(patternPiece, previousNode); + + emit NeedFullParsing(); + doc->ChangedActivPP(namePP); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DeletePatternPiece::redo() +{ + QDomElement rootElement = doc->documentElement(); + QDomElement patternPiece = doc->GetPPElement(namePP); + rootElement.removeChild(patternPiece); + emit NeedFullParsing(); +} diff --git a/src/app/undocommands/deletepatternpiece.h b/src/app/undocommands/deletepatternpiece.h new file mode 100644 index 000000000..fa5d14cd6 --- /dev/null +++ b/src/app/undocommands/deletepatternpiece.h @@ -0,0 +1,56 @@ +/************************************************************************ + ** + ** @file deletepatternpiece.h + ** @author Roman Telezhynskyi + ** @date 14 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef DELETEPATTERNPIECE_H +#define DELETEPATTERNPIECE_H + +#include +#include + +class VPattern; + +class DeletePatternPiece : public QObject, public QUndoCommand +{ + Q_OBJECT +public: + DeletePatternPiece(VPattern *doc, const QString &namePP, QUndoCommand *parent = 0); + virtual ~DeletePatternPiece(); + virtual void undo(); + virtual void redo(); +signals: + void NeedFullParsing(); +private: + Q_DISABLE_COPY(DeletePatternPiece) + VPattern *doc; + QString namePP; + QDomElement patternPiece; + QString mPath; + QDomNode previousNode; +}; + +#endif // DELETEPATTERNPIECE_H diff --git a/src/app/undocommands/deltool.cpp b/src/app/undocommands/deltool.cpp new file mode 100644 index 000000000..831f70b9b --- /dev/null +++ b/src/app/undocommands/deltool.cpp @@ -0,0 +1,89 @@ +/************************************************************************ + ** + ** @file deltool.cpp + ** @author Roman Telezhynskyi + ** @date 13 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "deltool.h" +#include "../xml/vpattern.h" +#include +#include "../tools/vtooldetail.h" + +//--------------------------------------------------------------------------------------------------------------------- +DelTool::DelTool(VPattern *doc, quint32 id, QUndoCommand *parent) + : QObject(), QUndoCommand(parent), xml(QDomElement()), parentNode(QDomNode()), doc(doc), toolId(id), + cursor(doc->getCursor()) +{ + setText(tr("Delete tool")); + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + xml = domElement.cloneNode().toElement(); + parentNode = domElement.parentNode(); + } + else + { + qDebug()<<"Can't get tool by id = "<elementById(QString().setNum(cursor)); + if (refElement.isElement()) + { + parentNode.insertAfter(xml, refElement); + } + } + emit NeedFullParsing(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DelTool::redo() +{ + QDomElement domElement = doc->elementById(QString().setNum(toolId)); + if (domElement.isElement()) + { + parentNode.removeChild(domElement); + emit NeedFullParsing(); + } + else + { + qDebug()<<"Can't get tool by id = "< + ** @date 13 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef DELTOOL_H +#define DELTOOL_H + +#include +#include + +class VPattern; +class QGraphicsItem; + +class DelTool : public QObject, public QUndoCommand +{ + Q_OBJECT +public: + DelTool(VPattern *doc, quint32 id, QUndoCommand *parent = 0); + virtual ~DelTool(); + virtual void undo(); + virtual void redo(); +signals: + void NeedFullParsing(); +private: + Q_DISABLE_COPY(DelTool) + QDomElement xml; + QDomNode parentNode; + VPattern *doc; + quint32 toolId; + quint32 cursor; +}; + +#endif // DELTOOL_H diff --git a/src/app/undocommands/movedetail.cpp b/src/app/undocommands/movedetail.cpp new file mode 100644 index 000000000..84270c8ac --- /dev/null +++ b/src/app/undocommands/movedetail.cpp @@ -0,0 +1,130 @@ +/************************************************************************ + ** + ** @file movedetail.cpp + ** @author Roman Telezhynskyi + ** @date 13 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "movedetail.h" +#include +#include +#include "../xml/vpattern.h" +#include "../tools/vabstracttool.h" +#include "../widgets/vapplication.h" +#include "undocommands.h" + +//--------------------------------------------------------------------------------------------------------------------- +MoveDetail::MoveDetail(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), detId(id), scene(scene), + redoFlag(false) +{ + setText(QObject::tr("Move detail")); + + SCASSERT(scene != nullptr); + QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + oldX = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0")); + oldY = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0")); + } + else + { + qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO; + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +MoveDetail::~MoveDetail() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveDetail::undo() +{ + QDomElement domElement = doc->elementById(QString().setNum(detId)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, VAbstractTool::AttrMx, QString().setNum(qApp->fromPixel(oldX))); + doc->SetAttribute(domElement, VAbstractTool::AttrMy, QString().setNum(qApp->fromPixel(oldY))); + + emit NeedLiteParsing(); + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO; + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveDetail::redo() +{ + QDomElement domElement = doc->elementById(QString().setNum(detId)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, VAbstractTool::AttrMx, QString().setNum(qApp->fromPixel(newX))); + doc->SetAttribute(domElement, VAbstractTool::AttrMy, QString().setNum(qApp->fromPixel(newY))); + + if (redoFlag) + { + emit NeedLiteParsing(); + } + redoFlag = true; + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO; + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool MoveDetail::mergeWith(const QUndoCommand *command) +{ + const MoveDetail *moveCommand = static_cast(command); + SCASSERT(moveCommand != nullptr); + const quint32 id = moveCommand->getDetId(); + + if (id != detId) + { + return false; + } + + newX = moveCommand->getNewX(); + newY = moveCommand->getNewY(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int MoveDetail::id() const +{ + return static_cast(UndoCommand::MoveDetail); +} diff --git a/src/app/undocommands/movedetail.h b/src/app/undocommands/movedetail.h new file mode 100644 index 000000000..aa5e8520b --- /dev/null +++ b/src/app/undocommands/movedetail.h @@ -0,0 +1,83 @@ +/************************************************************************ + ** + ** @file movedetail.h + ** @author Roman Telezhynskyi + ** @date 13 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef MOVEDETAIL_H +#define MOVEDETAIL_H + +#include + +class VPattern; +class QGraphicsScene; + +class MoveDetail : public QObject, public QUndoCommand +{ + Q_OBJECT +public: + MoveDetail(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, + QUndoCommand *parent = 0); + virtual ~MoveDetail(); + virtual void undo(); + virtual void redo(); + virtual bool mergeWith(const QUndoCommand *command); + virtual int id() const; + quint32 getDetId() const; + double getNewX() const; + double getNewY() const; +signals: + void NeedLiteParsing(); +private: + Q_DISABLE_COPY(MoveDetail) + VPattern *doc; + double oldX; + double oldY; + double newX; + double newY; + quint32 detId; + QGraphicsScene *scene; + bool redoFlag; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 MoveDetail::getDetId() const +{ + return detId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline double MoveDetail::getNewX() const +{ + return newX; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline double MoveDetail::getNewY() const +{ + return newY; +} + +#endif // MOVEDETAIL_H diff --git a/src/app/undocommands/movespline.cpp b/src/app/undocommands/movespline.cpp new file mode 100644 index 000000000..d6f557a7d --- /dev/null +++ b/src/app/undocommands/movespline.cpp @@ -0,0 +1,118 @@ +/************************************************************************ + ** + ** @file movespline.cpp + ** @author Roman Telezhynskyi + ** @date 9 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "movespline.h" +#include "../tools/vabstracttool.h" +#include +#include +#include "../xml/vpattern.h" +#include "undocommands.h" + +//--------------------------------------------------------------------------------------------------------------------- +MoveSpline::MoveSpline(VPattern *doc, const VSpline *oldSpl, const VSpline &newSpl, const quint32 &id, + QGraphicsScene *scene, QUndoCommand *parent) + : QObject(), QUndoCommand(parent), doc(doc), oldSpline(*oldSpl), newSpline(newSpl), splineId(id), scene(scene) +{ + setText(tr("Move spline")); + + SCASSERT(scene != nullptr); +} + +//--------------------------------------------------------------------------------------------------------------------- +MoveSpline::~MoveSpline() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveSpline::undo() +{ + QDomElement domElement = doc->elementById(QString().setNum(splineId)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, VAbstractTool::AttrAngle1, QString().setNum(oldSpline.GetAngle1())); + doc->SetAttribute(domElement, VAbstractTool::AttrAngle2, QString().setNum(oldSpline.GetAngle2())); + doc->SetAttribute(domElement, VAbstractTool::AttrKAsm1, QString().setNum(oldSpline.GetKasm1())); + doc->SetAttribute(domElement, VAbstractTool::AttrKAsm2, QString().setNum(oldSpline.GetKasm2())); + doc->SetAttribute(domElement, VAbstractTool::AttrKCurve, QString().setNum(oldSpline.GetKcurve())); + + emit NeedLiteParsing(); + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qDebug()<<"Can't find spline with id ="<< splineId << Q_FUNC_INFO; + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveSpline::redo() +{ + QDomElement domElement = doc->elementById(QString().setNum(splineId)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, VAbstractTool::AttrAngle1, QString().setNum(newSpline.GetAngle1())); + doc->SetAttribute(domElement, VAbstractTool::AttrAngle2, QString().setNum(newSpline.GetAngle2())); + doc->SetAttribute(domElement, VAbstractTool::AttrKAsm1, QString().setNum(newSpline.GetKasm1())); + doc->SetAttribute(domElement, VAbstractTool::AttrKAsm2, QString().setNum(newSpline.GetKasm2())); + doc->SetAttribute(domElement, VAbstractTool::AttrKCurve, QString().setNum(newSpline.GetKcurve())); + + emit NeedLiteParsing(); + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qDebug()<<"Can't find spline with id ="<< splineId << Q_FUNC_INFO; + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool MoveSpline::mergeWith(const QUndoCommand *command) +{ + const MoveSpline *moveCommand = static_cast(command); + SCASSERT(moveCommand != nullptr); + const quint32 id = moveCommand->getSplineId(); + + if (id != splineId) + { + return false; + } + + newSpline = moveCommand->getNewSpline(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int MoveSpline::id() const +{ + return static_cast(UndoCommand::MoveSpline); +} diff --git a/src/app/undocommands/movespline.h b/src/app/undocommands/movespline.h new file mode 100644 index 000000000..24045858b --- /dev/null +++ b/src/app/undocommands/movespline.h @@ -0,0 +1,74 @@ +/************************************************************************ + ** + ** @file movespline.h + ** @author Roman Telezhynskyi + ** @date 9 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef MOVESPLINE_H +#define MOVESPLINE_H + +#include +#include "../geometry/vspline.h" + +class VPattern; +class QGraphicsScene; + +class MoveSpline : public QObject, public QUndoCommand +{ + Q_OBJECT +public: + MoveSpline(VPattern *doc, const VSpline *oldSpl, const VSpline &spl, const quint32 &id, QGraphicsScene *scene, + QUndoCommand *parent = 0); + virtual ~MoveSpline(); + virtual void undo(); + virtual void redo(); + virtual bool mergeWith(const QUndoCommand *command); + virtual int id() const; + quint32 getSplineId() const; + VSpline getNewSpline() const; +signals: + void NeedLiteParsing(); +private: + Q_DISABLE_COPY(MoveSpline) + VPattern *doc; + VSpline oldSpline; + VSpline newSpline; + quint32 splineId; + QGraphicsScene *scene; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 MoveSpline::getSplineId() const +{ + return splineId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline VSpline MoveSpline::getNewSpline() const +{ + return newSpline; +} + +#endif // MOVESPLINE_H diff --git a/src/app/undocommands/movesplinepath.cpp b/src/app/undocommands/movesplinepath.cpp new file mode 100644 index 000000000..535b85770 --- /dev/null +++ b/src/app/undocommands/movesplinepath.cpp @@ -0,0 +1,111 @@ +/************************************************************************ + ** + ** @file movesplinepath.cpp + ** @author Roman Telezhynskyi + ** @date 11 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "movesplinepath.h" +#include +#include "../tools/drawTools/vtoolsplinepath.h" +#include "undocommands.h" + +//--------------------------------------------------------------------------------------------------------------------- +MoveSplinePath::MoveSplinePath(VPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath, + const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent) + : QObject(), QUndoCommand(parent), doc(doc), oldSplinePath(oldSplPath), newSplinePath(newSplPath), splinePathId(id), + scene(scene) +{ + setText(tr("Move spline path")); + + SCASSERT(scene != nullptr); +} + +//--------------------------------------------------------------------------------------------------------------------- +MoveSplinePath::~MoveSplinePath() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveSplinePath::undo() +{ + QDomElement domElement = doc->elementById(QString().setNum(splinePathId)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, VToolSplinePath::AttrKCurve, QString().setNum(oldSplinePath.getKCurve())); + VToolSplinePath::UpdatePathPoint(doc, domElement, oldSplinePath); + + emit NeedLiteParsing(); + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qDebug()<<"Can't find spline path with id ="<< splinePathId << Q_FUNC_INFO; + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveSplinePath::redo() +{ + QDomElement domElement = doc->elementById(QString().setNum(splinePathId)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, VToolSplinePath::AttrKCurve, QString().setNum(newSplinePath.getKCurve())); + VToolSplinePath::UpdatePathPoint(doc, domElement, newSplinePath); + + emit NeedLiteParsing(); + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qDebug()<<"Can't find spline path with id ="<< splinePathId << Q_FUNC_INFO; + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool MoveSplinePath::mergeWith(const QUndoCommand *command) +{ + const MoveSplinePath *moveCommand = static_cast(command); + SCASSERT(moveCommand != nullptr); + const quint32 id = moveCommand->getSplinePathId(); + + if (id != splinePathId) + { + return false; + } + + newSplinePath = moveCommand->getNewSplinePath(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int MoveSplinePath::id() const +{ + return static_cast(UndoCommand::MoveSplinePath); +} diff --git a/src/app/undocommands/movesplinepath.h b/src/app/undocommands/movesplinepath.h new file mode 100644 index 000000000..aab71cc0b --- /dev/null +++ b/src/app/undocommands/movesplinepath.h @@ -0,0 +1,74 @@ +/************************************************************************ + ** + ** @file movesplinepath.h + ** @author Roman Telezhynskyi + ** @date 11 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef MOVESPLINEPATH_H +#define MOVESPLINEPATH_H + +#include +#include "../geometry/vsplinepath.h" + +class VPattern; +class QGraphicsScene; + +class MoveSplinePath : public QObject, public QUndoCommand +{ + Q_OBJECT +public: + MoveSplinePath(VPattern *doc, const VSplinePath &oldSplPath, const VSplinePath &newSplPath, const quint32 &id, + QGraphicsScene *scene, QUndoCommand *parent = 0); + virtual ~MoveSplinePath(); + virtual void undo(); + virtual void redo(); + virtual bool mergeWith(const QUndoCommand *command); + virtual int id() const; + quint32 getSplinePathId() const; + VSplinePath getNewSplinePath() const; +signals: + void NeedLiteParsing(); +private: + Q_DISABLE_COPY(MoveSplinePath) + VPattern *doc; + VSplinePath oldSplinePath; + VSplinePath newSplinePath; + quint32 splinePathId; + QGraphicsScene *scene; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 MoveSplinePath::getSplinePathId() const +{ + return splinePathId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline VSplinePath MoveSplinePath::getNewSplinePath() const +{ + return newSplinePath; +} + +#endif // MOVESPLINEPATH_H diff --git a/src/app/undocommands/movespoint.cpp b/src/app/undocommands/movespoint.cpp new file mode 100644 index 000000000..1a3c2abe5 --- /dev/null +++ b/src/app/undocommands/movespoint.cpp @@ -0,0 +1,125 @@ +/************************************************************************ + ** + ** @file movespoint.cpp + ** @author Roman Telezhynskyi + ** @date 9 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "movespoint.h" +#include +#include +#include "../xml/vpattern.h" +#include "../tools/vabstracttool.h" +#include "../widgets/vapplication.h" +#include "undocommands.h" + +//--------------------------------------------------------------------------------------------------------------------- +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; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +MoveSPoint::~MoveSPoint() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveSPoint::undo() +{ + QDomElement domElement = doc->elementById(QString().setNum(sPointId)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, VAbstractTool::AttrX, QString().setNum(qApp->fromPixel(oldX))); + doc->SetAttribute(domElement, VAbstractTool::AttrY, QString().setNum(qApp->fromPixel(oldY))); + + emit NeedLiteParsing(); + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qDebug()<<"Can't find spoint with id ="<< sPointId << Q_FUNC_INFO; + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MoveSPoint::redo() +{ + QDomElement domElement = doc->elementById(QString().setNum(sPointId)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, VAbstractTool::AttrX, QString().setNum(qApp->fromPixel(newX))); + doc->SetAttribute(domElement, VAbstractTool::AttrY, QString().setNum(qApp->fromPixel(newY))); + + emit NeedLiteParsing(); + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qDebug()<<"Can't find spoint with id ="<< sPointId << Q_FUNC_INFO; + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool MoveSPoint::mergeWith(const QUndoCommand *command) +{ + const MoveSPoint *moveCommand = static_cast(command); + SCASSERT(moveCommand != nullptr); + const quint32 id = moveCommand->getSPointId(); + + if (id != sPointId) + { + return false; + } + + newX = moveCommand->getNewX(); + newY = moveCommand->getNewY(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int MoveSPoint::id() const +{ + return static_cast(UndoCommand::MoveSPoint); +} diff --git a/src/app/undocommands/movespoint.h b/src/app/undocommands/movespoint.h new file mode 100644 index 000000000..17a5c869f --- /dev/null +++ b/src/app/undocommands/movespoint.h @@ -0,0 +1,82 @@ +/************************************************************************ + ** + ** @file movespoint.h + ** @author Roman Telezhynskyi + ** @date 9 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef MOVESPOINT_H +#define MOVESPOINT_H + +#include + +class VPattern; +class QGraphicsScene; + +class MoveSPoint : public QObject, public QUndoCommand +{ + Q_OBJECT +public: + MoveSPoint(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, + QUndoCommand *parent = 0); + virtual ~MoveSPoint(); + virtual void undo(); + virtual void redo(); + virtual bool mergeWith(const QUndoCommand *command); + virtual int id() const; + quint32 getSPointId() const; + double getNewX() const; + double getNewY() const; +signals: + void NeedLiteParsing(); +private: + Q_DISABLE_COPY(MoveSPoint) + VPattern *doc; + double oldX; + double oldY; + double newX; + double newY; + quint32 sPointId; + QGraphicsScene *scene; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 MoveSPoint::getSPointId() const +{ + return sPointId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline double MoveSPoint::getNewX() const +{ + return newX; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline double MoveSPoint::getNewY() const +{ + return newY; +} + +#endif // MOVESPOINT_H diff --git a/src/app/undocommands/savedetailoptions.cpp b/src/app/undocommands/savedetailoptions.cpp new file mode 100644 index 000000000..500bafe6b --- /dev/null +++ b/src/app/undocommands/savedetailoptions.cpp @@ -0,0 +1,141 @@ +/************************************************************************ + ** + ** @file savedetailoptions.cpp + ** @author Roman Telezhynskyi + ** @date 12 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "savedetailoptions.h" +#include "undocommands.h" +#include "../tools/nodeDetails/vabstractnode.h" +#include + +SaveDetailOptions::SaveDetailOptions(const VDetail &oldDet, const VDetail &newDet, VPattern *doc, const quint32 &id, + QGraphicsScene *scene, QUndoCommand *parent) + : QObject(), QUndoCommand(parent), oldDet(oldDet), newDet(newDet), doc(doc), detId(id), scene(scene) +{ + setText(tr("Save detail option")); +} + +//--------------------------------------------------------------------------------------------------------------------- +SaveDetailOptions::~SaveDetailOptions() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void SaveDetailOptions::undo() +{ + QDomElement domElement = doc->elementById(QString().setNum(detId)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, VAbstractTool::AttrName, oldDet.getName()); + doc->SetAttribute(domElement, VToolDetail::AttrSupplement, QString().setNum(oldDet.getSeamAllowance())); + doc->SetAttribute(domElement, VToolDetail::AttrClosed, QString().setNum(oldDet.getClosed())); + doc->SetAttribute(domElement, VToolDetail::AttrWidth, QString().setNum(oldDet.getWidth())); + doc->RemoveAllChild(domElement); + for (ptrdiff_t i = 0; i < oldDet.CountNode(); ++i) + { + VToolDetail::AddNode(doc, domElement, oldDet.at(i)); + } + QVector nodes = oldDet.getNodes(); + QHash* tools = doc->getTools(); + if (nodes.size()>0) + { + for (qint32 i = 0; i < nodes.size(); ++i) + { + VAbstractNode *node = qobject_cast(tools->value(nodes.at(i).getId())); + node->RestoreNode(); + } + } + emit NeedLiteParsing(); + + QList list = scene->views(); + VAbstractTool::NewSceneRect(scene, list[0]); + } + else + { + qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO; + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void SaveDetailOptions::redo() +{ + QDomElement domElement = doc->elementById(QString().setNum(detId)); + if (domElement.isElement()) + { + doc->SetAttribute(domElement, VAbstractTool::AttrName, newDet.getName()); + doc->SetAttribute(domElement, VToolDetail::AttrSupplement, QString().setNum(newDet.getSeamAllowance())); + doc->SetAttribute(domElement, VToolDetail::AttrClosed, QString().setNum(newDet.getClosed())); + doc->SetAttribute(domElement, VToolDetail::AttrWidth, QString().setNum(newDet.getWidth())); + doc->RemoveAllChild(domElement); + for (ptrdiff_t i = 0; i < newDet.CountNode(); ++i) + { + VToolDetail::AddNode(doc, domElement, newDet.at(i)); + } + QList list = oldDet.Missing(newDet); + QHash* tools = doc->getTools(); + if (list.size()>0) + { + for (qint32 i = 0; i < list.size(); ++i) + { + VAbstractNode *node = qobject_cast(tools->value(list.at(i))); + node->DeleteNode(); + } + } + emit NeedLiteParsing(); + + QList listV = scene->views(); + VAbstractTool::NewSceneRect(scene, listV[0]); + } + else + { + qDebug()<<"Can't find detail with id ="<< detId << Q_FUNC_INFO; + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool SaveDetailOptions::mergeWith(const QUndoCommand *command) +{ + const SaveDetailOptions *saveCommand = static_cast(command); + SCASSERT(saveCommand != nullptr); + const quint32 id = saveCommand->getDetId(); + + if (id != detId) + { + return false; + } + + newDet = saveCommand->getNewDet(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int SaveDetailOptions::id() const +{ + return static_cast(UndoCommand::SaveDetailOptions); +} + + diff --git a/src/app/undocommands/savedetailoptions.h b/src/app/undocommands/savedetailoptions.h new file mode 100644 index 000000000..3f8cda414 --- /dev/null +++ b/src/app/undocommands/savedetailoptions.h @@ -0,0 +1,75 @@ +/************************************************************************ + ** + ** @file savedetailoptions.h + ** @author Roman Telezhynskyi + ** @date 12 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef SAVEDETAILOPTIONS_H +#define SAVEDETAILOPTIONS_H + +#include +#include +#include "../tools/vtooldetail.h" + +class VPattern; +class QGraphicsScene; + +class SaveDetailOptions : public QObject, public QUndoCommand +{ + Q_OBJECT +public: + SaveDetailOptions(const VDetail &oldDet, const VDetail &newDet, VPattern *doc, const quint32 &id, + QGraphicsScene *scene, QUndoCommand *parent = 0); + virtual ~SaveDetailOptions(); + virtual void undo(); + virtual void redo(); + virtual bool mergeWith(const QUndoCommand *command); + virtual int id() const; + quint32 getDetId() const; + VDetail getNewDet() const; +signals: + void NeedLiteParsing(); +private: + Q_DISABLE_COPY(SaveDetailOptions) + const VDetail oldDet; + VDetail newDet; + VPattern *doc; + const quint32 detId; + QGraphicsScene *scene; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 SaveDetailOptions::getDetId() const +{ + return detId; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline VDetail SaveDetailOptions::getNewDet() const +{ + return newDet; +} + +#endif // SAVEDETAILOPTIONS_H diff --git a/src/app/undocommands/savetooloptions.cpp b/src/app/undocommands/savetooloptions.cpp new file mode 100644 index 000000000..12bbd704c --- /dev/null +++ b/src/app/undocommands/savetooloptions.cpp @@ -0,0 +1,100 @@ +/************************************************************************ + ** + ** @file savetooloptions.cpp + ** @author Roman Telezhynskyi + ** @date 11 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "savetooloptions.h" +#include "../options.h" +#include "../xml/vpattern.h" +#include "undocommands.h" + +//--------------------------------------------------------------------------------------------------------------------- +SaveToolOptions::SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VPattern *doc, const quint32 &id, + QUndoCommand *parent) + : QObject(), QUndoCommand(parent), oldXml(oldXml), newXml(newXml), doc(doc), toolId(id) +{ + setText(tr("Save tool option")); +} + +//--------------------------------------------------------------------------------------------------------------------- +SaveToolOptions::~SaveToolOptions() +{} + +//--------------------------------------------------------------------------------------------------------------------- +void SaveToolOptions::undo() +{ + QDomElement domElement = doc->elementById(QString().setNum(toolId)); + if (domElement.isElement()) + { + domElement.parentNode().replaceChild(oldXml, domElement); + + emit NeedLiteParsing(); + } + else + { + qDebug()<<"Can't find tool with id ="<< toolId << Q_FUNC_INFO; + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void SaveToolOptions::redo() +{ + QDomElement domElement = doc->elementById(QString().setNum(toolId)); + if (domElement.isElement()) + { + domElement.parentNode().replaceChild(newXml, domElement); + + emit NeedLiteParsing(); + } + else + { + qDebug()<<"Can't find tool with id ="<< toolId << Q_FUNC_INFO; + return; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +bool SaveToolOptions::mergeWith(const QUndoCommand *command) +{ + const SaveToolOptions *saveCommand = static_cast(command); + SCASSERT(saveCommand != nullptr); + const quint32 id = saveCommand->getToolId(); + + if (id != toolId) + { + return false; + } + + newXml = saveCommand->getNewXml(); + return true; +} + +//--------------------------------------------------------------------------------------------------------------------- +int SaveToolOptions::id() const +{ + return static_cast(UndoCommand::SaveToolOptions); +} diff --git a/src/app/undocommands/savetooloptions.h b/src/app/undocommands/savetooloptions.h new file mode 100644 index 000000000..4112312d9 --- /dev/null +++ b/src/app/undocommands/savetooloptions.h @@ -0,0 +1,71 @@ +/************************************************************************ + ** + ** @file savetooloptions.h + ** @author Roman Telezhynskyi + ** @date 11 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef SAVETOOLOPTIONS_H +#define SAVETOOLOPTIONS_H + +#include +#include + +class VPattern; + +class SaveToolOptions : public QObject, public QUndoCommand +{ + Q_OBJECT +public: + SaveToolOptions(const QDomElement &oldXml, const QDomElement &newXml, VPattern *doc, const quint32 &id, QUndoCommand *parent = 0); + virtual ~SaveToolOptions(); + virtual void undo(); + virtual void redo(); + virtual bool mergeWith(const QUndoCommand *command); + virtual int id() const; + QDomElement getNewXml() const; + quint32 getToolId() const; +signals: + void NeedLiteParsing(); +private: + Q_DISABLE_COPY(SaveToolOptions) + const QDomElement oldXml; + QDomElement newXml; + VPattern *doc; + const quint32 toolId; +}; + +//--------------------------------------------------------------------------------------------------------------------- +inline QDomElement SaveToolOptions::getNewXml() const +{ + return newXml; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline quint32 SaveToolOptions::getToolId() const +{ + return toolId; +} + +#endif // SAVETOOLOPTIONS_H diff --git a/src/app/undocommands/undocommands.h b/src/app/undocommands/undocommands.h new file mode 100644 index 000000000..ed7f7c93a --- /dev/null +++ b/src/app/undocommands/undocommands.h @@ -0,0 +1,44 @@ +/************************************************************************ + ** + ** @file undocommands.h + ** @author Roman Telezhynskyi + ** @date 11 6, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef UNDOCOMMANDS_H +#define UNDOCOMMANDS_H + +enum class UndoCommand: char { AddPatternPiece, + AddToCalc, + MoveSpline, + MoveSplinePath, + MoveSPoint, + SaveToolOptions, + SaveDetailOptions, + MoveDetail, + DeleteTool, + DeletePatternPiece + }; + +#endif // UNDOCOMMANDS_H diff --git a/src/app/undocommands/undocommands.pri b/src/app/undocommands/undocommands.pri new file mode 100644 index 000000000..22d36e3f7 --- /dev/null +++ b/src/app/undocommands/undocommands.pri @@ -0,0 +1,34 @@ +HEADERS += \ + undocommands/addtocalc.h \ + undocommands/addpatternpiece.h \ + undocommands/movespoint.h \ + undocommands/movespline.h \ + undocommands/movesplinepath.h \ + undocommands/savetooloptions.h \ + undocommands/undocommands.h \ + undocommands/savedetailoptions.h \ + undocommands/movedetail.h \ + undocommands/deltool.h \ + undocommands/deletepatternpiece.h \ + undocommands/adddetnode.h \ + undocommands/adddet.h \ + undocommands/adduniondetails.h \ + undocommands/deletedetail.h + + +SOURCES += \ + undocommands/addtocalc.cpp \ + undocommands/addpatternpiece.cpp \ + undocommands/movespoint.cpp \ + undocommands/movespline.cpp \ + undocommands/movesplinepath.cpp \ + undocommands/savetooloptions.cpp \ + undocommands/savedetailoptions.cpp \ + undocommands/movedetail.cpp \ + undocommands/deltool.cpp \ + undocommands/deletepatternpiece.cpp \ + undocommands/adddetnode.cpp \ + undocommands/adddet.cpp \ + undocommands/adduniondetails.cpp \ + undocommands/deletedetail.cpp + diff --git a/src/app/widgets/doubledelegate.cpp b/src/app/widgets/doubledelegate.cpp index e36704f77..0411b07d9 100644 --- a/src/app/widgets/doubledelegate.cpp +++ b/src/app/widgets/doubledelegate.cpp @@ -31,6 +31,14 @@ #include "../options.h" //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief createEditorReturns the widget used to edit the item specified by index for editing. The parent widget and + * style option are used to control how the editor widget appears. + * @param parent parent widget. + * @param option item options. + * @param index index of data item. + * @return editor to be used for editing the data item. + */ //cppcheck-suppress unusedFunction QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const @@ -45,6 +53,12 @@ QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOption } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setEditorData sets the data to be displayed and edited by the editor from the data model item specified by + * the model index. + * @param editor editor. + * @param index index of data item. + */ //cppcheck-suppress unusedFunction void DoubleSpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { @@ -56,6 +70,12 @@ void DoubleSpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &in } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setModelData gets data from the editor widget and stores it in the specified model at the item index. + * @param editor editor. + * @param model model. + * @param index index of data item. + */ //cppcheck-suppress unusedFunction void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { @@ -68,6 +88,13 @@ void DoubleSpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *mo } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief updateEditorGeometry updates the editor for the item specified by index according to the style option + * given. + * @param editor editor. + * @param option item options. + * @param index index of data item. + */ //cppcheck-suppress unusedFunction void DoubleSpinBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const @@ -77,6 +104,9 @@ void DoubleSpinBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOp } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief commitAndCloseEditor commit value if changed. + */ void DoubleSpinBoxDelegate::commitAndCloseEditor() { QDoubleSpinBox *spinBox = qobject_cast(sender()); diff --git a/src/app/widgets/doubledelegate.h b/src/app/widgets/doubledelegate.h index 9d8c258a7..61ca17124 100644 --- a/src/app/widgets/doubledelegate.h +++ b/src/app/widgets/doubledelegate.h @@ -39,51 +39,19 @@ class DoubleSpinBoxDelegate : public QItemDelegate { Q_OBJECT public: - /** - * @brief DoubleSpinBoxDelegate constructor. - * @param parent parent object. - */ + /** + * @brief DoubleSpinBoxDelegate constructor. + * @param parent parent object. + */ DoubleSpinBoxDelegate(QObject *parent = nullptr): QItemDelegate(parent), lastValue(-10001.0){} - /** - * @brief createEditorReturns the widget used to edit the item specified by index for editing. The parent widget and - * style option are used to control how the editor widget appears. - * @param parent parent widget. - * @param option item options. - * @param index index of data item. - * @return editor to be used for editing the data item. - */ QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; - /** - * @brief setEditorData sets the data to be displayed and edited by the editor from the data model item specified by - * the model index. - * @param editor editor. - * @param index index of data item. - */ void setEditorData(QWidget *editor, const QModelIndex &index) const; - /** - * @brief setModelData gets data from the editor widget and stores it in the specified model at the item index. - * @param editor editor. - * @param model model. - * @param index index of data item. - */ void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; - /** - * @brief updateEditorGeometry updates the editor for the item specified by index according to the style option - * given. - * @param editor editor. - * @param option item options. - * @param index index of data item. - */ void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; public slots: - /** - * @brief commitAndCloseEditor commit value if changed. - */ void commitAndCloseEditor(); private: - /** - * @brief lastValue last saved value. - */ + /** @brief lastValue last saved value. */ qreal lastValue; }; diff --git a/src/app/widgets/textdelegate.cpp b/src/app/widgets/textdelegate.cpp index d3605d3a6..47fc974f7 100644 --- a/src/app/widgets/textdelegate.cpp +++ b/src/app/widgets/textdelegate.cpp @@ -31,6 +31,10 @@ #include "../options.h" //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief TextDelegate constructor. + * @param parent parent widget. + */ TextDelegate::TextDelegate(const QString ®ex, QObject *parent): QItemDelegate(parent), lastText(QString("Name_")), regex(regex) { @@ -39,6 +43,14 @@ TextDelegate::TextDelegate(const QString ®ex, QObject *parent): QItemDelegate } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief createEditorReturns the widget used to edit the item specified by index for editing. The parent widget and + * style option are used to control how the editor widget appears. + * @param parent parent widget. + * @param option item options. + * @param index index of data item. + * @return editor to be used for editing the data item. + */ QWidget *TextDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_UNUSED(option); @@ -51,6 +63,12 @@ QWidget *TextDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setEditorData sets the data to be displayed and edited by the editor from the data model item specified by + * the model index. + * @param editor editor. + * @param index index of data item. + */ void TextDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QString text = index.model()->data(index, Qt::EditRole).toString(); @@ -66,6 +84,12 @@ void TextDelegate::setEditorData(QWidget *editor, const QModelIndex &index) cons } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setModelData gets data from the editor widget and stores it in the specified model at the item index. + * @param editor editor. + * @param model model. + * @param index index of data item. + */ void TextDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { QLineEdit *lineEdit = qobject_cast(editor); @@ -80,6 +104,13 @@ void TextDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, cons } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief updateEditorGeometry updates the editor for the item specified by index according to the style option + * given. + * @param editor editor. + * @param option item options. + * @param index index of data item. + */ void TextDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const { @@ -88,6 +119,9 @@ void TextDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewI } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief commitAndCloseEditor commit value if changed. + */ void TextDelegate::commitAndCloseEditor() { QLineEdit *lineEdit = qobject_cast(sender()); @@ -107,6 +141,10 @@ void TextDelegate::commitAndCloseEditor() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief InitText initialize text. + * @param text text. + */ void TextDelegate::InitText(const QString &text) { lastText = text; diff --git a/src/app/widgets/textdelegate.h b/src/app/widgets/textdelegate.h index ff05b52d1..77f0a8462 100644 --- a/src/app/widgets/textdelegate.h +++ b/src/app/widgets/textdelegate.h @@ -39,41 +39,10 @@ class TextDelegate : public QItemDelegate { Q_OBJECT public: - /** - * @brief TextDelegate constructor. - * @param parent parent widget. - */ TextDelegate(const QString ®ex, QObject *parent = nullptr); - /** - * @brief createEditorReturns the widget used to edit the item specified by index for editing. The parent widget and - * style option are used to control how the editor widget appears. - * @param parent parent widget. - * @param option item options. - * @param index index of data item. - * @return editor to be used for editing the data item. - */ QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; - /** - * @brief setEditorData sets the data to be displayed and edited by the editor from the data model item specified by - * the model index. - * @param editor editor. - * @param index index of data item. - */ void setEditorData(QWidget *editor, const QModelIndex &index) const; - /** - * @brief setModelData gets data from the editor widget and stores it in the specified model at the item index. - * @param editor editor. - * @param model model. - * @param index index of data item. - */ void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; - /** - * @brief updateEditorGeometry updates the editor for the item specified by index according to the style option - * given. - * @param editor editor. - * @param option item options. - * @param index index of data item. - */ void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; signals: /** @@ -82,21 +51,12 @@ signals: */ void SaveText(const QString &text) const; public slots: - /** - * @brief commitAndCloseEditor commit value if changed. - */ void commitAndCloseEditor(); - /** - * @brief InitText initialize text. - * @param text text. - */ void InitText(const QString &text); private: - /** - * @brief lastValue last saved value. - */ - QString lastText; - QString regex; + /** @brief lastValue last saved value. */ + QString lastText; + QString regex; }; #endif // TEXTDELEGATE_H diff --git a/src/app/widgets/vapplication.cpp b/src/app/widgets/vapplication.cpp index 40cd580f5..eb5d6b7d4 100644 --- a/src/app/widgets/vapplication.cpp +++ b/src/app/widgets/vapplication.cpp @@ -32,26 +32,37 @@ #include "../exception/vexceptionconversionerror.h" #include "../exception/vexceptionemptyparameter.h" #include "../exception/vexceptionwrongid.h" +#include "vmaingraphicsview.h" +#include "../container/calculator.h" -#include #include #include #include -#include -#include +#include + +#ifdef Q_OS_WIN32 +# include // for M_PI on Windows +#endif /*Q_OS_WIN32*/ const qreal VApplication::PrintDPI = 96.0; #define DefWidth 1.2//mm //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VApplication constructor. + * @param argc number arguments. + * @param argv command line. + */ VApplication::VApplication(int &argc, char **argv) - : QApplication(argc, argv), _patternUnit(Valentina::Cm), _patternType(Pattern::Individual), + : QApplication(argc, argv), _patternUnit(Unit::Cm), _patternType(MeasurementsType::Individual), _widthMainLine(DefWidth), _widthHairLine(DefWidth/3.0), measurements(QMap()), guiTexts(QMap()), descriptions(QMap()), variables(QMap()), functions(QMap()), - postfixOperators(QMap()) + postfixOperators(QMap()), undoStack(nullptr), sceneView(nullptr), autoSaveTimer(nullptr) { + undoStack = new QUndoStack(this); + InitLineWidth(); InitMeasurements(); InitVariables(); @@ -60,6 +71,12 @@ VApplication::VApplication(int &argc, char **argv) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief notify Reimplemented from QApplication::notify(). + * @param receiver receiver. + * @param event event. + * @return value that is returned from the receiver's event handler. + */ // reimplemented from QApplication so we can throw exceptions in slots bool VApplication::notify(QObject *receiver, QEvent *event) { @@ -110,13 +127,13 @@ double VApplication::toPixel(double unit) const double result = 0; switch (_patternUnit) { - case Valentina::Mm: + case Unit::Mm: result = (unit / 25.4) * PrintDPI; break; - case Valentina::Cm: + case Unit::Cm: result = ((unit * 10.0) / 25.4) * PrintDPI; break; - case Valentina::Inch: + case Unit::Inch: result = unit * PrintDPI; break; default: @@ -131,13 +148,13 @@ double VApplication::fromPixel(double pix) const double result = 0; switch (_patternUnit) { - case Valentina::Mm: + case Unit::Mm: result = (pix / PrintDPI) * 25.4; break; - case Valentina::Cm: + case Unit::Cm: result = ((pix / PrintDPI) * 25.4) / 10.0; break; - case Valentina::Inch: + case Unit::Inch: result = pix / PrintDPI; break; default: @@ -149,7 +166,7 @@ double VApplication::fromPixel(double pix) const //--------------------------------------------------------------------------------------------------------------------- QString VApplication::pathToTables() const { - if (_patternType == Pattern::Individual) + if (_patternType == MeasurementsType::Individual) { return QStringLiteral("://tables/individual/individual.vit"); } @@ -202,13 +219,13 @@ void VApplication::InitLineWidth() { switch (_patternUnit) { - case Valentina::Mm: + case Unit::Mm: _widthMainLine = DefWidth; break; - case Valentina::Cm: + case Unit::Cm: _widthMainLine = DefWidth/10.0; break; - case Valentina::Inch: + case Unit::Inch: _widthMainLine = DefWidth/25.4; break; default: @@ -1627,7 +1644,7 @@ void VApplication::BiasTokens(int position, int bias, QMap &tokens } //--------------------------------------------------------------------------------------------------------------------- -void VApplication::setPatternUnit(const Valentina::Units &patternUnit) +void VApplication::setPatternUnit(const Unit &patternUnit) { _patternUnit = patternUnit; InitLineWidth(); diff --git a/src/app/widgets/vapplication.h b/src/app/widgets/vapplication.h index 820ea55e5..acbf8bb57 100644 --- a/src/app/widgets/vapplication.h +++ b/src/app/widgets/vapplication.h @@ -34,6 +34,8 @@ #include "vtranslation.h" class VApplication; +class QUndoStack; +class VMainGraphicsView; #if defined(qApp) #undef qApp @@ -47,92 +49,123 @@ class VApplication : public QApplication { Q_OBJECT public: - /** - * @brief VApplication constructor. - * @param argc number arguments. - * @param argv command line. - */ VApplication(int &argc, char ** argv); virtual ~VApplication() {} - /** - * @brief notify Reimplemented from QApplication::notify(). - * @param receiver receiver. - * @param event event. - * @return value that is returned from the receiver's event handler. - */ - virtual bool notify(QObject * receiver, QEvent * event); - Valentina::Units patternUnit() const; - void setPatternUnit(const Valentina::Units &patternUnit); - Pattern::Measurements patternType() const; - void setPatternType(const Pattern::Measurements &patternType); - double toPixel(double unit) const; - double fromPixel(double pix) const; - static const qreal PrintDPI; - QString translationsPath() const; - QString pathToTables() const; - qreal widthMainLine() const; - qreal widthHairLine() const; - QString VarToUser(const QString &var) const; - QString VarFromUser(const QString &var) const; - QString GuiText(const QString &measurement) const; - QString Description(const QString &measurement) const; - QString Variable(const QString &name) const; - QString Function(const QString &name) const; - QString PostfixOperator(const QString &name) const; - QString FormulaFromUser(const QString &formula); - QString FormulaToUser(const QString &formula); + virtual bool notify(QObject * receiver, QEvent * event); + Unit patternUnit() const; + void setPatternUnit(const Unit &patternUnit); + MeasurementsType patternType() const; + void setPatternType(const MeasurementsType &patternType); + double toPixel(double unit) const; + double fromPixel(double pix) const; + static const qreal PrintDPI; + QString translationsPath() const; + QString pathToTables() const; + qreal widthMainLine() const; + qreal widthHairLine() const; + QString VarToUser(const QString &var) const; + QString VarFromUser(const QString &var) const; + QString GuiText(const QString &measurement) const; + QString Description(const QString &measurement) const; + QString Variable(const QString &name) const; + QString Function(const QString &name) const; + QString PostfixOperator(const QString &name) const; + QString FormulaFromUser(const QString &formula); + QString FormulaToUser(const QString &formula); + QUndoStack *getUndoStack() const; + VMainGraphicsView *getSceneView() const; + void setSceneView(VMainGraphicsView *value); + QTimer *getAutoSaveTimer() const; + void setAutoSaveTimer(QTimer *value); private: - Valentina::Units _patternUnit; - Pattern::Measurements _patternType; - qreal _widthMainLine; - qreal _widthHairLine; + Q_DISABLE_COPY(VApplication) + Unit _patternUnit; + MeasurementsType _patternType; + qreal _widthMainLine; + qreal _widthHairLine; QMap measurements; QMap guiTexts; QMap descriptions; QMap variables; QMap functions; QMap postfixOperators; - void InitLineWidth(); - void InitMeasurements(); - void InitVariables(); - void InitFunctions(); - void InitPostfixOperators(); - bool MeasurementsFromUser(QString &newFormula, int position, const QString &token, - int &bias) const; - bool VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const; - bool PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token, - int &bias) const; - bool FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const; - bool VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const; - void CorrectionsPositions(int position, int bias, QMap &tokens, - QMap &numbers); - void BiasTokens(int position, int bias, QMap &tokens) const; - + QUndoStack *undoStack; + VMainGraphicsView *sceneView; + QTimer *autoSaveTimer; + void InitLineWidth(); + void InitMeasurements(); + void InitVariables(); + void InitFunctions(); + void InitPostfixOperators(); + bool MeasurementsFromUser(QString &newFormula, int position, const QString &token, int &bias) const; + bool VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const; + bool PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token, + int &bias) const; + bool FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const; + bool VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const; + void CorrectionsPositions(int position, int bias, QMap &tokens, + QMap &numbers); + void BiasTokens(int position, int bias, QMap &tokens) const; }; -inline Valentina::Units VApplication::patternUnit() const +//--------------------------------------------------------------------------------------------------------------------- +inline Unit VApplication::patternUnit() const { return _patternUnit; } -inline Pattern::Measurements VApplication::patternType() const +//--------------------------------------------------------------------------------------------------------------------- +inline MeasurementsType VApplication::patternType() const { return _patternType; } -inline void VApplication::setPatternType(const Pattern::Measurements &patternType) +//--------------------------------------------------------------------------------------------------------------------- +inline void VApplication::setPatternType(const MeasurementsType &patternType) { _patternType = patternType; } +//--------------------------------------------------------------------------------------------------------------------- inline qreal VApplication::widthMainLine() const { return _widthMainLine; } +//--------------------------------------------------------------------------------------------------------------------- inline qreal VApplication::widthHairLine() const { return _widthHairLine; } +//--------------------------------------------------------------------------------------------------------------------- +inline QUndoStack *VApplication::getUndoStack() const +{ + return undoStack; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline VMainGraphicsView *VApplication::getSceneView() const +{ + return sceneView; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VApplication::setSceneView(VMainGraphicsView *value) +{ + sceneView = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline QTimer *VApplication::getAutoSaveTimer() const +{ + return autoSaveTimer; +} + +//--------------------------------------------------------------------------------------------------------------------- +inline void VApplication::setAutoSaveTimer(QTimer *value) +{ + autoSaveTimer = value; +} + #endif // VAPPLICATION_H diff --git a/src/app/widgets/vcontrolpointspline.cpp b/src/app/widgets/vcontrolpointspline.cpp index ec28865bd..9a8f46b3e 100644 --- a/src/app/widgets/vcontrolpointspline.cpp +++ b/src/app/widgets/vcontrolpointspline.cpp @@ -33,11 +33,18 @@ #include "../widgets/vapplication.h" //--------------------------------------------------------------------------------------------------------------------- -VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePoint::Position position, +/** + * @brief VControlPointSpline constructor. + * @param indexSpline index spline in list. + * @param position position point in spline. + * @param controlPoint control point. + * @param splinePoint spline point. + * @param parent parent object. + */ +VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, const QPointF &controlPoint, const QPointF &splinePoint, QGraphicsItem *parent) - :QGraphicsEllipseItem(parent), radius(0), controlLine(nullptr), indexSpline(indexSpline), - position(position) + :QGraphicsEllipseItem(parent), radius(0), controlLine(nullptr), indexSpline(indexSpline), position(position) { //create circle radius = (1.5/*mm*/ / 25.4) * VApplication::PrintDPI; @@ -60,6 +67,10 @@ VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePoint: } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ void VControlPointSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -74,6 +85,12 @@ void VControlPointSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange handle item change. + * @param change change. + * @param value value. + * @return value. + */ QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) { if (change == ItemPositionChange && scene()) @@ -86,7 +103,14 @@ QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange chang } //--------------------------------------------------------------------------------------------------------------------- -void VControlPointSpline::RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos, +/** + * @brief RefreshLine refresh line control point. + * @param indexSpline index spline in list. + * @param pos position point in spline. + * @param controlPoint control point. + * @param splinePoint spline point. + */ +void VControlPointSpline::RefreshLine(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint, const QPointF &splinePoint) { if (this->indexSpline == indexSpline && this->position == pos) @@ -98,6 +122,10 @@ void VControlPointSpline::RefreshLine(const qint32 &indexSpline, SplinePoint::Po } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setEnabledPoint disable or enable control point. + * @param enable true - enable. + */ void VControlPointSpline::setEnabledPoint(bool enable) { if (enable == true) diff --git a/src/app/widgets/vcontrolpointspline.h b/src/app/widgets/vcontrolpointspline.h index 9a6745b59..b29686827 100644 --- a/src/app/widgets/vcontrolpointspline.h +++ b/src/app/widgets/vcontrolpointspline.h @@ -40,17 +40,8 @@ class VControlPointSpline : public QObject, public QGraphicsEllipseItem { Q_OBJECT public: - /** - * @brief VControlPointSpline constructor. - * @param indexSpline index spline in list. - * @param position position point in spline. - * @param controlPoint control point. - * @param splinePoint spline point. - * @param parent parent object. - */ - VControlPointSpline(const qint32 &indexSpline, SplinePoint::Position position, - const QPointF &controlPoint, const QPointF &splinePoint, - QGraphicsItem * parent = nullptr); + VControlPointSpline(const qint32 &indexSpline, SplinePointPosition position, const QPointF &controlPoint, + const QPointF &splinePoint, QGraphicsItem * parent = nullptr); signals: /** * @brief ControlPointChangePosition emit when control point change position. @@ -58,59 +49,29 @@ signals: * @param position position point in spline. * @param pos new posotion. */ - void ControlPointChangePosition(const qint32 &indexSpline, SplinePoint::Position position, + void ControlPointChangePosition(const qint32 &indexSpline, SplinePointPosition position, const QPointF pos); public slots: - /** - * @brief RefreshLine refresh line control point. - * @param indexSpline index spline in list. - * @param pos position point in spline. - * @param controlPoint control point. - * @param splinePoint spline point. - */ - void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos, const QPointF &controlPoint, + void RefreshLine(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint, const QPointF &splinePoint); - /** - * @brief setEnabledPoint disable or enable control point. - * @param enable true - enable. - */ void setEnabledPoint(bool enable); protected: - /** - * @brief radius radius circle. - */ + /** @brief radius radius circle. */ qreal radius; - /** - * @brief controlLine pointer to line control point. - */ + + /** @brief controlLine pointer to line control point. */ QGraphicsLineItem *controlLine; - /** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ + virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief itemChange handle item change. - * @param change change. - * @param value value. - * @return value. - */ QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); private: Q_DISABLE_COPY(VControlPointSpline) - /** - * @brief indexSpline index spline in list.. - */ + /** @brief indexSpline index spline in list.. */ qint32 indexSpline; - /** - * @brief position position point in spline. - */ - SplinePoint::Position position; + + /** @brief position position point in spline. */ + SplinePointPosition position; }; #endif // VCONTROLPOINTSPLINE_H diff --git a/src/app/widgets/vgraphicssimpletextitem.cpp b/src/app/widgets/vgraphicssimpletextitem.cpp index 4cadfbbe2..5621f7703 100644 --- a/src/app/widgets/vgraphicssimpletextitem.cpp +++ b/src/app/widgets/vgraphicssimpletextitem.cpp @@ -28,9 +28,11 @@ #include "vgraphicssimpletextitem.h" -#include - //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VGraphicsSimpleTextItem default constructor. + * @param parent parent object. + */ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent) :QGraphicsSimpleTextItem(parent), fontSize(0) { @@ -45,6 +47,11 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VGraphicsSimpleTextItem constructor. + * @param text text. + * @param parent parent object. + */ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent ) :QGraphicsSimpleTextItem(text, parent), fontSize(0) { @@ -55,6 +62,12 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphic } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange handle item change. + * @param change change. + * @param value value. + * @return value. + */ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QVariant &value) { if (change == ItemPositionChange && scene()) @@ -66,6 +79,10 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ void VGraphicsSimpleTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -73,6 +90,10 @@ void VGraphicsSimpleTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -80,6 +101,10 @@ void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief contextMenuEvent handle context menu events. + * @param event context menu event. + */ void VGraphicsSimpleTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { emit ShowContextMenu(event); diff --git a/src/app/widgets/vgraphicssimpletextitem.h b/src/app/widgets/vgraphicssimpletextitem.h index 9593d0da8..89d7da52b 100644 --- a/src/app/widgets/vgraphicssimpletextitem.h +++ b/src/app/widgets/vgraphicssimpletextitem.h @@ -30,6 +30,7 @@ #define VGRAPHICSSIMPLETEXTITEM_H #include +#include /** * @brief The VGraphicsSimpleTextItem class pointer label. @@ -38,16 +39,9 @@ class VGraphicsSimpleTextItem : public QObject, public QGraphicsSimpleTextItem { Q_OBJECT public: - /** - * @brief VGraphicsSimpleTextItem default constructor. - * @param parent parent object. - */ + VGraphicsSimpleTextItem(QGraphicsItem * parent = nullptr); - /** - * @brief VGraphicsSimpleTextItem constructor. - * @param text text. - * @param parent parent object. - */ + VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent = nullptr ); /** * @brief FontSize return label font size. @@ -66,32 +60,12 @@ signals: */ void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); protected: - /** - * @brief itemChange handle item change. - * @param change change. - * @param value value. - * @return value. - */ QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); - /** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief contextMenuEvent handle context menu events. - * @param event context menu event. - */ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); private: - /** - * @brief fontSize label font size. - */ + /** @brief fontSize label font size. */ qint32 fontSize; }; diff --git a/src/app/widgets/vitem.cpp b/src/app/widgets/vitem.cpp index f75559412..dfb5f6cec 100644 --- a/src/app/widgets/vitem.cpp +++ b/src/app/widgets/vitem.cpp @@ -33,20 +33,37 @@ #include "../widgets/vapplication.h" //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VItem constructor. + * @param path detail path. + * @param numInList index in list of details. + * @param parent parent object. + */ VItem::VItem (const QPainterPath & path, int numInList, QGraphicsItem * parent ) :QGraphicsPathItem ( path, parent ), numInOutList(numInList), paper(nullptr) {} //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VItem default constructor. + */ VItem::VItem():numInOutList(0), paper(nullptr) {} //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VItem constructor. + * @param numInList index in list of details. + * @param parent parent object. + */ VItem::VItem(int numInList, QGraphicsItem *parent):QGraphicsPathItem (parent), numInOutList(numInList), paper(nullptr) {} //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief checkItemChange change item change. If detail create colission or moved out paper emit signal. + */ void VItem::checkItemChange() { QRectF rect; @@ -87,6 +104,12 @@ void VItem::checkItemChange() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief itemChange handle item change. + * @param change change. + * @param value value. + * @return value. + */ QVariant VItem::itemChange( GraphicsItemChange change, const QVariant &value ) { if ( change == QGraphicsItem::ItemPositionHasChanged && scene() ) @@ -103,6 +126,9 @@ QVariant VItem::itemChange( GraphicsItemChange change, const QVariant &value ) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief LengthChanged handle signal change paper length. + */ void VItem::LengthChanged() { checkItemChange(); diff --git a/src/app/widgets/vitem.h b/src/app/widgets/vitem.h index e30c12cdd..63f31353a 100644 --- a/src/app/widgets/vitem.h +++ b/src/app/widgets/vitem.h @@ -39,28 +39,9 @@ class VItem : public QObject, public QGraphicsPathItem { Q_OBJECT public: - /** - * @brief VItem default constructor. - */ - VItem (); - /** - * @brief VItem constructor. - * @param numInList index in list of details. - * @param parent parent object. - */ - VItem (int numInList, QGraphicsItem * parent = nullptr); - /** - * @brief VItem constructor. - * @param path detail path. - * @param numInList index in list of details. - * @param parent parent object. - */ - VItem ( const QPainterPath & path, int numInList, QGraphicsItem * parent = nullptr ); - /** - * @brief Rotate rotate detail on angle in degree. - * @param angle angle in degree. - */ - void Rotate ( qreal angle ); + VItem (); + VItem (int numInList, QGraphicsItem * parent = nullptr); + VItem ( const QPainterPath & path, int numInList, QGraphicsItem * parent = nullptr ); /** * @brief getPaper return pointer to paper sheet. * @return pointer to paper sheet. @@ -72,36 +53,17 @@ public: */ void setPaper(QGraphicsRectItem *value) {paper = value;} public slots: - /** - * @brief LengthChanged handle signal change paper length. - */ void LengthChanged(); - /** - * @brief SetIndexInList set detail index in list. - * @param index index in list. - */ void SetIndexInList( qint32 index ); protected: - /** - * @brief itemChange handle item change. - * @param change change. - * @param value value. - * @return value. - */ QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); - /** - * @brief checkItemChange change item change. If detail create colission or moved out paper emit signal. - */ void checkItemChange (); private: Q_DISABLE_COPY(VItem) - /** - * @brief numInOutList index in list. - */ + /** @brief numInOutList index in list. */ qint32 numInOutList; - /** - * @brief paper pointer to paper item. - */ + + /** @brief paper pointer to paper item. */ QGraphicsRectItem* paper; signals: /** @@ -118,6 +80,11 @@ signals: void itemColliding ( QList list, int number ); }; +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetIndexInList set detail index in list. + * @param index index in list. + */ inline void VItem::SetIndexInList(qint32 index) { numInOutList = index; diff --git a/src/app/widgets/vmaingraphicsscene.cpp b/src/app/widgets/vmaingraphicsscene.cpp index f96733bce..761327227 100644 --- a/src/app/widgets/vmaingraphicsscene.cpp +++ b/src/app/widgets/vmaingraphicsscene.cpp @@ -28,19 +28,29 @@ #include "vmaingraphicsscene.h" -#include - //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VMainGraphicsScene default constructor. + */ VMainGraphicsScene::VMainGraphicsScene() :QGraphicsScene(), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform()) {} //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VMainGraphicsScene constructor. + * @param sceneRect scene rect. + * @param parent parent object. + */ VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * parent) :QGraphicsScene ( sceneRect, parent ), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform()) {} //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseMoveEvent handle mouse move events. + * @param event mouse move event. + */ void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { emit mouseMove(event->scenePos()); @@ -48,6 +58,10 @@ void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mousePressEvent mouse press events. + * @param event mouse press event + */ void VMainGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event) { emit mousePress(event->scenePos()); @@ -55,24 +69,41 @@ void VMainGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief transform return view transformation. + * @return view transformation. + */ QTransform VMainGraphicsScene::transform() const { return _transform; } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setTransform set view transformation. + * @param transform view transformation. + */ void VMainGraphicsScene::setTransform(const QTransform &transform) { _transform = transform; } //--------------------------------------------------------------------------------------------------------------------- -void VMainGraphicsScene::ChoosedItem(quint32 id, const Valentina::Scenes &type) +/** + * @brief ChoosedItem emit ChoosedObject signal. + * @param id object id. + * @param type object scene type. + */ +void VMainGraphicsScene::ChoosedItem(quint32 id, const SceneObject &type) { emit ChoosedObject(id, type); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetFactor set current scale factor of scene. + * @param factor scene scale factor. scene scale factor. + */ void VMainGraphicsScene::SetFactor(qreal factor) { scaleFactor=scaleFactor*factor; diff --git a/src/app/widgets/vmaingraphicsscene.h b/src/app/widgets/vmaingraphicsscene.h index b32ab8470..da0489ea9 100644 --- a/src/app/widgets/vmaingraphicsscene.h +++ b/src/app/widgets/vmaingraphicsscene.h @@ -39,68 +39,19 @@ class VMainGraphicsScene : public QGraphicsScene { Q_OBJECT public: - /** - * @brief VMainGraphicsScene default constructor. - */ - VMainGraphicsScene(); - /** - * @brief VMainGraphicsScene constructor. - * @param sceneRect scene rect. - * @param parent parent object. - */ - VMainGraphicsScene(const QRectF & sceneRect, QObject * parent = nullptr); - /** - * @brief getHorScrollBar return scene horizontal scrollbar. - * @return horizontal scrollbar. - */ + VMainGraphicsScene(); + VMainGraphicsScene(const QRectF & sceneRect, QObject * parent = nullptr); qint32 getHorScrollBar() const; - /** - * @brief setHorScrollBar set scene horizontal scrollbar. - * @param value horizontal scrollbar. - */ void setHorScrollBar(const qint32 &value); - /** - * @brief getVerScrollBar return scene vertical scrollbar. - * @return vertical scrollbar. - */ qint32 getVerScrollBar() const; - /** - * @brief setVerScrollBar set scene vertical scrollbar. - * @param value vertical scrollbar. - */ void setVerScrollBar(const qint32 &value); - /** - * @brief transform return view transformation. - * @return view transformation. - */ QTransform transform() const; - /** - * @brief setTransform set view transformation. - * @param transform view transformation. - */ void setTransform(const QTransform &transform); public slots: - /** - * @brief ChoosedItem emit ChoosedObject signal. - * @param id object id. - * @param type object scene type. - */ - void ChoosedItem(quint32 id, const Valentina::Scenes &type); - /** - * @brief SetFactor set current scale factor of scene. - * @param factor scene scale factor. scene scale factor. - */ + void ChoosedItem(quint32 id, const SceneObject &type); void SetFactor(qreal factor); protected: - /** - * @brief mouseMoveEvent handle mouse move events. - * @param event mouse move event. - */ void mouseMoveEvent(QGraphicsSceneMouseEvent* event); - /** - * @brief mousePressEvent mouse press events. - * @param event mouse press event - */ void mousePressEvent(QGraphicsSceneMouseEvent *event); signals: /** @@ -118,46 +69,61 @@ signals: * @param id object id. * @param type object scene type. */ - void ChoosedObject(quint32 id, Valentina::Scenes type); + void ChoosedObject(quint32 id, SceneObject type); /** * @brief NewFactor send new scale factor. * @param factor scene scale factor. */ void NewFactor(qreal factor); private: - /** - * @brief horScrollBar value horizontal scroll bar. - */ + /** @brief horScrollBar value horizontal scroll bar. */ qint32 horScrollBar; - /** - * @brief verScrollBar value vertical scroll bar. - */ + + /** @brief verScrollBar value vertical scroll bar. */ qint32 verScrollBar; - /** - * @brief scaleFactor scale factor. - */ + + /** @brief scaleFactor scale factor. */ qreal scaleFactor; - /** - * @brief _transform view transform value. - */ + + /** @brief _transform view transform value. */ QTransform _transform; }; +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getHorScrollBar return scene horizontal scrollbar. + * @return horizontal scrollbar. + */ inline qint32 VMainGraphicsScene::getHorScrollBar() const { return horScrollBar; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setHorScrollBar set scene horizontal scrollbar. + * @param value horizontal scrollbar. + */ inline void VMainGraphicsScene::setHorScrollBar(const qint32 &value) { horScrollBar = value; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getVerScrollBar return scene vertical scrollbar. + * @return vertical scrollbar. + */ inline qint32 VMainGraphicsScene::getVerScrollBar() const { return verScrollBar; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setVerScrollBar set scene vertical scrollbar. + * @param value vertical scrollbar. + */ inline void VMainGraphicsScene::setVerScrollBar(const qint32 &value) { verScrollBar = value; diff --git a/src/app/widgets/vmaingraphicsview.cpp b/src/app/widgets/vmaingraphicsview.cpp index d60616362..b59ba8114 100644 --- a/src/app/widgets/vmaingraphicsview.cpp +++ b/src/app/widgets/vmaingraphicsview.cpp @@ -35,6 +35,10 @@ #include "../tools/vabstracttool.h" //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VMainGraphicsView constructor. + * @param parent parent object. + */ VMainGraphicsView::VMainGraphicsView(QWidget *parent) :QGraphicsView(parent), _numScheduledScalings(0) { @@ -44,6 +48,10 @@ VMainGraphicsView::VMainGraphicsView(QWidget *parent) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief wheelEvent handle wheel events. + * @param event wheel event. + */ //cppcheck-suppress unusedFunction void VMainGraphicsView::wheelEvent(QWheelEvent *event) { @@ -71,6 +79,10 @@ void VMainGraphicsView::wheelEvent(QWheelEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief scalingTime call each time when need handle scaling. + * @param x value from 0.0 to 1.0 + */ void VMainGraphicsView::scalingTime(qreal x) { Q_UNUSED(x); @@ -90,6 +102,10 @@ void VMainGraphicsView::scalingTime(qreal x) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief scrollingTime call each time when need handle scrolling. + * @param x value from 0.0 to 1.0 + */ void VMainGraphicsView::scrollingTime(qreal x) { Q_UNUSED(x); @@ -110,6 +126,9 @@ void VMainGraphicsView::scrollingTime(qreal x) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief animFinished + */ void VMainGraphicsView::animFinished() { if (_numScheduledScalings > 0) @@ -140,6 +159,10 @@ void VMainGraphicsView::ZoomOut() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mousePressEvent handle mouse press events. + * @param mousePress mouse press event. + */ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress) { if (mousePress->button() & Qt::LeftButton) @@ -158,6 +181,10 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event) { QGraphicsView::mouseReleaseEvent ( event ); diff --git a/src/app/widgets/vmaingraphicsview.h b/src/app/widgets/vmaingraphicsview.h index aa87b9be2..c275ab525 100644 --- a/src/app/widgets/vmaingraphicsview.h +++ b/src/app/widgets/vmaingraphicsview.h @@ -38,10 +38,7 @@ class VMainGraphicsView : public QGraphicsView { Q_OBJECT public: - /** - * @brief VMainGraphicsView constructor. - * @param parent parent object. - */ + explicit VMainGraphicsView(QWidget *parent = nullptr); signals: /** @@ -50,42 +47,17 @@ signals: */ void NewFactor(qreal factor); public slots: - /** - * @brief scalingTime call each time when need handle scaling. - * @param x value from 0.0 to 1.0 - */ void scalingTime(qreal x); - /** - * @brief scrollingTime call each time when need handle scrolling. - * @param x value from 0.0 to 1.0 - */ void scrollingTime(qreal x); - /** - * @brief animFinished - */ void animFinished(); void ZoomIn(); void ZoomOut(); protected: - /** - * @brief wheelEvent handle wheel events. - * @param event wheel event. - */ void wheelEvent ( QWheelEvent * event ); - /** - * @brief mousePressEvent handle mouse press events. - * @param mousePress mouse press event. - */ void mousePressEvent(QMouseEvent *mousePress); - /** - * @brief mouseReleaseEvent handle mouse release events. - * @param event mouse release event. - */ void mouseReleaseEvent(QMouseEvent *event); private: - /** - * @brief _numScheduledScalings keep number scheduled scalings. - */ + /** @brief _numScheduledScalings keep number scheduled scalings. */ qint32 _numScheduledScalings; }; diff --git a/src/app/widgets/vsimplearc.cpp b/src/app/widgets/vsimplearc.cpp index 7a3c8a359..f7f4d4079 100644 --- a/src/app/widgets/vsimplearc.cpp +++ b/src/app/widgets/vsimplearc.cpp @@ -32,8 +32,15 @@ #include //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VSimpleArc constructor. + * @param id arc id. + * @param currentColor current color. + * @param factor scale factor. + * @param parent parent object. + */ VSimpleArc::VSimpleArc(quint32 id, Qt::GlobalColor *currentColor, qreal *factor, QObject *parent) -:QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor) + :QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor) { if (factor == nullptr) { @@ -48,6 +55,10 @@ VSimpleArc::VSimpleArc(quint32 id, Qt::GlobalColor *currentColor, qreal *factor, } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ void VSimpleArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) @@ -58,6 +69,10 @@ void VSimpleArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ void VSimpleArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -72,6 +87,10 @@ void VSimpleArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ void VSimpleArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); diff --git a/src/app/widgets/vsimplearc.h b/src/app/widgets/vsimplearc.h index fcbfe2d90..8a0f9b725 100644 --- a/src/app/widgets/vsimplearc.h +++ b/src/app/widgets/vsimplearc.h @@ -31,15 +31,7 @@ #include -namespace SimpleArc -{ - /** - * @brief The Translation enum position point. - */ - enum Translation { FirstPoint, ForthPoint }; - Q_DECLARE_FLAGS(Translations, Translation) -} -Q_DECLARE_OPERATORS_FOR_FLAGS( SimpleArc::Translations ) +enum class SimpleArcPoint : char { FirstPoint, ForthPoint }; /** * @brief The VSimpleArc class for simple arc. This object used when we cut arc and want show peaces. @@ -48,13 +40,6 @@ class VSimpleArc : public QObject, public QGraphicsPathItem { Q_OBJECT public: - /** - * @brief VSimpleArc constructor. - * @param id arc id. - * @param currentColor current color. - * @param factor scale factor. - * @param parent parent object. - */ VSimpleArc(quint32 id, Qt::GlobalColor *currentColor, qreal *factor = nullptr, QObject *parent = nullptr); signals: /** @@ -63,34 +48,18 @@ signals: */ void Choosed(quint32 id); protected: - /** - * @brief mouseReleaseEvent handle mouse release events. - * @param event mouse release event. - */ virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); private: Q_DISABLE_COPY(VSimpleArc) - /** - * @brief id arc id. - */ + /** @brief id arc id. */ quint32 id; - /** - * @brief factor scale factor. - */ + + /** @brief factor scale factor. */ qreal *factor; - /** - * @brief currentColor current color. - */ + + /** @brief currentColor current color. */ Qt::GlobalColor *currentColor; }; diff --git a/src/app/widgets/vsimplespline.cpp b/src/app/widgets/vsimplespline.cpp index bc53d4e22..fec2cf76f 100644 --- a/src/app/widgets/vsimplespline.cpp +++ b/src/app/widgets/vsimplespline.cpp @@ -32,6 +32,13 @@ #include //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VSimpleSpline constructor. + * @param id spline id. + * @param factor scene scale factor. + * @param currentColor current color. + * @param parent parent object. + */ VSimpleSpline::VSimpleSpline(quint32 id, Qt::GlobalColor *currentColor, qreal *factor, QObject *parent) :QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor) { @@ -56,6 +63,10 @@ void VSimpleSpline::ChangedActivDraw(const bool &flag) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ void VSimpleSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) @@ -66,6 +77,10 @@ void VSimpleSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ void VSimpleSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -80,6 +95,10 @@ void VSimpleSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ void VSimpleSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); diff --git a/src/app/widgets/vsimplespline.h b/src/app/widgets/vsimplespline.h index eb77e1b6e..f66243336 100644 --- a/src/app/widgets/vsimplespline.h +++ b/src/app/widgets/vsimplespline.h @@ -31,15 +31,7 @@ #include -namespace SimpleSpline -{ - /** - * @brief The Translation enum position point. - */ - enum Translation { FirstPoint, ForthPoint }; - Q_DECLARE_FLAGS(Translations, Translation) -} -Q_DECLARE_OPERATORS_FOR_FLAGS( SimpleSpline::Translations ) +enum class SimpleSplinePoint : char { FirstPoint, ForthPoint }; /** * @brief The VSimpleSpline class for simple spline. This object used when we cut spline and want show peaces. @@ -48,50 +40,27 @@ class VSimpleSpline : public QObject, public QGraphicsPathItem { Q_OBJECT public: - /** - * @brief VSimpleSpline constructor. - * @param id spline id. - * @param factor scene scale factor. - * @param currentColor current color. - * @param parent parent object. - */ VSimpleSpline(quint32 id, Qt::GlobalColor *currentColor, qreal *factor = nullptr, QObject *parent = 0); - void ChangedActivDraw(const bool &flag); + void ChangedActivDraw(const bool &flag); signals: /** * @brief Choosed send id when clicked. * @param id spline id. */ - void Choosed(quint32 id); + void Choosed(quint32 id); protected: - /** - * @brief mouseReleaseEvent handle mouse release events. - * @param event mouse release event. - */ virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); private: Q_DISABLE_COPY(VSimpleSpline) - /** - * @brief id spline id. - */ - quint32 id; - /** - * @brief factor scale factor. - */ + /** @brief id spline id. */ + quint32 id; + + /** @brief factor scale factor. */ qreal *factor; - /** - * @brief currentColor current color. - */ + + /** @brief currentColor current color. */ Qt::GlobalColor *currentColor; }; diff --git a/src/app/widgets/vsimplesplinepath.cpp b/src/app/widgets/vsimplesplinepath.cpp index 6decd6d2f..8752fcf5c 100644 --- a/src/app/widgets/vsimplesplinepath.cpp +++ b/src/app/widgets/vsimplesplinepath.cpp @@ -31,21 +31,36 @@ #include //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VSimpleSplinePath constructor. + * @param doc dom document container. + * @param data container with variables. + * @param id spline path id. + * @param factor scale factor. + */ VSimpleSplinePath::VSimpleSplinePath(VPattern *doc, VContainer *data, quint32 id, qreal *factor) :VAbstractTool(doc, data, id), factor(factor) {} //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ void VSimpleSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { - emit ChoosedTool(id, Valentina::SplinePath); + emit ChoosedTool(id, SceneObject::SplinePath); } QGraphicsItem::mouseReleaseEvent(event); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverMoveEvent handle hover move events. + * @param event hover move event. + */ void VSimpleSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); @@ -53,6 +68,10 @@ void VSimpleSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief hoverLeaveEvent handle hover leave events. + * @param event hover leave event. + */ void VSimpleSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); diff --git a/src/app/widgets/vsimplesplinepath.h b/src/app/widgets/vsimplesplinepath.h index a3c88f6aa..eb535ebcc 100644 --- a/src/app/widgets/vsimplesplinepath.h +++ b/src/app/widgets/vsimplesplinepath.h @@ -40,35 +40,14 @@ class VSimpleSplinePath : public VAbstractTool, public QGraphicsPathItem { Q_OBJECT public: - /** - * @brief VSimpleSplinePath constructor. - * @param doc dom document container. - * @param data container with variables. - * @param id spline path id. - * @param factor scale factor. - */ VSimpleSplinePath(VPattern *doc, VContainer *data, quint32 id, qreal *factor); protected: - /** - * @brief mouseReleaseEvent handle mouse release events. - * @param event mouse release event. - */ virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); - /** - * @brief hoverMoveEvent handle hover move events. - * @param event hover move event. - */ virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); - /** - * @brief hoverLeaveEvent handle hover leave events. - * @param event hover leave event. - */ virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); private: Q_DISABLE_COPY(VSimpleSplinePath) - /** - * @brief factor scale factor. - */ + /** @brief factor scale factor. */ qreal *factor; }; diff --git a/src/app/widgets/vtablegraphicsview.cpp b/src/app/widgets/vtablegraphicsview.cpp index 54fe88337..28fe99fa9 100644 --- a/src/app/widgets/vtablegraphicsview.cpp +++ b/src/app/widgets/vtablegraphicsview.cpp @@ -29,7 +29,6 @@ #include "vtablegraphicsview.h" #include -#include #include #include "../options.h" @@ -42,6 +41,9 @@ VTableGraphicsView::VTableGraphicsView(QGraphicsScene* pScene, QWidget *parent) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief selectionChanged handle selection change. + */ void VTableGraphicsView::selectionChanged() { QList listSelectedItems = scene()->selectedItems(); @@ -58,6 +60,9 @@ void VTableGraphicsView::selectionChanged() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief MirrorItem mirror detail. + */ void VTableGraphicsView::MirrorItem() { QList list = scene()->selectedItems(); @@ -99,6 +104,10 @@ void VTableGraphicsView::MirrorItem() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief wheelEvent handle wheel events. + * @param event wheel event. + */ void VTableGraphicsView::wheelEvent(QWheelEvent *event) { if (QGuiApplication::keyboardModifiers() == Qt::ControlModifier) @@ -120,6 +129,10 @@ void VTableGraphicsView::wheelEvent(QWheelEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mousePressEvent handle mouse press events. + * @param mousePress mouse press event. + */ void VTableGraphicsView::mousePressEvent(QMouseEvent *mousePress) { if (mousePress->button() & Qt::LeftButton) @@ -138,6 +151,10 @@ void VTableGraphicsView::mousePressEvent(QMouseEvent *mousePress) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mouseReleaseEvent handle mouse release events. + * @param event mouse release event. + */ void VTableGraphicsView::mouseReleaseEvent(QMouseEvent *event) { QGraphicsView::mouseReleaseEvent ( event ); @@ -145,6 +162,10 @@ void VTableGraphicsView::mouseReleaseEvent(QMouseEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief keyPressEvent handle key press events. + * @param event key press event. + */ void VTableGraphicsView::keyPressEvent(QKeyEvent *event) { switch (event->key()) @@ -171,6 +192,9 @@ void VTableGraphicsView::keyPressEvent(QKeyEvent *event) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief rotateIt rotate selected details on 180 degree. + */ void VTableGraphicsView::rotateIt() { QList list = scene()->selectedItems(); @@ -187,6 +211,10 @@ void VTableGraphicsView::rotateIt() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief MoveItem move selected detail. + * @param move type of move. + */ void VTableGraphicsView::MoveItem(VTableGraphicsView::typeMove_e move) { qreal dx = 0, dy = 0; diff --git a/src/app/widgets/vtablegraphicsview.h b/src/app/widgets/vtablegraphicsview.h index ac826609d..a627d2e31 100644 --- a/src/app/widgets/vtablegraphicsview.h +++ b/src/app/widgets/vtablegraphicsview.h @@ -51,69 +51,42 @@ signals: */ void itemChect( bool flag ); public slots: - /** - * @brief selectionChanged handle selection change. - */ void selectionChanged(); - /** - * @brief rotateItems handle rotatation detail. - */ void rotateItems(); - /** - * @brief MirrorItem mirror detail. - */ void MirrorItem(); - /** - * @brief ZoomIn zoom in paper scale. - */ void ZoomIn(); - /** - * @brief ZoomOut zoom out paper scale. - */ void ZoomOut(); protected: - /** - * @brief wheelEvent handle wheel events. - * @param event wheel event. - */ void wheelEvent ( QWheelEvent * event ); - /** - * @brief mousePressEvent handle mouse press events. - * @param mousePress mouse press event. - */ void mousePressEvent(QMouseEvent *mousePress); - /** - * @brief mouseReleaseEvent handle mouse release events. - * @param event mouse release event. - */ void mouseReleaseEvent ( QMouseEvent * event ); - /** - * @brief keyPressEvent handle key press events. - * @param event key press event. - */ void keyPressEvent ( QKeyEvent * event ); - /** - * @brief rotateIt rotate selected details on 180 degree. - */ void rotateIt(); - /** - * @brief MoveItem move selected detail. - * @param move type of move. - */ void MoveItem( VTableGraphicsView::typeMove_e move ); - }; +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief rotateItems handle rotatation detail. + */ inline void VTableGraphicsView::rotateItems() { rotateIt(); } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ZoomIn zoom in paper scale. + */ inline void VTableGraphicsView::ZoomIn() { scale(1.1, 1.1); } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ZoomOut zoom out paper scale. + */ inline void VTableGraphicsView::ZoomOut() { scale(1/1.1, 1/1.1); diff --git a/src/app/widgets/vtranslation.h b/src/app/widgets/vtranslation.h index 8fec40fb5..edcd3b3a8 100644 --- a/src/app/widgets/vtranslation.h +++ b/src/app/widgets/vtranslation.h @@ -29,7 +29,6 @@ #ifndef VTRANSLATION_H #define VTRANSLATION_H -#include #include /** diff --git a/src/app/xml/vdomdocument.cpp b/src/app/xml/vdomdocument.cpp index db5c76302..e20845a25 100644 --- a/src/app/xml/vdomdocument.cpp +++ b/src/app/xml/vdomdocument.cpp @@ -104,6 +104,11 @@ VDomDocument::~VDomDocument() {} //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Finds an element by id. + * @param id value id attribute. + * @return dom element. + */ QDomElement VDomDocument::elementById(const QString& id) { if (map.contains(id)) @@ -125,6 +130,10 @@ QDomElement VDomDocument::elementById(const QString& id) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Removes all children of a given element tag. RENAME: removeAllChildren + * @param element tag + */ void VDomDocument::removeAllChilds(QDomElement &element) { QDomNode domNode = element.firstChild(); @@ -143,6 +152,12 @@ void VDomDocument::removeAllChilds(QDomElement &element) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Find element by id. + * @param node node + * @param id id value + * @return true if found + */ bool VDomDocument::find(const QDomElement &node, const QString& id) { if (node.hasAttribute(AttrId)) @@ -170,6 +185,12 @@ bool VDomDocument::find(const QDomElement &node, const QString& id) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Returns the long long value of the given attribute. RENAME: GetParameterLongLong? + * @param domElement tag in xml tree + * @param name attribute name + * @return long long value + */ quint32 VDomDocument::GetParametrUInt(const QDomElement &domElement, const QString &name, const QString &defValue) const { Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty"); @@ -200,6 +221,13 @@ quint32 VDomDocument::GetParametrUInt(const QDomElement &domElement, const QStri } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Returns the string value of the given attribute. RENAME: see above + * + * if attribute empty return default value. If default value empty too throw exception. + * @return attribute value + * @throw VExceptionEmptyParameter when attribute is empty + */ QString VDomDocument::GetParametrString(const QDomElement &domElement, const QString &name, const QString &defValue) const { @@ -221,6 +249,12 @@ QString VDomDocument::GetParametrString(const QDomElement &domElement, const QSt } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Returns the double value of the given attribute. + * @param domElement tag in xml tree + * @param name attribute name + * @return double value + */ qreal VDomDocument::GetParametrDouble(const QDomElement &domElement, const QString &name, const QString &defValue) const { Q_ASSERT_X(name.isEmpty() == false, Q_FUNC_INFO, "name of parametr is empty"); @@ -272,6 +306,11 @@ QString VDomDocument::UniqueTagText(const QString &tagName, const QString &defVa } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ValidateXML validate xml file by xsd schema. + * @param schema path to schema file. + * @param fileName name of xml file. + */ void VDomDocument::ValidateXML(const QString &schema, const QString &fileName) { QFile pattern(fileName); @@ -344,45 +383,81 @@ void VDomDocument::setContent(const QString &fileName) } //--------------------------------------------------------------------------------------------------------------------- -Valentina::Units VDomDocument::StrToUnits(const QString &unit) +Unit VDomDocument::StrToUnits(const QString &unit) { QStringList units{UnitMM, UnitCM, UnitINCH}; - Valentina::Units result = Valentina::Cm; + Unit result = Unit::Cm; switch (units.indexOf(unit)) { case 0:// mm - result = Valentina::Mm; + result = Unit::Mm; break; case 1:// cm - result = Valentina::Cm; + result = Unit::Cm; break; case 2:// inch - result = Valentina::Inch; + result = Unit::Inch; break; default: - result = Valentina::Cm; + result = Unit::Cm; break; } return result; } //--------------------------------------------------------------------------------------------------------------------- -QString VDomDocument::UnitsToStr(const Valentina::Units &unit) +/** + * @brief UnitsToStr translate unit to string. + * + * This method used when need write unit in xml file and for showing unit in dialogs. + * @param unit curent unit + * @param translate true if need show translated name. Default value false. + * @return string reprezantation for unit. + */ +QString VDomDocument::UnitsToStr(const Unit &unit, const bool translate) { QString result; switch (unit) { - case Valentina::Mm: - result = "mm"; + case Unit::Mm: + if (translate) + { + result = QObject::tr("mm"); + } + else + { + result = "mm"; + } break; - case Valentina::Cm: - result = "cm"; + case Unit::Cm: + if (translate) + { + result = QObject::tr("cm"); + } + else + { + result = "cm"; + } break; - case Valentina::Inch: - result = "inch"; + case Unit::Inch: + if (translate) + { + result = QObject::tr("in", "inch abbreviation"); + } + else + { + result = "inch";//I decided use full name in xml file. + } break; default: - result = "cm"; + if (translate) + { + result = QObject::tr("cm"); + } + else + { + result = "cm"; + } break; } return result; @@ -491,3 +566,19 @@ void VDomDocument::setTagText(const QString &tag, const QString &text) } } } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveAllChild remove all child from file. + * @param domElement tag in xml tree. + */ +void VDomDocument::RemoveAllChild(QDomElement &domElement) +{ + if ( domElement.hasChildNodes() ) + { + while ( domElement.childNodes().length() >= 1 ) + { + domElement.removeChild( domElement.firstChild() ); + } + } +} diff --git a/src/app/xml/vdomdocument.h b/src/app/xml/vdomdocument.h index 3dbc52476..a51a2d562 100644 --- a/src/app/xml/vdomdocument.h +++ b/src/app/xml/vdomdocument.h @@ -29,11 +29,9 @@ #ifndef VDOMDOCUMENT_H #define VDOMDOCUMENT_H -#include "../container/vcontainer.h" - #include #include -#include "../options.h" +#include "../container/vcontainer.h" /* can be used like #if (V_FORMAT_VERSION >= V_FORMAT_VERSION_CHECK(4, 4, 0)) @@ -81,16 +79,7 @@ public: */ VDomDocument(VContainer *data); virtual ~VDomDocument(); - /** - * @brief Finds an element by id. - * @param id value id attribute. - * @return dom element. - */ QDomElement elementById(const QString& id); - /** - * @brief Removes all children of a given element tag. RENAME: removeAllChildren - * @param element tag - */ void removeAllChilds(QDomElement &element); template /** @@ -104,84 +93,53 @@ public: * @return cursor * @throw VExceptionUniqueId */ - void SetAttribute(QDomElement &domElement, const QString &name, const T &value) + void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const { QString val = QString().setNum(value); val = val.replace(",", "."); domElement.setAttribute(name, val); } - /** - * @brief Returns the long long value of the given attribute. RENAME: GetParameterLongLong? - * @param domElement tag in xml tree - * @param name attribute name - * @return long long value - */ - quint32 GetParametrUInt(const QDomElement& domElement, const QString &name, - const QString &defValue) const; - /** - * @brief Returns the string value of the given attribute. RENAME: see above - * - * if attribute empty return default value. If default value empty too throw exception. - * @return attribute value - * @throw VExceptionEmptyParameter when attribute is empty - */ + quint32 GetParametrUInt(const QDomElement& domElement, const QString &name, const QString &defValue) const; QString GetParametrString(const QDomElement& domElement, const QString &name, const QString &defValue = QString()) const; - /** - * @brief Returns the double value of the given attribute. - * @param domElement tag in xml tree - * @param name attribute name - * @return double value - */ qreal GetParametrDouble(const QDomElement& domElement, const QString &name, const QString &defValue) const; QString UniqueTagText(const QString &tagName, const QString &defVal = QString()) const; - /** - * @brief ValidateXML validate xml file by xsd schema. - * @param schema path to schema file. - * @param fileName name of xml file. - */ static void ValidateXML(const QString &schema, const QString &fileName); void setContent(const QString &fileName); - static Valentina::Units StrToUnits(const QString &unit); - static QString UnitsToStr(const Valentina::Units &unit); + static Unit StrToUnits(const QString &unit); + static QString UnitsToStr(const Unit &unit, const bool translate = false); virtual bool SaveDocument(const QString &fileName); QString Major() const; QString Minor() const; QString Patch() const; + static void RemoveAllChild(QDomElement &domElement); protected: - /** - * @brief data container with data. - */ + /** @brief data container with data. */ VContainer *data; - void setTagText(const QString &tag, const QString &text); + void setTagText(const QString &tag, const QString &text); private: Q_DISABLE_COPY(VDomDocument) - /** - * @brief Map used for finding element by id. - */ + /** @brief Map used for finding element by id. */ QHash map; - /** - * @brief Find element by id. - * @param node node - * @param id id value - * @return true if found - */ bool find(const QDomElement &node, const QString& id); }; +//--------------------------------------------------------------------------------------------------------------------- template <> -inline void VDomDocument::SetAttribute(QDomElement &domElement, const QString &name, const QString &value) +inline void VDomDocument::SetAttribute(QDomElement &domElement, const QString &name, + const QString &value) const { domElement.setAttribute(name, value); } +//--------------------------------------------------------------------------------------------------------------------- template <> -inline void VDomDocument::SetAttribute(QDomElement &domElement, const QString &name, - const Pattern::Measurements &value) +inline void VDomDocument::SetAttribute(QDomElement &domElement, const QString &name, + const MeasurementsType &value) const { - if (value == Pattern::Standard) + if (value == MeasurementsType::Standard) { domElement.setAttribute(name, "standard"); } diff --git a/src/app/xml/vindividualmeasurements.cpp b/src/app/xml/vindividualmeasurements.cpp index 6ff524afe..b0217e0c8 100644 --- a/src/app/xml/vindividualmeasurements.cpp +++ b/src/app/xml/vindividualmeasurements.cpp @@ -48,14 +48,14 @@ VIndividualMeasurements::~VIndividualMeasurements() {} //--------------------------------------------------------------------------------------------------------------------- -Valentina::Units VIndividualMeasurements::Unit() const +Unit VIndividualMeasurements::MUnit() const { const QString unit = UniqueTagText(TagUnit, UnitCM); return VDomDocument::StrToUnits(unit); } //--------------------------------------------------------------------------------------------------------------------- -void VIndividualMeasurements::setUnit(const Valentina::Units &unit) +void VIndividualMeasurements::setUnit(const Unit &unit) { setTagText(TagUnit, UnitsToStr(unit)); } @@ -221,7 +221,7 @@ void VIndividualMeasurements::Measurement(const QString &tag) { qreal value = GetParametrDouble(domElement, AttrValue, "0.0"); - if (Unit() == Valentina::Mm)//Convert to Cm. + if (MUnit() == Unit::Mm)//Convert to Cm. { value = value / 10.0; } @@ -269,13 +269,13 @@ void VIndividualMeasurements::setBirthDate(const QDate &date) } //--------------------------------------------------------------------------------------------------------------------- -VIndividualMeasurements::Genders VIndividualMeasurements::Sex() const +SexType VIndividualMeasurements::Sex() const { return StrToGender(UniqueTagText(TagSex, "")); } //--------------------------------------------------------------------------------------------------------------------- -void VIndividualMeasurements::setSex(const VIndividualMeasurements::Genders &sex) +void VIndividualMeasurements::setSex(const SexType &sex) { setTagText(TagSex, GenderToStr(sex)); } @@ -293,13 +293,13 @@ void VIndividualMeasurements::setMail(const QString &text) } //--------------------------------------------------------------------------------------------------------------------- -QString VIndividualMeasurements::GenderToStr(const VIndividualMeasurements::Genders &sex) +QString VIndividualMeasurements::GenderToStr(const SexType &sex) { switch (sex) { - case Male: + case SexType::Male: return SexMale; - case Female: + case SexType::Female: return SexFemale; default: return SexMale; @@ -307,16 +307,16 @@ QString VIndividualMeasurements::GenderToStr(const VIndividualMeasurements::Gend } //--------------------------------------------------------------------------------------------------------------------- -VIndividualMeasurements::Genders VIndividualMeasurements::StrToGender(const QString &sex) +SexType VIndividualMeasurements::StrToGender(const QString &sex) { QStringList genders{SexMale, SexFemale}; switch (genders.indexOf(sex)) { case 0: // SexMale - return Male; + return SexType::Male; case 1: // SexFemale - return Female; + return SexType::Female; default: - return Male; + return SexType::Male; } } diff --git a/src/app/xml/vindividualmeasurements.h b/src/app/xml/vindividualmeasurements.h index 61b0c4823..ced9a7b43 100644 --- a/src/app/xml/vindividualmeasurements.h +++ b/src/app/xml/vindividualmeasurements.h @@ -30,7 +30,6 @@ #define VINDIVIDUALMEASUREMENTS_H #include "vdomdocument.h" -#include /* VIT_VERSION is (major << 16) + (minor << 8) + patch. @@ -40,27 +39,26 @@ // max support version of format #define VIT_VERSION 0x000100 +enum class SexType : char { Male, Female }; + class VIndividualMeasurements:public VDomDocument { public: - enum Sex { Male, Female }; - Q_DECLARE_FLAGS(Genders, Sex) - VIndividualMeasurements(VContainer *data); virtual ~VIndividualMeasurements(); - Valentina::Units Unit() const; - void setUnit(const Valentina::Units &unit); - void Measurements(); - QString FamilyName() const; - void setFamilyName(const QString &text); - QString GivenName() const; - void setGivenName(const QString &text); - QDate BirthDate() const; - void setBirthDate(const QDate &date); - VIndividualMeasurements::Genders Sex() const; - void setSex(const VIndividualMeasurements::Genders &sex); - QString Mail() const; - void setMail(const QString &text); + Unit MUnit() const; + void setUnit(const Unit &unit); + void Measurements(); + QString FamilyName() const; + void setFamilyName(const QString &text); + QString GivenName() const; + void setGivenName(const QString &text); + QDate BirthDate() const; + void setBirthDate(const QDate &date); + SexType Sex() const; + void setSex(const SexType &sex); + QString Mail() const; + void setMail(const QString &text); static const QString AttrValue; static const QString TagFamily_name; static const QString TagGiven_name; @@ -71,13 +69,11 @@ public: static const QString SexMale; static const QString SexFemale; - static QString GenderToStr(const VIndividualMeasurements::Genders &sex); - static VIndividualMeasurements::Genders StrToGender(const QString &sex); + static QString GenderToStr(const SexType &sex); + static SexType StrToGender(const QString &sex); private: Q_DISABLE_COPY(VIndividualMeasurements) void Measurement(const QString &tag); }; -Q_DECLARE_OPERATORS_FOR_FLAGS( VIndividualMeasurements::Genders ) - #endif // VINDIVIDUALMEASUREMENTS_H diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 465ebba2e..4151e75e7 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -27,7 +27,7 @@ *************************************************************************/ #include "vpattern.h" - +#include "../tools/vdatatool.h" #include "../tools/vtooldetail.h" #include "../tools/vtooluniondetails.h" #include "../tools/drawTools/drawtools.h" @@ -35,12 +35,12 @@ #include "../exception/vexceptionobjecterror.h" #include "../exception/vexceptionwrongid.h" #include "../exception/vexceptionconversionerror.h" +#include "../exception/vexceptionemptyparameter.h" #include "vstandardmeasurements.h" #include "vindividualmeasurements.h" - -#include #include "../../libs/qmuparser/qmuparsererror.h" -#include +#include "../geometry/varc.h" +#include const QString VPattern::TagPattern = QStringLiteral("pattern"); const QString VPattern::TagCalculation = QStringLiteral("calculation"); @@ -70,18 +70,28 @@ const QString VPattern::IncrementKgrowth = QStringLiteral("kgrowth"); const QString VPattern::IncrementDescription = QStringLiteral("description"); //--------------------------------------------------------------------------------------------------------------------- -VPattern::VPattern(VContainer *data, QComboBox *comboBoxDraws, Valentina::Draws *mode, QObject *parent) +VPattern::VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw, + VMainGraphicsScene *sceneDetail, QObject *parent) : QObject(parent), VDomDocument(data), nameActivDraw(QString()), tools(QHash()), - history(QVector()), cursor(0), comboBoxDraws(comboBoxDraws), mode(mode), patternModified(false) -{} + history(QVector()), cursor(0), patternPieces(QStringList()), mode(mode), sceneDraw(sceneDraw), + sceneDetail(sceneDetail) +{ + SCASSERT(sceneDraw != nullptr); + SCASSERT(sceneDetail != nullptr); +} //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CreateEmptyFile create minimal empty file. + * @param tablePath path to measurement file (standard or individual) + */ void VPattern::CreateEmptyFile(const QString &tablePath) { if (tablePath.isEmpty()) { throw VException("Path to measurement table empty."); } + this->clear(); QDomElement patternElement = this->createElement(TagPattern); patternElement.appendChild(createComment("Valentina pattern format.")); @@ -108,21 +118,31 @@ void VPattern::CreateEmptyFile(const QString &tablePath) } //--------------------------------------------------------------------------------------------------------------------- -void VPattern::ChangeActivDraw(const QString &name, const Document::Documents &parse) +/** + * @brief ChangeActivPP set new active pattern piece name. + * @param name new name. + * @param parse parser file mode. + */ +void VPattern::ChangeActivPP(const QString &name, const Document &parse) { - Q_ASSERT_X(name.isEmpty() == false, "ChangeActivDraw", "name draw is empty"); - if (CheckNameDraw(name)) + Q_ASSERT_X(name.isEmpty() == false, "ChangeActivPP", "name pattern piece is empty"); + if (CheckNamePP(name)) { this->nameActivDraw = name; if (parse == Document::FullParse) { - emit ChangedActivDraw(name); + emit ChangedActivPP(name); } } } //--------------------------------------------------------------------------------------------------------------------- -bool VPattern::GetActivDrawElement(QDomElement &element) +/** + * @brief GetActivDrawElement return draw tag for current pattern peace. + * @param element draw tag. + * @return true if found. + */ +bool VPattern::GetActivDrawElement(QDomElement &element) const { if (nameActivDraw.isEmpty() == false) { @@ -148,33 +168,31 @@ bool VPattern::GetActivDrawElement(QDomElement &element) } //--------------------------------------------------------------------------------------------------------------------- -bool VPattern::appendDraw(const QString &name) +/** + * @brief appendPP add new pattern piece. + * + * Method check if not exist pattern piece with the same name and change name active pattern piece name, send signal + * about change pattern piece. Doen't add pattern piece to file structure. This task make SPoint tool. + * @param name pattern peace name. + * @return true if success. + */ +bool VPattern::appendPP(const QString &name) { - Q_ASSERT_X(name.isEmpty() == false, "appendDraw", "name draw is empty"); + Q_ASSERT_X(name.isEmpty() == false, "appendPP", "name pattern piece is empty"); if (name.isEmpty()) { return false; } - if (CheckNameDraw(name) == false) + if (CheckNamePP(name) == false) { - QDomElement rootElement = this->documentElement(); - - QDomElement drawElement = this->createElement(TagDraw); - SetAttribute(drawElement, AttrName, name); - - drawElement.appendChild(createElement(TagCalculation)); - drawElement.appendChild(createElement(TagModeling)); - drawElement.appendChild(createElement(TagDetails)); - - rootElement.appendChild(drawElement); - if (nameActivDraw.isEmpty()) { - SetActivDraw(name); + SetActivPP(name); } else { - ChangeActivDraw(name); + this->nameActivDraw = name; + emit ChangedActivPP(name); } return true; } @@ -182,6 +200,11 @@ bool VPattern::appendDraw(const QString &name) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SetNameDraw change current pattern peace. + * @param name pattern peace name. + * @return true if success. + */ bool VPattern::SetNameDraw(const QString &name) { Q_ASSERT_X(name.isEmpty() == false, "SetNameDraw", "name draw is empty"); @@ -203,12 +226,18 @@ bool VPattern::SetNameDraw(const QString &name) } //--------------------------------------------------------------------------------------------------------------------- -void VPattern::Parse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail) +/** + * @brief Parse parse file. + * @param parse parser file mode. + * @param sceneDraw pointer to draw scene. + * @param sceneDetail pointer to details scene. + */ +void VPattern::Parse(const Document &parse) { SCASSERT(sceneDraw != nullptr); SCASSERT(sceneDetail != nullptr); QStringList tags{TagDraw, TagIncrements, TagAuthor, TagDescription, TagNotes, TagMeasurements, TagVersion}; - PrepareForParse(parse, sceneDraw, sceneDetail); + PrepareForParse(parse); QDomNode domNode = documentElement().firstChild(); while (domNode.isNull() == false) { @@ -224,17 +253,17 @@ void VPattern::Parse(const Document::Documents &parse, VMainGraphicsScene *scene { if (nameActivDraw.isEmpty()) { - SetActivDraw(GetParametrString(domElement, AttrName)); + SetActivPP(GetParametrString(domElement, AttrName)); } else { - ChangeActivDraw(GetParametrString(domElement, AttrName)); + ChangeActivPP(GetParametrString(domElement, AttrName)); } - comboBoxDraws->addItem(GetParametrString(domElement, AttrName)); + patternPieces << GetParametrString(domElement, AttrName); } else { - ChangeActivDraw(GetParametrString(domElement, AttrName), Document::LiteParse); + ChangeActivPP(GetParametrString(domElement, AttrName), Document::LiteParse); } ParseDrawElement(sceneDraw, sceneDetail, domElement, parse); break; @@ -262,6 +291,11 @@ void VPattern::Parse(const Document::Documents &parse, VMainGraphicsScene *scene } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getTool return tool from tool list. + * @param id tool id. + * @return tool. + */ VDataTool *VPattern::getTool(const quint32 &id) { if (tools.contains(id)) @@ -277,21 +311,33 @@ VDataTool *VPattern::getTool(const quint32 &id) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setCursor set cursor. + * @param value cursor. + */ void VPattern::setCursor(const quint32 &value) { - cursor = value; - emit ChangedCursor(cursor); + if (cursor != value) + { + cursor = value; + emit ChangedCursor(cursor); + } } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setCurrentData set current data set. + * + * Each time after parsing need set correct data set for current pattern piece. After parsing it is always last. + * Current data set for pattern pice it is data set for last object in pattern pice (point, arc, spline, spline path so + * on). + */ void VPattern::setCurrentData() { - if (*mode == Valentina::Calculation) + if (*mode == Draw::Calculation) { - const QString nameDraw = comboBoxDraws->itemText(comboBoxDraws->currentIndex()); - if (nameActivDraw != nameDraw) + if (CountPP() > 1)//don't need upadate data if we have only one pattern piece { - nameActivDraw = nameDraw; quint32 id = 0; if (history.size() == 0) { @@ -300,7 +346,7 @@ void VPattern::setCurrentData() for (qint32 i = 0; i < history.size(); ++i) { const VToolRecord tool = history.at(i); - if (tool.getNameDraw() == nameDraw) + if (tool.getNameDraw() == nameActivDraw) { id = tool.getId(); } @@ -324,6 +370,11 @@ void VPattern::setCurrentData() } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief AddTool add tool to list tools. + * @param id tool id. + * @param tool tool. + */ void VPattern::AddTool(const quint32 &id, VDataTool *tool) { Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); @@ -332,6 +383,11 @@ void VPattern::AddTool(const quint32 &id, VDataTool *tool) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief UpdateToolData update tool in list tools. + * @param id tool id. + * @param data container with variables. + */ void VPattern::UpdateToolData(const quint32 &id, VContainer *data) { Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); @@ -342,6 +398,10 @@ void VPattern::UpdateToolData(const quint32 &id, VContainer *data) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief IncrementReferens increment reference parent objects. + * @param id parent object id. + */ void VPattern::IncrementReferens(quint32 id) const { Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); @@ -351,6 +411,10 @@ void VPattern::IncrementReferens(quint32 id) const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief DecrementReferens decrement reference parent objects. + * @param id parent object id. + */ void VPattern::DecrementReferens(quint32 id) const { Q_ASSERT_X(id > 0, Q_FUNC_INFO, "id <= 0"); @@ -360,6 +424,9 @@ void VPattern::DecrementReferens(quint32 id) const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief TestUniqueId test exist unique id in pattern file. Each id must be unique. + */ void VPattern::TestUniqueId() const { QVector vector; @@ -367,6 +434,10 @@ void VPattern::TestUniqueId() const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief SPointActiveDraw return id base point current pattern peace. + * @return id base point. + */ quint32 VPattern::SPointActiveDraw() { QDomElement calcElement; @@ -390,7 +461,12 @@ quint32 VPattern::SPointActiveDraw() } //--------------------------------------------------------------------------------------------------------------------- -bool VPattern::CheckNameDraw(const QString &name) const +/** + * @brief CheckNameDraw check if exist pattern peace with this name. + * @param name pattern peace name. + * @return true if exist. + */ +bool VPattern::CheckNamePP(const QString &name) const { Q_ASSERT_X(name.isEmpty() == false, "CheckNameDraw", "name draw is empty"); const QDomNodeList elements = this->documentElement().elementsByTagName( TagDraw ); @@ -413,14 +489,24 @@ bool VPattern::CheckNameDraw(const QString &name) const } //--------------------------------------------------------------------------------------------------------------------- -void VPattern::SetActivDraw(const QString &name) +/** + * @brief SetActivPP set current pattern piece. + * @param name pattern peace name. + */ +void VPattern::SetActivPP(const QString &name) { - Q_ASSERT_X(name.isEmpty() == false, "SetActivDraw", "name draw is empty"); + Q_ASSERT_X(name.isEmpty() == false, "SetActivPP", "name pattern piece is empty"); this->nameActivDraw = name; } //--------------------------------------------------------------------------------------------------------------------- -bool VPattern::GetActivNodeElement(const QString &name, QDomElement &element) +/** + * @brief GetActivNodeElement find element in current pattern piece by name. + * @param name name tag. + * @param element element. + * @return true if found. + */ +bool VPattern::GetActivNodeElement(const QString &name, QDomElement &element) const { Q_ASSERT_X(name.isEmpty() == false, "GetActivNodeElement", "name draw is empty"); QDomElement drawElement; @@ -481,7 +567,7 @@ void VPattern::SetPath(const QString &path) } //--------------------------------------------------------------------------------------------------------------------- -Valentina::Units VPattern::MUnit() const +Unit VPattern::MUnit() const { QDomNodeList list = elementsByTagName(VPattern::TagMeasurements); QDomElement element = list.at(0).toElement(); @@ -492,27 +578,27 @@ Valentina::Units VPattern::MUnit() const switch (units.indexOf(unit)) { case 0:// mm - return Valentina::Mm; + return Unit::Mm; break; case 1:// cm - return Valentina::Cm; + return Unit::Cm; break; case 2:// in - return Valentina::Inch; + return Unit::Inch; break; default: - return Valentina::Cm; + return Unit::Cm; break; } } else { - return Valentina::Cm; + return Unit::Cm; } } //--------------------------------------------------------------------------------------------------------------------- -Pattern::Measurements VPattern::MType() const +MeasurementsType VPattern::MType() const { QDomNodeList list = elementsByTagName(VPattern::TagMeasurements); QDomElement element = list.at(0).toElement(); @@ -523,19 +609,19 @@ Pattern::Measurements VPattern::MType() const switch (types.indexOf(type)) { case 0:// standard - return Pattern::Standard; + return MeasurementsType::Standard; break; case 1:// individual - return Pattern::Individual; + return MeasurementsType::Individual; break; default: - return Pattern::Individual; + return MeasurementsType::Individual; break; } } else { - return Pattern::Individual; + return MeasurementsType::Individual; } } @@ -551,56 +637,52 @@ bool VPattern::SaveDocument(const QString &fileName) e.CriticalMessageBox(tr("Error no unique id.")); return false; } + return VDomDocument::SaveDocument(fileName); } //--------------------------------------------------------------------------------------------------------------------- -void VPattern::FullUpdateTree() +/** + * @brief LiteParseTree lite parse file. + */ +void VPattern::LiteParseTree() { - VMainGraphicsScene *scene = nullptr; try { - scene = new VMainGraphicsScene(); - Parse(Document::LiteParse, scene, scene); + Parse(Document::LiteParse); } catch (const VExceptionObjectError &e) { - delete scene; e.CriticalMessageBox(tr("Error parsing file.")); emit ClearMainWindow(); return; } catch (const VExceptionConversionError &e) { - delete scene; e.CriticalMessageBox(tr("Error can't convert value.")); emit ClearMainWindow(); return; } catch (const VExceptionEmptyParameter &e) { - delete scene; e.CriticalMessageBox(tr("Error empty parameter.")); emit ClearMainWindow(); return; } catch (const VExceptionWrongId &e) { - delete scene; e.CriticalMessageBox(tr("Error wrong id.")); emit ClearMainWindow(); return; } catch (VException &e) { - delete scene; e.CriticalMessageBox(tr("Error parsing file.")); emit ClearMainWindow(); return; } catch (const std::bad_alloc &) { - delete scene; #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif @@ -619,27 +701,53 @@ void VPattern::FullUpdateTree() return; } - delete scene; setCurrentData(); emit FullUpdateFromFile(); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief haveLiteChange we have unsaved change. + */ void VPattern::haveLiteChange() { - patternModified = true; emit patternChanged(); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ShowHistoryTool hightlight tool. + * @param id tool id. + * @param color hightlight color. + * @param enable enable or diasable hightlight. + */ void VPattern::ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable) { emit ShowTool(id, color, enable); } //--------------------------------------------------------------------------------------------------------------------- +void VPattern::NeedFullParsing() +{ + emit UndoCommand(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::ClearScene() +{ + emit ClearMainWindow(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParseDrawElement parse draw tag. + * @param sceneDraw draw scene. + * @param sceneDetail details scene. + * @param node node. + * @param parse parser file mode. + */ void VPattern::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, const QDomNode &node, - const Document::Documents &parse) + const Document &parse) { QStringList tags{TagCalculation, TagModeling, TagDetails}; QDomNode domNode = node.firstChild(); @@ -654,10 +762,10 @@ void VPattern::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScen { case 0: // TagCalculation data->ClearCalculationGObjects(); - ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Valentina::Calculation); + ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Draw::Calculation); break; case 1: // TagModeling - ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Valentina::Modeling); + ParseDrawMode(sceneDraw, sceneDetail, domElement, parse, Draw::Modeling); break; case 2: // TagDetails ParseDetails(sceneDetail, domElement, parse); @@ -673,13 +781,21 @@ void VPattern::ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScen } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParseDrawMode parse draw tag with draw mode. + * @param sceneDraw draw scene. + * @param sceneDetail details scene. + * @param node node. + * @param parse parser file mode. + * @param mode draw mode. + */ void VPattern::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, const QDomNode &node, - const Document::Documents &parse, const Valentina::Draws &mode) + const Document &parse, const Draw &mode) { SCASSERT(sceneDraw != nullptr); SCASSERT(sceneDetail != nullptr); VMainGraphicsScene *scene = nullptr; - if (mode == Valentina::Calculation) + if (mode == Draw::Calculation) { scene = sceneDraw; } @@ -721,8 +837,14 @@ void VPattern::ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene * } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParseDetailElement parse detail tag. + * @param sceneDetail detail scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + */ void VPattern::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, - const Document::Documents &parse) + const Document &parse) { SCASSERT(sceneDetail != nullptr); Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); @@ -751,24 +873,24 @@ void VPattern::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomEle const quint32 id = GetParametrUInt(element, VToolDetail::AttrIdObject, "0"); const qreal mx = qApp->toPixel(GetParametrDouble(element, VAbstractTool::AttrMx, "0.0")); const qreal my = qApp->toPixel(GetParametrDouble(element, VAbstractTool::AttrMy, "0.0")); - const NodeDetail::NodeDetails nodeType = NodeDetail::Contour; + const NodeDetail nodeType = NodeDetail::Contour; const QString t = GetParametrString(element, AttrType, "NodePoint"); - Valentina::Tools tool; + Tool tool; switch (types.indexOf(t)) { case 0: // VToolDetail::NodePoint - tool = Valentina::NodePoint; + tool = Tool::NodePoint; break; case 1: // VToolDetail::NodeArc - tool = Valentina::NodeArc; + tool = Tool::NodeArc; break; case 2: // VToolDetail::NodeSpline - tool = Valentina::NodeSpline; + tool = Tool::NodeSpline; break; case 3: // VToolDetail::NodeSplinePath - tool = Valentina::NodeSplinePath; + tool = Tool::NodeSplinePath; break; default: qDebug()<<"Wrong node type."<toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); data->UpdateGObject(id, new VPointF(x, y, name, mx, my)); - VDrawTool::AddRecord(id, Valentina::SinglePointTool, this); + VDrawTool::AddRecord(id, Tool::SinglePointTool, this); if (parse != Document::FullParse) { UpdateToolData(id, data); } if (parse == Document::FullParse) { - spoint = new VToolSinglePoint(this, data, id, Valentina::FromFile); + spoint = new VToolSinglePoint(this, data, id, Source::FromFile, nameActivDraw, MPath()); scene->addItem(spoint); connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor); @@ -881,7 +1016,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0"); VToolEndLine::Create(id, name, typeLine, f, angle, basePointId, - mx, my, scene, this, data, parse, Valentina::FromFile); + mx, my, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -919,7 +1054,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); VToolAlongLine::Create(id, name, typeLine, f, firstPointId, secondPointId, mx, my, scene, this, - data, parse, Valentina::FromFile); + data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -958,7 +1093,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const quint32 pShoulder = GetParametrUInt(domElement, VAbstractTool::AttrPShoulder, "0"); VToolShoulderPoint::Create(id, f, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this, - data, parse, Valentina::FromFile); + data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -997,7 +1132,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0"); VToolNormal::Create(id, f, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene, - this, data, parse, Valentina::FromFile); + this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1036,7 +1171,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const quint32 thirdPointId = GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, "0"); VToolBisector::Create(id, f, firstPointId, secondPointId, thirdPointId, - typeLine, name, mx, my, scene, this, data, parse, Valentina::FromFile); + typeLine, name, mx, my, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1072,7 +1207,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const quint32 p2Line2Id = GetParametrUInt(domElement, VAbstractTool::AttrP2Line2, "0"); VToolLineIntersect::Create(id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, name, - mx, my, scene, this, data, parse, Valentina::FromFile); + mx, my, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) { @@ -1095,7 +1230,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); VToolPointOfContact::Create(id, f, center, firstPointId, secondPointId, name, mx, my, scene, this, - data, parse, Valentina::FromFile); + data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != radius) { @@ -1128,8 +1263,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0")); const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0")); data->UpdateGObject(id, new VPointF(point->x(), point->y(), point->name(), mx, my, idObject, - Valentina::Modeling)); - VNodePoint::Create(this, data, id, idObject, parse, Valentina::FromFile, idTool); + Draw::Modeling)); + VNodePoint::Create(this, data, id, idObject, parse, Source::FromFile, idTool); } catch (const VExceptionBadId &e) { @@ -1152,7 +1287,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const quint32 p2LineId = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0"); VToolHeight::Create(id, name, typeLine, basePointId, p1LineId, p2LineId, - mx, my, scene, this, data, parse, Valentina::FromFile); + mx, my, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) { @@ -1174,7 +1309,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); VToolTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my, scene, this, - data, parse, Valentina::FromFile); + data, parse, Source::FromFile); } catch (const VExceptionBadId &e) { @@ -1194,7 +1329,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); VToolPointOfIntersection::Create(id, name, firstPointId, secondPointId, mx, my, scene, this, data, - parse, Valentina::FromFile); + parse, Source::FromFile); } catch (const VExceptionBadId &e) { @@ -1214,7 +1349,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem QString f = formula;//need for saving fixed formula; const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0"); - VToolCutSpline::Create(id, name, f, splineId, mx, my, scene, this, data, parse, Valentina::FromFile); + VToolCutSpline::Create(id, name, f, splineId, mx, my, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1249,7 +1384,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0"); VToolCutSplinePath::Create(id, name, f, splinePathId, mx, my, scene, this, data, parse, - Valentina::FromFile); + Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1283,7 +1418,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem QString f = formula;//need for saving fixed formula; const quint32 arcId = GetParametrUInt(domElement, VToolCutArc::AttrArc, "0"); - VToolCutArc::Create(id, name, f, arcId, mx, my, scene, this, data, parse, Valentina::FromFile); + VToolCutArc::Create(id, name, f, arcId, mx, my, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1313,8 +1448,14 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParseLineElement parse line tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + */ void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement, - const Document::Documents &parse) + const Document &parse) { SCASSERT(scene != nullptr); Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); @@ -1326,7 +1467,7 @@ void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &do const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); - VToolLine::Create(id, firstPoint, secondPoint, typeLine, scene, this, data, parse, Valentina::FromFile); + VToolLine::Create(id, firstPoint, secondPoint, typeLine, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) { @@ -1337,8 +1478,15 @@ void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &do } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParseSplineElement parse spline tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + * @param type type of spline. + */ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &domElement, - const Document::Documents &parse, const QString &type) + const Document &parse, const QString &type) { SCASSERT(scene != nullptr); Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); @@ -1361,7 +1509,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & const qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0"); VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this, data, parse, - Valentina::FromFile); + Source::FromFile); } catch (const VExceptionBadId &e) { @@ -1405,7 +1553,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & } } - VToolSplinePath::Create(id, path, scene, this, data, parse, Valentina::FromFile); + VToolSplinePath::Create(id, path, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) { @@ -1422,9 +1570,9 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0"); VSpline *spl = new VSpline(*data->GeometricObject(idObject)); spl->setIdObject(idObject); - spl->setMode(Valentina::Modeling); + spl->setMode(Draw::Modeling); data->UpdateGObject(id, spl); - VNodeSpline::Create(this, data, id, idObject, parse, Valentina::FromFile, idTool); + VNodeSpline::Create(this, data, id, idObject, parse, Source::FromFile, idTool); } catch (const VExceptionBadId &e) { @@ -1441,9 +1589,9 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0"); VSplinePath *path = new VSplinePath(*data->GeometricObject(idObject)); path->setIdObject(idObject); - path->setMode(Valentina::Modeling); + path->setMode(Draw::Modeling); data->UpdateGObject(id, path); - VNodeSplinePath::Create(this, data, id, idObject, parse, Valentina::FromFile, idTool); + VNodeSplinePath::Create(this, data, id, idObject, parse, Source::FromFile, idTool); } catch (const VExceptionBadId &e) { @@ -1459,7 +1607,14 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & } //--------------------------------------------------------------------------------------------------------------------- -void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document::Documents &parse, +/** + * @brief ParseArcElement parse arc tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + * @param type type of spline. + */ +void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, const QString &type) { SCASSERT(scene != nullptr); @@ -1482,7 +1637,7 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen const QString f2 = GetParametrString(domElement, VAbstractTool::AttrAngle2, "270"); QString f2Fix = f2;//need for saving fixed formula; - VToolArc::Create(id, center, r, f1Fix, f2Fix, scene, this, data, parse, Valentina::FromFile); + VToolArc::Create(id, center, r, f1Fix, f2Fix, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (r != radius || f1Fix != f1 || f2Fix != f2) { @@ -1515,9 +1670,9 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen const quint32 idTool = GetParametrUInt(domElement, VAbstractNode::AttrIdTool, "0"); VArc *arc = new VArc(*data->GeometricObject(idObject)); arc->setIdObject(idObject); - arc->setMode(Valentina::Modeling); + arc->setMode(Draw::Modeling); data->UpdateGObject(id, arc); - VNodeArc::Create(this, data, id, idObject, parse, Valentina::FromFile, idTool); + VNodeArc::Create(this, data, id, idObject, parse, Source::FromFile, idTool); } catch (const VExceptionBadId &e) { @@ -1533,8 +1688,15 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParseToolsElement parse tools tag. + * @param scene scene. + * @param domElement tag in xml tree. + * @param parse parser file mode. + * @param type type of spline. + */ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &domElement, - const Document::Documents &parse, const QString &type) + const Document &parse, const QString &type) { SCASSERT(scene != nullptr); Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); @@ -1554,7 +1716,7 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d const QVector vector = VToolUnionDetails::GetDetailFromFile(this, domElement); VToolUnionDetails::Create(id, vector[0], vector[1], 0, 0, indexD1, indexD2, scene, this, data, parse, - Valentina::FromFile); + Source::FromFile); } catch (const VExceptionBadId &e) { @@ -1570,6 +1732,10 @@ void VPattern::ParseToolsElement(VMainGraphicsScene *scene, const QDomElement &d } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ParseIncrementsElement parse increments tag. + * @param node tag in xml tree. + */ void VPattern::ParseIncrementsElement(const QDomNode &node) { QDomNode domNode = node.firstChild(); @@ -1598,6 +1764,11 @@ void VPattern::ParseIncrementsElement(const QDomNode &node) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetParametrId return value id attribute. + * @param domElement tag in xml tree. + * @return id value. + */ quint32 VPattern::GetParametrId(const QDomElement &domElement) const { Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null"); @@ -1623,6 +1794,11 @@ quint32 VPattern::GetParametrId(const QDomElement &domElement) const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CollectId recursive function, try find id attribute in file. Throw exclusion if find not unique. + * @param node tag in xml tree. + * @param vector list with ids. + */ void VPattern::CollectId(const QDomElement &node, QVector &vector) const { if (node.hasAttribute(VDomDocument::AttrId)) @@ -1646,8 +1822,7 @@ void VPattern::CollectId(const QDomElement &node, QVector &vector) cons } //--------------------------------------------------------------------------------------------------------------------- -void VPattern::PrepareForParse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw, - VMainGraphicsScene *sceneDetail) +void VPattern::PrepareForParse(const Document &parse) { SCASSERT(sceneDraw != nullptr); SCASSERT(sceneDetail != nullptr); @@ -1659,7 +1834,7 @@ void VPattern::PrepareForParse(const Document::Documents &parse, VMainGraphicsSc nameActivDraw.clear(); sceneDraw->clear(); sceneDetail->clear(); - comboBoxDraws->clear(); + patternPieces.clear(); tools.clear(); cursor = 0; } @@ -1675,7 +1850,7 @@ void VPattern::PrepareForParse(const Document::Documents &parse, VMainGraphicsSc void VPattern::UpdateMeasurements() { const QString path = MPath(); - if (MType() == Pattern::Standard) + if (MType() == MeasurementsType::Standard) { VStandardMeasurements m(data); m.setContent(path); @@ -1688,3 +1863,61 @@ void VPattern::UpdateMeasurements() m.Measurements(); } } + +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::GarbageCollector() +{ + QHashIterator t(tools); + while (t.hasNext()) { + t.next(); + VDataTool *tool = t.value(); + if(tool->referens() <= 0){ + QDomElement domElement = elementById(QString().setNum(t.key())); + if(domElement.isElement()){ + QDomNode parent = domElement.parentNode(); + if(!parent.isNull()){ + parent.removeChild(domElement); + } else { + qWarning()<documentElement().elementsByTagName( TagDraw ); + if (elements.size() == 0) + { + return QDomElement(); + } + for ( qint32 i = 0; i < elements.count(); i++ ) + { + QDomElement element = elements.at( i ).toElement(); + if (element.isNull() == false) + { + if ( element.attribute( AttrName ) == name ) + { + return element; + } + } + } + } + return QDomElement(); +} + +//--------------------------------------------------------------------------------------------------------------------- +int VPattern::CountPP() const +{ + const QDomElement rootElement = this->documentElement(); + if (rootElement.isNull()) + { + return 0; + } + + return rootElement.elementsByTagName( TagDraw ).count(); +} diff --git a/src/app/xml/vpattern.h b/src/app/xml/vpattern.h index 98699120e..f1497e878 100644 --- a/src/app/xml/vpattern.h +++ b/src/app/xml/vpattern.h @@ -30,20 +30,12 @@ #define VPATTERN_H #include "vdomdocument.h" -#include "../widgets/vmaingraphicsscene.h" -#include "../tools/vdatatool.h" #include "vtoolrecord.h" -#include -namespace Document -{ - /** - * @brief The Document enum parse types. - */ - enum Document { LiteParse, FullParse}; - Q_DECLARE_FLAGS(Documents, Document) -} -Q_DECLARE_OPERATORS_FOR_FLAGS(Document::Documents) +class VDataTool; +class VMainGraphicsScene; + +enum class Document : char { LiteParse, FullParse}; /* VAL_VERSION is (major << 16) + (minor << 8) + patch. @@ -62,123 +54,34 @@ class VPattern : public QObject, public VDomDocument { Q_OBJECT public: - VPattern(VContainer *data, QComboBox *comboBoxDraws, Valentina::Draws *mode, QObject *parent = nullptr); - /** - * @brief CreateEmptyFile create minimal empty file. - * @param tablePath path to measurement file (standard or individual) - */ + VPattern(VContainer *data, Draw *mode, VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, + QObject *parent = nullptr); void CreateEmptyFile(const QString &tablePath); - /** - * @brief ChangeActivDraw set new pattern peace name. - * @param name new name. - * @param parse parser file mode. - */ - void ChangeActivDraw(const QString& name, const Document::Documents &parse = Document::FullParse); - /** - * @brief GetNameActivDraw return current pattern peace name. - * @return pattern peace name. - */ + void ChangeActivPP(const QString& name, const Document &parse = Document::FullParse); QString GetNameActivDraw() const; - /** - * @brief GetActivDrawElement return draw tag for current pattern peace. - * @param element draw tag. - * @return true if found. - */ - bool GetActivDrawElement(QDomElement &element); - /** - * @brief appendDraw add new pattern peace structure to the file. - * @param name pattern peace name. - * @return true if success. - */ - bool appendDraw(const QString& name); - /** - * @brief SetNameDraw change current pattern peace. - * @param name pattern peace name. - * @return true if success. - */ + bool GetActivDrawElement(QDomElement &element) const; + bool appendPP(const QString& name); bool SetNameDraw(const QString& name); - /** - * @brief Parse parse file. - * @param parse parser file mode. - * @param sceneDraw pointer to draw scene. - * @param sceneDetail pointer to details scene. - */ - void Parse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw, - VMainGraphicsScene *sceneDetail); - /** - * @brief getTools return list of tools pointers. - * @return list. - */ + void Parse(const Document &parse); QHash* getTools(); - /** - * @brief getTool return tool from tool list. - * @param id tool id. - * @return tool. - */ VDataTool* getTool(const quint32 &id); - /** - * @brief getHistory return list with list of history records. - * @return list of history records. - */ QVector *getHistory(); - /** - * @brief getCursor return cursor. - * @return cursor. - */ quint32 getCursor() const; - /** - * @brief setCursor set cursor. - * @param value cursor. - */ void setCursor(const quint32 &value); - /** - * @brief setCurrentData set current data set. - */ void setCurrentData(); - /** - * @brief AddTool add tool to list tools. - * @param id tool id. - * @param tool tool. - */ void AddTool(const quint32 &id, VDataTool *tool); - /** - * @brief UpdateToolData update tool in list tools. - * @param id tool id. - * @param data container with variables. - */ void UpdateToolData(const quint32 &id, VContainer *data); - /** - * @brief IncrementReferens increment reference parent objects. - * @param id parent object id. - */ void IncrementReferens(quint32 id) const; - /** - * @brief DecrementReferens decrement reference parent objects. - * @param id parent object id. - */ void DecrementReferens(quint32 id) const; - /** - * @brief TestUniqueId test exist unique id in pattern file. Each id must be unique. - */ void TestUniqueId() const; - /** - * @brief SPointActiveDraw return id base point current pattern peace. - * @return id base point. - */ quint32 SPointActiveDraw(); bool isPatternModified() const; void setPatternModified(bool value); - /** - * @brief GetActivNodeElement find element in current pattern piece by name. - * @param name name tag. - * @param element element. - * @return true if found. - */ - bool GetActivNodeElement(const QString& name, QDomElement& element); + bool GetActivNodeElement(const QString& name, QDomElement& element) const; QString MPath() const; void SetPath(const QString &path); - Valentina::Units MUnit() const; - Pattern::Measurements MType() const; + Unit MUnit() const; + MeasurementsType MType() const; static const QString TagPattern; static const QString TagCalculation; static const QString TagModeling; @@ -204,12 +107,16 @@ public: static const QString IncrementKgrowth; static const QString IncrementDescription; virtual bool SaveDocument(const QString &fileName); + QStringList getPatternPieces() const; + QDomElement GetPPElement(const QString &name); + bool CheckNamePP(const QString& name) const; + int CountPP() const; signals: /** * @brief ChangedActivDraw change active pattern peace. * @param newName new pattern peace name. */ - void ChangedActivDraw(const QString &newName); + void ChangedActivPP(const QString &newName); /** * @brief ChangedNameDraw save new name active pattern peace. * @param oldName old name. @@ -237,190 +144,109 @@ signals: */ void ChangedCursor(quint32 id); void ClearMainWindow(); + void UndoCommand(); public slots: - /** - * @brief FullUpdateTree lite parse file. - */ - void FullUpdateTree(); - /** - * @brief haveLiteChange we have unsaved change. - */ + void LiteParseTree(); void haveLiteChange(); - /** - * @brief ShowHistoryTool hightlight tool. - * @param id tool id. - * @param color hightlight color. - * @param enable enable or diasable hightlight. - */ void ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable); + void NeedFullParsing(); + void ClearScene(); private: Q_DISABLE_COPY(VPattern) - /** - * @brief nameActivDraw name current pattern peace. - */ - QString nameActivDraw; - /** - * @brief tools list with pointer on tools. - */ - QHash tools; - /** - * @brief history history records. - */ - QVector history; - /** - * @brief cursor cursor keep id tool after which we will add new tool in file. - */ - quint32 cursor; - QComboBox *comboBoxDraws; - /** - * @brief mode current draw mode. - */ - Valentina::Draws *mode; - /** - * @brief fileModified true if exist change in file. - */ - bool patternModified; - /** - * @brief CheckNameDraw check if exist pattern peace with this name. - * @param name pattern peace name. - * @return true if exist. - */ - bool CheckNameDraw(const QString& name) const; - /** - * @brief SetActivDraw set current pattern peace. - * @param name pattern peace name. - */ - void SetActivDraw(const QString& name); - /** - * @brief ParseDrawElement parse draw tag. - * @param sceneDraw draw scene. - * @param sceneDetail details scene. - * @param node node. - * @param parse parser file mode. - */ + /** @brief nameActivDraw name current pattern peace. */ + QString nameActivDraw; + + /** @brief tools list with pointer on tools. */ + QHash tools; + + /** @brief history history records. */ + QVector history; + + /** @brief cursor cursor keep id tool after which we will add new tool in file. */ + quint32 cursor; + + QStringList patternPieces; + + /** @brief mode current draw mode. */ + Draw *mode; + + VMainGraphicsScene *sceneDraw; + VMainGraphicsScene *sceneDetail; + + void SetActivPP(const QString& name); void ParseDrawElement(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, - const QDomNode& node, const Document::Documents &parse); - /** - * @brief ParseDrawMode parse draw tag with draw mode. - * @param sceneDraw draw scene. - * @param sceneDetail details scene. - * @param node node. - * @param parse parser file mode. - * @param mode draw mode. - */ + const QDomNode& node, const Document &parse); void ParseDrawMode(VMainGraphicsScene *sceneDraw, VMainGraphicsScene *sceneDetail, - const QDomNode& node, const Document::Documents &parse, const Valentina::Draws &mode); - /** - * @brief ParseDetailElement parse detail tag. - * @param sceneDetail detail scene. - * @param domElement tag in xml tree. - * @param parse parser file mode. - */ + const QDomNode& node, const Document &parse, const Draw &mode); void ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, - const Document::Documents &parse); - /** - * @brief ParseDetails parse details tag. - * @param sceneDetail detail scene. - * @param domElement tag in xml tree. - * @param parse parser file mode. - */ + const Document &parse); void ParseDetails(VMainGraphicsScene *sceneDetail, const QDomElement &domElement, - const Document::Documents &parse); - /** - * @brief ParsePointElement parse point tag. - * @param scene scene. - * @param domElement tag in xml tree. - * @param parse parser file mode. - * @param type type of point. - */ + const Document &parse); void ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement, - const Document::Documents &parse, const QString &type); - /** - * @brief ParseLineElement parse line tag. - * @param scene scene. - * @param domElement tag in xml tree. - * @param parse parser file mode. - */ + const Document &parse, const QString &type); void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement, - const Document::Documents &parse); - /** - * @brief ParseSplineElement parse spline tag. - * @param scene scene. - * @param domElement tag in xml tree. - * @param parse parser file mode. - * @param type type of spline. - */ + const Document &parse); void ParseSplineElement(VMainGraphicsScene *scene, const QDomElement& domElement, - const Document::Documents &parse, const QString& type); - /** - * @brief ParseArcElement parse arc tag. - * @param scene scene. - * @param domElement tag in xml tree. - * @param parse parser file mode. - * @param type type of spline. - */ + const Document &parse, const QString& type); void ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, - const Document::Documents &parse, const QString& type); - /** - * @brief ParseToolsElement parse tools tag. - * @param scene scene. - * @param domElement tag in xml tree. - * @param parse parser file mode. - * @param type type of spline. - */ + const Document &parse, const QString& type); void ParseToolsElement(VMainGraphicsScene *scene, const QDomElement& domElement, - const Document::Documents &parse, const QString& type); - /** - * @brief ParseIncrementsElement parse increments tag. - * @param node tag in xml tree. - */ + const Document &parse, const QString& type); void ParseIncrementsElement(const QDomNode& node); - /** - * @brief GetParametrId return value id attribute. - * @param domElement tag in xml tree. - * @return id value. - */ - quint32 GetParametrId(const QDomElement& domElement) const; - /** - * @brief CollectId recursive function, try find id attribute in file. Throw exclusion if find not unique. - * @param node tag in xml tree. - * @param vector list with ids. - */ + quint32 GetParametrId(const QDomElement& domElement) const; void CollectId(const QDomElement &node, QVector &vector)const; - void PrepareForParse(const Document::Documents &parse, VMainGraphicsScene *sceneDraw, - VMainGraphicsScene *sceneDetail); + void PrepareForParse(const Document &parse); void UpdateMeasurements(); + void GarbageCollector(); }; +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetNameActivDraw return current pattern peace name. + * @return pattern peace name. + */ inline QString VPattern::GetNameActivDraw() const { return nameActivDraw; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getTools return list of tools pointers. + * @return list. + */ inline QHash *VPattern::getTools() { return &tools; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getHistory return list with list of history records. + * @return list of history records. + */ inline QVector *VPattern::getHistory() { return &history; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getCursor return cursor. + * @return cursor. + */ inline quint32 VPattern::getCursor() const { return cursor; } -inline bool VPattern::isPatternModified() const +//--------------------------------------------------------------------------------------------------------------------- +inline QStringList VPattern::getPatternPieces() const { - return patternModified; + return patternPieces; } -inline void VPattern::setPatternModified(bool value) -{ - patternModified = value; -} + #endif // VPATTERN_H diff --git a/src/app/xml/vstandardmeasurements.cpp b/src/app/xml/vstandardmeasurements.cpp index fa096b1dd..82f10b09e 100644 --- a/src/app/xml/vstandardmeasurements.cpp +++ b/src/app/xml/vstandardmeasurements.cpp @@ -46,7 +46,7 @@ VStandardMeasurements::~VStandardMeasurements() {} //--------------------------------------------------------------------------------------------------------------------- -Valentina::Units VStandardMeasurements::Unit() +Unit VStandardMeasurements::MUnit() { const QString unit = UniqueTagText(AttrUnit, UnitCM); return VDomDocument::StrToUnits(unit); @@ -224,7 +224,7 @@ void VStandardMeasurements::Measurement(const QString &tag) const qreal size_increase = GetParametrDouble(domElement, AttrSize_increase, "0.0"); const qreal height_increase = GetParametrDouble(domElement, AttrHeight_increase, "0.0"); - if (Unit() == Valentina::Mm)// Convert to Cm. + if (MUnit() == Unit::Mm)// Convert to Cm. { data->AddMeasurement(tag, VMeasurement(value/10.0, size_increase/10.0, height_increase/10.0, qApp->GuiText(tag), qApp->Description(tag), tag)); @@ -257,7 +257,7 @@ void VStandardMeasurements::SetSize() if (domElement.isNull() == false) { qreal value = GetParametrDouble(domElement, AttrValue, "50.0"); - if (Unit() == Valentina::Mm)// Convert to Cm. + if (MUnit() == Unit::Mm)// Convert to Cm. { value = value/10.0; } @@ -286,7 +286,7 @@ void VStandardMeasurements::SetHeight() if (domElement.isNull() == false) { qreal value = GetParametrDouble(domElement, AttrValue, "176.0"); - if (Unit() == Valentina::Mm)// Convert to Cm. + if (MUnit() == Unit::Mm)// Convert to Cm. { value = value / 10.0; } diff --git a/src/app/xml/vstandardmeasurements.h b/src/app/xml/vstandardmeasurements.h index f124165f1..92b50a430 100644 --- a/src/app/xml/vstandardmeasurements.h +++ b/src/app/xml/vstandardmeasurements.h @@ -44,7 +44,7 @@ class VStandardMeasurements:public VDomDocument public: VStandardMeasurements(VContainer *data); virtual ~VStandardMeasurements(); - Valentina::Units Unit(); + Unit MUnit(); QString Description(); void Measurements(); void SetSize(); diff --git a/src/app/xml/vtoolrecord.cpp b/src/app/xml/vtoolrecord.cpp index 4ea39a243..c9d4e1887 100644 --- a/src/app/xml/vtoolrecord.cpp +++ b/src/app/xml/vtoolrecord.cpp @@ -29,11 +29,20 @@ #include "vtoolrecord.h" //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VToolRecord default constructor. + */ VToolRecord::VToolRecord() - :id(0), typeTool(Valentina::ArrowTool), nameDraw(QString()) + :id(0), typeTool(Tool::ArrowTool), nameDraw(QString()) {} //--------------------------------------------------------------------------------------------------------------------- -VToolRecord::VToolRecord(const quint32 &id, const Valentina::Tools &typeTool, const QString &nameDraw) +/** + * @brief VToolRecord constructor. + * @param id tool id. + * @param typeTool tool type. + * @param nameDraw pattern peace name. + */ +VToolRecord::VToolRecord(const quint32 &id, const Tool &typeTool, const QString &nameDraw) :id(id), typeTool(typeTool), nameDraw(nameDraw) {} diff --git a/src/app/xml/vtoolrecord.h b/src/app/xml/vtoolrecord.h index 52dd16603..302a5575c 100644 --- a/src/app/xml/vtoolrecord.h +++ b/src/app/xml/vtoolrecord.h @@ -39,87 +39,80 @@ class VToolRecord { public: - /** - * @brief VToolRecord default constructor. - */ VToolRecord(); - /** - * @brief VToolRecord constructor. - * @param id tool id. - * @param typeTool tool type. - * @param nameDraw pattern peace name. - */ - VToolRecord(const quint32 &id, const Valentina::Tools &typeTool, const QString &nameDraw); - /** - * @brief getId return tool id. - * @return id. - */ - quint32 getId() const; - /** - * @brief setId set tool id. - * @param value id. - */ - void setId(const quint32 &value); - /** - * @brief getTypeTool return tool type. - * @return tool type. - */ - Valentina::Tools getTypeTool() const; - /** - * @brief setTypeTool set tool type. - * @param value tool type. - */ - void setTypeTool(const Valentina::Tools &value); - /** - * @brief getNameDraw return pattern peace name. - * @return pattern peace name. - */ - QString getNameDraw() const; - /** - * @brief setNameDraw set pattern peace name. - * @param value pattern peace name. - */ - void setNameDraw(const QString &value); + VToolRecord(const quint32 &id, const Tool &typeTool, const QString &nameDraw); + quint32 getId() const; + void setId(const quint32 &value); + Tool getTypeTool() const; + void setTypeTool(const Tool &value); + QString getNameDraw() const; + void setNameDraw(const QString &value); private: - /** - * @brief id tool id. - */ - quint32 id; - /** - * @brief typeTool tool type. - */ - Valentina::Tools typeTool; - /** - * @brief nameDraw pattern peace name. - */ - QString nameDraw; + /** @brief id tool id. */ + quint32 id; + + /** @brief typeTool tool type. */ + Tool typeTool; + + /** @brief nameDraw pattern peace name. */ + QString nameDraw; }; +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getId return tool id. + * @return id. + */ inline quint32 VToolRecord::getId() const { return id; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setId set tool id. + * @param value id. + */ inline void VToolRecord::setId(const quint32 &value) { id = value; } -inline Valentina::Tools VToolRecord::getTypeTool() const +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getTypeTool return tool type. + * @return tool type. + */ +inline Tool VToolRecord::getTypeTool() const { return typeTool; } -inline void VToolRecord::setTypeTool(const Valentina::Tools &value) +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setTypeTool set tool type. + * @param value tool type. + */ +inline void VToolRecord::setTypeTool(const Tool &value) { typeTool = value; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getNameDraw return pattern peace name. + * @return pattern peace name. + */ inline QString VToolRecord::getNameDraw() const { return nameDraw; } +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setNameDraw set pattern peace name. + * @param value pattern peace name. + */ inline void VToolRecord::setNameDraw(const QString &value) { nameDraw = value; diff --git a/src/libs/qmuparser/qmuparser.cpp b/src/libs/qmuparser/qmuparser.cpp index 4772f42ec..dd3f1b228 100644 --- a/src/libs/qmuparser/qmuparser.cpp +++ b/src/libs/qmuparser/qmuparser.cpp @@ -21,7 +21,11 @@ ******************************************************************************************************/ #include "qmuparser.h" -#include + +#ifdef Q_OS_WIN32 +# include // for M_PI on Windows +#endif /*Q_OS_WIN32*/ + #include using namespace std; diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp index cbfd20c94..10a55b563 100644 --- a/src/libs/qmuparser/qmuparserbase.cpp +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -21,16 +21,17 @@ ******************************************************************************************************/ #include "qmuparserbase.h" -#include -#include +//#include + +#ifdef Q_OS_WIN32 +# include // for M_PI on Windows +#endif /*Q_OS_WIN32*/ + #include #ifdef QMUP_USE_OPENMP #include #endif -#include "qmuparsererror.h" -#include "qmuparsertokenreader.h" - using namespace std; /** diff --git a/src/libs/qmuparser/qmuparserbase.h b/src/libs/qmuparser/qmuparserbase.h index c7727426b..d7d92c090 100644 --- a/src/libs/qmuparser/qmuparserbase.h +++ b/src/libs/qmuparser/qmuparserbase.h @@ -31,8 +31,6 @@ #include "qmuparserdef.h" #include "qmuparsertokenreader.h" #include "qmuparserbytecode.h" -#include "qmuparsererror.h" - namespace qmu { diff --git a/src/libs/qmuparser/qmuparserbytecode.cpp b/src/libs/qmuparser/qmuparserbytecode.cpp index 3634612eb..d49357c06 100644 --- a/src/libs/qmuparser/qmuparserbytecode.cpp +++ b/src/libs/qmuparser/qmuparserbytecode.cpp @@ -24,11 +24,12 @@ #include #include -#include -#include -#include "qmuparserdef.h" -#include "qmuparsererror.h" +#ifdef Q_OS_WIN32 +# include // for M_PI on Windows +#endif /*Q_OS_WIN32*/ + +#include #include "qmuparsertoken.h" diff --git a/src/libs/qmuparser/qmuparserbytecode.h b/src/libs/qmuparser/qmuparserbytecode.h index e32e37260..7140fe97d 100644 --- a/src/libs/qmuparser/qmuparserbytecode.h +++ b/src/libs/qmuparser/qmuparserbytecode.h @@ -24,7 +24,6 @@ #define QMUPARSERBYTECODE_H #include "qmuparserdef.h" -#include "qmuparsererror.h" #include "qmuparsertoken.h" /** diff --git a/src/libs/qmuparser/qmuparsertest.cpp b/src/libs/qmuparser/qmuparsertest.cpp index 7664df6a3..25869eeac 100644 --- a/src/libs/qmuparser/qmuparsertest.cpp +++ b/src/libs/qmuparser/qmuparsertest.cpp @@ -21,7 +21,11 @@ ******************************************************************************************************/ #include "qmuparsertest.h" -#include + +#ifdef Q_OS_WIN32 +# include // for M_PI on Windows +#endif /*Q_OS_WIN32*/ + #include #include #include "qmuparsererror.h"