From 638ab25498f0c26d01ec3842962ad319e55c3424 Mon Sep 17 00:00:00 2001 From: CHARRAS Date: Sun, 6 Jan 2008 20:58:27 +0000 Subject: [PATCH] more about zones. --- include/build_version.h | 2 +- pcbnew/class_board.cpp | 25 +++++++++++++++++++++++++ pcbnew/class_board.h | 24 +++++++++++++++++++++++- pcbnew/class_board_item.cpp | 18 +++++++++++++----- pcbnew/class_zone.cpp | 32 +++++++++++++++++++++++++------- pcbnew/ioascii.cpp | 2 +- pcbnew/ratsnest.cpp | 2 ++ pcbnew/zones_by_polygon.cpp | 31 +++++++++++++++++++++++++++++++ polygon/PolyLine.cpp | 8 +------- polygon/PolyLine.h | 20 +------------------- polygon/PolyLine2Kicad.h | 14 -------------- 11 files changed, 123 insertions(+), 55 deletions(-) diff --git a/include/build_version.h b/include/build_version.h index 8b5d80415c..0b35e1808f 100644 --- a/include/build_version.h +++ b/include/build_version.h @@ -5,7 +5,7 @@ COMMON_GLOBL wxString g_BuildVersion #ifdef EDA_BASE - (wxT("(2008-01-01)")) + (wxT("(2008-01-06)")) #endif ; diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 90bfa189e6..75c95b1280 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -688,6 +688,31 @@ EQUIPOT* BOARD::FindNet( int anetcode ) const } +/** + * Function FindNet overlayed + * searches for a net with the given name. + * @param aNetname A Netname to search for. + * @return EQUIPOT* - the net or NULL if not found. + */ +EQUIPOT* BOARD::FindNet( const wxString & aNetname ) const +{ + // the first valid netcode is 1. + // zero is reserved for "no connection" and is not used. + if( ! aNetname.IsEmpty() ) + { + for( EQUIPOT* net = m_Equipots; net; net=net->Next() ) + { + if( net->m_Netname == aNetname ) + return net; + } + } + return NULL; +} + + + + + /* Two sort functions used in BOARD::ReturnSortedNetnamesList */ // Sort nets by name int s_SortByNames(const void * ptr1, const void * ptr2) diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 4cd05518ff..d5e032c0a9 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -177,6 +177,14 @@ public: */ EQUIPOT* FindNet( int aNetcode ) const; + /** + * Function FindNet overlayed + * searches for a net with the given name. + * @param aNetname A Netname to search for. + * @return EQUIPOT* - the net or NULL if not found. + */ + EQUIPOT* FindNet( const wxString & aNetname ) const; + /** * Function ReturnSortedNetnamesList * searches for a net with the given netcode. @@ -223,8 +231,22 @@ public: #endif + /*************************/ /* Copper Areas handling */ - /** + /*************************/ + + /** + * Function SetAreasNetCodesFromNetNames + * Set the .m_NetCode member of all copper areas, according to the area Net Name + * The SetNetCodesFromNetNames is an equivalent to net name, for fas comparisons. + * However the Netcode is an arbitrary equyivalence, it must be set after each netlist read + * or net change + * Must be called after pad netcodes are calculated + * @return : error count + */ + int SetAreasNetCodesFromNetNames(void); + + /** * Function GetArea * returns the Area (Zone Container) at a given index. * @param index The array type index into a collection of ZONE_CONTAINER *. diff --git a/pcbnew/class_board_item.cpp b/pcbnew/class_board_item.cpp index 3b912a7d62..c283ccaac8 100644 --- a/pcbnew/class_board_item.cpp +++ b/pcbnew/class_board_item.cpp @@ -161,11 +161,19 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const TimeStampText.Printf( wxT( "(%8.8X)" ), item->m_TimeStamp ); text << TimeStampText; } - net = aPcb->FindNet( ( (ZONE_CONTAINER*) item )->GetNet() ); - if( net ) - { - text << wxT( " [" ) << net->m_Netname << wxT( "]" ); - } + if ( ((ZONE_CONTAINER*) item)->GetNet() >= 0 ) + { + net = aPcb->FindNet( ( (ZONE_CONTAINER*) item )->GetNet() ); + if( net ) + { + text << wxT( " [" ) << net->m_Netname << wxT( "]" ); + } + } + else // A netcode < 0 is an error flag (Netname not found or area not initialised) + { + text << wxT( " [" ) << ( (ZONE_CONTAINER*) item )->m_Netname << wxT( "]" ); + text << wxT(" <") << _("Not Found") << wxT(">"); + } text << _( " on " ) << ReturnPcbLayerName( item->GetLayer() ).Trim(); break; diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index e4bbece76f..47982e7b6f 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -67,16 +67,24 @@ ZONE_CONTAINER::~ZONE_CONTAINER() /*******************************************/ void ZONE_CONTAINER::SetNet( int anet_code ) /*******************************************/ +/** + * Set the netcode and the netname + * if netcode >= 0, set the netname + * if netcode < 0: keep old netname (used to set an necode error flag) + */ { m_NetCode = anet_code; + + if ( anet_code < 0 ) return; + if ( m_Parent ) { - EQUIPOT* net = ((BOARD*) m_Parent)->FindNet( g_HightLigth_NetCode ); + EQUIPOT* net = ((BOARD*) m_Parent)->FindNet( anet_code ); if( net ) m_Netname = net->m_Netname; else m_Netname.Empty(); } - else m_Netname.Empty(); + else m_Netname.Empty(); } @@ -446,12 +454,22 @@ void ZONE_CONTAINER::Display_Infos( WinEDA_DrawFrame* frame ) Affiche_1_Parametre( frame, text_pos, _( "Type" ), msg, DARKCYAN ); text_pos += 15; - EQUIPOT* equipot = ( (WinEDA_PcbFrame*) frame )->m_Pcb->FindNet( GetNet() ); + + if ( GetNet() >= 0 ) + { + EQUIPOT* equipot = ( (WinEDA_PcbFrame*) frame )->m_Pcb->FindNet( GetNet() ); - if( equipot ) - msg = equipot->m_Netname; - else - msg = wxT( "" ); + if( equipot ) + msg = equipot->m_Netname; + else + msg = wxT( "" ); + } + else // a netcode <à is an error + { + msg = wxT( " [" ); + msg << m_Netname + wxT( "]" ); + msg << wxT(" <") << _("Not Found") << wxT(">"); + } Affiche_1_Parametre( frame, text_pos, _( "NetName" ), msg, RED ); diff --git a/pcbnew/ioascii.cpp b/pcbnew/ioascii.cpp index 0c06a800e4..871344c7aa 100644 --- a/pcbnew/ioascii.cpp +++ b/pcbnew/ioascii.cpp @@ -819,7 +819,7 @@ int WinEDA_PcbFrame::ReadPcbFile( wxDC* DC, FILE* File, bool Append ) { ZONE_CONTAINER * zone_descr = new ZONE_CONTAINER(m_Pcb); zone_descr->ReadDescr( File, &LineNum ); - m_Pcb->m_ZoneDescriptorList.push_back(zone_descr); + m_Pcb->Add(zone_descr); } if( strnicmp( Line, "$MODULE", 7 ) == 0 ) diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp index bc9b02a541..20a6c927c6 100644 --- a/pcbnew/ratsnest.cpp +++ b/pcbnew/ratsnest.cpp @@ -956,6 +956,8 @@ void WinEDA_BasePcbFrame::recalcule_pad_net_code() MyFree( BufPtEquipot ); m_Pcb->m_Status_Pcb |= NET_CODES_OK; + + m_Pcb->SetAreasNetCodesFromNetNames(); } diff --git a/pcbnew/zones_by_polygon.cpp b/pcbnew/zones_by_polygon.cpp index f5f7e045e2..e95961f77b 100644 --- a/pcbnew/zones_by_polygon.cpp +++ b/pcbnew/zones_by_polygon.cpp @@ -878,3 +878,34 @@ int WinEDA_PcbFrame::Fill_All_Zones( wxDC* DC, bool verbose ) DrawPanel->Refresh( true ); return error_level; } + + +/** + * Function SetAreasNetCodesFromNetNames + * Set the .m_NetCode member of all copper areas, according to the area Net Name + * The SetNetCodesFromNetNames is an equivalent to net name, for fas comparisons. + * However the Netcode is an arbitrary equyivalence, it must be set after each netlist read + * or net change + * Must be called after pad netcodes are calculated + * @return : error count + */ +int BOARD::SetAreasNetCodesFromNetNames(void) +{ + int error_count = 0; + + for ( int ii = 0; ii < GetAreaCount(); ii++ ) + { + const EQUIPOT* net = FindNet( GetArea(ii)->m_Netname ); + if ( net ) + { + GetArea(ii)->SetNet(net->GetNet()); + } + else + { + error_count++; + GetArea(ii)->SetNet(-1); //keep Net Name ane set m_NetCode to -1 : error flag + } + } + + return error_count; +} diff --git a/polygon/PolyLine.cpp b/polygon/PolyLine.cpp index eb8aab2941..1fb065bb6c 100644 --- a/polygon/PolyLine.cpp +++ b/polygon/PolyLine.cpp @@ -1,6 +1,6 @@ // PolyLine.cpp ... implementation of CPolyLine class from FreePCB. // -// Adaptation for kicad +// implementation for kicad // using namespace std; @@ -879,11 +879,6 @@ int CPolyLine::GetNumSides() return corner.size()-1; } -int CPolyLine::GetW() -{ - return m_Width; -} - int CPolyLine::GetNumContours() { int ncont = 0; @@ -1011,7 +1006,6 @@ void CPolyLine::Hatch() { enum { MAXPTS = 100, - MAXLINES = 1000 }; int xx[MAXPTS], yy[MAXPTS]; diff --git a/polygon/PolyLine.h b/polygon/PolyLine.h index 35f314356d..8eeac368a6 100644 --- a/polygon/PolyLine.h +++ b/polygon/PolyLine.h @@ -63,10 +63,8 @@ class CPolyLine public: enum { STRAIGHT, ARC_CW, ARC_CCW }; // side styles enum { NO_HATCH, DIAGONAL_FULL, DIAGONAL_EDGE }; // hatch styles - enum { DEF_SIZE = 50, DEF_ADD = 50 }; // number of array elements to add at a time // constructors/destructor -// CPolyLine( CDisplayList * dl = NULL ); CPolyLine(); ~CPolyLine(); @@ -82,16 +80,9 @@ public: void RemoveAllContours( void ); // drawing functions -/* void HighlightSide( int is ); - void HighlightCorner( int ic ); - void StartDraggingToInsertCorner( CDC * pDC, int ic, int x, int y); - void StartDraggingToMoveCorner( CDC * pDC, int ic, int x, int y); - void CancelDraggingToInsertCorner( int ic ); - void CancelDraggingToMoveCorner( int ic ); -*/ void Undraw(); + void Undraw(); void Draw( ); void Hatch(); -// void MakeVisible( bool visible = TRUE ); void MoveOrigin( int x_off, int y_off ); // misc. functions @@ -121,15 +112,12 @@ public: int GetEndContour( int ic ); int GetUtility( int ic ){ return corner[ic].utility; }; void SetUtility( int ic, int utility ){ corner[ic].utility = utility; }; - int GetW(); int GetSideStyle( int is ); int GetHatchStyle(){ return m_HatchStyle; } void SetHatch( int hatch ){ Undraw(); m_HatchStyle = hatch; Draw(); }; void SetX( int ic, int x ); void SetY( int ic, int y ); void SetEndContour( int ic, bool end_contour ); -// void SetLayer( int layer ); - void SetW( int w ); void SetSideStyle( int is, int style ); // GPC functions @@ -150,7 +138,6 @@ public: void ClipPhpPolygon( int php_op, CPolyLine * poly ); private: -// CDisplayList * m_dlist; // display list int m_layer; // layer to draw on int m_Width; // line width int m_sel_box; // corner selection box width/2 @@ -158,11 +145,6 @@ private: public: std::vector corner; // array of points for corners std::vector side_style; // array of styles for sides -private: -// std::vector dl_side; // graphic elements -// std::vector dl_side_sel; -// std::vector dl_corner_sel; -public: int m_HatchStyle; // hatch style, see enum above std::vector m_HatchLines; // hatch lines private: diff --git a/polygon/PolyLine2Kicad.h b/polygon/PolyLine2Kicad.h index 4466f5023b..34c3cf016a 100644 --- a/polygon/PolyLine2Kicad.h +++ b/polygon/PolyLine2Kicad.h @@ -30,20 +30,6 @@ #define CDC wxDC class wxDC; -#if 0 -class dl_element; -class CDisplayList { -public: - void Set_visible(void*, int) {}; - int Get_x(void) { return 0;}; - int Get_y(void) { return 0;}; - void StopDragging(void) {}; - void CancelHighLight(void) {}; - void StartDraggingLineVertex(...) {}; - void Add() {}; -}; -#endif - class CRect { public: