From c61cce48c0fa6f2585b0dd15951544d87e473b7b Mon Sep 17 00:00:00 2001 From: charras Date: Wed, 8 Jul 2009 15:42:45 +0000 Subject: [PATCH] More about ERC and markers in eeschema ( work in progress ) --- common/CMakeLists.txt | 1 + common/about_kicad.cpp | 2 +- common/class_marker_base.cpp | 14 + common/dialog_display_info_HTML_base.cpp | 30 + common/dialog_display_info_HTML_base.fbp | 133 ++ eeschema/CMakeLists.txt | 1 + eeschema/annotate.cpp | 26 +- eeschema/class_drc_erc_item.cpp | 70 + eeschema/class_marker_sch.cpp | 67 +- eeschema/class_marker_sch.h | 27 +- eeschema/controle.cpp | 6 +- eeschema/dialog_erc.cpp | 140 +- eeschema/dialog_erc.h | 44 +- eeschema/dialog_erc_base.cpp | 11 +- eeschema/dialog_erc_base.fbp | 25 +- eeschema/dialog_erc_base.h | 9 +- eeschema/dialog_erc_listbox.h | 117 ++ eeschema/eelibs_read_libraryfiles.cpp | 2 +- eeschema/erc.cpp | 41 +- eeschema/load_one_schematic_file.cpp | 18 +- eeschema/netform.cpp | 2 +- eeschema/onrightclick.cpp | 14 +- eeschema/schedit.cpp | 7 + include/class_drc_item.h | 32 +- include/class_marker_base.h | 19 + include/dialog_display_info_HTML_base.h | 41 + include/id.h | 2 +- include/wxEeschemaStruct.h | 4 +- internat/fr/kicad.mo | Bin 187620 -> 187621 bytes internat/fr/kicad.po | 1686 +++++++++++----------- 30 files changed, 1599 insertions(+), 992 deletions(-) create mode 100644 common/dialog_display_info_HTML_base.cpp create mode 100644 common/dialog_display_info_HTML_base.fbp create mode 100644 eeschema/class_drc_erc_item.cpp create mode 100644 eeschema/dialog_erc_listbox.h create mode 100644 include/dialog_display_info_HTML_base.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index b9cef65088..31adcaec67 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -22,6 +22,7 @@ set(COMMON_SRCS common_plotDXF_functions.cpp confirm.cpp copy_to_clipboard.cpp + dialog_display_info_HTML_base.cpp dcsvg.cpp displlst.cpp dlist.cpp diff --git a/common/about_kicad.cpp b/common/about_kicad.cpp index a1193b41c8..222b0b927a 100644 --- a/common/about_kicad.cpp +++ b/common/about_kicad.cpp @@ -8,7 +8,7 @@ #include "appl_wxstruct.h" -#define BUILD_VERSION "(20090628-unstable)" +#define BUILD_VERSION "(20090708-unstable)" #ifdef HAVE_SVN_VERSION diff --git a/common/class_marker_base.cpp b/common/class_marker_base.cpp index 8e27b9a0f4..c4e79a9376 100644 --- a/common/class_marker_base.cpp +++ b/common/class_marker_base.cpp @@ -123,6 +123,20 @@ bool MARKER_BASE::HitTestMarker( const wxPoint& refPos ) return false; } +/** + * Function GetBoundingBoxMarker + * returns the orthogonal, bounding box of this object for display purposes. + * This box should be an enclosing perimeter for visible components of this + * object, and the units should be in the pcb or schematic coordinate system. + * It is OK to overestimate the size by a few counts. + */ +EDA_Rect MARKER_BASE::GetBoundingBoxMarker() +{ + wxSize Realsize = m_Size; + Realsize.x *= m_ScalingFactor; + Realsize.y *= m_ScalingFactor; + return EDA_Rect( m_Pos,Realsize ); +} /**********************************************************************/ void MARKER_BASE::DrawMarker( WinEDA_DrawPanel* aPanel, wxDC* aDC, int aDrawMode, diff --git a/common/dialog_display_info_HTML_base.cpp b/common/dialog_display_info_HTML_base.cpp new file mode 100644 index 0000000000..bdeb26f277 --- /dev/null +++ b/common/dialog_display_info_HTML_base.cpp @@ -0,0 +1,30 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 16 2008) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_display_info_HTML_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_DISPLAY_HTML_TEXT_BASE::DIALOG_DISPLAY_HTML_TEXT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bMainSizer; + bMainSizer = new wxBoxSizer( wxVERTICAL ); + + m_htmlWindow = new wxHtmlWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHW_SCROLLBAR_AUTO ); + m_htmlWindow->SetMinSize( wxSize( 400,150 ) ); + + bMainSizer->Add( m_htmlWindow, 1, wxALL|wxEXPAND, 5 ); + + this->SetSizer( bMainSizer ); + this->Layout(); +} + +DIALOG_DISPLAY_HTML_TEXT_BASE::~DIALOG_DISPLAY_HTML_TEXT_BASE() +{ +} diff --git a/common/dialog_display_info_HTML_base.fbp b/common/dialog_display_info_HTML_base.fbp new file mode 100644 index 0000000000..b14c7bb2d3 --- /dev/null +++ b/common/dialog_display_info_HTML_base.fbp @@ -0,0 +1,133 @@ + + + + + + C++ + 1 + UTF-8 + connect + dialog_display_info_HTML_base + 1000 + none + 1 + dialog_display_info_HTML + + . + + 1 + 0 + 0 + + + + + 1 + + + + 0 + wxID_ANY + + + DIALOG_DISPLAY_HTML_TEXT_BASE + + 291,165 + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bMainSizer + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 1 + + + + 1 + + + 0 + wxID_ANY + + 400,150 + m_htmlWindow + public + + + wxHW_SCROLLBAR_AUTO + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 501bb5350d..e8578fe187 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -16,6 +16,7 @@ set(EESCHEMA_SRCS class_BodyItem_Text.cpp class_drawsheet.cpp class_drawsheetpath.cpp + class_drc_erc_item.cpp class_hierarchical_PIN_sheet.cpp class_libentry.cpp class_libentry_fields.cpp diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index 9a48618d63..2e2d0734fa 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -632,7 +632,7 @@ static int ExistUnit( int aObjet, int Unit, /***************************************************************************************/ -int WinEDA_SchematicFrame::CheckAnnotate( wxTextCtrl* aMessageList, bool aOneSheetOnly ) +int WinEDA_SchematicFrame::CheckAnnotate( wxArrayString* aMessageList, bool aOneSheetOnly ) /***************************************************************************************/ /** @@ -644,7 +644,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxTextCtrl* aMessageList, bool aOneShe * part number > number of parts * different values between parts * @return errors count - * @param aMessageList = a wxTextCtrl to display merssages. If NULL, they are displyed in a wxMessageBox + * @param aMessageList = a wxArrayString to store messages. If NULL, they are displayed in a wxMessageBox * @param aOneSheetOnly : true = search is made only in the current sheet * false = search in whole hierarchy (usual search). */ @@ -700,8 +700,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxTextCtrl* aMessageList, bool aOneShe } if( aMessageList ) { - aMessageList->AppendText( msg ); - aMessageList->AppendText( wxT( "\n" ) ); + aMessageList->Add( msg + wxT( "\n" ) ); } else DisplayError( NULL, msg ); @@ -726,8 +725,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxTextCtrl* aMessageList, bool aOneShe msg << Buff; if( aMessageList ) { - aMessageList->AppendText( msg ); - aMessageList->AppendText( wxT( "\n" ) ); + aMessageList->Add( msg + wxT( "\n" )); } else DisplayError( NULL, msg ); @@ -769,8 +767,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxTextCtrl* aMessageList, bool aOneShe } if( aMessageList ) { - aMessageList->AppendText( msg ); - aMessageList->AppendText( wxT( "\n" ) ); + aMessageList->Add( msg + wxT( "\n" )); } else DisplayError( NULL, msg ); @@ -799,8 +796,7 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxTextCtrl* aMessageList, bool aOneShe if( aMessageList ) { - aMessageList->AppendText( msg ); - aMessageList->AppendText( wxT( "\n" ) ); + aMessageList->Add( msg + wxT( "\n" )); } else DisplayError( NULL, msg ); @@ -836,9 +832,8 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxTextCtrl* aMessageList, bool aOneShe if( aMessageList ) { - aMessageList->AppendText( msg ); - aMessageList->AppendText( wxT( "\n" ) ); - } + aMessageList->Add( msg + wxT( "\n" )); + } else DisplayError( NULL, msg ); error++; @@ -867,9 +862,8 @@ int WinEDA_SchematicFrame::CheckAnnotate( wxTextCtrl* aMessageList, bool aOneShe nextcmpref.GetData(), ComponentsList[ii + 1].m_NumRef ); if( aMessageList ) { - aMessageList->AppendText( msg ); - aMessageList->AppendText( wxT( "\n" ) ); - } + aMessageList->Add( msg + wxT( "\n" )); + } else DisplayError( NULL, msg ); error++; diff --git a/eeschema/class_drc_erc_item.cpp b/eeschema/class_drc_erc_item.cpp new file mode 100644 index 0000000000..bb86f0a5b1 --- /dev/null +++ b/eeschema/class_drc_erc_item.cpp @@ -0,0 +1,70 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 2007 Kicad Developers, see change_log.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + + +/******************************************************************/ +/* class_drc_erc_item.cpp - DRC_ITEM class functions for eeschema */ +/******************************************************************/ +#include "fctsys.h" +#include "common.h" + +#include "class_drc_item.h" +#include "erc.h" + +wxString DRC_ITEM::GetErrorText() const +{ + switch( m_ErrorCode ) + { + case ERCE_UNSPECIFIED: + return wxString( _("ERC err unspecified") ); + case ERCE_DUPLICATE_SHEET_NAME: + return wxString( _("Duplicate sheet names within a given sheet") ); + case ERCE_PIN_NOT_CONNECTED: + return wxString( _("Pin not connected (and no connect symbol found on this pin)") ); + case ERCE_PIN_NOT_DRIVEN: + return wxString( _("Pin connected to some others pins but no pin to drive it") ); + case ERCE_PIN_TO_PIN_WARNING: + return wxString( _("Confict problem between pins. Severity: warning") ); + case ERCE_PIN_TO_PIN_ERROR: + return wxString( _("Confict problem between pins. Severity: error") ); + case ERCE_HIERACHICAL_LABEL: + return wxString( _("Mismatch between hierarchical labels and pins sheets")); + case ERCE_NOCONNECT_CONNECTED: + return wxString( _("A no connect symbol is connected to more than 1 pin")); + + default: + return wxString( wxT("Unkown.") ); + } +} + + +wxString DRC_ITEM::ShowCoord( const wxPoint& aPos ) +{ + wxString ret; + wxPoint pos_in_pcb_units = aPos; + pos_in_pcb_units.x *= 10; + pos_in_pcb_units.y *= 10; + ret << pos_in_pcb_units; + return ret; +} + diff --git a/eeschema/class_marker_sch.cpp b/eeschema/class_marker_sch.cpp index 216f8fabb3..3127271012 100644 --- a/eeschema/class_marker_sch.cpp +++ b/eeschema/class_marker_sch.cpp @@ -11,11 +11,11 @@ #include "class_marker_sch.h" #include "erc.h" - +#include "dialog_display_info_HTML_base.h" /* Marker are mainly used to show an ERC error * but they could be used to give a specifi info -*/ + */ const wxChar* NameMarqueurType[] = @@ -32,15 +32,16 @@ const wxChar* NameMarqueurType[] = /* class MARKER_SCH */ /**************************/ -MARKER_SCH::MARKER_SCH( ) : +MARKER_SCH::MARKER_SCH() : SCH_ITEM( NULL, DRAW_MARKER_STRUCT_TYPE ), - MARKER_BASE( ) + MARKER_BASE() { } + MARKER_SCH::MARKER_SCH( const wxPoint& pos, const wxString& text ) : SCH_ITEM( NULL, DRAW_MARKER_STRUCT_TYPE ), - MARKER_BASE(0, pos, text, pos) + MARKER_BASE( 0, pos, text, pos ) { } @@ -52,16 +53,15 @@ MARKER_SCH::~MARKER_SCH() MARKER_SCH* MARKER_SCH::GenCopy() { - MARKER_SCH* newitem = new MARKER_SCH( GetPos(), GetErrorText() ); + MARKER_SCH* newitem = new MARKER_SCH( GetPos(), GetReporter().GetMainText() ); - newitem->SetMarkerType( GetMarkerType()); - newitem->SetErrorLevel( GetErrorLevel()); + newitem->SetMarkerType( GetMarkerType() ); + newitem->SetErrorLevel( GetErrorLevel() ); return newitem; } - #if defined(DEBUG) /** @@ -89,11 +89,12 @@ void MARKER_SCH::Show( int nestLevel, std::ostream& os ) */ bool MARKER_SCH::Save( FILE* aFile ) const { - bool success = true; - wxString msg = GetErrorText(); - if( fprintf( aFile, "Kmarq %c %-4d %-4d \"%s\" F=%X\n", - GetMarkerType() + 'A', GetPos().x, GetPos().y, - CONV_TO_UTF8( msg ), GetErrorLevel() ) == EOF ) + bool success = true; + wxString msg = GetReporter().GetMainText(); + + if( fprintf( aFile, "Kmarq %c %-4d %-4d \"%s\" F=%X T=%X\n", + GetMarkerType() + 'A', GetPos().x, GetPos().y, + CONV_TO_UTF8( msg ), GetErrorLevel(), GetReporter().GetErrorCode() ) == EOF ) { success = false; } @@ -104,19 +105,20 @@ bool MARKER_SCH::Save( FILE* aFile ) const /****************************************************************************/ void MARKER_SCH::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, - const wxPoint& aOffset, int aDrawMode, int aColor ) + const wxPoint& aOffset, int aDrawMode, int aColor ) /****************************************************************************/ { EDA_Colors color = (EDA_Colors) m_Color; - EDA_Colors tmp = color; + EDA_Colors tmp = color; + if( GetMarkerType() == MARK_ERC ) { color = (GetErrorLevel() == WAR ) ? - (EDA_Colors)g_LayerDescr.LayerColor[LAYER_ERC_WARN] : - (EDA_Colors)g_LayerDescr.LayerColor[LAYER_ERC_ERR]; + (EDA_Colors) g_LayerDescr.LayerColor[LAYER_ERC_WARN] : + (EDA_Colors) g_LayerDescr.LayerColor[LAYER_ERC_ERR]; } - if ( aColor < 0 ) + if( aColor < 0 ) m_Color = color; else m_Color = (EDA_Colors) aColor; @@ -125,3 +127,30 @@ void MARKER_SCH::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, m_Color = tmp; } + +/** + * Function GetBoundingBox + * returns the orthogonal, bounding box of this object for display purposes. + * This box should be an enclosing perimeter for visible components of this + * object, and the units should be in the pcb or schematic coordinate system. + * It is OK to overestimate the size by a few counts. + */ +EDA_Rect MARKER_SCH::GetBoundingBox() +{ + return GetBoundingBoxMarker(); +} + + +/** Function DisplayMarkerInfo() + * Displays the full info of this marker, within an HTML window + */ +void MARKER_SCH::DisplayMarkerInfo( WinEDA_SchematicFrame* aFrame ) +{ + wxString msg = GetReporter().ShowHtml(); + + DIALOG_DISPLAY_HTML_TEXT_BASE infodisplay( aFrame, -1, wxEmptyString, + wxGetMousePosition(), wxSize( 550, 130 ) ); + + infodisplay.m_htmlWindow->SetPage( msg ); + infodisplay.ShowModal(); +} diff --git a/eeschema/class_marker_sch.h b/eeschema/class_marker_sch.h index 96d1676c27..85e4d6fe8b 100644 --- a/eeschema/class_marker_sch.h +++ b/eeschema/class_marker_sch.h @@ -5,6 +5,7 @@ #ifndef _CLASS_MARKER_SCH_H_ #define _CLASS_MARKER_SCH_H_ +#include "sch_item_struct.h" #include "class_marker_base.h" /* Marker are mainly used to show an ERC error @@ -42,17 +43,6 @@ public: int aColor = -1 ); - wxString GetErrorText( ) const - { - wxString text = m_drc.GetMainText(); - return text; - } - - void SetErrorText( wxString aText) - { - SetData( m_drc.GetErrorCode(), GetPos(), aText, GetPos() ); - } - /** * Function Save * writes the data structures for this object out to a FILE in "*.sch" @@ -76,6 +66,21 @@ public: { return HitTestMarker( aPosRef ); } + + /** + * Function GetBoundingBox + * returns the orthogonal, bounding box of this object for display purposes. + * This box should be an enclosing perimeter for visible components of this + * object, and the units should be in the pcb or schematic coordinate system. + * It is OK to overestimate the size by a few counts. + */ + virtual EDA_Rect GetBoundingBox(); + + /** Function DisplayMarkerInfo() + * Displays the full info of this marker, in a HTML window + */ + void DisplayMarkerInfo(WinEDA_SchematicFrame * aFrame); + #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ); #endif diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index 4856848d6c..6641ac1f5f 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -128,11 +128,9 @@ SCH_ITEM* WinEDA_SchematicFrame:: SchematicGeneralLocateAndDisplay( const wxPoin if( DrawStruct ) { MARKER_SCH* Marker = (MARKER_SCH*) DrawStruct; - Text = Marker->GetErrorText(); - if( Text.IsEmpty() ) - Text = wxT( "???" ); + Text = Marker->GetReporter().GetErrorText(); ii = Marker->GetMarkerType(); - msg = NameMarqueurType[ii]; msg << wxT( " << " ) << Text; + msg = NameMarqueurType[ii]; msg << wxT( " " ) << Text; Affiche_Message( msg ); return DrawStruct; } diff --git a/eeschema/dialog_erc.cpp b/eeschema/dialog_erc.cpp index 38fee15fd8..db90e7f1c8 100644 --- a/eeschema/dialog_erc.cpp +++ b/eeschema/dialog_erc.cpp @@ -1,4 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// + // Name: dialog_erc.cpp // Purpose: // Author: jean-pierre Charras @@ -20,84 +21,151 @@ #include "protos.h" #include "dialog_erc.h" +#include "dialog_erc_listbox.h" #include "erc.h" BEGIN_EVENT_TABLE( DIALOG_ERC, DIALOG_ERC_BASE ) - EVT_COMMAND_RANGE(ID_MATRIX_0, - ID_MATRIX_0 + (PIN_NMAX * PIN_NMAX) - 1, - wxEVT_COMMAND_BUTTON_CLICKED, - DIALOG_ERC::ChangeErrorLevel) +EVT_COMMAND_RANGE( ID_MATRIX_0, + ID_MATRIX_0 + (PIN_NMAX * PIN_NMAX) - 1, + wxEVT_COMMAND_BUTTON_CLICKED, + DIALOG_ERC::ChangeErrorLevel ) END_EVENT_TABLE() -DIALOG_ERC::DIALOG_ERC( WinEDA_SchematicFrame* parent ) - : DIALOG_ERC_BASE(parent) +DIALOG_ERC::DIALOG_ERC( WinEDA_SchematicFrame* parent ) : + DIALOG_ERC_BASE( parent ) { - m_Parent = parent; - Init(); - - GetSizer()->SetSizeHints(this); + m_Parent = parent; + Init(); + GetSizer()->SetSizeHints( this ); } + void DIALOG_ERC::Init() { SetFocus(); - m_Initialized = FALSE; - for( int ii = 0; ii < PIN_NMAX; ii++ ) - for( int jj = 0; jj < PIN_NMAX; jj++ ) - m_ButtonList[ii][jj] = NULL; + m_Initialized = FALSE; + for( int ii = 0; ii < PIN_NMAX; ii++ ) + for( int jj = 0; jj < PIN_NMAX; jj++ ) + m_ButtonList[ii][jj] = NULL; m_WriteResultOpt->SetValue( WriteFichierERC ); - wxString num; - num.Printf(wxT("%d"), g_EESchemaVar.NbErrorErc); - m_TotalErrCount->SetLabel(num); + wxString num; + num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc ); + m_TotalErrCount->SetLabel( num ); - num.Printf(wxT("%d"), g_EESchemaVar.NbErrorErc-g_EESchemaVar.NbWarningErc); - m_LastErrCount->SetLabel(num); + num.Printf( wxT( "%d" ), g_EESchemaVar.NbErrorErc - g_EESchemaVar.NbWarningErc ); + m_LastErrCount->SetLabel( num ); - num.Printf(wxT("%d"), g_EESchemaVar.NbWarningErc); - m_LastWarningCount->SetLabel(num); + num.Printf( wxT( "%d" ), g_EESchemaVar.NbWarningErc ); + m_LastWarningCount->SetLabel( num ); - DisplayERC_MarkersList( ); + DisplayERC_MarkersList(); - // Init Panel Matrix - ReBuildMatrixPanel(); + // Init Panel Matrix + ReBuildMatrixPanel(); } + /* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERASE_DRC_MARKERS */ void DIALOG_ERC::OnEraseDrcMarkersClick( wxCommandEvent& event ) + /* Delete the old ERC markers, over the whole hierarchy */ { DeleteAllMarkers( MARK_ERC ); - m_MessagesList->Clear(); + m_MessagesList->ClearList(); m_Parent->DrawPanel->Refresh(); } + /* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL */ void DIALOG_ERC::OnCancelClick( wxCommandEvent& event ) { - EndModal(0); + EndModal( 0 ); } /* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RESET_MATRIX */ void DIALOG_ERC::OnResetMatrixClick( wxCommandEvent& event ) { - ResetDefaultERCDiag(event); + ResetDefaultERCDiag( event ); } /* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_ERC_CMP */ void DIALOG_ERC::OnErcCmpClick( wxCommandEvent& event ) { + wxBusyCursor(); m_MessagesList->Clear(); wxSafeYield(); // m_MessagesList must be redraw - TestErc( m_MessagesList); + wxArrayString messageList; + TestErc( &messageList ); +#warning m_MessagesList->Append(messageList); +} + + +// Double click on a marker info: +void DIALOG_ERC::OnLeftDClickMarkersList( wxCommandEvent& event ) +{ + int index = m_MessagesList->GetSelection(); + + if( index < 0 ) + return; + + const MARKER_SCH* marker = m_MessagesList->GetItem( (unsigned) index ); + + EndModal( 1 ); + + + // Search for the selected marker + DrawSheetPath* sheet; + bool NotFound; + wxPoint pos = marker->m_Pos; + wxPoint curpos, old_cursor_position; + + EDA_SheetList SheetList; + + NotFound = TRUE; + /* Search for the selected marker */ + for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() ) + { + SCH_ITEM*item = (SCH_ITEM*) sheet->LastDrawList(); + while( item && NotFound ) + { + if( item == marker ) + { + NotFound = FALSE; + break; + } + item = item->Next(); + } + + if( NotFound == false ) + break; + } + + + if( NotFound ) // Error + { + wxMessageBox( wxT( "OnLeftDClickMarkersList() error: Marker Not Found" ) ); + return; + } + + if( sheet != m_Parent->GetSheet() ) + { + sheet->LastScreen()->SetZoom( m_Parent->GetScreen()->GetZoom() ); + *m_Parent->m_CurrentSheet = *sheet; + ActiveScreen = m_Parent->m_CurrentSheet->LastScreen(); + m_Parent->m_CurrentSheet->UpdateAllScreenReferences(); + } + + sheet->LastScreen()->m_Curseur = pos; + m_Parent->Recadre_Trace( true ); } @@ -219,7 +287,6 @@ void DIALOG_ERC::ReBuildMatrixPanel() } - /** Function DisplayERC_MarkersList * read the schematic and display the list of ERC markers */ @@ -227,6 +294,8 @@ void DIALOG_ERC::DisplayERC_MarkersList() { EDA_SheetList SheetList; + m_MessagesList->ClearList(); + for( DrawSheetPath* Sheet = SheetList.GetFirst(); Sheet != NULL; Sheet = SheetList.GetNext() ) { SCH_ITEM* DrawStruct = Sheet->LastDrawList(); @@ -241,12 +310,12 @@ void DIALOG_ERC::DisplayERC_MarkersList() continue; /* Display diag */ - wxString msg; - msg.Printf( _( "sheet %s (loc X=%f" ", Y=%f" "): %s\n" ), - Sheet->PathHumanReadable().GetData(), - (float) Marker->m_Pos.x / 1000, (float) Marker->m_Pos.y / 1000, - Marker->GetErrorText().GetData() ); - m_MessagesList->AppendText( msg ); + +// wxString msg; +// msg.Printf( _( "sheet %s