Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/visu.git] / src / VISUGUI / VisuGUI_InputPane.cxx
index 442bc0a15907d9611923a6af446eac2daf6b8367..387a1643350d3ecbf6ea0ed0ad2efb53a333a192 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  VISU VISUGUI : GUI of VISU component
 //  File   : VisuGUI_InputPane.cxx
 //  Author : Oleg UVAROV
@@ -76,8 +77,8 @@ class VisuGUI_ListWidget: public QListWidget
 
 //---------------------------------------------------------------
 VisuGUI_InputPane::VisuGUI_InputPane( VISU::VISUType theType,
-                                     SalomeApp_Module* theModule,
-                                     VisuGUI_Prs3dDlg* theDialog ) :
+                                      SalomeApp_Module* theModule,
+                                      VisuGUI_Prs3dDlg* theDialog ) :
   QGroupBox( theDialog ),
   myModule( theModule ),
   myDialog( theDialog ),
@@ -234,17 +235,19 @@ VisuGUI_InputPane::VisuGUI_InputPane( VISU::VISUType theType,
 //---------------------------------------------------------------
 VisuGUI_InputPane::~VisuGUI_InputPane()
 {
-  LightApp_SelectionMgr* aSelectionMgr = VISU::GetSelectionMgr(myModule);
+  if ( myModule->getApp() ) {
+    LightApp_SelectionMgr* aSelectionMgr = VISU::GetSelectionMgr(myModule);
+    
+    if (myFieldFilter)
+      {
+        aSelectionMgr->removeFilter(myFieldFilter);
+        delete myFieldFilter;
+      }
 
-  if (myFieldFilter)
-  {
-    aSelectionMgr->removeFilter(myFieldFilter);
-    delete myFieldFilter;
+    // Restore initial selection
+    if(isRestoreInitialSelection)
+      aSelectionMgr->setSelectedObjects(mySavedSelection);
   }
-
-  // Restore initial selection
-  if(isRestoreInitialSelection)
-    aSelectionMgr->setSelectedObjects(mySavedSelection);
 }
 
 void VisuGUI_InputPane::SetRestoreInitialSelection(bool on){
@@ -342,7 +345,7 @@ void VisuGUI_InputPane::onListDoubleClicked( QListWidgetItem* theItem )
     {
       QList<QListWidgetItem*> aList = mySelectedGroups->findItems( theItem->text(), Qt::MatchExactly );
       if ( aList.isEmpty() )
-       mySelectedGroups->insertItem( mySelectedGroups->count(), theItem->text()  );
+        mySelectedGroups->insertItem( mySelectedGroups->count(), theItem->text()  );
     }
   else if (aListWidget == mySelectedGroups)
     delete theItem;
@@ -402,20 +405,20 @@ void VisuGUI_InputPane::onSelectionChanged()
     {
       _PTR(SObject) aChildObj = aIter->Value();
       if( !aChildObj )
-       return;
+        return;
 
       if( anEntityName.isNull() )
       {
-       _PTR(SObject) aRefObj;
-       if( aChildObj->ReferencedObject( aRefObj ) )
-         anEntityName = aRefObj->GetName().c_str();
+        _PTR(SObject) aRefObj;
+        if( aChildObj->ReferencedObject( aRefObj ) )
+          anEntityName = aRefObj->GetName().c_str();
       }
 
       VISU::Storable::TRestoringMap aRestoringMap = VISU::Storable::GetStorableMap(aChildObj);
       if( aRestoringMap["myComment"] == "TIMESTAMP" )
       {
-       aTimeStampName = aChildObj->GetName().c_str();
-       myTimeStamps->addItem( aTimeStampName );
+        aTimeStampName = aChildObj->GetName().c_str();
+        myTimeStamps->addItem( aTimeStampName );
       }
     }
 
@@ -554,10 +557,10 @@ void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs )
     for(; anIter != aGroupNames.end(); anIter++){
       const std::string aGroupName = *anIter;
       mySelectedGroups->insertItem(mySelectedGroups->count(), aGroupName.c_str());
-    }      
+    }
+    myUseGroupsGroupBox->setEnabled(true);
   }
   myUseGroupsGroupBox->setChecked(mySelectedGroups->count() > 0);
-  myUseGroupsGroupBox->setEnabled(anIsTimeStampFixed);
 }