Salome HOME
Merge remote branch 'origin/V7_dev' into V8_0_0_BR
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI_ReduceStudyDlg.cxx
index 4bd464a78dac41e4e8b2d45def5de9a2eb6f7d0f..6784a91d6aaa2b471287d870374b46689ce4705f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2014-2015  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -32,7 +32,7 @@
 
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
-#include <SALOME_ListIteratorOfListIO.hxx>
+#include <SALOME_ListIO.hxx>
 
 // Qt includes
 #include <QGridLayout>
@@ -222,9 +222,15 @@ void GEOMToolsGUI_ReduceStudyDlg::createTreeWidget( QTreeWidget* theTreeWidget )
   QTreeWidgetItem * headerItem = new QTreeWidgetItem( columnNames );
   theTreeWidget->setHeaderItem ( headerItem );
   theTreeWidget->header()->moveSection( 1, 0 );
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
   theTreeWidget->header()->setClickable( true );
   theTreeWidget->header()->setMovable( false );
   theTreeWidget->header()->setResizeMode( 1, QHeaderView::ResizeToContents );
+#else
+  theTreeWidget->header()->setSectionsClickable( true );
+  theTreeWidget->header()->setSectionsMovable( false );
+  theTreeWidget->header()->setSectionResizeMode( 1, QHeaderView::ResizeToContents );
+#endif
   theTreeWidget->setSelectionMode( QAbstractItemView::ExtendedSelection );
 }
 
@@ -282,7 +288,10 @@ GEOMToolsGUI_TreeWidgetItem* GEOMToolsGUI_ReduceStudyDlg::addSubObject( QTreeWid
 {
   GEOMToolsGUI_TreeWidgetItem* item;
   if( !theObject->IsMainShape() ) {
-    GEOMToolsGUI_TreeWidgetItem* parentItem = addSubObject( theWidget, theObjects, theObject->GetMainShape() );
+    GEOM::GEOM_Object_var aMainShape = theObject->GetMainShape();
+    if ( CORBA::is_nil( aMainShape ) )
+      return NULL;
+    GEOMToolsGUI_TreeWidgetItem* parentItem = addSubObject( theWidget, theObjects, aMainShape );
     item = findObjectInTree( theWidget, theObject );
     if( !item )
       item = new GEOMToolsGUI_TreeWidgetItem( parentItem, QStringList() << theObject->GetName(), theObject->GetStudyEntry() );
@@ -396,6 +405,13 @@ void GEOMToolsGUI_ReduceStudyDlg::unpublishObjects( std::set<std::string>& theOb
       _PTR(AttributeDrawable) aDrw = aStudyBuilder->FindOrCreateAttribute( obj, "AttributeDrawable" );
       aDrw->SetDrawable( false );
       myDisplayer.EraseWithChildren( new SALOME_InteractiveObject( studyEntry.c_str(), "GEOM", "TEMP_IO" ) );
+      // hide references if any
+      std::vector< _PTR(SObject) > vso = myStudy->FindDependances(obj);
+      for ( int i = 0; i < vso.size(); i++ ) {
+        _PTR(SObject) refObj = vso[i];
+        aDrw = aStudyBuilder->FindOrCreateAttribute( refObj, "AttributeDrawable" );
+        aDrw->SetDrawable( false );
+      }
     }
   }
   myApp->updateObjectBrowser( false );
@@ -439,7 +455,7 @@ void GEOMToolsGUI_ReduceStudyDlg::removeObject( std::string& theStudyEntry )
   _PTR(SObject) obj ( myStudy->FindObjectID( theStudyEntry.c_str() ) );
   if ( obj ) {
     // remove visual properties of the object
-    appStudy->removeObjectFromAll(obj->GetID().c_str());
+    appStudy->removeObjectProperties(obj->GetID().c_str());
     // remove references to this object
     appStudy->deleteReferencesTo( obj );
     // remove objects from study
@@ -641,21 +657,16 @@ void GEOMToolsGUI_ReduceStudyDlg::clickOnOk()
     objectsToBeUnpublished.insert( *iter );
   }
   if( myGroupIntermediates->checkedId() == 2 ) { // remove
-       if( myCBSoftRemoval->isChecked() )
-      for( iter = myListParents.begin(); iter != myListParents.end(); ++iter )
-        objectsToBeRemoved.insert( *iter );
-       else {
-      if ( SUIT_MessageBox::question( this,
-                                      tr( "GEOM_WRN_WARNING" ),
-                                      tr( "GEOM_REDUCE_STUDY_WARNING_DELETE" ),
-                                      QMessageBox::Yes | QMessageBox::No,
-                                      QMessageBox::Yes ) == QMessageBox::Yes ) {
-        for( iter = myListParents.begin(); iter != myListParents.end(); ++iter )
-          objectsToBeRemoved.insert( *iter );
-      }
-      else
-        return;
-       }
+    if( !myCBSoftRemoval->isChecked() && 
+       SUIT_MessageBox::question( this,
+                                  tr( "GEOM_WRN_WARNING" ),
+                                  tr( "GEOM_REDUCE_STUDY_WARNING_DELETE" ),
+                                  QMessageBox::Yes | QMessageBox::No,
+                                  QMessageBox::Yes ) == QMessageBox::No ) {
+      return;
+    }
+    for( iter = myListParents.begin(); iter != myListParents.end(); ++iter )
+      objectsToBeRemoved.insert( *iter );
   }
 
   // Create lists of sub-objects to be removed or to be unpublished
@@ -688,10 +699,11 @@ void GEOMToolsGUI_ReduceStudyDlg::clickOnOk()
 
 //=================================================================================
 // function : clickOnHelp()
-// purpose  : called when Help button was clicked
+// purpose  : called when Help button was clicked to open a help page
 //=================================================================================
 void GEOMToolsGUI_ReduceStudyDlg::clickOnHelp()
 {
+  myApp->onHelpContextModule( "GEOM", "reduce_study_page.html" );
 }
 
 GEOMToolsGUI_TreeWidgetItem::GEOMToolsGUI_TreeWidgetItem( QTreeWidget* view, const QStringList &strings,