From f64007cd8d6856f7f539ef6e00a187af8f495890 Mon Sep 17 00:00:00 2001 From: gdd Date: Wed, 16 Mar 2011 09:00:22 +0000 Subject: [PATCH] rnc: Modified and improved IHM --- src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx | 17 +- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 2 +- src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 338 +++++++++++++----- src/GUI/BLSURFPluginGUI_HypothesisCreator.h | 20 +- src/GUI/BLSURFPlugin_msg_en.ts | 14 +- 5 files changed, 284 insertions(+), 107 deletions(-) diff --git a/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx b/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx index 891108c..7edd1ec 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx @@ -207,12 +207,17 @@ double BLSURFPlugin_Attractor::GetSize(double u, double v){ switch(_type) { case TYPE_EXP: -// if (fabs(_actionRadius) < eps){ // TODO definir eps et decommenter -// return _endSize; -// } -// else{ - return _endSize - (_endSize - _startSize) * exp(- myDist * myDist / (_actionRadius * _actionRadius) ); -// } + if (fabs(_actionRadius) < 1e-12){ // TODO definir eps et decommenter + if (myDist < 1e-12){ + return _startSize; + } + else { + return _endSize; + } + } + else{ + return _endSize - (_endSize - _startSize) * exp(- myDist * myDist / (_actionRadius * _actionRadius) ); + } break; case TYPE_LIN: return _startSize + ( 0.5 * (_distance(u,v) - _constantRadius + abs(_distance(u,v) - _constantRadius)) ) ; diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index db43e85..4fdfd31 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -479,7 +479,7 @@ 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.003 * diag); + BLSURFPlugin_Attractor* myAttractor = new BLSURFPlugin_Attractor(FaceShape, AttractorShape, attEntry, 0.002 * diag); myAttractor->BuildMap(); myAttractor->SetParameters(StartSize, EndSize, ActionRadius, ConstantRadius); _classAttractors[entry] = myAttractor; diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index 1c20f6a..f045ca6 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -124,31 +125,38 @@ enum { }; enum { - SMP_BTNS = 0, +// SMP_BTNS = 0, // SMP_ATTRACTOR_BTN, // SMP_SEPARATOR1, // SMP_POINT_BTN, // SMP_EDGE_BTN, // SMP_SURFACE_BTN, SMP_GEOM_BTN, - SMP_SEPARATOR2, - SMP_ATT_GROUP, - SMP_DIST_GROUP, +// SMP_SEPARATOR2, +// SMP_SEPARATOR, + SMP_TAB_WDG, +// SMP_ATT_GROUP, SMP_ADD_BTN, - SMP_REMOVE_BTN, - SMP_NB_LINES +// SMP_REMOVE_BTN, + SMP_NB_LINES, + SMP_STD_TAB = 0, + ATT_TAB }; enum { - SMP_ATT_BTNS = 0, SMP_ATT_SHAPE, SMP_ATT_SIZE, SMP_ATT_DIST }; enum { - SMP_DIST_BTNS = 0, - SMP_DIST + SMP_SIZE, + SMP_SPACE, + SMP_DIST_GROUP, +// SMP_CHECK, + SMP_SPACE2, + SMP_DIST=0, + SMP_DIST_SHAPE, }; // Enforced vertices inputs @@ -754,11 +762,19 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() // Size Maps parameters mySmpGroup = new QWidget(); - mySmpGroup->setMinimumWidth(450); -// mySmpGroup->setMinimumHeight(300); + mySmpGroup->setMinimumWidth(500); + //mySmpGroup->setMinimumHeight(350); + //Layout QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup); - //anSmpLayout->setColumnStretch(0,1); + // Table mySizeMapTable = new QTableWidget( 0, SMP_NB_COLUMNS, mySmpGroup ); + // tab widget + smpTab = new QTabWidget( mySmpGroup ); + smpTab->setTabShape( QTabWidget::Rounded ); + smpTab->setTabPosition( QTabWidget::South ); + lay->addWidget( smpTab ); + + // Table settings //mySizeMapTable->setSortingEnabled(true); QStringList sizeMapHeaders; sizeMapHeaders << tr( "SMP_ENTRY_COLUMN" )<< tr( "SMP_NAME_COLUMN" ) << tr( "SMP_SIZEMAP_COLUMN" ) << tr( "SMP_DIST_COLUMN" ); @@ -786,64 +802,114 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() SMESH_NumberFilter* myFilter1 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, SM_ShapeTypes); SMESH_NumberFilter* myFilter2 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, ATT_ShapeTypes); + SMESH_NumberFilter* myFilter3 = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 0, TopAbs_FACE); // Size Map GroupBox myGeomSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false,/*stretch=*/false); myGeomSelWdg->SetDefaultText("Select a Shape", "QLineEdit { color: grey }"); - QFrame *line2 = new QFrame(mySmpGroup); - line2->setFrameShape(QFrame::HLine); - line2->setFrameShadow(QFrame::Sunken); +// QFrame *line2 = new QFrame(mySmpGroup); +// line2->setFrameShape(QFrame::HLine); +// line2->setFrameShadow(QFrame::Sunken); removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup); addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup); // Attractor GroupBox - myAttractorGroup = new QGroupBox(tr("BLSURF_SM_ATTRACTOR"),mySmpGroup); - myAttractorGroup->setCheckable(true); - myAttractorGroup->setChecked(false); - myAttractorGroup->setEnabled(false); + //myAttractorGroup = new QGroupBox(tr("BLSURF_SM_ATTRACTOR"),mySmpGroup); + myAttractorGroup = new QWidget(); +// myAttractorGroup->setMinimumWidth(220); +// myAttractorGroup->setCheckable(true); +// myAttractorGroup->setChecked(false); +// myAttractorGroup->setEnabled(false); QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup); myAttDistSpin = new QDoubleSpinBox(myAttractorGroup); myAttSizeSpin = new QDoubleSpinBox(myAttractorGroup); - QLabel* myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup); - QLabel* myAttSizeLabel = new QLabel(tr("BLSURF_ATT_SIZE"),myAttractorGroup); + myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup); + myAttSizeLabel = new QLabel(tr("BLSURF_ATT_SIZE"),myAttractorGroup); myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myAttractorGroup, /*multiSel=*/false,/*stretch=*/false); myAttSelWdg->SetDefaultText("Select a Shape", "QLineEdit { color: grey }"); myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg); - myAttDistSpin->setValue(0.); - myAttSizeSpin->setValue(0.); + // Initialization of widgets +// myAttDistSpin->hide(); +// myAttSizeSpin->hide(); +// myAttDistLabel->hide(); +// myAttSizeLabel->hide(); +// myAttSelWdg->hide(); + + // Standard size map tab + mySmpStdGroup = new QWidget(); + QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup); + // Constant Size GroupBox - myDistanceGroup = new QGroupBox(tr("BLSURF_SM_CONST"),mySmpGroup); + mySmpSizeSpin = new QDoubleSpinBox(mySmpStdGroup); + QLabel* mySmpSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),mySmpStdGroup); +// myConstSizeCheck = new QCheckBox(tr("BLSURF_SM_CONST"),mySmpStdGroup); + myDistanceGroup = new QGroupBox(tr("BLSURF_SM_CONST"),mySmpStdGroup); + myDistanceGroup->setFlat(true); myDistanceGroup->setCheckable(true); myDistanceGroup->setChecked(false); myDistanceGroup->setEnabled(false); - QGridLayout* aDistLayout = new QGridLayout(myDistanceGroup); + + QGridLayout* aDistLayout = new QGridLayout(myDistanceGroup ); mySmpDistSpin = new QDoubleSpinBox(myDistanceGroup); QLabel* mySmpDistLabel = new QLabel(tr("BLSURF_SM_DIST"),myDistanceGroup); - + myDistSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, myDistanceGroup, /*multiSel=*/true,/*stretch=*/false); + myDistSelWdg->SetDefaultText("On Face(s)", "QLineEdit { color: grey }"); + myDistSelWdg->AvoidSimultaneousSelection(myGeomSelWdg); + myDistSelWdg->AvoidSimultaneousSelection(myAttSelWdg); + + // Parameters of SpinBoxes + myAttDistSpin->setMaximum(1000); // TODO use preferences of SALOME + mySmpDistSpin->setMaximum(1000); + myAttSizeSpin->setMaximum(1000); + mySmpSizeSpin->setMaximum(1000); + myAttDistSpin->setDecimals(4); + mySmpDistSpin->setDecimals(4); + myAttSizeSpin->setDecimals(4); + mySmpSizeSpin->setDecimals(4); + myAttDistSpin->setValue(0.); + myAttSizeSpin->setValue(0.); + mySmpDistSpin->setValue(0.); + mySmpSizeSpin->setValue(0.); // ADD WIDGETS (SIZEMAP TAB) // anSmpLayout->addWidget(mySizeMapTable, SMP_POINT_BTN, 0, SMP_NB_LINES+1, 1); - anSmpLayout->addWidget(mySizeMapTable, 1, 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(mySizeMapTable, 0, 0, SMP_NB_LINES, 1); anSmpLayout->addWidget(myGeomSelWdg, SMP_GEOM_BTN, 1, 1, 2); - anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 1, 2); - anSmpLayout->addWidget(myAttractorGroup, SMP_ATT_GROUP, 1, 1, 2); - anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1); - anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1); - anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1); - anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1); +// anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2); + anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 2); +// anSmpLayout->addWidget(myAttractorGroup, SMP_ATT_GROUP, 1, 1, 2); +// anSmpLayout->addWidget(myDistanceGroup, SMP_DIST_GROUP, 1, 1, 2); + anSmpLayout->setRowStretch(SMP_TAB_WDG, 1); + anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1); + anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1); + anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2); - anSmpLayout->addWidget(myDistanceGroup, SMP_DIST_GROUP, 1, 1, 2); - aDistLayout->addWidget(mySmpDistLabel, SMP_DIST, 1, 1, 1); - aDistLayout->addWidget(mySmpDistSpin, SMP_DIST, 2, 1, 1); - anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 2); - anSmpLayout->addWidget(removeMapButton, SMP_REMOVE_BTN, 1, 1, 2); + anAttLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1); + anAttLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1); + anAttLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1); + anAttLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1); + anAttLayout->setRowStretch(SMP_ATT_DIST+1, 1); + + anSmpStdLayout->addWidget(mySmpSizeLabel, SMP_SIZE, 1, 1, 1); + anSmpStdLayout->addWidget(mySmpSizeSpin, SMP_SIZE, 2, 1, 1); +// anSmpStdLayout->addWidget(myDistanceGroup, SMP_DIST_GROUP, 1, 1, 2); +// anSmpStdLayout->setRowStretch(SMP_DIST_GROUP+1, 1); +// +// anSmpStdLayout->addWidget(myConstSizeCheck,SMP_CHECK, 1, 1, 2); + anSmpStdLayout->addWidget(myDistanceGroup, SMP_DIST_GROUP, 1, 1, 2); + aDistLayout->addWidget(mySmpDistLabel, SMP_DIST, 1, 1, 1); + aDistLayout->addWidget(mySmpDistSpin, SMP_DIST, 2, 1, 1); + aDistLayout->addWidget(myDistSelWdg, SMP_DIST_SHAPE, 1, 1, 2); +// aDistLayout->setRowMinimumHeight(SMP_CHECK, 15); + anSmpStdLayout->setRowMinimumHeight(SMP_SPACE, 12); + anSmpStdLayout->setRowStretch(SMP_SPACE2, 1); + + smpTab->insertTab( SMP_STD_TAB, mySmpStdGroup, tr( "BLSURF_SM_STD_TAB" ) ); + smpTab->insertTab( ATT_TAB, myAttractorGroup, tr( "BLSURF_SM_ATT_TAB" ) ); + + smpTab->setCurrentIndex( SMP_STD_TAB ); @@ -1416,9 +1482,23 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const MESSAGE("attEntry = "<getNameFromEntry(attEntry.toStdString()); MESSAGE("attName = "<setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( QString::fromStdString("Attractor :" + attName) ) ); - mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable | + if (that->myAttDistMap[entry] > 1e-12){ + mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( QString::fromStdString("Attractor :" + attName) ) ); + mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable | + 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 ); + } + else{ + mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( QString::fromStdString("Const. size from : " + attName + " (size = ") + sizeMap + QString::fromStdString(" )") ) ); + 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 ); + } } else { @@ -1426,10 +1506,11 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const 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->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_NAME_COLUMN ); @@ -2220,31 +2301,54 @@ void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified() mySMapObject = myGeomSelWdg->GetObject< GEOM::GEOM_Object >(0); TopAbs_ShapeEnum myShapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( mySMapObject ).ShapeType(); if ( myShapeType == TopAbs_FACE ){ - myAttractorGroup->setEnabled(true); - if (!myAttractorGroup->isChecked()){ - myDistanceGroup->setEnabled(false); - myDistanceGroup->setChecked(false); - } + smpTab->setTabEnabled(ATT_TAB,true); +// if (!myAttractorGroup->isChecked()){ + myDistanceGroup->setEnabled(false); +// myDistanceGroup->setChecked(false); +// } } else { - myAttractorGroup->setEnabled(false); - myAttractorGroup->setChecked(false); + smpTab->setTabEnabled(ATT_TAB,false); +// myAttractorGroup->setEnabled(false); +// myAttractorGroup->setChecked(false); myDistanceGroup->setEnabled(true); } } } -void BLSURFPluginGUI_HypothesisCreator::onAttractorGroupClicked(bool checked){ - if (checked){ - myDistanceGroup->setEnabled(true); - } - else{ - myDistanceGroup->setEnabled(false); - myDistanceGroup->setChecked(false); - } -} +// void BLSURFPluginGUI_HypothesisCreator::onAttractorGroupClicked(bool checked){ +// // QObjectList grpChildren = myAttractorGroup->children(); +// // QObjectList::iterator it; +// // QObject* myChild; +// if (checked){ +// myDistanceGroup->setEnabled(true); +// myAttDistSpin->show(); // TODO voir si on garde ça +// myAttSizeSpin->show(); +// myAttDistLabel->show(); +// myAttSizeLabel->show(); +// myAttSelWdg->show(); +// // for(it = grpChildren.begin(); it != grpChildren.end(); it++){ +// // myChild=*it; +// // myChild->hide(); +// // } +// } +// else{ +// myDistanceGroup->setEnabled(false); +// myDistanceGroup->setChecked(false); +// myAttDistSpin->hide(); +// myAttSizeSpin->hide(); +// myAttDistLabel->hide(); +// myAttSizeLabel->hide(); +// myAttSelWdg->hide(); +// +// // for(it = grpChildren.begin(); it != grpChildren.end(); it++){ +// // myChild=*it; +// // myChild->show(); +// // } +// } +// } void BLSURFPluginGUI_HypothesisCreator::onItemClicked(QTableWidgetItem * item) { @@ -2257,26 +2361,43 @@ void BLSURFPluginGUI_HypothesisCreator::onItemClicked(QTableWidgetItem * item) QString sizeMap = that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->text().trimmed(); if (sizeMap.startsWith("Attractor :")){ - myAttractorGroup->setChecked( true ); - myDistanceGroup->setChecked( true ); - myDistanceGroup->setEnabled( true ); +// myAttractorGroup->setChecked( true ); +// myDistanceGroup->setChecked( true ); +// myDistanceGroup->setEnabled( true ); + smpTab->setCurrentIndex(ATT_TAB); double phySize = that->mySMPMap[entry].toDouble(); double infDist = that->myAttDistMap[entry]; QString attEntry = that->myATTMap[entry]; CORBA::Object_var attObj = entryToObject(attEntry); + CORBA::Object_var obj = entryToObject(entry); + myGeomSelWdg->SetObject(obj); myAttSelWdg->SetObject(attObj); myAttSizeSpin->setValue(phySize); myAttDistSpin->setValue(infDist); } - else { - myAttractorGroup->setChecked( false ); + else if (sizeMap.startsWith("Const.")){ + smpTab->setCurrentIndex(SMP_STD_TAB); + myDistanceGroup->setChecked( true ); + myDistanceGroup->setEnabled( true ); + double constDist = that->myDistMap[entry]; + QString attEntry = that->myATTMap[entry]; + mySmpDistSpin->setValue(constDist); + mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble()); + CORBA::Object_var attObj = entryToObject(attEntry); + CORBA::Object_var obj = entryToObject(entry); + myGeomSelWdg->SetObject(attObj); + myDistSelWdg->SetObject(obj); } - CORBA::Object_var obj = entryToObject(entry); - double constDist = that->myDistMap[entry]; - - myGeomSelWdg->SetObject(obj); - mySmpDistSpin->setValue(constDist); + else { + smpTab->setCurrentIndex(SMP_STD_TAB); + CORBA::Object_var obj = entryToObject(entry); + myGeomSelWdg->SetObject(obj); + if (!sizeMap.startsWith("def")){ + mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble()); +// myAttractorGroup->setChecked( false ); + } + } } } @@ -2331,7 +2452,9 @@ void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(int row,int col) if (! that->mySMPShapeTypeMap.contains(entry)) return; if (that->mySMPMap.contains(entry)) - if (that->mySMPMap[entry] == sizeMap || sizeMap.startsWith("Attractor :")){ + if (that->mySMPMap[entry] == sizeMap + || sizeMap.startsWith("Attractor :") + || sizeMap.startsWith("Const.") ){ return; } // QColor* bgColor = new QColor("white"); @@ -2363,14 +2486,26 @@ void BLSURFPluginGUI_HypothesisCreator::onAddMap() { if ( myGeomSelWdg->IsObjectSelected() ){ mySMapObject = myGeomSelWdg->GetObject< GEOM::GEOM_Object >(0); - if ( myAttractorGroup->isChecked() ){ +// if ( myAttractorGroup->isChecked() ){ + if ( smpTab->currentIndex() == ATT_TAB ){ if ( myAttSelWdg->IsObjectSelected() ){ myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0); insertAttractor(mySMapObject, myAttObject); } } - else { - insertElement(mySMapObject); +// if ( myDistanceGroup->isChecked() && !myAttractorGroup->isChecked()) + if (smpTab->currentIndex() == SMP_STD_TAB ){ + if ( myDistSelWdg->IsObjectSelected() ){ + int Nb_obj = myDistSelWdg->NbObjects(); + int i = 0; + for (; i!=Nb_obj; i++){ + myDistObject = myDistSelWdg->GetObject< GEOM::GEOM_Object >(i); + insertAttractor(myDistObject, mySMapObject, false); + } + } + else { + insertElement(mySMapObject); + } } BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; that->getGeomSelectionTool()->selectionMgr()->clearFilters(); @@ -2397,17 +2532,17 @@ void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anOb mySizeMapTable->setFocus(); QString shapeEntry; shapeEntry = QString::fromStdString(entry); - double phySize = h->GetPhySize(); + double phySize = mySmpSizeSpin->value(); std::ostringstream oss; oss << phySize; QString sizeMap; sizeMap = QString::fromStdString(oss.str()); - if (that->mySMPMap.contains(shapeEntry)) { - if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") { -// MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")"); - return; - } - } +// if (that->mySMPMap.contains(shapeEntry)) { +// if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") { +// // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")"); +// return; +// } +// } that->mySMPMap[shapeEntry] = sizeMap; that->myDistMap[shapeEntry] = 0. ; that->mySMPShapeTypeMap[shapeEntry] = shapeType; @@ -2433,7 +2568,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anOb } } -void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor) +void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool influence) { MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertAttractor()"); BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = @@ -2452,9 +2587,15 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF QString shapeEntry = QString::fromStdString(entry); QString qAttEntry = QString::fromStdString(attEntry); - //double phySize = h->GetPhySize(); - double phySize = myAttSizeSpin->value(); - double infDist = myAttDistSpin->value(); + double phySize = h->GetPhySize(); + double infDist = 0. ; + if (influence){ + infDist = myAttDistSpin->value(); + phySize = myAttSizeSpin->value(); + } + else{ + phySize = mySmpSizeSpin->value(); + } double constDist = 0. ; if (myDistanceGroup->isChecked()){ constDist = mySmpDistSpin->value(); @@ -2494,13 +2635,20 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF that->mySMPMap.insert(shapeEntry,sizeMap); that->myATTMap.insert(shapeEntry,qAttEntry); that->myAttDistMap.insert(shapeEntry,infDist); - that->myDistMap.insert(shapeEntry,constDist); that->mySMPShapeTypeMap.insert(shapeEntry,shapeType); - mySizeMapTable->item( rowToChange, SMP_ENTRY_COLUMN )->setText(shapeEntry); - mySizeMapTable->item( rowToChange, SMP_NAME_COLUMN )->setText( QString::fromStdString(faceName)); - mySizeMapTable->item( rowToChange, SMP_SIZEMAP_COLUMN )->setText(QString::fromStdString("Attractor : "+attName)); - mySizeMapTable->item( rowToChange, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled ); - mySizeMapTable->item( rowToChange, SMP_DIST_COLUMN )->setText(constDistString ); + if (influence){ + mySizeMapTable->item( rowToChange, SMP_ENTRY_COLUMN )->setText(shapeEntry); + mySizeMapTable->item( rowToChange, SMP_NAME_COLUMN )->setText( QString::fromStdString(faceName)); + mySizeMapTable->item( rowToChange, SMP_SIZEMAP_COLUMN )->setText(QString::fromStdString("Attractor : "+attName)); + } + else { + that->myDistMap.insert(shapeEntry,constDist); + mySizeMapTable->item( rowToChange, SMP_ENTRY_COLUMN )->setText(shapeEntry); + mySizeMapTable->item( rowToChange, SMP_NAME_COLUMN )->setText( QString::fromStdString(faceName)); + mySizeMapTable->item( rowToChange, SMP_SIZEMAP_COLUMN )->setText(QString::fromStdString("Const. size from : " + attName + " (size = ") + sizeMap + QString::fromStdString(" )")); + mySizeMapTable->item( rowToChange, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled ); + mySizeMapTable->item( row, SMP_DIST_COLUMN )->setText(constDistString); + } mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN ); mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN ); mySizeMapTable->resizeColumnToContents( SMP_DIST_COLUMN ); diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h index a412e70..971cd59 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h @@ -74,6 +74,7 @@ class QMenu; class QAction; class QTreeWidgetItem; class QTableWidgetItem; +class QObject; class SMESHGUI_SpinBox; class LightApp_SelectionMgr; @@ -141,7 +142,7 @@ public: virtual QString helpPage() const; //void insertElementType( TopAbs_ShapeEnum ); void insertElement( GEOM::GEOM_Object_var ); - void insertAttractor(GEOM::GEOM_Object_var, GEOM::GEOM_Object_var); + void insertAttractor(GEOM::GEOM_Object_var, GEOM::GEOM_Object_var, bool influence = true); int findRowFromEntry(QString entry); CORBA::Object_var entryToObject(QString entry); static LightApp_SelectionMgr* selectionMgr(); @@ -164,7 +165,7 @@ protected slots: // void onAddAttractor(); // void onMapSelectionActivated(); void onMapGeomContentModified(); - void onAttractorGroupClicked(bool); +// void onAttractorGroupClicked(bool); void onItemClicked( QTableWidgetItem * ); void onAddMap(); void onRemoveMap(); @@ -219,16 +220,27 @@ private: QPushButton *addPointButton; QPushButton *addMapButton; QPushButton *removeMapButton; - QGroupBox *myAttractorGroup; + QTabWidget *smpTab; + QWidget *myAttractorGroup; + QWidget *mySmpStdGroup; + QCheckBox *myConstSizeCheck; QGroupBox *myDistanceGroup; QDoubleSpinBox *myAttSizeSpin; QDoubleSpinBox *myAttDistSpin; - QDoubleSpinBox *mySmpDistSpin; + QDoubleSpinBox *mySmpDistSpin; + QDoubleSpinBox *mySmpSizeSpin; + QLabel *myAttDistLabel; + QLabel *myAttSizeLabel; // Sizemap widgets StdMeshersGUI_ObjectReferenceParamWdg *myGeomSelWdg; StdMeshersGUI_ObjectReferenceParamWdg *myAttSelWdg; + StdMeshersGUI_ObjectReferenceParamWdg *myDistSelWdg; GEOM::GEOM_Object_var mySMapObject; GEOM::GEOM_Object_var myAttObject; + GEOM::GEOM_Object_var myDistObject; + + + QWidget* myEnfGroup; // TODO FACE AND VERTEX SELECTION diff --git a/src/GUI/BLSURFPlugin_msg_en.ts b/src/GUI/BLSURFPlugin_msg_en.ts index 4c9360d..92000e9 100644 --- a/src/GUI/BLSURFPlugin_msg_en.ts +++ b/src/GUI/BLSURFPlugin_msg_en.ts @@ -155,6 +155,14 @@ BLSURF_SM_ATTRACTOR Add Attractor + + BLSURF_SM_STD_TAB + Classic map + + + BLSURF_SM_ATT_TAB + Attractor + BLSURF_ATT_DIST Influence dist. @@ -165,7 +173,11 @@ BLSURF_SM_CONST - Keep size constant + Keep constant size near shape + + + BLSURF_SM_SIZE + Local Size BLSURF_SM_DIST -- 2.39.2