Example #1
0
void KstViewArrow::paintArrow(KstPainter& p, const QPoint& to, const QPoint &from, int w, double scaling) {
  double deltax = scaling * 2.0 * double(w);
  double theta = atan2(double(from.y() - to.y()), double(from.x() - to.x())) - M_PI / 2.0;
  double sina = sin(theta);
  double cosa = cos(theta);
  double yin = sqrt(3.0) * deltax;
  double x1, y1, x2, y2;
  QMatrix m(cosa, sina, -sina, cosa, 0.0, 0.0);
  
  m.map( deltax, yin, &x1, &y1);
  m.map(-deltax, yin, &x2, &y2);
  
  Q3PointArray pts(3);
  pts[0] = to;
  pts[1] = to + QPoint(d2i(x1), d2i(y1));
  pts[2] = to + QPoint(d2i(x2), d2i(y2));
  
  p.drawPolygon(pts);
}