Salome HOME
Modify default icon for the module
[modules/gui.git] / src / SOCC / SOCC_ViewModel.cxx
index 86d97ff67ff83f8776795b4eed6564907992040b..686cd58fc221d629928e50e0cdb89206b5addabd 100755 (executable)
@@ -24,6 +24,8 @@
 #include "SALOMEDSClient.hxx"
 #include "SALOMEDS_StudyManager.hxx"
 
+#include <AIS_TypeOfIso.hxx>
+
 // in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study.
 // SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from 
 // SALOMEDS::StudyManager - no linkage with SalomeApp. 
@@ -469,23 +471,23 @@ SALOME_Prs* SOCC_Viewer::CreatePrs( const char* entry )
 //=======================================================================
 void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode )
 {
-  Handle(AIS_InteractiveContext) anIC = getAISContext();
+  Handle(AIS_InteractiveContext) ic = getAISContext();
   
   const SOCC_Prs* anOCCPrs = dynamic_cast<const SOCC_Prs*>( thePrs );
-  if ( anIC.IsNull() )
+  if ( ic.IsNull() )
     return;
   
   // Open local context if there is no one
   bool allObjects = thePrs == 0 || thePrs->IsNull();
-  if ( !anIC->HasOpenedContext() ) {
-    anIC->ClearCurrents( false );
-    anIC->OpenLocalContext( allObjects, true, true );
+  if ( !ic->HasOpenedContext() ) {
+    ic->ClearCurrents( false );
+    ic->OpenLocalContext( allObjects, true, true );
   }
 
   AIS_ListOfInteractive anObjs;
   // Get objects to be activated
   if ( allObjects ) 
-    anIC->DisplayedObjects( anObjs );
+    ic->DisplayedObjects( anObjs );
   else
     anOCCPrs->GetObjects( anObjs );
 
@@ -497,13 +499,13 @@ void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode
     {
       if ( anAIS->IsKind( STANDARD_TYPE( AIS_Shape ) ) )
       {
-        anIC->Load( anAIS, -1, false );
-        anIC->Activate( anAIS, AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)theMode ) );
+        ic->Load( anAIS, -1, false );
+        ic->Activate( anAIS, AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)theMode ) );
       }
       else if ( anAIS->DynamicType() != STANDARD_TYPE(AIS_Trihedron) )
       {
-        anIC->Load( anAIS, -1, false );
-        anIC->Activate( anAIS, theMode );
+        ic->Load( anAIS, -1, false );
+        ic->Activate( anAIS, theMode );
       }
     }
   }
@@ -515,11 +517,13 @@ void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode
 //=======================================================================
 void SOCC_Viewer::GlobalSelection( const bool update ) const
 {
-  Handle(AIS_InteractiveContext) anIC = getAISContext();
-  if ( !anIC.IsNull() )
-    anIC->CloseAllContexts( false );
-  if ( update )
-    anIC->CurrentViewer()->Redraw();
+  Handle(AIS_InteractiveContext) ic = getAISContext();
+  if ( !ic.IsNull() )
+  {
+    ic->CloseAllContexts( false );
+    if ( update )
+      ic->CurrentViewer()->Redraw();
+  }
 }
 
 //=======================================================================
@@ -550,7 +554,13 @@ bool SOCC_Viewer::getTrihedronSize( double& theNewSize, double& theSize )
   theNewSize = 100;
   theSize = 100;
 
-  Handle(V3d_View) view3d = getViewer3d()->ActiveView();
+  //SRN: BUG IPAL8996, a usage of method ActiveView without an initialization
+  Handle(V3d_Viewer) viewer = getViewer3d();
+  viewer->InitActiveViews();
+  if(!viewer->MoreActiveViews()) return false;
+
+  Handle(V3d_View) view3d = viewer->ActiveView();
+  //SRN: END of fix
 
   if ( view3d.IsNull() )
     return false;
@@ -587,4 +597,3 @@ void SOCC_Viewer::Repaint()
 //  onAdjustTrihedron();
   getViewer3d()->Update();
 }
-