From: nds Date: Fri, 18 Dec 2015 18:20:43 +0000 (+0300) Subject: An attempt to realize the separation of VERTEX/EDGE/FACE for the modified attribute... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FBR_SKETCH_SHAPE_PLUGIN;p=modules%2Fshaper.git An attempt to realize the separation of VERTEX/EDGE/FACE for the modified attribute on the FEATURE side. The problem is that ::attributeChanged is called 1. too many times, 2. until shape is set in attribute selection (only object is set). --- diff --git a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp b/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp index 89d9356b9..c6cea8911 100755 --- a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp +++ b/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.cpp @@ -7,6 +7,8 @@ #include #include +#include + #include #include @@ -25,10 +27,12 @@ ModuleBase_WidgetCheckGroupBox::ModuleBase_WidgetCheckGroupBox(QWidget* theParen { QString aToolTip = QString::fromStdString(theData->widgetTooltip()); bool isChecked = theData->getBooleanAttribute(ATTR_DEFAULT, false); + QString aGroupName = QString::fromStdString(theData->getProperty(CONTAINER_PAGE_NAME)); QVBoxLayout* aMainLayout = new QVBoxLayout(this); ModuleBase_Tools::zeroMargins(aMainLayout); myGroupBox = new QGroupBox(this); + myGroupBox->setTitle(aGroupName); myGroupBox->setCheckable(true); myGroupBox->setToolTip(aToolTip); myGroupBox->setChecked(isChecked); @@ -46,11 +50,6 @@ ModuleBase_WidgetCheckGroupBox::~ModuleBase_WidgetCheckGroupBox() { } -void ModuleBase_WidgetCheckGroupBox::setTitle(const QString& theTitle) -{ - myGroupBox->setTitle(theTitle); -} - QWidget* ModuleBase_WidgetCheckGroupBox::pageWidget() { return myGroupBox; diff --git a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h b/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h index 4d8c12a41..b276c68dd 100755 --- a/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h +++ b/src/ModuleBase/ModuleBase_WidgetCheckGroupBox.h @@ -31,8 +31,6 @@ public: const std::string& theParentId); virtual ~ModuleBase_WidgetCheckGroupBox(); - void setTitle(const QString& theTitle); - /// Methods to be redefined from ModuleBase_PageBase: start /// Cast the page to regular QWidget virtual QWidget* pageWidget(); diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index f32f0aca8..1d8b6c073 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -133,10 +133,8 @@ ModuleBase_PageBase* ModuleBase_WidgetFactory::createPageByType(const std::strin aResult = aPage; } else if (theType == WDG_CHECK_GROUP) { - QString aGroupName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME)); ModuleBase_WidgetCheckGroupBox* aPage = new ModuleBase_WidgetCheckGroupBox(theParent, myWidgetApi, myParentId); - aPage->setTitle(aGroupName); aResult = aPage; } if (!aResult) diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 95dfd185f..fe92347df 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -113,6 +113,9 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen QLabel* aListLabel = new QLabel(!aLabelText.empty() ? aLabelText.c_str() : tr("Selected objects:"), this); aMainLay->addWidget(aListLabel, 1, 0); + bool aUseListLabel = theData->getBooleanAttribute("use_label", true); + if (!aUseListLabel) + aListLabel->setVisible(false); // if the xml definition contains one type, an information label should be shown near to the latest if (aShapeTypes.size() <= 1) { QString aLabelIcon = QString::fromStdString(theData->widgetIcon()); diff --git a/src/SketchShapePlugin/SketchShapePlugin_Feature.cpp b/src/SketchShapePlugin/SketchShapePlugin_Feature.cpp index 4de0c8de3..93f50ebe0 100755 --- a/src/SketchShapePlugin/SketchShapePlugin_Feature.cpp +++ b/src/SketchShapePlugin/SketchShapePlugin_Feature.cpp @@ -14,7 +14,7 @@ #include SketchShapePlugin_Feature::SketchShapePlugin_Feature() -: ModelAPI_Feature() +: ModelAPI_Feature(), myIsAttributeChangeBlocked(false) { } @@ -41,6 +41,9 @@ void SketchShapePlugin_Feature::execute() void SketchShapePlugin_Feature::attributeChanged(const std::string& theID) { + if (myIsAttributeChangeBlocked) + return; + if (theID == VERTEX_CHOICE_ID() || theID == EDGE_CHOICE_ID() || theID == FACE_CHOICE_ID()) { @@ -51,25 +54,74 @@ void SketchShapePlugin_Feature::attributeChanged(const std::string& theID) AttributeBooleanPtr aChoiceAttribute = std::dynamic_pointer_cast( data()->attribute(theID)); if (!aChoiceAttribute->value()) { - AttributeSelectionListPtr aListAttribute = - std::dynamic_pointer_cast(data()->attribute(aListAttrId)); + AttributeSelectionListPtr aListAttribute = data()->selectionList(aListAttrId); aListAttribute->clear(); } } else if (theID == VERTEX_LIST_ID() || theID == EDGE_LIST_ID() || theID == FACE_LIST_ID()) { - AttributeSelectionListPtr aSelectionListAttr = - std::dynamic_pointer_cast(data()->attribute(theID)); - for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize; i++) { - AttributeSelectionPtr aSelectAttr = aSelectionListAttr->value(i); - ObjectPtr anObject = aSelectAttr->context(); + myIsAttributeChangeBlocked = true; + + DataPtr aData = data(); + AttributeSelectionListPtr aChangedAttr = aData->selectionList(theID); + + AttributeSelectionListPtr aVertexAttr = aData->selectionList(VERTEX_LIST_ID()); + AttributeSelectionListPtr anEdgeAttr = aData->selectionList(EDGE_LIST_ID()); + AttributeSelectionListPtr aFaceAttr = aData->selectionList(FACE_LIST_ID()); + + if (theID != VERTEX_LIST_ID()) + aVertexAttr->clear(); + if (theID != EDGE_LIST_ID()) + anEdgeAttr->clear(); + if (theID != FACE_LIST_ID()) + aFaceAttr->clear(); + + std::list > aChangedAttrValues; + for (int i = 0, aSize = aChangedAttr->size(); i < aSize; i++) { + AttributeSelectionPtr aSelectAttr = aChangedAttr->value(i); + ResultPtr anObject = aSelectAttr->context(); if (!anObject.get()) continue; else { - FeaturePtr aFeature = ModelAPI_Feature::feature(anObject); + GeomShapePtr aGeomShape = aSelectAttr->value(); + if (aGeomShape.get() == NULL) + aGeomShape = anObject->shape(); + + if (aGeomShape.get() == NULL) + continue; + + GeomAPI_Shape::ShapeType aShapeType = aGeomShape->shapeType(); + if (aGeomShape->isVertex()) { + if (theID == VERTEX_LIST_ID()) + aChangedAttrValues.push_back(std::make_pair(anObject, aGeomShape)); + else { + aVertexAttr->append(anObject, aGeomShape); + } + } + else if (aGeomShape->isEdge()) { + if (theID == EDGE_LIST_ID()) + aChangedAttrValues.push_back(std::make_pair(anObject, aGeomShape)); + else { + anEdgeAttr->append(anObject, aGeomShape); + } + } + else if (aGeomShape->isFace()) { + if (theID == FACE_LIST_ID()) + aChangedAttrValues.push_back(std::make_pair(anObject, aGeomShape)); + else { + aFaceAttr->append(anObject, aGeomShape); + } + } } } + //aChangedAttr->clear(); + std::list >::const_iterator anIt = aChangedAttrValues.begin(), + aLast = aChangedAttrValues.end(); + for (; anIt != aLast; anIt++) + aChangedAttr->append((*anIt).first, (*anIt).second); + + myIsAttributeChangeBlocked = false; } } diff --git a/src/SketchShapePlugin/SketchShapePlugin_Feature.h b/src/SketchShapePlugin/SketchShapePlugin_Feature.h index 0a59da95d..2add7c231 100755 --- a/src/SketchShapePlugin/SketchShapePlugin_Feature.h +++ b/src/SketchShapePlugin/SketchShapePlugin_Feature.h @@ -97,6 +97,9 @@ class SketchShapePlugin_Feature : public ModelAPI_Feature /// Use plugin manager for features creation SketchShapePlugin_Feature(); + +protected: + bool myIsAttributeChangeBlocked; /// flag to do not apply attributeChanged functionality }; #endif diff --git a/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.cpp b/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.cpp index db4d9eb70..e2f443e44 100755 --- a/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.cpp +++ b/src/SketchShapePlugin/SketchShapePlugin_PageGroupBox.cpp @@ -6,6 +6,9 @@ #include +#include +#include + SketchShapePlugin_PageGroupBox::SketchShapePlugin_PageGroupBox(QWidget* theParent) : ModuleBase_PageGroupBox(theParent) { @@ -13,6 +16,12 @@ SketchShapePlugin_PageGroupBox::SketchShapePlugin_PageGroupBox(QWidget* theParen void SketchShapePlugin_PageGroupBox::setHighlightedGroupBox(bool isHighlighted) { - ModuleBase_Tools::setShadowEffect(this, isHighlighted); + QList aListWidgets = findChildren(); + + QList::const_iterator anIt = aListWidgets.begin(), aLast = aListWidgets.end(); + for (; anIt != aLast; anIt++) { + QListWidget* aListWidget = *anIt; + ModuleBase_Tools::setShadowEffect(aListWidget, isHighlighted); + } } diff --git a/src/SketchShapePlugin/plugin-SketchShape.xml b/src/SketchShapePlugin/plugin-SketchShape.xml index ace539bf6..e988883b6 100755 --- a/src/SketchShapePlugin/plugin-SketchShape.xml +++ b/src/SketchShapePlugin/plugin-SketchShape.xml @@ -18,7 +18,8 @@ tooltip="Select list of vertices" type_choice="Vertices Edges Faces" use_external="false" - use_choice="false"> + use_choice="false" + use_label="false"> @@ -28,7 +29,8 @@ tooltip="Select list of edges" type_choice="Vertices Edges Faces" use_external="false" - use_choice="false"> + use_choice="false" + use_label="false"> @@ -38,7 +40,8 @@ tooltip="Select list of faces" type_choice="Vertices Edges Faces" use_external="false" - use_choice="false"> + use_choice="false" + use_label="false">