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

List:       kde-commits
Subject:    koffice/plugins/pathshapes/enhancedpath
From:       Thorsten Zachmann <t.zachmann () zagge ! de>
Date:       2010-11-12 12:12:50
Message-ID: 20101112121250.233A4AC89E () svn ! kde ! org
[Download RAW message or body]

SVN commit 1196016 by zachmann:

Fix mirroring of EnhancedPathShape.

It is not perfect yet, but it works much better then before.

CCBUG: 231686


 M  +16 -7     EnhancedPathShape.cpp  
 M  +2 -1      EnhancedPathShape.h  


--- trunk/koffice/plugins/pathshapes/enhancedpath/EnhancedPathShape.cpp \
#1196015:1196016 @@ -81,9 +81,14 @@
 
     m_viewBound = outline().boundingRect();
 
+    m_mirrorMatrix.reset();
+    m_mirrorMatrix.translate(m_viewBound.center().x(), m_viewBound.center().y());
+    m_mirrorMatrix.scale(m_mirrorHorizontally ? -1 : 1, m_mirrorVertically ? -1 : \
1); +    m_mirrorMatrix.translate(-m_viewBound.center().x(), \
-m_viewBound.center().y()); +
     QTransform matrix;
     matrix.translate(m_viewBoxOffset.x(), m_viewBoxOffset.y());
-    matrix = m_viewMatrix * matrix;
+    matrix = m_mirrorMatrix * m_viewMatrix * matrix;
 
     KoSubpathList::const_iterator pathIt(m_subpaths.constBegin());
     for (; pathIt != m_subpaths.constEnd(); ++pathIt) {
@@ -103,6 +108,7 @@
 
 void EnhancedPathShape::setSize(const QSizeF &newSize)
 {
+    // handle offset
     KoParameterShape::setSize(newSize);
 
     // calculate scaling factors from viewbox size to shape size
@@ -111,9 +117,7 @@
 
     // create view matrix, take mirroring into account
     m_viewMatrix.reset();
-    m_viewMatrix.translate(m_viewBound.center().x(), m_viewBound.center().y());
-    m_viewMatrix.scale(m_mirrorHorizontally ? -xScale : xScale, m_mirrorVertically ? \
                -yScale : yScale);
-    m_viewMatrix.translate(-m_viewBound.center().x(), -m_viewBound.center().y());
+    m_viewMatrix.scale(xScale, yScale);
 
     updatePath(newSize);
 }
@@ -129,7 +133,7 @@
 
 QPointF EnhancedPathShape::shapeToViewbox(const QPointF &point) const
 {
-    return m_viewMatrix.inverted().map( point-m_viewBoxOffset );
+    return (m_mirrorMatrix * m_viewMatrix).inverted().map( point-m_viewBoxOffset );
 }
 
 void EnhancedPathShape::evaluateHandles()
@@ -412,6 +416,10 @@
             }
 
         }
+
+        setMirrorHorizontally(enhancedGeometry.attributeNS(KoXmlNS::draw, \
"mirror-horizontal") == "true"); +        \
setMirrorVertically(enhancedGeometry.attributeNS(KoXmlNS::draw, "mirror-vertical") == \
"true"); +
         // load the enhanced path data
         QString path = enhancedGeometry.attributeNS(KoXmlNS::draw, "enhanced-path", \
"");  #ifndef NWORKAROUND_ODF_BUGS
@@ -431,8 +439,6 @@
             m_viewBox = m_viewBound;
         }
 
-        setMirrorHorizontally(enhancedGeometry.attributeNS(KoXmlNS::draw, \
                "mirror-horizontal") == "true");
-        setMirrorVertically(enhancedGeometry.attributeNS(KoXmlNS::draw, \
"mirror-vertical") == "true");  }
 
     QSizeF size;
@@ -491,12 +497,15 @@
 {
     if( m_mirrorHorizontally != mirrorHorizontally) {
         m_mirrorHorizontally = mirrorHorizontally;
+        updatePath(size());
     }
+
 }
 
 void EnhancedPathShape::setMirrorVertically(bool mirrorVertically)
 {
     if( m_mirrorVertically != mirrorVertically) {
         m_mirrorVertically = mirrorVertically;
+        updatePath(size());
     }
 }
--- trunk/koffice/plugins/pathshapes/enhancedpath/EnhancedPathShape.h \
#1196015:1196016 @@ -114,8 +114,8 @@
     virtual void moveHandleAction(int handleId, const QPointF &point, \
Qt::KeyboardModifiers modifiers = Qt::NoModifier);  // from KoParameterShape
     virtual void updatePath(const QSizeF &size);
+
 private:
-
     void evaluateHandles();
     void reset();
 
@@ -132,6 +132,7 @@
     QRectF m_viewBox;     ///< the viewbox rectangle
     QRectF m_viewBound;   ///< the bounding box of the path in viewbox coordinates
     QTransform m_viewMatrix; ///< matrix to convert from viewbox coordinates to \
shape coordinates +    QTransform m_mirrorMatrix; ///< matrix to used for mirroring
     QPointF m_viewBoxOffset;
     QList<EnhancedPathCommand*> m_commands; ///< the commands creating the outline
     QList<EnhancedPathHandle*> m_enhancedHandles; ///< the handles for modifiying \
the shape


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

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