From: nds Date: Tue, 17 Mar 2015 13:22:17 +0000 (+0300) Subject: Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0 X-Git-Tag: V_1.1.0~122 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=eb0bc337423e37ed5bfbd9cbcb3c6ec183108c3b;hp=08069d25db8d7d1ac6012a316e68edecf0fb9fb3;p=modules%2Fshaper.git Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0 --- diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 335d5046d..b125a7be8 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -127,10 +127,8 @@ ModuleBase_WidgetShapeSelector::~ModuleBase_WidgetShapeSelector() //******************************************************************** bool ModuleBase_WidgetShapeSelector::storeValueCustom() const { - bool isStored = storeAttributeValues(mySelectedObject, myShape); - if (isStored) - updateObject(myFeature); - return isStored; + // the value is stored on the selection changed signal processing + return true; } //******************************************************************** @@ -193,27 +191,10 @@ void ModuleBase_WidgetShapeSelector::clearAttribute() //******************************************************************** bool ModuleBase_WidgetShapeSelector::restoreValue() { - DataPtr aData = myFeature->data(); bool isBlocked = this->blockSignals(true); - - AttributeSelectionPtr aSelect = aData->selection(attributeID()); - if (aSelect) { - mySelectedObject = aSelect->context(); - myShape = aSelect->value(); - } else { - AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID()); - if (aRefAttr) { - mySelectedObject = aRefAttr->object(); - } else { - AttributeReferencePtr aRef = aData->reference(attributeID()); - if (aRef) { - mySelectedObject = aRef->value(); - } - } - } updateSelectionName(); - this->blockSignals(isBlocked); + return true; } @@ -243,7 +224,8 @@ void ModuleBase_WidgetShapeSelector::onSelectionChanged() bool ModuleBase_WidgetShapeSelector::setSelection(ModuleBase_ViewerPrs theValue) { ObjectPtr aObject = theValue.object(); - if ((!mySelectedObject) && (!aObject)) + ObjectPtr aCurrentObject = getObject(); + if ((!aCurrentObject) && (!aObject)) return false; // Check that the selected object is result (others can not be accepted) @@ -305,9 +287,10 @@ bool ModuleBase_WidgetShapeSelector::setSelection(ModuleBase_ViewerPrs theValue) //******************************************************************** void ModuleBase_WidgetShapeSelector::setObject(ObjectPtr theObj, std::shared_ptr theShape) { - mySelectedObject = theObj; - myShape = theShape; - if (mySelectedObject) { + if (storeAttributeValues(theObj, theShape)) + updateObject(myFeature); + + if (theObj) { raisePanel(); } updateSelectionName(); @@ -355,6 +338,47 @@ bool ModuleBase_WidgetShapeSelector::acceptSubShape(std::shared_ptrdata(); + if (aData.get() == NULL) + return anObject; + + AttributeSelectionPtr aSelect = aData->selection(attributeID()); + if (aSelect) { + anObject = aSelect->context(); + } else { + AttributeRefAttrPtr aRefAttr = aData->refattr(attributeID()); + if (aRefAttr) { + anObject = aRefAttr->object(); + } else { + AttributeReferencePtr aRef = aData->reference(attributeID()); + if (aRef) { + anObject = aRef->value(); + } + } + } + return anObject; +} + +//******************************************************************** +GeomShapePtr ModuleBase_WidgetShapeSelector::getShape() const +{ + GeomShapePtr aShape; + DataPtr aData = myFeature->data(); + if (aData.get() == NULL) + return aShape; + + AttributeSelectionPtr aSelect = aData->selection(attributeID()); + if (aSelect) + aShape = aSelect->value(); + + return aShape; +} + //******************************************************************** void ModuleBase_WidgetShapeSelector::updateSelectionName() { @@ -368,8 +392,9 @@ void ModuleBase_WidgetShapeSelector::updateSelectionName() } } if (!isNameUpdated) { - if (mySelectedObject) { - std::string aName = mySelectedObject->data()->name(); + ObjectPtr anObject = getObject(); + if (anObject.get() != NULL) { + std::string aName = anObject->data()->name(); myTextLine->setText(QString::fromStdString(aName)); } else { if (myIsActive) { @@ -456,9 +481,6 @@ bool ModuleBase_WidgetShapeSelector::isValid(ObjectPtr theObj, std::shared_ptrblockSendAttributeUpdated(true); - ObjectPtr aPrevSelectedObject = mySelectedObject; - GeomShapePtr aPrevShape = myShape; - storeAttributeValues(theObj, theShape); // 3. check the acceptability of the current values diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h index 54b928ee8..c334bdcaf 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.h @@ -80,21 +80,17 @@ Q_OBJECT /// \return a control list virtual QList getControls() const; - /// Returns currently selected data object - ObjectPtr selectedFeature() const - { - return mySelectedObject; - } - /// Set the given wrapped value to the current widget /// This value should be processed in the widget according to the needs /// \param theValue the wrapped widget value virtual bool setSelection(ModuleBase_ViewerPrs theValue); - /// The methiod called when widget is deactivated virtual void deactivate(); + // Get the object from the attribute + /// \param theObj an object + static ObjectPtr getObject(const AttributePtr& theAttribute) const; public slots: @@ -128,6 +124,10 @@ Q_OBJECT /// \param theShape a shape void setObject(ObjectPtr theObj, std::shared_ptr theShape = std::shared_ptr()); + // Get the shape from the attribute it the attribute contain a shape, e.g. selection attribute + /// \return a shape + GeomShapePtr getShape() const; + /// Check the selected with validators if installed /// \param theObj the object for checking /// \param theShape the shape for checking @@ -153,12 +153,6 @@ Q_OBJECT /// Reference to workshop ModuleBase_IWorkshop* myWorkshop; - /// Pointer to selected object - ObjectPtr mySelectedObject; - - /// Pointer to selected shape - GeomShapePtr myShape; - /// List of accepting shapes types QStringList myShapeTypes; diff --git a/src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp b/src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp index 1c99b1f4f..405fc74b5 100644 --- a/src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp +++ b/src/PartSet/PartSet_WidgetConstraintShapeSelector.cpp @@ -21,8 +21,8 @@ bool PartSet_WidgetConstraintShapeSelector::storeAttributeValues(ObjectPtr theSe if (aFeature) { std::shared_ptr aSPFeature = std::dynamic_pointer_cast(aFeature); - if ((!aSPFeature) && (!myShape->isNull())) { - ObjectPtr aObj = PartSet_Tools::createFixedObjectByExternal(myShape->impl(), + if ((!aSPFeature) && (!theShape->isNull())) { + ObjectPtr aObj = PartSet_Tools::createFixedObjectByExternal(theShape->impl(), aSelectedObject, mySketch); if (aObj) { PartSet_WidgetConstraintShapeSelector* that = (PartSet_WidgetConstraintShapeSelector*) this;