From 8f09d362a50ccbc085841c24af2e755121e458ba Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 20 Aug 2015 10:24:03 +0300 Subject: [PATCH] 1. Mirror/Rotation/Translation constraint: using RefList instead of SelectionList 2. External edge: do not use execute() for external objects, created temporary for validating; union create/remove external objects 3. Compsolid redisplay: erase CompSolid on redisplay signal if it is visualized but number of sub results is positive 4. Deviation coefficient for visualized shapes with Edge shape type. --- src/ModelAPI/ModelAPI_Tools.cpp | 6 + src/ModelAPI/ModelAPI_Tools.h | 7 + src/ModuleBase/ModuleBase_ResultPrs.cpp | 3 +- src/ModuleBase/ModuleBase_Tools.cpp | 7 +- src/ModuleBase/ModuleBase_Tools.h | 12 +- .../ModuleBase_WidgetMultiSelector.cpp | 159 +++++++++++------- .../ModuleBase_WidgetMultiSelector.h | 6 +- .../ModuleBase_WidgetShapeSelector.cpp | 4 + src/ModuleBase/ModuleBase_WidgetValidated.cpp | 14 +- src/ModuleBase/ModuleBase_WidgetValidated.h | 5 +- src/PartSet/PartSet_CustomPrs.cpp | 3 - src/PartSet/PartSet_ExternalObjectsMgr.cpp | 56 +++--- src/PartSet/PartSet_ExternalObjectsMgr.h | 17 +- src/PartSet/PartSet_Module.cpp | 11 -- src/PartSet/PartSet_OperationPrs.cpp | 13 +- src/PartSet/PartSet_Tools.cpp | 32 ++-- src/PartSet/PartSet_Tools.h | 4 +- src/PartSet/PartSet_Validators.cpp | 46 ++++- src/PartSet/PartSet_WidgetMultiSelector.cpp | 36 ++-- src/PartSet/PartSet_WidgetShapeSelector.cpp | 4 +- src/PartSet/PartSet_WidgetSketchLabel.cpp | 4 +- .../SketchPlugin_ConstraintMirror.cpp | 17 +- .../SketchPlugin_MultiRotation.cpp | 20 +-- .../SketchPlugin_MultiTranslation.cpp | 21 +-- src/SketchPlugin/SketchPlugin_Validators.cpp | 18 +- src/XGUI/XGUI_WorkshopListener.cpp | 31 ++-- 26 files changed, 326 insertions(+), 230 deletions(-) mode change 100644 => 100755 src/ModelAPI/ModelAPI_Tools.cpp mode change 100644 => 100755 src/ModelAPI/ModelAPI_Tools.h mode change 100644 => 100755 src/ModuleBase/ModuleBase_ResultPrs.cpp mode change 100644 => 100755 src/ModuleBase/ModuleBase_Tools.cpp mode change 100644 => 100755 src/ModuleBase/ModuleBase_Tools.h mode change 100644 => 100755 src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp mode change 100644 => 100755 src/ModuleBase/ModuleBase_WidgetMultiSelector.h mode change 100644 => 100755 src/PartSet/PartSet_ExternalObjectsMgr.cpp mode change 100644 => 100755 src/PartSet/PartSet_ExternalObjectsMgr.h mode change 100644 => 100755 src/PartSet/PartSet_Module.cpp mode change 100644 => 100755 src/PartSet/PartSet_Tools.cpp mode change 100644 => 100755 src/PartSet/PartSet_Tools.h mode change 100644 => 100755 src/PartSet/PartSet_Validators.cpp mode change 100644 => 100755 src/PartSet/PartSet_WidgetMultiSelector.cpp mode change 100644 => 100755 src/PartSet/PartSet_WidgetShapeSelector.cpp mode change 100644 => 100755 src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp mode change 100644 => 100755 src/SketchPlugin/SketchPlugin_MultiRotation.cpp mode change 100644 => 100755 src/SketchPlugin/SketchPlugin_MultiTranslation.cpp mode change 100644 => 100755 src/SketchPlugin/SketchPlugin_Validators.cpp diff --git a/src/ModelAPI/ModelAPI_Tools.cpp b/src/ModelAPI/ModelAPI_Tools.cpp old mode 100644 new mode 100755 index 2f4fba720..1da66a845 --- a/src/ModelAPI/ModelAPI_Tools.cpp +++ b/src/ModelAPI/ModelAPI_Tools.cpp @@ -203,5 +203,11 @@ ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub) return ResultCompSolidPtr(); // not found } +bool hasSubResults(const ResultPtr& theResult) +{ + ResultCompSolidPtr aCompSolid = std::dynamic_pointer_cast(theResult); + return aCompSolid.get() && aCompSolid->numberOfSubs() > 0; +} + } // namespace ModelAPI_Tools diff --git a/src/ModelAPI/ModelAPI_Tools.h b/src/ModelAPI/ModelAPI_Tools.h old mode 100644 new mode 100755 index 97b93c9d5..e40494835 --- a/src/ModelAPI/ModelAPI_Tools.h +++ b/src/ModelAPI/ModelAPI_Tools.h @@ -67,6 +67,13 @@ MODELAPI_EXPORT CompositeFeaturePtr compositeOwner(const FeaturePtr& theFeature) */ MODELAPI_EXPORT ResultCompSolidPtr compSolidOwner(const ResultPtr& theSub); +/*! +* Returns true if the result contains a not empty list of sub results. It processes result compsolid. +* \param theResult a result object +* \returns boolean value +*/ +MODELAPI_EXPORT bool hasSubResults(const ResultPtr& theResult); + } #endif diff --git a/src/ModuleBase/ModuleBase_ResultPrs.cpp b/src/ModuleBase/ModuleBase_ResultPrs.cpp old mode 100644 new mode 100755 index 8ac112972..73a492df9 --- a/src/ModuleBase/ModuleBase_ResultPrs.cpp +++ b/src/ModuleBase/ModuleBase_ResultPrs.cpp @@ -66,8 +66,7 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t Set(myOriginalShape); // change deviation coefficient to provide more precise circle - Handle(Prs3d_Drawer) aDrawer = Attributes(); - //aDrawer->SetDeviationCoefficient(ModuleBase_Tools::defaultDeviationCoefficient()); + ModuleBase_Tools::setDefaultDeviationCoefficient(myOriginalShape, Attributes()); AIS_Shape::Compute(thePresentationManager, thePresentation, theMode); } } diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp old mode 100644 new mode 100755 index bed9b77ae..2c9114380 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -254,10 +254,11 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe } } -double defaultDeviationCoefficient() +void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape, + const Handle(Prs3d_Drawer)& theDrawer) { - // this value is chosen by performance check. Test case is an extrusion on sketch circle. - return 1.e-4; // default value is 1.e-3 + if (!theShape.IsNull() && theShape.ShapeType() == TopAbs_EDGE) + theDrawer->SetDeviationCoefficient(1.e-4); } } diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h old mode 100644 new mode 100755 index e0aa9c6ed..aa22e46ba --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -12,6 +12,8 @@ #include #include +#include +#include #include @@ -96,12 +98,16 @@ Check types of objects which are in the given list \param hasParameter will be set to true if list contains Parameter objects \param hasSubFeature will be set to true if list contains Sub-Feature objects */ -MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter, bool& hasSubFeature); +MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, + bool& hasFeature, bool& hasParameter, bool& hasSubFeature); -/*! Returns the default deviation coefficient value +/*! Sets the default coeffient into the driver calculated accordingly the shape type. +It provides 1.e-4 for a shape withe Edge shape type +\param theShape a shape to define the deviation coeffient, \return double value */ -MODULEBASE_EXPORT double defaultDeviationCoefficient(); +MODULEBASE_EXPORT void setDefaultDeviationCoefficient(const TopoDS_Shape& theShape, + const Handle(Prs3d_Drawer)& theDrawer); } #endif diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp old mode 100644 new mode 100755 index 242b05c8c..a7025605a --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -19,6 +19,8 @@ #include #include +#include +#include #include @@ -64,7 +66,7 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen const Config_WidgetAPI* theData, const std::string& theParentId) : ModuleBase_WidgetSelector(theParent, theWorkshop, theData, theParentId), - mySelectionCount(0), myIsInValidate(false) + mySelectionCount(0) { QGridLayout* aMainLay = new QGridLayout(this); ModuleBase_Tools::adjustMargins(aMainLay); @@ -130,16 +132,11 @@ bool ModuleBase_WidgetMultiSelector::storeValueCustom() const { // the value is stored on the selection changed signal processing // A rare case when plugin was not loaded. - if(!myFeature) + if (!myFeature) return false; - DataPtr aData = myFeature->data(); - AttributeSelectionListPtr aSelectionListAttr = - std::dynamic_pointer_cast(aData->attribute(attributeID())); - - if (aSelectionListAttr) { - // Store shapes type - TopAbs_ShapeEnum aCurrentType = - ModuleBase_Tools::shapeType(myTypeCombo->currentText()); + + AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); + if (aSelectionListAttr.get()) { aSelectionListAttr->setSelectionType(myTypeCombo->currentText().toStdString()); } return true; @@ -149,73 +146,86 @@ bool ModuleBase_WidgetMultiSelector::storeValueCustom() const bool ModuleBase_WidgetMultiSelector::restoreValueCustom() { // A rare case when plugin was not loaded. - if(!myFeature) + if (!myFeature) return false; - DataPtr aData = myFeature->data(); - AttributeSelectionListPtr aSelectionListAttr = - std::dynamic_pointer_cast(aData->attribute(attributeID())); - if (aSelectionListAttr) { + AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); + if (aSelectionListAttr.get()) { // Restore shape type if (!aSelectionListAttr->selectionType().empty()) setCurrentShapeType(ModuleBase_Tools::shapeType(aSelectionListAttr->selectionType().c_str())); - updateSelectionList(aSelectionListAttr); - return true; } - return false; + updateSelectionList(); + return true; } //******************************************************************** void ModuleBase_WidgetMultiSelector::storeAttributeValue() { - myIsInValidate = true; - DataPtr aData = myFeature->data(); - AttributeSelectionListPtr aSelectionListAttr = - std::dynamic_pointer_cast(aData->attribute(attributeID())); - if (aSelectionListAttr.get() == NULL) - return; - - mySelectionType = aSelectionListAttr->selectionType(); - mySelectionCount = aSelectionListAttr->size(); + ModuleBase_WidgetValidated::storeAttributeValue(); + + AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); + if (aSelectionListAttr.get()) { + mySelectionType = aSelectionListAttr->selectionType(); + mySelectionCount = aSelectionListAttr->size(); + } + else { + AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID()); + mySelectionCount = aRefListAttr->size(); + } } //******************************************************************** -void ModuleBase_WidgetMultiSelector::clearAttribute() +void ModuleBase_WidgetMultiSelector::restoreAttributeValue(bool theValid) { - DataPtr aData = myFeature->data(); - AttributeSelectionListPtr aSelectionListAttr = - std::dynamic_pointer_cast(aData->attribute(attributeID())); - aSelectionListAttr->clear(); + ModuleBase_WidgetValidated::restoreAttributeValue(theValid); + + // Store shape type + AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); + if (aSelectionListAttr.get()) { + aSelectionListAttr->setSelectionType(mySelectionType); + + // restore selection in the attribute. Indeed there is only one stored object + int aCountAppened = aSelectionListAttr->size() - mySelectionCount; + for (int i = 0; i < aCountAppened; i++) + aSelectionListAttr->removeLast(); + } + else { + AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID()); + // restore objects in the attribute. Indeed there is only one stored object +#ifdef DEBUG_REFLIST + int aCountAppened = aRefListAttr->size() - mySelectionCount; + for (int i = 0; i < aCountAppened; i++) + aRefListAttr->removeLast(); +#endif + } } //******************************************************************** -void ModuleBase_WidgetMultiSelector::setObject(ObjectPtr theSelectedObject, - GeomShapePtr theShape) +void ModuleBase_WidgetMultiSelector::clearAttribute() { - DataPtr aData = myFeature->data(); - AttributeSelectionListPtr aSelectionListAttr = - std::dynamic_pointer_cast(aData->attribute(attributeID())); - - int aSelCount = aSelectionListAttr->size(); - ResultPtr aResult = std::dynamic_pointer_cast(theSelectedObject); - aSelectionListAttr->append(aResult, theShape, myIsInValidate); + AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); + if (aSelectionListAttr.get()) + aSelectionListAttr->clear(); + else { + AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID()); + aRefListAttr->clear(); + } } //******************************************************************** -void ModuleBase_WidgetMultiSelector::restoreAttributeValue(bool/* theValid*/) +void ModuleBase_WidgetMultiSelector::setObject(ObjectPtr theSelectedObject, + GeomShapePtr theShape) { - myIsInValidate = false; - - // Store shape type - DataPtr aData = myFeature->data(); - AttributeSelectionListPtr aSelectionListAttr = - std::dynamic_pointer_cast(aData->attribute(attributeID())); - aSelectionListAttr->setSelectionType(mySelectionType); - - // restore selection in the attribute - int aCountAppened = aSelectionListAttr->size() - mySelectionCount; - for ( int i = 0; i < aCountAppened; i++) - aSelectionListAttr->removeLast(); + AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); + if (aSelectionListAttr.get()) { + ResultPtr aResult = std::dynamic_pointer_cast(theSelectedObject); + aSelectionListAttr->append(aResult, theShape, myIsInValidate); + } + else { + AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID()); + aRefListAttr->append(theSelectedObject); + } } //******************************************************************** @@ -355,12 +365,10 @@ QList ModuleBase_WidgetMultiSelector::getAttributeSelectio QList aSelected; // Restore selection in the viewer by the attribute selection list if(myFeature) { - DataPtr aData = myFeature->data(); - AttributeSelectionListPtr aListAttr = - std::dynamic_pointer_cast(aData->attribute(attributeID())); - if (aListAttr) { - for (int i = 0; i < aListAttr->size(); i++) { - AttributeSelectionPtr anAttr = aListAttr->value(i); + AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); + if (aSelectionListAttr.get()) { + for (int i = 0; i < aSelectionListAttr->size(); i++) { + AttributeSelectionPtr anAttr = aSelectionListAttr->value(i); ResultPtr anObject = anAttr->context(); if (anObject.get()) { TopoDS_Shape aShape; @@ -372,17 +380,40 @@ QList ModuleBase_WidgetMultiSelector::getAttributeSelectio } } } + else { + AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID()); + if (aRefListAttr.get()) { + for (int i = 0; i < aRefListAttr->size(); i++) { + ObjectPtr anObject = aRefListAttr->object(i); + if (anObject.get()) { + aSelected.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL)); + } + } + } + } } return aSelected; } //******************************************************************** -void ModuleBase_WidgetMultiSelector::updateSelectionList(AttributeSelectionListPtr theList) +void ModuleBase_WidgetMultiSelector::updateSelectionList() { myListControl->clear(); - for (int i = 0; i < theList->size(); i++) { - AttributeSelectionPtr aAttr = theList->value(i); - myListControl->addItem(aAttr->namingName().c_str()); + + AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID()); + if (aSelectionListAttr.get()) { + for (int i = 0; i < aSelectionListAttr->size(); i++) { + AttributeSelectionPtr aAttr = aSelectionListAttr->value(i); + myListControl->addItem(aAttr->namingName().c_str()); + } + } + else { + AttributeRefListPtr aRefListAttr = myFeature->data()->reflist(attributeID()); + for (int i = 0; i < aRefListAttr->size(); i++) { + ObjectPtr anObject = aRefListAttr->object(i); + if (anObject.get()) + myListControl->addItem(anObject->data()->name().c_str()); + } } // We have to call repaint because sometimes the List control is not updated myListControl->repaint(); diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h old mode 100644 new mode 100755 index 5a86bdfa3..403847ddf --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -15,7 +15,6 @@ #include #include -#include #include #include @@ -135,8 +134,8 @@ protected: /// a shape. If the attribute do not uses the shape, it is empty virtual QList getAttributeSelection() const; - /// Update selection list - void updateSelectionList(AttributeSelectionListPtr); + /// Fills the list control by the attribute values + void updateSelectionList(); /// Converts the XML defined type choice to the validator type /// For example, the "Edges" is converted to "edge" @@ -163,7 +162,6 @@ protected: /// Variable of GeomSelection int mySelectionCount; // number of elements in the attribute selection list when store - bool myIsInValidate; // the widget is in validation mode: store is performed, restore is not bool myIsUseChoice; }; diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 6d47be32c..16e0d2a62 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -249,6 +249,8 @@ void ModuleBase_WidgetShapeSelector::updateSelectionName() //******************************************************************** void ModuleBase_WidgetShapeSelector::storeAttributeValue() { + ModuleBase_WidgetValidated::storeAttributeValue(); + DataPtr aData = myFeature->data(); AttributePtr anAttribute = myFeature->attribute(attributeID()); @@ -266,6 +268,8 @@ void ModuleBase_WidgetShapeSelector::storeAttributeValue() //******************************************************************** void ModuleBase_WidgetShapeSelector::restoreAttributeValue(bool theValid) { + ModuleBase_WidgetValidated::restoreAttributeValue(theValid); + DataPtr aData = myFeature->data(); AttributePtr anAttribute = myFeature->attribute(attributeID()); diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.cpp b/src/ModuleBase/ModuleBase_WidgetValidated.cpp index 20b33095f..d549ac306 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.cpp +++ b/src/ModuleBase/ModuleBase_WidgetValidated.cpp @@ -25,7 +25,7 @@ ModuleBase_WidgetValidated::ModuleBase_WidgetValidated(QWidget* theParent, const Config_WidgetAPI* theData, const std::string& theParentId) : ModuleBase_ModelWidget(theParent, theData, theParentId), - myWorkshop(theWorkshop) + myWorkshop(theWorkshop), myIsInValidate(false) { } @@ -60,6 +60,18 @@ ObjectPtr ModuleBase_WidgetValidated::findPresentedObject(const AISObjectPtr& th return myPresentedObject; } +//******************************************************************** +void ModuleBase_WidgetValidated::storeAttributeValue() +{ + myIsInValidate = true; +} + +//******************************************************************** +void ModuleBase_WidgetValidated::restoreAttributeValue(const bool theValid) +{ + myIsInValidate = false; +} + //******************************************************************** bool ModuleBase_WidgetValidated::isValidInFilters(const ModuleBase_ViewerPrs& thePrs) { diff --git a/src/ModuleBase/ModuleBase_WidgetValidated.h b/src/ModuleBase/ModuleBase_WidgetValidated.h index d53bbb705..a9b77d939 100644 --- a/src/ModuleBase/ModuleBase_WidgetValidated.h +++ b/src/ModuleBase/ModuleBase_WidgetValidated.h @@ -70,13 +70,13 @@ protected: /// Creates a backup of the current values of the attribute /// It should be realized in the specific widget because of different /// parameters of the current attribute - virtual void storeAttributeValue() = 0; + virtual void storeAttributeValue(); /// Creates a backup of the current values of the attribute /// It should be realized in the specific widget because of different /// parameters of the current attribute /// \param theValid a boolean flag, if restore happens for valid parameters - virtual void restoreAttributeValue(const bool theValid) = 0; + virtual void restoreAttributeValue(const bool theValid); /// Checks the widget validity. By default, it returns true. /// \param theValue a selected presentation in the view @@ -125,6 +125,7 @@ protected: protected: ModuleBase_IWorkshop* myWorkshop; /// Reference to workshop + bool myIsInValidate; // the widget is in validation mode: store is performed, restore is not private: ObjectPtr myPresentedObject; /// back up of the filtered object diff --git a/src/PartSet/PartSet_CustomPrs.cpp b/src/PartSet/PartSet_CustomPrs.cpp index aedc188b5..008640c20 100755 --- a/src/PartSet/PartSet_CustomPrs.cpp +++ b/src/PartSet/PartSet_CustomPrs.cpp @@ -17,9 +17,6 @@ #include -#include -#include - #include #include diff --git a/src/PartSet/PartSet_ExternalObjectsMgr.cpp b/src/PartSet/PartSet_ExternalObjectsMgr.cpp old mode 100644 new mode 100755 index 2cdcd24bf..df63169bc --- a/src/PartSet/PartSet_ExternalObjectsMgr.cpp +++ b/src/PartSet/PartSet_ExternalObjectsMgr.cpp @@ -42,22 +42,27 @@ bool PartSet_ExternalObjectsMgr::isValidObject(const ObjectPtr& theObject) ObjectPtr PartSet_ExternalObjectsMgr::externalObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape, - const CompositeFeaturePtr& theSketch) + const CompositeFeaturePtr& theSketch, + const bool theTemporary) { - ObjectPtr aSelectedObject = PartSet_Tools::findFixedObjectByExternal(theShape->impl(), - theSelectedObject, theSketch); + ObjectPtr aSelectedObject = PartSet_Tools::findFixedObjectByExternal( + theShape->impl(), theSelectedObject, theSketch); if (!aSelectedObject.get()) { // Processing of external (non-sketch) object aSelectedObject = PartSet_Tools::createFixedObjectByExternal(theShape->impl(), - theSelectedObject, theSketch); - if (aSelectedObject.get()) - myExternalObjects.append(aSelectedObject); + theSelectedObject, theSketch, theTemporary); + if (aSelectedObject.get()) { + if (theTemporary) + myExternalObjectValidated = aSelectedObject; + else + myExternalObjects.append(aSelectedObject); + } } return aSelectedObject; } //******************************************************************** -ObjectPtr PartSet_ExternalObjectsMgr::externalObjectValidated(const ObjectPtr& theSelectedObject, +/*ObjectPtr PartSet_ExternalObjectsMgr::externalObjectValidated(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape, const CompositeFeaturePtr& theSketch) { @@ -72,35 +77,24 @@ ObjectPtr PartSet_ExternalObjectsMgr::externalObjectValidated(const ObjectPtr& t myExternalObjectValidated = aSelectedObject; } return aSelectedObject; -} +}*/ //******************************************************************** void PartSet_ExternalObjectsMgr::removeExternal(const CompositeFeaturePtr& theSketch, const FeaturePtr& theFeature, - ModuleBase_IWorkshop* theWorkshop) + ModuleBase_IWorkshop* theWorkshop, + const bool theTemporary) { - QObjectPtrList::const_iterator anIt = myExternalObjects.begin(), aLast = myExternalObjects.end(); - for (; anIt != aLast; anIt++) { - ObjectPtr anObject = *anIt; - if (anObject.get()) { - DocumentPtr aDoc = anObject->document(); - FeaturePtr aFeature = ModelAPI_Feature::feature(anObject); - if (aFeature.get() != NULL) { - QObjectPtrList anObjects; - anObjects.append(aFeature); - // the external feature should be removed with all references, sketch feature should be ignored - std::set anIgnoredFeatures; - // the current feature should be ignored, because it can use the external feature in the - // attributes and, therefore have a references to it. So, the delete functionality tries - // to delete this feature. Test case is creation of a constraint on external point, - // use in this control after an external point, the point of the sketch. - anIgnoredFeatures.insert(theFeature); - workshop(theWorkshop)->deleteFeatures(anObjects, anIgnoredFeatures); - } + if (theTemporary) + removeExternalObject(myExternalObjectValidated, theSketch, theFeature, theWorkshop); + else{ + QObjectPtrList::const_iterator anIt = myExternalObjects.begin(), aLast = myExternalObjects.end(); + for (; anIt != aLast; anIt++) { + ObjectPtr anObject = *anIt; + removeExternalObject(anObject, theSketch, theFeature, theWorkshop); } - //removeExternalObject(anObject, theSketch, theFeature); + myExternalObjects.clear(); } - myExternalObjects.clear(); } //******************************************************************** @@ -126,14 +120,14 @@ void PartSet_ExternalObjectsMgr::removeUnusedExternalObjects(const QObjectPtrLis } //******************************************************************** -void PartSet_ExternalObjectsMgr::removeExternalValidated(const CompositeFeaturePtr& theSketch, +/*void PartSet_ExternalObjectsMgr::removeExternalValidated(const CompositeFeaturePtr& theSketch, const FeaturePtr& theFeature, ModuleBase_IWorkshop* theWorkshop) { // TODO(nds): unite with removeExternal(), remove parameters removeExternalObject(myExternalObjectValidated, theSketch, theFeature, theWorkshop); myExternalObjectValidated = ObjectPtr(); -} +}*/ void PartSet_ExternalObjectsMgr::removeExternalObject(const ObjectPtr& theObject, const CompositeFeaturePtr& theSketch, diff --git a/src/PartSet/PartSet_ExternalObjectsMgr.h b/src/PartSet/PartSet_ExternalObjectsMgr.h old mode 100644 new mode 100755 index 82f9dbfb0..97dae5248 --- a/src/PartSet/PartSet_ExternalObjectsMgr.h +++ b/src/PartSet/PartSet_ExternalObjectsMgr.h @@ -45,24 +45,27 @@ class PARTSET_EXPORT PartSet_ExternalObjectsMgr /// \param theSelectedObject an object /// \param theShape a selected shape, which is used in the selection attribute /// \param theSketch a current sketch + /// \param theTemporary the created external object is temporary, execute is not performed for it /// \return the object ObjectPtr externalObject(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape, - const CompositeFeaturePtr& theSketch); + const CompositeFeaturePtr& theSketch, const bool theTemporary = false); - ObjectPtr externalObjectValidated(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape, - const CompositeFeaturePtr& theSketch); + //ObjectPtr externalObjectValidated(const ObjectPtr& theSelectedObject, const GeomShapePtr& theShape, + // const CompositeFeaturePtr& theSketch); // Removes the external presentation from the model /// \param theSketch a current sketch /// \param theFeature a current feature /// \param theFeature a current workshop + /// \param theTemporary if true, a temporary external object is removed overwise all ext objects void removeExternal(const CompositeFeaturePtr& theSketch, const FeaturePtr& theFeature, - ModuleBase_IWorkshop* theWorkshop); + ModuleBase_IWorkshop* theWorkshop, + const bool theTemporary); - void removeExternalValidated(const CompositeFeaturePtr& theSketch, - const FeaturePtr& theFeature, - ModuleBase_IWorkshop* theWorkshop); + //void removeExternalVali+dated(const CompositeFeaturePtr& theSketch, + // const FeaturePtr& theFeature, + // ModuleBase_IWorkshop* theWorkshop); void removeUnusedExternalObjects(const QObjectPtrList& theIgnoreObjects, const CompositeFeaturePtr& theSketch, diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp old mode 100644 new mode 100755 index ab86f1bf9..03b29dd75 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -48,7 +48,6 @@ #include #include #include -#include #include #include @@ -110,9 +109,6 @@ #include #endif -#define DEBUG_COMPOSOLID - - /*!Create and return new instance of XGUI_Module*/ extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop) { @@ -361,13 +357,6 @@ bool PartSet_Module::canCommitOperation() const bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const { -#ifdef DEBUG_COMPOSOLID - ResultCompSolidPtr aCompSolid = std::dynamic_pointer_cast - (theObject); - if (aCompSolid.get() && aCompSolid->numberOfSubs() > 0) - return false; -#endif - // the sketch manager put the restriction to the objects display return mySketchMgr->canDisplayObject(theObject); } diff --git a/src/PartSet/PartSet_OperationPrs.cpp b/src/PartSet/PartSet_OperationPrs.cpp index e775102d3..d20041e43 100755 --- a/src/PartSet/PartSet_OperationPrs.cpp +++ b/src/PartSet/PartSet_OperationPrs.cpp @@ -19,6 +19,8 @@ #include #include #include +#include + #include @@ -88,7 +90,7 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t continue; TopoDS_Shape aShape = aGeomShape->impl(); // change deviation coefficient to provide more precise circle - //aDrawer->SetDeviationCoefficient(ModuleBase_Tools::defaultDeviationCoefficient()); + ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, aDrawer); StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer); } } @@ -178,6 +180,14 @@ void PartSet_OperationPrs::getFeatureShapes(QMap addValue(aResult, aShape, myFeature, theObjectShapes); } } + if (anAttrType == ModelAPI_AttributeRefList::typeId()) { + std::shared_ptr aCurSelList = + std::dynamic_pointer_cast(anAttribute); + for (int i = 0; i < aCurSelList->size(); i++) { + GeomShapePtr aShape; + addValue(aCurSelList->object(i), aShape, myFeature, theObjectShapes); + } + } else { ObjectPtr anObject; GeomShapePtr aShape; @@ -214,6 +224,7 @@ bool PartSet_OperationPrs::isSelectionAttribute(const AttributePtr& theAttribute std::string anAttrType = theAttribute->attributeType(); return anAttrType == ModelAPI_AttributeSelectionList::typeId() || + anAttrType == ModelAPI_AttributeRefList::typeId() || anAttrType == ModelAPI_AttributeRefAttr::typeId() || anAttrType == ModelAPI_AttributeSelection::typeId() || anAttrType == ModelAPI_AttributeReference::typeId(); diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp old mode 100644 new mode 100755 index f9c42efa5..7644c7268 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -480,8 +480,9 @@ ResultPtr PartSet_Tools::findFixedObjectByExternal(const TopoDS_Shape& theShape, } ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShape, - const ObjectPtr& theObject, - CompositeFeaturePtr theSketch) + const ObjectPtr& theObject, + CompositeFeaturePtr theSketch, + const bool theTemporary) { if (theShape.ShapeType() == TopAbs_EDGE) { Standard_Real aStart, aEnd; @@ -517,14 +518,14 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap anEdge->setImpl(new TopoDS_Shape(theShape)); anAttr->setValue(aRes, anEdge); + if (!theTemporary) { + aMyFeature->execute(); - aMyFeature->execute(); - - // fix this edge - FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID()); - aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())-> - setObject(aMyFeature->lastResult()); - + // fix this edge + FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID()); + aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())-> + setObject(aMyFeature->lastResult()); + } return aMyFeature->lastResult(); } } @@ -544,13 +545,14 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap aVert->setImpl(new TopoDS_Shape(theShape)); anAttr->setValue(aRes, aVert); - aMyFeature->execute(); - - // fix this edge - FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID()); - aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())-> - setObject(aMyFeature->lastResult()); + if (theTemporary) { + aMyFeature->execute(); + // fix this edge + FeaturePtr aFix = theSketch->addFeature(SketchPlugin_ConstraintRigid::ID()); + aFix->data()->refattr(SketchPlugin_Constraint::ENTITY_A())-> + setObject(aMyFeature->lastResult()); + } return aMyFeature->lastResult(); } } diff --git a/src/PartSet/PartSet_Tools.h b/src/PartSet/PartSet_Tools.h old mode 100644 new mode 100755 index c113b832a..957849308 --- a/src/PartSet/PartSet_Tools.h +++ b/src/PartSet/PartSet_Tools.h @@ -166,10 +166,12 @@ class PARTSET_EXPORT PartSet_Tools /// \param theShape an edge /// \param theObject a selected result object /// \param theSketch a sketch feature + /// \param theTemporary the created external object is temporary, execute is not performed for it /// \return result of created feature static ResultPtr createFixedObjectByExternal(const TopoDS_Shape& theShape, const ObjectPtr& theObject, - CompositeFeaturePtr theSketch); + CompositeFeaturePtr theSketch, + const bool theTemporary = false); /// Checks whether the list of selected presentations contains the given one /// \param theSelected a list of presentations diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp old mode 100644 new mode 100755 index f62a88b48..86f6cb97e --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -295,6 +296,28 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute } } } + else if (anAttrType == ModelAPI_AttributeRefList::typeId()) { + std::shared_ptr aCurSelList = + std::dynamic_pointer_cast(theAttribute); + anAttrs = aFeature->data()->attributes(ModelAPI_AttributeRefList::typeId()); + if (anAttrs.size() > 0) { + std::list>::iterator anAttrItr = anAttrs.begin(); + for (; anAttrItr != anAttrs.end(); anAttrItr++){ + if ((*anAttrItr).get() && (*anAttrItr)->id() != theAttribute->id()){ + std::shared_ptr aRefSelList = + std::dynamic_pointer_cast(*anAttrItr); + for (int i = 0; i < aCurSelList->size(); i++) { + ObjectPtr aCurSelObject = aCurSelList->object(i); + for (int j = 0; j < aRefSelList->size(); j++) { + if (aCurSelObject == aRefSelList->object(j)) { + return false; + } + } + } + } + } + } + } return !featureHasReferences(theAttribute); } @@ -343,11 +366,8 @@ bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute, if (anAttributeType == ModelAPI_AttributeSelectionList::typeId()) { AttributeSelectionListPtr aSelectionListAttr = std::dynamic_pointer_cast(theAttribute); - // it filters only selection list attributes - std::string aType = aSelectionListAttr->selectionType().c_str(); // all context objects should be sketch entities - int aSize = aSelectionListAttr->size(); - for (int i = 0; i < aSelectionListAttr->size() && isSketchEntities; i++) { + for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize && isSketchEntities; i++) { AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i); ObjectPtr anObject = aSelectAttr->context(); // a context of the selection attribute is a feature result. It can be a case when the result @@ -362,6 +382,24 @@ bool PartSet_SketchEntityValidator::isValid(const AttributePtr& theAttribute, } } } + if (anAttributeType == ModelAPI_AttributeRefList::typeId()) { + AttributeRefListPtr aRefListAttr = + std::dynamic_pointer_cast(theAttribute); + // all context objects should be sketch entities + for (int i = 0, aSize = aRefListAttr->size(); i < aSize && isSketchEntities; i++) { + ObjectPtr anObject = aRefListAttr->object(i); + // a context of the selection attribute is a feature result. It can be a case when the result + // of the feature is null, e.g. the feature is modified and has not been executed yet. + // The validator returns an invalid result here. The case is an extrusion built on a sketch + // feature. A new sketch element creation leads to an empty result. + if (!anObject.get()) + isSketchEntities = false; + else { + FeaturePtr aFeature = ModelAPI_Feature::feature(anObject); + isSketchEntities = anEntityKinds.find(aFeature->getKind()) != anEntityKinds.end(); + } + } + } if (anAttributeType == ModelAPI_AttributeRefAttr::typeId()) { std::shared_ptr aRef = std::dynamic_pointer_cast(theAttribute); diff --git a/src/PartSet/PartSet_WidgetMultiSelector.cpp b/src/PartSet/PartSet_WidgetMultiSelector.cpp old mode 100644 new mode 100755 index 91404aaeb..9f76f8120 --- a/src/PartSet/PartSet_WidgetMultiSelector.cpp +++ b/src/PartSet/PartSet_WidgetMultiSelector.cpp @@ -7,6 +7,8 @@ #include "PartSet_WidgetMultiSelector.h" #include +#include +#include #include #include @@ -49,15 +51,25 @@ bool PartSet_WidgetMultiSelector::setSelection(QList& theV // TODO(nds): unite with externalObject(), remove parameters //myFeature->execute(); - DataPtr aData = myFeature->data(); - AttributeSelectionListPtr aSelectionListAttr = - std::dynamic_pointer_cast(aData->attribute(attributeID())); - QObjectPtrList aListOfAttributeObjects; - for (int i = 0; i < aSelectionListAttr->size(); i++) { - AttributeSelectionPtr anAttr = aSelectionListAttr->value(i); - aListOfAttributeObjects.append(anAttr->context()); + + AttributePtr anAttribute = myFeature->data()->attribute(attributeID()); + if (anAttribute->attributeType() == ModelAPI_AttributeSelectionList::typeId()) { + AttributeSelectionListPtr aSelectionListAttr = + std::dynamic_pointer_cast(anAttribute); + for (int i = 0; i < aSelectionListAttr->size(); i++) { + AttributeSelectionPtr anAttr = aSelectionListAttr->value(i); + aListOfAttributeObjects.append(anAttr->context()); + } } + else if (anAttribute->attributeType() == ModelAPI_AttributeRefList::typeId()) { + AttributeRefListPtr aRefListAttr = + std::dynamic_pointer_cast(anAttribute); + for (int i = 0; i < aRefListAttr->size(); i++) { + aListOfAttributeObjects.append(aRefListAttr->object(i)); + } + } + myExternalObjectMgr->removeUnusedExternalObjects(aListOfAttributeObjects, sketch(), myFeature); } return aSucceed; @@ -79,7 +91,7 @@ void PartSet_WidgetMultiSelector::restoreAttributeValue(const bool theValid) { ModuleBase_WidgetMultiSelector::restoreAttributeValue(theValid); - myExternalObjectMgr->removeExternalValidated(sketch(), myFeature, myWorkshop); + myExternalObjectMgr->removeExternal/*Validated*/(sketch(), myFeature, myWorkshop, true); } void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrs& thePrs, @@ -101,10 +113,10 @@ void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrs& t aShape = aResult->shape(); } if (aShape.get() != NULL && !aShape->isNull()) { - if (myIsInValidate) - theObject = myExternalObjectMgr->externalObjectValidated(theObject, aShape, sketch()); - else - theObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch()); + //if (myIsInValidate) + // theObject = myExternalObjectMgr->externalObjectValidated(theObject, aShape, sketch()); + //else + theObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch(), myIsInValidate); } } } diff --git a/src/PartSet/PartSet_WidgetShapeSelector.cpp b/src/PartSet/PartSet_WidgetShapeSelector.cpp old mode 100644 new mode 100755 index 5b2a4e715..0bbeb05e8 --- a/src/PartSet/PartSet_WidgetShapeSelector.cpp +++ b/src/PartSet/PartSet_WidgetShapeSelector.cpp @@ -94,7 +94,7 @@ void PartSet_WidgetShapeSelector::getGeomSelection(const ModuleBase_ViewerPrs& t aShape = aResult->shape(); } if (aShape.get() != NULL && !aShape->isNull()) - theObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch()); + theObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch(), myIsInValidate); } } @@ -115,7 +115,7 @@ GeomShapePtr PartSet_WidgetShapeSelector::getShape() const void PartSet_WidgetShapeSelector::restoreAttributeValue(const bool theValid) { ModuleBase_WidgetShapeSelector::restoreAttributeValue(theValid); - myExternalObjectMgr->removeExternal(sketch(), myFeature, myWorkshop); + myExternalObjectMgr->removeExternal(sketch(), myFeature, myWorkshop, true); } //******************************************************************** diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index b2883760d..73fd01d6c 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -197,7 +197,6 @@ std::shared_ptr PartSet_WidgetSketchLabel::plane() const { CompositeFeaturePtr aSketch = std::dynamic_pointer_cast(myFeature); return PartSet_Tools::sketchPlane(aSketch); - } bool PartSet_WidgetSketchLabel::focusTo() @@ -213,10 +212,13 @@ void PartSet_WidgetSketchLabel::enableFocusProcessing() void PartSet_WidgetSketchLabel::storeAttributeValue() { + ModuleBase_WidgetValidated::storeAttributeValue(); } void PartSet_WidgetSketchLabel::restoreAttributeValue(const bool theValid) { + ModuleBase_WidgetValidated::restoreAttributeValue(theValid); + // it is not necessary to save the previous plane value because the plane is chosen once DataPtr aData = feature()->data(); AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast diff --git a/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp b/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp old mode 100644 new mode 100755 index 73649b1cf..5691e6c7f --- a/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -31,18 +30,14 @@ void SketchPlugin_ConstraintMirror::initAttributes() data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefList::typeId()); - AttributeSelectionListPtr aSelection = - std::dynamic_pointer_cast(data()->addAttribute( - SketchPlugin_ConstraintMirror::MIRROR_LIST_ID(), ModelAPI_AttributeSelectionList::typeId())); - aSelection->setSelectionType("EDGE"); + data()->addAttribute(SketchPlugin_ConstraintMirror::MIRROR_LIST_ID(), ModelAPI_AttributeRefList::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_B()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_C()); } void SketchPlugin_ConstraintMirror::execute() { - AttributeSelectionListPtr aMirrorObjectRefs = - selectionList(SketchPlugin_ConstraintMirror::MIRROR_LIST_ID()); + AttributeRefListPtr aMirrorObjectRefs = reflist(SketchPlugin_ConstraintMirror::MIRROR_LIST_ID()); // Wait all objects being created, then send update events static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); @@ -60,16 +55,16 @@ void SketchPlugin_ConstraintMirror::execute() std::vector isUsed(anInitialList.size(), false); // add new items to the list for(int anInd = 0; anInd < aMirrorObjectRefs->size(); anInd++) { - std::shared_ptr aSelect = aMirrorObjectRefs->value(anInd); + ObjectPtr anObject = aMirrorObjectRefs->object(anInd); std::list::const_iterator anIt = anInitialList.begin(); std::vector::iterator aUsedIt = isUsed.begin(); for (; anIt != anInitialList.end(); anIt++, aUsedIt++) - if (*anIt == aSelect->context()) { + if (*anIt == anObject) { *aUsedIt = true; break; } if (anIt == anInitialList.end()) - aRefListOfShapes->append(aSelect->context()); + aRefListOfShapes->append(anObject); } // remove unused items std::list::iterator anInitIter = anInitialList.begin(); @@ -204,7 +199,7 @@ AISObjectPtr SketchPlugin_ConstraintMirror::getAISObject(AISObjectPtr thePreviou void SketchPlugin_ConstraintMirror::attributeChanged(const std::string& theID) { if (theID == MIRROR_LIST_ID()) { - AttributeSelectionListPtr aMirrorObjectRefs = selectionList(MIRROR_LIST_ID()); + AttributeRefListPtr aMirrorObjectRefs = reflist(MIRROR_LIST_ID()); if (aMirrorObjectRefs->size() == 0) { // Clear list of objects AttributeRefListPtr aRefListOfMirrored = std::dynamic_pointer_cast( diff --git a/src/SketchPlugin/SketchPlugin_MultiRotation.cpp b/src/SketchPlugin/SketchPlugin_MultiRotation.cpp old mode 100644 new mode 100755 index 126c2fe59..726ffe4dd --- a/src/SketchPlugin/SketchPlugin_MultiRotation.cpp +++ b/src/SketchPlugin/SketchPlugin_MultiRotation.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -37,10 +36,7 @@ void SketchPlugin_MultiRotation::initAttributes() data()->addAttribute(NUMBER_OF_COPIES_ID(), ModelAPI_AttributeInteger::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefList::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId()); - AttributeSelectionListPtr aSelection = - std::dynamic_pointer_cast(data()->addAttribute( - ROTATION_LIST_ID(), ModelAPI_AttributeSelectionList::typeId())); - aSelection->setSelectionType("EDGE"); + data()->addAttribute(ROTATION_LIST_ID(), ModelAPI_AttributeRefList::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_A()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_B()); } @@ -53,7 +49,7 @@ void SketchPlugin_MultiRotation::execute() return; } - AttributeSelectionListPtr aRotationObjectRefs = selectionList(ROTATION_LIST_ID()); + AttributeRefListPtr aRotationObjectRefs = reflist(ROTATION_LIST_ID()); int aNbCopies = integer(NUMBER_OF_COPIES_ID())->value(); // Obtain center and angle of rotation @@ -84,20 +80,20 @@ void SketchPlugin_MultiRotation::execute() aRefListOfRotated->size() / aRefListOfShapes->size() - 1 : 0; std::list anInitialList = aRefListOfShapes->list(); std::list aTargetList = aRefListOfRotated->list(); - std::list anAddition; + std::list anAddition; std::vector isUsed(anInitialList.size(), false); // collect new items and check the items to remove for(int anInd = 0; anInd < aRotationObjectRefs->size(); anInd++) { - std::shared_ptr aSelect = aRotationObjectRefs->value(anInd); + ObjectPtr anObject = aRotationObjectRefs->object(anInd); std::list::const_iterator anIt = anInitialList.begin(); std::vector::iterator aUsedIt = isUsed.begin(); for (; anIt != anInitialList.end(); anIt++, aUsedIt++) - if (*anIt == aSelect->context()) { + if (*anIt == anObject) { *aUsedIt = true; break; } if (anIt == anInitialList.end()) - anAddition.push_back(aSelect->context()); + anAddition.push_back(anObject); } // remove unused items std::list::iterator anInitIter = anInitialList.begin(); @@ -170,7 +166,7 @@ void SketchPlugin_MultiRotation::execute() aRefListOfRotated->append(*aTargetIter); } // add new items - std::list::iterator anAddIter = anAddition.begin(); + std::list::iterator anAddIter = anAddition.begin(); for (; anAddIter != anAddition.end(); anAddIter++) { aRefListOfShapes->append(*anAddIter); aRefListOfRotated->append(*anAddIter); @@ -281,7 +277,7 @@ void SketchPlugin_MultiRotation::rotateFeature( void SketchPlugin_MultiRotation::attributeChanged(const std::string& theID) { if (theID == ROTATION_LIST_ID()) { - AttributeSelectionListPtr aRotationObjectRefs = selectionList(ROTATION_LIST_ID()); + AttributeRefListPtr aRotationObjectRefs = reflist(ROTATION_LIST_ID()); if (aRotationObjectRefs->size() == 0) { int aNbCopies = integer(NUMBER_OF_COPIES_ID())->value(); // Clear list of objects diff --git a/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp b/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp old mode 100644 new mode 100755 index eadf54a5a..3e6a702b6 --- a/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp +++ b/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -31,10 +30,7 @@ void SketchPlugin_MultiTranslation::initAttributes() data()->addAttribute(NUMBER_OF_COPIES_ID(), ModelAPI_AttributeInteger::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefList::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId()); - AttributeSelectionListPtr aSelection = - std::dynamic_pointer_cast(data()->addAttribute( - TRANSLATION_LIST_ID(), ModelAPI_AttributeSelectionList::typeId())); - aSelection->setSelectionType("EDGE"); + data()->addAttribute(TRANSLATION_LIST_ID(), ModelAPI_AttributeRefList::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_A()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_B()); } @@ -47,7 +43,7 @@ void SketchPlugin_MultiTranslation::execute() return; } - AttributeSelectionListPtr aTranslationObjectRefs = selectionList(TRANSLATION_LIST_ID()); + AttributeRefListPtr aTranslationObjectRefs = reflist(TRANSLATION_LIST_ID()); int aNbCopies = integer(NUMBER_OF_COPIES_ID())->value(); // Calculate shift vector @@ -79,20 +75,21 @@ void SketchPlugin_MultiTranslation::execute() aRefListOfTranslated->size() / aRefListOfShapes->size() - 1 : 0; std::list anInitialList = aRefListOfShapes->list(); std::list aTargetList = aRefListOfTranslated->list(); - std::list anAddition; + std::list anAddition; std::vector isUsed(anInitialList.size(), false); // collect new items and check the items to remove for(int anInd = 0; anInd < aTranslationObjectRefs->size(); anInd++) { - std::shared_ptr aSelect = aTranslationObjectRefs->value(anInd); + //std::shared_ptr aSelect = aTranslationObjectRefs->value(anInd); + ObjectPtr anObject = aTranslationObjectRefs->object(anInd); std::list::const_iterator anIt = anInitialList.begin(); std::vector::iterator aUsedIt = isUsed.begin(); for (; anIt != anInitialList.end(); anIt++, aUsedIt++) - if (*anIt == aSelect->context()) { + if (*anIt == anObject) { *aUsedIt = true; break; } if (anIt == anInitialList.end()) - anAddition.push_back(aSelect->context()); + anAddition.push_back(anObject); } // remove unused items std::list::iterator anInitIter = anInitialList.begin(); @@ -165,7 +162,7 @@ void SketchPlugin_MultiTranslation::execute() aRefListOfTranslated->append(*aTargetIter); } // add new items - std::list::iterator anAddIter = anAddition.begin(); + std::list::iterator anAddIter = anAddition.begin(); for (; anAddIter != anAddition.end(); anAddIter++) { aRefListOfShapes->append(*anAddIter); aRefListOfTranslated->append(*anAddIter); @@ -223,7 +220,7 @@ ObjectPtr SketchPlugin_MultiTranslation::copyFeature(ObjectPtr theObject) void SketchPlugin_MultiTranslation::attributeChanged(const std::string& theID) { if (theID == TRANSLATION_LIST_ID()) { - AttributeSelectionListPtr aTranslationObjectRefs = selectionList(TRANSLATION_LIST_ID()); + AttributeRefListPtr aTranslationObjectRefs = reflist(TRANSLATION_LIST_ID()); if (aTranslationObjectRefs->size() == 0) { int aNbCopies = integer(NUMBER_OF_COPIES_ID())->value(); // Clear list of objects diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp old mode 100644 new mode 100755 index 6e8b36b6b..377affa7f --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -199,8 +199,8 @@ bool SketchPlugin_MirrorAttrValidator::isValid(const AttributePtr& theAttribute, std::string& theError) const { FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); - AttributeSelectionListPtr aSelAttr = - std::dynamic_pointer_cast(theAttribute); + AttributeRefListPtr aSelAttr = + std::dynamic_pointer_cast(theAttribute); if (!aSelAttr) return false; @@ -209,10 +209,10 @@ bool SketchPlugin_MirrorAttrValidator::isValid(const AttributePtr& theAttribute, std::list aMirroredObjects = aRefListOfMirrored->list(); for(int anInd = 0; anInd < aSelAttr->size(); anInd++) { - std::shared_ptr aSelect = aSelAttr->value(anInd); + ObjectPtr aSelObject = aSelAttr->object(anInd); std::list::iterator aMirIter = aMirroredObjects.begin(); for (; aMirIter != aMirroredObjects.end(); aMirIter++) - if (aSelect->context() == *aMirIter) + if (aSelObject == *aMirIter) return false; } return true; @@ -268,8 +268,8 @@ bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute, std::string& theError) const { FeaturePtr aFeature = std::dynamic_pointer_cast(theAttribute->owner()); - AttributeSelectionListPtr aSelAttr = - std::dynamic_pointer_cast(theAttribute); + AttributeRefListPtr aSelAttr = + std::dynamic_pointer_cast(theAttribute); if (!aSelAttr) return false; @@ -282,16 +282,16 @@ bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute, std::list::iterator anObjIter; for(int anInd = 0; anInd < aSelAttr->size(); anInd++) { - std::shared_ptr aSelect = aSelAttr->value(anInd); + ObjectPtr aSelObject = aSelAttr->object(anInd); anObjIter = anInitialObjects.begin(); for (; anObjIter != anInitialObjects.end(); anObjIter++) - if (aSelect->context() == *anObjIter) + if (aSelObject == *anObjIter) break; if (anObjIter != anInitialObjects.end()) continue; anObjIter = aCopiedObjects.begin(); for (; anObjIter != aCopiedObjects.end(); anObjIter++) - if (aSelect->context() == *anObjIter) + if (aSelObject == *anObjIter) return false; } return true; diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index bc201061f..982765299 100755 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -54,7 +55,6 @@ #include #endif -//#define DEBUG_CANDISPLAY //#define DEBUG_FEATURE_CREATED //#define DEBUG_FEATURE_REDISPLAY @@ -270,15 +270,14 @@ void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr - (aObj); - if (aCompSolid.get() && aCompSolid->numberOfSubs() > 0) { + if (ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast(aObj))) { aDisplayer->erase(aObj, false); - }*/ - - aDisplayer->redisplay(aObj, false); - // Deactivate object of current operation from selection - aWorkshop->deactivateActiveObject(aObj, false); + } + else { + aDisplayer->redisplay(aObj, false); + // Deactivate object of current operation from selection + aWorkshop->deactivateActiveObject(aObj, false); + } } else { // display object if the current operation has it if (displayObject(aObj)) { // Deactivate object of current operation from selection @@ -316,15 +315,8 @@ void XGUI_WorkshopListener::onFeatureCreatedMsg(const std::shared_ptrmodule()->canDisplayObject(anObject)*/) { - anObject->setDisplayed(true); - //isDisplayed = displayObject(anObject); -#else - if (myWorkshop->module()->canDisplayObject(anObject)) { + if (displayObject(anObject)) { anObject->setDisplayed(true); - isDisplayed = displayObject(anObject); -#endif } else anObject->setDisplayed(false); } @@ -436,8 +428,9 @@ void XGUI_WorkshopListener::addFeature(const std::shared_ptrmodule()->canDisplayObject(theObj)) + XGUI_Workshop* aWorkshop = workshop(); + if (ModelAPI_Tools::hasSubResults(std::dynamic_pointer_cast(theObj)) || + !aWorkshop->module()->canDisplayObject(theObj)) return false; XGUI_Displayer* aDisplayer = aWorkshop->displayer(); -- 2.39.2