Salome HOME
Updated for PAL14857.
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI.cxx
index 4efbfbbad598f31f00f9fc3c39dac89795f1c80c..39022be14fe8b2d8cdf4d9877ce83a57955e67da 100644 (file)
@@ -46,6 +46,7 @@
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
 #include <LightApp_SelectionMgr.h>
+#include <GEOMImpl_Types.hxx>
 
 #include <SALOME_ListIteratorOfListIO.hxx>
 #include <SALOME_Prs.h>
@@ -154,6 +155,46 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
        Export();
        break;
       }
+    case 2171: // POPUP VIEWER - SELECT ONLY - VERTEX
+      {
+       OnSelectOnly( GEOM_POINT );
+       break;
+      }
+    case 2172: // POPUP VIEWER - SELECT ONLY - EDGE
+      {
+       OnSelectOnly( GEOM_EDGE );
+       break;
+      }
+    case 2173: // POPUP VIEWER - SELECT ONLY - WIRE
+      {
+       OnSelectOnly( GEOM_WIRE );
+       break;
+      }
+    case 2174: // POPUP VIEWER - SELECT ONLY - FACE
+      {
+       OnSelectOnly( GEOM_FACE );
+       break;
+      }
+    case 2175: // POPUP VIEWER - SELECT ONLY - SHELL
+      {
+       OnSelectOnly( GEOM_SHELL );
+       break;
+      }
+    case 2176: // POPUP VIEWER - SELECT ONLY - SOLID
+      {
+       OnSelectOnly( GEOM_SOLID );
+       break;
+      }
+    case 2177: // POPUP VIEWER - SELECT ONLY - COMPOUND
+      {
+       OnSelectOnly( GEOM_COMPOUND );
+       break;
+      }
+    case 2178: // POPUP VIEWER - SELECT ONLY - SELECT ALL
+      {
+       OnSelectOnly( GEOM_ALLOBJECTS );
+       break;
+      }    
     case 411: // SETTINGS - ADD IN STUDY
       {
        // SAN -- TO BE REMOVED !!!
@@ -309,23 +350,12 @@ void GEOMToolsGUI::OnEditDelete()
           _PTR(ChildIterator) it (aStudy->NewChildIterator(aGeom));
           for ( it->InitEx( true ); it->More(); it->Next() ) {
              _PTR(SObject) chobj (it->Value());
-             CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(chobj);
-             GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
-             if( CORBA::is_nil(geomObj) ) 
-                continue;
-             GEOM::ListOfGO_var list = geomObj->GetDependency();
-             if( list->length() > 1 )
-               for(int i = 0; i < list->length(); i++ ){
-                 CORBA::Object_var corbaObj_rem = GeometryGUI::ClientSObjectToObject(obj);
-                 GEOM::GEOM_Object_var geomObj_rem = GEOM::GEOM_Object::_narrow( corbaObj_rem );
-                if( list[i]->_is_equivalent( geomObj_rem ) ){
-                   SUIT_MessageBox::warn1 ( app->desktop(),
-                                           QObject::tr("WRN_WARNING"),
-                                           QObject::tr("DEP_OBJECT"),
-                                           QObject::tr("BUT_OK") );
-                  return;
-               }
-              }
+            if(CheckSubObjectInUse(chobj, obj, aStudy)) return;
+            //check subobjects
+            for (_PTR(ChildIterator) it (aStudy->NewChildIterator(obj)); it->More(); it->Next()) {
+              _PTR(SObject) child (it->Value());
+              if(CheckSubObjectInUse( chobj, child, aStudy)) return;
+            }
           }
 
           RemoveObjectWithChildren(obj, aStudy, views, disp);
@@ -470,7 +500,6 @@ bool GEOMToolsGUI::Import()
     anObj = aInsOp->Import(fileN, fileT);
 
     if ( !anObj->_is_nil() && aInsOp->IsDone() ) {
-      anObj->SetName(GEOMBase::GetDefaultName(QObject::tr("GEOM_IMPORT")).latin1());
       QString aPublishObjName =
         GEOMBase::GetDefaultName(SUIT_Tools::file(fileName, /*withExten=*/true));
 
@@ -681,6 +710,54 @@ void GEOMToolsGUI::RemoveObjectWithChildren(_PTR(SObject) obj,
   }
 }
 
+//=====================================================================================
+// function : CheckSubObjectInUse
+// purpose  : to be used by OnEditDelete() method
+//=====================================================================================
+bool GEOMToolsGUI::CheckSubObjectInUse(_PTR(SObject) checkobj,
+                                      _PTR(SObject) remobj,
+                                       _PTR(Study) aStudy)
+{
+  CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(checkobj);
+  GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
+  if( CORBA::is_nil(geomObj) ) 
+    return false;
+
+  GEOM::ListOfGO_var list = geomObj->GetDependency();
+  if( list->length() > 1 )
+    for(int i = 0; i < list->length(); i++ ){
+      CORBA::Object_var corbaObj_rem = GeometryGUI::ClientSObjectToObject(remobj);
+      GEOM::GEOM_Object_var geomObj_rem = GEOM::GEOM_Object::_narrow( corbaObj_rem );
+      if( list[i]->_is_equivalent( geomObj_rem ) ){
+       SalomeApp_Application* app =
+         dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+
+       SUIT_MessageBox::warn1 ( app->desktop(),
+                                QObject::tr("WRN_WARNING"),
+                                QObject::tr("DEP_OBJECT"),
+                                QObject::tr("BUT_OK") );
+       return true;
+      }
+    }
+
+  return false;
+}
+
+//=================================================================================
+// function : deactivate()
+// purpose  : Called when GEOM component is deactivated
+//=================================================================================
+void GEOMToolsGUI::deactivate()
+{
+  SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+  if ( app ) {
+    SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+    GEOM_Displayer aDisp (appStudy);
+    aDisp.GlobalSelection();
+    getGeometryGUI()->setLocalSelectionMode(GEOM_ALLOBJECTS);
+  }
+}
+
 //=====================================================================================
 // EXPORTED METHODS
 //=====================================================================================