GME  13
AutoRouterPath.h
Go to the documentation of this file.
00001 // AutoRouterPath.h : Declaration of the CAutoRouterPath
00002 
00003 #pragma once
00004 #include "../resource.h"       // main symbols
00005 
00006 #include <vector>
00007 
00008 #include "ArHelper.h"
00009 
00010 #include "AutoRouterPort.h"
00011 #include "AutoRouterBox.h"
00012 
00013 #define ARPATH_EndOnDefault             0x0000
00014 #define ARPATH_EndOnTop                 0x0010
00015 #define ARPATH_EndOnRight               0x0020
00016 #define ARPATH_EndOnBottom              0x0040
00017 #define ARPATH_EndOnLeft                0x0080
00018 #define ARPATH_EndMask                  (ARPATH_EndOnTop | ARPATH_EndOnRight | ARPATH_EndOnBottom | ARPATH_EndOnLeft)
00019 
00020 
00021 #define ARPATH_StartOnDefault   0x0000
00022 #define ARPATH_StartOnTop               0x0100
00023 #define ARPATH_StartOnRight             0x0200
00024 #define ARPATH_StartOnBottom    0x0400
00025 #define ARPATH_StartOnLeft              0x0800
00026 #define ARPATH_StartMask                (ARPATH_StartOnTop | ARPATH_StartOnRight | ARPATH_StartOnBottom | ARPATH_StartOnLeft)
00027 
00028 #define ARPATH_HighLighted              0x0002          // attributes
00029 #define ARPATH_Fixed                    0x0001
00030 #define ARPATH_Default                  0x0000
00031 
00032 #define ARPATHST_Connected              0x0001          // states
00033 #define ARPATHST_Default                0x0000
00034 
00035 
00036 typedef CList<CPoint, CPoint&>  CPointList;
00037 
00038 
00039 class CAutoRouterGraph;
00040 class CAutoRouterPort;
00041 
00042 // CAutoRouterPath
00043 
00044 class CAutoRouterPath : public CObject
00045 {
00046 public:
00047         CAutoRouterPath();
00048         ~CAutoRouterPath();
00049 
00050 private:
00051         CAutoRouterGraph* owner;
00052 
00053 // --- Ports
00054 
00055         CAutoRouterPort* startport;                                                     // reference
00056         CAutoRouterPort* endport;                                                       // reference
00057 
00058         POSITION GetPointPosAt(const CPoint& point, int nearness = 0) const;
00059         POSITION GetEdgePosAt(const CPoint& point, int nearness = 0) const;
00060 
00061 // --- Edges
00062         CPointListPath points;
00063 
00064 private:
00065         unsigned int attributes;
00066         int state;
00067         bool isAutoRoutingOn;
00068 
00069         std::vector<CustomPathData> customPathData;
00070         std::vector<CustomPathData> pathDataToDelete;
00071 
00072 public:
00073         CAutoRouterGraph* GetOwner(void) const;
00074         bool HasOwner(void) const;
00075         void SetOwner(CAutoRouterGraph* graph);
00076         // Ports
00077         void SetStartPort(CAutoRouterPort* port);
00078         void SetEndPort(CAutoRouterPort* port);
00079         void ClearPorts(void);
00080         CAutoRouterPort* GetStartPort(void);
00081         CAutoRouterPort* GetEndPort(void);
00082         // Points
00083         void AddTail(CPoint& p);
00084         void DeleteAll(void);
00085 
00086         bool HasNoPoint(void) const;
00087         long GetPointCount(void) const;
00088 
00089         CPoint GetStartPoint(void) const;
00090         CPoint GetEndPoint(void) const;
00091         CRect GetStartBox(void) const;
00092         CRect GetEndBox(void) const;
00093         CPoint GetOutOfBoxStartPoint(RoutingDirection hintDir) const;
00094         CPoint GetOutOfBoxEndPoint(RoutingDirection hintDir) const;
00095 
00096         void SimplifyTrivially(void);
00097 
00098         CPointListPath& GetPointList(void);
00099         void SetPoints(CPointListPath& pls);
00100         // Edges
00101 
00102         CRect GetSurroundRect(void) const;
00103 
00104         bool IsEmpty(void) const;
00105         bool IsPathAt(const CPoint& point, long nearness) const;
00106         bool IsPathClip(const CRect& r, bool isStartOrEndRect = false) const;
00107 
00108         void SetAttributes(long attr);
00109         long GetAttributes(void) const;
00110 
00111         bool IsFixed(void) const;
00112         bool IsMoveable(void) const;
00113         bool IsHighLighted(void) const;
00114 
00115         long GetState(void) const;
00116         bool IsConnected(void) const;
00117         void SetState(long state);
00118 
00119         RoutingDirection GetEndDir(void) const;
00120         RoutingDirection GetStartDir(void) const;
00121 
00122         void SetEndDir(long arpath_end);
00123         void SetStartDir(long arpath_start);
00124         // CustomData
00125         void SetCustomPathData(const std::vector<CustomPathData>& pDat);
00126         void ApplyCustomizationsBeforeAutoConnectPoints(CPointListPath& plist);
00127         void ApplyCustomizationsAfterAutoConnectPointsAndStuff(void);
00128         void RemovePathCustomizations(void);
00129         void MarkPathCustomizationsForDeletion(long asp);
00130         void RemoveInvalidPathCustomizations(long asp);
00131         bool AreTherePathCustomizations(void) const;
00132         bool AreThereDeletedPathCustomizations(void) const;
00133         void GetDeletedCustomPathData(std::vector<CustomPathData>& cpd) const;
00134         void GetCustomizedEdgeIndexes(std::vector<int>& indexes) const;
00135 
00136         bool IsAutoRouted(void) const;
00137         void SetAutoRouting(bool autoRoutingState);
00138         // Other
00139         void Destroy(void);
00140 
00141 // --- External Pointer (ONLY FOR EXTERNAL USE)
00142 
00143         void* GetExtPtr() const;
00144         void SetExtPtr(void* p);
00145 private:
00146         void* extptr;
00147 
00148 // --- Debug
00149 #ifdef _DEBUG
00150 public:
00151         virtual void AssertValid();
00152         void AssertValidPos(POSITION pos) const;
00153         void AssertValidPoints() const;
00154 #endif
00155 };