diff --git a/src/app/container/container.pri b/src/app/container/container.pri index e469485cb..626222518 100644 --- a/src/app/container/container.pri +++ b/src/app/container/container.pri @@ -13,7 +13,8 @@ SOURCES += \ $$PWD/variables/vcurvelength.cpp \ $$PWD/variables/vlinelength.cpp \ $$PWD/variables/vsplinelength.cpp \ - $$PWD/vformula.cpp + $$PWD/vformula.cpp \ + $$PWD/variables/varcradius.cpp HEADERS += \ $$PWD/vcontainer.h \ @@ -35,4 +36,6 @@ HEADERS += \ $$PWD/variables/vlineangle_p.h \ $$PWD/variables/vlinelength_p.h \ $$PWD/variables/vmeasurement_p.h \ - $$PWD/vformula.h + $$PWD/vformula.h \ + $$PWD/variables/varcradius.h \ + $$PWD/variables/varcradius_p.h diff --git a/src/app/container/variables.h b/src/app/container/variables.h index 3c7daf4d3..49fba0320 100644 --- a/src/app/container/variables.h +++ b/src/app/container/variables.h @@ -36,5 +36,6 @@ #include "variables/vsplinelength.h" #include "variables/vlinelength.h" #include "variables/vlineangle.h" +#include "variables/varcradius.h" #endif // VARIABLES_H diff --git a/src/app/container/variables/varcradius.cpp b/src/app/container/variables/varcradius.cpp new file mode 100644 index 000000000..6a10b2ac0 --- /dev/null +++ b/src/app/container/variables/varcradius.cpp @@ -0,0 +1,93 @@ +/************************************************************************ + ** + ** @file varcradius.cpp + ** @author Roman Telezhynskyi + ** @date 30 5, 2015 + ** + ** @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) 2015 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 "varcradius.h" +#include "varcradius_p.h" +#include "../libs/vgeometry/varc.h" +#include "../core/vapplication.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +VArcRadius::VArcRadius() + :VInternalVariable(), d(new VArcRadiusData) +{ + SetType(VarType::ArcRadius); +} + +//--------------------------------------------------------------------------------------------------------------------- +VArcRadius::VArcRadius(const VArc *arc, quint32 arcId) + :VInternalVariable(), d(new VArcRadiusData(arcId)) +{ + SCASSERT(arc != nullptr); + + SetType(VarType::ArcRadius); + SetName(QString(radiusArc_+"%1").arg(arc->name())); + SetValue(arc); +} + +//--------------------------------------------------------------------------------------------------------------------- +VArcRadius::VArcRadius(const VArcRadius &var) + :VInternalVariable(var), d(var.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VArcRadius &VArcRadius::operator=(const VArcRadius &var) +{ + if ( &var == this ) + { + return *this; + } + VInternalVariable::operator=(var); + d = var.d; + return *this; +} + +//--------------------------------------------------------------------------------------------------------------------- +VArcRadius::~VArcRadius() +{} + +//--------------------------------------------------------------------------------------------------------------------- +bool VArcRadius::Filter(quint32 id) +{ + return id == d->arcId; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VArcRadius::SetValue(const VArc *arc) +{ + SCASSERT(arc != nullptr); + + VInternalVariable::SetValue(qApp->fromPixel(arc->GetRadius())); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VArcRadius::GetArcId() const +{ + return d->arcId; +} diff --git a/src/app/container/variables/varcradius.h b/src/app/container/variables/varcradius.h new file mode 100644 index 000000000..a620c7114 --- /dev/null +++ b/src/app/container/variables/varcradius.h @@ -0,0 +1,53 @@ +/************************************************************************ + ** + ** @file varcradius.h + ** @author Roman Telezhynskyi + ** @date 30 5, 2015 + ** + ** @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) 2015 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 VARCRADIUS_H +#define VARCRADIUS_H + +#include "vinternalvariable.h" + +class VArc; +class VArcRadiusData; + +class VArcRadius :public VInternalVariable +{ +public: + VArcRadius(); + VArcRadius(const VArc *arc, quint32 arcId); + VArcRadius(const VArcRadius &var); + VArcRadius &operator=(const VArcRadius &var); + virtual ~VArcRadius(); + + virtual bool Filter(quint32 id); + void SetValue(const VArc *arc); + quint32 GetArcId() const; +private: + QSharedDataPointer d; +}; + +#endif // VARCRADIUS_H diff --git a/src/app/container/variables/varcradius_p.h b/src/app/container/variables/varcradius_p.h new file mode 100644 index 000000000..80fc935b6 --- /dev/null +++ b/src/app/container/variables/varcradius_p.h @@ -0,0 +1,67 @@ +/************************************************************************ + ** + ** @file VArcRadiusData.h + ** @author Roman Telezhynskyi + ** @date 30 5, 2015 + ** + ** @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) 2015 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 VARCRADIUSDATA_H +#define VARCRADIUSDATA_H + +#include + +#ifdef Q_CC_GNU + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Weffc++" +#endif + +class VArcRadiusData : public QSharedData +{ +public: + + VArcRadiusData() + :arcId(NULL_ID) + {} + + VArcRadiusData(const quint32 &arcId) + :arcId(arcId) + {} + + VArcRadiusData(const VArcRadiusData &var) + :QSharedData(var), arcId(var.arcId) + {} + + virtual ~VArcRadiusData(); + + quint32 arcId; +}; + +VArcRadiusData::~VArcRadiusData() +{} + +#ifdef Q_CC_GNU +#pragma GCC diagnostic pop +#endif + +#endif // VARCRADIUSDATA_H diff --git a/src/app/container/vcontainer.cpp b/src/app/container/vcontainer.cpp index 9a910543d..ede4f8332 100644 --- a/src/app/container/vcontainer.cpp +++ b/src/app/container/vcontainer.cpp @@ -315,6 +315,16 @@ void VContainer::AddLine(const quint32 &firstPointId, const quint32 &secondPoint AddVariable(angle->GetName(), angle); } +//--------------------------------------------------------------------------------------------------------------------- +void VContainer::AddArc(const quint32 &arcId, const quint32 &parentId) +{ + AddCurveLength(arcId, parentId); + + const QSharedPointer arc = GeometricObject(arcId); + VArcRadius *radius = new VArcRadius(arc.data(), arcId); + AddVariable(radius->GetName(), radius); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief AddObject add object to container @@ -417,6 +427,12 @@ const QMap > VContainer::DataAngleLines() co return DataVar(VarType::LineAngle); } +//--------------------------------------------------------------------------------------------------------------------- +const QMap > VContainer::DataRadiusesArcs() const +{ + return DataVar(VarType::ArcRadius); +} + //--------------------------------------------------------------------------------------------------------------------- bool VContainer::IsUnique(const QString &name) { diff --git a/src/app/container/vcontainer.h b/src/app/container/vcontainer.h index e96151708..54cec0731 100644 --- a/src/app/container/vcontainer.h +++ b/src/app/container/vcontainer.h @@ -157,6 +157,7 @@ public: quint32 AddGObject(VGObject *obj); quint32 AddDetail(VDetail detail); void AddLine(const quint32 &firstPointId, const quint32 &secondPointId); + void AddArc(const quint32 &arcId, const quint32 &parentId = 0); template /** @@ -223,6 +224,7 @@ public: const QMap > DataLengthSplines() const; const QMap > DataLengthArcs() const; const QMap > DataAngleLines() const; + const QMap > DataRadiusesArcs() const; static bool IsUnique(const QString &name); diff --git a/src/app/core/vapplication.cpp b/src/app/core/vapplication.cpp index af379c38b..1800df246 100644 --- a/src/app/core/vapplication.cpp +++ b/src/app/core/vapplication.cpp @@ -1485,7 +1485,9 @@ void VApplication::InitVariables() variables.insert(arc_, QmuTranslation::translate("Variables", "Arc_", "Left symbol _ in name")); variables.insert(spl_, QmuTranslation::translate("Variables", "Spl_", "Left symbol _ in name")); variables.insert(splPath, QmuTranslation::translate("Variables", "SplPath", - "Do not add symbol _ to the end of name")); + "Do not add symbol _ to the end of name")); + variables.insert(radiusArc_, QmuTranslation::translate("Variables", "Radius", + "Do not add symbol _ to the end of name")); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/app/dialogincrements.cpp b/src/app/dialogs/app/dialogincrements.cpp index f64242add..a1346a6ce 100644 --- a/src/app/dialogs/app/dialogincrements.cpp +++ b/src/app/dialogs/app/dialogincrements.cpp @@ -97,6 +97,7 @@ DialogIncrements::DialogIncrements(VContainer *data, VPattern *doc, QWidget *par FillLengthLinesAngle(); FillLengthSplines(); FillLengthArcs(); + FillRadiusesArcs(); if (qApp->patternType() == MeasurementsType::Standard) { @@ -380,6 +381,12 @@ void DialogIncrements::FillLengthArcs() FillTable(data->DataLengthArcs(), ui->tableWidgetArcs); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogIncrements::FillRadiusesArcs() +{ + FillTable(data->DataRadiusesArcs(), ui->tableWidgetRadiusesArcs); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogIncrements::SetItemViewOnly(QTableWidgetItem *item) { @@ -406,6 +413,7 @@ void DialogIncrements::ShowUnits() ShowHeaderUnits(ui->tableWidgetSplines, 1, unit);// lengths ShowHeaderUnits(ui->tableWidgetArcs, 1, unit);// lengths ShowHeaderUnits(ui->tableWidgetLinesAngle, 1, "°");// lengths + ShowHeaderUnits(ui->tableWidgetRadiusesArcs, 1, unit);// radius } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/app/dialogincrements.h b/src/app/dialogs/app/dialogincrements.h index d45f7dab2..3aac33054 100644 --- a/src/app/dialogs/app/dialogincrements.h +++ b/src/app/dialogs/app/dialogincrements.h @@ -102,6 +102,7 @@ private: void FillLengthLinesAngle(); void FillLengthSplines(); void FillLengthArcs(); + void FillRadiusesArcs(); void AddIncrementToFile(const quint32 &id, const QString &name, const qreal &base, const qreal &ksize, const qreal &kheight, const QString &description); void HideColumns(QTableWidget *table); diff --git a/src/app/dialogs/app/dialogincrements.ui b/src/app/dialogs/app/dialogincrements.ui index 1f2a3ccce..e1dedad6b 100644 --- a/src/app/dialogs/app/dialogincrements.ui +++ b/src/app/dialogs/app/dialogincrements.ui @@ -39,7 +39,7 @@ QTabWidget::North - 3 + 6 @@ -665,6 +665,45 @@ + + + Radiuses arcs + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + false + + + 137 + + + false + + + false + + + + Arc + + + + + Radius + + + + + + diff --git a/src/app/dialogs/tools/dialogeditwrongformula.cpp b/src/app/dialogs/tools/dialogeditwrongformula.cpp index ad1386994..23f614630 100644 --- a/src/app/dialogs/tools/dialogeditwrongformula.cpp +++ b/src/app/dialogs/tools/dialogeditwrongformula.cpp @@ -182,6 +182,14 @@ void DialogEditWrongFormula::ValChenged(int row) ui->labelDescription->setText(desc); return; } + if (ui->radioButtonRadiusesArcs->isChecked()) + { + QString desc = QString("%1(%2) - %3").arg(item->text()) + .arg(*data->GetVariable(qApp->VarFromUser(item->text()))->GetValue()) + .arg(tr("Arc radius")); + ui->labelDescription->setText(desc); + return; + } } //--------------------------------------------------------------------------------------------------------------------- @@ -258,6 +266,13 @@ void DialogEditWrongFormula::LengthLines() ShowVariable(data->DataLengthLines()); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogEditWrongFormula::RadiusArcs() +{ + ui->checkBoxHideEmpty->setEnabled(false); + ShowVariable(data->DataRadiusesArcs()); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief LengthArcs show in list lengths of arcs variables @@ -364,6 +379,7 @@ void DialogEditWrongFormula::InitVariables() connect(ui->radioButtonLengthSpline, &QRadioButton::clicked, this, &DialogEditWrongFormula::LengthCurves); connect(ui->radioButtonAngleLine, &QRadioButton::clicked, this, &DialogEditWrongFormula::AngleLines); connect(ui->checkBoxHideEmpty, &QCheckBox::stateChanged, this, &DialogEditWrongFormula::Measurements); + connect(ui->radioButtonRadiusesArcs, &QRadioButton::clicked, this, &DialogEditWrongFormula::RadiusArcs); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/tools/dialogeditwrongformula.h b/src/app/dialogs/tools/dialogeditwrongformula.h index dffb9b228..6a559115c 100644 --- a/src/app/dialogs/tools/dialogeditwrongformula.h +++ b/src/app/dialogs/tools/dialogeditwrongformula.h @@ -70,6 +70,7 @@ public slots: void Measurements(); void LengthLines(); + void RadiusArcs(); void LengthArcs(); void LengthCurves(); void AngleLines(); diff --git a/src/app/dialogs/tools/dialogeditwrongformula.ui b/src/app/dialogs/tools/dialogeditwrongformula.ui index 27668da0b..33acda72b 100644 --- a/src/app/dialogs/tools/dialogeditwrongformula.ui +++ b/src/app/dialogs/tools/dialogeditwrongformula.ui @@ -342,6 +342,13 @@ + + + + Radius of arcs + + + diff --git a/src/app/options.cpp b/src/app/options.cpp index 40ea0e7e0..dfb49b74c 100644 --- a/src/app/options.cpp +++ b/src/app/options.cpp @@ -186,6 +186,7 @@ const QString depthWaistSecond_M = QStringLiteral("depth_waist_ //variables const QString line_ = QStringLiteral("Line_"); const QString angleLine_ = QStringLiteral("AngleLine_"); +const QString radiusArc_ = QStringLiteral("Radius"); //functions const QString sin_F = QStringLiteral("sin"); diff --git a/src/app/options.h b/src/app/options.h index 478bf66a1..14d9a9940 100644 --- a/src/app/options.h +++ b/src/app/options.h @@ -126,7 +126,8 @@ enum class Vis : unsigned char enum class Source : char { FromGui, FromFile, FromTool }; enum class NodeDetail : char { Contour, Modeling }; enum class Contour : char { OpenContour, CloseContour }; -enum class VarType : char { Measurement, Increment, LineLength, SplineLength, ArcLength, LineAngle, Unknown }; +enum class VarType : char { Measurement, Increment, LineLength, SplineLength, ArcLength, ArcRadius, LineAngle, + Unknown }; enum class GHeights : unsigned char { ALL, H92=92, H98=98, H104=104, H110=110, H116=116, H122=122, H128=128, H134=134, @@ -283,6 +284,7 @@ extern const QString depthWaistSecond_M; // variables name extern const QString line_; extern const QString angleLine_; +extern const QString radiusArc_; // functions extern const QString sin_F; diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp index 27f27878d..62429b9ac 100644 --- a/src/app/tools/drawTools/vtoolarc.cpp +++ b/src/app/tools/drawTools/vtoolarc.cpp @@ -138,12 +138,12 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &ra if (typeCreation == Source::FromGui) { id = data->AddGObject(arc); - data->AddCurveLength(id); + data->AddArc(id); } else { data->UpdateGObject(id, arc); - data->AddCurveLength(id); + data->AddArc(id); if (parse != Document::FullParse) { doc->UpdateToolData(id, data); diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp index 86a9c8f3e..9792f96a8 100644 --- a/src/app/tools/drawTools/vtoolcutarc.cpp +++ b/src/app/tools/drawTools/vtoolcutarc.cpp @@ -138,8 +138,8 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS arc1id = data->AddGObject(new VArc(arc1)); arc2id = data->AddGObject(new VArc(arc2)); - data->AddCurveLength(arc1id, id); - data->AddCurveLength(arc2id, id); + data->AddArc(arc1id, id); + data->AddArc(arc2id, id); } else { @@ -150,8 +150,8 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS data->UpdateGObject(arc1id, new VArc(arc1)); data->UpdateGObject(arc2id, new VArc(arc2)); - data->AddCurveLength(arc1id, id); - data->AddCurveLength(arc2id, id); + data->AddArc(arc1id, id); + data->AddArc(arc2id, id); if (parse != Document::FullParse) { diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 7b912c7f4..b6b77aac3 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -2611,6 +2611,7 @@ void VPattern::PrepareForParse(const Document &parse) data->ClearVariables(VarType::LineAngle); data->ClearVariables(VarType::LineLength); data->ClearVariables(VarType::SplineLength); + data->ClearVariables(VarType::ArcRadius); } }