Loading common/CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -278,6 +278,7 @@ set( PCB_COMMON_SRCS ../pcbnew/class_track.cpp ../pcbnew/class_zone.cpp ../pcbnew/class_zone_settings.cpp ../pcbnew/class_teardrop.cpp ../pcbnew/classpcb.cpp ../pcbnew/ratsnest_data.cpp ../pcbnew/ratsnest_viewitem.cpp Loading include/wxPcbStruct.h +2 −0 Original line number Diff line number Diff line Loading @@ -636,6 +636,8 @@ public: */ void ShowDesignRulesEditor( wxCommandEvent& event ); void ShowTeardropsWnd( wxCommandEvent& event ); /* toolbars update UI functions: */ void PrepareLayerIndicator(); Loading pcbnew/class_teardrop.cpp +82 −1 Original line number Diff line number Diff line #include "class_teardrop.h" #include "class_board.h" #include "class_board_item.h" TEARDROP::TEARDROP(BOARD_ITEM *aParent) : TRACK(aParent, PCB_TRACE_T) Loading @@ -6,9 +8,28 @@ TEARDROP::TEARDROP(BOARD_ITEM *aParent) : m_type = TEARDROP_NONE; } bool TEARDROP::Create(TRACK &aTrack) bool TEARDROP::Create(TRACK &aTrack, ENDPOINT_T endPoint, TEARDROP_TYPE type = TEARDROP_STRAIGHT) { std::vector<VECTOR2I> upperSegment; std::vector<VECTOR2I> lowerSegment; bool result = false; VIA *aVia = GetViaOnEnd(aTrack, endPoint); if (aVia == NULL) { return false; } if (type == TEARDROP_STRAIGHT) { result = StraightSegments(aTrack, *aVia, upperSegment, lowerSegment, 100); } else if (type == TEARDROP_CURVED) { result = CurvedSegments(aTrack, *aVia, upperSegment, lowerSegment); } if (result == true) { result = BuildTracks(aTrack, upperSegment, lowerSegment); } return result; } bool TEARDROP::SetVector(TRACK &aTrack, const VIA & aVia, VECTOR2I &startPoint, VECTOR2I &endPoint) Loading Loading @@ -106,3 +127,63 @@ bool TEARDROP::StraightSegments(TRACK &aTrack, const VIA &aVia, std::vector<VECT return true; } // TODO: m_TracksConnected member is considered a temporary storage. Find another way to get an object VIA *TEARDROP::GetViaOnEnd(TRACK &aTrack, ENDPOINT_T endPoint) { wxPoint trackPoint; std::vector<TRACK *>::const_iterator iter; if (endPoint == ENDPOINT_START) { trackPoint = aTrack.GetStart(); } else { trackPoint = aTrack.GetEnd(); } for (iter = aTrack.m_TracksConnected.begin(); iter != aTrack.m_TracksConnected.end(); ++iter) { KICAD_T type = (*iter)->Type(); bool hitTest = (*iter)->HitTest(trackPoint); if (type == PCB_VIA_T && hitTest == true) { return static_cast<VIA *>(*iter); } } return NULL; } bool TEARDROP::BuildTracks(TRACK &aTrack, std::vector<VECTOR2I> upperSegments, std::vector<VECTOR2I> lowerSegments) { BOARD *board = aTrack.GetBoard(); wxPoint currentPoint(0, 0); wxPoint prevPoint(upperSegments[0].x, upperSegments[0].y); for (size_t i = 0; i < upperSegments.size(); i++) { TRACK *track = new TRACK(board); track->SetWidth(aTrack.GetWidth()); track->SetLayer(aTrack.GetLayer()); track->SetNetCode(aTrack.GetNetCode()); currentPoint.x = upperSegments[i].x; currentPoint.y = upperSegments[i].y; track->SetStart(prevPoint); track->SetEnd(currentPoint); board->Add(track); m_upperSegment.push_back(track); prevPoint = currentPoint; } currentPoint = wxPoint(0, 0); prevPoint = wxPoint(lowerSegments[0].x, lowerSegments[0].y); for (size_t i = 0; i < lowerSegments.size(); i++) { TRACK *track = new TRACK(board); track->SetWidth(aTrack.GetWidth()); track->SetLayer(aTrack.GetLayer()); track->SetNetCode(aTrack.GetNetCode()); currentPoint.x = lowerSegments[i].x; currentPoint.y = lowerSegments[i].y; track->SetStart(prevPoint); track->SetEnd(currentPoint); board->Add(track); m_lowerSegment.push_back(track); prevPoint = currentPoint; } return true; } pcbnew/class_teardrop.h +10 −7 Original line number Diff line number Diff line Loading @@ -36,9 +36,9 @@ public: * @brief Defines the type of a teardrop. */ typedef enum { TEARDROP_NONE, /// The type is undefined TEARDROP_STRAIGHT, /// The teardrop is created by two straight segments TEARDROP_CURVED /// The teardrop is created by several segments approximating deltoid TEARDROP_NONE, ///< The type is undefined TEARDROP_STRAIGHT, ///< The teardrop is created by two straight segments TEARDROP_CURVED ///< The teardrop is created by several segments approximating deltoid } TEARDROP_TYPE; /** Loading @@ -52,14 +52,14 @@ public: * @param aTrack * @return \a true in case the teardrops were successfully built and \a false otherwise */ bool Create(TRACK &aTrack); bool Create(TRACK &aTrack, ENDPOINT_T endPoint, TEARDROP_TYPE type); private: ///> Contains the type of teardrop TEARDROP_TYPE m_type; ///> \a m_upperSegment and \a m_lowerSegment contain actual segments composing a teardrop std::vector<TRACK> m_upperSegment; std::vector<TRACK> m_lowerSegment; ///> \a m_upperSegment and \a m_lowerSegment contain pointers to actual segments composing a teardrop std::vector<TRACK *> m_upperSegment; std::vector<TRACK *> m_lowerSegment; /** * @brief Function \a CurvedSegments computes several points on deltoid curve and moves Loading Loading @@ -96,6 +96,9 @@ private: * @return \a true in case the vector is created successfully and \a false otherwise */ bool SetVector(TRACK &aTrack, const VIA &aVia, VECTOR2I &startPoint, VECTOR2I &endPoint); VIA* GetViaOnEnd(TRACK &aTrack, ENDPOINT_T endPoint); bool BuildTracks(TRACK &aTrack, std::vector<VECTOR2I> upperSegments, std::vector<VECTOR2I> lowerSegments); }; #endif // CLASS_TEARDROP_H pcbnew/menubar_pcbframe.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -615,6 +615,10 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() _( "Fast access to the Web Based FreeROUTE advanced router" ), KiBitmap( web_support_xpm ) ); AddMenuItem( toolsMenu, ID_TEARDROPS_WINDOW, _( "Teardrops" ), _("Add teardrops"), KiBitmap( new_pcb_xpm ) ); #if defined(KICAD_SCRIPTING_WXPYTHON) AddMenuItem( toolsMenu, ID_TOOLBARH_PCB_SCRIPTING_CONSOLE, _( "&Scripting Console" ), Loading Loading
common/CMakeLists.txt +1 −0 Original line number Diff line number Diff line Loading @@ -278,6 +278,7 @@ set( PCB_COMMON_SRCS ../pcbnew/class_track.cpp ../pcbnew/class_zone.cpp ../pcbnew/class_zone_settings.cpp ../pcbnew/class_teardrop.cpp ../pcbnew/classpcb.cpp ../pcbnew/ratsnest_data.cpp ../pcbnew/ratsnest_viewitem.cpp Loading
include/wxPcbStruct.h +2 −0 Original line number Diff line number Diff line Loading @@ -636,6 +636,8 @@ public: */ void ShowDesignRulesEditor( wxCommandEvent& event ); void ShowTeardropsWnd( wxCommandEvent& event ); /* toolbars update UI functions: */ void PrepareLayerIndicator(); Loading
pcbnew/class_teardrop.cpp +82 −1 Original line number Diff line number Diff line #include "class_teardrop.h" #include "class_board.h" #include "class_board_item.h" TEARDROP::TEARDROP(BOARD_ITEM *aParent) : TRACK(aParent, PCB_TRACE_T) Loading @@ -6,9 +8,28 @@ TEARDROP::TEARDROP(BOARD_ITEM *aParent) : m_type = TEARDROP_NONE; } bool TEARDROP::Create(TRACK &aTrack) bool TEARDROP::Create(TRACK &aTrack, ENDPOINT_T endPoint, TEARDROP_TYPE type = TEARDROP_STRAIGHT) { std::vector<VECTOR2I> upperSegment; std::vector<VECTOR2I> lowerSegment; bool result = false; VIA *aVia = GetViaOnEnd(aTrack, endPoint); if (aVia == NULL) { return false; } if (type == TEARDROP_STRAIGHT) { result = StraightSegments(aTrack, *aVia, upperSegment, lowerSegment, 100); } else if (type == TEARDROP_CURVED) { result = CurvedSegments(aTrack, *aVia, upperSegment, lowerSegment); } if (result == true) { result = BuildTracks(aTrack, upperSegment, lowerSegment); } return result; } bool TEARDROP::SetVector(TRACK &aTrack, const VIA & aVia, VECTOR2I &startPoint, VECTOR2I &endPoint) Loading Loading @@ -106,3 +127,63 @@ bool TEARDROP::StraightSegments(TRACK &aTrack, const VIA &aVia, std::vector<VECT return true; } // TODO: m_TracksConnected member is considered a temporary storage. Find another way to get an object VIA *TEARDROP::GetViaOnEnd(TRACK &aTrack, ENDPOINT_T endPoint) { wxPoint trackPoint; std::vector<TRACK *>::const_iterator iter; if (endPoint == ENDPOINT_START) { trackPoint = aTrack.GetStart(); } else { trackPoint = aTrack.GetEnd(); } for (iter = aTrack.m_TracksConnected.begin(); iter != aTrack.m_TracksConnected.end(); ++iter) { KICAD_T type = (*iter)->Type(); bool hitTest = (*iter)->HitTest(trackPoint); if (type == PCB_VIA_T && hitTest == true) { return static_cast<VIA *>(*iter); } } return NULL; } bool TEARDROP::BuildTracks(TRACK &aTrack, std::vector<VECTOR2I> upperSegments, std::vector<VECTOR2I> lowerSegments) { BOARD *board = aTrack.GetBoard(); wxPoint currentPoint(0, 0); wxPoint prevPoint(upperSegments[0].x, upperSegments[0].y); for (size_t i = 0; i < upperSegments.size(); i++) { TRACK *track = new TRACK(board); track->SetWidth(aTrack.GetWidth()); track->SetLayer(aTrack.GetLayer()); track->SetNetCode(aTrack.GetNetCode()); currentPoint.x = upperSegments[i].x; currentPoint.y = upperSegments[i].y; track->SetStart(prevPoint); track->SetEnd(currentPoint); board->Add(track); m_upperSegment.push_back(track); prevPoint = currentPoint; } currentPoint = wxPoint(0, 0); prevPoint = wxPoint(lowerSegments[0].x, lowerSegments[0].y); for (size_t i = 0; i < lowerSegments.size(); i++) { TRACK *track = new TRACK(board); track->SetWidth(aTrack.GetWidth()); track->SetLayer(aTrack.GetLayer()); track->SetNetCode(aTrack.GetNetCode()); currentPoint.x = lowerSegments[i].x; currentPoint.y = lowerSegments[i].y; track->SetStart(prevPoint); track->SetEnd(currentPoint); board->Add(track); m_lowerSegment.push_back(track); prevPoint = currentPoint; } return true; }
pcbnew/class_teardrop.h +10 −7 Original line number Diff line number Diff line Loading @@ -36,9 +36,9 @@ public: * @brief Defines the type of a teardrop. */ typedef enum { TEARDROP_NONE, /// The type is undefined TEARDROP_STRAIGHT, /// The teardrop is created by two straight segments TEARDROP_CURVED /// The teardrop is created by several segments approximating deltoid TEARDROP_NONE, ///< The type is undefined TEARDROP_STRAIGHT, ///< The teardrop is created by two straight segments TEARDROP_CURVED ///< The teardrop is created by several segments approximating deltoid } TEARDROP_TYPE; /** Loading @@ -52,14 +52,14 @@ public: * @param aTrack * @return \a true in case the teardrops were successfully built and \a false otherwise */ bool Create(TRACK &aTrack); bool Create(TRACK &aTrack, ENDPOINT_T endPoint, TEARDROP_TYPE type); private: ///> Contains the type of teardrop TEARDROP_TYPE m_type; ///> \a m_upperSegment and \a m_lowerSegment contain actual segments composing a teardrop std::vector<TRACK> m_upperSegment; std::vector<TRACK> m_lowerSegment; ///> \a m_upperSegment and \a m_lowerSegment contain pointers to actual segments composing a teardrop std::vector<TRACK *> m_upperSegment; std::vector<TRACK *> m_lowerSegment; /** * @brief Function \a CurvedSegments computes several points on deltoid curve and moves Loading Loading @@ -96,6 +96,9 @@ private: * @return \a true in case the vector is created successfully and \a false otherwise */ bool SetVector(TRACK &aTrack, const VIA &aVia, VECTOR2I &startPoint, VECTOR2I &endPoint); VIA* GetViaOnEnd(TRACK &aTrack, ENDPOINT_T endPoint); bool BuildTracks(TRACK &aTrack, std::vector<VECTOR2I> upperSegments, std::vector<VECTOR2I> lowerSegments); }; #endif // CLASS_TEARDROP_H
pcbnew/menubar_pcbframe.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -615,6 +615,10 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() _( "Fast access to the Web Based FreeROUTE advanced router" ), KiBitmap( web_support_xpm ) ); AddMenuItem( toolsMenu, ID_TEARDROPS_WINDOW, _( "Teardrops" ), _("Add teardrops"), KiBitmap( new_pcb_xpm ) ); #if defined(KICAD_SCRIPTING_WXPYTHON) AddMenuItem( toolsMenu, ID_TOOLBARH_PCB_SCRIPTING_CONSOLE, _( "&Scripting Console" ), Loading