From a3dc1fad044fa45fa07ab5c94ccee5e537106972 Mon Sep 17 00:00:00 2001 From: gdd Date: Tue, 5 Oct 2010 16:12:21 +0000 Subject: [PATCH] - Replace QLineEdit by SMESH_SpinBox - Prepare for groups when solution is found - Renaming of some variables --- idl/BLSURFPlugin_Algorithm.idl | 87 ++- resources/Makefile.am | 1 + resources/mesh_select_BLSURF.png | Bin 0 -> 1143 bytes src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 152 +++- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 387 ++++++++-- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx | 75 +- .../BLSURFPlugin_Hypothesis_i.cxx | 220 ++++-- .../BLSURFPlugin_Hypothesis_i.hxx | 68 +- src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 716 ++++++++++++------ src/GUI/BLSURFPluginGUI_HypothesisCreator.h | 51 +- src/GUI/BLSURFPlugin_images.ts | 4 + src/GUI/BLSURFPlugin_msg_en.ts | 20 + src/GUI/BLSURFPlugin_msg_fr.ts | 34 +- 13 files changed, 1345 insertions(+), 470 deletions(-) create mode 100644 resources/mesh_select_BLSURF.png diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index 4438e12..64b34bc 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -36,13 +36,36 @@ module BLSURFPlugin { typedef sequence string_array; - typedef sequence TEnforcedVertex; - typedef sequence TEnforcedVertexList; - struct TEnforcedVertexMapElement { - string entry; - TEnforcedVertexList vertexList; + + // Entry + typedef string TEnfEntry; + // Enforced vertex = 3 coordinates + typedef sequence TEnfVertex; + // List of enforced vertices + typedef sequence TEnfVertexList; + // Map Entry / List of enforced vertices + struct TEntryEnfVertexListMapElement { + TEnfEntry entry; + TEnfVertexList vertexList; + }; + typedef sequence TEntryEnfVertexListMap; + /* TODO GROUPS + // Group name + typedef string TEnfGroupName; + // Map Group Name / List of enforced vertices + struct TGroupNameEnfVertexListMapElement { + TEnfGroupName groupName; + TEnfVertexList vertexList; }; - typedef sequence TEnforcedVertexMap; + typedef sequence TGroupNameEnfVertexListMap; + // Map Enforced vertex / Group Name + struct TEnfVertexGroupNameMapElement { + TEnfVertex vertex; + TEnfGroupName groupName; + }; + typedef sequence TEnfVertexGroupNameMap; + */ + /*! * BLSURFPlugin_BLSURF: interface of BLSURF algorithm @@ -216,33 +239,49 @@ module BLSURFPlugin // ENFORCED VERTEXES // /////////////////////// - TEnforcedVertexMap GetAllEnforcedVertices(); - void ClearAllEnforcedVertices(); + TEntryEnfVertexListMap GetAllEnforcedVertices(); + void ClearAllEnforcedVertices(); - /*! - * Set/get/unset an enforced vertex on geom object - */ - void SetEnforcedVertex(in GEOM::GEOM_Object GeomObj, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); -// void SetEnforcedVertexList(in GEOM::GEOM_Object GeomObj, in TEnforcedVertexList vertexList) raises (SALOME::SALOME_Exception); + /*! + * Set/get/unset an enforced vertex on geom object + */ + void SetEnforcedVertex(in GEOM::GEOM_Object GeomObj, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); + /* TODO GROUPS + void SetEnforcedVertexWithGroup(in GEOM::GEOM_Object GeomObj, in double x, in double y, in double z, in TEnfGroupName groupName) raises (SALOME::SALOME_Exception); + */ +// void SetEnforcedVertexList(in GEOM::GEOM_Object GeomObj, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); - TEnforcedVertexList GetEnforcedVertices(in GEOM::GEOM_Object GeomObj) raises (SALOME::SALOME_Exception); + TEnfVertexList GetEnforcedVertices(in GEOM::GEOM_Object GeomObj) raises (SALOME::SALOME_Exception); - void UnsetEnforcedVertex(in GEOM::GEOM_Object GeomObj, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); -// void UnsetEnforcedVertexList(in GEOM::GEOM_Object GeomObj, in TEnforcedVertexList vertexList) raises (SALOME::SALOME_Exception); - void UnsetEnforcedVertices(in GEOM::GEOM_Object GeomObj) raises (SALOME::SALOME_Exception); + void UnsetEnforcedVertex(in GEOM::GEOM_Object GeomObj, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); +// void UnsetEnforcedVertexList(in GEOM::GEOM_Object GeomObj, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); + void UnsetEnforcedVertices(in GEOM::GEOM_Object GeomObj) raises (SALOME::SALOME_Exception); /*! * Set/get/unset an enforced vertex on geom object given by entry */ - void SetEnforcedVertexEntry(in string entry, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); -// void SetEnforcedVertexListEntry(in string entry, in TEnforcedVertexList vertexList) raises (SALOME::SALOME_Exception); + void SetEnforcedVertexEntry(in TEnfEntry entry, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); + /* TODO GROUPS + void SetEnforcedVertexEntryWithGroup(in TEnfEntry entry, in double x, in double y, in double z, in TEnfGroupName groupName) + raises (SALOME::SALOME_Exception); + */ +// void SetEnforcedVertexListEntry(in TEnfEntry entry, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); // - TEnforcedVertexList GetEnforcedVerticesEntry(in string entry) raises (SALOME::SALOME_Exception); + TEnfVertexList GetEnforcedVerticesEntry(in TEnfEntry entry) raises (SALOME::SALOME_Exception); // - void UnsetEnforcedVertexEntry(in string entry, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); -// void UnsetEnforcedVertexListEntry(in string entry, in TEnforcedVertexList vertexList) raises (SALOME::SALOME_Exception); - void UnsetEnforcedVerticesEntry(in string entry) raises (SALOME::SALOME_Exception); - + void UnsetEnforcedVertexEntry(in TEnfEntry entry, in double x, in double y, in double z) raises (SALOME::SALOME_Exception); +// void UnsetEnforcedVertexListEntry(in TEnfEntry entry, in TEnfVertexList vertexList) raises (SALOME::SALOME_Exception); + void UnsetEnforcedVerticesEntry(in TEnfEntry entry) raises (SALOME::SALOME_Exception); + + /*! + * Set/get an enforced vertex on geom object and add it to a group + */ + /* TODO GROUPS + void SetEnforcedVertexGroupName(in double x, in double y, in double z, in TEnfGroupName groupName) + raises (SALOME::SALOME_Exception); + string GetEnforcedVertexGroupName(in double x, in double y, in double z) + raises (SALOME::SALOME_Exception); + */ /////////////////////// }; diff --git a/resources/Makefile.am b/resources/Makefile.am index b545ef4..ff2c901 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -31,6 +31,7 @@ dist_salomeres_DATA = \ if BLSURFPLUGIN_ENABLE_GUI dist_salomeres_DATA += \ BLSURF.png \ + mesh_select_BLSURF.png \ mesh_algo_BLSURF.png \ mesh_hypo_BLSURF.png \ mesh_tree_algo_BLSURF.png \ diff --git a/resources/mesh_select_BLSURF.png b/resources/mesh_select_BLSURF.png new file mode 100644 index 0000000000000000000000000000000000000000..ecb252ab77e4d4b1c8b37de449155e4e77806fd8 GIT binary patch literal 1143 zcmV--1c>{IP)z@;j(q!3lK=n!AY({UO#lFTB>(_`g8%^e{{R4h=>PzA zFaQARU;qF*m;eA5Z<1fdMgRZ*Y z+1|@J&vTys*x8s(A9y&=ABPX$@Ar2R#uxzVK5M}eVA}#m3ZfBZ@`~am4@2{B2*kg@6q&*BNEwM?&B@+_EcgOBFPbq)fl4T!YS@w}t zFVDWmkpfEygkanm1x6e}ti+})Zj&gJl$S{orION^4KN{5Ud{{4>Hywey>xcXnpdU^ zrOY^>9C?&PZQ`Xi@t94l#NwI9rp^VH0yU-aL{&Q7&jSk=qk`z-UEi)-47^pla@I!R z8mbt{@XMVYl*J`Wp1gAbuzXHs^@|Tb`aE;0?qkxevlz^2GOi+>_33PD%CS{TeJaziQldy^CkLzy55TqhE(>~8;uAP9aj#$*8>=mlDV z%OSJ~1Y?1RF1MZ}lj=tKMI0xJ5JCc(Vj=&Y5Te@{(;r&%LUkP>tN;Xn8J(1OKW)?| z(4U<8>jw;m@|$iW5{<`&5INwYG3M{E03-Jja23df6*kw5p4J*;%$DPazoU@LAZ3IZ z6*btlT@k9d8dkC^{H8*i=DM?NOn~qE?Y@`a@O%A60II4V$F}7nA%q2}(3%^n@@h9X zn;R|%hWpWYo>$k_dVI&xgWD)8pG4)ok07Od6>vt(tlM~A*KWEnelv^(3SqH!{b>Uf zl~V8gd%Avi!~U&Q&wrL%CeL_UN;waR@_&yvR44?NWdkTbOZ1|fK+8*w^>#Xem1^}qu>hx~?yEOm+002ov JPDHLkV1g&y5jFq- literal 0 HcmV?d00001 diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index 7e679fa..dcc193b 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -40,6 +40,9 @@ extern "C"{ #include #include #include +#include +#include "SMESHDS_Group.hxx" +#include "SMESH_Group.hxx" #include @@ -211,6 +214,7 @@ std::map > FaceId2AttractorCoords; TopTools_IndexedMapOfShape FacesWithEnforcedVertices; std::map< int, std::set< std::vector > > FaceId2EnforcedVertexCoords; +std::map< std::vector, std::vector > EnfVertex2ProjVertex; bool HasSizeMapOnFace=false; bool HasSizeMapOnEdge=false; @@ -272,7 +276,7 @@ BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF(int hypId, int studyId, FaceId2AttractorCoords.clear(); FacesWithEnforcedVertices.Clear(); FaceId2EnforcedVertexCoords.clear(); - + EnfVertex2ProjVertex.clear(); } //============================================================================= @@ -415,19 +419,22 @@ TopoDS_Shape BLSURFPlugin_BLSURF::entryToShape(std::string entry) } ///////////////////////////////////////////////////////// -void createEnforcedVertexOnFace(TopoDS_Shape GeomShape, BLSURFPlugin_Hypothesis::TEnforcedVertexList enforcedVertexList) +void createEnforcedVertexOnFace(TopoDS_Shape GeomShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList) { double xe, ye, ze; std::vector coords; - BLSURFPlugin_Hypothesis::TEnforcedVertex enforcedVertex; - BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator evlIt = enforcedVertexList.begin(); + std::vector s_coords; + std::vector enfVertex; +// BLSURFPlugin_Hypothesis::TEnfVertex enfVertex; + BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin(); - for( ; evlIt != enforcedVertexList.end() ; ++evlIt ) { + for( ; evlIt != enfVertexList.end() ; ++evlIt ) { coords.clear(); - enforcedVertex = *evlIt; - xe = enforcedVertex[0]; - ye = enforcedVertex[1]; - ze = enforcedVertex[2]; + s_coords.clear(); + enfVertex = *evlIt; + xe = enfVertex[0]; + ye = enfVertex[1]; + ze = enfVertex[2]; MESSAGE("Enforced Vertex: " << xe << ", " << ye << ", " << ze); // Get the (u,v) values of the enforced vertex on the face projectionPoint myPoint = getProjectionPoint(TopoDS::Face(GeomShape),gp_XYZ(xe,ye,ze)); @@ -445,7 +452,16 @@ void createEnforcedVertexOnFace(TopoDS_Shape GeomShape, BLSURFPlugin_Hypothesis: coords.push_back(x0); coords.push_back(y0); coords.push_back(z0); - + + s_coords.push_back(x0); + s_coords.push_back(y0); + s_coords.push_back(z0); + + // Save pair projected vertex / enf vertex + MESSAGE("Storing pair projected vertex / enf vertex:"); + MESSAGE("("<< x0 << ", " << y0 << ", " << z0 <<") / (" << xe << ", " << ye << ", " << ze<<")"); + EnfVertex2ProjVertex[s_coords] = enfVertex; + int key = 0; if (! FacesWithEnforcedVertices.Contains(TopoDS::Face(GeomShape))) { key = FacesWithEnforcedVertices.Add(TopoDS::Face(GeomShape)); @@ -785,9 +801,9 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, // Enforced Vertices // MESSAGE("Setting Enforced Vertices"); - const BLSURFPlugin_Hypothesis::TEnforcedVertexMap enforcedVertexMap = BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(hyp); - BLSURFPlugin_Hypothesis::TEnforcedVertexMap::const_iterator enfIt = enforcedVertexMap.begin(); - for ( ; enfIt != enforcedVertexMap.end(); ++enfIt ) { + const BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap entryEnfVertexListMap = BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(hyp); + BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap::const_iterator enfIt = entryEnfVertexListMap.begin(); + for ( ; enfIt != entryEnfVertexListMap.end(); ++enfIt ) { if ( !enfIt->second.empty() ) { GeomShape = entryToShape(enfIt->first); GeomType = GeomShape.ShapeType(); @@ -920,6 +936,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) int iface = 0; string bad_end = "return"; int faceKey = -1; + int ienf = 0; for (TopExp_Explorer face_iter(aShape,TopAbs_FACE);face_iter.More();face_iter.Next()) { TopoDS_Face f=TopoDS::Face(face_iter.Current()); @@ -953,7 +970,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) } if (HasSizeMapOnFace){ - std::cout << "A size map is defined on a face" << std::endl; +// std::cout << "A size map is defined on a face" << std::endl; // Classic size map faceKey = FacesWithSizeMap.FindIndex(f); @@ -1016,8 +1033,8 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) faceKey = FacesWithEnforcedVertices.FindIndex(f); std::map > >::const_iterator evmIt = FaceId2EnforcedVertexCoords.find(faceKey); if (evmIt != FaceId2EnforcedVertexCoords.end()) { - std::cout << "Some enforced vertices are defined" << std::endl; - int ienf = 0; + MESSAGE("Some enforced vertices are defined"); +// int ienf = 0; std::set > evl; // std::vector ev; MESSAGE("Face indice: " << iface); @@ -1026,12 +1043,11 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) MESSAGE("Number of vertices to add: "<< evl.size()); std::set< std::vector >::const_iterator evlIt = evl.begin(); for (; evlIt != evl.end(); ++evlIt) { -// ev = *evlIt; -// for (int i=0; iat(2), evlIt->at(3), evlIt->at(4)}; + std::vector xyzCoords; + xyzCoords.push_back(evlIt->at(2)); + xyzCoords.push_back(evlIt->at(3)); + xyzCoords.push_back(evlIt->at(4)); +// double xyzCoords[3] = {evlIt->at(2), evlIt->at(3), evlIt->at(4)}; MESSAGE("Check position of vertex =(" << xyzCoords[0] << "," << xyzCoords[1] << "," << xyzCoords[2] << ")"); gp_Pnt P(xyzCoords[0],xyzCoords[1],xyzCoords[2]); BRepClass_FaceClassifier scl(f,P,1e-7); @@ -1040,12 +1056,21 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) BRepClass_FaceClassifierPerform(&scl,f,P,1e-7); TopAbs_State result = scl.State(); MESSAGE("Position of point on face: "<AddNode(xyz[0], xyz[1], xyz[2]); + + /* TODO GROUPS + // Create group of enforced vertices if requested + if(_hypothesis) { + std::vector projVertex; + projVertex.push_back((double)xyz[0]); + projVertex.push_back((double)xyz[1]); + projVertex.push_back((double)xyz[2]); + std::map< std::vector, std::vector >::const_iterator projIt = EnfVertex2ProjVertex.find(projVertex); + if (projIt != EnfVertex2ProjVertex.end()) { + double x = (projIt->second)[0]; + double y = (projIt->second)[1]; + double z = (projIt->second)[2]; + BLSURFPlugin_Hypothesis::TEnfVertex enfVertex; + enfVertex.push_back(x); + enfVertex.push_back(y); + enfVertex.push_back(z); + + BLSURFPlugin_Hypothesis::TEnfVertexGroupNameMap groupNameMap = _hypothesis->_GetEnforcedVertexGroupNameMap(); + BLSURFPlugin_Hypothesis::TEnfVertexGroupNameMap::const_iterator groupNameMapIt = groupNameMap.find(enfVertex); + if (groupNameMapIt != groupNameMap.end()) { + MESSAGE("Found enforced vertex @ " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]) + BLSURFPlugin_Hypothesis::TEnfGroupName groupName = groupNameMapIt->second; + if (groupName != "") { + bool groupDone = false; + const set& allGroups = meshDS->GetGroups(); + set::const_iterator grIt; + MESSAGE("Parsing the groups of the mesh"); + for ( grIt = allGroups.begin(); grIt != allGroups.end(); ++grIt ) { + SMESHDS_Group* group = dynamic_cast( *grIt ); + MESSAGE("Group: " << group->GetStoreName()); + if ( group && group->SMDSGroup().GetType()==SMDSAbs_Node + && groupName.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 " << groupName); + break; + } + } + if (!groupDone) + { + int groupId; + SMESH_Group* aGroup = aMesh.AddGroup(SMDSAbs_Node, groupName.c_str(), groupId); + if ( aGroup ) { + SMESHDS_Group* aGroupDS = dynamic_cast( aGroup->GetGroupDS() ); + if ( aGroupDS ) { + aGroupDS->SetStoreName( groupName.c_str() ); + aGroupDS->SMDSGroup().Add(nodes[iv]); + MESSAGE("Successfully created enforced vertex group " << groupName); + groupDone = true; + } + } + } + if (!groupDone) + throw SALOME_Exception(LOCALIZED("A enforced vertex node was not added to a group")); + } + else + MESSAGE("Group name is empty: '"< group is not created"); + } + else + MESSAGE("No group name for projected vertex ("< 0 && tag <= pmap.Extent() ){ meshDS->SetNodeOnVertex(nodes[iv], TopoDS::Vertex(pmap(tag))); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index b3d09fd..bcb0a0e 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -50,7 +50,12 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis (int hypId, int studyId, _verb( GetDefaultVerbosity() ), _sizeMap(GetDefaultSizeMap()), _attractors(GetDefaultSizeMap()), - _enforcedVertices(GetDefaultEnforcedVertexMap()) + _enfVertexList(GetDefaultEnfVertexList()), + _entryEnfVertexListMap(GetDefaultEntryEnfVertexListMap()) + /* TODO GROUPS + _groupNameEnfVertexListMap(GetDefaultGroupNameEnfVertexListMap()), + _enfVertexGroupNameMap(GetDefaultEnfVertexGroupNameMap()) + */ { _name = "BLSURF_Parameters"; _param_algo_dim = 2; @@ -130,6 +135,13 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis (int hypId, int studyId, } _sizeMap.clear(); + _attractors.clear(); + _enfVertexList.clear(); + _entryEnfVertexListMap.clear(); + /* TODO GROUPS + _groupNameEnfVertexListMap.clear(); + _enfVertexGroupNameMap.clear(); + */ } //============================================================================= @@ -406,8 +418,9 @@ BLSURFPlugin_Hypothesis::TSizeMap BLSURFPlugin_Hypothesis::GetAttractorEntries(c return hyp ? hyp->_GetAttractorEntries():GetDefaultSizeMap(); } - - +//======================================================================= +//function : ClearEntry +//======================================================================= void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry) { TSizeMap::iterator it = _sizeMap.find( entry ); @@ -426,7 +439,9 @@ void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry) } } - +//======================================================================= +//function : ClearSizeMaps +//======================================================================= void BLSURFPlugin_Hypothesis::ClearSizeMaps() { _sizeMap.clear(); @@ -438,41 +453,170 @@ void BLSURFPlugin_Hypothesis::ClearSizeMaps() //======================================================================= //function : SetEnforcedVertex //======================================================================= - -void BLSURFPlugin_Hypothesis::SetEnforcedVertex(const std::string& entry, double x, double y, double z) +/* TODO GROUPS +void BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEnfEntry& entry, + double x, double y, double z, + const TEnfGroupName& groupName) +*/ +void BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEnfEntry& entry, + double x, double y, double z) { - BLSURFPlugin_Hypothesis::TEnforcedVertex coord; - coord.push_back(x); - coord.push_back(y); - coord.push_back(z); + /* TODO GROUPS + MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex START - entry: " << entry << " vertex: " << x << " " << y << " " << z << " group name: " << groupName); + */ + MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex START - entry: " << entry << " vertex: " << x << " " << y << " " << z); + TEnfVertex enfVertex; + enfVertex.push_back(x); + enfVertex.push_back(y); + enfVertex.push_back(z); + bool toNotify = false; - if (_enforcedVertices.count(entry)>0) - if (_enforcedVertices[entry].count(coord)==0) + if (_entryEnfVertexListMap.count(entry)>0) + if (_entryEnfVertexListMap[entry].count(enfVertex)==0) toNotify = true; else toNotify = true; - - _enforcedVertices[entry].insert(coord); + + _enfVertexList.insert(enfVertex); +// _entryEnfVertexListMap[entry].insert(enfVertex); + TEnfVertexList& entryEnfVertexList = _entryEnfVertexListMap[entry]; + entryEnfVertexList.insert(enfVertex); + + /* TODO GROUPS + bool toNotify2 = _setEnfVertexWithGroup(x,y,z,groupName); + + if (toNotify || toNotify2) + NotifySubMeshesHypothesisModification(); + */ if (toNotify) NotifySubMeshesHypothesisModification(); + + MESSAGE("BLSURFPlugin_Hypothesis::SetEnforcedVertex END"); } +/* TODO GROUPS +bool BLSURFPlugin_Hypothesis::_setEnfVertexWithGroup(double x, double y, double z, const std::string groupName) throw (std::invalid_argument) +{ + bool isModified = false; + std::vector enfVertex; + enfVertex.push_back(x); + enfVertex.push_back(y); + enfVertex.push_back(z); + if (_enfVertexList.find(enfVertex) != _enfVertexList.end()) { + TEnfGroupName oldGroupName = _enfVertexGroupNameMap[enfVertex]; + _enfVertexGroupNameMap[enfVertex] = groupName; + if ((groupName != "") && (groupName != oldGroupName)) { + MESSAGE("Group name is not empty"); + TEnfVertexList& enfVertexList = _groupNameEnfVertexListMap[groupName]; + enfVertexList.insert(enfVertex); + isModified = true; + } + else { + if (oldGroupName != "") { + // groupName = "" => remove group name + TGroupNameEnfVertexListMap::iterator it = _groupNameEnfVertexListMap.find(oldGroupName); + if (it != _groupNameEnfVertexListMap.end()) { + _groupNameEnfVertexListMap[oldGroupName].erase(enfVertex); + if (_groupNameEnfVertexListMap[oldGroupName].size() == 0) + _groupNameEnfVertexListMap.erase(oldGroupName); + isModified = true; + } + } + } + return isModified; + } + + std::ostringstream msg ; + msg << "No enforced vertex at (" << x << "," << y << "," << z << ")" ; + throw std::invalid_argument(msg.str()); +} + +//======================================================================= +//function : SetEnforcedVertexGroupName +//======================================================================= +void BLSURFPlugin_Hypothesis::SetEnforcedVertexGroupName(double x, double y, double z, + const TEnfGroupName& groupName) + throw (std::invalid_argument) +{ + bool toNotify = _setEnfVertexWithGroup(x,y,z,groupName); + if (toNotify) + NotifySubMeshesHypothesisModification(); +// bool toNotify = false; +// TEnfVertex enfVertex; +// enfVertex.push_back(x); +// enfVertex.push_back(y); +// enfVertex.push_back(z); +// +// if (_enfVertexList.find(enfVertex) != _enfVertexList.end()) { +// TEnfGroupName oldGroupName = _enfVertexGroupNameMap[enfVertex]; +// _enfVertexGroupNameMap[enfVertex] = groupName; +// if ((groupName != "") && (groupName != oldGroupName)) { +// MESSAGE("Group name is not empty"); +// TEnfVertexList& enfVertexList = _groupNameEnfVertexListMap[groupName]; +// enfVertexList.insert(enfVertex); +// toNotify = true; +// } +// else { +// if (oldGroupName != "") { +// // groupName = "" => remove group name +// TGroupNameEnfVertexListMap::iterator it = _groupNameEnfVertexListMap.find(oldGroupName); +// if (it != _groupNameEnfVertexListMap.end()) { +// _groupNameEnfVertexListMap[oldGroupName].erase(enfVertex); +// if (_groupNameEnfVertexListMap[oldGroupName].size() == 0) +// _groupNameEnfVertexListMap.erase(oldGroupName); +// toNotify = true; +// } +// } +// } +// if (toNotify) +// NotifySubMeshesHypothesisModification(); +// return; +// } + +// // std::ostringstream msg ; +// // msg << "No enforced vertex at (" << x << "," << y << "," << z << ")" ; +// // throw std::invalid_argument(msg.str()); +} + + +//======================================================================= +//function : GetEnforcedVertexGroupName +//======================================================================= +BLSURFPlugin_Hypothesis::TEnfGroupName BLSURFPlugin_Hypothesis::GetEnforcedVertexGroupName(double x, double y, double z) + throw (std::invalid_argument) +{ + TEnfVertex enfVertex; + enfVertex.push_back(x); + enfVertex.push_back(y); + enfVertex.push_back(z); + + if (_enfVertexGroupNameMap.find(enfVertex) != _enfVertexGroupNameMap.end()) + return _enfVertexGroupNameMap[enfVertex]; + + std::ostringstream msg ; + msg << "No enforced vertex at (" << x << "," << y << "," << z << ")" ; + throw std::invalid_argument(msg.str()); +} +*/ + /* //======================================================================= //function : SetEnforcedVertexList //======================================================================= -void BLSURFPlugin_Hypothesis::SetEnforcedVertexList(const std::string& entry, const BLSURFPlugin_Hypothesis::TEnforcedVertexList vertexList) +void BLSURFPlugin_Hypothesis::SetEnforcedVertexList(const TEnfEntry& entry, + const TEnfVertexList vertexList) { - BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator it; + TEnfVertexList::const_iterator it; bool toNotify = false; for(it = vertexList.begin();it!=vertexList.end();++it) { - if (_enforcedVertices.count(entry)>0) - if (_enforcedVertices[entry].count(*it)==0) + if (_entryEnfVertexListMap.count(entry)>0) + if (_entryEnfVertexListMap[entry].count(*it)==0) toNotify = true; else toNotify = true; - _enforcedVertices[entry].insert(*it); + _entryEnfVertexListMap[entry].insert(*it); + _enfVertexList.insert(*it); } if (toNotify) NotifySubMeshesHypothesisModification(); @@ -483,11 +627,11 @@ void BLSURFPlugin_Hypothesis::SetEnforcedVertexList(const std::string& entry, co //function : GetEnforcedVertices //======================================================================= -BLSURFPlugin_Hypothesis::TEnforcedVertexList BLSURFPlugin_Hypothesis::GetEnforcedVertices(const std::string& entry) +BLSURFPlugin_Hypothesis::TEnfVertexList BLSURFPlugin_Hypothesis::GetEnforcedVertices(const TEnfEntry& entry) throw (std::invalid_argument) { - if (_enforcedVertices.count(entry)>0) - return _enforcedVertices[entry]; + if (_entryEnfVertexListMap.count(entry)>0) + return _entryEnfVertexListMap[entry]; std::ostringstream msg ; msg << "No enforced vertex for entry " << entry ; throw std::invalid_argument(msg.str()); @@ -497,31 +641,60 @@ BLSURFPlugin_Hypothesis::TEnforcedVertexList BLSURFPlugin_Hypothesis::GetEnforce //function : ClearEnforcedVertex //======================================================================= -void BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const std::string& entry, double x, double y, double z) +void BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEnfEntry& entry, double x, double y, double z) throw (std::invalid_argument) { - BLSURFPlugin_Hypothesis::TEnforcedVertex coord; - coord.push_back(x); - coord.push_back(y); - coord.push_back(z); - BLSURFPlugin_Hypothesis::TEnforcedVertexList::iterator it; - bool toNotify = false; + std::ostringstream msg ; + + TEnfVertex enfVertex; + enfVertex.push_back(x); + enfVertex.push_back(y); + enfVertex.push_back(z); + + // check that enf vertex with given coords exists + if (_enfVertexList.count(enfVertex) == 0) { + msg << "No enforced vertex for " << entry; + throw std::invalid_argument(msg.str()); + } + - BLSURFPlugin_Hypothesis::TEnforcedVertexMap::iterator it_enf = _enforcedVertices.find(entry); - if (it_enf != _enforcedVertices.end()) { - it = _enforcedVertices[entry].find(coord); - if (it != _enforcedVertices[entry].end()) { + TEntryEnfVertexListMap::iterator it_enf = _entryEnfVertexListMap.find(entry); + if (it_enf != _entryEnfVertexListMap.end()) { + bool toNotify = false; + TEnfVertexList::iterator it = _entryEnfVertexListMap[entry].find(enfVertex); + if (it != _entryEnfVertexListMap[entry].end()) { toNotify = true; - _enforcedVertices[entry].erase(it); - if (_enforcedVertices[entry].size() == 0) - _enforcedVertices.erase(it_enf); + + // Update entry2enfList map + _entryEnfVertexListMap[entry].erase(it); + if (_entryEnfVertexListMap[entry].size() == 0) + _entryEnfVertexListMap.erase(it_enf); + + /* TODO GROUPS + // Update groupName2enfCoord map + TEnfGroupName groupName = _enfVertexGroupNameMap[enfVertex]; + if (groupName != "") { + TGroupNameEnfVertexListMap::iterator it_grp =_groupNameEnfVertexListMap.find(groupName); + if (it_grp != _groupNameEnfVertexListMap.end()) { + _groupNameEnfVertexListMap[groupName].erase(enfVertex); + if (_groupNameEnfVertexListMap[groupName].size() == 0) + _groupNameEnfVertexListMap.erase(it_grp); + } + } + + // Update _enfVertexGroupNameMap + _enfVertexGroupNameMap.erase(enfVertex); + */ + + // Update _enfVertexList + _enfVertexList.erase(enfVertex); + } if (toNotify) NotifySubMeshesHypothesisModification(); return; } - std::ostringstream msg ; msg << "No enforced vertex for " << entry; throw std::invalid_argument(msg.str()); } @@ -530,27 +703,28 @@ void BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const std::string& entry, doub //function : ClearEnforcedVertexList //======================================================================= -void BLSURFPlugin_Hypothesis::ClearEnforcedVertexList(const std::string& entry, BLSURFPlugin_Hypothesis::TEnforcedVertexList vertexList) +void BLSURFPlugin_Hypothesis::ClearEnforcedVertexList(const std::string& entry, TEnfVertexList vertexList) throw (std::invalid_argument) { - BLSURFPlugin_Hypothesis::TEnforcedVertex coord; - BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator it_toRemove; - BLSURFPlugin_Hypothesis::TEnforcedVertexList::iterator it; + TEnfVertex coord; + TEnfVertexList::const_iterator it_toRemove; + TEnfVertexList::iterator it; bool toNotify = false; - BLSURFPlugin_Hypothesis::TEnforcedVertexMap::iterator it_enf = _enforcedVertices.find(entry); - if (it_enf != _enforcedVertices.end()) { + TEntryEnfVertexListMap::iterator it_enf = _entryEnfVertexListMap.find(entry); + if (it_enf != _entryEnfVertexListMap.end()) { for (it_toRemove = vertexList.begin() ; it_toRemove != vertexList.end() ; ++it_toRemove) { coord = *it_toRemove; - it = _enforcedVertices[entry].find(coord); - if (it != _enforcedVertices[entry].end()) { + it = _entryEnfVertexListMap[entry].find(coord); + if (it != _entryEnfVertexListMap[entry].end()) { toNotify = true; - _enforcedVertices[entry].erase(it); + _entryEnfVertexListMap[entry].erase(it); + _enfVertexList.erase(it); } } - if (_enforcedVertices[entry].size() == 0) { + if (_entryEnfVertexListMap[entry].size() == 0) { toNotify = true; - _enforcedVertices.erase(it_enf); + _entryEnfVertexListMap.erase(it_enf); } if (toNotify) NotifySubMeshesHypothesisModification(); @@ -566,12 +740,29 @@ void BLSURFPlugin_Hypothesis::ClearEnforcedVertexList(const std::string& entry, //function : ClearEnforcedVertices //======================================================================= -void BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const std::string& entry) +void BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const TEnfEntry& entry) throw (std::invalid_argument) { - BLSURFPlugin_Hypothesis::TEnforcedVertexMap::iterator it_enf = _enforcedVertices.find(entry); - if (it_enf != _enforcedVertices.end()) { - _enforcedVertices.erase(it_enf); + TEntryEnfVertexListMap::iterator it_enf = _entryEnfVertexListMap.find(entry); + if (it_enf != _entryEnfVertexListMap.end()) { + TEnfVertexList enfList = it_enf->second; + TEnfVertexList::iterator it; + for(it = enfList.begin();it!=enfList.end();++it) { + /* TODO GROUPS + TEnfGroupName groupName = _enfVertexGroupNameMap[*it]; + if (groupName != "") { + TGroupNameEnfVertexListMap::iterator it_grp =_groupNameEnfVertexListMap.find(groupName); + if (it_grp != _groupNameEnfVertexListMap.end()) { + _groupNameEnfVertexListMap[groupName].erase(it); + if (_groupNameEnfVertexListMap[groupName].size() == 0) + _groupNameEnfVertexListMap.erase(it_grp); + } + } + _enfVertexGroupNameMap.erase(*it); + */ + _enfVertexList.erase(it); + } + _entryEnfVertexListMap.erase(it_enf); NotifySubMeshesHypothesisModification(); return; } @@ -586,7 +777,12 @@ void BLSURFPlugin_Hypothesis::ClearEnforcedVertices(const std::string& entry) //======================================================================= void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() { - _enforcedVertices.clear(); + _enfVertexList.clear(); + _entryEnfVertexListMap.clear(); + /* TODO GROUPS + _groupNameEnfVertexListMap.clear(); + _enfVertexGroupNameMap.clear(); + */ NotifySubMeshesHypothesisModification(); } @@ -596,9 +792,9 @@ void BLSURFPlugin_Hypothesis::ClearAllEnforcedVertices() */ //================================================================================ -BLSURFPlugin_Hypothesis::TEnforcedVertexMap BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp) +BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp) { - return hyp ? hyp->_GetAllEnforcedVertices():GetDefaultEnforcedVertexMap(); + return hyp ? hyp->_GetAllEnforcedVertices():GetDefaultEntryEnfVertexListMap(); } @@ -652,20 +848,26 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) save << " " << "__ATTRACTORS_END__"; } - TEnforcedVertexMap::const_iterator it_enf = _enforcedVertices.begin(); - if (it_enf != _enforcedVertices.end()) { + TEntryEnfVertexListMap::const_iterator it_enf = _entryEnfVertexListMap.begin(); + if (it_enf != _entryEnfVertexListMap.end()) { save << " " << "__ENFORCED_VERTICES_BEGIN__"; - for ( ; it_enf != _enforcedVertices.end(); ++it_enf ) { + for ( ; it_enf != _entryEnfVertexListMap.end(); ++it_enf ) { save << " " << it_enf->first; - TEnforcedVertexList evl = it_enf->second; - TEnforcedVertexList::const_iterator it_evl = evl.begin(); - if (it_evl != evl.end()) { - for ( ; it_evl != evl.end() ; ++it_evl) { - save << " " << (*it_evl)[0]; - save << " " << (*it_evl)[1]; - save << " " << (*it_evl)[2]; - save << "$"; // "$" is a mark of enforced vertex end + TEnfVertexList evl = it_enf->second; + TEnfVertexList::const_iterator it_evl = evl.begin(); + for ( ; it_evl != evl.end() ; ++it_evl) { + save << " " << (*it_evl)[0]; + save << " " << (*it_evl)[1]; + save << " " << (*it_evl)[2]; + /* TODO GROUPS + TEnfVertexGroupNameMap::const_iterator it_enfGroup = _enfVertexGroupNameMap.find(*it_evl); + if (it_enfGroup != _enfVertexGroupNameMap.end()) { + save << " " << "__ENF_GROUP_BEGIN__"; + save << " " << it_enfGroup->second ; + save << " " << "__ENF_GROUP_END__"; } + */ + save << " " << "$"; // "$" is a mark of enforced vertex end } save << "#"; // "#" is a mark of enforced shape end } @@ -897,20 +1099,24 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) hasEnforcedVertex = true; } - std::string enfEntry, enfValue, trace; + std::string enfEntry, enfValue, enfGroup, trace; std::ostringstream oss; while (isOK && hasEnforcedVertex) { isOK = (load >> enfEntry); if (isOK) { + MESSAGE("enfEntry: " <> enfValue); if (isOK) { + MESSAGE("enfValue: " <> enfGroup); + MESSAGE("enfGroup: " <> enfGroup); + if (isOK) { + MESSAGE("enfGroup: " < TEnforcedVertex; - typedef std::set< TEnforcedVertex > TEnforcedVertexList; - typedef std::map< std::string, TEnforcedVertexList > TEnforcedVertexMap; + // Entry + typedef std::string TEnfEntry; + // Enforced vertex = 3 coordinates + typedef std::vector TEnfVertex; + // List of enforced vertices + typedef std::set< TEnfVertex > TEnfVertexList; + // Map Entry / List of enforced vertices + typedef std::map< TEnfEntry , TEnfVertexList > TEntryEnfVertexListMap; + /* TODO GROUPS + // Group name + typedef std::string TEnfGroupName; + // Map Group Name / List of enforced vertices + typedef std::map< TEnfGroupName , TEnfVertexList > TGroupNameEnfVertexListMap; + // Map Enforced vertex / Group Name + typedef std::map< TEnfVertex , TEnfGroupName > TEnfVertexGroupNameMap; + */ + - void SetEnforcedVertex(const std::string& entry, double x, double y, double z); -// void SetEnforcedVertexList(const std::string& entry, const TEnforcedVertexList vertexList); - TEnforcedVertexList GetEnforcedVertices(const std::string& entry) throw (std::invalid_argument); - void ClearEnforcedVertex(const std::string& entry, double x, double y, double z) throw (std::invalid_argument); -// void ClearEnforcedVertexList(const std::string& entry, TEnforcedVertexList vertexList) throw (std::invalid_argument); - void ClearEnforcedVertices(const std::string& entry) throw (std::invalid_argument); + /* TODO GROUPS + void SetEnforcedVertex(const TEnfEntry& entry, double x, double y, double z, const TEnfGroupName& groupName=""); + */ + void SetEnforcedVertex(const TEnfEntry& entry, double x, double y, double z); +// void SetEnforcedVertexList(const TEnfEntry& entry, const TEnfVertexList vertexList); + TEnfVertexList GetEnforcedVertices(const TEnfEntry& entry) throw (std::invalid_argument); + void ClearEnforcedVertex(const TEnfEntry& entry, double x, double y, double z) throw (std::invalid_argument); +// void ClearEnforcedVertexList(const TEnfEntry& entry, TEnfVertexList vertexList) throw (std::invalid_argument); + void ClearEnforcedVertices(const TEnfEntry& entry) throw (std::invalid_argument); void ClearAllEnforcedVertices(); - const TEnforcedVertexMap _GetAllEnforcedVertices() const { return _enforcedVertices; } + const TEntryEnfVertexListMap _GetAllEnforcedVertices() const { return _entryEnfVertexListMap; } + /* TODO GROUPS + const TEnfVertexGroupNameMap _GetEnforcedVertexGroupNameMap() const { return _enfVertexGroupNameMap; } + */ /*! * \brief Return the enforced vertices */ - static TEnforcedVertexMap GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp); - + static TEntryEnfVertexListMap GetAllEnforcedVertices(const BLSURFPlugin_Hypothesis* hyp); + + /*! + * \brief Set/get node group to an enforced vertex + */ + /* TODO GROUPS + void SetEnforcedVertexGroupName(double x, double y, double z, const TEnfGroupName& groupName) throw (std::invalid_argument); + TEnfGroupName GetEnforcedVertexGroupName(double x, double y, double z) throw (std::invalid_argument); + TEnfVertexList GetEnforcedVertexByGroupName(TEnfGroupName& groupName) throw (std::invalid_argument); + */ static Topology GetDefaultTopology(); static PhysicalMesh GetDefaultPhysicalMesh(); @@ -165,7 +193,12 @@ public: static bool GetDefaultDecimesh(); static int GetDefaultVerbosity() { return 10; } static TSizeMap GetDefaultSizeMap() { return TSizeMap();} - static TEnforcedVertexMap GetDefaultEnforcedVertexMap() { return TEnforcedVertexMap(); } + static TEnfVertexList GetDefaultEnfVertexList() { return TEnfVertexList(); } + static TEntryEnfVertexListMap GetDefaultEntryEnfVertexListMap() { return TEntryEnfVertexListMap(); } + /* TODO GROUPS + static TGroupNameEnfVertexListMap GetDefaultGroupNameEnfVertexListMap() { return TGroupNameEnfVertexListMap(); } + static TEnfVertexGroupNameMap GetDefaultEnfVertexGroupNameMap() { return TEnfVertexGroupNameMap(); } + */ static double undefinedDouble() { return -1.0; } @@ -198,6 +231,11 @@ public: */ virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0); +/* TODO GROUPS +private: + bool _setEnfVertexWithGroup(double x, double y, double z, const std::string groupName) throw (std::invalid_argument); +*/ + private: Topology _topology; PhysicalMesh _physicalMesh; @@ -212,10 +250,13 @@ private: TOptionNames _doubleOptions, _charOptions; TSizeMap _sizeMap; TSizeMap _attractors; - TEnforcedVertexMap _enforcedVertices; -/* - TSizeMap _customSizeMap; -*/ + TEnfVertexList _enfVertexList; + TEntryEnfVertexListMap _entryEnfVertexListMap; + /* TODO GROUPS + TGroupNameEnfVertexListMap _groupNameEnfVertexListMap; + TEnfVertexGroupNameMap _enfVertexGroupNameMap; + */ +// TSizeMap _customSizeMap; }; #endif diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 4fcbe2c..cca2d9a 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -32,6 +32,7 @@ #include "utilities.h" #include +#include #include "boost/regex.hpp" //============================================================================= @@ -786,38 +787,38 @@ BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries() // ENFORCED VERTEXES // /////////////////////// -BLSURFPlugin::TEnforcedVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices() +BLSURFPlugin::TEntryEnfVertexListMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVertices() { MESSAGE("IDL: GetAllEnforcedVertices()"); ASSERT(myBaseImpl); - BLSURFPlugin::TEnforcedVertexMap_var resultMap = new BLSURFPlugin::TEnforcedVertexMap(); - const ::BLSURFPlugin_Hypothesis::TEnforcedVertexMap enforcedVertexMap = this->GetImpl()->_GetAllEnforcedVertices(); - resultMap->length(enforcedVertexMap.size()); - MESSAGE("Enforced Vertex map size is " << enforcedVertexMap.size()); - - ::BLSURFPlugin_Hypothesis::TEnforcedVertexList enforcedVertexList; - ::BLSURFPlugin_Hypothesis::TEnforcedVertexMap::const_iterator evmIt = enforcedVertexMap.begin(); - for ( int i = 0 ; evmIt != enforcedVertexMap.end(); ++evmIt, ++i ) { - string entry = evmIt->first; + BLSURFPlugin::TEntryEnfVertexListMap_var resultMap = new BLSURFPlugin::TEntryEnfVertexListMap(); + const ::BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap entryEnfVertexListMap = this->GetImpl()->_GetAllEnforcedVertices(); + resultMap->length(entryEnfVertexListMap.size()); + MESSAGE("Enforced Vertex map size is " << entryEnfVertexListMap.size()); + + ::BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList; + ::BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap::const_iterator evmIt = entryEnfVertexListMap.begin(); + for ( int i = 0 ; evmIt != entryEnfVertexListMap.end(); ++evmIt, ++i ) { + std::string entry = evmIt->first; MESSAGE("Entry: " << entry); - enforcedVertexList = evmIt->second; + enfVertexList = evmIt->second; - BLSURFPlugin::TEnforcedVertexMapElement_var mapElement = new BLSURFPlugin::TEnforcedVertexMapElement(); + BLSURFPlugin::TEntryEnfVertexListMapElement_var mapElement = new BLSURFPlugin::TEntryEnfVertexListMapElement(); - BLSURFPlugin::TEnforcedVertexList_var vertexList = new BLSURFPlugin::TEnforcedVertexList(); - vertexList->length(enforcedVertexList.size()); - MESSAGE("Number of enforced vertices: " << enforcedVertexList.size()); + BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList(); + vertexList->length(enfVertexList.size()); + MESSAGE("Number of enforced vertices: " << enfVertexList.size()); - ::BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator evlIt = enforcedVertexList.begin(); - for ( int j = 0 ; evlIt != enforcedVertexList.end(); ++evlIt, ++j ) { + ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin(); + for ( int j = 0 ; evlIt != enfVertexList.end(); ++evlIt, ++j ) { MESSAGE("Enforced Vertex #" << j); - BLSURFPlugin::TEnforcedVertex_var enforcedVertex = new BLSURFPlugin::TEnforcedVertex(); - enforcedVertex->length(3); - enforcedVertex[0] = (*evlIt)[0]; - enforcedVertex[1] = (*evlIt)[1]; - enforcedVertex[2] = (*evlIt)[2]; - vertexList[j] = enforcedVertex; - MESSAGE("Enforced vertex: " << enforcedVertex[0] << ", " << enforcedVertex[1] << ", " << enforcedVertex[2]); + BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); + enfVertex->length(3); + enfVertex[0] = (*evlIt)[0]; + enfVertex[1] = (*evlIt)[1]; + enfVertex[2] = (*evlIt)[2]; + vertexList[j] = enfVertex; + MESSAGE("Enforced vertex: " << enfVertex[0] << ", " << enfVertex[1] << ", " << enfVertex[2]); } mapElement->entry = CORBA::string_dup(entry.c_str()); @@ -844,6 +845,7 @@ void BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, { ASSERT(myBaseImpl); // TODO check that GeomObj is a face => in engine ? + // TODO Affecter un nom de groupe vide string entry = GeomObj->GetStudyEntry(); MESSAGE("IDL : GetName : " << GeomObj->GetName()); MESSAGE("IDL : SetEnforcedVertex ( "<< entry << ", " << x << ", " << y << ", " << z << ")"); @@ -855,8 +857,28 @@ void BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, } } - -BLSURFPlugin::TEnforcedVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj) +/*! + * Set/get/unset an enforced vertex on geom object with group name + */ +/* TODO GROUPS +void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr GeomObj, + CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + // TODO check that GeomObj is a face => in engine ? + string entry = GeomObj->GetStudyEntry(); + MESSAGE("IDL : GetName : " << GeomObj->GetName()); + MESSAGE("IDL : SetEnforcedVertexWithGroup ( "<< entry << ", " << x << ", " << y << ", " << z << ", " << groupName <<")"); + try { + SetEnforcedVertexEntryWithGroup(entry.c_str(), x, y, z, groupName); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } +} +*/ +BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); @@ -917,8 +939,8 @@ void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* entry, double bool newValue = false; try { - ::BLSURFPlugin_Hypothesis::TEnforcedVertexList vertexList = this->GetImpl()->GetEnforcedVertices(entry); - ::BLSURFPlugin_Hypothesis::TEnforcedVertex vertex; + ::BLSURFPlugin_Hypothesis::TEnfVertexList vertexList = this->GetImpl()->GetEnforcedVertices(entry); + ::BLSURFPlugin_Hypothesis::TEnfVertex vertex; vertex.push_back(x); vertex.push_back(y); vertex.push_back(z); @@ -948,34 +970,96 @@ void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntry(const char* entry, double } MESSAGE("IDL : SETENFORCEDVERTEX END - ENTRY: " << entry); } + +/*! + * Set/get/unset an enforced vertex on geom object given by entry + */ +/* TODO GROUPS +void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexEntryWithGroup(const char* entry, + double x, double y, double z, const char* groupName) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + MESSAGE("IDL : SETENFORCEDVERTEXWITHGROUP START - ENTRY: " << entry << " VERTEX: " + << x << " " << y << " " << z << " group name: " << groupName); + bool newValue = false; + bool newGroupName = false; + try { + ::BLSURFPlugin_Hypothesis::TEnfVertexList vertexList = this->GetImpl()->GetEnforcedVertices(entry); + ::BLSURFPlugin_Hypothesis::TEnfVertex vertex; + vertex.push_back(x); + vertex.push_back(y); + vertex.push_back(z); + if (vertexList.find(vertex) == vertexList.end()) { + MESSAGE("Vertex not found: add it in vertexList"); + newValue = true; + } + else { + MESSAGE("Vertex already found"); + std::string oldGroupName = this->GetImpl()->GetEnforcedVertexGroupName(x,y,z); + if (strcmp(oldGroupName.c_str(),groupName)!=0) + newGroupName = true; + } + } + catch (const std::invalid_argument& ex) { + // no enforced vertex for entry + MESSAGE("Entry not found : add it to the list"); + newValue = true; + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + + if ( newValue ) { + this->GetImpl()->SetEnforcedVertex(entry, x, y, z, groupName); + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexWithGroup(" + << entry << ", " + << x << ", " + << y << ", " + << z << ", '" + << groupName << "')"; + } + else { + if (newGroupName) { + this->GetImpl()->SetEnforcedVertexGroupName(x, y, z, groupName); + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName(" + << x << ", " + << y << ", " + << z << ", '" + << groupName << "')"; + } + } + MESSAGE("IDL : SETENFORCEDVERTEXWITHGROUP END - ENTRY: " << entry); +} +*/ /* -void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnforcedVertexList& vertexList) +void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); } */ -BLSURFPlugin::TEnforcedVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(const char* entry) +BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(const char* entry) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); MESSAGE("ENGINE : GETENFORCEDVERTICES START ENTRY : " << entry); try { - BLSURFPlugin::TEnforcedVertexList_var vertexList = new BLSURFPlugin::TEnforcedVertexList(); - ::BLSURFPlugin_Hypothesis::TEnforcedVertexList _vList = this->GetImpl()->GetEnforcedVertices(entry); + BLSURFPlugin::TEnfVertexList_var vertexList = new BLSURFPlugin::TEnfVertexList(); + ::BLSURFPlugin_Hypothesis::TEnfVertexList _vList = this->GetImpl()->GetEnforcedVertices(entry); vertexList->length(_vList.size()); MESSAGE("Number of enforced vertices: " << _vList.size()); - ::BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator evlIt = _vList.begin(); + ::BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = _vList.begin(); for ( int i = 0; evlIt != _vList.end() ; ++evlIt, ++i ) { - BLSURFPlugin::TEnforcedVertex_var enforcedVertex = new BLSURFPlugin::TEnforcedVertex(); - enforcedVertex->length(3); + BLSURFPlugin::TEnfVertex_var enfVertex = new BLSURFPlugin::TEnfVertex(); + enfVertex->length(3); MESSAGE("Enforced vertex #" << i << ": "<< (*evlIt)[0] << ", " << (*evlIt)[1] << ", " << (*evlIt)[2]); - enforcedVertex[0] = (*evlIt)[0]; - enforcedVertex[1] = (*evlIt)[1]; - enforcedVertex[2] = (*evlIt)[2]; - vertexList[i] = enforcedVertex; + enfVertex[0] = (*evlIt)[0]; + enfVertex[1] = (*evlIt)[1]; + enfVertex[2] = (*evlIt)[2]; + vertexList[i] = enfVertex; } return vertexList._retn(); } @@ -984,7 +1068,7 @@ BLSURFPlugin::TEnforcedVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertice ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVerticesEntry(entry)"; - ExDescription.lineNumber = 945; + ExDescription.lineNumber = 1048; throw SALOME::SALOME_Exception(ExDescription); } catch(const std::exception& ex) { @@ -1014,7 +1098,7 @@ void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* entry, CORB ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(entry,x,y,z)"; - ExDescription.lineNumber = 1003; + ExDescription.lineNumber = 1086; throw SALOME::SALOME_Exception(ExDescription); } catch(const std::exception& ex) { @@ -1024,7 +1108,7 @@ void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexEntry(const char* entry, CORB MESSAGE("ENGINE : UNSETENFORCEDVERTEX END ENTRY : " << entry); } /* -void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnforcedVertexList& vertexList) +void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList) throw (SALOME::SALOME_Exception) { ASSERT(myBaseImpl); @@ -1045,7 +1129,7 @@ void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* entry) ExDescription.text = ex.what(); ExDescription.type = SALOME::BAD_PARAM; ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(entry)"; - ExDescription.lineNumber = 1051; + ExDescription.lineNumber = 1121; throw SALOME::SALOME_Exception(ExDescription); } catch(const std::exception& ex) { @@ -1055,7 +1139,57 @@ void BLSURFPlugin_Hypothesis_i::UnsetEnforcedVerticesEntry(const char* entry) MESSAGE("ENGINE : UNSETENFORCEDVERTICES END ENTRY : " << entry); } +/* TODO GROUPS +char* BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + MESSAGE("ENGINE : GetEnforcedVertexGroupName START "); + try { + return CORBA::string_dup( this->GetImpl()->GetEnforcedVertexGroupName(x, y, z).c_str()); + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "BLSURFPlugin_Hypothesis_i::GetEnforcedVertexGroupName(entry)"; + ExDescription.lineNumber = 1146; + throw SALOME::SALOME_Exception(ExDescription); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + MESSAGE("ENGINE : GetEnforcedVertexGroupName END "); + return 0; +} + +void BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z, const char* groupName) + throw (SALOME::SALOME_Exception) +{ + ASSERT(myBaseImpl); + MESSAGE("ENGINE : SetEnforcedVertexGroupName START "); + try { + this->GetImpl()->SetEnforcedVertexGroupName(x, y, z, groupName); + } + catch (const std::invalid_argument& ex) { + SALOME::ExceptionStruct ExDescription; + ExDescription.text = ex.what(); + ExDescription.type = SALOME::BAD_PARAM; + ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetEnforcedVertexGroupName(x,y,z)"; + ExDescription.lineNumber = 1170; + throw SALOME::SALOME_Exception(ExDescription); + } + catch (SALOME_Exception& ex) { + THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); + } + + SMESH::TPythonDump() << _this() << ".SetEnforcedVertexGroupName(" + << x << ", " << y << ", " << z << ", '" << groupName << "' )"; + + MESSAGE("ENGINE : SetEnforcedVertexGroupName END "); +} +*/ /////////////////////// diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index 5212d05..fc22a46 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@ -145,28 +145,68 @@ class BLSURFPlugin_Hypothesis_i: // ENFORCED VERTEXES // /////////////////////// - BLSURFPlugin::TEnforcedVertexMap* GetAllEnforcedVertices(); - void ClearAllEnforcedVertices(); + BLSURFPlugin::TEntryEnfVertexListMap* GetAllEnforcedVertices(); + void ClearAllEnforcedVertices(); /*! * Set/get/unset an enforced vertex on geom object */ - void SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception); -// void SetEnforcedVertexList(GEOM::GEOM_Object_ptr GeomObj, const BLSURFPlugin::TEnforcedVertexList& vertexList) throw (SALOME::SALOME_Exception); - BLSURFPlugin::TEnforcedVertexList* GetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj) throw (SALOME::SALOME_Exception); - void UnsetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception); -// void UnsetEnforcedVertexList(GEOM::GEOM_Object_ptr GeomObj, BLSURFPlugin::TEnforcedVertexList& vertexList) throw (SALOME::SALOME_Exception); - void UnsetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj) throw (SALOME::SALOME_Exception); + void SetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z) + throw (SALOME::SALOME_Exception); + /* TODO GROUPS + void SetEnforcedVertexWithGroup(GEOM::GEOM_Object_ptr GeomObj, + CORBA::Double x, CORBA::Double y, CORBA::Double z, + const char* groupName) + throw (SALOME::SALOME_Exception); + */ +// void SetEnforcedVertexList(GEOM::GEOM_Object_ptr GeomObj, const BLSURFPlugin::TEnfVertexList& vertexList) +// throw (SALOME::SALOME_Exception); + + BLSURFPlugin::TEnfVertexList* GetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj) + throw (SALOME::SALOME_Exception); + + void UnsetEnforcedVertex(GEOM::GEOM_Object_ptr GeomObj, CORBA::Double x, CORBA::Double y, CORBA::Double z) + throw (SALOME::SALOME_Exception); + +// void UnsetEnforcedVertexList(GEOM::GEOM_Object_ptr GeomObj, BLSURFPlugin::TEnfVertexList& vertexList) +// throw (SALOME::SALOME_Exception); + + void UnsetEnforcedVertices(GEOM::GEOM_Object_ptr GeomObj) + throw (SALOME::SALOME_Exception); /*! * Set/get/unset an enforced vertex on geom object given by entry */ - void SetEnforcedVertexEntry(const char* entry, double x, double y, double z) throw (SALOME::SALOME_Exception); -// void SetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnforcedVertexList& vertexList) throw (SALOME::SALOME_Exception); - BLSURFPlugin::TEnforcedVertexList* GetEnforcedVerticesEntry(const char* entry) throw (SALOME::SALOME_Exception); - void UnsetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception); -// void UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnforcedVertexList& vertexList) throw (SALOME::SALOME_Exception); - void UnsetEnforcedVerticesEntry(const char* entry) throw (SALOME::SALOME_Exception); + void SetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z) + throw (SALOME::SALOME_Exception); + /* TODO GROUPS + void SetEnforcedVertexEntryWithGroup(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z, + const char* groupName) + throw (SALOME::SALOME_Exception); + */ +// void SetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList) +// throw (SALOME::SALOME_Exception); + + BLSURFPlugin::TEnfVertexList* GetEnforcedVerticesEntry(const char* entry) + throw (SALOME::SALOME_Exception); + + void UnsetEnforcedVertexEntry(const char* entry, CORBA::Double x, CORBA::Double y, CORBA::Double z) + throw (SALOME::SALOME_Exception); +// void UnsetEnforcedVertexListEntry(const char* entry, BLSURFPlugin::TEnfVertexList& vertexList) +// throw (SALOME::SALOME_Exception); + void UnsetEnforcedVerticesEntry(const char* entry) + throw (SALOME::SALOME_Exception); + + /*! + * Set/get node group to an enforced vertex + */ + /* TODO GROUPS + void SetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z, + const char* groupName) + throw (SALOME::SALOME_Exception); + char* GetEnforcedVertexGroupName(CORBA::Double x, CORBA::Double y, CORBA::Double z) + throw (SALOME::SALOME_Exception); + */ /////////////////////// // Get implementation diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index d4a8dcc..1a3758e 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -25,16 +25,17 @@ // --- // #include "BLSURFPluginGUI_HypothesisCreator.h" +// #include #include #include #include +#include "SMESHGUI_SpinBox.h" #include #include #include #include -#include #include #include @@ -69,9 +70,9 @@ #include #include #include +#include #include -// #include #define WITH_SIZE_BOUNDARIES enum Topology { @@ -105,7 +106,15 @@ enum { SMP_ENTRY_COLUMN = 0, SMP_NAME_COLUMN, SMP_SIZEMAP_COLUMN, - SMP_NB_COLUMNS + SMP_NB_COLUMNS, +// Enforced vertices array columns + ENF_VER_NAME_COLUMN = 0, + ENF_VER_ENTRY_COLUMN, + ENF_VER_X_COLUMN, + ENF_VER_Y_COLUMN, + ENF_VER_Z_COLUMN, +// ENF_VER_GROUP_COLUMN, + ENF_VER_NB_COLUMNS }; enum { @@ -117,27 +126,22 @@ enum { SMP_SURFACE_BTN, SMP_SEPARATOR2, SMP_REMOVE_BTN, + SMP_NB_LINES }; // Enforced vertices inputs enum { - ENF_VER_BTNS = 0, +// ENF_VER_FACE = 0, +// ENF_VER_VERTEX, ENF_VER_X_COORD = 0, ENF_VER_Y_COORD, ENF_VER_Z_COORD, +// ENF_VER_GROUP, ENF_VER_VERTEX_BTN, - ENF_VER_SEPARATOR, ENF_VER_REMOVE_BTN, -}; - -// Enforced vertices array columns -enum { - ENF_VER_NAME_COLUMN = 0, - ENF_VER_ENTRY_COLUMN, - ENF_VER_X_COLUMN, - ENF_VER_Y_COLUMN, - ENF_VER_Z_COLUMN, - ENF_VER_NB_COLUMNS +// ENF_VER_SEPARATOR, +// ENF_VER_GROUP_CHECK, + ENF_VER_NB_LINES }; @@ -263,46 +267,71 @@ QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & option , const QModelIndex & index ) const { - QLineEdit *editor = new QLineEdit(parent); +// QLineEdit *editor = new QLineEdit(parent); if (index.column() == ENF_VER_X_COLUMN || \ index.column() == ENF_VER_Y_COLUMN || \ index.column() == ENF_VER_Z_COLUMN) - editor->setValidator(new QDoubleValidator(parent)); + { + SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent); + editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + return editor; + } +// editor->setValidator(new QDoubleValidator(parent)); + else + { + QLineEdit *editor = new QLineEdit(parent); + return editor; + } - return editor; +// return editor; } void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QString value = index.model()->data(index, Qt::EditRole).toString(); - - QLineEdit *lineEdit = static_cast(editor); - lineEdit->setText(value); + if (index.column() == ENF_VER_X_COLUMN || \ + index.column() == ENF_VER_Y_COLUMN || \ + index.column() == ENF_VER_Z_COLUMN) { + SMESHGUI_SpinBox *lineEdit = static_cast(editor); + lineEdit->setText(value); +// lineEdit->editor()->setText(value); + } + else { + QLineEdit *lineEdit = static_cast(editor); + lineEdit->setText(value); + } } void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { - QLineEdit *lineEdit = static_cast(editor); +// QLineEdit *lineEdit = static_cast(editor); if (index.column() == ENF_VER_X_COLUMN || \ index.column() == ENF_VER_Y_COLUMN || \ index.column() == ENF_VER_Z_COLUMN) { - if (! vertexExists(model, index, lineEdit->text())) { - bool ok; - double value = lineEdit->text().toDouble(&ok); - if (ok) - model->setData(index, value, Qt::EditRole); + SMESHGUI_SpinBox *lineEdit = static_cast(editor); + if (! vertexExists(model, index, lineEdit->GetString())) { + model->setData(index, lineEdit->GetValue(), Qt::EditRole); } } else if (index.column() == ENF_VER_NAME_COLUMN) { + QLineEdit *lineEdit = static_cast(editor); QString value = lineEdit->text(); - if (! vertexExists(model, index, value)) + if (! vertexExists(model, index, value)) { model->setData(index, value, Qt::EditRole); + } +// MESSAGE("Value " << value.toString().toStdString() << " was set at index(" << index.row() << "," << index.column() << ")"); + } + /* TODO GROUPS + else if (index.column() == ENF_VER_GROUP_COLUMN) { + QLineEdit *lineEdit = static_cast(editor); + model->setData(index, lineEdit->text(), Qt::EditRole); // MESSAGE("Value " << value.toString().toStdString() << " was set at index(" << index.row() << "," << index.column() << ")"); } + */ } void EnforcedTreeWidgetDelegate::updateEditorGeometry(QWidget *editor, @@ -448,28 +477,28 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams() const { MESSAGE("BLSURFPluginGUI_HypothesisCreator::checkParams"); bool ok = true; - if ( !isDouble( myPhySize->text(), false )) { - if ( myPhySize->text().isEmpty() ) - myPhySize->setText(tr("OBLIGATORY_VALUE")); - myPhySize->selectAll(); - ok = false; - } - if ( !isDouble( myPhyMin->text(), true )) { - myPhyMin->selectAll(); - ok = false; - } - if ( !isDouble( myPhyMax->text(), true )) { - myPhyMax->selectAll(); - ok = false; - } - if ( !isDouble( myGeoMin->text(), true )) { - myGeoMin->selectAll(); - ok = false; - } - if ( !isDouble( myGeoMin->text(), true )) { - myGeoMin->selectAll(); - ok = false; - } +// if ( !isDouble( myPhySize->text(), false )) { +// if ( myPhySize->text().isEmpty() ) +// myPhySize->setText(tr("OBLIGATORY_VALUE")); +// myPhySize->selectAll(); +// ok = false; +// } +// if ( !isDouble( myPhyMin->text(), true )) { +// myPhyMin->selectAll(); +// ok = false; +// } +// if ( !isDouble( myPhyMax->text(), true )) { +// myPhyMax->selectAll(); +// ok = false; +// } +// if ( !isDouble( myGeoMin->text(), true )) { +// myGeoMin->selectAll(); +// ok = false; +// } +// if ( !isDouble( myGeoMin->text(), true )) { +// myGeoMin->selectAll(); +// ok = false; +// } if ( ok ) { myOptionTable->setFocus(); @@ -545,6 +574,7 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams() const QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() { MESSAGE("BLSURFPluginGUI_HypothesisCreator::buildFrame"); + QFrame* fr = new QFrame( 0 ); QVBoxLayout* lay = new QVBoxLayout( fr ); lay->setMargin( 5 ); @@ -562,101 +592,104 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() aStdLayout->setSpacing( 6 ); aStdLayout->setMargin( 11 ); - int row = 0; myName = 0; - if( isCreation() ) { - aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 ); + if( isCreation() ) myName = new QLineEdit( myStdGroup ); - aStdLayout->addWidget( myName, row++, 1, 1, 1 ); - } - aStdLayout->addWidget( new QLabel( tr( "BLSURF_GRADATION" ), myStdGroup ), row, 0, 1, 1 ); - myGradation = new SalomeApp_DoubleSpinBox( myStdGroup ); - aStdLayout->addWidget( myGradation, row++, 1, 1, 1 ); - myGradation->setMinimum( 1.1 ); - myGradation->setMaximum( 2.5 ); - myGradation->setSingleStep( 0.1 ); + myGradation = new SMESHGUI_SpinBox( myStdGroup ); + myGradation->RangeStepAndValidator(1.1, 2.5, 0.1, "length_precision"); - aStdLayout->addWidget( new QLabel( tr( "BLSURF_PHY_MESH" ), myStdGroup ), row, 0, 1, 1 ); myPhysicalMesh = new QComboBox( myStdGroup ); - aStdLayout->addWidget( myPhysicalMesh, row++, 1, 1, 1 ); QStringList physicalTypes; physicalTypes << tr( "BLSURF_DEFAULT_USER" ) << tr( "BLSURF_CUSTOM_USER" ) << tr( "BLSURF_SIZE_MAP"); myPhysicalMesh->addItems( physicalTypes ); - aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYDEF" ), myStdGroup), row, 0, 1, 1 ); - myPhySize = new QLineEdit( myStdGroup ); - aStdLayout->addWidget( myPhySize, row++, 1, 1, 1 ); + myPhySize = new SMESHGUI_SpinBox( myStdGroup ); + myPhySize->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision"); #ifdef WITH_SIZE_BOUNDARIES - aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMIN" ), myStdGroup ), row, 0, 1, 1 ); - myPhyMin = new QLineEdit( myStdGroup ); - aStdLayout->addWidget( myPhyMin, row++, 1, 1, 1 ); - - aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMAX" ), myStdGroup ), row, 0, 1, 1 ); - myPhyMax = new QLineEdit( myStdGroup ); - aStdLayout->addWidget( myPhyMax, row++, 1, 1, 1 ); + myPhyMin = new SMESHGUI_SpinBox( myStdGroup ); + myPhyMin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision"); + myPhyMin->setText(""); + myPhyMax = new SMESHGUI_SpinBox( myStdGroup ); + myPhyMax->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision"); + myPhyMax->setText(""); #endif - aStdLayout->addWidget( new QLabel( tr( "BLSURF_GEOM_MESH" ), myStdGroup ), row, 0, 1, 1 ); myGeometricMesh = new QComboBox( myStdGroup ); - aStdLayout->addWidget( myGeometricMesh, row++, 1, 1, 1 ); QStringList types; types << tr( "BLSURF_DEFAULT_GEOM" ) << tr( "BLSURF_CUSTOM_GEOM" ); myGeometricMesh->addItems( types ); - aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_S" ), myStdGroup ), row, 0, 1, 1 ); - myAngleMeshS = new SalomeApp_DoubleSpinBox( myStdGroup ); - aStdLayout->addWidget( myAngleMeshS, row++, 1, 1, 1 ); - myAngleMeshS->setMinimum( 0 ); - myAngleMeshS->setMaximum( 16 ); - myAngleMeshS->setSingleStep( 0.5 ); + myAngleMeshS = new SMESHGUI_SpinBox( myStdGroup ); + myAngleMeshS->RangeStepAndValidator(0, 16, 0.5, "angular_precision"); - aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_C" ), myStdGroup ), row, 0, 1, 1 ); - myAngleMeshC = new SalomeApp_DoubleSpinBox( myStdGroup ); - aStdLayout->addWidget( myAngleMeshC, row++, 1, 1, 1 ); - myAngleMeshC->setMinimum( 0 ); - myAngleMeshC->setMaximum( 16 ); - myAngleMeshC->setSingleStep( 0.5 ); + myAngleMeshC = new SMESHGUI_SpinBox( myStdGroup ); + myAngleMeshC->RangeStepAndValidator(0, 16, 0.5, "angular_precision"); #ifdef WITH_SIZE_BOUNDARIES - aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMIN" ), myStdGroup ), row, 0, 1, 1 ); - myGeoMin = new QLineEdit( myStdGroup ); - aStdLayout->addWidget( myGeoMin, row++, 1, 1, 1 ); - - aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMAX" ), myStdGroup ), row, 0, 1, 1 ); - myGeoMax = new QLineEdit( myStdGroup ); - aStdLayout->addWidget( myGeoMax, row++, 1, 1, 1 ); + myGeoMin = new SMESHGUI_SpinBox( myStdGroup ); + myGeoMin->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision"); + myGeoMin->setText(""); + myGeoMax = new SMESHGUI_SpinBox( myStdGroup ); + myGeoMax->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision"); + myGeoMax->setText(""); #endif - myAllowQuadrangles = new QCheckBox( tr( "BLSURF_ALLOW_QUADRANGLES" ), myStdGroup ); - aStdLayout->addWidget( myAllowQuadrangles, row++, 0, 1, 2 ); - myDecimesh = new QCheckBox( tr( "BLSURF_DECIMESH" ), myStdGroup ); - aStdLayout->addWidget( myDecimesh, row++, 0, 1, 2 ); + + // ADD WIDGETS (STANDARD TAB) + int row = 0; + if( isCreation() ) { + aStdLayout->addWidget( new QLabel( tr( "SMESH_NAME" ), myStdGroup ), row, 0, 1, 1 ); + aStdLayout->addWidget( myName, row++, 1, 1, 1 ); + } + aStdLayout->addWidget( new QLabel( tr( "BLSURF_GRADATION" ), myStdGroup ), row, 0, 1, 1 ); + aStdLayout->addWidget( myGradation, row++, 1, 1, 1 ); + aStdLayout->addWidget( new QLabel( tr( "BLSURF_PHY_MESH" ), myStdGroup ), row, 0, 1, 1 ); + aStdLayout->addWidget( myPhysicalMesh, row++, 1, 1, 1 ); + aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYDEF" ), myStdGroup), row, 0, 1, 1 ); + aStdLayout->addWidget( myPhySize, row++, 1, 1, 1 ); +#ifdef WITH_SIZE_BOUNDARIES + aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMIN" ), myStdGroup ), row, 0, 1, 1 ); + aStdLayout->addWidget( myPhyMin, row++, 1, 1, 1 ); + aStdLayout->addWidget( new QLabel( tr( "BLSURF_HPHYMAX" ), myStdGroup ), row, 0, 1, 1 ); + aStdLayout->addWidget( myPhyMax, row++, 1, 1, 1 ); +#endif + aStdLayout->addWidget( new QLabel( tr( "BLSURF_GEOM_MESH" ), myStdGroup ), row, 0, 1, 1 ); + aStdLayout->addWidget( myGeometricMesh, row++, 1, 1, 1 ); + aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_S" ), myStdGroup ), row, 0, 1, 1 ); + aStdLayout->addWidget( myAngleMeshS, row++, 1, 1, 1 ); + aStdLayout->addWidget( new QLabel( tr( "BLSURF_ANGLE_MESH_C" ), myStdGroup ), row, 0, 1, 1 ); + aStdLayout->addWidget( myAngleMeshC, row++, 1, 1, 1 ); +#ifdef WITH_SIZE_BOUNDARIES + aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMIN" ), myStdGroup ), row, 0, 1, 1 ); + aStdLayout->addWidget( myGeoMin, row++, 1, 1, 1 ); + aStdLayout->addWidget( new QLabel( tr( "BLSURF_HGEOMAX" ), myStdGroup ), row, 0, 1, 1 ); + aStdLayout->addWidget( myGeoMax, row++, 1, 1, 1 ); +#endif + aStdLayout->addWidget( myAllowQuadrangles, row++, 0, 1, 2 ); + aStdLayout->addWidget( myDecimesh, row++, 0, 1, 2 ); // advanced parameters myAdvGroup = new QWidget(); QGridLayout* anAdvLayout = new QGridLayout( myAdvGroup ); anAdvLayout->setSpacing( 6 ); anAdvLayout->setMargin( 11 ); + anAdvLayout->setRowStretch( 4, 5 ); + anAdvLayout->setColumnStretch( 1, 5 ); - anAdvLayout->addWidget( new QLabel( tr( "BLSURF_TOPOLOGY" ), myAdvGroup ), 0, 0, 1, 1 ); myTopology = new QComboBox( myAdvGroup ); - anAdvLayout->addWidget( myTopology, 0, 1, 1, 1 ); QStringList topologyTypes; topologyTypes << tr( "BLSURF_TOPOLOGY_CAD" ) << tr( "BLSURF_TOPOLOGY_PROCESS" ) << tr( "BLSURF_TOPOLOGY_PROCESS2" ); myTopology->addItems( topologyTypes ); - anAdvLayout->addWidget( new QLabel( tr( "BLSURF_VERBOSITY" ), myAdvGroup ), 1, 0, 1, 1 ); myVerbosity = new QSpinBox( myAdvGroup ); - anAdvLayout->addWidget( myVerbosity, 1, 1, 1, 1 ); myVerbosity->setMinimum( 0 ); myVerbosity->setMaximum( 100 ); myVerbosity->setSingleStep( 5 ); myOptionTable = new QTableWidget( 0, NB_COLUMNS, myAdvGroup ); - anAdvLayout->addWidget( myOptionTable, 2, 0, 3, 2 ); QStringList headers; headers << tr( "OPTION_ID_COLUMN" ) << tr( "OPTION_NAME_COLUMN" ) << tr( "OPTION_VALUE_COLUMN" ); myOptionTable->setHorizontalHeaderLabels( headers ); @@ -667,14 +700,19 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() //myOptionTable->setSelectionBehavior( QAbstractItemView::SelectRows ); QPushButton* addBtn = new QPushButton( tr( "ADD_OPTION"), myAdvGroup ); - anAdvLayout->addWidget( addBtn, 2, 2, 1, 1 ); addBtn->setMenu( new QMenu() ); - QPushButton* rmBtn = new QPushButton( tr( "REMOVE_OPTION"), myAdvGroup ); - anAdvLayout->addWidget( rmBtn, 3, 2, 1, 1 ); + + + // ADD WIDGETS (ADVANCED TAB) + anAdvLayout->addWidget( new QLabel( tr( "BLSURF_TOPOLOGY" ), myAdvGroup ), 0, 0, 1, 1 ); + anAdvLayout->addWidget( myTopology, 0, 1, 1, 1 ); + anAdvLayout->addWidget( new QLabel( tr( "BLSURF_VERBOSITY" ), myAdvGroup ), 1, 0, 1, 1 ); + anAdvLayout->addWidget( myVerbosity, 1, 1, 1, 1 ); + anAdvLayout->addWidget( myOptionTable, 2, 0, 3, 2 ); + anAdvLayout->addWidget( addBtn, 2, 2, 1, 1 ); + anAdvLayout->addWidget( rmBtn, 3, 2, 1, 1 ); - anAdvLayout->setRowStretch( 4, 5 ); - anAdvLayout->setColumnStretch( 1, 5 ); // Size Maps parameters @@ -682,54 +720,58 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup); mySizeMapTable = new QTableWidget( 0, SMP_NB_COLUMNS, mySmpGroup ); - anSmpLayout->addWidget(mySizeMapTable, 1, 0, 8, 1); QStringList sizeMapHeaders; sizeMapHeaders << tr( "SMP_ENTRY_COLUMN" )<< tr( "SMP_NAME_COLUMN" ) << tr( "SMP_SIZEMAP_COLUMN" ); mySizeMapTable->setHorizontalHeaderLabels(sizeMapHeaders); mySizeMapTable->horizontalHeader()->hideSection( SMP_ENTRY_COLUMN ); mySizeMapTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive); -// mySizeMapTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN); mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN); mySizeMapTable->setAlternatingRowColors(true); mySizeMapTable->verticalHeader()->hide(); - /* addAttractorButton = new QPushButton(tr("BLSURF_SM_ATTRACTOR"),mySmpGroup); - anSmpLayout->addWidget(addAttractorButton, SMP_ATTRACTOR_BTN, 1, 1, 1); - QFrame *line = new QFrame(mySmpGroup); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); - anSmpLayout->addWidget(line, SMP_SEPARATOR1, 1, 1, 1); */ addSurfaceButton = new QPushButton(tr("BLSURF_SM_SURFACE"),mySmpGroup); - anSmpLayout->addWidget(addSurfaceButton, SMP_SURFACE_BTN, 1, 1, 1); - addEdgeButton = new QPushButton(tr("BLSURF_SM_EDGE"),mySmpGroup); - anSmpLayout->addWidget(addEdgeButton, SMP_EDGE_BTN, 1, 1, 1); - addPointButton = new QPushButton(tr("BLSURF_SM_POINT"),mySmpGroup); - anSmpLayout->addWidget(addPointButton, SMP_POINT_BTN, 1, 1, 1); - QFrame *line2 = new QFrame(mySmpGroup); line2->setFrameShape(QFrame::HLine); line2->setFrameShadow(QFrame::Sunken); - anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 1, 1); - removeButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup); - anSmpLayout->addWidget(removeButton, SMP_REMOVE_BTN, 1, 1, 1); + + + // ADD WIDGETS (SIZEMAP TAB) + anSmpLayout->addWidget(mySizeMapTable, SMP_POINT_BTN, 0, SMP_NB_LINES+1, 1); +// anSmpLayout->addWidget(addAttractorButton, SMP_ATTRACTOR_BTN, 1, 1, 1); +// anSmpLayout->addWidget(line, SMP_SEPARATOR1, 1, 1, 1); + anSmpLayout->addWidget(addPointButton, SMP_POINT_BTN, 1, 1, 1); + anSmpLayout->addWidget(addEdgeButton, SMP_EDGE_BTN, 1, 1, 1); + anSmpLayout->addWidget(addSurfaceButton, SMP_SURFACE_BTN, 1, 1, 1); + anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 1, 1); + anSmpLayout->addWidget(removeButton, SMP_REMOVE_BTN, 1, 1, 1); - // Enforced vertices parameters + // Enforced vertices parameters myEnfGroup = new QWidget(); QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup); - +// +// myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(myEnfGroup); +// anEnfLayout->addWidget(myEnforcedVertexWidget); +// MESSAGE("Creating DlgBlSurfHyp_Enforced widget instance"); +// myEnforcedVertexWidget = new DlgBlSurfHyp_Enforced(); + myEnforcedTreeWidget = new QTreeWidget(myEnfGroup); myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS ); myEnforcedTreeWidget->setSortingEnabled(true); QStringList enforcedHeaders; - enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_X_COLUMN" )<< tr( "BLSURF_ENF_VER_Y_COLUMN" ) << tr( "BLSURF_ENF_VER_Z_COLUMN" ) ; + enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_X_COLUMN" )<< tr( "BLSURF_ENF_VER_Y_COLUMN" ) << tr( "BLSURF_ENF_VER_Z_COLUMN" ); + /* TODO GROUPS + enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_X_COLUMN" )<< tr( "BLSURF_ENF_VER_Y_COLUMN" ) << tr( "BLSURF_ENF_VER_Z_COLUMN" ) << tr( "BLSURF_ENF_VER_GROUP_COLUMN" ); + */ myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders); myEnforcedTreeWidget->setAlternatingRowColors(true); myEnforcedTreeWidget->setUniformRowHeights(true); @@ -742,42 +784,90 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() } myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN); myEnforcedTreeWidget->setItemDelegate(new EnforcedTreeWidgetDelegate()); - anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, 8, 1); + /* TODO FACE AND VERTEX SELECTION + selectFaceButton = new QPushButton(myEnfGroup); + QPixmap imageSel1(SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "BLSURF_ICON_SELECT"))); + selectFaceButton->setIcon(imageSel1); + + mySelectedFace = new QLineEdit(myEnfGroup); + mySelectedFace->setReadOnly(true); + mySelectedFace->setText(tr( "BLSURF_ENF_SELECT_FACE")); + mySelectedFace->setStyleSheet("QLineEdit { color: grey }"); + + selectVertexButton = new QPushButton(myEnfGroup); + QPixmap imageSel2(SUIT_Session::session()->resourceMgr()->loadPixmap( "BLSURFPlugin", tr( "BLSURF_ICON_SELECT"))); + selectVertexButton->setIcon(imageSel2); + + mySelectedEnforcedVertex = new QLineEdit(myEnfGroup); + mySelectedEnforcedVertex->setReadOnly(true); + mySelectedEnforcedVertex->setText(tr( "BLSURF_ENF_SELECT_VERTEX")); + mySelectedEnforcedVertex->setStyleSheet("QLineEdit { color: grey }"); + */ QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup ); - anEnfLayout->addWidget(myXCoordLabel, ENF_VER_X_COORD, 1, 1, 1); - myXCoord = new QLineEdit(myEnfGroup); - myXCoord->setValidator(new QDoubleValidator(myEnfGroup)); - anEnfLayout->addWidget(myXCoord, ENF_VER_X_COORD, 2, 1, 1); + myXCoord = new SMESHGUI_SpinBox(myEnfGroup); + myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup ); - anEnfLayout->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 1, 1, 1); - myYCoord = new QLineEdit(myEnfGroup); - myYCoord->setValidator(new QDoubleValidator(myEnfGroup)); - anEnfLayout->addWidget(myYCoord, ENF_VER_Y_COORD, 2, 1, 1); + myYCoord = new SMESHGUI_SpinBox(myEnfGroup); + myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup ); - anEnfLayout->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 1, 1, 1); - myZCoord = new QLineEdit(myEnfGroup); - myZCoord->setValidator(new QDoubleValidator(myEnfGroup)); - anEnfLayout->addWidget(myZCoord, ENF_VER_Z_COORD, 2, 1, 1); + myZCoord = new SMESHGUI_SpinBox(myEnfGroup); + myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision"); + /* TODO GROUPS + QLabel* myGroupNameLabel = new QLabel( tr( "BLSURF_ENF_VER_GROUP_LABEL" ), myEnfGroup ); + myGroupName = new QLineEdit(myEnfGroup); + */ + addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup); - anEnfLayout->addWidget(addVertexButton, ENF_VER_VERTEX_BTN, 1, 1, 2); - - QFrame *line = new QFrame(myEnfGroup); - line->setFrameShape(QFrame::HLine); - line->setFrameShadow(QFrame::Sunken); - anEnfLayout->addWidget(line, ENF_VER_SEPARATOR, 1, 1, 2); - +// QFrame *line = new QFrame(myEnfGroup); +// line->setFrameShape(QFrame::HLine); +// line->setFrameShadow(QFrame::Sunken); removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup); - anEnfLayout->addWidget(removeVertexButton, ENF_VER_REMOVE_BTN, 1, 1, 2); + /* TODO GROUPS + // CheckBox for groups generation + makeGroupsCheck = new QGroupBox(tr("BLSURF_ENF_VER_GROUPS"), myEnfGroup); + makeGroupsCheck->setCheckable(true); + makeGroupsCheck->setChecked(false); + QGridLayout* aGroupLayout = new QGridLayout(makeGroupsCheck); + myGlobalGroupName = new QLineEdit(makeGroupsCheck); + aGroupLayout->addWidget(myGlobalGroupName); + */ + + + anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, ENF_VER_NB_LINES+1, 1); + /* TODO FACE AND VERTEX SELECTION + anEnfLayout->addWidget(selectFaceButton, ENF_VER_FACE, 1, 1, 1); + anEnfLayout->addWidget(mySelectedFace, ENF_VER_FACE, 2, 1, 1); + anEnfLayout->addWidget(selectVertexButton, ENF_VER_VERTEX, 1, 1, 1); + anEnfLayout->addWidget(mySelectedEnforcedVertex, ENF_VER_VERTEX, 2, 1, 1); + */ + anEnfLayout->addWidget(myXCoordLabel, ENF_VER_X_COORD, 1, 1, 1); + anEnfLayout->addWidget(myXCoord, ENF_VER_X_COORD, 2, 1, 1); + anEnfLayout->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 1, 1, 1); + anEnfLayout->addWidget(myYCoord, ENF_VER_Y_COORD, 2, 1, 1); + anEnfLayout->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 1, 1, 1); + anEnfLayout->addWidget(myZCoord, ENF_VER_Z_COORD, 2, 1, 1); + /* TODO GROUPS + anEnfLayout->addWidget(myGroupNameLabel, ENF_VER_GROUP, 1, 1, 1); + anEnfLayout->addWidget(myGroupName, ENF_VER_GROUP, 2, 1, 1); + */ + anEnfLayout->addWidget(addVertexButton, ENF_VER_VERTEX_BTN, 1, 1, 2); + anEnfLayout->addWidget(removeVertexButton, ENF_VER_REMOVE_BTN, 1, 1, 2); +// anEnfLayout->addWidget(line, ENF_VER_SEPARATOR, 1, 1, 2); + /* TODO GROUPS + anEnfLayout->addWidget(makeGroupsCheck, ENF_VER_GROUP_CHECK, 1, 1, 2); + */ + // --- tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) ); tab->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) ); tab->insertTab( SMP_TAB, mySmpGroup, tr( "BLSURF_SIZE_MAP" ) ); tab->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) ); +// tab->insertTab( ENF_TAB, myEnforcedVertexWidget, tr( "BLSURF_ENF_VER" ) ); tab->setCurrentIndex( STD_TAB ); @@ -814,6 +904,9 @@ void BLSURFPluginGUI_HypothesisCreator::update(QTreeWidgetItem* item, int column QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole); QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole); QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole); + /* TODO GROUPS + QString groupName = item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString(); + */ QTreeWidgetItem* parent = item->parent(); if (parent) { @@ -825,15 +918,17 @@ void BLSURFPluginGUI_HypothesisCreator::update(QTreeWidgetItem* item, int column toolTip += QString(")"); item->setToolTip(ENF_VER_NAME_COLUMN,toolTip); } - - myXCoord->setText(x.toString()); - myYCoord->setText(y.toString()); - myZCoord->setText(z.toString()); + myXCoord->SetValue(x.toDouble()); + myYCoord->SetValue(y.toDouble()); + myZCoord->SetValue(z.toDouble()); + /* TODO GROUPS + myGroupName->setText(groupName); + */ } } /** BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() -This method synchronizes the QLineEdit widgets content with the coordinates +This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates of the enforced vertex clicked in the tree widget. */ void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() { @@ -847,9 +942,12 @@ void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() { if (! x.isNull()) { QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole); QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole); - myXCoord->setText(x.toString()); - myYCoord->setText(y.toString()); - myZCoord->setText(z.toString()); + myXCoord->SetValue(x.toDouble()); + myYCoord->SetValue(y.toDouble()); + myZCoord->SetValue(z.toDouble()); + /* TODO GROUPS + myGroupName->setText(item->data(ENF_VER_GROUP_COLUMN, Qt::EditRole).toString()); + */ break; } } @@ -859,7 +957,12 @@ void BLSURFPluginGUI_HypothesisCreator::synchronizeCoords() { /** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z) This method adds an enforced vertex (x,y,z) to shapeName in the tree widget. */ -void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std::string shapeName, double x, double y, double z) { +/* TODO GROUPS +void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std::string shapeName, + double x, double y, double z, std::string groupName) { +*/ +void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std::string shapeName, + double x, double y, double z) { // Find entry item QList theItemList = myEnforcedTreeWidget->findItems(QString(entry.c_str()),Qt::MatchExactly,ENF_VER_ENTRY_COLUMN); QTreeWidgetItem* theItem; @@ -881,6 +984,7 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std // MESSAGE("Number of child rows: " << nbVert); if (nbVert >0) { double childValueX,childValueY,childValueZ; +// QString childGrouName; QTreeWidgetItem* child; for (int row = 0;rowchild(row); @@ -888,6 +992,10 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std 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)) { + /* TODO GROUPS + // update group name + child->setData(ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str())); + */ okToCreate = false; break; } @@ -916,6 +1024,9 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std 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) ); + /* TODO GROUPS + vertexItem->setData( ENF_VER_GROUP_COLUMN, Qt::EditRole, QVariant(groupName.c_str())); + */ QString toolTip = QString(shapeName.c_str())+QString(": ")+vertexName; toolTip += QString(" (%1, ").arg(x); toolTip += QString("%1, ").arg(y); @@ -925,7 +1036,11 @@ void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN); } else - MESSAGE("In " << shapeName << " vertex with coords " << x << ", " << y << ", " << z<< " already exist: dont create again"); + /* TODO GROUPS + MESSAGE("In " << shapeName << " vertex with coords " << x << ", " << y << ", " << z << + " already exist: dont create again, only group name is updated with " << groupName); + */ + MESSAGE("In " << shapeName << " vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again"); } /** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() @@ -939,11 +1054,22 @@ void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() { BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; - if ((myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty())) return; - - double x = myXCoord->text().toDouble(); - double y = myYCoord->text().toDouble(); - double z = myZCoord->text().toDouble(); + if ((myXCoord->text().isEmpty()) || + (myYCoord->text().isEmpty()) || + (myZCoord->text().isEmpty())) return; + + double x = myXCoord->GetValue(); + double y = myYCoord->GetValue(); + double z = myZCoord->GetValue(); + + /* TODO GROUPS + std::string groupName = myGroupName->text().toStdString(); + if (makeGroupsCheck->isChecked()) + groupName = myGlobalGroupName->text().toStdString(); + + if (boost::trim_copy(groupName) == "") + groupName = ""; + */ TopAbs_ShapeEnum shapeType; string entry, shapeName; @@ -960,6 +1086,9 @@ void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVertices() { shapeType = myGeomToolSelected->entryToShapeType(entry); // MESSAGE("Object Name = " << shapeName << "& Type is " << anObject->getComponentDataType() << " & ShapeType is " << shapeType); if (shapeType == TopAbs_FACE) { + /* TODO GROUPS + addEnforcedVertex(entry, shapeName, x, y, z, groupName); + */ addEnforcedVertex(entry, shapeName, x, y, z); } } @@ -1029,17 +1158,36 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const } myTopology->setCurrentIndex( data.myTopology ); myPhysicalMesh->setCurrentIndex( data.myPhysicalMesh ); - myPhySize->setText( data.myPhySize ); + myPhySize->SetValue( data.myPhySize ); #ifdef WITH_SIZE_BOUNDARIES - myPhyMin->setText( data.myPhyMin ); - myPhyMax->setText( data.myPhyMax ); - myGeoMin->setText( data.myGeoMin ); - myGeoMax->setText( data.myGeoMax ); + MESSAGE("data.myPhyMin: "<setText(""); + else + myPhyMin->SetValue( data.myPhyMin ); + MESSAGE("data.myPhyMax: "<setText(""); + else + myPhyMax->SetValue( data.myPhyMax ); + MESSAGE("data.myGeoMin: "<setText(""); + else + myGeoMin->SetValue( data.myGeoMin ); + MESSAGE("data.myGeoMax: "<setText(""); + else + myGeoMax->SetValue( data.myGeoMax ); #endif myGeometricMesh->setCurrentIndex( data.myGeometricMesh ); - myAngleMeshS->setValue( data.myAngleMeshS ); - myAngleMeshC->setValue( data.myAngleMeshC ); - myGradation->setValue( data.myGradation ); +// myAngleMeshS->setValue( data.myAngleMeshS ); +// myAngleMeshC->setValue( data.myAngleMeshC ); +// myGradation->setValue( data.myGradation ); + myAngleMeshS->SetValue( data.myAngleMeshS ); + myAngleMeshC->SetValue( data.myAngleMeshC ); + myGradation->SetValue( data.myGradation ); myAllowQuadrangles->setChecked( data.myAllowQuadrangles ); myDecimesh->setChecked( data.myDecimesh ); myVerbosity->setValue( data.myVerbosity ); @@ -1091,9 +1239,9 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN); // Enforced vertices -// MESSAGE("retrieveParams(): data.enfVertMap.size() = " << data.enfVertMap.size()); - std::map > >::const_iterator evmIt = data.enfVertMap.begin(); - for ( ; evmIt != data.enfVertMap.end() ; ++evmIt) { +// MESSAGE("retrieveParams(): data.entryEnfVertexListMap.size() = " << data.entryEnfVertexListMap.size()); + std::map > >::const_iterator evmIt = data.entryEnfVertexListMap.begin(); + for ( ; evmIt != data.entryEnfVertexListMap.end() ; ++evmIt) { std::string entry = (*evmIt).first; std::string shapeName = myGeomToolSelected->getNameFromEntry(entry); @@ -1113,6 +1261,11 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const x = (*evsIt)[0]; y = (*evsIt)[1]; z = (*evsIt)[2]; + /* TODO GROUPS + std::string groupName = data.enfVertexGroupNameMap[(*evsIt)]; + MESSAGE("Vertex "<addEnforcedVertex(entry, shapeName, x, y, z, groupName); + */ that->addEnforcedVertex(entry, shapeName, x, y, z); } } @@ -1152,7 +1305,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData h_data.myTopology = (int) h->GetTopology(); h_data.myPhysicalMesh = (int) h->GetPhysicalMesh(); - h_data.myPhySize = QString::number( h->GetPhySize() ); + h_data.myPhySize = h->GetPhySize(); h_data.myGeometricMesh = (int) h->GetGeometricMesh(); h_data.myAngleMeshS = h->GetAngleMeshS(); h_data.myAngleMeshC = h->GetAngleMeshC(); @@ -1166,11 +1319,15 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData double PhyMax = h->GetPhyMax(); double GeoMin = h->GetGeoMin(); double GeoMax = h->GetGeoMax(); - if ( PhyMin > 0 ) - h_data.myPhyMin = PhyMin > 0 ? QString::number( h->GetPhyMin() ) : QString(""); - h_data.myPhyMax = PhyMax > 0 ? QString::number( h->GetPhyMax() ) : QString(""); - h_data.myGeoMin = GeoMin > 0 ? QString::number( h->GetGeoMin() ) : QString(""); - h_data.myGeoMax = GeoMax > 0 ? QString::number( h->GetGeoMax() ) : QString(""); +// if ( PhyMin > 0 ) +// h_data.myPhyMin = PhyMin > 0 ? QString::number( h->GetPhyMin() ) : QString(""); +// h_data.myPhyMax = PhyMax > 0 ? QString::number( h->GetPhyMax() ) : QString(""); +// h_data.myGeoMin = GeoMin > 0 ? QString::number( h->GetGeoMin() ) : QString(""); +// h_data.myGeoMax = GeoMax > 0 ? QString::number( h->GetGeoMax() ) : QString(""); + h_data.myPhyMin = PhyMin > 0 ? PhyMin : -1.0; + h_data.myPhyMax = PhyMax > 0 ? PhyMax : -1.0; + h_data.myGeoMin = GeoMin > 0 ? GeoMin : -1.0; + h_data.myGeoMax = GeoMax > 0 ? GeoMax : -1.0; #endif BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; @@ -1238,15 +1395,24 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData } // Enforced vertices - BLSURFPlugin::TEnforcedVertexMap_var enforcedVertexMap = h->GetAllEnforcedVertices(); -// MESSAGE("enforcedVertexMap->length() = " << enforcedVertexMap->length()); + h_data.enfVertexList.clear(); + h_data.entryEnfVertexListMap.clear(); + /* TODO GROUPS + h_data.groupNameEnfVertexListMap.clear(); +// h_data.enfVertexGroupNameMap.clear(); + */ - for ( int i = 0;ilength(); ++i ) { - std::string entry = enforcedVertexMap[i].entry.in(); -// BLSURFPlugin::TEnforcedVertexList_var vertexList = enforcedVertexMap[i].vertexList; - BLSURFPlugin::TEnforcedVertexList vertexList = enforcedVertexMap[i].vertexList; + BLSURFPlugin::TEntryEnfVertexListMap_var entryEnfVertexListMap = h->GetAllEnforcedVertices(); +// MESSAGE("entryEnfVertexListMap->length() = " << entryEnfVertexListMap->length()); + + for ( int i = 0;ilength(); ++i ) { + std::string entry = entryEnfVertexListMap[i].entry.in(); + BLSURFPlugin::TEnfVertexList_var vertexList = h->GetEnforcedVerticesEntry(entry.c_str()); std::set > evs; - for (int j=0 ; jlength(); ++j) { double x = vertexList[j][0]; double y = vertexList[j][1]; double z = vertexList[j][2]; @@ -1255,12 +1421,23 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData ev.push_back(y); ev.push_back(z); evs.insert(ev); + h_data.enfVertexList.insert(ev); + /* TODO GROUPS + groupName.assign(h->GetEnforcedVertexGroupName(x, y, z)); + MESSAGE("readParamsFromHypo, groupName = "<SetVerbosity( h_data.myVerbosity ); if( ((int) h_data.myPhysicalMesh == PhysicalUserDefined)||((int) h_data.myPhysicalMesh == SizeMap) ) { - if ( h->GetPhySize() != h_data.myPhySize.toDouble() ) - h->SetPhySize( h_data.myPhySize.toDouble() ); + if ( h->GetPhySize() != h_data.myPhySize ) + h->SetPhySize( h_data.myPhySize ); } if( (int) h_data.myGeometricMesh == UserDefined ) { if ( h->GetAngleMeshS() != h_data.myAngleMeshS ) @@ -1308,22 +1485,30 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi h->SetAngleMeshC( h_data.myAngleMeshC ); } #ifdef WITH_SIZE_BOUNDARIES - if ( !isDouble( h_data.myPhyMin )) - h->SetPhyMin( -1 ); - else if ( h->GetPhyMin() != h_data.myPhyMin.toDouble() ) - h->SetPhyMin( h_data.myPhyMin.toDouble() ); - if ( !isDouble( h_data.myPhyMax )) - h->SetPhyMax( -1 ); - else if ( h->GetPhyMax() != h_data.myPhyMax.toDouble() ) - h->SetPhyMax( h_data.myPhyMax.toDouble() ); - if ( !isDouble( h_data.myGeoMin )) - h->SetGeoMin( -1 ); - else if ( h->GetGeoMin() != h_data.myGeoMin.toDouble() ) - h->SetGeoMin( h_data.myGeoMin.toDouble() ); - if ( !isDouble( h_data.myGeoMax )) - h->SetGeoMax( -1 ); - else if ( h->GetGeoMax() != h_data.myGeoMax.toDouble() ) - h->SetGeoMax( h_data.myGeoMax.toDouble() ); +// if ( !isDouble( h_data.myPhyMin )) +// h->SetPhyMin( -1 ); +// else if ( h->GetPhyMin() != h_data.myPhyMin.toDouble() ) +// h->SetPhyMin( h_data.myPhyMin.toDouble() ); +// if ( !isDouble( h_data.myPhyMax )) +// h->SetPhyMax( -1 ); +// else if ( h->GetPhyMax() != h_data.myPhyMax.toDouble() ) +// h->SetPhyMax( h_data.myPhyMax.toDouble() ); +// if ( !isDouble( h_data.myGeoMin )) +// h->SetGeoMin( -1 ); +// else if ( h->GetGeoMin() != h_data.myGeoMin.toDouble() ) +// h->SetGeoMin( h_data.myGeoMin.toDouble() ); +// if ( !isDouble( h_data.myGeoMax )) +// h->SetGeoMax( -1 ); +// else if ( h->GetGeoMax() != h_data.myGeoMax.toDouble() ) +// h->SetGeoMax( h_data.myGeoMax.toDouble() ); + if (h_data.myPhyMin > 0) + h->SetPhyMin( h_data.myPhyMin ); + if (h_data.myPhyMax > 0) + h->SetPhyMax( h_data.myPhyMax ); + if (h_data.myGeoMin > 0) + h->SetGeoMin( h_data.myGeoMin ); + if (h_data.myGeoMax > 0) + h->SetGeoMax( h_data.myGeoMax ); #endif //printf("storeParamsToHypo():myOptions->length()=%d\n",myOptions->length()); @@ -1365,13 +1550,16 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi } // Enforced vertices - std::map > >::const_iterator evmIt = h_data.enfVertMap.begin(); - for ( ; evmIt != h_data.enfVertMap.end() ; ++evmIt) { + std::map > >::const_iterator evmIt = h_data.entryEnfVertexListMap.begin(); + for ( ; evmIt != h_data.entryEnfVertexListMap.end() ; ++evmIt) { std::string entry = evmIt->first; std::set > evs; std::set >::const_iterator evsIt; double x, y, z; - BLSURFPlugin::TEnforcedVertexList_var hypVertexList; + /* TODO GROUPS + std::string groupName = ""; + */ + BLSURFPlugin::TEnfVertexList_var hypVertexList; int hypNbVertex = 0; try { hypVertexList = h->GetEnforcedVerticesEntry(entry.c_str()); @@ -1385,7 +1573,14 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi x = (*evsIt)[0]; y = (*evsIt)[1]; z = (*evsIt)[2]; + + /* TODO GROUPS + std::map , std::string >::const_iterator grpIt = h_data.enfVertexGroupNameMap.find(*evsIt); + if (grpIt != h_data.enfVertexGroupNameMap.end()) + groupName = grpIt->second; // MESSAGE("SetEnforcedVertexEntry("<SetEnforcedVertexEntryWithGroup( entry.c_str(), x, y, z, groupName.c_str() ); + */ h->SetEnforcedVertexEntry( entry.c_str(), x, y, z ); } // Remove old vertices @@ -1423,17 +1618,17 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes h_data.myName = myName ? myName->text() : ""; h_data.myTopology = myTopology->currentIndex(); h_data.myPhysicalMesh = myPhysicalMesh->currentIndex(); - h_data.myPhySize = myPhySize->text(); + h_data.myPhySize = myPhySize->GetValue(); #ifdef WITH_SIZE_BOUNDARIES - h_data.myPhyMin = myPhyMin->text(); - h_data.myPhyMax = myPhyMax->text(); - h_data.myGeoMin = myGeoMin->text(); - h_data.myGeoMax = myGeoMax->text(); + h_data.myPhyMin = myPhyMin->GetValue(); + h_data.myPhyMax = myPhyMax->GetValue(); + h_data.myGeoMin = myGeoMin->GetValue(); + h_data.myGeoMax = myGeoMax->GetValue(); #endif h_data.myGeometricMesh = myGeometricMesh->currentIndex(); - h_data.myAngleMeshS = myAngleMeshS->value(); - h_data.myAngleMeshC = myAngleMeshC->value(); - h_data.myGradation = myGradation->value(); + h_data.myAngleMeshS = myAngleMeshS->GetValue(); + h_data.myAngleMeshC = myAngleMeshC->GetValue(); + h_data.myGradation = myGradation->GetValue(); h_data.myAllowQuadrangles = myAllowQuadrangles->isChecked(); h_data.myDecimesh = myDecimesh->isChecked(); h_data.myVerbosity = myVerbosity->value(); @@ -1441,17 +1636,17 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes QString guiHyp; guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; "; guiHyp += tr("BLSURF_PHY_MESH") + " = " + QString::number( h_data.myPhysicalMesh ) + "; "; - guiHyp += tr("BLSURF_HPHYDEF") + " = " + h_data.myPhySize + "; "; + guiHyp += tr("BLSURF_HPHYDEF") + " = " + QString::number( h_data.myPhySize ) + "; "; guiHyp += tr("BLSURF_GEOM_MESH") + " = " + QString::number( h_data.myGeometricMesh ) + "; "; guiHyp += tr("BLSURF_ANGLE_MESH_S") + " = " + QString::number( h_data.myAngleMeshS ) + "; "; guiHyp += tr("BLSURF_GRADATION") + " = " + QString::number( h_data.myGradation ) + "; "; guiHyp += tr("BLSURF_ALLOW_QUADRANGLES") + " = " + QString(h_data.myAllowQuadrangles ? "yes" : "no") + "; "; guiHyp += tr("BLSURF_DECIMESH") + " = " + QString(h_data.myDecimesh ? "yes" : "no") + "; "; #ifdef WITH_SIZE_BOUNDARIES - if ( isDouble( h_data.myPhyMin )) guiHyp += "hphymin = " + h_data.myPhyMin + "; "; - if ( isDouble( h_data.myPhyMax )) guiHyp += "hphymax = " + h_data.myPhyMax + "; "; - if ( isDouble( h_data.myGeoMin )) guiHyp += "hgeomin = " + h_data.myGeoMin + "; "; - if ( isDouble( h_data.myGeoMax )) guiHyp += "hgeomax = " + h_data.myGeoMax + "; "; + guiHyp += "hphymin = " + QString::number( h_data.myPhyMin ) + "; "; + guiHyp += "hphymax = " + QString::number( h_data.myPhyMax ) + "; "; + guiHyp += "hgeomin = " + QString::number( h_data.myGeoMin ) + "; "; + guiHyp += "hgeomax = " + QString::number( h_data.myGeoMax ) + "; "; #endif BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; @@ -1481,10 +1676,16 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes } // Enforced vertices - // h_data.enfVertMap - + h_data.enfVertexList.clear(); + h_data.entryEnfVertexListMap.clear(); + /* TODO GROUPS + h_data.groupNameEnfVertexListMap.clear(); + h_data.enfVertexGroupNameMap.clear(); + */ + int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount(); int nbEnforcedVertices = 0; + std::string groupName = ""; // MESSAGE("Nb of enforced shapes: " << nbEnforcedShapes); for (int i=0 ; itopLevelItem(i); @@ -1505,8 +1706,18 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes vertex.push_back(childValueY); vertex.push_back(childValueZ); evs.insert(vertex); + h_data.enfVertexList.insert(vertex); + /* TODO GROUPS + groupName = child->data(ENF_VER_GROUP_COLUMN,Qt::EditRole).toString().toStdString(); + // Group + if (makeGroupsCheck->isChecked()) + groupName = myGlobalGroupName->text().toStdString(); + h_data.enfVertexGroupNameMap[vertex] = groupName; + if (groupName != "") + h_data.groupNameEnfVertexListMap[groupName].insert(vertex); + */ } - h_data.enfVertMap[entry] = evs; + h_data.entryEnfVertexListMap[entry] = evs; } } } @@ -1528,21 +1739,22 @@ void BLSURFPluginGUI_HypothesisCreator::onPhysicalMeshChanged() { myPhyMin->setEnabled(isCustom); if ( !myGradation->isEnabled()) - myGradation->setValue( 1.1 ); +// myGradation->setValue( 1.1 ); + myGradation->SetValue( 1.1 ); if ( !isCustom ) { - QString aPhySize = ""; - switch( myPhysicalMesh->currentIndex() ) { - case DefaultSize: - default: - aPhySize = "10"; - break; - } - myPhySize->setText( aPhySize ); - if ( !isDouble( myPhyMin->text(), true )) - myPhyMin->setText(""); - if ( !isDouble( myPhyMax->text(), true )) - myPhyMax->setText(""); +// QString aPhySize = ""; +// switch( myPhysicalMesh->currentIndex() ) { +// case DefaultSize: +// default: +// aPhySize = "10"; +// break; +// } +// myPhySize->setText( aPhySize ); +// if ( !isDouble( myPhyMin->text(), true )) +// myPhyMin->setText(""); +// if ( !isDouble( myPhyMax->text(), true )) +// myPhyMax->setText(""); if ( myGeometricMesh->currentIndex() == DefaultGeom ) { myGeometricMesh->setCurrentIndex( UserDefined ); onGeometricMeshChanged(); @@ -1562,22 +1774,22 @@ void BLSURFPluginGUI_HypothesisCreator::onGeometricMeshChanged() { myGeoMin->setEnabled(isCustom); if ( !myGradation->isEnabled()) - myGradation->setValue( 1.1 ); + myGradation->SetValue( 1.1 ); if ( ! isCustom ) { - double aAngleMeshS; - switch( myGeometricMesh->currentIndex() ) { - case DefaultGeom: - default: - aAngleMeshS = 8; - break; - } - myAngleMeshS->setValue( aAngleMeshS ); - myAngleMeshC->setValue( aAngleMeshS ); - if ( !isDouble( myGeoMin->text(), true )) - myGeoMin->setText(""); - if ( !isDouble( myGeoMax->text(), true )) - myGeoMax->setText(""); +// double aAngleMeshS; +// switch( myGeometricMesh->currentIndex() ) { +// case DefaultGeom: +// default: +// aAngleMeshS = 8; +// break; +// } +// myAngleMeshS->SetValue( aAngleMeshS ); +// myAngleMeshC->SetValue( aAngleMeshS ); +// if ( !isDouble( myGeoMin->text(), true )) +// myGeoMin->setText(""); +// if ( !isDouble( myGeoMax->text(), true )) +// myGeoMax->setText(""); // hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec) if ( myPhysicalMesh->currentIndex() == DefaultSize ) { myPhysicalMesh->setCurrentIndex( PhysicalUserDefined ); diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h index c074321..63d105e 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h @@ -71,17 +71,23 @@ class QMenu; class QAction; class QTreeWidgetItem; -class SalomeApp_DoubleSpinBox; +class SMESHGUI_SpinBox; class LightApp_SelectionMgr; +// class DlgBlSurfHyp_Enforced; typedef struct { int myTopology, myVerbosity; int myPhysicalMesh, myGeometricMesh; double myAngleMeshS, myAngleMeshC, myGradation; - QString myPhySize, myGeoMin, myGeoMax, myPhyMin,myPhyMax; + double myPhySize, myGeoMin, myGeoMax, myPhyMin,myPhyMax; bool myAllowQuadrangles, myDecimesh,mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex; - std::map > > enfVertMap; + std::set > enfVertexList; + std::map > > entryEnfVertexListMap; + /* TODO GROUPS + std::map > > groupNameEnfVertexListMap; + std::map , std::string > enfVertexGroupNameMap; + */ QString myName; } BlsurfHypothesisData; @@ -124,6 +130,9 @@ protected slots: void onRemoveMap(); void onSetSizeMap(int,int); + /* TODO GROUPS + void addEnforcedVertex(std::string, std::string, double, double, double, std::string); + */ void addEnforcedVertex(std::string, std::string, double, double, double); void onAddEnforcedVertices(); void onRemoveEnforcedVertex(); @@ -143,15 +152,15 @@ private: QWidget* myStdGroup; QLineEdit* myName; QComboBox* myPhysicalMesh; - QLineEdit* myPhySize; - QLineEdit* myPhyMin; - QLineEdit* myPhyMax; + SMESHGUI_SpinBox* myPhySize; + SMESHGUI_SpinBox* myPhyMin; + SMESHGUI_SpinBox* myPhyMax; QComboBox* myGeometricMesh; - SalomeApp_DoubleSpinBox* myAngleMeshS; - SalomeApp_DoubleSpinBox* myAngleMeshC; - QLineEdit* myGeoMin; - QLineEdit* myGeoMax; - SalomeApp_DoubleSpinBox* myGradation; + SMESHGUI_SpinBox* myAngleMeshS; + SMESHGUI_SpinBox* myAngleMeshC; + SMESHGUI_SpinBox* myGeoMin; + SMESHGUI_SpinBox* myGeoMax; + SMESHGUI_SpinBox* myGradation; QCheckBox* myAllowQuadrangles; QCheckBox* myDecimesh; @@ -169,10 +178,24 @@ private: QPushButton *removeButton; QWidget* myEnfGroup; + /* TODO FACE AND VERTEX SELECTION + QPushButton* selectFaceButton; + QLineEdit* mySelectedFace; +// GEOM::GEOM_Object_var myEnfFace; + QPushButton* selectVertexButton; + QLineEdit* mySelectedEnforcedVertex; +// GEOM::GEOM_Object_var myEnfVertex; + */ +// DlgBlSurfHyp_Enforced* myEnforcedVertexWidget; QTreeWidget* myEnforcedTreeWidget; - QLineEdit* myXCoord; - QLineEdit* myYCoord; - QLineEdit* myZCoord; + SMESHGUI_SpinBox* myXCoord; + SMESHGUI_SpinBox* myYCoord; + SMESHGUI_SpinBox* myZCoord; + /* TODO GROUPS + QLineEdit* myGroupName; + QGroupBox* makeGroupsCheck; + QLineEdit* myGlobalGroupName; + */ QPushButton* addVertexButton; QPushButton* removeVertexButton; diff --git a/src/GUI/BLSURFPlugin_images.ts b/src/GUI/BLSURFPlugin_images.ts index d453de9..c267058 100644 --- a/src/GUI/BLSURFPlugin_images.ts +++ b/src/GUI/BLSURFPlugin_images.ts @@ -22,6 +22,10 @@ @default + + BLSURF_ICON_SELECT + mesh_select_BLSURF.png + ICON_DLG_BLSURF_PARAMETERS mesh_hypo_BLSURF.png diff --git a/src/GUI/BLSURFPlugin_msg_en.ts b/src/GUI/BLSURFPlugin_msg_en.ts index 2b5f1ca..c949189 100644 --- a/src/GUI/BLSURFPlugin_msg_en.ts +++ b/src/GUI/BLSURFPlugin_msg_en.ts @@ -191,6 +191,18 @@ BLSURF_ENF_VER_Z_COLUMN Z + + BLSURF_ENF_VER_GROUP_COLUMN + Group + + + BLSURF_ENF_SELECT_FACE + Select a face + + + BLSURF_ENF_SELECT_VERTEX + Select a vertex + BLSURF_ENF_VER_X_LABEL X: @@ -203,6 +215,10 @@ BLSURF_ENF_VER_Z_LABEL Z: + + BLSURF_ENF_VER_GROUP_LABEL + Group: + BLSURF_ENF_VER_VERTEX Add enforced vertex @@ -211,5 +227,9 @@ BLSURF_ENF_VER_REMOVE Remove vertex + + BLSURF_ENF_VER_GROUPS + Unique group + diff --git a/src/GUI/BLSURFPlugin_msg_fr.ts b/src/GUI/BLSURFPlugin_msg_fr.ts index 40bb4df..8a9f962 100755 --- a/src/GUI/BLSURFPlugin_msg_fr.ts +++ b/src/GUI/BLSURFPlugin_msg_fr.ts @@ -9,7 +9,7 @@ BLSURF_ALLOW_QUADRANGLES - Permettre les Quadrangles (Teste) + Permettre les Quadrangles (Test) BLSURF_ANGLE_MESH_C @@ -89,7 +89,7 @@ BLSURF_TOPOLOGY_CAD - A partir de CAD + A partir de la CAO BLSURF_TOPOLOGY_PROCESS @@ -133,7 +133,7 @@ SMP_SIZEMAP_COLUMN - Carte des tailles + Carte de taille BLSURF_SM_SURFACE @@ -157,7 +157,7 @@ BLSURF_SM_SURF_VALUE - Valeur sur la Surface(s) + Taille sur la Surface BLSURF_SM_EDGE_VALUE @@ -165,11 +165,11 @@ BLSURF_SM_POINT_VALUE - Taille sur le Point(s) + Taille sur le Point BLSURF_ENF_VER - Points Enforcés + Points de Passage BLSURF_ENF_VER_ENTRY_COLUMN @@ -191,6 +191,18 @@ BLSURF_ENF_VER_Z_COLUMN Z + + BLSURF_ENF_VER_GROUP_COLUMN + Groupe + + + BLSURF_ENF_SELECT_FACE + Sélectionner une face + + + BLSURF_ENF_SELECT_VERTEX + Sélectionner un point + BLSURF_ENF_VER_X_LABEL X: @@ -203,13 +215,21 @@ BLSURF_ENF_VER_Z_LABEL Z: + + BLSURF_ENF_VER_GROUP_LABEL + Groupe: + BLSURF_ENF_VER_VERTEX - Ajouter un point enforcé + Ajouter un point de passage BLSURF_ENF_VER_REMOVE Supprimer un point + + BLSURF_ENF_VER_GROUPS + Groupe unique + -- 2.39.2