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

« back to all changes in this revision

Viewing changes to src/ipelib/ipepath.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:
177
177
      painter.CurveTo(bez[i]);}
178
178
    break;
179
179
  case EArc: {
180
 
    painter.IpePainter::Push();
 
180
    painter.Push();
181
181
    painter.Transform(Matrix());
182
182
    IpeArc arc = Arc();
183
183
    painter.Transform(IpeLinear(arc.iAlpha));
184
184
    painter.DrawArc(arc.iBeta - arc.iAlpha);
185
 
    painter.IpePainter::Pop();
 
185
    painter.Pop();
186
186
    break; }
187
187
  }
188
188
}
403
403
 
404
404
void IpeEllipse::Draw(IpePainter &painter) const
405
405
{
406
 
  painter.IpePainter::Push();
 
406
  painter.Push();
407
407
  painter.Transform(iM);
408
408
  painter.DrawEllipse();
409
 
  painter.IpePainter::Pop();
 
409
  painter.Pop();
410
410
}
411
411
 
412
412
void IpeEllipse::AddToBBox(IpeRect &box, const IpeMatrix &m) const
450
450
 
451
451
IpeClosedSpline::IpeClosedSpline(const std::vector<IpeVector> &v)
452
452
{
 
453
  assert(v.size() >= 3);
453
454
  std::copy(v.begin(), v.end(), std::back_inserter(iCP));
454
455
}
455
456
 
493
494
{
494
495
  std::vector<IpeBezier> bez;
495
496
  Beziers(bez);
496
 
  painter.BeginClosedPath(bez.front().iV[0]);
 
497
  painter.MoveTo(bez.front().iV[0]);
497
498
  for (uint i = 0; i < bez.size(); ++i)
498
499
    painter.CurveTo(bez[i]);
499
 
  painter.EndClosedPath();
 
500
  painter.ClosePath();
500
501
}
501
502
 
502
503
void IpeClosedSpline::AddToBBox(IpeRect &box, const IpeMatrix &m) const
733
734
}
734
735
 
735
736
//! Delete a control point from a spline segment.
736
 
/*! If \a seg or \cp are negative, count from the end.
 
737
/*! If \a seg or \a cp are negative, count from the end.
737
738
  This cannot be used to remove the first or last CP of a spline curve,
738
739
  unless the spline is the first or last segment of the subpath.
739
740
  If the spline has only two vertices, it is simply deleted. */
857
858
}
858
859
 
859
860
//! Return segment.
860
 
/*! If \a i is negative, elements from the end are returned. */
 
861
/*! If \a i is negative, elements from the end are returned.  The
 
862
  closing segment of a closed path is not accessible this way (use
 
863
  ClosingSegment instead)!
 
864
*/
861
865
IpePathSegment IpeSegmentSubPath::Segment(int i) const
862
866
{
863
867
  if (i < 0)
924
928
 
925
929
void IpeSegmentSubPath::Draw(IpePainter &painter) const
926
930
{
927
 
  if (Closed())
928
 
    painter.BeginClosedPath(iCP[0]);
929
 
  else
930
 
    painter.BeginPath(iCP[0]);
 
931
  painter.MoveTo(iCP[0]);
931
932
  for (int i = 0; i < NumSegments(); ++i) {
932
933
    Segment(i).Draw(painter);
933
934
  }
934
935
  if (Closed())
935
 
    painter.EndClosedPath();
936
 
  else
937
 
    painter.EndPath();
 
936
    painter.ClosePath();
938
937
}
939
938
 
940
939
void IpeSegmentSubPath::AddToBBox(IpeRect &box, const IpeMatrix &m) const
981
980
  }
982
981
}
983
982
 
 
983
//! Returns the closing segment of a closed path.
 
984
/*! Since the closing segment isn't actually stored inside this
 
985
  object, you have to provide a length-2 vector for the control points.
 
986
*/
984
987
IpePathSegment IpeSegmentSubPath::ClosingSegment(IpeVector u[2]) const
985
988
{
986
989
  assert(iClosed);
989
992
  return IpePathSegment(IpePathSegment::ESegment, 2, u, 0);
990
993
}
991
994
 
992
 
 
993
 
 
994
995
// --------------------------------------------------------------------
995
996
 
996
997
/*! \class IpePath
1127
1128
      IpeEllipse *e = new IpeEllipse(GetMatrix(args));
1128
1129
      iImp->iSubPaths.push_back(e);
1129
1130
    } else if (stream.Token() == "u") {
1130
 
      assert(args.size() >= 8 && (args.size() % 2 == 0));
 
1131
      assert(args.size() >= 6 && (args.size() % 2 == 0));
1131
1132
      stream.NextToken();
1132
1133
      sp = 0;
1133
1134
      std::vector<IpeVector> v;
1371
1372
  if (color.IsNullOrVoid() || !absSize)
1372
1373
    return;
1373
1374
 
1374
 
  double siz = painter.Repository()->ToScalar(absSize);
 
1375
  double siz = painter.Repository()->ToScalar(absSize).ToDouble();
1375
1376
 
1376
 
  painter.IpePainter::Push();
 
1377
  painter.Push();
1377
1378
  painter.SetFill(color);
1378
1379
  painter.SetStroke(color);
1379
1380
  painter.SetDashStyle(IpeAttribute::Solid());
1380
1381
  painter.Translate(pos);
1381
1382
  painter.Transform(IpeLinear(angle));
1382
1383
  painter.Untransform(true);
1383
 
  painter.BeginClosedPath(IpeVector::Zero);
 
1384
  painter.NewPath();
 
1385
  painter.MoveTo(IpeVector::Zero);
1384
1386
  painter.LineTo(IpeVector(-siz, siz/3.0));
1385
1387
  painter.LineTo(IpeVector(-siz, -siz/3.0));
1386
 
  painter.EndClosedPath();
 
1388
  painter.ClosePath();
1387
1389
  painter.DrawPath();
1388
 
  painter.IpePainter::Pop();
 
1390
  painter.Pop();
1389
1391
}
1390
1392
 
1391
1393
//! Add a subpath to object.
1405
1407
void IpePath::Draw(IpePainter &painter) const
1406
1408
{
1407
1409
  ApplyAttributes(painter);
 
1410
  painter.NewPath();
1408
1411
  for (int i = 0; i < NumSubPaths(); ++i)
1409
1412
    SubPath(i)->Draw(painter);
1410
1413
  painter.DrawPath();