Salome HOME
Merge V8_4_BR branch.
[modules/geom.git] / src / EntityGUI / EntityGUI_3DSketcherDlg.cxx
index 861d7c5b3fd4edcfdb38d47a9a9a4d99be9587c7..7416a3643ad473475fc5ef9a78fbe0432b23cb0c 100755 (executable)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -28,8 +28,6 @@
 #include "EntityGUI_3DSketcherDlg.h"
 #include "EntityGUI_Widgets.h"
 
-#include <Basics_OCCTVersion.hxx>
-
 #include <GEOMBase.h>
 #include <GeometryGUI.h>
 #include <Precision.hxx>
@@ -105,8 +103,7 @@ DEFINE_STANDARD_HANDLE(AIS_Text, AIS_InteractiveObject)
 class AIS_Text:public AIS_InteractiveObject
 {
 public:
-  // CASCADE RTTI
-  DEFINE_STANDARD_RTTI(AIS_Text );
+  DEFINE_STANDARD_RTTIEXT(AIS_Text,AIS_InteractiveObject)
 
   AIS_Text(){};
 
@@ -148,7 +145,6 @@ protected:
   Graphic3d_VerticalTextAlignment     aVJustification;
 };
 
-IMPLEMENT_STANDARD_HANDLE(AIS_Text, AIS_InteractiveObject)
 IMPLEMENT_STANDARD_RTTIEXT(AIS_Text, AIS_InteractiveObject)
 
 AIS_Text::AIS_Text( const TCollection_ExtendedString& text, const gp_Pnt& position,
@@ -180,7 +176,7 @@ void AIS_Text::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentation
 
   aPresentation->Clear();
 
-  Handle_Prs3d_TextAspect asp = myDrawer->TextAspect();
+  Handle(Prs3d_TextAspect) asp = myDrawer->TextAspect();
 
   asp->SetFont(aFont);
   asp->SetColor(aColor);
@@ -1287,7 +1283,7 @@ gp_Dir EntityGUI_3DSketcherDlg::getPresentationPlane() const
       gp_Vec V = Vec1.Transformed(aTransform.Inverted());
       gp_Vec Vec3(V.X(),V.Y(),0.0);
       
-      // Express the coordinates in the refernce coordinate system (OXY)
+      // Express the coordinates in the reference coordinate system (OXY)
       Vec3.Transform(aTransform);   
       if(Abs(Vec1.CrossMagnitude(Vec3)) > Precision::Confusion())                                  
       { 
@@ -1390,19 +1386,26 @@ void EntityGUI_3DSketcherDlg::displayTrihedron (int selMode)
 {
   // Add trihedron to preview
   SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
-
+  
+  SOCC_Viewer* anOCCViewer = dynamic_cast<SOCC_Viewer*>( vw->getViewManager()->getViewModel() );
+  if( !anOCCViewer )
+    return;
+  
+  Handle(AIS_InteractiveContext) anAISContext = anOCCViewer->getAISContext();
+  if( !anAISContext )
+    return;
+  
   gp_Pnt P(getLastPoint().x,getLastPoint().y,getLastPoint().z);
   Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement(P,gp::DZ(),gp::DX());
   Handle(AIS_Trihedron) anIO = new AIS_Trihedron(anAxis);
-  anIO->SetSelectionMode(selMode);
 
-  SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>
-    (((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));
+  SOCC_Prs* aSPrs = dynamic_cast<SOCC_Prs*>( anOCCViewer->CreatePrs(0) );
 
   if (aSPrs) {
     aSPrs->PrependObject(anIO);
     GEOMBase_Helper::displayPreview(aSPrs, true, true);
   }
+  anAISContext->Activate(anIO, selMode);
 }
 
 //================================================================
@@ -1477,7 +1480,7 @@ void EntityGUI_3DSketcherDlg::displayDimensions (bool store)
                  aLength * sin(anAngle1 * M_PI / 180. ),
                  0.0); 
     
-    // Express the coordinates in the refernce coordinate system (OXY)
+    // Express the coordinates in the reference coordinate system (OXY)
     gp_Trsf aTranform = toReferenceSystem(P0);
     P1.Transform(aTranform);    
     P2.Transform(aTranform);
@@ -1536,7 +1539,7 @@ void EntityGUI_3DSketcherDlg::displayAngle (double theAngle,
                                                                  P0, 
                                                                  P1, 
                                                                  P2);
-  if (anAngleIO == NULL)
+  if (anAngleIO.IsNull())
     return;
   
   if (store)
@@ -1651,7 +1654,7 @@ void EntityGUI_3DSketcherDlg::displayText ( std::string theText,
 //================================================================
 // Function : createAISLengthDimension()
 // Purpose  : Method for creation of a length dimension object
-//            Returns an Handle on the AIS_LengthDimension obect
+//            Returns an Handle on the AIS_LengthDimension object
 //================================================================
 Handle(AIS_LengthDimension) EntityGUI_3DSketcherDlg::createAISLengthDimension(double theLength, 
                                                                               gp_Pnt P1, 
@@ -1689,7 +1692,7 @@ Handle(AIS_LengthDimension) EntityGUI_3DSketcherDlg::createAISLengthDimension(do
 //================================================================
 // Function : createAISAngleDimension()
 // Purpose  : Method for creation of an angle dimension object
-//            Returns an Handle on the AIS_AngleDimension obect
+//            Returns an Handle on the AIS_AngleDimension object
 //================================================================
 Handle(AIS_AngleDimension) EntityGUI_3DSketcherDlg::createAISAngleDimension(double theAngle, 
                                                                             gp_Pnt P0,