Merge with feature. Resolved issue #315. New tool: 'Elliptic Arc'.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-12-19 16:01:20 +02:00
commit 961204a2c1
12 changed files with 214 additions and 32 deletions

View File

@ -322,6 +322,9 @@ void VToolOptionsPropertyBrowser::UpdateOptions()
case VToolMove::Type:
UpdateOptionsToolMove();
break;
case VToolEllipticalArc::Type:
UpdateOptionsToolEllipticalArc();
break;
default:
break;
}
@ -460,6 +463,9 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property)
case VToolMove::Type:
ChangeDataToolMove(prop);
break;
case VToolEllipticalArc::Type:
ChangeDataToolEllipticalArc(prop);
break;
default:
break;
}
@ -1728,6 +1734,42 @@ void VToolOptionsPropertyBrowser::ChangeDataToolFlippingByAxis(VProperty *proper
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ChangeDataToolEllipticalArc(VProperty *property)
{
SCASSERT(property != nullptr)
QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole);
const QString id = propertyToId[property];
VToolEllipticalArc *i = qgraphicsitem_cast<VToolEllipticalArc *>(currentItem);
SCASSERT(i != nullptr);
switch (PropertiesList().indexOf(id))
{
case 40://AttrRadius1
i->SetFormulaRadius1(value.value<VFormula>());
break;
case 41://AttrRadius2
i->SetFormulaRadius2(value.value<VFormula>());
break;
case 9://AttrAngle1
i->SetFormulaF1(value.value<VFormula>());
break;
case 10://AttrAngle2
i->SetFormulaF2(value.value<VFormula>());
break;
case 42://AttrRotationAngle
i->SetFormulaRotationAngle(value.value<VFormula>());
break;
case 27://AttrColor
i->SetLineColor(value.toString());
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolSinglePoint(QGraphicsItem *item)
{
@ -2656,6 +2698,35 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolFlippingByAxis()
idToProperty[AttrSuffix]->setValue(i->Suffix());
}
//---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::UpdateOptionsToolEllipticalArc()
{
VToolEllipticalArc *i = qgraphicsitem_cast<VToolEllipticalArc *>(currentItem);
QVariant valueFormulaRadius1;
valueFormulaRadius1.setValue(i->GetFormulaRadius1());
idToProperty[AttrRadius1]->setValue(valueFormulaRadius1);
QVariant valueFormulaRadius2;
valueFormulaRadius2.setValue(i->GetFormulaRadius2());
idToProperty[AttrRadius2]->setValue(valueFormulaRadius2);
QVariant valueFormulaF1;
valueFormulaF1.setValue(i->GetFormulaF1());
idToProperty[AttrAngle1]->setValue(valueFormulaF1);
QVariant valueFormulaF2;
valueFormulaF2.setValue(i->GetFormulaF2());
idToProperty[AttrAngle2]->setValue(valueFormulaF2);
QVariant valueFormulaRotationAngle;
valueFormulaRotationAngle.setValue(i->GetFormulaRotationAngle());
idToProperty[AttrRotationAngle]->setValue(valueFormulaRotationAngle);
const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor());
idToProperty[AttrColor]->setValue(index);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VToolOptionsPropertyBrowser::PropertiesList() const
{

View File

@ -161,6 +161,7 @@ private:
void ChangeDataToolMove(VPE::VProperty *property);
void ChangeDataToolFlippingByLine(VPE::VProperty *property);
void ChangeDataToolFlippingByAxis(VPE::VProperty *property);
void ChangeDataToolEllipticalArc(VPE::VProperty *property);
void ShowOptionsToolSinglePoint(QGraphicsItem *item);
void ShowOptionsToolEndLine(QGraphicsItem *item);
@ -230,6 +231,7 @@ private:
void UpdateOptionsToolMove();
void UpdateOptionsToolFlippingByLine();
void UpdateOptionsToolFlippingByAxis();
void UpdateOptionsToolEllipticalArc();
};
#endif // VTOOLOPTIONSPROPERTYBROWSER_H

View File

@ -270,25 +270,25 @@ QString DialogHistory::Record(const VToolRecord &tool)
case Tool::Spline:
{
const QSharedPointer<VSpline> spl = data->GeometricObject<VSpline>(tool.getId());
SCASSERT(spl != nullptr);
SCASSERT(not spl.isNull());
return spl->NameForHistory(tr("Curve"));
}
case Tool::CubicBezier:
{
const QSharedPointer<VCubicBezier> spl = data->GeometricObject<VCubicBezier>(tool.getId());
SCASSERT(spl != nullptr);
SCASSERT(not spl.isNull());
return spl->NameForHistory(tr("Cubic bezier curve"));
}
case Tool::Arc:
{
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(tool.getId());
SCASSERT(arc != nullptr);
SCASSERT(not arc.isNull());
return arc->NameForHistory(tr("Arc"));
}
case Tool::ArcWithLength:
{
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(tool.getId());
SCASSERT(arc != nullptr);
SCASSERT(not arc.isNull());
return tr("%1 with length %2")
.arg(arc->NameForHistory(tr("Arc")))
.arg(arc->GetLength());
@ -296,13 +296,13 @@ QString DialogHistory::Record(const VToolRecord &tool)
case Tool::SplinePath:
{
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(tool.getId());
SCASSERT(splPath != nullptr);
SCASSERT(not splPath.isNull());
return splPath->NameForHistory(tr("Spline path"));
}
case Tool::CubicBezierPath:
{
const QSharedPointer<VCubicBezierPath> splPath = data->GeometricObject<VCubicBezierPath>(tool.getId());
SCASSERT(splPath != nullptr);
SCASSERT(not splPath.isNull());
return splPath->NameForHistory(tr("Cubic bezier curve path"));
}
case Tool::PointOfContact:
@ -330,7 +330,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
case Tool::CutArc:
{
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(AttrUInt(domElem, AttrArc));
SCASSERT(arc != nullptr);
SCASSERT(not arc.isNull());
return tr("%1 - cut %2")
.arg(PointName(tool.getId()))
.arg(arc->NameForHistory(tr("arc")));
@ -339,7 +339,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
{
const quint32 splineId = AttrUInt(domElem, VToolCutSpline::AttrSpline);
const QSharedPointer<VAbstractCubicBezier> spl = data->GeometricObject<VAbstractCubicBezier>(splineId);
SCASSERT(spl != nullptr);
SCASSERT(not spl.isNull());
return tr("%1 - cut %2")
.arg(PointName(tool.getId()))
.arg(spl->NameForHistory(tr("curve")));
@ -349,7 +349,7 @@ QString DialogHistory::Record(const VToolRecord &tool)
const quint32 splinePathId = AttrUInt(domElem, VToolCutSplinePath::AttrSplinePath);
const QSharedPointer<VAbstractCubicBezierPath> splPath =
data->GeometricObject<VAbstractCubicBezierPath>(splinePathId);
SCASSERT(splPath != nullptr);
SCASSERT(not splPath.isNull());
return tr("%1 - cut %2")
.arg(PointName(tool.getId()))
.arg(splPath->NameForHistory(tr("curve path")));
@ -382,8 +382,10 @@ QString DialogHistory::Record(const VToolRecord &tool)
case Tool::EllipticalArc:
{
const QSharedPointer<VEllipticalArc> elArc = data->GeometricObject<VEllipticalArc>(tool.getId());
SCASSERT(elArc != nullptr);
return elArc->NameForHistory(tr("Elliptical arc"));
SCASSERT(not elArc.isNull());
return tr("%1 with length %2")
.arg(elArc->NameForHistory(tr("Elliptical arc")))
.arg(elArc->GetLength());
}
//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.

View File

@ -427,7 +427,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>117</width>
<width>130</width>
<height>110</height>
</rect>
</property>
@ -536,7 +536,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>117</width>
<width>130</width>
<height>248</height>
</rect>
</property>
@ -798,7 +798,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>117</width>
<width>130</width>
<height>248</height>
</rect>
</property>
@ -1064,7 +1064,7 @@
<x>0</x>
<y>0</y>
<width>130</width>
<height>56</height>
<height>58</height>
</rect>
</property>
<property name="sizePolicy">
@ -1078,7 +1078,7 @@
</property>
<attribute name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/16x16/toolsectionelarc@2x.png</normaloff>:/icon/16x16/toolsectionelarc@2x.png</iconset>
<normaloff>:/icon/16x16/toolsectionelarc.png</normaloff>:/icon/16x16/toolsectionelarc.png</iconset>
</attribute>
<attribute name="label">
<string>Elliptical Arc</string>
@ -1116,7 +1116,7 @@
<bool>false</bool>
</property>
<property name="toolTip">
<string>Arc</string>
<string>Elliptical Arc</string>
</property>
<property name="text">
<string notr="true">...</string>
@ -1144,7 +1144,7 @@
<x>0</x>
<y>0</y>
<width>130</width>
<height>356</height>
<height>326</height>
</rect>
</property>
<attribute name="icon">
@ -1321,7 +1321,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>117</width>
<width>130</width>
<height>104</height>
</rect>
</property>
@ -1431,7 +1431,7 @@
<x>0</x>
<y>0</y>
<width>130</width>
<height>356</height>
<height>326</height>
</rect>
</property>
<attribute name="icon">

View File

@ -22,6 +22,7 @@
<file>schema/pattern/v0.3.6.xsd</file>
<file>schema/pattern/v0.3.7.xsd</file>
<file>schema/pattern/v0.3.8.xsd</file>
<file>schema/pattern/v0.3.9.xsd</file>
<file>schema/standard_measurements/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file>
@ -32,6 +33,5 @@
<file>schema/individual_measurements/v0.3.1.xsd</file>
<file>schema/individual_measurements/v0.3.2.xsd</file>
<file>schema/individual_measurements/v0.3.3.xsd</file>
<file>schema/pattern/v0.3.9.xsd</file>
</qresource>
</RCC>

View File

@ -1409,8 +1409,10 @@ QStringList VAbstractPattern::ListExpressions() const
{
QStringList list;
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
list << ListPointExpressions();
list << ListArcExpressions();
list << ListElArcExpressions();
list << ListSplineExpressions();
list << ListIncrementExpressions();
list << ListOperationExpressions();
@ -1422,7 +1424,8 @@ QStringList VAbstractPattern::ListExpressions() const
QStringList VAbstractPattern::ListPointExpressions() const
{
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number
// If no just increment a number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49);
QStringList expressions;
@ -1493,7 +1496,8 @@ QStringList VAbstractPattern::ListPointExpressions() const
QStringList VAbstractPattern::ListArcExpressions() const
{
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number
// If no just increment number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49);
QStringList expressions;
@ -1542,6 +1546,69 @@ QStringList VAbstractPattern::ListArcExpressions() const
return expressions;
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VAbstractPattern::ListElArcExpressions() const
{
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49);
QStringList expressions;
const QDomNodeList list = elementsByTagName(TagElArc);
for (int i=0; i < list.size(); ++i)
{
const QDomElement dom = list.at(i).toElement();
try
{
expressions.append(GetParametrString(dom, AttrRadius1));
}
catch (VExceptionEmptyParameter &e)
{
Q_UNUSED(e)
}
try
{
expressions.append(GetParametrString(dom, AttrRadius2));
}
catch (VExceptionEmptyParameter &e)
{
Q_UNUSED(e)
}
try
{
expressions.append(GetParametrString(dom, AttrAngle1));
}
catch (VExceptionEmptyParameter &e)
{
Q_UNUSED(e)
}
try
{
expressions.append(GetParametrString(dom, AttrAngle2));
}
catch (VExceptionEmptyParameter &e)
{
Q_UNUSED(e)
}
try
{
expressions.append(GetParametrString(dom, AttrRotationAngle));
}
catch (VExceptionEmptyParameter &e)
{
Q_UNUSED(e)
}
}
return expressions;
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VAbstractPattern::ListSplineExpressions() const
{
@ -1554,7 +1621,8 @@ QStringList VAbstractPattern::ListSplineExpressions() const
QStringList VAbstractPattern::ListPathPointExpressions() const
{
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number
// If no just increment number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49);
QStringList expressions;
@ -1620,7 +1688,8 @@ QStringList VAbstractPattern::ListIncrementExpressions() const
QStringList VAbstractPattern::ListOperationExpressions() const
{
// Check if new tool doesn't bring new attribute with a formula.
// If no just increment number
// If no just increment number.
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
Q_STATIC_ASSERT(static_cast<int>(Tool::LAST_ONE_DO_NOT_USE) == 49);
QStringList expressions;

View File

@ -351,6 +351,7 @@ private:
QStringList ListExpressions() const;
QStringList ListPointExpressions() const;
QStringList ListArcExpressions() const;
QStringList ListElArcExpressions() const;
QStringList ListSplineExpressions() const;
QStringList ListPathPointExpressions() const;
QStringList ListIncrementExpressions() const;

View File

@ -175,6 +175,8 @@ QString VPatternConverter::XSDSchema(int ver) const
case (0x000307):
return QStringLiteral("://schema/pattern/v0.3.7.xsd");
case (0x000308):
return QStringLiteral("://schema/pattern/v0.3.8.xsd");
case (0x000309):
return CurrentSchema;
default:
InvalidVersion(ver);
@ -274,6 +276,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(0x000308), fileName);
V_FALLTHROUGH
case (0x000308):
ToV0_3_9();
ValidateXML(XSDSchema(0x000309), fileName);
V_FALLTHROUGH
case (0x000309):
break;
default:
break;
@ -462,6 +468,13 @@ void VPatternConverter::ToV0_3_8()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_3_9()
{
SetVersion(QStringLiteral("0.3.9"));
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{

View File

@ -55,10 +55,10 @@ public:
// GCC 4.6 doesn't allow constexpr and const together
#if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) <= 406
static Q_DECL_CONSTEXPR int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 8);
static Q_DECL_CONSTEXPR int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 9);
#else
static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 8);
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 3, 9);
#endif
protected:
@ -97,6 +97,7 @@ private:
void ToV0_3_6();
void ToV0_3_7();
void ToV0_3_8();
void ToV0_3_9();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();

View File

@ -58,7 +58,31 @@ class VContainer;
* @param parent parent widget
*/
DialogEllipticalArc::DialogEllipticalArc(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogEllipticalArc)
: DialogTool(data, toolId, parent),
ui(new Ui::DialogEllipticalArc),
flagRadius1(false),
flagRadius2(false),
flagF1(false),
flagF2(false),
flagRotationAngle(false),
timerRadius1(nullptr),
timerRadius2(nullptr),
timerF1(nullptr),
timerF2(nullptr),
timerRotationAngle(nullptr),
radius1(),
radius2(),
f1(),
f2(),
rotationAngle(),
formulaBaseHeightRadius1(0),
formulaBaseHeightRadius2(0),
formulaBaseHeightF1(0),
formulaBaseHeightF2(0),
formulaBaseHeightRotationAngle(0),
angleF1(INT_MIN),
angleF2(INT_MIN),
angleRotation(INT_MIN)
{
ui->setupUi(this);
@ -372,7 +396,7 @@ void DialogEllipticalArc::EvalAngles()
angleF2 = Eval(ui->plainTextEditF2->toPlainText(), flagF2, ui->labelResultF2, degreeSymbol, false);
labelEditFormula = ui->labelEditRotationAngle;
rotationAngle = Eval(ui->plainTextEditRotationAngle->toPlainText(), flagRotationAngle,
angleRotation = Eval(ui->plainTextEditRotationAngle->toPlainText(), flagRotationAngle,
ui->labelResultRotationAngle, degreeSymbol, false);
CheckAngles();

View File

@ -61,7 +61,7 @@ void VisToolArc::RefreshGeometry()
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(object1Id);
DrawPoint(arcCenter, *first, supportColor);
if (not qFuzzyIsNull(radius) && f1 >= 0 && f2 >= 0 && not VFuzzyComparePossibleNulls(f1, f2))
if (not qFuzzyIsNull(radius) && f1 >= 0 && f2 >= 0)
{
VArc arc = VArc (*first, radius, f1, f2);
DrawPath(this, arc.GetPath(PathDirection::Show), mainColor, Qt::SolidLine, Qt::RoundCap);

View File

@ -58,8 +58,7 @@ void VisToolEllipticalArc::RefreshGeometry()
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(object1Id);
DrawPoint(arcCenter, *first, supportColor);
if (not qFuzzyIsNull(radius1) && not qFuzzyIsNull(radius2) && f1 >= 0 && f2 >= 0 && rotationAngle >= 0
&& not VFuzzyComparePossibleNulls(f1, f2))
if (not qFuzzyIsNull(radius1) && not qFuzzyIsNull(radius2) && f1 >= 0 && f2 >= 0 && rotationAngle >= 0)
{
VEllipticalArc elArc = VEllipticalArc(*first, radius1, radius2, f1, f2, rotationAngle);
DrawPath(this, elArc.GetPath(PathDirection::Show), mainColor, Qt::SolidLine, Qt::RoundCap);