Salome HOME
Merge from BR_Dev_For_4_0 branch (from tag mergeto_BR_QT4_Dev_17Jan08)
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI.cxx
index 6a14b957104b7f16759eed79f073690c01f8c102..10c901d73ef713ab88372480a472479208fbe4e9 100644 (file)
@@ -1,40 +1,37 @@
-//  GEOM GEOMGUI : GUI for Geometry component
+// GEOM GEOMGUI : GUI for Geometry component
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003  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
 //
+// File   : GEOMBase_Tools.cxx
+// Author : Damien COQUERET, Open CASCADE S.A.S.
 //
-//
-//  File   : GEOMBase_Tools.cxx
-//  Author : Damien COQUERET
-//  Module : GEOM
-//  $Header$
 
 #include "GEOMToolsGUI.h"
+#include "GEOMToolsGUI_DeleteDlg.h"
 
-#include "GeometryGUI.h"
-#include "GEOMBase.h"
-#include "GEOM_Operation.h"
-#include "GEOM_Displayer.h"
+#include <GeometryGUI.h>
+#include <GEOMBase.h>
+#include <GEOM_Operation.h>
+#include <GEOM_Displayer.h>
 
 #include <SUIT_Session.h>
-//#include <SUIT_Application.h>
 #include <SUIT_OverrideCursor.h>
 #include <SUIT_MessageBox.h>
 #include <SUIT_Tools.h>
@@ -71,14 +68,19 @@ typedef QMap<QString, QString> FilterMap;
 static QString getFileName( QWidget*           parent,
                            const QString&     initial,
                            const FilterMap&   filterMap,
+                            const QStringList& filters,
                            const QString&     caption,
                            bool               open,
                            QString&           format )
 {
   static QString lastUsedFilter;
-  QStringList filters;
-  for ( FilterMap::const_iterator it = filterMap.begin(); it != filterMap.end(); ++it )
-    filters.push_back( it.key() );
+  //QStringList filters;
+  QString aBrepFilter;
+  for ( FilterMap::const_iterator it = filterMap.begin(); it != filterMap.end(); ++it ) {
+    //filters.push_back( it.key() );
+    if ( it.key().contains( "BREP", Qt::CaseInsensitive ) )
+      aBrepFilter = it.key();
+  }
 
   SUIT_FileDlg* fd = new SUIT_FileDlg( parent, open, true, true );
   if ( !caption.isEmpty() )
@@ -87,8 +89,14 @@ static QString getFileName( QWidget*           parent,
   if ( !initial.isEmpty() )
     fd->selectFile( initial );
 
-  if ( !lastUsedFilter.isEmpty() && filterMap.contains( lastUsedFilter ) )
+  fd->setFilters( filters );
+  
+  if ( !lastUsedFilter.isEmpty() && filterMap.contains( lastUsedFilter ) ) {
     fd->selectFilter( lastUsedFilter );
+  }
+  else if ( !aBrepFilter.isEmpty() ) {
+    fd->selectFilter( aBrepFilter );
+  }
 
   fd->setFilters( filters );
 
@@ -204,16 +212,6 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
        OnSettingsColor();
        break;
       }
-    case 413: // SETTINGS - ISOS
-      {
-       OnSettingsIsos();
-       break;
-      }
-    case 414: // SETTINGS : STEP VALUE FOR SPIN BOXES
-      {
-       OnSettingsStep();
-       break;
-      }
     case 804: // ADD IN STUDY - POPUP VIEWER
       {
        // SAN -- TO BE REMOVED !!!!
@@ -244,6 +242,16 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
        OnNbIsos();
        break;
       }
+    case 8035: // AUTO COLOR - POPUP VIEWER
+      {
+       OnAutoColor();
+       break;
+      }
+    case 8036: // DISABLE AUTO COLOR - POPUP VIEWER
+      {
+       OnDisableAutoColor();
+       break;
+      }
     case 9024 : // OPEN - OBJBROSER POPUP
       {
        OnOpen();
@@ -289,7 +297,7 @@ void GEOMToolsGUI::OnEditDelete()
        // VSR 17/11/04: check if all objects selected belong to GEOM component --> start
        // modifications of ASV 01.06.05
        QString parentComp = getParentComponent( aStudy, selected );
-  CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
+       CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
        QString geomComp = getParentComponent( aStudy->FindObjectIOR( geomIOR.in() ) );
 
        if ( parentComp != geomComp )  {
@@ -301,11 +309,27 @@ void GEOMToolsGUI::OnEditDelete()
        }
        // VSR 17/11/04: check if all objects selected belong to GEOM component <-- finish
 
-       if ( SUIT_MessageBox::warning( app->desktop(),
-                                      QObject::tr( "GEOM_WRN_WARNING" ),
-                                      QObject::tr( "GEOM_REALLY_DELETE" ),
-                                      QObject::tr( "GEOM_BUT_YES" ),
-                                      QObject::tr( "GEOM_BUT_NO" ), 1 ) != 0 )
+       QStringList aNameList;
+       for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+         Handle(SALOME_InteractiveObject) anIObject = It.Value();
+         QString aName = anIObject->getName();
+         if ( aName != "" && aName[ 0 ] != '*' ) {
+           aNameList.append( aName );
+         
+           _PTR(SObject) obj ( aStudy->FindObjectID( anIObject->getEntry() ) );
+           _PTR(ChildIterator) it ( aStudy->NewChildIterator( obj ) );
+           for ( it->InitEx( true ); it->More(); it->Next() ) {
+             _PTR(SObject) child( it->Value() );
+             QString aName = child->GetName().c_str();
+             if ( aName != "" && aName[ 0 ] != '*' ) {
+               aNameList.append( aName );
+             }
+           }
+         }
+       }
+
+       GEOMToolsGUI_DeleteDlg dlg( app->desktop(), aNameList );
+       if ( !dlg.exec() )
          return;
 
        //      QAD_Operation* op = new SALOMEGUI_ImportOperation(.....);
@@ -361,7 +385,7 @@ void GEOMToolsGUI::OnEditDelete()
           RemoveObjectWithChildren(obj, aStudy, views, disp);
 
          // Remove objects from Study
-         aStudyBuilder->RemoveObject( obj );
+         aStudyBuilder->RemoveObjectWithChildren( obj );
 
          //deleted = true;
        } // MAIN LOOP of selected
@@ -463,15 +487,18 @@ bool GEOMToolsGUI::Import()
 
   // Obtain a list of available import formats
   FilterMap aMap;
+  QStringList filters;
   GEOM::string_array_var aFormats, aPatterns;
   aInsOp->ImportTranslators( aFormats, aPatterns );
 
-  for ( int i = 0, n = aFormats->length(); i < n; i++ )
+  for ( int i = 0, n = aFormats->length(); i < n; i++ ) {
     aMap.insert( (char*)aPatterns[i], (char*)aFormats[i] );
+    filters.push_back( (char*)aPatterns[i] );
+  }
 
   QString fileType;
 
-  QString fileName = getFileName(app->desktop(), "", aMap,
+  QString fileName = getFileName(app->desktop(), "", aMap, filters,
                                  tr("GEOM_MEN_IMPORT"), true, fileType);
 
   if (fileType.isEmpty() )
@@ -568,10 +595,13 @@ bool GEOMToolsGUI::Export()
 
   // Obtain a list of available export formats
   FilterMap aMap;
+  QStringList filters;
   GEOM::string_array_var aFormats, aPatterns;
   aInsOp->ExportTranslators( aFormats, aPatterns );
-  for ( int i = 0, n = aFormats->length(); i < n; i++ )
+  for ( int i = 0, n = aFormats->length(); i < n; i++ ) {
     aMap.insert( (char*)aPatterns[i], (char*)aFormats[i] );
+    filters.push_back( (char*)aPatterns[i] );
+  }
 
   // Get selected objects
   LightApp_SelectionMgr* sm = app->selectionMgr();
@@ -591,7 +621,7 @@ bool GEOMToolsGUI::Export()
       continue;
 
     QString fileType;
-    QString file = getFileName(app->desktop(), QString( IObject->getName() ), aMap,
+    QString file = getFileName(app->desktop(), QString( IObject->getName() ), aMap, filters,
                               tr("GEOM_MEN_EXPORT"), false, fileType);
 
     // User has pressed "Cancel" --> stop the operation
@@ -763,7 +793,9 @@ void GEOMToolsGUI::deactivate()
 //=====================================================================================
 extern "C"
 {
-GEOMTOOLSGUI_EXPORT
+#ifdef WIN32
+  __declspec( dllexport )
+#endif
   GEOMGUI* GetLibGUI( GeometryGUI* parent )
   {
     return new GEOMToolsGUI( parent );