return GEOMUtils::ConvertClickToPoint( x, y, aView );
}
+std::list<float> CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theContext )
+{
+ std::list<float> aSelectedPoints;
+
+ gp_Pnt aPnt;
+ for ( theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected() ) {
+ TopoDS_Vertex aVertex;
+ TopoDS_Shape aShape = theContext->SelectedShape();
+ if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
+ aVertex = TopoDS::Vertex( theContext->SelectedShape() );
+ else {
+ Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner();
+ if ( !anOwner.IsNull() ) {
+ Handle(AIS_InteractiveObject) anAIS = Handle(AIS_InteractiveObject)::DownCast( anOwner->Selectable() );
+ if ( !anAIS.IsNull() ) {
+ Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast( anAIS);
+ if ( !aPoint.IsNull() )
+ aVertex = TopoDS::Vertex( aPoint->Vertex() );
+ }
+ if ( aVertex.IsNull() ) {
+ // the following happens if there are no points in the current curve, there is only a shape
+ /*Handle(StdSelect_BRepOwner) aBrepOwner = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
+ if ( aBrepOwner.IsNull() )
+ continue;
+ if ( aBrepOwner->HasShape() ) {
+ const TopoDS_Shape& aShape = aBrepOwner->Shape();
+ if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
+ {
+ aVertex = TopoDS::Vertex( aShape );
+ }
+ }*/
+ }
+ }
+ }
+ if ( aVertex.IsNull() )
+ continue;
+ aPnt = BRep_Tool::Pnt( aVertex );
+ aSelectedPoints.push_back( aPnt.X() );
+ aSelectedPoints.push_back( aPnt.Y() );
+ aSelectedPoints.push_back( aPnt.Z() );
+ }
+
+ return aSelectedPoints;
+}
//=======================================================================
// function : setLocalPointContext
// purpose : Open/close the viewer local context
#include <gp_Pnt.hxx>
#include <Geom_Curve.hxx>
+#include <list>
+
class CurveCreator_Utils
{
public:
* \retval gp_Pnt Returns the point clicked in 3D view
*/
CURVECREATOR_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y,
- Handle(V3d_View) theView );
+ Handle(V3d_View) theView );
+
+ /**
+ * Find selected points in the context
+ * \param theContext the viewer context
+ */
+ CURVECREATOR_EXPORT static std::list<float> getSelectedPoints(
+ Handle(AIS_InteractiveContext) theContext );
/*!
* \brief Sets the local point context for the 3D viewer.
if ( aContext.IsNull() )
return;
+ std::list<float> aSelectedList = CurveCreator_Utils::getSelectedPoints( aContext );
+
+ std::list<float>::const_iterator anIt = aSelectedList.begin(), aLast = aSelectedList.end();
+ float aX, anY, aZ;
+
bool isBlocked = myLocalPointView->blockSignals(true);
- gp_Pnt aPnt;
myLocalPointView->setRowCount( 0 );
- for ( aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected() ) {
- TopoDS_Vertex aVertex;
- TopoDS_Shape aShape = aContext->SelectedShape();
- if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
- aVertex = TopoDS::Vertex( aContext->SelectedShape() );
- else {
- Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
- if ( !anOwner.IsNull() ) {
- Handle(AIS_InteractiveObject) anAIS = Handle(AIS_InteractiveObject)::DownCast( anOwner->Selectable() );
- if ( !anAIS.IsNull() ) {
- Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast( anAIS);
- if ( !aPoint.IsNull() )
- aVertex = TopoDS::Vertex( aPoint->Vertex() );
- }
- if ( aVertex.IsNull() ) {
- // the following happens if there are no points in the current curve, there is only a shape
- /*Handle(StdSelect_BRepOwner) aBrepOwner = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
- if ( aBrepOwner.IsNull() )
- continue;
- if ( aBrepOwner->HasShape() ) {
- const TopoDS_Shape& aShape = aBrepOwner->Shape();
- if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
- {
- aVertex = TopoDS::Vertex( aShape );
- }
- }*/
- }
- }
- }
- if ( aVertex.IsNull() )
- continue;
- aPnt = BRep_Tool::Pnt( aVertex );
- addLocalPointToTable( aPnt.X(), aPnt.Y() );
+ for ( ; anIt != aLast; anIt++ )
+ {
+ aX = *anIt;
+ anIt++;
+ anY = *anIt;
+ anIt++;
+ aZ = *anIt;
+ addLocalPointToTable( aX, anY );
}
myLocalPointView->blockSignals(isBlocked);
}