[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: Review Request: Fixes missing translation of the KoShapeContainter
From:       "Johannes Simon" <johannes.simon () gmail ! com>
Date:       2010-10-09 15:16:37
Message-ID: 20101009151637.2937.27102 () vidsolbach ! de
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


> On 2010-10-01 12:59:33, Johannes Simon wrote:
> > Mhh. I wonder why this works for charts that you manually insert into documents \
> > (or anything I've tested so far). Do they still show up correctly with your \
> > patch? The painter itself should probably be translated before \
> > KoShapeContainer::paint() is called (which it is, maybe just not correctly) and \
> > that trivially handles the transformation of the container. Maybe a caller of \
> > KoShapeContainer::paint() or KoShape::paint() does not transform the painter \
> > correctly?
> 
> Björn Breitmeyer wrote:
> Well i have found some problems and am still not sure why they occur, in kspread \
> and with newly added chartshapes the size of the chart has to be increased for the \
> content to become visible. Im still unsure about the zoom, specifically i don't \
> know why the zoom should matter to the bounding box test at all. But the design is \
> generally very complicated an scene graph like approach would be easier to handle \
> as only local transformations need to be applied to make sure the bounding box test \
> works correctly. 
> Regarding the painter issue, thats the fascinating thing, the diagram drawing is \
> fully independent to the bounding box check, it draws everything correctly if the \
> bounding box test does not prohibit it. Deleting the bounding box test shows the \
> chart legend as expected. 
> Björn Breitmeyer wrote:
> Ah and regarding the fact that this works for everything you have tested so far i \
> have a very good explanation. There is a shape level more in the loaded kword \
> documents, this layer is not present if you just add a new chart to the document or \
> use another program.

I looked at your patch and I am pretty sure it is incorrect - Setting the painter's \
transformation (as done in the folling excerpt from KoShapeContainer::paint()) \
automatically transforms its current clipPath():

        painter.save();
        painter.setTransform(shape->absoluteTransformation(&converter) * baseMatrix);
        shape->paint(painter, converter);

Thus, your patch only does that a second time (leading to a wrong clip path).

My rough guess is that something is wrong with the intersection test in \
KoShapeContainer::paint()

        if (!toPaintRect.intersects(shape->boundingRect()))

Could you try the folling patch?

diff --git a/libs/flake/KoShapeContainer.cpp b/libs/flake/KoShapeContainer.cpp
index ea269a3..0c3cf5a 100644
--- a/libs/flake/KoShapeContainer.cpp
+++ b/libs/flake/KoShapeContainer.cpp
@@ -158,12 +158,14 @@ void KoShapeContainer::paint(QPainter &painter, const \
KoViewConverter &converter  qreal zoomX, zoomY;
     converter.zoom(&zoomX, &zoomY);
     m.scale(zoomX, zoomY);
-    if ( parent() )
-        m *= absoluteTransformation(&converter);
     painter.setClipPath(m.map(outline()));
 
-    QRectF toPaintRect = \
                converter.viewToDocument(painter.clipRegion().boundingRect());
-    toPaintRect = transform().mapRect(toPaintRect);
+    // We'll use this clipRect to see if our child shapes lie within it.
+    // Because shape->boundingRect() uses absoluteTransformation(0) we'll
+    // use that as well to have the same (absolute) reference transformation
+    // of our and the child's bounding boxes.
+    QTransform absTrans = absoluteTransformation(0);
+    QRectF clipRect = absTrans.map(outline()).boundingRect();
 
     foreach(KoShape *shape, sortedObjects) {
         //kDebug(30006) <<"KoShapeContainer::painting shape:" << shape->shapeId() \
<<"," << shape->boundingRect(); @@ -172,7 +174,7 @@ void \
                KoShapeContainer::paint(QPainter &painter, const KoViewConverter \
                &converter
         if (!isClipped(shape))  // the shapeManager will have to draw those, or else \
we can't do clipRects  continue;
         // don't try to draw a child shape that is not in the clipping rect of the \
                painter.
-        if (!toPaintRect.intersects(shape->boundingRect()))
+        if (!clipRect.intersects(shape->boundingRect()))
             continue;
 
         painter.save();


- Johannes


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://svn.reviewboard.kde.org/r/5505/#review7920
-----------------------------------------------------------


On 2010-10-01 14:24:13, Björn Breitmeyer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://svn.reviewboard.kde.org/r/5505/
> -----------------------------------------------------------
> 
> (Updated 2010-10-01 14:24:13)
> 
> 
> Review request for KOffice.
> 
> 
> Summary
> -------
> 
> The KoShapeContainer was assuming it is a top level component, so it did not \
> translated its own outline before testing if the child shapes intersect with it. \
> This lead to missing legends in msoo documents. Fixed it by applying the \
> transformation of the own object. 
> 
> Diffs
> -----
> 
> /trunk/koffice/libs/flake/KoShapeContainer.cpp 1180844 
> 
> Diff: http://svn.reviewboard.kde.org/r/5505/diff
> 
> 
> Testing
> -------
> 
> Tested with some documents.
> 
> 
> Thanks,
> 
> Björn
> 
> 


[Attachment #5 (text/html)]

<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;">  <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="http://svn.reviewboard.kde.org/r/5505/">http://svn.reviewboard.kde.org/r/5505/</a>
  </td>
    </tr>
   </table>
   <br />





<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;">  <p style="margin-top: 0;">On October 1st, 2010, 12:59 p.m., <b>Johannes \
Simon</b> wrote:</p>  <blockquote style="margin-left: 1em; border-left: 2px solid \
#d0d0d0; padding-left: 10px;">  <pre style="white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">Mhh. I wonder why this works for charts that you manually insert into \
documents (or anything I&#39;ve tested so far). Do they still show up correctly with \
your patch? The painter itself should probably be translated before \
KoShapeContainer::paint() is called (which it is, maybe just not correctly) and that \
trivially handles the transformation of the container. Maybe a caller of \
KoShapeContainer::paint() or KoShape::paint() does not transform the painter \
correctly?</pre>  </blockquote>




 <p>On October 1st, 2010, 1:33 p.m., <b>Björn Breitmeyer</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;">  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Well i have found some \
problems and am still not sure why they occur, in kspread and with newly added \
chartshapes the size of the chart has to be increased for the content to become \
visible. Im still unsure about the zoom, specifically i don&#39;t know why the zoom \
should matter to the bounding box test at all. But the design is generally very \
complicated an scene graph like approach would be easier to handle as only local \
transformations need to be applied to make sure the bounding box test works \
correctly.

Regarding the painter issue, thats the fascinating thing, the diagram drawing is \
fully independent to the bounding box check, it draws everything correctly if the \
bounding box test does not prohibit it. Deleting the bounding box test shows the \
chart legend as expected.</pre>  </blockquote>





 <p>On October 1st, 2010, 2:03 p.m., <b>Björn Breitmeyer</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;">  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Ah and regarding the \
fact that this works for everything you have tested so far i have a very good \
explanation. There is a shape level more in the loaded kword documents, this layer is \
not present if you just add a new chart to the document or use another program.</pre>
 </blockquote>








</blockquote>

<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I looked at your patch \
and I am pretty sure it is incorrect - Setting the painter&#39;s transformation (as \
done in the folling excerpt from KoShapeContainer::paint()) automatically transforms \
its current clipPath():

        painter.save();
        painter.setTransform(shape-&gt;absoluteTransformation(&amp;converter) * \
baseMatrix);  shape-&gt;paint(painter, converter);

Thus, your patch only does that a second time (leading to a wrong clip path).

My rough guess is that something is wrong with the intersection test in \
KoShapeContainer::paint()

        if (!toPaintRect.intersects(shape-&gt;boundingRect()))

Could you try the folling patch?

diff --git a/libs/flake/KoShapeContainer.cpp b/libs/flake/KoShapeContainer.cpp
index ea269a3..0c3cf5a 100644
--- a/libs/flake/KoShapeContainer.cpp
+++ b/libs/flake/KoShapeContainer.cpp
@@ -158,12 +158,14 @@ void KoShapeContainer::paint(QPainter &amp;painter, const \
KoViewConverter &amp;converter  qreal zoomX, zoomY;
     converter.zoom(&amp;zoomX, &amp;zoomY);
     m.scale(zoomX, zoomY);
-    if ( parent() )
-        m *= absoluteTransformation(&amp;converter);
     painter.setClipPath(m.map(outline()));
 
-    QRectF toPaintRect = \
                converter.viewToDocument(painter.clipRegion().boundingRect());
-    toPaintRect = transform().mapRect(toPaintRect);
+    // We&#39;ll use this clipRect to see if our child shapes lie within it.
+    // Because shape-&gt;boundingRect() uses absoluteTransformation(0) we&#39;ll
+    // use that as well to have the same (absolute) reference transformation
+    // of our and the child&#39;s bounding boxes.
+    QTransform absTrans = absoluteTransformation(0);
+    QRectF clipRect = absTrans.map(outline()).boundingRect();
 
     foreach(KoShape *shape, sortedObjects) {
         //kDebug(30006) &lt;&lt;&quot;KoShapeContainer::painting shape:&quot; \
&lt;&lt; shape-&gt;shapeId() &lt;&lt;&quot;,&quot; &lt;&lt; shape-&gt;boundingRect(); \
@@ -172,7 +174,7 @@ void KoShapeContainer::paint(QPainter &amp;painter, const \
                KoViewConverter &amp;converter
         if (!isClipped(shape))  // the shapeManager will have to draw those, or else \
we can&#39;t do clipRects  continue;
         // don&#39;t try to draw a child shape that is not in the clipping rect of \
                the painter.
-        if (!toPaintRect.intersects(shape-&gt;boundingRect()))
+        if (!clipRect.intersects(shape-&gt;boundingRect()))
             continue;
 
         painter.save();</pre>
<br />








<p>- Johannes</p>


<br />
<p>On October 1st, 2010, 2:24 p.m., Björn Breitmeyer wrote:</p>






<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('http://svn.reviewboard.kde.orgrb/images/review_request_box_top_bg.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;">  <tr>
  <td>

<div>Review request for KOffice.</div>
<div>By Björn Breitmeyer.</div>


<p style="color: grey;"><i>Updated 2010-10-01 14:24:13</i></p>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">The KoShapeContainer was assuming it is a top level component, so it did \
not translated its own outline before testing if the child shapes intersect with it. \
This lead to missing legends in msoo documents. Fixed it by applying the \
transformation of the own object.</pre>  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0">  <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">Tested with some documents.</pre>  </td>
 </tr>
</table>




<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>/trunk/koffice/libs/flake/KoShapeContainer.cpp <span style="color: \
grey">(1180844)</span></li>

</ul>

<p><a href="http://svn.reviewboard.kde.org/r/5505/diff/" style="margin-left: \
3em;">View Diff</a></p>




  </td>
 </tr>
</table>








  </div>
 </body>
</html>



_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic