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

List:       koffice-devel
Subject:    kpresenter patch. more code cleanup
From:       Thorsten Zachmann <t.zachmann () zagge ! de>
Date:       2004-02-02 5:07:05
Message-ID: 200402020607.06148.t.zachmann () zagge ! de
[Download RAW message or body]

Hello all,

the attached patch moves commen functions of KPPointObjects to the base class. 
Also the base class is put in its own file. So if there are changes there not 
all objects have to be recompiled.

What do you think. If there are no objections I will commit tomorrow.

Thorsten	

["patch70" (text/x-diff)]

Index: kppointobject.h
===================================================================
RCS file: kppointobject.h
diff -N kppointobject.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ kppointobject.h	31 Jan 2004 15:54:52 -0000
@@ -0,0 +1,64 @@
+// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
+/* This file is part of the KDE project
+   Copyright (C) 2004 Thorsten Zachmann  <zachmann@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+*/
+
+#ifndef kppointobject_h
+#define kppointobject_h
+
+#include "kpobject.h"
+
+class KPPointObject : public KPShadowObject
+{
+public:
+    KPPointObject();
+    KPPointObject( const QPen &_pen, LineEnd _lineBegin, LineEnd _lineEnd );
+    KPPointObject( const QPen &_pen, LineEnd _lineBegin, LineEnd _lineEnd, const \
QBrush &_brush ); +
+    virtual KoSize getRealSize() const;
+    virtual KoPoint getRealOrig() const;
+
+    virtual QDomDocumentFragment save( QDomDocument& doc, double offset );
+    virtual double load( const QDomElement &element );
+
+    virtual void setLineBegin( LineEnd _lineBegin ) { lineBegin = _lineBegin; }
+    virtual void setLineEnd( LineEnd _lineEnd ) { lineEnd = _lineEnd; }
+    
+    virtual LineEnd getLineBegin() const { return lineBegin; }
+    virtual LineEnd getLineEnd() const { return lineEnd; }
+    
+    virtual void setSize( double _width, double _height );
+    virtual void setSize( const KoSize & _size )
+        { setSize( _size.width(), _size.height() ); }
+    
+    virtual void flip( bool horizontal );
+
+    virtual void closeObject( bool close );
+    virtual bool isClosed() const;
+
+protected:
+    virtual void paint( QPainter *_painter,KoZoomHandler*_zoomHandler,
+                        bool drawingShadow, bool drawContour = FALSE );
+    virtual void updatePoints( double _fx, double _fy );
+    virtual KoPointArray getDrawingPoints();
+
+    KoPointArray points;
+    LineEnd lineBegin, lineEnd;
+};
+
+#endif
Index: kppointobject.cc
===================================================================
RCS file: kppointobject.cc
diff -N kppointobject.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ kppointobject.cc	31 Jan 2004 15:54:52 -0000
@@ -0,0 +1,281 @@
+// -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
+/* This file is part of the KDE project
+   Copyright (C) 2004 Thorsten Zachmann  <zachmann@kde.org>
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public License
+   along with this library; see the file COPYING.LIB.  If not, write to
+   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+*/
+
+#include "kppointobject.h"
+#include "kpresenter_utils.h"
+#include <kozoomhandler.h>
+
+#include <qdom.h>
+#include <qpainter.h>
+
+KPPointObject::KPPointObject()
+    : KPShadowObject(), lineBegin(L_NORMAL), lineEnd( L_NORMAL )
+{
+}
+
+
+KPPointObject::KPPointObject( const QPen &_pen, LineEnd _lineBegin, LineEnd _lineEnd \
) +    : KPShadowObject( _pen ), lineBegin(_lineBegin), lineEnd(_lineEnd)
+{
+}
+
+
+  KPPointObject::KPPointObject( const QPen &_pen, LineEnd _lineBegin, LineEnd \
_lineEnd, const QBrush &_brush ) +    : KPShadowObject( _pen, _brush ), \
lineBegin(_lineBegin), lineEnd(_lineEnd) +{
+}
+
+
+KoSize KPPointObject::getRealSize() const
+{
+    KoSize size( ext );
+    KoPoint realOrig( orig );
+    KoPointArray p( points );
+    getRealSizeAndOrigFromPoints( p, angle, size, realOrig );
+    return size;
+}
+
+
+KoPoint KPPointObject::getRealOrig() const
+{
+    KoSize size( ext );
+    KoPoint realOrig( orig );
+    KoPointArray p( points );
+    getRealSizeAndOrigFromPoints( p, angle, size, realOrig );
+    return realOrig;
+}
+
+
+QDomDocumentFragment KPPointObject::save( QDomDocument& doc, double offset )
+{
+    QDomDocumentFragment fragment = KPShadowObject::save( doc, offset );
+    if ( !points.isNull() ) {
+        QDomElement elemPoints = doc.createElement( "POINTS" );
+        KoPointArray::ConstIterator it;
+        for ( it = points.begin(); it != points.end(); ++it ) {
+            QDomElement elemPoint = doc.createElement( "Point" );
+            KoPoint point = (*it);
+            elemPoint.setAttribute( "point_x", point.x() );
+            elemPoint.setAttribute( "point_y", point.y() );
+
+            elemPoints.appendChild( elemPoint );
+        }
+        fragment.appendChild( elemPoints );
+    }
+
+    if ( lineBegin != L_NORMAL )
+        fragment.appendChild( KPObject::createValueElement( "LINEBEGIN",
+                                                            static_cast<int>( \
lineBegin ), doc ) ); +
+    if ( lineEnd != L_NORMAL )
+        fragment.appendChild( KPObject::createValueElement( "LINEEND",
+                                                            static_cast<int>( \
lineEnd ), doc ) ); +
+    return fragment;
+}
+
+
+double KPPointObject::load( const QDomElement &element )
+{
+    double offset = KPShadowObject::load( element );
+
+    QDomElement e = element.namedItem( "POINTS" ).toElement();
+    if ( !e.isNull() ) {
+        QDomElement elemPoint = e.firstChild().toElement();
+        unsigned int index = 0;
+        while ( !elemPoint.isNull() ) {
+            if ( elemPoint.tagName() == "Point" ) {
+                double tmpX = 0;
+                double tmpY = 0;
+                if( elemPoint.hasAttribute( "point_x" ) )
+                    tmpX = elemPoint.attribute( "point_x" ).toDouble();
+                if( elemPoint.hasAttribute( "point_y" ) )
+                    tmpY = elemPoint.attribute( "point_y" ).toDouble();
+
+                points.putPoints( index, 1, tmpX,tmpY );
+            }
+            elemPoint = elemPoint.nextSibling().toElement();
+            ++index;
+        }
+    }
+
+    e = element.namedItem( "LINEBEGIN" ).toElement();
+    if( !e.isNull() ) {
+        int tmp = 0;
+        if( e.hasAttribute( "value" ) )
+            tmp = e.attribute( "value" ).toInt();
+        lineBegin = static_cast<LineEnd>( tmp );
+    }
+
+    e = element.namedItem( "LINEEND" ).toElement();
+    if( !e.isNull() ) {
+        int tmp = 0;
+        if( e.hasAttribute( "value" ) )
+            tmp = e.attribute( "value" ).toInt();
+        lineEnd = static_cast<LineEnd>( tmp );
+    }
+
+    return offset;
+}
+
+
+void KPPointObject::setSize( double _width, double _height )
+{
+    KoSize origSize( ext );
+    KPObject::setSize( _width, _height );
+
+    double fx = ext.width() / origSize.width();
+    double fy = ext.height() / origSize.height();
+
+    updatePoints( fx, fy );
+}
+
+
+void KPPointObject::flip( bool horizontal )
+{
+    KPObject::flip( horizontal );
+
+    KoPointArray tmpPoints;
+    int index = 0;
+    if ( horizontal )
+    {
+        KoPointArray::ConstIterator it;
+        double horiz = getSize().height()/2;
+        for ( it = points.begin(); it != points.end(); ++it ) {
+            KoPoint point = (*it);
+            if ( point.y()> horiz )
+                tmpPoints.putPoints( index, 1, point.x(),point.y()- \
2*(point.y()-horiz) ); +            else
+                tmpPoints.putPoints( index, 1, point.x(),point.y()+ 2*(horiz - \
point.y()) ); +            ++index;
+        }
+    }
+    else
+    {
+        KoPointArray::ConstIterator it;
+        double vert = getSize().width()/2;
+        for ( it = points.begin(); it != points.end(); ++it ) {
+            KoPoint point = (*it);
+            if ( point.x()> vert )
+                tmpPoints.putPoints( index, 1, point.x()- 2*(point.x()-vert), \
point.y() ); +            else
+                tmpPoints.putPoints( index, 1, point.x()+ 2*(vert - \
point.x()),point.y() ); +            ++index;
+        }
+    }
+
+    points = tmpPoints;
+}
+
+
+void KPPointObject::closeObject( bool close )
+{
+    points = getCloseObject( points, close, isClosed() );
+}
+
+
+bool KPPointObject::isClosed() const
+{
+    return ( points.at(0) == points.at(points.count()-1) );
+}
+
+
+void KPPointObject::paint( QPainter* _painter, KoZoomHandler*_zoomHandler,
+                           bool /*drawingShadow*/, bool drawContour )
+{
+    int _w = pen.width();
+
+    QPen pen2;
+    if ( drawContour ) {
+        pen2 = QPen( Qt::black, 1, Qt::DotLine );
+        _painter->setRasterOp( Qt::NotXorROP );
+    }
+    else {
+        pen2 = pen;
+        pen2.setWidth( _zoomHandler->zoomItX( pen.width() ) );
+    }
+    _painter->setPen( pen2 );
+
+    QPointArray pointArray = getDrawingPoints().zoomPointArray( _zoomHandler, _w );
+    _painter->drawPolyline( pointArray );
+
+    if ( lineBegin != L_NORMAL && !drawContour && !isClosed()) {
+        QPoint startPoint;
+        bool first = true;
+        QPointArray::ConstIterator it1;
+        for ( it1 = pointArray.begin(); it1 != pointArray.end(); ++it1 ) {
+            if ( first ) {
+                startPoint = (*it1);
+                first = false;
+            }
+
+            QPoint point = (*it1);
+            if ( startPoint != point ) {
+                float angle = KoPoint::getAngle( startPoint, point );
+                drawFigureWithOffset( lineBegin, _painter, startPoint, pen2.color(), \
_w, angle,_zoomHandler ); +
+                break;
+            }
+        }
+    }
+
+    if ( lineEnd != L_NORMAL && !drawContour &&!isClosed()) {
+        QPoint endPoint;
+        bool last = true;
+        QPointArray::ConstIterator it2 = pointArray.end();
+        for ( it2 = it2 - 1; it2 != pointArray.begin(); --it2 ) {
+            if ( last ) {
+                endPoint = (*it2);
+                last = false;
+            }
+
+            QPoint point = (*it2);
+            if ( endPoint != point ) {
+                float angle = KoPoint::getAngle( endPoint, point );
+                drawFigureWithOffset( lineEnd, _painter, endPoint, pen2.color(), _w, \
angle,_zoomHandler ); +
+                break;
+            }
+        }
+    }
+}
+
+
+void KPPointObject::updatePoints( double _fx, double _fy )
+{
+    int index = 0;
+    KoPointArray tmpPoints;
+    KoPointArray::ConstIterator it;
+    for ( it = points.begin(); it != points.end(); ++it ) {
+        KoPoint point = (*it);
+        double tmpX = point.x() * _fx;
+        double tmpY = point.y() * _fy;
+
+        tmpPoints.putPoints( index, 1, tmpX,tmpY );
+        ++index;
+    }
+    points = tmpPoints;
+}
+
+
+KoPointArray KPPointObject::getDrawingPoints()
+{
+  return points;
+}
Index: Makefile.am
===================================================================
RCS file: /home/kde/koffice/kpresenter/Makefile.am,v
retrieving revision 1.211
diff -u -3 -p -r1.211 Makefile.am
--- Makefile.am	8 Jan 2004 15:54:29 -0000	1.211
+++ Makefile.am	31 Jan 2004 15:54:58 -0000
@@ -27,7 +27,7 @@ libkpresenterpart_la_SOURCES = koPointAr
 	sidebar.cc \
 	insertpagedia.ui generalconfig.ui \
 	kpresenter_dlg_config.cc kprvariable.cc kprdrag.cc \
-	kprtextdocument.cc kpfreehandobject.cc kppolylineobject.cc \
+	kprtextdocument.cc kppointobject.cc kpfreehandobject.cc kppolylineobject.cc \
 	kpquadricbeziercurveobject.cc kpcubicbeziercurveobject.cc \
 	confpolygondia.cc kppolygonobject.cc notebar.cc \
 	KPTextObjectIface.skel KPTextObjectIface.cc \
@@ -74,7 +74,7 @@ noinst_HEADERS = koPointArray.h kprcanva
 		kpresenter_factory.h kpresenter_aboutdata.h \
 		KPresenterDocIface.h KPresenterViewIface.h KPresenterObjectIface.h \
 		KPresenterPageIface.h sidebar.h  kpresenter_dlg_config.h \
-		kprvariable.h kprdrag.h notebar.h kprtextdocument.h kpfreehandobject.h \
+		kprvariable.h kprdrag.h notebar.h kprtextdocument.h kppointobject.h \
kpfreehandobject.h \  kppolylineobject.h kpquadricbeziercurveobject.h \
kpcubicbeziercurveobject.h \  confpolygondia.h kppolygonobject.h KPTextViewIface.h \
KPTextObjectIface.h \  presdurationdia.h KPPieObjectIface.h KPPolygonObjectIface.h \
                KPRectObjectIface.h KPPixmapObjectIface.h \
Index: kpcubicbeziercurveobject.h
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpcubicbeziercurveobject.h,v
retrieving revision 1.23
diff -u -3 -p -r1.23 kpcubicbeziercurveobject.h
--- kpcubicbeziercurveobject.h	30 Dec 2003 08:38:50 -0000	1.23
+++ kpcubicbeziercurveobject.h	31 Jan 2004 15:54:58 -0000
@@ -21,10 +21,7 @@
 #ifndef kpcubicbeziercurveobject_h
 #define kpcubicbeziercurveobject_h
 
-#include <qpointarray.h>
-#include "koPointArray.h"
-#include "kpobject.h"
-#include <koSize.h>
+#include "kppointobject.h"
 
 class QPainter;
 class DCOPObject;
@@ -53,10 +50,8 @@ public:
 
 
 protected:
-    virtual void paint( QPainter *_painter,KoZoomHandler*_zoomHandler,
-                        bool drawingShadow, bool drawContour = FALSE );
-
     virtual void updatePoints( double _fx, double _fy );
+    virtual KoPointArray getDrawingPoints();
 
     KoPointArray getCubicBezierPointsFrom( const KoPointArray &_pointArray );
 
Index: kpcubicbeziercurveobject.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpcubicbeziercurveobject.cc,v
retrieving revision 1.39
diff -u -3 -p -r1.39 kpcubicbeziercurveobject.cc
--- kpcubicbeziercurveobject.cc	30 Dec 2003 08:38:50 -0000	1.39
+++ kpcubicbeziercurveobject.cc	31 Jan 2004 15:54:58 -0000
@@ -74,66 +74,6 @@ double KPCubicBezierCurveObject::load(co
     return offset;
 }
 
-void KPCubicBezierCurveObject::paint( QPainter* _painter, \
                KoZoomHandler*_zoomHandler,
-                                      bool /*drawingShadow*/, bool drawContour )
-{
-    int _w = pen.width();
-
-    QPen pen2;
-    if ( drawContour ) {
-        pen2 = QPen( Qt::black, 1, Qt::DotLine );
-        _painter->setRasterOp( Qt::NotXorROP );
-    }
-    else {
-        pen2 = pen;
-        pen2.setWidth( _zoomHandler->zoomItX( pen.width() ) );
-    }
-    _painter->setPen( pen2 );
-
-    QPointArray pointArray = allPoints.zoomPointArray( _zoomHandler, _w );
-    _painter->drawPolyline( pointArray );
-
-    if ( lineBegin != L_NORMAL && !drawContour && !isClosed()) {
-        QPoint startPoint;
-        bool first = true;
-        QPointArray::ConstIterator it1;
-        for ( it1 = pointArray.begin(); it1 != pointArray.end(); ++it1 ) {
-            if ( first ) {
-                startPoint = (*it1);
-                first = false;
-            }
-
-            QPoint point = (*it1);
-            if ( startPoint != point ) {
-                float angle = KoPoint::getAngle( startPoint, point );
-                drawFigureWithOffset( lineBegin, _painter, startPoint, pen2.color(), \
                _w, angle,_zoomHandler );
-
-                break;
-            }
-        }
-    }
-
-    if ( lineEnd != L_NORMAL && !drawContour &&!isClosed()) {
-        QPoint endPoint;
-        bool last = true;
-        QPointArray::ConstIterator it2 = pointArray.end();
-        for ( it2 = it2 - 1; it2 != pointArray.begin(); --it2 ) {
-            if ( last ) {
-                endPoint = (*it2);
-                last = false;
-            }
-
-            QPoint point = (*it2);
-            if ( endPoint != point ) {
-                float angle = KoPoint::getAngle( endPoint, point );
-                drawFigureWithOffset( lineEnd, _painter, endPoint, pen2.color(), _w, \
                angle,_zoomHandler );
-
-                break;
-            }
-        }
-    }
-}
-
 void KPCubicBezierCurveObject::updatePoints( double _fx, double _fy )
 {
     KPPointObject::updatePoints( _fx, _fy );
@@ -262,3 +202,9 @@ bool KPCubicBezierCurveObject::isClosed(
 {
     return ( allPoints.at(0) == allPoints.at(allPoints.count()-1) );
 }
+
+
+KoPointArray KPCubicBezierCurveObject::getDrawingPoints()
+{
+  return allPoints;
+}
Index: kpfreehandobject.h
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpfreehandobject.h,v
retrieving revision 1.24
diff -u -3 -p -r1.24 kpfreehandobject.h
--- kpfreehandobject.h	30 Dec 2003 08:38:50 -0000	1.24
+++ kpfreehandobject.h	31 Jan 2004 15:54:58 -0000
@@ -21,9 +21,7 @@
 #ifndef kpfreehandobject_h
 #define kpfreehandobject_h
 
-#include "koPointArray.h"
-
-#include "kpobject.h"
+#include "kppointobject.h"
 
 class QPainter;
 class DCOPObject;
@@ -44,10 +42,6 @@ public:
 
     virtual QDomDocumentFragment save( QDomDocument& doc,double offset );
     virtual double load( const QDomElement &element );
-    
-protected:
-    virtual void paint( QPainter *_painter, KoZoomHandler*_zoomHandler,
-                        bool drawingShadow, bool drawContour = FALSE );
 };
 
 #endif
Index: kpfreehandobject.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpfreehandobject.cc,v
retrieving revision 1.40
diff -u -3 -p -r1.40 kpfreehandobject.cc
--- kpfreehandobject.cc	30 Dec 2003 08:38:50 -0000	1.40
+++ kpfreehandobject.cc	31 Jan 2004 15:54:58 -0000
@@ -63,65 +63,3 @@ double KPFreehandObject::load( const QDo
 {
     return KPPointObject::load( element );
 }
-
-void KPFreehandObject::paint( QPainter* _painter,KoZoomHandler*_zoomHandler,
-                              bool /*drawingShadow*/, bool drawContour )
-{
-    int _w = pen.width();
-
-    QPen pen2;
-    if ( drawContour ) {
-        pen2 = QPen( Qt::black, 1, Qt::DotLine );
-        _painter->setRasterOp( Qt::NotXorROP );
-    }
-    else {
-        pen2 = pen;
-        pen2.setWidth( _zoomHandler->zoomItX( pen.width() ) );
-    }
-    _painter->setPen( pen2 );
-
-    QPointArray pointArray = points.zoomPointArray( _zoomHandler, _w );
-
-    _painter->drawPolyline( pointArray );
-
-
-    if ( lineBegin != L_NORMAL && !drawContour && !isClosed()) {
-        QPoint startPoint;
-        bool first = true;
-        QPointArray::ConstIterator it1;
-        for ( it1 = pointArray.begin(); it1 != pointArray.end(); ++it1 ) {
-            if ( first ) {
-                startPoint = (*it1);
-                first = false;
-            }
-
-            QPoint point = (*it1);
-            if ( startPoint != point ) {
-                float angle = KoPoint::getAngle( startPoint, point );
-                drawFigureWithOffset( lineBegin, _painter, startPoint, pen2.color(), \
                _w, angle,_zoomHandler );
-
-                break;
-            }
-        }
-    }
-
-    if ( lineEnd != L_NORMAL && !drawContour && !isClosed()) {
-        QPoint endPoint;
-        bool last = true;
-        QPointArray::ConstIterator it2 = pointArray.end();
-        for ( it2 = it2 - 1; it2 != pointArray.begin(); --it2 ) {
-            if ( last ) {
-                endPoint = (*it2);
-                last = false;
-            }
-
-            QPoint point = (*it2);
-            if ( endPoint != point ) {
-                float angle = KoPoint::getAngle( endPoint, point );
-                drawFigureWithOffset( lineEnd, _painter, endPoint, pen2.color(), _w, \
                angle,_zoomHandler );
-
-                break;
-            }
-        }
-    }
-}
Index: kpobject.h
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpobject.h,v
retrieving revision 1.84
diff -u -3 -p -r1.84 kpobject.h
--- kpobject.h	30 Dec 2003 08:38:50 -0000	1.84
+++ kpobject.h	31 Jan 2004 15:54:59 -0000
@@ -367,41 +367,6 @@ protected:
     QBrush brush;
 };
 
-class KPPointObject : public KPShadowObject
-{
-public:
-    KPPointObject();
-    KPPointObject( const QPen &_pen, LineEnd _lineBegin, LineEnd _lineEnd );
-    KPPointObject( const QPen &_pen, LineEnd _lineBegin, LineEnd _lineEnd, const \
                QBrush &_brush );
-
-    virtual KoSize getRealSize() const;
-    virtual KoPoint getRealOrig() const;
-
-    virtual QDomDocumentFragment save( QDomDocument& doc, double offset );
-    virtual double load( const QDomElement &element );
-
-    virtual void setLineBegin( LineEnd _lineBegin ) { lineBegin = _lineBegin; }
-    virtual void setLineEnd( LineEnd _lineEnd ) { lineEnd = _lineEnd; }
-    
-    virtual LineEnd getLineBegin() const { return lineBegin; }
-    virtual LineEnd getLineEnd() const { return lineEnd; }
-    
-    virtual void setSize( double _width, double _height );
-    virtual void setSize( const KoSize & _size )
-        { setSize( _size.width(), _size.height() ); }
-    
-    virtual void flip( bool horizontal );
-
-    virtual void closeObject( bool close );
-    virtual bool isClosed() const;
-
-protected:
-    virtual void updatePoints( double _fx, double _fy );
-
-    KoPointArray points;
-    LineEnd lineBegin, lineEnd;
-};
-
 class KP2DObject : public KPShadowObject
 {
 public:
Index: kpobject.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpobject.cc,v
retrieving revision 1.122
diff -u -3 -p -r1.122 kpobject.cc
--- kpobject.cc	30 Dec 2003 08:38:50 -0000	1.122
+++ kpobject.cc	31 Jan 2004 15:55:01 -0000
@@ -930,183 +930,6 @@ QPen KPShadowObject::defaultPen() const
     return QPen();
 }
 
-KPPointObject::KPPointObject()
-    : KPShadowObject(), lineBegin(L_NORMAL), lineEnd( L_NORMAL )
-{
-}
-
-KPPointObject::KPPointObject( const QPen &_pen, LineEnd _lineBegin, LineEnd _lineEnd \
                )
-    : KPShadowObject( _pen ), lineBegin(_lineBegin), lineEnd(_lineEnd)
-{
-}
-
-KPPointObject::KPPointObject( const QPen &_pen, LineEnd _lineBegin, LineEnd \
                _lineEnd, const QBrush &_brush )
-    : KPShadowObject( _pen, _brush ), lineBegin(_lineBegin), lineEnd(_lineEnd)
-{
-}
-
-KoSize KPPointObject::getRealSize() const
-{
-    KoSize size( ext );
-    KoPoint realOrig( orig );
-    KoPointArray p( points );
-    getRealSizeAndOrigFromPoints( p, angle, size, realOrig );
-    return size;
-}
-
-KoPoint KPPointObject::getRealOrig() const
-{
-    KoSize size( ext );
-    KoPoint realOrig( orig );
-    KoPointArray p( points );
-    getRealSizeAndOrigFromPoints( p, angle, size, realOrig );
-    return realOrig;
-}
-
-QDomDocumentFragment KPPointObject::save( QDomDocument& doc, double offset )
-{
-    QDomDocumentFragment fragment = KPShadowObject::save( doc, offset );
-    if ( !points.isNull() ) {
-        QDomElement elemPoints = doc.createElement( "POINTS" );
-        KoPointArray::ConstIterator it;
-        for ( it = points.begin(); it != points.end(); ++it ) {
-            QDomElement elemPoint = doc.createElement( "Point" );
-            KoPoint point = (*it);
-            elemPoint.setAttribute( "point_x", point.x() );
-            elemPoint.setAttribute( "point_y", point.y() );
-
-            elemPoints.appendChild( elemPoint );
-        }
-        fragment.appendChild( elemPoints );
-    }
-
-    if ( lineBegin != L_NORMAL )
-        fragment.appendChild( KPObject::createValueElement( "LINEBEGIN",
-                                                            static_cast<int>( \
                lineBegin ), doc ) );
-
-    if ( lineEnd != L_NORMAL )
-        fragment.appendChild( KPObject::createValueElement( "LINEEND",
-                                                            static_cast<int>( \
                lineEnd ), doc ) );
-
-    return fragment;
-}
-
-double KPPointObject::load( const QDomElement &element )
-{
-    double offset = KPShadowObject::load( element );
-
-    QDomElement e = element.namedItem( "POINTS" ).toElement();
-    if ( !e.isNull() ) {
-        QDomElement elemPoint = e.firstChild().toElement();
-        unsigned int index = 0;
-        while ( !elemPoint.isNull() ) {
-            if ( elemPoint.tagName() == "Point" ) {
-                double tmpX = 0;
-                double tmpY = 0;
-                if( elemPoint.hasAttribute( "point_x" ) )
-                    tmpX = elemPoint.attribute( "point_x" ).toDouble();
-                if( elemPoint.hasAttribute( "point_y" ) )
-                    tmpY = elemPoint.attribute( "point_y" ).toDouble();
-
-                points.putPoints( index, 1, tmpX,tmpY );
-            }
-            elemPoint = elemPoint.nextSibling().toElement();
-            ++index;
-        }
-    }
-
-    e = element.namedItem( "LINEBEGIN" ).toElement();
-    if( !e.isNull() ) {
-        int tmp = 0;
-        if( e.hasAttribute( "value" ) )
-            tmp = e.attribute( "value" ).toInt();
-        lineBegin = static_cast<LineEnd>( tmp );
-    }
-
-    e = element.namedItem( "LINEEND" ).toElement();
-    if( !e.isNull() ) {
-        int tmp = 0;
-        if( e.hasAttribute( "value" ) )
-            tmp = e.attribute( "value" ).toInt();
-        lineEnd = static_cast<LineEnd>( tmp );
-    }
-
-    return offset;
-}
-
-void KPPointObject::setSize( double _width, double _height )
-{
-    KoSize origSize( ext );
-    KPObject::setSize( _width, _height );
-
-    double fx = ext.width() / origSize.width();
-    double fy = ext.height() / origSize.height();
-
-    updatePoints( fx, fy );
-}
-
-void KPPointObject::flip( bool horizontal )
-{
-    KPObject::flip( horizontal );
-
-    KoPointArray tmpPoints;
-    int index = 0;
-    if ( horizontal )
-    {
-        KoPointArray::ConstIterator it;
-        double horiz = getSize().height()/2;
-        for ( it = points.begin(); it != points.end(); ++it ) {
-            KoPoint point = (*it);
-            if ( point.y()> horiz )
-                tmpPoints.putPoints( index, 1, point.x(),point.y()- \
                2*(point.y()-horiz) );
-            else
-                tmpPoints.putPoints( index, 1, point.x(),point.y()+ 2*(horiz - \
                point.y()) );
-            ++index;
-        }
-    }
-    else
-    {
-        KoPointArray::ConstIterator it;
-        double vert = getSize().width()/2;
-        for ( it = points.begin(); it != points.end(); ++it ) {
-            KoPoint point = (*it);
-            if ( point.x()> vert )
-                tmpPoints.putPoints( index, 1, point.x()- 2*(point.x()-vert), \
                point.y() );
-            else
-                tmpPoints.putPoints( index, 1, point.x()+ 2*(vert - \
                point.x()),point.y() );
-            ++index;
-        }
-    }
-
-    points = tmpPoints;
-}
-
-void KPPointObject::closeObject( bool close )
-{
-    points = getCloseObject( points, close, isClosed() );
-}
-
-bool KPPointObject::isClosed() const
-{
-    return ( points.at(0) == points.at(points.count()-1) );
-}
-
-void KPPointObject::updatePoints( double _fx, double _fy )
-{
-    int index = 0;
-    KoPointArray tmpPoints;
-    KoPointArray::ConstIterator it;
-    for ( it = points.begin(); it != points.end(); ++it ) {
-        KoPoint point = (*it);
-        double tmpX = point.x() * _fx;
-        double tmpY = point.y() * _fy;
-
-        tmpPoints.putPoints( index, 1, tmpX,tmpY );
-        ++index;
-    }
-    points = tmpPoints;
-}
-    
 KP2DObject::KP2DObject()
     : KPShadowObject(), gColor1( Qt::red ), gColor2( Qt::green )
 {
Index: kppolylineobject.h
===================================================================
RCS file: /home/kde/koffice/kpresenter/kppolylineobject.h,v
retrieving revision 1.20
diff -u -3 -p -r1.20 kppolylineobject.h
--- kppolylineobject.h	30 Dec 2003 08:38:50 -0000	1.20
+++ kppolylineobject.h	31 Jan 2004 15:55:02 -0000
@@ -21,9 +21,7 @@
 #ifndef kppolylineobject_h
 #define kppolylineobject_h
 
-#include <qpointarray.h>
-#include "koPointArray.h"
-#include "kpobject.h"
+#include "kppointobject.h"
 
 #define RAD_FACTOR 180.0 / M_PI
 
@@ -47,10 +45,6 @@ public:
 
     virtual QDomDocumentFragment save( QDomDocument& doc, double offset );
     virtual double load( const QDomElement &element );
-
-protected:
-    virtual void paint( QPainter *_painter,KoZoomHandler*_zoomHandler,
-                        bool drawingShadow, bool drawContour = FALSE );
 };
 
 #endif
Index: kppolylineobject.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kppolylineobject.cc,v
retrieving revision 1.38
diff -u -3 -p -r1.38 kppolylineobject.cc
--- kppolylineobject.cc	30 Dec 2003 08:38:50 -0000	1.38
+++ kppolylineobject.cc	31 Jan 2004 15:55:02 -0000
@@ -65,64 +65,3 @@ double KPPolylineObject::load(const QDom
 {
     return KPPointObject::load( element );
 }
-
-void KPPolylineObject::paint( QPainter* _painter,KoZoomHandler*_zoomHandler,
-                              bool /*drawingShadow*/, bool drawContour )
-{
-    int _w = pen.width();
-
-    QPen pen2;
-    if ( drawContour ) {
-        pen2 = QPen( Qt::black, 1, Qt::DotLine );
-        _painter->setRasterOp( Qt::NotXorROP );
-    }
-    else {
-        pen2 = pen;
-        pen2.setWidth( _zoomHandler->zoomItX( pen.width() ) );
-    }
-    _painter->setPen( pen2 );
-
-    QPointArray pointArray = points.zoomPointArray( _zoomHandler, _w );
-
-    _painter->drawPolyline( pointArray );
-
-    if ( lineBegin != L_NORMAL && !drawContour &&!isClosed()) {
-        QPoint startPoint;
-        bool first = true;
-        QPointArray::ConstIterator it1;
-        for ( it1 = pointArray.begin(); it1 != pointArray.end(); ++it1 ) {
-            if ( first ) {
-                startPoint = (*it1);
-                first = false;
-            }
-
-            QPoint point = (*it1);
-            if ( startPoint != point ) {
-                float angle = KoPoint::getAngle( startPoint, point );
-                drawFigureWithOffset( lineBegin, _painter, startPoint, pen2.color(), \
                _w, angle,_zoomHandler );
-
-                break;
-            }
-        }
-    }
-
-    if ( lineEnd != L_NORMAL && !drawContour &&!isClosed()) {
-        QPoint endPoint;
-        bool last = true;
-        QPointArray::ConstIterator it2 = pointArray.end();
-        for ( it2 = it2 - 1; it2 != pointArray.begin(); --it2 ) {
-            if ( last ) {
-                endPoint = (*it2);
-                last = false;
-            }
-
-            QPoint point = (*it2);
-            if ( endPoint != point ) {
-                float angle = KoPoint::getAngle( endPoint, point );
-                drawFigureWithOffset( lineEnd, _painter, endPoint, pen2.color(), _w, \
                angle,_zoomHandler );
-
-                break;
-            }
-        }
-    }
-}
Index: kpquadricbeziercurveobject.h
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpquadricbeziercurveobject.h,v
retrieving revision 1.22
diff -u -3 -p -r1.22 kpquadricbeziercurveobject.h
--- kpquadricbeziercurveobject.h	30 Dec 2003 08:38:50 -0000	1.22
+++ kpquadricbeziercurveobject.h	31 Jan 2004 15:55:02 -0000
@@ -21,10 +21,7 @@
 #ifndef kpquadricbeziercurveobject_h
 #define kpquadricbeziercurveobject_h
 
-#include <qpointarray.h>
-#include "koPointArray.h"
-#include "kpobject.h"
-#include <koSize.h>
+#include "kppointobject.h"
 
 class QPainter;
 class KoZoomHandler;
@@ -53,10 +50,8 @@ public:
     bool isClosed()const;
 
 protected:
-    virtual void paint( QPainter *_painter,KoZoomHandler*_zoomHandler,
-                        bool drawingShadow, bool drawContour = FALSE );
-
     virtual void updatePoints( double _fx, double _fy );
+    virtual KoPointArray getDrawingPoints();
 
     KoPointArray getQuadricBezierPointsFrom( const KoPointArray &_pointArray );
 
Index: kpquadricbeziercurveobject.cc
===================================================================
RCS file: /home/kde/koffice/kpresenter/kpquadricbeziercurveobject.cc,v
retrieving revision 1.39
diff -u -3 -p -r1.39 kpquadricbeziercurveobject.cc
--- kpquadricbeziercurveobject.cc	30 Dec 2003 08:38:50 -0000	1.39
+++ kpquadricbeziercurveobject.cc	31 Jan 2004 15:55:02 -0000
@@ -74,66 +74,6 @@ double KPQuadricBezierCurveObject::load(
     return offset;
 }
 
-void KPQuadricBezierCurveObject::paint( QPainter* \
                _painter,KoZoomHandler*_zoomHandler,
-                                        bool /*drawingShadow*/, bool drawContour )
-{
-    int _w = pen.width();
-
-    QPen pen2;
-    if ( drawContour ) {
-        pen2 = QPen( Qt::black, 1, Qt::DotLine );
-        _painter->setRasterOp( Qt::NotXorROP );
-    }
-    else {
-        pen2 = pen;
-        pen2.setWidth( _zoomHandler->zoomItX( pen.width() ) );
-    }
-    _painter->setPen( pen2 );
-
-    QPointArray pointArray = allPoints.zoomPointArray( _zoomHandler, _w );
-    _painter->drawPolyline( pointArray );
-
-    if ( lineBegin != L_NORMAL && !drawContour && !isClosed()) {
-        QPoint startPoint;
-        bool first = true;
-        QPointArray::ConstIterator it1;
-        for ( it1 = pointArray.begin(); it1 != pointArray.end(); ++it1 ) {
-            if ( first ) {
-                startPoint = (*it1);
-                first = false;
-            }
-
-            QPoint point = (*it1);
-            if ( startPoint != point ) {
-                float angle = KoPoint::getAngle( startPoint, point );
-                drawFigureWithOffset( lineBegin, _painter, startPoint, pen2.color(), \
                _w, angle,_zoomHandler );
-
-                break;
-            }
-        }
-    }
-
-    if ( lineEnd != L_NORMAL && !drawContour && !isClosed()) {
-        QPoint endPoint;
-        bool last = true;
-        QPointArray::ConstIterator it2 = pointArray.end();
-        for ( it2 = it2 - 1; it2 != pointArray.begin(); --it2 ) {
-            if ( last ) {
-                endPoint = (*it2);
-                last = false;
-            }
-
-            QPoint point = (*it2);
-            if ( endPoint != point ) {
-                float angle = KoPoint::getAngle( endPoint, point );
-                drawFigureWithOffset( lineEnd, _painter, endPoint, pen2.color(), _w, \
                angle,_zoomHandler );
-
-                break;
-            }
-        }
-    }
-}
-
 void KPQuadricBezierCurveObject::updatePoints( double _fx, double _fy )
 {
     KPPointObject::updatePoints( _fx, _fy );
@@ -260,3 +200,9 @@ bool KPQuadricBezierCurveObject::isClose
 {
     return ( allPoints.at(0) == allPoints.at(allPoints.count()-1) );
 }
+
+
+KoPointArray KPQuadricBezierCurveObject::getDrawingPoints()
+{
+  return allPoints;
+}



_______________________________________________
koffice-devel mailing list
koffice-devel@mail.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