Alias field for tool Arc.
This commit is contained in:
parent
8b49ea68c8
commit
1246aba24d
|
@ -516,12 +516,32 @@ void VToolOptionsPropertyBrowser::AddPropertyFormula(const QString &propertyName
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
template<class Tool>
|
template<class Tool>
|
||||||
void VToolOptionsPropertyBrowser::AddPropertyObjectName(Tool *i, const QString &propertyName, bool readOnly)
|
void VToolOptionsPropertyBrowser::AddPropertyObjectName(Tool *i, const QString &propertyName, bool readOnly)
|
||||||
|
{
|
||||||
|
if (readOnly)
|
||||||
|
{
|
||||||
|
auto *itemName = new VPE::VLabelProperty(propertyName);
|
||||||
|
itemName->setValue(qApp->TrVars()->VarToUser(i->name()));
|
||||||
|
AddProperty(itemName, AttrName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto *itemName = new VPE::VStringProperty(propertyName);
|
||||||
|
itemName->setClearButtonEnable(true);
|
||||||
|
itemName->setValue(qApp->TrVars()->VarToUser(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);
|
auto *itemName = new VPE::VStringProperty(propertyName);
|
||||||
itemName->setClearButtonEnable(true);
|
itemName->setClearButtonEnable(true);
|
||||||
itemName->setValue(qApp->TrVars()->VarToUser(i->name()));
|
itemName->setValue(qApp->TrVars()->VarToUser(i->GetAliasSuffix()));
|
||||||
itemName->setReadOnly(readOnly);
|
AddProperty(itemName, AttrAlias);
|
||||||
AddProperty(itemName, AttrName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -927,6 +947,26 @@ 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>
|
template<class Tool>
|
||||||
void VToolOptionsPropertyBrowser::SetLineType(VPE::VProperty *property)
|
void VToolOptionsPropertyBrowser::SetLineType(VPE::VProperty *property)
|
||||||
|
@ -1275,6 +1315,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolArc(VPE::VProperty *property)
|
||||||
case 61: // AttrNotes
|
case 61: // AttrNotes
|
||||||
SetNotes<VToolArc>(property);
|
SetNotes<VToolArc>(property);
|
||||||
break;
|
break;
|
||||||
|
case 62: // AttrAlias
|
||||||
|
SetAlias<VToolArc>(property);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
qWarning()<<"Unknown property type. id = "<<id;
|
qWarning()<<"Unknown property type. id = "<<id;
|
||||||
break;
|
break;
|
||||||
|
@ -2429,6 +2472,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolArc(QGraphicsItem *item)
|
||||||
AddPropertyFormula(tr("Radius:"), i->GetFormulaRadius(), AttrRadius);
|
AddPropertyFormula(tr("Radius:"), i->GetFormulaRadius(), AttrRadius);
|
||||||
AddPropertyFormula(tr("First angle:"), i->GetFormulaF1(), AttrAngle1);
|
AddPropertyFormula(tr("First angle:"), i->GetFormulaF1(), AttrAngle1);
|
||||||
AddPropertyFormula(tr("Second angle:"), i->GetFormulaF2(), AttrAngle2);
|
AddPropertyFormula(tr("Second angle:"), i->GetFormulaF2(), AttrAngle2);
|
||||||
|
AddPropertyAlias(i, tr("Alias:"));
|
||||||
AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics());
|
AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics());
|
||||||
AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor);
|
AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor);
|
||||||
AddPropertyApproximationScale(tr("Approximation scale:"), i->GetApproximationScale());
|
AddPropertyApproximationScale(tr("Approximation scale:"), i->GetApproximationScale());
|
||||||
|
@ -3002,6 +3046,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolArc()
|
||||||
{
|
{
|
||||||
auto *i = qgraphicsitem_cast<VToolArc *>(currentItem);
|
auto *i = qgraphicsitem_cast<VToolArc *>(currentItem);
|
||||||
|
|
||||||
|
idToProperty[AttrName]->setValue(i->name());
|
||||||
|
|
||||||
QVariant valueRadius;
|
QVariant valueRadius;
|
||||||
valueRadius.setValue(i->GetFormulaRadius());
|
valueRadius.setValue(i->GetFormulaRadius());
|
||||||
idToProperty[AttrRadius]->setValue(valueRadius);
|
idToProperty[AttrRadius]->setValue(valueRadius);
|
||||||
|
@ -3033,6 +3079,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolArc()
|
||||||
idToProperty[AttrAScale]->setValue(valueApproximationScale);
|
idToProperty[AttrAScale]->setValue(valueApproximationScale);
|
||||||
|
|
||||||
idToProperty[AttrNotes]->setValue(i->GetNotes());
|
idToProperty[AttrNotes]->setValue(i->GetNotes());
|
||||||
|
|
||||||
|
idToProperty[AttrAlias]->setValue(i->GetAliasSuffix());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -3844,67 +3892,70 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolEllipticalArc()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QStringList VToolOptionsPropertyBrowser::PropertiesList() const
|
QStringList VToolOptionsPropertyBrowser::PropertiesList() const
|
||||||
{
|
{
|
||||||
static QStringList attr = QStringList() << AttrName /* 0 */
|
static QStringList attr{
|
||||||
<< QLatin1String("position") /* 1 */
|
AttrName, /* 0 */
|
||||||
<< AttrBasePoint /* 2 */
|
QLatin1String("position"), /* 1 */
|
||||||
<< AttrTypeLine /* 3 */
|
AttrBasePoint, /* 2 */
|
||||||
<< AttrLength /* 4 */
|
AttrTypeLine, /* 3 */
|
||||||
<< AttrAngle /* 5 */
|
AttrLength, /* 4 */
|
||||||
<< AttrFirstPoint /* 6 */
|
AttrAngle, /* 5 */
|
||||||
<< AttrSecondPoint /* 7 */
|
AttrFirstPoint, /* 6 */
|
||||||
<< AttrRadius /* 8 */
|
AttrSecondPoint, /* 7 */
|
||||||
<< AttrAngle1 /* 9 */
|
AttrRadius, /* 8 */
|
||||||
<< AttrAngle2 /* 10 */
|
AttrAngle1, /* 9 */
|
||||||
<< AttrCenter /* 11 */
|
AttrAngle2, /* 10 */
|
||||||
<< AttrThirdPoint /* 12 */
|
AttrCenter, /* 11 */
|
||||||
<< AttrArc /* 13 */
|
AttrThirdPoint, /* 12 */
|
||||||
<< VToolCutSpline::AttrSpline /* 14 */
|
AttrArc, /* 13 */
|
||||||
<< VToolCutSplinePath::AttrSplinePath /* 15 */
|
VToolCutSpline::AttrSpline, /* 14 */
|
||||||
<< AttrP1Line /* 16 */
|
VToolCutSplinePath::AttrSplinePath, /* 15 */
|
||||||
<< AttrP2Line /* 17 */
|
AttrP1Line, /* 16 */
|
||||||
<< AttrP1Line1 /* 18 */
|
AttrP2Line, /* 17 */
|
||||||
<< AttrP2Line1 /* 19 */
|
AttrP1Line1, /* 18 */
|
||||||
<< AttrP1Line2 /* 20 */
|
AttrP2Line1, /* 19 */
|
||||||
<< AttrP2Line2 /* 21 */
|
AttrP1Line2, /* 20 */
|
||||||
<< AttrPShoulder /* 22 */
|
AttrP2Line2, /* 21 */
|
||||||
<< AttrAxisP1 /* 23 */
|
AttrPShoulder, /* 22 */
|
||||||
<< AttrAxisP2 /* 24 */
|
AttrAxisP1, /* 23 */
|
||||||
<< AttrKCurve /*Not used*/ /* 25 */
|
AttrAxisP2, /* 24 */
|
||||||
<< AttrLineColor /* 26 */
|
AttrKCurve, /*Not used*/ /* 25 */
|
||||||
<< AttrColor /* 27 */
|
AttrLineColor, /* 26 */
|
||||||
<< AttrCrossPoint /* 28 */
|
AttrColor, /* 27 */
|
||||||
<< AttrC1Radius /* 29 */
|
AttrCrossPoint, /* 28 */
|
||||||
<< AttrC2Radius /* 30 */
|
AttrC1Radius, /* 29 */
|
||||||
<< AttrCRadius /* 31 */
|
AttrC2Radius, /* 30 */
|
||||||
<< AttrName1 /* 32 */
|
AttrCRadius, /* 31 */
|
||||||
<< AttrName2 /* 33 */
|
AttrName1, /* 32 */
|
||||||
<< AttrVCrossPoint /* 34 */
|
AttrName2, /* 33 */
|
||||||
<< AttrHCrossPoint /* 35 */
|
AttrVCrossPoint, /* 34 */
|
||||||
<< AttrLength1 /* 36 */
|
AttrHCrossPoint, /* 35 */
|
||||||
<< AttrLength2 /* 37 */
|
AttrLength1, /* 36 */
|
||||||
<< AttrSuffix /* 38 */
|
AttrLength2, /* 37 */
|
||||||
<< AttrAxisType /* 39 */
|
AttrSuffix, /* 38 */
|
||||||
<< AttrRadius1 /* 40 */
|
AttrAxisType, /* 39 */
|
||||||
<< AttrRadius2 /* 41 */
|
AttrRadius1, /* 40 */
|
||||||
<< AttrRotationAngle /* 42 */
|
AttrRadius2, /* 41 */
|
||||||
<< AttrDartP1 /* 43 */
|
AttrRotationAngle, /* 42 */
|
||||||
<< AttrDartP2 /* 44 */
|
AttrDartP1, /* 43 */
|
||||||
<< AttrDartP3 /* 45 */
|
AttrDartP2, /* 44 */
|
||||||
<< AttrCurve /* 46 */
|
AttrDartP3, /* 45 */
|
||||||
<< AttrFirstArc /* 47 */
|
AttrCurve, /* 46 */
|
||||||
<< AttrSecondArc /* 48 */
|
AttrFirstArc, /* 47 */
|
||||||
<< AttrC1Center /* 49 */
|
AttrSecondArc, /* 48 */
|
||||||
<< AttrC2Center /* 50 */
|
AttrC1Center, /* 49 */
|
||||||
<< AttrCurve1 /* 51 */
|
AttrC2Center, /* 50 */
|
||||||
<< AttrCurve2 /* 52 */
|
AttrCurve1, /* 51 */
|
||||||
<< AttrCCenter /* 53 */
|
AttrCurve2, /* 52 */
|
||||||
<< AttrTangent /* 54 */
|
AttrCCenter, /* 53 */
|
||||||
<< AttrPoint1 /* 55 */
|
AttrTangent, /* 54 */
|
||||||
<< AttrPoint2 /* 56 */
|
AttrPoint1, /* 55 */
|
||||||
<< AttrPoint3 /* 57 */
|
AttrPoint2, /* 56 */
|
||||||
<< AttrPoint4 /* 58 */
|
AttrPoint3, /* 57 */
|
||||||
<< AttrPenStyle /* 59 */
|
AttrPoint4, /* 58 */
|
||||||
<< AttrAScale /* 60 */
|
AttrPenStyle, /* 59 */
|
||||||
<< AttrNotes; /* 61 */
|
AttrAScale, /* 60 */
|
||||||
|
AttrNotes, /* 61 */
|
||||||
|
AttrAlias /* 62 */
|
||||||
|
};
|
||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,9 @@ private:
|
||||||
template<class Tool>
|
template<class Tool>
|
||||||
void SetNotes(VPE::VProperty *property);
|
void SetNotes(VPE::VProperty *property);
|
||||||
|
|
||||||
|
template<class Tool>
|
||||||
|
void SetAlias(VPE::VProperty *property);
|
||||||
|
|
||||||
template<class Tool>
|
template<class Tool>
|
||||||
void SetLineType(VPE::VProperty *property);
|
void SetLineType(VPE::VProperty *property);
|
||||||
|
|
||||||
|
@ -129,6 +132,9 @@ private:
|
||||||
template<class Tool>
|
template<class Tool>
|
||||||
void AddPropertyObjectName(Tool *i, const QString &propertyName, bool readOnly = false);
|
void AddPropertyObjectName(Tool *i, const QString &propertyName, bool readOnly = false);
|
||||||
|
|
||||||
|
template<class Tool>
|
||||||
|
void AddPropertyAlias(Tool *i, const QString &propertyName);
|
||||||
|
|
||||||
template<class Tool>
|
template<class Tool>
|
||||||
void AddPropertyPointName1(Tool *i, const QString &propertyName);
|
void AddPropertyPointName1(Tool *i, const QString &propertyName);
|
||||||
|
|
||||||
|
|
|
@ -2992,6 +2992,7 @@ void VPattern::ParseToolArc(VMainGraphicsScene *scene, QDomElement &domElement,
|
||||||
initData.color = GetParametrString(domElement, AttrColor, ColorBlack);
|
initData.color = GetParametrString(domElement, AttrColor, ColorBlack);
|
||||||
initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
|
initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
|
||||||
initData.approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0'));
|
initData.approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0'));
|
||||||
|
initData.aliasSuffix = GetParametrEmptyString(domElement, AttrAlias);
|
||||||
|
|
||||||
VToolArc::Create(initData);
|
VToolArc::Create(initData);
|
||||||
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
||||||
|
|
|
@ -134,6 +134,7 @@ const QString AttrVersion = QStringLiteral("version");
|
||||||
const QString AttrFirstToCountour = QStringLiteral("firstToCountour");
|
const QString AttrFirstToCountour = QStringLiteral("firstToCountour");
|
||||||
const QString AttrLastToCountour = QStringLiteral("lastToCountour");
|
const QString AttrLastToCountour = QStringLiteral("lastToCountour");
|
||||||
const QString AttrNotes = QStringLiteral("notes");
|
const QString AttrNotes = QStringLiteral("notes");
|
||||||
|
const QString AttrAlias = QStringLiteral("alias");
|
||||||
|
|
||||||
const QString TypeLineNone = QStringLiteral("none");
|
const QString TypeLineNone = QStringLiteral("none");
|
||||||
const QString TypeLineLine = QStringLiteral("hair");
|
const QString TypeLineLine = QStringLiteral("hair");
|
||||||
|
|
|
@ -152,6 +152,7 @@ extern const QString AttrVersion;
|
||||||
extern const QString AttrFirstToCountour;
|
extern const QString AttrFirstToCountour;
|
||||||
extern const QString AttrLastToCountour;
|
extern const QString AttrLastToCountour;
|
||||||
extern const QString AttrNotes;
|
extern const QString AttrNotes;
|
||||||
|
extern const QString AttrAlias;
|
||||||
|
|
||||||
extern const QString TypeLineNone;
|
extern const QString TypeLineNone;
|
||||||
extern const QString TypeLineLine;
|
extern const QString TypeLineLine;
|
||||||
|
|
|
@ -181,7 +181,8 @@ QString VAbstractArc::NameForHistory(const QString &toolName) const
|
||||||
{
|
{
|
||||||
name += QString("_%1").arg(GetDuplicate());
|
name += QString("_%1").arg(GetDuplicate());
|
||||||
}
|
}
|
||||||
return name;
|
|
||||||
|
return not GetAlias().isEmpty() ? QString("%1 (%2)").arg(GetAlias(), name) : name;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -516,6 +516,19 @@ void VAbstractCubicBezier::CreateName()
|
||||||
setName(name);
|
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.
|
* @brief GetCubicBezierPoints return list with cubic bezier curve points.
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CreateName() override;
|
virtual void CreateName() override;
|
||||||
|
virtual void CreateAlias() override;
|
||||||
|
|
||||||
static QVector<QPointF> GetCubicBezierPoints(const QPointF &p1, const QPointF &p2, const QPointF &p3,
|
static QVector<QPointF> GetCubicBezierPoints(const QPointF &p1, const QPointF &p2, const QPointF &p3,
|
||||||
const QPointF &p4, qreal approximationScale);
|
const QPointF &p4, qreal approximationScale);
|
||||||
|
|
|
@ -288,3 +288,16 @@ void VAbstractCubicBezierPath::CreateName()
|
||||||
}
|
}
|
||||||
setName(name);
|
setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VAbstractCubicBezierPath::CreateAlias()
|
||||||
|
{
|
||||||
|
const QString aliasSuffix = GetAliasSuffix();
|
||||||
|
if (aliasSuffix.isEmpty())
|
||||||
|
{
|
||||||
|
SetAlias(QString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetAlias(splPath + '_' + aliasSuffix);
|
||||||
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void CreateName() override;
|
virtual void CreateName() override;
|
||||||
|
virtual void CreateAlias() override;
|
||||||
|
|
||||||
virtual VPointF FirstPoint() const =0;
|
virtual VPointF FirstPoint() const =0;
|
||||||
virtual VPointF LastPoint() const =0;
|
virtual VPointF LastPoint() const =0;
|
||||||
|
|
|
@ -603,6 +603,13 @@ qreal VAbstractCurve::LengthCurveDirectionArrow()
|
||||||
return qApp->Settings()->GetLineWidth() * 8.0;
|
return qApp->Settings()->GetLineWidth() * 8.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VAbstractCurve::SetAliasSuffix(const QString &aliasSuffix)
|
||||||
|
{
|
||||||
|
VGObject::SetAliasSuffix(aliasSuffix);
|
||||||
|
CreateAlias();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
qreal VAbstractCurve::PathLength(const QVector<QPointF> &path)
|
qreal VAbstractCurve::PathLength(const QVector<QPointF> &path)
|
||||||
{
|
{
|
||||||
|
|
|
@ -105,8 +105,11 @@ public:
|
||||||
static QPainterPath ShowDirection(const QVector<DirectionArrow> &arrows, qreal width);
|
static QPainterPath ShowDirection(const QVector<DirectionArrow> &arrows, qreal width);
|
||||||
|
|
||||||
static qreal LengthCurveDirectionArrow();
|
static qreal LengthCurveDirectionArrow();
|
||||||
|
|
||||||
|
virtual void SetAliasSuffix(const QString &aliasSuffix) override;
|
||||||
protected:
|
protected:
|
||||||
virtual void CreateName() =0;
|
virtual void CreateName() =0;
|
||||||
|
virtual void CreateAlias() =0;
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VAbstractCurveData> d;
|
QSharedDataPointer<VAbstractCurveData> d;
|
||||||
|
|
||||||
|
|
|
@ -378,7 +378,7 @@ QPointF VArc::CutArc(qreal length) const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VArc::CreateName()
|
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)
|
if (getMode() == Draw::Modeling && getIdObject() != NULL_ID)
|
||||||
{
|
{
|
||||||
|
@ -397,6 +397,19 @@ void VArc::CreateName()
|
||||||
setName(name);
|
setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VArc::CreateAlias()
|
||||||
|
{
|
||||||
|
const QString aliasSuffix = GetAliasSuffix();
|
||||||
|
if (aliasSuffix.isEmpty())
|
||||||
|
{
|
||||||
|
SetAlias(QString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetAlias(ARC_ + aliasSuffix);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VArc::FindF2(qreal length)
|
void VArc::FindF2(qreal length)
|
||||||
{
|
{
|
||||||
|
|
|
@ -85,6 +85,7 @@ public:
|
||||||
QPointF CutArc (qreal length) const;
|
QPointF CutArc (qreal length) const;
|
||||||
protected:
|
protected:
|
||||||
virtual void CreateName() override;
|
virtual void CreateName() override;
|
||||||
|
virtual void CreateAlias() override;
|
||||||
virtual void FindF2(qreal length) override;
|
virtual void FindF2(qreal length) override;
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VArcData> d;
|
QSharedDataPointer<VArcData> d;
|
||||||
|
|
|
@ -399,6 +399,19 @@ void VEllipticalArc::CreateName()
|
||||||
setName(name);
|
setName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VEllipticalArc::CreateAlias()
|
||||||
|
{
|
||||||
|
const QString aliasSuffix = GetAliasSuffix();
|
||||||
|
if (aliasSuffix.isEmpty())
|
||||||
|
{
|
||||||
|
SetAlias(QString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetAlias(ELARC_ + aliasSuffix);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VEllipticalArc::FindF2(qreal length)
|
void VEllipticalArc::FindF2(qreal length)
|
||||||
{
|
{
|
||||||
|
|
|
@ -104,6 +104,7 @@ public:
|
||||||
static qreal OptimizeAngle(qreal angle);
|
static qreal OptimizeAngle(qreal angle);
|
||||||
protected:
|
protected:
|
||||||
virtual void CreateName() override;
|
virtual void CreateName() override;
|
||||||
|
virtual void CreateAlias() override;
|
||||||
virtual void FindF2(qreal length) override;
|
virtual void FindF2(qreal length) override;
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VEllipticalArcData> d;
|
QSharedDataPointer<VEllipticalArcData> d;
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
#include "ui_dialogarc.h"
|
#include "ui_dialogarc.h"
|
||||||
|
#include "../vgeometry/varc.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -122,6 +123,8 @@ DialogArc::DialogArc(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArc::DeployF1TextEdit);
|
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArc::DeployF1TextEdit);
|
||||||
connect(ui->pushButtonGrowLengthF2, &QPushButton::clicked, this, &DialogArc::DeployF2TextEdit);
|
connect(ui->pushButtonGrowLengthF2, &QPushButton::clicked, this, &DialogArc::DeployF2TextEdit);
|
||||||
|
|
||||||
|
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogArc::GetAliasSuffix);
|
||||||
|
|
||||||
vis = new VisToolArc(data);
|
vis = new VisToolArc(data);
|
||||||
|
|
||||||
ui->tabWidget->setCurrentIndex(0);
|
ui->tabWidget->setCurrentIndex(0);
|
||||||
|
@ -237,6 +240,19 @@ QString DialogArc::GetNotes() const
|
||||||
return ui->plainTextEditToolNotes->toPlainText();
|
return ui->plainTextEditToolNotes->toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogArc::SetAliasSuffix(const QString &alias)
|
||||||
|
{
|
||||||
|
ui->lineEditAlias->setText(alias);
|
||||||
|
ValidateAlias();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogArc::GetAliasSuffix() const
|
||||||
|
{
|
||||||
|
return ui->lineEditAlias->text();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief SetF1 set formula first angle of arc
|
* @brief SetF1 set formula first angle of arc
|
||||||
|
@ -337,6 +353,25 @@ void DialogArc::closeEvent(QCloseEvent *event)
|
||||||
DialogTool::closeEvent(event);
|
DialogTool::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogArc::ValidateAlias()
|
||||||
|
{
|
||||||
|
VArc arc;
|
||||||
|
arc.SetAliasSuffix(GetAliasSuffix());
|
||||||
|
if (not GetAliasSuffix().isEmpty() && not data->IsUnique(arc.GetAlias()))
|
||||||
|
{
|
||||||
|
flagAlias = false;
|
||||||
|
ChangeColor(ui->labelAlias, errorColor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flagAlias = true;
|
||||||
|
ChangeColor(ui->labelAlias, OkColor(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckState();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArc::FXRadius()
|
void DialogArc::FXRadius()
|
||||||
{
|
{
|
||||||
|
|
|
@ -76,6 +76,9 @@ public:
|
||||||
|
|
||||||
void SetNotes(const QString ¬es);
|
void SetNotes(const QString ¬es);
|
||||||
QString GetNotes() const;
|
QString GetNotes() const;
|
||||||
|
|
||||||
|
void SetAliasSuffix(const QString &alias);
|
||||||
|
QString GetAliasSuffix() const;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
/**
|
/**
|
||||||
|
@ -97,6 +100,9 @@ protected:
|
||||||
virtual void SaveData() override;
|
virtual void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
virtual bool IsValid() const final;
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void ValidateAlias();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogArc)
|
Q_DISABLE_COPY(DialogArc)
|
||||||
|
|
||||||
|
@ -112,6 +118,8 @@ private:
|
||||||
/** @brief flagF2 true if value of second angle is correct */
|
/** @brief flagF2 true if value of second angle is correct */
|
||||||
bool flagF2;
|
bool flagF2;
|
||||||
|
|
||||||
|
bool flagAlias{true};
|
||||||
|
|
||||||
/** @brief timerRadius timer of check formula of radius */
|
/** @brief timerRadius timer of check formula of radius */
|
||||||
QTimer *timerRadius;
|
QTimer *timerRadius;
|
||||||
|
|
||||||
|
@ -145,7 +153,7 @@ private:
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline bool DialogArc::IsValid() const
|
inline bool DialogArc::IsValid() const
|
||||||
{
|
{
|
||||||
return flagRadius && flagF1 && flagF2;
|
return flagRadius && flagF1 && flagF2 && flagAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DIALOGARC_H
|
#endif // DIALOGARC_H
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>407</width>
|
<width>407</width>
|
||||||
<height>456</height>
|
<height>476</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -662,6 +662,20 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -332,6 +332,7 @@ void VAbstractSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &ob
|
||||||
doc->SetAttribute(tag, AttrColor, curve->GetColor());
|
doc->SetAttribute(tag, AttrColor, curve->GetColor());
|
||||||
doc->SetAttribute(tag, AttrPenStyle, curve->GetPenStyle());
|
doc->SetAttribute(tag, AttrPenStyle, curve->GetPenStyle());
|
||||||
doc->SetAttribute(tag, AttrAScale, curve->GetApproximationScale());
|
doc->SetAttribute(tag, AttrAScale, curve->GetApproximationScale());
|
||||||
|
doc->SetAttributeOrRemoveIf(tag, AttrAlias, curve->GetAliasSuffix(), curve->GetAliasSuffix().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -494,6 +495,21 @@ quint32 VAbstractSpline::GetDuplicate() const
|
||||||
return VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id)->GetDuplicate();
|
return VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id)->GetDuplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VAbstractSpline::GetAliasSuffix() const
|
||||||
|
{
|
||||||
|
return ObjectAliasSuffix<VAbstractCurve>(m_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VAbstractSpline::SetAliasSuffix(const QString &alias)
|
||||||
|
{
|
||||||
|
QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id);
|
||||||
|
curve->SetAliasSuffix(alias);
|
||||||
|
QSharedPointer<VGObject> obj = qSharedPointerCast<VGObject>(curve);
|
||||||
|
SaveOption(obj);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VAbstractSpline::GroupVisibility(quint32 object, bool visible)
|
void VAbstractSpline::GroupVisibility(quint32 object, bool visible)
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,6 +66,7 @@ struct VAbstractSplineInitData : VDrawToolInitData
|
||||||
QString color;
|
QString color;
|
||||||
QString penStyle;
|
QString penStyle;
|
||||||
qreal approximationScale;
|
qreal approximationScale;
|
||||||
|
QString aliasSuffix{};
|
||||||
};
|
};
|
||||||
|
|
||||||
class VAbstractSpline:public VDrawTool, public QGraphicsPathItem
|
class VAbstractSpline:public VDrawTool, public QGraphicsPathItem
|
||||||
|
@ -95,13 +96,16 @@ public:
|
||||||
|
|
||||||
quint32 GetDuplicate() const;
|
quint32 GetDuplicate() const;
|
||||||
|
|
||||||
|
QString GetAliasSuffix() const;
|
||||||
|
void SetAliasSuffix(const QString &alias);
|
||||||
|
|
||||||
virtual void GroupVisibility(quint32 object, bool visible) override;
|
virtual void GroupVisibility(quint32 object, bool visible) override;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile () override;
|
virtual void FullUpdateFromFile () override;
|
||||||
virtual void Disable(bool disable, const QString &namePP) override;
|
virtual void Disable(bool disable, const QString &namePP) override;
|
||||||
virtual void DetailsMode(bool mode) override;
|
virtual void DetailsMode(bool mode) override;
|
||||||
virtual void AllowHover(bool enabled) override;
|
virtual void AllowHover(bool enabled) override;
|
||||||
virtual void AllowSelecting(bool enabled) override;
|
virtual void AllowSelecting(bool enabled) override;
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* @brief setEnabledPoint disable control points.
|
* @brief setEnabledPoint disable control points.
|
||||||
|
|
|
@ -91,6 +91,7 @@ void VToolArc::setDialog()
|
||||||
dialogTool->SetPenStyle(arc->GetPenStyle());
|
dialogTool->SetPenStyle(arc->GetPenStyle());
|
||||||
dialogTool->SetApproximationScale(arc->GetApproximationScale());
|
dialogTool->SetApproximationScale(arc->GetApproximationScale());
|
||||||
dialogTool->SetNotes(m_notes);
|
dialogTool->SetNotes(m_notes);
|
||||||
|
dialogTool->SetAliasSuffix(arc->GetAliasSuffix());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -122,6 +123,7 @@ VToolArc* VToolArc::Create(const QPointer<DialogTool> &dialog, VMainGraphicsScen
|
||||||
initData.typeCreation = Source::FromGui;
|
initData.typeCreation = Source::FromGui;
|
||||||
initData.approximationScale = dialogTool->GetApproximationScale();
|
initData.approximationScale = dialogTool->GetApproximationScale();
|
||||||
initData.notes = dialogTool->GetNotes();
|
initData.notes = dialogTool->GetNotes();
|
||||||
|
initData.aliasSuffix = dialogTool->GetAliasSuffix();
|
||||||
|
|
||||||
VToolArc* point = Create(initData);
|
VToolArc* point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
|
@ -150,6 +152,7 @@ VToolArc* VToolArc::Create(VToolArcInitData &initData)
|
||||||
arc->SetColor(initData.color);
|
arc->SetColor(initData.color);
|
||||||
arc->SetPenStyle(initData.penStyle);
|
arc->SetPenStyle(initData.penStyle);
|
||||||
arc->SetApproximationScale(initData.approximationScale);
|
arc->SetApproximationScale(initData.approximationScale);
|
||||||
|
arc->SetAliasSuffix(initData.aliasSuffix);
|
||||||
|
|
||||||
if (initData.typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
|
@ -338,6 +341,8 @@ void VToolArc::SaveDialog(QDomElement &domElement, QList<quint32> &oldDependenci
|
||||||
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
|
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
|
||||||
doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle());
|
doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle());
|
||||||
doc->SetAttribute(domElement, AttrAScale, dialogTool->GetApproximationScale());
|
doc->SetAttribute(domElement, AttrAScale, dialogTool->GetApproximationScale());
|
||||||
|
doc->SetAttributeOrRemoveIf(domElement, AttrAlias, dialogTool->GetAliasSuffix(),
|
||||||
|
dialogTool->GetAliasSuffix().isEmpty());
|
||||||
|
|
||||||
const QString notes = dialogTool->GetNotes();
|
const QString notes = dialogTool->GetNotes();
|
||||||
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
||||||
|
@ -398,6 +403,6 @@ QString VToolArc::MakeToolTip() const
|
||||||
.arg(arc->GetStartAngle())
|
.arg(arc->GetStartAngle())
|
||||||
.arg(tr("End angle"))
|
.arg(tr("End angle"))
|
||||||
.arg(arc->GetEndAngle())
|
.arg(arc->GetEndAngle())
|
||||||
.arg(tr("Label"), arc->name());
|
.arg(tr("Label"), arc->ObjectName());
|
||||||
return toolTip;
|
return toolTip;
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,6 +138,9 @@ protected:
|
||||||
template <class T>
|
template <class T>
|
||||||
QString ObjectName(quint32 id) const;
|
QString ObjectName(quint32 id) const;
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
QString ObjectAliasSuffix(quint32 id) const;
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
static void InitDrawToolConnections(VMainGraphicsScene *scene, T *tool);
|
static void InitDrawToolConnections(VMainGraphicsScene *scene, T *tool);
|
||||||
private:
|
private:
|
||||||
|
@ -357,14 +360,35 @@ QString VDrawTool::ObjectName(quint32 id) const
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return data.GeometricObject<T>(id)->name();
|
return data.GeometricObject<T>(id)->ObjectName();
|
||||||
}
|
}
|
||||||
catch (const VExceptionBadId &e)
|
catch (const VExceptionBadId &e)
|
||||||
{
|
{
|
||||||
qCDebug(vTool, "Error! Couldn't get object name by id = %s. %s %s", qUtf8Printable(QString().setNum(id)),
|
qCDebug(vTool, "Error! Couldn't get object name by id = %s. %s %s", qUtf8Printable(QString().setNum(id)),
|
||||||
qUtf8Printable(e.ErrorMessage()),
|
qUtf8Printable(e.ErrorMessage()),
|
||||||
qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.DetailedInformation()));
|
||||||
return QString(QString());// Return empty string for property browser
|
return QString();// Return empty string for property browser
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
template <class T>
|
||||||
|
/**
|
||||||
|
* @brief ObjectAlias get object (point, curve, arc) alias.
|
||||||
|
* @param id object id in container.
|
||||||
|
*/
|
||||||
|
QString VDrawTool::ObjectAliasSuffix(quint32 id) const
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return data.GeometricObject<T>(id)->GetAliasSuffix();
|
||||||
|
}
|
||||||
|
catch (const VExceptionBadId &e)
|
||||||
|
{
|
||||||
|
qCDebug(vTool, "Error! Couldn't get object alias suffix by id = %s. %s %s", qUtf8Printable(QString().setNum(id)),
|
||||||
|
qUtf8Printable(e.ErrorMessage()),
|
||||||
|
qUtf8Printable(e.DetailedInformation()));
|
||||||
|
return QString();// Return empty string for property browser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user