~ubuntu-branches/ubuntu/precise/ipe/precise

« back to all changes in this revision

Viewing changes to src/ipecanvas/ipecreatearc.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2005-02-24 22:09:16 UTC
  • mfrom: (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050224220916-9vxiiqjz066r5489
Tags: 6.0pre23-2
debian/control: Ipe should depend on exact version of libipe.
Closes: #296771.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
                   0.5 * (iV[0] + iV[1]), 0.5 * (iV[1] - iV[0]).Len());
63
63
  case E3Points:
64
64
  default:
65
 
    IpeLine l1(iV[0], (iV[1] - iV[0]).Normalized());
66
65
    if (iCur == 1 || iV[1] == iV[2] ) {
67
66
      return IpePath(iServices->OvSvcAttributes(),
68
67
                     0.5 * (iV[0] + iV[1]), 0.5 * (iV[1] - iV[0]).Len());
69
 
    } else if (IpeAbs(l1.Side(iV[2])) < 1e-9) {
70
 
      // Argh. We really need an eps here!
71
 
      return IpePath(iServices->OvSvcAttributes(),
72
 
                     IpeSegment(iV[0], iV[2]));
73
68
    } else {
74
 
      IpeLine l1(iV[0], iV[1] - iV[0]);
75
 
      IpeLine l2(iV[1], iV[2] - iV[1]);
76
 
      IpeLine bi1(0.5 * (iV[0] + iV[1]), l1.Normal().Normalized());
77
 
      IpeLine bi2(0.5 * (iV[1] + iV[2]), l2.Normal().Normalized());
78
 
      IpeVector center;
79
 
      bi1.Intersects(bi2, center);
80
 
      return IpePath(iServices->OvSvcAttributes(), center,
81
 
                     (iV[0] - center).Len());
 
69
      IpeLine l1(iV[0], (iV[1] - iV[0]).Normalized());
 
70
      if (IpeAbs(l1.Side(iV[2])) < 1e-9) {
 
71
        // Argh. We really need an eps here!
 
72
        return IpePath(iServices->OvSvcAttributes(),
 
73
                       IpeSegment(iV[0], iV[2]));
 
74
      } else {
 
75
        IpeLine l2(iV[1], (iV[2] - iV[1]).Normalized());
 
76
        IpeLine bi1(0.5 * (iV[0] + iV[1]), l1.Normal().Normalized());
 
77
        IpeLine bi2(0.5 * (iV[1] + iV[2]), l2.Normal().Normalized());
 
78
        IpeVector center;
 
79
        bi1.Intersects(bi2, center);
 
80
        return IpePath(iServices->OvSvcAttributes(), center,
 
81
                       (iV[0] - center).Len());
 
82
      }
82
83
    }
83
84
  }
84
85
}
101
102
 
102
103
void IpeCreateCircle::MousePress(QMouseEvent *)
103
104
{
 
105
  // refuse point identical to previous
 
106
  if (iCanvas->Pos() == iV[iCur - 1])
 
107
    return;
 
108
 
104
109
  iV[iCur++] = iCanvas->Pos();
105
110
  if (iCur == 3 || iMode != E3Points && iCur == 2) {
106
111
    // finished
107
112
    IpePath *obj = new IpePath(Create());
108
113
    iServices->OvSvcAddObject(obj);
109
114
    iCanvas->FinishOverlay();
110
 
  } else
 
115
  } else {
 
116
    iV[iCur] = iCanvas->Pos();
111
117
    iCanvas->UpdateOverlay();
 
118
  }
112
119
}
113
120
 
114
121
// --------------------------------------------------------------------
185
192
  painter.Transform(iCanvas->CanvasTfm());
186
193
  painter.Push();
187
194
  if (iMode == E3Points && iCur == 1) {
188
 
    painter.BeginPath(iV[0]);
 
195
    painter.NewPath();
 
196
    painter.MoveTo(iV[0]);
189
197
    painter.LineTo(iV[1]);
190
 
    painter.EndPath();
191
198
    painter.DrawPath();
192
199
  } else
193
200
    Create().Draw(painter);