wxArt2D
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
a2dRouteData Class Reference

Class for rerouting wires. More...

#include <route.h>

Inheritance diagram for a2dRouteData:
Inheritance graph
[legend]
Collaboration diagram for a2dRouteData:
Collaboration graph
[legend]

Classes

struct  BorderPoint
 An entry in the border queue. More...
 
class  BorderQueue
 This is a priority queue for border points. More...
 
struct  RoutePoint
 the data structure holding the per point information More...
 

Public Types

enum  RoutePointFlag {
  flag_original = 0x01, flag_targetwire = 0x02, flag_targetpin = 0x04, flag_targetapprox = 0x08,
  flag_reachable = 0x10, flag_final = 0x20
}
 flags for RoutePoint
 
enum  RoutePointDirection {
  dir_xminus = 0, dir_xplus = 1, dir_yminus = 2, dir_yplus = 3,
  dir_start = 4, dir_min = 0, dir_max = 3, dir_count = 4,
  dir_invxor = 1
}
 directions for RoutePoint More...
 
- Public Types inherited from a2dObject
enum  CloneOptions {
  clone_members = 0x00000001, clone_properties = 0x00000002, clone_childs = 0x00000004, clone_unused = 0x00000008,
  clone_setoriginal = 0x00000010, clone_seteditcopy = 0x00000020, clone_noReference = 0x00000040, clone_noCameleonRef = 0x00000080,
  clone_toDrag = 0x00000100, clone_flat = 0x00000000, clone_deep = clone_members | clone_properties | clone_childs
}
 options for cloning More...
 
typedef a2dAutoZeroPtr< a2dObjectTAutoZeroPtrListClass
 this is needed inside the smart pointer template code
 

Public Member Functions

 a2dRouteData (a2dCanvasObject *showobject, bool final)
 Standard constructor takes the show object under which is routed. More...
 
 ~a2dRouteData ()
 Destructor.
 
bool RerouteWire (a2dWirePolylineL *wire, a2dPin *dispin, a2dPin *startpin, bool startisbegin, bool final)
 Reroute a wire. More...
 
- Public Member Functions inherited from a2dObject
virtual bool ProcessEvent (wxEvent &event)
 
bool SearchDynamicEventTable (wxEvent &event)
 
void Connect (int winid, int lastId, int eventType, wxObjectEventFunction func, wxObject *userData=(wxObject *) NULL, wxEvtHandler *eventSink=(wxEvtHandler *) NULL)
 
bool Disconnect (int winid, int lastId, wxEventType eventType, wxObjectEventFunction func=NULL, wxObject *userData=(wxObject *) NULL, wxEvtHandler *eventSink=(wxEvtHandler *) NULL)
 
void ProcessConnectedEvent (wxEvent &event)
 wxCHECK_VERSION(2,9,0) More...
 
void ConnectEvent (wxEventType type, wxEvtHandler *eventSink)
 
bool DisconnectEvent (wxEventType type, wxEvtHandler *eventSink)
 
bool DisconnectEventAll (wxEvtHandler *eventSink)
 Remove all dynamic events in classA, going to classB (eventSink) More...
 
 a2dObject ()
 constructor
 
virtual ~a2dObject ()
 destructor
 
void operator= (const a2dObject &other)
 assignment operator
 
int GetOwnedBy ()
 like it to be protected, but this does not work with wxList macros More...
 
virtual a2dObjectSetNonDynamic ()
 Call to mark this object as non-dynamic (static/local/auto) More...
 
void CheckReferences ()
 Check zero reference count and delete if count is 0. More...
 
a2dObjectClone (CloneOptions options, a2dRefMap *refs=NULL) const
 create an exact copy of this property
 
 a2dObject (const a2dObject &other, CloneOptions options, a2dRefMap *refs)
 
virtual wxString GetName () const
 Returns the name of this object, if no name is given the internal id will be returned. More...
 
virtual void SetName (const wxString &name)
 Creates the a2dStringProperty PROPID_Name. More...
 
virtual bool IsTemporary_DontSave () const
 Check if this is a temporary object, which should not be saved.
 
void SaveAsDocument (a2dIOHandlerXmlSerOut &out)
 Save this object and all below as an XML document. More...
 
virtual void Save (wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dObjectList *towrite)
 write all needed to an XML type of file called the CVG format More...
 
void LoadFromDocument (a2dIOHandlerXmlSerIn &parser)
 Load this object and all below from an XML document. More...
 
virtual void Load (wxObject *parent, a2dIOHandlerXmlSerIn &parser)
 load object from CVG file More...
 
wxInt64 GetUniqueSerializationId () const
 return a unique id for this object More...
 
virtual bool AlwaysWriteSerializationId () const
 If true, always write an id. More...
 
virtual bool LinkReference (a2dObject *other)
 link a reference in the object to the given value More...
 
virtual void ResolveInform ()
 inform an object that reference resolution was done More...
 
void Walker (wxObject *parent, a2dWalkerIOHandler &handler)
 This is used to recursively walk through an object tree.
 
void SetCheck (bool check)
 general flag use at will. More...
 
bool GetCheck () const
 general flag use at will.
 
void SetRelease (bool value)
 set release flag More...
 
bool GetRelease () const
 get release flag More...
 
a2dAutoZeroPtr< a2dObject > ** GetAutoZeroPtrList ()
 return the list head pointer for autozero pointers to this object More...
 
 DECLARE_PROPERTIES ()
 
a2dNamedPropertyGetProperty (const a2dPropertyId *propertyId, a2dPropertyId::Flags flags=a2dPropertyId::flag_none) const
 get property on this object More...
 
void SetProperty (a2dNamedProperty *propertyHolder, a2dPropertyId::SetFlags flags=a2dPropertyId::set_none)
 Set the property to the this object. More...
 
void SetProperty (const a2dNamedProperty &propertyHolder, a2dPropertyId::SetFlags flags=a2dPropertyId::set_none)
 Set the property to the this object and if enabled, to all childs and object members. More...
 
virtual a2dNamedPropertyFindProperty (const a2dPropertyId *id, a2dPropertyId::Flags flags=a2dPropertyId::flag_none)
 Find a dynamic property with given id in the property list. More...
 
virtual const a2dNamedPropertyFindProperty (const a2dPropertyId *id, a2dPropertyId::Flags flags=a2dPropertyId::flag_none) const
 Find a dynamic property with given id in the property list. More...
 
virtual bool HasProperty (const a2dPropertyId *id, const wxString &stringvalue=wxEmptyString) const
 Check if the object has a property with given id and string representation. More...
 
virtual void OnPropertyChanged (const a2dPropertyId *id)
 This function is called after a property changed. More...
 
virtual bool EditProperties (const a2dPropertyId *id, bool withUndo=true)
 edit properties of the object More...
 
void TakeOverProperties (a2dObject *from, a2dPropertyIdList *listOfIds)
 Properties in the id list are taken from the given object, en set to this. More...
 
wxURI GetURI () const
 quick way to get to PROPID_URI property More...
 
void SetURI (const wxURI &url)
 quickly set a property PROPID_URI More...
 
const a2dNamedPropertyListGetPropertyList () const
 Get the Property List. More...
 
bool HasDynamicProperties () const
 test if there are dynamic properties in the m_propertylist
 
virtual bool RemoveProperty (const a2dPropertyId *id, bool all=true)
 This function is called by a2dPropertyId to remove a property from the list. More...
 
void RemoveTemporaryProperties ()
 remove all temporary properties
 
virtual bool AddProperty (a2dNamedProperty *property)
 This function is called by a2dPropertyId to add a property to the list. More...
 

Static Public Member Functions

static void SetRaster (double raster)
 the size of the raster
 

Protected Member Functions

unsigned short & GetVerticalOccupation (int x, int y)
 Get an element of the vertical occupation array.
 
unsigned short & GetHorizontalOccupation (int x, int y)
 Get an element of the horizontal occupation array.
 
bool IsVerticalOccupied (int x, int y)
 Is an element of the vertical occupation array.
 
bool IsHorizontalOccupied (int x, int y)
 Is an element of the horizontal occupation array.
 
RoutePointGetRoutePoint (int x, int y, int dir)
 Get an element of the route point array.
 
void AddOccupationRect (const a2dBoundingBox &bbox, short incr)
 add a bounding box to the occupied area More...
 
void AddOccupationPolyline (const a2dVertexList *points, const a2dAffineMatrix &trns, short incr)
 add a polyline to the occupation area More...
 
void SetFlagRect (const a2dBoundingBox &bbox, RoutePointFlag flag)
 Set a RoutePoint flag in a rectangle.
 
void SetFlagPolyline (const a2dVertexList *points, const a2dAffineMatrix &trns, RoutePointFlag flag)
 Set a RoutePoint flag along a polyline. More...
 
void SetFlagRoutePointAllDirs (int x, int y, RoutePointFlag flag)
 Set a flag in the route points for all directions.
 
void AddBorderPoint (BorderQueue *queue, RoutePoint *current, int nextx, int nexty, int dir, int prevdir)
 Add a new point on the route. More...
 
a2dBoundingBox CalculateRoutingBbox (a2dCanvasObject *object)
 Calculates the routing relevant bounding box of an object. More...
 
void DumpOccupation (FILE *file)
 Dump the occupation arrays.
 
void DumpCost ()
 
void DumpVertexList (a2dVertexList *list)
 
virtual a2dObjectDoClone (CloneOptions options, a2dRefMap *refs) const
 File for debug dumps. More...
 
virtual void DoSave (wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
 Save settings.
 
virtual void DoLoad (wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
 Load settings.
 
- Protected Member Functions inherited from a2dObject
virtual bool DoIgnoreIfNotMember (const a2dPropertyId *id) const
 used to decide if a property shall be ignored, if it is not a member More...
 
virtual void DoWalker (wxObject *parent, a2dWalkerIOHandler &handler)
 iterate over this object and its children More...
 

Protected Attributes

bool m_ok
 if true, the raster is initialized
 
a2dCanvasObjectm_showobject
 the show object given in the constructor
 
int m_width
 width of the routing raster array
 
int m_widthp1
 width of the routing raster array + 1
 
int m_height
 height of the routing raster array
 
int m_heightp1
 height of the routing raster array + 1
 
double m_rasterinv
 the inverse size of the raster
 
int m_rasterminx
 the limits of the raster area
 
int m_rastermaxx
 
int m_rasterminy
 
int m_rastermaxy
 
double m_rasterborder
 an extra border in the raster area around the bounding box
 
unsigned short * m_verticaloccupation
 occupation counts for vertical edges ( a 2d array )
 
unsigned short * m_horizontaloccupation
 occupation counts for horizontal edges ( a 2d array )
 
RoutePointm_routepoints
 Routing points.
 
- Protected Attributes inherited from a2dObject
a2dNamedPropertyList m_propertylist
 properties
 
int m_refcount
 how many references to this object do exist
 
bool m_check: 1
 used for linking multiple referenced objects when serializing
 
bool m_release: 1
 when set object is treated as being deleted, and wil be deleted in idle time.
 
bool m_recursion_active: 1
 this is used as a recursion stopper
 
bool m_pendingDisconnects: 1
 
unsigned int m_iteratorCount
 
a2dAutoZeroPtr< a2dObject > * m_autozeroptrlist
 this is a list of all a2dAutoZeroPtr object pointing to this object
 

Static Protected Attributes

static double m_raster = 4
 the size of the raster
 

Additional Inherited Members

- Static Public Attributes inherited from a2dObject
static a2dPropertyIdBoolPROPID_Check = NULL
 used for linking multiple referenced objects when serializing
 
static a2dPropertyIdUriPROPID_URI = NULL
 attach an URL to the object
 
static a2dPropertyIdStringPROPID_Name = NULL
 Name property, to return name of this object.
 
static a2dPropertyIdVoidPtrPROPID_autozeroptrlist = NULL
 
static const a2dSignal sm_Edit_properties = wxNewId()
 edit properties event, see EditProperties()
 
- Protected Types inherited from a2dObject
enum  { refcount_nondynamic = 0x76543210 }
 special refcount value for non-dynamic objects
 

Detailed Description

Class for rerouting wires.

This class implements a usual Lee router. The one special thing is, that there are penalties for corners. This makes routing a bit complicated, because the lowest cost to reach one point might not be the best for succeeding from this point, as the following example shows:

0-1 0- 3 | | 1-14 16 | | 2-15 19 | | 3-16 22 | | 29 25

The numbers are cost. 0 is the routing start point. The points with cost 1..3 are lying on the original line and have a low cost for this reason. The destination is the point with a cost of 29/25. The important point is, that the target can be reached via the right path with higher intermediate cost with lower final cost.

To get true least cost routing, the cost is stored for every raster point for the four incomming directions.

Definition at line 51 of file route.h.

Member Enumeration Documentation

directions for RoutePoint

Enumerator
dir_start 

start point

dir_min 

min usual direction value

dir_max 

max usual direction value

dir_count 

number of usual direction values

dir_invxor 

result of dir1^dir2 for two opposing directions

Definition at line 107 of file route.h.

Constructor & Destructor Documentation

a2dRouteData::a2dRouteData ( a2dCanvasObject showobject,
bool  final 
)

Standard constructor takes the show object under which is routed.

The boundingbox of the child objects in showobject is taken as the area in which to route

a wire. This with a certain margin added, in order to route around the outer objects too. Temporary tool objects are skipped from this boundingbox. The boundingbox is divided into a rectangular grid, each grid of size m_raster. The grid points are points where a routed wire can be routed onto. Buffers are allocated to maintain information on the grid points, e.g. which grid points are occupied by objects, and therefore a wire can not be routed there. a2dWirePolylineL objects marked with property PROPID_rerouteadded, indicates a wire to be rerouted, and will not be added to the occupation area. Only polylines are currently added accurate to the occuption area. Meaning the right grid points are disabled for routing. For the other objects currently the boundingbox is used.

Definition at line 166 of file route.cpp.

Member Function Documentation

void a2dRouteData::AddBorderPoint ( BorderQueue queue,
RoutePoint current,
int  nextx,
int  nexty,
int  dir,
int  prevdir 
)
inlineprotected

Add a new point on the route.

Based on the point where we are and a next point and direction, a new border point is added (unless already reached). The cost for the new point is calculated based on:

  • if is on the orginal wire +1
  • not on original wire +3
  • corner compared to current point direction +10
  • crossing occupied area +10 (in case of diagonal lines?)

This is a large function, but it is inlined for speed

Definition at line 301 of file route.cpp.

void a2dRouteData::AddOccupationPolyline ( const a2dVertexList points,
const a2dAffineMatrix trns,
short  incr 
)
protected

add a polyline to the occupation area

All vertical and horizontal lines are set into the vertical and horizontal occupation areas as being occupied. That is the grid points where those lines pass, are incremented by incr.

Definition at line 934 of file route.cpp.

void a2dRouteData::AddOccupationRect ( const a2dBoundingBox bbox,
short  incr 
)
protected

add a bounding box to the occupied area

All grid points within the rectangle are incremented by incr in the vertical and horizontal occupation buffers.

Definition at line 897 of file route.cpp.

a2dBoundingBox a2dRouteData::CalculateRoutingBbox ( a2dCanvasObject object)
protected

Calculates the routing relevant bounding box of an object.

This includes one level of childs, but no pins Pins are not included because their size may change during routing and this might lead to pre-final / final inconsistencies.

Definition at line 1074 of file route.cpp.

virtual a2dObject* a2dRouteData::DoClone ( CloneOptions  options,
a2dRefMap refs 
) const
inlineprotectedvirtual

File for debug dumps.

for wxStaticCast

Implements a2dObject.

Definition at line 381 of file route.h.

bool a2dRouteData::RerouteWire ( a2dWirePolylineL wire,
a2dPin dispin,
a2dPin startpin,
bool  startisbegin,
bool  final 
)

Reroute a wire.

Reroute the given wire, between a start and end pin. The start or end pin is used as a start for producing a border wave, which sets route points to a cost to reach that route point. At the same time the wave itself is expanded at the point with the best cost first. If that point is already reached through another part of the border wave, that point is removed from the wave, else based on the current border point a new point a new border point is created, followed by removing the current best border point. In the end the target pin or wire will be reached and the border wave will be empty. While the border wave is working itself like this through the routing points, the best route is via pointer in the route points.

Parameters
wireon input this is the wire in its original (edited but unadjusted) state
dispinthe pin that became disconnected
startpinthe pin where routing starts
startisbeginthe pin where routing starts is the begin point of the wire
finallast route to destination
Returns
true if wire was changed

Definition at line 367 of file route.cpp.

void a2dRouteData::SetFlagPolyline ( const a2dVertexList points,
const a2dAffineMatrix trns,
RoutePointFlag  flag 
)
protected

Set a RoutePoint flag along a polyline.

Vertical and horizontal segments result in a set in the routepoints which the cover. That is for all directions in a routepoint.

Definition at line 1016 of file route.cpp.


The documentation for this class was generated from the following files:
a2dRouteData Class Reference -- Sun Oct 12 2014 17:04:48 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation