From: Jérôme Date: Fri, 30 Oct 2020 15:53:54 +0000 (+0100) Subject: Improvement coding style, documentation, translation X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=20f92a250f9c34a32df4d52d637d1d0f60623d37;p=modules%2Fshaper.git Improvement coding style, documentation, translation --- diff --git a/src/FeaturesAPI/FeaturesAPI_Fillet.cpp b/src/FeaturesAPI/FeaturesAPI_Fillet.cpp index 1b0f7172d..4863546aa 100644 --- a/src/FeaturesAPI/FeaturesAPI_Fillet.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Fillet.cpp @@ -141,33 +141,33 @@ FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptr& theFeature, - const std::list& theEdgesFaces, + const std::list& theBaseObjects, const ModelHighAPI_Double& theRadius1, const ModelHighAPI_Double& theRadius2) : FeaturesAPI_Fillet(theFeature) { if (initialize()) { fillAttribute(FeaturesPlugin_Fillet::CREATION_METHOD_VARYING_RADIUS(), mycreationMethod); - fillAttribute(theEdgesFaces, myedgesfacesselected); + fillAttribute(theBaseObjects, mybaseObjects); fillAttribute(theRadius1, mystartRadius); fillAttribute(theRadius2, myendRadius); - if (myedgesfacesselected->size() > 0) - execute(); + + execIfBaseNotEmpty(); } } FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptr& theFeature, - const ModelHighAPI_Selection & theedgeselected, - const std::list& thepoint, + const ModelHighAPI_Selection & theEdgeSelected, + const std::list& thePoint, const std::list& theRadius) : FeaturesAPI_Fillet(theFeature) { if (initialize()) { fillAttribute(FeaturesPlugin_Fillet::METHOD_MULTIPLES_RADIUSES(), mycreationMethod); fillAttribute(FeaturesPlugin_Fillet::CREATION_METHOD_BY_POINTS(), mycreationMethodmulti); - fillAttribute(theedgeselected, myedgeselected); - fillAttribute(thepoint, myarraypointradiusbypoint); + fillAttribute(theEdgeSelected, myedgeselected); + fillAttribute(thePoint, myarraypointradiusbypoint); GeomEdgePtr anEdge = GeomEdgePtr(new GeomAPI_Edge( edgeselected()->value())); GeomPointPtr first = anEdge->firstPoint(); @@ -220,21 +220,21 @@ FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptr& theFeature, const std::list& theEdgesFaces, - const std::list& thepointCurvCood, + const std::list& thePointCurvCood, const std::list& theRadius) : FeaturesAPI_Fillet(theFeature) { if (initialize()) { fillAttribute(FeaturesPlugin_Fillet::METHOD_MULTIPLES_RADIUSES(), mycreationMethod); fillAttribute(FeaturesPlugin_Fillet::CREATION_METHOD_BY_CURVILEAR_ABSCISSA(), - mycreationMethodmulti); + mycreationMethodmulti); fillAttribute(theEdgesFaces, myedgesfacesmultiselected); int aRowIndex = 0; - myvaluescurv()->setSize( thepointCurvCood.size(), 2 ); - std::list::const_iterator aRowsCoodIter = thepointCurvCood.begin(); + myvaluescurv()->setSize( thePointCurvCood.size(), 2 ); + std::list::const_iterator aRowsCoodIter = thePointCurvCood.begin(); std::list::const_iterator aRowsRadiusIter = theRadius.begin(); - for(; aRowsCoodIter != thepointCurvCood.end(); + for(; aRowsCoodIter != thePointCurvCood.end(); aRowsCoodIter++, aRowsRadiusIter++, aRowIndex++) { ModelAPI_AttributeTables::Value aVal; aVal.myDouble = aRowsCoodIter->value(); @@ -292,7 +292,7 @@ void FeaturesAPI_Fillet2D::dump(ModelHighAPI_Dumper& theDumper) const AttributeSelectionPtr anAttrEdgeSelec = aBase->selection(FeaturesPlugin_Fillet::EDGE_SELECTED_ID()); - if( aBase->string(FeaturesPlugin_Fillet::CREATION_MULTI_RADIUS_METHODE())->value() + if( aBase->string(FeaturesPlugin_Fillet::CREATION_MULTI_RADIUS_METHOD())->value() == FeaturesPlugin_Fillet::CREATION_METHOD_BY_POINTS() ) { @@ -301,7 +301,7 @@ void FeaturesAPI_Fillet2D::dump(ModelHighAPI_Dumper& theDumper) const AttributeTablesPtr anAttrTable = aBase->tables(FeaturesPlugin_Fillet::VALUES_ID()); theDumper << aBase << " = model.addFilletMultiRadiusByPoints(" - << aDocName << ", " << anAttrEdgeSelec; + << aDocName << ", " << anAttrEdgeSelec; theDumper << ", " << anAttrPoint ; theDumper<<", ["; for(int aRow = 0; aRow < myvalues()->rows(); aRow++) { @@ -317,7 +317,7 @@ void FeaturesAPI_Fillet2D::dump(ModelHighAPI_Dumper& theDumper) const aBase->selectionList(FeaturesPlugin_Fillet::EDGES_FACES_MULTI_LIST_ID()); AttributeTablesPtr anAttrTable = aBase->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID()); theDumper << aBase << " = model.addFilletMultiRadiusBycurvAbs(" - << aDocName << ", " << anAttrEdgesFaces; + << aDocName << ", " << anAttrEdgesFaces; theDumper << ", "; theDumper<<"["; for(int aRow = 0; aRow < myvaluescurv()->rows(); aRow++) { @@ -337,7 +337,8 @@ void FeaturesAPI_Fillet2D::dump(ModelHighAPI_Dumper& theDumper) const }else { - std::string aCreationMethod = aBase->string(FeaturesPlugin_Fillet::CREATION_METHOD())->value(); + std::string aCreationMethod = + aBase->string(FeaturesPlugin_Fillet::CREATION_METHOD())->value(); if(aCreationMethod == FeaturesPlugin_Fillet::CREATION_METHOD_SINGLE_RADIUS()) { theDumper << aBase << " = model.addFillet(" << aDocName << ", " << anAttrObjects; @@ -365,9 +366,7 @@ void FeaturesAPI_Fillet2D::execIfBaseNotEmpty() execute(); } - //================================================================================================== - FilletPtr addFillet(const std::shared_ptr& thePart, const std::list& theBaseObjects, const ModelHighAPI_Double& theRadius1, @@ -393,10 +392,10 @@ FilletPtr addFillet(const std::shared_ptr& thePart, } FilletPtr addFilletMultiRadiusByPoints(const std::shared_ptr& thePart, - const ModelHighAPI_Selection & theedgeselected, - const std::list& thepoint, - const std::list& theRadius, - const bool keepSubResults) + const ModelHighAPI_Selection & theEdgeSelected, + const std::list& thePoint, + const std::list& theRadius, + const bool keepSubResults) { FeaturePtr aFeature = thePart->addFeature(FeaturesAPI_Fillet2D::ID()); @@ -405,14 +404,14 @@ FilletPtr addFilletMultiRadiusByPoints(const std::shared_ptr& FilletPtr aFillet; - aFillet.reset(new FeaturesAPI_Fillet2D(aFeature, theedgeselected, thepoint, theRadius)); + aFillet.reset(new FeaturesAPI_Fillet2D(aFeature, theEdgeSelected, thePoint, theRadius)); return aFillet; } FilletPtr addFilletMultiRadiusBycurvAbs(const std::shared_ptr& thePart, const std::list& theBaseObjects, - const std::list& thepointCurvCood, + const std::list& thePointCurvCood, const std::list& theRadius, const bool keepSubResults) { @@ -423,7 +422,7 @@ FilletPtr addFilletMultiRadiusBycurvAbs(const std::shared_ptr FilletPtr aFillet; - aFillet.reset(new FeaturesAPI_Fillet2D(aFeature, theBaseObjects, thepointCurvCood, theRadius)); + aFillet.reset(new FeaturesAPI_Fillet2D(aFeature, theBaseObjects, thePointCurvCood, theRadius)); return aFillet; } \ No newline at end of file diff --git a/src/FeaturesAPI/FeaturesAPI_Fillet.h b/src/FeaturesAPI/FeaturesAPI_Fillet.h index 3e5e45db1..413bb49f7 100644 --- a/src/FeaturesAPI/FeaturesAPI_Fillet.h +++ b/src/FeaturesAPI/FeaturesAPI_Fillet.h @@ -127,21 +127,21 @@ public: /// Constructor with values. FEATURESAPI_EXPORT explicit FeaturesAPI_Fillet2D(const std::shared_ptr& theFeature, - const std::list& theEdgesFaces, + const std::list& theBaseObjects, const ModelHighAPI_Double& theRadius1, const ModelHighAPI_Double& theRadius2); /// Constructor with values. FEATURESAPI_EXPORT explicit FeaturesAPI_Fillet2D(const std::shared_ptr& theFeature, - const ModelHighAPI_Selection& theedgeselected, - const std::list& thepoint, + const ModelHighAPI_Selection& theEdgeSelected, + const std::list& thePoint, const std::list& theRadius); /// Constructor with values. FEATURESAPI_EXPORT explicit FeaturesAPI_Fillet2D(const std::shared_ptr& theFeature, - const std::list& theEdgesFaces, + const std::list& theBaseObjects, const std::list& thepointCurvCood, const std::list& theRadius); /// Destructor. @@ -152,7 +152,7 @@ public: creationMethod, FeaturesPlugin_Fillet::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */, - creationMethodmulti, FeaturesPlugin_Fillet::CREATION_MULTI_RADIUS_METHODE(), + creationMethodmulti, FeaturesPlugin_Fillet::CREATION_MULTI_RADIUS_METHOD(), ModelAPI_AttributeString, /** Creation method */, baseObjects, FeaturesPlugin_Fillet::OBJECT_LIST_ID(), @@ -220,8 +220,8 @@ FilletPtr addFillet(const std::shared_ptr& thePart, /// \brief Create Fillet feature. FEATURESAPI_EXPORT FilletPtr addFilletMultiRadiusByPoints(const std::shared_ptr& thePart, - const ModelHighAPI_Selection & theedgeselected, - const std::list& thepoint, + const ModelHighAPI_Selection & theEdgeSelected, + const std::list& thePoint, const std::list& theRadius, const bool keepSubResults= false); @@ -231,7 +231,7 @@ FilletPtr addFilletMultiRadiusByPoints(const std::shared_ptr& FEATURESAPI_EXPORT FilletPtr addFilletMultiRadiusBycurvAbs( const std::shared_ptr& thePart, const std::list& theBaseObjects, - const std::list& thepointCurvCood, + const std::list& thePointCurvCood, const std::list& theRadius, const bool keepSubResults= false); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp b/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp index 1fc290423..0095a62e9 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp @@ -75,7 +75,7 @@ void FeaturesPlugin_Fillet::initAttributes() 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(CREATION_MULTI_RADIUS_METHOD(), ModelAPI_AttributeString::typeId()); data()->addAttribute(START_RADIUS_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(END_RADIUS_ID(), ModelAPI_AttributeDouble::typeId()); @@ -85,13 +85,17 @@ void FeaturesPlugin_Fillet::initAttributes() data()->addAttribute(ARRAY_POINT_RADIUS_BY_POINTS(), ModelAPI_AttributeSelectionList::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_MULTI_RADIUS_METHODE()); + + 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_MULTI_RADIUS_METHOD()); initVersion(aSelectionEdgeSelected); initVersion(aSelectionEdgesFacesMultiList); @@ -104,18 +108,17 @@ AttributePtr FeaturesPlugin_Fillet::objectsAttribute() { if( string(CREATION_METHOD())->value() == METHOD_MULTIPLES_RADIUSES() ) { - if( string(CREATION_MULTI_RADIUS_METHODE())->value() == CREATION_METHOD_BY_POINTS()) + if( string(CREATION_MULTI_RADIUS_METHOD())->value() == CREATION_METHOD_BY_POINTS()) { return attribute(EDGE_SELECTED_ID()); }else{ - return attribute(EDGES_FACES_MULTI_LIST_ID()); + return attribute(EDGES_FACES_MULTI_LIST_ID()); } }else if ( string(CREATION_METHOD())->value() == CREATION_METHOD_VARYING_RADIUS() ) { return attribute(EDGES_FACES_LIST_ID()); } - return attribute(OBJECT_LIST_ID()); } @@ -144,6 +147,7 @@ GeomMakeShapePtr FeaturesPlugin_Fillet::performOperation(const GeomShapePtr& the std::shared_ptr aFilletBuilder; ListOfShape aFilletEdges = extractEdges(theEdges); + if ( aCreationMethod->value() == METHOD_MULTIPLES_RADIUSES()) { @@ -151,7 +155,8 @@ GeomMakeShapePtr FeaturesPlugin_Fillet::performOperation(const GeomShapePtr& the std::list aRadiuses; AttributeTablesPtr aTablesAttr; - if( string(CREATION_MULTI_RADIUS_METHODE())->value() == CREATION_METHOD_BY_POINTS() ) + + if( string(CREATION_MULTI_RADIUS_METHOD())->value() == CREATION_METHOD_BY_POINTS() ) { aTablesAttr = tables(VALUES_ID()); @@ -167,6 +172,8 @@ GeomMakeShapePtr FeaturesPlugin_Fillet::performOperation(const GeomShapePtr& the aVal = aTablesAttr->value(k, 1); aRadiuses.push_back(aVal.myDouble); } + + aFilletBuilder.reset(new GeomAlgoAPI_Fillet(theSolid, aFilletEdges, aCoodCurv,aRadiuses)); }else diff --git a/src/FeaturesPlugin/FeaturesPlugin_Fillet.h b/src/FeaturesPlugin/FeaturesPlugin_Fillet.h index 817592837..60bba75ed 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Fillet.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Fillet.h @@ -67,15 +67,15 @@ public: return MY_METHOD_MULTIPLES_RADIUSES; } - inline static const std::string CREATION_MULTI_RADIUS_METHODE() + inline static const std::string CREATION_MULTI_RADIUS_METHOD() { - static std::string MY_CREATION_MULTI_RADIUS_METHODE("multiple_radiuses_methode"); + static std::string MY_CREATION_MULTI_RADIUS_METHODE("multiple_radiuses_method"); 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"); + static std::string MY_CREATION_METHOD_BY_CURVILEAR_ABSCISSA("by_curvilinear_abscissa_method"); return MY_CREATION_METHOD_BY_CURVILEAR_ABSCISSA; } inline static const std::string CREATION_METHOD_BY_POINTS() @@ -90,8 +90,6 @@ public: return MY_ARRAY_POINT_RADIUS_BY_POINTS; } - - /// Attribute name of main objects. inline static const std::string& OBJECT_LIST_ID() { diff --git a/src/FeaturesPlugin/FeaturesPlugin_WidgetCreator.cpp b/src/FeaturesPlugin/FeaturesPlugin_WidgetCreator.cpp index 310ef8388..fd62f428a 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_WidgetCreator.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_WidgetCreator.cpp @@ -57,6 +57,5 @@ ModuleBase_ModelWidget* FeaturesPlugin_WidgetCreator::createWidgetByType( false); } - return aWidget; } diff --git a/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp b/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp index ca8cfa72b..3c390fd16 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp @@ -68,43 +68,38 @@ const char* MYFalse = "False"; class TextFieldDoubleValidator : public QDoubleValidator { public: - TextFieldDoubleValidator (QObject * parent = 0) : QDoubleValidator(parent) {} - TextFieldDoubleValidator (double bottom, double top, int decimals, QObject * parent) : - QDoubleValidator(bottom, top, decimals, parent) {} + TextFieldDoubleValidator (QObject * theParent = 0) : QDoubleValidator(theParent) {} + TextFieldDoubleValidator (double theBottom, double theTop, int theDecimals, QObject * theParent) : + QDoubleValidator(theBottom, theTop, theDecimals, theParent) {} - QValidator::State validate(QString & s, int & pos) const { - if (s.isEmpty() || s.startsWith("0.") || s == "0" ){ + QValidator::State validate(QString & theS, int & thePos) const { + if (theS.isEmpty() || theS.startsWith("0.") || theS == "0" ){//|| s.startsWith("-")) { // allow empty field or minus sign return QValidator::Intermediate; } // check length of decimal places QChar point = locale().decimalPoint(); - if(s.indexOf(point) != -1) { - int lengthDecimals = s.length() - s.indexOf(point) - 1; - if (lengthDecimals > decimals()) { + if(theS.indexOf(point) != -1) { + int alengthDecimals = theS.length() - theS.indexOf(point) - 1; + if (alengthDecimals > decimals()) { return QValidator::Invalid; } } - // check range of value bool isNumber; - double value = locale().toDouble(s, &isNumber); - if (isNumber && bottom() <= value && value <= top()) { + double aValue = locale().toDouble(theS, &isNumber); + if (isNumber && bottom() <= aValue && aValue <= top()) { return QValidator::Acceptable; } return QValidator::Invalid; } - }; - - -DataArrayItemDelegate::DataArrayItemDelegate(bool theTypeMethode) - : QStyledItemDelegate(), myTypeMethodePoint(theTypeMethode) +DataArrayItemDelegate::DataArrayItemDelegate(bool theTypeMethod) + : QStyledItemDelegate(), myTypeMethodPoint(theTypeMethod) { } - QWidget* DataArrayItemDelegate::createEditor(QWidget* theParent, const QStyleOptionViewItem & theOption, const QModelIndex& theIndex ) const @@ -124,7 +119,7 @@ QWidget* DataArrayItemDelegate::createEditor(QWidget* theParent, if (aLineEdt) { if( theIndex.column() == 1 ){ TextFieldDoubleValidator* doubleVal = - new TextFieldDoubleValidator(0.00001 , 0.99, 6, aLineEdt); + new TextFieldDoubleValidator(0.00001 , 0.99, 6, aLineEdt); doubleVal->setNotation(TextFieldDoubleValidator::StandardNotation); aLineEdt->setValidator(doubleVal); } @@ -148,17 +143,14 @@ void DataArrayItemDelegate::onEditItem(const QString& theText) commitData(aWgt); } - -//********************************************************************************** -//********************************************************************************** //********************************************************************************** FeaturesPlugin_WidgetFilletMultiRadiuses:: FeaturesPlugin_WidgetFilletMultiRadiuses(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, - bool TypeMethodeBypoint): + bool theTypeMethodBypoint): ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0), - myTypeMethodeBypoint(TypeMethodeBypoint),mySetSelection(true), mySortList(false) + myTypeMethodBypoint(theTypeMethodBypoint),mySetSelection(true) { QVBoxLayout* aMainLayout = new QVBoxLayout(this); @@ -173,14 +165,12 @@ ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0), myDataTbl = new QTableWidget(2, 3, aRadiusesFrame); - myDelegate = new DataArrayItemDelegate(myTypeMethodeBypoint); - + myDelegate = new DataArrayItemDelegate(myTypeMethodBypoint); myDataTbl->setItemDelegate(myDelegate); - myDataTbl->verticalHeader()->hide(); myDataTbl->setRowHeight(0, 25); - if(myTypeMethodeBypoint){ + if(myTypeMethodBypoint){ myfirstRowValue.push_back("Start extremity"); myfirstRowValue.push_back("0"); myfirstRowValue.push_back("1"); @@ -196,7 +186,7 @@ ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0), myLastRowValue.push_back("2"); } - if(myTypeMethodeBypoint) + if(myTypeMethodBypoint) myDataTbl->hideColumn(1); else myDataTbl->hideColumn(0); @@ -206,20 +196,19 @@ ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0), aHeaders << "Curvilinear \n Abscissa"; aHeaders << "Radius"; - myDataTbl->setHorizontalHeaderLabels(aHeaders); - QTableWidgetItem* aItem; + QTableWidgetItem* anItem; for(int j =0; j<3;j++) { - aItem = new QTableWidgetItem(myfirstRowValue[j]); + anItem = new QTableWidgetItem(myfirstRowValue[j]); if(j==0 || j== 1) - aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled); - myDataTbl->setItem(0, j, aItem); - aItem = new QTableWidgetItem(myLastRowValue[j]); + anItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled); + myDataTbl->setItem(0, j, anItem); + anItem = new QTableWidgetItem(myLastRowValue[j]); if(j==0 || j== 1) - aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled); - myDataTbl->setItem(1, j, aItem); + anItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled); + myDataTbl->setItem(1, j, anItem); } connect(myDataTbl, SIGNAL(cellChanged(int, int)), SLOT(onTableEdited(int, int))); @@ -235,16 +224,16 @@ ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0), aBtnLayout->setContentsMargins(0, 0, 0, 0); QPushButton* aAddBtn = new QPushButton(tr("+"), aBtnWgt); - QFont font = aAddBtn->font(); - font.setPointSize(12); - aAddBtn->setFont(font); + QFont aFont = aAddBtn->font(); + aFont.setPointSize(12); + aAddBtn->setFont(aFont); aBtnLayout->addWidget(aAddBtn); aBtnLayout->addStretch(1); myRemoveBtn = new QPushButton(tr("-"), aBtnWgt); - font = myRemoveBtn->font(); - font.setPointSize(12); - myRemoveBtn->setFont(font); + aFont = myRemoveBtn->font(); + aFont.setPointSize(12); + myRemoveBtn->setFont(aFont); aBtnLayout->addWidget(myRemoveBtn); aRadiusesFrame->setLayout(aRadiusesLayout ) ; @@ -252,7 +241,8 @@ ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0), connect(aAddBtn, SIGNAL(clicked(bool)), SLOT(onAdd())); connect(myRemoveBtn, SIGNAL(clicked(bool)), SLOT(onRemove())); - connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), SLOT(onFocusChanged(QWidget*, QWidget*))); + connect(qApp,SIGNAL(focusChanged(QWidget*, QWidget*)),SLOT(onFocusChanged(QWidget*,QWidget*))); + connect(myDataTbl, SIGNAL(itemSelectionChanged()), SLOT(onListSelection())); } QList FeaturesPlugin_WidgetFilletMultiRadiuses::getControls() const @@ -275,33 +265,31 @@ QIntList FeaturesPlugin_WidgetFilletMultiRadiuses::shapeTypes() const //********************************************************************************** void FeaturesPlugin_WidgetFilletMultiRadiuses::deactivate() { + + myWorkshop->module()->enableCustomModes(); + ModuleBase_WidgetSelector::deactivate(); + + myWorkshop->module()->deactivateCustomPrs(ModuleBase_IModule::CustomizeHighlightedObjects, true); + storeValueCustom(); } //********************************************************************************** bool FeaturesPlugin_WidgetFilletMultiRadiuses::eventFilter(QObject* theObject, QEvent* theEvent) { - if (theEvent->type() == QEvent::FocusIn) { - QTableWidget* aTable = dynamic_cast(theObject); - if (aTable) { - ModuleBase_IPropertyPanel* aPanel = myWorkshop->propertyPanel(); - if (aPanel->activeWidget() != this) { - aPanel->activateWidget(this, false); - } - } - } return ModuleBase_WidgetSelector::eventFilter(theObject, theEvent); } //********************************************************************************** bool FeaturesPlugin_WidgetFilletMultiRadiuses::storeValueCustom() { + DataPtr aData = myFeature->data(); AttributeTablesPtr aTablesAttr; - if(myTypeMethodeBypoint) + if(myTypeMethodBypoint) aTablesAttr = aData->tables(FeaturesPlugin_Fillet::VALUES_ID()); else aTablesAttr = aData->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID()); @@ -319,18 +307,18 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::storeValueCustom() } } - if(myTypeMethodeBypoint && mySortList ){ + if(myTypeMethodBypoint && mySortList ){ AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS()); if( aSelectionListAttr->isInitialized() ) { - std::map>::iterator itValuesSort; + std::map>::iterator anItValuesSort; QList> alist = getAttributeSelection(); aSelectionListAttr->clear(); - itValuesSort = myValuesSort.begin(); - for(;itValuesSort != myValuesSort.end();++itValuesSort) + anItValuesSort = myValuesSort.begin(); + for(;anItValuesSort != myValuesSort.end();++anItValuesSort) { - std::pair elem = itValuesSort->second; + std::pair elem = anItValuesSort->second; ResultPtr aResult; GeomShapePtr aShape; foreach(ModuleBase_ViewerPrsPtr aPrs, alist) { @@ -346,13 +334,13 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::storeValueCustom() } } } - return true; } //********************************************************************************** bool FeaturesPlugin_WidgetFilletMultiRadiuses::restoreValueCustom() { + if ( !mySetSelection) { mySetSelection = true; return false; @@ -361,7 +349,7 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::restoreValueCustom() AttributeTablesPtr aTablesAttr; - if(myTypeMethodeBypoint){ + if(myTypeMethodBypoint){ aTablesAttr = aData->tables(FeaturesPlugin_Fillet::VALUES_ID()); } else{ @@ -369,41 +357,41 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::restoreValueCustom() } 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); - } + { + 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::dynamic_pointer_cast + (aData->attribute(FeaturesPlugin_Fillet::EDGE_SELECTED_ID())); myValuesSort.clear(); - double res; + double aRes; int aRows = 0; - std::map>::iterator itValuesSort; - if(myTypeMethodeBypoint) + std::map>::iterator anItValuesSort; + if(myTypeMethodBypoint) { if( !anEdges->isInitialized() ) return false; GeomEdgePtr anEdge = GeomEdgePtr(new GeomAPI_Edge( anEdges->value())); - GeomPointPtr first = anEdge->firstPoint(); - GeomPointPtr last = anEdge->lastPoint(); - double taille = first->distance(last); + GeomPointPtr aFirst = anEdge->firstPoint(); + GeomPointPtr aLast = anEdge->lastPoint(); + double taille = aFirst->distance(aLast); std::shared_ptr aCurve(new GeomAPI_Curve(anEdges->value())); // Load points AttributeSelectionListPtr aSelectionListAttr = - aData->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS()); + aData->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS()); AttributeDoubleArrayPtr aArrayAttr; ListOfShape aPoints; @@ -421,93 +409,95 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::restoreValueCustom() aPoints.push_back(aShape); } - int i =0; + + int anI =0; ListOfShape::const_iterator aPointsIt = aPoints.begin(); for (; aPointsIt != aPoints.end(); ++aPointsIt) { - AttributeSelectionPtr attsel = aSelectionListAttr->value(i); + AttributeSelectionPtr attsel = aSelectionListAttr->value(anI); std::shared_ptr aPnt = GeomAlgoAPI_PointBuilder::point(*aPointsIt); std::shared_ptr aPntCurv = aCurve->project(aPnt); - res = (aPntCurv->distance(first) / taille); + aRes = (aPntCurv->distance(aFirst) / taille); QString aName = QString::fromStdWString(attsel->namingName()); - QString aRad = findRadius( QString::number(res) ); - if ( myValuesSort.find( res ) == myValuesSort.end() ) - myValuesSort[ res ] = std::make_pair(aName, aRad ); - i++; + QString aRad = findRadius( QString::number(aRes) ); + if ( myValuesSort.find( aRes ) == myValuesSort.end() ) + myValuesSort[ aRes ] = std::make_pair(aName, aRad ); + anI++; mySortList = true; } - res = 0.0; - myValuesSort[ res ] = std::make_pair (myfirstRowValue[0], findRadius( QString::number(res) )); - res = 1.0; - myValuesSort[ res ] = std::make_pair (myLastRowValue[0], findRadius( QString::number(res) )); + aRes = 0.0; + myValuesSort[ aRes ] = std::make_pair (myfirstRowValue[0], findRadius( QString::number(aRes))); + aRes = 1.0; + myValuesSort[ aRes ] = std::make_pair (myLastRowValue[0], findRadius( QString::number(aRes))); aRows = myValuesSort.size(); }else{ ModelAPI_AttributeTables::Value aVal; if (aTablesAttr->isInitialized()){ + for (int anIndex = 0; anIndex < aTablesAttr->rows(); ++anIndex) { aVal = aTablesAttr->value(anIndex,0); - double curv = getValueText(aVal).toDouble(); - if ( myValuesSort.find( curv ) == myValuesSort.end() ) - myValuesSort[ curv ] = std::make_pair(getValueText(aVal), - findRadius(getValueText(aVal))); + double aCurv = getValueText(aVal).toDouble(); + if ( myValuesSort.find( aCurv ) == myValuesSort.end() ) + myValuesSort[ aCurv ] = + std::make_pair(getValueText(aVal),findRadius(getValueText(aVal))); } aRows = myValuesSort.size(); }else{ - res = 0.0; - myValuesSort[ res ] = std::make_pair (myfirstRowValue[0], myfirstRowValue[2]); - res = 1.0; - myValuesSort[ res ] = std::make_pair (myLastRowValue[0], myLastRowValue[2]); + aRes = 0.0; + myValuesSort[ aRes ] = std::make_pair (myfirstRowValue[0], myfirstRowValue[2]) ; + aRes = 1.0; + myValuesSort[ aRes ] = std::make_pair (myLastRowValue[0], myLastRowValue[2]) ; aRows = 2; } } - QTableWidgetItem* aItem = 0; + QTableWidgetItem* anItem = 0; myDataTbl->blockSignals(true); - aItem = myDataTbl->item( myDataTbl->rowCount() -1, 0 ); - aItem->setFlags(Qt::NoItemFlags - | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); - aItem = myDataTbl->item( myDataTbl->rowCount() -1, 1 ); - aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable - | Qt::ItemIsEnabled | Qt::ItemIsEditable); + anItem = myDataTbl->item( myDataTbl->rowCount() -1, 0 ); + anItem->setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable + | Qt::ItemIsEnabled | Qt::ItemIsEditable); + anItem = myDataTbl->item( myDataTbl->rowCount() -1, 1 ); + anItem->setFlags(Qt::NoItemFlags | Qt::ItemIsSelectable + | Qt::ItemIsEnabled | Qt::ItemIsEditable); myDataTbl->setRowCount(aRows); - itValuesSort = myValuesSort.begin(); + anItValuesSort = myValuesSort.begin(); - for (int k = 0; k < aRows; k++, ++itValuesSort ) { + for (int k = 0; k < aRows; k++, ++anItValuesSort ) { - std::pair elem = itValuesSort->second; - QString aCurv = QString::number(itValuesSort->first); + std::pair elem = anItValuesSort->second; + QString aCurv = QString::number(anItValuesSort->first); - aItem = myDataTbl->item(k, 0); - if (aItem) { - aItem->setText( elem.first); + anItem = myDataTbl->item(k, 0); + if (anItem) { + anItem->setText( elem.first); } else { - aItem = new QTableWidgetItem(elem.first); - myDataTbl->setItem(k, 0, aItem); + anItem = new QTableWidgetItem(elem.first); + myDataTbl->setItem(k, 0, anItem); } - aItem = myDataTbl->item(k, 1); - if (aItem) { - aItem->setText( aCurv); + anItem = myDataTbl->item(k, 1); + if (anItem) { + anItem->setText( aCurv); } else { - aItem = new QTableWidgetItem(aCurv); - myDataTbl->setItem(k, 1, aItem); + anItem = new QTableWidgetItem(aCurv); + myDataTbl->setItem(k, 1, anItem); } - aItem = myDataTbl->item(k, 2); - if (aItem) { - aItem->setText( elem.second); + anItem = myDataTbl->item(k, 2); + if (anItem) { + anItem->setText( elem.second); } else { - aItem = new QTableWidgetItem(elem.second); - myDataTbl->setItem(k, 2, aItem); + anItem = new QTableWidgetItem(elem.second); + myDataTbl->setItem(k, 2, anItem); } } - aItem = myDataTbl->item(myDataTbl->rowCount()-1, 0 ); - aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled ); - aItem = myDataTbl->item(myDataTbl->rowCount()-1, 1 ); - aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled ); + anItem = myDataTbl->item(myDataTbl->rowCount()-1, 0 ); + anItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled ); + anItem = myDataTbl->item(myDataTbl->rowCount()-1, 1 ); + anItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled ); myDataTbl->blockSignals(false); return true; @@ -517,8 +507,8 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::restoreValueCustom() //********************************************************************************** void FeaturesPlugin_WidgetFilletMultiRadiuses::onAdd() { - QModelIndex index = myDataTbl->currentIndex(); - int i = index.row(); + QModelIndex anIndex = myDataTbl->currentIndex(); + int i = anIndex.row(); if( i != -1 && !(!myDataTbl->currentItem()->isSelected() && myDataTbl->rowCount() >2)) { @@ -532,18 +522,18 @@ void FeaturesPlugin_WidgetFilletMultiRadiuses::onAdd() i = 1; else i= i+1; - myDataTbl->model()->insertRow(i); - QTableWidgetItem* aItem =0; + myDataTbl->model()->insertRow(i); - aItem = myDataTbl->item( i, 0 ); - aItem = new QTableWidgetItem( "" ); - myDataTbl->setItem(i, 0, aItem); - aItem = new QTableWidgetItem("0.1"); - myDataTbl->setItem(i, 1, aItem); + QTableWidgetItem* anItem =0; - aItem = new QTableWidgetItem("0.5"); - myDataTbl->setItem(i, 2, aItem); + anItem = myDataTbl->item( i, 0 ); + anItem = new QTableWidgetItem( "" ); + myDataTbl->setItem(i, 0, anItem); + anItem = new QTableWidgetItem("0.1"); + myDataTbl->setItem(i, 1, anItem); + anItem = new QTableWidgetItem("0.5"); + myDataTbl->setItem(i, 2, anItem); myDataTbl->blockSignals(false); emit valuesChanged(); @@ -554,31 +544,30 @@ void FeaturesPlugin_WidgetFilletMultiRadiuses::onAdd() //********************************************************************************** void FeaturesPlugin_WidgetFilletMultiRadiuses::onRemove() { - QModelIndex index = myDataTbl->currentIndex(); + QModelIndex anIndex = myDataTbl->currentIndex(); if( myDataTbl->currentItem()->isSelected() && myDataTbl->rowCount() >2 - && index.row() != -1 - && index.row() != 0 - && index.row() != myDataTbl->rowCount() -1){ + && anIndex.row() != -1 + && anIndex.row() != 0 + && anIndex.row() != myDataTbl->rowCount() -1){ myDataTbl->blockSignals(true); - if (myTypeMethodeBypoint) + if (myTypeMethodBypoint) { - QString aName = myDataTbl->item( index.row() , 0 )->text(); + QString aName = myDataTbl->item( anIndex.row() , 0 )->text(); AttributeSelectionListPtr aSelList = - myFeature->data() - ->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS()); + myFeature->data()->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS()); - AttributeSelectionPtr aAttr; + AttributeSelectionPtr anAttr; for (int i = 0; i < aSelList->size(); i++) { - aAttr = aSelList->value(i); - if( aName == QString::fromStdWString( aAttr->namingName()) ) + anAttr = aSelList->value(i); + if( aName == QString::fromStdWString( anAttr->namingName()) ) { aSelList->remove({i}); } } } - myDataTbl->model()->removeRow(index.row()); + myDataTbl->model()->removeRow(anIndex.row()); myDataTbl->blockSignals(false); emit valuesChanged(); @@ -602,7 +591,7 @@ void FeaturesPlugin_WidgetFilletMultiRadiuses::onTableEdited(int theRow, int the AttributeTablesPtr aTablesAttr; - if(myTypeMethodeBypoint) + if(myTypeMethodBypoint) aTablesAttr = myFeature->data()->tables(FeaturesPlugin_Fillet::VALUES_ID()); else aTablesAttr = myFeature->data()->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID()); @@ -632,9 +621,8 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::processEnter() bool FeaturesPlugin_WidgetFilletMultiRadiuses:: setSelection(QList>& theValues, const bool theToValidate) { - mySortList = false; - if ( theValues.size() > 1 || !myTypeMethodeBypoint || theValues.size() == 0 ) + if ( theValues.size() > 1 || !myTypeMethodBypoint || theValues.size() == 0 ) { mySetSelection = false; return false; @@ -705,7 +693,7 @@ QString FeaturesPlugin_WidgetFilletMultiRadiuses::findRadius(QString thename) co { AttributeTablesPtr aTablesAttr; - if(myTypeMethodeBypoint) + if(myTypeMethodBypoint) aTablesAttr = myFeature->data()->tables(FeaturesPlugin_Fillet::VALUES_ID()); else aTablesAttr = myFeature->data()->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID()); @@ -724,8 +712,71 @@ QString FeaturesPlugin_WidgetFilletMultiRadiuses::findRadius(QString thename) co //********************************************************************************** QString FeaturesPlugin_WidgetFilletMultiRadiuses:: - getValueText(ModelAPI_AttributeTables::Value& theVal) const + getValueText(ModelAPI_AttributeTables::Value& theVal) const { - return QString::number(theVal.myDouble); } + +//******************************************************************** +void FeaturesPlugin_WidgetFilletMultiRadiuses:: + getHighlighted(QList& theValues) +{ + std::set anAttributeIds; + getSelectedAttributeIndices(anAttributeIds); + if (!anAttributeIds.empty()) + convertIndicesToViewerSelection(anAttributeIds, theValues); +} + +//******************************************************************** +void FeaturesPlugin_WidgetFilletMultiRadiuses:: + getSelectedAttributeIndices(std::set& theAttributeIds) +{ + QModelIndexList indexList = myDataTbl->selectionModel()->selectedIndexes(); + int aRow; + foreach (QModelIndex index, indexList) { + aRow = index.row(); + theAttributeIds.insert(aRow-1); + } +} + +void FeaturesPlugin_WidgetFilletMultiRadiuses:: + convertIndicesToViewerSelection(std::set theAttributeIds, + QList& theValues) const +{ + if(myFeature.get() == NULL) + return; + + DataPtr aData = myFeature->data(); + AttributePtr anAttribute = + aData->attribute(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS()); + + AttributeSelectionListPtr aSelectionListAttr = + aData->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS()); + for (int i = 0; i < aSelectionListAttr->size(); i++) { + // filter by attribute indices only if the container is not empty otherwise return all items + if (!theAttributeIds.empty() && theAttributeIds.find(i) == theAttributeIds.end()) + continue; + AttributeSelectionPtr anAttr = aSelectionListAttr->value(i); + ObjectPtr anObject = anAttr->contextObject(); + if (anObject.get()) + theValues.append(std::shared_ptr( + new ModuleBase_ViewerPrs(anObject, anAttr->value(), NULL))); + } +} + +//******************************************************************** +void FeaturesPlugin_WidgetFilletMultiRadiuses::onListSelection() +{ + myWorkshop->module()->customizeFeature(myFeature,ModuleBase_IModule::CustomizeHighlightedObjects, + true); +} + +//******************************************************************** +void FeaturesPlugin_WidgetFilletMultiRadiuses::activateCustom() +{ + ModuleBase_WidgetSelector::activateCustom(); + + ModuleBase_IModule* aModule = myWorkshop->module(); + aModule->activateCustomPrs(myFeature, + ModuleBase_IModule::CustomizeHighlightedObjects, true); +} diff --git a/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.h b/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.h index 4de9debbf..4d60f3389 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.h +++ b/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.h @@ -41,7 +41,7 @@ class DataArrayItemDelegate : public QStyledItemDelegate { Q_OBJECT public: - DataArrayItemDelegate(bool theTypeMethode); + DataArrayItemDelegate(bool theTypeMethod); virtual QWidget* createEditor(QWidget* theParent, const QStyleOptionViewItem & theOption, @@ -51,7 +51,7 @@ private slots: void onEditItem(const QString& theText); private: - bool myTypeMethodePoint; + bool myTypeMethodPoint; }; @@ -66,7 +66,7 @@ public: FeaturesPlugin_WidgetFilletMultiRadiuses(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, const Config_WidgetAPI* theData, - bool TypeMethodeBypoint); + bool TypeMethodBypoint); virtual ~FeaturesPlugin_WidgetFilletMultiRadiuses() {} @@ -81,7 +81,15 @@ public: /// \return a boolean value virtual bool isValidSelectionCustom(const std::shared_ptr& theValue); + /// Returns values which should be highlighted when the whidget is active + /// \param theValues a list of presentations + virtual void getHighlighted(QList>& theValues); + protected: + /// The methiod called when widget is activated + virtual void activateCustom(); + + /// Saves the internal parameters to the given feature /// \return True in success virtual bool storeValueCustom(); @@ -112,6 +120,16 @@ protected: /// a shape. If the attribute do not uses the shape, it is empty virtual QList> getAttributeSelection() const; + /// Returns attribute indices selected in the widget selection list + /// \param theIndices a list of indices + void getSelectedAttributeIndices(std::set& theIndices); + + /// Gets the feature attribute and fill a list of viewer presentation for the attribute + /// indices. If the the container of indices is empty, it returns all objects. + /// \param theAttributeIds indices in attribute list to be returned + /// \param theValues the result presentations, filled with object and shape of an attribute item + void convertIndicesToViewerSelection(std::set theAttributeIds, + QList>& theValues) const; private slots: /// Slot called on add a row @@ -129,6 +147,8 @@ private slots: /// \param theCol a column of the cell void onTableEdited(int theRow, int theCol); + /// Slot is called on selection of list of selected items + void onListSelection(); private: @@ -153,16 +173,20 @@ private: /// Editor for table header QLineEdit* myHeaderEditor; - bool myTypeMethodeBypoint; + // Choice of the method + bool myTypeMethodBypoint; + //Sort the selection bool mySetSelection; bool mySortList; DataArrayItemDelegate* myDelegate; + // Label for first and last row std::vector myfirstRowValue; std::vector myLastRowValue; + // map to sort std::map> myValuesSort; }; diff --git a/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts b/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts index aeebd768d..9eb3e05e6 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts +++ b/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts @@ -971,7 +971,26 @@ Rayon du congé au point final. - + + Fillet:multiple_radiuses + + Radii + Rayons + + + Radius + Rayon + + + Curvilinear \n Abscissa + Abscisse \n curviligne + + + Edges or/and faces + Arêtes et/ou faces + + + Fillet1D diff --git a/src/FeaturesPlugin/doc/TUI_filletvariableFeature.rst b/src/FeaturesPlugin/doc/TUI_filletvariableFeature.rst index 36311a584..a2b47959c 100644 --- a/src/FeaturesPlugin/doc/TUI_filletvariableFeature.rst +++ b/src/FeaturesPlugin/doc/TUI_filletvariableFeature.rst @@ -9,3 +9,25 @@ Create Fillet by variable radius :language: python :download:`Download this script ` + + .. _tui_create_fillet_MultiRadiusBycurvAbs: + +Create Fillet with multiple radiuses by curvilinear abscissa +============================================================ + +.. literalinclude:: examples/filletMultiRadiusBycurvAbs.py + :linenos: + :language: python + +:download:`Download this script ` + + .. _tui_create_filletMultiRadiusByPoints: + +Create Fillet with multiple radiuses by points +============================================== + +.. literalinclude:: examples/filletMultiRadiusByPoints.py + :linenos: + :language: python + +:download:`Download this script ` diff --git a/src/FeaturesPlugin/doc/examples/filletMultiRadiusByPoints.py b/src/FeaturesPlugin/doc/examples/filletMultiRadiusByPoints.py new file mode 100644 index 000000000..d3f3ca65c --- /dev/null +++ b/src/FeaturesPlugin/doc/examples/filletMultiRadiusByPoints.py @@ -0,0 +1,17 @@ +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +### Create Point +Point_1 = model.addPoint(Part_1_doc, model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), 0.5, True, False) +Point_2 = model.addPoint(Part_1_doc, model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), 0.2, True, False) +Fillet_1 = model.addFilletMultiRadiusByPoints(Part_1_doc, + model.selection("EDGE", "[Box_1_1/Left][Box_1_1/Top]"), + [model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2")], + [1, 0.5, 0.5, 2], keepSubResults = True) + +model.do() +model.end() diff --git a/src/FeaturesPlugin/doc/examples/filletMultiRadiusBycurvAbs.py b/src/FeaturesPlugin/doc/examples/filletMultiRadiusBycurvAbs.py new file mode 100644 index 000000000..02456d833 --- /dev/null +++ b/src/FeaturesPlugin/doc/examples/filletMultiRadiusBycurvAbs.py @@ -0,0 +1,12 @@ +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Box_1 = model.addBox(Part_1_doc, 10, 10, 10) +Fillet_1 = model.model.addFilletMultiRadiusBycurvAbs + (Part_1_doc, [model.selection("EDGE", "[Box_1_1/Front][Box_1_1/Top]")], + [0, 0.5, 1],[1, 0.5, 1], keepSubResults = True) +model.do() +model.end() diff --git a/src/FeaturesPlugin/doc/filletFeature.rst b/src/FeaturesPlugin/doc/filletFeature.rst index b41c2e16b..c501ed4fe 100644 --- a/src/FeaturesPlugin/doc/filletFeature.rst +++ b/src/FeaturesPlugin/doc/filletFeature.rst @@ -12,7 +12,7 @@ To create a Fillet in the active part: #. select in the Main Menu *Feature - > Fillet* item or #. click |fillet.icon| **Fillet** button in the toolbar -There are 2 types of fillet: +There are 3 types of fillet: .. figure:: images/fillet_fixed_radius.png :align: left @@ -26,6 +26,12 @@ fillet by fixed radius fillet by variable radius +.. figure:: images/fillet_var_multiple_radiuses.png + :align: left + :height: 24px + +fillet by multiple radius + -------------------------------------------------------------------------------- Fillet by fixed radius @@ -40,15 +46,15 @@ The property panel is shown below. Input fields: -- **Faces or/and edges** panel contains filleted faces and edges. All edges of a face are subject to fillet operation. Faces and edges are selected in 3D OCC viewer; +- **Faces, edges or/and solids** panel contains filleted faces, edges and solids. All edges of a face or solid are subject to fillet operation. Faces, edges and solids are selected in 3D OCC viewer; - **Radius** defines fillet radius. **TUI Command**: -.. py:function:: model.addFillet(Part_doc, [face,edge], radius) +.. py:function:: model.addFillet(Part_doc, [face,edge,solid], radius) :param part: The current part object. - :param list: A list of faces and edges subject to fillet operation in format *model.selection(TYPE, shape)*. + :param list: A list of faces, edges and solids subject to fillet operation in format *model.selection(TYPE, shape)*. :param number: Radius value. :return: Created object. @@ -101,3 +107,104 @@ Result of **Fillet by variable radius** is shown below. Fillet by variable radius **See Also** a sample TUI Script of :ref:`tui_create_fillet2` operation. + +Fillet by multiple radius +------------------------- + +There is a possibility to create a fillet with multiple radius define along an edge. + +.. figure:: images/FilletMultipleRadius.png + :align: center + + Fillet by multiple radius + +There are two methods for creating a fillet by multiple radius : + +.. figure:: images/fillet_multiradius_by_curv.png + :align: left + :height: 24px + +Fillet with multiple radiuses by curvilinear abscissa + +.. figure:: images/fillet_multiradius_by_point.png + :align: left + :height: 24px + +Fillet with multiple radiuses by points + +Fillet with multiple radiuses by curvilinear abscissa +""""""""""""""""""""""""""""""""""""""""""""""""""""" +The property panel is shown below. + +.. figure:: images/FilletMultiplebycurv.png + :align: center + + Fillet with multiple radiuses by curvilinear abscissa property panel + +Input fields: + +- **Edges or/and faces** panel contains filleted faces and edges. All edges of a face are subject to fillet operation. Faces and edges are selected in 3D OCC viewer; +- **Radii** table allows to define a radius for each selected abscissa along the selected edge(s); + - **Curvilinea Abscissa** contains the curvilinear abscissa of points on edge; + - **Radius** contains the radius for each point. + +**TUI Command**: + +.. py:function:: model.addFilletMultiRadiusBycurvAbs(Part_doc, shapes, listAbsc, listRadius) + + :param document Part_doc: The current part object. + :param list shapes: A list of faces and edges subject to fillet operation in format *model.selection(TYPE, shape)*. + :param listAbsc: list of curvilinea abscissa. + :param listRadius: list of radius value. + :return: Created object. + +Result +"""""" + +Result of **Fillet with multiple radiuses by curvilinear abscissa** is shown below. + +.. figure:: images/filletmultiRadiusCurvResult.png + :align: center + + Fillet with multiple radiuses by curvilinear abscissa + +**See Also** a sample TUI Script of :ref:`tui_create_fillet_MultiRadiusBycurvAbs` operation. + +Fillet with multiple radiuses by points +""""""""""""""""""""""""""""""""""""""" +The property panel is shown below. + +.. figure:: images/FilletMultiplebypoint.png + :align: center + + Fillet with multiple radiuses by points property panel + +Input fields: + +- Selection panel contains one edge which has to be selected in 3D OCC viewer; +- **Radii** defines the radius along the selected edge; + - **Point** column contains points on edge. These points have to selected in 3D OCC viewer; + - **Radius** column contains the radius for each selected point. + +**TUI Command**: + +.. py:function:: model.addFilletMultiRadiusByPoints(Part_doc, edge, Points, ListRadius) + + :param document Part_doc: The current part object. + :param edge: An edge subject to fillet operation in format *model.selection(TYPE, shape)*. + :param Points: list of point in format *model.selection(TYPE, shape)*. + :param ListRadius: list of radius value. + :return: Created object. + +Result +"""""" + +Result of **Fillet with multiple radiuses by points** is shown below. + +.. figure:: images/filletmultiRadiuspointResult.png + :align: center + + Fillet with multiple radiuses by points + +**See Also** a sample TUI Script of :ref:`tui_create_filletMultiRadiusByPoints` operation. + diff --git a/src/FeaturesPlugin/doc/images/FilletFixed.png b/src/FeaturesPlugin/doc/images/FilletFixed.png index 9b2b15d3e..11e5d3e1e 100644 Binary files a/src/FeaturesPlugin/doc/images/FilletFixed.png and b/src/FeaturesPlugin/doc/images/FilletFixed.png differ diff --git a/src/FeaturesPlugin/doc/images/FilletMultipleRadius.png b/src/FeaturesPlugin/doc/images/FilletMultipleRadius.png new file mode 100644 index 000000000..76adbb1e8 Binary files /dev/null and b/src/FeaturesPlugin/doc/images/FilletMultipleRadius.png differ diff --git a/src/FeaturesPlugin/doc/images/FilletMultiplebycurv.png b/src/FeaturesPlugin/doc/images/FilletMultiplebycurv.png new file mode 100644 index 000000000..6664adc23 Binary files /dev/null and b/src/FeaturesPlugin/doc/images/FilletMultiplebycurv.png differ diff --git a/src/FeaturesPlugin/doc/images/FilletMultiplebypoint.png b/src/FeaturesPlugin/doc/images/FilletMultiplebypoint.png new file mode 100644 index 000000000..4645c9118 Binary files /dev/null and b/src/FeaturesPlugin/doc/images/FilletMultiplebypoint.png differ diff --git a/src/FeaturesPlugin/doc/images/FilletVarious.png b/src/FeaturesPlugin/doc/images/FilletVarious.png index fbcdf4c82..88545bbea 100644 Binary files a/src/FeaturesPlugin/doc/images/FilletVarious.png and b/src/FeaturesPlugin/doc/images/FilletVarious.png differ diff --git a/src/FeaturesPlugin/doc/images/fillet_multiradius_by_curv.png b/src/FeaturesPlugin/doc/images/fillet_multiradius_by_curv.png new file mode 100644 index 000000000..015d270bf Binary files /dev/null and b/src/FeaturesPlugin/doc/images/fillet_multiradius_by_curv.png differ diff --git a/src/FeaturesPlugin/doc/images/fillet_multiradius_by_point.png b/src/FeaturesPlugin/doc/images/fillet_multiradius_by_point.png new file mode 100644 index 000000000..53dbb0820 Binary files /dev/null and b/src/FeaturesPlugin/doc/images/fillet_multiradius_by_point.png differ diff --git a/src/FeaturesPlugin/doc/images/fillet_var_multiple_radiuses.png b/src/FeaturesPlugin/doc/images/fillet_var_multiple_radiuses.png new file mode 100644 index 000000000..1951a8e4f Binary files /dev/null and b/src/FeaturesPlugin/doc/images/fillet_var_multiple_radiuses.png differ diff --git a/src/FeaturesPlugin/doc/images/filletmultiRadiusCurvResult.png b/src/FeaturesPlugin/doc/images/filletmultiRadiusCurvResult.png new file mode 100644 index 000000000..d167d1725 Binary files /dev/null and b/src/FeaturesPlugin/doc/images/filletmultiRadiusCurvResult.png differ diff --git a/src/FeaturesPlugin/doc/images/filletmultiRadiuspointResult.png b/src/FeaturesPlugin/doc/images/filletmultiRadiuspointResult.png new file mode 100644 index 000000000..f8fd816b1 Binary files /dev/null and b/src/FeaturesPlugin/doc/images/filletmultiRadiuspointResult.png differ diff --git a/src/FeaturesPlugin/fillet_widget.xml b/src/FeaturesPlugin/fillet_widget.xml index 2a756d3f7..b634ce52b 100644 --- a/src/FeaturesPlugin/fillet_widget.xml +++ b/src/FeaturesPlugin/fillet_widget.xml @@ -55,8 +55,8 @@ title="Multiple radiuses" tooltip="Fillet with multiple radiuses" icon="icons/Features/fillet_var_multiple_radiuses.png"> - - + diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml index 74b60d59a..ba80beedd 100644 --- a/src/FeaturesPlugin/plugin-Features.xml +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -126,7 +126,7 @@ + icon="icons/Features/fillet.png" auto_preview="true" helpfile="filletFeature.html"> ::const_iterator itCurv = theCurvCoord.begin(); - std::list::const_iterator itRadius = theRadiuses.begin(); + std::list::const_iterator anItCurv = theCurvCoord.begin(); + std::list::const_iterator anItRadius = theRadiuses.begin(); - for( ; itCurv != theCurvCoord.end(); ++itCurv, ++itRadius ) + for( ; anItCurv != theCurvCoord.end(); ++anItCurv, ++anItRadius ) { - array.SetValue(i, gp_Pnt2d( (*itCurv) , (*itRadius))); + array.SetValue(i, gp_Pnt2d( (*anItCurv) , (*anItRadius))); i++; } // assign fillet radii for each contour of filleting edges