more zone preps

This commit is contained in:
dickelbeck 2007-10-31 06:40:15 +00:00
parent 64e9e16886
commit f353c77cdc
14 changed files with 1088 additions and 850 deletions

View File

@ -19,6 +19,8 @@ email address.
design and was crashing. Also, export_to_pcbnew.cpp now uses the simple
BOARD::Save() function. It was another place to maintain the PCB file format,
rather than simply putting that knowledge into one place like BOARD::Save().
+ all
beautified gr_basic.cpp and made CLIP_LINE macro a static inline function.
2007-Oct-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>

View File

@ -57,23 +57,6 @@ void EDA_BaseStruct::InitVars()
}
/* Gestion de l'etat (status) de la structure (active, deleted..) */
int EDA_BaseStruct::GetState( int type ) const
{
return m_Status & type;
}
void EDA_BaseStruct::SetState( int type, int state )
{
if( state )
m_Status |= type;/* state = ON ou OFF */
else
m_Status &= ~type;
}
/***********************************************************/
void EDA_BaseStruct::DeleteStructList()
/***********************************************************/

File diff suppressed because it is too large Load Diff

View File

@ -191,8 +191,19 @@ public:
/* Gestion de l'etat (status) de la structure (active, deleted..) */
int GetState( int type ) const;
void SetState( int type, int state );
int GetState( int type ) const
{
return m_Status & type;
}
void SetState( int type, int state )
{
if( state )
m_Status |= type; // state = ON or OFF
else
m_Status &= ~type;
}
int ReturnStatus() const { return m_Status; }

View File

@ -442,6 +442,17 @@ public:
EDGE_ZONE( BOARD_ITEM* StructFather );
EDGE_ZONE( const EDGE_ZONE& edgezone );
~EDGE_ZONE();
EDGE_ZONE* Next() { return (EDGE_ZONE*) Pnext; }
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.pcb" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile ) const;
};

View File

@ -535,7 +535,13 @@ public:
void Block_Move( wxDC* DC );
void Block_Duplicate( wxDC* DC );
// zone handling:
/**
* Function DelLimitesZone
* deletes the limits of a zone.
* @param DC A wxDC to draw onto.
* @param Redraw If true, means redraw the pcb without the zone limits
*/
void DelLimitesZone( wxDC* DC, bool Redraw );
// layerhandling:

View File

@ -610,7 +610,7 @@ bool BOARD::Save( FILE* aFile ) const
default:
// future: throw exception here
#if defined(DEBUG)
printf( "BOARD::Save() ignoring draw type %d\n", item->Type() );
printf( "BOARD::Save() ignoring m_Drawings type %d\n", item->Type() );
#endif
break;
}
@ -623,14 +623,22 @@ bool BOARD::Save( FILE* aFile ) const
goto out;
fprintf( aFile, "$EndTRACK\n" );
// save the zones
fprintf( aFile, "$ZONE\n" );
for( item = m_Zone; item; item=item->Next() )
if( !item->Save( aFile ) )
goto out;
fprintf( aFile, "$EndZONE\n" );
// save the zone edges
if( m_CurrentLimitZone )
{
fprintf( aFile, "$ZONE_EDGE\n" );
for( item = m_CurrentLimitZone; item; item=item->Next() )
if( !item->Save( aFile ) )
goto out;
fprintf( aFile, "$EndZONE_EDGE\n" );
}
if( fprintf( aFile, "$EndBOARD\n" ) != sizeof("$EndBOARD\n")-1 )
goto out;
@ -690,11 +698,11 @@ void BOARD::Show( int nestLevel, std::ostream& os )
p->Show( nestLevel+2, os );
NestedSpace( nestLevel+1, os ) << "</zones>\n";
NestedSpace( nestLevel+1, os ) << "<edgezones>\n";
NestedSpace( nestLevel+1, os ) << "<zoneedges>\n";
p = m_CurrentLimitZone;
for( ; p; p = p->Pnext )
p->Show( nestLevel+2, os );
NestedSpace( nestLevel+1, os ) << "</edgezones>\n";
NestedSpace( nestLevel+1, os ) << "</zoneedges>\n";
p = m_Son;
for( ; p; p = p->Pnext )

View File

@ -404,7 +404,9 @@ bool EDGE_MODULE::Save( FILE* aFile ) const
default:
// future: throw an exception here
printf( "%s unexpected EDGE_MODULE::m_Shape: %d\n", __func__, m_Shape );
#if defined(DEBUG)
printf( "EDGE_MODULE::Save(): unexpected m_Shape: %d\n", m_Shape );
#endif
break;
}

View File

@ -80,10 +80,12 @@ public:
*/
void Insert( BOARD* Pcb, BOARD_ITEM* InsertPoint );
/*Search the "best" insertion point within the track linked list
* the best point is the of the corresponding net code section
* @return the item found in the linked list (or NULL if no track)
*/
/**
* Function GetBestInsertPoint
* searches the "best" insertion point within the track linked list.
* The best point is the of the corresponding net code section.
* @return TRACK* - the item found in the linked list (or NULL if no track)
*/
TRACK* GetBestInsertPoint( BOARD* Pcb );
/* Search (within the track linked list) the first segment matching the netcode

View File

@ -38,6 +38,7 @@ void EDA_BaseStruct::Place( WinEDA_DrawFrame* frame, wxDC* DC )
EDGE_ZONE::EDGE_ZONE( BOARD_ITEM* parent ) :
DRAWSEGMENT( parent, TYPEEDGEZONE )
{
m_Width = 2; // a minimum for visibility, while dragging
}
@ -47,6 +48,23 @@ EDGE_ZONE:: ~EDGE_ZONE()
}
bool EDGE_ZONE::Save( FILE* aFile ) const
{
if( GetState( DELETED ) )
return true;
int ret = fprintf( aFile, "ZE %d %d %d %d %d %lX %X\n",
m_Start.x, m_Start.y,
m_End.x, m_End.y,
m_Angle,
m_TimeStamp,
ReturnStatus()
);
return (ret > 14 );
}
/**********************/
/* Classe DRAWSEGMENT */
/**********************/
@ -131,7 +149,7 @@ bool DRAWSEGMENT::Save( FILE* aFile ) const
bool rc = false;
if( fprintf( aFile, "$DRAWSEGMENT\n" ) != sizeof("%DRAWSEGMENT\n")-1 )
if( fprintf( aFile, "$DRAWSEGMENT\n" ) != sizeof("$DRAWSEGMENT\n")-1 )
goto out;
fprintf( aFile, "Po %d %d %d %d %d %d\n",

View File

@ -235,9 +235,13 @@ int WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, wxDC * DC, bo
#if 1 && defined(DEBUG)
// note this seems to freeze up pcbnew when run under the kicad project
// manager. runs fine from command prompt.
// output the board object tree to stdout:
// note this freezes up pcbnew when run under the kicad project
// manager. runs fine from command prompt. This is because the kicad
// project manager redirects stdout of the child pcbnew process to itself,
// but never reads from that pipe, and that in turn eventually blocks
// the pcbnew program when the pipe it is writing to gets full.
// Output the board object tree to stdout, but please run from command prompt:
m_Pcb->Show( 0, std::cout );
#endif

View File

@ -177,10 +177,11 @@ void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode )
DrawHightLight( DC, g_HightLigth_NetCode );
EDGE_ZONE* segment = m_Pcb->m_CurrentLimitZone;
for( ; segment != NULL; segment = (EDGE_ZONE*) segment->Pback )
for( ; segment != NULL; segment = (EDGE_ZONE*) segment->Pback )
{
if( segment->m_Flags & IS_MOVED )
continue;
Trace_DrawSegmentPcb( DrawPanel, DC, segment, mode );
}

View File

@ -92,11 +92,11 @@ void Trace_DrawSegmentPcb( WinEDA_DrawPanel* panel, wxDC* DC,
/* coord de depart */
ux0 = PtDrawSegment->m_Start.x;
uy0 = PtDrawSegment->m_Start.y;
/* coord d'arrivee */
dx = PtDrawSegment->m_End.x;
dy = PtDrawSegment->m_End.y;
mode = DisplayOpt.DisplayDrawItems;
if( PtDrawSegment->m_Flags & FORCE_SKETCH )
mode = SKETCH;

View File

@ -412,8 +412,7 @@ void WinEDA_PcbFrame::Edit_Zone_Width( wxDC* DC, SEGZONE* aZone )
Line.ToDouble( &f_new_width );
g_DesignSettings.m_CurrentTrackWidth = From_User_Unit( g_UnitMetric,
f_new_width, GetScreen(
)->GetInternalUnits() );
f_new_width, GetScreen()->GetInternalUnits() );
for( SEGZONE* zone = m_Pcb->m_Zone; zone; zone = zone->Next() )
{
@ -604,16 +603,16 @@ static void Display_Zone_Netname( WinEDA_PcbFrame* frame )
static void Exit_Zones( WinEDA_DrawPanel* Panel, wxDC* DC )
/********************************************************/
/* routine d'annulation de la Commande Begin_Zone si une piste est en cours
* de tracage, ou de sortie de l'application SEGZONES.
* Appel par la touche ESC
/**
* Function Exit_Zones
* cancels the Begin_Zone state if at least one EDGE_ZONE has been created.
*/
{
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) Panel->m_Parent;
if( pcbframe->m_Pcb->m_CurrentLimitZone )
{
if( Panel->ManageCurseur ) /* trace en cours */
if( Panel->ManageCurseur ) // trace in progress
{
Panel->ManageCurseur( Panel, DC, 0 );
}
@ -629,12 +628,9 @@ static void Exit_Zones( WinEDA_DrawPanel* Panel, wxDC* DC )
/**************************************************************/
void WinEDA_BasePcbFrame::DelLimitesZone( wxDC* DC, bool Redraw )
/**************************************************************/
/* Supprime la liste des segments constituant la frontiere courante
* Libere la memoire correspondante
*/
{
EDGE_ZONE* segment, * Next;
EDGE_ZONE* segment;
EDGE_ZONE* next;
if( m_Pcb->m_CurrentLimitZone == NULL )
return;
@ -642,14 +638,17 @@ void WinEDA_BasePcbFrame::DelLimitesZone( wxDC* DC, bool Redraw )
if( !IsOK( this, _( "Delete Current Zone Edges" ) ) )
return;
/* efface ancienne limite de zone */
// erase the old zone border, one segment at a time
segment = m_Pcb->m_CurrentLimitZone;
for( ; segment != NULL; segment = Next )
for( ; segment != NULL; segment = next )
{
Next = (EDGE_ZONE*) segment->Pback;
next = (EDGE_ZONE*) segment->Pback;
if( Redraw )
Trace_DrawSegmentPcb( DrawPanel, DC, segment, GR_XOR );
segment->Pnext = NULL; delete segment;
segment->Pnext = NULL;
delete segment;
}
SetCurItem( NULL );
@ -657,47 +656,53 @@ void WinEDA_BasePcbFrame::DelLimitesZone( wxDC* DC, bool Redraw )
}
/********************************************/
EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone()
/********************************************/
/*
* Routine d'initialisation d'un trace de Limite de Zone ou
* de placement d'un point intermediaire
/**
* Function Begin_Zone
* either initializes the first segment of a new zone, or adds an
* intermediate segment.
*/
EDGE_ZONE* WinEDA_PcbFrame::Begin_Zone()
{
EDGE_ZONE* oldedge, * newedge = NULL;
EDGE_ZONE* oldedge;
EDGE_ZONE* newedge = NULL;
oldedge = m_Pcb->m_CurrentLimitZone;
// if first segment
if( (m_Pcb->m_CurrentLimitZone == NULL ) /* debut reel du trace */
|| (DrawPanel->ManageCurseur == NULL) ) /* reprise d'un trace complementaire */
{
m_Pcb->m_CurrentLimitZone = newedge = new EDGE_ZONE( m_Pcb );
newedge = new EDGE_ZONE( m_Pcb );
newedge->m_Flags = IS_NEW | STARTPOINT | IS_MOVED;
newedge->m_Start = newedge->m_End = GetScreen()->m_Curseur;
newedge->SetLayer( GetScreen()->m_Active_Layer );
// link into list:
newedge->Pback = oldedge;
if( oldedge )
oldedge->Pnext = newedge;
newedge->SetLayer( GetScreen()->m_Active_Layer );
newedge->m_Width = 2; /* Largeur minimum tracable */
newedge->m_Start = newedge->m_End = GetScreen()->m_Curseur;
m_Pcb->m_CurrentLimitZone = newedge;
DrawPanel->ManageCurseur = Show_Zone_Edge_While_MoveMouse;
DrawPanel->ForceCloseManageCurseur = Exit_Zones;
}
// edge in progress:
else /* piste en cours : les coord du point d'arrivee ont ete mises
* a jour par la routine Show_Zone_Edge_While_MoveMouse*/
{
if( oldedge->m_Start != oldedge->m_End )
{
newedge = new EDGE_ZONE( oldedge );
newedge->Pback = oldedge;
oldedge->Pnext = newedge;
newedge->m_Flags = IS_NEW | IS_MOVED;
newedge->m_Start = newedge->m_End = oldedge->m_End;
newedge->SetLayer( GetScreen()->m_Active_Layer );
// link into list:
newedge->Pback = oldedge;
oldedge->Pnext = newedge;
m_Pcb->m_CurrentLimitZone = newedge;
}
}
@ -724,11 +729,13 @@ void WinEDA_PcbFrame::End_Zone( wxDC* DC )
/* il sera raccorde au point de depart */
PtLim = m_Pcb->m_CurrentLimitZone;
PtLim->m_Flags &= ~(IS_NEW | IS_MOVED);
while( PtLim && PtLim->Pback )
{
PtLim = (EDGE_ZONE*) PtLim->Pback;
if( PtLim->m_Flags & STARTPOINT )
break;
PtLim->m_Flags &= ~(IS_NEW | IS_MOVED);
}