~ubuntu-branches/ubuntu/saucy/kig/saucy

« back to all changes in this revision

Viewing changes to misc/kigpainter.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-10-02 15:28:24 UTC
  • mfrom: (1.1.14)
  • Revision ID: package-import@ubuntu.com-20121002152824-971803jif02m40i1
Tags: 4:4.9.2-0ubuntu1
New upstream bugfix release

Show diffs side-by-side

added added

removed removed

Lines of Context:
628
628
  drawRay( d.a, d.b );
629
629
}
630
630
 
631
 
void KigPainter::drawAngle( const Coordinate& cpoint, double dstartangle,
632
 
                            double dangle )
 
631
void KigPainter::drawAngle( const Coordinate& point, double startangle, double angle, int radius )
633
632
{
634
 
  // convert to 16th of degrees...
635
 
  const int startangle = static_cast<int>( Goniometry::convert( 16 * dstartangle, Goniometry::Rad, Goniometry::Deg ) );
636
 
  const int angle = static_cast<int>( Goniometry::convert( 16 * dangle, Goniometry::Rad, Goniometry::Deg ) );
637
 
 
638
 
  QPoint point = toScreen( cpoint );
639
 
 
640
 
//   int radius = mP.window().width() / 5;
641
 
  int radius = 50;
 
633
  const int startangleDegrees = static_cast<int>( Goniometry::convert( startangle, Goniometry::Rad, Goniometry::Deg ) );
 
634
  const int angleDegrees = static_cast<int>( Goniometry::convert( angle, Goniometry::Rad, Goniometry::Deg ) );
 
635
 
 
636
  QPoint screenPoint = toScreen( point );
642
637
  QRect surroundingRect( 0, 0, radius*2, radius*2 );
643
 
  surroundingRect.moveCenter( point );
 
638
  surroundingRect.moveCenter( screenPoint );
644
639
 
645
 
  mP.drawArc( surroundingRect, startangle, angle );
 
640
  mP.drawArc( surroundingRect, 16 * startangleDegrees, 16 * angleDegrees );
646
641
 
647
642
  // now for the arrow...
648
 
  QPoint end( static_cast<int>( point.x() + radius * cos( dstartangle + dangle ) ),
649
 
              static_cast<int>( point.y() - radius * sin( dstartangle + dangle ) ) );
650
 
  QPoint vect = (end - point);
 
643
  QPoint end( static_cast<int>( screenPoint.x() + radius * cos( startangle + angle ) ),
 
644
              static_cast<int>( screenPoint.y() - radius * sin( startangle + angle ) ) );
 
645
  QPoint vect = (end - screenPoint);
651
646
  double vectlen = std::sqrt( float( vect.x() * vect.x() + vect.y() * vect.y() ) );
652
647
  QPoint orthvect( -vect.y(), vect.x() );
653
648
  vect = vect * 6 / vectlen;
657
652
  arrow.setPoint( 0, end );
658
653
  arrow.setPoint( 1, end + orthvect + vect );
659
654
  arrow.setPoint( 2, end + orthvect - vect );
660
 
//  std::vector<QPoint> arrow;
661
 
//  arrow.push_back( end );
662
 
//  arrow.push_back( end + orthvect + vect );
663
 
//  arrow.push_back( end + orthvect - vect );
664
655
 
665
656
  setBrushStyle( Qt::SolidPattern );
666
 
//  drawPolygon( arrow );
667
657
  mP.drawPolygon( arrow );
668
658
 
669
659
//  if ( mNeedOverlay ) mOverlay.push_back( toScreen( r ) );