#include <ElSLib.hxx>
const double LOCAL_SELECTION_TOLERANCE = 0.0001;
-const int SCENE_PIXEL_TOLERANCE = 10;
+const int SCENE_PIXEL_TOLERANCE = 10;
//=======================================================================
// function : ConvertClickToPoint()
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;
- */
}
//=======================================================================
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
return;
Handle(AIS_InteractiveContext) aContext = getAISContext();
- if( !myCurve || !aContext )
+ if( !myCurve || aContext.IsNull() )
return;
mySection= -1;
if ( pe->modifiers() != Qt::ControlModifier ) {
Handle(AIS_InteractiveContext) ic = getAISContext();
- if ( !ic )
+ if ( ic.IsNull() )
return;
gp_Pnt aPnt;
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;
if ( myDragStarted )
return;
Handle(AIS_InteractiveContext) aContext = getAISContext();
- if ( !aContext )
+ if ( aContext.IsNull() )
return;
bool isBlocked = myLocalPointView->blockSignals(true);
if ( myDragStarted )
return;
Handle(AIS_InteractiveContext) ic = getAISContext();
- if ( !ic || !ic->HasOpenedContext() )
+ if ( ic.IsNull() || !ic->HasOpenedContext() )
return;
AIS_ListOfInteractive aListToSelect;