Menu

[r168]: / plugins / simplerouter / simplerouter.h  Maximize  Restore  History

Download this file

107 lines (93 with data), 5.1 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
/*******************************************************************************
* Copyright (C) 2014 Pike Aerospace Research Corporation *
* Author: Mike Sharkey <mike@pikeaero.com> *
* *
* 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 3 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 at <http://www.gnu.org/licenses/> *
* for more details. *
* *
*******************************************************************************/
#ifndef SIMPLEROUTER_H
#define SIMPLEROUTER_H
#include <QString>
#include <QDateTime>
#include <QList>
#include <QRectF>
#include <QStack>
#include <QMap>
#include <QPoint>
#include <QPointF>
#include <QPainterPath>
#include <QGraphicsPathItem>
#include <cplugininterface.h>
#include <simplerouternode.h>
class CPcb;
class CPcbNet;
class CGPadstack;
class SimpleRouter : public QObject, public CPluginInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "com.pikeaero.QAutoRouter.Plugins.CPluginInterface" FILE "simplerouter.json")
Q_INTERFACES(CPluginInterface)
public:
friend class CSegmentState;
virtual tPluginType type(); /** is the a router or post-router */
virtual QString title() const; /** a brief name for the plugin */
virtual QString version() const; /** return a version number string */
virtual QStringList credits() const; /** name of authors + email */
virtual QString website() const; /** the author's website */
virtual QString description() const; /** a brief description of the plugin */
virtual QStringList license() const; /** the license text for the plugin */
virtual bool start(CPcb* pcb); /** initialize, gets' called once prior to exec() being called */
virtual void stop(); /** stop processing */
virtual bool exec(); /** get's called repeatedly while exec() returns true, return false to stop */
virtual QString elapsed(); /** elapsed time of the run in hh:mm:ss format */
signals:
void status(QString txt); /** emit a status text */
private:
typedef enum {
Idle, /** there is nothing happening */
Selecting, /** selecting which net(s) to route */
Routing, /** committing a route */
} tRunState;
CPcb* pcb() {return mPcb;}
tRunState state();
bool running() {return state() != Idle;}
void setState(tRunState state);
QString currentStatus(); /** a brief status report for the status bar */
CPcbNet* selectNet();
bool endPoints();
QGraphicsPathItem* drawRatLine();
QGraphicsPathItem* drawRatLine(QList<SimpleRouterNode> path);
void route();
QList<SimpleRouterNode>& path();
QList<SimpleRouterNode*> neighbours(SimpleRouterNode* node);
void open(SimpleRouterNode* node);
void close(SimpleRouterNode* node);
void clear(QList<SimpleRouterNode*>& nodes);
double manhattanLength(QPointF a, QPointF b);
double adjacentCost(QPointF a, QPointF b);
double cost(SimpleRouterNode node);
double g(SimpleRouterNode node);
double h(SimpleRouterNode node);
QList<SimpleRouterNode> neighbours(SimpleRouterNode node);
private:
void insort(QList<SimpleRouterNode*>& list, SimpleRouterNode* node);
CPcb* mPcb;
QDateTime mStartTime;
tRunState mState;
CPcbNet* mNet; /** the current net */
CGPadstack* mEndPoint[2]; /** current route end points */
QGraphicsPathItem* mRatLine; /** The current rat line */
QList<SimpleRouterNode*> mOpenList;
QList<SimpleRouterNode*> mClosedList; /** closed nodes ordered by cost */
QList<SimpleRouterNode> mPath; /** The resulting path */
};
#endif // SIMPLEROUTER_H
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.