bool PSelectionInteraction::Calculate (Painter &inPainter, PPlot& inPPlot) { if (mCommand == kNone) { return true; } PlotDataContainer &theContainer = inPPlot.mPlotDataContainer; long thePlotCount = theContainer.GetPlotCount (); float theDist = -1; for (long theI=0;theI<thePlotCount;theI++) { PlotDataBase *theXData = theContainer.GetXData (theI); PlotDataBase *theYData = theContainer.GetYData (theI); DataDrawerBase *theDataDrawer = theContainer.GetDataDrawer (theI); PlotDataSelection *thePlotDataSelection = theContainer.GetPlotDataSelection (theI); long theNearestPointIndex; float theLocalDist = CalculateDistanceToPlot (theXData, theYData, theNearestPointIndex); // fprintf (stderr, "dist %f\n", theLocalDist); bool theHit = theLocalDist < kHitDistance; if (!SelectNotify(-1, 0, NULL, NULL, false)) return true; if (mCommand == kPointwiseSelection) { HandlePointwiseInteraction (theI, theXData, theYData, theHit, theNearestPointIndex, theDataDrawer, thePlotDataSelection); } else if (mCommand == kGlobalSelection){ HandleGlobalInteraction (theI, theXData, theYData, theHit, theNearestPointIndex, theDataDrawer, thePlotDataSelection); } else if (mCommand == kSelectAll) { SelectAll (theI, theXData, theYData, thePlotDataSelection); } SelectNotify(-2, 0, NULL, NULL, false); if (theHit) { // fprintf (stderr, "hit/n"); } } if (mListener) { mListener->HandlePSelectionInteraction (); } mCommand = kNone; return true; }
void PSelectionInteraction::UpdateSelection (int inIndex, int inSampleIndex, PlotDataBase *inXData, PlotDataBase *inYData, bool inHit, PlotDataSelection *inPlotDataSelection) { if ((*inPlotDataSelection)[inSampleIndex] != inHit) { if (SelectNotify(inIndex, inSampleIndex, inXData, inYData, inHit)) (*inPlotDataSelection)[inSampleIndex] = inHit; } }