From 6efce74c96d34de035bc2dbca2df017f02dafefd Mon Sep 17 00:00:00 2001 From: charras Date: Wed, 13 Jan 2010 13:43:36 +0000 Subject: [PATCH] Eeschema: fixed bug when edit a component reference using the component dialog editor Code cleaning and using DrawPanel->Refresh() instead of ReDraw() when possible. --- CMakeLists.txt | 6 +-- eeschema/cleanup.cpp | 7 ++-- eeschema/controle.cpp | 9 +++-- .../dialog_edit_component_in_schematic.cpp | 6 +++ eeschema/files-io.cpp | 25 +----------- eeschema/symbdraw.cpp | 17 ++++---- eeschema/viewlib_frame.cpp | 6 +-- gerbview/controle.cpp | 6 ++- gerbview/files.cpp | 2 +- gerbview/hotkeys.cpp | 4 +- include/wxEeschemaStruct.h | 1 - pcbnew/class_netclass.cpp | 28 +++++++++++++ pcbnew/class_netclass.h | 5 +++ pcbnew/controle.cpp | 4 +- pcbnew/drc.cpp | 6 +-- pcbnew/moduleframe.cpp | 6 +-- pcbnew/modules.cpp | 40 ++++++++----------- 17 files changed, 97 insertions(+), 81 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fe7075f34..d8e4da66dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,10 +139,10 @@ check_find_package_result(OPENGL_FOUND "OpenGL") # http://www.wxwidgets.org/manuals/2.8/wx_librarieslist.html if( KICAD_AUIMANAGER OR KICAD_AUITOOLBAR ) - find_package(wxWidgets COMPONENTS gl html adv core net base aui QUIET) -# find_package(wxWidgets COMPONENTS gl html adv core net base QUIET) + find_package(wxWidgets COMPONENTS gl aui adv html core net base QUIET) +# find_package(wxWidgets COMPONENTS gl adv html core net base QUIET) else( KICAD_AUIMANAGER OR KICAD_AUITOOLBAR ) - find_package(wxWidgets COMPONENTS gl html adv core net base QUIET) + find_package(wxWidgets COMPONENTS gl adv html core net base QUIET) endif( KICAD_AUIMANAGER OR KICAD_AUITOOLBAR ) check_find_package_result(wxWidgets_FOUND "wxWidgets") diff --git a/eeschema/cleanup.cpp b/eeschema/cleanup.cpp index ed009958e0..c654c06152 100644 --- a/eeschema/cleanup.cpp +++ b/eeschema/cleanup.cpp @@ -28,10 +28,6 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC ) int flag; bool Modify = FALSE; - WinEDA_SchematicFrame* frame; - - frame = (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow(); - DrawList = EEDrawList; for( ; DrawList != NULL; DrawList = DrawList->Next() ) { @@ -63,7 +59,10 @@ bool SCH_SCREEN::SchematicCleanUp( wxDC* DC ) } } + WinEDA_SchematicFrame* frame; + frame = (WinEDA_SchematicFrame*) wxGetApp().GetTopWindow(); frame->TestDanglingEnds( EEDrawList, DC ); + return Modify; } diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index 61fe571f6d..3baa9b7eb9 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -279,7 +279,8 @@ void WinEDA_SchematicFrame::GeneralControle( wxDC* DC, if( screen->IsRefreshReq() ) { - RedrawActiveWindow( DC, TRUE ); + DrawPanel->Refresh( ); + wxSafeYield(); } if( oldpos != screen->m_Curseur ) @@ -372,7 +373,8 @@ void WinEDA_LibeditFrame::GeneralControle( wxDC* DC, if( screen->IsRefreshReq() ) { - RedrawActiveWindow( DC, TRUE ); + DrawPanel->Refresh( ); + wxSafeYield(); } if( oldpos != screen->m_Curseur ) @@ -464,7 +466,8 @@ void WinEDA_ViewlibFrame::GeneralControle( wxDC* DC, if( screen->IsRefreshReq() ) { - RedrawActiveWindow( DC, TRUE ); + DrawPanel->Refresh( ); + wxSafeYield(); } if( oldpos != screen->m_Curseur ) diff --git a/eeschema/dialog_edit_component_in_schematic.cpp b/eeschema/dialog_edit_component_in_schematic.cpp index da4dce1c84..96763c7ee3 100644 --- a/eeschema/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialog_edit_component_in_schematic.cpp @@ -272,6 +272,12 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick( wxCommandEvent& event // copy all the fields back, and change the length of m_Fields. m_Cmp->SetFields( m_FieldsBuf ); + + // Reference has a specific initialisation, depending on the current active sheet + // because for a given component, in a complexe hierarchy, there are more than one + // reference. + m_Cmp->SetRef( m_Parent->GetSheet(), m_FieldsBuf[REFERENCE].m_Text ); + m_Parent->GetScreen()->SetModify(); diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 3956559e1e..9fa8a26671 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -224,33 +224,10 @@ Error: %s" ), } -/* Create a new screen - * - * This screen is chained with OldScreen. The timestamp value is assigned to - * the parameter NewScreen-> TimeStamp - */ -SCH_SCREEN* WinEDA_SchematicFrame::CreateNewScreen( SCH_SCREEN* OldScreen, - int TimeStamp ) -{ - SCH_SCREEN* NewScreen; - - NewScreen = new SCH_SCREEN(); - - NewScreen->SetRefreshReq(); - if( OldScreen ) - NewScreen->m_Company = OldScreen->m_Company; - NewScreen->m_TimeStamp = TimeStamp; - - NewScreen->SetBack( OldScreen ); - - return NewScreen; -} - - /** * Save the entire project and create an archive for components. * - * The library archive name is .cache.lib + * The library archive name is -cache.lib */ void WinEDA_SchematicFrame::SaveProject() { diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index c4eeaacd25..b1cc9a9828 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -112,11 +112,14 @@ static void AbortSymbolTraceOn( WinEDA_DrawPanel* Panel, wxDC* DC ) if( item->m_Flags & IS_NEW ) { - if( item->Type() == COMPONENT_ARC_DRAW_TYPE ) - Panel->GetParent()->RedrawActiveWindow( DC, TRUE ); - else - item->Draw( Panel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL, - DefaultTransformMatrix ); + if( DC ) + { + if( item->Type() == COMPONENT_ARC_DRAW_TYPE ) + Panel->GetParent()->DrawPanel->Refresh( ); + else + item->Draw( Panel, DC, wxPoint( 0, 0 ), -1, g_XorMode, NULL, + DefaultTransformMatrix ); + } SAFE_DELETE( item ); parent->SetDrawItem( NULL ); @@ -214,13 +217,13 @@ LIB_DRAW_ITEM* WinEDA_LibeditFrame::CreateGraphicItem( LIB_COMPONENT* LibEntry, Text->m_Orient = m_textOrientation; Text->m_Pos = GetScreen()->m_Curseur; NEGATE( Text->m_Pos.y ); - + // Enter the graphic text info DrawPanel->m_IgnoreMouseEvents = true; EditSymbolText( NULL, Text ); DrawPanel->MouseToCursorSchema(); DrawPanel->m_IgnoreMouseEvents = false; - + if( Text->m_Text.IsEmpty() ) { SAFE_DELETE( Text ); diff --git a/eeschema/viewlib_frame.cpp b/eeschema/viewlib_frame.cpp index 3ee7221a01..34030fd4ce 100644 --- a/eeschema/viewlib_frame.cpp +++ b/eeschema/viewlib_frame.cpp @@ -287,9 +287,6 @@ void WinEDA_ViewlibFrame::OnSashDrag( wxSashEvent& event ) // Now, we must recalculate the position and size of subwindows wxSizeEvent SizeEv; OnSize( SizeEv ); - - // Ensure the panel is always redrawn (sometimes some garbage remains): - DrawPanel->Refresh(); } @@ -351,6 +348,9 @@ void WinEDA_ViewlibFrame::OnSize( wxSizeEvent& SizeEv ) #endif SizeEv.Skip(); + + // Ensure the panel is always redrawn (sometimes some garbage remains): + DrawPanel->Refresh(); } diff --git a/gerbview/controle.cpp b/gerbview/controle.cpp index 2dfcc7893c..f284002a0e 100644 --- a/gerbview/controle.cpp +++ b/gerbview/controle.cpp @@ -25,7 +25,8 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) if( GetScreen()->IsRefreshReq() ) { - RedrawActiveWindow( DC, TRUE ); + DrawPanel->Refresh( ); + wxSafeYield(); // We must return here, instead of proceeding. // If we let the cursor move during a refresh request, @@ -105,7 +106,8 @@ void WinEDA_GerberFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) if( GetScreen()->IsRefreshReq() ) { - RedrawActiveWindow( DC, TRUE ); + DrawPanel->Refresh( ); + wxSafeYield(); } SetToolbars(); diff --git a/gerbview/files.cpp b/gerbview/files.cpp index a1f5ac0ad4..3ab6da5c3a 100644 --- a/gerbview/files.cpp +++ b/gerbview/files.cpp @@ -65,7 +65,7 @@ void WinEDA_GerberFrame::Files_io( wxCommandEvent& event ) case ID_NEW_BOARD: Clear_Pcb( true ); Zoom_Automatique( false ); - GetScreen()->SetRefreshReq(); + DrawPanel->Refresh(); break; case ID_GERBVIEW_LOAD_DRILL_FILE: diff --git a/gerbview/hotkeys.cpp b/gerbview/hotkeys.cpp index 2ab3540d2f..4b0d714d23 100644 --- a/gerbview/hotkeys.cpp +++ b/gerbview/hotkeys.cpp @@ -7,7 +7,7 @@ #include "hotkeys.h" #include "gerbview.h" -#include "protos.h" +#include "class_drawpanel.h" /* How to add a new hotkey: * add a new id in the enum hotkey_id_commnand like MY_NEW_ID_FUNCTION. @@ -139,7 +139,7 @@ void WinEDA_GerberFrame::OnHotKey( wxDC* DC, int hotkey, case HK_SWITCH_TRACK_DISPLAY_MODE: DisplayOpt.DisplayPcbTrackFill ^= 1; DisplayOpt.DisplayPcbTrackFill &= 1; - GetScreen()->SetRefreshReq(); + DrawPanel->Refresh(); break; case HK_SWITCH_LAYER_TO_PREVIOUS: diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index 1cf1ac3854..fb2dad4b32 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -233,7 +233,6 @@ public: bool aSetFielsAttributeToVisible ); bool SaveEEFile( SCH_SCREEN* screen, int FileSave ); - SCH_SCREEN* CreateNewScreen( SCH_SCREEN* OldScreen, int TimeStamp ); // General search: diff --git a/pcbnew/class_netclass.cpp b/pcbnew/class_netclass.cpp index 1ce3ccf995..7becb44160 100644 --- a/pcbnew/class_netclass.cpp +++ b/pcbnew/class_netclass.cpp @@ -397,3 +397,31 @@ bool NETCLASS::ReadDescr( FILE* aFile, int* aLineNum ) return result; } + + +int NETCLASS::GetTrackMinWidth() const +{ + return m_Parent->m_BoardSettings->m_TrackMinWidth; +} + +int NETCLASS::GetViaMinDiameter() const +{ + return m_Parent->m_BoardSettings->m_ViasMinSize; +} + +int NETCLASS::GetViaMinDrill() const +{ + return m_Parent->m_BoardSettings->m_ViasMinDrill; +} + +int NETCLASS::GetuViaMinDiameter() const +{ + return m_Parent->m_BoardSettings->m_MicroViasMinSize; +} + +int NETCLASS::GetuViaMinDrill() const +{ + return m_Parent->m_BoardSettings->m_MicroViasMinDrill; +} + + diff --git a/pcbnew/class_netclass.h b/pcbnew/class_netclass.h index d7e022bb10..b984b9a71d 100644 --- a/pcbnew/class_netclass.h +++ b/pcbnew/class_netclass.h @@ -163,18 +163,23 @@ public: void SetClearance( int aClearance ) { m_Clearance = aClearance; } int GetTrackWidth() const { return m_TrackWidth; } + int GetTrackMinWidth() const; void SetTrackWidth( int aWidth ) { m_TrackWidth = aWidth; } int GetViaDiameter() const { return m_ViaDia; } + int GetViaMinDiameter() const; void SetViaDiameter( int aDia ) { m_ViaDia = aDia; } int GetViaDrill() const { return m_ViaDrill; } + int GetViaMinDrill() const; void SetViaDrill( int aSize ) { m_ViaDrill = aSize; } int GetuViaDiameter() const { return m_uViaDia; } + int GetuViaMinDiameter() const; void SetuViaDiameter( int aSize ) { m_uViaDia = aSize; } int GetuViaDrill() const { return m_uViaDrill; } + int GetuViaMinDrill() const; void SetuViaDrill( int aSize ) { m_uViaDrill = aSize; } diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index ed7e7b0657..5f293a81bd 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -368,10 +368,10 @@ void WinEDA_PcbFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) if( GetScreen()->IsRefreshReq() ) { - RedrawActiveWindow( DC, TRUE ); + DrawPanel->Refresh( ); + wxSafeYield(); } SetToolbars(); - UpdateStatusBar(); /* Display new cursor coordinates */ } diff --git a/pcbnew/drc.cpp b/pcbnew/drc.cpp index 6f85951fd3..baee9e7b8d 100644 --- a/pcbnew/drc.cpp +++ b/pcbnew/drc.cpp @@ -730,7 +730,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) // test if the via size is smaller than minimum if( aRefSeg->Shape() == VIA_MICROVIA ) { - if( aRefSeg->m_Width < netclass->GetuViaDiameter() ) + if( aRefSeg->m_Width < netclass->GetuViaMinDiameter() ) { m_currentMarker = fillMarker( aRefSeg, NULL, DRCE_TOO_SMALL_MICROVIA, m_currentMarker ); @@ -739,7 +739,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) } else { - if( aRefSeg->m_Width < netclass->GetViaDiameter() ) + if( aRefSeg->m_Width < netclass->GetViaMinDiameter() ) { m_currentMarker = fillMarker( aRefSeg, NULL, DRCE_TOO_SMALL_VIA, m_currentMarker ); @@ -784,7 +784,7 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) } else // This is a track segment { - if( aRefSeg->m_Width < netclass->GetTrackWidth() ) + if( aRefSeg->m_Width < netclass->GetTrackMinWidth() ) { m_currentMarker = fillMarker( aRefSeg, NULL, DRCE_TOO_SMALL_TRACK_WIDTH, m_currentMarker ); diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index 579271a4fb..7cf06f5531 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -436,7 +436,7 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) if( GetScreen()->IsRefreshReq() ) { - RedrawActiveWindow( DC, TRUE ); + DrawPanel->Refresh( ); // We must return here, instead of proceeding. // If we let the cursor move during a refresh request, @@ -515,9 +515,9 @@ void WinEDA_ModuleEditFrame::GeneralControle( wxDC* DC, wxPoint Mouse ) if( GetScreen()->IsRefreshReq() ) { - RedrawActiveWindow( DC, TRUE ); + DrawPanel->Refresh( ); + wxSafeYield(); } - SetToolbars(); UpdateStatusBar(); } diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index 9a1435a423..0b1b02890a 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -131,7 +131,7 @@ void WinEDA_PcbFrame::StartMove_Module( MODULE* module, wxDC* DC ) GetBoard()->m_Status_Pcb |= DO_NOT_SHOW_GENERAL_RASTNEST; DrawPanel->ManageCurseur = Montre_Position_Empreinte; DrawPanel->ForceCloseManageCurseur = Abort_MoveOrCopyModule; - DrawPanel->m_AutoPAN_Request = TRUE; + DrawPanel->m_AutoPAN_Request = true; // Erase the module. if( DC ) @@ -290,7 +290,7 @@ void Montre_Position_Empreinte( WinEDA_DrawPanel* panel, wxDC* DC, bool erase ) * The ratsnest and pad list are recalculated * @param module = footprint to delete * @param DC = currentDevice Context. if NULL: do not redraw new ratsnest and - * dirty rectangle + * screen * @param aPromptBeforeDeleting : if true: ask for confirmation before deleting */ bool WinEDA_PcbFrame::Delete_Module( MODULE* module, @@ -307,9 +307,9 @@ bool WinEDA_PcbFrame::Delete_Module( MODULE* module, /* Confirm module delete. */ if( aAskBeforeDeleting ) { - msg << _( "Delete Module" ) << wxT( " " ) << module->m_Reference->m_Text - << wxT( " (" ) << _( "Value " ) << module->m_Value->m_Text - << wxT( ") ?" ); + msg.Printf( _( "Delete Module %s (value %s) ?"), + GetChars(module->m_Reference->m_Text), + GetChars(module->m_Value->m_Text) ); if( !IsOK( this, msg ) ) { return FALSE; @@ -318,13 +318,6 @@ bool WinEDA_PcbFrame::Delete_Module( MODULE* module, GetScreen()->SetModify(); - /* Erase ratsnest if needed - * Dirty rectangle is not used here because usually using a XOR draw mode - * gives good results (very few artifacts) for ratsnest - */ - if( g_Show_Ratsnest ) - DrawGeneralRatsnest( DC ); - /* Remove module from list, and put it in undo command list */ m_Pcb->m_Modules.Remove( module ); module->SetState( DELETED, ON ); @@ -332,11 +325,11 @@ bool WinEDA_PcbFrame::Delete_Module( MODULE* module, Compile_Ratsnest( DC, true ); - // redraw the area where the module was + // Redraw the full screen to ensure perfect display of board and ratsnest. if( DC ) - DrawPanel->PostDirtyRect( module->GetBoundingBox() ); - RedrawActiveWindow( DC, TRUE ); - return TRUE; + DrawPanel->Refresh( ); + + return true; } @@ -493,7 +486,7 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module, Compile_Ratsnest( DC, true ); if( DC ) - RedrawActiveWindow( DC, TRUE ); + DrawPanel->Refresh( ); module->DisplayInfo( this ); @@ -502,7 +495,7 @@ void WinEDA_BasePcbFrame::Place_Module( MODULE* module, /* * Rotate the footprint angle degrees in the direction < 0. - * If incremental == TRUE, the rotation is made from the last orientation, + * If incremental == true, the rotation is made from the last orientation, * If the module is placed in the absolute orientation angle. * If DC == NULL, the component does not redraw. * Otherwise, it erases and redraws turns @@ -549,18 +542,19 @@ void WinEDA_BasePcbFrame::Rotate_Module( wxDC* DC, MODULE* module, if( DC ) { - if( !( module->m_Flags & IS_MOVED ) ) /* Rotation simple */ - { + if( !( module->m_Flags & IS_MOVED ) ) + { // not beiing moved: redraw the module and update ratsnest module->Draw( DrawPanel, DC, GR_OR ); - Compile_Ratsnest( DC, true ); } else - { + { // Beiing moved: just redraw it DrawModuleOutlines( DrawPanel, DC, module ); Dessine_Segments_Dragges( DrawPanel, DC ); } - RedrawActiveWindow( DC, TRUE ); + + if( module->m_Flags == 0 ) // module not in edit: redraw full screen + DrawPanel->Refresh( ); } }