]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
IPAL21396 Quadrangle parameters Hypothesis Construction Bugs.
authordmv <dmv@opencascade.com>
Tue, 27 Apr 2010 11:57:40 +0000 (11:57 +0000)
committerdmv <dmv@opencascade.com>
Tue, 27 Apr 2010 11:57:40 +0000 (11:57 +0000)
src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx
src/StdMeshersGUI/StdMeshersGUI_SubShapeSelectorWdg.cxx

index 05d4152eb7ec6616ad1d93d7d30edb8a805c080a..8fd24f3510ec063b15f3fff65dcbc086f212bed2 100644 (file)
@@ -1000,12 +1000,14 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const
       anEntry = h->GetObjectEntry();
     aDirectionWidget->SetGeomShapeEntry( anEntry );
     aDirectionWidget->SetMainShapeEntry( aMainEntry );
-    SMESH::long_array_var aVec = new SMESH::long_array;
-    int vertID = h->GetTriaVertex();
-    if(vertID>0) {
-      aVec->length(1);
-      aVec[0] = vertID;
-      aDirectionWidget->SetListOfIDs( aVec );
+    if ( !isCreation() ) {
+      SMESH::long_array_var aVec = new SMESH::long_array;
+      int vertID = h->GetTriaVertex();
+      if(vertID>0) {
+        aVec->length(1);
+        aVec[0] = vertID;
+        aDirectionWidget->SetListOfIDs( aVec );
+      }
     }
     aDirectionWidget->showPreview( true );
     customWidgets()->append ( aDirectionWidget );
index 6adcbc1fde5658102fdd5868ae61177b8485652d..4bc2b7549dbcf411263af80a6b69815b14d6e86f 100644 (file)
@@ -143,6 +143,9 @@ void StdMeshersGUI_SubShapeSelectorWdg::init()
   myListOfIDs.clear();
   mySelectedIDs.clear();
 
+  myAddButton->setEnabled( false );
+  myRemoveButton->setEnabled( false );
+
   mySMESHGUI     = SMESHGUI::GetSMESHGUI();
   mySelectionMgr = SMESH::GetSelectionMgr( mySMESHGUI );
   mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
@@ -196,63 +199,76 @@ void StdMeshersGUI_SubShapeSelectorWdg::SelectionIntoArgument()
   mySelectionMgr->selectedObjects( aList );
   int nbSel = aList.Extent();
 
-  if (nbSel < 1)
-    return;
-
-  SALOME_ListIteratorOfListIO anIt (aList);
+  if (nbSel > 0) {
+    SALOME_ListIteratorOfListIO anIt (aList);
     
-  for ( ; anIt.More(); anIt.Next()) { // Loop on selected objects
-    Handle(SALOME_InteractiveObject) IO = anIt.Value();
-
-    GEOM::GEOM_Object_var aGeomObj = GetGeomObjectByEntry( IO->getEntry() );  
-    if ( !CORBA::is_nil( aGeomObj ) ) { // Selected Object From Study
-      GEOM::GEOM_Object_ptr aGeomFatherObj = aGeomObj->GetMainShape();
-      QString aFatherEntry = "";
-      QString aMainFatherEntry = "";
-      TopoDS_Shape shape;
-      if ( !CORBA::is_nil( aGeomFatherObj ) ) {
-        // Get Main Shape
-        GEOM::GEOM_Object_var aGeomMain = GetGeomObjectByEntry( myEntry );
-        if ( !CORBA::is_nil( aGeomMain ) && aGeomMain->GetType() == 37 ) {  // Main Shape is a Group
-          GEOM::GEOM_Object_ptr aMainFatherObj = aGeomMain->GetMainShape();
-          if ( !CORBA::is_nil( aMainFatherObj ) )
-            aMainFatherEntry = aMainFatherObj->GetStudyEntry();
-        }
-        aFatherEntry = aGeomFatherObj->GetStudyEntry();
-      }
+    for ( ; anIt.More(); anIt.Next()) { // Loop on selected objects
+      Handle(SALOME_InteractiveObject) IO = anIt.Value();
       
-      if ( aFatherEntry != "" && ( aFatherEntry == myEntry || aFatherEntry == aMainFatherEntry ) ) {
-        if ( aGeomObj->GetType() == 37 /*GEOM_GROUP*/ ) { // Selected Group that belongs the main object
-          GEOMBase::GetShape(aGeomObj, shape); 
-          if ( !shape.IsNull() ) {
-            TopExp_Explorer exp( shape, mySubShType );
-            for ( ; exp.More(); exp.Next() ) {
-              int index = myPreviewActor->GetIndexByShape( exp.Current() );
+      GEOM::GEOM_Object_var aGeomObj = GetGeomObjectByEntry( IO->getEntry() );  
+      if ( !CORBA::is_nil( aGeomObj ) ) { // Selected Object From Study
+        GEOM::GEOM_Object_ptr aGeomFatherObj = aGeomObj->GetMainShape();
+        QString aFatherEntry = "";
+        QString aMainFatherEntry = "";
+        TopoDS_Shape shape;
+        if ( !CORBA::is_nil( aGeomFatherObj ) ) {
+          // Get Main Shape
+          GEOM::GEOM_Object_var aGeomMain = GetGeomObjectByEntry( myEntry );
+          if ( !CORBA::is_nil( aGeomMain ) && aGeomMain->GetType() == 37 ) {  // Main Shape is a Group
+            GEOM::GEOM_Object_ptr aMainFatherObj = aGeomMain->GetMainShape();
+            if ( !CORBA::is_nil( aMainFatherObj ) )
+              aMainFatherEntry = aMainFatherObj->GetStudyEntry();
+          }
+          aFatherEntry = aGeomFatherObj->GetStudyEntry();
+        }
+        
+        if ( aFatherEntry != "" && ( aFatherEntry == myEntry || aFatherEntry == aMainFatherEntry ) ) {
+          if ( aGeomObj->GetType() == 37 /*GEOM_GROUP*/ ) { // Selected Group that belongs the main object
+            GEOMBase::GetShape(aGeomObj, shape); 
+            if ( !shape.IsNull() ) {
+              TopExp_Explorer exp( shape, mySubShType );
+              for ( ; exp.More(); exp.Next() ) {
+                int index = myPreviewActor->GetIndexByShape( exp.Current() );
+                if ( index ) {
+                  mySelectedIDs.append( index );
+                  myPreviewActor->HighlightID( index );
+                }
+              }
+            }
+          } else if ( aGeomObj->GetType() == 28 /*GEOM_SUBSHAPE*/  ) {
+            GEOMBase::GetShape(aGeomObj, shape); 
+            if ( !shape.IsNull() && shape.ShapeType() == mySubShType ) {
+              int index = myPreviewActor->GetIndexByShape( shape );
               if ( index ) {
                 mySelectedIDs.append( index );
                 myPreviewActor->HighlightID( index );
               }
             }
           }
-        } else if ( aGeomObj->GetType() == 28 /*GEOM_SUBSHAPE*/  ) {
-          GEOMBase::GetShape(aGeomObj, shape); 
-          if ( !shape.IsNull() && shape.ShapeType() == mySubShType ) {
-            int index = myPreviewActor->GetIndexByShape( shape );
-            if ( index ) {
-              mySelectedIDs.append( index );
-              myPreviewActor->HighlightID( index );
-            }
-          }
         }
+      } else { // Selected Actor from Actor Collection
+        QString anEntry = IO->getEntry();
+        QString str = "_";
+        int index = anEntry.lastIndexOf( str );
+        anEntry.remove(0, index+1);
+        int ind = anEntry.toInt();
+        if ( ind )
+          mySelectedIDs.append( ind );
       }
-    } else { // Selected Actor from Actor Collection
-      QString anEntry = IO->getEntry();
-      QString str = "_";
-      int index = anEntry.lastIndexOf( str );
-      anEntry.remove(0, index+1);
-      int ind = anEntry.toInt();
-      if ( ind )
-        mySelectedIDs.append( ind );
+    }
+  }
+  // update add button
+  myAddButton->setEnabled( myListWidget->count() < myMaxSize && mySelectedIDs.size() > 0 && ( mySelectedIDs.size() <= myMaxSize || myMaxSize == -1 ) );
+
+  //Connect Selected Ids in viewer and dialog's Ids list
+  myListWidget->clearSelection();
+  if ( mySelectedIDs.size() > 0 ) {
+    for (int i = 0; i < mySelectedIDs.size(); i++) {
+      QString anID = QString(" %1").arg( mySelectedIDs.at(i) );
+      QList<QListWidgetItem*> anItems = myListWidget->findItems ( anID, Qt::MatchExactly );
+      QListWidgetItem* item;
+      foreach(item, anItems)
+        item->setSelected(true);
     }
   }
 }
@@ -324,6 +340,9 @@ void StdMeshersGUI_SubShapeSelectorWdg::onListSelectionChanged()
   QListWidgetItem* anItem;
   foreach(anItem, selItems)
     myPreviewActor->HighlightID( anItem->text().toInt() );
+
+  // update remove button
+  myRemoveButton->setEnabled( selItems.size() > 0 );
 }
 
 //=================================================================================
@@ -352,8 +371,7 @@ void StdMeshersGUI_SubShapeSelectorWdg::updateState()
     state = true;
   
   myListWidget->setEnabled( state );
-  myAddButton->setEnabled( state );
-  myRemoveButton->setEnabled( state );
+  myAddButton->setEnabled( mySelectedIDs.size() > 0 );
   
   if (state) {
     myPreviewActor = new SMESH_PreviewActorsCollection();