Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Commit [6dd4ed] Maximize Restore History

Merge branch 'routing'

Julian Bäume Julian Bäume 2010-09-08

1 2 3 > >> (Page 1 of 3)
added src/interfaces/irouterplugin.cpp
added src/plugins/automatic_router/utils.h
changed src/interfaces/component/connector.cpp
changed src/interfaces/component/connector.h
changed src/interfaces/component/connectoritem.cpp
changed src/interfaces/component/connectoritem.h
changed src/interfaces/component/icomponentitem.cpp
changed src/interfaces/component/icomponentitem.h
changed src/interfaces/CMakeLists.txt
changed src/interfaces/icomponentdocument.h
changed src/interfaces/idocumentscene.cpp
changed src/interfaces/idocumentscene.h
changed src/interfaces/iroutinginformation.h
changed src/plugins/automatic_router/cells.cpp
changed src/plugins/automatic_router/cells.h
changed src/plugins/automatic_router/ktlautomatic_router.desktop
changed src/plugins/automatic_router/ktlautomaticrouterplugin.cpp
changed src/plugins/automatic_router/ktlautomaticrouterplugin.h
changed src/plugins/circuit/circuitdocument.cpp
changed src/plugins/circuit/circuitdocument.h
changed src/plugins/circuit/circuitscene.cpp
copied src/interfaces/iconrouter.cpp -> src/interfaces/irouterplugin.h
copied src/interfaces/iconrouter.h -> src/interfaces/iroutinginformation.cpp
src/interfaces/irouterplugin.cpp Diff Switch to side-by-side view
Loading...
src/plugins/automatic_router/utils.h Diff Switch to side-by-side view
Loading...
src/interfaces/component/connector.cpp Diff Switch to side-by-side view
Loading...
src/interfaces/component/connector.h Diff Switch to side-by-side view
Loading...
src/interfaces/component/connectoritem.cpp Diff Switch to side-by-side view
Loading...
src/interfaces/component/connectoritem.h Diff Switch to side-by-side view
Loading...
src/interfaces/component/icomponentitem.cpp Diff Switch to side-by-side view
Loading...
src/interfaces/component/icomponentitem.h Diff Switch to side-by-side view
Loading...
src/interfaces/CMakeLists.txt Diff Switch to side-by-side view
Loading...
src/interfaces/icomponentdocument.h Diff Switch to side-by-side view
Loading...
src/interfaces/idocumentscene.cpp Diff Switch to side-by-side view
Loading...
src/interfaces/idocumentscene.h Diff Switch to side-by-side view
Loading...
src/interfaces/iroutinginformation.h Diff Switch to side-by-side view
Loading...
src/plugins/automatic_router/cells.cpp Diff Switch to side-by-side view
Loading...
src/plugins/automatic_router/cells.h Diff Switch to side-by-side view
Loading...
src/plugins/automatic_router/ktlautomatic_router.desktop Diff Switch to side-by-side view
Loading...
src/plugins/automatic_router/ktlautomaticrouterplugin.cpp Diff Switch to side-by-side view
Loading...
src/plugins/automatic_router/ktlautomaticrouterplugin.h Diff Switch to side-by-side view
Loading...
src/plugins/circuit/circuitdocument.cpp Diff Switch to side-by-side view
Loading...
src/plugins/circuit/circuitdocument.h Diff Switch to side-by-side view
Loading...
src/plugins/circuit/circuitscene.cpp Diff Switch to side-by-side view
Loading...
src/interfaces/iconrouter.cpp to src/interfaces/irouterplugin.h
--- a/src/interfaces/iconrouter.cpp
+++ b/src/interfaces/irouterplugin.h
@@ -19,67 +19,56 @@
 
 */
 
-#include "iconrouter.h"
+#ifndef IROUTERPLUGIN_H
+#define IROUTERPLUGIN_H
 
-#include <QPointF>
-#include <QPainterPath>
-#include <KDebug>
-#include "idocumentscene.h"
+#include "ktlinterfacesexport.h"
 
-using namespace KTechLab;
+#include <QtCore/QObject>
+#include <kdevplatform/interfaces/iextension.h>
 
-IConRouter::IConRouter()
-{}
+class QPointF;
+class QPainterPath;
 
-IConRouter::~IConRouter()
-{}
+namespace KTechLab
+{
 
+class IRoutingInformation;
+class IDocumentScene;
 
-void IConRouter::mapRoute(qreal sx, qreal sy, qreal ex, qreal ey)
+/**
+ * \short Abstraction for the routing of a connection
+ * This is a base-class to provide a list of points that need to be connected
+ * in order to draw a connection between 2 pins of a component.
+ */
+class KTLINTERFACES_EXPORT IRouterPlugin
 {
-    mapRoute(QPointF(sx,sy),QPointF(ex,ey));
+public:
+
+    IRouterPlugin();
+    virtual ~IRouterPlugin();
+
+    /**
+     * Set the scene for the document to provide necessary information to
+     * calculate the route. This way the router can take components into
+     * account. The scene will also provide mechanisms for collision
+     * detection.
+     * \param scene - the scene to set
+     */
+    void setDocumentScene( IDocumentScene *scene );
+
+protected:
+    /**
+     * Create internal routing information and attach it to the scene.
+     *
+     * \param scene - routing information is created for this scene
+     */
+    virtual void generateRoutingInfo( IDocumentScene *scene )=0;
+};
+
 }
 
-QPainterPath IConRouter::paintedRoute() const
-{
-    QPainterPath p;
-    if (m_route.size() < 2)
-        return p;
+KDEV_DECLARE_EXTENSION_INTERFACE_NS( KTechLab, IRouterPlugin, "org.ktechlab.IRouterPlugin" )
+Q_DECLARE_INTERFACE( KTechLab::IRouterPlugin, "org.ktechlab.IRouterPlugin" )
 
-    QList<QPointF>::const_iterator end = m_route.constEnd();
-    QList<QPointF>::const_iterator it=m_route.constBegin();
-    p.moveTo(*it);
-    for ( ++it; it != end; ++it ){
-        p.lineTo(*it);
-    }
-    return p;
-}
-
-QList< QPointF > IConRouter::route() const
-{
-    return m_route;
-}
-
-void IConRouter::setRoute(const QList< QPointF >& route)
-{
-    if (m_route.size()>0) {
-        //this can happen, but in debug-mode, we should inform about it
-        kDebug() << "Overwriting non-empty route.";
-    }
-
-    m_route = route;
-}
-
-void IConRouter::setDocumentScene(IDocumentScene* scene)
-{
-    m_documentScene = scene;
-    if (scene->routingInfo().isNull()){
-        generateRoutingInfo( scene );
-    }
-}
-
-QPixmap KTechLab::IConRouter::visualizedData(const QRectF &region) const
-{
-    Q_UNUSED(region);
-    return QPixmap();
-}
+#endif // IROUTERPLUGIN_H
src/interfaces/iconrouter.h to src/interfaces/iroutinginformation.cpp
--- a/src/interfaces/iconrouter.h
+++ b/src/interfaces/iroutinginformation.cpp
@@ -1,142 +1,111 @@
 /*
-    Abstraction for the routing of a connection
-    Copyright (C) 2003-2004 by David Saxton <david@bluehaze.org>
-    Copyright (C) 2010  Julian B채ume <julian@svg4all.de>
+ *  Copyright (C) 2010 Julian B채ume <julian@svg4all.de>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, write to the Free Software Foundation, Inc.,
+ *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
 
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
+#include "iroutinginformation.h"
 
-    This program 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 General Public License for more details.
+#include "idocumentscene.h"
+#include <KDebug>
 
-    You should have received a copy of the GNU General Public License along
-    with this program; if not, write to the Free Software Foundation, Inc.,
-    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+using namespace KTechLab;
 
-*/
-
-#ifndef ICONROUTER_H
-#define ICONROUTER_H
-
-#include "ktlinterfacesexport.h"
-
-#include <QtCore/QObject>
-#include <kdevplatform/interfaces/iextension.h>
-#include <qpainter.h>
-
-class QPointF;
-class QPainterPath;
-
-namespace KTechLab
+IRoutingInformation::IRoutingInformation(IDocumentScene* scene, QObject* parent)
+    : QObject(parent),
+      m_documentScene(scene),
+      m_visualize(VisualizeRaster)
 {
-
-class IRoutingInformation;
-class IDocumentScene;
-
-/**
- * \short Abstraction for the routing of a connection
- * This is a base-class to provide a list of points that need to be connected
- * in order to draw a connection between 2 pins of a component.
- */
-class KTLINTERFACES_EXPORT IConRouter
-{
-public:
-    IConRouter();
-    virtual ~IConRouter();
-
-    /**
-     * What this class is all about - finding a route, from p1 to p2.
-     * This is the default way to map a route. Override this method
-     * to provide an implementation for the routing algorithm.
-     * \param p1 - starting point of the route
-     * \param p2 - end-point of the route
-     */
-    virtual void mapRoute( QPointF p1, QPointF p2 )=0;
-
-    /**
-     * What this class is all about - finding a route, from (sx,sy) to (ex,ey).
-     * The default implementation calls mapRoute(QPointF(sx,sy),QPointF(ex,ey)).
-     * This method is provided for convenience.
-     */
-    virtual void mapRoute( qreal sx, qreal sy, qreal ex, qreal ey);
-
-    /**
-     * Set the scene for the document to provide necessary information to
-     * calculate the route. This way the router can take components into
-     * account. The scene will also provide mechanisms for collision
-     * detection.
-     * \param scene - the scene to set
-     */
-    void setDocumentScene( IDocumentScene *scene );
-
-    /**
-     * Get the route in a paintable format. This can be directly used
-     * with the QGraphicsView framework.
-     * \returns the path describing the route
-     */
-    QPainterPath paintedRoute() const;
-
-    /**
-     * Get the list of points representing the route
-     * \returns the list of points representing the route
-     */
-    virtual QList<QPointF> route() const;
-
-    /**
-     * Provide a list of points representing the route.
-     * \param route - the points on the route
-     */
-    virtual void setRoute( const QList<QPointF> &route );
-
-    /**
-     * Provide a \ref QPixmap that visualizes the internal data
-     * of the routing algorithm.
-     *
-     * This can be useful to debug or understand the underlying
-     * routing algorithm. Since this method will be called quite
-     * frequently by the scene, make sure the pixmap is created
-     * and cached in the plugin.
-     *
-     * The rectangle region can be provided to only visualize parts
-     * of the scene. The region-rect might not intersect with your
-     * scene-rect, so you might want to return a null-pixmap in that case.
-     *
-     * Parts of the code to implement this method could look like:
-     * \code
-        if (region.isNull())
-            region = sceneRect;
-        if (!region.intersects(sceneRect))
-            return QPixmap();
-
-        QRectF dataRegion = region.intersected(sceneRect);
-        QPixmap pic(region.size().toSize());
-        pic.fill(Qt::transparent);
-        QPainter p(&pic);
-        //only draw the interesting part of the visualizedData onto the result
-        p.drawPixmap(dataRegion, m_visualizedData, dataRegion);
-     * \endcode
-     *
-     *
-     * \param region - a \ref QRectF describing the region of interest
-     * \returns a \ref QPixmap visualizing the internal data,
-     *          the default implementation will return a null-pixmap
-     */
-    virtual QPixmap visualizedData( const QRectF &region = QRectF() ) const;
-
-protected:
-    virtual void generateRoutingInfo( IDocumentScene *scene )=0;
-    QList<QPointF> m_route;
-    QSharedPointer<IRoutingInformation> m_routingInfo;
-    IDocumentScene* m_documentScene;
-};
 
 }
 
-KDEV_DECLARE_EXTENSION_INTERFACE_NS( KTechLab, IConRouter, "org.ktechlab.IConRouter" )
-Q_DECLARE_INTERFACE( KTechLab::IConRouter, "org.ktechlab.IConRouter" )
+QPointF IRoutingInformation::alignToGrid(const QPointF& point)
+{
+    return point;
+}
 
-#endif // ICONROUTER_H
+void IRoutingInformation::mapRoute(qreal sx, qreal sy, qreal ex, qreal ey)
+{
+    mapRoute(QPointF(sx,sy),QPointF(ex,ey));
+}
+
+QPainterPath IRoutingInformation::paintedRoute() const
+{
+    QPainterPath p;
+    if (m_route.size() < 2)
+        return p;
+
+    QList<QPointF>::const_iterator end = m_route.constEnd();
+    QList<QPointF>::const_iterator it=m_route.constBegin();
+    p.moveTo(*it);
+    for ( ++it; it != end; ++it ){
+        p.lineTo(*it);
+    }
+        return p;
+}
+
+QList< QPointF > IRoutingInformation::route() const
+{
+    return m_route;
+}
+
+void IRoutingInformation::setRoute(const QList< QPointF >& route)
+{
+    if (m_route.size()>0) {
+        //this can happen, but in debug-mode, we should inform about it
+        kDebug() << "Overwriting non-empty route.";
+    }
+
+        m_route = route;
+}
+
+QPixmap IRoutingInformation::visualizedData(const QRectF &region) const
+{
+    if (!m_visualize || !m_documentScene)
+        return QPixmap();
+
+    QRectF sceneRect = m_documentScene->sceneRect();
+
+    QRectF dataRegion = region.intersected(sceneRect);
+    QRectF targetRegion(dataRegion);
+
+    dataRegion.moveLeft(dataRegion.left()-sceneRect.left());
+    dataRegion.moveTop(dataRegion.top()-sceneRect.top());
+    targetRegion.moveLeft(targetRegion.left()-region.left());
+    targetRegion.moveTop(targetRegion.top()-region.top());
+
+    QPixmap pic(region.size().toSize());
+    pic.fill(Qt::transparent);
+    QPainter p(&pic);
+    if (m_visualize & IRoutingInformation::VisualizeRaster)
+        paintRaster(&p, region);
+    if (dataRegion.isValid() && m_visualize & IRoutingInformation::VisualizeRoutingInformation)
+        paintRoutingInfo(&p, targetRegion, dataRegion);
+    return pic;
+}
+
+void IRoutingInformation::paintRoutingInfo(QPainter* p, const QRectF& target, const QRectF& source) const
+{
+    Q_UNUSED(p)
+    Q_UNUSED(target)
+    Q_UNUSED(source)
+}
+
+void IRoutingInformation::paintRaster(QPainter* p, const QRectF& region) const
+{
+    Q_UNUSED(p)
+    Q_UNUSED(region)
+}
1 2 3 > >> (Page 1 of 3)