Commit 0415674d authored by dickelbeck's avatar dickelbeck

MARKER and DRC rework, continued

parent aef4b6e8
......@@ -4,6 +4,26 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
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>
================================================================================
+pcbnew
......
......@@ -254,7 +254,7 @@ bool LocateAndDeleteItem(WinEDA_SchematicFrame * frame, wxDC * DC)
/*****************************************************************/
/* Locate and delete the item found under the mouse cousor
If more than one item found: the priority order is:
1 : MARQUEUR
1 : MARKER
2 : JUNCTION
2 : NOCONNECT
3 : WIRE ou BUS
......
......@@ -35,7 +35,7 @@ enum KICAD_T {
TYPETRACK,
TYPEZONE,
TYPEVIA,
TYPEMARQUEUR,
TYPEMARKER,
TYPECOTATION,
TYPEMIRE,
TYPESCREEN,
......@@ -178,7 +178,7 @@ private:
public:
EDA_BaseStruct( EDA_BaseStruct* parent, KICAD_T idType );
EDA_BaseStruct( KICAD_T struct_type );
EDA_BaseStruct( KICAD_T idType );
virtual ~EDA_BaseStruct() { };
/**
......@@ -219,10 +219,6 @@ public:
m_Status = new_status;
}
/* addition d'une nouvelle struct a la liste chain� */
void AddToChain( EDA_BaseStruct* laststruct );
/* fonction de placement */
virtual void Place( WinEDA_DrawFrame* frame, wxDC* DC );
......@@ -316,6 +312,16 @@ public:
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)
/**
......@@ -450,6 +456,7 @@ public:
BOARD_ITEM* Back() const { return (BOARD_ITEM*) Pback; }
BOARD_ITEM* GetParent() const { return (BOARD_ITEM*) m_Parent; }
/**
* Function GetLayer
* returns the layer this item is on.
......
......@@ -133,7 +133,7 @@ enum Track_Shapes {
/* Forward declaration */
class MODULE;
class EQUIPOT;
class MARQUEUR;
class MARKER;
class TRACK;
class D_PAD;
struct CHEVELU;
......@@ -198,6 +198,10 @@ enum DisplayViaMode {
class BOARD : public BOARD_ITEM
{
friend class WinEDA_PcbFrame;
private:
std::vector<MARKER*> m_markers; ///< MARKERs which we own by pointer
public:
WinEDA_BasePcbFrame* m_PcbFrame; // Window de visualisation
EDA_Rect m_BoundaryBox; // Limites d'encadrement du PCB
......@@ -232,6 +236,41 @@ public:
/* supprime du chainage la structure Struct */
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 */
int GetNumSegmTrack();
int GetNumSegmZone();
......
......@@ -74,6 +74,8 @@ BOARD::~BOARD()
MyFree( m_LocalRatsnest );
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 */
int BOARD::GetNumSegmTrack()
{
TRACK* CurTrack = m_Track;
int ii = 0;
for( ; CurTrack != NULL; CurTrack = (TRACK*) CurTrack->Pnext )
for( ; CurTrack != NULL; CurTrack = CurTrack->Next() )
ii++;
m_NbSegmTrack = ii;
......@@ -119,7 +173,7 @@ int BOARD::GetNumSegmZone()
TRACK* CurTrack = m_Zone;
int ii = 0;
for( ; CurTrack != NULL; CurTrack = (TRACK*) CurTrack->Pnext )
for( ; CurTrack != NULL; CurTrack = CurTrack->Next() )
ii++;
m_NbSegmZone = ii;
......@@ -385,7 +439,6 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
case TYPEDRAWSEGMENT:
case TYPETEXTE:
case TYPEMARQUEUR:
case TYPECOTATION:
case TYPEMIRE:
result = IterateForward( m_Drawings, inspector, testData, p );
......@@ -396,7 +449,6 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
{
case TYPEDRAWSEGMENT:
case TYPETEXTE:
case TYPEMARQUEUR:
case TYPECOTATION:
case TYPEMIRE:
continue;
......@@ -447,7 +499,18 @@ SEARCH_RESULT BOARD::Visit( INSPECTOR* inspector, const void* testData,
++p;
break;
#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:
result = IterateForward( m_Equipots, inspector, testData, p );
++p;
......@@ -604,9 +667,6 @@ bool BOARD::Save( FILE* aFile ) const
goto out;
break;
case TYPEMARQUEUR: // do not save MARKERs, they can be regenerated easily
break;
default:
// future: throw exception here
#if defined(DEBUG)
......@@ -615,6 +675,8 @@ bool BOARD::Save( FILE* aFile ) const
break;
}
}
// do not save MARKERs, they can be regenerated easily
// save the tracks & vias
fprintf( aFile, "$TRACK\n" );
......
......@@ -194,8 +194,8 @@ wxString BOARD_ITEM::MenuText( const BOARD* aPcb ) const
}
break;
case TYPEMARQUEUR:
text << _( "Marker" ) << wxT( " @(" ) << ((MARQUEUR*)item)->m_Pos.x << wxT(",") << ((MARQUEUR*)item)->m_Pos.y << wxT(")");
case TYPEMARKER:
text << _( "Marker" ) << wxT( " @(" ) << ((MARKER*)item)->m_Pos.x << wxT(",") << ((MARKER*)item)->m_Pos.y << wxT(")");
break;
case TYPECOTATION:
......@@ -275,7 +275,7 @@ const char** BOARD_ITEM::MenuIcon() const
xpm = pad_sketch_xpm;
break;
case TYPEMARQUEUR:
case TYPEMARKER:
xpm = pad_xpm; // @todo: create and use marker xpm
break;
......
......@@ -35,11 +35,11 @@ static char Default_MarkerBitmap[] =
/*******************/
/* Classe MARQUEUR */
/* Classe MARKER */
/*******************/
MARQUEUR::MARQUEUR( BOARD_ITEM* StructFather ) :
BOARD_ITEM( StructFather, TYPEMARQUEUR )
MARKER::MARKER( BOARD_ITEM* StructFather ) :
BOARD_ITEM( StructFather, TYPEMARKER )
{
m_Bitmap = NULL;
m_Type = 0;
......@@ -51,38 +51,24 @@ MARQUEUR::MARQUEUR( BOARD_ITEM* StructFather ) :
/* 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
* les structures arrieres et avant sont chainees directement
*/
void MARQUEUR::UnLink()
void MARKER::UnLink()
{
/* Modification du chainage arriere */
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;
wxFAIL_MSG( wxT("MARKER::UnLink is deprecated") );
}
void MARQUEUR::Display_Infos( WinEDA_DrawFrame* frame )
void MARKER::Display_Infos( WinEDA_DrawFrame* frame )
{
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
......@@ -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 )
/**********************************************************************/
/*
......
......@@ -8,21 +8,39 @@
#include "base_struct.h"
class MARQUEUR : public BOARD_ITEM
class MARKER : public BOARD_ITEM
{
private:
wxString m_Diag; /* Associated text (comment) */
public:
wxPoint m_Pos;
char* m_Bitmap; /* Shape (bitmap) */
int m_Type;
int m_Color; /* color */
wxString m_Diag; /* Associated text (comment) */
wxSize m_Size; /* Size of the graphic symbol */
public:
MARQUEUR( BOARD_ITEM* StructFather );
~MARQUEUR();
MARKER( BOARD_ITEM* StructFather );
~MARKER();
void UnLink();
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
......
......@@ -38,7 +38,7 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
// all items in m_Drawings for instance should be contiguous.
TYPETEXTE,
TYPEDRAWSEGMENT,
TYPEMARQUEUR,
TYPEMARKER,
TYPECOTATION,
TYPEMIRE,
TYPEVIA,
......@@ -55,7 +55,7 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
const KICAD_T GENERAL_COLLECTOR::PrimaryItems[] = {
TYPETEXTE,
TYPEDRAWSEGMENT,
TYPEMARQUEUR,
TYPEMARKER,
TYPECOTATION,
TYPEVIA,
TYPETRACK,
......@@ -68,7 +68,7 @@ const KICAD_T GENERAL_COLLECTOR::PrimaryItems[] = {
const KICAD_T GENERAL_COLLECTOR::AllButZones[] = {
TYPETEXTE,
TYPEDRAWSEGMENT,
TYPEMARQUEUR,
TYPEMARKER,
TYPECOTATION,
TYPEMIRE,
TYPEVIA,
......
......@@ -39,19 +39,14 @@
////@end XPM images
DRC_LIST gList; // gets moved into DRC_TESTER later.
/**
* 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
{
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:
DRCLISTBOX( wxWindow* parent, wxWindowID id = wxID_ANY,
......@@ -86,7 +81,7 @@ public:
wxString OnGetItem( size_t n ) const
{
if( m_List )
return (*m_List)[n].ShowHtml();
return (*m_List)[n]->ShowHtml();
else
return wxString();
}
......@@ -101,7 +96,7 @@ public:
wxString OnGetItemMarkup( size_t n ) const
{
if( m_List )
return (*m_List)[n].ShowHtml();
return (*m_List)[n]->ShowHtml();
else
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,
const wxString& caption,
const wxPoint& pos,
const wxSize& size,
long style )
{
m_Tester = aDrc_tester;
m_Parent = parent;
m_DC = panelDC;
AbortDrc = FALSE;
......@@ -227,16 +224,8 @@ bool WinEDA_DrcFrame::Create( wxWindow* parent, wxWindowID id, const wxString& c
////@end WinEDA_DrcFrame creation
DRC_ITEM a( 2, wxString( wxT("A item") ), wxString( wxT("B item") ),
wxPoint(12000,3000), wxPoint(13000,3000));
gList.push_back( a );
gList.push_back( a );
gList.push_back( a );
gList.push_back( a );
m_ClearanceListBox->SetList( &gList );
m_UnconnectedListBox->SetList( &gList );
// m_ClearanceListBox->SetList( &gList );
// m_UnconnectedListBox->SetList( &gList );
return true;
}
......@@ -250,7 +239,7 @@ void WinEDA_DrcFrame::CreateControls()
SetFont( *g_DialogFont );
////@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;
......
......@@ -88,7 +88,7 @@ class WinEDA_DrcFrame: public wxDialog
public:
/// Constructors
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,
const wxString& caption = SYMBOL_WINEDA_DRCFRAME_TITLE,
const wxPoint& pos = SYMBOL_WINEDA_DRCFRAME_POSITION,
......@@ -177,9 +177,11 @@ public:
wxStdDialogButtonSizer* StdDialogButtonSizer;
////@end WinEDA_DrcFrame member variables
WinEDA_PcbFrame * m_Parent;
wxDC * m_DC;
int m_UnconnectedCount;
DRC_TESTER* m_Tester;
WinEDA_PcbFrame* m_Parent;
wxDC* m_DC;
int m_UnconnectedCount;
};
#endif // _DIALOG_DRC_H_
......
......@@ -21,6 +21,10 @@ class WinEDA_DrcFrame;
WinEDA_DrcFrame* DrcFrame;
//#define WXYIELD() wxYield()
#define WXYIELD() do { } while(0) // nothing
/* saving drc options */
static bool s_Pad2PadTestOpt = true;
static bool s_UnconnectedTestOpt = true;
......@@ -30,7 +34,7 @@ static FILE* s_RptFile = NULL;
static wxString s_RptFilename;
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 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;
DrcFrame = new WinEDA_DrcFrame( this, DC );
DrcFrame = new WinEDA_DrcFrame( NULL, this, DC ); // @todo
DrcFrame->ShowModal();
DrcFrame->Destroy();
DrcFrame = NULL;
......@@ -281,8 +285,7 @@ int WinEDA_PcbFrame::Test_DRC( wxDC* DC, bool TestPad2Pad, bool TestZone )
int flag_err_Drc;
TRACK* pt_segm;
D_PAD* pad;
MARQUEUR* Marqueur;
EDA_BaseStruct* PtStruct;
MARKER* Marqueur;
wxString Line;
#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 );
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;
if( PtStruct )
PtStruct->Pback = Marqueur;
m_Pcb->m_Drawings = Marqueur;
m_Pcb->Add( Marqueur );
}
}
......@@ -375,7 +373,7 @@ int WinEDA_PcbFrame::Test_DRC( wxDC* DC, bool TestPad2Pad, bool TestZone )
if( jj == 0 )
{
jj = 10;
wxYield();
WXYIELD();
if( AbortDrc )
{
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" ) );
return ErrorsDRC_Count;
}
Marqueur->Pnext = m_Pcb->m_Drawings;
Marqueur->Pback = m_Pcb;
PtStruct = m_Pcb->m_Drawings;
if( PtStruct )
PtStruct->Pback = Marqueur;
m_Pcb->m_Drawings = Marqueur;
m_Pcb->Add( Marqueur );
GRSetDrawMode( DC, GR_OR );
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 )
{
jj = 100;
wxYield();
WXYIELD();
if( AbortDrc )
{
AbortDrc = FALSE;
......@@ -487,13 +480,8 @@ int WinEDA_PcbFrame::Test_DRC( wxDC* DC, bool TestPad2Pad, bool TestZone )
DisplayError( this, wxT( "Test_Drc(): internal err" ) );
return ErrorsDRC_Count;
}
Marqueur->Pnext = m_Pcb->m_Drawings;
Marqueur->Pback = m_Pcb;
PtStruct = m_Pcb->m_Drawings;
if( PtStruct )
PtStruct->Pback = Marqueur;
m_Pcb->m_Drawings = Marqueur;
m_Pcb->Add( Marqueur );
GRSetDrawMode( DC, GR_OR );
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" ) );
return ErrorsDRC_Count;
}
Marqueur->Pnext = m_Pcb->m_Drawings;
Marqueur->Pback = m_Pcb;
PtStruct = m_Pcb->m_Drawings;
if( PtStruct )
PtStruct->Pback = Marqueur;
m_Pcb->m_Drawings = Marqueur;
m_Pcb->Add( Marqueur );
GRSetDrawMode( DC, GR_OR );
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 ) );
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_Color = WHITE;
current_marqueur->m_Diag = msg;
current_marqueur->SetMessage( msg );
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 ) );
if( current_marqueur == NULL )
current_marqueur = new MARQUEUR( Pcb );
current_marqueur = new MARKER( Pcb );
current_marqueur->m_Pos = pad1->m_Pos;
current_marqueur->m_Color = WHITE;
current_marqueur->m_Diag = msg;
current_marqueur->SetMessage( msg );
current_marqueur->Draw( panel, DC, GR_OR );
}
......
......@@ -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
* 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
* 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.
*/
class DRC_ITEM
class DRC_ITEM : public REPORT_ISSUE
{
protected:
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_BText; ///< text for the second BOARD_ITEM
wxPoint m_APos; ///< the location of the first BOARD_ITEM
......@@ -56,16 +94,19 @@ protected:
public:
DRC_ITEM( int aErrorCode, const wxString& aText, const wxString& bText,
const wxPoint& aPos, const wxPoint& bPos )
DRC_ITEM( int aErrorCode, const wxPoint& aIssuePos,
const wxString& aText, const wxString& bText,
const wxPoint& aPos, const wxPoint& bPos )
{
m_ErrorCode = aErrorCode;
m_Pos = aIssuePos;
m_AText = aText;
m_BText = bText;
m_APos = aPos;
m_BPos = bPos;
}
//-----<Interface REPORT_ISSUE>---------------------------------------
/**
* Function ShowHtml
......@@ -77,7 +118,7 @@ public:
{
wxString ret;
ret.Printf( wxT("<b>%s</b> <ul><li> %s: %s </li> <li> %s: %s </li> </ul>"),
ret.Printf( wxT("<b>%s</b><ul><li> %s: %s </li><li> %s: %s </li></ul>"),
GetErrorText().GetData(),
ShowCoord( m_APos ).GetData(), m_AText.GetData(),
ShowCoord( m_BPos ).GetData(), m_BText.GetData() );
......@@ -85,7 +126,6 @@ public:
return ret;
}
/**
* Function ShowText
* translates this object into a text string suitable for saving
......@@ -104,7 +144,19 @@ public:
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
* returns the string form of a drc error code.
......@@ -119,15 +171,17 @@ public:
* @return wxString - The formated string
*/
static wxString ShowCoord( const wxPoint& aPos );
};
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
{
protected:
bool doPad2PadTest;
bool doUnconnectedTest;
bool doZonesTest;
bool doCreateRptFile;
FILE* rptFile;
wxString rptFilename;
int errorCount;
MARQUEUR* currentMarker;
bool abortDrc;
bool drcInProgress;
int spot_cX;
int spot_cY;
int finx;
int finy; // coord relatives de l'extremite du segm de reference
int segmAngle; // angle d'inclinaison du segment de reference en 0,1 degre
int segmLong; // longueur du segment de reference
int xcliplo;
int ycliplo;
int xcliphi;
int ycliphi; // coord de la surface de securite du segment a comparer
DRC_LIST drcList;
WinEDA_DrawPanel* drawPanel;
bool m_doPad2PadTest;
bool m_doUnconnectedTest;
bool m_doZonesTest;
bool m_doCreateRptFile;
FILE* m_rptFile;
wxString m_rptFilename;
int m_errorCount;
MARKER* m_currentMarker;
bool m_aboartDRC;
bool m_drcInProgress;
int m_spotcx;
int m_spotcy;
int m_finx;
int m_finy; // coord relatives de l'extremite du segm de reference
int m_segmAngle; // angle d'inclinaison du segment de reference en 0,1 degre
int m_segmLong; // longueur du segment de reference
int m_xcliplo;
int m_ycliplo;
int m_xcliphi;
int m_ycliphi; // coord de la surface de securite du segment a comparer
int m_unconnectedCount;
DRC_LIST* m_drcList;
WinEDA_DrawPanel* m_drawPanel;
public:
DRC_TESTER()
{
doPad2PadTest = true;
doUnconnectedTest = true;
doZonesTest = false;
doCreateRptFile = false;
m_doPad2PadTest = true;
m_doUnconnectedTest = true;
m_doZonesTest = 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 )
{
doPad2PadTest = aPad2PadTest;
doUnconnectedTest = aUnconnectedTest;
doZonesTest = aZonesTest;
m_doPad2PadTest = aPad2PadTest;
m_doUnconnectedTest = aUnconnectedTest;
m_doZonesTest = aZonesTest;
rptFilename = aRptFilename;
if( rptFilename.IsEmpty() )
doCreateRptFile = false;
m_rptFilename = aRptFilename;
if( m_rptFilename.IsEmpty() )
m_doCreateRptFile = false;
else
doCreateRptFile = true;
m_doCreateRptFile = true;
}
};
......
......@@ -962,15 +962,13 @@ void WinEDA_PcbFrame::RemoveStruct( BOARD_ITEM* Item, wxDC* DC )
Delete_Zone( DC, (SEGZONE*) Item );
break;
case TYPEMARQUEUR:
case TYPEMARKER:
if( Item == GetCurItem() )
SetCurItem( NULL );
( (MARQUEUR*) Item )->Draw( DrawPanel, DC, GR_XOR );
( (MARKER*) Item )->Draw( DrawPanel, DC, GR_XOR );
/* unlikf item an free the memory
* (not put in undelete stack, because this seems unnecessary)
*/
Item->DeleteStructure();
// delete the marker, and free memory. Don't use undelete stack.
m_Pcb->Delete( Item );
break;
case TYPEPAD:
......
......@@ -234,7 +234,7 @@ int WinEDA_PcbFrame::LoadOnePcbFile( const wxString& FullFileName, wxDC * DC, bo
g_SaveTime = time( NULL );
#if 1 && defined(DEBUG)
#if 0 && defined(DEBUG)
// 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,
......
......@@ -48,7 +48,6 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
wxPoint locate_pos;
wxString msg;
bool FindMarker = FALSE;
int StartCount;
BOARD_ITEM* foundItem = 0;
switch( event.GetId() )
......@@ -69,32 +68,22 @@ void WinEDA_PcbFindFrame::FindItem( wxCommandEvent& event )
s_OldStringFound = m_NewText->GetValue();
m_Parent->DrawPanel->GetViewStart( &screen->m_StartVisu.x, &screen->m_StartVisu.y );
StartCount = 0;
if( FindMarker )
{
MARQUEUR* marker = (MARQUEUR*) m_Parent->m_Pcb->m_Drawings;
for( ; marker; marker = (MARQUEUR*) marker->Next() )
MARKER* marker = m_Parent->m_Pcb->GetMARKER( s_MarkerCount++ );
if( marker )
{
if( marker->Type() != TYPEMARQUEUR )
continue;
StartCount++;
if( StartCount > s_MarkerCount )
{
foundItem = marker;
locate_pos = marker->m_Pos;
s_MarkerCount++;
break;
}
foundItem = marker;
locate_pos = marker->m_Pos;
}
}
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(),
FALSE ) )
if( WildCompareString( s_OldStringFound, module->GetReference().GetData(), FALSE ) )
{
StartCount++;
if( StartCount > s_ItemCount )
......
......@@ -1079,7 +1079,7 @@ void WinEDA_DrillFrame::GenDrillMap( int format )
PlotMirePcb( (MIREPCB*) PtStruct, format, EDGE_LAYER );
break;
case TYPEMARQUEUR: // do not draw
case TYPEMARKER: // do not draw
break;
default:
......
......@@ -349,15 +349,7 @@ void WinEDA_PcbFrame::Erase_Textes_Pcb( wxDC* DC, bool query )
void WinEDA_PcbFrame::Erase_Marqueurs()
/*******************************************/
{
BOARD_ITEM* PtStruct, * PtNext;
PtStruct = m_Pcb->m_Drawings;
for( ; PtStruct != NULL; PtStruct = PtNext )
{
PtNext = PtStruct->Next();
if( PtStruct->Type() == TYPEMARQUEUR )
PtStruct ->DeleteStructure();
}
m_Pcb->DeleteMARKERs();
GetScreen()->SetModify();
}
......@@ -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 );
break;
case TYPEMARQUEUR: /* Trace des marqueurs */
case TYPEMARKER: /* Trace des marqueurs */
break;
default:
......
......@@ -334,7 +334,7 @@ bool WinEDA_ModuleEditFrame::OnRightClick( const wxPoint& MousePos,
case TYPEVIA:
case TYPETRACK:
case TYPEZONE:
case TYPEMARQUEUR:
case TYPEMARKER:
case TYPECOTATION:
case TYPEMIRE:
break;
......
......@@ -292,7 +292,7 @@ bool WinEDA_PcbFrame::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
_( "Delete Zone" ), delete_xpm );
break;
case TYPEMARQUEUR:
case TYPEMARKER:
ADD_MENUITEM( aPopMenu, ID_POPUP_PCB_DELETE_MARKER,
_( "Delete Marker" ), delete_xpm );
break;
......
......@@ -67,7 +67,7 @@ wxString msg;
// EDGE_LAYER | masque_layer );
break;
case TYPEMARQUEUR:
case TYPEMARKER:
break;
default:
......
......@@ -183,7 +183,7 @@ wxString msg;
masque_layer );
break;
case TYPEMARQUEUR:
case TYPEMARKER:
break;
default:
......
......@@ -235,7 +235,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_HPGL( FILE* File, int masque_layer,
masque_layer );
break;
case TYPEMARQUEUR:
case TYPEMARKER:
break;
default:
......
......@@ -273,7 +273,7 @@ void WinEDA_BasePcbFrame::Plot_Layer_PS( FILE* File, int masque_layer,
masque_layer );
break;
case TYPEMARQUEUR:
case TYPEMARKER:
break;
default:
......
......@@ -101,7 +101,6 @@ void WinEDA_PcbFrame::Trace_Pcb( wxDC* DC, int mode )
/****************************************************/
/* Redraw the BOARD items but not cursors, axis or grid */
{
MARQUEUR* Marqueur;
MODULE* Module;
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 );
break;
case TYPEMARQUEUR: /* Trace des marqueurs */
Marqueur = (MARQUEUR*) PtStruct;
Marqueur->Draw( DrawPanel, DC, mode );
break;
case TYPEDRAWSEGMENT:
Trace_DrawSegmentPcb( DrawPanel, DC, (DRAWSEGMENT*) PtStruct, mode );
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 );
if( g_HightLigt_Status )
DrawHightLight( DC, g_HightLigth_NetCode );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment