From a91d4cb4300bd7a6358467f84668e9318507536a Mon Sep 17 00:00:00 2001 From: gdd Date: Tue, 19 Apr 2011 13:20:04 +0000 Subject: [PATCH] rnc: - Made possible to define attractors as compounds - Removed some useless parts and comments - Restored lost code due to merge (to allow saving to hdf) --- src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx | 60 +++--- src/BLSURFPlugin/BLSURFPlugin_Attractor.hxx | 6 +- src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 25 ++- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 44 +++- src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 201 ++++-------------- 5 files changed, 120 insertions(+), 216 deletions(-) diff --git a/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx b/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx index 364adb1..457fd43 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx @@ -43,7 +43,6 @@ BLSURFPlugin_Attractor::BLSURFPlugin_Attractor () : _face(), _attractorShape(), _attEntry(), - _step(0), _gridU(0), _gridV(0), _vectU(), @@ -63,11 +62,10 @@ BLSURFPlugin_Attractor::BLSURFPlugin_Attractor () _isMapBuilt(false), _isEmpty(true){ MESSAGE("construction of a void attractor"); } -BLSURFPlugin_Attractor::BLSURFPlugin_Attractor (const TopoDS_Face& Face, const TopoDS_Shape& Attractor, const std::string& attEntry, double Step) // TODO Step is now unused -> remove it if testing is OK +BLSURFPlugin_Attractor::BLSURFPlugin_Attractor (const TopoDS_Face& Face, const TopoDS_Shape& Attractor, const std::string& attEntry) : _face(), _attractorShape(), _attEntry(attEntry), - _step(), _gridU(), _gridV(), _vectU(), @@ -106,10 +104,9 @@ bool BLSURFPlugin_Attractor::init(){ MESSAGE("v1 = "<<_v1<<" ,v2 = "<<_v2); // _gridU = floor (_u2 - _u1) / _step; // _gridV = floor (_v2 - _v1) / _step; - // TEST + _gridU = 300; _gridV = 300; - _step = std::min((_u2-_u1)/_gridU,(_v2-_v1)/_gridV); for (i=0; i<=_gridU; i++){ _vectU.push_back(_u1+i*(_u2-_u1)/_gridU) ; @@ -127,11 +124,21 @@ bool BLSURFPlugin_Attractor::init(){ for (i=0; i<=_gridU; i++){ _known.push_back(temp2); } - + + // Determination of the starting points - if (_attractorShape.ShapeType() == TopAbs_VERTEX){ + TopExp_Explorer anEdgeExp(_attractorShape, TopAbs_EDGE, TopAbs_FACE); + TopExp_Explorer aVertExp(_attractorShape, TopAbs_VERTEX, TopAbs_EDGE); + + for(; anEdgeExp.More(); anEdgeExp.Next()){ + const TopoDS_Edge& anEdge = TopoDS::Edge(anEdgeExp.Current()); + edgeInit(aSurf, anEdge); + } + + for(; aVertExp.More(); aVertExp.Next()){ + const TopoDS_Vertex& aVertex = TopoDS::Vertex(aVertExp.Current()); Trial_Pnt TPnt(3,0); - gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(_attractorShape)); + gp_Pnt P = BRep_Tool::Pnt(aVertex); GeomAPI_ProjectPointOnSurf projector( P, aSurf ); projector.LowerDistanceParameters(u0,v0); MESSAGE("u0 = "<Value(first + i * (last-first) / N); i0 = floor( (P2.X() - _u1) * _gridU / (_u2 - _u1) + 0.5 ); @@ -263,26 +259,26 @@ double BLSURFPlugin_Attractor::_distance(double u, double v){ double BLSURFPlugin_Attractor::GetSize(double u, double v){ double myDist = 0.5 * (_distance(u,v) - _constantRadius + fabs(_distance(u,v) - _constantRadius)); - if (myDist<0){ - MESSAGE("Warning myDist<0 : myDist= "<first << " = " << AtIt->second); GeomShape = entryToShape(AtIt->first); - AttShape = AtIt->second->GetAttractorShape(); + AttShape = AtIt->second->GetAttractorShape(); GeomType = GeomShape.ShapeType(); // Group Management // if (GeomType == TopAbs_COMPOUND){ @@ -902,20 +902,23 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, if (GeomType == TopAbs_FACE && (AttShape.ShapeType() == TopAbs_VERTEX || AttShape.ShapeType() == TopAbs_EDGE - || AttShape.ShapeType() == TopAbs_WIRE)){ - HasSizeMapOnFace = true; - if (! FacesWithSizeMap.Contains(TopoDS::Face(GeomShape)) ) { + || AttShape.ShapeType() == TopAbs_WIRE + || AttShape.ShapeType() == TopAbs_COMPOUND) ){ + HasSizeMapOnFace = true; + + if (! FacesWithSizeMap.Contains(TopoDS::Face(GeomShape)) ) { key = FacesWithSizeMap.Add(TopoDS::Face(GeomShape) ); - } - else { - key = FacesWithSizeMap.FindIndex(TopoDS::Face(GeomShape)); + } + else { + key = FacesWithSizeMap.FindIndex(TopoDS::Face(GeomShape)); // MESSAGE("Face with key " << key << " already in map"); - } - FaceId2ClassAttractor[key] = AtIt->second; + } + + FaceId2ClassAttractor[key] = AtIt->second; } else{ - MESSAGE("Wrong shape type !!") - } + MESSAGE("Wrong shape type !!") + } } } diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index 83ddca1..b2617dc 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -412,8 +412,8 @@ void BLSURFPlugin_Hypothesis::SetClassAttractorEntry(const std::string& entry, c if ( !attExists || (attExists && _classAttractors[entry]->GetAttractorEntry().compare(attEntry) != 0)){ ShapeAnalysis::GetFaceUVBounds(FaceShape,u1,u2,v1,v2); - diag = sqrt((u2 - u1) * (u2 - u1) + (v2 - v1) * (v2 - v1)); - BLSURFPlugin_Attractor* myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry, 0.1 ); // test 0.002 * diag); +// diag = sqrt((u2 - u1) * (u2 - u1) + (v2 - v1) * (v2 - v1)); + BLSURFPlugin_Attractor* myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry);//, 0.1 ); // test 0.002 * diag); myAttractor->BuildMap(); myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius); _classAttractors[entry] = myAttractor; @@ -956,15 +956,15 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) { for (; it_At != _classAttractors.end(); ++it_At) { std::vector attParams; attParams = it_At->second->GetParameters(); - double step = it_At->second->GetStep(); +// double step = it_At->second->GetStep(); save << " " << it_At->first; save << " " << it_At->second->GetAttractorEntry(); save << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3]; - save << " " << step; +// save << " " << step; test << " " << it_At->first; test << " " << it_At->second->GetAttractorEntry(); test << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3]; - test << " " << step; +// test << " " << step; } save << " " << "__NEW_ATTRACTORS_END__"; test << " " << "__NEW_ATTRACTORS_END__"; @@ -1240,6 +1240,40 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) { hasEnforcedVertex = true; } + std::string newAtFaceEntry, atTestString; + std::string newAtShapeEntry; + double attParams[4]; + double step; + while (isOK && hasNewAttractor) { + std::cout<<"Load new attractor"<> newAtFaceEntry); + if (isOK) { + if (newAtFaceEntry == "__NEW_ATTRACTORS_END__") + break; + isOK = (load >> newAtShapeEntry); + if (!isOK) + break; + isOK = (load >> attParams[0]>>attParams[1]>>attParams[2]>>attParams[3]); //>>step); + } + if (isOK) { + MESSAGE(" LOADING ATTRACTOR HYPOTHESIS ") + const TopoDS_Shape attractorShape = BLSURFPlugin_Hypothesis::entryToShape(newAtShapeEntry); + const TopoDS_Face faceShape = TopoDS::Face(BLSURFPlugin_Hypothesis::entryToShape(newAtFaceEntry)); + BLSURFPlugin_Attractor* attractor = new BLSURFPlugin_Attractor(faceShape, attractorShape, newAtShapeEntry);//, step); + attractor->SetParameters(attParams[0], attParams[1], attParams[2], attParams[3]); + attractor->BuildMap(); + _classAttractors[newAtFaceEntry]=attractor; + } + } + + + if (hasNewAttractor) { + isOK = (load >> option_or_sm); + if (isOK) + if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__") + hasEnforcedVertex = true; + } + // // Here is a example of the saved stream: diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index 74c1714..6c0f605 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -820,6 +820,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() ATT_ShapeTypes.Add( TopAbs_VERTEX ); ATT_ShapeTypes.Add( TopAbs_EDGE ); ATT_ShapeTypes.Add( TopAbs_WIRE ); + ATT_ShapeTypes.Add( TopAbs_COMPOUND ); SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes); SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes); @@ -1499,15 +1500,15 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const if ( name_value.count() > 1 ) { QString idStr = QString("%1").arg( i ); int row = myOptionTable->rowCount(); - myOptionTable->setRowCount( row+1 ); - myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) ); - myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 ); - myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) ); - myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 ); - myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) ); - myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable | - Qt::ItemIsEditable | - Qt::ItemIsEnabled ); + myOptionTable->setRowCount( row+1 ); + myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) ); + myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 ); + myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) ); + myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 ); + myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) ); + myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable | + Qt::ItemIsEditable | + Qt::ItemIsEnabled ); } } } @@ -1520,10 +1521,9 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const while (i.hasNext()) { i.next(); const QString entry = i.key(); - string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString()); const QString sizeMap = i.value(); + string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString()); int row = mySizeMapTable->topLevelItemCount(); -// mySizeMapTable->setRowCount( row+1 ); QTreeWidgetItem* item = new QTreeWidgetItem(); mySizeMapTable->addTopLevelItem( item ); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled ); @@ -1539,35 +1539,17 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const child->setData(SMP_ENTRY_COLUMN, Qt::DisplayRole, QVariant( attEntry ) ); child->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString( attName ) ) ); - if (that->myAttDistMap[entry] > 1e-12){ - item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Attractor" ) ) ); - /*mySizeMapTable->setItem( row, SMP_DIST_COLUMN, new QTableWidgetItem( QString::number( that->myDistMap[entry], 'g', 6) ) ); - mySizeMapTable->item( row, SMP_DIST_COLUMN )->setFlags( Qt::ItemIsSelectable | - Qt::ItemIsEnabled );*/ + if (that->myAttDistMap[entry] > std::numeric_limits::epsilon()){ + item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Attractor" ) ) ); } else{ - item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Constant Size" ) ) ); -// mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( QString::fromStdString("Constant size") ); -// mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable | -// Qt::ItemIsEnabled ); -// mySizeMapTable->item( row, SMP_NAME_COLUMN)->setText(QString::fromStdString(shapeName)); -// mySizeMapTable->setItem( row, SMP_DIST_COLUMN, new QTableWidgetItem( QString::number( that->myDistMap[entry], 'g', 6) )); -// mySizeMapTable->item( row, SMP_DIST_COLUMN )->setFlags( Qt::ItemIsSelectable | -// Qt::ItemIsEnabled ); + item->setData(SMP_SIZEMAP_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString("Constant Size" ) ) ); } } else { item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) ); -// mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( sizeMap ) ); -// mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable | -// Qt::ItemIsEditable | -// Qt::ItemIsEnabled ); - /* mySizeMapTable->setItem( row, SMP_DIST_COLUMN, new QTableWidgetItem( QString::number( that->myDistMap[entry], 'g', 6) ) ); - mySizeMapTable->item( row, SMP_DIST_COLUMN )->setFlags( Qt::ItemIsSelectable | - Qt::ItemIsEnabled ); */ - } - + } } mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN ); mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN ); @@ -2301,27 +2283,27 @@ void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, CORBA::Object_var attObj = entryToObject(attEntry); myAttSizeSpin->setValue(phySize); if (sizeMap.startsWith("Attractor")){ - myAttDistSpin->setValue(infDist); + myAttDistSpin->setValue(infDist); myAttractorCheck->setChecked(true); } else { - myAttractorCheck->setChecked(false); + myAttractorCheck->setChecked(false); } - if (sizeMap.startsWith("Constant") || constDist > 1e-12 ){ - myAttDistSpin2->setValue(constDist); - myConstSizeCheck->setChecked(true); + if (sizeMap.startsWith("Constant") || constDist > std::numeric_limits::epsilon()){ + myAttDistSpin2->setValue(constDist); + myConstSizeCheck->setChecked(true); } else{ - myConstSizeCheck->setChecked(false); + myConstSizeCheck->setChecked(false); } myGeomSelWdg2->SetObject(obj); myAttSelWdg->SetObject(attObj); } else { // CLASSIC MAPS smpTab->setCurrentIndex(SMP_STD_TAB); // Change Tab - myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets + myGeomSelWdg1->SetObject(obj); // Retrieve values of the selected item in the current tab widgets if (!sizeMap.startsWith("def")){ - mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble()); + mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble()); } } } @@ -2346,40 +2328,28 @@ void BLSURFPluginGUI_HypothesisCreator::onSmpTabChanged(int tab) void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state) { if (state == Qt::Checked){ -// myParamsGroup->setEnabled(true); myAttSelWdg->setEnabled(true); myAttSizeSpin->setEnabled(true); myAttSizeLabel->setEnabled(true); myAttDistSpin->setEnabled(true); myAttDistLabel->setEnabled(true); -// myAttDistSpin2->setEnabled(true); -// myAttDistLabel2->setEnabled(true); if (!myAttSelWdg->IsObjectSelected()){ myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }"); } -// if(myConstSizeCheck->checkState() == Qt::Checked){ // Only attractor -// myAttDistSpin2->setEnabled(true); -// myAttDistLabel2->setEnabled(true); -// // myAttDistSpin2->setValue(0.); -// } } if (state == Qt::Unchecked){ myAttDistSpin->setEnabled(false); myAttDistLabel->setEnabled(false); myAttDistSpin->setValue(0.); if(myConstSizeCheck->checkState() == Qt::Unchecked){ // No predefined map selected - myAttSelWdg->setEnabled(false); - myAttSizeSpin->setEnabled(false); - myAttSizeLabel->setEnabled(false); - myAttDistSpin2->setEnabled(false); - myAttDistLabel2->setEnabled(false); -// myParamsGroup->setEnabled(false); + myAttSelWdg->setEnabled(false); + myAttSizeSpin->setEnabled(false); + myAttSizeLabel->setEnabled(false); + myAttDistSpin2->setEnabled(false); + myAttDistLabel2->setEnabled(false); } else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected -// myAttDistSpin->setEnabled(false); -// myAttDistLabel->setEnabled(false); -// myAttDistSpin->setValue(0.); - myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }"); + myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }"); } } } @@ -2392,13 +2362,6 @@ void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state) myAttSizeLabel->setEnabled(true); myAttDistSpin2->setEnabled(true); myAttDistLabel2->setEnabled(true); -// myAttDistSpin2->setEnabled(true); -// myAttDistLabel2->setEnabled(true); -// if(myConstSizeCheck->checkState() == Qt::Checked){ // Only attractor -// myAttDistSpin2->setEnabled(true); -// myAttDistLabel2->setEnabled(true); -// // myAttDistSpin2->setValue(0.); -// } if (myAttractorCheck->checkState() == Qt::Unchecked && !myAttSelWdg->IsObjectSelected()){ myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }"); @@ -2414,41 +2377,11 @@ void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state) myAttSizeLabel->setEnabled(false); myAttDistSpin->setEnabled(false); myAttDistLabel->setEnabled(false); -// myParamsGroup->setEnabled(false); } else if (!myAttSelWdg->IsObjectSelected()){ // Only constant size selected -// myAttDistSpin->setEnabled(false); -// myAttDistLabel->setEnabled(false); -// myAttDistSpin->setValue(0.); myAttSelWdg->SetDefaultText(tr("BLS_SEL_ATTRACTOR"), "QLineEdit { color: grey }"); } - } - -// if (state == Qt::Checked){ -// myParamsGroup->setEnabled(true); -// myAttDistSpin->setEnabled(true); -// myAttDistLabel->setEnabled(true); -// myAttDistSpin2->setEnabled(true); -// myAttDistLabel2->setEnabled(true); -// if(myAttractorCheck->checkState() == Qt::Unchecked){ // Only constant size -// myAttDistSpin->setEnabled(false); -// myAttDistLabel->setEnabled(false); -// myAttDistSpin->setValue(0.); -// if (!myAttSelWdg->IsObjectSelected()){ -// myAttSelWdg->SetDefaultText(tr("BLS_SEL_SHAPE"), "QLineEdit { color: grey }"); -// } -// } -// } -// if (state == Qt::Unchecked){ -// if(myAttractorCheck->checkState() == Qt::Unchecked){ // No predefined map selected -// myParamsGroup->setEnabled(false); -// } -// else{ -// myAttDistSpin2->setEnabled(false); // Only attractor selected -// myAttDistLabel2->setEnabled(false); -// myAttDistSpin2->setValue(0.); -// } -// } + } } void BLSURFPluginGUI_HypothesisCreator::onRemoveMap() @@ -2457,11 +2390,6 @@ void BLSURFPluginGUI_HypothesisCreator::onRemoveMap() QList selectedRows; QList selected = mySizeMapTable->selectedItems(); QTreeWidgetItem* item; -// foreach( item, selected ) { -// if ( !selected.contains( item ) ) -// selected.append( row ); -// } - BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; qSort( selectedRows ); @@ -2499,29 +2427,18 @@ void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int return; if (that->mySMPMap.contains(entry)) if (that->mySMPMap[entry] == sizeMap - || sizeMap.startsWith("Attractor") - || sizeMap.startsWith("Constant") ){ + || sizeMap.startsWith("Attractor") + || sizeMap.startsWith("Constant") ){ return; - } -// QColor* bgColor = new QColor("white"); -// QColor* fgColor = new QColor("black"); - + } if (! sizeMap.isEmpty()) { that->mySMPMap[entry] = sizeMap; sizeMapValidationFromEntry(entry); -// if (! sizeMapValidationFromRow(row)) { -// bgColor->setRgb(255,0,0); -// fgColor->setRgb(255,255,255); -// } } else { MESSAGE("Size map empty: reverse to precedent value" ); item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) ); } -// that->mySizeMapTable->item(row, SMP_NAME_COLUMN)->setBackground(QBrush(*bgColor)); -// that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->setBackground(QBrush(*bgColor)); -// that->mySizeMapTable->item(row, SMP_NAME_COLUMN)->setForeground(QBrush(*fgColor)); -// that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->setForeground(QBrush(*fgColor)); mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN); } } @@ -2553,8 +2470,6 @@ void BLSURFPluginGUI_HypothesisCreator::onAddMap() myGeomSelWdg1->SetObject(CORBA::Object::_nil()); myGeomSelWdg2->SetObject(CORBA::Object::_nil()); myAttSelWdg->SetObject(CORBA::Object::_nil()); -// mySmpDistSpin->setValue(0.); -// mySmpSizeSpin->setValue(0.); } void BLSURFPluginGUI_HypothesisCreator::onModifyMap() @@ -2609,8 +2524,6 @@ void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anOb oss << phySize; QString sizeMap; sizeMap = QString::fromStdString(oss.str()); - // int row = mySizeMapTable->rowCount(); - // mySizeMapTable->setRowCount( row + 1 ); QTreeWidgetItem* item = new QTreeWidgetItem(); if (modify){ int rowToChange = findRowFromEntry(shapeEntry); @@ -2636,7 +2549,6 @@ void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anOb mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN ); mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN ); mySizeMapTable->clearSelection(); -// mySizeMapTable->scrollToItem( mySizeMapTable->item( row , SMP_SIZEMAP_COLUMN ) ); //TODO voir si cette option est utile if ( myPhysicalMesh->currentIndex() != SizeMap ) { myPhysicalMesh->setCurrentIndex( SizeMap ); @@ -2683,8 +2595,6 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF QString infDistString = QString::fromStdString(oss2.str()); QString constDistString = QString::fromStdString(oss3.str()); -// int row = mySizeMapTable->topLevelItemCount(); -// int rowToChange; QTreeWidgetItem* item; QTreeWidgetItem* child; if (modify){ @@ -2696,7 +2606,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF if (that->mySMPMap.contains(shapeEntry)) { if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") { // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")"); - return; + return; } } item = new QTreeWidgetItem(); @@ -2712,10 +2622,10 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF item->setExpanded(true); item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) ); item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(faceName)) ); - if (infDist > 1e-12){ + if (infDist > std::numeric_limits::epsilon()){ item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) ); } - else if (constDist > 1e-12){ + else if (constDist > std::numeric_limits::epsilon()){ item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) ); } item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled ); @@ -2727,8 +2637,6 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN ); mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN ); mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN ); -// mySizeMapTable->clearSelection(); -// mySizeMapTable->scrollToItem( mySizeMapTable->item( row , SMP_SIZEMAP_COLUMN ) );//TODO voir si l'option est utile if ( myPhysicalMesh->currentIndex() != SizeMap ) { myPhysicalMesh->setCurrentIndex( SizeMap ); @@ -2851,43 +2759,6 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEnt return true; } -/* -void BLSURFPluginGUI_HypothesisCreator::OnEditMapFunction(QModelIndex* index) { - int myRow = index->row(); - int myColumn = index->column(); - - if (myColumn == 2){ - if (!myEditor) { - myEditor = new BLSURFPluginGUI_MapFunctionEditor(sizeMapModel->item(myRow,0)->text()); - connect(myEditor, SIGNAL(FunctionEntered(QString)), this, SLOT(FunctionLightValidation(QString))); - } - myEditor->exec(); -// myEditor->show(); -// myEditor->raise(); -// myEditor->activateWindow(); - - -// BLSURFPluginGUI_MapFunctionEditor* myEditor = new BLSURFPluginGUI_MapFunctionEditor(sizeMapModel->item(myRow,0)->text()); -// myEditor->exec(); - QString myFunction = myEditor->GetFunctionText(); - // FIN RECUPERATION FONCTION - - if (! myFunction.isEmpty()) { - - // MAJ DE LA MAP - - BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = - BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis()); - -// h->SetSizeMapEntry(sizeMapModel->item(myRow,1)->text().toLatin1().constData(), -// item->text().toLatin1().constData()); - h->SetSizeMapEntry(sizeMapModel->item(myRow,1)->text().toLatin1().constData(), - myFunction.toLatin1().constData()); - // FIN MAJ DE LA MAP - } - } -}*/ - QString BLSURFPluginGUI_HypothesisCreator::caption() const { return tr( "BLSURF_TITLE" ); -- 2.39.2