Commit 3e2662ae authored by dickelbeck's avatar dickelbeck

mord DRC changes

parent 36c316e7
/*********************/ /*********************/
/* File: cvframe.cpp */ /* File: cvframe.cpp */
/*********************/ /*********************/
#include "fctsys.h" #include "fctsys.h"
#include "common.h" #include "common.h"
#include <wx/fontdlg.h> #include <wx/fontdlg.h>
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
#define FRAME_MIN_SIZE_X 450 #define FRAME_MIN_SIZE_X 450
#define FRAME_MIN_SIZE_Y 300 #define FRAME_MIN_SIZE_Y 300
/*******************************************************/ /*******************************************************/
/* Constructeur de WinEDA_CvpcbFrame: la fenetre generale */ /* Constructeur de WinEDA_CvpcbFrame: la fenetre generale */
/*******************************************************/ /*******************************************************/
WinEDA_CvpcbFrame::WinEDA_CvpcbFrame(WinEDA_App *parent, const wxString & title, long style ): WinEDA_CvpcbFrame::WinEDA_CvpcbFrame( WinEDA_App* parent, const wxString& title, long style ) :
WinEDA_BasicFrame(NULL, CVPCB_FRAME, parent, title, wxDefaultPosition, wxDefaultSize, style ) WinEDA_BasicFrame( NULL, CVPCB_FRAME, parent, title, wxDefaultPosition, wxDefaultSize, style )
{ {
m_FrameName = wxT("CvpcbFrame"); m_FrameName = wxT( "CvpcbFrame" );
m_ListCmp = NULL; m_ListCmp = NULL;
m_FootprintList = NULL; m_FootprintList = NULL;
DrawFrame = NULL; DrawFrame = NULL;
...@@ -33,23 +33,25 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame(WinEDA_App *parent, const wxString & title, ...@@ -33,23 +33,25 @@ WinEDA_CvpcbFrame::WinEDA_CvpcbFrame(WinEDA_App *parent, const wxString & title,
// Give an icon // Give an icon
#ifdef __WINDOWS__ #ifdef __WINDOWS__
SetIcon( wxICON(a_icon_cvpcb)); SetIcon( wxICON( a_icon_cvpcb ) );
#else #else
SetIcon( wxICON(icon_cvpcb)); SetIcon( wxICON( icon_cvpcb ) );
#endif #endif
SetFont(*g_StdFont); SetFont( *g_StdFont );
SetAutoLayout(TRUE); SetAutoLayout( TRUE );
GetSettings(); GetSettings();
if ( m_FrameSize.x < FRAME_MIN_SIZE_X ) m_FrameSize.x = FRAME_MIN_SIZE_X; if( m_FrameSize.x < FRAME_MIN_SIZE_X )
if ( m_FrameSize.y < FRAME_MIN_SIZE_Y ) m_FrameSize.y = FRAME_MIN_SIZE_Y; m_FrameSize.x = FRAME_MIN_SIZE_X;
if( m_FrameSize.y < FRAME_MIN_SIZE_Y )
m_FrameSize.y = FRAME_MIN_SIZE_Y;
// create the status bar // create the status bar
int dims[3] = { -1, -1, 250}; int dims[3] = { -1, -1, 250 };
CreateStatusBar(3); CreateStatusBar( 3 );
SetStatusWidths(3,dims); SetStatusWidths( 3, dims );
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
...@@ -59,25 +61,27 @@ int dims[3] = { -1, -1, 250}; ...@@ -59,25 +61,27 @@ int dims[3] = { -1, -1, 250};
BuildFootprintListBox(); BuildFootprintListBox();
/* Creation des contraintes de dimension de la fenetre d'affichage des composants /* Creation des contraintes de dimension de la fenetre d'affichage des composants
du schema */ * du schema */
wxLayoutConstraints * linkpos = new wxLayoutConstraints; wxLayoutConstraints* linkpos = new wxLayoutConstraints;
linkpos->top.SameAs(this,wxTop); linkpos->top.SameAs( this, wxTop );
linkpos->bottom.SameAs(this,wxBottom); linkpos->bottom.SameAs( this, wxBottom );
linkpos->left.SameAs(this,wxLeft); linkpos->left.SameAs( this, wxLeft );
linkpos->width.PercentOf(this,wxWidth,66); linkpos->width.PercentOf( this, wxWidth, 66 );
if ( m_ListCmp ) m_ListCmp->SetConstraints(linkpos); if( m_ListCmp )
m_ListCmp->SetConstraints( linkpos );
/* Creation des contraintes de dimension de la fenetre d'affichage des modules /* Creation des contraintes de dimension de la fenetre d'affichage des modules
de la librairie */ * de la librairie */
linkpos = new wxLayoutConstraints; linkpos = new wxLayoutConstraints;
linkpos->top.SameAs(m_ListCmp,wxTop); linkpos->top.SameAs( m_ListCmp, wxTop );
linkpos->bottom.SameAs(m_ListCmp,wxBottom); linkpos->bottom.SameAs( m_ListCmp, wxBottom );
linkpos->right.SameAs(this,wxRight); linkpos->right.SameAs( this, wxRight );
linkpos->left.SameAs(m_ListCmp,wxRight); linkpos->left.SameAs( m_ListCmp, wxRight );
if ( m_FootprintList ) m_FootprintList->SetConstraints(linkpos); if( m_FootprintList )
m_FootprintList->SetConstraints( linkpos );
SetSizeHints(FRAME_MIN_SIZE_X,FRAME_MIN_SIZE_Y, -1,-1, -1,-1); // Set minimal size to w,h
SetSize(m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y); SetSizeHints( FRAME_MIN_SIZE_X, FRAME_MIN_SIZE_Y, -1, -1, -1, -1 ); // Set minimal size to w,h
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
} }
...@@ -87,88 +91,95 @@ WinEDA_CvpcbFrame::~WinEDA_CvpcbFrame() ...@@ -87,88 +91,95 @@ WinEDA_CvpcbFrame::~WinEDA_CvpcbFrame()
{ {
if( m_Parent->m_EDA_Config ) if( m_Parent->m_EDA_Config )
{ {
int state = m_HToolBar->GetToolState(ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST); int state = m_HToolBar->GetToolState( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST );
m_Parent->m_EDA_Config->Write(wxT(FILTERFOOTPRINTKEY), state); m_Parent->m_EDA_Config->Write( wxT( FILTERFOOTPRINTKEY ), state );
} }
} }
/************************************************/ /************************************************/
void WinEDA_CvpcbFrame::OnSize(wxSizeEvent& event) void WinEDA_CvpcbFrame::OnSize( wxSizeEvent& event )
/************************************************/ /************************************************/
{ {
event.Skip(); event.Skip();
} }
/***************************************************************/ /***************************************************************/
/* Construction de la table des evenements pour WinEDA_CvpcbFrame */ /* Construction de la table des evenements pour WinEDA_CvpcbFrame */
/***************************************************************/ /***************************************************************/
BEGIN_EVENT_TABLE(WinEDA_CvpcbFrame, wxFrame) BEGIN_EVENT_TABLE( WinEDA_CvpcbFrame, wxFrame )
EVT_MENU_RANGE(ID_LOAD_PROJECT,ID_LOAD_FILE_10, EVT_MENU_RANGE( ID_LOAD_PROJECT, ID_LOAD_FILE_10,
WinEDA_CvpcbFrame::LoadNetList) WinEDA_CvpcbFrame::LoadNetList )
EVT_MENU(ID_SAVE_PROJECT, WinEDA_CvpcbFrame::SaveQuitCvpcb) EVT_MENU( ID_SAVE_PROJECT, WinEDA_CvpcbFrame::SaveQuitCvpcb )
EVT_MENU(ID_CVPCB_QUIT, WinEDA_CvpcbFrame::OnQuit) EVT_MENU( ID_CVPCB_QUIT, WinEDA_CvpcbFrame::OnQuit )
EVT_MENU(ID_CVPCB_DISPLAY_HELP, WinEDA_CvpcbFrame::GetKicadHelp) EVT_MENU( ID_CVPCB_DISPLAY_HELP, WinEDA_CvpcbFrame::GetKicadHelp )
EVT_MENU(ID_CVPCB_DISPLAY_LICENCE, WinEDA_CvpcbFrame::GetKicadAbout) EVT_MENU( ID_CVPCB_DISPLAY_LICENCE, WinEDA_CvpcbFrame::GetKicadAbout )
EVT_MENU(ID_CONFIG_REQ,WinEDA_CvpcbFrame::ConfigCvpcb) EVT_MENU( ID_CONFIG_REQ, WinEDA_CvpcbFrame::ConfigCvpcb )
EVT_MENU(ID_CONFIG_SAVE,WinEDA_CvpcbFrame::Update_Config) EVT_MENU( ID_CONFIG_SAVE, WinEDA_CvpcbFrame::Update_Config )
EVT_MENU_RANGE(ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END, EVT_MENU_RANGE( ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END,
WinEDA_CvpcbFrame::ProcessFontPreferences) WinEDA_CvpcbFrame::ProcessFontPreferences )
EVT_MENU_RANGE(ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
WinEDA_CvpcbFrame::SetLanguage) WinEDA_CvpcbFrame::SetLanguage )
EVT_TOOL(ID_CVPCB_QUIT, WinEDA_CvpcbFrame::OnQuit) EVT_TOOL( ID_CVPCB_QUIT, WinEDA_CvpcbFrame::OnQuit )
EVT_TOOL(ID_CVPCB_READ_INPUT_NETLIST, WinEDA_CvpcbFrame::LoadNetList) EVT_TOOL( ID_CVPCB_READ_INPUT_NETLIST, WinEDA_CvpcbFrame::LoadNetList )
EVT_TOOL(ID_CVPCB_SAVEQUITCVPCB, WinEDA_CvpcbFrame::SaveQuitCvpcb) EVT_TOOL( ID_CVPCB_SAVEQUITCVPCB, WinEDA_CvpcbFrame::SaveQuitCvpcb )
EVT_TOOL(ID_CVPCB_CREATE_CONFIGWINDOW,WinEDA_CvpcbFrame::ConfigCvpcb) EVT_TOOL( ID_CVPCB_CREATE_CONFIGWINDOW, WinEDA_CvpcbFrame::ConfigCvpcb )
EVT_TOOL(ID_CVPCB_CREATE_SCREENCMP, WinEDA_CvpcbFrame::DisplayModule) EVT_TOOL( ID_CVPCB_CREATE_SCREENCMP, WinEDA_CvpcbFrame::DisplayModule )
EVT_TOOL(ID_CVPCB_GOTO_FIRSTNA, WinEDA_CvpcbFrame::ToFirstNA) EVT_TOOL( ID_CVPCB_GOTO_FIRSTNA, WinEDA_CvpcbFrame::ToFirstNA )
EVT_TOOL(ID_CVPCB_GOTO_PREVIOUSNA, WinEDA_CvpcbFrame::ToPreviousNA) EVT_TOOL( ID_CVPCB_GOTO_PREVIOUSNA, WinEDA_CvpcbFrame::ToPreviousNA )
EVT_TOOL(ID_CVPCB_DEL_ASSOCIATIONS, WinEDA_CvpcbFrame::DelAssociations) EVT_TOOL( ID_CVPCB_DEL_ASSOCIATIONS, WinEDA_CvpcbFrame::DelAssociations )
EVT_TOOL(ID_CVPCB_AUTO_ASSOCIE, WinEDA_CvpcbFrame::AssocieModule) EVT_TOOL( ID_CVPCB_AUTO_ASSOCIE, WinEDA_CvpcbFrame::AssocieModule )
EVT_TOOL(ID_CVPCB_CREATE_STUFF_FILE, WinEDA_CvpcbFrame::WriteStuffList) EVT_TOOL( ID_CVPCB_CREATE_STUFF_FILE, WinEDA_CvpcbFrame::WriteStuffList )
EVT_TOOL(ID_PCB_DISPLAY_FOOTPRINT_DOC, WinEDA_CvpcbFrame::DisplayDocFile) EVT_TOOL( ID_PCB_DISPLAY_FOOTPRINT_DOC, WinEDA_CvpcbFrame::DisplayDocFile )
EVT_TOOL(ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, WinEDA_CvpcbFrame::OnSelectFilteringFootprint) EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, WinEDA_CvpcbFrame::OnSelectFilteringFootprint )
EVT_TOOL(ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, WinEDA_CvpcbFrame::OnSelectFilteringFootprint) EVT_TOOL( ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, WinEDA_CvpcbFrame::OnSelectFilteringFootprint )
EVT_CHAR_HOOK(WinEDA_CvpcbFrame::OnChar) EVT_CHAR_HOOK( WinEDA_CvpcbFrame::OnChar )
EVT_CLOSE(WinEDA_CvpcbFrame::OnCloseWindow) EVT_CLOSE( WinEDA_CvpcbFrame::OnCloseWindow )
EVT_SIZE( WinEDA_CvpcbFrame::OnSize) EVT_SIZE( WinEDA_CvpcbFrame::OnSize )
EVT_LIST_ITEM_SELECTED (ID_CVPCB_FOOTPRINT_LIST, WinEDA_CvpcbFrame::OnLeftClick) EVT_LIST_ITEM_SELECTED( ID_CVPCB_FOOTPRINT_LIST, WinEDA_CvpcbFrame::OnLeftClick )
EVT_LIST_ITEM_ACTIVATED (ID_CVPCB_FOOTPRINT_LIST, WinEDA_CvpcbFrame::OnLeftDClick) EVT_LIST_ITEM_ACTIVATED( ID_CVPCB_FOOTPRINT_LIST, WinEDA_CvpcbFrame::OnLeftDClick )
EVT_LIST_ITEM_SELECTED(ID_CVPCB_COMPONENT_LIST, WinEDA_CvpcbFrame::OnSelectComponent) EVT_LIST_ITEM_SELECTED( ID_CVPCB_COMPONENT_LIST, WinEDA_CvpcbFrame::OnSelectComponent )
END_EVENT_TABLE() END_EVENT_TABLE()
/************************************************************/ /************************************************************/
/* Fonctions de base de WinEDA_CvpcbFrame: la fenetre generale */ /* Fonctions de base de WinEDA_CvpcbFrame: la fenetre generale */
/************************************************************/ /************************************************************/
/* Sortie de CVPCB */ /* Sortie de CVPCB */
void WinEDA_CvpcbFrame::OnQuit(wxCommandEvent& event) void WinEDA_CvpcbFrame::OnQuit( wxCommandEvent& event )
{ {
Close(TRUE); Close( TRUE );
} }
/**********************************************************/ /**********************************************************/
void WinEDA_CvpcbFrame::OnCloseWindow(wxCloseEvent & Event) void WinEDA_CvpcbFrame::OnCloseWindow( wxCloseEvent& Event )
/**********************************************************/ /**********************************************************/
{ {
int diag; int diag;
if( modified ) if( modified )
{ {
unsigned ii; unsigned ii;
wxMessageDialog dialog(this, _("Netlist and Cmp list modified, Save before exit ?"), wxMessageDialog dialog( this, _( "Netlist and Cmp list modified, Save before exit ?" ),
_("Confirmation"), wxYES_NO | wxCANCEL | wxICON_EXCLAMATION | wxYES_DEFAULT); _(
"Confirmation" ), wxYES_NO | wxCANCEL | wxICON_EXCLAMATION |
wxYES_DEFAULT );
ii = dialog.ShowModal(); ii = dialog.ShowModal();
switch ( ii )
switch( ii )
{ {
case wxID_CANCEL: case wxID_CANCEL:
Event.Veto(); Event.Veto();
...@@ -179,11 +190,12 @@ int diag; ...@@ -179,11 +190,12 @@ int diag;
case wxID_OK: case wxID_OK:
case wxID_YES: case wxID_YES:
diag = SaveNetList(wxEmptyString); diag = SaveNetList( wxEmptyString );
if( diag > 0 ) modified = 0; if( diag > 0 )
else if ( diag == 0 ) modified = 0;
else if( diag == 0 )
{ {
if( ! IsOK(this, _("Problem when saving files, Exit anyway") ) ) if( !IsOK( this, _( "Problem when saving files, Exit anyway" ) ) )
{ {
Event.Veto(); return; Event.Veto(); return;
} }
...@@ -193,15 +205,15 @@ int diag; ...@@ -193,15 +205,15 @@ int diag;
} }
// Close the help frame // Close the help frame
if ( m_Parent->m_HtmlCtrl ) if( m_Parent->m_HtmlCtrl )
{ {
if ( m_Parent->m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active if( m_Parent->m_HtmlCtrl->GetFrame() ) // returns NULL if no help frame active
m_Parent->m_HtmlCtrl->GetFrame()->Close(TRUE); m_Parent->m_HtmlCtrl->GetFrame()->Close( TRUE );
} }
if ( ! NetInNameBuffer.IsEmpty() ) if( !NetInNameBuffer.IsEmpty() )
{ {
SetLastProject(NetInNameBuffer); SetLastProject( NetInNameBuffer );
} }
FreeMemoryModules(); FreeMemoryModules();
...@@ -216,129 +228,138 @@ int diag; ...@@ -216,129 +228,138 @@ int diag;
/************************************************/ /************************************************/
void WinEDA_CvpcbFrame::OnChar(wxKeyEvent& event) void WinEDA_CvpcbFrame::OnChar( wxKeyEvent& event )
/************************************************/ /************************************************/
{ {
event.Skip(); event.Skip();
} }
/*******************************************************/ /*******************************************************/
void WinEDA_CvpcbFrame::ToFirstNA(wxCommandEvent& event) void WinEDA_CvpcbFrame::ToFirstNA( wxCommandEvent& event )
/*******************************************************/ /*******************************************************/
{ {
STORECMP * Composant; STORECMP* Composant;
int ii, selection;; int ii, selection;;
Composant = g_BaseListeCmp; Composant = g_BaseListeCmp;
selection= m_ListCmp->GetSelection(); selection = m_ListCmp->GetSelection();
if(selection < 0) selection = 0; if( selection < 0 )
for (ii = 0 ; Composant != NULL; Composant = Composant->Pnext) selection = 0;
for( ii = 0; Composant != NULL; Composant = Composant->Pnext )
{ {
if( Composant->m_Module.IsEmpty() && (ii > selection) ) if( Composant->m_Module.IsEmpty() && (ii > selection) )
break; break;
ii++; ii++;
} }
if ( Composant == NULL ) if( Composant == NULL )
{ {
wxBell(); ii = selection; wxBell(); ii = selection;
} }
if ( g_BaseListeCmp ) m_ListCmp->SetSelection(ii); if( g_BaseListeCmp )
m_ListCmp->SetSelection( ii );
} }
/**********************************************************/ /**********************************************************/
void WinEDA_CvpcbFrame::ToPreviousNA(wxCommandEvent& event) void WinEDA_CvpcbFrame::ToPreviousNA( wxCommandEvent& event )
/**********************************************************/ /**********************************************************/
{ {
STORECMP * Composant; STORECMP* Composant;
int ii, selection; int ii, selection;
Composant = g_BaseListeCmp; Composant = g_BaseListeCmp;
selection = m_ListCmp->GetSelection(); selection = m_ListCmp->GetSelection();
if(selection < 0) selection = 0; if( selection < 0 )
selection = 0;
for (ii = 0 ; Composant != NULL; Composant = Composant->Pnext) for( ii = 0; Composant != NULL; Composant = Composant->Pnext )
{ {
if( ii == selection ) break; if( ii == selection )
ii ++; break;
ii++;
} }
for ( ; Composant != NULL ; Composant = Composant->Pback) for( ; Composant != NULL; Composant = Composant->Pback )
{ {
if( Composant->m_Module.IsEmpty() && (ii != selection) ) if( Composant->m_Module.IsEmpty() && (ii != selection) )
break; break;
ii--; ii--;
} }
if ( Composant == NULL ) if( Composant == NULL )
{ {
wxBell(); ii = selection; wxBell(); ii = selection;
} }
if ( g_BaseListeCmp ) m_ListCmp->SetSelection(ii); if( g_BaseListeCmp )
m_ListCmp->SetSelection( ii );
} }
/**********************************************************/ /**********************************************************/
void WinEDA_CvpcbFrame::SaveQuitCvpcb(wxCommandEvent& event) void WinEDA_CvpcbFrame::SaveQuitCvpcb( wxCommandEvent& event )
/**********************************************************/ /**********************************************************/
{ {
if( SaveNetList(wxEmptyString) > 0) if( SaveNetList( wxEmptyString ) > 0 )
{ {
modified = 0; modified = 0;
Close(TRUE); Close( TRUE );
} }
} }
/*************************************************************/ /*************************************************************/
void WinEDA_CvpcbFrame::DelAssociations(wxCommandEvent& event) void WinEDA_CvpcbFrame::DelAssociations( wxCommandEvent& event )
/*************************************************************/ /*************************************************************/
/* Supprime toutes les associations deja faites /* Supprime toutes les associations deja faites
*/ */
{ {
int ii; int ii;
STORECMP * Composant; STORECMP* Composant;
wxString Line; wxString Line;
if( IsOK(this, _("Delete selections")) ) if( IsOK( this, _( "Delete selections" ) ) )
{ {
Composant = g_BaseListeCmp; Composant = g_BaseListeCmp;
for ( ii = 0; Composant != NULL; Composant = Composant->Pnext, ii++) for( ii = 0; Composant != NULL; Composant = Composant->Pnext, ii++ )
{ {
Composant->m_Module.Empty(); Composant->m_Module.Empty();
m_ListCmp->SetSelection(ii); m_ListCmp->SetSelection( ii );
SetNewPkg(wxEmptyString); SetNewPkg( wxEmptyString );
} }
m_ListCmp->SetSelection(0);
m_ListCmp->SetSelection( 0 );
composants_non_affectes = nbcomp; composants_non_affectes = nbcomp;
} }
Line.Printf( _("Componants: %d (free: %d)"), nbcomp, composants_non_affectes); Line.Printf( _( "Componants: %d (free: %d)" ), nbcomp, composants_non_affectes );
SetStatusText(Line,1); SetStatusText( Line, 1 );
} }
/***********************************************************/ /***********************************************************/
void WinEDA_CvpcbFrame::LoadNetList(wxCommandEvent& event) void WinEDA_CvpcbFrame::LoadNetList( wxCommandEvent& event )
/***********************************************************/ /***********************************************************/
/* Fonction liee au boutton "Load" /* Fonction liee au boutton "Load"
Lit la netliste * Lit la netliste
*/ */
{ {
int id = event.GetId(); int id = event.GetId();
wxString fullfilename; wxString fullfilename;
wxString oldfilename; wxString oldfilename;
bool newfile; bool newfile;
if ( ! NetInNameBuffer.IsEmpty() ) if( !NetInNameBuffer.IsEmpty() )
{ {
oldfilename = NetInNameBuffer; oldfilename = NetInNameBuffer;
} }
switch ( id ) switch( id )
{ {
case ID_LOAD_FILE_1: case ID_LOAD_FILE_1:
case ID_LOAD_FILE_2: case ID_LOAD_FILE_2:
...@@ -351,173 +372,189 @@ bool newfile; ...@@ -351,173 +372,189 @@ bool newfile;
case ID_LOAD_FILE_9: case ID_LOAD_FILE_9:
case ID_LOAD_FILE_10: case ID_LOAD_FILE_10:
id -= ID_LOAD_FILE_1; id -= ID_LOAD_FILE_1;
fullfilename = GetLastProject(id); fullfilename = GetLastProject( id );
break; break;
} }
newfile = ReadInputNetList(fullfilename);
if (newfile && ! oldfilename.IsEmpty() ) newfile = ReadInputNetList( fullfilename );
if( newfile && !oldfilename.IsEmpty() )
{ {
SetLastProject(NetInNameBuffer); SetLastProject( NetInNameBuffer );
ReCreateMenuBar(); ReCreateMenuBar();
} }
} }
/***********************************************************/ /***********************************************************/
void WinEDA_CvpcbFrame::ConfigCvpcb(wxCommandEvent& event) void WinEDA_CvpcbFrame::ConfigCvpcb( wxCommandEvent& event )
/***********************************************************/ /***********************************************************/
/* Fonction liee au boutton "Config" /* Fonction liee au boutton "Config"
Affiche le panneau de configuration * Affiche le panneau de configuration
*/ */
{ {
CreateConfigWindow(); CreateConfigWindow();
} }
/************************************************************/ /************************************************************/
void WinEDA_CvpcbFrame::DisplayModule(wxCommandEvent& event) void WinEDA_CvpcbFrame::DisplayModule( wxCommandEvent& event )
/************************************************************/ /************************************************************/
/* Fonction liee au boutton "Visu" /* Fonction liee au boutton "Visu"
Affiche l'ecran de visualisation des modules * Affiche l'ecran de visualisation des modules
*/ */
{ {
CreateScreenCmp(); CreateScreenCmp();
DrawFrame->AdjustScrollBars(); DrawFrame->AdjustScrollBars();
DrawFrame->Recadre_Trace(FALSE); DrawFrame->Recadre_Trace( FALSE );
} }
/****************************************************************/ /****************************************************************/
void WinEDA_CvpcbFrame::AddFontSelectionMenu(wxMenu * main_menu) void WinEDA_CvpcbFrame::AddFontSelectionMenu( wxMenu* main_menu )
/*****************************************************************/ /*****************************************************************/
/* create the submenu for fonte selection and setup fonte size /* create the submenu for fonte selection and setup fonte size
*/ */
{ {
wxMenu * fontmenu = new wxMenu(); wxMenu* fontmenu = new wxMenu();
ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_DIALOG, _("font for dialog boxes"),
ADD_MENUITEM( fontmenu, ID_PREFERENCES_FONT_DIALOG, _( "font for dialog boxes" ),
fonts_xpm ); fonts_xpm );
ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_INFOSCREEN, _("font for Lists"), ADD_MENUITEM( fontmenu, ID_PREFERENCES_FONT_INFOSCREEN, _( "font for Lists" ),
fonts_xpm ); fonts_xpm );
ADD_MENUITEM(fontmenu, ID_PREFERENCES_FONT_STATUS, _("font for Status Line"), ADD_MENUITEM( fontmenu, ID_PREFERENCES_FONT_STATUS, _( "font for Status Line" ),
fonts_xpm );
ADD_MENUITEM_WITH_HELP_AND_SUBMENU( main_menu, fontmenu,
ID_PREFERENCES_FONT, _( "&Font selection" ),
_(
"Choose font type and size for dialogs, infos and status box" ),
fonts_xpm ); fonts_xpm );
ADD_MENUITEM_WITH_HELP_AND_SUBMENU(main_menu, fontmenu,
ID_PREFERENCES_FONT, _("&Font selection"),
_("Choose font type and size for dialogs, infos and status box"),
fonts_xpm);
} }
/********************************************************/ /********************************************************/
void WinEDA_CvpcbFrame::SetLanguage(wxCommandEvent& event) void WinEDA_CvpcbFrame::SetLanguage( wxCommandEvent& event )
/********************************************************/ /********************************************************/
{ {
int id = event.GetId(); int id = event.GetId();
m_Parent->SetLanguageIdentifier(id ); m_Parent->SetLanguageIdentifier( id );
m_Parent->SetLanguage(); m_Parent->SetLanguage();
} }
/*************************************************************/ /*************************************************************/
void WinEDA_CvpcbFrame::DisplayDocFile(wxCommandEvent & event) void WinEDA_CvpcbFrame::DisplayDocFile( wxCommandEvent& event )
/*************************************************************/ /*************************************************************/
{ {
wxString msg = FindKicadHelpPath(); wxString msg = FindKicadHelpPath();
msg += wxT("pcbnew/footprints.pdf");
GetAssociatedDocument(this, wxEmptyString, msg); msg += wxT( "pcbnew/footprints.pdf" );
GetAssociatedDocument( this, wxEmptyString, msg );
} }
/********************************************************************/ /********************************************************************/
void WinEDA_CvpcbFrame::ProcessFontPreferences(wxCommandEvent& event) void WinEDA_CvpcbFrame::ProcessFontPreferences( wxCommandEvent& event )
/********************************************************************/ /********************************************************************/
{ {
int id = event.GetId(); int id = event.GetId();
wxFont font; wxFont font;
switch (id) switch( id )
{ {
case ID_PREFERENCES_FONT: case ID_PREFERENCES_FONT:
case ID_PREFERENCES_FONT_DIALOG: case ID_PREFERENCES_FONT_DIALOG:
case ID_PREFERENCES_FONT_STATUS: case ID_PREFERENCES_FONT_STATUS:
WinEDA_BasicFrame::ProcessFontPreferences(id); WinEDA_BasicFrame::ProcessFontPreferences( id );
break; break;
case ID_PREFERENCES_FONT_INFOSCREEN: case ID_PREFERENCES_FONT_INFOSCREEN:
{ {
font = wxGetFontFromUser(this, *g_FixedFont); font = wxGetFontFromUser( this, *g_FixedFont );
if ( font.Ok() ) if( font.Ok() )
{ {
int pointsize = font.GetPointSize(); int pointsize = font.GetPointSize();
*g_FixedFont = font; *g_FixedFont = font;
g_FixedFontPointSize = pointsize; g_FixedFontPointSize = pointsize;
m_FootprintList->SetFont(*g_FixedFont); m_FootprintList->SetFont( *g_FixedFont );
m_ListCmp->SetFont(*g_FixedFont); m_ListCmp->SetFont( *g_FixedFont );
} }
break; break;
} }
default: DisplayError(this, wxT("WinEDA_DrawFrame::ProcessFontPreferences Internal Error") );
default:
DisplayError( this, wxT( "WinEDA_DrawFrame::ProcessFontPreferences Internal Error" ) );
break; break;
} }
} }
/******************************************************/ /******************************************************/
void WinEDA_CvpcbFrame::OnLeftClick(wxListEvent& event) void WinEDA_CvpcbFrame::OnLeftClick( wxListEvent& event )
/******************************************************/ /******************************************************/
{ {
m_FootprintList->OnLeftClick(event); m_FootprintList->OnLeftClick( event );
} }
/******************************************************/ /******************************************************/
void WinEDA_CvpcbFrame::OnLeftDClick(wxListEvent& event) void WinEDA_CvpcbFrame::OnLeftDClick( wxListEvent& event )
/******************************************************/ /******************************************************/
{ {
m_FootprintList->OnLeftDClick(event); m_FootprintList->OnLeftDClick( event );
} }
/*************************************************************/ /*************************************************************/
void WinEDA_CvpcbFrame::OnSelectComponent(wxListEvent& event) void WinEDA_CvpcbFrame::OnSelectComponent( wxListEvent& event )
/*************************************************************/ /*************************************************************/
{ {
STORECMP * Component; STORECMP* Component;
int selection; int selection;
if ( ! m_HToolBar->GetToolState(ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST) ) if( !m_HToolBar->GetToolState( ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST ) )
{ {
m_FootprintList->SetActiveFootprintList(TRUE, TRUE); m_FootprintList->SetActiveFootprintList( TRUE, TRUE );
return; return;
} }
selection = m_ListCmp->GetSelection(); selection = m_ListCmp->GetSelection();
if(selection < 0) if( selection < 0 )
{ {
m_FootprintList->SetActiveFootprintList(TRUE, TRUE); m_FootprintList->SetActiveFootprintList( TRUE, TRUE );
return; return;
} }
Component = g_BaseListeCmp; Component = g_BaseListeCmp;
for (int ii = 0 ; Component != NULL; Component = Component->Pnext) for( int ii = 0; Component != NULL; Component = Component->Pnext )
{ {
if( ii == selection ) break; if( ii == selection )
ii ++; break;
ii++;
} }
if ( Component == NULL ) if( Component == NULL )
{ {
m_FootprintList->SetActiveFootprintList(TRUE, TRUE); m_FootprintList->SetActiveFootprintList( TRUE, TRUE );
return; return;
} }
m_FootprintList->SetFootprintFilteredList(Component); m_FootprintList->SetFootprintFilteredList( Component );
} }
/************************************************************************/ /************************************************************************/
void WinEDA_CvpcbFrame::OnSelectFilteringFootprint(wxCommandEvent & event) void WinEDA_CvpcbFrame::OnSelectFilteringFootprint( wxCommandEvent& event )
/************************************************************************/ /************************************************************************/
/* Select full/filtered footprint display on tool click /* Select full/filtered footprint display on tool click
*/ */
{ {
wxListEvent l_event; wxListEvent l_event;
OnSelectComponent(l_event);
}
OnSelectComponent( l_event );
}
...@@ -97,6 +97,81 @@ public: ...@@ -97,6 +97,81 @@ public:
}; };
/**
* Class DRC_LIST_UNCONNECTED
* is an implementation of the interface named DRC_ITEM_LIST which uses
* a vector of pointers to DRC_ITEMs to fulfill the interface. No ownership is taken of the
* vector, which will reside in class DRC
*/
class DRC_LIST_UNCONNECTED : public DRC_ITEM_LIST
{
DRC_LIST* m_vector;
public:
DRC_LIST_UNCONNECTED( DRC_LIST* aList ) :
m_vector(aList)
{
}
/* no destructor since we do not own anything to delete, not even the BOARD.
~DRC_LIST_UNCONNECTED() {}
*/
//-----<Interface DRC_ITEM_LIST>---------------------------------------
void DeleteAllItems()
{
if( m_vector )
{
for( unsigned i=0; i<m_vector->size(); ++i )
delete (*m_vector)[i];
m_vector->clear();
}
}
const DRC_ITEM* GetItem( int aIndex )
{
if( m_vector && (unsigned)aIndex < m_vector->size() )
{
const DRC_ITEM* item = (*m_vector)[aIndex];
return item;
}
return NULL;
}
void DeleteItem( int aIndex )
{
if( m_vector && (unsigned)aIndex < m_vector->size() )
{
delete (*m_vector)[aIndex];
m_vector->erase( m_vector->begin()+aIndex );
}
}
/**
* Function GetCount
* returns the number of items in the list.
*/
int GetCount()
{
if( m_vector )
{
return m_vector->size();
}
return 0;
}
//-----</Interface DRC_ITEM_LIST>--------------------------------------
};
/** /**
* Class DRCLISTBOX * Class DRCLISTBOX
* is used to display a DRC_ITEM_LIST. * is used to display a DRC_ITEM_LIST.
...@@ -192,14 +267,15 @@ public: ...@@ -192,14 +267,15 @@ public:
{ {
if( m_list ) if( m_list )
{ {
int selection = GetSelection();
m_list->DeleteItem( aIndex ); m_list->DeleteItem( aIndex );
int count = m_list->GetCount(); int count = m_list->GetCount();
SetItemCount( count ); SetItemCount( count );
if( aIndex < count ) // if old selection >= new count
SetSelection( aIndex ); if( selection >= count )
else SetSelection( count-1 ); // -1 is "no selection"
SetSelection( aIndex-1 ); // -1 is no selection
Refresh(); Refresh();
} }
} }
...@@ -283,9 +359,6 @@ DrcDialog::DrcDialog( DRC* aTester, WinEDA_PcbFrame* parent, ...@@ -283,9 +359,6 @@ DrcDialog::DrcDialog( DRC* aTester, WinEDA_PcbFrame* parent,
m_Parent = parent; m_Parent = parent;
Create(parent, id, caption, pos, size, style); Create(parent, id, caption, pos, size, style);
PutValueInLocalUnits( *m_SetClearance, g_DesignSettings.m_TrackClearence,
m_Parent->m_InternalUnits );
} }
/*! /*!
...@@ -556,7 +629,7 @@ void DrcDialog::OnStartdrcClick( wxCommandEvent& event ) ...@@ -556,7 +629,7 @@ void DrcDialog::OnStartdrcClick( wxCommandEvent& event )
SetCursor( wxCursor( wxCURSOR_WAIT ) ); SetCursor( wxCursor( wxCURSOR_WAIT ) );
wxYield(); // process the cursor change event and the redraw. wxYield(); // attempt to process the cursor change
// run all the tests, with no UI at this time. // run all the tests, with no UI at this time.
m_tester->RunTests(); m_tester->RunTests();
...@@ -566,12 +639,19 @@ void DrcDialog::OnStartdrcClick( wxCommandEvent& event ) ...@@ -566,12 +639,19 @@ void DrcDialog::OnStartdrcClick( wxCommandEvent& event )
{ {
FILE* fp = wxFopen( reportName, wxT( "w" ) ); FILE* fp = wxFopen( reportName, wxT( "w" ) );
m_tester->WriteReport( fp ); writeReport( fp );
fclose(fp); fclose(fp);
// @todo put up message box saying we created the report wxString msg;
//msg.Printf( _( "Report file <%s> created\n" ), s_RptFilename.GetData() );
msg.Printf( _( "Report file \"%s\" created" ), reportName.GetData() );
wxString caption( _("Disk File Report Completed") );
wxMessageDialog popupWindow( this, msg, caption );
popupWindow.ShowModal();
} }
SetCursor( wxCursor( wxCURSOR_ARROW ) ); SetCursor( wxCursor( wxCURSOR_ARROW ) );
...@@ -624,9 +704,8 @@ void DrcDialog::OnListUnconnectedClick( wxCommandEvent& event ) ...@@ -624,9 +704,8 @@ void DrcDialog::OnListUnconnectedClick( wxCommandEvent& event )
SetCursor( wxCursor( wxCURSOR_WAIT ) ); SetCursor( wxCursor( wxCURSOR_WAIT ) );
wxYield(); wxYield(); // attempt to process the cursor change
// run all the tests, with no UI at this time.
m_tester->ListUnconnectedPads(); m_tester->ListUnconnectedPads();
// Generate the report // Generate the report
...@@ -634,19 +713,26 @@ void DrcDialog::OnListUnconnectedClick( wxCommandEvent& event ) ...@@ -634,19 +713,26 @@ void DrcDialog::OnListUnconnectedClick( wxCommandEvent& event )
{ {
FILE* fp = wxFopen( reportName, wxT( "w" ) ); FILE* fp = wxFopen( reportName, wxT( "w" ) );
m_tester->WriteReport( fp ); writeReport( fp );
fclose(fp); fclose(fp);
// @todo put up message box saying we created the report wxString msg;
//msg.Printf( _( "Report file <%s> created\n" ), s_RptFilename.GetData() );
msg.Printf( _( "Report file \"%s\" created" ), reportName.GetData() );
wxString caption( _("Disk File Report Completed") );
wxMessageDialog popupWindow( this, msg, caption );
popupWindow.ShowModal();
} }
SetCursor( wxCursor( wxCURSOR_ARROW ) ); SetCursor( wxCursor( wxCURSOR_ARROW ) );
// @todo set the list counts in the DRCLISTITEMS here. /* there is currently nothing visible on the DrawPanel for unconnected pads
RedrawDrawPanel(); RedrawDrawPanel();
*/
} }
/*! /*!
...@@ -690,8 +776,7 @@ void DrcDialog::OnOkClick( wxCommandEvent& event ) ...@@ -690,8 +776,7 @@ void DrcDialog::OnOkClick( wxCommandEvent& event )
#endif #endif
SetReturnCode( wxID_OK ); SetReturnCode( wxID_OK );
m_tester->DestroyDialog(); m_tester->DestroyDialog( wxID_OK );
// event.Skip();
} }
...@@ -706,8 +791,7 @@ void DrcDialog::OnCancelClick( wxCommandEvent& event ) ...@@ -706,8 +791,7 @@ void DrcDialog::OnCancelClick( wxCommandEvent& event )
#endif #endif
SetReturnCode( wxID_CANCEL ); SetReturnCode( wxID_CANCEL );
m_tester->DestroyDialog(); m_tester->DestroyDialog( wxID_CANCEL );
// event.Skip();
} }
...@@ -759,6 +843,10 @@ void DrcDialog::OnInitDialog( wxInitDialogEvent& event ) ...@@ -759,6 +843,10 @@ void DrcDialog::OnInitDialog( wxInitDialogEvent& event )
void DrcDialog::OnLeftDClickClearance( wxMouseEvent& event ) void DrcDialog::OnLeftDClickClearance( wxMouseEvent& event )
{ {
event.Skip();
// I am assuming that the double click actually changed the selected item.
// please verify this.
int selection = m_ClearanceListBox->GetSelection(); int selection = m_ClearanceListBox->GetSelection();
if( selection != wxNOT_FOUND ) if( selection != wxNOT_FOUND )
...@@ -769,18 +857,20 @@ void DrcDialog::OnLeftDClickClearance( wxMouseEvent& event ) ...@@ -769,18 +857,20 @@ void DrcDialog::OnLeftDClickClearance( wxMouseEvent& event )
if( item ) if( item )
{ {
// after the goto, process a button OK command later. // after the goto, process a button OK command later.
/*
wxCommandEvent cmd( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ); wxCommandEvent cmd( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK );
::wxPostEvent( GetEventHandler(), cmd ); ::wxPostEvent( GetEventHandler(), cmd );
*/
m_Parent->CursorGoto( item->GetPosition() ); m_Parent->CursorGoto( item->GetPosition() );
}
}
// On linux, the double click is being propagated to the parent. The // turn control over to m_Parent, hide this DrcDialog window,
// call to StopPropagation was an attempt to prevent this. // no destruction so we can preserve listbox cursor
Hide();
event.StopPropagation(); // we handled the double click event here. event.StopPropagation(); // still get the popup window.
// well that didn't work, we still get a popup menu }
}
} }
...@@ -812,28 +902,28 @@ void DrcDialog::OnRightUpClearance( wxMouseEvent& event ) ...@@ -812,28 +902,28 @@ void DrcDialog::OnRightUpClearance( wxMouseEvent& event )
void DrcDialog::OnLeftDClickUnconnected( wxMouseEvent& event ) void DrcDialog::OnLeftDClickUnconnected( wxMouseEvent& event )
{ {
event.Skip();
// I am assuming that the double click actually changed the selected item.
// please verify this.
int selection = m_UnconnectedListBox->GetSelection(); int selection = m_UnconnectedListBox->GetSelection();
if( selection != wxNOT_FOUND ) if( selection != wxNOT_FOUND )
{ {
// Find the selected DRC_ITEM in the DRC, position cursor there. // Find the selected DRC_ITEM in the listbox, position cursor there,
// Then close the dialog. // at the first of the two pads.
// Then hide the dialog.
const DRC_ITEM* item = m_UnconnectedListBox->GetItem( selection ); const DRC_ITEM* item = m_UnconnectedListBox->GetItem( selection );
if( item ) if( item )
{ {
// after the goto, process a button OK command later.
wxCommandEvent cmd( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK );
::wxPostEvent( GetEventHandler(), cmd );
m_Parent->CursorGoto( item->GetPosition() ); m_Parent->CursorGoto( item->GetPosition() );
}
}
// On linux, the double click is being propagated to the parent. The Hide();
// call to StopPropagation was an attempt to prevent this.
event.StopPropagation(); // we handled the double click event here. // intermittently, still get the popup window, even with this.
// well that didn't work, we still get a popup menu event.StopPropagation();
}
}
} }
...@@ -879,6 +969,33 @@ void DrcDialog::DelDRCMarkers() ...@@ -879,6 +969,33 @@ void DrcDialog::DelDRCMarkers()
} }
void DrcDialog::writeReport( FILE* fp )
{
int count;
fprintf( fp, "** Drc report for %s **\n",
CONV_TO_UTF8( m_Parent->GetScreen()->m_FileName ) );
char line[256];
fprintf( fp, "** Created on %s **\n", DateAndTime( line ) ); //@todo make DateAndTime use localtime, not gmtime
count = m_ClearanceListBox->GetItemCount();
fprintf( fp, "\n** Found %d DRC errors **\n", count );
for( int i=0; i<count; ++i )
fprintf( fp, m_ClearanceListBox->GetItem(i)->ShowReport().mb_str() );
count = m_UnconnectedListBox->GetItemCount();
fprintf( fp, "\n** Found %d unconnected pads **\n", count );
for( int i=0; i<count; ++i )
fprintf( fp, m_UnconnectedListBox->GetItem(i)->ShowReport().mb_str() );
fprintf( fp, "\n** End of Report **\n" );
}
/*! /*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DELETE_ONE * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DELETE_ONE
...@@ -895,6 +1012,8 @@ void DrcDialog::OnDeleteOneClick( wxCommandEvent& event ) ...@@ -895,6 +1012,8 @@ void DrcDialog::OnDeleteOneClick( wxCommandEvent& event )
if( selectedIndex != wxNOT_FOUND ) if( selectedIndex != wxNOT_FOUND )
{ {
m_ClearanceListBox->DeleteItem( selectedIndex ); m_ClearanceListBox->DeleteItem( selectedIndex );
// redraw the pcb
RedrawDrawPanel(); RedrawDrawPanel();
} }
} }
...@@ -905,7 +1024,10 @@ void DrcDialog::OnDeleteOneClick( wxCommandEvent& event ) ...@@ -905,7 +1024,10 @@ void DrcDialog::OnDeleteOneClick( wxCommandEvent& event )
if( selectedIndex != wxNOT_FOUND ) if( selectedIndex != wxNOT_FOUND )
{ {
m_UnconnectedListBox->DeleteItem( selectedIndex ); m_UnconnectedListBox->DeleteItem( selectedIndex );
/* these unconnected DRC_ITEMs are not currently visible on the pcb
RedrawDrawPanel(); RedrawDrawPanel();
*/
} }
} }
......
...@@ -85,6 +85,16 @@ class DrcDialog: public wxDialog ...@@ -85,6 +85,16 @@ class DrcDialog: public wxDialog
DECLARE_DYNAMIC_CLASS( DrcDialog ) DECLARE_DYNAMIC_CLASS( DrcDialog )
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
/**
* Function writeReport
* outputs the MARKER items and unconnecte DRC_ITEMs with commentary to an
* open text file.
* @param fpOut The text file to write the report to.
*/
void writeReport( FILE* fpOut );
public: public:
/// Constructors /// Constructors
DrcDialog( ); DrcDialog( );
......
...@@ -44,15 +44,9 @@ ...@@ -44,15 +44,9 @@
#include "dialog_drc.cpp" #include "dialog_drc.cpp"
#define EC_INC // ++m_errorCount don't need this anymore, vector counts
/******************************************************/ /******************************************************/
void WinEDA_PcbFrame::Install_Test_DRC_Frame( wxDC* DC ) void WinEDA_PcbFrame::Install_Test_DRC_Frame( wxDC* DC )
/******************************************************/ /******************************************************/
/* install a dialog box to handle the general DRC control
*/
{ {
m_drc->ShowDialog(); m_drc->ShowDialog();
} }
...@@ -63,24 +57,41 @@ void DRC::ShowDialog() ...@@ -63,24 +57,41 @@ void DRC::ShowDialog()
if( !m_ui ) if( !m_ui )
{ {
m_ui = new DrcDialog( this, m_mainWindow ); m_ui = new DrcDialog( this, m_mainWindow );
}
updatePointers(); updatePointers();
// copy data retained in this DRC object into the m_ui DrcPanel:
PutValueInLocalUnits( *m_ui->m_SetClearance, g_DesignSettings.m_TrackClearence,
m_mainWindow->m_InternalUnits );;
// @todo enter retentitive member data into the DrcDialog here m_ui->m_Pad2PadTestCtrl->SetValue( m_doPad2PadTest );
m_ui->m_ZonesTestCtrl->SetValue( m_doZonesTest );
m_ui->m_UnconnectedTestCtrl->SetValue( m_doUnconnectedTest );
m_ui->Show(true); m_ui->m_CreateRptCtrl->SetValue( m_doCreateRptFile );
m_ui->m_RptFilenameCtrl->SetValue( m_rptFilename );
}
else
updatePointers();
// @todo capture the UI entered data into this DRC object. BUT in the OK handler m_ui->Show(true);
} }
void DRC::DestroyDialog() void DRC::DestroyDialog( int aReason )
{ {
if( m_ui ) if( m_ui )
{ {
if( aReason == wxID_OK )
{
// if user clicked OK, save his choices in this DRC object.
m_doCreateRptFile = m_ui->m_CreateRptCtrl->GetValue();
m_doPad2PadTest = m_ui->m_Pad2PadTestCtrl->GetValue();
m_doZonesTest = m_ui->m_ZonesTestCtrl->GetValue();
m_doUnconnectedTest = m_ui->m_UnconnectedTestCtrl->GetValue();
m_rptFilename = m_ui->m_RptFilenameCtrl->GetValue();
}
m_ui->Destroy(); m_ui->Destroy();
m_ui = 0; m_ui = 0;
} }
...@@ -103,7 +114,6 @@ DRC::DRC( WinEDA_PcbFrame* aPcbWindow ) ...@@ -103,7 +114,6 @@ DRC::DRC( WinEDA_PcbFrame* aPcbWindow )
// m_rptFilename set to empty by its constructor // m_rptFilename set to empty by its constructor
//m_errorCount = 0;
m_currentMarker = 0; m_currentMarker = 0;
m_spotcx = 0; m_spotcx = 0;
...@@ -119,10 +129,15 @@ DRC::DRC( WinEDA_PcbFrame* aPcbWindow ) ...@@ -119,10 +129,15 @@ DRC::DRC( WinEDA_PcbFrame* aPcbWindow )
m_xcliphi = 0; m_xcliphi = 0;
m_ycliphi = 0; m_ycliphi = 0;
m_unconnectedCount = 0;
m_drawPanel = 0; m_drawPanel = 0;
} }
DRC::~DRC()
{
// maybe someday look at pointainer.h <- google for "pointainer.h"
for( unsigned i=0; i<m_unconnected.size(); ++i )
delete m_unconnected[i];
}
/***********************************************************************/ /***********************************************************************/
int DRC::Drc( TRACK* aRefSegm, TRACK* aList ) int DRC::Drc( TRACK* aRefSegm, TRACK* aList )
...@@ -142,36 +157,9 @@ int DRC::Drc( TRACK* aRefSegm, TRACK* aList ) ...@@ -142,36 +157,9 @@ int DRC::Drc( TRACK* aRefSegm, TRACK* aList )
} }
void DRC::WriteReport( FILE* fp )
{
fprintf( fp, "** Drc report for %s **\n",
CONV_TO_UTF8( m_mainWindow->GetScreen()->m_FileName ) );
char line[256];
fprintf( fp, "** Created on %s **\n", DateAndTime( line ) );
fprintf( fp, "** Found %d DRC errors **\n", m_pcb->GetMARKERCount() );
for( int i=0; i<m_pcb->GetMARKERCount(); ++i )
fprintf( fp, m_pcb->GetMARKER(i)->GetReporter().ShowReport().mb_str() );
// @todo: the unconnected report comes here:
/*
for( int i=0; i<m_pcb->GetOPENNETCount(); ++i )
fprintf( fp, m_pcb->GetOPENNET(i)->GetReporter().ShowReport().mb_str() );
*/
fprintf( fp, "** End of Report **\n" );
}
void DRC::RunTests() void DRC::RunTests()
{ {
// erase the MARKERs here. // someone should have cleared the two lists before calling this.
m_pcb->DeleteMARKERs();
// test pad to pad clearances, nothing to do with tracks, vias or zones. // test pad to pad clearances, nothing to do with tracks, vias or zones.
if( m_doPad2PadTest ) if( m_doPad2PadTest )
...@@ -188,7 +176,7 @@ void DRC::RunTests() ...@@ -188,7 +176,7 @@ void DRC::RunTests()
if( m_doUnconnectedTest ) if( m_doUnconnectedTest )
testUnconnected(); testUnconnected();
// update the listboxes // update the m_ui listboxes
updatePointers(); updatePointers();
} }
...@@ -198,10 +186,10 @@ void DRC::RunTests() ...@@ -198,10 +186,10 @@ void DRC::RunTests()
void DRC::ListUnconnectedPads() void DRC::ListUnconnectedPads()
/***************************************************************/ /***************************************************************/
{ {
// erase the MARKERs here.
m_pcb->DeleteMARKERs();
testUnconnected(); testUnconnected();
// update the m_ui listboxes
updatePointers();
} }
...@@ -212,8 +200,9 @@ void DRC::updatePointers() ...@@ -212,8 +200,9 @@ void DRC::updatePointers()
m_pcb = m_mainWindow->m_Pcb; m_pcb = m_mainWindow->m_Pcb;
m_ui->m_ClearanceListBox->SetList( new DRC_LIST_MARKERS( m_pcb ) ); m_ui->m_ClearanceListBox->SetList( new DRC_LIST_MARKERS( m_pcb ) );
}
m_ui->m_UnconnectedListBox->SetList( new DRC_LIST_UNCONNECTED( &m_unconnected ) );
}
void DRC::testTracks() void DRC::testTracks()
...@@ -273,22 +262,20 @@ void DRC::testUnconnected() ...@@ -273,22 +262,20 @@ void DRC::testUnconnected()
if( m_pcb->m_Ratsnest == NULL ) if( m_pcb->m_Ratsnest == NULL )
return; return;
m_unconnectedCount = 0;
CHEVELU* rat = m_pcb->m_Ratsnest; CHEVELU* rat = m_pcb->m_Ratsnest;
for( int i=0; i<m_pcb->GetNumRatsnests(); ++i, ++rat ) for( int i=0; i<m_pcb->GetNumRatsnests(); ++i, ++rat )
{ {
if( (rat->status & CH_ACTIF) == 0 ) if( (rat->status & CH_ACTIF) == 0 )
continue; continue;
m_unconnectedCount++;
D_PAD* padStart = rat->pad_start; D_PAD* padStart = rat->pad_start;
D_PAD* padEnd = rat->pad_end; D_PAD* padEnd = rat->pad_end;
MARKER* marker = fillMarker( padStart, padEnd, DRCE_UNCONNECTED_PADS, NULL ); DRC_ITEM* uncItem = new DRC_ITEM( DRCE_UNCONNECTED_PADS, padStart->GetPosition(),
padStart->MenuText(m_pcb), padEnd->MenuText(m_pcb),
padStart->GetPosition(), padEnd->GetPosition() );
m_pcb->Add( marker ); m_unconnected.push_back( uncItem );
} }
} }
...@@ -466,7 +453,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) ...@@ -466,7 +453,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
if( !checkClearanceSegmToPad( &pseudo_pad, w_dist, if( !checkClearanceSegmToPad( &pseudo_pad, w_dist,
g_DesignSettings.m_TrackClearence ) ) g_DesignSettings.m_TrackClearence ) )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, pad, m_currentMarker = fillMarker( aRefSeg, pad,
DRCE_TRACK_NEAR_THROUGH_HOLE, m_currentMarker ); DRCE_TRACK_NEAR_THROUGH_HOLE, m_currentMarker );
return false; return false;
...@@ -487,7 +473,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) ...@@ -487,7 +473,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
m_spotcy = shape_pos.y - org_Y; m_spotcy = shape_pos.y - org_Y;
if( !checkClearanceSegmToPad( pad, w_dist, g_DesignSettings.m_TrackClearence ) ) if( !checkClearanceSegmToPad( pad, w_dist, g_DesignSettings.m_TrackClearence ) )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, pad, m_currentMarker = fillMarker( aRefSeg, pad,
DRCE_TRACK_NEAR_PAD, m_currentMarker ); DRCE_TRACK_NEAR_PAD, m_currentMarker );
return false; return false;
...@@ -543,7 +528,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) ...@@ -543,7 +528,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
// Test distance between two vias // Test distance between two vias
if( (int) hypot( x0, y0 ) < w_dist ) if( (int) hypot( x0, y0 ) < w_dist )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, track, m_currentMarker = fillMarker( aRefSeg, track,
DRCE_VIA_NEAR_VIA, m_currentMarker ); DRCE_VIA_NEAR_VIA, m_currentMarker );
return false; return false;
...@@ -560,7 +544,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) ...@@ -560,7 +544,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
if( !checkMarginToCircle( x0, y0, w_dist, dx ) ) if( !checkMarginToCircle( x0, y0, w_dist, dx ) )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, track, m_currentMarker = fillMarker( aRefSeg, track,
DRCE_VIA_NEAR_TRACK, m_currentMarker ); DRCE_VIA_NEAR_TRACK, m_currentMarker );
return false; return false;
...@@ -587,7 +570,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) ...@@ -587,7 +570,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
if( checkMarginToCircle( x0, y0, w_dist, m_segmLength ) ) if( checkMarginToCircle( x0, y0, w_dist, m_segmLength ) )
continue; continue;
EC_INC;
m_currentMarker = fillMarker( aRefSeg, track, m_currentMarker = fillMarker( aRefSeg, track,
DRCE_TRACK_NEAR_VIA, m_currentMarker ); DRCE_TRACK_NEAR_VIA, m_currentMarker );
return false; return false;
...@@ -611,14 +593,12 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) ...@@ -611,14 +593,12 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
/* Fine test : we consider the rounded shape of the ends */ /* Fine test : we consider the rounded shape of the ends */
if( x0 >= 0 && x0 <= m_segmLength ) if( x0 >= 0 && x0 <= m_segmLength )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, track, m_currentMarker = fillMarker( aRefSeg, track,
DRCE_TRACK_ENDS1, m_currentMarker ); DRCE_TRACK_ENDS1, m_currentMarker );
return false; return false;
} }
if( !checkMarginToCircle( x0, y0, w_dist, m_segmLength ) ) if( !checkMarginToCircle( x0, y0, w_dist, m_segmLength ) )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, track, m_currentMarker = fillMarker( aRefSeg, track,
DRCE_TRACK_ENDS2, m_currentMarker ); DRCE_TRACK_ENDS2, m_currentMarker );
return false; return false;
...@@ -629,14 +609,12 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) ...@@ -629,14 +609,12 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
/* Fine test : we consider the rounded shape of the ends */ /* Fine test : we consider the rounded shape of the ends */
if( xf >= 0 && xf <= m_segmLength ) if( xf >= 0 && xf <= m_segmLength )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, track, m_currentMarker = fillMarker( aRefSeg, track,
DRCE_TRACK_ENDS3, m_currentMarker ); DRCE_TRACK_ENDS3, m_currentMarker );
return false; return false;
} }
if( !checkMarginToCircle( xf, yf, w_dist, m_segmLength ) ) if( !checkMarginToCircle( xf, yf, w_dist, m_segmLength ) )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, track, m_currentMarker = fillMarker( aRefSeg, track,
DRCE_TRACK_ENDS4, m_currentMarker ); DRCE_TRACK_ENDS4, m_currentMarker );
return false; return false;
...@@ -645,7 +623,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) ...@@ -645,7 +623,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
if( x0 <=0 && xf >= 0 ) if( x0 <=0 && xf >= 0 )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, track, m_currentMarker = fillMarker( aRefSeg, track,
DRCE_TRACK_UNKNOWN1, m_currentMarker ); DRCE_TRACK_UNKNOWN1, m_currentMarker );
return false; return false;
...@@ -661,7 +638,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) ...@@ -661,7 +638,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
EXCHG( y0, yf ); EXCHG( y0, yf );
if( (y0 < 0) && (yf > 0) ) if( (y0 < 0) && (yf > 0) )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, track, m_currentMarker = fillMarker( aRefSeg, track,
DRCE_TRACKS_CROSSING, m_currentMarker ); DRCE_TRACKS_CROSSING, m_currentMarker );
return false; return false;
...@@ -670,14 +646,12 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) ...@@ -670,14 +646,12 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
// At this point the drc error is due to an end near a reference segm end // At this point the drc error is due to an end near a reference segm end
if( !checkMarginToCircle( x0, y0, w_dist, m_segmLength ) ) if( !checkMarginToCircle( x0, y0, w_dist, m_segmLength ) )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, track, m_currentMarker = fillMarker( aRefSeg, track,
DRCE_ENDS_PROBLEM1, m_currentMarker ); DRCE_ENDS_PROBLEM1, m_currentMarker );
return false; return false;
} }
if( !checkMarginToCircle( xf, yf, w_dist, m_segmLength ) ) if( !checkMarginToCircle( xf, yf, w_dist, m_segmLength ) )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, track, m_currentMarker = fillMarker( aRefSeg, track,
DRCE_ENDS_PROBLEM2, m_currentMarker ); DRCE_ENDS_PROBLEM2, m_currentMarker );
return false; return false;
...@@ -706,7 +680,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) ...@@ -706,7 +680,6 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
if( !checkLine( x0, y0, xf, yf ) ) if( !checkLine( x0, y0, xf, yf ) )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, track, m_currentMarker = fillMarker( aRefSeg, track,
DRCE_ENDS_PROBLEM3, m_currentMarker ); DRCE_ENDS_PROBLEM3, m_currentMarker );
return false; return false;
...@@ -742,14 +715,12 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart ) ...@@ -742,14 +715,12 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart )
RotatePoint( &rxf, &ryf, angle ); RotatePoint( &rxf, &ryf, angle );
if( !checkMarginToCircle( rx0, ry0, w_dist, dx ) ) if( !checkMarginToCircle( rx0, ry0, w_dist, dx ) )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, track, m_currentMarker = fillMarker( aRefSeg, track,
DRCE_ENDS_PROBLEM4, m_currentMarker ); DRCE_ENDS_PROBLEM4, m_currentMarker );
return false; return false;
} }
if( !checkMarginToCircle( rxf, ryf, w_dist, dx ) ) if( !checkMarginToCircle( rxf, ryf, w_dist, dx ) )
{ {
EC_INC;
m_currentMarker = fillMarker( aRefSeg, track, m_currentMarker = fillMarker( aRefSeg, track,
DRCE_ENDS_PROBLEM5, m_currentMarker ); DRCE_ENDS_PROBLEM5, m_currentMarker );
return false; return false;
...@@ -801,7 +772,6 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, LISTE_PAD* aEnd, ...@@ -801,7 +772,6 @@ bool DRC::doPadToPadsDrc( D_PAD* aRefPad, LISTE_PAD* aStart, LISTE_PAD* aEnd,
if( !checkClearancePadToPad( aRefPad, pad, g_DesignSettings.m_TrackClearence ) ) if( !checkClearancePadToPad( aRefPad, pad, g_DesignSettings.m_TrackClearence ) )
{ {
// here we have a drc error! // here we have a drc error!
EC_INC;
m_currentMarker = fillMarker( aRefPad, pad, m_currentMarker = fillMarker( aRefPad, pad,
DRCE_PAD_NEAR_PAD1, m_currentMarker ); DRCE_PAD_NEAR_PAD1, m_currentMarker );
return false; return false;
...@@ -832,16 +802,16 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, const int dist_mi ...@@ -832,16 +802,16 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, const int dist_mi
bool diag = true; bool diag = true;
/* tst rapide: si les cercles exinscrits sont distants de dist_min au moins, /* tst rapide: si les cercles exinscrits sont distants de dist_min au moins,
* il n'y a pas de risque: */ * il n'y a pas de risque: */
if( (dist - aRefPad->m_Rayon - aPad->m_Rayon) >= dist_min ) if( (dist - aRefPad->m_Rayon - aPad->m_Rayon) >= dist_min )
return OK_DRC; goto exit;
/* Ici les pads sont proches et les cercles exinxcrits sont trop proches /* Ici les pads sont proches et les cercles exinxcrits sont trop proches
* Selon les formes relatives il peut y avoir ou non erreur */ * Selon les formes relatives il peut y avoir ou non erreur */
bool swap_pads = false; bool swap_pads;
swap_pads = false;
if( (aRefPad->m_PadShape != CIRCLE) && (aPad->m_PadShape == CIRCLE) ) if( (aRefPad->m_PadShape != CIRCLE) && (aPad->m_PadShape == CIRCLE) )
swap_pads = true; swap_pads = true;
else if( (aRefPad->m_PadShape != OVALE) && (aPad->m_PadShape == OVALE) ) else if( (aRefPad->m_PadShape != OVALE) && (aPad->m_PadShape == OVALE) )
...@@ -939,6 +909,8 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, const int dist_mi ...@@ -939,6 +909,8 @@ bool DRC::checkClearancePadToPad( D_PAD* aRefPad, D_PAD* aPad, const int dist_mi
break; break;
} }
exit: // the only way out (hopefully) for simpler debugging
return diag; return diag;
} }
......
...@@ -114,7 +114,9 @@ public: ...@@ -114,7 +114,9 @@ public:
{ {
wxString ret; wxString ret;
ret.Printf( _("<b>ErrType(%d): %s</b><ul><li> %s: %s </li><li> %s: %s </li></ul>"), // an html fragment for the entire message in the listbox. feel free
// to add color if you want:
ret.Printf( _("ErrType(%d): <b>%s</b><ul><li> %s: %s </li><li> %s: %s </li></ul>"),
m_ErrorCode, m_ErrorCode,
GetErrorText().GetData(), GetErrorText().GetData(),
ShowCoord( m_APos ).GetData(), m_AText.GetData(), ShowCoord( m_APos ).GetData(), m_AText.GetData(),
...@@ -249,6 +251,8 @@ public: ...@@ -249,6 +251,8 @@ public:
}; };
typedef std::vector<DRC_ITEM*> DRC_LIST;
/** /**
* Class DRC * Class DRC
...@@ -292,14 +296,12 @@ private: ...@@ -292,14 +296,12 @@ private:
int m_xcliphi; int m_xcliphi;
int m_ycliphi; // coord de la surface de securite du segment a comparer int m_ycliphi; // coord de la surface de securite du segment a comparer
int m_unconnectedCount;
WinEDA_PcbFrame* m_mainWindow; WinEDA_PcbFrame* m_mainWindow;
WinEDA_DrawPanel* m_drawPanel; WinEDA_DrawPanel* m_drawPanel;
BOARD* m_pcb; BOARD* m_pcb;
DrcDialog* m_ui; DrcDialog* m_ui;
std::vector<DRC_ITEM> m_unconnected; DRC_LIST m_unconnected; ///< list of unconnected pads, as DRC_ITEMs
/** /**
...@@ -425,6 +427,7 @@ private: ...@@ -425,6 +427,7 @@ private:
public: public:
DRC( WinEDA_PcbFrame* aPcbWindow ); DRC( WinEDA_PcbFrame* aPcbWindow );
~DRC();
/** /**
* Function Drc * Function Drc
...@@ -466,8 +469,9 @@ public: ...@@ -466,8 +469,9 @@ public:
* Function DestroyDialog * Function DestroyDialog
* deletes this ui dialog box and zeros out its pointer to remember * deletes this ui dialog box and zeros out its pointer to remember
* the state of the dialog's existence. * the state of the dialog's existence.
* @param aReason Indication of which button was clicked to cause the destruction.
*/ */
void DestroyDialog(); void DestroyDialog( int aReason );
/** /**
...@@ -505,13 +509,6 @@ public: ...@@ -505,13 +509,6 @@ public:
*/ */
void ListUnconnectedPads(); void ListUnconnectedPads();
/**
* Function WriteReport
* outputs the MARKER items with commentary to an open text file.
* @param fpOut The text file to write the report to.
*/
void WriteReport( FILE* fpOut );
}; };
......
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