From 056d5738ce52f3e6365739402aa4bbceef1d4a99 Mon Sep 17 00:00:00 2001 From: gdd Date: Thu, 10 Mar 2011 16:50:53 +0000 Subject: [PATCH] rnc : some slight ameliorations (all parameters are retrieved in spinboxes and lineedit when one clicks on an attractor item in the table) --- src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 152 +++++++++--------- src/GUI/BLSURFPlugin_msg_en.ts | 6 +- 2 files changed, 81 insertions(+), 77 deletions(-) diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index e895b6e..1c20f6a 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -611,7 +611,9 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() MESSAGE("BLSURFPluginGUI_HypothesisCreator::buildFrame"); QFrame* fr = new QFrame( 0 ); + // fr-> setMinimumSize(600,400); QVBoxLayout* lay = new QVBoxLayout( fr ); + // lay->setSizeConstraint(QLayout::SetDefaultConstraint); lay->setMargin( 5 ); lay->setSpacing( 0 ); @@ -752,8 +754,10 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() // Size Maps parameters mySmpGroup = new QWidget(); + mySmpGroup->setMinimumWidth(450); +// mySmpGroup->setMinimumHeight(300); QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup); - + //anSmpLayout->setColumnStretch(0,1); mySizeMapTable = new QTableWidget( 0, SMP_NB_COLUMNS, mySmpGroup ); //mySizeMapTable->setSortingEnabled(true); QStringList sizeMapHeaders; @@ -770,16 +774,6 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() mySizeMapTable->verticalHeader()->hide(); mySizeMapTable->setShowGrid(true); -/* - addAttractorButton = new QPushButton(tr("BLSURF_SM_ATTRACTOR"),mySmpGroup); - QFrame *line = new QFrame(mySmpGroup); - line->setFrameShape(QFrame::HLine); - line->setFrameShadow(QFrame::Sunken); -*/ - //addSurfaceButton = new QPushButton(tr("BLSURF_SM_SURFACE"),mySmpGroup); - //addEdgeButton = new QPushButton(tr("BLSURF_SM_EDGE"),mySmpGroup); - //addPointButton = new QPushButton(tr("BLSURF_SM_POINT"),mySmpGroup); - // Filters of selection TColStd_MapOfInteger SM_ShapeTypes, ATT_ShapeTypes; @@ -1434,7 +1428,8 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const Qt::ItemIsEnabled ); } mySizeMapTable->setItem( row, SMP_DIST_COLUMN, new QTableWidgetItem( QString::number( that->myDistMap[entry], 'g', 6) ) ); - mySizeMapTable->item( row, SMP_DIST_COLUMN )->setFlags( 0 ); + mySizeMapTable->item( row, SMP_DIST_COLUMN )->setFlags( Qt::ItemIsSelectable | + Qt::ItemIsEnabled ); } mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN ); @@ -2228,6 +2223,7 @@ void BLSURFPluginGUI_HypothesisCreator::onMapGeomContentModified() myAttractorGroup->setEnabled(true); if (!myAttractorGroup->isChecked()){ myDistanceGroup->setEnabled(false); + myDistanceGroup->setChecked(false); } } else @@ -2246,9 +2242,45 @@ void BLSURFPluginGUI_HypothesisCreator::onAttractorGroupClicked(bool checked){ } else{ myDistanceGroup->setEnabled(false); + myDistanceGroup->setChecked(false); } } +void BLSURFPluginGUI_HypothesisCreator::onItemClicked(QTableWidgetItem * item) +{ + 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 ); + double phySize = that->mySMPMap[entry].toDouble(); + double infDist = that->myAttDistMap[entry]; + QString attEntry = that->myATTMap[entry]; + CORBA::Object_var attObj = entryToObject(attEntry); + + myAttSelWdg->SetObject(attObj); + myAttSizeSpin->setValue(phySize); + myAttDistSpin->setValue(infDist); + } + else { + myAttractorGroup->setChecked( false ); + } + CORBA::Object_var obj = entryToObject(entry); + double constDist = that->myDistMap[entry]; + + myGeomSelWdg->SetObject(obj); + mySmpDistSpin->setValue(constDist); + } +} + + void BLSURFPluginGUI_HypothesisCreator::onRemoveMap() { @@ -2287,54 +2319,6 @@ void BLSURFPluginGUI_HypothesisCreator::onRemoveMap() mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN); } -CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry) -{ - SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen(); - SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy(); - CORBA::Object_var obj; - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() ); - if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) { - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - CORBA::String_var aVal = anIOR->Value(); - obj = myStudy->ConvertIORToObject(aVal); - } - return obj; -} - -void BLSURFPluginGUI_HypothesisCreator::onItemClicked(QTableWidgetItem * item) -{ - 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 ); - double phySize = that->mySMPMap[entry].toDouble(); - double infDist = that->myAttDistMap[entry]; - QString attEntry = that->myATTMap[entry]; - CORBA::Object_var attObj = entryToObject(attEntry); - - myAttSelWdg->SetObject(attObj); - myAttSizeSpin->setValue(phySize); - myAttDistSpin->setValue(infDist); - } - else { - myAttractorGroup->setChecked( false ); - } - CORBA::Object_var obj = entryToObject(entry); - double constDist = that->myDistMap[entry]; - - myGeomSelWdg->SetObject(obj); - mySmpDistSpin->setValue(constDist); - } -} - void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(int row,int col) { MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSetSizeMap("<< row << "," << col << ")"); @@ -2436,7 +2420,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anOb 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( 0 ); + mySizeMapTable->item( row, SMP_DIST_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled ); mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN ); mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN ); mySizeMapTable->resizeColumnToContents( SMP_DIST_COLUMN ); @@ -2449,19 +2433,6 @@ void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anOb } } -int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){ - QString entryForChecking; - int endRow = mySizeMapTable->rowCount()-1; - int row = 0; - entryForChecking = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text(); - while (entry != entryForChecking && row <= endRow){ - row++; - entryForChecking = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text(); - } - MESSAGE("BLSURFPluginGUI_HypothesisCreator::findRowFromEntry; row = "<rowCount(); int rowToChange; - if (!that->mySMPMap.contains(shapeEntry)) { + 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 ); @@ -2509,7 +2480,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF 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::ItemIsEditable |Qt::ItemIsEnabled); + mySizeMapTable->item( row, SMP_DIST_COLUMN )->setFlags( Qt::ItemIsSelectable |Qt::ItemIsEnabled); rowToChange = row; } // if (that->mySMPMap[shapeEntry] != "__TO_DELETE__") { @@ -2528,6 +2499,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertAttractor(GEOM::GEOM_Object_var aF 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 ); mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN ); mySizeMapTable->resizeColumnToContents( SMP_SIZEMAP_COLUMN ); @@ -2723,4 +2695,32 @@ LightApp_SelectionMgr* BLSURFPluginGUI_HypothesisCreator::selectionMgr() return 0; } +CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry) +{ + SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen(); + SALOMEDS::Study_ptr myStudy = smeshGen_i->GetCurrentStudy(); + CORBA::Object_var obj; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() ); + if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) { + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + CORBA::String_var aVal = anIOR->Value(); + obj = myStudy->ConvertIORToObject(aVal); + } + return obj; +} + +int BLSURFPluginGUI_HypothesisCreator::findRowFromEntry(QString entry){ + QString entryForChecking; + int endRow = mySizeMapTable->rowCount()-1; + int row = 0; + entryForChecking = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text(); + while (entry != entryForChecking && row <= endRow){ + row++; + entryForChecking = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text(); + } + MESSAGE("BLSURFPluginGUI_HypothesisCreator::findRowFromEntry; row = "<