Beispiel #1
0
bool PointImp::hit(LocationType point) const
{
   PlotViewImp* pPlot = getPlot();
   if (pPlot == NULL)
   {
      return false;
   }

   double dScreenX = 0.0;
   double dScreenY = 0.0;
   pPlot->translateWorldToScreen(point.mX, point.mY, dScreenX, dScreenY);

   double dCurrentScreenX = 0.0;
   double dCurrentScreenY = 0.0;

   pPlot->translateDataToScreen(mLocation.mX, mLocation.mY, dCurrentScreenX, dCurrentScreenY);

   double dXDist = fabs(dCurrentScreenX - dScreenX);
   double dYDist = fabs(dCurrentScreenY - dScreenY);

   double dDist = mSymbolSize;
   if (isSelected() == true)
   {
      dDist *= 2.0;
   }

   if ((dXDist < dDist) && (dYDist < dDist))
   {
      return true;
   }

   return false;
}
Beispiel #2
0
bool CurveImp::hit(LocationType point) const
{
   PlotViewImp* pPlot = getPlot();
   if (pPlot == NULL)
   {
      return false;
   }

   unsigned int numPoints = mPoints.size();
   for (unsigned int i = 0; i < numPoints; i++)
   {
      double dScreenX = 0;
      double dScreenY = 0;
      pPlot->translateWorldToScreen(point.mX, point.mY, dScreenX, dScreenY);

      LocationType currentPoint = mPoints.at(i);

      double dCurrentScreenX = 0;
      double dCurrentScreenY = 0;
      pPlot->translateDataToScreen(currentPoint.mX, currentPoint.mY, 
         dCurrentScreenX, dCurrentScreenY);

      double dXDist = fabs(dCurrentScreenX - dScreenX);
      double dYDist = fabs(dCurrentScreenY - dScreenY);

      if ((dXDist < 3.0) && (dYDist < 3.0))
      {
         return true;
      }
   }

   return false;
}
Beispiel #3
0
bool PointSetImp::hit(LocationType point) const
{
   if (mLine == true)
   {
      if (mPoints.size() > 0)
      {
         PlotViewImp* pPlot = getPlot();
         if (pPlot != NULL)
         {
            double dPointX = 0.0;
            double dPointY = 0.0;
            pPlot->translateWorldToScreen(point.mX, point.mY, dPointX, dPointY);

            point.mX = dPointX;
            point.mY = dPointY;

            LocationType oldLocation;
            LocationType currentLocation;

            Point* pPoint = NULL;
            pPoint = mPoints.front();
            if (pPoint != NULL)
            {
               const LocationType& location = pPoint->getLocation();

               double dLocationX = 0.0;
               double dLocationY = 0.0;
               pPlot->translateDataToScreen(location.mX, location.mY, dLocationX, dLocationY);

               oldLocation.mX = dLocationX;
               oldLocation.mY = dLocationY;
            }

            for (unsigned int i = 1; i < mPoints.size(); i++)
            {
               pPoint = mPoints.at(i);
               if (pPoint != NULL)
               {
                  const LocationType& location = pPoint->getLocation();

                  double dLocationX = 0.0;
                  double dLocationY = 0.0;
                  pPlot->translateDataToScreen(location.mX, location.mY, dLocationX, dLocationY);

                  currentLocation.mX = dLocationX;
                  currentLocation.mY = dLocationY;

                  bool bHit = false;
                  bHit = DrawUtil::lineHit(oldLocation, currentLocation, point, 3.0);
                  if (bHit == true)
                  {
                     return true;
                  }

                  oldLocation = currentLocation;
               }
            }
         }
      }
   }

   Point* pPoint = hitPoint(point);
   return (pPoint != NULL);
}