]> SALOME platform Git repositories - plugins/blsurfplugin.git/commitdiff
Salome HOME
Merge from V6_main
authorgdd <gdd>
Tue, 22 Mar 2011 17:18:47 +0000 (17:18 +0000)
committergdd <gdd>
Tue, 22 Mar 2011 17:18:47 +0000 (17:18 +0000)
src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx
src/GUI/BLSURFPluginGUI_HypothesisCreator.h

index e9274e647952ad8ed59700cc4ec532a8709ba0d1..1e40b89c89d325aa789b70e931b2e8bad7db7baa 100644 (file)
@@ -801,7 +801,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   QGridLayout* anSmpLayout = new QGridLayout(mySmpGroup);
   // Table
   mySizeMapTable = new QTreeWidget( mySmpGroup );
-  mySizeMapTable ->setMinimumWidth(300);
+  mySizeMapTable ->setMinimumWidth(250);
   // tab widget
   smpTab = new QTabWidget( mySmpGroup );
   smpTab->setTabShape( QTabWidget::Rounded );
@@ -851,6 +851,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   removeMapButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
   addMapButton = new QPushButton(tr("BLSURF_SM_ADD"),mySmpGroup);
   modifyMapButton = new QPushButton(tr("BLSURF_SM_MODIFY"),mySmpGroup);
+  modifyMapButton->setEnabled(false);
   
   // Attractor GroupBox
   //myAttractorGroup = new QGroupBox(tr("BLSURF_SM_ATTRACTOR"),mySmpGroup);
@@ -876,8 +877,10 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   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);
+  myGeomSelWdg1->AvoidSimultaneousSelection(myGeomSelWdg2);
   
   // Initialization of widgets
 //   myAttDistSpin->hide();
@@ -1068,7 +1071,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
 
   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( 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() ) );
@@ -1085,12 +1088,14 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   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 (QTreeWidgetItem *, int)),this,SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
-//   connect( myGeomSelWdg2,        SIGNAL( contentModified() ),           this,         SLOT( onMapGeomContentModified() ) );
+  connect( mySizeMapTable,      SIGNAL( itemClicked (QTreeWidgetItem *, int)),this,  SLOT( onSmpItemClicked(QTreeWidgetItem *, int) ) );
+  connect( myGeomSelWdg2,       SIGNAL( contentModified() ),           this,         SLOT( onMapGeomContentModified() ) );
+  connect( myGeomSelWdg1,       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( mySizeMapTable,      SIGNAL( itemChanged (QTreeWidgetItem *, int)),this,  SLOT( onSetSizeMap(QTreeWidgetItem *, int) ) );
   connect( myAttractorCheck,    SIGNAL( stateChanged ( int )),         this,         SLOT( onAttractorClicked( int ) ) );
   connect( myConstSizeCheck,    SIGNAL( stateChanged ( int )),         this,         SLOT( onConstSizeClicked( int ) ) );
+  connect( smpTab,              SIGNAL( currentChanged ( int )),       this,         SLOT( onSmpTabChanged( int ) ) );
 
   // Enforced vertices
   connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this,  SLOT( synchronizeCoords() ) );
@@ -2304,28 +2309,28 @@ void BLSURFPluginGUI_HypothesisCreator::onDeleteOption()
 // *** BEGIN SIZE MAP ***
 // **********************
 
-// 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::onMapGeomContentModified()
+{
+  BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
+  
+  if ( myGeomSelWdg2->IsObjectSelected() ){ 
+    mySMapObject = myGeomSelWdg2->GetObject< GEOM::GEOM_Object >(0);
+  }
+  else if ( myGeomSelWdg1->IsObjectSelected() ){
+    mySMapObject = myGeomSelWdg1->GetObject< GEOM::GEOM_Object >(0);
+  }
+  std::string entry = (string) mySMapObject->GetStudyEntry();
+  QString qEntry = QString::fromStdString(entry);
+  if (that->mySMPMap.contains(qEntry) && that->mySMPMap[qEntry] != "__TO_DELETE__" ) {  
+    addMapButton->setEnabled(false);
+    modifyMapButton->setEnabled(true);
+  }
+  else{
+    addMapButton->setEnabled(true);
+    modifyMapButton->setEnabled(false);
+  }
+      
+} 
 
 // void BLSURFPluginGUI_HypothesisCreator::onAttractorGroupClicked(bool checked){
 // //   QObjectList grpChildren = myAttractorGroup->children();
@@ -2361,40 +2366,64 @@ void BLSURFPluginGUI_HypothesisCreator::onDeleteOption()
 
 void BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked(QTreeWidgetItem * item, int col)
 { 
   MESSAGE("BLSURFPluginGUI_HypothesisCreator::onSmpItemClicked("<<col<<")")
   BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
   if (col == SMP_SIZEMAP_COLUMN){
     QString entry   = item->data( SMP_ENTRY_COLUMN, Qt::EditRole ).toString();
+    if (!mySMPMap.contains(entry))
+      return;
     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();
+    if (sizeMap.startsWith("Attractor") || sizeMap.startsWith("Constant")){  // ADVANCED MAPS
+      smpTab->setCurrentIndex(ATT_TAB);         // Change Tab
+      double phySize = that->mySMPMap[entry].toDouble();  // Retrieve values of the selected item in the current tab widgets
       double infDist = that->myAttDistMap[entry];
       double constDist = that->myDistMap[entry];
       QString attEntry = that->myATTMap[entry];
       CORBA::Object_var attObj = entryToObject(attEntry);
+      myGeomSelWdg2->SetObject(obj); 
       myAttSelWdg->SetObject(attObj);
       myAttSizeSpin->setValue(phySize);
       if (sizeMap.startsWith("Attractor")){    
        myAttDistSpin->setValue(infDist);
         myAttractorCheck->setChecked(true);
       }
+      else {
+       myAttractorCheck->setChecked(false);
+      }
       if (sizeMap.startsWith("Constant") || constDist > 1e-12 ){
        myAttDistSpin2->setValue(constDist);
        myConstSizeCheck->setChecked(true);
       }
+      else{
+       myConstSizeCheck->setChecked(false);
+      }
     }
-    else {
-      smpTab->setCurrentIndex(SMP_STD_TAB); 
+    else {                                                                   // CLASSIC MAPS
+      smpTab->setCurrentIndex(SMP_STD_TAB);  // Change Tab
+      myGeomSelWdg1->SetObject(obj);        // Retrieve values of the selected item in the current tab widgets
       if (!sizeMap.startsWith("def")){
        mySmpSizeSpin->setValue(that->mySMPMap[entry].toDouble()); 
 //       myAttractorGroup->setChecked( false );
       }
     }  
-  }
+  } 
+}
+
+void BLSURFPluginGUI_HypothesisCreator::onSmpTabChanged(int tab)
+{
+  myAttDistSpin->setValue(0.);           // Reinitialize widgets 
+  myAttSizeSpin->setValue(0.);
+  myAttDistSpin2->setValue(0.);
+  mySmpSizeSpin->setValue(0.); 
+  myGeomSelWdg1->deactivateSelection();
+  myGeomSelWdg2->deactivateSelection();
+  myAttSelWdg->deactivateSelection();
+  myGeomSelWdg1->SetObject(CORBA::Object::_nil());
+  myGeomSelWdg2->SetObject(CORBA::Object::_nil());
+  myAttSelWdg->SetObject(CORBA::Object::_nil());
+  myAttractorCheck->setChecked(false);
+  myConstSizeCheck->setChecked(false);
 }
 
 void BLSURFPluginGUI_HypothesisCreator::onAttractorClicked(int state)
@@ -2497,8 +2526,8 @@ void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int
       return;
     if (that->mySMPMap.contains(entry))
       if (that->mySMPMap[entry] == sizeMap 
-       || sizeMap.startsWith("Attractor :") 
-       || sizeMap.startsWith("Const.") ){
+       || sizeMap.startsWith("Attractor") 
+       || sizeMap.startsWith("Constant") ){
         return;
       }
 //     QColor* bgColor = new QColor("white");
@@ -2506,7 +2535,7 @@ void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int
     
     if (! sizeMap.isEmpty()) {
       that->mySMPMap[entry] = sizeMap;
-  //    sizeMapValidationFromRow(row); // TODO utiliser sizempavalidationfromitem
+      sizeMapValidationFromEntry(entry); 
 //       if (! sizeMapValidationFromRow(row)) {
 //         bgColor->setRgb(255,0,0);
 //         fgColor->setRgb(255,255,255);
@@ -2514,8 +2543,6 @@ void BLSURFPluginGUI_HypothesisCreator::onSetSizeMap(QTreeWidgetItem* item, int
     }
     else {
       MESSAGE("Size map empty: reverse to precedent value" );
-    }
-    if (sizeMap.isEmpty()) {
       item->setData(SMP_SIZEMAP_COLUMN, Qt::EditRole, QVariant(that->mySMPMap[entry]) );
     }
 //     that->mySizeMapTable->item(row, SMP_NAME_COLUMN)->setBackground(QBrush(*bgColor));
@@ -2546,9 +2573,13 @@ void BLSURFPluginGUI_HypothesisCreator::onAddMap()
   myAttDistSpin->setValue(0.);
   myAttSizeSpin->setValue(0.);
   myAttDistSpin2->setValue(0.);
+  mySmpSizeSpin->setValue(0.);
   myGeomSelWdg1->deactivateSelection();
   myGeomSelWdg2->deactivateSelection();
   myAttSelWdg->deactivateSelection();
+  myGeomSelWdg1->SetObject(CORBA::Object::_nil());
+  myGeomSelWdg2->SetObject(CORBA::Object::_nil());
+  myAttSelWdg->SetObject(CORBA::Object::_nil());
 //   mySmpDistSpin->setValue(0.);
 //   mySmpSizeSpin->setValue(0.);
 }
@@ -2574,9 +2605,13 @@ void BLSURFPluginGUI_HypothesisCreator::onModifyMap()
   myAttDistSpin->setValue(0.);
   myAttSizeSpin->setValue(0.);
   myAttDistSpin2->setValue(0.);
+  mySmpSizeSpin->setValue(0.);
   myGeomSelWdg1->deactivateSelection();
   myGeomSelWdg2->deactivateSelection();
   myAttSelWdg->deactivateSelection();
+  myGeomSelWdg1->SetObject(CORBA::Object::_nil());
+  myGeomSelWdg2->SetObject(CORBA::Object::_nil());
+  myAttSelWdg->SetObject(CORBA::Object::_nil());
 }
 
 void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anObject, bool modify)
@@ -2606,7 +2641,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anOb
   QTreeWidgetItem* item = new QTreeWidgetItem();
   if (modify){
     int rowToChange = findRowFromEntry(shapeEntry);
-    item = mySizeMapTable->takeTopLevelItem( rowToChange );
+    item = mySizeMapTable->topLevelItem( rowToChange );
   }
   else{
     if (that->mySMPMap.contains(shapeEntry)) {  
@@ -2624,9 +2659,9 @@ void BLSURFPluginGUI_HypothesisCreator::insertElement(GEOM::GEOM_Object_var anOb
   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_NAME_COLUMN );
+  mySizeMapTable->resizeColumnToContents( SMP_ENTRY_COLUMN );
   mySizeMapTable->clearSelection();
 //   mySizeMapTable->scrollToItem( mySizeMapTable->item( row  , SMP_SIZEMAP_COLUMN ) ); //TODO voir si cette option est utile
 
index eaa573ea741088e8bf5c698cda6bd5b9e3539a8d..454a41b2f194116740eeb01e5953c751a0262ea4 100644 (file)
@@ -194,9 +194,10 @@ protected slots:
   void                onOptionChosenInPopup( QAction* );
 //  void                onAddAttractor();
 //  void                onMapSelectionActivated();
-//   void                onMapGeomContentModified();
+  void                onMapGeomContentModified();
 //   void                onAttractorGroupClicked(bool);
   void                onSmpItemClicked( QTreeWidgetItem *, int );
+  void                onSmpTabChanged(int);
   void                onAttractorClicked(int);
   void                onConstSizeClicked(int);
   void                onAddMap();