more about zones.

This commit is contained in:
CHARRAS 2008-01-06 20:58:27 +00:00
parent 0120f07d54
commit 638ab25498
11 changed files with 123 additions and 55 deletions

View File

@ -5,7 +5,7 @@
COMMON_GLOBL wxString g_BuildVersion
#ifdef EDA_BASE
(wxT("(2008-01-01)"))
(wxT("(2008-01-06)"))
#endif
;

View File

@ -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)

View File

@ -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 *.

View File

@ -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;

View File

@ -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( "<noname>" );
if( equipot )
msg = equipot->m_Netname;
else
msg = wxT( "<noname>" );
}
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 );

View File

@ -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 )

View File

@ -956,6 +956,8 @@ void WinEDA_BasePcbFrame::recalcule_pad_net_code()
MyFree( BufPtEquipot );
m_Pcb->m_Status_Pcb |= NET_CODES_OK;
m_Pcb->SetAreasNetCodesFromNetNames();
}

View File

@ -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;
}

View File

@ -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];

View File

@ -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 <CPolyPt> corner; // array of points for corners
std::vector <int> side_style; // array of styles for sides
private:
// std::vector <dl_element*> dl_side; // graphic elements
// std::vector <dl_element*> dl_side_sel;
// std::vector <dl_element*> dl_corner_sel;
public:
int m_HatchStyle; // hatch style, see enum above
std::vector <CSegment> m_HatchLines; // hatch lines
private:

View File

@ -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: