#include <AIS_Shape.hxx>
#include <AIS_Point.hxx>
#include <AIS_Line.hxx>
+#include <AIS_LocalContext.hxx>
#include <Geom_Point.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_Line.hxx>
#include <StdSelect_BRepOwner.hxx>
+#include <SelectMgr_Selection.hxx>
+#include <Select3D_SensitivePoint.hxx>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QMouseEvent>
#include <QApplication>
#include <QTableWidget>
+#include <QTime>
+
+#define MEASURE_TIME
+
+#ifdef MEASURE_TIME
+
+ #define START_MEASURE_TIME \
+ QTime aTimer; \
+ aTimer.start(); \
+
+ #define END_MEASURE_TIME( theMsg ) \
+ double aTime = aTimer.elapsed() * 0.001; \
+ FILE* aFile = fopen( "performance", "a" ); \
+ fprintf( aFile, "%s = %.3lf sec\n", theMsg, aTime ); \
+ fclose( aFile ); \
+
+#else
+
+ #define START_MEASURE_TIME
+ #define END_MEASURE_TIME( theMsg )
+
+#endif
+
+
+
+
+
const double LOCAL_SELECTION_TOLERANCE = 0.0001;
setDragStarted( false );
// if the drag of some points has happened, restore the drag selection
if ( aDraggedPoints.size() > 0 )
+ {
+ START_MEASURE_TIME;
setSelectedPonts( aDraggedPoints );
+ END_MEASURE_TIME( "drop" );
+ }
}
else // check whether the segment is clicked an a new point should be added to the segment
insertPointToSelectedSegment( theEvent->pos().x(), theEvent->pos().y() );
if ( (aPos - myDragStartPosition).manhattanLength() < QApplication::startDragDistance() )
return;
+ START_MEASURE_TIME;
+
moveSelectedPoints( aPos.x(), aPos.y() );
myDragStartPosition = aPos;
+
+ END_MEASURE_TIME( "drag" );
}
/**
{
if ( myDragStarted )
return;
+
Handle(AIS_InteractiveContext) ic = getAISContext();
if ( ic.IsNull() || !ic->HasOpenedContext() )
return;
ic->DisplayedObjects( aDisplayedList );
ic->ClearSelected( Standard_False );
- std::vector<TopoDS_Vertex> aVetexVec;
+ bool isSelectedVertex = false;
+
+ //ASL: std::vector<TopoDS_Vertex> aVetexVec;
for ( AIS_ListIteratorOfListOfInteractive it( aDisplayedList ); it.More(); it.Next() )
{
Handle(AIS_InteractiveObject) anAIS = it.Value();
Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast( anAIS );
if ( anAISShape.IsNull() )
continue;
- const TopoDS_Shape& aShape = anAISShape->Shape();
+
+
+ /*ASL: const TopoDS_Shape& aShape = anAISShape->Shape();
TopExp_Explorer aExpV( aShape, TopAbs_VERTEX);
for ( ; aExpV.More(); aExpV.Next() )
{
const TopoDS_Vertex& aVertex = TopoDS::Vertex( aExpV.Current() );
aVetexVec.push_back( aVertex );
+ }*/
+
+
+ //ASL: we convert list of point indices to list of points coordinates
+ int aSize = thePoints.size();
+ std::vector<gp_Pnt> aPntsToSelect( aSize );
+
+ CurveCreator_ICurve::SectionToPointList::const_iterator
+ aPIt = thePoints.begin(), aPLast = thePoints.end();
+ CurveCreator_ICurve::SectionToPoint aSToPoint;
+ for( int i=0; aPIt != aPLast; aPIt++, i++ )
+ {
+ gp_Pnt aPntToSelect;
+ CurveCreator_UtilsICurve::getPoint( myCurve, aPIt->first, aPIt->second, aPntToSelect );
+ aPntsToSelect[i] = aPntToSelect;
+ }
+
+
+ //ASL: we switch off automatic highlight to improve performance of selection
+ ic->SetAutomaticHilight( Standard_False );
+
+ Handle_SelectMgr_Selection aSelection = anAISShape->Selection( AIS_Shape::SelectionMode( TopAbs_VERTEX ) );
+ for( aSelection->Init(); aSelection->More(); aSelection->Next() )
+ {
+ Handle_SelectBasics_SensitiveEntity aSenEntity = aSelection->Sensitive();
+ Handle_Select3D_SensitivePoint aSenPnt = Handle_Select3D_SensitivePoint::DownCast( aSenEntity );
+
+ gp_Pnt anOwnerPnt = aSenPnt->Point();
+ Handle_SelectMgr_EntityOwner anOwner = Handle_SelectMgr_EntityOwner::DownCast( aSenPnt->OwnerId() );
+
+
+ CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(),
+ aLast = thePoints.end();
+ bool isFound = false;
+ for( int i=0; i<aSize; i++ )
+ {
+ bool isIntersect = fabs( aPntsToSelect[i].X() - anOwnerPnt.X() ) < LOCAL_SELECTION_TOLERANCE &&
+ fabs( aPntsToSelect[i].Y() - anOwnerPnt.Y() ) < LOCAL_SELECTION_TOLERANCE;
+ if( isIntersect )
+ {
+ ic->AddOrRemoveSelected( anOwner, Standard_False );
+ break;
+ }
+ }
}
}
- bool isSelectedVertex = false;
- std::vector<TopoDS_Vertex>::const_iterator aVecIt = aVetexVec.begin(), aVecLast = aVetexVec.end();
+ /*ASL: std::vector<TopoDS_Vertex>::const_iterator aVecIt = aVetexVec.begin(), aVecLast = aVetexVec.end();
CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(),
aLast = thePoints.end();
int aSize = aVetexVec.size();
anAddedSize++;
}
}
- }
+ }*/
+
+ //ASL: we switch on again automatic highlight (otherwise selection will not be shown)
+ // and call HilightPicked to draw selected owners
+ ic->SetAutomaticHilight( Standard_True );
+ ic->LocalContext()->HilightPicked( Standard_True );
- ic->UpdateCurrentViewer();
+ //ic->UpdateCurrentViewer();
if ( !isSelectedVertex )
setObjectsSelected( aListToSelect );
updateLocalPointView();