From 4f4640b03547458def2a346268898ca3cbf40ead Mon Sep 17 00:00:00 2001 From: gdd Date: Mon, 7 Feb 2011 18:31:06 +0000 Subject: [PATCH] New structure: in progress TODO: - GUI - OnLoad --- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 63 ++++---- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx | 9 +- .../BLSURFPlugin_Hypothesis_i.cxx | 134 ++++++++++++++++-- src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 64 +++++++-- src/GUI/BLSURFPluginGUI_HypothesisCreator.h | 53 ++++--- 5 files changed, 248 insertions(+), 75 deletions(-) diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index d5dc6b5..21d51dd 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -425,7 +425,7 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEntry& theFaceEntry, doub // update _faceEntryEnfVertexListMap TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry]; for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) { - if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { currentEnfVertexList.erase(it); currentEnfVertexList.insert(newEnfVertex); break; @@ -434,7 +434,7 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEntry& theFaceEntry, doub // update _enfVertexList for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) { - if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { _enfVertexList.erase(it); _enfVertexList.insert(newEnfVertex); break; @@ -454,7 +454,7 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEntry& theFaceEntry, doub // update _faceEntryEnfVertexListMap TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry]; for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) { - if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { currentEnfVertexList.erase(it); currentEnfVertexList.insert(newEnfVertex); break; @@ -463,7 +463,7 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEntry& theFaceEntry, doub // update _enfVertexList for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) { - if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { _enfVertexList.erase(it); _enfVertexList.insert(newEnfVertex); break; @@ -487,7 +487,7 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEntry& theFaceEntry, doub // update _faceEntryEnfVertexListMap TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry]; for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) { - if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { currentEnfVertexList.erase(it); currentEnfVertexList.insert(newEnfVertex); break; @@ -496,7 +496,7 @@ bool BLSURFPlugin_Hypothesis::SetEnforcedVertex(const TEntry& theFaceEntry, doub // update _enfVertexList for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) { - if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { _enfVertexList.erase(it); _enfVertexList.insert(newEnfVertex); break; @@ -685,7 +685,7 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do // update _enfVertexList for (TEnfVertexList::iterator it = _enfVertexList.begin() ; it != _enfVertexList.end() ; ++it) { - if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { _enfVertexList.erase(it); toNotify = true; MESSAGE("Done"); @@ -696,7 +696,7 @@ bool BLSURFPlugin_Hypothesis::ClearEnforcedVertex(const TEntry& theFaceEntry, do // update _faceEntryEnfVertexListMap TEnfVertexList& currentEnfVertexList = _faceEntryEnfVertexListMap[theFaceEntry]; for (TEnfVertexList::iterator it = currentEnfVertexList.begin() ; it != currentEnfVertexList.end() ; ++it) { - if (TEnfVertexCmp(&(*it),&oldEnfVertex) == 0){ + if (TEnfVertexCmp(&(*it),&oldEnfVertex)) { currentEnfVertexList.erase(it); toNotify = true; break; @@ -846,27 +846,26 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) { save << " " << "__ATTRACTORS_END__"; } - TFaceEntryCoordsListMap::const_iterator it_enf = _faceEntryCoordsListMap.begin(); - if (it_enf != _faceEntryCoordsListMap.end()) { + TFaceEntryEnfVertexListMap::const_iterator it_enf = _faceEntryEnfVertexListMap.begin(); + if (it_enf != _faceEntryEnfVertexListMap.end()) { save << " " << "__ENFORCED_VERTICES_BEGIN__"; - for (; it_enf != _faceEntryCoordsListMap.end(); ++it_enf) { + for (; it_enf != _faceEntryEnfVertexListMap.end(); ++it_enf) { save << " " << it_enf->first; - TEnfVertexCoordsList coordsList = it_enf->second; - TEnfVertexCoordsList::const_iterator it_coordsList = coordsList.begin(); - for (; it_coordsList != coordsList.end(); ++it_coordsList) { - TEnfVertex enfVertex = _coordsEnfVertexMap[(*it_coordsList)]; - save << " " << enfVertex.name; - save << " " << enfVertex.coords[0]; - save << " " << enfVertex.coords[1]; - save << " " << enfVertex.coords[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__"; - } - */ + TEnfVertexList enfVertexList = it_enf->second; + TEnfVertexList::const_iterator it_enfVertexList = enfVertexList.begin(); + for (; it_enfVertexList != enfVertexList.end(); ++it_enfVertexList) { + TEnfVertex enfVertex = (*it_enfVertexList); + save << " " << enfVertex.name << ";"; + save << " " << enfVertex.geomEntry << ";"; + if (enfVertex.coords.size()) { + save << " " << enfVertex.coords[0] << ";"; + save << " " << enfVertex.coords[1] << ";"; + save << " " << enfVertex.coords[2] << ";"; + } + else { + save <<" ; ; ;"; + } + save << " " << enfVertex.grpName; save << " " << "$"; // "$" is a mark of enforced vertex end } save << "#"; // "#" is a mark of enforced shape end @@ -1092,6 +1091,16 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) { hasEnforcedVertex = true; } +// MAPS TO FILL +// TFaceEntryEnfVertexListMap _faceEntryEnfVertexListMap; +// TEnfVertexList _enfVertexList; +// // maps to get "manual" enf vertex (through their coordinates) +// TFaceEntryCoordsListMap _faceEntryCoordsListMap; +// TCoordsEnfVertexMap _coordsEnfVertexMap; +// // maps to get "geom" enf vertex (through their geom entries) +// TFaceEntryEnfVertexEntryListMap _faceEntryEnfVertexEntryListMap; +// TEnfVertexEntryEnfVertexMap _enfVertexEntryEnfVertexMap; + std::string enfVertexEntry, enfValue, enfGroup, trace; std::ostringstream oss; while (isOK && hasEnforcedVertex) { diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index 65799bf..7019f00 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -155,13 +155,11 @@ public: TEnfGroupName grpName; // TEntryList faceEntries; // any use ? } TEnfVertex; + struct CompareEnfVertices { bool operator () (const TEnfVertex &e1, const TEnfVertex &e2) const - { -// MESSAGE("Comparing 2 enf vertices"); return true; - } }; int TEnfVertexCmp(const TEnfVertex *e1, const TEnfVertex *e2) { @@ -170,9 +168,8 @@ public: if (e1->coords.size() && e2->coords.size()) sameCoords = (e1->coords[0] == e2->coords[0]) && (e1->coords[1] == e2->coords[1]) && (e1->coords[2] == e2->coords[2]); - if( sameCoords && (e1->geomEntry == e2->geomEntry) && (e1->grpName == e2->grpName) - && (e1->name == e2->name)) - return 0; + return ( sameCoords && (e1->geomEntry == e2->geomEntry) && (e1->grpName == e2->grpName) + && (e1->name == e2->name)); } else return (e1 < e2); } diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 0680bd1..e17b02b 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -1034,8 +1034,21 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertex(GEOM::GEOM_Object_ptr theFace, THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); } - // TODO Affecter un nom de groupe vide string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry == "") { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } if (theFaceEntry == "") THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); MESSAGE("IDL : GetName : " << theFace->GetName()); @@ -1059,10 +1072,24 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexNamed(GEOM::GEOM_Object_ptr the THROW_SALOME_CORBA_EXCEPTION("theFace shape type is not FACE or COMPOUND", SALOME::BAD_PARAM); } - // TODO Affecter un nom de groupe vide string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry == "") { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } if (theFaceEntry == "") THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + MESSAGE("IDL : GetName : " << theFace->GetName()); MESSAGE("IDL : SetEnforcedVertex ( "<< theFaceEntry << ", " << x << ", " << y << ", " << z << ", " << theVertexName << ")"); try { @@ -1098,28 +1125,37 @@ bool BLSURFPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theF // x = y = z = 0.; // measureOp->PointCoordinates(theVertex, x, y, z); - // TODO publish geom objects it not published string theFaceEntry = theFace->GetStudyEntry(); string theVertexEntry = theVertex->GetStudyEntry(); + + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + + if (theFaceEntry == "") { + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } + if (theFaceEntry == "") + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + if (theVertexEntry == "") { - GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); - SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); - string aName; if (theVertex->GetShapeType() == GEOM::VERTEX) aName = "Vertex_"; if (theVertex->GetShapeType() == GEOM::COMPOUND) aName = "Compound_"; aName += theVertex->GetEntry(); - MESSAGE("Publish"); -// geomGen->AddInStudy(smeshGen->GetCurrentStudy(), theVertex, aName.c_str(), NULL); SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); if (!theSVertex->_is_nil()) theVertexEntry = theSVertex->GetID(); - MESSAGE("Done, study entry: " << theVertexEntry); } - -// if ((theFaceEntry == "") || (theVertexEntry == "")) - if (theFaceEntry == "") + if (theVertexEntry == "") THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); string theVertexName = theVertex->GetName(); @@ -1175,6 +1211,20 @@ BLSURFPlugin::TEnfVertexList* BLSURFPlugin_Hypothesis_i::GetEnforcedVertices(GEO } string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry == "") { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } if (theFaceEntry == "") THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); @@ -1197,6 +1247,20 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertex(GEOM::GEOM_Object_ptr theFac } string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry == "") { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } if (theFaceEntry == "") THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); MESSAGE("IDL : GetName : " << theFace->GetName()); @@ -1233,8 +1297,37 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertexGeom(GEOM::GEOM_Object_ptr th std::string theFaceEntry = theFace->GetStudyEntry(); std::string theVertexEntry = theVertex->GetStudyEntry(); - if ((theFaceEntry == "") || (theVertexEntry == "")) + + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + + if (theFaceEntry == "") { + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } + if (theFaceEntry == "") + THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + + if (theVertexEntry == "") { + if (theVertex->GetShapeType() == GEOM::VERTEX) + aName = "Vertex_"; + if (theVertex->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theVertex->GetEntry(); + SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str()); + if (!theSVertex->_is_nil()) + theVertexEntry = theSVertex->GetID(); + } + if (theVertexEntry == "") THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + MESSAGE("IDL : UnsetEnforcedVertexGeom ( "<< theFaceEntry << ", " << theVertexEntry << ")"); try { @@ -1253,8 +1346,23 @@ bool BLSURFPlugin_Hypothesis_i::UnsetEnforcedVertices(GEOM::GEOM_Object_ptr theF } string theFaceEntry = theFace->GetStudyEntry(); + + if (theFaceEntry == "") { + GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine(); + SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen(); + string aName; + if (theFace->GetShapeType() == GEOM::FACE) + aName = "Face_"; + if (theFace->GetShapeType() == GEOM::COMPOUND) + aName = "Compound_"; + aName += theFace->GetEntry(); + SALOMEDS::SObject_ptr theSFace = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theFace, aName.c_str()); + if (!theSFace->_is_nil()) + theFaceEntry = theSFace->GetID(); + } if (theFaceEntry == "") THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM ); + MESSAGE("IDL : GetName : " << theFace->GetName()); MESSAGE("IDL : UnsetEnforcedVertices ( "<< theFaceEntry << ")"); diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index 726f0d8..bb7d0e2 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -289,12 +289,31 @@ QWidget *EnforcedTreeWidgetDelegate::createEditor(QWidget *parent, void EnforcedTreeWidgetDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { + QModelIndex parent = index.parent(); + QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString(); QString value = index.model()->data(index, Qt::EditRole).toString(); - 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); + if (index.column() == ENF_VER_X_COLUMN || + index.column() == ENF_VER_Y_COLUMN || + index.column() == ENF_VER_Z_COLUMN) + { + // If no entry for current index => manual enforced vertex + // Editor is a SMESHGUI_SpinBox + if (entry.isEmpty()) { + SMESHGUI_SpinBox *lineEdit = static_cast(editor); + lineEdit->setText(value); + } else { + // If there is an entry => selected enforced vertexEntry + // Editor is a read-only QLineEdit + QLineEdit *lineEdit = static_cast(editor); + lineEdit->setText(""); + lineEdit->setReadOnly(true); + } + } else if ((entry.isEmpty()) && (index.column() == ENF_VER_NAME_COLUMN)) { + // If there is an entry => selected enforced vertexEntry + // Editor is a read-only QLineEdit + QLineEdit *lineEdit = static_cast(editor); lineEdit->setText(value); + lineEdit->setReadOnly(true); } else { QLineEdit *lineEdit = static_cast(editor); @@ -313,8 +332,7 @@ void EnforcedTreeWidgetDelegate::setModelData(QWidget *editor, QAbstractItemMode if (! vertexExists(model, index, lineEdit->GetString())) { model->setData(index, lineEdit->GetValue(), Qt::EditRole); } - } - else if (index.column() == ENF_VER_NAME_COLUMN) { + } else if (index.column() == ENF_VER_NAME_COLUMN) { QLineEdit *lineEdit = static_cast(editor); QString value = lineEdit->text(); if (! vertexExists(model, index, value)) { @@ -344,7 +362,7 @@ bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model, int row = index.row(); int col = index.column(); - if (parent.isValid()) { + if (parent.isValid() && !value.isEmpty()) { if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) { double x, y, z; if (col == ENF_VER_X_COLUMN) { @@ -375,7 +393,23 @@ bool EnforcedTreeWidgetDelegate::vertexExists(QAbstractItemModel *model, } } } - else if (index.column() == ENF_VER_NAME_COLUMN) { +// else if (col == ENF_VER_ENTRY_COLUMN) { +// // Compare entries if no coords (= selected geom) +// xString = parent.child(row, ENF_VER_X_COLUMN).data(Qt::EditRole).toString(); +// if (xString.isEmpty) { +// int nbChildren = model->rowCount(parent); +// for (int i = 0 ; i < nbChildren ; i++) { +// if (i != row) { +// QString childName = parent.child(i, ENF_VER_ENTRY_COLUMN).data(Qt::EditRole).toString(); +// if (childName == value) { +// exists = true; +// break; +// } +// } +// } +// } +// } + else if (col == ENF_VER_NAME_COLUMN) { int nbChildren = model->rowCount(parent); for (int i = 0 ; i < nbChildren ; i++) { if (i != row) { @@ -875,7 +909,8 @@ is synchronized with the coordinates of the enforced vertex clicked in the tree void BLSURFPluginGUI_HypothesisCreator::update(QTreeWidgetItem* item, int column) { // MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateVertexList"); QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole); - if (! x.isNull()) { + QVariant entry = item->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole); + if (!x.isNull() && !entry.isNull()) { 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); @@ -887,10 +922,13 @@ void BLSURFPluginGUI_HypothesisCreator::update(QTreeWidgetItem* item, int column if (parent) { QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString(); QString toolTip = shapeName + QString(": ") + vertexName.toString(); - toolTip += QString("(") + x.toString(); - toolTip += QString(", ") + y.toString(); - toolTip += QString(", ") + z.toString(); - toolTip += QString(")"); + QString entryName = parent->data(ENF_VER_ENTRY_COLUMN, Qt::EditRole).toString(); + if (entryName.isEmpty()) { + toolTip += QString("(") + x.toString(); + toolTip += QString(", ") + y.toString(); + toolTip += QString(", ") + z.toString(); + toolTip += QString(")"); + } item->setToolTip(ENF_VER_NAME_COLUMN,toolTip); } myXCoord->SetValue(x.toDouble()); diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h index 98ebfaa..0ba44b2 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h @@ -87,22 +87,43 @@ typedef std::set TEntryList; typedef std::vector TEnfVertexCoords; // List of enforced vertices typedef std::set< TEnfVertexCoords > TEnfVertexCoordsList; - // Enforced vertex - typedef struct { - TEnfName name; - TEntry geomEntry; - TEnfVertexCoords coords; - TEnfName grpName; - } TEnfVertex; +// Enforced vertex +typedef struct { + TEnfName name; + TEntry geomEntry; + TEnfVertexCoords coords; + TEnfName grpName; +} TEnfVertex; + +int TEnfVertexCmp(const TEnfVertex *e1, const TEnfVertex *e2) { + if (e1 && e2) { + bool sameCoords = true; + if (e1->coords.size() && e2->coords.size()) + sameCoords = (e1->coords[0] == e2->coords[0]) && (e1->coords[1] == e2->coords[1]) && (e1->coords[2] + == e2->coords[2]); + return ( sameCoords && (e1->geomEntry == e2->geomEntry) && (e1->grpName == e2->grpName) + && (e1->name == e2->name)); + } else + return (e1 < e2); +} + +struct CompareEnfVertices +{ + bool operator () (const TEnfVertex &e1, const TEnfVertex &e2) const + return true; +}; // List of enforced vertices -typedef std::set< TEnfVertex > TEnfVertexList; +typedef std::set< TEnfVertex, CompareEnfVertices > TEnfVertexList; - // Map Coords / Enforced vertex -typedef std::map< TEnfVertexCoords, TEnfVertex > TCoordsEnfVertexMap; +// Map Face Entry / List of enforced vertices +typedef std::map< TEntry, TEnfVertexList > TFaceEntryEnfVertexListMap; -// Map Entry / List of coords -typedef std::map< TEntry, TEnfVertexCoordsList > TEntryCoordsListMap; +// // Map Coords / Enforced vertex +// typedef std::map< TEnfVertexCoords, TEnfVertex > TCoordsEnfVertexMap; +// +// // Map Entry / List of coords +// typedef std::map< TEntry, TEnfVertexCoordsList > TEntryCoordsListMap; typedef struct { @@ -111,12 +132,12 @@ typedef struct double myAngleMeshS, myAngleMeshC, myGradation; double myPhySize, myGeoMin, myGeoMax, myPhyMin,myPhyMax; bool myAllowQuadrangles, myDecimesh,mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex; - TEnfVertexCoordsList coordsList; - TEntryCoordsListMap entryCoordsListMap; - TCoordsEnfVertexMap coordsEnfVertexMap; + TEnfVertexList enfVertexList; + TFaceEntryEnfVertexListMap faceEntryEnfVertexListMap; +// TEntryCoordsListMap entryCoordsListMap; +// TCoordsEnfVertexMap coordsEnfVertexMap; /* TODO GROUPS TGroupNameEnfVertexListMap groupNameEnfVertexListMap; - TEnfVertexGroupNameMap enfVertexGroupNameMap; */ QString myName; } BlsurfHypothesisData; -- 2.39.2