#include <wx/wx.h>
#endif
-#include <wx/wxexpr.h>
+#if wxUSE_PROLOGIO
+#include <wx/deprecated/wxexpr.h>
+#endif
#ifdef new
#undef new
#include <ctype.h>
#include <math.h>
-#include <wx/ogl/basic.h>
-#include <wx/ogl/basicp.h>
-#include <wx/ogl/lines.h>
-#include <wx/ogl/linesp.h>
-#include <wx/ogl/drawn.h>
-#include <wx/ogl/misc.h>
-#include <wx/ogl/canvas.h>
+#include "wx/ogl/ogl.h"
+
// Line shape
IMPLEMENT_DYNAMIC_CLASS(wxLineShape, wxShape)
wxRealPoint *point1 = (wxRealPoint *)node->GetData();
wxRealPoint *point2 = (wxRealPoint *)node->GetNext()->GetData();
- // Allow for inaccurate mousing or vert/horiz lines
+ // For inaccurate mousing allow 8 pixel corridor
int extra = 4;
- double left = wxMin(point1->x, point2->x) - extra;
- double right = wxMax(point1->x, point2->x) + extra;
- double bottom = wxMin(point1->y, point2->y) - extra;
- double top = wxMax(point1->y, point2->y) + extra;
-
- if ((x > left && x < right && y > bottom && y < top) || inLabelRegion)
+ double dx = point2->x - point1->x;
+ double dy = point2->y - point1->y;
+ double seg_len = sqrt(dx*dx+dy*dy);
+ double distance_from_seg =
+ seg_len*((x-point1->x)*dy-(y-point1->y)*dx)/(dy*dy+dx*dx);
+ double distance_from_prev =
+ seg_len*((y-point1->y)*dy+(x-point1->x)*dx)/(dy*dy+dx*dx);
+
+ if ((fabs(distance_from_seg) < extra &&
+ distance_from_prev >= 0 && distance_from_prev <= seg_len)
+ || inLabelRegion)
{
- // Work out distance from centre of line
- double centre_x = (double)(left + (right - left)/2.0);
- double centre_y = (double)(bottom + (top - bottom)/2.0);
-
*attachment = 0;
- *distance = (double)sqrt((centre_x - x)*(centre_x - x) + (centre_y - y)*(centre_y - y));
+ *distance = distance_from_seg;
return TRUE;
}
wxString arrowName;
long arrowId = -1;
- wxExpr *type_expr = node->Item(0);
- wxExpr *end_expr = node->Item(1);
- wxExpr *dist_expr = node->Item(2);
- wxExpr *size_expr = node->Item(3);
- wxExpr *name_expr = node->Item(4);
- wxExpr *id_expr = node->Item(5);
+ wxExpr *type_expr = node->Nth(0);
+ wxExpr *end_expr = node->Nth(1);
+ wxExpr *dist_expr = node->Nth(2);
+ wxExpr *size_expr = node->Nth(3);
+ wxExpr *name_expr = node->Nth(4);
+ wxExpr *id_expr = node->Nth(5);
// New members of wxArrowHead
- wxExpr *yOffsetExpr = node->Item(6);
- wxExpr *spacingExpr = node->Item(7);
+ wxExpr *yOffsetExpr = node->Nth(6);
+ wxExpr *spacingExpr = node->Nth(7);
if (type_expr)
arrowType = (int)type_expr->IntegerValue();