Merge branch 'object-alias' into develop

This commit is contained in:
Roman Telezhynskyi 2020-11-07 16:21:45 +02:00
commit d9f4035f7d
130 changed files with 4564 additions and 693 deletions

View File

@ -4,6 +4,7 @@
- Improve editing a spline path through control points for locked angles.
- [smart-pattern/valentina#73] Notes for tools.
- Fix crash while synchronize measurements.
- Object alias.
# Version 0.7.36 October 24, 2020
- [#892] Show tooltip for piece node point.

View File

@ -516,12 +516,52 @@ void VToolOptionsPropertyBrowser::AddPropertyFormula(const QString &propertyName
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyObjectName(Tool *i, const QString &propertyName, bool readOnly)
{
if (readOnly)
{
auto *itemName = new VPE::VLabelProperty(propertyName);
itemName->setValue(i->name());
AddProperty(itemName, AttrName);
}
else
{
auto *itemName = new VPE::VStringProperty(propertyName);
itemName->setClearButtonEnable(true);
itemName->setValue(i->name());
itemName->setReadOnly(readOnly);
AddProperty(itemName, AttrName);
}
}
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyAlias(Tool *i, const QString &propertyName)
{
auto *itemName = new VPE::VStringProperty(propertyName);
itemName->setClearButtonEnable(true);
itemName->setValue(qApp->TrVars()->VarToUser(i->name()));
itemName->setReadOnly(readOnly);
AddProperty(itemName, AttrName);
itemName->setValue(qApp->TrVars()->VarToUser(i->GetAliasSuffix()));
AddProperty(itemName, AttrAlias);
}
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyAlias1(Tool *i, const QString &propertyName)
{
auto *itemName = new VPE::VStringProperty(propertyName);
itemName->setClearButtonEnable(true);
itemName->setValue(qApp->TrVars()->VarToUser(i->GetAliasSuffix1()));
AddProperty(itemName, AttrAlias1);
}
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::AddPropertyAlias2(Tool *i, const QString &propertyName)
{
auto *itemName = new VPE::VStringProperty(propertyName);
itemName->setClearButtonEnable(true);
itemName->setValue(qApp->TrVars()->VarToUser(i->GetAliasSuffix2()));
AddProperty(itemName, AttrAlias2);
}
//---------------------------------------------------------------------------------------------------------------------
@ -927,6 +967,66 @@ void VToolOptionsPropertyBrowser::SetNotes(VPE::VProperty *property)
}
}
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::SetAlias(VPE::VProperty *property)
{
if (auto *i = qgraphicsitem_cast<Tool *>(currentItem))
{
QString notes = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString();
if (notes == i->GetAliasSuffix())
{
return;
}
i->SetAliasSuffix(notes);
}
else
{
qWarning()<<"Can't cast item";
}
}
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::SetAlias1(VPE::VProperty *property)
{
if (auto *i = qgraphicsitem_cast<Tool *>(currentItem))
{
QString notes = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString();
if (notes == i->GetAliasSuffix1())
{
return;
}
i->SetAliasSuffix1(notes);
}
else
{
qWarning()<<"Can't cast item";
}
}
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::SetAlias2(VPE::VProperty *property)
{
if (auto *i = qgraphicsitem_cast<Tool *>(currentItem))
{
QString notes = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString();
if (notes == i->GetAliasSuffix2())
{
return;
}
i->SetAliasSuffix2(notes);
}
else
{
qWarning()<<"Can't cast item";
}
}
//---------------------------------------------------------------------------------------------------------------------
template<class Tool>
void VToolOptionsPropertyBrowser::SetLineType(VPE::VProperty *property)
@ -1275,6 +1375,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolArc(VPE::VProperty *property)
case 61: // AttrNotes
SetNotes<VToolArc>(property);
break;
case 62: // AttrAlias
SetAlias<VToolArc>(property);
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
@ -1316,6 +1419,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolArcWithLength(VPE::VProperty *pr
case 61: // AttrNotes
SetNotes<VToolArcWithLength>(property);
break;
case 62: // AttrAlias
SetAlias<VToolArcWithLength>(property);
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
@ -1406,6 +1512,12 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCutArc(VPE::VProperty *property)
case 61: // AttrNotes
SetNotes<VToolCutArc>(property);
break;
case 63: // AttrAlias1
SetAlias1<VToolCutArc>(property);
break;
case 64: // AttrAlias2
SetAlias2<VToolCutArc>(property);
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
@ -1432,6 +1544,12 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCutSpline(VPE::VProperty *proper
case 61: // AttrNotes
SetNotes<VToolCutSpline>(property);
break;
case 63: // AttrAlias1
SetAlias1<VToolCutSpline>(property);
break;
case 64: // AttrAlias2
SetAlias2<VToolCutSpline>(property);
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
@ -1458,6 +1576,12 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCutSplinePath(VPE::VProperty *pr
case 61: // AttrNotes
SetNotes<VToolCutSplinePath>(property);
break;
case 63: // AttrAlias1
SetAlias1<VToolCutSplinePath>(property);
break;
case 64: // AttrAlias2
SetAlias2<VToolCutSplinePath>(property);
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
@ -1966,6 +2090,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolSpline(VPE::VProperty *property)
case 61: // AttrNotes
SetNotes<VToolSpline>(property);
break;
case 62: // AttrAlias
SetAlias<VToolSpline>(property);
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
@ -2004,6 +2131,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCubicBezier(VPE::VProperty *prop
case 61: // AttrNotes
SetNotes<VToolCubicBezier>(property);
break;
case 62: // AttrAlias
SetAlias<VToolCubicBezier>(property);
break;
case 55: // AttrPoint1 (read only)
case 56: // AttrPoint2 (read only)
case 57: // AttrPoint3 (read only)
@ -2047,6 +2177,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolSplinePath(VPE::VProperty *prope
case 61: // AttrNotes
SetNotes<VToolSplinePath>(property);
break;
case 62: // AttrAlias
SetAlias<VToolSplinePath>(property);
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
@ -2085,6 +2218,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCubicBezierPath(VPE::VProperty *
case 61: // AttrNotes
SetNotes<VToolCubicBezierPath>(property);
break;
case 62: // AttrAlias
SetAlias<VToolCubicBezierPath>(property);
break;
default:
qWarning()<<"Unknown property type. id = "<<id;
break;
@ -2355,6 +2491,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolEllipticalArc(VPE::VProperty *pr
case 27://AttrColor
SetLineColor<VToolEllipticalArc>(property);
break;
case 62: // AttrAlias
SetAlias<VToolEllipticalArc>(property);
break;
case 59: // AttrPenStyle
SetPenStyle<VToolEllipticalArc>(property);
break;
@ -2429,6 +2568,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolArc(QGraphicsItem *item)
AddPropertyFormula(tr("Radius:"), i->GetFormulaRadius(), AttrRadius);
AddPropertyFormula(tr("First angle:"), i->GetFormulaF1(), AttrAngle1);
AddPropertyFormula(tr("Second angle:"), i->GetFormulaF2(), AttrAngle2);
AddPropertyAlias(i, tr("Alias:"));
AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics());
AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor);
AddPropertyApproximationScale(tr("Approximation scale:"), i->GetApproximationScale());
@ -2447,6 +2587,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolArcWithLength(QGraphicsItem *it
AddPropertyFormula(tr("Radius:"), i->GetFormulaRadius(), AttrRadius);
AddPropertyFormula(tr("First angle:"), i->GetFormulaF1(), AttrAngle1);
AddPropertyFormula(tr("Length:"), i->GetFormulaLength(), AttrLength);
AddPropertyAlias(i, tr("Alias:"));
AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics());
AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor);
AddPropertyApproximationScale(tr("Approximation scale:"), i->GetApproximationScale());
@ -2496,6 +2637,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutArc(QGraphicsItem *item)
AddPropertyObjectName(i, tr("Point label:"));
AddPropertyParentPointName(i->CurveName(), tr("Arc:"), AttrArc);
AddPropertyAlias1(i, tr("Alias1:"));
AddPropertyAlias2(i, tr("Alias2:"));
AddPropertyFormula(tr("Length:"), i->GetFormulaLength(), AttrLength);
AddPropertyText(tr("Notes:"), i->GetNotes(), AttrNotes);
}
@ -2509,6 +2652,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutSpline(QGraphicsItem *item)
AddPropertyObjectName(i, tr("Point label:"));
AddPropertyParentPointName(i->CurveName(), tr("Curve:"), AttrCurve);
AddPropertyAlias1(i, tr("Alias1:"));
AddPropertyAlias2(i, tr("Alias2:"));
AddPropertyFormula(tr("Length:"), i->GetFormulaLength(), AttrLength);
AddPropertyText(tr("Notes:"), i->GetNotes(), AttrNotes);
}
@ -2522,6 +2667,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutSplinePath(QGraphicsItem *it
AddPropertyObjectName(i, tr("Point label:"));
AddPropertyParentPointName(i->CurveName(), tr("Curve:"), AttrCurve);
AddPropertyAlias1(i, tr("Alias1:"));
AddPropertyAlias2(i, tr("Alias2:"));
AddPropertyFormula(tr("Length:"), i->GetFormulaLength(), AttrLength);
AddPropertyText(tr("Notes:"), i->GetNotes(), AttrNotes);
}
@ -2755,6 +2902,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item)
length2.Eval();
AddPropertyFormula(tr("C2: length:"), length2, AttrLength2);
AddPropertyAlias(i, tr("Alias:"));
AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics());
AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor);
AddPropertyApproximationScale(tr("Approximation scale:"), spl.GetApproximationScale());
@ -2773,6 +2921,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCubicBezier(QGraphicsItem *item
AddPropertyParentPointName(i->SecondPointName(), tr("Second point:"), AttrPoint2);
AddPropertyParentPointName(i->ThirdPointName(), tr("Third point:"), AttrPoint3);
AddPropertyParentPointName(i->ForthPointName(), tr("Fourth point:"), AttrPoint4);
AddPropertyAlias(i, tr("Alias:"));
AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics());
AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor);
AddPropertyApproximationScale(tr("Approximation scale:"), i->getSpline().GetApproximationScale());
@ -2787,6 +2936,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSplinePath(QGraphicsItem *item)
formView->setTitle(tr("Tool for path curve"));
AddPropertyObjectName(i, tr("Name:"), true);
AddPropertyAlias(i, tr("Alias:"));
AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics());
AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor);
AddPropertyApproximationScale(tr("Approximation scale:"), i->getSplinePath().GetApproximationScale());
@ -2801,6 +2951,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCubicBezierPath(QGraphicsItem *
formView->setTitle(tr("Tool cubic bezier curve"));
AddPropertyObjectName(i, tr("Name:"), true);
AddPropertyAlias(i, tr("Alias:"));
AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics());
AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor);
AddPropertyApproximationScale(tr("Approximation scale:"), i->getSplinePath().GetApproximationScale());
@ -2922,6 +3073,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolEllipticalArc(QGraphicsItem *it
AddPropertyFormula(tr("First angle:"), i->GetFormulaF1(), AttrAngle1);
AddPropertyFormula(tr("Second angle:"), i->GetFormulaF2(), AttrAngle2);
AddPropertyFormula(tr("Rotation angle:"), i->GetFormulaRotationAngle(), AttrRotationAngle);
AddPropertyAlias(i, tr("Alias:"));
AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor);
AddPropertyText(tr("Notes:"), i->GetNotes(), AttrNotes);
}
@ -3002,6 +3154,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolArc()
{
auto *i = qgraphicsitem_cast<VToolArc *>(currentItem);
idToProperty[AttrName]->setValue(i->name());
QVariant valueRadius;
valueRadius.setValue(i->GetFormulaRadius());
idToProperty[AttrRadius]->setValue(valueRadius);
@ -3033,6 +3187,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolArc()
idToProperty[AttrAScale]->setValue(valueApproximationScale);
idToProperty[AttrNotes]->setValue(i->GetNotes());
idToProperty[AttrAlias]->setValue(i->GetAliasSuffix());
}
//---------------------------------------------------------------------------------------------------------------------
@ -3040,6 +3196,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolArcWithLength()
{
auto *i = qgraphicsitem_cast<VToolArcWithLength *>(currentItem);
idToProperty[AttrName]->setValue(i->name());
QVariant valueRadius;
valueRadius.setValue(i->GetFormulaRadius());
idToProperty[AttrRadius]->setValue(valueRadius);
@ -3071,6 +3229,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolArcWithLength()
idToProperty[AttrAScale]->setValue(valueApproximationScale);
idToProperty[AttrNotes]->setValue(i->GetNotes());
idToProperty[AttrAlias]->setValue(i->GetAliasSuffix());
}
//---------------------------------------------------------------------------------------------------------------------
@ -3156,6 +3316,9 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCutArc()
idToProperty[AttrArc]->setValue(valueArc);
idToProperty[AttrNotes]->setValue(i->GetNotes());
idToProperty[AttrAlias1]->setValue(i->GetAliasSuffix1());
idToProperty[AttrAlias2]->setValue(i->GetAliasSuffix2());
}
//---------------------------------------------------------------------------------------------------------------------
@ -3174,6 +3337,9 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSpline()
idToProperty[AttrCurve]->setValue(valueCurve);
idToProperty[AttrNotes]->setValue(i->GetNotes());
idToProperty[AttrAlias1]->setValue(i->GetAliasSuffix1());
idToProperty[AttrAlias2]->setValue(i->GetAliasSuffix2());
}
//---------------------------------------------------------------------------------------------------------------------
@ -3192,6 +3358,9 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSplinePath()
idToProperty[AttrCurve]->setValue(valueCurve);
idToProperty[AttrNotes]->setValue(i->GetNotes());
idToProperty[AttrAlias1]->setValue(i->GetAliasSuffix1());
idToProperty[AttrAlias2]->setValue(i->GetAliasSuffix2());
}
//---------------------------------------------------------------------------------------------------------------------
@ -3506,7 +3675,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
auto *i = qgraphicsitem_cast<VToolSpline *>(currentItem);
const VSpline spl = i->getSpline();
idToProperty[AttrName]->setValue(qApp->TrVars()->VarToUser(i->name()));
idToProperty[AttrName]->setValue(i->name());
VFormula angle1F(spl.GetStartAngleFormula(), i->getData());
angle1F.setCheckZero(false);
@ -3557,6 +3726,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
idToProperty[AttrAScale]->setValue(valueApproximationScale);
idToProperty[AttrNotes]->setValue(i->GetNotes());
idToProperty[AttrAlias]->setValue(i->GetAliasSuffix());
}
//---------------------------------------------------------------------------------------------------------------------
@ -3564,7 +3735,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCubicBezier()
{
auto *i = qgraphicsitem_cast<VToolCubicBezier *>(currentItem);
idToProperty[AttrName]->setValue(qApp->TrVars()->VarToUser(i->name()));
idToProperty[AttrName]->setValue(i->name());
{
const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle());
@ -3595,6 +3766,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCubicBezier()
idToProperty[AttrAScale]->setValue(valueApproximationScale);
idToProperty[AttrNotes]->setValue(i->GetNotes());
idToProperty[AttrAlias]->setValue(i->GetAliasSuffix());
}
//---------------------------------------------------------------------------------------------------------------------
@ -3602,7 +3775,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSplinePath()
{
auto *i = qgraphicsitem_cast<VToolSplinePath *>(currentItem);
idToProperty[AttrName]->setValue(qApp->TrVars()->VarToUser(i->name()));
idToProperty[AttrName]->setValue(i->name());
{
const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle());
@ -3617,6 +3790,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSplinePath()
idToProperty[AttrAScale]->setValue(valueApproximationScale);
idToProperty[AttrNotes]->setValue(i->GetNotes());
idToProperty[AttrAlias]->setValue(i->GetAliasSuffix());
}
//---------------------------------------------------------------------------------------------------------------------
@ -3624,7 +3799,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCubicBezierPath()
{
auto *i = qgraphicsitem_cast<VToolCubicBezierPath *>(currentItem);
idToProperty[AttrName]->setValue(qApp->TrVars()->VarToUser(i->name()));
idToProperty[AttrName]->setValue(i->name());
{
const qint32 index = VPE::VLineTypeProperty::IndexOfStyle(CurvePenStylesPics(), i->GetPenStyle());
@ -3639,6 +3814,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCubicBezierPath()
idToProperty[AttrAScale]->setValue(valueApproximationScale);
idToProperty[AttrNotes]->setValue(i->GetNotes());
idToProperty[AttrAlias]->setValue(i->GetAliasSuffix());
}
//---------------------------------------------------------------------------------------------------------------------
@ -3811,6 +3988,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolEllipticalArc()
{
auto *i = qgraphicsitem_cast<VToolEllipticalArc *>(currentItem);
idToProperty[AttrName]->setValue(i->name());
QVariant valueFormulaRadius1;
valueFormulaRadius1.setValue(i->GetFormulaRadius1());
idToProperty[AttrRadius1]->setValue(valueFormulaRadius1);
@ -3839,72 +4018,79 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolEllipticalArc()
idToProperty[AttrCenter]->setValue(valueCenterPoint);
idToProperty[AttrNotes]->setValue(i->GetNotes());
idToProperty[AttrAlias]->setValue(i->GetAliasSuffix());
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VToolOptionsPropertyBrowser::PropertiesList() const
{
static QStringList attr = QStringList() << AttrName /* 0 */
<< QLatin1String("position") /* 1 */
<< AttrBasePoint /* 2 */
<< AttrTypeLine /* 3 */
<< AttrLength /* 4 */
<< AttrAngle /* 5 */
<< AttrFirstPoint /* 6 */
<< AttrSecondPoint /* 7 */
<< AttrRadius /* 8 */
<< AttrAngle1 /* 9 */
<< AttrAngle2 /* 10 */
<< AttrCenter /* 11 */
<< AttrThirdPoint /* 12 */
<< AttrArc /* 13 */
<< VToolCutSpline::AttrSpline /* 14 */
<< VToolCutSplinePath::AttrSplinePath /* 15 */
<< AttrP1Line /* 16 */
<< AttrP2Line /* 17 */
<< AttrP1Line1 /* 18 */
<< AttrP2Line1 /* 19 */
<< AttrP1Line2 /* 20 */
<< AttrP2Line2 /* 21 */
<< AttrPShoulder /* 22 */
<< AttrAxisP1 /* 23 */
<< AttrAxisP2 /* 24 */
<< AttrKCurve /*Not used*/ /* 25 */
<< AttrLineColor /* 26 */
<< AttrColor /* 27 */
<< AttrCrossPoint /* 28 */
<< AttrC1Radius /* 29 */
<< AttrC2Radius /* 30 */
<< AttrCRadius /* 31 */
<< AttrName1 /* 32 */
<< AttrName2 /* 33 */
<< AttrVCrossPoint /* 34 */
<< AttrHCrossPoint /* 35 */
<< AttrLength1 /* 36 */
<< AttrLength2 /* 37 */
<< AttrSuffix /* 38 */
<< AttrAxisType /* 39 */
<< AttrRadius1 /* 40 */
<< AttrRadius2 /* 41 */
<< AttrRotationAngle /* 42 */
<< AttrDartP1 /* 43 */
<< AttrDartP2 /* 44 */
<< AttrDartP3 /* 45 */
<< AttrCurve /* 46 */
<< AttrFirstArc /* 47 */
<< AttrSecondArc /* 48 */
<< AttrC1Center /* 49 */
<< AttrC2Center /* 50 */
<< AttrCurve1 /* 51 */
<< AttrCurve2 /* 52 */
<< AttrCCenter /* 53 */
<< AttrTangent /* 54 */
<< AttrPoint1 /* 55 */
<< AttrPoint2 /* 56 */
<< AttrPoint3 /* 57 */
<< AttrPoint4 /* 58 */
<< AttrPenStyle /* 59 */
<< AttrAScale /* 60 */
<< AttrNotes; /* 61 */
static QStringList attr{
AttrName, /* 0 */
QLatin1String("position"), /* 1 */
AttrBasePoint, /* 2 */
AttrTypeLine, /* 3 */
AttrLength, /* 4 */
AttrAngle, /* 5 */
AttrFirstPoint, /* 6 */
AttrSecondPoint, /* 7 */
AttrRadius, /* 8 */
AttrAngle1, /* 9 */
AttrAngle2, /* 10 */
AttrCenter, /* 11 */
AttrThirdPoint, /* 12 */
AttrArc, /* 13 */
VToolCutSpline::AttrSpline, /* 14 */
VToolCutSplinePath::AttrSplinePath, /* 15 */
AttrP1Line, /* 16 */
AttrP2Line, /* 17 */
AttrP1Line1, /* 18 */
AttrP2Line1, /* 19 */
AttrP1Line2, /* 20 */
AttrP2Line2, /* 21 */
AttrPShoulder, /* 22 */
AttrAxisP1, /* 23 */
AttrAxisP2, /* 24 */
AttrKCurve, /*Not used*/ /* 25 */
AttrLineColor, /* 26 */
AttrColor, /* 27 */
AttrCrossPoint, /* 28 */
AttrC1Radius, /* 29 */
AttrC2Radius, /* 30 */
AttrCRadius, /* 31 */
AttrName1, /* 32 */
AttrName2, /* 33 */
AttrVCrossPoint, /* 34 */
AttrHCrossPoint, /* 35 */
AttrLength1, /* 36 */
AttrLength2, /* 37 */
AttrSuffix, /* 38 */
AttrAxisType, /* 39 */
AttrRadius1, /* 40 */
AttrRadius2, /* 41 */
AttrRotationAngle, /* 42 */
AttrDartP1, /* 43 */
AttrDartP2, /* 44 */
AttrDartP3, /* 45 */
AttrCurve, /* 46 */
AttrFirstArc, /* 47 */
AttrSecondArc, /* 48 */
AttrC1Center, /* 49 */
AttrC2Center, /* 50 */
AttrCurve1, /* 51 */
AttrCurve2, /* 52 */
AttrCCenter, /* 53 */
AttrTangent, /* 54 */
AttrPoint1, /* 55 */
AttrPoint2, /* 56 */
AttrPoint3, /* 57 */
AttrPoint4, /* 58 */
AttrPenStyle, /* 59 */
AttrAScale, /* 60 */
AttrNotes, /* 61 */
AttrAlias, /* 62 */
AttrAlias1, /* 63 */
AttrAlias2 /* 64 */
};
return attr;
}

View File

@ -96,6 +96,15 @@ private:
template<class Tool>
void SetNotes(VPE::VProperty *property);
template<class Tool>
void SetAlias(VPE::VProperty *property);
template<class Tool>
void SetAlias1(VPE::VProperty *property);
template<class Tool>
void SetAlias2(VPE::VProperty *property);
template<class Tool>
void SetLineType(VPE::VProperty *property);
@ -129,6 +138,15 @@ private:
template<class Tool>
void AddPropertyObjectName(Tool *i, const QString &propertyName, bool readOnly = false);
template<class Tool>
void AddPropertyAlias(Tool *i, const QString &propertyName);
template<class Tool>
void AddPropertyAlias1(Tool *i, const QString &propertyName);
template<class Tool>
void AddPropertyAlias2(Tool *i, const QString &propertyName);
template<class Tool>
void AddPropertyPointName1(Tool *i, const QString &propertyName);

View File

@ -2030,7 +2030,7 @@ void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domEle
try
{
VToolCutSplineInitData initData;
VToolCutInitData initData;
initData.scene = scene;
initData.doc = this;
initData.data = data;
@ -2040,7 +2040,9 @@ void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domEle
PointsCommonAttributes(domElement, initData);
initData.formula = GetParametrString(domElement, AttrLength, QChar('0'));
const QString f = initData.formula;//need for saving fixed formula;
initData.splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR);
initData.baseCurveId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR);
initData.aliasSuffix1 = GetParametrEmptyString(domElement, AttrAlias1);
initData.aliasSuffix2 = GetParametrEmptyString(domElement, AttrAlias2);
VToolCutSpline::Create(initData);
//Rewrite attribute formula. Need for situation when we have wrong formula.
@ -2073,7 +2075,7 @@ void VPattern::ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &do
try
{
VToolCutSplinePathInitData initData;
VToolCutInitData initData;
initData.scene = scene;
initData.doc = this;
initData.data = data;
@ -2083,7 +2085,9 @@ void VPattern::ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &do
PointsCommonAttributes(domElement, initData);
initData.formula = GetParametrString(domElement, AttrLength, QChar('0'));
const QString f = initData.formula;//need for saving fixed formula;
initData.splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, NULL_ID_STR);
initData.baseCurveId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, NULL_ID_STR);
initData.aliasSuffix1 = GetParametrEmptyString(domElement, AttrAlias1);
initData.aliasSuffix2 = GetParametrEmptyString(domElement, AttrAlias2);
VToolCutSplinePath::Create(initData);
//Rewrite attribute formula. Need for situation when we have wrong formula.
@ -2116,7 +2120,7 @@ void VPattern::ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElemen
try
{
VToolCutArcInitData initData;
VToolCutInitData initData;
initData.scene = scene;
initData.doc = this;
initData.data = data;
@ -2126,7 +2130,9 @@ void VPattern::ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElemen
PointsCommonAttributes(domElement, initData);
initData.formula = GetParametrString(domElement, AttrLength, QChar('0'));
const QString f = initData.formula;//need for saving fixed formula;
initData.arcId = GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
initData.baseCurveId = GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
initData.aliasSuffix1 = GetParametrEmptyString(domElement, AttrAlias1);
initData.aliasSuffix2 = GetParametrEmptyString(domElement, AttrAlias2);
VToolCutArc::Create(initData);
//Rewrite attribute formula. Need for situation when we have wrong formula.
@ -2557,6 +2563,7 @@ void VPattern::ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElemen
initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
initData.duplicate = GetParametrUInt(domElement, AttrDuplicate, QChar('0'));
initData.approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0'));
initData.aliasSuffix = GetParametrEmptyString(domElement, AttrAlias);
VToolSpline *spl = VToolSpline::Create(initData);
@ -2618,6 +2625,7 @@ void VPattern::ParseToolCubicBezier(VMainGraphicsScene *scene, const QDomElement
const QString penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, QChar('0'));
const qreal approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0'));
const QString alias = GetParametrEmptyString(domElement, AttrAlias);
auto p1 = data->GeometricObject<VPointF>(point1);
auto p2 = data->GeometricObject<VPointF>(point2);
@ -2633,6 +2641,7 @@ void VPattern::ParseToolCubicBezier(VMainGraphicsScene *scene, const QDomElement
initData.spline->SetPenStyle(penStyle);
initData.spline->SetPenStyle(penStyle);
initData.spline->SetApproximationScale(approximationScale);
initData.spline->SetAliasSuffix(alias);
VToolCubicBezier::Create(initData);
}
@ -2736,6 +2745,7 @@ void VPattern::ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement
initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
initData.duplicate = GetParametrUInt(domElement, AttrDuplicate, QChar('0'));
initData.approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0'));
initData.aliasSuffix = GetParametrEmptyString(domElement, AttrAlias);
const QDomNodeList nodeList = domElement.childNodes();
const qint32 num = nodeList.size();
@ -2828,6 +2838,7 @@ void VPattern::ParseToolCubicBezierPath(VMainGraphicsScene *scene, const QDomEle
const QString penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, QChar('0'));
const qreal approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0'));
const QString alias = GetParametrEmptyString(domElement, AttrAlias);
QVector<VPointF> points;
@ -2859,6 +2870,7 @@ void VPattern::ParseToolCubicBezierPath(VMainGraphicsScene *scene, const QDomEle
initData.path->SetColor(color);
initData.path->SetPenStyle(penStyle);
initData.path->SetApproximationScale(approximationScale);
initData.path->SetAliasSuffix(alias);
VToolCubicBezierPath::Create(initData);
}
@ -2992,6 +3004,7 @@ void VPattern::ParseToolArc(VMainGraphicsScene *scene, QDomElement &domElement,
initData.color = GetParametrString(domElement, AttrColor, ColorBlack);
initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
initData.approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0'));
initData.aliasSuffix = GetParametrEmptyString(domElement, AttrAlias);
VToolArc::Create(initData);
//Rewrite attribute formula. Need for situation when we have wrong formula.
@ -3048,6 +3061,7 @@ void VPattern::ParseToolEllipticalArc(VMainGraphicsScene *scene, QDomElement &do
initData.color = GetParametrString(domElement, AttrColor, ColorBlack);
initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
initData.approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0'));
initData.aliasSuffix = GetParametrEmptyString(domElement, AttrAlias);
VToolEllipticalArc::Create(initData);
//Rewrite attribute formula. Need for situation when we have wrong formula.
@ -3181,6 +3195,7 @@ void VPattern::ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &do
initData.color = GetParametrString(domElement, AttrColor, ColorBlack);
initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
initData.approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0'));
initData.aliasSuffix = GetParametrEmptyString(domElement, AttrAlias);
VToolArcWithLength::Create(initData);
//Rewrite attribute formula. Need for situation when we have wrong formula.

View File

@ -134,6 +134,9 @@ const QString AttrVersion = QStringLiteral("version");
const QString AttrFirstToCountour = QStringLiteral("firstToCountour");
const QString AttrLastToCountour = QStringLiteral("lastToCountour");
const QString AttrNotes = QStringLiteral("notes");
const QString AttrAlias = QStringLiteral("alias");
const QString AttrAlias1 = QStringLiteral("alias1");
const QString AttrAlias2 = QStringLiteral("alias2");
const QString TypeLineNone = QStringLiteral("none");
const QString TypeLineLine = QStringLiteral("hair");

View File

@ -152,6 +152,9 @@ extern const QString AttrVersion;
extern const QString AttrFirstToCountour;
extern const QString AttrLastToCountour;
extern const QString AttrNotes;
extern const QString AttrAlias;
extern const QString AttrAlias1;
extern const QString AttrAlias2;
extern const QString TypeLineNone;
extern const QString TypeLineLine;

View File

@ -61,6 +61,7 @@
<file>schema/pattern/v0.8.7.xsd</file>
<file>schema/pattern/v0.8.8.xsd</file>
<file>schema/pattern/v0.8.9.xsd</file>
<file>schema/pattern/v0.8.10.xsd</file>
<file>schema/multisize_measurements/v0.3.0.xsd</file>
<file>schema/multisize_measurements/v0.4.0.xsd</file>
<file>schema/multisize_measurements/v0.4.1.xsd</file>

File diff suppressed because it is too large Load Diff

View File

@ -59,8 +59,8 @@ class QDomElement;
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.9");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.9.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.10");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.10.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -239,7 +239,8 @@ QString VPatternConverter::XSDSchema(int ver) const
std::make_pair(FORMAT_VERSION(0, 8, 6), QStringLiteral("://schema/pattern/v0.8.6.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 7), QStringLiteral("://schema/pattern/v0.8.7.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 8), QStringLiteral("://schema/pattern/v0.8.8.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 9), CurrentSchema)
std::make_pair(FORMAT_VERSION(0, 8, 9), QStringLiteral("://schema/pattern/v0.8.9.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 10), CurrentSchema)
};
if (schemas.contains(ver))
@ -496,6 +497,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 9)));
Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 8, 9)):
ToV0_8_10();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 10)));
Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 8, 10)):
break;
default:
InvalidVersion(m_ver);
@ -513,7 +518,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
bool VPatternConverter::IsReadOnly() const
{
// Check if attribute readOnly was not changed in file format
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 9),
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 10),
"Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc.
@ -1174,6 +1179,16 @@ void VPatternConverter::ToV0_8_9()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_8_10()
{
// TODO. Delete if minimal supported version is 0.8.10
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 8, 10),
"Time to refactor the code.");
SetVersion(QStringLiteral("0.8.10"));
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()
{

View File

@ -53,7 +53,7 @@ public:
static const QString PatternMaxVerStr;
static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int PatternMinVer = FORMAT_VERSION(0, 1, 4);
static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 9);
static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 10);
protected:
virtual int MinVer() const override;
@ -132,6 +132,7 @@ private:
void ToV0_8_7();
void ToV0_8_8();
void ToV0_8_9();
void ToV0_8_10();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();

View File

@ -89,7 +89,7 @@ VPatternRecipe::VPatternRecipe(VContainer *data, VAbstractPattern *pattern, QObj
QDomElement recipeElement = createElement(QStringLiteral("recipe"));
recipeElement.appendChild(createComment(FileComment()));
SetAttribute(recipeElement, QStringLiteral("version"), QStringLiteral("1.2.0"));
SetAttribute(recipeElement, QStringLiteral("version"), QStringLiteral("1.3.0"));
recipeElement.appendChild(Prerequisite());
recipeElement.appendChild(Content());
@ -811,6 +811,8 @@ QDomElement VPatternRecipe::CutArc(const VToolRecord &record)
Formula(step, tool->GetFormulaLength(), AttrLength, AttrLengthValue);
SetAttribute(step, AttrArc, tool->CurveName());
CutCurveAttributes(step, tool);
return step;
}
@ -825,6 +827,8 @@ QDomElement VPatternRecipe::CutSpline(const VToolRecord &record)
Formula(step, tool->GetFormulaLength(), AttrLength, AttrLengthValue);
SetAttribute(step, VToolCutSpline::AttrSpline, tool->CurveName());
CutCurveAttributes(step, tool);
return step;
}
@ -839,6 +843,8 @@ QDomElement VPatternRecipe::CutSplinePath(const VToolRecord &record)
Formula(step, tool->GetFormulaLength(), AttrLength, AttrLengthValue);
SetAttribute(step, VToolCutSplinePath::AttrSplinePath, tool->CurveName());
CutCurveAttributes(step, tool);
return step;
}
@ -1097,6 +1103,16 @@ void VPatternRecipe::CurveAttributes(QDomElement &step, T *tool)
SetAttribute(step, AttrPenStyle, tool->GetPenStyle());
SetAttribute(step, AttrAScale, tool->GetApproximationScale());
SetAttribute(step, AttrDuplicate, tool->GetDuplicate());
SetAttribute(step, AttrAlias, tool->GetAliasSuffix());
}
//---------------------------------------------------------------------------------------------------------------------
template<typename T>
void VPatternRecipe::CutCurveAttributes(QDomElement &step, T *tool)
{
SetAttribute(step, AttrAlias1, tool->GetAliasSuffix1());
SetAttribute(step, AttrAlias2, tool->GetAliasSuffix2());
}
//---------------------------------------------------------------------------------------------------------------------
@ -1114,17 +1130,34 @@ QDomElement VPatternRecipe::GroupOperationSource(VAbstractOperation *tool, quint
SCASSERT(tool)
QDomElement nodes = createElement(QStringLiteral("nodes"));
QVector<QString> names = tool->SourceItems();
QVector<SourceItem> items = tool->SourceItems();
if (names.isEmpty())
if (items.isEmpty())
{
throw VExceptionInvalidHistory(QObject::tr("Empty list of nodes for tool with id '%1'.").arg(id));
}
for (auto &nodeName : names)
for (auto &item : items)
{
QDomElement node = createElement(QStringLiteral("node"));
SetAttribute(node, AttrItem, nodeName);
QSharedPointer<VGObject> obj;
try
{
obj = m_data->GetGObject(item.id);
}
catch (const VExceptionBadId &e)
{
qCritical() << e.ErrorMessage()<<Q_FUNC_INFO;
continue;
}
SetAttribute(node, AttrItem, obj->name());
if (not obj->GetAlias().isEmpty())
{
SetAttribute(node, AttrAlias, obj->GetAlias());
}
nodes.appendChild(node);
}

View File

@ -115,6 +115,9 @@ private:
template <typename T>
void CurveAttributes(QDomElement &step, T* tool);
template <typename T>
void CutCurveAttributes(QDomElement &step, T* tool);
QDomElement GroupOperationSource(VAbstractOperation *tool, quint32 id);
};

View File

@ -181,7 +181,15 @@ QString VAbstractArc::NameForHistory(const QString &toolName) const
{
name += QString("_%1").arg(GetDuplicate());
}
return name;
QString alias;
if (not GetAliasSuffix().isEmpty())
{
alias = QString("%1 %2").arg(toolName, GetAliasSuffix());
}
return not alias.isEmpty() ? QString("%1 (%2)").arg(alias, name) : name;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -475,7 +475,15 @@ QString VAbstractCubicBezier::NameForHistory(const QString &toolName) const
{
name += QString("_%1").arg(GetDuplicate());
}
return name;
QString alias;
if (not GetAliasSuffix().isEmpty())
{
alias = QString("%1 %2").arg(toolName, GetAliasSuffix());
}
return not alias.isEmpty() ? QString("%1 (%2)").arg(alias, name) : name;
}
//---------------------------------------------------------------------------------------------------------------------
@ -516,6 +524,19 @@ void VAbstractCubicBezier::CreateName()
setName(name);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractCubicBezier::CreateAlias()
{
const QString aliasSuffix = GetAliasSuffix();
if (aliasSuffix.isEmpty())
{
SetAlias(QString());
return;
}
SetAlias(SPL_ + aliasSuffix);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetCubicBezierPoints return list with cubic bezier curve points.

View File

@ -63,6 +63,7 @@ public:
protected:
virtual void CreateName() override;
virtual void CreateAlias() override;
static QVector<QPointF> GetCubicBezierPoints(const QPointF &p1, const QPointF &p2, const QPointF &p3,
const QPointF &p4, qreal approximationScale);

View File

@ -265,7 +265,15 @@ QString VAbstractCubicBezierPath::NameForHistory(const QString &toolName) const
name += QString("_%1").arg(GetDuplicate());
}
}
return name;
QString alias;
if (not GetAliasSuffix().isEmpty())
{
alias = QString("%1 %2").arg(toolName, GetAliasSuffix());
}
return not alias.isEmpty() ? QString("%1 (%2)").arg(alias, name) : name;
}
//---------------------------------------------------------------------------------------------------------------------
@ -288,3 +296,16 @@ void VAbstractCubicBezierPath::CreateName()
}
setName(name);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractCubicBezierPath::CreateAlias()
{
const QString aliasSuffix = GetAliasSuffix();
if (aliasSuffix.isEmpty())
{
SetAlias(QString());
return;
}
SetAlias(splPath + '_' + aliasSuffix);
}

View File

@ -74,6 +74,7 @@ public:
protected:
virtual void CreateName() override;
virtual void CreateAlias() override;
virtual VPointF FirstPoint() const =0;
virtual VPointF LastPoint() const =0;

View File

@ -603,6 +603,13 @@ qreal VAbstractCurve::LengthCurveDirectionArrow()
return qApp->Settings()->GetLineWidth() * 8.0;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractCurve::SetAliasSuffix(const QString &aliasSuffix)
{
VGObject::SetAliasSuffix(aliasSuffix);
CreateAlias();
}
//---------------------------------------------------------------------------------------------------------------------
qreal VAbstractCurve::PathLength(const QVector<QPointF> &path)
{

View File

@ -105,8 +105,11 @@ public:
static QPainterPath ShowDirection(const QVector<DirectionArrow> &arrows, qreal width);
static qreal LengthCurveDirectionArrow();
virtual void SetAliasSuffix(const QString &aliasSuffix) override;
protected:
virtual void CreateName() =0;
virtual void CreateName() =0;
virtual void CreateAlias() =0;
private:
QSharedDataPointer<VAbstractCurveData> d;

View File

@ -145,6 +145,12 @@ VArc VArc::Rotate(const QPointF &originPoint, qreal degrees, const QString &pref
VArc arc(center, GetRadius(), f1, f2);
arc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
arc.SetAliasSuffix(GetAliasSuffix() + prefix);
}
arc.SetColor(GetColor());
arc.SetPenStyle(GetPenStyle());
arc.SetFlipped(IsFlipped());
@ -165,6 +171,12 @@ VArc VArc::Flip(const QLineF &axis, const QString &prefix) const
VArc arc(center, GetRadius(), f1, f2);
arc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
arc.SetAliasSuffix(GetAliasSuffix() + prefix);
}
arc.SetColor(GetColor());
arc.SetPenStyle(GetPenStyle());
arc.SetFlipped(not IsFlipped());
@ -185,6 +197,12 @@ VArc VArc::Move(qreal length, qreal angle, const QString &prefix) const
VArc arc(center, GetRadius(), f1, f2);
arc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
arc.SetAliasSuffix(GetAliasSuffix() + prefix);
}
arc.SetColor(GetColor());
arc.SetPenStyle(GetPenStyle());
arc.SetFlipped(IsFlipped());
@ -378,7 +396,7 @@ QPointF VArc::CutArc(qreal length) const
//---------------------------------------------------------------------------------------------------------------------
void VArc::CreateName()
{
QString name = ARC_ + QString("%1").arg(this->GetCenter().name());
QString name = ARC_ + this->GetCenter().name();
if (getMode() == Draw::Modeling && getIdObject() != NULL_ID)
{
@ -397,6 +415,19 @@ void VArc::CreateName()
setName(name);
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::CreateAlias()
{
const QString aliasSuffix = GetAliasSuffix();
if (aliasSuffix.isEmpty())
{
SetAlias(QString());
return;
}
SetAlias(ARC_ + aliasSuffix);
}
//---------------------------------------------------------------------------------------------------------------------
void VArc::FindF2(qreal length)
{

View File

@ -85,6 +85,7 @@ public:
QPointF CutArc (qreal length) const;
protected:
virtual void CreateName() override;
virtual void CreateAlias() override;
virtual void FindF2(qreal length) override;
private:
QSharedDataPointer<VArcData> d;

View File

@ -88,6 +88,12 @@ VCubicBezier VCubicBezier::Rotate(const QPointF &originPoint, qreal degrees, con
const VPointF p4 = GetP4().Rotate(originPoint, degrees);
VCubicBezier curve(p1, p2, p3, p4);
curve.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
}
curve.SetColor(GetColor());
curve.SetPenStyle(GetPenStyle());
curve.SetApproximationScale(GetApproximationScale());
@ -103,6 +109,12 @@ VCubicBezier VCubicBezier::Flip(const QLineF &axis, const QString &prefix) const
const VPointF p4 = GetP4().Flip(axis);
VCubicBezier curve(p1, p2, p3, p4);
curve.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
}
curve.SetColor(GetColor());
curve.SetPenStyle(GetPenStyle());
curve.SetApproximationScale(GetApproximationScale());
@ -118,6 +130,12 @@ VCubicBezier VCubicBezier::Move(qreal length, qreal angle, const QString &prefix
const VPointF p4 = GetP4().Move(length, angle);
VCubicBezier curve(p1, p2, p3, p4);
curve.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
}
curve.SetColor(GetColor());
curve.SetPenStyle(GetPenStyle());
curve.SetApproximationScale(GetApproximationScale());

View File

@ -104,6 +104,12 @@ VCubicBezierPath VCubicBezierPath::Rotate(const QPointF &originPoint, qreal degr
curve.append(point.Rotate(originPoint, degrees));
}
curve.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
}
curve.SetColor(GetColor());
curve.SetPenStyle(GetPenStyle());
curve.SetApproximationScale(GetApproximationScale());
@ -120,6 +126,12 @@ VCubicBezierPath VCubicBezierPath::Flip(const QLineF &axis, const QString &prefi
curve.append(point.Flip(axis));
}
curve.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
}
curve.SetColor(GetColor());
curve.SetPenStyle(GetPenStyle());
curve.SetApproximationScale(GetApproximationScale());
@ -136,6 +148,12 @@ VCubicBezierPath VCubicBezierPath::Move(qreal length, qreal angle, const QString
curve.append(point.Move(length, angle));
}
curve.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
curve.SetAliasSuffix(GetAliasSuffix() + prefix);
}
curve.SetColor(GetColor());
curve.SetPenStyle(GetPenStyle());
curve.SetApproximationScale(GetApproximationScale());

View File

@ -153,6 +153,12 @@ VEllipticalArc VEllipticalArc::Rotate(QPointF originPoint, qreal degrees, const
VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(),
VAbstractArc::GetEndAngle(), GetRotationAngle());
elArc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
elArc.SetAliasSuffix(GetAliasSuffix() + prefix);
}
elArc.SetColor(GetColor());
elArc.SetPenStyle(GetPenStyle());
elArc.SetFlipped(IsFlipped());
@ -166,6 +172,12 @@ VEllipticalArc VEllipticalArc::Flip(const QLineF &axis, const QString &prefix) c
VEllipticalArc elArc(VAbstractArc::GetCenter(), GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(),
VAbstractArc::GetEndAngle(), GetRotationAngle());
elArc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
elArc.SetAliasSuffix(GetAliasSuffix() + prefix);
}
elArc.SetColor(GetColor());
elArc.SetPenStyle(GetPenStyle());
elArc.SetFlipped(not IsFlipped());
@ -188,6 +200,12 @@ VEllipticalArc VEllipticalArc::Move(qreal length, qreal angle, const QString &pr
VEllipticalArc elArc(oldCenter, GetRadius1(), GetRadius2(), VAbstractArc::GetStartAngle(),
VAbstractArc::GetEndAngle(), GetRotationAngle());
elArc.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
elArc.SetAliasSuffix(GetAliasSuffix() + prefix);
}
elArc.SetColor(GetColor());
elArc.SetPenStyle(GetPenStyle());
elArc.SetFlipped(IsFlipped());
@ -399,6 +417,19 @@ void VEllipticalArc::CreateName()
setName(name);
}
//---------------------------------------------------------------------------------------------------------------------
void VEllipticalArc::CreateAlias()
{
const QString aliasSuffix = GetAliasSuffix();
if (aliasSuffix.isEmpty())
{
SetAlias(QString());
return;
}
SetAlias(ELARC_ + aliasSuffix);
}
//---------------------------------------------------------------------------------------------------------------------
void VEllipticalArc::FindF2(qreal length)
{

View File

@ -104,6 +104,7 @@ public:
static qreal OptimizeAngle(qreal angle);
protected:
virtual void CreateName() override;
virtual void CreateAlias() override;
virtual void FindF2(qreal length) override;
private:
QSharedDataPointer<VEllipticalArcData> d;

View File

@ -41,6 +41,7 @@
#include "../vmisc/compatibility.h"
#include "../ifc/ifcdef.h"
#include "vgobject_p.h"
#include "../vmisc/vabstractapplication.h"
namespace
{
@ -243,6 +244,38 @@ void VGObject::setId(const quint32 &id)
d->_id = id;
}
//---------------------------------------------------------------------------------------------------------------------
void VGObject::SetAlias(const QString &alias)
{
d->m_alias = alias;
}
//---------------------------------------------------------------------------------------------------------------------
QString VGObject::GetAlias() const
{
return d->m_alias;
}
//---------------------------------------------------------------------------------------------------------------------
void VGObject::SetAliasSuffix(const QString &aliasSuffix)
{
d->m_aliasSuffix = aliasSuffix;
}
//---------------------------------------------------------------------------------------------------------------------
QString VGObject::GetAliasSuffix() const
{
return d->m_aliasSuffix;
}
//---------------------------------------------------------------------------------------------------------------------
QString VGObject::ObjectName() const
{
const QString alias = qApp->TrVars()->VarToUser(d->m_alias);
const QString name = qApp->TrVars()->VarToUser(d->_name);
return not d->m_alias.isEmpty() ? QString("%1 (%2)").arg(alias, name) : name;
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VGObject::getIdTool() const
{

View File

@ -78,6 +78,14 @@ public:
quint32 id() const;
virtual void setId(const quint32 &id);
virtual void SetAlias(const QString &alias);
QString GetAlias() const;
virtual void SetAliasSuffix(const QString &aliasSuffix);
QString GetAliasSuffix() const;
QString ObjectName() const;
quint32 getIdTool() const;
virtual QJsonObject ToJson() const;

View File

@ -42,33 +42,44 @@ class VGObjectData : public QSharedData
{
public:
VGObjectData()
:_id(NULL_ID), type(GOType::Unknown), idObject(NULL_ID), _name(QString()), mode(Draw::Calculation)
{}
VGObjectData(const GOType &type, const quint32 &idObject, const Draw &mode)
:_id(NULL_ID), type(type), idObject(idObject), _name(QString()), mode(mode)
:type(type),
idObject(idObject),
mode(mode)
{}
VGObjectData(const VGObjectData &obj)
:QSharedData(obj), _id(obj._id), type(obj.type), idObject(obj.idObject), _name(obj._name), mode(obj.mode)
:QSharedData(obj),
_id(obj._id),
type(obj.type),
idObject(obj.idObject),
_name(obj._name),
mode(obj.mode),
m_alias(obj.m_alias),
m_aliasSuffix(obj.m_aliasSuffix)
{}
virtual ~VGObjectData();
/** @brief _id id in container. Ned for arcs, spline and spline paths. */
quint32 _id;
quint32 _id{NULL_ID};
/** @brief type type of graphical object */
GOType type;
GOType type{GOType::Unknown};
/** @brief idObject id of parent object. */
quint32 idObject;
quint32 idObject{NULL_ID};
/** @brief _name object name */
QString _name;
QString _name{};
/** @brief mode object created in calculation or drawing mode */
Draw mode;
Draw mode{Draw::Calculation};
QString m_alias{};
QString m_aliasSuffix{};
private:
Q_DISABLE_ASSIGN(VGObjectData)

View File

@ -147,6 +147,7 @@ VPointF VPointF::Move(qreal length, qreal angle, const QString &prefix) const
const QPointF p = MovePF(toQPointF(), length, angle);
VPointF moved(p, name() + prefix, mx(), my());
moved.SetShowLabel(IsShowLabel());
return moved;
}
@ -260,6 +261,20 @@ QJsonObject VPointF::ToJson() const
return object;
}
//---------------------------------------------------------------------------------------------------------------------
void VPointF::SetAlias(const QString &alias)
{
Q_UNUSED(alias);
// do nothing
}
//---------------------------------------------------------------------------------------------------------------------
void VPointF::SetAliasSuffix(const QString &aliasSuffix)
{
Q_UNUSED(aliasSuffix);
// do nothing
}
//---------------------------------------------------------------------------------------------------------------------
QPointF VPointF::RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees)
{

View File

@ -85,6 +85,9 @@ public:
virtual QJsonObject ToJson() const override;
virtual void SetAlias(const QString &alias) override;
virtual void SetAliasSuffix(const QString &aliasSuffix) override;
static QPointF RotatePF(const QPointF &originPoint, const QPointF &point, qreal degrees);
static QPointF FlipPF(const QLineF &axis, const QPointF &point);
static QPointF MovePF(const QPointF &originPoint, qreal length, qreal angle);

View File

@ -122,6 +122,12 @@ VSpline VSpline::Rotate(const QPointF &originPoint, qreal degrees, const QString
VSpline spl(p1, p2, p3, p4);
spl.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
spl.SetAliasSuffix(GetAliasSuffix() + prefix);
}
spl.SetColor(GetColor());
spl.SetPenStyle(GetPenStyle());
spl.SetApproximationScale(GetApproximationScale());
@ -139,6 +145,12 @@ VSpline VSpline::Flip(const QLineF &axis, const QString &prefix) const
VSpline spl(p1, p2, p3, p4);
spl.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
spl.SetAliasSuffix(GetAliasSuffix() + prefix);
}
spl.SetColor(GetColor());
spl.SetPenStyle(GetPenStyle());
spl.SetApproximationScale(GetApproximationScale());
@ -156,6 +168,12 @@ VSpline VSpline::Move(qreal length, qreal angle, const QString &prefix) const
VSpline spl(p1, p2, p3, p4);
spl.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
spl.SetAliasSuffix(GetAliasSuffix() + prefix);
}
spl.SetColor(GetColor());
spl.SetPenStyle(GetPenStyle());
spl.SetApproximationScale(GetApproximationScale());

View File

@ -122,6 +122,12 @@ VSplinePath VSplinePath::Rotate(const QPointF &originPoint, qreal degrees, const
VSplinePath splPath(newPoints);
splPath.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
splPath.SetAliasSuffix(GetAliasSuffix() + prefix);
}
splPath.SetColor(GetColor());
splPath.SetPenStyle(GetPenStyle());
splPath.SetApproximationScale(GetApproximationScale());
@ -147,6 +153,12 @@ VSplinePath VSplinePath::Flip(const QLineF &axis, const QString &prefix) const
VSplinePath splPath(newPoints);
splPath.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
splPath.SetAliasSuffix(GetAliasSuffix() + prefix);
}
splPath.SetColor(GetColor());
splPath.SetPenStyle(GetPenStyle());
splPath.SetApproximationScale(GetApproximationScale());
@ -172,6 +184,12 @@ VSplinePath VSplinePath::Move(qreal length, qreal angle, const QString &prefix)
VSplinePath splPath(newPoints);
splPath.setName(name() + prefix);
if (not GetAliasSuffix().isEmpty())
{
splPath.SetAliasSuffix(GetAliasSuffix() + prefix);
}
splPath.SetColor(GetColor());
splPath.SetPenStyle(GetPenStyle());
splPath.SetApproximationScale(GetApproximationScale());

View File

@ -49,7 +49,12 @@ VArcRadius::VArcRadius(const quint32 &id, const quint32 &parentId, const VArc *a
SCASSERT(arc != nullptr)
SetType(VarType::ArcRadius);
SetName(radius_V + QString("%1").arg(arc->name()));
SetName(radius_V + arc->name());
if (not arc->GetAlias().isEmpty())
{
SetAlias(radius_V + arc->GetAlias());
}
SetValue(FromPixel(arc->GetRadius(), patternUnit));
}
@ -62,6 +67,12 @@ VArcRadius::VArcRadius(const quint32 &id, const quint32 &parentId, const VEllipt
SetType(VarType::ArcRadius);
SetName(radius_V + QString("%1%2").arg(numberRadius).arg(elArc->name()));
if (not elArc->GetAlias().isEmpty())
{
SetAlias(radius_V + elArc->GetAlias());
}
if (numberRadius == 1)
{
SetValue(FromPixel(elArc->GetRadius1(), patternUnit));

View File

@ -62,29 +62,51 @@ VCurveAngle::VCurveAngle(const quint32 &id, const quint32 &parentId, const VAbst
{
SetValue(curve->GetStartAngle());
SetName(angle1_V + curve->name());
if (not curve->GetAlias().isEmpty())
{
SetAlias(angle1_V + curve->GetAlias());
}
}
else
{
SetValue(curve->GetEndAngle());
SetName(angle2_V + curve->name());
if (not curve->GetAlias().isEmpty())
{
SetAlias(angle2_V + curve->GetAlias());
}
}
}
//---------------------------------------------------------------------------------------------------------------------
VCurveAngle::VCurveAngle(const quint32 &id, const quint32 &parentId, const QString &baseCurveName, const VSpline &spl,
CurveAngle angle, qint32 segment)
VCurveAngle::VCurveAngle(const quint32 &id, const quint32 &parentId, const VAbstractCurve *baseCurve,
const VSpline &spl, CurveAngle angle, qint32 segment)
:VCurveVariable(id, parentId)
{
SCASSERT(baseCurve != nullptr)
SetType(VarType::CurveAngle);
if (angle == CurveAngle::StartAngle)
{
SetValue(spl.GetStartAngle());
SetName(angle1_V + baseCurveName + QLatin1String("_") + seg_ + QString().setNum(segment));
SetName(angle1_V + baseCurve->name() + QLatin1String("_") + seg_ + QString().setNum(segment));
if (not baseCurve->GetAlias().isEmpty())
{
SetAlias(angle1_V + baseCurve->GetAlias() + QLatin1String("_") + seg_ + QString().setNum(segment));
}
}
else
{
SetValue(spl.GetEndAngle());
SetName(angle2_V + baseCurveName + QLatin1String("_") + seg_ + QString().setNum(segment));
SetName(angle2_V + baseCurve->name() + QLatin1String("_") + seg_ + QString().setNum(segment));
if (not baseCurve->GetAlias().isEmpty())
{
SetAlias(angle2_V + baseCurve->GetAlias() + QLatin1String("_") + seg_ + QString().setNum(segment));
}
}
}
@ -103,4 +125,9 @@ VEllipticalArcRotation::VEllipticalArcRotation(const quint32 &id, const quint32
SCASSERT(elArc != nullptr)
SetValue(elArc->GetRotationAngle());
SetName(rotation_V + elArc->name());
if (not elArc->GetAlias().isEmpty())
{
SetAlias(rotation_V + elArc->GetAlias());
}
}

View File

@ -46,7 +46,7 @@ class VCurveAngle : public VCurveVariable
public:
VCurveAngle();
VCurveAngle(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve, CurveAngle angle);
VCurveAngle(const quint32 &id, const quint32 &parentId, const QString &baseCurveName, const VSpline &spl,
VCurveAngle(const quint32 &id, const quint32 &parentId, const VAbstractCurve *baseCurve, const VSpline &spl,
CurveAngle angle, qint32 segment);
protected:
VCurveAngle(const quint32 &id, const quint32 &parentId);

View File

@ -55,29 +55,51 @@ VCurveCLength::VCurveCLength(const quint32 &id, const quint32 &parentId, const V
{
SetValue(FromPixel(curve->GetC1Length(), patternUnit));
SetName(c1Length_V + curve->name());
if (not curve->GetAlias().isEmpty())
{
SetAlias(c1Length_V + curve->GetAlias());
}
}
else
{
SetValue(FromPixel(curve->GetC2Length(), patternUnit));
SetName(c2Length_V + curve->name());
if (not curve->GetAlias().isEmpty())
{
SetAlias(c2Length_V + curve->GetAlias());
}
}
}
//---------------------------------------------------------------------------------------------------------------------
VCurveCLength::VCurveCLength(const quint32 &id, const quint32 &parentId, const QString &baseCurveName,
VCurveCLength::VCurveCLength(const quint32 &id, const quint32 &parentId, const VAbstractBezier *baseCurve,
const VSpline &spl, CurveCLength cType, Unit patternUnit, qint32 segment)
: VCurveVariable(id, parentId)
{
SCASSERT(baseCurve != nullptr)
SetType(VarType::CurveCLength);
if (cType == CurveCLength::C1)
{
SetValue(FromPixel(spl.GetC1Length(), patternUnit));
SetName(c1Length_V + baseCurveName + QLatin1String("_") + seg_ + QString().setNum(segment));
SetName(c1Length_V + baseCurve->name() + QLatin1String("_") + seg_ + QString().setNum(segment));
if (not baseCurve->GetAlias().isEmpty())
{
SetAlias(c1Length_V + baseCurve->GetAlias() + QLatin1String("_") + seg_ + QString().setNum(segment));
}
}
else
{
SetValue(FromPixel(spl.GetC2Length(), patternUnit));
SetName(c2Length_V + baseCurveName + QLatin1String("_") + seg_ + QString().setNum(segment));
SetName(c2Length_V + baseCurve->name() + QLatin1String("_") + seg_ + QString().setNum(segment));
if (not baseCurve->GetAlias().isEmpty())
{
SetAlias(c2Length_V + baseCurve->GetAlias() + QLatin1String("_") + seg_ + QString().setNum(segment));
}
}
}

View File

@ -46,7 +46,7 @@ public:
VCurveCLength();
VCurveCLength(const quint32 &id, const quint32 &parentId, const VAbstractBezier *curve, CurveCLength cType,
Unit patternUnit);
VCurveCLength(const quint32 &id, const quint32 &parentId, const QString &baseCurveName, const VSpline &spl,
VCurveCLength(const quint32 &id, const quint32 &parentId, const VAbstractBezier *baseCurve, const VSpline &spl,
CurveCLength cType, Unit patternUnit, qint32 segment);
VCurveCLength(const VCurveCLength &var);
VCurveCLength &operator=(const VCurveCLength &var);

View File

@ -50,18 +50,30 @@ VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAb
SetType(VarType::CurveLength);
SCASSERT(curve != nullptr)
SetName(curve->name());
if (not curve->GetAlias().isEmpty())
{
SetAlias(curve->GetAlias());
}
SetValue(FromPixel(curve->GetLength(), patternUnit));
}
//---------------------------------------------------------------------------------------------------------------------
VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const QString &baseCurveName, const VSpline &spl,
Unit patternUnit, qint32 segment)
VCurveLength::VCurveLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *baseCurve,
const VSpline &spl, Unit patternUnit, qint32 segment)
:VCurveVariable(id, parentId)
{
SCASSERT(not baseCurveName.isEmpty())
SCASSERT(baseCurve != nullptr)
SetType(VarType::CurveLength);
SetName(baseCurveName + QLatin1String("_") + seg_ + QString().setNum(segment));
SetName(baseCurve->name() + QLatin1String("_") + seg_ + QString().setNum(segment));
if (not baseCurve->GetAlias().isEmpty())
{
SetAlias(baseCurve->GetAlias() + QLatin1String("_") + seg_ + QString().setNum(segment));
}
SetValue(FromPixel(spl.GetLength(), patternUnit));
}

View File

@ -45,7 +45,7 @@ class VCurveLength : public VCurveVariable
public:
VCurveLength();
VCurveLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *curve, Unit patternUnit);
VCurveLength(const quint32 &id, const quint32 &parentId, const QString &baseCurveName, const VSpline &spl,
VCurveLength(const quint32 &id, const quint32 &parentId, const VAbstractCurve *baseCurve, const VSpline &spl,
Unit patternUnit, qint32 segment);
VCurveLength(const VCurveLength &var);
VCurveLength &operator=(const VCurveLength &var);

View File

@ -45,7 +45,6 @@ class VCurveVariableData : public QSharedData
public:
VCurveVariableData()
:id(NULL_ID), parentId(NULL_ID)
{}
VCurveVariableData(const quint32 &id, const quint32 &parentId)
@ -53,13 +52,15 @@ public:
{}
VCurveVariableData(const VCurveVariableData &var)
:QSharedData(var), id(var.id), parentId(var.parentId)
:QSharedData(var),
id(var.id),
parentId(var.parentId)
{}
virtual ~VCurveVariableData();
quint32 id;
quint32 parentId;
quint32 id{NULL_ID};
quint32 parentId{NULL_ID};
private:
Q_DISABLE_ASSIGN(VCurveVariableData)

View File

@ -123,3 +123,15 @@ void VInternalVariable::SetType(const VarType &type)
{
d->type = type;
}
//---------------------------------------------------------------------------------------------------------------------
void VInternalVariable::SetAlias(const QString &alias)
{
d->alias = alias;
}
//---------------------------------------------------------------------------------------------------------------------
QString VInternalVariable::GetAlias() const
{
return d->alias;
}

View File

@ -61,6 +61,9 @@ public:
VarType GetType() const;
void SetType(const VarType &type);
void SetAlias(const QString &alias);
QString GetAlias() const;
virtual bool Filter(quint32 id);
virtual bool IsNotUsed() const;

View File

@ -42,23 +42,26 @@ QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
class VInternalVariableData : public QSharedData
{
public:
VInternalVariableData()
:type(VarType::Unknown), value(0), name(QString())
{}
VInternalVariableData(const VInternalVariableData &var)
:QSharedData(var), type(var.type), value(var.value), name(var.name)
:QSharedData(var),
type(var.type),
value(var.value),
name(var.name),
alias(var.alias)
{}
virtual ~VInternalVariableData();
VarType type;
VarType type{VarType::Unknown};
/** @brief value variable's value */
qreal value;
qreal value{0};
QString name;
QString name{};
QString alias{};
private:
Q_DISABLE_ASSIGN(VInternalVariableData)

View File

@ -241,6 +241,27 @@ quint32 VContainer::GetPieceForPiecePath(quint32 id) const
return NULL_ID;
}
//---------------------------------------------------------------------------------------------------------------------
void VContainer::RegisterUniqueName(VGObject *obj)
{
SCASSERT(obj != nullptr)
QSharedPointer<VGObject> pointer(obj);
RegisterUniqueName(pointer);
}
//---------------------------------------------------------------------------------------------------------------------
void VContainer::RegisterUniqueName(const QSharedPointer<VGObject> &obj)
{
SCASSERT(not obj.isNull())
uniqueNames[d->nspace].insert(obj->name());
if (not obj->GetAlias().isEmpty())
{
uniqueNames[d->nspace].insert(obj->GetAlias());
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddGObject add new GObject to container
@ -265,7 +286,8 @@ quint32 VContainer::AddGObject(const QSharedPointer<VGObject> &obj)
return NULL_ID;
}
uniqueNames[d->nspace].insert(obj->name());
RegisterUniqueName(obj);
const quint32 id = getNextId();
obj->setId(id);
@ -503,11 +525,11 @@ void VContainer::AddCurveWithSegments(const QSharedPointer<VAbstractCubicBezierP
{
const VSpline spl = curve->GetSpline(i);
AddVariable(new VCurveLength(id, parentId, curve->name(), spl, *GetPatternUnit(), i));
AddVariable(new VCurveAngle(id, parentId, curve->name(), spl, CurveAngle::StartAngle, i));
AddVariable(new VCurveAngle(id, parentId, curve->name(), spl, CurveAngle::EndAngle, i));
AddVariable(new VCurveCLength(id, parentId, curve->name(), spl, CurveCLength::C1, *GetPatternUnit(), i));
AddVariable(new VCurveCLength(id, parentId, curve->name(), spl, CurveCLength::C2, *GetPatternUnit(), i));
AddVariable(new VCurveLength(id, parentId, curve.data(), spl, *GetPatternUnit(), i));
AddVariable(new VCurveAngle(id, parentId, curve.data(), spl, CurveAngle::StartAngle, i));
AddVariable(new VCurveAngle(id, parentId, curve.data(), spl, CurveAngle::EndAngle, i));
AddVariable(new VCurveCLength(id, parentId, curve.data(), spl, CurveCLength::C1, *GetPatternUnit(), i));
AddVariable(new VCurveCLength(id, parentId, curve.data(), spl, CurveCLength::C2, *GetPatternUnit(), i));
}
}

View File

@ -151,6 +151,9 @@ public:
void UpdateId(quint32 newId) const;
static void UpdateId(quint32 newId, const QString &nspace);
void RegisterUniqueName(VGObject *obj);
void RegisterUniqueName(const QSharedPointer<VGObject> &obj);
quint32 AddGObject(VGObject *obj);
quint32 AddGObject(const QSharedPointer<VGObject> &obj);
quint32 AddPiece(const VPiece &detail);
@ -227,6 +230,9 @@ private:
void AddCurve(const QSharedPointer<VAbstractCurve> &curve, const quint32 &id, quint32 parentId = NULL_ID);
template <typename T>
void AddVariable(const QSharedPointer<T> &var, const QString &name);
template <class T>
uint qHash( const QSharedPointer<T> &p );
@ -334,25 +340,42 @@ template <typename T>
void VContainer::AddVariable(const QSharedPointer<T> &var)
{
SCASSERT(not var->GetName().isEmpty())
if (d->variables.contains(var->GetName()))
AddVariable(var, var->GetName());
if (not var->GetAlias().isEmpty())
{
if (d->variables.value(var->GetName())->GetType() == var->GetType())
AddVariable(var, var->GetAlias());
}
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
void VContainer::AddVariable(const QSharedPointer<T> &var, const QString &name)
{
if (name.isEmpty())
{
return;
}
if (d->variables.contains(name))
{
if (d->variables.value(name)->GetType() == var->GetType())
{
QSharedPointer<T> v = qSharedPointerDynamicCast<T>(d->variables.value(var->GetName()));
QSharedPointer<T> v = qSharedPointerDynamicCast<T>(d->variables.value(name));
if (v.isNull())
{
throw VExceptionBadId(tr("Can't cast object."), var->GetName());
throw VExceptionBadId(tr("Can't cast object."), name);
}
*v = *var;
}
else
{
throw VExceptionBadId(tr("Can't find object. Type mismatch."), var->GetName());
throw VExceptionBadId(tr("Can't find object. Type mismatch."), name);
}
}
else
{
d->variables.insert(var->GetName(), var);
d->variables.insert(name, var);
}
}
@ -382,7 +405,7 @@ void VContainer::UpdateGObject(quint32 id, const QSharedPointer<T> &obj)
{
SCASSERT(not obj.isNull())
UpdateObject(id, obj);
uniqueNames[d->nspace].insert(obj->name());
RegisterUniqueName(obj);
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -70,6 +70,17 @@ QWidget *VPE::VLabelProperty::createEditor(QWidget *parent, const QStyleOptionVi
return d_ptr->editor;
}
bool VPE::VLabelProperty::setEditorData(QWidget *editor)
{
if (QLabel* tmpWidget = qobject_cast<QLabel*>(editor))
{
tmpWidget->setText(d_ptr->VariantValue.toString());
return true;
}
return false;
}
QVariant VPE::VLabelProperty::getEditorData(const QWidget *editor) const
{
const QLabel* tmpEditor = qobject_cast<const QLabel*>(editor);

View File

@ -63,6 +63,9 @@ public:
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
const QAbstractItemDelegate* delegate) override;
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
virtual bool setEditorData(QWidget* editor) override;
//! Gets the data from the widget
virtual QVariant getEditorData(const QWidget* editor) const override;

View File

@ -65,6 +65,20 @@ QWidget *VPE::VStringProperty::createEditor(QWidget *parent, const QStyleOptionV
return d_ptr->editor;
}
bool VPE::VStringProperty::setEditorData(QWidget *editor)
{
if (QLineEdit* tmpWidget = qobject_cast<QLineEdit*>(editor))
{
if (not readOnly)
{
tmpWidget->setText(d_ptr->VariantValue.toString());
}
return true;
}
return false;
}
QVariant VPE::VStringProperty::getEditorData(const QWidget *editor) const
{
const QLineEdit* tmpEditor = qobject_cast<const QLineEdit*>(editor);

View File

@ -55,6 +55,9 @@ public:
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
const QAbstractItemDelegate* delegate) override;
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
virtual bool setEditorData(QWidget* editor) override;
//! Gets the data from the widget
virtual QVariant getEditorData(const QWidget* editor) const override;

View File

@ -86,6 +86,17 @@ QWidget *VPE::VTextProperty::createEditor(QWidget *parent, const QStyleOptionVie
return d_ptr->editor;
}
bool VPE::VTextProperty::setEditorData(QWidget *editor)
{
if (QPlainTextEdit* tmpWidget = qobject_cast<QPlainTextEdit*>(editor))
{
tmpWidget->setPlainText(d_ptr->VariantValue.toString());
return true;
}
return false;
}
QVariant VPE::VTextProperty::getEditorData(const QWidget *editor) const
{
const QPlainTextEdit* tmpEditor = qobject_cast<const QPlainTextEdit*>(editor);

View File

@ -52,6 +52,9 @@ public:
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
const QAbstractItemDelegate* delegate) override;
//! Sets the property's data to the editor (returns false, if the standard delegate should do that)
virtual bool setEditorData(QWidget* editor) override;
//! Gets the data from the widget
virtual QVariant getEditorData(const QWidget* editor) const override;

View File

@ -47,6 +47,8 @@
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#include "ui_dialogarc.h"
#include "../vgeometry/varc.h"
#include "../qmuparser/qmudef.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -122,6 +124,8 @@ DialogArc::DialogArc(const VContainer *data, quint32 toolId, QWidget *parent)
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArc::DeployF1TextEdit);
connect(ui->pushButtonGrowLengthF2, &QPushButton::clicked, this, &DialogArc::DeployF2TextEdit);
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogArc::ValidateAlias);
vis = new VisToolArc(data);
ui->tabWidget->setCurrentIndex(0);
@ -237,6 +241,20 @@ QString DialogArc::GetNotes() const
return ui->plainTextEditToolNotes->toPlainText();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArc::SetAliasSuffix(const QString &alias)
{
originAliasSuffix = alias;
ui->lineEditAlias->setText(originAliasSuffix);
ValidateAlias();
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogArc::GetAliasSuffix() const
{
return ui->lineEditAlias->text();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetF1 set formula first angle of arc
@ -337,6 +355,28 @@ void DialogArc::closeEvent(QCloseEvent *event)
DialogTool::closeEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArc::ValidateAlias()
{
QRegularExpression rx(NameRegExp());
VArc arc;
arc.SetAliasSuffix(GetAliasSuffix());
if (not GetAliasSuffix().isEmpty() &&
(not rx.match(arc.GetAlias()).hasMatch() ||
(originAliasSuffix != GetAliasSuffix() && not data->IsUnique(arc.GetAlias()))))
{
flagAlias = false;
ChangeColor(ui->labelAlias, errorColor);
}
else
{
flagAlias = true;
ChangeColor(ui->labelAlias, OkColor(this));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArc::FXRadius()
{

View File

@ -76,6 +76,9 @@ public:
void SetNotes(const QString &notes);
QString GetNotes() const;
void SetAliasSuffix(const QString &alias);
QString GetAliasSuffix() const;
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
/**
@ -97,6 +100,9 @@ protected:
virtual void SaveData() override;
virtual void closeEvent(QCloseEvent *event) override;
virtual bool IsValid() const final;
private slots:
void ValidateAlias();
private:
Q_DISABLE_COPY(DialogArc)
@ -112,6 +118,8 @@ private:
/** @brief flagF2 true if value of second angle is correct */
bool flagF2;
bool flagAlias{true};
/** @brief timerRadius timer of check formula of radius */
QTimer *timerRadius;
@ -138,6 +146,8 @@ private:
qreal angleF1;
qreal angleF2;
QString originAliasSuffix{};
void EvalRadius();
void EvalF();
};
@ -145,7 +155,7 @@ private:
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogArc::IsValid() const
{
return flagRadius && flagF1 && flagF2;
return flagRadius && flagF1 && flagF2 && flagAlias;
}
#endif // DIALOGARC_H

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>407</width>
<height>456</height>
<height>476</height>
</rect>
</property>
<property name="windowTitle">
@ -662,6 +662,20 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelAlias">
<property name="text">
<string>Alias:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditAlias">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -47,6 +47,8 @@
#include "../vmisc/vcommonsettings.h"
#include "../../visualization/visualization.h"
#include "ui_dialogarcwithlength.h"
#include "../vgeometry/varc.h"
#include "../qmuparser/qmudef.h"
//---------------------------------------------------------------------------------------------------------------------
DialogArcWithLength::DialogArcWithLength(const VContainer *data, quint32 toolId, QWidget *parent)
@ -115,6 +117,8 @@ DialogArcWithLength::DialogArcWithLength(const VContainer *data, quint32 toolId,
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArcWithLength::DeployF1TextEdit);
connect(ui->pushButtonGrowLengthArcLength, &QPushButton::clicked, this, &DialogArcWithLength::DeployLengthTextEdit);
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogArcWithLength::ValidateAlias);
vis = new VisToolArcWithLength(data);
ui->tabWidget->setCurrentIndex(0);
@ -263,6 +267,20 @@ QString DialogArcWithLength::GetNotes() const
return ui->plainTextEditToolNotes->toPlainText();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::SetAliasSuffix(const QString &alias)
{
originAliasSuffix = alias;
ui->lineEditAlias->setText(originAliasSuffix);
ValidateAlias();
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogArcWithLength::GetAliasSuffix() const
{
return ui->lineEditAlias->text();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::ChosenObject(quint32 id, const SceneObject &type)
{
@ -374,6 +392,28 @@ void DialogArcWithLength::closeEvent(QCloseEvent *event)
DialogTool::closeEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::ValidateAlias()
{
QRegularExpression rx(NameRegExp());
VArc arc;
arc.SetAliasSuffix(GetAliasSuffix());
if (not GetAliasSuffix().isEmpty() &&
(not rx.match(arc.GetAlias()).hasMatch() ||
(originAliasSuffix != GetAliasSuffix() && not data->IsUnique(arc.GetAlias()))))
{
flagAlias = false;
ChangeColor(ui->labelAlias, errorColor);
}
else
{
flagAlias = true;
ChangeColor(ui->labelAlias, OkColor(this));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogArcWithLength::Radius()
{

View File

@ -74,6 +74,9 @@ public:
void SetNotes(const QString &notes);
QString GetNotes() const;
void SetAliasSuffix(const QString &alias);
QString GetAliasSuffix() const;
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
/**
@ -96,6 +99,9 @@ protected:
virtual void closeEvent(QCloseEvent *event) override;
virtual bool IsValid() const final;
private slots:
void ValidateAlias();
private:
Q_DISABLE_COPY(DialogArcWithLength)
Ui::DialogArcWithLength *ui;
@ -108,6 +114,8 @@ private:
bool flagLength;
bool flagAlias{true};
/** @brief timerRadius timer of check formula of radius */
QTimer *timerRadius;
@ -129,6 +137,8 @@ private:
int formulaBaseHeightF1;
int formulaBaseHeightLength;
QString originAliasSuffix{};
void Radius();
void Length();
void EvalF();
@ -137,7 +147,7 @@ private:
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogArcWithLength::IsValid() const
{
return flagRadius && flagF1 && flagLength;
return flagRadius && flagF1 && flagLength && flagAlias;
}
#endif // DIALOGARCWITHLENGTH_H

View File

@ -651,6 +651,20 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelAlias">
<property name="text">
<string>Alias:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditAlias">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -42,6 +42,7 @@
#include "../vpatterndb/vcontainer.h"
#include "dialogtool.h"
#include "ui_dialogcubicbezier.h"
#include "../qmuparser/qmudef.h"
//---------------------------------------------------------------------------------------------------------------------
DialogCubicBezier::DialogCubicBezier(const VContainer *data, quint32 toolId, QWidget *parent)
@ -72,6 +73,8 @@ DialogCubicBezier::DialogCubicBezier(const VContainer *data, quint32 toolId, QWi
connect(ui->comboBoxP4, &QComboBox::currentTextChanged,
this, &DialogCubicBezier::PointNameChanged);
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogCubicBezier::ValidateAlias);
vis = new VisToolCubicBezier(data);
ui->tabWidget->setCurrentIndex(0);
@ -106,6 +109,10 @@ void DialogCubicBezier::SetSpline(const VCubicBezier &spline)
ui->lineEditSplineName->setText(qApp->TrVars()->VarToUser(spl.name()));
ui->doubleSpinBoxApproximationScale->setValue(spl.GetApproximationScale());
originAliasSuffix = spl.GetAliasSuffix();
ui->lineEditAlias->setText(originAliasSuffix);
ValidateAlias();
auto path = qobject_cast<VisToolCubicBezier *>(vis);
SCASSERT(path != nullptr)
path->setApproximationScale(spl.GetApproximationScale());
@ -241,6 +248,7 @@ void DialogCubicBezier::SaveData()
spl.SetApproximationScale(ui->doubleSpinBoxApproximationScale->value());
spl.SetPenStyle(GetComboBoxCurrentData(ui->comboBoxPenStyle, TypeLineLine));
spl.SetColor(GetComboBoxCurrentData(ui->comboBoxColor, ColorBlack));
spl.SetAliasSuffix(ui->lineEditAlias->text());
const quint32 d = spl.GetDuplicate();//Save previous value
newDuplicate <= -1 ? spl.SetDuplicate(d) : spl.SetDuplicate(static_cast<quint32>(newDuplicate));
@ -256,6 +264,28 @@ void DialogCubicBezier::SaveData()
path->RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCubicBezier::ValidateAlias()
{
QRegularExpression rx(NameRegExp());
VCubicBezier spline = spl;
spline.SetAliasSuffix(ui->lineEditAlias->text());
if (not ui->lineEditAlias->text().isEmpty() &&
(not rx.match(spline.GetAlias()).hasMatch() ||
(originAliasSuffix != ui->lineEditAlias->text() && not data->IsUnique(spline.GetAlias()))))
{
flagAlias = false;
ChangeColor(ui->labelAlias, errorColor);
}
else
{
flagAlias = true;
ChangeColor(ui->labelAlias, OkColor(this));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
const QSharedPointer<VPointF> DialogCubicBezier::GetP1() const
{

View File

@ -68,6 +68,9 @@ protected:
*/
virtual void SaveData() override;
virtual bool IsValid() const final;
private slots:
void ValidateAlias();
private:
Q_DISABLE_COPY(DialogCubicBezier)
Ui::DialogCubicBezier *ui;
@ -78,6 +81,9 @@ private:
qint32 newDuplicate;
bool flagError;
bool flagAlias{true};
QString originAliasSuffix{};
const QSharedPointer<VPointF> GetP1() const;
const QSharedPointer<VPointF> GetP2() const;
@ -88,7 +94,7 @@ private:
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogCubicBezier::IsValid() const
{
return flagError;
return flagError && flagAlias;
}
#endif // DIALOGCUBICBEZIER_H

View File

@ -154,6 +154,20 @@
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="labelAlias">
<property name="text">
<string>Alias:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="lineEditAlias">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">

View File

@ -54,6 +54,7 @@
#include "../vwidgets/vabstractmainwindow.h"
#include "dialogtool.h"
#include "ui_dialogcubicbezierpath.h"
#include "../qmuparser/qmudef.h"
class QWidget;
@ -80,6 +81,8 @@ DialogCubicBezierPath::DialogCubicBezierPath(const VContainer *data, quint32 too
connect(ui->comboBoxPoint, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &DialogCubicBezierPath::currentPointChanged);
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogCubicBezierPath::ValidateAlias);
vis = new VisToolCubicBezierPath(data);
ui->tabWidget->setCurrentIndex(0);
@ -112,6 +115,10 @@ void DialogCubicBezierPath::SetPath(const VCubicBezierPath &value)
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name()));
ui->doubleSpinBoxApproximationScale->setValue(path.GetApproximationScale());
originAliasSuffix = path.GetAliasSuffix();
ui->lineEditAlias->setText(originAliasSuffix);
ValidateAlias();
ChangeCurrentData(ui->comboBoxPenStyle, path.GetPenStyle());
ChangeCurrentData(ui->comboBoxColor, path.GetColor());
@ -200,6 +207,7 @@ void DialogCubicBezierPath::SaveData()
path.SetPenStyle(GetComboBoxCurrentData(ui->comboBoxPenStyle, TypeLineLine));
path.SetColor(GetComboBoxCurrentData(ui->comboBoxColor, ColorBlack));
path.SetApproximationScale(ui->doubleSpinBoxApproximationScale->value());
path.SetAliasSuffix(ui->lineEditAlias->text());
auto visPath = qobject_cast<VisToolCubicBezierPath *>(vis);
SCASSERT(visPath != nullptr)
@ -245,6 +253,28 @@ void DialogCubicBezierPath::currentPointChanged(int index)
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCubicBezierPath::ValidateAlias()
{
QRegularExpression rx(NameRegExp());
VCubicBezierPath tempPath = path;
tempPath.SetAliasSuffix(ui->lineEditAlias->text());
if (not ui->lineEditAlias->text().isEmpty() &&
(not rx.match(tempPath.GetAlias()).hasMatch() ||
(originAliasSuffix != ui->lineEditAlias->text() && not data->IsUnique(tempPath.GetAlias()))))
{
flagAlias = false;
ChangeColor(ui->labelAlias, errorColor);
}
else
{
flagAlias = true;
ChangeColor(ui->labelAlias, OkColor(this));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCubicBezierPath::NewItem(const VPointF &point)
{

View File

@ -69,6 +69,7 @@ protected:
private slots:
void PointChanged(int row);
void currentPointChanged(int index);
void ValidateAlias();
private:
Q_DISABLE_COPY(DialogCubicBezierPath)
@ -80,6 +81,9 @@ private:
qint32 newDuplicate;
bool flagError;
bool flagAlias{true};
QString originAliasSuffix{};
void NewItem(const VPointF &point);
void DataPoint(const VPointF &p);
@ -93,7 +97,7 @@ private:
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogCubicBezierPath::IsValid() const
{
return flagError;
return flagError && flagAlias;
}
#endif // DIALOGCUBICBEZIERPATH_H

View File

@ -138,6 +138,20 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelAlias">
<property name="text">
<string>Alias:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditAlias">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -47,6 +47,7 @@
#include "../vmisc/vcommonsettings.h"
#include "ui_dialogcutarc.h"
#include "../vgeometry/varc.h"
#include "../qmuparser/qmudef.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -93,6 +94,9 @@ DialogCutArc::DialogCutArc(const VContainer *data, quint32 toolId, QWidget *pare
connect(ui->comboBoxArc, &QComboBox::currentTextChanged, this, &DialogCutArc::ArcChanged);
connect(ui->lineEditAlias1, &QLineEdit::textEdited, this, &DialogCutArc::ValidateAlias);
connect(ui->lineEditAlias2, &QLineEdit::textEdited, this, &DialogCutArc::ValidateAlias);
vis = new VisToolCutArc(data);
ui->tabWidget->setCurrentIndex(0);
@ -201,6 +205,48 @@ void DialogCutArc::ArcChanged()
CurrentCurveLength(getArcId(), const_cast<VContainer *> (data));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::ValidateAlias()
{
QRegularExpression rx(NameRegExp());
VArc arc1;
arc1.SetAliasSuffix(GetAliasSuffix1());
VArc arc2;
arc2.SetAliasSuffix(GetAliasSuffix2());
if (not GetAliasSuffix1().isEmpty() &&
(not rx.match(arc1.GetAlias()).hasMatch() ||
(originAliasSuffix2 != GetAliasSuffix1() && not data->IsUnique(arc1.GetAlias())) ||
arc1.GetAlias() == arc2.GetAlias()))
{
flagAlias1 = false;
ChangeColor(ui->labelAlias1, errorColor);
}
else
{
flagAlias1 = true;
ChangeColor(ui->labelAlias1, OkColor(this));
}
if (not GetAliasSuffix2().isEmpty() &&
(not rx.match(arc2.GetAlias()).hasMatch() ||
(originAliasSuffix2 != GetAliasSuffix2() && not data->IsUnique(arc2.GetAlias())) ||
arc1.GetAlias() == arc2.GetAlias()))
{
flagAlias2 = false;
ChangeColor(ui->labelAlias2, errorColor);
}
else
{
flagAlias2 = true;
ChangeColor(ui->labelAlias2, OkColor(this));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief setArcId set id of arc
@ -279,3 +325,31 @@ QString DialogCutArc::GetNotes() const
{
return ui->plainTextEditToolNotes->toPlainText();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::SetAliasSuffix1(const QString &alias)
{
originAliasSuffix1 = alias;
ui->lineEditAlias1->setText(originAliasSuffix1);
ValidateAlias();
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogCutArc::GetAliasSuffix1() const
{
return ui->lineEditAlias1->text();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::SetAliasSuffix2(const QString &alias)
{
originAliasSuffix2 = alias;
ui->lineEditAlias2->setText(originAliasSuffix2);
ValidateAlias();
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogCutArc::GetAliasSuffix2() const
{
return ui->lineEditAlias2->text();
}

View File

@ -54,17 +54,24 @@ public:
DialogCutArc(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
virtual ~DialogCutArc() override;
QString GetPointName() const;
void SetPointName(const QString &value);
QString GetPointName() const;
void SetPointName(const QString &value);
QString GetFormula() const;
void SetFormula(const QString &value);
QString GetFormula() const;
void SetFormula(const QString &value);
quint32 getArcId() const;
void setArcId(quint32 value);
quint32 getArcId() const;
void setArcId(quint32 value);
void SetNotes(const QString &notes);
QString GetNotes() const;
void SetAliasSuffix1(const QString &alias);
QString GetAliasSuffix1() const;
void SetAliasSuffix2(const QString &alias);
QString GetAliasSuffix2() const;
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
/**
@ -84,6 +91,7 @@ protected:
virtual bool IsValid() const final;
private slots:
void ArcChanged();
void ValidateAlias();
private:
Q_DISABLE_COPY(DialogCutArc)
/** @brief ui keeps information about user interface */
@ -94,18 +102,23 @@ private:
QString pointName;
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
int formulaBaseHeight;
QTimer *timerFormula;
bool flagFormula;
bool flagName;
bool flagAlias1{true};
bool flagAlias2{true};
QString originAliasSuffix1{};
QString originAliasSuffix2{};
};
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogCutArc::IsValid() const
{
return flagFormula && flagName;
return flagFormula && flagName && flagAlias1 && flagAlias2;
}
#endif // DIALOGCUTARC_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>334</width>
<height>247</height>
<width>573</width>
<height>295</height>
</rect>
</property>
<property name="windowTitle">
@ -255,6 +255,34 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelAlias1">
<property name="text">
<string>Alias1:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditAlias1">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelAlias2">
<property name="text">
<string>Alias2:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEditAlias2">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -47,6 +47,7 @@
#include "../vmisc/vcommonsettings.h"
#include "ui_dialogcutspline.h"
#include "../vgeometry/vspline.h"
#include "../qmuparser/qmudef.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -92,6 +93,9 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, quint32 toolId, QWidget
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSpline::DeployFormulaTextEdit);
connect(ui->comboBoxSpline, &QComboBox::currentTextChanged, this, &DialogCutSpline::SplineChanged);
connect(ui->lineEditAlias1, &QLineEdit::textEdited, this, &DialogCutSpline::ValidateAlias);
connect(ui->lineEditAlias2, &QLineEdit::textEdited, this, &DialogCutSpline::ValidateAlias);
vis = new VisToolCutSpline(data);
ui->tabWidget->setCurrentIndex(0);
@ -208,6 +212,48 @@ void DialogCutSpline::SplineChanged()
CurrentCurveLength(getSplineId(), const_cast<VContainer *> (data));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSpline::ValidateAlias()
{
QRegularExpression rx(NameRegExp());
VSpline spl1;
spl1.SetAliasSuffix(GetAliasSuffix1());
VSpline spl2;
spl2.SetAliasSuffix(GetAliasSuffix2());
if (not GetAliasSuffix1().isEmpty() &&
(not rx.match(spl1.GetAlias()).hasMatch() ||
(originAliasSuffix2 != GetAliasSuffix1() && not data->IsUnique(spl1.GetAlias())) ||
spl1.GetAlias() == spl2.GetAlias()))
{
flagAlias1 = false;
ChangeColor(ui->labelAlias1, errorColor);
}
else
{
flagAlias1 = true;
ChangeColor(ui->labelAlias1, OkColor(this));
}
if (not GetAliasSuffix2().isEmpty() &&
(not rx.match(spl2.GetAlias()).hasMatch() ||
(originAliasSuffix2 != GetAliasSuffix2() && not data->IsUnique(spl2.GetAlias())) ||
spl1.GetAlias() == spl2.GetAlias()))
{
flagAlias2 = false;
ChangeColor(ui->labelAlias2, errorColor);
}
else
{
flagAlias2 = true;
ChangeColor(ui->labelAlias2, OkColor(this));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSpline::DeployFormulaTextEdit()
{
@ -279,3 +325,31 @@ QString DialogCutSpline::GetNotes() const
{
return ui->plainTextEditToolNotes->toPlainText();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSpline::SetAliasSuffix1(const QString &alias)
{
originAliasSuffix1 = alias;
ui->lineEditAlias1->setText(originAliasSuffix1);
ValidateAlias();
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogCutSpline::GetAliasSuffix1() const
{
return ui->lineEditAlias1->text();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSpline::SetAliasSuffix2(const QString &alias)
{
originAliasSuffix2 = alias;
ui->lineEditAlias2->setText(originAliasSuffix2);
ValidateAlias();
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogCutSpline::GetAliasSuffix2() const
{
return ui->lineEditAlias2->text();
}

View File

@ -64,6 +64,12 @@ public:
void SetNotes(const QString &notes);
QString GetNotes() const;
void SetAliasSuffix1(const QString &alias);
QString GetAliasSuffix1() const;
void SetAliasSuffix2(const QString &alias);
QString GetAliasSuffix2() const;
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
/**
@ -82,6 +88,7 @@ protected:
virtual bool IsValid() const final;
private slots:
void SplineChanged();
void ValidateAlias();
private:
Q_DISABLE_COPY(DialogCutSpline)
@ -100,12 +107,17 @@ private:
bool flagFormula;
bool flagName;
bool flagAlias1{true};
bool flagAlias2{true};
QString originAliasSuffix1{};
QString originAliasSuffix2{};
};
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogCutSpline::IsValid() const
{
return flagFormula && flagName;
return flagFormula && flagName && flagAlias1 && flagAlias2;
}
#endif // DIALOGCUTSPLINE_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>324</width>
<height>240</height>
<width>527</width>
<height>379</height>
</rect>
</property>
<property name="windowTitle">
@ -255,6 +255,26 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelAlias1">
<property name="text">
<string>Alias1:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditAlias1"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelAlias2">
<property name="text">
<string>Alias2:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEditAlias2"/>
</item>
</layout>
</item>
<item>

View File

@ -47,6 +47,7 @@
#include "../vmisc/vcommonsettings.h"
#include "ui_dialogcutsplinepath.h"
#include "../vgeometry/vsplinepath.h"
#include "../qmuparser/qmudef.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -92,6 +93,9 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, quint32 toolId,
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSplinePath::DeployFormulaTextEdit);
connect(ui->comboBoxSplinePath, &QComboBox::currentTextChanged, this, &DialogCutSplinePath::SplinePathChanged);
connect(ui->lineEditAlias1, &QLineEdit::textEdited, this, &DialogCutSplinePath::ValidateAlias);
connect(ui->lineEditAlias2, &QLineEdit::textEdited, this, &DialogCutSplinePath::ValidateAlias);
vis = new VisToolCutSplinePath(data);
ui->tabWidget->setCurrentIndex(0);
@ -208,6 +212,48 @@ void DialogCutSplinePath::SplinePathChanged()
CurrentCurveLength(getSplinePathId(), const_cast<VContainer *> (data));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::ValidateAlias()
{
QRegularExpression rx(NameRegExp());
VSplinePath path1;
path1.SetAliasSuffix(GetAliasSuffix1());
VSplinePath path2;
path2.SetAliasSuffix(GetAliasSuffix2());
if (not GetAliasSuffix1().isEmpty() &&
(not rx.match(path1.GetAlias()).hasMatch() ||
(originAliasSuffix2 != GetAliasSuffix1() && not data->IsUnique(path1.GetAlias())) ||
path1.GetAlias() == path2.GetAlias()))
{
flagAlias1 = false;
ChangeColor(ui->labelAlias1, errorColor);
}
else
{
flagAlias1 = true;
ChangeColor(ui->labelAlias1, OkColor(this));
}
if (not GetAliasSuffix2().isEmpty() &&
(not rx.match(path2.GetAlias()).hasMatch() ||
(originAliasSuffix2 != GetAliasSuffix2() && not data->IsUnique(path2.GetAlias())) ||
path1.GetAlias() == path2.GetAlias()))
{
flagAlias2 = false;
ChangeColor(ui->labelAlias2, errorColor);
}
else
{
flagAlias2 = true;
ChangeColor(ui->labelAlias2, OkColor(this));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::DeployFormulaTextEdit()
{
@ -279,3 +325,31 @@ QString DialogCutSplinePath::GetNotes() const
{
return ui->plainTextEditToolNotes->toPlainText();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::SetAliasSuffix1(const QString &alias)
{
originAliasSuffix1 = alias;
ui->lineEditAlias1->setText(originAliasSuffix1);
ValidateAlias();
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogCutSplinePath::GetAliasSuffix1() const
{
return ui->lineEditAlias1->text();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::SetAliasSuffix2(const QString &alias)
{
originAliasSuffix2 = alias;
ui->lineEditAlias2->setText(originAliasSuffix2);
ValidateAlias();
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogCutSplinePath::GetAliasSuffix2() const
{
return ui->lineEditAlias2->text();
}

View File

@ -64,6 +64,12 @@ public:
void SetNotes(const QString &notes);
QString GetNotes() const;
void SetAliasSuffix1(const QString &alias);
QString GetAliasSuffix1() const;
void SetAliasSuffix2(const QString &alias);
QString GetAliasSuffix2() const;
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
/**
@ -82,6 +88,7 @@ protected:
virtual bool IsValid() const final;
private slots:
void SplinePathChanged();
void ValidateAlias();
private:
Q_DISABLE_COPY(DialogCutSplinePath)
@ -99,12 +106,17 @@ private:
bool flagFormula;
bool flagName;
bool flagAlias1{true};
bool flagAlias2{true};
QString originAliasSuffix1{};
QString originAliasSuffix2{};
};
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogCutSplinePath::IsValid() const
{
return flagFormula;
return flagFormula && flagAlias1 && flagAlias2;
}
#endif // DIALOGCUTSPLINEPATH_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>326</width>
<height>245</height>
<width>483</width>
<height>373</height>
</rect>
</property>
<property name="windowTitle">
@ -255,6 +255,34 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelAlias1">
<property name="text">
<string>Alias1:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelAlias2">
<property name="text">
<string>Alias2:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditAlias1">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEditAlias2">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -47,6 +47,8 @@
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vcommonsettings.h"
#include "ui_dialogellipticalarc.h"
#include "../vgeometry/vellipticalarc.h"
#include "../qmuparser/qmudef.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -154,6 +156,8 @@ DialogEllipticalArc::DialogEllipticalArc(const VContainer *data, quint32 toolId,
connect(ui->pushButtonGrowLengthRotationAngle, &QPushButton::clicked,
this, &DialogEllipticalArc::DeployRotationAngleTextEdit);
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogEllipticalArc::ValidateAlias);
vis = new VisToolEllipticalArc(data);
ui->tabWidget->setCurrentIndex(0);
@ -592,6 +596,28 @@ void DialogEllipticalArc::closeEvent(QCloseEvent *event)
DialogTool::closeEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEllipticalArc::ValidateAlias()
{
QRegularExpression rx(NameRegExp());
VEllipticalArc arc;
arc.SetAliasSuffix(GetAliasSuffix());
if (not GetAliasSuffix().isEmpty() &&
(not rx.match(arc.GetAlias()).hasMatch() ||
(originAliasSuffix != GetAliasSuffix() && not data->IsUnique(arc.GetAlias()))))
{
flagAlias = false;
ChangeColor(ui->labelAlias, errorColor);
}
else
{
flagAlias = true;
ChangeColor(ui->labelAlias, OkColor(this));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEllipticalArc::SetNotes(const QString &notes)
{
@ -603,3 +629,17 @@ QString DialogEllipticalArc::GetNotes() const
{
return ui->plainTextEditToolNotes->toPlainText();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEllipticalArc::SetAliasSuffix(const QString &alias)
{
originAliasSuffix = alias;
ui->lineEditAlias->setText(originAliasSuffix);
ValidateAlias();
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogEllipticalArc::GetAliasSuffix() const
{
return ui->lineEditAlias->text();
}

View File

@ -77,6 +77,9 @@ public:
void SetNotes(const QString &notes);
QString GetNotes() const;
void SetAliasSuffix(const QString &alias);
QString GetAliasSuffix() const;
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
/**
@ -103,6 +106,9 @@ protected:
virtual void closeEvent(QCloseEvent *event) override;
virtual bool IsValid() const final;
private slots:
void ValidateAlias();
private:
Q_DISABLE_COPY(DialogEllipticalArc)
@ -124,6 +130,8 @@ private:
/** @brief flagRotationAngle true if value of rotation angle is correct */
bool flagRotationAngle;
bool flagAlias{true};
/** @brief timerRadius1 timer of check formula of radius1 */
QTimer *timerRadius1;
@ -165,6 +173,8 @@ private:
qreal angleF2;
qreal angleRotation;
QString originAliasSuffix{};
void EvalRadiuses();
void EvalAngles();
};
@ -172,7 +182,7 @@ private:
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogEllipticalArc::IsValid() const
{
return flagRadius1 && flagRadius2 && flagF1 && flagF2 && flagRotationAngle;
return flagRadius1 && flagRadius2 && flagF1 && flagF2 && flagRotationAngle && flagAlias;
}
#endif // DIALOGELLIPTICALARC_H

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>396</width>
<height>575</height>
<height>595</height>
</rect>
</property>
<property name="windowTitle">
@ -1026,6 +1026,16 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelAlias">
<property name="text">
<string>Alias:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEditAlias"/>
</item>
</layout>
</item>
<item>

View File

@ -64,7 +64,6 @@
DialogFlippingByAxis::DialogFlippingByAxis(const VContainer *data, quint32 toolId, QWidget *parent)
: DialogTool(data, toolId, parent),
ui(new Ui::DialogFlippingByAxis),
objects(),
stage1(true),
m_suffix(),
flagName(true),
@ -87,6 +86,9 @@ DialogFlippingByAxis::DialogFlippingByAxis(const VContainer *data, quint32 toolI
connect(ui->comboBoxOriginPoint, &QComboBox::currentTextChanged,
this, &DialogFlippingByAxis::PointChanged);
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogFlippingByAxis::ShowSourceDetails);
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogFlippingByAxis::AliasChanged);
vis = new VisToolFlippingByAxis(data);
ui->tabWidget->setCurrentIndex(0);
@ -147,12 +149,6 @@ void DialogFlippingByAxis::SetSuffix(const QString &value)
ui->lineEditSuffix->setText(value);
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogFlippingByAxis::GetObjects() const
{
return ConvertToVector(objects);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogFlippingByAxis::GetVisibilityGroupName() const
{
@ -201,7 +197,7 @@ void DialogFlippingByAxis::ShowDialog(bool click)
{
if (stage1 && not click)
{
if (objects.isEmpty())
if (sourceObjects.isEmpty())
{
return;
}
@ -214,7 +210,7 @@ void DialogFlippingByAxis::ShowDialog(bool click)
VisToolFlippingByAxis *operation = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(ConvertToVector(objects));
operation->SetObjects(SourceToObjects(sourceObjects));
operation->VisualMode();
scene->ToggleArcSelection(false);
@ -229,6 +225,8 @@ void DialogFlippingByAxis::ShowDialog(bool click)
qApp->getSceneView()->AllowRubberBand(false);
FillSourceList();
emit ToolTip(tr("Select origin point"));
}
else if (not stage1 && prepare && click)
@ -240,6 +238,23 @@ void DialogFlippingByAxis::ShowDialog(bool click)
}
}
//---------------------------------------------------------------------------------------------------------------------
QVector<SourceItem> DialogFlippingByAxis::GetSourceObjects() const
{
return sourceObjects;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::SetSourceObjects(const QVector<SourceItem> &value)
{
sourceObjects = value;
FillSourceList();
VisToolFlippingByAxis *operation = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(SourceToObjects(sourceObjects));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::ChosenObject(quint32 id, const SceneObject &type)
{
@ -247,7 +262,10 @@ void DialogFlippingByAxis::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
if (objects.contains(id))
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id](const SourceItem &sItem) { return sItem.id == id; });
if (obj != sourceObjects.end())
{
emit ToolTip(tr("Select origin point that is not part of the list of objects"));
return;
@ -272,16 +290,23 @@ void DialogFlippingByAxis::SelectedObject(bool selected, quint32 object, quint32
Q_UNUSED(tool)
if (stage1)
{
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[object](const SourceItem &sItem) { return sItem.id == object; });
if (selected)
{
if (not objects.contains(object))
if (obj == sourceObjects.cend())
{
objects.append(object);
SourceItem item;
item.id = object;
sourceObjects.append(item);
}
}
else
{
objects.removeOne(object);
if (obj != sourceObjects.end())
{
sourceObjects.erase(obj);
}
}
}
}
@ -297,6 +322,7 @@ void DialogFlippingByAxis::SuffixChanged()
{
flagName = false;
ChangeColor(ui->labelSuffix, errorColor);
ui->labelStatus->setText(tr("Invalid suffix"));
CheckState();
return;
}
@ -313,6 +339,7 @@ void DialogFlippingByAxis::SuffixChanged()
{
flagName = false;
ChangeColor(ui->labelSuffix, errorColor);
ui->labelStatus->setText(tr("Invalid suffix"));
CheckState();
return;
}
@ -337,6 +364,7 @@ void DialogFlippingByAxis::GroupNameChanged()
{
flagGroupName = false;
ChangeColor(ui->labelGroupName, errorColor);
ui->labelStatus->setText(tr("Invalid group name"));
CheckState();
return;
}
@ -347,6 +375,50 @@ void DialogFlippingByAxis::GroupNameChanged()
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::ShowSourceDetails(int row)
{
ui->lineEditAlias->setDisabled(true);
if (ui->listWidget->count() == 0)
{
return;
}
const auto sourceItem = qvariant_cast<SourceItem>(ui->listWidget->item(row)->data(Qt::UserRole));
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
ui->labelAlias->setText(obj->getType() == GOType::Point ? tr("Label:") : tr("Alias:"));
ui->lineEditAlias->blockSignals(true);
ui->lineEditAlias->setText(sourceItem.alias);
ui->lineEditAlias->setEnabled(true);
ui->lineEditAlias->blockSignals(false);
SetAliasValid(sourceItem.id, SourceAliasValid(sourceItem, obj, data,
OriginAlias(sourceItem.id, sourceObjects, obj)));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::AliasChanged(const QString &text)
{
if (ui->listWidget->count() == 0)
{
return;
}
if (auto *item = ui->listWidget->currentItem())
{
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
sourceItem.alias = text;
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
ValidateSourceAliases();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::ShowVisualization()
{
@ -358,10 +430,22 @@ void DialogFlippingByAxis::SaveData()
{
m_suffix = ui->lineEditSuffix->text();
sourceObjects.clear();
sourceObjects.reserve(ui->listWidget->count());
for (int i=0; i<ui->listWidget->count(); ++i)
{
if (const QListWidgetItem *item = ui->listWidget->item(i))
{
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
sourceObjects.append(sourceItem);
}
}
VisToolFlippingByAxis *operation = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(ConvertToVector(objects));
operation->SetObjects(SourceToObjects(sourceObjects));
operation->SetOriginPointId(GetOriginPointId());
operation->SetAxisType(GetAxisType());
operation->RefreshGeometry();
@ -383,9 +467,13 @@ void DialogFlippingByAxis::SaveData()
void DialogFlippingByAxis::PointChanged()
{
QColor color;
if (objects.contains(getCurrentObjectId(ui->comboBoxOriginPoint)))
quint32 id = getCurrentObjectId(ui->comboBoxOriginPoint);
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id](const SourceItem &sItem) { return sItem.id == id; });
if (obj != sourceObjects.end())
{
flagError = false;
ui->labelStatus->setText(tr("Invalid point"));
color = errorColor;
}
else
@ -406,6 +494,84 @@ void DialogFlippingByAxis::FillComboBoxAxisType(QComboBox *box)
box->addItem(tr("Horizontal axis"), QVariant(static_cast<int>(AxisType::HorizontalAxis)));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::FillSourceList()
{
ui->listWidget->blockSignals(true);
ui->listWidget->clear();
int row = -1;
for (auto &sourceItem : sourceObjects)
{
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
bool valid = SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj));
auto *item = new QListWidgetItem(valid ? obj->ObjectName() : obj->ObjectName() + '*');
item->setToolTip(obj->ObjectName());
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
ui->listWidget->insertItem(++row, item);
}
ui->listWidget->blockSignals(false);
if (ui->listWidget->count() > 0)
{
ui->listWidget->setCurrentRow(0);
}
ValidateSourceAliases();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::ValidateSourceAliases()
{
for (int i=0; i<ui->listWidget->count(); ++i)
{
if (const QListWidgetItem *item = ui->listWidget->item(i))
{
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
if (not SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj)))
{
flagAlias = false;
ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias"));
SetAliasValid(sourceItem.id, false);
CheckState();
return;
}
else
{
SetAliasValid(sourceItem.id, true);
}
}
}
flagAlias = true;
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::SetAliasValid(quint32 id, bool valid)
{
if (ui->listWidget->currentRow() != -1)
{
auto *item = ui->listWidget->item(ui->listWidget->currentRow());
const auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
if (id == sourceItem.id)
{
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
item->setText(valid ? obj->ObjectName() : obj->ObjectName() + '*');
ChangeColor(ui->labelAlias, valid ? OkColor(this) : errorColor);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByAxis::SetNotes(const QString &notes)
{
@ -417,3 +583,16 @@ QString DialogFlippingByAxis::GetNotes() const
{
return ui->plainTextEditToolNotes->toPlainText();
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogFlippingByAxis::IsValid() const
{
bool ready = flagError && flagName && flagGroupName && flagAlias;
if (ready)
{
ui->labelStatus->setText(tr("Ready"));
}
return ready;
}

View File

@ -40,6 +40,7 @@
#include <QtGlobal>
#include "../vmisc/def.h"
#include "../../tools/toolsdef.h"
namespace Ui
{
@ -63,8 +64,6 @@ public:
QString GetSuffix() const;
void SetSuffix(const QString &value);
QVector<quint32> GetObjects() const;
QString GetVisibilityGroupName() const;
void SetVisibilityGroupName(const QString &name);
@ -81,6 +80,9 @@ public:
virtual void ShowDialog(bool click) override;
QVector<SourceItem> GetSourceObjects() const;
void SetSourceObjects(const QVector<SourceItem> &value);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
@ -88,6 +90,8 @@ public slots:
private slots:
void SuffixChanged();
void GroupNameChanged();
void ShowSourceDetails(int row);
void AliasChanged(const QString &text);
protected:
virtual void ShowVisualization() override;
@ -104,7 +108,7 @@ private:
Ui::DialogFlippingByAxis *ui;
QList<quint32> objects;
QVector<SourceItem> sourceObjects{};
bool stage1;
@ -113,16 +117,16 @@ private:
bool flagName;
bool flagGroupName;
bool flagError;
bool flagAlias{true};
QStringList m_groupTags{};
static void FillComboBoxAxisType(QComboBox *box);
void FillSourceList();
void ValidateSourceAliases();
void SetAliasValid(quint32 id, bool valid);
};
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogFlippingByAxis::IsValid() const
{
return flagError && flagName && flagGroupName;
}
#endif // DIALOGFLIPPINGBYAXIS_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>304</width>
<height>296</height>
<width>415</width>
<height>464</height>
</rect>
</property>
<property name="windowTitle">
@ -28,6 +28,35 @@
<string>Tool</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QListWidget" name="listWidget"/>
<widget class="QWidget" name="formLayoutWidget">
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="labelAlias">
<property name="text">
<string>Alias:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditAlias">
<property name="enabled">
<bool>false</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
@ -48,7 +77,11 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditSuffix"/>
<widget class="QLineEdit" name="lineEditSuffix">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelAxisType">
@ -117,6 +150,13 @@
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="labelStatus">
<property name="text">
<string>Ready</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -64,7 +64,6 @@
DialogFlippingByLine::DialogFlippingByLine(const VContainer *data, quint32 toolId, QWidget *parent)
: DialogTool(data, toolId, parent),
ui(new Ui::DialogFlippingByLine),
objects(),
stage1(true),
m_suffix(),
flagName(true),
@ -142,12 +141,6 @@ void DialogFlippingByLine::SetSuffix(const QString &value)
ui->lineEditSuffix->setText(value);
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogFlippingByLine::GetObjects() const
{
return ConvertToVector(objects);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogFlippingByLine::GetVisibilityGroupName() const
{
@ -196,7 +189,7 @@ void DialogFlippingByLine::ShowDialog(bool click)
{
if (stage1 && not click)
{
if (objects.isEmpty())
if (sourceObjects.isEmpty())
{
return;
}
@ -209,7 +202,7 @@ void DialogFlippingByLine::ShowDialog(bool click)
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(ConvertToVector(objects));
operation->SetObjects(SourceToObjects(sourceObjects));
operation->VisualMode();
scene->ToggleArcSelection(false);
@ -224,6 +217,8 @@ void DialogFlippingByLine::ShowDialog(bool click)
qApp->getSceneView()->AllowRubberBand(false);
FillSourceList();
emit ToolTip(tr("Select first line point"));
}
else if (not stage1 && prepare && click)
@ -234,6 +229,23 @@ void DialogFlippingByLine::ShowDialog(bool click)
}
}
//---------------------------------------------------------------------------------------------------------------------
QVector<SourceItem> DialogFlippingByLine::GetSourceObjects() const
{
return sourceObjects;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::SetSourceObjects(const QVector<SourceItem> &value)
{
sourceObjects = value;
FillSourceList();
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(SourceToObjects(sourceObjects));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type)
{
@ -241,10 +253,12 @@ void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id](const SourceItem &sItem) { return sItem.id == id; });
switch (number)
{
case 0:
if (objects.contains(id))
if (obj != sourceObjects.end())
{
emit ToolTip(tr("Select first line point that is not part of the list of objects"));
return;
@ -260,7 +274,7 @@ void DialogFlippingByLine::ChosenObject(quint32 id, const SceneObject &type)
}
break;
case 1:
if (objects.contains(id))
if (obj != sourceObjects.end())
{
emit ToolTip(tr("Select second line point that is not part of the list of objects"));
return;
@ -296,16 +310,23 @@ void DialogFlippingByLine::SelectedObject(bool selected, quint32 object, quint32
Q_UNUSED(tool)
if (stage1)
{
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[object](const SourceItem &sItem) { return sItem.id == object; });
if (selected)
{
if (not objects.contains(object))
if (obj == sourceObjects.cend())
{
objects.append(object);
SourceItem item;
item.id = object;
sourceObjects.append(item);
}
}
else
{
objects.removeOne(object);
if (obj != sourceObjects.end())
{
sourceObjects.erase(obj);
}
}
}
}
@ -321,6 +342,7 @@ void DialogFlippingByLine::SuffixChanged()
{
flagName = false;
ChangeColor(ui->labelSuffix, errorColor);
ui->labelStatus->setText(tr("Invalid suffix"));
CheckState();
return;
}
@ -337,6 +359,7 @@ void DialogFlippingByLine::SuffixChanged()
{
flagName = false;
ChangeColor(ui->labelSuffix, errorColor);
ui->labelStatus->setText(tr("Invalid suffix"));
CheckState();
return;
}
@ -361,6 +384,7 @@ void DialogFlippingByLine::GroupNameChanged()
{
flagGroupName = false;
ChangeColor(ui->labelGroupName, errorColor);
ui->labelStatus->setText(tr("Invalid group name"));
CheckState();
return;
}
@ -371,6 +395,50 @@ void DialogFlippingByLine::GroupNameChanged()
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::ShowSourceDetails(int row)
{
ui->lineEditAlias->setDisabled(true);
if (ui->listWidget->count() == 0)
{
return;
}
const auto sourceItem = qvariant_cast<SourceItem>(ui->listWidget->item(row)->data(Qt::UserRole));
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
ui->labelAlias->setText(obj->getType() == GOType::Point ? tr("Label:") : tr("Alias:"));
ui->lineEditAlias->blockSignals(true);
ui->lineEditAlias->setText(sourceItem.alias);
ui->lineEditAlias->setEnabled(true);
ui->lineEditAlias->blockSignals(false);
SetAliasValid(sourceItem.id, SourceAliasValid(sourceItem, obj, data,
OriginAlias(sourceItem.id, sourceObjects, obj)));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::AliasChanged(const QString &text)
{
if (ui->listWidget->count() == 0)
{
return;
}
if (auto *item = ui->listWidget->currentItem())
{
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
sourceItem.alias = text;
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
ValidateSourceAliases();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::ShowVisualization()
{
@ -382,10 +450,22 @@ void DialogFlippingByLine::SaveData()
{
m_suffix = ui->lineEditSuffix->text();
sourceObjects.clear();
sourceObjects.reserve(ui->listWidget->count());
for (int i=0; i<ui->listWidget->count(); ++i)
{
if (const QListWidgetItem *item = ui->listWidget->item(i))
{
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
sourceObjects.append(sourceItem);
}
}
VisToolFlippingByLine *operation = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(ConvertToVector(objects));
operation->SetObjects(SourceToObjects(sourceObjects));
operation->SetFirstLinePointId(GetFirstLinePointId());
operation->SetSecondLinePointId(GetSecondLinePointId());
operation->RefreshGeometry();
@ -411,29 +491,118 @@ void DialogFlippingByLine::PointChanged()
ChangeColor(ui->labelFirstLinePoint, color);
ChangeColor(ui->labelSecondLinePoint, color);
quint32 id1 = getCurrentObjectId(ui->comboBoxFirstLinePoint);
auto obj1 = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id1](const SourceItem &sItem) { return sItem.id == id1; });
quint32 id2 = getCurrentObjectId(ui->comboBoxSecondLinePoint);
auto obj2 = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id2](const SourceItem &sItem) { return sItem.id == id2; });
if (getCurrentObjectId(ui->comboBoxFirstLinePoint) == getCurrentObjectId(ui->comboBoxSecondLinePoint))
{
flagError = false;
color = errorColor;
ChangeColor(ui->labelFirstLinePoint, color);
ChangeColor(ui->labelSecondLinePoint, color);
ui->labelStatus->setText(tr("Invalid line points"));
}
else if (objects.contains(getCurrentObjectId(ui->comboBoxFirstLinePoint)))
else if (obj1 != sourceObjects.end())
{
flagError = false;
color = errorColor;
ChangeColor(ui->labelFirstLinePoint, color);
ui->labelStatus->setText(tr("Invalid first line point"));
}
else if (objects.contains(getCurrentObjectId(ui->comboBoxSecondLinePoint)))
else if (obj2 != sourceObjects.end())
{
flagError = false;
color = errorColor;
ChangeColor(ui->labelSecondLinePoint, color);
ui->labelStatus->setText(tr("Invalid second line point"));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::FillSourceList()
{
ui->listWidget->blockSignals(true);
ui->listWidget->clear();
int row = -1;
for (auto &sourceItem : sourceObjects)
{
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
bool valid = SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj));
auto *item = new QListWidgetItem(valid ? obj->ObjectName() : obj->ObjectName() + '*');
item->setToolTip(obj->ObjectName());
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
ui->listWidget->insertItem(++row, item);
}
ui->listWidget->blockSignals(false);
if (ui->listWidget->count() > 0)
{
ui->listWidget->setCurrentRow(0);
}
ValidateSourceAliases();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::ValidateSourceAliases()
{
for (int i=0; i<ui->listWidget->count(); ++i)
{
if (const QListWidgetItem *item = ui->listWidget->item(i))
{
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
if (not SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj)))
{
flagAlias = false;
ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias"));
SetAliasValid(sourceItem.id, false);
CheckState();
return;
}
else
{
SetAliasValid(sourceItem.id, true);
}
}
}
flagAlias = true;
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::SetAliasValid(quint32 id, bool valid)
{
if (ui->listWidget->currentRow() != -1)
{
auto *item = ui->listWidget->item(ui->listWidget->currentRow());
const auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
if (id == sourceItem.id)
{
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
item->setText(valid ? obj->ObjectName() : obj->ObjectName() + '*');
ChangeColor(ui->labelAlias, valid ? OkColor(this) : errorColor);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogFlippingByLine::SetNotes(const QString &notes)
{
@ -445,3 +614,16 @@ QString DialogFlippingByLine::GetNotes() const
{
return ui->plainTextEditToolNotes->toPlainText();
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogFlippingByLine::IsValid() const
{
bool ready = flagError && flagName && flagGroupName && flagAlias;
if (ready)
{
ui->labelStatus->setText(tr("Ready"));
}
return ready;
}

View File

@ -40,6 +40,7 @@
#include <QtGlobal>
#include "../vmisc/def.h"
#include "../../tools/toolsdef.h"
namespace Ui
{
@ -63,8 +64,6 @@ public:
QString GetSuffix() const;
void SetSuffix(const QString &value);
QVector<quint32> GetObjects() const;
QString GetVisibilityGroupName() const;
void SetVisibilityGroupName(const QString &name);
@ -81,6 +80,9 @@ public:
virtual void ShowDialog(bool click) override;
QVector<SourceItem> GetSourceObjects() const;
void SetSourceObjects(const QVector<SourceItem> &value);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
@ -88,6 +90,8 @@ public slots:
private slots:
void SuffixChanged();
void GroupNameChanged();
void ShowSourceDetails(int row);
void AliasChanged(const QString &text);
protected:
virtual void ShowVisualization() override;
@ -104,7 +108,7 @@ private:
Ui::DialogFlippingByLine *ui;
QList<quint32> objects;
QVector<SourceItem> sourceObjects{};
bool stage1;
@ -113,14 +117,14 @@ private:
bool flagName;
bool flagGroupName;
bool flagError;
bool flagAlias{true};
QStringList m_groupTags{};
void FillSourceList();
void ValidateSourceAliases();
void SetAliasValid(quint32 id, bool valid);
};
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogFlippingByLine::IsValid() const
{
return flagError && flagName && flagGroupName;
}
#endif // DIALOGFLIPPINGBYLINE_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>319</width>
<height>301</height>
<width>387</width>
<height>440</height>
</rect>
</property>
<property name="windowTitle">
@ -28,6 +28,35 @@
<string>Tool</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QListWidget" name="listWidget"/>
<widget class="QWidget" name="formLayoutWidget">
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="labelAlias">
<property name="text">
<string>Alias:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditAlias">
<property name="enabled">
<bool>false</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
@ -48,7 +77,11 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditSuffix"/>
<widget class="QLineEdit" name="lineEditSuffix">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelSecondLinePoint">
@ -117,6 +150,13 @@
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="labelStatus">
<property name="text">
<string>Ready</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -78,7 +78,6 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
formulaBaseHeightAngle(0),
formulaBaseHeightRotationAngle(0),
formulaBaseHeightLength(0),
objects(),
stage1(true),
stage2(false),
m_suffix(),
@ -143,6 +142,9 @@ DialogMove::DialogMove(const VContainer *data, quint32 toolId, QWidget *parent)
connect(ui->pushButtonGrowRotationAngle, &QPushButton::clicked, this, &DialogMove::DeployRotationAngleTextEdit);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogMove::DeployLengthTextEdit);
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogMove::ShowSourceDetails);
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogMove::AliasChanged);
vis = new VisToolMove(data);
SetRotationOrigPointId(NULL_ID);
@ -257,12 +259,6 @@ void DialogMove::SetRotationOrigPointId(const quint32 &value)
operation->SetRotationOriginPointId(value);
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogMove::GetObjects() const
{
return ConvertToVector(objects);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogMove::GetVisibilityGroupName() const
{
@ -311,7 +307,7 @@ void DialogMove::ShowDialog(bool click)
{
if (stage1 && not click)
{
if (objects.isEmpty())
if (sourceObjects.isEmpty())
{
return;
}
@ -325,7 +321,7 @@ void DialogMove::ShowDialog(bool click)
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(ConvertToVector(objects));
operation->SetObjects(SourceToObjects(sourceObjects));
operation->VisualMode();
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
@ -343,6 +339,8 @@ void DialogMove::ShowDialog(bool click)
scene->ToggleSplinePathHover(false);
qApp->getSceneView()->AllowRubberBand(false);
FillSourceList();
}
else if (not stage2 && not stage1 && prepare && click)
{
@ -416,16 +414,23 @@ void DialogMove::SelectedObject(bool selected, quint32 object, quint32 tool)
Q_UNUSED(tool)
if (stage1)
{
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[object](const SourceItem &sItem) { return sItem.id == object; });
if (selected)
{
if (not objects.contains(object))
if (obj == sourceObjects.cend())
{
objects.append(object);
SourceItem item;
item.id = object;
sourceObjects.append(item);
}
}
else
{
objects.removeOne(object);
if (obj != sourceObjects.end())
{
sourceObjects.erase(obj);
}
}
}
}
@ -501,6 +506,7 @@ void DialogMove::SuffixChanged()
{
flagName = false;
ChangeColor(ui->labelSuffix, errorColor);
ui->labelStatus->setText(tr("Invalid suffix"));
CheckState();
return;
}
@ -517,6 +523,7 @@ void DialogMove::SuffixChanged()
{
flagName = false;
ChangeColor(ui->labelSuffix, errorColor);
ui->labelStatus->setText(tr("Invalid suffix"));
CheckState();
return;
}
@ -541,6 +548,7 @@ void DialogMove::GroupNameChanged()
{
flagGroupName = false;
ChangeColor(ui->labelGroupName, errorColor);
ui->labelStatus->setText(tr("Invalid group name"));
CheckState();
return;
}
@ -551,6 +559,50 @@ void DialogMove::GroupNameChanged()
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::ShowSourceDetails(int row)
{
ui->lineEditAlias->setDisabled(true);
if (ui->listWidget->count() == 0)
{
return;
}
const auto sourceItem = qvariant_cast<SourceItem>(ui->listWidget->item(row)->data(Qt::UserRole));
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
ui->labelAlias->setText(obj->getType() == GOType::Point ? tr("Label:") : tr("Alias:"));
ui->lineEditAlias->blockSignals(true);
ui->lineEditAlias->setText(sourceItem.alias);
ui->lineEditAlias->setEnabled(true);
ui->lineEditAlias->blockSignals(false);
SetAliasValid(sourceItem.id, SourceAliasValid(sourceItem, obj, data,
OriginAlias(sourceItem.id, sourceObjects, obj)));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::AliasChanged(const QString &text)
{
if (ui->listWidget->count() == 0)
{
return;
}
if (auto *item = ui->listWidget->currentItem())
{
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
sourceItem.alias = text;
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
ValidateSourceAliases();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::ShowVisualization()
{
@ -565,10 +617,22 @@ void DialogMove::SaveData()
formulaRotationAngle = ui->plainTextEditRotationAngle->toPlainText();
formulaLength = ui->plainTextEditLength->toPlainText();
sourceObjects.clear();
sourceObjects.reserve(ui->listWidget->count());
for (int i=0; i<ui->listWidget->count(); ++i)
{
if (const QListWidgetItem *item = ui->listWidget->item(i))
{
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
sourceObjects.append(sourceItem);
}
}
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(ConvertToVector(objects));
operation->SetObjects(SourceToObjects(sourceObjects));
operation->SetAngle(formulaAngle);
operation->SetLength(formulaLength);
operation->SetRotationAngle(formulaRotationAngle);
@ -597,6 +661,23 @@ void DialogMove::closeEvent(QCloseEvent *event)
DialogTool::closeEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
QVector<SourceItem> DialogMove::GetSourceObjects() const
{
return sourceObjects;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::SetSourceObjects(const QVector<SourceItem> &value)
{
sourceObjects = value;
FillSourceList();
VisToolMove *operation = qobject_cast<VisToolMove *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(SourceToObjects(sourceObjects));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::EvalAngle()
{
@ -609,6 +690,11 @@ void DialogMove::EvalAngle()
formulaData.checkZero = false;
Eval(formulaData, flagAngle);
if (not flagAngle)
{
ui->labelStatus->setText(tr("Invalid angle formula"));
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -623,6 +709,11 @@ void DialogMove::EvalRotationAngle()
formulaData.checkZero = false;
Eval(formulaData, flagRotationAngle);
if (not flagRotationAngle)
{
ui->labelStatus->setText(tr("Invalid rotation angle formula"));
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -636,6 +727,89 @@ void DialogMove::EvalLength()
formulaData.postfix = UnitsToStr(qApp->patternUnits(), true);
Eval(formulaData, flagLength);
if (not flagLength)
{
ui->labelStatus->setText(tr("Invalid length formula"));
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::FillSourceList()
{
ui->listWidget->blockSignals(true);
ui->listWidget->clear();
int row = -1;
for (auto &sourceItem : sourceObjects)
{
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
bool valid = SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj));
auto *item = new QListWidgetItem(valid ? obj->ObjectName() : obj->ObjectName() + '*');
item->setToolTip(obj->ObjectName());
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
ui->listWidget->insertItem(++row, item);
}
ui->listWidget->blockSignals(false);
if (ui->listWidget->count() > 0)
{
ui->listWidget->setCurrentRow(0);
}
ValidateSourceAliases();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::ValidateSourceAliases()
{
for (int i=0; i<ui->listWidget->count(); ++i)
{
if (const QListWidgetItem *item = ui->listWidget->item(i))
{
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
if (not SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj)))
{
flagAlias = false;
ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias"));
SetAliasValid(sourceItem.id, false);
CheckState();
return;
}
else
{
SetAliasValid(sourceItem.id, true);
}
}
}
flagAlias = true;
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogMove::SetAliasValid(quint32 id, bool valid)
{
if (ui->listWidget->currentRow() != -1)
{
auto *item = ui->listWidget->item(ui->listWidget->currentRow());
const auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
if (id == sourceItem.id)
{
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
item->setText(valid ? obj->ObjectName() : obj->ObjectName() + '*');
ChangeColor(ui->labelAlias, valid ? OkColor(this) : errorColor);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -649,3 +823,16 @@ QString DialogMove::GetNotes() const
{
return ui->plainTextEditToolNotes->toPlainText();
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogMove::IsValid() const
{
bool ready = flagAngle && flagRotationAngle && flagLength && flagName && flagGroupName && flagAlias;
if (ready)
{
ui->labelStatus->setText(tr("Ready"));
}
return ready;
}

View File

@ -39,6 +39,7 @@
#include "../vmisc/def.h"
#include "dialogtool.h"
#include "../../tools/toolsdef.h"
namespace Ui
{
@ -68,8 +69,6 @@ public:
quint32 GetRotationOrigPointId() const;
void SetRotationOrigPointId(const quint32 &value);
QVector<quint32> GetObjects() const;
QString GetVisibilityGroupName() const;
void SetVisibilityGroupName(const QString &name);
@ -86,6 +85,9 @@ public:
virtual void ShowDialog(bool click) override;
QVector<SourceItem> GetSourceObjects() const;
void SetSourceObjects(const QVector<SourceItem> &value);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
@ -103,6 +105,9 @@ private slots:
void SuffixChanged();
void GroupNameChanged();
void ShowSourceDetails(int row);
void AliasChanged(const QString &text);
protected:
virtual void ShowVisualization() override;
@ -130,7 +135,7 @@ private:
int formulaBaseHeightRotationAngle;
int formulaBaseHeightLength;
QList<quint32> objects;
QVector<SourceItem> sourceObjects{};
bool stage1;
bool stage2;
@ -145,18 +150,18 @@ private:
bool flagLength;
bool flagName;
bool flagGroupName;
bool flagAlias{true};
QStringList m_groupTags{};
void EvalAngle();
void EvalRotationAngle();
void EvalLength();
void FillSourceList();
void ValidateSourceAliases();
void SetAliasValid(quint32 id, bool valid);
};
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogMove::IsValid() const
{
return flagAngle && flagRotationAngle && flagLength && flagName && flagGroupName;
}
#endif // DIALOGMOVING_H

View File

@ -2,12 +2,15 @@
<ui version="4.0">
<class>DialogMove</class>
<widget class="QDialog" name="DialogMove">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>411</width>
<height>498</height>
<width>536</width>
<height>669</height>
</rect>
</property>
<property name="windowTitle">
@ -28,6 +31,39 @@
<string>Tool</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QListWidget" name="listWidget">
<property name="editTriggers">
<set>QAbstractItemView::CurrentChanged</set>
</property>
</widget>
<widget class="QWidget" name="formLayoutWidget">
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="labelAlias">
<property name="text">
<string>Alias:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditAlias">
<property name="enabled">
<bool>false</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item alignment="Qt::AlignLeft">
@ -656,6 +692,13 @@
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="labelStatus">
<property name="text">
<string>Ready</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -72,7 +72,6 @@ DialogRotation::DialogRotation(const VContainer *data, quint32 toolId, QWidget *
timerAngle(new QTimer(this)),
formulaAngle(),
formulaBaseHeightAngle(0),
objects(),
stage1(true),
m_suffix(),
m_firstRelease(false),
@ -170,12 +169,6 @@ void DialogRotation::SetSuffix(const QString &value)
ui->lineEditSuffix->setText(value);
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> DialogRotation::GetObjects() const
{
return ConvertToVector(objects);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogRotation::GetVisibilityGroupName() const
{
@ -224,7 +217,7 @@ void DialogRotation::ShowDialog(bool click)
{
if (stage1 && not click)
{
if (objects.isEmpty())
if (sourceObjects.isEmpty())
{
return;
}
@ -237,7 +230,7 @@ void DialogRotation::ShowDialog(bool click)
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(ConvertToVector(objects));
operation->SetObjects(SourceToObjects(sourceObjects));
operation->VisualMode();
scene->ToggleArcSelection(false);
@ -252,6 +245,8 @@ void DialogRotation::ShowDialog(bool click)
qApp->getSceneView()->AllowRubberBand(false);
FillSourceList();
emit ToolTip(tr("Select origin point"));
}
else if (not stage1 && prepare && click)
@ -294,6 +289,23 @@ void DialogRotation::ShowDialog(bool click)
}
}
//---------------------------------------------------------------------------------------------------------------------
QVector<SourceItem> DialogRotation::GetSourceObjects() const
{
return sourceObjects;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::SetSourceObjects(const QVector<SourceItem> &value)
{
sourceObjects = value;
FillSourceList();
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(SourceToObjects(sourceObjects));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::ChosenObject(quint32 id, const SceneObject &type)
{
@ -304,14 +316,17 @@ void DialogRotation::ChosenObject(quint32 id, const SceneObject &type)
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr)
if (objects.contains(id))
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id](const SourceItem &sItem) { return sItem.id == id; });
if (obj != sourceObjects.end())
{
if (objects.size() > 1)
if (sourceObjects.size() > 1)
{
// It's not really logical for a user that a center of rotation no need to select.
// To fix this issue we just silently remove it from the list.
objects.removeOne(id);
operation->SetObjects(ConvertToVector(objects));
sourceObjects.erase(obj);
operation->SetObjects(SourceToObjects(sourceObjects));
}
else
{
@ -341,16 +356,23 @@ void DialogRotation::SelectedObject(bool selected, quint32 object, quint32 tool)
Q_UNUSED(tool)
if (stage1)
{
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[object](const SourceItem &sItem) { return sItem.id == object; });
if (selected)
{
if (not objects.contains(object))
if (obj == sourceObjects.cend())
{
objects.append(object);
SourceItem item;
item.id = object;
sourceObjects.append(item);
}
}
else
{
objects.removeOne(object);
if (obj != sourceObjects.end())
{
sourceObjects.erase(obj);
}
}
}
}
@ -386,6 +408,7 @@ void DialogRotation::SuffixChanged()
{
flagName = false;
ChangeColor(ui->labelSuffix, errorColor);
ui->labelStatus->setText(tr("Invalid suffix"));
CheckState();
return;
}
@ -402,6 +425,7 @@ void DialogRotation::SuffixChanged()
{
flagName = false;
ChangeColor(ui->labelSuffix, errorColor);
ui->labelStatus->setText(tr("Invalid suffix"));
CheckState();
return;
}
@ -426,6 +450,7 @@ void DialogRotation::GroupNameChanged()
{
flagGroupName = false;
ChangeColor(ui->labelGroupName, errorColor);
ui->labelStatus->setText(tr("Invalid group name"));
CheckState();
return;
}
@ -448,10 +473,22 @@ void DialogRotation::SaveData()
m_suffix = ui->lineEditSuffix->text();
formulaAngle = ui->plainTextEditFormula->toPlainText();
sourceObjects.clear();
sourceObjects.reserve(ui->listWidget->count());
for (int i=0; i<ui->listWidget->count(); ++i)
{
if (const QListWidgetItem *item = ui->listWidget->item(i))
{
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
sourceObjects.append(sourceItem);
}
}
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr)
operation->SetObjects(ConvertToVector(objects));
operation->SetObjects(SourceToObjects(sourceObjects));
operation->SetOriginPointId(GetOrigPointId());
operation->SetAngle(formulaAngle);
operation->RefreshGeometry();
@ -479,11 +516,17 @@ void DialogRotation::closeEvent(QCloseEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::PointChanged()
{
quint32 id = getCurrentObjectId(ui->comboBoxOriginPoint);
auto obj = std::find_if(sourceObjects.begin(), sourceObjects.end(),
[id](const SourceItem &sItem) { return sItem.id == id; });
QColor color;
if (objects.contains(getCurrentObjectId(ui->comboBoxOriginPoint)))
if (obj != sourceObjects.end())
{
flagError = false;
color = errorColor;
ui->labelStatus->setText(tr("Invalid rotation point"));
}
else
{
@ -494,6 +537,84 @@ void DialogRotation::PointChanged()
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::FillSourceList()
{
ui->listWidget->blockSignals(true);
ui->listWidget->clear();
int row = -1;
for (auto &sourceItem : sourceObjects)
{
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
bool valid = SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj));
auto *item = new QListWidgetItem(valid ? obj->ObjectName() : obj->ObjectName() + '*');
item->setToolTip(obj->ObjectName());
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
ui->listWidget->insertItem(++row, item);
}
ui->listWidget->blockSignals(false);
if (ui->listWidget->count() > 0)
{
ui->listWidget->setCurrentRow(0);
}
ValidateSourceAliases();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::ValidateSourceAliases()
{
for (int i=0; i<ui->listWidget->count(); ++i)
{
if (const QListWidgetItem *item = ui->listWidget->item(i))
{
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
if (not SourceAliasValid(sourceItem, obj, data, OriginAlias(sourceItem.id, sourceObjects, obj)))
{
flagAlias = false;
ui->labelStatus->setText(obj->getType() == GOType::Point ? tr("Invalid label") : tr("Invalid alias"));
SetAliasValid(sourceItem.id, false);
CheckState();
return;
}
else
{
SetAliasValid(sourceItem.id, true);
}
}
}
flagAlias = true;
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::SetAliasValid(quint32 id, bool valid)
{
if (ui->listWidget->currentRow() != -1)
{
auto *item = ui->listWidget->item(ui->listWidget->currentRow());
const auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
if (id == sourceItem.id)
{
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
item->setText(valid ? obj->ObjectName() : obj->ObjectName() + '*');
ChangeColor(ui->labelAlias, valid ? OkColor(this) : errorColor);
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::EvalAngle()
{
@ -506,6 +627,55 @@ void DialogRotation::EvalAngle()
formulaData.checkZero = false;
Eval(formulaData, flagAngle);
if (not flagAngle)
{
ui->labelStatus->setText(tr("Invalid angle formula"));
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::ShowSourceDetails(int row)
{
ui->lineEditAlias->setDisabled(true);
if (ui->listWidget->count() == 0)
{
return;
}
const auto sourceItem = qvariant_cast<SourceItem>(ui->listWidget->item(row)->data(Qt::UserRole));
const QSharedPointer<VGObject> obj = data->GetGObject(sourceItem.id);
ui->labelAlias->setText(obj->getType() == GOType::Point ? tr("Label:") : tr("Alias:"));
ui->lineEditAlias->blockSignals(true);
ui->lineEditAlias->setText(sourceItem.alias);
ui->lineEditAlias->setEnabled(true);
ui->lineEditAlias->blockSignals(false);
SetAliasValid(sourceItem.id, SourceAliasValid(sourceItem, obj, data,
OriginAlias(sourceItem.id, sourceObjects, obj)));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogRotation::AliasChanged(const QString &text)
{
if (ui->listWidget->count() == 0)
{
return;
}
if (auto *item = ui->listWidget->currentItem())
{
auto sourceItem = qvariant_cast<SourceItem>(item->data(Qt::UserRole));
sourceItem.alias = text;
item->setData(Qt::UserRole, QVariant::fromValue(sourceItem));
ValidateSourceAliases();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -519,3 +689,16 @@ QString DialogRotation::GetNotes() const
{
return ui->plainTextEditToolNotes->toPlainText();
}
//---------------------------------------------------------------------------------------------------------------------
bool DialogRotation::IsValid() const
{
bool ready = flagAngle && flagName && flagError && flagGroupName && flagAlias;
if (ready)
{
ui->labelStatus->setText(tr("Ready"));
}
return ready;
}

View File

@ -39,6 +39,7 @@
#include "../vmisc/def.h"
#include "dialogtool.h"
#include "../../tools/toolsdef.h"
namespace Ui
{
@ -61,8 +62,6 @@ public:
QString GetSuffix() const;
void SetSuffix(const QString &value);
QVector<quint32> GetObjects() const;
QString GetVisibilityGroupName() const;
void SetVisibilityGroupName(const QString &name);
@ -79,6 +78,9 @@ public:
virtual void ShowDialog(bool click) override;
QVector<SourceItem> GetSourceObjects() const;
void SetSourceObjects(const QVector<SourceItem> &value);
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
@ -90,6 +92,8 @@ private slots:
void SuffixChanged();
void GroupNameChanged();
void EvalAngle();
void ShowSourceDetails(int row);
void AliasChanged(const QString &text);
protected:
virtual void ShowVisualization() override;
@ -115,7 +119,7 @@ private:
/** @brief formulaBaseHeightAngle base height defined by dialogui */
int formulaBaseHeightAngle;
QList<quint32> objects;
QVector<SourceItem> sourceObjects{};
bool stage1;
@ -128,14 +132,14 @@ private:
bool flagName;
bool flagGroupName;
bool flagError;
bool flagAlias{true};
QStringList m_groupTags{};
void FillSourceList();
void ValidateSourceAliases();
void SetAliasValid(quint32 id, bool valid);
};
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogRotation::IsValid() const
{
return flagAngle && flagName && flagError && flagGroupName;
}
#endif // DIALOGROTATION_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>304</width>
<height>338</height>
<width>410</width>
<height>485</height>
</rect>
</property>
<property name="windowTitle">
@ -28,6 +28,35 @@
<string>Tool</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QListWidget" name="listWidget"/>
<widget class="QWidget" name="formLayoutWidget">
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="labelAlias">
<property name="text">
<string>Alias</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditAlias">
<property name="enabled">
<bool>false</bool>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item alignment="Qt::AlignLeft">
@ -287,6 +316,13 @@
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="labelStatus">
<property name="text">
<string>Ready</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -56,6 +56,7 @@
#include "../vwidgets/vmaingraphicsscene.h"
#include "ui_dialogspline.h"
#include "vtranslatevars.h"
#include "../qmuparser/qmudef.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -148,6 +149,8 @@ DialogSpline::DialogSpline(const VContainer *data, quint32 toolId, QWidget *pare
connect(ui->pushButtonGrowLength1, &QPushButton::clicked, this, &DialogSpline::DeployLength1TextEdit);
connect(ui->pushButtonGrowLength2, &QPushButton::clicked, this, &DialogSpline::DeployLength2TextEdit);
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogSpline::ValidateAlias);
vis = new VisToolSpline(data);
auto path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr)
@ -432,6 +435,30 @@ void DialogSpline::EvalLength2()
Eval(formulaData, flagLength2);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSpline::ValidateAlias()
{
QRegularExpression rx(NameRegExp());
VSpline spline = spl;
spline.SetAliasSuffix(ui->lineEditAlias->text());
if (not ui->lineEditAlias->text().isEmpty() &&
(not rx.match(spline.GetAlias()).hasMatch() ||
(originAliasSuffix != ui->lineEditAlias->text() && not data->IsUnique(spline.GetAlias()))))
{
flagAlias = false;
ChangeColor(ui->labelAlias, errorColor);
}
else
{
flagAlias = true;
ChangeColor(ui->labelAlias, OkColor(this));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
VSpline DialogSpline::CurrentSpline() const
{
@ -458,6 +485,7 @@ VSpline DialogSpline::CurrentSpline() const
spline.SetApproximationScale(ui->doubleSpinBoxApproximationScale->value());
spline.SetPenStyle(GetComboBoxCurrentData(ui->comboBoxPenStyle, TypeLineLine));
spline.SetColor(GetComboBoxCurrentData(ui->comboBoxColor, ColorBlack));
spline.SetAliasSuffix(ui->lineEditAlias->text());
return spline;
}
@ -588,6 +616,10 @@ void DialogSpline::SetSpline(const VSpline &spline)
ui->plainTextEditLength2F->setPlainText(length2F);
ui->lineEditSplineName->setText(qApp->TrVars()->VarToUser(spl.name()));
originAliasSuffix = spl.GetAliasSuffix();
ui->lineEditAlias->setText(originAliasSuffix);
ValidateAlias();
auto path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr)

View File

@ -88,6 +88,8 @@ private slots:
void EvalAngle2();
void EvalLength1();
void EvalLength2();
void ValidateAlias();
private:
Q_DISABLE_COPY(DialogSpline)
@ -117,6 +119,9 @@ private:
bool flagLength1;
bool flagLength2;
bool flagError;
bool flagAlias{true};
QString originAliasSuffix{};
const QSharedPointer<VPointF> GetP1() const;
const QSharedPointer<VPointF> GetP4() const;
@ -127,7 +132,7 @@ private:
//---------------------------------------------------------------------------------------------------------------------
inline bool DialogSpline::IsValid() const
{
return flagAngle1 && flagAngle2 && flagLength1 && flagLength2 && flagError;
return flagAngle1 && flagAngle2 && flagLength1 && flagLength2 && flagError && flagAlias;
}
#endif // DIALOGSPLINE_H

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>532</width>
<height>452</height>
<height>482</height>
</rect>
</property>
<property name="windowTitle">
@ -925,6 +925,20 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelAlias">
<property name="text">
<string>Alias:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditAlias">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -63,6 +63,7 @@
#include "../vwidgets/vmaingraphicsscene.h"
#include "ui_dialogsplinepath.h"
#include "vtranslatevars.h"
#include "../qmuparser/qmudef.h"
//---------------------------------------------------------------------------------------------------------------------
/**
@ -125,6 +126,8 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, quint32 toolId, QWidg
connect(ui->pushButtonGrowLength1, &QPushButton::clicked, this, &DialogSplinePath::DeployLength1TextEdit);
connect(ui->pushButtonGrowLength2, &QPushButton::clicked, this, &DialogSplinePath::DeployLength2TextEdit);
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogSplinePath::ValidateAlias);
vis = new VisToolSplinePath(data);
auto path = qobject_cast<VisToolSplinePath *>(vis);
SCASSERT(path != nullptr)
@ -167,6 +170,10 @@ void DialogSplinePath::SetPath(const VSplinePath &value)
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name()));
ui->doubleSpinBoxApproximationScale->setValue(path.GetApproximationScale());
originAliasSuffix = path.GetAliasSuffix();
ui->lineEditAlias->setText(originAliasSuffix);
ValidateAlias();
ChangeCurrentData(ui->comboBoxPenStyle, path.GetPenStyle());
ChangeCurrentData(ui->comboBoxColor, path.GetColor());
@ -490,6 +497,30 @@ void DialogSplinePath::FXLength2()
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSplinePath::ValidateAlias()
{
QRegularExpression rx(NameRegExp());
VSplinePath tempPath = path;
tempPath.SetAliasSuffix(ui->lineEditAlias->text());
if (not ui->lineEditAlias->text().isEmpty() &&
(not rx.match(tempPath.GetAlias()).hasMatch() ||
(originAliasSuffix != ui->lineEditAlias->text() && not data->IsUnique(tempPath.GetAlias()))))
{
flagAlias = false;
ChangeColor(ui->labelAlias, errorColor);
}
else
{
flagAlias = true;
ChangeColor(ui->labelAlias, OkColor(this));
}
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSplinePath::EvalAngle1()
{
@ -874,6 +905,7 @@ void DialogSplinePath::SavePath()
path.SetApproximationScale(ui->doubleSpinBoxApproximationScale->value());
path.SetPenStyle(GetComboBoxCurrentData(ui->comboBoxPenStyle, TypeLineLine));
path.SetColor(GetComboBoxCurrentData(ui->comboBoxColor, ColorBlack));
path.SetAliasSuffix(ui->lineEditAlias->text());
}
//---------------------------------------------------------------------------------------------------------------------
@ -945,7 +977,7 @@ bool DialogSplinePath::IsValid() const
fLength2 = fLength2 && flagLength2.at(i);
}
return fAngle1 && fAngle2 && fLength1 && fLength2 && flagError;
return fAngle1 && fAngle2 && fLength1 && fLength2 && flagError && flagAlias;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -88,6 +88,8 @@ private slots:
void FXAngle2();
void FXLength1();
void FXLength2();
void ValidateAlias();
private:
Q_DISABLE_COPY(DialogSplinePath)
@ -111,6 +113,9 @@ private:
QVector<bool> flagLength1;
QVector<bool> flagLength2;
bool flagError;
bool flagAlias{true};
QString originAliasSuffix{};
void EvalAngle1();
void EvalAngle2();

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>460</width>
<height>647</height>
<height>677</height>
</rect>
</property>
<property name="windowTitle">
@ -887,6 +887,16 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="labelAlias">
<property name="text">
<string>Alias:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="lineEditAlias"/>
</item>
</layout>
</item>
<item>

View File

@ -397,13 +397,10 @@ quint32 DialogTool::DNumber(const QString &baseName) const
QString DialogTool::GetNodeName(const VPieceNode &node, bool showPassmarkDetails) const
{
const QSharedPointer<VGObject> obj = data->GetGObject(node.GetId());
QString name = obj->name();
QString name = obj->ObjectName();
if (node.GetTypeTool() != Tool::NodePoint)
{
int bias = 0;
qApp->TrVars()->VariablesToUser(name, 0, obj->name(), bias);
if (node.GetReverse())
{
name = QStringLiteral("- ") + name;
@ -706,17 +703,7 @@ void DialogTool::PrepareList(QMap<QString, quint32> &list, quint32 id) const
{
const auto obj = data->GeometricObject<T>(id);
SCASSERT(obj != nullptr)
QString newName = obj->name();
int bias = 0;
if (qApp->TrVars()->VariablesToUser(newName, 0, obj->name(), bias))
{
list[newName] = id;
}
else
{
list[obj->name()] = id;
}
list[obj->ObjectName()] = id;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -109,7 +109,7 @@ void DialogInsertNode::SetNode(const VPieceNode &node)
QString name = tr("Uknown");
try
{
name = qApp->TrVars()->InternalVarToUser(data->GetGObject(m_node.GetId())->name());
name = data->GetGObject(m_node.GetId())->ObjectName();
}
catch (const VExceptionBadId &)
{

View File

@ -38,12 +38,9 @@
#include "../vgeometry/vsplinepath.h"
//---------------------------------------------------------------------------------------------------------------------
VAbstractFlipping::VAbstractFlipping(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
const QString &notes, QGraphicsItem *parent)
: VAbstractOperation(doc, data, id, suffix, source, destination, notes, parent)
{
}
VAbstractFlipping::VAbstractFlipping(const VAbstractOperationInitData &initData, QGraphicsItem *parent)
: VAbstractOperation(initData, parent)
{}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractFlipping::CreateDestination(VAbstractOperationInitData &initData, const QPointF &fPoint,
@ -55,9 +52,9 @@ void VAbstractFlipping::CreateDestination(VAbstractOperationInitData &initData,
initData.id = initData.data->getNextId();//Just reserve id for tool
for (auto idObject : qAsConst(initData.source))
for (auto object : qAsConst(initData.source))
{
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
const QSharedPointer<VGObject> obj = initData.data->GetGObject(object.id);
// This check helps to find missed objects in the switch
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
@ -67,32 +64,32 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
switch(static_cast<GOType>(obj->getType()))
{
case GOType::Point:
initData.destination.append(CreatePoint(initData.id, idObject, fPoint, sPoint, initData.suffix,
initData.destination.append(CreatePoint(initData.id, object, fPoint, sPoint, initData.suffix,
initData.data));
break;
case GOType::Arc:
initData.destination.append(CreateArc<VArc>(initData.id, idObject, fPoint, sPoint, initData.suffix,
initData.destination.append(CreateArc<VArc>(initData.id, object, fPoint, sPoint, initData.suffix,
initData.data));
break;
case GOType::EllipticalArc:
initData.destination.append(CreateArc<VEllipticalArc>(initData.id, idObject, fPoint, sPoint,
initData.destination.append(CreateArc<VEllipticalArc>(initData.id, object, fPoint, sPoint,
initData.suffix, initData.data));
break;
case GOType::Spline:
initData.destination.append(CreateCurve<VSpline>(initData.id, idObject, fPoint, sPoint,
initData.destination.append(CreateCurve<VSpline>(initData.id, object, fPoint, sPoint,
initData.suffix, initData.data));
break;
case GOType::SplinePath:
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, idObject, fPoint,
initData.destination.append(CreateCurveWithSegments<VSplinePath>(initData.id, object, fPoint,
sPoint, initData.suffix,
initData.data));
break;
case GOType::CubicBezier:
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, idObject, fPoint, sPoint,
initData.destination.append(CreateCurve<VCubicBezier>(initData.id, object, fPoint, sPoint,
initData.suffix, initData.data));
break;
case GOType::CubicBezierPath:
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, fPoint,
initData.destination.append(CreateCurveWithSegments<VCubicBezierPath>(initData.id, object, fPoint,
sPoint, initData.suffix,
initData.data));
break;
@ -108,8 +105,8 @@ QT_WARNING_POP
{
for (int i = 0; i < initData.source.size(); ++i)
{
const quint32 idObject = initData.source.at(i);
const QSharedPointer<VGObject> obj = initData.data->GetGObject(idObject);
const SourceItem object = initData.source.at(i);
const QSharedPointer<VGObject> obj = initData.data->GetGObject(object.id);
// This check helps to find missed objects in the switch
Q_STATIC_ASSERT_X(static_cast<int>(GOType::Unknown) == 8, "Not all objects were handled.");
@ -121,31 +118,31 @@ QT_WARNING_DISABLE_GCC("-Wswitch-default")
case GOType::Point:
{
const DestinationItem &item = initData.destination.at(i);
UpdatePoint(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data, item);
UpdatePoint(initData.id, object, fPoint, sPoint, initData.suffix, initData.data, item);
break;
}
case GOType::Arc:
UpdateArc<VArc>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
UpdateArc<VArc>(initData.id, object, fPoint, sPoint, initData.suffix, initData.data,
initData.destination.at(i).id);
break;
case GOType::EllipticalArc:
UpdateArc<VEllipticalArc>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
UpdateArc<VEllipticalArc>(initData.id, object, fPoint, sPoint, initData.suffix, initData.data,
initData.destination.at(i).id);
break;
case GOType::Spline:
UpdateCurve<VSpline>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
UpdateCurve<VSpline>(initData.id, object, fPoint, sPoint, initData.suffix, initData.data,
initData.destination.at(i).id);
break;
case GOType::SplinePath:
UpdateCurveWithSegments<VSplinePath>(initData.id, idObject, fPoint, sPoint, initData.suffix,
UpdateCurveWithSegments<VSplinePath>(initData.id, object, fPoint, sPoint, initData.suffix,
initData.data, initData.destination.at(i).id);
break;
case GOType::CubicBezier:
UpdateCurve<VCubicBezier>(initData.id, idObject, fPoint, sPoint, initData.suffix, initData.data,
UpdateCurve<VCubicBezier>(initData.id, object, fPoint, sPoint, initData.suffix, initData.data,
initData.destination.at(i).id);
break;
case GOType::CubicBezierPath:
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, idObject, fPoint, sPoint, initData.suffix,
UpdateCurveWithSegments<VCubicBezierPath>(initData.id, object, fPoint, sPoint, initData.suffix,
initData.data, initData.destination.at(i).id);
break;
case GOType::Unknown:
@ -163,13 +160,18 @@ QT_WARNING_POP
}
//---------------------------------------------------------------------------------------------------------------------
DestinationItem VAbstractFlipping::CreatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
DestinationItem VAbstractFlipping::CreatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data)
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(sItem.id);
VPointF rotated = point->Flip(QLineF(firstPoint, secondPoint), suffix);
rotated.setIdObject(idTool);
if (not sItem.alias.isEmpty())
{
rotated.setName(sItem.alias);
}
DestinationItem item;
item.mx = rotated.mx();
item.my = rotated.my();
@ -180,33 +182,39 @@ DestinationItem VAbstractFlipping::CreatePoint(quint32 idTool, quint32 idItem, c
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VAbstractFlipping::CreateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
DestinationItem VAbstractFlipping::CreateArc(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data)
{
const DestinationItem item = CreateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data);
const DestinationItem item = CreateItem<Item>(idTool, sItem, firstPoint, secondPoint, suffix, data);
data->AddArc(data->GeometricObject<Item>(item.id), item.id);
return item;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractFlipping::UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
void VAbstractFlipping::UpdatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data,
const DestinationItem &item)
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idItem);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(sItem.id);
VPointF rotated = point->Flip(QLineF(firstPoint, secondPoint), suffix);
rotated.setIdObject(idTool);
rotated.setMx(item.mx);
rotated.setMy(item.my);
rotated.SetShowLabel(item.showLabel);
if (not sItem.alias.isEmpty())
{
rotated.setName(sItem.alias);
}
data->UpdateGObject(item.id, new VPointF(rotated));
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VAbstractFlipping::UpdateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id)
void VAbstractFlipping::UpdateArc(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id)
{
UpdateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data, id);
UpdateItem<Item>(idTool, sItem, firstPoint, secondPoint, suffix, data, id);
data->AddArc(data->GeometricObject<Item>(id), id);
}

View File

@ -39,41 +39,40 @@ class VAbstractFlipping : public VAbstractOperation
public:
virtual ~VAbstractFlipping() Q_DECL_EQ_DEFAULT;
protected:
VAbstractFlipping(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination, const QString &notes,
QGraphicsItem *parent = nullptr);
explicit VAbstractFlipping(const VAbstractOperationInitData &initData, QGraphicsItem *parent = nullptr);
static void CreateDestination(VAbstractOperationInitData &initData, const QPointF &fPoint, const QPointF &sPoint);
static DestinationItem CreatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
static DestinationItem CreatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data);
template <class Item>
static DestinationItem CreateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
static DestinationItem CreateItem(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data);
template <class Item>
static DestinationItem CreateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
static DestinationItem CreateArc(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data);
template <class Item>
static DestinationItem CreateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
static DestinationItem CreateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data);
template <class Item>
static DestinationItem CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
static DestinationItem CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data);
static void UpdatePoint(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, const DestinationItem &item);
static void UpdatePoint(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data,
const DestinationItem &item);
template <class Item>
static void UpdateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id);
static void UpdateItem(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id);
template <class Item>
static void UpdateArc(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id);
static void UpdateArc(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id);
template <class Item>
static void UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data, quint32 id);
static void UpdateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id);
template <class Item>
static void UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
static void UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data,
quint32 id);
private:
@ -82,68 +81,77 @@ private:
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VAbstractFlipping::CreateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
DestinationItem VAbstractFlipping::CreateItem(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data)
{
const QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
const QSharedPointer<Item> i = data->GeometricObject<Item>(sItem.id);
Item rotated = i->Flip(QLineF(firstPoint, secondPoint), suffix);
rotated.setIdObject(idTool);
if (not sItem.alias.isEmpty())
{
rotated.SetAliasSuffix(sItem.alias);
}
DestinationItem item;
item.mx = INT_MAX;
item.my = INT_MAX;
item.id = data->AddGObject(new Item(rotated));
return item;
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VAbstractFlipping::CreateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
DestinationItem VAbstractFlipping::CreateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data)
{
const DestinationItem item = CreateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data);
const DestinationItem item = CreateItem<Item>(idTool, sItem, firstPoint, secondPoint, suffix, data);
data->AddSpline(data->GeometricObject<Item>(item.id), item.id);
return item;
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
DestinationItem VAbstractFlipping::CreateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix,
VContainer *data)
DestinationItem VAbstractFlipping::CreateCurveWithSegments(quint32 idTool, const SourceItem &sItem,
const QPointF &firstPoint, const QPointF &secondPoint,
const QString &suffix, VContainer *data)
{
const DestinationItem item = CreateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data);
const DestinationItem item = CreateItem<Item>(idTool, sItem, firstPoint, secondPoint, suffix, data);
data->AddCurveWithSegments(data->GeometricObject<Item>(item.id), item.id);
return item;
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VAbstractFlipping::UpdateItem(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
void VAbstractFlipping::UpdateItem(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id)
{
const QSharedPointer<Item> i = data->GeometricObject<Item>(idItem);
const QSharedPointer<Item> i = data->GeometricObject<Item>(sItem.id);
Item rotated = i->Flip(QLineF(firstPoint, secondPoint), suffix);
rotated.setIdObject(idTool);
if (not sItem.alias.isEmpty())
{
rotated.SetAliasSuffix(sItem.alias);
}
data->UpdateGObject(id, new Item(rotated));
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VAbstractFlipping::UpdateCurve(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
void VAbstractFlipping::UpdateCurve(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data, quint32 id)
{
UpdateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data, id);
UpdateItem<Item>(idTool, sItem, firstPoint, secondPoint, suffix, data, id);
data->AddSpline(data->GeometricObject<Item>(id), id);
}
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
void VAbstractFlipping::UpdateCurveWithSegments(quint32 idTool, quint32 idItem, const QPointF &firstPoint,
void VAbstractFlipping::UpdateCurveWithSegments(quint32 idTool, const SourceItem &sItem, const QPointF &firstPoint,
const QPointF &secondPoint, const QString &suffix, VContainer *data,
quint32 id)
{
UpdateItem<Item>(idTool, idItem, firstPoint, secondPoint, suffix, data, id);
UpdateItem<Item>(idTool, sItem, firstPoint, secondPoint, suffix, data, id);
data->AddCurveWithSegments(data->GeometricObject<Item>(id), id);
}

View File

@ -75,6 +75,7 @@ void VToolFlippingByAxis::setDialog()
dialogTool->SetAxisType(m_axisType);
dialogTool->SetSuffix(suffix);
dialogTool->SetNotes(m_notes);
dialogTool->SetSourceObjects(source);
SetDialogVisibilityGroupData(dialogTool);
}
@ -91,7 +92,7 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(const QPointer<DialogTool> &dia
initData.originPointId = dialogTool->GetOriginPointId();
initData.axisType = dialogTool->GetAxisType();
initData.suffix = dialogTool->GetSuffix();
initData.source = dialogTool->GetObjects();
initData.source = dialogTool->GetSourceObjects();
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
@ -141,9 +142,9 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(VToolFlippingByAxisInitData ini
InitOperationToolConnections(initData.scene, tool);
VAbstractPattern::AddTool(initData.id, tool);
initData.doc->IncrementReferens(originPoint.getIdTool());
for (auto idObject : qAsConst(initData.source))
for (auto object : qAsConst(initData.source))
{
initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
initData.doc->IncrementReferens(initData.data->GetGObject(object.id)->getIdTool());
}
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
@ -206,7 +207,7 @@ void VToolFlippingByAxis::SetVisualization()
VisToolFlippingByAxis *visual = qobject_cast<VisToolFlippingByAxis *>(vis);
SCASSERT(visual != nullptr)
visual->SetObjects(source);
visual->SetObjects(SourceToObjects(source));
visual->SetOriginPointId(m_originPointId);
visual->SetAxisType(m_axisType);
visual->RefreshGeometry();
@ -231,6 +232,9 @@ void VToolFlippingByAxis::SaveDialog(QDomElement &domElement, QList<quint32> &ol
const QString notes = dialogTool->GetNotes();
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
source = dialogTool->GetSourceObjects();
SaveSourceDestination(domElement);
// Save visibility data for later use
SaveVisibilityGroupData(dialogTool);
}
@ -242,7 +246,6 @@ void VToolFlippingByAxis::ReadToolAttributes(const QDomElement &domElement)
m_originPointId = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR);
m_axisType = static_cast<AxisType>(doc->GetParametrUInt(domElement, AttrAxisType, QChar('1')));
suffix = doc->GetParametrString(domElement, AttrSuffix);
}
//---------------------------------------------------------------------------------------------------------------------
@ -253,9 +256,6 @@ void VToolFlippingByAxis::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrCenter, QString().setNum(m_originPointId));
doc->SetAttribute(tag, AttrAxisType, QString().setNum(static_cast<int>(m_axisType)));
doc->SetAttribute(tag, AttrSuffix, suffix);
SaveSourceDestination(tag);
}
//---------------------------------------------------------------------------------------------------------------------
@ -269,8 +269,7 @@ QString VToolFlippingByAxis::MakeToolTip() const
//---------------------------------------------------------------------------------------------------------------------
VToolFlippingByAxis::VToolFlippingByAxis(const VToolFlippingByAxisInitData &initData, QGraphicsItem *parent)
: VAbstractFlipping(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
initData.destination, initData.notes, parent),
: VAbstractFlipping(initData, parent),
m_originPointId(initData.originPointId),
m_axisType(initData.axisType)
{

View File

@ -75,6 +75,7 @@ void VToolFlippingByLine::setDialog()
dialogTool->SetSecondLinePointId(m_secondLinePointId);
dialogTool->SetSuffix(suffix);
dialogTool->SetNotes(m_notes);
dialogTool->SetSourceObjects(source);
SetDialogVisibilityGroupData(dialogTool);
}
@ -91,7 +92,7 @@ VToolFlippingByLine *VToolFlippingByLine::Create(const QPointer<DialogTool> &dia
initData.firstLinePointId = dialogTool->GetFirstLinePointId();
initData.secondLinePointId = dialogTool->GetSecondLinePointId();
initData.suffix = dialogTool->GetSuffix();
initData.source = dialogTool->GetObjects();
initData.source = dialogTool->GetSourceObjects();
initData.hasLinkedVisibilityGroup = dialogTool->HasLinkedVisibilityGroup();
initData.visibilityGroupName = dialogTool->GetVisibilityGroupName();
initData.visibilityGroupTags = dialogTool->GetVisibilityGroupTags();
@ -135,9 +136,9 @@ VToolFlippingByLine *VToolFlippingByLine::Create(VToolFlippingByLineInitData ini
VAbstractPattern::AddTool(initData.id, tool);
initData.doc->IncrementReferens(firstPoint.getIdTool());
initData.doc->IncrementReferens(secondPoint.getIdTool());
for (auto idObject : qAsConst(initData.source))
for (auto object : qAsConst(initData.source))
{
initData.doc->IncrementReferens(initData.data->GetGObject(idObject)->getIdTool());
initData.doc->IncrementReferens(initData.data->GetGObject(object.id)->getIdTool());
}
if (initData.typeCreation == Source::FromGui && initData.hasLinkedVisibilityGroup)
@ -191,7 +192,7 @@ void VToolFlippingByLine::SetVisualization()
VisToolFlippingByLine *visual = qobject_cast<VisToolFlippingByLine *>(vis);
SCASSERT(visual != nullptr)
visual->SetObjects(source);
visual->SetObjects(SourceToObjects(source));
visual->SetFirstLinePointId(m_firstLinePointId);
visual->SetSecondLinePointId(m_secondLinePointId);
visual->RefreshGeometry();
@ -218,6 +219,9 @@ void VToolFlippingByLine::SaveDialog(QDomElement &domElement, QList<quint32> &ol
const QString notes = dialogTool->GetNotes();
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
source = dialogTool->GetSourceObjects();
SaveSourceDestination(domElement);
// Save visibility data for later use
SaveVisibilityGroupData(dialogTool);
}
@ -229,7 +233,6 @@ void VToolFlippingByLine::ReadToolAttributes(const QDomElement &domElement)
m_firstLinePointId = doc->GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR);
m_secondLinePointId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
suffix = doc->GetParametrString(domElement, AttrSuffix);
}
//---------------------------------------------------------------------------------------------------------------------
@ -240,9 +243,6 @@ void VToolFlippingByLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
doc->SetAttribute(tag, AttrType, ToolType);
doc->SetAttribute(tag, AttrP1Line, QString().setNum(m_firstLinePointId));
doc->SetAttribute(tag, AttrP2Line, QString().setNum(m_secondLinePointId));
doc->SetAttribute(tag, AttrSuffix, suffix);
SaveSourceDestination(tag);
}
//---------------------------------------------------------------------------------------------------------------------
@ -258,8 +258,7 @@ QString VToolFlippingByLine::MakeToolTip() const
//---------------------------------------------------------------------------------------------------------------------
VToolFlippingByLine::VToolFlippingByLine(const VToolFlippingByLineInitData &initData, QGraphicsItem *parent)
: VAbstractFlipping(initData.doc, initData.data, initData.id, initData.suffix, initData.source,
initData.destination, initData.notes, parent),
: VAbstractFlipping(initData, parent),
m_firstLinePointId(initData.firstLinePointId),
m_secondLinePointId(initData.secondLinePointId)
{

View File

@ -46,15 +46,15 @@ namespace
* @param source list with source objects
* @return visibility group data
*/
QMap<quint32, quint32> VisibilityGroupDataFromSource(const VContainer *data, const QVector<quint32> &source)
QMap<quint32, quint32> VisibilityGroupDataFromSource(const VContainer *data, const QVector<SourceItem> &source)
{
QMap<quint32, quint32> groupData;
for (auto &sId : source)
for (auto &sItem : source)
{
try
{
groupData.insert(sId, data->GetGObject(sId)->getIdTool());
groupData.insert(sItem.id, data->GetGObject(sItem.id)->getIdTool());
}
catch (const VExceptionBadId &)
{
@ -89,25 +89,9 @@ void VAbstractOperation::SetSuffix(const QString &suffix)
}
//---------------------------------------------------------------------------------------------------------------------
QVector<QString> VAbstractOperation::SourceItems() const
QVector<SourceItem> VAbstractOperation::SourceItems() const
{
QVector<QString> itemNames;
itemNames.reserve(source.size());
try
{
for (auto &item : source)
{
itemNames.append(VAbstractTool::data.GetGObject(item)->name());
}
}
catch (const VExceptionBadId &e)
{
qCritical() << e.ErrorMessage()<<Q_FUNC_INFO;
return QVector<QString>();
}
return itemNames;
return source;
}
//---------------------------------------------------------------------------------------------------------------------
@ -201,27 +185,49 @@ void VAbstractOperation::SetLabelVisible(quint32 id, bool visible)
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::ExtractData(const QDomElement &domElement, VAbstractOperationInitData &initData)
{
initData.source = ExtractSourceData(domElement);
initData.destination = ExtractDestinationData(domElement);
}
//---------------------------------------------------------------------------------------------------------------------
QVector<SourceItem> VAbstractOperation::ExtractSourceData(const QDomElement &domElement)
{
QVector<SourceItem> source;
const QDomNodeList nodeList = domElement.childNodes();
for (qint32 i = 0; i < nodeList.size(); ++i)
{
const QDomElement dataElement = nodeList.at(i).toElement();
if (not dataElement.isNull() && dataElement.tagName() == TagSource)
{
initData.source.clear();
const QDomNodeList srcList = dataElement.childNodes();
for (qint32 j = 0; j < srcList.size(); ++j)
{
const QDomElement element = srcList.at(j).toElement();
if (not element.isNull())
{
initData.source.append(VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR));
SourceItem item;
item.id = VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR);
item.alias = VDomDocument::GetParametrEmptyString(element, AttrAlias);
source.append(item);
}
}
return source;
}
}
return source;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<DestinationItem> VAbstractOperation::ExtractDestinationData(const QDomElement &domElement)
{
QVector<DestinationItem> destination;
const QDomNodeList nodeList = domElement.childNodes();
for (qint32 i = 0; i < nodeList.size(); ++i)
{
const QDomElement dataElement = nodeList.at(i).toElement();
if (not dataElement.isNull() && dataElement.tagName() == TagDestination)
{
initData.destination.clear();
const QDomNodeList srcList = dataElement.childNodes();
for (qint32 j = 0; j < srcList.size(); ++j)
{
@ -230,14 +236,18 @@ void VAbstractOperation::ExtractData(const QDomElement &domElement, VAbstractOpe
{
DestinationItem d;
d.id = VDomDocument::GetParametrUInt(element, AttrIdObject, NULL_ID_STR);
d.mx = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMx, QString::number(INT_MAX)));
d.my = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMy, QString::number(INT_MAX)));
d.mx = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMx, QChar('1')));
d.my = qApp->toPixel(VDomDocument::GetParametrDouble(element, AttrMy, QChar('1')));
d.showLabel = VDomDocument::GetParametrBool(element, AttrShowLabel, trueStr);
initData.destination.append(d);
destination.append(d);
}
}
return destination;
}
}
return destination;
}
//---------------------------------------------------------------------------------------------------------------------
@ -520,17 +530,15 @@ void VAbstractOperation::LabelChangePosition(const QPointF &pos, quint32 labelId
}
//---------------------------------------------------------------------------------------------------------------------
VAbstractOperation::VAbstractOperation(VAbstractPattern *doc, VContainer *data, quint32 id, const QString &suffix,
const QVector<quint32> &source, const QVector<DestinationItem> &destination,
const QString &notes, QGraphicsItem *parent)
: VDrawTool(doc, data, id, notes),
VAbstractOperation::VAbstractOperation(const VAbstractOperationInitData &initData, QGraphicsItem *parent)
: VDrawTool(initData.doc, initData.data, initData.id, initData.notes),
QGraphicsLineItem(parent),
suffix(suffix),
source(source),
destination(destination),
suffix(initData.suffix),
source(initData.source),
destination(initData.destination),
operatedObjects()
{
connect(doc, &VAbstractPattern::UpdateToolTip, this, [this]()
connect(initData.doc, &VAbstractPattern::UpdateToolTip, this, [this]()
{
QMapIterator<quint32, VAbstractSimple *> i(operatedObjects);
while (i.hasNext())
@ -669,6 +677,26 @@ void VAbstractOperation::PerformDelete()
}
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::ReadToolAttributes(const QDomElement &domElement)
{
VDrawTool::ReadToolAttributes(domElement);
source = ExtractSourceData(domElement);
destination = ExtractDestinationData(domElement);
suffix = doc->GetParametrString(domElement, AttrSuffix);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
{
VDrawTool::SaveOptions(tag, obj);
doc->SetAttribute(tag, AttrSuffix, suffix);
SaveSourceDestination(tag);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractOperation::UpdateNamePosition(quint32 id, const QPointF &pos)
{
@ -695,10 +723,11 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag)
doc->RemoveAllChildren(tag);
QDomElement tagObjects = doc->createElement(TagSource);
for (auto id : qAsConst(source))
for (auto sItem : qAsConst(source))
{
QDomElement item = doc->createElement(TagItem);
doc->SetAttribute(item, AttrIdObject, id);
doc->SetAttribute(item, AttrIdObject, sItem.id);
doc->SetAttributeOrRemoveIf(item, AttrAlias, sItem.alias, sItem.alias.isEmpty());
tagObjects.appendChild(item);
}
tag.appendChild(tagObjects);
@ -709,13 +738,13 @@ void VAbstractOperation::SaveSourceDestination(QDomElement &tag)
QDomElement item = doc->createElement(TagItem);
doc->SetAttribute(item, AttrIdObject, dItem.id);
if (not VFuzzyComparePossibleNulls(dItem.mx, INT_MAX) &&
not VFuzzyComparePossibleNulls(dItem.my, INT_MAX))
{
doc->SetAttribute(item, AttrMx, qApp->fromPixel(dItem.mx));
doc->SetAttribute(item, AttrMy, qApp->fromPixel(dItem.my));
doc->SetAttribute<bool>(item, AttrShowLabel, dItem.showLabel);
}
VAbstractSimple *obj = operatedObjects.value(dItem.id, nullptr);
doc->SetAttributeOrRemoveIf(item, AttrMx, qApp->fromPixel(dItem.mx),
obj && obj->GetType() != GOType::Point);
doc->SetAttributeOrRemoveIf(item, AttrMy, qApp->fromPixel(dItem.my),
obj && obj->GetType() != GOType::Point);
doc->SetAttributeOrRemoveIf<bool>(item, AttrShowLabel, dItem.showLabel, dItem.showLabel);
tagObjects.appendChild(item);
}
@ -888,7 +917,7 @@ QString VAbstractOperation::ComplexCurveToolTip(quint32 itemId) const
"<tr> <td><b>%3:</b> %4 %5</td> </tr>"
"%6"
"</table>")
.arg(tr("Label"), curve->name(), tr("Length"))
.arg(tr("Label"), curve->ObjectName(), tr("Length"))
.arg(qApp->fromPixel(curve->GetLength()))
.arg(UnitsToStr(qApp->patternUnits(), true), MakeToolTip());
return toolTip;

Some files were not shown because too many files have changed in this diff Show More