From d8fba833a4a6d6fa8526c008b3d9f9dea0861a88 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 23 Oct 2014 18:44:46 +0400 Subject: [PATCH] Create group operation --- src/FeaturesPlugin/FeaturesPlugin_Group.cpp | 14 ++++----- src/FeaturesPlugin/FeaturesPlugin_Group.h | 10 +++---- src/FeaturesPlugin/group_widget.xml | 4 --- src/Model/Model_AttributeSelectionList.cpp | 12 ++++++-- .../ModuleBase_WidgetMultiSelector.cpp | 30 +++++++++++++++---- 5 files changed, 46 insertions(+), 24 deletions(-) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Group.cpp b/src/FeaturesPlugin/FeaturesPlugin_Group.cpp index ae5d82771..dad22dbf6 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Group.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Group.cpp @@ -19,16 +19,16 @@ FeaturesPlugin_Group::FeaturesPlugin_Group() void FeaturesPlugin_Group::initAttributes() { - data()->addAttribute(FeaturesPlugin_Group::NAME_ID(), ModelAPI_AttributeString::type()); + //data()->addAttribute(FeaturesPlugin_Group::NAME_ID(), ModelAPI_AttributeString::type()); data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::type()); } void FeaturesPlugin_Group::execute() { - AttributeStringPtr aNameAttr = boost::dynamic_pointer_cast( - data()->attribute(FeaturesPlugin_Group::NAME_ID())); - if (!aNameAttr) - return; - std::string aName = aNameAttr->value(); - data()->setName(aName); + //AttributeStringPtr aNameAttr = boost::dynamic_pointer_cast( + // data()->attribute(FeaturesPlugin_Group::NAME_ID())); + //if (!aNameAttr) + // return; + //std::string aName = aNameAttr->value(); + //data()->setName(aName); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_Group.h b/src/FeaturesPlugin/FeaturesPlugin_Group.h index 34385caab..23078ae67 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Group.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Group.h @@ -19,11 +19,11 @@ class FeaturesPlugin_Group : public ModelAPI_Feature return MY_GROUP_ID; } /// attribute name of group name - inline static const std::string& NAME_ID() - { - static const std::string MY_GROUP_NAME_ID("group_name"); - return MY_GROUP_NAME_ID; - } + //inline static const std::string& NAME_ID() + //{ + // static const std::string MY_GROUP_NAME_ID("group_name"); + // return MY_GROUP_NAME_ID; + //} /// attribute name of selected entities list inline static const std::string& LIST_ID() { diff --git a/src/FeaturesPlugin/group_widget.xml b/src/FeaturesPlugin/group_widget.xml index 5d8ad7565..d4288b638 100644 --- a/src/FeaturesPlugin/group_widget.xml +++ b/src/FeaturesPlugin/group_widget.xml @@ -1,8 +1,4 @@ - diff --git a/src/Model/Model_AttributeSelectionList.cpp b/src/Model/Model_AttributeSelectionList.cpp index 848341184..5aca20aee 100644 --- a/src/Model/Model_AttributeSelectionList.cpp +++ b/src/Model/Model_AttributeSelectionList.cpp @@ -17,9 +17,16 @@ void Model_AttributeSelectionList::append( { int aNewTag = mySize->Get() + 1; TDF_Label aNewLab = mySize->Label().FindChild(aNewTag); - mySubs.push_back(boost::shared_ptr( - new Model_AttributeSelection(aNewLab))); + + boost::shared_ptr aNewAttr = + boost::shared_ptr(new Model_AttributeSelection(aNewLab)); + if (owner()) { + aNewAttr->setObject(owner()); + } + mySubs.push_back(aNewAttr); mySize->Set(aNewTag); + aNewAttr->setValue(theContext, theSubShape); + owner()->data()->sendAttributeUpdated(this); } int Model_AttributeSelectionList::size() @@ -40,6 +47,7 @@ void Model_AttributeSelectionList::clear() for(; aSubIter.More(); aSubIter.Next()) { aSubIter.Value().ForgetAllAttributes(Standard_True); } + owner()->data()->sendAttributeUpdated(this); } Model_AttributeSelectionList::Model_AttributeSelectionList(TDF_Label& theLabel) diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 563cc1878..ed40ee204 100644 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -11,10 +11,8 @@ #include #include -#include #include #include -#include #include #include @@ -45,8 +43,9 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen aMainLay->addWidget(aTypeLabel, 0, 0); myTypeCombo = new QComboBox(myMainWidget); - std::string aTypes = theData->getProperty("type_choice"); - myShapeTypes = QString::fromStdString(aTypes).split(' '); + // There is no sence to paramerize list of types while we can not parametrize selection mode + QString aTypesStr("Vertices Edges Faces Solids"); + myShapeTypes = aTypesStr.split(' '); myTypeCombo->addItems(myShapeTypes); aMainLay->addWidget(myTypeCombo, 0, 1); @@ -70,6 +69,7 @@ ModuleBase_WidgetMultiSelector::~ModuleBase_WidgetMultiSelector() activateSelection(false); } +//******************************************************************** bool ModuleBase_WidgetMultiSelector::storeValue() const { // A rare case when plugin was not loaded. @@ -90,9 +90,9 @@ bool ModuleBase_WidgetMultiSelector::storeValue() const return false; } +//******************************************************************** bool ModuleBase_WidgetMultiSelector::restoreValue() { - return false; // A rare case when plugin was not loaded. if(!myFeature) return false; @@ -112,11 +112,13 @@ bool ModuleBase_WidgetMultiSelector::restoreValue() return false; } +//******************************************************************** QWidget* ModuleBase_WidgetMultiSelector::getControl() const { return myMainWidget; } +//******************************************************************** QList ModuleBase_WidgetMultiSelector::getControls() const { QList result; @@ -135,6 +137,7 @@ bool ModuleBase_WidgetMultiSelector::eventFilter(QObject* theObj, QEvent* theEve return ModuleBase_ModelWidget::eventFilter(theObj, theEvent); } +//******************************************************************** void ModuleBase_WidgetMultiSelector::onSelectionChanged() { ModuleBase_ISelection* aSelection = myWorkshop->selection(); @@ -153,23 +156,36 @@ void ModuleBase_WidgetMultiSelector::onSelectionChanged() mySelection.append(GeomSelection(aResult, aShape)); } updateSelectionList(); + storeValue(); emit valuesChanged(); } +//******************************************************************** void ModuleBase_WidgetMultiSelector::updateSelectionList() { + QString aType; + if (myTypeCombo->currentText().toLower() == "vertices") + aType = "vertex"; + else if (myTypeCombo->currentText().toLower() == "edges") + aType = "edge"; + else if (myTypeCombo->currentText().toLower() == "faces") + aType = "face"; + else if (myTypeCombo->currentText().toLower() == "solids") + aType = "solid"; + myListControl->clear(); int i = 1; foreach (GeomSelection aSel, mySelection) { QString aName(aSel.first->data()->name().c_str()); - aName += ":" + myTypeCombo->currentText() + QString::number(i); + aName += ":" + aType + QString("_%1").arg(i); myListControl->addItem(aName); i++; } } +//******************************************************************** void ModuleBase_WidgetMultiSelector::filterShapes(const NCollection_List& theShapesToFilter, NCollection_List& theResult) { @@ -186,6 +202,7 @@ void ModuleBase_WidgetMultiSelector::filterShapes(const NCollection_ListcurrentText(); -- 2.39.2