[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/plugins/pathshapes/enhancedpath
From: Carlos Licea <carlos_licea () hotmail ! com>
Date: 2010-02-28 0:57:36
Message-ID: 1267318656.468228.2921.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1096957 by clicea:
Add the hability to load the draw:mirror-vertical and draw:mirror-horizontal
properties. Unfortunately, they aren't applied because there's a bug somewhere
that deforms the shapes.
M +37 -9 EnhancedPathShape.cpp
M +15 -1 EnhancedPathShape.h
--- trunk/koffice/plugins/pathshapes/enhancedpath/EnhancedPathShape.cpp \
#1096956:1096957 @@ -32,7 +32,7 @@
#include <KoOdfWorkaround.h>
EnhancedPathShape::EnhancedPathShape(const QRectF &viewBox)
-: m_viewBox(viewBox), m_viewBoxOffset(0.0, 0.0)
+: m_viewBox(viewBox), m_viewBoxOffset(0.0, 0.0), m_mirrorVertically(false), \
m_mirrorHorizontally(false) {
}
@@ -89,6 +89,8 @@
m_viewBoxOffset.rx() *= scaleX;
m_viewBoxOffset.ry() *= scaleY;
m_viewMatrix.scale(scaleX, scaleY);
+
+ setMirroring();
}
@@ -295,22 +297,18 @@
QPointF EnhancedPathShape::shapeToViewbox(const QPointF &point) const
{
- return m_viewMatrix.inverted().map(point-m_viewBoxOffset);
+ //NOTE: m_flipMatrix doesn't need to be inverted since when we flip twice the \
efect of the flip is inverted. + return m_viewMatrix.inverted().map( \
m_flipMatrix.map(point)-m_viewBoxOffset ); }
QPointF EnhancedPathShape::viewboxToShape(const QPointF &point) const
{
- return m_viewMatrix.map(point) + m_viewBoxOffset;
+ return m_flipMatrix.map(m_viewMatrix.map(point) + m_viewBoxOffset);
}
-qreal EnhancedPathShape::shapeToViewbox(qreal value) const
-{
- return m_viewMatrix.inverted().map(QPointF(value, value)).x();
-}
-
qreal EnhancedPathShape::viewboxToShape(qreal value) const
{
- return m_viewMatrix.map(QPointF(value, value)).x();
+ return m_flipMatrix.map(m_viewMatrix.map(QPointF(value, value))).x();
}
void EnhancedPathShape::saveOdf(KoShapeSavingContext &context) const
@@ -369,6 +367,9 @@
addModifiers(modifiers);
}
+ setMirrorHorizontally( child.attributeNS(KoXmlNS::draw, \
"mirror-horizontal") == "true"); + setMirrorVertically( \
child.attributeNS(KoXmlNS::draw, "mirror-vertical") == "true"); +
KoXmlElement grandChild;
forEachElement(grandChild, child) {
if (grandChild.namespaceURI() != KoXmlNS::draw)
@@ -445,3 +446,30 @@
if (start != -1)
updatePath(size());
}
+
+void EnhancedPathShape::setMirrorHorizontally(bool mirrorHorizontally)
+{
+ if( m_mirrorHorizontally != mirrorHorizontally) {
+ m_mirrorHorizontally = mirrorHorizontally;
+// setMirroring();
+ }
+}
+
+void EnhancedPathShape::setMirrorVertically(bool mirrorVertically)
+{
+ if( m_mirrorVertically != mirrorVertically) {
+ m_mirrorVertically = mirrorVertically;
+// setMirroring();
+ }
+}
+
+void EnhancedPathShape::setMirroring()
+{
+ qreal centerX = size().width() * 0.5;
+ qreal centerY = size().height() * 0.5;
+
+ m_flipMatrix.reset();
+ m_flipMatrix.translate(centerX, centerY);
+ m_flipMatrix.scale(m_mirrorHorizontally? -1.0 : 1.0, m_mirrorVertically? -1.0 : \
1.0); + m_flipMatrix.translate(-centerX, -centerY);
+}
--- trunk/koffice/plugins/pathshapes/enhancedpath/EnhancedPathShape.h \
#1096956:1096957 @@ -83,9 +83,18 @@
const QRectF & viewBox() const;
QPointF shapeToViewbox(const QPointF &point) const;
QPointF viewboxToShape(const QPointF &point) const;
- qreal shapeToViewbox(qreal value) const;
qreal viewboxToShape(qreal value) const;
+ /// Sets if the shape is to be mirrored horizontally before aplying any other \
transformations + //NOTE: in the standard nothing is mentioned about the \
priorities of the transformations" + //it's assumed like this because of the \
behavior shwon in OOo + void setMirrorHorizontally(bool mirrorHorizontally);
+
+ /// Sets if the shape is to be mirrored vertically before aplying any other \
transformations + //NOTE: in the standard nothing is mentioned about the \
priorities of the transformations" + //it's assumed like this because of the \
behavior shwon in OOo + void setMirrorVertically(bool mirrorVertically);
+
/// Returns parameter from given textual representation
EnhancedPathParameter *parameter(const QString &text);
@@ -107,18 +116,23 @@
/// Adds a new command
void addCommand(const QString &command, bool triggerUpdate);
+ void setMirroring();
+
typedef QMap<QString, EnhancedPathFormula*> FormulaStore;
typedef QList<qreal> ModifierStore;
typedef QMap<QString, EnhancedPathParameter*> ParameterStore;
QRectF m_viewBox;
QMatrix m_viewMatrix;
+ QMatrix m_flipMatrix;
QPointF m_viewBoxOffset;
QList<EnhancedPathCommand*> m_commands; ///< the commands creating the outline
QList<EnhancedPathHandle*> m_enhancedHandles; ///< the handles for modifiying \
the shape FormulaStore m_formulae; ///< the formulae
ModifierStore m_modifiers; ///< the modifier values
ParameterStore m_parameters; ///< the shared parameters
+ bool m_mirrorVertically; ///<whether or not the shape is to be mirrored \
vertically before transforming it + bool m_mirrorHorizontally; ///<whether or not \
the shape is to be mirrored horizontally before transforming it };
#endif // KOENHANCEDPATHSHAPE_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic