MARKER and DRC rework, continued

This commit is contained in:
dickelbeck 2007-11-27 22:49:35 +00:00
parent aef4b6e81c
commit 0415674d82
26 changed files with 391 additions and 218 deletions

View File

@ -4,6 +4,26 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2007-Nov-26 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
+pcbnew
* changed class MARQUEUR to class MARKER name only.
* Moved BOARD's MARKERs from m_Drawings to vector<MARKER*> m_markers so
they can be easily deleted and navigated to from the drc dialog.
* deprecated the MARKER::Unlink() function.
* Added
BOARD::Add( BOARD_ITEM*, int )
BOARD::GetMARKER(int)
BOARD::Delete( BOARD_ITEM* )
BOARD::DeleteMARKERs();
* Changed BOARD::~BOARD() to use DeleteMARKERs().
* Revised screen drawing routine to know about BOARD::m_markers.
* Revised BOARD::Visit() to know about BOARD::m_markers.
* Revised pcbnew/find.cpp to know about BOARD::m_markers.
* removed wxYield() from drc.cpp
2007-Nov-26 UPDATE Dick Hollenbeck <dick@softplc.com> 2007-Nov-26 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
+pcbnew +pcbnew

View File

@ -254,7 +254,7 @@ bool LocateAndDeleteItem(WinEDA_SchematicFrame * frame, wxDC * DC)
/*****************************************************************/ /*****************************************************************/
/* Locate and delete the item found under the mouse cousor /* Locate and delete the item found under the mouse cousor
If more than one item found: the priority order is: If more than one item found: the priority order is:
1 : MARQUEUR 1 : MARKER
2 : JUNCTION 2 : JUNCTION
2 : NOCONNECT 2 : NOCONNECT
3 : WIRE ou BUS 3 : WIRE ou BUS

View File

@ -35,7 +35,7 @@ enum KICAD_T {
TYPETRACK, TYPETRACK,
TYPEZONE, TYPEZONE,
TYPEVIA, TYPEVIA,
TYPEMARQUEUR, TYPEMARKER,
TYPECOTATION, TYPECOTATION,
TYPEMIRE, TYPEMIRE,
TYPESCREEN, TYPESCREEN,
@ -178,7 +178,7 @@ private:
public: public:
EDA_BaseStruct( EDA_BaseStruct* parent, KICAD_T idType ); EDA_BaseStruct( EDA_BaseStruct* parent, KICAD_T idType );
EDA_BaseStruct( KICAD_T struct_type ); EDA_BaseStruct( KICAD_T idType );
virtual ~EDA_BaseStruct() { }; virtual ~EDA_BaseStruct() { };
/** /**
@ -219,10 +219,6 @@ public:
m_Status = new_status; m_Status = new_status;
} }
/* addition d'une nouvelle struct a la liste chain<69> */
void AddToChain( EDA_BaseStruct* laststruct );
/* fonction de placement */ /* fonction de placement */
virtual void Place( WinEDA_DrawFrame* frame, wxDC* DC ); virtual void Place( WinEDA_DrawFrame* frame, wxDC* DC );
@ -316,6 +312,16 @@ public:
void DeleteStructList(); void DeleteStructList();
/**
* Function AddToChain
* adds this item just after laststruct in a linked list established
* by the Prev and Back pointers of my base EDA_BaseStruct.
* @deprecated
* @param laststruct The item to add after
*/
void AddToChain( EDA_BaseStruct* laststruct );
#if defined (DEBUG) #if defined (DEBUG)
/** /**
@ -450,6 +456,7 @@ public:
BOARD_ITEM* Back() const { return (BOARD_ITEM*) Pback; } BOARD_ITEM* Back() const { return (BOARD_ITEM*) Pback; }
BOARD_ITEM* GetParent() const { return (BOARD_ITEM*) m_Parent; } BOARD_ITEM* GetParent() const { return (BOARD_ITEM*) m_Parent; }
/** /**
* Function GetLayer * Function GetLayer
* returns the layer this item is on. * returns the layer this item is on.

View File

@ -133,7 +133,7 @@ enum Track_Shapes {
/* Forward declaration */ /* Forward declaration */
class MODULE; class MODULE;
class EQUIPOT; class EQUIPOT;
class MARQUEUR; class MARKER;
class TRACK; class TRACK;
class D_PAD; class D_PAD;
struct CHEVELU; struct CHEVELU;
@ -198,6 +198,10 @@ enum DisplayViaMode {
class BOARD : public BOARD_ITEM class BOARD : public BOARD_ITEM
{ {
friend class WinEDA_PcbFrame;
private:
std::vector<MARKER*> m_markers; ///< MARKERs which we own by pointer
public: public:
WinEDA_BasePcbFrame* m_PcbFrame; // Window de visualisation WinEDA_BasePcbFrame* m_PcbFrame; // Window de visualisation
EDA_Rect m_BoundaryBox; // Limites d'encadrement du PCB EDA_Rect m_BoundaryBox; // Limites d'encadrement du PCB
@ -232,6 +236,41 @@ public:
/* supprime du chainage la structure Struct */ /* supprime du chainage la structure Struct */
void UnLink(); void UnLink();
/**
* Function Add
* adds the given item to this BOARD and takes ownership of its memory.
* @param aBoardItem The item to add to this board.
* @param aControl An int which can vary how the item is added.
*/
void Add( BOARD_ITEM* aBoardItem, int aControl = 0 );
/**
* Function Delete
* deletes the given single item from this BOARD and deletes its memory. If you
* need the object after deletion, first copy it.
* @param aBoardItem The item to remove from this board and delete
*/
void Delete( BOARD_ITEM* aBoardItem );
/**
* Function DeleteMARKERs
* deletes ALL MARKERS from the board.
*/
void DeleteMARKERs();
/**
* Function GetMARKER
* returns the MARKER at a given index.
* @param index The array type index into a collection of MARKERS.
* @return MARKER* - a pointer to the MARKER or NULL if index out of range.
*/
MARKER* GetMARKER( int index ) const
{
if( (unsigned) index < m_markers.size() )
return m_markers[index];
return NULL;
}
/* Routines de calcul des nombres de segments pistes et zones */ /* Routines de calcul des nombres de segments pistes et zones */
int GetNumSegmTrack(); int GetNumSegmTrack();
int GetNumSegmZone(); int GetNumSegmZone();

View File

@ -74,6 +74,8 @@ BOARD::~BOARD()
MyFree( m_LocalRatsnest ); MyFree( m_LocalRatsnest );
m_LocalRatsnest = 0; m_LocalRatsnest = 0;
DeleteMARKERs();
} }
@ -100,13 +102,65 @@ void BOARD::UnLink()
} }
void BOARD::Add( BOARD_ITEM* aBoardItem, int aControl )
{
switch( aBoardItem->Type() )
{
// this one uses a vector
case TYPEMARKER:
m_markers.push_back( (MARKER*) aBoardItem );
break;
// other types may use linked list
default:
wxFAIL_MSG( wxT("BOARD::Add() needs work") );
}
}
void BOARD::Delete( BOARD_ITEM* aBoardItem )
{
switch( aBoardItem->Type() )
{
// this one uses a vector
case TYPEMARKER:
// find the item in the vector, then delete then erase it.
for( unsigned i=0; i<m_markers.size(); ++i )
{
if( m_markers[i] == (MARKER*) aBoardItem )
{
delete m_markers[i];
m_markers.erase( m_markers.begin() + i );
break;
}
}
break;
// other types may use linked list
default:
wxFAIL_MSG( wxT("BOARD::Delete() needs work") );
}
}
void BOARD::DeleteMARKERs()
{
// the vector does not know how to delete the MARKER, it holds pointers
for( unsigned i=0; i<m_markers.size(); ++i )
delete m_markers[i];
m_markers.clear();
}
/* Routines de calcul des nombres de segments pistes et zones */ /* Routines de calcul des nombres de segments pistes et zones */
int BOARD::GetNumSegmTrack() int BOARD::GetNumSegmTrack()
{ {
TRACK* CurTrack = m_Track; TRACK* CurTrack = m_Track;
int ii = 0; int ii = 0;
for( ; CurTrack != NULL; CurTrack = (TRACK*) CurTrack->Pnext ) for( ; CurTrack != NULL; CurTrack = CurTrack->Next() )
ii++; ii++;
m_NbSegmTrack = ii; m_NbSegmTrack = ii;
@ -119,7 +173,7 @@ int BOARD::GetNumSegmZone()
TRACK* CurTrack = m_Zone; TRACK* CurTrack = m_Zone;
int ii = 0; int ii = 0;
for( ; CurTrack != NULL; CurTrack = (TRACK*) CurTrack->Pnext ) for( ; CurTrack != NULL; CurTrack = CurTrack->Next() )
ii++; ii++;
m_NbSegmZone = ii; m_NbSegmZone = ii;
@ -385,7 +439,6 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
case TYPEDRAWSEGMENT: case TYPEDRAWSEGMENT:
case TYPETEXTE: case TYPETEXTE:
case TYPEMARQUEUR:
case TYPECOTATION: case TYPECOTATION:
case TYPEMIRE: case TYPEMIRE:
result = IterateForward( m_Drawings, inspector, testData, p ); result = IterateForward( m_Drawings, inspector, testData, p );
@ -396,7 +449,6 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
{ {
case TYPEDRAWSEGMENT: case TYPEDRAWSEGMENT:
case TYPETEXTE: case TYPETEXTE:
case TYPEMARQUEUR:
case TYPECOTATION: case TYPECOTATION:
case TYPEMIRE: case TYPEMIRE:
continue; continue;
@ -448,6 +500,17 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
break; break;
#endif #endif
case TYPEMARKER:
// MARKERS are in the m_markers std::vector
for( unsigned i=0; i<m_markers.size(); ++i )
{
result = m_markers[i]->Visit( inspector, testData, p );
if( result == SEARCH_QUIT )
break;
}
++p;
break;
case PCB_EQUIPOT_STRUCT_TYPE: case PCB_EQUIPOT_STRUCT_TYPE:
result = IterateForward( m_Equipots, inspector, testData, p ); result = IterateForward( m_Equipots, inspector, testData, p );
++p; ++p;
@ -604,9 +667,6 @@ bool BOARD::Save( FILE* aFile ) const
goto out; goto out;
break; break;
case TYPEMARQUEUR: // do not save MARKERs, they can be regenerated easily
break;
default: default:
// future: throw exception here // future: throw exception here
#if defined(DEBUG) #if defined(DEBUG)
@ -616,6 +676,8 @@ bool BOARD::Save( FILE* aFile ) const
} }
} }
// do not save MARKERs, they can be regenerated easily
// save the tracks & vias // save the tracks & vias
fprintf( aFile, "$TRACK\n" ); fprintf( aFile, "$TRACK\n" );
for( item = m_Track; item; item=item->Next() ) for( item = m_Track; item; item=item->Next() )

View File

@ -194,8 +194,8 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
} }
break; break;
case TYPEMARQUEUR: case TYPEMARKER:
text << _( "Marker" ) << wxT( " @(" ) << ((MARQUEUR*)item)->m_Pos.x << wxT(",") << ((MARQUEUR*)item)->m_Pos.y << wxT(")"); text << _( "Marker" ) << wxT( " @(" ) << ((MARKER*)item)->m_Pos.x << wxT(",") << ((MARKER*)item)->m_Pos.y << wxT(")");
break; break;
case TYPECOTATION: case TYPECOTATION:
@ -275,7 +275,7 @@ const char** BOARD_ITEM::MenuIcon() const
xpm = pad_sketch_xpm; xpm = pad_sketch_xpm;
break; break;
case TYPEMARQUEUR: case TYPEMARKER:
xpm = pad_xpm; // @todo: create and use marker xpm xpm = pad_xpm; // @todo: create and use marker xpm
break; break;

View File

@ -35,11 +35,11 @@ static char Default_MarkerBitmap[] =
/*******************/ /*******************/
/* Classe MARQUEUR */ /* Classe MARKER */
/*******************/ /*******************/
MARQUEUR::MARQUEUR( BOARD_ITEM* StructFather ) : MARKER::MARKER( BOARD_ITEM* StructFather ) :
BOARD_ITEM( StructFather, TYPEMARQUEUR ) BOARD_ITEM( StructFather, TYPEMARKER )
{ {
m_Bitmap = NULL; m_Bitmap = NULL;
m_Type = 0; m_Type = 0;
@ -51,38 +51,24 @@ MARQUEUR::MARQUEUR( BOARD_ITEM* StructFather ) :
/* Effacement memoire de la structure */ /* Effacement memoire de la structure */
MARQUEUR:: ~MARQUEUR() MARKER::~MARKER()
{ {
#if defined(DEBUG)
printf("MARKER %p deleted\n", this );
#endif
} }
/* supprime du chainage la structure Struct /* supprime du chainage la structure Struct
* les structures arrieres et avant sont chainees directement * les structures arrieres et avant sont chainees directement
*/ */
void MARQUEUR::UnLink() void MARKER::UnLink()
{ {
/* Modification du chainage arriere */ wxFAIL_MSG( wxT("MARKER::UnLink is deprecated") );
if( Pback )
{
if( Pback->Type() != TYPEPCB )
{
Pback->Pnext = Pnext;
}
else /* Le chainage arriere pointe sur la structure "Pere" */
{
( (BOARD*) Pback )->m_Drawings = (BOARD_ITEM*) Pnext;
}
}
/* Modification du chainage avant */
if( Pnext )
Pnext->Pback = Pback;
Pnext = Pback = NULL;
} }
void MARQUEUR::Display_Infos( WinEDA_DrawFrame* frame ) void MARKER::Display_Infos( WinEDA_DrawFrame* frame )
{ {
int text_pos; int text_pos;
@ -97,7 +83,7 @@ void MARQUEUR::Display_Infos( WinEDA_DrawFrame* frame )
/**********************************************/ /**********************************************/
bool MARQUEUR::HitTest( const wxPoint& refPos ) bool MARKER::HitTest( const wxPoint& refPos )
/**********************************************/ /**********************************************/
{ {
// the MARKER is 12 pixels by 12 pixels, but is not resized with zoom, so // the MARKER is 12 pixels by 12 pixels, but is not resized with zoom, so
@ -125,7 +111,7 @@ bool MARQUEUR::HitTest( const wxPoint& refPos )
/**********************************************************************/ /**********************************************************************/
void MARQUEUR::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode ) void MARKER::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode )
/**********************************************************************/ /**********************************************************************/
/* /*

View File

@ -8,22 +8,40 @@
#include "base_struct.h" #include "base_struct.h"
class MARQUEUR : public BOARD_ITEM class MARKER : public BOARD_ITEM
{ {
private:
wxString m_Diag; /* Associated text (comment) */
public: public:
wxPoint m_Pos; wxPoint m_Pos;
char* m_Bitmap; /* Shape (bitmap) */ char* m_Bitmap; /* Shape (bitmap) */
int m_Type; int m_Type;
int m_Color; /* color */ int m_Color; /* color */
wxString m_Diag; /* Associated text (comment) */
wxSize m_Size; /* Size of the graphic symbol */ wxSize m_Size; /* Size of the graphic symbol */
public: public:
MARQUEUR( BOARD_ITEM* StructFather ); MARKER( BOARD_ITEM* StructFather );
~MARQUEUR(); ~MARKER();
void UnLink(); void UnLink();
void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode ); void Draw( WinEDA_DrawPanel* panel, wxDC* DC, int DrawMode );
/**
* Function GetMessage
* @return const wxString& - the diagnostic message
*/
const wxString& GetMessage()
{
return m_Diag;
}
void SetMessage( const wxString& aMsg )
{
m_Diag = aMsg;
}
/** /**
* Function Display_Infos * Function Display_Infos
* has knowledge about the frame and how and where to put status information * has knowledge about the frame and how and where to put status information

View File

@ -38,7 +38,7 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
// all items in m_Drawings for instance should be contiguous. // all items in m_Drawings for instance should be contiguous.
TYPETEXTE, TYPETEXTE,
TYPEDRAWSEGMENT, TYPEDRAWSEGMENT,
TYPEMARQUEUR, TYPEMARKER,
TYPECOTATION, TYPECOTATION,
TYPEMIRE, TYPEMIRE,
TYPEVIA, TYPEVIA,
@ -55,7 +55,7 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
const KICAD_T GENERAL_COLLECTOR::PrimaryItems[] = { const KICAD_T GENERAL_COLLECTOR::PrimaryItems[] = {
TYPETEXTE, TYPETEXTE,
TYPEDRAWSEGMENT, TYPEDRAWSEGMENT,
TYPEMARQUEUR, TYPEMARKER,
TYPECOTATION, TYPECOTATION,
TYPEVIA, TYPEVIA,
TYPETRACK, TYPETRACK,
@ -68,7 +68,7 @@ const KICAD_T GENERAL_COLLECTOR::PrimaryItems[] = {
const KICAD_T GENERAL_COLLECTOR::AllButZones[] = { const KICAD_T GENERAL_COLLECTOR::AllButZones[] = {
TYPETEXTE, TYPETEXTE,
TYPEDRAWSEGMENT, TYPEDRAWSEGMENT,
TYPEMARQUEUR, TYPEMARKER,
TYPECOTATION, TYPECOTATION,
TYPEMIRE, TYPEMIRE,
TYPEVIA, TYPEVIA,

View File

@ -39,19 +39,14 @@
////@end XPM images ////@end XPM images
DRC_LIST gList; // gets moved into DRC_TESTER later.
/** /**
* Class DRCLISTBOX * Class DRCLISTBOX
* is used to display a DRC_LIST, which contains DRC_ITEMs. * is used to display a DRC_LIST, which contains DRC_ITEM_OWNERs.
*/ */
class DRCLISTBOX : public wxHtmlListBox class DRCLISTBOX : public wxHtmlListBox
{ {
private: private:
DRC_LIST* m_List; ///< wxWidgets does not own the list items, we do DRC_LIST* m_List; ///< wxHtmlListBox does not own the list items, we do
public: public:
DRCLISTBOX( wxWindow* parent, wxWindowID id = wxID_ANY, DRCLISTBOX( wxWindow* parent, wxWindowID id = wxID_ANY,
@ -86,7 +81,7 @@ public:
wxString OnGetItem( size_t n ) const wxString OnGetItem( size_t n ) const
{ {
if( m_List ) if( m_List )
return (*m_List)[n].ShowHtml(); return (*m_List)[n]->ShowHtml();
else else
return wxString(); return wxString();
} }
@ -101,7 +96,7 @@ public:
wxString OnGetItemMarkup( size_t n ) const wxString OnGetItemMarkup( size_t n ) const
{ {
if( m_List ) if( m_List )
return (*m_List)[n].ShowHtml(); return (*m_List)[n]->ShowHtml();
else else
return wxString(); return wxString();
} }
@ -173,13 +168,15 @@ WinEDA_DrcFrame::WinEDA_DrcFrame( )
{ {
} }
WinEDA_DrcFrame::WinEDA_DrcFrame( WinEDA_PcbFrame* parent, wxDC * panelDC, WinEDA_DrcFrame::WinEDA_DrcFrame( DRC_TESTER* aDrc_tester, WinEDA_PcbFrame* parent, wxDC * panelDC,
wxWindowID id, wxWindowID id,
const wxString& caption, const wxString& caption,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long style ) long style )
{ {
m_Tester = aDrc_tester;
m_Parent = parent; m_Parent = parent;
m_DC = panelDC; m_DC = panelDC;
AbortDrc = FALSE; AbortDrc = FALSE;
@ -227,16 +224,8 @@ bool WinEDA_DrcFrame::Create( wxWindow* parent, wxWindowID id, const wxString& c
////@end WinEDA_DrcFrame creation ////@end WinEDA_DrcFrame creation
DRC_ITEM a( 2, wxString( wxT("A item") ), wxString( wxT("B item") ), // m_ClearanceListBox->SetList( &gList );
wxPoint(12000,3000), wxPoint(13000,3000)); // m_UnconnectedListBox->SetList( &gList );
gList.push_back( a );
gList.push_back( a );
gList.push_back( a );
gList.push_back( a );
m_ClearanceListBox->SetList( &gList );
m_UnconnectedListBox->SetList( &gList );
return true; return true;
} }
@ -250,7 +239,7 @@ void WinEDA_DrcFrame::CreateControls()
SetFont( *g_DialogFont ); SetFont( *g_DialogFont );
////@begin WinEDA_DrcFrame content construction ////@begin WinEDA_DrcFrame content construction
// Generated by DialogBlocks, Mon 26 Nov 2007 19:22:56 CST (unregistered) // Generated by DialogBlocks, Tue 27 Nov 2007 00:10:16 CST (unregistered)
WinEDA_DrcFrame* itemDialog1 = this; WinEDA_DrcFrame* itemDialog1 = this;

View File

@ -88,7 +88,7 @@ class WinEDA_DrcFrame: public wxDialog
public: public:
/// Constructors /// Constructors
WinEDA_DrcFrame( ); WinEDA_DrcFrame( );
WinEDA_DrcFrame( WinEDA_PcbFrame* parent, wxDC * panelDC, WinEDA_DrcFrame( DRC_TESTER* aDrc_tester, WinEDA_PcbFrame* parent, wxDC * panelDC,
wxWindowID id = SYMBOL_WINEDA_DRCFRAME_IDNAME, wxWindowID id = SYMBOL_WINEDA_DRCFRAME_IDNAME,
const wxString& caption = SYMBOL_WINEDA_DRCFRAME_TITLE, const wxString& caption = SYMBOL_WINEDA_DRCFRAME_TITLE,
const wxPoint& pos = SYMBOL_WINEDA_DRCFRAME_POSITION, const wxPoint& pos = SYMBOL_WINEDA_DRCFRAME_POSITION,
@ -177,6 +177,8 @@ public:
wxStdDialogButtonSizer* StdDialogButtonSizer; wxStdDialogButtonSizer* StdDialogButtonSizer;
////@end WinEDA_DrcFrame member variables ////@end WinEDA_DrcFrame member variables
DRC_TESTER* m_Tester;
WinEDA_PcbFrame* m_Parent; WinEDA_PcbFrame* m_Parent;
wxDC* m_DC; wxDC* m_DC;
int m_UnconnectedCount; int m_UnconnectedCount;

View File

@ -21,6 +21,10 @@ class WinEDA_DrcFrame;
WinEDA_DrcFrame* DrcFrame; WinEDA_DrcFrame* DrcFrame;
//#define WXYIELD() wxYield()
#define WXYIELD() do { } while(0) // nothing
/* saving drc options */ /* saving drc options */
static bool s_Pad2PadTestOpt = true; static bool s_Pad2PadTestOpt = true;
static bool s_UnconnectedTestOpt = true; static bool s_UnconnectedTestOpt = true;
@ -30,7 +34,7 @@ static FILE* s_RptFile = NULL;
static wxString s_RptFilename; static wxString s_RptFilename;
static int ErrorsDRC_Count; static int ErrorsDRC_Count;
static MARQUEUR* current_marqueur; /* Pour gestion des marqueurs sur pcb */ static MARKER* current_marqueur; /* Pour gestion des marqueurs sur pcb */
static bool AbortDrc, DrcInProgress = FALSE; static bool AbortDrc, DrcInProgress = FALSE;
static int spot_cX, spot_cY; /* position d'elements a tester */ static int spot_cX, spot_cY; /* position d'elements a tester */
@ -261,7 +265,7 @@ void WinEDA_PcbFrame::Install_Test_DRC_Frame( wxDC* DC )
*/ */
{ {
AbortDrc = FALSE; AbortDrc = FALSE;
DrcFrame = new WinEDA_DrcFrame( this, DC ); DrcFrame = new WinEDA_DrcFrame( NULL, this, DC ); // @todo
DrcFrame->ShowModal(); DrcFrame->ShowModal();
DrcFrame->Destroy(); DrcFrame->Destroy();
DrcFrame = NULL; DrcFrame = NULL;
@ -281,8 +285,7 @@ int WinEDA_PcbFrame::Test_DRC( wxDC* DC, bool TestPad2Pad, bool TestZone )
int flag_err_Drc; int flag_err_Drc;
TRACK* pt_segm; TRACK* pt_segm;
D_PAD* pad; D_PAD* pad;
MARQUEUR* Marqueur; MARKER* Marqueur;
EDA_BaseStruct* PtStruct;
wxString Line; wxString Line;
#define PRINT_NB_PAD_POS 42 #define PRINT_NB_PAD_POS 42
@ -344,13 +347,8 @@ int WinEDA_PcbFrame::Test_DRC( wxDC* DC, bool TestPad2Pad, bool TestZone )
} }
Line.Printf( wxT( "%d" ), ErrorsDRC_Count ); Line.Printf( wxT( "%d" ), ErrorsDRC_Count );
Affiche_1_Parametre( this, PRINT_PAD_ERR_POS, wxEmptyString, Line, LIGHTRED ); Affiche_1_Parametre( this, PRINT_PAD_ERR_POS, wxEmptyString, Line, LIGHTRED );
Marqueur->Pnext = m_Pcb->m_Drawings;
Marqueur->Pback = m_Pcb;
PtStruct = m_Pcb->m_Drawings; m_Pcb->Add( Marqueur );
if( PtStruct )
PtStruct->Pback = Marqueur;
m_Pcb->m_Drawings = Marqueur;
} }
} }
@ -375,7 +373,7 @@ int WinEDA_PcbFrame::Test_DRC( wxDC* DC, bool TestPad2Pad, bool TestZone )
if( jj == 0 ) if( jj == 0 )
{ {
jj = 10; jj = 10;
wxYield(); WXYIELD();
if( AbortDrc ) if( AbortDrc )
{ {
AbortDrc = FALSE; break; AbortDrc = FALSE; break;
@ -409,13 +407,8 @@ int WinEDA_PcbFrame::Test_DRC( wxDC* DC, bool TestPad2Pad, bool TestZone )
DisplayError( this, wxT( "Test_Drc(): internal err" ) ); DisplayError( this, wxT( "Test_Drc(): internal err" ) );
return ErrorsDRC_Count; return ErrorsDRC_Count;
} }
Marqueur->Pnext = m_Pcb->m_Drawings;
Marqueur->Pback = m_Pcb;
PtStruct = m_Pcb->m_Drawings; m_Pcb->Add( Marqueur );
if( PtStruct )
PtStruct->Pback = Marqueur;
m_Pcb->m_Drawings = Marqueur;
GRSetDrawMode( DC, GR_OR ); GRSetDrawMode( DC, GR_OR );
pt_segm->Draw( DrawPanel, DC, RED ^ LIGHTRED ); pt_segm->Draw( DrawPanel, DC, RED ^ LIGHTRED );
@ -449,7 +442,7 @@ int WinEDA_PcbFrame::Test_DRC( wxDC* DC, bool TestPad2Pad, bool TestZone )
if( jj == 0 ) if( jj == 0 )
{ {
jj = 100; jj = 100;
wxYield(); WXYIELD();
if( AbortDrc ) if( AbortDrc )
{ {
AbortDrc = FALSE; AbortDrc = FALSE;
@ -487,13 +480,8 @@ int WinEDA_PcbFrame::Test_DRC( wxDC* DC, bool TestPad2Pad, bool TestZone )
DisplayError( this, wxT( "Test_Drc(): internal err" ) ); DisplayError( this, wxT( "Test_Drc(): internal err" ) );
return ErrorsDRC_Count; return ErrorsDRC_Count;
} }
Marqueur->Pnext = m_Pcb->m_Drawings;
Marqueur->Pback = m_Pcb;
PtStruct = m_Pcb->m_Drawings; m_Pcb->Add( Marqueur );
if( PtStruct )
PtStruct->Pback = Marqueur;
m_Pcb->m_Drawings = Marqueur;
GRSetDrawMode( DC, GR_OR ); GRSetDrawMode( DC, GR_OR );
pt_segm->Draw( DrawPanel, DC, RED ^ LIGHTRED ); pt_segm->Draw( DrawPanel, DC, RED ^ LIGHTRED );
@ -517,14 +505,8 @@ int WinEDA_PcbFrame::Test_DRC( wxDC* DC, bool TestPad2Pad, bool TestZone )
DisplayError( this, wxT( "Test_Drc(): internal err" ) ); DisplayError( this, wxT( "Test_Drc(): internal err" ) );
return ErrorsDRC_Count; return ErrorsDRC_Count;
} }
Marqueur->Pnext = m_Pcb->m_Drawings;
Marqueur->Pback = m_Pcb;
PtStruct = m_Pcb->m_Drawings; m_Pcb->Add( Marqueur );
if( PtStruct )
PtStruct->Pback = Marqueur;
m_Pcb->m_Drawings = Marqueur;
GRSetDrawMode( DC, GR_OR ); GRSetDrawMode( DC, GR_OR );
pt_segm->Draw( DrawPanel, DC, RED ^ LIGHTRED ); pt_segm->Draw( DrawPanel, DC, RED ^ LIGHTRED );
@ -1469,11 +1451,11 @@ static void Affiche_Erreur_DRC( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb,
fprintf( s_RptFile, "%s", CONV_TO_UTF8( msg ) ); fprintf( s_RptFile, "%s", CONV_TO_UTF8( msg ) );
if( current_marqueur == NULL ) if( current_marqueur == NULL )
current_marqueur = new MARQUEUR( Pcb ); current_marqueur = new MARKER( Pcb );
current_marqueur->m_Pos = wxPoint( erc_pos.x, erc_pos.y ); current_marqueur->m_Pos = wxPoint( erc_pos.x, erc_pos.y );
current_marqueur->m_Color = WHITE; current_marqueur->m_Color = WHITE;
current_marqueur->m_Diag = msg; current_marqueur->SetMessage( msg );
current_marqueur->Draw( panel, DC, GR_OR ); current_marqueur->Draw( panel, DC, GR_OR );
} }
@ -1527,11 +1509,11 @@ static void Affiche_Erreur_DRC( WinEDA_DrawPanel* panel, wxDC* DC, BOARD* Pcb,
fprintf( s_RptFile, "%s", CONV_TO_UTF8( msg ) ); fprintf( s_RptFile, "%s", CONV_TO_UTF8( msg ) );
if( current_marqueur == NULL ) if( current_marqueur == NULL )
current_marqueur = new MARQUEUR( Pcb ); current_marqueur = new MARKER( Pcb );
current_marqueur->m_Pos = pad1->m_Pos; current_marqueur->m_Pos = pad1->m_Pos;
current_marqueur->m_Color = WHITE; current_marqueur->m_Color = WHITE;
current_marqueur->m_Diag = msg; current_marqueur->SetMessage( msg );
current_marqueur->Draw( panel, DC, GR_OR ); current_marqueur->Draw( panel, DC, GR_OR );
} }

View File

@ -34,20 +34,58 @@
/**
* Class REPORT_ISSUE
* is an abstract interface used by DRCLISTBOX. It has functions to return
* either html text or disk file report text on this item. It also can
* return the drawing coordinate of the report item.
*/
class REPORT_ISSUE
{
public:
/**
* Function ShowHtml
* translates this object into a fragment of HTML suitable for the
* wxWidget's wxHtmlListBox class.
* @return wxString - the html text.
*/
virtual wxString ShowHtml() const = 0;
/**
* Function ShowText
* translates this object into a text string suitable for saving
* to disk in a report.
* @return wxString - the simple non-html text.
*/
virtual wxString ShowText() const = 0;
/**
* Function GetPosition
* @return const wxPoint& - the position of this report item within
* the drawing.
*/
virtual const wxPoint& GetPosition() const = 0;
};
/** /**
* Class DRC_ITEM * Class DRC_ITEM
* is a holder for a DRC error item. It is generated when two objects are * is a holder for a DRC error item. It is generated when two objects are
* too close. There are holders for information on two items. The * too close. There are holders for information on two items. The
* information held is the board coordinate and the MenuText for each item. * information held is the board coordinate and the MenuText for each item.
* Also held is the type of error by number and the location of the MARQUEUR. * Also held is the type of error by number and the location of the MARKER.
* A function is provided to translate that number into text. * A function is provided to translate that number into text.
*/ */
class DRC_ITEM class DRC_ITEM : public REPORT_ISSUE
{ {
protected: protected:
int m_ErrorCode; ///< the error code's numeric value int m_ErrorCode; ///< the error code's numeric value
wxPoint m_MarkerPos; ///< position of the MARKER wxPoint m_Pos; ///< position of the issue
wxString m_AText; ///< text for the first BOARD_ITEM wxString m_AText; ///< text for the first BOARD_ITEM
wxString m_BText; ///< text for the second BOARD_ITEM wxString m_BText; ///< text for the second BOARD_ITEM
wxPoint m_APos; ///< the location of the first BOARD_ITEM wxPoint m_APos; ///< the location of the first BOARD_ITEM
@ -56,16 +94,19 @@ protected:
public: public:
DRC_ITEM( int aErrorCode, const wxString& aText, const wxString& bText, DRC_ITEM( int aErrorCode, const wxPoint& aIssuePos,
const wxString& aText, const wxString& bText,
const wxPoint& aPos, const wxPoint& bPos ) const wxPoint& aPos, const wxPoint& bPos )
{ {
m_ErrorCode = aErrorCode; m_ErrorCode = aErrorCode;
m_Pos = aIssuePos;
m_AText = aText; m_AText = aText;
m_BText = bText; m_BText = bText;
m_APos = aPos; m_APos = aPos;
m_BPos = bPos; m_BPos = bPos;
} }
//-----<Interface REPORT_ISSUE>---------------------------------------
/** /**
* Function ShowHtml * Function ShowHtml
@ -85,7 +126,6 @@ public:
return ret; return ret;
} }
/** /**
* Function ShowText * Function ShowText
* translates this object into a text string suitable for saving * translates this object into a text string suitable for saving
@ -104,6 +144,18 @@ public:
return ret; return ret;
} }
/**
* Function GetPosition
* @return const wxPoint& - the position of this report item within
* the drawing.
*/
const wxPoint& GetPosition() const
{
return m_Pos;
}
//-----</Interface REPORT_ISSUE>---------------------------------------
/** /**
* Function GetErrorText * Function GetErrorText
@ -119,15 +171,17 @@ public:
* @return wxString - The formated string * @return wxString - The formated string
*/ */
static wxString ShowCoord( const wxPoint& aPos ); static wxString ShowCoord( const wxPoint& aPos );
}; };
class WinEDA_DrawPanel; class WinEDA_DrawPanel;
class MARQUEUR; class MARKER;
typedef std::vector<DRC_ITEM> DRC_LIST; /// A smart pointer to a DRC_ITEM
//typedef OWNER<DRC_ITEM> DRC_ITEM_OWNER;
/// A list of DRC_ITEM_PTRs
typedef std::vector<DRC_ITEM*> DRC_LIST;
/** /**
@ -139,45 +193,83 @@ typedef std::vector<DRC_ITEM> DRC_LIST;
class DRC_TESTER class DRC_TESTER
{ {
protected: protected:
bool doPad2PadTest; bool m_doPad2PadTest;
bool doUnconnectedTest; bool m_doUnconnectedTest;
bool doZonesTest; bool m_doZonesTest;
bool doCreateRptFile; bool m_doCreateRptFile;
FILE* rptFile; FILE* m_rptFile;
wxString rptFilename; wxString m_rptFilename;
int errorCount; int m_errorCount;
MARQUEUR* currentMarker; MARKER* m_currentMarker;
bool abortDrc; bool m_aboartDRC;
bool drcInProgress; bool m_drcInProgress;
int spot_cX; int m_spotcx;
int spot_cY; int m_spotcy;
int finx; int m_finx;
int finy; // coord relatives de l'extremite du segm de reference int m_finy; // coord relatives de l'extremite du segm de reference
int segmAngle; // angle d'inclinaison du segment de reference en 0,1 degre int m_segmAngle; // angle d'inclinaison du segment de reference en 0,1 degre
int segmLong; // longueur du segment de reference int m_segmLong; // longueur du segment de reference
int xcliplo; int m_xcliplo;
int ycliplo; int m_ycliplo;
int xcliphi; int m_xcliphi;
int ycliphi; // coord de la surface de securite du segment a comparer int m_ycliphi; // coord de la surface de securite du segment a comparer
DRC_LIST drcList; int m_unconnectedCount;
WinEDA_DrawPanel* drawPanel; DRC_LIST* m_drcList;
WinEDA_DrawPanel* m_drawPanel;
public: public:
DRC_TESTER() DRC_TESTER()
{ {
doPad2PadTest = true; m_doPad2PadTest = true;
doUnconnectedTest = true; m_doUnconnectedTest = true;
doZonesTest = false; m_doZonesTest = false;
doCreateRptFile = false; m_doCreateRptFile = false;
m_rptFile = 0;
m_errorCount = 0;
m_currentMarker = 0;
m_aboartDRC = false;
m_drcInProgress = false;
m_spotcx = 0;
m_spotcy = 0;
m_finx = 0;
m_finy = 0; // coord relatives de l'extremite du segm de reference
m_segmAngle = 0; // angle d'inclinaison du segment de reference en 0,1 degre
m_segmLong = 0; // longueur du segment de reference
m_xcliplo = 0;
m_ycliplo = 0;
m_xcliphi = 0;
m_ycliphi = 0; // coord de la surface de securite du segment a comparer
m_unconnectedCount = 0;
m_drcList = new DRC_LIST();
m_drawPanel = 0;
for( int i=0; i<12; ++i )
{
DRC_ITEM* ditem = new DRC_ITEM( 2, wxPoint(12000,3000),
wxString( wxT("A item") ), wxString( wxT("B item") ),
wxPoint(12000,3000), wxPoint(13000,3000));
m_drcList->push_back( ditem );
}
} }
@ -192,19 +284,16 @@ public:
*/ */
void SetTests( bool aPad2PadTest, bool aUnconnectedTest, bool aZonesTest, const wxString& aRptFilename ) void SetTests( bool aPad2PadTest, bool aUnconnectedTest, bool aZonesTest, const wxString& aRptFilename )
{ {
doPad2PadTest = aPad2PadTest; m_doPad2PadTest = aPad2PadTest;
doUnconnectedTest = aUnconnectedTest; m_doUnconnectedTest = aUnconnectedTest;
doZonesTest = aZonesTest; m_doZonesTest = aZonesTest;
rptFilename = aRptFilename; m_rptFilename = aRptFilename;
if( rptFilename.IsEmpty() ) if( m_rptFilename.IsEmpty() )
doCreateRptFile = false; m_doCreateRptFile = false;
else else
doCreateRptFile = true; m_doCreateRptFile = true;
} }
}; };

View File

@ -962,15 +962,13 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
Delete_Zone( DC, (SEGZONE*) Item ); Delete_Zone( DC, (SEGZONE*) Item );
break; break;
case TYPEMARQUEUR: case TYPEMARKER:
if( Item == GetCurItem() ) if( Item == GetCurItem() )
SetCurItem( NULL ); SetCurItem( NULL );
( (MARQUEUR*) Item )->Draw( DrawPanel, DC, GR_XOR ); ( (MARKER*) Item )->Draw( DrawPanel, DC, GR_XOR );
/* unlikf item an free the memory // delete the marker, and free memory. Don't use undelete stack.
* (not put in undelete stack, because this seems unnecessary) m_Pcb->Delete( Item );
*/
Item->DeleteStructure();
break; break;
case TYPEPAD: case TYPEPAD:

View File

@ -234,7 +234,7 @@ int WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, wxDC * DC, bo
g_SaveTime = time( NULL ); g_SaveTime = time( NULL );
#if 1 && defined(DEBUG) #if 0 && defined(DEBUG)
// note this freezes up pcbnew when run under the kicad project // note this freezes up pcbnew when run under the kicad project
// manager. runs fine from command prompt. This is because the kicad // manager. runs fine from command prompt. This is because the kicad
// project manager redirects stdout of the child pcbnew process to itself, // project manager redirects stdout of the child pcbnew process to itself,

View File

@ -48,7 +48,6 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
wxPoint locate_pos; wxPoint locate_pos;
wxString msg; wxString msg;
bool FindMarker = FALSE; bool FindMarker = FALSE;
int StartCount;
BOARD_ITEM* foundItem = 0; BOARD_ITEM* foundItem = 0;
switch( event.GetId() ) switch( event.GetId() )
@ -69,32 +68,22 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
s_OldStringFound = m_NewText->GetValue(); s_OldStringFound = m_NewText->GetValue();
m_Parent->DrawPanel->GetViewStart( &screen->m_StartVisu.x, &screen->m_StartVisu.y ); m_Parent->DrawPanel->GetViewStart( &screen->m_StartVisu.x, &screen->m_StartVisu.y );
StartCount = 0;
if( FindMarker ) if( FindMarker )
{ {
MARQUEUR* marker = (MARQUEUR*) m_Parent->m_Pcb->m_Drawings; MARKER* marker = m_Parent->m_Pcb->GetMARKER( s_MarkerCount++ );
for( ; marker; marker = (MARQUEUR*) marker->Next() ) if( marker )
{
if( marker->Type() != TYPEMARQUEUR )
continue;
StartCount++;
if( StartCount > s_MarkerCount )
{ {
foundItem = marker; foundItem = marker;
locate_pos = marker->m_Pos; locate_pos = marker->m_Pos;
s_MarkerCount++;
break;
}
} }
} }
else else
{ {
for( MODULE* module = m_Parent->m_Pcb->m_Modules; module; module = (MODULE*) module->Next() ) int StartCount = 0;
for( MODULE* module = m_Parent->m_Pcb->m_Modules; module; module = module->Next() )
{ {
if( WildCompareString( s_OldStringFound, module->GetReference().GetData(), if( WildCompareString( s_OldStringFound, module->GetReference().GetData(), FALSE ) )
FALSE ) )
{ {
StartCount++; StartCount++;
if( StartCount > s_ItemCount ) if( StartCount > s_ItemCount )

View File

@ -1079,7 +1079,7 @@ void WinEDA_DrillFrame::GenDrillMap( int format )
PlotMirePcb( (MIREPCB*) PtStruct, format, EDGE_LAYER ); PlotMirePcb( (MIREPCB*) PtStruct, format, EDGE_LAYER );
break; break;
case TYPEMARQUEUR: // do not draw case TYPEMARKER: // do not draw
break; break;
default: default:

View File

@ -349,15 +349,7 @@ void WinEDA_PcbFrame::Erase_Textes_Pcb( wxDC* DC, bool query )
void WinEDA_PcbFrame::Erase_Marqueurs() void WinEDA_PcbFrame::Erase_Marqueurs()
/*******************************************/ /*******************************************/
{ {
BOARD_ITEM* PtStruct, * PtNext; m_Pcb->DeleteMARKERs();
PtStruct = m_Pcb->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtNext )
{
PtNext = PtStruct->Next();
if( PtStruct->Type() == TYPEMARQUEUR )
PtStruct ->DeleteStructure();
}
GetScreen()->SetModify(); GetScreen()->SetModify();
} }

View File

@ -86,7 +86,7 @@ void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref, int printmaskl
( (MIREPCB*) PtStruct )->Draw( this, DC, wxPoint( 0, 0 ), drawmode ); ( (MIREPCB*) PtStruct )->Draw( this, DC, wxPoint( 0, 0 ), drawmode );
break; break;
case TYPEMARQUEUR: /* Trace des marqueurs */ case TYPEMARKER: /* Trace des marqueurs */
break; break;
default: default:

View File

@ -334,7 +334,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
case TYPEVIA: case TYPEVIA:
case TYPETRACK: case TYPETRACK:
case TYPEZONE: case TYPEZONE:
case TYPEMARQUEUR: case TYPEMARKER:
case TYPECOTATION: case TYPECOTATION:
case TYPEMIRE: case TYPEMIRE:
break; break;

View File

@ -292,7 +292,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
_( "Delete Zone" ), delete_xpm ); _( "Delete Zone" ), delete_xpm );
break; break;
case TYPEMARQUEUR: case TYPEMARKER:
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_MARKER, ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_MARKER,
_( "Delete Marker" ), delete_xpm ); _( "Delete Marker" ), delete_xpm );
break; break;

View File

@ -67,7 +67,7 @@ wxString msg;
// EDGE_LAYER | masque_layer ); // EDGE_LAYER | masque_layer );
break; break;
case TYPEMARQUEUR: case TYPEMARKER:
break; break;
default: default:

View File

@ -183,7 +183,7 @@ wxString msg;
masque_layer ); masque_layer );
break; break;
case TYPEMARQUEUR: case TYPEMARKER:
break; break;
default: default:

View File

@ -235,7 +235,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_HPGL( FILE* File, int masque_layer,
masque_layer ); masque_layer );
break; break;
case TYPEMARQUEUR: case TYPEMARKER:
break; break;
default: default:

View File

@ -273,7 +273,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_PS( FILE* File, int masque_layer,
masque_layer ); masque_layer );
break; break;
case TYPEMARQUEUR: case TYPEMARKER:
break; break;
default: default:

View File

@ -101,7 +101,6 @@ void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode )
/****************************************************/ /****************************************************/
/* Redraw the BOARD items but not cursors, axis or grid */ /* Redraw the BOARD items but not cursors, axis or grid */
{ {
MARQUEUR* Marqueur;
MODULE* Module; MODULE* Module;
EDA_BaseStruct* PtStruct; EDA_BaseStruct* PtStruct;
@ -158,11 +157,6 @@ void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode )
( (MIREPCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), mode ); ( (MIREPCB*) PtStruct )->Draw( DrawPanel, DC, wxPoint( 0, 0 ), mode );
break; break;
case TYPEMARQUEUR: /* Trace des marqueurs */
Marqueur = (MARQUEUR*) PtStruct;
Marqueur->Draw( DrawPanel, DC, mode );
break;
case TYPEDRAWSEGMENT: case TYPEDRAWSEGMENT:
Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, mode ); Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, mode );
break; break;
@ -172,6 +166,12 @@ void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode )
} }
} }
// draw the BOARD's markers.
for( unsigned i=0; i<m_Pcb->m_markers.size(); ++i )
{
m_Pcb->m_markers[i]->Draw( DrawPanel, DC, mode );
}
Trace_Pistes( DrawPanel, m_Pcb, DC, mode ); Trace_Pistes( DrawPanel, m_Pcb, DC, mode );
if( g_HightLigt_Status ) if( g_HightLigt_Status )
DrawHightLight( DC, g_HightLigth_NetCode ); DrawHightLight( DC, g_HightLigth_NetCode );