New internal variable "Radius arc".

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-05-31 12:17:09 +03:00
parent d6c90d1bcc
commit b1a354df69
19 changed files with 324 additions and 11 deletions

View File

@ -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

View File

@ -36,5 +36,6 @@
#include "variables/vsplinelength.h"
#include "variables/vlinelength.h"
#include "variables/vlineangle.h"
#include "variables/varcradius.h"
#endif // VARIABLES_H

View File

@ -0,0 +1,93 @@
/************************************************************************
**
** @file varcradius.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "varcradius.h"
#include "varcradius_p.h"
#include "../libs/vgeometry/varc.h"
#include "../core/vapplication.h"
#include <QLineF>
//---------------------------------------------------------------------------------------------------------------------
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;
}

View File

@ -0,0 +1,53 @@
/************************************************************************
**
** @file varcradius.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#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<VArcRadiusData> d;
};
#endif // VARCRADIUS_H

View File

@ -0,0 +1,67 @@
/************************************************************************
**
** @file VArcRadiusData.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VARCRADIUSDATA_H
#define VARCRADIUSDATA_H
#include <QSharedData>
#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

View File

@ -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<VArcLength>(arcId, parentId);
const QSharedPointer<VArc> arc = GeometricObject<VArc>(arcId);
VArcRadius *radius = new VArcRadius(arc.data(), arcId);
AddVariable(radius->GetName(), radius);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddObject add object to container
@ -417,6 +427,12 @@ const QMap<QString, QSharedPointer<VLineAngle> > VContainer::DataAngleLines() co
return DataVar<VLineAngle>(VarType::LineAngle);
}
//---------------------------------------------------------------------------------------------------------------------
const QMap<QString, QSharedPointer<VArcRadius> > VContainer::DataRadiusesArcs() const
{
return DataVar<VArcRadius>(VarType::ArcRadius);
}
//---------------------------------------------------------------------------------------------------------------------
bool VContainer::IsUnique(const QString &name)
{

View File

@ -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 <typename TLength>
/**
@ -223,6 +224,7 @@ public:
const QMap<QString, QSharedPointer<VSplineLength> > DataLengthSplines() const;
const QMap<QString, QSharedPointer<VArcLength> > DataLengthArcs() const;
const QMap<QString, QSharedPointer<VLineAngle> > DataAngleLines() const;
const QMap<QString, QSharedPointer<VArcRadius> > DataRadiusesArcs() const;
static bool IsUnique(const QString &name);

View File

@ -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"));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -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
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -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);

View File

@ -39,7 +39,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>3</number>
<number>6</number>
</property>
<widget class="QWidget" name="tabStandard">
<property name="sizePolicy">
@ -665,6 +665,45 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Radiuses arcs</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QTableWidget" name="tableWidgetRadiusesArcs">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>137</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Arc</string>
</property>
</column>
<column>
<property name="text">
<string>Radius</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>

View File

@ -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<VArcRadius>(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);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -70,6 +70,7 @@ public slots:
void Measurements();
void LengthLines();
void RadiusArcs();
void LengthArcs();
void LengthCurves();
void AngleLines();

View File

@ -342,6 +342,13 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonRadiusesArcs">
<property name="text">
<string>Radius of arcs</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -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");

View File

@ -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;

View File

@ -138,12 +138,12 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &ra
if (typeCreation == Source::FromGui)
{
id = data->AddGObject(arc);
data->AddCurveLength<VArcLength>(id);
data->AddArc(id);
}
else
{
data->UpdateGObject(id, arc);
data->AddCurveLength<VArcLength>(id);
data->AddArc(id);
if (parse != Document::FullParse)
{
doc->UpdateToolData(id, data);

View File

@ -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<VArcLength>(arc1id, id);
data->AddCurveLength<VArcLength>(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<VArcLength>(arc1id, id);
data->AddCurveLength<VArcLength>(arc2id, id);
data->AddArc(arc1id, id);
data->AddArc(arc2id, id);
if (parse != Document::FullParse)
{

View File

@ -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);
}
}