Updated property dialog for tool Spline.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-02-27 12:28:15 +02:00
parent 53cb607f34
commit a2561bc7da
4 changed files with 157 additions and 13 deletions

View file

@ -1298,20 +1298,52 @@ void VToolOptionsPropertyBrowser::ChangeDataToolSpline(VProperty *property)
QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole); QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole);
const QString id = propertyToId[property]; const QString id = propertyToId[property];
VToolSpline *i = qgraphicsitem_cast<VToolSpline *>(currentItem); auto i = qgraphicsitem_cast<VToolSpline *>(currentItem);
SCASSERT(i != nullptr); SCASSERT(i != nullptr);
VSpline spl = i->getSpline();
const VFormula f = value.value<VFormula>();
switch (PropertiesList().indexOf(id)) switch (PropertiesList().indexOf(id))
{ {
case 0: // AttrName case 0: // AttrName
Q_UNREACHABLE();//The attribute is read only Q_UNREACHABLE();//The attribute is read only
break; break;
case 25: // AttrKCurve case 9: // AttrAngle1
{ if (not f.error())
VSpline spl = i->getSpline(); {
spl.SetKcurve(value.toDouble()); spl.SetStartAngle(f.getDoubleValue(), f.GetFormula(FormulaType::FromUser));
i->setSpline(spl); i->setSpline(spl);
}
break;
case 10: // AttrAngle2
if (not f.error())
{
spl.SetEndAngle(f.getDoubleValue(), f.GetFormula(FormulaType::FromUser));
i->setSpline(spl);
}
break;
case 36: // AttrLength1
if (not f.error() && f.getDoubleValue() >= 0)
{
spl.SetC1Length(qApp->toPixel(f.getDoubleValue()), f.GetFormula(FormulaType::FromUser));
i->setSpline(spl);
}
break;
case 37: // AttrLength2
if (not f.error() && f.getDoubleValue() >= 0)
{
spl.SetC2Length(qApp->toPixel(f.getDoubleValue()), f.GetFormula(FormulaType::FromUser));
i->setSpline(spl);
}
break;
case 25: // AttrKCurve
if (value.toDouble() > 0)
{
spl.SetKcurve(value.toDouble());
i->setSpline(spl);
}
break; break;
}
case 27: // AttrTypeColor case 27: // AttrTypeColor
i->SetLineColor(value.toString()); i->SetLineColor(value.toString());
break; break;
@ -1709,14 +1741,39 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *it
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item)
{ {
VToolSpline *i = qgraphicsitem_cast<VToolSpline *>(item); auto i = qgraphicsitem_cast<VToolSpline *>(item);
i->ShowVisualization(true); i->ShowVisualization(true);
formView->setTitle(tr("Curve tool")); formView->setTitle(tr("Curve tool"));
const auto spl = i->getSpline();
AddPropertyObjectName(i, tr("Name"), true); AddPropertyObjectName(i, tr("Name"), true);
VDoubleProperty* itemFactor = new VDoubleProperty(tr("Curve factor")); VFormula angle1(spl.GetStartAngleFormula(), i->getData());
VSpline spl = i->getSpline(); angle1.setCheckZero(false);
angle1.setToolId(i->getId());
angle1.setPostfix(degreeSymbol);
AddPropertyFormula(tr("C1: angle"), angle1, AttrAngle1);
VFormula length1(spl.GetC1LengthFormula(), i->getData());
length1.setCheckZero(false);
length1.setToolId(i->getId());
length1.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit()));
AddPropertyFormula(tr("C1: length"), length1, AttrLength1);
VFormula angle2(spl.GetEndAngleFormula(), i->getData());
angle2.setCheckZero(false);
angle2.setToolId(i->getId());
angle2.setPostfix(degreeSymbol);
AddPropertyFormula(tr("C2: angle"), angle2, AttrAngle2);
VFormula length2(spl.GetC2LengthFormula(), i->getData());
length2.setCheckZero(false);
length2.setToolId(i->getId());
length2.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit()));
AddPropertyFormula(tr("C2: length"), length2, AttrLength2);
auto itemFactor = new VDoubleProperty(tr("Curve factor"));
itemFactor->setSetting("Min", 0.1); itemFactor->setSetting("Min", 0.1);
itemFactor->setSetting("Max", 1000); itemFactor->setSetting("Max", 1000);
itemFactor->setSetting("Step", 0.01); itemFactor->setSetting("Step", 0.01);
@ -2124,9 +2181,43 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint()
void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline() void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline()
{ {
auto i = qgraphicsitem_cast<VToolSpline *>(currentItem); auto i = qgraphicsitem_cast<VToolSpline *>(currentItem);
const VSpline spl = i->getSpline();
idToProperty[AttrName]->setValue(i->name()); idToProperty[AttrName]->setValue(i->name());
idToProperty[AttrKCurve]->setValue(i->getSpline().GetKcurve());
VFormula angle1F(spl.GetStartAngleFormula(), i->getData());
angle1F.setCheckZero(false);
angle1F.setToolId(i->getId());
angle1F.setPostfix(degreeSymbol);
QVariant angle1;
angle1.setValue(angle1F);
idToProperty[AttrAngle1]->setValue(angle1);
VFormula length1F(spl.GetC1LengthFormula(), i->getData());
length1F.setCheckZero(false);
length1F.setToolId(i->getId());
length1F.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit()));
QVariant length1;
length1.setValue(length1F);
idToProperty[AttrLength1]->setValue(length1);
VFormula angle2F(spl.GetEndAngleFormula(), i->getData());
angle2F.setCheckZero(false);
angle2F.setToolId(i->getId());
angle2F.setPostfix(degreeSymbol);
QVariant angle2;
angle2.setValue(angle2F);
idToProperty[AttrAngle2]->setValue(angle2);
VFormula length2F(spl.GetC2LengthFormula(), i->getData());
length2F.setCheckZero(false);
length2F.setToolId(i->getId());
length2F.setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit()));
QVariant length2;
length2.setValue(length2F);
idToProperty[AttrLength2]->setValue(length2);
idToProperty[AttrKCurve]->setValue(spl.GetKcurve());
idToProperty[AttrColor]->setValue(VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor())); idToProperty[AttrColor]->setValue(VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()));
} }
@ -2228,6 +2319,8 @@ QStringList VToolOptionsPropertyBrowser::PropertiesList() const
<< AttrName1 /* 32 */ << AttrName1 /* 32 */
<< AttrName2 /* 33 */ << AttrName2 /* 33 */
<< AttrVCrossPoint /* 34 */ << AttrVCrossPoint /* 34 */
<< AttrHCrossPoint; /* 35 */ << AttrHCrossPoint /* 35 */
<< AttrLength1 /* 36 */
<< AttrLength2; /* 37 */
return attr; return attr;
} }

View file

@ -689,6 +689,12 @@ VPointF VSpline::GetP1() const
return d->p1; return d->p1;
} }
//---------------------------------------------------------------------------------------------------------------------
void VSpline::SetP1(const VPointF &p)
{
d->p1 = p;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief GetP2 return first control point. * @brief GetP2 return first control point.
@ -723,6 +729,12 @@ VPointF VSpline::GetP4() const
return d->p4; return d->p4;
} }
//---------------------------------------------------------------------------------------------------------------------
void VSpline::SetP4(const VPointF &p)
{
d->p4 = p;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief GetAngle1 return first angle control line. * @brief GetAngle1 return first angle control line.
@ -755,6 +767,20 @@ QString VSpline::GetEndAngleFormula() const
return d->angle2F; return d->angle2F;
} }
//---------------------------------------------------------------------------------------------------------------------
void VSpline::SetStartAngle(qreal angle, const QString &formula)
{
d->angle1 = angle;
d->angle1F = formula;
}
//---------------------------------------------------------------------------------------------------------------------
void VSpline::SetEndAngle(qreal angle, const QString &formula)
{
d->angle2 = angle;
d->angle2F = formula;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VSpline::GetC1Length() const qreal VSpline::GetC1Length() const
{ {
@ -779,6 +805,20 @@ QString VSpline::GetC2LengthFormula() const
return d->c2LengthF; return d->c2LengthF;
} }
//---------------------------------------------------------------------------------------------------------------------
void VSpline::SetC1Length(qreal length, const QString &formula)
{
d->c1Length = length;
d->c1LengthF = formula;
}
//---------------------------------------------------------------------------------------------------------------------
void VSpline::SetC2Length(qreal length, const QString &formula)
{
d->c2Length = length;
d->c2LengthF = formula;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief GetKasm1 return coefficient of length first control line. * @brief GetKasm1 return coefficient of length first control line.

View file

@ -56,10 +56,15 @@ public:
const QString &c2LengthFormula, qreal kCurve, quint32 idObject = 0, Draw mode = Draw::Calculation); const QString &c2LengthFormula, qreal kCurve, quint32 idObject = 0, Draw mode = Draw::Calculation);
virtual ~VSpline() Q_DECL_OVERRIDE; virtual ~VSpline() Q_DECL_OVERRIDE;
VSpline &operator=(const VSpline &spl); VSpline &operator=(const VSpline &spl);
VPointF GetP1 () const; VPointF GetP1 () const;
void SetP1 (const VPointF &p);
QPointF GetP2 () const; QPointF GetP2 () const;
QPointF GetP3 () const; QPointF GetP3 () const;
VPointF GetP4 () const; VPointF GetP4 () const;
void SetP4 (const VPointF &p);
virtual qreal GetStartAngle () const Q_DECL_OVERRIDE; virtual qreal GetStartAngle () const Q_DECL_OVERRIDE;
virtual qreal GetEndAngle() const Q_DECL_OVERRIDE; virtual qreal GetEndAngle() const Q_DECL_OVERRIDE;
@ -67,12 +72,18 @@ public:
QString GetStartAngleFormula () const; QString GetStartAngleFormula () const;
QString GetEndAngleFormula() const; QString GetEndAngleFormula() const;
void SetStartAngle(qreal angle, const QString &formula);
void SetEndAngle(qreal angle, const QString &formula);
qreal GetC1Length() const; qreal GetC1Length() const;
qreal GetC2Length() const; qreal GetC2Length() const;
QString GetC1LengthFormula() const; QString GetC1LengthFormula() const;
QString GetC2LengthFormula() const; QString GetC2LengthFormula() const;
void SetC1Length(qreal length, const QString &formula);
void SetC2Length(qreal length, const QString &formula);
qreal GetLength () const; qreal GetLength () const;
qreal GetKasm1() const; qreal GetKasm1() const;
qreal GetKasm2() const; qreal GetKasm2() const;

View file

@ -221,7 +221,7 @@ VToolSpline *VToolSpline::Create(const quint32 _id, quint32 point1, quint32 poin
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSpline VToolSpline::getSpline() const VSpline VToolSpline::getSpline() const
{ {
QSharedPointer<VSpline> spline = VAbstractTool::data.GeometricObject<VSpline>(id); auto spline = VAbstractTool::data.GeometricObject<VSpline>(id);
return *spline.data(); return *spline.data();
} }