Salome HOME
PAL17233: Projection 2D doesn't work (bis)
[modules/geom.git] / src / GEOMBase / GEOMBase.cxx
index 194a81c96d63f86225d10d76414fb41d88f6d355..230515df9b16b190cf10eb4b3e4b3131649a6168 100644 (file)
@@ -17,7 +17,7 @@
 //  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 //
 //
@@ -40,9 +40,9 @@
 
 #include "GEOM_AssemblyBuilder.h"
 #include "GEOM_Actor.h"
-#include "VTKViewer_RenderWindowInteractor.h"
-#include "VTKViewer_ViewModel.h"
-#include "VTKViewer_ViewWindow.h"
+#include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_ViewModel.h"
+#include "SVTK_ViewWindow.h"
 #include "OCCViewer_ViewPort3d.h"
 #include "OCCViewer_ViewModel.h"
 #include "OCCViewer_ViewWindow.h"
@@ -82,6 +82,8 @@
 #include <qvaluelist.h>
 #include <qstringlist.h>
 
+#include <set>
+
 #include "GEOMImpl_Types.hxx"
 
 using namespace std;
@@ -89,23 +91,6 @@ using namespace std;
 #include "SALOMEDSClient.hxx"
 
 
-//=======================================================================
-// function : GEOMBase()
-// purpose  : Constructor
-//=======================================================================
-GEOMBase::GEOMBase()
-{
-}
-
-
-//=======================================================================
-// function : ~GEOMBase()
-// purpose  : Destructor
-//=======================================================================
-GEOMBase::~GEOMBase()
-{
-}
-
 //=====================================================================================
 // function : GetShapeFromIOR()
 // purpose  : exist also as static method !
@@ -402,8 +387,10 @@ GEOM_Actor* GEOMBase::ConvertIORinGEOMActor(const char* IOR, Standard_Boolean& t
   QPtrList<SUIT_ViewWindow> aViewWindowsList = SUIT_Session::session()->activeApplication()->desktop()->windows();
 
   for ( QPtrListIterator<SUIT_ViewWindow> it( aViewWindowsList ); it.current(); ++it ) {
-    if (it.current()->getViewManager()->getType() == VTKViewer_Viewer::Type()) {
-      VTKViewer_ViewWindow* aVTKViewWindow = (VTKViewer_ViewWindow*)it.current();
+    if (it.current()->getViewManager()->getType() == SVTK_Viewer::Type()) {
+      SVTK_ViewWindow* aVTKViewWindow = dynamic_cast<SVTK_ViewWindow*>( it.current() );
+      if( !aVTKViewWindow )
+       continue;
       vtkRenderer* Renderer = aVTKViewWindow->getRenderer();
       vtkActorCollection* theActors = Renderer->GetActors();
       theActors->InitTraversal();
@@ -864,18 +851,30 @@ QString GEOMBase::GetDefaultName(const QString& theOperation)
 {
   QString aName = "";
 
-  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+  // collect all object names of GEOM component
+  SalomeApp_Study* appStudy =
+    dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
   if ( !appStudy ) return aName;
   _PTR(Study) aStudy = appStudy->studyDS();
 
-  int aNumber = 0;
-  _PTR(SObject) obj;
-  do
-    {
-      aName = theOperation+"_"+QString::number(++aNumber);
-      obj = aStudy->FindObject(aName.latin1());
+  std::set<std::string> aSet;
+  _PTR(SComponent) aGeomCompo (aStudy->FindComponent("GEOM"));
+  if (aGeomCompo) {
+    _PTR(ChildIterator) it (aStudy->NewChildIterator(aGeomCompo));
+    _PTR(SObject) obj;
+    for (it->InitEx(true); it->More(); it->Next()) {
+      obj = it->Value();
+      aSet.insert(obj->GetName());
     }
-  while (obj);
+  }
+
+  // build a unique name
+  int aNumber = 0;
+  bool isUnique = false;
+  while (!isUnique) {
+    aName = theOperation + "_" + QString::number(++aNumber);
+    isUnique = (aSet.count(aName.latin1()) == 0);
+  }
 
   return aName;
 }
@@ -955,10 +954,10 @@ QString GEOMBase::GetName( GEOM::GEOM_Object_ptr theObj )
 
   if ( appStudy )
   {
-    string anIOR = SalomeApp_Application::orb()->object_to_string( theObj );
-    if ( anIOR != "" )
+    CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( theObj );
+    if ( strcmp(anIOR.in(), "") != 0 )
     {
-      _PTR(SObject) aSObj ( appStudy->studyDS()->FindObjectIOR( anIOR ) );
+      _PTR(SObject) aSObj ( appStudy->studyDS()->FindObjectIOR( string( anIOR ) ) );
 
       _PTR(GenericAttribute) anAttr;