Salome HOME
Porting to OCCT 7.4.1 dev
[modules/geom.git] / src / EntityGUI / EntityGUI_3DSketcherDlg.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 861d7c5..74abede
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2020  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);
@@ -758,7 +754,7 @@ void EntityGUI_3DSketcherDlg::SelectionIntoArgument()
         aSelMgr->GetIndexes(aSelList.First(), aMap);
         if (aMap.Extent() == 1) {
           int anIndex = aMap(1);
-          GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
+          GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations();
           aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
         }
       }
@@ -945,7 +941,7 @@ void EntityGUI_3DSketcherDlg::enterEvent (QEvent*)
 //=================================================================================
 GEOM::GEOM_IOperations_ptr EntityGUI_3DSketcherDlg::createOperation()
 {
-  return getGeomEngine()->GetICurvesOperations(getStudyId());
+  return getGeomEngine()->GetICurvesOperations();
 }
 
 //=================================================================================
@@ -999,10 +995,10 @@ bool EntityGUI_3DSketcherDlg::execute (ObjectList& objects)
 //   MESSAGE("aCommands.last() = "<< aCommands.last().toStdString());
   GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
   //GEOM::GEOM_Object_var anObj = anOper->Make3DSketcher(aCoordsArray);
-  GEOM::GEOM_Object_var anObj = anOper->Make3DSketcherCommand(aCommands.join(":").toLatin1().constData());
+  GEOM::GEOM_Object_var anObj = anOper->Make3DSketcherCommand(aCommands.join(":").toUtf8().constData());
 
   if (!anObj->_is_nil()) {
-    if (!IsPreview()) anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+    if (!IsPreview()) anObj->SetParameters(aParameters.join(":").toUtf8().constData());
     objects.push_back(anObj._retn());
   }
 
@@ -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,10 +1480,10 @@ void EntityGUI_3DSketcherDlg::displayDimensions (bool store)
                  aLength * sin(anAngle1 * M_PI / 180. ),
                  0.0); 
     
-    // Express the coordinates in the refernce coordinate system (OXY)
-    gp_Trsf aTranform = toReferenceSystem(P0);
-    P1.Transform(aTranform);    
-    P2.Transform(aTranform);
+    // Express the coordinates in the reference coordinate system (OXY)
+    gp_Trsf aTransform = toReferenceSystem(P0);
+    P1.Transform(aTransform);    
+    P2.Transform(aTransform);
     P1.Translate(Origin, P0);
     P2.Translate(Origin, P0);
     
@@ -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,