Bug 260518

Summary: Artefacts while rotating thick lines
Product: [Applications] calligracommon Reporter: BKrev <krevert>
Component: generalAssignee: Calligra Bugs <calligra-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: cbo, t.zachmann
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Archlinux   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Screenshot

Description David Faure 2010-12-17 19:41:15 UTC


---- Reported by krevert@gmail.com 2010-06-23 16:53:11 ----

Created an attachment
Screenshot

Version:           svn (using KDE 4.4.4) 
OS:                Linux

Rotating thick lines causes artefacts.

Reproducible: Didn't try

Steps to Reproduce:
1.) Create a line
2.) Make it huge
3.) Rotate it



This solution seems to work:

===================================================================
--- KoPathShape.cpp     (Revision 1138839)
+++ KoPathShape.cpp     (Arbeitskopie)
@@ -24,6 +24,7 @@
 #include "KoPathPoint.h"
 #include "KoPointGroup.h"
 #include "KoShapeBorderModel.h"
+#include "KoLineBorder.h"
 #include "KoViewConverter.h"
 #include "KoPathShapeLoader.h"
 #include "KoShapeSavingContext.h"
@@ -395,6 +396,14 @@
         QRectF clipRect = filterEffectStack()->clipRectForBoundingRect(QRectF(QPointF(), size()));
         bb |= transform.mapRect(clipRect);
     }
+
+    //remove artefacts
+    KoLineBorder *lineBorder = dynamic_cast<KoLineBorder *>(border());
+    if (lineBorder) {
+        qreal halfWidth = lineBorder->lineWidth()/2;
+        bb.adjust(-halfWidth, -halfWidth, halfWidth, halfWidth);
+    }
+
     return bb;
 }



---- Additional Comments From t.zachmann@zagge.de 2010-06-24 08:18:22 ----

The artefact are not shown when the shape(line) is not rotated. So the bouding box returns the correct size. The bug only happens when the e.g. the shape is rotated. Looks more like a bug in the move tool in case the shapes are rotated.

As the bounding box is also used for aligning objects modifying the bounding box is not an option.



---- Additional Comments From t.zachmann@zagge.de 2010-06-24 08:25:08 ----

I did some more testing and it looks more like that the bounding box is not correct in case the shape is rotated.



---- Additional Comments From zander@kde.org 2010-06-26 11:02:04 ----

The boudingbox of path shapes is indeed wrong, its easy to see by inserting any sort of path shape and making the border really large. The default tool draws the outline of the shape in place that doesn't change when the border grows, and as such a big chunk of the actual content falls outside of the bounding box.

The full shape, including the border, has to be contained in the bounding box.

Notice that its easier to see redrawin artifacts if you have two views open and the shape only selected in one of the two views. Rotate it and the other view will show more artifacts.



--- Bug imported by faure@kde.org 2010-12-17 19:42  ---

This bug was previously known as bug 242612.

Imported an attachment (id=54940)

The original submitter of attachment 54940 [details] is unknown.
   Reassigning to the person who moved it here: faure@kde.org.

Comment 1 Camilla Boemann 2012-04-30 21:06:56 UTC
So much confusion in the comments.

Boundingbox is in document coordinates and view aligned and should only be used for finding parts of the screen that needs updating.

Outline is what the shape manipulation tool draws around the shape when rotating. The outline is specified in shape coordinates.

The poster is correct in modifying the bounding box, though it should be done a bit earlier in the code i feel. so scaling etc would also happen to the width.

Bounding box should _never_ be used for calculating (eg aligning shapes). If that is still done it should be fixed. If someone is not convinced: bounding box even includes shadow and filter effect
Comment 2 Camilla Boemann 2012-04-30 21:12:07 UTC
Looking at the code it seems a similar but more advanced fix has been added. I can still get artifacts though
Comment 3 Camilla Boemann 2012-04-30 21:15:14 UTC
ah bah that code is only entered when there is markers, will rearrange the code and then it should be fixed
Comment 4 Camilla Boemann 2012-04-30 21:53:34 UTC
ok it worked but here is something to consider:

In pathshape we stroke the path to create an outline when there are markers. It seems overkill to me. All we need is a bounding box. If there is an easy way to find the length and width of the markers it can be done considerably easier:

1) take the boundingbox of the outline()
2) make a square rect that has side equal to 2*max(length,width) of the start marker
3) same for end marker
4) create a union rect of 1 and 2 (centered on start of path) and 3 (centered on end of path)
Comment 5 Camilla Boemann 2012-05-01 18:21:31 UTC
Git commit 3ae76a85250832092c5fc3510ec4b556cddb6467 by C. Boemann.
Committed on 01/05/2012 at 20:10.
Pushed by boemann into branch 'master'.

Fix artifacts due to linewidth
We just use the method already used for lines with markers.
It's similar idea to what the bug owner posted, just more advanced

M  +6    -10   libs/flake/KoPathShape.cpp

http://commits.kde.org/calligra/3ae76a85250832092c5fc3510ec4b556cddb6467