Salome HOME
Merge from V5_1_3_BR branch (07/12/09)
[modules/geom.git] / src / EntityGUI / EntityGUI.cxx
index 8bdee4ae6c135be6223b465e3881cfcdf18abd1b..25e0103f68eef9f2dacaf28e85e3a2316509c81f 100644 (file)
@@ -1,55 +1,44 @@
-//  GEOM GEOMGUI : GUI for Geometry component
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  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 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 
-// 
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  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 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
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// GEOM GEOMGUI : GUI for Geometry component
+// File   : EntityGUI.cxx
+// Author : Damien COQUERET, Open CASCADE S.A.S.
 //
-//  File   : EntityGUI.cxx
-//  Author : Damien COQUERET
-//  Module : GEOM
-//  $Header$
-
 #include "EntityGUI.h"
-#include "GeometryGUI.h"
-#include "GEOM_AssemblyBuilder.h"
-
-#include "SUIT_Desktop.h"
-#include "SUIT_Session.h"
-#include "SUIT_ViewWindow.h"
-#include "OCCViewer_ViewModel.h"
-#include "OCCViewer_ViewManager.h"
-#include "SalomeApp_Study.h"
-#include "SalomeApp_Tools.h"
-#include "SalomeApp_Application.h"
-
-#include <TopoDS_Compound.hxx>
-#include <BRep_Builder.hxx>
-#include <TopExp_Explorer.hxx>
 
-#include "EntityGUI_SketcherDlg.h" // Sketcher
-#include "EntityGUI_SubShapeDlg.h" // Method SUBSHAPE
+#include <GeometryGUI.h>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewWindow.h>
+#include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewManager.h>
+#include <SalomeApp_Study.h>
+#include <SalomeApp_Application.h>
 
-#include "utilities.h"
+#include <TopoDS_Shape.hxx>
 
-using namespace boost;
-using namespace std;
+#include "EntityGUI_SketcherDlg.h" // Sketcher
+#include "EntityGUI_3DSketcherDlg.h" // Sketcher
+#include "EntityGUI_SubShapeDlg.h" // Method SUBSHAPE
 
 //=======================================================================
 // function : EntityGUI()
@@ -57,8 +46,8 @@ using namespace std;
 //=======================================================================
 EntityGUI::EntityGUI( GeometryGUI* parent ) :  GEOMGUI( parent )
 {
-  mySimulationShape1 = new AIS_Shape(TopoDS_Shape());
-  mySimulationShape2 = new AIS_Shape(TopoDS_Shape());
+  mySimulationShape1 = new AIS_Shape( TopoDS_Shape() );
+  mySimulationShape2 = new AIS_Shape( TopoDS_Shape() );
 }
 
 //=======================================================================
@@ -74,7 +63,7 @@ EntityGUI::~EntityGUI()
 // function : OnGUIEvent()
 // purpose  : 
 //=======================================================================
-bool EntityGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
+bool EntityGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
 {
   SalomeApp_Application* app = getGeometryGUI()->getApp();
   if ( !app ) return false;
@@ -82,22 +71,24 @@ bool EntityGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
   getGeometryGUI()->EmitSignalDeactivateDialog();
   QDialog* aDlg = NULL;
 
-  switch (theCommandID)
-  {
-    case 404: // SKETCHER
-      getGeometryGUI()->ActiveWorkingPlane();
-      aDlg = new EntityGUI_SketcherDlg(getGeometryGUI(), parent, "");
-      break;
-    case 407: // EXPLODE : use ic
-      aDlg = new EntityGUI_SubShapeDlg(getGeometryGUI(), parent, "");
-      break;
-    default:
-      app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
-      break;
+  switch ( theCommandID ) {
+  case 404: // SKETCHER
+    getGeometryGUI()->ActiveWorkingPlane();
+    aDlg = new EntityGUI_SketcherDlg( getGeometryGUI(), parent );
+    break;
+  case 405: // 3D SKETCHER
+    aDlg = new EntityGUI_3DSketcherDlg( getGeometryGUI(), parent );
+    break;
+  case 407: // EXPLODE : use ic
+    aDlg = new EntityGUI_SubShapeDlg( getGeometryGUI(), parent );
+    break;
+  default:
+    app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
+    break;
   }
   if ( aDlg )
     aDlg->show();
-
+  
   return true;
 }
 
@@ -106,49 +97,48 @@ bool EntityGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
 // function : DisplaySimulationShape() 
 // purpose  : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape
 //=====================================================================================
-void EntityGUI::DisplaySimulationShape(const TopoDS_Shape& S1, const TopoDS_Shape& S2
+void EntityGUI::DisplaySimulationShape( const TopoDS_Shape& S1, const TopoDS_Shape& S2 
 {
   SalomeApp_Application* app = getGeometryGUI()->getApp();
   if ( !app ) return;
 
   SUIT_ViewManager* aVM = app->desktop()->activeWindow()->getViewManager();
-  if (aVM->getType() != OCCViewer_Viewer::Type())
+  if ( aVM->getType() != OCCViewer_Viewer::Type() )
     return;
 
-  OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)aVM)->getOCCViewer();
+  OCCViewer_Viewer* v3d = ( (OCCViewer_ViewManager*)aVM )->getOCCViewer();
   Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
   try {
-    if (!S1.IsNull()) {
+    if ( !S1.IsNull() ) {
       /* erase any previous */
-      ic->Erase(mySimulationShape1, Standard_True, Standard_False);
-      ic->ClearPrs(mySimulationShape1);
+      ic->Erase( mySimulationShape1, Standard_True, Standard_False );
+      ic->ClearPrs( mySimulationShape1 );
 
-      mySimulationShape1 = new AIS_Shape(TopoDS_Shape());
-      mySimulationShape1->Set(S1);
-      mySimulationShape1->SetColor(Quantity_NOC_RED);
+      mySimulationShape1 = new AIS_Shape( TopoDS_Shape() );
+      mySimulationShape1->Set( S1 );
+      mySimulationShape1->SetColor( Quantity_NOC_RED );
 
-      ic->Deactivate(mySimulationShape1);
-      ic->Display(mySimulationShape1, Standard_False);
+      ic->Deactivate( mySimulationShape1 );
+      ic->Display( mySimulationShape1, Standard_False );
       mySimulationShape1->UnsetColor();
     }
-    if (!S2.IsNull()) {
-      ic->Erase(mySimulationShape2, Standard_True, Standard_False);
-      ic->ClearPrs(mySimulationShape2);
+    if ( !S2.IsNull() ) {
+      ic->Erase( mySimulationShape2, Standard_True, Standard_False );
+      ic->ClearPrs( mySimulationShape2 );
 
-      mySimulationShape2 = new AIS_Shape(TopoDS_Shape());
-      mySimulationShape2->Set(S2);
-      mySimulationShape2->SetColor(Quantity_NOC_VIOLET);
+      mySimulationShape2 = new AIS_Shape( TopoDS_Shape() );
+      mySimulationShape2->Set( S2 );
+      mySimulationShape2->SetColor( Quantity_NOC_VIOLET );
 
-      ic->Deactivate(mySimulationShape2);
-      ic->Display(mySimulationShape2, Standard_False);
+      ic->Deactivate( mySimulationShape2 );
+      ic->Display( mySimulationShape2, Standard_False );
       mySimulationShape2->UnsetColor();
     }
     ic->UpdateCurrentViewer();
   }
-  catch(Standard_Failure) {
-    MESSAGE("Exception catched in EntityGUI::DisplaySimulationShape ");
+  catch( Standard_Failure ) {
+    MESSAGE( "Exception catched in EntityGUI::DisplaySimulationShape" );
   } 
-  return;
 }
 
 //==================================================================================
@@ -161,22 +151,25 @@ void EntityGUI::EraseSimulationShape()
   if ( !app ) return;
 
   // get all view windows at the desktop
-  QPtrList<SUIT_ViewWindow> aWndLst = app->desktop()->windows();
+  QList<SUIT_ViewWindow*> aWndLst = app->desktop()->windows();
   //get all view windows, which belong to the active study
-  QPtrList<SUIT_ViewWindow> aWndLstAS;
+  QList<SUIT_ViewWindow*> aWndLstAS;
   SUIT_ViewWindow* vw;
-  for ( vw = aWndLst.first(); vw; vw = aWndLst.next() )
+
+  QListIterator<SUIT_ViewWindow*> itWL( aWndLst );
+  while ( itWL.hasNext() && ( vw = itWL.next() ) )
     if ( vw->getViewManager()->study() == app->activeStudy() )
       aWndLstAS.append( vw );
 
-  for ( vw = aWndLstAS.first(); vw; vw = aWndLstAS.next() ) {
+  QListIterator<SUIT_ViewWindow*> itWLAS( aWndLstAS );
+  while ( itWLAS.hasNext() && ( vw = itWLAS.next() ) ) {
     if ( vw->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
-      OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(vw->getViewManager()))->getOCCViewer();
+      OCCViewer_Viewer* v3d = ( (OCCViewer_ViewManager*)( vw->getViewManager() ) )->getOCCViewer();
       Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
-      ic->Erase(mySimulationShape1, Standard_True, Standard_False);
-      ic->ClearPrs(mySimulationShape1);
-      ic->Erase(mySimulationShape2, Standard_True, Standard_False);
-      ic->ClearPrs(mySimulationShape2);
+      ic->Erase( mySimulationShape1, Standard_True, Standard_False );
+      ic->ClearPrs( mySimulationShape1 );
+      ic->Erase( mySimulationShape2, Standard_True, Standard_False );
+      ic->ClearPrs( mySimulationShape2 );
       ic->UpdateCurrentViewer();
     } 
   }
@@ -186,7 +179,7 @@ void EntityGUI::EraseSimulationShape()
 // function : SObjectExist()
 // purpose  :
 //=====================================================================================
-bool EntityGUI::SObjectExist(const _PTR(SObject)& theFatherObject, const char* IOR)
+bool EntityGUI::SObjectExist( const _PTR(SObject)& theFatherObject, const char* IOR )
 {
   SalomeApp_Application* app = getGeometryGUI()->getApp();
   if ( !app ) return false;
@@ -194,20 +187,20 @@ bool EntityGUI::SObjectExist(const _PTR(SObject)& theFatherObject, const char* I
   if ( !appStudy ) return false;
 
   _PTR(Study) aStudy = appStudy->studyDS();
-  _PTR(ChildIterator) it ( aStudy->NewChildIterator(theFatherObject) );
+  _PTR(ChildIterator) it ( aStudy->NewChildIterator( theFatherObject ) );
   _PTR(SObject) RefSO;
   _PTR(GenericAttribute) anAttr;
-  for(; it->More();it->Next()) {
+  for ( ; it->More();it->Next() ) {
     _PTR(SObject) SO ( it->Value() );
-    if(SO->FindAttribute(anAttr, "AttributeIOR")) {
+    if ( SO->FindAttribute( anAttr, "AttributeIOR" ) ) {
       _PTR(AttributeIOR) anIOR ( anAttr  );
-      if(strcmp( anIOR->Value().c_str(), IOR ) == 0)
+      if ( strcmp( anIOR->Value().c_str(), IOR ) == 0 )
        return true;
     }
-    if(SO->ReferencedObject(RefSO)) {
-      if(RefSO->FindAttribute(anAttr, "AttributeIOR")) {
+    if ( SO->ReferencedObject( RefSO ) ) {
+      if ( RefSO->FindAttribute( anAttr, "AttributeIOR" ) ) {
         _PTR(AttributeIOR) anIOR ( anAttr );
-       if(strcmp(anIOR->Value().c_str(), IOR) == 0)
+       if ( strcmp( anIOR->Value().c_str(), IOR ) == 0 )
          return true;
       }
     }
@@ -221,7 +214,9 @@ bool EntityGUI::SObjectExist(const _PTR(SObject)& theFatherObject, const char* I
 //=====================================================================================
 extern "C"
 {
-GEOM_ENTITYGUI_EXPORT
+#ifdef WIN32
+  __declspec( dllexport )
+#endif
   GEOMGUI* GetLibGUI( GeometryGUI* parent )
   {
     return new EntityGUI( parent );