From: Jérôme Date: Sun, 18 Oct 2020 15:00:27 +0000 (+0200) Subject: Fix issue for concealment validate X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=62ff493578810c78bdd817bfce95b6cb2d04b539;p=modules%2Fshaper.git Fix issue for concealment validate --- diff --git a/src/FeaturesAPI/FeaturesAPI_Fillet.cpp b/src/FeaturesAPI/FeaturesAPI_Fillet.cpp index 531586796..a62332752 100644 --- a/src/FeaturesAPI/FeaturesAPI_Fillet.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Fillet.cpp @@ -151,8 +151,8 @@ FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptrsize() > 0) + execute(); } } @@ -164,9 +164,9 @@ FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptrvalue())); @@ -213,7 +213,8 @@ FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptrsetValue(aVal, aRowIndex, 0 ); aVal.myDouble = aRowsRadiusIter->value(); myvalues()->setValue(aVal, aRowIndex, 1 ); - execIfBaseNotEmpty(); + + execute(); } } @@ -224,9 +225,9 @@ FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptrsetSize( thepointCurvCood.size(), 2 ); @@ -239,8 +240,9 @@ FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptrsetValue(aVal, aRowIndex, 0 ); aVal.myDouble = aRowsRadiusIter->value(); myvaluescurv()->setValue(aVal, aRowIndex, 1 ); - } - execIfBaseNotEmpty(); + } + if (myedgesfacesmultiselected->size() > 0) + execute(); } } @@ -284,12 +286,12 @@ void FeaturesAPI_Fillet2D::dump(ModelHighAPI_Dumper& theDumper) const if ( aBase->string(FeaturesPlugin_Fillet::CREATION_METHOD())->value() - == FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES() ) + == FeaturesPlugin_Fillet::METHOD_MULTIPLES_RADIUSES() ) { AttributeSelectionPtr anAttrEdgeSelec = aBase->selection(FeaturesPlugin_Fillet::EDGE_SELECTED_ID()); - if( aBase->string(FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES())->value() + if( aBase->string(FeaturesPlugin_Fillet::CREATION_MULTI_RADIUS_METHODE())->value() == FeaturesPlugin_Fillet::CREATION_METHOD_BY_POINTS() ) { @@ -310,7 +312,7 @@ void FeaturesAPI_Fillet2D::dump(ModelHighAPI_Dumper& theDumper) const }else{ AttributeSelectionListPtr anAttrEdgesFaces = - aBase->selectionList(FeaturesPlugin_Fillet::EDGES_FACES_LIST_ID()); + aBase->selectionList(FeaturesPlugin_Fillet::EDGES_FACES_MULTI_LIST_ID()); AttributeTablesPtr anAttrTable = aBase->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID()); theDumper << aBase << " = model.addFilletMultiRadiusBycurvAbs(" << aDocName << ", " << anAttrEdgesFaces; theDumper << ", "; diff --git a/src/FeaturesAPI/FeaturesAPI_Fillet.h b/src/FeaturesAPI/FeaturesAPI_Fillet.h index c61c032d2..3e5e45db1 100644 --- a/src/FeaturesAPI/FeaturesAPI_Fillet.h +++ b/src/FeaturesAPI/FeaturesAPI_Fillet.h @@ -148,11 +148,11 @@ public: FEATURESAPI_EXPORT virtual ~FeaturesAPI_Fillet2D(); - INTERFACE_11(FeaturesPlugin_Fillet::ID(), + INTERFACE_12(FeaturesPlugin_Fillet::ID(), creationMethod, FeaturesPlugin_Fillet::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */, - creationMethodmulti, FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES(), + creationMethodmulti, FeaturesPlugin_Fillet::CREATION_MULTI_RADIUS_METHODE(), ModelAPI_AttributeString, /** Creation method */, baseObjects, FeaturesPlugin_Fillet::OBJECT_LIST_ID(), @@ -164,6 +164,9 @@ public: edgesfacesselected, FeaturesPlugin_Fillet::EDGES_FACES_LIST_ID(), ModelAPI_AttributeSelectionList, /** edge and face objects */, + edgesfacesmultiselected, FeaturesPlugin_Fillet::EDGES_FACES_MULTI_LIST_ID(), + ModelAPI_AttributeSelectionList, + /** edge and face objects */, arraypointradiusbypoint, FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS(), ModelAPI_AttributeSelectionList, /** selection points */, diff --git a/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp b/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp index 41b786e73..96054ea28 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp @@ -61,62 +61,52 @@ FeaturesPlugin_Fillet::FeaturesPlugin_Fillet() void FeaturesPlugin_Fillet::initAttributes() { - data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(CREATION_METHOD_MULTIPLES_RADIUSES(), ModelAPI_AttributeString::typeId()); - + AttributePtr aSelectionList = data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); - data()->addAttribute(EDGES_FACES_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); + AttributePtr aSelectionEdgesFacesList = + data()->addAttribute(EDGES_FACES_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); + + AttributePtr aSelectionEdgesFacesMultiList = + data()->addAttribute(EDGES_FACES_MULTI_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); + + AttributePtr aSelectionEdgeSelected = + data()->addAttribute(EDGE_SELECTED_ID(), ModelAPI_AttributeSelection::typeId()); + + data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(CREATION_MULTI_RADIUS_METHODE(), ModelAPI_AttributeString::typeId()); data()->addAttribute(START_RADIUS_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(END_RADIUS_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(VALUES_ID(), ModelAPI_AttributeTables::typeId()); data()->addAttribute(VALUES_CURV_ID(), ModelAPI_AttributeTables::typeId()); - data()->addAttribute(EDGE_SELECTED_ID(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(ARRAY_POINT_RADIUS_BY_POINTS(), ModelAPI_AttributeSelectionList::typeId()); - data()->addAttribute(CREATION_METHOD_BY_POINTS(), ModelAPI_AttributeString::typeId()); - - data()->addAttribute(CREATION_METHOD_BY_CURVILEAR_ABSCISSA(), ModelAPI_AttributeString::typeId()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), END_RADIUS_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ARRAY_POINT_RADIUS_BY_POINTS()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VALUES_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VALUES_CURV_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CREATION_METHOD_MULTIPLES_RADIUSES()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CREATION_METHOD_BY_CURVILEAR_ABSCISSA()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CREATION_METHOD_BY_POINTS()); - tables(VALUES_ID())->setSize(2,2); - tables(VALUES_CURV_ID())->setSize(2,2); - ModelAPI_AttributeTables::Value aVar; - aVar.myDouble = 0.0; - tables(VALUES_ID())->setValue(aVar,0,0); - tables(VALUES_CURV_ID())->setValue(aVar,0,0); - aVar.myDouble = 1; - tables(VALUES_ID())->setValue(aVar,0,1); - tables(VALUES_CURV_ID())->setValue(aVar,0,1); - - tables(VALUES_ID())->setValue(aVar,1,0); - tables(VALUES_CURV_ID())->setValue(aVar,1,0); - aVar.myDouble = 2; - tables(VALUES_ID())->setValue(aVar,1,1); - tables(VALUES_CURV_ID())->setValue(aVar,1,1); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CREATION_MULTI_RADIUS_METHODE()); + initVersion(aSelectionEdgeSelected); + initVersion(aSelectionEdgesFacesMultiList); + initVersion(aSelectionEdgesFacesList); initVersion(aSelectionList); + } AttributePtr FeaturesPlugin_Fillet::objectsAttribute() { - if( string(CREATION_METHOD())->value() == CREATION_METHOD_MULTIPLES_RADIUSES() ) + if( string(CREATION_METHOD())->value() == METHOD_MULTIPLES_RADIUSES() ) { - if( string(CREATION_METHOD_MULTIPLES_RADIUSES())->value() == CREATION_METHOD_BY_POINTS()) + if( string(CREATION_MULTI_RADIUS_METHODE())->value() == CREATION_METHOD_BY_POINTS()) { return attribute(EDGE_SELECTED_ID()); }else{ - return attribute(EDGES_FACES_LIST_ID()); + return attribute(EDGES_FACES_MULTI_LIST_ID()); } }else if ( string(CREATION_METHOD())->value() == CREATION_METHOD_VARYING_RADIUS() ) { @@ -152,14 +142,14 @@ GeomMakeShapePtr FeaturesPlugin_Fillet::performOperation(const GeomShapePtr& the std::shared_ptr aFilletBuilder; ListOfShape aFilletEdges = extractEdges(theEdges); - if ( aCreationMethod->value() == CREATION_METHOD_MULTIPLES_RADIUSES() ) + if ( aCreationMethod->value() == METHOD_MULTIPLES_RADIUSES()) { std::list coodCurv; std::list radiuses; AttributeTablesPtr aTablesAttr; - if( string(CREATION_METHOD_MULTIPLES_RADIUSES())->value() == CREATION_METHOD_BY_POINTS() ) + if( string(CREATION_MULTI_RADIUS_METHODE())->value() == CREATION_METHOD_BY_POINTS() ) { aTablesAttr = tables(VALUES_ID()); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Fillet.h b/src/FeaturesPlugin/FeaturesPlugin_Fillet.h index 98b406cbe..b8d11935d 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Fillet.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Fillet.h @@ -61,15 +61,26 @@ public: return MY_VARYING_RADIUS; } - inline static const std::string CREATION_METHOD_MULTIPLES_RADIUSES() + inline static const std::string METHOD_MULTIPLES_RADIUSES() { static std::string MY_METHOD_MULTIPLES_RADIUSES("multiple_radiuses"); return MY_METHOD_MULTIPLES_RADIUSES; } + inline static const std::string CREATION_MULTI_RADIUS_METHODE() + { + static std::string MY_CREATION_MULTI_RADIUS_METHODE("multiple_radiuses_methode"); + return MY_CREATION_MULTI_RADIUS_METHODE; + } + + inline static const std::string CREATION_METHOD_BY_CURVILEAR_ABSCISSA() + { + static std::string MY_CREATION_METHOD_BY_CURVILEAR_ABSCISSA("by_curvilinear_abscissa_methode"); + return MY_CREATION_METHOD_BY_CURVILEAR_ABSCISSA; + } inline static const std::string CREATION_METHOD_BY_POINTS() { - static std::string MY_CREATION_METHOD_BY_POINTS("by_point_method"); + static std::string MY_CREATION_METHOD_BY_POINTS("by_points"); return MY_CREATION_METHOD_BY_POINTS; } @@ -79,11 +90,7 @@ public: return MY_ARRAY_POINT_RADIUS_BY_POINTS; } - inline static const std::string CREATION_METHOD_BY_CURVILEAR_ABSCISSA() - { - static std::string MY_CREATION_METHOD_BY_CURVILEAR_ABSCISSA("by_curvilinear_abscissa_methode"); - return MY_CREATION_METHOD_BY_CURVILEAR_ABSCISSA; - } + /// Attribute name of main objects. inline static const std::string& OBJECT_LIST_ID() @@ -98,6 +105,13 @@ public: return MY_EDGES_FACES_LIST_ID; } + /// Attribute name of main objects. + inline static const std::string& EDGES_FACES_MULTI_LIST_ID() + { + static const std::string + MY_EDGES_FACES_MULTI_LIST_ID("edges_faces_seleted_multi"); + return MY_EDGES_FACES_MULTI_LIST_ID; + } /// Attribute name of start radius. inline static const std::string& START_RADIUS_ID() { diff --git a/src/FeaturesPlugin/FeaturesPlugin_VersionedChFi.cpp b/src/FeaturesPlugin/FeaturesPlugin_VersionedChFi.cpp index 5a13070b2..51bba73a3 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_VersionedChFi.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_VersionedChFi.cpp @@ -114,7 +114,7 @@ bool FeaturesPlugin_VersionedChFi::processAttribute(const AttributePtr& theAttri { bool isStoreFullHierarchy = data()->version() == CHAMFERFILLET_VERSION_1; - AttributeSelectionPtr anObject = + AttributeSelectionPtr anObject = std::dynamic_pointer_cast(theAttribute); if( anObject.get() ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp b/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp index 4dfe53b66..d2091a551 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp @@ -158,7 +158,7 @@ FeaturesPlugin_WidgetFilletMultiRadiuses:: const Config_WidgetAPI* theData, bool TypeMethodeBypoint): ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0), - myTypeMethodeBypoint(TypeMethodeBypoint),mySetSelection(true) + myTypeMethodeBypoint(TypeMethodeBypoint),mySetSelection(true), mySortList(false) { QVBoxLayout* aMainLayout = new QVBoxLayout(this); @@ -291,20 +291,9 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::eventFilter(QObject* theObject, Q } } } - else if (theEvent->type() == QEvent::Show ) { - DataPtr aData = myFeature->data(); - if( myTypeMethodeBypoint ) - aData->string(FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES()) - ->setValue(FeaturesPlugin_Fillet::CREATION_METHOD_BY_POINTS() ); - else - aData->string(FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES()) - ->setValue(FeaturesPlugin_Fillet::CREATION_METHOD_BY_CURVILEAR_ABSCISSA() ); - } return ModuleBase_WidgetSelector::eventFilter(theObject, theEvent); } - - //********************************************************************************** bool FeaturesPlugin_WidgetFilletMultiRadiuses::storeValueCustom() { @@ -329,6 +318,35 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::storeValueCustom() aTablesAttr->setValue( getValue( aTblVal ), i, j); } } + + + if(myTypeMethodeBypoint && mySortList ){ + AttributeSelectionListPtr aSelectionListAttr = + aData->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS()); + if( aSelectionListAttr->isInitialized() ) + { + std::map>::iterator itValuesSort; + QList> alist = getAttributeSelection(); + aSelectionListAttr->clear(); + itValuesSort = myValuesSort.begin(); + for(;itValuesSort != myValuesSort.end();++itValuesSort) + { + std::pair elem = itValuesSort->second; + ResultPtr aResult; + GeomShapePtr aShape; + foreach(ModuleBase_ViewerPrsPtr aPrs, alist) { + aResult = std::dynamic_pointer_cast(aPrs->object()); + aShape = aPrs->shape(); + if (!aResult.get() && !aShape.get()) + continue; + if (aResult->data()->name()== Locale::Convert::toWString(elem.first.toStdString())) { + aSelectionListAttr->append(aResult, aShape); + break; + } + } + } + } + } return true; } @@ -350,13 +368,25 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::restoreValueCustom() else{ aTablesAttr = aData->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID()); } + + if( aTablesAttr->rows() == 0 ) + { + aTablesAttr->setSize(2,2); + ModelAPI_AttributeTables::Value aVar; + aVar.myDouble = 0.0; + aTablesAttr->setValue(aVar,0,0); + aVar.myDouble = 1; + aTablesAttr->setValue(aVar,0,1); + aTablesAttr->setValue(aVar,1,0); + aVar.myDouble = 2; + aTablesAttr->setValue(aVar,1,1); + } AttributeSelectionPtr anEdges = std::dynamic_pointer_cast( aData->attribute(FeaturesPlugin_Fillet::EDGE_SELECTED_ID())); - std::map> aValuesSort; - + myValuesSort.clear(); double res; int aRows = 0; std::map>::iterator itValuesSort; @@ -402,16 +432,18 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::restoreValueCustom() res = (aPntCurv->distance(first) / taille); QString aName = QString::fromStdWString(attsel->namingName()); QString aRad = findRadius( QString::number(res) ); - if ( aValuesSort.find( res ) == aValuesSort.end() ) - aValuesSort[ res ] = std::make_pair(aName, aRad ); + if ( myValuesSort.find( res ) == myValuesSort.end() ) + myValuesSort[ res ] = std::make_pair(aName, aRad ); i++; + mySortList = true; } res = 0.0; - aValuesSort[ res ] = std::make_pair (myfirstRowValue[0], findRadius( QString::number(res) )); + myValuesSort[ res ] = std::make_pair (myfirstRowValue[0], findRadius( QString::number(res) )); res = 1.0; - aValuesSort[ res ] = std::make_pair (myLastRowValue[0], findRadius( QString::number(res) )); - aRows = aValuesSort.size(); + std::cout << "res = restore = " << res << std::endl; + myValuesSort[ res ] = std::make_pair (myLastRowValue[0], findRadius( QString::number(res) )); + aRows = myValuesSort.size(); }else{ ModelAPI_AttributeTables::Value aVal; @@ -419,16 +451,16 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::restoreValueCustom() for (int anIndex = 0; anIndex < aTablesAttr->rows(); ++anIndex) { aVal = aTablesAttr->value(anIndex,0); double curv = getValueText(aVal).toDouble(); - if ( aValuesSort.find( curv ) == aValuesSort.end() ) - aValuesSort[ curv ] = std::make_pair(getValueText(aVal), - findRadius(getValueText(aVal))); + if ( myValuesSort.find( curv ) == myValuesSort.end() ) + myValuesSort[ curv ] = std::make_pair(getValueText(aVal), + findRadius(getValueText(aVal))); } - aRows = aValuesSort.size(); + aRows = myValuesSort.size(); }else{ res = 0.0; - aValuesSort[ res ] = std::make_pair (myfirstRowValue[0], myfirstRowValue[2]); + myValuesSort[ res ] = std::make_pair (myfirstRowValue[0], myfirstRowValue[2]); res = 1.0; - aValuesSort[ res ] = std::make_pair (myLastRowValue[0], myLastRowValue[2]); + myValuesSort[ res ] = std::make_pair (myLastRowValue[0], myLastRowValue[2]); aRows = 2; } @@ -445,7 +477,7 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::restoreValueCustom() myDataTbl->setRowCount(aRows); - itValuesSort = aValuesSort.begin(); + itValuesSort = myValuesSort.begin(); for (int k = 0; k < aRows; k++, ++itValuesSort ) { @@ -603,6 +635,7 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses:: setSelection(QList>& theValues, const bool theToValidate) { + mySortList = false; if ( theValues.size() > 1 || !myTypeMethodeBypoint || theValues.size() == 0 ) { mySetSelection = false; diff --git a/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.h b/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.h index 2e2af1f38..4de9debbf 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.h +++ b/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.h @@ -106,6 +106,7 @@ protected: /// \param theToValidate a validation of the values flag virtual bool setSelection(QList>& theValues, const bool theToValidate); + /// Return the attribute values wrapped in a list of viewer presentations /// \return a list of viewer presentations, which contains an attribute result and /// a shape. If the attribute do not uses the shape, it is empty @@ -156,10 +157,13 @@ private: bool mySetSelection; + bool mySortList; + DataArrayItemDelegate* myDelegate; std::vector myfirstRowValue; std::vector myLastRowValue; + std::map> myValuesSort; }; diff --git a/src/FeaturesPlugin/fillet_widget.xml b/src/FeaturesPlugin/fillet_widget.xml index bedfb94e3..2a756d3f7 100644 --- a/src/FeaturesPlugin/fillet_widget.xml +++ b/src/FeaturesPlugin/fillet_widget.xml @@ -34,7 +34,7 @@ use_choice="false" concealment="true"> - + - - - - - - - - - - - - + - - + + + + + + + + + +