[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kig] misc: Use QRectF/QPointF when drawing circles
From: Maurizio Paolini <paolini () dmf ! unicatt ! it>
Date: 2016-03-22 22:28:25
Message-ID: E1aiUmn-00035P-Tb () scm ! kde ! org
[Download RAW message or body]
Git commit 8b02e57b9cfc1494045a082fcb9a609c363298f8 by Maurizio Paolini.
Committed on 22/03/2016 at 22:27.
Pushed by paolini into branch 'master'.
Use QRectF/QPointF when drawing circles
M +11 -1 misc/kigpainter.cpp
M +2 -0 misc/kigpainter.h
M +17 -0 misc/screeninfo.cc
M +2 -0 misc/screeninfo.h
http://commits.kde.org/kig/8b02e57b9cfc1494045a082fcb9a609c363298f8
diff --git a/misc/kigpainter.cpp b/misc/kigpainter.cpp
index e547bf2..d0ef806 100644
--- a/misc/kigpainter.cpp
+++ b/misc/kigpainter.cpp
@@ -86,7 +86,7 @@ void KigPainter::drawCircle( const Coordinate& center, double radius )
Coordinate bottomLeft = center - Coordinate(radius, radius);
Coordinate topRight = center + Coordinate(radius, radius);
Rect r( bottomLeft, topRight );
- QRect qr = toScreen( r );
+ QRectF qr = toScreenF( r );
mP.drawEllipse ( qr );
if( mNeedOverlay ) circleOverlay( center, radius );
}
@@ -506,6 +506,11 @@ QPoint KigPainter::toScreen( const Coordinate& p ) const
return msi.toScreen( p );
}
+QPointF KigPainter::toScreenF( const Coordinate& p ) const
+{
+ return msi.toScreenF( p );
+}
+
void KigPainter::drawGrid( const CoordinateSystem& c, bool showGrid, bool showAxes )
{
c.drawGrid( *this, showGrid, showAxes );
@@ -549,6 +554,11 @@ QRect KigPainter::toScreen( const Rect& r ) const
return msi.toScreen( r );
}
+QRectF KigPainter::toScreenF( const Rect& r ) const
+{
+ return msi.toScreenF( r );
+}
+
QRect KigPainter::toScreenEnlarge( const Rect& r ) const
{
if ( overlayenlarge == 0 ) return msi.toScreen( r );
diff --git a/misc/kigpainter.h b/misc/kigpainter.h
index e36c153..ea4ddae 100644
--- a/misc/kigpainter.h
+++ b/misc/kigpainter.h
@@ -89,6 +89,8 @@ public:
QPoint toScreen( const Coordinate& p ) const;
QRect toScreen( const Rect& r ) const;
+ QPointF toScreenF( const Coordinate& p ) const;
+ QRectF toScreenF( const Rect& r ) const;
QRect toScreenEnlarge( const Rect& r ) const;
Coordinate fromScreen( const QPoint& p ) const;
Rect fromScreen( const QRect& r ) const;
diff --git a/misc/screeninfo.cc b/misc/screeninfo.cc
index 8fdf115..200c0ef 100644
--- a/misc/screeninfo.cc
+++ b/misc/screeninfo.cc
@@ -58,6 +58,23 @@ QRect ScreenInfo::toScreen( const Rect& r ) const
).normalized();
}
+QPointF ScreenInfo::toScreenF( const Coordinate& p ) const
+{
+ Coordinate t = p - mkrect.bottomLeft();
+ t *= mqrect.width();
+ t /= mkrect.width();
+ // invert the y-axis: 0 is at the bottom !
+ return QPointF( t.x, mqrect.height() - t.y );
+}
+
+QRectF ScreenInfo::toScreenF( const Rect& r ) const
+{
+ return QRectF(
+ toScreenF( r.bottomLeft() ),
+ toScreenF( r.topRight() )
+ ).normalized();
+}
+
double ScreenInfo::pixelWidth() const
{
Coordinate a = fromScreen( QPoint( 0, 0 ) );
diff --git a/misc/screeninfo.h b/misc/screeninfo.h
index b7f94c4..c72b599 100644
--- a/misc/screeninfo.h
+++ b/misc/screeninfo.h
@@ -40,6 +40,8 @@ public:
QPoint toScreen( const Coordinate& p ) const;
QRect toScreen( const Rect& r ) const;
+ QPointF toScreenF( const Coordinate& p ) const;
+ QRectF toScreenF( const Rect& r ) const;
double pixelWidth() const;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic