diff --git a/pcbnew/dialog_copper_zones.cpp b/pcbnew/dialog_copper_zones.cpp index 6a4cd69960..265c6128b2 100644 --- a/pcbnew/dialog_copper_zones.cpp +++ b/pcbnew/dialog_copper_zones.cpp @@ -229,6 +229,7 @@ void dialog_copper_zone::OnInitDialog( wxInitDialogEvent& event ) if( ListNetName[ii] == equipot->m_Netname ) { m_ListNetNameSelection->SetSelection( ii ); + m_ListNetNameSelection->EnsureVisible( ii ); break; } } @@ -388,6 +389,29 @@ void dialog_copper_zone::OnNetSortingOptionSelected( wxCommandEvent& event ) m_Parent->m_Parent->m_EDA_Config->Write( ZONE_NET_SORT_OPTION_KEY, (long) m_NetSorting ); m_Parent->m_Parent->m_EDA_Config->Write( ZONE_NET_FILTER_STRING_KEY, m_NetNameFilter->GetValue() ); } + + // Select and isplay current zone net name in listbox: + int net_select = g_HightLigth_NetCode; + if( m_Zone_Container ) + net_select = m_Zone_Container->GetNet(); + + if( net_select > 0 ) + { + EQUIPOT* equipot = m_Parent->m_Pcb->FindNet( net_select ); + if( equipot ) // Search net in list and select it + { + for( unsigned ii = 0; ii < ListNetName.GetCount(); ii++ ) + { + if( ListNetName[ii] == equipot->m_Netname ) + { + m_ListNetNameSelection->SetSelection( ii ); + m_ListNetNameSelection->EnsureVisible( ii ); + break; + } + } + } + } + } diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index 027fe5a4cb..e12cd9c218 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -508,11 +508,23 @@ int WinEDA_PcbFrame::Begin_Zone( wxDC* DC ) if( s_CurrentZone == NULL ) // A new outline is created { int diag; - DrawPanel->m_IgnoreMouseEvents = TRUE; + // Init zone params to reasonnable values zone->SetLayer( ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer ); + + // Prompt user fro exact parameters: + DrawPanel->m_IgnoreMouseEvents = TRUE; if( zone->IsOnCopperLayer() ) { // Put a zone on a copper layer - dialog_copper_zone* frame = new dialog_copper_zone( this, zone ); + if ( g_HightLigth_NetCode ) + { + g_NetcodeSelection = g_HightLigth_NetCode; + zone->SetNet( g_NetcodeSelection ); + EQUIPOT* net = m_Pcb->FindNet( g_NetcodeSelection ); + if( net ) + zone->m_Netname = net->m_Netname; + } + + dialog_copper_zone* frame = new dialog_copper_zone( this, zone ); diag = frame->ShowModal(); frame->Destroy(); } diff --git a/polygon/math_for_graphics.cpp b/polygon/math_for_graphics.cpp index 428c8e3b5e..ccd5b182fe 100644 --- a/polygon/math_for_graphics.cpp +++ b/polygon/math_for_graphics.cpp @@ -832,111 +832,8 @@ bool TestForIntersectionOfStraightLineSegments( int x1i, int y1i, int x1f, int y } -// quicksort algorithm -// sorts array numbers[], also moves elements of another array index[] -// -#define Q3WAY -void quickSort(int numbers[], int index[], int array_size) -{ -#ifdef Q3WAY - q_sort_3way(numbers, index, 0, array_size - 1); -#else - q_sort(numbers, index, 0, array_size - 1); -#endif -} - -// standard quicksort -// -void q_sort(int numbers[], int index[], int left, int right) -{ - int pivot, pivot_index, l_hold, r_hold; - - l_hold = left; - r_hold = right; - pivot = numbers[left]; - pivot_index = index[left]; - while (left < right) - { - while ((numbers[right] >= pivot) && (left < right)) - right--; - if (left != right) - { - numbers[left] = numbers[right]; - index[left] = index[right]; - left++; - } - while ((numbers[left] <= pivot) && (left < right)) - left++; - if (left != right) - { - numbers[right] = numbers[left]; - index[right] = index[left]; - right--; - } - } - numbers[left] = pivot; - index[left] = pivot_index; - - pivot = left; - left = l_hold; - right = r_hold; - if (left < pivot) - q_sort(numbers, index, left, pivot-1); - if (right > pivot) - q_sort(numbers, index, pivot+1, right); -} - -// 3-way quicksort...useful where there are duplicate values -// -void q_sort_3way( int a[], int b[], int l, int r ) -{ - #define EXCH(i,j) {int temp=a[i]; a[i]=a[j]; a[j]=temp; temp=b[i]; b[i]=b[j]; b[j]=temp;} - - int i = l - 1; - int j = r; - int p = l - 1; - int q = r; - int v = a[r]; - - if( r <= l ) - return; - - for(;;) - { - while( a[++i] < v ); - while( v < a[--j] ) - if( j == 1 ) - break; - if( i >= j ) - break; - EXCH( i, j ); - if( a[i] == v ) - { - p++; - EXCH( p, i ); - } - if( v == a[j] ) - { - q--; - EXCH( j, q ); - } - } - EXCH( i, r ); - j = i - 1; - i = i + 1; - for( int k=l; k
q; k--, i++ )
- EXCH( i, k );
- q_sort_3way( a, b, l, j );
- q_sort_3way( a, b, i, r );
-}
-
-// solves quadratic equation
-// i.e. ax**2 + bx + c = 0
-// returns true if solution exist, with solutions in x1 and x2
-// else returns false
-//
+/*solves the Quadratic equation = a*x*x + b*x + c
+*/
bool Quadratic( double a, double b, double c, double *x1, double *x2 )
{
double root = b*b - 4.0*a*c;
diff --git a/polygon/math_for_graphics.h b/polygon/math_for_graphics.h
index b7adcaf333..a524117f9e 100644
--- a/polygon/math_for_graphics.h
+++ b/polygon/math_for_graphics.h
@@ -106,7 +106,3 @@ int GetArcIntersections( EllipseKH * el1, EllipseKH * el2,
double * x2=NULL, double * y2=NULL );
CPoint GetInflectionPoint( CPoint pi, CPoint pf, int mode );
-// quicksort (2-way or 3-way)
-void quickSort(int numbers[], int index[], int array_size);
-void q_sort(int numbers[], int index[], int left, int right);
-void q_sort_3way( int a[], int b[], int left, int right );
diff --git a/polygon/polygon_test_point_inside.cpp b/polygon/polygon_test_point_inside.cpp
index b19d9e37d1..64f7754696 100644
--- a/polygon/polygon_test_point_inside.cpp
+++ b/polygon/polygon_test_point_inside.cpp
@@ -1,4 +1,5 @@
/////////////////////////////////////////////////////////////////////////////
+
// Name: polygon_test_point_inside.cpp
/////////////////////////////////////////////////////////////////////////////
@@ -9,18 +10,18 @@
using namespace std;
/* this algo uses the the Jordan curve theorem to find if a point is inside or outside a polygon:
- * It run a semi-infinite line horizontally (increasing x, fixed y)
- * out from the test point, and count how many edges it crosses.
- * At each crossing, the ray switches between inside and outside.
- * If odd count, the test point is inside the polygon
- * This is called the Jordan curve theorem, or sometimes referred to as the "even-odd" test.
+ * It run a semi-infinite line horizontally (increasing x, fixed y)
+ * out from the test point, and count how many edges it crosses.
+ * At each crossing, the ray switches between inside and outside.
+ * If odd count, the test point is inside the polygon
+ * This is called the Jordan curve theorem, or sometimes referred to as the "even-odd" test.
*/
/* 2 versions are given.
* the second version is GPL (currently used)
* the first version is for explanations and tests (used to test the second version)
* both use the same algorithm.
-*/
+ */
#if 0
/* This text and the algorithm come from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
@@ -282,9 +283,6 @@ bool TestPointInsidePolygon( std::vector