Bug 270203

Summary: Smoother rounded rectangle, antialiasing
Product: [Applications] kolourpaint Reporter: Victor Varvaryuk <victor.varvariuc>
Component: generalAssignee: Glen Kaukola <gkaukola>
Status: RESOLVED FIXED    
Severity: normal CC: gkaukola
Priority: NOR    
Version First Reported In: Comes with KDE   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: wrong right bottom corner
QPainter::drawRoundedRect()
python and pyqt4 test
Antialiasing setting

Description Victor Varvaryuk 2011-04-06 10:45:51 UTC
Created attachment 58620 [details]
wrong right bottom corner

Version:           Comes with KDE (using KDE 4.6.1) 
OS:                Linux

Rounded rectangle tool draws a rectangle, whose right bottom corner is different than the other corners (see attachment).
Also, it would very cool to have all the drawing tools (line, circle, rounded rectangles, etc.) to support anti-aliasing - have a check-box to enable/disable it either in settings or under line thickness box.

Reproducible: Always




OS: Linux (x86_64) release 2.6.35-28-generic
Compiler: cc
Comment 1 Glen Kaukola 2011-06-10 19:11:56 UTC
It looks like you uploaded the wrong image Victor.
Comment 2 Victor Varvaryuk 2011-06-10 20:02:32 UTC
Hey, it's the right image! Look at the red rounded rectangle around the button for settings of shadow effect.
Comment 3 Glen Kaukola 2011-06-10 23:31:17 UTC
Sorry.  My Mistake.
Comment 4 Glen Kaukola 2011-06-12 05:37:39 UTC
Looks like a Qt problem to me.

I made a simple little Qt app, the meat being:
   QRectF rect(10.0, 20.0, 80.0, 25.0);
   QPainter painter(this);
   painter.setPen(QPen(Qt::blue, 2));
   painter.drawRoundedRect(rect, 15.0, 15.0, Qt::RelativeSize);

And that gives me the same thing.  Screen shot follows.

Anyhow, I'll file a report with the Qt people and see what they have to say.
Comment 5 Glen Kaukola 2011-06-12 05:40:52 UTC
Created attachment 60918 [details]
QPainter::drawRoundedRect()
Comment 6 Glen Kaukola 2011-06-12 06:16:49 UTC
Well, according to this:
http://bugreports.qt.nokia.com/browse/QTBUG-6073

It's from drawing without antialiasing?
Comment 7 Victor Varvaryuk 2011-06-12 08:09:26 UTC
I don't know if it's a bug or not, maybe i am missing something. 
But the rounded rectangle is not rounded at all. See my attached Python and PyQt4 code.

Solutions:
1. Always use antialiasing.
and
2. painter.drawRoundedRect(rect, 15.0, 15.0, Qt::RelativeSize);
>When mode is Qt::RelativeSize, xRadius and yRadius are specified in percentage of half the rectangle's width and height respectively, and should be in the range 0.0 to 100.0.
So maybe use Qt::AbsoluteSize? It gives much nicer corners. Otherwise corners are distorted depending on the size of width/height.
Comment 8 Victor Varvaryuk 2011-06-12 08:10:37 UTC
Created attachment 60920 [details]
python and pyqt4 test

See four rounded rectangles with different parameters: antialiasing and round corners size
Comment 9 Victor Varvaryuk 2011-06-12 08:22:44 UTC
Created attachment 60922 [details]
Antialiasing setting

So what about adding antialiasing setting to lines, rounded rectangles, circles?
Or to all tools (would apply where appropriate?
Comment 10 Martin Koller 2017-02-05 19:19:04 UTC
Git commit 4ac4fa0bebc4b73b0774b8fe5b3d561ce9686375 by Martin Koller.
Committed on 05/02/2017 at 19:14.
Pushed by mkoller into branch 'master'.

Add setting for anti-aliased drawing; lots of code cleanup

The mentioned bug is about rounded rectangle and anti-aliased drawing.
This patch fixes both: rounded-rectangles are now drawn with the same
radius in x and y direction, which makes it look much better and
avoids the mentioned problem in the bug report.
An additional option in the settings menu allows now to define if
the tools draw with anti-aliasing (default) or not.
GUI: added a new option in the settings menu for anti-aliased drawing

M  +5    -0    environments/tools/kpToolEnvironment.cpp
M  +2    -0    environments/tools/kpToolEnvironment.h
M  +0    -81   imagelib/kpPainter.cpp
M  +0    -50   imagelib/kpPainter.h
M  +2    -1    kolourpaintui.rc
M  +1    -0    kpDefs.h
M  +4    -6    layers/selections/kpAbstractSelection.cpp
M  +5    -7    mainWindow/kpMainWindow.cpp
M  +1    -0    mainWindow/kpMainWindow.h
M  +20   -4    mainWindow/kpMainWindow_Settings.cpp
M  +5    -36   pixmapfx/kpPixmapFX.h
M  +8    -222  pixmapfx/kpPixmapFX_DrawShapes.cpp
M  +5    -6    tools/kpToolZoom.cpp
M  +26   -9    tools/polygonal/kpToolCurve.cpp
M  +6    -25   tools/polygonal/kpToolLine.cpp
M  +0    -1    tools/polygonal/kpToolLine.h
M  +37   -9    tools/polygonal/kpToolPolygon.cpp
M  +2    -7    tools/polygonal/kpToolPolygonalBase.cpp
M  +0    -8    tools/polygonal/kpToolPolygonalBase.h
M  +22   -13   tools/polygonal/kpToolPolyline.cpp
M  +1    -2    tools/polygonal/kpToolPolyline.h
M  +39   -4    tools/rectangular/kpToolEllipse.cpp
M  +5    -0    tools/rectangular/kpToolEllipse.h
M  +40   -5    tools/rectangular/kpToolRectangle.cpp
M  +5    -0    tools/rectangular/kpToolRectangle.h
M  +1    -5    tools/rectangular/kpToolRectangularBase.cpp
M  +1    -0    tools/rectangular/kpToolRectangularBase.h
M  +44   -5    tools/rectangular/kpToolRoundedRectangle.cpp
M  +5    -0    tools/rectangular/kpToolRoundedRectangle.h

https://commits.kde.org/kolourpaint/4ac4fa0bebc4b73b0774b8fe5b3d561ce9686375