From: gdd Date: Tue, 22 Mar 2011 11:04:33 +0000 (+0000) Subject: Enhancement of the GUI : X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2b90e3190f24dd8b5809e9cccda91135e57742b8;p=plugins%2Fblsurfplugin.git Enhancement of the GUI : - The table has been replaced by a tree - The tabs of the tab widget have been reorganised in : Simple and Advanced tabs --- diff --git a/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx b/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx index 7edd1ec..8c26eb1 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Attractor.cxx @@ -5,6 +5,8 @@ // cascade include #include "ShapeAnalysis.hxx" +#include "ShapeConstruct_ProjectCurveOnSurface.hxx" +#include BLSURFPlugin_Attractor::BLSURFPlugin_Attractor () : _face(), @@ -109,10 +111,15 @@ bool BLSURFPlugin_Attractor::init(){ gp_Pnt2d P2; double first; double last; - Handle(Geom2d_Curve) Curve2d = BRep_Tool::CurveOnSurface(TopoDS::Edge(_attractorShape), _face, first, last); - int N = 2 * (last - first) / _step; + Handle(Geom2d_Curve) aCurve2d; + Handle(Geom_Curve) aCurve3d = BRep_Tool::Curve (TopoDS::Edge(_attractorShape), first, last); + ShapeConstruct_ProjectCurveOnSurface curveProjector; + curveProjector.Init(aSurf, Precision::Confusion()); + curveProjector.PerformAdvanced (aCurve3d, first, last, aCurve2d); + //Handle(Geom2d_Curve) Curve2d = BRep_Tool::CurveOnSurface(TopoDS::Edge(_attractorShape), _face, first, last); + int N = 20 * (last - first) / _step; // If the edge is a circle : 4>Pi so the number of points on the edge should be good -> 5 for ellipses for (i=0; i<=N; i++){ - P2 = Curve2d->Value(first + i * (last-first) / N); + P2 = aCurve2d->Value(first + i * (last-first) / N); i0 = floor( (P2.X() - _u1) * _gridU / (_u2 - _u1) + 0.5 ); j0 = floor( (P2.Y() - _v1) * _gridV / (_v2 - _v1) + 0.5 ); MESSAGE("i0 = "< attParams; + attParams = it_At->second->GetParameters(); + save << " " << it_At->first; +// save << " " << "__BEGIN_AT_SHAPE__"; + save << " " << it_At->second->GetAttractorEntry(); +// save << " " << "__END_AT_SHAPE__"; +// save << " " << "__BEGIN_AT_PARAMS__"; + save << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3]; +// save << " " << "__END_AT_PARAMS__"<< "%#"; // "%#" is a mark of value end + //test + test << " " << it_At->first; +// test << " " << "__BEGIN_AT_SHAPE__"; + test << " " << it_At->second->GetAttractorEntry(); +// test << " " << "__END_AT_SHAPE__"; +// test << " " << "__BEGIN_AT_PARAMS__"; + test << " " << attParams[0] << " " << attParams[1] << " " << attParams[2] << " " << attParams[3]; +// test << " " << "__END_AT_PARAMS__"<< "%#"; // "%#" is a mark of value end + } + save << " " << "__NEW_ATTRACTORS_END__"; + test << " " << "__NEW_ATTRACTORS_END__"; + MESSAGE(" Attractor hypothesis saved as "<> option_or_sm); @@ -1097,6 +1127,8 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) { hasSizeMap = true; else if (option_or_sm == "__ATTRACTORS_BEGIN__") hasAttractor = true; + else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__") + hasNewAttractor = true; else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__") hasEnforcedVertex = true; @@ -1134,6 +1166,8 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) { hasSizeMap = true; else if (option_or_sm == "__ATTRACTORS_BEGIN__") hasAttractor = true; + else if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__") + hasNewAttractor = true; else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__") hasEnforcedVertex = true; } @@ -1170,6 +1204,8 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) { if (isOK) if (option_or_sm == "__ATTRACTORS_BEGIN__") hasAttractor = true; + if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__") + hasNewAttractor = true; else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__") hasEnforcedVertex = true; } @@ -1200,8 +1236,57 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) { value3[len3 - 2] = '\0'; //cut off "%#" } } - + if (hasAttractor) { + isOK = (load >> option_or_sm); + if (isOK) + if (option_or_sm == "__NEW_ATTRACTORS_BEGIN__") + hasNewAttractor = true; + else if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__") + hasEnforcedVertex = true; + } + + std::string newAtFaceEntry, atTestString; + std::string newAtShapeEntry; + double AttParams[4]; + 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]); + } + 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); + Attractor->SetParameters(AttParams[0], AttParams[1], AttParams[2], AttParams[3]); + _classAttractors[newAtFaceEntry]=Attractor; +// load >> atTestString; +// std::string & value4 = atTestString; +// int len4 = value4.size(); +// // continue reading until "%#" encountered +// while (value4[len4 - 1] != '#' || value4[len4 - 2] != '%') { +// isOK = (load >> atTestString); +// if (isOK) { +// value4 += " "; +// value4 += atTestString; +// len4 = value4.size(); +// } else { +// break; +// } +// } +// value4[len4 - 2] = '\0'; //cut off "%#" + } + } + + + if (hasNewAttractor) { isOK = (load >> option_or_sm); if (isOK) if (option_or_sm == "__ENFORCED_VERTICES_BEGIN__") diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index d132042..e9274e6 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -108,10 +108,10 @@ enum { OPTION_NAME_COLUMN, OPTION_VALUE_COLUMN, NB_COLUMNS, - SMP_ENTRY_COLUMN = 0, - SMP_NAME_COLUMN, + SMP_NAME_COLUMN =0, SMP_SIZEMAP_COLUMN, - SMP_DIST_COLUMN, + SMP_ENTRY_COLUMN, +// SMP_DIST_COLUMN, SMP_NB_COLUMNS, // Enforced vertices array columns ENF_VER_NAME_COLUMN = 0, @@ -131,33 +131,30 @@ enum { // SMP_POINT_BTN, // SMP_EDGE_BTN, // SMP_SURFACE_BTN, - SMP_GEOM_BTN, // SMP_SEPARATOR2, -// SMP_SEPARATOR, +// SMP_SEPARATOR, SMP_TAB_WDG, // SMP_ATT_GROUP, SMP_ADD_BTN, // SMP_REMOVE_BTN, SMP_NB_LINES, SMP_STD_TAB = 0, - ATT_TAB -}; - -enum { - SMP_ATT_SHAPE, + ATT_TAB, + SMP_GEOM_BTN_2 = 0, + ATT_CHECK, + CONST_SIZE_CHECK, + SMP_SPACE, + SMP_PARAMS, + SMP_ATT_SHAPE = 0, SMP_ATT_SIZE, SMP_ATT_DIST, SMP_ATT_RAD }; - + enum { + SMP_GEOM_BTN_1, SMP_SIZE, - SMP_SPACE, - SMP_DIST_GROUP, -// SMP_CHECK, SMP_SPACE2, - SMP_DIST=0, - SMP_DIST_SHAPE, }; // Enforced vertices inputs @@ -615,11 +612,12 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams() const BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = BLSURFPlugin::BLSURFPlugin_Hypothesis::_narrow( initParamsHypothesis() ); BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; - int row = 0, nbRows = mySizeMapTable->rowCount(); +// int row = 0, nbRows = mySizeMapTable->rowCount(); + int row = 0, nbRows = mySizeMapTable->topLevelItemCount(); for ( ; row < nbRows; ++row ) { - QString entry = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text(); - QString sizeMap = mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->text().trimmed(); + QString entry = mySizeMapTable->topLevelItem( row )->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString(); + QString sizeMap = mySizeMapTable->topLevelItem( row )->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString(); if ( !sizeMap.isEmpty() ) { if (that->sizeMapValidationFromRow(row)) { @@ -797,34 +795,36 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() // Size Maps parameters mySmpGroup = new QWidget(); - mySmpGroup->setMinimumWidth(500); +// mySmpGroup->setMinimumWidth(500); //mySmpGroup->setMinimumHeight(350); //Layout QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup); // Table - mySizeMapTable = new QTableWidget( 0, SMP_NB_COLUMNS, mySmpGroup ); + mySizeMapTable = new QTreeWidget( mySmpGroup ); + mySizeMapTable ->setMinimumWidth(300); // tab widget smpTab = new QTabWidget( mySmpGroup ); smpTab->setTabShape( QTabWidget::Rounded ); - smpTab->setTabPosition( QTabWidget::South ); + smpTab->setTabPosition( QTabWidget::East ); 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" ); - mySizeMapTable->setHorizontalHeaderLabels(sizeMapHeaders); - mySizeMapTable->horizontalHeader()->hideSection( SMP_ENTRY_COLUMN ); - mySizeMapTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive); - mySizeMapTable->horizontalHeader()->setStretchLastSection(true); + sizeMapHeaders << tr( "SMP_NAME_COLUMN" )<< tr( "SMP_SIZEMAP_COLUMN" )<< tr( "SMP_ENTRY_COLUMN" );// << tr( "SMP_DIST_COLUMN" ); + mySizeMapTable->setHeaderLabels(sizeMapHeaders); +// mySizeMapTable->headerItem()->hideSection( SMP_ENTRY_COLUMN ); +// mySizeMapTable->headerItem()->setResizeMode(QHeaderView::Interactive); +// mySizeMapTable->headerItem()->setStretchLastSection(true); //mySizeMapTable->horizontalHeader()->setProperty("showSortIndicator", QVariant(true)); mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN); mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN); - mySizeMapTable->resizeColumnToContents(SMP_DIST_COLUMN); + mySizeMapTable->hideColumn(SMP_ENTRY_COLUMN); + // mySizeMapTable->resizeColumnToContents(SMP_DIST_COLUMN); mySizeMapTable->setAlternatingRowColors(true); - mySizeMapTable->verticalHeader()->hide(); +// mySizeMapTable->verticalHeader()->hide(); - mySizeMapTable->setShowGrid(true); +// mySizeMapTable->setShowGrid(true); // Filters of selection TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes; @@ -841,13 +841,16 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() 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 }"); + myGeomSelWdg1 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter1, 0, /*multiSel=*/false,/*stretch=*/false); + myGeomSelWdg1->SetDefaultText("Select a shape", "QLineEdit { color: grey }"); + myGeomSelWdg2 = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter3, 0, /*multiSel=*/false,/*stretch=*/false); + myGeomSelWdg2->SetDefaultText("Select a face", "QLineEdit { color: grey }"); // 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); + modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup); // Attractor GroupBox //myAttractorGroup = new QGroupBox(tr("BLSURF_SM_ATTRACTOR"),mySmpGroup); @@ -857,15 +860,24 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() // myAttractorGroup->setChecked(false); // myAttractorGroup->setEnabled(false); QGridLayout* anAttLayout = new QGridLayout(myAttractorGroup); - myAttDistSpin = new QDoubleSpinBox(myAttractorGroup); - myAttDistSpin2 = new QDoubleSpinBox(myAttractorGroup); - myAttSizeSpin = new QDoubleSpinBox(myAttractorGroup); - myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myAttractorGroup); - myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),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); + myAttractorCheck = new QCheckBox(tr("BLSURF_ATTRACTOR"),myAttractorGroup); + myConstSizeCheck = new QCheckBox(tr("BLSURF_CONST_SIZE"),myAttractorGroup); + myParamsGroup = new QGroupBox(tr("BLSURF_SM_PARAMS"), myAttractorGroup); + myParamsGroup->setEnabled(false); + QGridLayout* aParamsLayout = new QGridLayout(myParamsGroup); + myAttDistSpin = new SMESHGUI_SpinBox(myParamsGroup); + myAttDistSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision"); + myAttDistSpin2 = new SMESHGUI_SpinBox(myParamsGroup); + myAttDistSpin2->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision"); + myAttSizeSpin = new SMESHGUI_SpinBox(myParamsGroup); + myAttSizeSpin->RangeStepAndValidator(0., COORD_MAX, 1.0, "length_precision"); + myAttDistLabel = new QLabel(tr("BLSURF_ATT_DIST"),myParamsGroup); + myAttDistLabel2 = new QLabel(tr("BLSURF_ATT_RADIUS"),myParamsGroup); + myAttSizeLabel = new QLabel(tr("BLSURF_SM_SIZE"),myParamsGroup); + myAttSelWdg = new StdMeshersGUI_ObjectReferenceParamWdg( myFilter2, myParamsGroup, /*multiSel=*/false,/*stretch=*/false); + myAttSelWdg->SetDefaultText("Select the attractor", "QLineEdit { color: grey }"); + myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg1); + myAttSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2); // Initialization of widgets // myAttDistSpin->hide(); @@ -879,74 +891,60 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() QGridLayout* anSmpStdLayout = new QGridLayout(mySmpStdGroup); // Constant Size GroupBox - mySmpSizeSpin = new QDoubleSpinBox(mySmpStdGroup); + mySmpSizeSpin = new SMESHGUI_SpinBox(mySmpStdGroup); + mySmpSizeSpin->RangeStepAndValidator(0., COORD_MAX, 10.0, "length_precision"); 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 ); - 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); + +// myDistanceGroup = new QGroupBox(tr("BLSURF_SM_CONST"),mySmpStdGroup); +// myDistanceGroup->setFlat(true); +// myDistanceGroup->setCheckable(true); +// myDistanceGroup->setChecked(false); +// myDistanceGroup->setEnabled(true); +// myDistanceGroup->setVisible(false); // NOTE Désactivé pour l'instant - // Parameters of SpinBoxes +// QGridLayout* aDistLayout = new QGridLayout(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(myGeomSelWdg1); +// myDistSelWdg->AvoidSimultaneousSelection(myGeomSelWdg2); +// myDistSelWdg->AvoidSimultaneousSelection(myAttSelWdg); - myAttDistSpin->setMaximum(1000); // TODO use preferences of SALOME - myAttDistSpin2->setMaximum(1000); - mySmpDistSpin->setMaximum(1000); - myAttSizeSpin->setMaximum(1000); - mySmpSizeSpin->setMaximum(1000); - myAttDistSpin->setDecimals(4); - myAttDistSpin2->setDecimals(4); - mySmpDistSpin->setDecimals(4); - myAttSizeSpin->setDecimals(4); - mySmpSizeSpin->setDecimals(4); + // Init SpinBoxes myAttDistSpin->setValue(0.); myAttDistSpin2->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, 0, 0, SMP_NB_LINES, 1); - anSmpLayout->addWidget(myGeomSelWdg, SMP_GEOM_BTN, 1, 1, 2); + anSmpLayout->addWidget(mySizeMapTable, 0, 0, SMP_NB_LINES, 1); + anSmpLayout->setColumnStretch(0, 1); // anSmpLayout->addWidget(line2, SMP_SEPARATOR2, 1, 2, 2); - anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 2); + anSmpLayout->addWidget(smpTab, SMP_TAB_WDG, 1, 1, 3); // 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); + anSmpLayout->addWidget(addMapButton, SMP_ADD_BTN, 1, 1, 1); + anSmpLayout->addWidget(removeMapButton, SMP_ADD_BTN, 2, 1, 1); + anSmpLayout->addWidget(modifyMapButton, SMP_ADD_BTN, 3, 1, 1); - anAttLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 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->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1); - anAttLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1); - anAttLayout->setRowStretch(SMP_ATT_RAD+1, 1); + anAttLayout->addWidget(myGeomSelWdg2, SMP_GEOM_BTN_2,1, 1, 2); + anAttLayout->addWidget(myAttractorCheck, ATT_CHECK, 1, 1, 2); + anAttLayout->addWidget(myConstSizeCheck, CONST_SIZE_CHECK, 1, 1, 2); + anAttLayout->addWidget(myParamsGroup, SMP_PARAMS, 1, 1, 2); + aParamsLayout->addWidget(myAttSelWdg, SMP_ATT_SHAPE, 1, 1, 2); + aParamsLayout->addWidget(myAttSizeLabel, SMP_ATT_SIZE, 1, 1, 1); + aParamsLayout->addWidget(myAttSizeSpin, SMP_ATT_SIZE, 2, 1, 1); + aParamsLayout->addWidget(myAttDistLabel, SMP_ATT_DIST, 1, 1, 1); + aParamsLayout->addWidget(myAttDistSpin, SMP_ATT_DIST, 2, 1, 1); + aParamsLayout->addWidget(myAttDistLabel2, SMP_ATT_RAD, 1, 1, 1); + aParamsLayout->addWidget(myAttDistSpin2, SMP_ATT_RAD, 2, 1, 1); + aParamsLayout->setRowStretch(SMP_ATT_RAD+1, 1); + anSmpStdLayout->addWidget(myGeomSelWdg1, SMP_GEOM_BTN_1, 1, 1, 2); 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" ) ); @@ -1062,18 +1060,18 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() tab->setCurrentIndex( STD_TAB ); // --- - connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) ); - connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) ); - connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) ); - connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) ); - connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) ); - - connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) ); - connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) ); - connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) ); - connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) ); - connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) ); - connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) ); + connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) ); + connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) ); + connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) ); + connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) ); + connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) ); + + connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) ); + connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( updateEnforcedVertexValues(QTreeWidgetItem *, int) ) ); + connect( myEnforcedTreeWidget,SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) ); + connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertices() ) ); + connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) ); + connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) ); // connect( myEnfVertexWdg, SIGNAL( selectionActivated()), this, SLOT( onVertexSelectionActivated() ) ); // connect( myEnfFaceWdg, SIGNAL( selectionActivated()), this, SLOT( onFaceSelectionActivated() ) ); // connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(deactivateSelection(QWidget*, QWidget*))); @@ -1085,11 +1083,14 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() // Size Maps connect( addMapButton, SIGNAL( clicked()), this, SLOT( onAddMap() ) ); connect( removeMapButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) ); + connect( modifyMapButton, SIGNAL( clicked()), this, SLOT( onModifyMap() ) ); connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) ); - connect( mySizeMapTable, SIGNAL( itemClicked (QTableWidgetItem *)),this, SLOT( onItemClicked(QTableWidgetItem *) ) ); - connect( myGeomSelWdg, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) ); + connect( mySizeMapTable, SIGNAL( itemClicked (QTreeWidgetItem *, int)),this,SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) ); +// connect( myGeomSelWdg2, SIGNAL( contentModified() ), this, SLOT( onMapGeomContentModified() ) ); connect( myAttractorGroup, SIGNAL( clicked(bool) ), this, SLOT( onAttractorGroupClicked(bool) ) ); connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) ); + connect( myAttractorCheck, SIGNAL( stateChanged ( int )), this, SLOT( onAttractorClicked( int ) ) ); + connect( myConstSizeCheck, SIGNAL( stateChanged ( int )), this, SLOT( onConstSizeClicked( int ) ) ); // Enforced vertices connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronizeCoords() ) ); @@ -1556,48 +1557,54 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const const QString entry = i.key(); string shapeName = myGeomToolSelected->getNameFromEntry(entry.toStdString()); const QString sizeMap = i.value(); - int row = mySizeMapTable->rowCount(); - mySizeMapTable->setRowCount( row+1 ); - mySizeMapTable->setItem( row, SMP_ENTRY_COLUMN, new QTableWidgetItem( entry ) ); - mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->setFlags( 0 ); - mySizeMapTable->setItem( row, SMP_NAME_COLUMN, new QTableWidgetItem( QString::fromStdString(shapeName) ) ); - mySizeMapTable->item( row, SMP_NAME_COLUMN )->setFlags( 0 ); + int row = mySizeMapTable->topLevelItemCount(); +// mySizeMapTable->setRowCount( row+1 ); + QTreeWidgetItem* item = new QTreeWidgetItem(); + mySizeMapTable->addTopLevelItem( item ); + item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled ); + item->setData(SMP_ENTRY_COLUMN,Qt::DisplayRole, QVariant(entry) ); + item->setData(SMP_NAME_COLUMN, Qt::DisplayRole, QVariant( QString::fromStdString(shapeName) ) ); if (that->myATTMap.contains(entry)){ const QString attEntry = that->myATTMap[entry]; - MESSAGE("attEntry = "<getNameFromEntry(attEntry.toStdString()); - MESSAGE("attName = "<addChild( child ); + item->setExpanded(true); + child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant( sizeMap ) ); + 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){ - 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) ) ); + 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 ); + 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 ); + 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 ); } } else { - 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) ) ); + 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 ); + Qt::ItemIsEnabled ); */ } } - + mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN ); mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN ); mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN); @@ -2109,10 +2116,10 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes } // SizeMap - row = 0, nbRows = mySizeMapTable->rowCount(); + row = 0, nbRows = mySizeMapTable->topLevelItemCount(); for ( ; row < nbRows; ++row ) { - QString entry = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text(); + QString entry = mySizeMapTable->topLevelItem(row)->data(SMP_ENTRY_COLUMN ,Qt::EditRole).toString(); if ( that->mySMPMap.contains(entry) ) guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); "; } @@ -2297,28 +2304,28 @@ void BLSURFPluginGUI_HypothesisCreator::onDeleteOption() // *** BEGIN SIZE MAP *** // ********************** -void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified() -{ - if ( myGeomSelWdg->IsObjectSelected() ){ - mySMapObject = myGeomSelWdg->GetObject< GEOM::GEOM_Object >(0); - TopAbs_ShapeEnum myShapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( mySMapObject ).ShapeType(); - if ( myShapeType == TopAbs_FACE ){ - smpTab->setTabEnabled(ATT_TAB,true); -// if (!myAttractorGroup->isChecked()){ - myDistanceGroup->setEnabled(false); -// myDistanceGroup->setChecked(false); -// } - } - else - { - smpTab->setTabEnabled(ATT_TAB,false); -// myAttractorGroup->setEnabled(false); -// myAttractorGroup->setChecked(false); - myDistanceGroup->setEnabled(true); - } - } - -} +// void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified() +// { +// if ( myGeomSelWdg2->IsObjectSelected() ){ +// mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0); +// TopAbs_ShapeEnum myShapeType = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( mySMapObject ).ShapeType(); +// if ( myShapeType == TopAbs_FACE ){ +// smpTab->setTabEnabled(ATT_TAB,true); +// // if (!myAttractorGroup->isChecked()){ +// myDistanceGroup->setEnabled(false); +// // myDistanceGroup->setChecked(false); +// // } +// } +// else +// { +// smpTab->setTabEnabled(ATT_TAB,false); +// // myAttractorGroup->setEnabled(false); +// // myAttractorGroup->setChecked(false); +// myDistanceGroup->setEnabled(true); +// } +// } +// +// } NOTE inutile pour l'instant à supprimer si toujours pas utile // void BLSURFPluginGUI_HypothesisCreator::onAttractorGroupClicked(bool checked){ // // QObjectList grpChildren = myAttractorGroup->children(); @@ -2352,50 +2359,36 @@ void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified() // } // } -void BLSURFPluginGUI_HypothesisCreator::onItemClicked(QTableWidgetItem * item) +void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col) { - int row = item->row(); - int col = item->column(); - MESSAGE("BLSURFPluginGUI_HypothesisCreator::onCellClicked("<mySizeMapTable->item(row, SMP_ENTRY_COLUMN)->text(); - QString sizeMap = that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->text().trimmed(); - if (sizeMap.startsWith("Attractor :")){ -// myAttractorGroup->setChecked( true ); -// myDistanceGroup->setChecked( true ); -// myDistanceGroup->setEnabled( true ); + QString entry = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString(); + QString sizeMap = item->data( SMP_SIZEMAP_COLUMN, Qt::EditRole ).toString(); + CORBA::Object_var obj = entryToObject(entry); + myGeomSelWdg2->SetObject(obj); + if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")){ smpTab->setCurrentIndex(ATT_TAB); double phySize = that->mySMPMap[entry].toDouble(); double infDist = that->myAttDistMap[entry]; double constDist = that->myDistMap[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); - myAttDistSpin2->setValue(constDist); - } - 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); + if (sizeMap.startsWith("Attractor")){ + myAttDistSpin->setValue(infDist); + myAttractorCheck->setChecked(true); + } + if (sizeMap.startsWith("Constant") || constDist > 1e-12 ){ + myAttDistSpin2->setValue(constDist); + myConstSizeCheck->setChecked(true); + } } else { - smpTab->setCurrentIndex(SMP_STD_TAB); - CORBA::Object_var obj = entryToObject(entry); - myGeomSelWdg->SetObject(obj); + smpTab->setCurrentIndex(SMP_STD_TAB); if (!sizeMap.startsWith("def")){ mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble()); // myAttractorGroup->setChecked( false ); @@ -2404,29 +2397,77 @@ void BLSURFPluginGUI_HypothesisCreator::onItemClicked(QTableWidgetItem * item) } } +void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state) +{ + if (state == Qt::Checked){ + myParamsGroup->setEnabled(true); + myAttDistSpin->setEnabled(true); + myAttDistLabel->setEnabled(true); + myAttDistSpin2->setEnabled(true); + myAttDistLabel2->setEnabled(true); + if(myConstSizeCheck->checkState() == Qt::Unchecked){ + myAttDistSpin2->setEnabled(false); + myAttDistLabel2->setEnabled(false); + myAttDistSpin2->setValue(0.); + } + } + if (state == Qt::Unchecked){ + if(myConstSizeCheck->checkState() == Qt::Unchecked){ + myParamsGroup->setEnabled(false); + } + else{ + myAttDistSpin->setEnabled(false); + myAttDistLabel->setEnabled(false); + myAttDistSpin->setValue(0.); + } + } +} +void BLSURFPluginGUI_HypothesisCreator::onConstSizeClicked(int state) +{ + if (state == Qt::Checked){ + myParamsGroup->setEnabled(true); + myAttDistSpin->setEnabled(true); + myAttDistLabel->setEnabled(true); + myAttDistSpin2->setEnabled(true); + myAttDistLabel2->setEnabled(true); + if(myAttractorCheck->checkState() == Qt::Unchecked){ + myAttDistSpin->setEnabled(false); + myAttDistLabel->setEnabled(false); + myAttDistSpin->setValue(0.); + } + } + if (state == Qt::Unchecked){ + if(myAttractorCheck->checkState() == Qt::Unchecked){ + myParamsGroup->setEnabled(false); + } + else{ + myAttDistSpin2->setEnabled(false); + myAttDistLabel2->setEnabled(false); + myAttDistSpin2->setValue(0.); + } + } +} void BLSURFPluginGUI_HypothesisCreator::onRemoveMap() { MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveMap()"); QList selectedRows; - QList selected = mySizeMapTable->selectedItems(); - QTableWidgetItem* item; - int row; - foreach( item, selected ) { - row = item->row(); - if ( !selectedRows.contains( row ) ) - selectedRows.append( row ); - } + QList selected = mySizeMapTable->selectedItems(); + QTreeWidgetItem* item; +// foreach( item, selected ) { +// if ( !selected.contains( item ) ) +// selected.append( row ); +// } BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; qSort( selectedRows ); - QListIterator it( selectedRows ); + QListIterator it( selected ); it.toBack(); while ( it.hasPrevious() ) { - row = it.previous(); - QString entry = mySizeMapTable->item(row,SMP_ENTRY_COLUMN)->text(); + item = it.previous(); + QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString(); if (that->mySMPMap.contains(entry)) that->mySMPMap[entry] = "__TO_DELETE__"; if (that->mySMPShapeTypeMap.contains(entry)) @@ -2437,20 +2478,20 @@ void BLSURFPluginGUI_HypothesisCreator::onRemoveMap() that->myDistMap.remove(entry); if (that->myAttDistMap.contains(entry)) that->myAttDistMap.remove(entry); - mySizeMapTable->removeRow(row ); + delete item; } mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN); mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN); } -void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(int row,int col) +void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int col) { - MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< row << "," << col << ")"); + MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< col << ")"); MESSAGE("mySMPMap.size() = "<mySizeMapTable->item(row, SMP_ENTRY_COLUMN)->text(); - QString sizeMap = that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->text().trimmed(); + QString entry = item->data(SMP_ENTRY_COLUMN, Qt::EditRole).toString(); + QString sizeMap = item->data(SMP_SIZEMAP_COLUMN, Qt::EditRole).toString(); // MESSAGE("entry: " << entry.toStdString() << ", sizeMap: " << sizeMap.toStdString()); if (! that->mySMPShapeTypeMap.contains(entry)) return; @@ -2465,7 +2506,7 @@ void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(int row,int col) if (! sizeMap.isEmpty()) { that->mySMPMap[entry] = sizeMap; - sizeMapValidationFromRow(row); + // sizeMapValidationFromRow(row); // TODO utiliser sizempavalidationfromitem // if (! sizeMapValidationFromRow(row)) { // bgColor->setRgb(255,0,0); // fgColor->setRgb(255,255,255); @@ -2475,7 +2516,7 @@ void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(int row,int col) MESSAGE("Size map empty: reverse to precedent value" ); } if (sizeMap.isEmpty()) { - that->mySizeMapTable->item(row, SMP_SIZEMAP_COLUMN)->setText(that->mySMPMap[entry]); + 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)); @@ -2487,42 +2528,58 @@ void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(int row,int col) void BLSURFPluginGUI_HypothesisCreator::onAddMap() { - if ( myGeomSelWdg->IsObjectSelected() ){ - mySMapObject = myGeomSelWdg->GetObject< GEOM::GEOM_Object >(0); -// if ( myAttractorGroup->isChecked() ){ - if ( smpTab->currentIndex() == ATT_TAB ){ - if ( myAttSelWdg->IsObjectSelected() ){ - myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0); - insertAttractor(mySMapObject, myAttObject); - } + if ( smpTab->currentIndex() == ATT_TAB ){ + if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){ + mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0); + myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0); + insertAttractor(mySMapObject, myAttObject); } -// 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); - } + } + if (smpTab->currentIndex() == SMP_STD_TAB ){ + if ( myGeomSelWdg1->IsObjectSelected() ){ + mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0); + insertElement(mySMapObject); + } + } + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + that->getGeomSelectionTool()->selectionMgr()->clearFilters(); + myAttDistSpin->setValue(0.); + myAttSizeSpin->setValue(0.); + myAttDistSpin2->setValue(0.); + myGeomSelWdg1->deactivateSelection(); + myGeomSelWdg2->deactivateSelection(); + myAttSelWdg->deactivateSelection(); +// mySmpDistSpin->setValue(0.); +// mySmpSizeSpin->setValue(0.); +} + +void BLSURFPluginGUI_HypothesisCreator::onModifyMap() +{ + MESSAGE("BLSURFPluginGUI_HypothesisCreator::onModifyMap()"); + if ( smpTab->currentIndex() == ATT_TAB ){ + if ( myGeomSelWdg2->IsObjectSelected() && myAttSelWdg->IsObjectSelected() ){ + mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0); + myAttObject = myAttSelWdg->GetObject< GEOM::GEOM_Object >(0); + insertAttractor(mySMapObject, myAttObject, /*modify = */true); } - BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; - that->getGeomSelectionTool()->selectionMgr()->clearFilters(); - myAttDistSpin->setValue(0.); - myAttSizeSpin->setValue(0.); - myAttDistSpin2->setValue(0.); - mySmpDistSpin->setValue(0.); - mySmpSizeSpin->setValue(0.); - myGeomSelWdg->deactivateSelection(); - myDistSelWdg->deactivateSelection(); } + if (smpTab->currentIndex() == SMP_STD_TAB ){ + if ( myGeomSelWdg1->IsObjectSelected() ){ + mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0); + insertElement(mySMapObject, /*modify = */true); + } + } + BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this; + that->getGeomSelectionTool()->selectionMgr()->clearFilters(); + myAttDistSpin->setValue(0.); + myAttSizeSpin->setValue(0.); + myAttDistSpin2->setValue(0.); + myGeomSelWdg1->deactivateSelection(); + myGeomSelWdg2->deactivateSelection(); + myAttSelWdg->deactivateSelection(); } -void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject) +void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify) { MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertElement()"); BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = @@ -2544,30 +2601,34 @@ void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anOb 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; -// } -// } + // int row = mySizeMapTable->rowCount(); + // mySizeMapTable->setRowCount( row + 1 ); + QTreeWidgetItem* item = new QTreeWidgetItem(); + if (modify){ + int rowToChange = findRowFromEntry(shapeEntry); + item = mySizeMapTable->takeTopLevelItem( rowToChange ); + } + else{ + if (that->mySMPMap.contains(shapeEntry)) { + if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") { + // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")"); + return; + } + } + mySizeMapTable->addTopLevelItem(item); + } that->mySMPMap[shapeEntry] = sizeMap; that->myDistMap[shapeEntry] = 0. ; that->mySMPShapeTypeMap[shapeEntry] = shapeType; - int row = mySizeMapTable->rowCount(); - mySizeMapTable->setRowCount( row + 1 ); - mySizeMapTable->setItem( row, SMP_ENTRY_COLUMN, new QTableWidgetItem( shapeEntry ) ); - mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->setFlags( 0 ); - mySizeMapTable->setItem( row, SMP_NAME_COLUMN, new QTableWidgetItem( QString::fromStdString(shapeName) ) ); - mySizeMapTable->item( row, SMP_NAME_COLUMN )->setFlags( 0 ); - 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( ) ); - mySizeMapTable->item( row, SMP_DIST_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled ); - mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN ); + item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled ); + item->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(shapeEntry) ); + item->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(shapeName)) ); + item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) ); + mySizeMapTable->addTopLevelItem(item); + mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN ); - mySizeMapTable->resizeColumnToContents( SMP_DIST_COLUMN ); mySizeMapTable->clearSelection(); - mySizeMapTable->scrollToItem( mySizeMapTable->item( row , SMP_SIZEMAP_COLUMN ) ); +// mySizeMapTable->scrollToItem( mySizeMapTable->item( row , SMP_SIZEMAP_COLUMN ) ); //TODO voir si cette option est utile if ( myPhysicalMesh->currentIndex() != SizeMap ) { myPhysicalMesh->setCurrentIndex( SizeMap ); @@ -2575,7 +2636,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anOb } } -void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool influence) +void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aFace, GEOM::GEOM_Object_var anAttractor, bool modify) { MESSAGE("BLSURFPluginGUI_HypothesisCreator::insertAttractor()"); BLSURFPlugin::BLSURFPlugin_Hypothesis_var h = @@ -2597,18 +2658,13 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF double phySize = h->GetPhySize(); double infDist = 0. ; double constDist = 0. ; - if (smpTab->currentIndex()==ATT_TAB){ // ATTRACTOR + phySize = myAttSizeSpin->value(); + if (myAttractorCheck->isChecked()){ infDist = myAttDistSpin->value(); - phySize = myAttSizeSpin->value(); - constDist = myAttDistSpin2->value(); - } - else{ // SIZE MAP WITH CONSTANT SIZE AROUND - phySize = mySmpSizeSpin->value(); - if (myDistanceGroup->isChecked()){ - constDist = mySmpDistSpin->value(); - } } - myGeomSelWdg->SetObject(CORBA::Object::_nil()); + if (myConstSizeCheck->isChecked()){ + constDist = myAttDistSpin2->value(); + } std::ostringstream oss; std::ostringstream oss2; std::ostringstream oss3; @@ -2619,52 +2675,53 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF QString infDistString = QString::fromStdString(oss2.str()); QString constDistString = QString::fromStdString(oss3.str()); - int row = mySizeMapTable->rowCount(); - int rowToChange; - if (!that->mySMPMap.contains(shapeEntry) || that->mySMPMap[shapeEntry] == "__TO_DELETE__") { - mySizeMapTable->setRowCount( row + 1 ); - mySizeMapTable->setItem( row, SMP_ENTRY_COLUMN, new QTableWidgetItem( ) ); - mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->setFlags( 0 ); - mySizeMapTable->setItem( row, SMP_NAME_COLUMN, new QTableWidgetItem( ) ); - mySizeMapTable->item( row, SMP_NAME_COLUMN )->setFlags( 0 ); - mySizeMapTable->setItem( row, SMP_SIZEMAP_COLUMN, new QTableWidgetItem( ) ); - mySizeMapTable->item( row, SMP_SIZEMAP_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled ); - mySizeMapTable->setItem( row, SMP_DIST_COLUMN, new QTableWidgetItem( ) ); - mySizeMapTable->item( row, SMP_DIST_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled); - rowToChange = row; - } - // if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") { -// // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")"); -// return; -// } - else { - rowToChange = findRowFromEntry(shapeEntry); - MESSAGE("rowToChange = "<topLevelItemCount(); +// int rowToChange; + QTreeWidgetItem* item; + QTreeWidgetItem* child; + if (modify){ + int rowToChange = findRowFromEntry(shapeEntry); + item = mySizeMapTable->topLevelItem( rowToChange ); + child = item->child( 0 ); + } + else{ + if (that->mySMPMap.contains(shapeEntry)) { + if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") { + // MESSAGE("Size map for shape with name(entry): "<< shapeName << "(" << entry << ")"); + return; + } + } + item = new QTreeWidgetItem(); + child = new QTreeWidgetItem(); + mySizeMapTable->addTopLevelItem(item); + item->addChild(child); } 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); - if (smpTab->currentIndex()==ATT_TAB){ - 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); + 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){ + item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Attractor")) ); } - else { - 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( rowToChange, SMP_DIST_COLUMN )->setText(constDistString); + else if (constDist > 1e-12){ + item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(QString::fromStdString("Constant Size")) ); } + item->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEditable |Qt::ItemIsEnabled ); + + child->setData(SMP_ENTRY_COLUMN, Qt::EditRole, QVariant(qAttEntry) ); + child->setData(SMP_NAME_COLUMN, Qt::EditRole, QVariant(QString::fromStdString(attName)) ); + child->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(sizeMap) ); + + mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN ); mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN ); mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN ); - mySizeMapTable->resizeColumnToContents( SMP_DIST_COLUMN ); - mySizeMapTable->clearSelection(); - mySizeMapTable->scrollToItem( mySizeMapTable->item( row , SMP_SIZEMAP_COLUMN ) ); +// mySizeMapTable->resizeColumnToContents( SMP_DIST_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 ); @@ -2676,7 +2733,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation() { MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation()"); - int row = 0, nbRows = mySizeMapTable->rowCount(); + int row = 0, nbRows = mySizeMapTable->topLevelItemCount(); for ( ; row < nbRows; ++row ) if (! sizeMapValidationFromRow(row)) return false; @@ -2686,7 +2743,7 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapsValidation() bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(int myRow, bool displayError) { MESSAGE("BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromRow(), row = "<item( myRow, SMP_ENTRY_COLUMN )->text(); + QString myEntry = mySizeMapTable->topLevelItem( myRow )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString(); bool res = sizeMapValidationFromEntry(myEntry,displayError); mySizeMapTable->setFocus(); return res; @@ -2871,12 +2928,12 @@ CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){ QString entryForChecking; - int endRow = mySizeMapTable->rowCount()-1; + int endRow = mySizeMapTable->topLevelItemCount()-1; int row = 0; - entryForChecking = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text(); + entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString(); while (entry != entryForChecking && row <= endRow){ row++; - entryForChecking = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text(); + entryForChecking = mySizeMapTable->topLevelItem( row )->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString(); } MESSAGE("BLSURFPluginGUI_HypothesisCreator::findRowFromEntry; row = "< BLSURF_SM_STD_TAB - Classic map + Simple map BLSURF_SM_ATT_TAB + Advanced + + + BLSURF_SM_PARAMS + Parameters + + + BLSURF_ATTRACTOR Attractor + + BLSURF_CONST_SIZE + Constant size near shape + BLSURF_ATT_DIST Influence dist. BLSURF_ATT_RADIUS - Const. size over - - - BLSURF_ATT_SIZE - Start size + Constant over BLSURF_SM_CONST @@ -189,7 +197,11 @@ BLSURF_SM_ADD - Add / Modify + Add + + + BLSURF_SM_MODIFY + Modify BLSURF_SM_REMOVE