From f59009c5fc75d033862d9ea04b9186f2fec55e6c Mon Sep 17 00:00:00 2001 From: dismine Date: Wed, 3 Sep 2014 14:10:51 +0300 Subject: [PATCH] Show lite tool options in options browser. --HG-- branch : feature --- src/app/geometry/vspline.cpp | 9 + src/app/geometry/vspline.h | 1 + src/app/geometry/vspline_p.h | 2 +- src/app/geometry/vsplinepath.cpp | 5 +- src/app/options.h | 2 +- src/app/tools/drawTools/vtoolcut.cpp | 3 + src/app/tools/drawTools/vtoolsplinepath.cpp | 1 + .../widgets/vtooloptionspropertybrowser.cpp | 576 ++++++++++++++++-- src/app/widgets/vtooloptionspropertybrowser.h | 5 +- .../plugins/vnumberproperty.cpp | 77 ++- .../plugins/vnumberproperty.h | 6 +- 11 files changed, 582 insertions(+), 105 deletions(-) diff --git a/src/app/geometry/vspline.cpp b/src/app/geometry/vspline.cpp index 09f9bc161..978ceec63 100644 --- a/src/app/geometry/vspline.cpp +++ b/src/app/geometry/vspline.cpp @@ -750,3 +750,12 @@ qreal VSpline::GetKcurve() const { return d->kCurve; } + +//--------------------------------------------------------------------------------------------------------------------- +void VSpline::SetKcurve(qreal factor) +{ + if (factor > 0) + { + d->kCurve = factor; + } +} diff --git a/src/app/geometry/vspline.h b/src/app/geometry/vspline.h index 48f724613..c70a84b03 100644 --- a/src/app/geometry/vspline.h +++ b/src/app/geometry/vspline.h @@ -63,6 +63,7 @@ public: qreal GetKasm1() const; qreal GetKasm2() const; qreal GetKcurve() const; + void SetKcurve(qreal factor); // cppcheck-suppress unusedFunction QLineF::IntersectType CrossingSplLine(const QLineF &line, QPointF *intersectionPoint ) const; qreal LengthT(qreal t) const; diff --git a/src/app/geometry/vspline_p.h b/src/app/geometry/vspline_p.h index d91951474..49863caaa 100644 --- a/src/app/geometry/vspline_p.h +++ b/src/app/geometry/vspline_p.h @@ -48,7 +48,7 @@ public: VSplineData ( const VSplineData &spline ) :QSharedData(spline), p1(spline.p1), p2(spline.p2), p3(spline.p3), p4(spline.p4), angle1(spline.angle1), - angle2(spline.angle2), kAsm1(spline.angle2), kAsm2(spline.kAsm1), kCurve(spline.kCurve) + angle2(spline.angle2), kAsm1(spline.kAsm1), kAsm2(spline.kAsm2), kCurve(spline.kCurve) {} VSplineData (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve) diff --git a/src/app/geometry/vsplinepath.cpp b/src/app/geometry/vsplinepath.cpp index 98d99ffd1..4fa7736d9 100644 --- a/src/app/geometry/vsplinepath.cpp +++ b/src/app/geometry/vsplinepath.cpp @@ -258,7 +258,10 @@ qreal VSplinePath::getKCurve() const //--------------------------------------------------------------------------------------------------------------------- void VSplinePath::setKCurve(const qreal &value) { - d->kCurve = value; + if (value > 0) + { + d->kCurve = value; + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/options.h b/src/app/options.h index 364068ddf..d2de5312e 100644 --- a/src/app/options.h +++ b/src/app/options.h @@ -79,7 +79,7 @@ enum class Tool : unsigned char enum class Vis : unsigned char { - ControlPointSpline, + ControlPointSpline = 29, // increase this value if need more positions in Tool enum GraphicsSimpleTextItem, Line, Path, diff --git a/src/app/tools/drawTools/vtoolcut.cpp b/src/app/tools/drawTools/vtoolcut.cpp index 1a870021c..984cf2729 100644 --- a/src/app/tools/drawTools/vtoolcut.cpp +++ b/src/app/tools/drawTools/vtoolcut.cpp @@ -118,6 +118,9 @@ void VToolCut::setFormula(const VFormula &value) if (value.error() == false) { formula = value.getFormula(FormulaType::FromUser); + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); } } diff --git a/src/app/tools/drawTools/vtoolsplinepath.cpp b/src/app/tools/drawTools/vtoolsplinepath.cpp index 5521027c4..f63b1e836 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolsplinepath.cpp @@ -365,6 +365,7 @@ void VToolSplinePath::SaveOptions(QDomElement &tag, QSharedPointer &ob doc->SetAttribute(tag, AttrType, ToolType); doc->SetAttribute(tag, AttrKCurve, splPath->getKCurve()); + doc->RemoveAllChild(tag); for (qint32 i = 0; i < splPath->CountPoint(); ++i) { AddPathPoint(tag, splPath->at(i)); diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp index bd3fda554..614a80ba2 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.cpp +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -49,12 +49,12 @@ VToolOptionsPropertyBrowser::VToolOptionsPropertyBrowser(QDockWidget *parent) idToProperty(QMap()) { PropertyModel = new VPropertyModel(this); - TreeView = new VPropertyFormView(PropertyModel, parent); - TreeView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + formView = new VPropertyFormView(PropertyModel, parent); + formView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QScrollArea *scroll = new QScrollArea(parent); scroll->setWidgetResizable(true); - scroll->setWidget(TreeView); + scroll->setWidget(formView); parent->setWidget(scroll); @@ -128,6 +128,10 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item) currentItem = item->parentItem(); ShowItemOptions(currentItem); break; + case VSimpleCurve::Type: + currentItem = item->parentItem(); + ShowItemOptions(currentItem); + break; default: break; } @@ -308,7 +312,6 @@ void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item) if (currentItem == nullptr) { - TreeView->setTitle(""); return; } @@ -333,26 +336,18 @@ void VToolOptionsPropertyBrowser::AddPropertyPointName(Tool *i, const QString &p AddProperty(itemName, VAbstractTool::AttrName); } -//--------------------------------------------------------------------------------------------------------------------- -template -void VToolOptionsPropertyBrowser::AddPropertyPointsList(Tool *i, const QString &propertyName, const quint32 &value, - const QString &attrName) -{ - VObjectProperty *pointsProperty = new VObjectProperty(propertyName); - QMap pointsList = i->PointsList(); - pointsProperty->setObjectsList(pointsList); - pointsProperty->setValue(value); - AddProperty(pointsProperty, attrName); -} - //--------------------------------------------------------------------------------------------------------------------- template void VToolOptionsPropertyBrowser::AddPropertyLineType(Tool *i, const QString &propertyName) { VEnumProperty *lineTypeProperty = new VEnumProperty(propertyName); - lineTypeProperty->setLiterals(VAbstractTool::Styles()); QStringList styles = VAbstractTool::Styles(); + lineTypeProperty->setLiterals(styles); qint32 index = styles.indexOf(i->getLineType()); + if (index == -1) + { + qWarning()<<"Can't find line style" << i->getLineType()<<"in list"; + } lineTypeProperty->setValue(index); AddProperty(lineTypeProperty, VAbstractTool::AttrTypeLine); } @@ -429,9 +424,6 @@ void VToolOptionsPropertyBrowser::ChangeDataToolEndLine(VProperty *property) case 0: // VAbstractTool::AttrName SetPointName(value.toString()); break; - case 2: // VAbstractTool::AttrBasePoint - i->setBasePointId(value.toUInt()); - break; case 3: // VAbstractTool::AttrTypeLine i->setTypeLine(value.toString()); break; @@ -460,13 +452,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolAlongLine(VProperty *property) switch (PropertiesList().indexOf(id)) { case 0: // VAbstractTool::AttrName - SetPointName(value.toString()); - break; - case 6: // VAbstractTool::AttrFirstPoint - i->setBasePointId(value.toUInt()); - break; - case 7: // VAbstractTool::AttrSecondPoint - i->setSecondPointId(value.toUInt()); + SetPointName(value.toString()); break; case 3: // VAbstractTool::AttrTypeLine i->setTypeLine(value.toString()); @@ -483,100 +469,375 @@ void VToolOptionsPropertyBrowser::ChangeDataToolAlongLine(VProperty *property) //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ChangeDataToolArc(VProperty *property) { + SCASSERT(property != nullptr) + QVariant value = property->data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolArc *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 8: // VAbstractTool::AttrRadius + i->setFormulaRadius(value.value()); + break; + case 9: // VAbstractTool::AttrAngle1 + i->setFormulaF1(value.value()); + break; + case 10: // VAbstractTool::AttrAngle2 + i->setFormulaF2(value.value()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolBisector *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 4: // VAbstractTool::AttrLength + i->setFormulaLength(value.value()); + break; + case 3: // VAbstractTool::AttrTypeLine + i->setTypeLine(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolCutArc *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 4: // VAbstractTool::AttrLength + i->setFormula(value.value()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolCutSpline *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 4: // VAbstractTool::AttrLength + i->setFormula(value.value()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolCutSplinePath *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 4: // VAbstractTool::AttrLength + i->setFormula(value.value()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolHeight *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 3: // VAbstractTool::AttrTypeLine + i->setTypeLine(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolLine *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 3: // VAbstractTool::AttrTypeLine + i->setTypeLine(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolLineIntersect *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolNormal *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 4: // VAbstractTool::AttrLength + i->setFormulaLength(value.value()); + break; + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 22: // VAbstractTool::AttrAngle + i->setAngle(value.toDouble()); + break; + case 3: // VAbstractTool::AttrTypeLine + i->setTypeLine(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolPointOfContact *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 8: // VAbstractTool::AttrRadius + i->setArcRadius(value.value()); + break; + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolPointOfIntersection *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolShoulderPoint *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 4: // VAbstractTool::AttrLength + i->setFormulaLength(value.value()); + break; + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + case 3: // VAbstractTool::AttrTypeLine + i->setTypeLine(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolSpline *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 26: // VAbstractTool::AttrKCurve + { + VSpline spl = i->getSpline(); + spl.SetKcurve(value.toDouble()); + i->setSpline(spl); + break; + } + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolSplinePath *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 26: // VAbstractTool::AttrKCurve + { + VSplinePath splPath = i->getSplinePath(); + splPath.setKCurve(value.toDouble()); + i->setSplinePath(splPath); + break; + } + default: + qWarning()<<"Unknown property type. id = "<data(VProperty::DPC_Data, Qt::DisplayRole); + const QString id = propertyToId[property]; + + VToolTriangle *i = qgraphicsitem_cast(currentItem); + SCASSERT(i != nullptr); + switch (PropertiesList().indexOf(id)) + { + case 0: // VAbstractTool::AttrName + SetPointName(value.toString()); + break; + default: + qWarning()<<"Unknown property type. id = "<(item); - TreeView->setTitle(tr("Base point")); + formView->setTitle(tr("Base point")); - AddPropertyPointName(i, tr("Point name")); + AddPropertyPointName(i, tr("Point label")); VPointFProperty* itemPosition = new VPointFProperty(tr("Position")); itemPosition->setValue(i->pos()); @@ -587,10 +848,9 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSinglePoint(QGraphicsItem *item void VToolOptionsPropertyBrowser::ShowOptionsToolEndLine(QGraphicsItem *item) { VToolEndLine *i = qgraphicsitem_cast(item); - TreeView->setTitle(tr("Point at distance and angle")); + formView->setTitle(tr("Point at distance and angle")); - AddPropertyPointName(i, tr("Point name")); - AddPropertyPointsList(i, tr("Base point"), i->getBasePointId(), VAbstractTool::AttrBasePoint); + AddPropertyPointName(i, tr("Point label")); AddPropertyLineType(i, tr("Line type")); AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); AddPropertyFormula(tr("Angle"), i->getFormulaAngle(), VAbstractTool::AttrAngle); @@ -600,11 +860,9 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolEndLine(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolAlongLine(QGraphicsItem *item) { VToolAlongLine *i = qgraphicsitem_cast(item); - TreeView->setTitle(tr("Point at distance along line")); + formView->setTitle(tr("Point at distance along line")); - AddPropertyPointName(i, tr("Point name")); - AddPropertyPointsList(i, tr("First point"), i->getBasePointId(), VAbstractTool::AttrFirstPoint); - AddPropertyPointsList(i, tr("Second point"), i->getSecondPointId(), VAbstractTool::AttrSecondPoint); + AddPropertyPointName(i, tr("Point label")); AddPropertyLineType(i, tr("Line type")); AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); } @@ -613,231 +871,423 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolAlongLine(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolArc(QGraphicsItem *item) { VToolArc *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Arc")); + + AddPropertyFormula(tr("Radius"), i->getFormulaRadius(), VAbstractTool::AttrRadius); + AddPropertyFormula(tr("First angle"), i->getFormulaF1(), VAbstractTool::AttrAngle1); + AddPropertyFormula(tr("Second angle"), i->getFormulaF2(), VAbstractTool::AttrAngle2); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolBisector(QGraphicsItem *item) { VToolBisector *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Point along bisector")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyLineType(i, tr("Line type")); + AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolCutArc(QGraphicsItem *item) { VToolCutArc *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Cut arc tool")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyFormula(tr("Length"), i->getFormula(), VAbstractTool::AttrLength); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolCutSpline(QGraphicsItem *item) { VToolCutSpline *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Tool for segmenting a curve")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyFormula(tr("Length"), i->getFormula(), VAbstractTool::AttrLength); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolCutSplinePath(QGraphicsItem *item) { VToolCutSplinePath *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Tool segment a pathed curve")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyFormula(tr("Length"), i->getFormula(), VAbstractTool::AttrLength); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolHeight(QGraphicsItem *item) { VToolHeight *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Perpendicular point along line")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyLineType(i, tr("Line type")); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolLine(QGraphicsItem *item) { VToolLine *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Line between points")); + + AddPropertyLineType(i, tr("Line type")); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolLineIntersect(QGraphicsItem *item) { VToolLineIntersect *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Point at line intersection")); + + AddPropertyPointName(i, tr("Point label")); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolNormal(QGraphicsItem *item) { VToolNormal *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Point along perpendicular")); + + AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); + AddPropertyPointName(i, tr("Point label")); + AddPropertyLineType(i, tr("Line type")); + + VDoubleProperty* itemAngle = new VDoubleProperty(tr("Additional angle degrees")); + itemAngle->setValue(i->getAngle()); + itemAngle->setSetting("Min", 0); + itemAngle->setSetting("Max", 360); + itemAngle->setSetting("Precision", 3); + AddProperty(itemAngle, VAbstractTool::AttrAngle); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfContact(QGraphicsItem *item) { VToolPointOfContact *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Point at intersection of arc and line")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyFormula(tr("Radius"), i->getArcRadius(), VAbstractTool::AttrRadius); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersection(QGraphicsItem *item) { VToolPointOfIntersection *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Tool to make point from x & y of two other points")); + + AddPropertyPointName(i, tr("Point label")); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *item) { VToolShoulderPoint *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Special point on shoulder")); + + AddPropertyPointName(i, tr("Point label")); + AddPropertyLineType(i, tr("Line type")); + AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item) { VToolSpline *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Curve tool")); + + VDoubleProperty* itemFactor = new VDoubleProperty(tr("Curve factor")); + VSpline spl = i->getSpline(); + itemFactor->setSetting("Min", 0.1); + itemFactor->setSetting("Max", 1000); + itemFactor->setSetting("Step", 0.01); + itemFactor->setSetting("Precision", 3); + itemFactor->setValue(spl.GetKcurve()); + AddProperty(itemFactor, VAbstractTool::AttrKCurve); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolSplinePath(QGraphicsItem *item) { VToolSplinePath *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Tool for path curve")); + + VDoubleProperty* itemFactor = new VDoubleProperty(tr("Curve factor")); + VSplinePath splPath = i->getSplinePath(); + itemFactor->setSetting("Min", 0.1); + itemFactor->setSetting("Max", 1000); + itemFactor->setSetting("Step", 0.01); + itemFactor->setSetting("Precision", 3); + itemFactor->setValue(splPath.getKCurve()); + AddProperty(itemFactor, VAbstractTool::AttrKCurve); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::ShowOptionsToolTriangle(QGraphicsItem *item) { VToolTriangle *i = qgraphicsitem_cast(item); + formView->setTitle(tr("Tool triangle")); + + AddPropertyPointName(i, tr("Point label")); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolSinglePoint() { VToolSinglePoint *i = qgraphicsitem_cast(currentItem); - TreeView->setTitle(tr("Base point")); - - AddPropertyPointName(i, tr("Point name")); - - VPointFProperty* itemPosition = new VPointFProperty(tr("Position")); - itemPosition->setValue(i->pos()); - AddProperty(itemPosition, QLatin1String("position")); + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + idToProperty[QLatin1String("position")]->setValue(i->pos()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolEndLine() { VToolEndLine *i = qgraphicsitem_cast(currentItem); - TreeView->setTitle(tr("Point at distance and angle")); + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); - AddPropertyPointName(i, tr("Point name")); - AddPropertyPointsList(i, tr("Base point"), i->getBasePointId(), VAbstractTool::AttrBasePoint); - AddPropertyLineType(i, tr("Line type")); - AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); - AddPropertyFormula(tr("Angle"), i->getFormulaAngle(), VAbstractTool::AttrAngle); + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + + QVariant valueFormula; + valueFormula.setValue(i->getFormulaLength()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); + + QVariant valueAngle; + valueAngle.setValue(i->getFormulaAngle()); + idToProperty[VAbstractTool::AttrAngle]->setValue(valueAngle); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolAlongLine() { VToolAlongLine *i = qgraphicsitem_cast(currentItem); - TreeView->setTitle(tr("Point at distance along line")); + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); - AddPropertyPointName(i, tr("Point name")); - AddPropertyPointsList(i, tr("First point"), i->getBasePointId(), VAbstractTool::AttrFirstPoint); - AddPropertyPointsList(i, tr("Second point"), i->getSecondPointId(), VAbstractTool::AttrSecondPoint); - AddPropertyLineType(i, tr("Line type")); - AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + + QVariant valueFormula; + valueFormula.setValue(i->getFormulaLength()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolArc() { VToolArc *i = qgraphicsitem_cast(currentItem); + + + QVariant valueRadius; + valueRadius.setValue(i->getFormulaRadius()); + idToProperty[VAbstractTool::AttrRadius]->setValue(valueRadius); + + QVariant valueFirstAngle; + valueFirstAngle.setValue(i->getFormulaF1()); + idToProperty[VAbstractTool::AttrAngle1]->setValue(valueFirstAngle); + + QVariant valueSecondAngle; + valueSecondAngle.setValue(i->getFormulaF2()); + idToProperty[VAbstractTool::AttrAngle2]->setValue(valueSecondAngle); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolBisector() { VToolBisector *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QVariant valueFormula; + valueFormula.setValue(i->getFormulaLength()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); + + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolCutArc() { VToolCutArc *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QVariant valueFormula; + valueFormula.setValue(i->getFormula()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSpline() { VToolCutSpline *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QVariant valueFormula; + valueFormula.setValue(i->getFormula()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSplinePath() { VToolCutSplinePath *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QVariant valueFormula; + valueFormula.setValue(i->getFormula()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolHeight() { VToolHeight *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolLine() { VToolLine *i = qgraphicsitem_cast(currentItem); + + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolLineIntersect() { VToolLineIntersect *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolNormal() { VToolNormal *i = qgraphicsitem_cast(currentItem); + + QVariant valueFormula; + valueFormula.setValue(i->getFormulaLength()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + idToProperty[VAbstractTool::AttrAngle]->setValue( i->getAngle()); + + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfContact() { VToolPointOfContact *i = qgraphicsitem_cast(currentItem); + + QVariant valueFormula; + valueFormula.setValue(i->getArcRadius()); + idToProperty[VAbstractTool::AttrRadius]->setValue(valueFormula); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersection() { VToolPointOfIntersection *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint() { VToolShoulderPoint *i = qgraphicsitem_cast(currentItem); + + QVariant valueFormula; + valueFormula.setValue(i->getFormulaLength()); + idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + + QStringList styles = VAbstractTool::Styles(); + qint32 index = styles.indexOf(i->getLineType()); + idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline() { VToolSpline *i = qgraphicsitem_cast(currentItem); + + VSpline spl = i->getSpline(); + idToProperty[VAbstractTool::AttrKCurve]->setValue(spl.GetKcurve()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolSplinePath() { VToolSplinePath *i = qgraphicsitem_cast(currentItem); + + VSplinePath splPath = i->getSplinePath(); + idToProperty[VAbstractTool::AttrKCurve]->setValue(splPath.getKCurve()); } //--------------------------------------------------------------------------------------------------------------------- void VToolOptionsPropertyBrowser::UpdateOptionsToolTriangle() { VToolTriangle *i = qgraphicsitem_cast(currentItem); + + idToProperty[VAbstractTool::AttrName]->setValue(i->name()); } //--------------------------------------------------------------------------------------------------------------------- QStringList VToolOptionsPropertyBrowser::PropertiesList() const { - QStringList attr{VAbstractTool::AttrName, /* 0 */ - QLatin1String("position"), /* 1 */ - VAbstractTool::AttrBasePoint, /* 2 */ - VAbstractTool::AttrTypeLine, /* 3 */ - VAbstractTool::AttrLength, /* 4 */ - VAbstractTool::AttrAngle, /* 5 */ - VAbstractTool::AttrFirstPoint, /* 6 */ - VAbstractTool::AttrSecondPoint};/* 7 */ + QStringList attr{VAbstractTool::AttrName, /* 0 */ + QLatin1String("position"), /* 1 */ + VAbstractTool::AttrBasePoint, /* 2 */ + VAbstractTool::AttrTypeLine, /* 3 */ + VAbstractTool::AttrLength, /* 4 */ + VAbstractTool::AttrAngle, /* 5 */ + VAbstractTool::AttrFirstPoint, /* 6 */ + VAbstractTool::AttrSecondPoint, /* 7 */ + VAbstractTool::AttrRadius, /* 8 */ + VAbstractTool::AttrAngle1, /* 9 */ + VAbstractTool::AttrAngle2, /* 10 */ + VAbstractTool::AttrCenter, /* 11 */ + VAbstractTool::AttrThirdPoint, /* 12 */ + VToolCutArc::AttrArc, /* 13 */ + VToolCutSpline::AttrSpline, /* 14 */ + VToolCutSplinePath::AttrSplinePath, /* 15 */ + VAbstractTool::AttrP1Line, /* 16 */ + VAbstractTool::AttrP2Line, /* 17 */ + VAbstractTool::AttrP1Line1, /* 18 */ + VAbstractTool::AttrP2Line1, /* 19 */ + VAbstractTool::AttrP1Line2, /* 20 */ + VAbstractTool::AttrP2Line2, /* 21 */ + VAbstractTool::AttrAngle, /* 22 */ + VAbstractTool::AttrPShoulder, /* 23 */ + VAbstractTool::AttrAxisP1, /* 24 */ + VAbstractTool::AttrAxisP2, /* 25 */ + VAbstractTool::AttrKCurve}; /* 26 */ return attr; } diff --git a/src/app/widgets/vtooloptionspropertybrowser.h b/src/app/widgets/vtooloptionspropertybrowser.h index 5a6b57e81..fd7ad093d 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.h +++ b/src/app/widgets/vtooloptionspropertybrowser.h @@ -56,7 +56,7 @@ private: Q_DISABLE_COPY(VToolOptionsPropertyBrowser) VPropertyModel* PropertyModel; - VPropertyFormView* TreeView; + VPropertyFormView* formView; QGraphicsItem *currentItem; QMap propertyToId; @@ -71,9 +71,6 @@ private: template void AddPropertyPointName(Tool *i, const QString &propertyName); - template - void AddPropertyPointsList(Tool *i, const QString &propertyName, const quint32 &value, const QString &attrName); - template void AddPropertyLineType(Tool *i, const QString &propertyName); diff --git a/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp b/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp index f82c510aa..7ccae32b6 100644 --- a/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vnumberproperty.cpp @@ -14,7 +14,7 @@ const int VIntegerProperty::StandardMin = -1000000; const int VIntegerProperty::StandardMax = 1000000; VIntegerProperty::VIntegerProperty(const QString& name, const QMap& settings) - : VProperty(name, QVariant::Int), Min(StandardMin), Max(StandardMax) + : VProperty(name, QVariant::Int), min(StandardMin), max(StandardMax), singleStep(1.0) { VProperty::setSettings(settings); VProperty::d_ptr->VariantValue.setValue(0); @@ -22,7 +22,7 @@ VIntegerProperty::VIntegerProperty(const QString& name, const QMapVariantValue.setValue(0); VProperty::d_ptr->VariantValue.convert(QVariant::Int); @@ -35,8 +35,9 @@ QWidget* VIntegerProperty::createEditor(QWidget * parent, const QStyleOptionView Q_UNUSED(delegate); QSpinBox* tmpEditor = new QSpinBox(parent); - tmpEditor->setMinimum(Min); - tmpEditor->setMaximum(Max); + tmpEditor->setMinimum(min); + tmpEditor->setMaximum(max); + tmpEditor->setSingleStep(singleStep); tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); tmpEditor->setValue(VProperty::d_ptr->VariantValue.toInt()); connect(tmpEditor, static_cast(&QSpinBox::valueChanged), this, @@ -56,33 +57,38 @@ QVariant VIntegerProperty::getEditorData(QWidget* editor) const return QVariant(0); } -void VIntegerProperty::setSettings(int minimum, int maxiumum) +void VIntegerProperty::setSettings(int minimum, int maxiumum, int singleStep) { - Min = minimum; - Max = maxiumum; + min = minimum; + max = maxiumum; + this->singleStep = singleStep; } void VIntegerProperty::setSetting(const QString& key, const QVariant& value) { - if(key == "Min") - setSettings(value.toInt(), Max); - else if(key == "Max") - setSettings(Min, value.toInt()); + if(key == QLatin1String("Min")) + setSettings(value.toInt(), max); + else if(key == QLatin1String("Max")) + setSettings(min, value.toInt()); + else if(key == QLatin1String("Step")) + setSettings(singleStep, value.toInt()); } QVariant VIntegerProperty::getSetting(const QString& key) const { - if(key == "Min") - return Min; - if(key == "Max") - return Max; + if(key == QLatin1String("Min")) + return min; + if(key == QLatin1String("Max")) + return max; + if(key == QLatin1String("Step")) + return singleStep; else return VProperty::getSetting(key); } QStringList VIntegerProperty::getSettingKeys() const { - return (QStringList("Min") << "Max"); + return (QStringList("Min") << "Max" << "Step"); } QString VIntegerProperty::type() const @@ -131,9 +137,10 @@ QWidget* VDoubleProperty::createEditor(QWidget * parent, const QStyleOptionViewI Q_UNUSED(options); Q_UNUSED(delegate); QDoubleSpinBox* tmpEditor = new QDoubleSpinBox(parent); - tmpEditor->setMinimum(Min); - tmpEditor->setMaximum(Max); + tmpEditor->setMinimum(min); + tmpEditor->setMaximum(max); tmpEditor->setDecimals(Precision); + tmpEditor->setSingleStep(singleStep); tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); tmpEditor->setValue(VProperty::d_ptr->VariantValue.toDouble()); connect(tmpEditor, static_cast(&QDoubleSpinBox::valueChanged), this, @@ -153,29 +160,35 @@ QVariant VDoubleProperty::getEditorData(QWidget* editor) const return QVariant(0); } -void VDoubleProperty::setSettings(double minimum, double maxiumum, int precision) +void VDoubleProperty::setSettings(double minimum, double maxiumum, double singleStep, int precision) { - VIntegerProperty::setSettings(minimum, maxiumum); + min = minimum; + max = maxiumum; + this->singleStep = singleStep; Precision = precision; } void VDoubleProperty::setSetting(const QString& key, const QVariant& value) { - if(key == "Min") - setSettings(value.toDouble(), Max, Precision); - else if(key == "Max") - setSettings(Min, value.toDouble(), Precision); - else if(key == "Precision") - setSettings(Min, Max, value.toDouble()); + if(key == QLatin1String("Min")) + setSettings(value.toDouble(), max, singleStep, Precision); + else if(key == QLatin1String("Max")) + setSettings(min, value.toDouble(), singleStep, Precision); + else if(key == QLatin1String("Step")) + setSettings(min, max, value.toDouble(), Precision); + else if(key == QLatin1String("Precision")) + setSettings(min, max, singleStep, value.toDouble()); } QVariant VDoubleProperty::getSetting(const QString& key) const { - if(key == "Min") - return Min; - if(key == "Max") - return Max; - if(key == "Precision") + if(key == QLatin1String("Min")) + return min; + if(key == QLatin1String("Max")) + return max; + if(key == QLatin1String("Step")) + return singleStep; + if(key == QLatin1String("Precision")) return Precision; else return VProperty::getSetting(key); @@ -183,7 +196,7 @@ QVariant VDoubleProperty::getSetting(const QString& key) const QStringList VDoubleProperty::getSettingKeys() const { - return (QStringList("Min") << "Max" << "Precision"); + return (QStringList("Min") << "Max" << "Step" << "Precision"); } QString VDoubleProperty::type() const diff --git a/src/libs/vpropertyexplorer/plugins/vnumberproperty.h b/src/libs/vpropertyexplorer/plugins/vnumberproperty.h index b1fdbcafb..bef7000df 100644 --- a/src/libs/vpropertyexplorer/plugins/vnumberproperty.h +++ b/src/libs/vpropertyexplorer/plugins/vnumberproperty.h @@ -28,7 +28,7 @@ public: //! Sets the settings of a basic integer property //! \param minimum The minimum value //! \param maxiumum The maximum value - virtual void setSettings(int minimum, int maxiumum); + virtual void setSettings(int minimum, int maxiumum, int singleStep = 1.0); //! Sets the settings. Available settings: //! @@ -53,7 +53,7 @@ public: public slots: void valueChanged(int i); protected: - int Min, Max; + double min, max, singleStep; static const int StandardMin;// = -1000000; static const int StandardMax;// = 1000000; @@ -82,7 +82,7 @@ public: //! \param minimum The minimum value //! \param maxiumum The maximum value //! \param precision The number of decimal places - virtual void setSettings(double minimum, double maxiumum, int precision); + virtual void setSettings(double minimum, double maxiumum, double singleStep, int precision); //! Sets the settings. Available settings: //!