Commit f9412c55 authored by Thorsten Zachmann's avatar Thorsten Zachmann

o let normalize return the diff in shape coordinates

  This fixes e.g. undoing of point deletion in rotated objects and is
  also needed for the ellipse I'm working on at the moment.
o Add a new typedef for the path shapes as discussed with Jan last
  weekend  

svn path=/trunk/koffice/; revision=605429
parent f7fce9cd
...@@ -117,3 +117,18 @@ void KoParameterShape::resize( const QSizeF &newSize ) ...@@ -117,3 +117,18 @@ void KoParameterShape::resize( const QSizeF &newSize )
KoPathShape::resize( newSize ); KoPathShape::resize( newSize );
} }
QPointF KoParameterShape::normalize()
{
QPointF offset( KoPathShape::normalize() );
QMatrix matrix;
matrix.translate( -offset.x(), -offset.y() );
for( int i = 0; i < m_handles.size(); ++i )
{
m_handles[i] = matrix.map( m_handles[i] );
}
return offset;
}
...@@ -93,6 +93,8 @@ public: ...@@ -93,6 +93,8 @@ public:
*/ */
void setModified( bool modified ) { m_modified = modified; } void setModified( bool modified ) { m_modified = modified; }
virtual QPointF normalize();
protected: protected:
/** /**
* @brief Updates the internal state of a KoParameterShape. * @brief Updates the internal state of a KoParameterShape.
......
...@@ -32,11 +32,15 @@ KoPathBaseCommand::KoPathBaseCommand( KoPathShape *shape ) ...@@ -32,11 +32,15 @@ KoPathBaseCommand::KoPathBaseCommand( KoPathShape *shape )
void KoPathBaseCommand::repaint( const QRectF &oldControlPointRect ) void KoPathBaseCommand::repaint( const QRectF &oldControlPointRect )
{ {
QRectF repaintRect( oldControlPointRect );
repaintRect.adjust( -5.0, -5.0, 5.0, 5.0 );
m_shape->repaint( oldControlPointRect );
// the bounding rect has changed -> normalize // the bounding rect has changed -> normalize
QPointF offset = m_shape->normalize(); m_shape->normalize();
// adjust the old control rect as the repainting is relative to the new shape position // adjust the old control rect as the repainting is relative to the new shape position
QRectF repaintRect = oldControlPointRect.translated( -offset ).unite( m_shape->outline().controlPointRect() ); repaintRect = m_shape->outline().controlPointRect();
// TODO use the proper adjustment if the actual point size could be retrieved // TODO use the proper adjustment if the actual point size could be retrieved
repaintRect.adjust( -5.0, -5.0, 5.0, 5.0 ); repaintRect.adjust( -5.0, -5.0, 5.0, 5.0 );
m_shape->repaint( repaintRect ); m_shape->repaint( repaintRect );
......
...@@ -701,7 +701,7 @@ QPointF KoPathShape::normalize() ...@@ -701,7 +701,7 @@ QPointF KoPathShape::normalize()
QPointF newTL( boundingRect().topLeft() ); QPointF newTL( boundingRect().topLeft() );
QPointF diff( oldTL - newTL ); QPointF diff( oldTL - newTL );
moveBy( diff.x(), diff.y() ); moveBy( diff.x(), diff.y() );
return diff; return tl;
} }
void KoPathShape::map( const QMatrix &matrix ) void KoPathShape::map( const QMatrix &matrix )
......
...@@ -36,6 +36,8 @@ class KoPointGroup; ...@@ -36,6 +36,8 @@ class KoPointGroup;
class KoPathPoint; class KoPathPoint;
typedef QMap<KoPathShape *, QSet<KoPathPoint *> > KoPathShapePointMap; typedef QMap<KoPathShape *, QSet<KoPathPoint *> > KoPathShapePointMap;
typedef QPair<int,int> KoPathPointIndex;
typedef QMap<KoPathShape *, QSet<KoPathPointIndex> > KoPathShapePointIndexMap;
/** /**
* @brief A KoPathPoint represents a point in a path. * @brief A KoPathPoint represents a point in a path.
...@@ -422,9 +424,9 @@ public: ...@@ -422,9 +424,9 @@ public:
* The path points are transformed so that the top-left corner * The path points are transformed so that the top-left corner
* of the bounding rect is (0,0). * of the bounding rect is (0,0).
* This should be called after adding points to the path. * This should be called after adding points to the path.
* @return the offset by which the points are moved. * @return the offset by which the points are moved in shape coordinates.
*/ */
QPointF normalize(); virtual QPointF normalize();
/** /**
* @brief Returns the path points within the given rectangle. * @brief Returns the path points within the given rectangle.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment