From: nds Date: Tue, 3 Dec 2013 08:42:47 +0000 (+0000) Subject: OCC functionality moving out from the widget X-Git-Tag: BR_hydro_v_0_4~86 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c3f79a88a881487ffae38af1a869ea7f91f08fa5;p=modules%2Fhydro.git OCC functionality moving out from the widget --- diff --git a/src/HYDROCurveCreator/CurveCreator_Utils.cxx b/src/HYDROCurveCreator/CurveCreator_Utils.cxx index 17751678..1fa61b33 100644 --- a/src/HYDROCurveCreator/CurveCreator_Utils.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Utils.cxx @@ -48,7 +48,7 @@ #include const double LOCAL_SELECTION_TOLERANCE = 0.0001; -const int SCENE_PIXEL_TOLERANCE = 10; +const int SCENE_PIXEL_TOLERANCE = 10; //======================================================================= // function : ConvertClickToPoint() @@ -69,26 +69,6 @@ void CurveCreator_Utils::ConvertPointToClick( const gp_Pnt& thePoint, gp_Pnt CurveCreator_Utils::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView ) { return GEOMUtils::ConvertClickToPoint( x, y, aView ); - /* - V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt; - aView->Eye( XEye, YEye, ZEye ); - - aView->At( XAt, YAt, ZAt ); - gp_Pnt EyePoint( XEye, YEye, ZEye ); - gp_Pnt AtPoint( XAt, YAt, ZAt ); - - gp_Vec EyeVector( EyePoint, AtPoint ); - gp_Dir EyeDir( EyeVector ); - - gp_Pln PlaneOfTheView = gp_Pln( AtPoint, EyeDir ); - Standard_Real X, Y, Z; - aView->Convert( x, y, X, Y, Z ); - gp_Pnt ConvertedPoint( X, Y, Z ); - - gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project( PlaneOfTheView, ConvertedPoint ); - gp_Pnt ResultPoint = ElSLib::Value( ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView ); - return ResultPoint; - */ } //======================================================================= diff --git a/src/HYDROCurveCreator/CurveCreator_Utils.h b/src/HYDROCurveCreator/CurveCreator_Utils.h index 52d34e63..c9ca6154 100644 --- a/src/HYDROCurveCreator/CurveCreator_Utils.h +++ b/src/HYDROCurveCreator/CurveCreator_Utils.h @@ -62,6 +62,22 @@ public: Handle(AIS_InteractiveContext) theContext, const bool theOpen ); + /** + * Find the neighbour points by the clicked coordinates + * \param theContext the viewer context. + * \param theContext the V3D view. + * \param theX the X coordinate in the view. + * \param theY the Y coordinate in the view. + * \param thePoint the output point to be append to the model curve + * \param thePoint1 the output point to bound the line where a new point should be inserted + * \param thePoint2 the output point to bound the line where a new point should be inserted + */ + CURVECREATOR_EXPORT static bool getNeighbourPoints( + Handle(AIS_InteractiveContext) theContext, + Handle(V3d_View) theView, + const int theX, const int theY, + gp_Pnt& thePoint, gp_Pnt& thePoint1, + gp_Pnt& thePoint2 ); /** * Checks whether the point belongs to the OCC object * \param theObject a line or shape with a bspline inside diff --git a/src/HYDROCurveCreator/CurveCreator_Widget.cxx b/src/HYDROCurveCreator/CurveCreator_Widget.cxx index a19fbead..be18c55a 100644 --- a/src/HYDROCurveCreator/CurveCreator_Widget.cxx +++ b/src/HYDROCurveCreator/CurveCreator_Widget.cxx @@ -468,7 +468,7 @@ void CurveCreator_Widget::onAdditionMode(bool checked) return; Handle(AIS_InteractiveContext) aContext = getAISContext(); - if( !myCurve || !aContext ) + if( !myCurve || aContext.IsNull() ) return; mySection= -1; @@ -925,7 +925,7 @@ void CurveCreator_Widget::onGetCoordsByClick( QMouseEvent* pe ) if ( pe->modifiers() != Qt::ControlModifier ) { Handle(AIS_InteractiveContext) ic = getAISContext(); - if ( !ic ) + if ( ic.IsNull() ) return; gp_Pnt aPnt; @@ -1128,35 +1128,18 @@ void CurveCreator_Widget::insertPointToSelectedSegment( const int theX, const int theY ) { Handle(AIS_InteractiveContext) aContext = getAISContext(); - if ( !aContext ) - return; - gp_Pnt aPoint; - gp_Pnt aPoint1, aPoint2; - bool isFoundPoint = false; OCCViewer_ViewPort3d* aViewPort = getViewPort(); Handle(V3d_View) aView; if ( aViewPort ) aView = aViewPort->getView(); - if ( aView.IsNull() ) - return; - - for ( aContext->InitSelected(); aContext->MoreSelected() && !isFoundPoint; - aContext->NextSelected() ) { - TopoDS_Shape aTShape = aContext->SelectedShape(); - if ( !aTShape.IsNull() && aTShape.ShapeType() == TopAbs_VERTEX ) - continue; - else { - Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner(); - if ( anOwner.IsNull() ) - continue; - const TopLoc_Location& aLocation = anOwner->Location(); - Handle(AIS_InteractiveObject) anAIS = Handle(AIS_InteractiveObject)::DownCast( anOwner->Selectable() ); - isFoundPoint = CurveCreator_Utils::pointOnObject( aView, anAIS, theX, theY, aPoint, - aPoint1, aPoint2 ); - } - } + if ( aContext.IsNull() || aView.IsNull() ) + return; + gp_Pnt aPoint; + gp_Pnt aPoint1, aPoint2; + bool isFoundPoint = CurveCreator_Utils::getNeighbourPoints( aContext, aView, theX, theY, + aPoint, aPoint1, aPoint2 ); if ( !isFoundPoint ) return; @@ -1248,7 +1231,7 @@ void CurveCreator_Widget::updateLocalPointView() if ( myDragStarted ) return; Handle(AIS_InteractiveContext) aContext = getAISContext(); - if ( !aContext ) + if ( aContext.IsNull() ) return; bool isBlocked = myLocalPointView->blockSignals(true); @@ -1393,7 +1376,7 @@ void CurveCreator_Widget::setSelectedPonts( const CurveCreator_Widget::SectionTo if ( myDragStarted ) return; Handle(AIS_InteractiveContext) ic = getAISContext(); - if ( !ic || !ic->HasOpenedContext() ) + if ( ic.IsNull() || !ic->HasOpenedContext() ) return; AIS_ListOfInteractive aListToSelect;