]> SALOME platform Git repositories - plugins/blsurfplugin.git/commitdiff
Salome HOME
GUI is updated
authorgdd <gdd>
Thu, 17 Feb 2011 18:42:47 +0000 (18:42 +0000)
committergdd <gdd>
Thu, 17 Feb 2011 18:42:47 +0000 (18:42 +0000)
The group creation is fixed
Some other bugs ar fixed

TODO: Save and Load

src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx
src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx

index eb6e9a7eda2ae857638993dc2cd7424ec611e28b..a854ba395bac663b46d98e671b7492f4b78d7c7f 100644 (file)
@@ -1324,72 +1324,55 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
       projVertex.push_back((double)xyz[0]);
       projVertex.push_back((double)xyz[1]);
       projVertex.push_back((double)xyz[2]);
-//       std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexCoords >::const_iterator projIt = EnfVertexCoords2ProjVertex.find(projVertex);
-//       if (projIt != EnfVertexCoords2ProjVertex.end()) {
-//         BLSURFPlugin_Hypothesis::TEnfVertexCoords enfVertexCoords = projIt->second;
-          
-//         BLSURFPlugin_Hypothesis::TEnfVertexGroupNameMap groupNameMap =  _hypothesis->_GetEnforcedVertexGroupNameMap();
-//         BLSURFPlugin_Hypothesis::TEnfVertexGroupNameMap::const_iterator groupNameMapIt = groupNameMap.find(enfVertexCoords);
-        std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexList >::const_iterator enfCoordsIt = EnfVertexCoords2EnfVertexList.find(projVertex);
-        if (enfCoordsIt != EnfVertexCoords2EnfVertexList.end()) {
-          MESSAGE("Found enforced vertex @ " << xyz[0] << ", " << xyz[1] << ", " << xyz[2])
-//           BLSURFPlugin_Hypothesis::TEnfGroupName groupName = groupNameMapIt->second;
-//           if (groupName != "") {
-          BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator enfListIt = enfCoordsIt->second.begin();
-          BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
-          for (; enfListIt != enfCoordsIt->second.end(); ++enfListIt) {
-            currentEnfVertex = (*enfListIt);
-            if (currentEnfVertex->grpName != "") {
-              bool groupDone = false;
-              const set<SMESHDS_GroupBase*>& allGroups = meshDS->GetGroups();
-              set<SMESHDS_GroupBase*>::const_iterator grIt;
-              MESSAGE("currentEnfVertex->grpName: " << currentEnfVertex->grpName);
-              MESSAGE("Parsing the groups of the mesh");
-              for ( grIt = allGroups.begin(); grIt != allGroups.end(); ++grIt ) {
-                SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *grIt );
-                if (group) {
-                  MESSAGE("Group: " << group->GetStoreName());
-                  MESSAGE("group->SMDSGroup().GetType(): " << (group->SMDSGroup().GetType()));
-                  MESSAGE("group->SMDSGroup().GetType()==SMDSAbs_Node: " << (group->SMDSGroup().GetType()==SMDSAbs_Node));
-                  MESSAGE("currentEnfVertex->grpName.compare(group->GetStoreName())==0: " << (currentEnfVertex->grpName.compare(group->GetStoreName())==0));
-                }
-                if ( group && (group->SMDSGroup().GetType()==SMDSAbs_Node || group->SMDSGroup().GetType()==SMDSAbs_All)
-                            && currentEnfVertex->grpName.compare(group->GetStoreName())==0) {
-                  group->SMDSGroup().Add(nodes[iv]);
-  //                 int id = // recuperer l'id SMESH du noeud
-  //                 _hypothesis->AddEnfVertexIDs(groupName,id)
-                  groupDone = true;
-                  MESSAGE("Successfully added enforced vertex to existing group " << currentEnfVertex->grpName);
-                  break;
-                }
-              }
-              if (!groupDone)
-              {
-                int groupId;
-                SMESH_Group* aGroup = aMesh.AddGroup(SMDSAbs_Node, currentEnfVertex->grpName.c_str(), groupId);
-                if ( aGroup ) {
-                  SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
-                  if ( aGroupDS ) {
-                    aGroupDS->SetType( SMDSAbs_Node );
-                    aGroupDS->SetStoreName( currentEnfVertex->grpName.c_str() );
-                    aGroupDS->SMDSGroup().Add(nodes[iv]);
-                    MESSAGE("Successfully created enforced vertex group " << currentEnfVertex->grpName);
-                    groupDone = true;
-                  }
-                }
+      std::map< BLSURFPlugin_Hypothesis::TEnfVertexCoords, BLSURFPlugin_Hypothesis::TEnfVertexList >::const_iterator enfCoordsIt = EnfVertexCoords2EnfVertexList.find(projVertex);
+      if (enfCoordsIt != EnfVertexCoords2EnfVertexList.end()) {
+        MESSAGE("Found enforced vertex @ " << xyz[0] << ", " << xyz[1] << ", " << xyz[2])
+        BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator enfListIt = enfCoordsIt->second.begin();
+        BLSURFPlugin_Hypothesis::TEnfVertex *currentEnfVertex;
+        for (; enfListIt != enfCoordsIt->second.end(); ++enfListIt) {
+          currentEnfVertex = (*enfListIt);
+          if (currentEnfVertex->grpName != "") {
+            bool groupDone = false;
+            SMESH_Mesh::GroupIteratorPtr grIt = aMesh.GetGroups();
+            MESSAGE("currentEnfVertex->grpName: " << currentEnfVertex->grpName);
+            MESSAGE("Parsing the groups of the mesh");
+            while (grIt->more()) {
+              SMESH_Group * group = grIt->next();
+              if ( !group ) continue;
+              MESSAGE("Group: " << group->GetName());
+              SMESHDS_GroupBase* groupDS = group->GetGroupDS();
+              if ( !groupDS ) continue;
+              MESSAGE("group->SMDSGroup().GetType(): " << (groupDS->GetType()));
+              MESSAGE("group->SMDSGroup().GetType()==SMDSAbs_Node: " << (groupDS->GetType()==SMDSAbs_Node));
+              MESSAGE("currentEnfVertex->grpName.compare(group->GetStoreName())==0: " << (currentEnfVertex->grpName.compare(group->GetName())==0));
+              if ( groupDS->GetType()==SMDSAbs_Node && currentEnfVertex->grpName.compare(group->GetName())==0) {
+                SMESHDS_Group* aGroupDS = static_cast<SMESHDS_Group*>( groupDS );
+                aGroupDS->SMDSGroup().Add(nodes[iv]);
+                MESSAGE("Node ID: " << nodes[iv]->GetID());
+                // How can I inform the hypothesis ?
+//                 _hypothesis->AddEnfVertexNodeID(currentEnfVertex->grpName,nodes[iv]->GetID());
+                groupDone = true;
+                MESSAGE("Successfully added enforced vertex to existing group " << currentEnfVertex->grpName);
+                break;
               }
-              if (!groupDone)
-                throw SALOME_Exception(LOCALIZED("A enforced vertex node was not added to a group"));
             }
-            else
-              MESSAGE("Group name is empty: '"<<currentEnfVertex->grpName<<"' => group is not created");
+            if (!groupDone)
+            {
+              int groupId;
+              SMESH_Group* aGroup = aMesh.AddGroup(SMDSAbs_Node, currentEnfVertex->grpName.c_str(), groupId);
+              aGroup->SetName( currentEnfVertex->grpName.c_str() );
+              SMESHDS_Group* aGroupDS = static_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
+              aGroupDS->SMDSGroup().Add(nodes[iv]);
+              MESSAGE("Successfully created enforced vertex group " << currentEnfVertex->grpName);
+              groupDone = true;
+            }
+            if (!groupDone)
+              throw SALOME_Exception(LOCALIZED("A enforced vertex node was not added to a group"));
           }
+          else
+            MESSAGE("Group name is empty: '"<<currentEnfVertex->grpName<<"' => group is not created");
         }
-//         else
-//           MESSAGE("No group name for projected vertex ("<<projVertex[0]<<","<<projVertex[1]<<","<<projVertex[2]<<")")
-//       }
-//       else
-//         MESSAGE("No group name for vertex ("<<xyz[0]<<","<<xyz[1]<<","<<xyz[2]<<")")
+      }
     }
 
 
index baeca852c00da2a7588fc2038216a455a521bdf9..b9bc8c0c99c1d21f5e93e0490bb8b912bf812712 100644 (file)
@@ -53,7 +53,8 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_G
   _faceEntryCoordsListMap(GetDefaultFaceEntryCoordsListMap()),
   _coordsEnfVertexMap(GetDefaultCoordsEnfVertexMap()),
   _faceEntryEnfVertexEntryListMap(GetDefaultFaceEntryEnfVertexEntryListMap()),
-  _enfVertexEntryEnfVertexMap(GetDefaultEnfVertexEntryEnfVertexMap())
+  _enfVertexEntryEnfVertexMap(GetDefaultEnfVertexEntryEnfVertexMap()),
+  _groupNameNodeIDMap(GetDefaultGroupNameNodeIDMap())
 
 /* TODO GROUPS
  _groupNameEnfVertexListMap(GetDefaultGroupNameEnfVertexListMap()),
@@ -102,6 +103,7 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_G
   _coordsEnfVertexMap.clear();
   _faceEntryEnfVertexEntryListMap.clear();
   _enfVertexEntryEnfVertexMap.clear();
+  _groupNameNodeIDMap.clear();
 
   /* TODO GROUPS
    _groupNameEnfVertexListMap.clear();
@@ -756,6 +758,38 @@ BLSURFPlugin_Hypothesis::TEnfVertexEntryEnfVertexMap BLSURFPlugin_Hypothesis::Ge
   return hyp ? hyp->_GetAllEnforcedVerticesByEnfVertexEntry() : GetDefaultEnfVertexEntryEnfVertexMap();
 }
 
+std::set<int> BLSURFPlugin_Hypothesis::GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument)
+{
+  TGroupNameNodeIDMap::const_iterator it = _groupNameNodeIDMap.find(theGroupName);
+  if (it != _groupNameNodeIDMap.end()) {
+    return it->second;
+  }
+  std::ostringstream msg;
+  msg << "No group " << theGroupName;
+  throw std::invalid_argument(msg.str());
+}
+
+void BLSURFPlugin_Hypothesis::AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID)
+{
+  _groupNameNodeIDMap[theGroupName].insert(theNodeID);
+}
+
+void BLSURFPlugin_Hypothesis::RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument)
+{
+  TGroupNameNodeIDMap::iterator it = _groupNameNodeIDMap.find(theGroupName);
+  if (it != _groupNameNodeIDMap.end()) {
+    std::set<int>::iterator IDit = it->second.find(theNodeID);
+    if (IDit != it->second.end())
+      it->second.erase(IDit);
+    std::ostringstream msg;
+    msg << "No node IDs " << theNodeID << " for group " << theGroupName;
+    throw std::invalid_argument(msg.str());
+  }
+  std::ostringstream msg;
+  msg << "No group " << theGroupName;
+  throw std::invalid_argument(msg.str());
+}
+
 //=============================================================================
 std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) {
   save << " " << (int) _topology << " " << (int) _physicalMesh << " " << (int) _geometricMesh << " " << _phySize << " "
index 0ccbfa206183fa585304a027add5a883106eab97..28c6911ce38f1c07445cb5115fee4a6a49039414 100644 (file)
@@ -187,6 +187,7 @@ public:
   // Map Vertex entry / Enforced vertex
   typedef std::map< TEntry, TEnfVertex* > TEnfVertexEntryEnfVertexMap;
 
+  typedef std::map< TEnfGroupName, std::set<int> > TGroupNameNodeIDMap;
   /* TODO GROUPS
   // Map Group Name / List of enforced vertices
   typedef std::map< TEnfGroupName , TEnfVertexList > TGroupNameEnfVertexListMap;
@@ -202,6 +203,9 @@ public:
   TEntryList            GetEnfVertexEntryList (const TEntry& theFaceEntry) throw (std::invalid_argument);
   TEnfVertex*           GetEnfVertex(TEnfVertexCoords coords) throw (std::invalid_argument);
   TEnfVertex*           GetEnfVertex(const TEntry& theEnfVertexEntry) throw (std::invalid_argument);
+  void                  AddEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID);
+  std::set<int>         GetEnfVertexNodeIDs(TEnfGroupName theGroupName) throw (std::invalid_argument);
+  void                  RemoveEnfVertexNodeID(TEnfGroupName theGroupName,int theNodeID) throw (std::invalid_argument);
   
   bool ClearEnforcedVertex(const TEntry& theFaceEntry, double x = 0.0, double y = 0.0, double z = 0.0, const TEntry& theVertexEntry="") throw (std::invalid_argument);
   bool ClearEnforcedVertices(const TEntry& theFaceEntry) throw (std::invalid_argument);
@@ -263,6 +267,7 @@ public:
   static TCoordsEnfVertexMap              GetDefaultCoordsEnfVertexMap() { return TCoordsEnfVertexMap(); }
   static TFaceEntryEnfVertexEntryListMap  GetDefaultFaceEntryEnfVertexEntryListMap() { return TFaceEntryEnfVertexEntryListMap(); }
   static TEnfVertexEntryEnfVertexMap      GetDefaultEnfVertexEntryEnfVertexMap() { return TEnfVertexEntryEnfVertexMap(); }
+  static TGroupNameNodeIDMap              GetDefaultGroupNameNodeIDMap() { return TGroupNameNodeIDMap(); }
 
   /* TODO GROUPS
   static TGroupNameEnfVertexListMap GetDefaultGroupNameEnfVertexListMap() { return TGroupNameEnfVertexListMap(); }
@@ -324,6 +329,7 @@ private:
   // maps to get "geom" enf vertex (through their geom entries)
   TFaceEntryEnfVertexEntryListMap _faceEntryEnfVertexEntryListMap;
   TEnfVertexEntryEnfVertexMap     _enfVertexEntryEnfVertexMap;
+  TGroupNameNodeIDMap             _groupNameNodeIDMap;
   
   /* TODO GROUPS
   TGroupNameEnfVertexListMap _groupNameEnfVertexListMap;
index 1718e03a675960f1c9ad11108dfa7ce7eb65fc7a..32a96d79a4ab91d192fb6078eec0115834f31eac 100644 (file)
@@ -1073,7 +1073,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace,
 
   string theFaceEntry = theFace->GetStudyEntry();
   
-  if (theFaceEntry == "") {
+  if (theFaceEntry.empty()) {
     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
     string aName;
@@ -1086,7 +1086,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace,
     if (!theSFace->_is_nil())
       theFaceEntry = theSFace->GetID();
   }
-  if (theFaceEntry == "")
+  if (theFaceEntry.empty())
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
   MESSAGE("IDL : GetName : " << theFace->GetName());
   MESSAGE("IDL : SetEnforcedVertex( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ")");
@@ -1111,7 +1111,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr the
 
   string theFaceEntry = theFace->GetStudyEntry();
   
-  if (theFaceEntry == "") {
+  if (theFaceEntry.empty()) {
     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
     string aName;
@@ -1124,7 +1124,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr the
     if (!theSFace->_is_nil())
       theFaceEntry = theSFace->GetID();
   }
-  if (theFaceEntry == "")
+  if (theFaceEntry.empty())
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
   
   MESSAGE("IDL : GetName : " << theFace->GetName());
@@ -1169,7 +1169,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theF
   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
   string aName;
   
-  if (theFaceEntry == "") {
+  if (theFaceEntry.empty()) {
     if (theFace->GetShapeType() == GEOM::FACE)
       aName = "Face_";
     if (theFace->GetShapeType() == GEOM::COMPOUND)
@@ -1179,10 +1179,10 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theF
     if (!theSFace->_is_nil())
       theFaceEntry = theSFace->GetID();
   }
-  if (theFaceEntry == "")
+  if (theFaceEntry.empty())
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
   
-  if (theVertexEntry == "") {
+  if (theVertexEntry.empty()) {
     if (theVertex->GetShapeType() == GEOM::VERTEX)
       aName = "Vertex_";
     if (theVertex->GetShapeType() == GEOM::COMPOUND)
@@ -1192,7 +1192,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theF
     if (!theSVertex->_is_nil())
       theVertexEntry = theSVertex->GetID();
   }
-  if (theVertexEntry == "")
+  if (theVertexEntry.empty())
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
 
   string theVertexName = theVertex->GetName();
@@ -1221,7 +1221,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr
 
   string theFaceEntry = theFace->GetStudyEntry();
   
-  if (theFaceEntry == "") {
+  if (theFaceEntry.empty()) {
     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
     string aName;
@@ -1234,7 +1234,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr
     if (!theSFace->_is_nil())
       theFaceEntry = theSFace->GetID();
   }
-  if (theFaceEntry == "")
+  if (theFaceEntry.empty())
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
   MESSAGE("IDL : GetName : " << theFace->GetName());
   MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theGroupName << ")");
@@ -1261,7 +1261,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(GEOM::GEOM_Objec
 
   string theFaceEntry = theFace->GetStudyEntry();
   
-  if (theFaceEntry == "") {
+  if (theFaceEntry.empty()) {
     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
     string aName;
@@ -1274,7 +1274,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(GEOM::GEOM_Objec
     if (!theSFace->_is_nil())
       theFaceEntry = theSFace->GetID();
   }
-  if (theFaceEntry == "")
+  if (theFaceEntry.empty())
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
   MESSAGE("IDL : GetName : " << theFace->GetName());
   MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theVertexName << ", " << theGroupName << ")");
@@ -1310,7 +1310,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object
   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
   string aName;
   
-  if (theFaceEntry == "") {
+  if (theFaceEntry.empty()) {
     if (theFace->GetShapeType() == GEOM::FACE)
       aName = "Face_";
     if (theFace->GetShapeType() == GEOM::COMPOUND)
@@ -1320,10 +1320,10 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object
     if (!theSFace->_is_nil())
       theFaceEntry = theSFace->GetID();
   }
-  if (theFaceEntry == "")
+  if (theFaceEntry.empty())
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
   
-  if (theVertexEntry == "") {
+  if (theVertexEntry.empty()) {
     if (theVertex->GetShapeType() == GEOM::VERTEX)
       aName = "Vertex_";
     if (theVertex->GetShapeType() == GEOM::COMPOUND)
@@ -1333,7 +1333,7 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object
     if (!theSVertex->_is_nil())
       theVertexEntry = theSVertex->GetID();
   }
-  if (theVertexEntry == "")
+  if (theVertexEntry.empty())
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
 
   string theVertexName = theVertex->GetName();
@@ -1361,7 +1361,7 @@ BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEO
 
   string theFaceEntry = theFace->GetStudyEntry();
   
-  if (theFaceEntry == "") {
+  if (theFaceEntry.empty()) {
     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
     string aName;
@@ -1374,7 +1374,7 @@ BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEO
     if (!theSFace->_is_nil())
       theFaceEntry = theSFace->GetID();
   }
-  if (theFaceEntry == "")
+  if (theFaceEntry.empty())
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
 
   MESSAGE("IDL : GetName : " << theFace->GetName());
@@ -1397,7 +1397,7 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr theFac
 
   string theFaceEntry = theFace->GetStudyEntry();
   
-  if (theFaceEntry == "") {
+  if (theFaceEntry.empty()) {
     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
     string aName;
@@ -1410,7 +1410,7 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr theFac
     if (!theSFace->_is_nil())
       theFaceEntry = theSFace->GetID();
   }
-  if (theFaceEntry == "")
+  if (theFaceEntry.empty())
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
   MESSAGE("IDL : GetName : " << theFace->GetName());
   MESSAGE("IDL : UnsetEnforcedVertex ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ")");
@@ -1451,7 +1451,7 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr th
   SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
   string aName;
   
-  if (theFaceEntry == "") {
+  if (theFaceEntry.empty()) {
     if (theFace->GetShapeType() == GEOM::FACE)
       aName = "Face_";
     if (theFace->GetShapeType() == GEOM::COMPOUND)
@@ -1461,10 +1461,10 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr th
     if (!theSFace->_is_nil())
       theFaceEntry = theSFace->GetID();
   }
-  if (theFaceEntry == "")
+  if (theFaceEntry.empty())
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
   
-  if (theVertexEntry == "") {
+  if (theVertexEntry.empty()) {
     if (theVertex->GetShapeType() == GEOM::VERTEX)
       aName = "Vertex_";
     if (theVertex->GetShapeType() == GEOM::COMPOUND)
@@ -1474,7 +1474,7 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr th
     if (!theSVertex->_is_nil())
       theVertexEntry = theSVertex->GetID();
   }
-  if (theVertexEntry == "")
+  if (theVertexEntry.empty())
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
   
   MESSAGE("IDL : UnsetEnforcedVertexGeom ( "<< theFaceEntry << ", " << theVertexEntry << ")");
@@ -1496,7 +1496,7 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr theF
 
   string theFaceEntry = theFace->GetStudyEntry();
   
-  if (theFaceEntry == "") {
+  if (theFaceEntry.empty()) {
     GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
     SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
     string aName;
@@ -1509,7 +1509,7 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr theF
     if (!theSFace->_is_nil())
       theFaceEntry = theSFace->GetID();
   }
-  if (theFaceEntry == "")
+  if (theFaceEntry.empty())
     THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
   
   MESSAGE("IDL : GetName : " << theFace->GetName());
@@ -1529,10 +1529,10 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry,
     CORBA::Double z, const char* theVertexName, const char* theVertexEntry, const char* theGroupName)
     throw (SALOME::SALOME_Exception) {
   ASSERT(myBaseImpl);
-  MESSAGE("IDL : SetEnforcedVertexEntry(" << theFaceEntry << "," << x << "," << y << "," << z << ", \"" << theVertexName << "\"," << theVertexEntry << ", \"" << theGroupName << "\")");
+  MESSAGE("IDL : SetEnforcedVertexEntry(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\")");
   bool newValue = false;
 
-  if (theVertexEntry == "") {
+  if (string(theVertexEntry).empty()) {
     try {
       ::BLSURFPlugin_Hypothesis::TEnfVertexCoordsList coordsList =
           this->GetImpl()->GetEnfVertexCoordsList(theFaceEntry);
@@ -1551,8 +1551,9 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry,
 //          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
           newValue = true;
         }
-        else
+        else {
           MESSAGE("The names are identical");
+        }
       }
     } catch (const std::invalid_argument& ex) {
       // no enforced vertex for entry
@@ -1560,32 +1561,44 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* theFaceEntry,
       newValue = true;
     }
     if (newValue)
-      if (theVertexName == "")
-        if (theGroupName == "")
+      if (string(theVertexName).empty())
+        if (string(theGroupName).empty())
           SMESH::TPythonDump() << _this() << ".SetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ")";
         else
           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexWithGroup(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theGroupName << "\")";
       else
-        if (theGroupName == "")
+        if (string(theGroupName).empty())
           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamed(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\")";
         else
           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamedWithGroup(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" 
-                                          << theVertexName << ", \"" << theGroupName << "\")";
+                                          << theVertexName << "\", \"" << theGroupName << "\")";
   } else {
     try {
       ::BLSURFPlugin_Hypothesis::TEntryList enfVertexEntryList = this->GetImpl()->GetEnfVertexEntryList(theFaceEntry);
-      if (enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
+      ::BLSURFPlugin_Hypothesis::TEntryList::const_iterator it = enfVertexEntryList.find(theVertexEntry);
+      if ( it == enfVertexEntryList.end()) {
         MESSAGE("Geom entry not found: add it in enfVertexEntryList");
         newValue = true;
-      } else
-      MESSAGE("Geom entry already found");
+      }
+      else {
+        MESSAGE("Geom entry already found, compare names");
+        ::BLSURFPlugin_Hypothesis::TEnfVertex *enfVertex = this->GetImpl()->GetEnfVertex((*it));
+        if ((enfVertex->name != theVertexName) || (enfVertex->grpName != theGroupName)) {
+          MESSAGE("The names are different: update");
+//          this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z);
+          newValue = true;
+        }
+        else {
+          MESSAGE("The names are identical");
+        }
+      }
     } catch (const std::invalid_argument& ex) {
       // no enforced vertex for entry
       MESSAGE("Face entry not found : add it to the list");
       newValue = true;
     }
     if (newValue)
-        if (theGroupName == "")
+        if (string(theGroupName).empty())
           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeom(" << theFaceEntry << ", " << theVertexEntry << ")";
         else
           SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGeomWithGroup(" << theFaceEntry << ", " << theVertexEntry << ", \"" << theGroupName << "\")";
@@ -1659,7 +1672,7 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* theFaceEntr
   try {
     this->GetImpl()->ClearEnforcedVertex(theFaceEntry, x, y, z, theVertexEntry);
 
-    if (theVertexEntry == "")
+    if (string(theVertexEntry).empty())
       SMESH::TPythonDump() << _this() << ".UnsetEnforcedVertex(" << theFaceEntry << ", " << x << ", " << y << ", " << z
           << ")";
     else
index cb0f1a404e8429bac8a0183c8ad90e9fbfe5d048..76dc1c61638f2850e3198a12c12d455e8c32424b 100644 (file)
@@ -270,8 +270,8 @@ QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
                                               const QStyleOptionViewItem & option ,
                                               const QModelIndex & index ) const
 {
-//   QModelIndex father = index.parent();
-//   QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
+  QModelIndex father = index.parent();
+  QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString();
   
   if (index.column() == ENF_VER_X_COLUMN || \
       index.column() == ENF_VER_Y_COLUMN || \
@@ -279,14 +279,17 @@ QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent,
   {
     SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
     editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
-//     editor->setEnabled(entry.isEmpty());
+    editor->setReadOnly(!entry.isEmpty());
+    editor->setDisabled(!entry.isEmpty());
     return editor;
   }
   else
   {
     QLineEdit *editor = new QLineEdit(parent);
-//     if (index.column() != ENF_VER_GROUP_COLUMN)
-//       editor->setEnabled(entry.isEmpty());
+    if (index.column() != ENF_VER_GROUP_COLUMN) {
+      editor->setReadOnly(!entry.isEmpty());
+      editor->setDisabled(!entry.isEmpty());
+    }
     return editor;
   }
 
@@ -832,7 +835,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
     myEnforcedTreeWidget->resizeColumnToContents(column);
   }
   myEnforcedTreeWidget->hideColumn(ENF_VER_FACE_ENTRY_COLUMN);
-//   myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
+  myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
   myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate());
   
 // FACE AND VERTEX SELECTION
@@ -1095,7 +1098,7 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEnt
       childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
       childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
       childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
-      if (((childValueX == x) && (childValueY == y) && (childValueZ == z)) || (childEntry.toStdString() == geomEntry)) {
+      if (((childValueX == x) && (childValueY == y) && (childValueZ == z)) || ( (childEntry.toStdString() != "") && (childEntry.toStdString() == geomEntry))) {
         // update group name
         if (childGroupName.toStdString() != groupName) {
           MESSAGE("Group is updated from \"" << childGroupName.toStdString() << "\" to \"" << groupName << "\"");
@@ -1107,7 +1110,7 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEnt
     } // for
   } // if
   if (!okToCreate) {
-    if (geomEntry == "") {
+    if (geomEntry.empty()) {
       MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
     }
     else {
@@ -1116,7 +1119,7 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEnt
     return;
   }
     
-  if (geomEntry == "") {
+  if (geomEntry.empty()) {
     MESSAGE("In " << theFaceName << " vertex with coords " << x << ", " << y << ", " << z<< " is created");
   }
   else {
@@ -1128,12 +1131,12 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEnt
   QPixmap iconSelect (SUIT_Session::session()->resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
   QSize iconSize = iconSelect.size()*0.7;
   
-  int vertexIndex=1;
+  int vertexIndex=myEnforcedTreeWidget->indexOfTopLevelItem(theItem);
   QString myVertexName;
-  int indexRef = 0;
+  int indexRef = -1;
   while(indexRef != vertexIndex) {
     indexRef = vertexIndex;
-    if (vertexName == "")
+    if (vertexName.empty())
       myVertexName = QString("Vertex #%1").arg(vertexIndex);
     else
       myVertexName = QString(vertexName.c_str());
@@ -1147,7 +1150,7 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEnt
     }
   }
   vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, myVertexName );
-  if (geomEntry == "") {
+  if (geomEntry.empty()) {
     vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
     vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
     vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
@@ -1160,7 +1163,7 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string theFaceEnt
     vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str()));
 
   QString toolTip = QString(theFaceName.c_str())+QString(": ")+myVertexName;
-  if (geomEntry == "") {
+  if (geomEntry.empty()) {
     toolTip += QString(" (%1, ").arg(x);
     toolTip += QString("%1, ").arg(y);
     toolTip += QString("%1)").arg(z);
@@ -1210,7 +1213,7 @@ void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() {
     if (makeGroupsCheck->isChecked())
       groupName = myGlobalGroupName->text().toStdString();
 
-    if (boost::trim_copy(groupName) == "")
+    if (boost::trim_copy(groupName).empty())
       groupName = "";
 
     if (selEnfVertex <= 1)
@@ -1745,8 +1748,11 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi
         enfVertexFromHyp.clear();
         for (int i =0 ; i<hypNbVertex ; i++) {
           TEnfVertex *_enfVertex = new TEnfVertex();
+          _enfVertex->name = string("");
           _enfVertex->name = CORBA::string_dup(hypEnfVertexList[i].name.in());
+          _enfVertex->geomEntry = string("");
           _enfVertex->geomEntry = CORBA::string_dup(hypEnfVertexList[i].geomEntry.in());
+          _enfVertex->grpName = string("");
           _enfVertex->grpName = CORBA::string_dup(hypEnfVertexList[i].grpName.in());
           for (int j=0 ; j< hypEnfVertexList[i].coords.length() ; j++)
             _enfVertex->coords.push_back(hypEnfVertexList[i].coords[j]);
@@ -1911,7 +1917,7 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes
 
           TEnfVertex *enfVertex = new TEnfVertex();
           enfVertex->name = childName;
-          if (vertexEntry == "") {
+          if (vertexEntry.empty()) {
             enfVertex->coords.push_back(childValueX);
             enfVertex->coords.push_back(childValueY);
             enfVertex->coords.push_back(childValueZ);