]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 23 Oct 2014 14:45:00 +0000 (18:45 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 23 Oct 2014 14:45:00 +0000 (18:45 +0400)
src/FeaturesPlugin/FeaturesPlugin_Group.cpp
src/FeaturesPlugin/FeaturesPlugin_Group.h
src/FeaturesPlugin/group_widget.xml
src/Model/Model_AttributeSelectionList.cpp
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp

index ae5d82771e3331402a607199249aedac24813317..dad22dbf60b9ec8b537c3aa1b2bc2e2f82cc206d 100644 (file)
@@ -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<ModelAPI_AttributeString>(
-      data()->attribute(FeaturesPlugin_Group::NAME_ID()));
-  if (!aNameAttr)
-    return;
-  std::string aName = aNameAttr->value();
-  data()->setName(aName);
+  //AttributeStringPtr aNameAttr = boost::dynamic_pointer_cast<ModelAPI_AttributeString>(
+  //    data()->attribute(FeaturesPlugin_Group::NAME_ID()));
+  //if (!aNameAttr)
+  //  return;
+  //std::string aName = aNameAttr->value();
+  //data()->setName(aName);
 }
index 34385caab13d67ea3f679f5882011ef9be8f2576..23078ae675c99b4b299724592b471d1930c182f3 100644 (file)
@@ -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()
   {
index 5d8ad7565a8d812dcb66cdc6726e6fed19c6e79c..d4288b638b250c23bb6e971c411cd1aec1112c02 100644 (file)
@@ -1,8 +1,4 @@
 <source>
-  <stringvalue
-    id="group_name"
-    label="Name"
-    tooltip="Name of the group" />
   <multi_selector id="group_list" 
     tooltip="List of selected objects" 
     type_choice="Vertices Edges Faces Solids" /> 
index 848341184cbb452fe03d9b38ff17e288976bb158..5aca20aee34c8822d9ab946131976e70c7f13827 100644 (file)
@@ -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<Model_AttributeSelection>(
-    new Model_AttributeSelection(aNewLab)));
+
+  boost::shared_ptr<Model_AttributeSelection> aNewAttr = 
+    boost::shared_ptr<Model_AttributeSelection>(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)
index 563cc18780fa6d01231a8b41a78bb38d3cb47eee..ed40ee20434af9d1fb022043a90e13be7f2f84f2 100644 (file)
 #include <ModuleBase_IWorkshop.h>
 #include <ModuleBase_Tools.h>
 
-#include <ModelAPI_AttributeString.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
-#include <ModelAPI_Validator.h>
 #include <ModelAPI_AttributeSelectionList.h>
 
 #include <Config_WidgetAPI.h>
@@ -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<QWidget*> ModuleBase_WidgetMultiSelector::getControls() const
 {
   QList<QWidget*> 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<TopoDS_Shape>& theShapesToFilter,
                                                   NCollection_List<TopoDS_Shape>& theResult)
 {
@@ -186,6 +202,7 @@ void ModuleBase_WidgetMultiSelector::filterShapes(const NCollection_List<TopoDS_
   }
 }
 
+//********************************************************************
 void ModuleBase_WidgetMultiSelector::activateSelection(bool toActivate)
 {
   myIsActive = toActivate;
@@ -198,6 +215,7 @@ void ModuleBase_WidgetMultiSelector::activateSelection(bool toActivate)
   }
 }
 
+//********************************************************************
 void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged()
 {
   QString aNewType = myTypeCombo->currentText();