Commit 4b8df000 authored by Mikhail Karpenko's avatar Mikhail Karpenko

WIP: adding teardrops to circular pads

parent aac3de4a
...@@ -12,10 +12,26 @@ bool TEARDROP::Create(TRACK &aTrack, ENDPOINT_T endPoint, TEARDROP_TYPE type = T ...@@ -12,10 +12,26 @@ bool TEARDROP::Create(TRACK &aTrack, ENDPOINT_T endPoint, TEARDROP_TYPE type = T
{ {
bool result = false; bool result = false;
VIA *aVia = GetViaOnEnd(aTrack, endPoint); BOARD_CONNECTED_ITEM *anObject = GetObjectOnEnd(aTrack, endPoint);
if (aVia == NULL) { VIA *aVia = NULL;
if (anObject == NULL) {
return false; return false;
} }
else {
switch (anObject->Type()) {
case PCB_VIA_T:
aVia = dynamic_cast<VIA *>(anObject);
break;
case PCB_PAD_T:
aVia = new VIA(NULL);
aVia->SetLayer(anObject->GetLayer());
aVia->SetPosition(anObject->GetPosition());
aVia->SetWidth(2 * dynamic_cast<D_PAD *>(anObject)->GetBoundingRadius());
break;
default:
break;
}
}
if (type == TEARDROP_STRAIGHT) { if (type == TEARDROP_STRAIGHT) {
result = StraightSegments(aTrack, *aVia, m_upperSegment, m_lowerSegment, 100); result = StraightSegments(aTrack, *aVia, m_upperSegment, m_lowerSegment, 100);
...@@ -144,9 +160,10 @@ bool TEARDROP::StraightSegments(TRACK &aTrack, const VIA &aVia, std::vector<VECT ...@@ -144,9 +160,10 @@ bool TEARDROP::StraightSegments(TRACK &aTrack, const VIA &aVia, std::vector<VECT
} }
// TODO: m_TracksConnected member is considered a temporary storage. Find another way to get an object // TODO: m_TracksConnected member is considered a temporary storage. Find another way to get an object
VIA *TEARDROP::GetViaOnEnd(TRACK &aTrack, ENDPOINT_T endPoint) BOARD_CONNECTED_ITEM* TEARDROP::GetObjectOnEnd(TRACK &aTrack, ENDPOINT_T endPoint)
{ {
wxPoint trackPoint; wxPoint trackPoint;
BOARD_CONNECTED_ITEM *item = NULL;
std::vector<TRACK *>::const_iterator iter; std::vector<TRACK *>::const_iterator iter;
if (endPoint == ENDPOINT_START) { if (endPoint == ENDPOINT_START) {
...@@ -156,34 +173,25 @@ VIA *TEARDROP::GetViaOnEnd(TRACK &aTrack, ENDPOINT_T endPoint) ...@@ -156,34 +173,25 @@ VIA *TEARDROP::GetViaOnEnd(TRACK &aTrack, ENDPOINT_T endPoint)
trackPoint = aTrack.GetEnd(); trackPoint = aTrack.GetEnd();
} }
// Check for vias first
for (iter = aTrack.m_TracksConnected.begin(); iter != aTrack.m_TracksConnected.end(); ++iter) { for (iter = aTrack.m_TracksConnected.begin(); iter != aTrack.m_TracksConnected.end(); ++iter) {
KICAD_T type = (*iter)->Type(); KICAD_T type = (*iter)->Type();
bool hitTest = (*iter)->HitTest(trackPoint); bool hitTest = (*iter)->HitTest(trackPoint);
if (type == PCB_VIA_T && hitTest == true) { if (type == PCB_VIA_T && hitTest == true) {
return static_cast<VIA *>(*iter); item = *iter;
} }
} }
return NULL; // Check for pads if via was not found on this end of the track
} if (item == NULL) {
for (std::vector<D_PAD *>::iterator iter = aTrack.m_PadsConnected.begin(); iter != aTrack.m_PadsConnected.end(); ++iter) {
bool TEARDROP::BuildTracks(TRACK &aTrack, std::vector<VECTOR2I> points, std::vector<TRACK *> tracks) PAD_SHAPE_T shape = (*iter)->GetShape();
{ bool hitTest = (*iter)->HitTest(trackPoint);
BOARD *board = aTrack.GetBoard(); if (shape == PAD_CIRCLE && hitTest == true) {
wxPoint currentPoint(0, 0); item = *iter;
wxPoint prevPoint(points[0].x, points[0].y); printf("found circle pad\n");
for (size_t i = 1; i < points.size(); i++) { }
TRACK *track = new TRACK(aTrack); }
track->SetWidth(aTrack.GetWidth());
track->SetLayer(aTrack.GetLayer());
track->SetNetCode(aTrack.GetNetCode());
currentPoint.x = points[i].x;
currentPoint.y = points[i].y;
track->SetStart(prevPoint);
track->SetEnd(currentPoint);
board->Add(track);
tracks.push_back(track);
prevPoint = currentPoint;
} }
return true; return item;
} }
...@@ -99,8 +99,7 @@ private: ...@@ -99,8 +99,7 @@ private:
*/ */
bool SetVector(TRACK &aTrack, const VIA &aVia, VECTOR2I &startPoint, VECTOR2I &endPoint); bool SetVector(TRACK &aTrack, const VIA &aVia, VECTOR2I &startPoint, VECTOR2I &endPoint);
VIA* GetViaOnEnd(TRACK &aTrack, ENDPOINT_T endPoint); BOARD_CONNECTED_ITEM* GetObjectOnEnd(TRACK &aTrack, ENDPOINT_T endPoint);
bool BuildTracks(TRACK &aTrack, const std::vector<VECTOR2I> points, std::vector<TRACK *> tracks);
}; };
#endif // CLASS_TEARDROP_H #endif // CLASS_TEARDROP_H
...@@ -603,7 +603,7 @@ ...@@ -603,7 +603,7 @@
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxEXPAND</property> <property name="flag">wxEXPAND</property>
<property name="proportion">1</property> <property name="proportion">1</property>
<object class="wxBoxSizer" expanded="0"> <object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">m_scopeSizer</property> <property name="name">m_scopeSizer</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
...@@ -622,7 +622,7 @@ ...@@ -622,7 +622,7 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL</property> <property name="flag"></property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxCheckBox" expanded="1"> <object class="wxCheckBox" expanded="1">
<property name="bg"></property> <property name="bg"></property>
...@@ -678,7 +678,7 @@ ...@@ -678,7 +678,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL</property> <property name="flag"></property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxCheckBox" expanded="1"> <object class="wxCheckBox" expanded="1">
<property name="bg"></property> <property name="bg"></property>
...@@ -734,7 +734,7 @@ ...@@ -734,7 +734,7 @@
</object> </object>
<object class="sizeritem" expanded="1"> <object class="sizeritem" expanded="1">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL</property> <property name="flag"></property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxCheckBox" expanded="1"> <object class="wxCheckBox" expanded="1">
<property name="bg"></property> <property name="bg"></property>
......
#include "edit_teardrops.h" #include "edit_teardrops.h"
#include "class_board.h" #include "class_board.h"
#include "class_module.h"
TEARDROPS_EDITOR::TEARDROPS_EDITOR(PCB_EDIT_FRAME *frame, KIGFX::VIEW *view) TEARDROPS_EDITOR::TEARDROPS_EDITOR(PCB_EDIT_FRAME *frame, KIGFX::VIEW *view)
{ {
...@@ -50,6 +51,7 @@ bool TEARDROPS_EDITOR::AddToAll(const DIALOG_TEARDROPS::TEARDROPS_SETTINGS &sett ...@@ -50,6 +51,7 @@ bool TEARDROPS_EDITOR::AddToAll(const DIALOG_TEARDROPS::TEARDROPS_SETTINGS &sett
bool retVal = false; bool retVal = false;
bool added = false; bool added = false;
// Iterate through all vias and add teardrops to connected tracks
if ((settings.m_scope & DIALOG_TEARDROPS::TEARDROPS_SCOPE_VIAS) == DIALOG_TEARDROPS::TEARDROPS_SCOPE_VIAS) { if ((settings.m_scope & DIALOG_TEARDROPS::TEARDROPS_SCOPE_VIAS) == DIALOG_TEARDROPS::TEARDROPS_SCOPE_VIAS) {
for (VIA *via = GetFirstVia(m_frame->GetBoard()->m_Track); via != NULL; for (VIA *via = GetFirstVia(m_frame->GetBoard()->m_Track); via != NULL;
via = GetFirstVia(via->Next())) { via = GetFirstVia(via->Next())) {
...@@ -69,6 +71,13 @@ bool TEARDROPS_EDITOR::AddToAll(const DIALOG_TEARDROPS::TEARDROPS_SETTINGS &sett ...@@ -69,6 +71,13 @@ bool TEARDROPS_EDITOR::AddToAll(const DIALOG_TEARDROPS::TEARDROPS_SETTINGS &sett
} }
} }
// Iterate through all modules and add teardrops to tracks connected to their pads
if ((settings.m_scope & DIALOG_TEARDROPS::TEARDROPS_SCOPE_PADS) == DIALOG_TEARDROPS::TEARDROPS_SCOPE_PADS) {
for (MODULE *module = m_frame->GetBoard()->m_Modules.GetFirst(); module != NULL; module = module->Next()) {
}
}
if (added == true) { if (added == true) {
m_frame->SaveCopyInUndoList(m_undoListPicker, UR_NEW); m_frame->SaveCopyInUndoList(m_undoListPicker, UR_NEW);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment