X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FEntityGUI%2FEntityGUI_3DSketcherDlg.cxx;h=7416a3643ad473475fc5ef9a78fbe0432b23cb0c;hb=2736f682fe0d63fbaf9dff49c46b4fa6c23d72ce;hp=343ee093943b5b073717745f754b9ad09f391c2c;hpb=92a33041adf8916f345483dadc1f507a58e5ca8c;p=modules%2Fgeom.git diff --git a/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx b/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx index 343ee0939..7416a3643 100755 --- a/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx +++ b/src/EntityGUI/EntityGUI_3DSketcherDlg.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 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 // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -28,8 +28,6 @@ #include "EntityGUI_3DSketcherDlg.h" #include "EntityGUI_Widgets.h" -#include - #include #include #include @@ -60,14 +58,12 @@ #include #include #include -#include #include #include #include #include #include #include -#if OCC_VERSION_LARGE > 0x06050300 #include #include #include @@ -75,7 +71,6 @@ #include #include #include -#endif // OCC_VERSION_LARGE > 0x06050300 // This include must be *AFTER* SOCC_ViewModel.h because // of the constant ROTATE which is a #define in @@ -103,14 +98,12 @@ private: bool& myLock; }; -#if OCC_VERSION_LARGE > 0x06050300 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(){}; @@ -152,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, @@ -184,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); @@ -197,7 +189,6 @@ void AIS_Text::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentation asp->Aspect()->SetTextFontAspect(aFontAspect); Prs3d_Text::Draw(aPresentation, asp, aText, aPosition); }; -#endif // OCC_VERSION_LARGE > 0x06050300 bool isSame (double d1, double d2) { @@ -219,7 +210,8 @@ EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg (GeometryGUI* theGeometryGUI, Q myOK(false), myLineWidth(lineWidth), myGeometryGUI(theGeometryGUI), - myLengthIORedoList() + myLengthIORedoList(), + myIsUndoRedo(false) { QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_UNDO"))); @@ -329,11 +321,9 @@ void EntityGUI_3DSketcherDlg::Init() SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); myAnglePrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); myLengthPrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); -#if OCC_VERSION_LARGE > 0x06050300 myTextPrs = dynamic_cast(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); -#endif // OCC_VERSION_LARGE > 0x06050300 - localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); + localSelection(TopAbs_VERTEX); /* Get setting of step value from file configuration */ double step = SUIT_Session::session()->resourceMgr()->doubleValue("Geometry", "SettingsGeomStep", 100.0); @@ -615,6 +605,7 @@ void EntityGUI_3DSketcherDlg::UpdatePointCoordinates() //================================================================================= void EntityGUI_3DSketcherDlg::ClickOnUndo() { + myIsUndoRedo = true; if (myPointsList.count() > 0) { myRedoList.append(myPointsList.last()); @@ -635,6 +626,7 @@ void EntityGUI_3DSketcherDlg::ClickOnUndo() ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myTextPrs); // Remove last point from list + myWorkPoint = myPointsList.last(); myPointsList.removeLast(); GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); UpdateButtonsState(); @@ -644,6 +636,7 @@ void EntityGUI_3DSketcherDlg::ClickOnUndo() updateViewer(); } + myIsUndoRedo = false; } //================================================================================= @@ -652,6 +645,7 @@ void EntityGUI_3DSketcherDlg::ClickOnUndo() //================================================================================= void EntityGUI_3DSketcherDlg::ClickOnRedo() { + myIsUndoRedo = true; if (myRedoList.count() > 0) { myPointsList.append(myRedoList.last()); @@ -672,6 +666,7 @@ void EntityGUI_3DSketcherDlg::ClickOnRedo() ((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->Display(myTextPrs); // Remove last point from redo list + myWorkPoint = myRedoList.last(); myRedoList.removeLast(); GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); UpdateButtonsState(); @@ -681,6 +676,7 @@ void EntityGUI_3DSketcherDlg::ClickOnRedo() updateViewer(); } + myIsUndoRedo = false; } //================================================================================= @@ -823,7 +819,7 @@ void EntityGUI_3DSketcherDlg::ActivateThisDialog() connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX); + localSelection(TopAbs_VERTEX); GEOMBase_Helper::displayPreview(true, false, true, true, myLineWidth); } @@ -1242,7 +1238,13 @@ gp_Dir EntityGUI_3DSketcherDlg::getPresentationPlane() const bool twoAngles = GroupAngles->checkBox->isChecked(); XYZ Last = getLastPoint(); - XYZ Current = getCurrentPoint(); + XYZ Current; + if( myIsUndoRedo ) { + Current = myWorkPoint; + } else { + Current = getCurrentPoint(); + } + XYZ Penultimate = getPenultimatePoint(); gp_Pnt P1 = gp_Pnt(Last.x,Last.y,Last.z); @@ -1281,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()) { @@ -1303,7 +1305,9 @@ gp_Dir EntityGUI_3DSketcherDlg::getPresentationPlane() const } } // If no angles, the plane is the one formed by the last edge and the current one - aNormal = gp_Dir(Vec1.Crossed(Vec2)); + if(Abs(Vec1.CrossMagnitude(Vec2)) > Precision::Confusion()) { + aNormal = gp_Dir(Vec1.Crossed(Vec2)); + } } return aNormal; } @@ -1382,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( 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_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0)); + SOCC_Prs* aSPrs = dynamic_cast( anOCCViewer->CreatePrs(0) ); if (aSPrs) { aSPrs->PrependObject(anIO); GEOMBase_Helper::displayPreview(aSPrs, true, true); } + anAISContext->Activate(anIO, selMode); } //================================================================ @@ -1469,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); @@ -1528,7 +1539,7 @@ void EntityGUI_3DSketcherDlg::displayAngle (double theAngle, P0, P1, P2); - if (anAngleIO == NULL) + if (anAngleIO.IsNull()) return; if (store) @@ -1611,7 +1622,6 @@ void EntityGUI_3DSketcherDlg::displayText ( std::string theText, gp_Pnt P, bool store ) { -#if OCC_VERSION_LARGE > 0x06050300 SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); Handle(AIS_Text) anIO = new AIS_Text(TCollection_ExtendedString(theText.c_str()), P); @@ -1638,13 +1648,13 @@ void EntityGUI_3DSketcherDlg::displayText ( std::string theText, GEOMBase_Helper::displayPreview(aSPrs, true, true); } } -#endif // OCC_VERSION_LARGE > 0x06050300 + } //================================================================ // 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, @@ -1669,7 +1679,10 @@ Handle(AIS_LengthDimension) EntityGUI_3DSketcherDlg::createAISLengthDimension(do aDimensionStyle->ArrowAspect()->SetLength( theLength / 20.0 ); aDimensionStyle->LineAspect()->SetWidth( w ); - aDimensionStyle->SetHorizontalTextAlignment( Prs3d_HTA_Center ); + aDimensionStyle->MakeText3d( Standard_False ); + aDimensionStyle->SetTextHorizontalPosition( Prs3d_DTHP_Center ); + aDimensionStyle->SetTextVerticalPosition( Prs3d_DTVP_Center ); + aDimensionStyle->MakeArrows3d( Standard_True ); anIO->SetFlyout( 0.0 ); anIO->SetDimensionAspect( aDimensionStyle ); @@ -1679,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, @@ -1693,38 +1706,10 @@ Handle(AIS_AngleDimension) EntityGUI_3DSketcherDlg::createAISAngleDimension(doub if (Abs(theAngle) < Precision::Angular() || aLength < Precision::Confusion()) return NULL; - - // Convert angles to string - std::string Angle_str = doubleToString(theAngle); - - // Construction of the plane - gce_MakePln gce_MP2(P0, P1, P2); - Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP2.Value()); - - TopoDS_Vertex V0 = BRepBuilderAPI_MakeVertex(P0); - TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(P1); - TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(P2); - - TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge(V0, V1); - TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(V0, V2); - - //Handle(AIS_AngleDimension) anIO = - // new AIS_AngleDimension(anEdge1, anEdge2, aPlane, theAngle * M_PI / 180., - // TCollection_ExtendedString(Angle_str.c_str())); - // - //anIO->SetArrowSize((theAngle * M_PI / 180) * (aLength/20)); - // - //SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - //int w = resMgr->integerValue("Geometry", "measures_line_width", 1); - //Handle(Prs3d_AngleAspect) asp = new Prs3d_AngleAspect(); - //asp->LineAspect()->SetWidth(w); - //anIO->Attributes()->SetAngleAspect(asp); - - // todo : port - Handle(AIS_AngleDimension) anIO = new AIS_AngleDimension( anEdge1, anEdge2, aPlane->Pln() ); + Handle(AIS_AngleDimension) anIO = new AIS_AngleDimension( P1, P0, P2 ); - anIO->SetCustomValue( theAngle ); + //anIO->SetCustomValue( theAngle ); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); int w = resMgr->integerValue( "Geometry", "measures_line_width", 1 ); @@ -1733,6 +1718,10 @@ Handle(AIS_AngleDimension) EntityGUI_3DSketcherDlg::createAISAngleDimension(doub aDimensionStyle->ArrowAspect()->SetLength( (theAngle * M_PI / 180.0) * (aLength / 20.0) ); aDimensionStyle->LineAspect()->SetWidth( w ); + aDimensionStyle->SetTextHorizontalPosition( Prs3d_DTHP_Center ); + aDimensionStyle->SetTextVerticalPosition( Prs3d_DTVP_Center ); + aDimensionStyle->MakeText3d( Standard_False ); + aDimensionStyle->MakeArrows3d( Standard_True ); anIO->SetDimensionAspect( aDimensionStyle );