+// Draw an outline using the current operation.
+bool wxOpPolyDraw::OnDrawOutline(wxDC& dc, double x, double y, double w, double h, double oldW, double oldH)
+{
+ dc.SetBrush(wxTRANSPARENT_BRUSH);
+
+ // Multiply all points by proportion of new size to old size
+ double x_proportion = (double)(fabs(w/oldW));
+ double y_proportion = (double)(fabs(h/oldH));
+
+ int n = m_noPoints;
+ wxPoint *intPoints = new wxPoint[n];
+ int i;
+ for (i = 0; i < n; i++)
+ {
+ intPoints[i].x = WXROUND (x_proportion * m_points[i].x);
+ intPoints[i].y = WXROUND (y_proportion * m_points[i].y);
+ }
+ dc.DrawPolygon(n, intPoints, x, y);
+ delete[] intPoints;
+ return TRUE;
+}
+
+// Assume (x1, y1) is centre of box (most generally, line end at box)
+bool wxOpPolyDraw::GetPerimeterPoint(double x1, double y1,
+ double x2, double y2,
+ double *x3, double *y3,
+ double xOffset, double yOffset,
+ bool attachmentMode)
+{
+ int n = m_noPoints;
+
+ // First check for situation where the line is vertical,
+ // and we would want to connect to a point on that vertical --
+ // oglFindEndForPolyline can't cope with this (the arrow
+ // gets drawn to the wrong place).
+ if ((!attachmentMode) && (x1 == x2))
+ {
+ // Look for the point we'd be connecting to. This is
+ // a heuristic...
+ int i;
+ for (i = 0; i < n; i++)
+ {
+ wxRealPoint *point = & (m_points[i]);
+ if (point->x == 0.0)
+ {
+ if ((y2 > y1) && (point->y > 0.0))
+ {
+ *x3 = point->x + xOffset;
+ *y3 = point->y + yOffset;
+ return TRUE;
+ }
+ else if ((y2 < y1) && (point->y < 0.0))
+ {
+ *x3 = point->x + xOffset;
+ *y3 = point->y + yOffset;
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ double *xpoints = new double[n];
+ double *ypoints = new double[n];
+
+ int i = 0;
+ for (i = 0; i < n; i++)
+ {
+ wxRealPoint *point = & (m_points[i]);
+ xpoints[i] = point->x + xOffset;
+ ypoints[i] = point->y + yOffset;
+ }
+
+ oglFindEndForPolyline(n, xpoints, ypoints,
+ x1, y1, x2, y2, x3, y3);
+
+ delete[] xpoints;
+ delete[] ypoints;
+
+ return TRUE;
+}
+