Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/visu.git] / src / VISUGUI / VisuGUI_Displayer.cxx
index 1fa6f098984eb6b1e560bf44fc517dd634a0beea..2939ca9082a037cab8963a7456937b517924be61 100644 (file)
 //  $Header: /home/server/cvs/VISU/VISU_SRC/src/VISUGUI/VisuGUI_Displayer.cxx
 
 #include "VisuGUI_Displayer.h"
-#include "VVTK_ViewModel.h"
+
 #include "VisuGUI_Tools.h"
+#include "VISU_ViewManager_i.hh"
 #include "VISU_Actor.h"
 
+#include "VVTK_ViewModel.h"
+
 #include <SVTK_ViewModel.h>
 #include <SVTK_ViewWindow.h>
 
@@ -41,7 +44,7 @@
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
 
-#include "VISU_ViewManager_i.hh"
+#include <SUIT_MessageBox.h>
 
 VisuGUI_Displayer::VisuGUI_Displayer( SalomeApp_Application* app )
 : LightApp_Displayer(),
@@ -67,7 +70,9 @@ SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& entry, SALOME_V
     if( CORBA::is_nil( anObj ) )
       return 0;
 
-    SVTK_Viewer* vtk_viewer = dynamic_cast<SVTK_Viewer*>( aViewFrame );
+    SVTK_Viewer* vtk_viewer = dynamic_cast<VVTK_Viewer*>( aViewFrame );
+    if (!vtk_viewer)
+      vtk_viewer = dynamic_cast<SVTK_Viewer*>( aViewFrame );
     if( vtk_viewer )
     {
       SVTK_ViewWindow* wnd =
@@ -116,14 +121,22 @@ SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& entry, SALOME_V
 
 void VisuGUI_Displayer::buildPrs3d( SVTK_ViewWindow* wnd, VISU::Prs3d_i* thePrs ) const
 {
-  VISU_Actor* newAct = VISU::FindActor( wnd, thePrs );
-  if( !newAct )
-  {
-    newAct = thePrs->CreateActor();
+  VISU_Actor* newAct = VISU::FindActor(wnd, thePrs);
+  if (!newAct) {
+    try {
+      newAct = thePrs->CreateActor();
+    } catch (std::runtime_error& exc) {
+      thePrs->RemoveActors();
+
+      INFOS(exc.what());
+      SUIT_MessageBox::warn1
+        (myApp->desktop(), QObject::tr("WRN_VISU"),
+         QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()),
+         QObject::tr("BUT_OK"));
+    }
   }
-  if( newAct )
-  {
-    wnd->AddActor( newAct );
+  if (newAct) {
+    wnd->AddActor(newAct);
     wnd->Repaint();
   }
 }