GME  13
AutoRouterPort.h
Go to the documentation of this file.
00001 // AutoRouterPort.h : Declaration of the CAutoRouterPort
00002 
00003 #pragma once
00004 #include "../resource.h"       // main symbols
00005 
00006 #include "ArHelper.h" 
00007 
00008 #include "AutoRouterBox.h"
00009 
00010 #include <vector>
00011 
00012 #define ARPORT_EndOnTop                                 0x0001
00013 #define ARPORT_EndOnRight                               0x0002
00014 #define ARPORT_EndOnBottom                              0x0004
00015 #define ARPORT_EndOnLeft                                0x0008
00016 #define ARPORT_EndOnAll                                 0x000F
00017 
00018 #define ARPORT_StartOnTop                               0x0010
00019 #define ARPORT_StartOnRight                             0x0020
00020 #define ARPORT_StartOnBottom                    0x0040
00021 #define ARPORT_StartOnLeft                              0x0080
00022 #define ARPORT_StartOnAll                               0x00F0
00023 
00024 #define ARPORT_ConnectOnAll                             0x00FF
00025 #define ARPORT_ConnectToCenter                  0x0100
00026 
00027 #define ARPORT_StartEndHorizontal               0x00AA
00028 #define ARPORT_StartEndVertical                 0x0055
00029 
00030 #define ARPORT_Default                                  0x00FF
00031 
00032 
00033 
00034 class CAutoRouterBox;
00035 class CAutoRouterEdgeList;
00036 class CAutoRouterGraph;
00037 
00038 // CAutoRouterPort
00039 
00040 class CAutoRouterPort : public CObject
00041 {
00042 public:
00043         CAutoRouterPort();
00044         virtual ~CAutoRouterPort();
00045 
00046 private:
00047         void CalculateSelfPoints();
00048 
00049 public:
00050         CAutoRouterBox* GetOwner(void) const;
00051         bool HasOwner(void) const;
00052         void SetOwner(CAutoRouterBox* box);
00053 
00054         CRect GetRect(void) const;
00055         bool IsRectEmpty(void) const;
00056         CPoint GetCenter(void) const;
00057         void SetRect(const CRect& r);
00058         void ShiftBy(const CPoint& offset);
00059         CPoint* GetSelfPoints(void) const;
00060 
00061         long GetAttributes(void) const;
00062         void SetAttributes(long attr);
00063         bool IsConnectToCenter(void) const;
00064         bool HasLimitedDirs() const;
00065         void SetLimitedDirs(bool ltd);
00066 
00067         bool IsPortAt(const CPoint& point, long nearness) const;
00068         bool IsPortClip(const CRect& r) const;
00069         bool IsPortIn(const CRect& r) const;
00070         RoutingDirection OnWhichEdge(const CPoint& p) const;
00071 
00072         bool CanHaveStartEndPointOn(RoutingDirection dir, bool isStart) const;
00073         bool CanHaveStartEndPoint(bool isStart) const;
00074         bool CanHaveStartEndPointHorizontal(bool isHorizontal) const;
00075         RoutingDirection GetStartEndDirTo(const CPoint& point, bool isStart, RoutingDirection notthis = Dir_None) const;
00076 
00077         bool CanCreateStartEndPointAt(const CPoint& point, bool isStart, long nearness) const;
00078         CPoint CreateStartEndPointAt(const CPoint& point, bool isStart) const;
00079         CPoint CreateStartEndPointTo(const CPoint& point, bool isStart) const;
00080         CPoint CreateStartEndPointOn(RoutingDirection dir) const;
00081 
00082 private:
00083         unsigned int attributes;
00084 
00085         bool  limitedDirections; // strictly respect the preferred directions (for ports East/West directions must be respected)
00086         CRect rect;
00087         CPoint selfpoints[4];
00088 
00089         CAutoRouterBox* owner;
00090 
00091 #ifdef _DEBUG
00092 public:
00093         virtual void AssertValid() const;
00094         void AssertValidStartEndPoint(const CPoint& point, RoutingDirection dir, bool isStart);
00095 #endif
00096 };