From 410644343d1145e6cb406eb9575868e3c26eb1f5 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 6 Feb 2013 12:54:51 +0100 Subject: [PATCH] Eeschema, Libedit: fixes color artifacts when moving/placing a pin. Very minor other fixes. --- common/class_plotter.cpp | 10 +++++++ eeschema/eeredraw.cpp | 11 ------- eeschema/lib_draw_item.cpp | 12 +++++--- eeschema/lib_pin.cpp | 6 ++-- eeschema/libedit_onleftclick.cpp | 4 +-- eeschema/libeditframe.h | 7 ++++- eeschema/pinedit.cpp | 50 ++++++++++++++++---------------- include/class_title_block.h | 2 ++ include/plot_common.h | 9 +----- pcbnew/connect.cpp | 4 +-- 10 files changed, 60 insertions(+), 55 deletions(-) diff --git a/common/class_plotter.cpp b/common/class_plotter.cpp index c4e9526d45..4b25c3c50d 100644 --- a/common/class_plotter.cpp +++ b/common/class_plotter.cpp @@ -37,6 +37,16 @@ PLOTTER::PLOTTER( ) negativeMode = false; } +PLOTTER::~PLOTTER() +{ + // Emergency cleanup, but closing the file is + // usually made in EndPlot(). + if( outputFile ) + { + fclose( outputFile ); + } +} + /* * Open or create the plot file aFullFilename * return true if success, false if the file connot be created/opened diff --git a/eeschema/eeredraw.cpp b/eeschema/eeredraw.cpp index 63422085fd..7d20248404 100644 --- a/eeschema/eeredraw.cpp +++ b/eeschema/eeredraw.cpp @@ -31,18 +31,7 @@ #include #include #include -#include - #include -#include -#include -#include -#include -#include -#include -#include -#include -#include void DrawDanglingSymbol( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& pos, EDA_COLOR_T Color ) diff --git a/eeschema/lib_draw_item.cpp b/eeschema/lib_draw_item.cpp index b29d080668..faafab2c1b 100644 --- a/eeschema/lib_draw_item.cpp +++ b/eeschema/lib_draw_item.cpp @@ -114,8 +114,10 @@ bool LIB_ITEM::operator<( const LIB_ITEM& aOther ) const } -void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, EDA_COLOR_T aColor, - GR_DRAWMODE aDrawMode, void* aData, const TRANSFORM& aTransform ) +void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, + const wxPoint& aOffset, EDA_COLOR_T aColor, + GR_DRAWMODE aDrawMode, void* aData, + const TRANSFORM& aTransform ) { if( InEditMode() ) { @@ -131,7 +133,8 @@ void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, { GRSetDrawMode( aDC, g_XorMode ); drawEditGraphics( aPanel->GetClipBox(), aDC, color ); - drawGraphic( aPanel, aDC, wxPoint( 0, 0 ), color, g_XorMode, aData, aTransform ); + drawGraphic( aPanel, aDC, wxPoint( 0, 0 ), color, g_XorMode, aData, + aTransform ); } #endif // Calculate the new attributes at the current cursor position. @@ -139,7 +142,8 @@ void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, // Draw the items using the new attributes. drawEditGraphics( aPanel->GetClipBox(), aDC, color ); - drawGraphic( aPanel, aDC, wxPoint( 0, 0 ), color, g_XorMode, aData, aTransform ); + drawGraphic( aPanel, aDC, wxPoint( 0, 0 ), color, g_XorMode, aData, + aTransform ); m_Fill = fillMode; } diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index ef4f277c29..1aa0db9a13 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1091,8 +1091,10 @@ void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, if( (Color < 0) && IsSelected() ) Color = GetItemSelectedColor(); - NameColor = (EDA_COLOR_T) ( Color == -1 ? ReturnLayerColor( LAYER_PINNAM ) : Color ); - NumColor = (EDA_COLOR_T) ( Color == -1 ? ReturnLayerColor( LAYER_PINNUM ) : Color ); + NameColor = (EDA_COLOR_T) ( Color == UNSPECIFIED_COLOR ? + ReturnLayerColor( LAYER_PINNAM ) : Color ); + NumColor = (EDA_COLOR_T) ( Color == UNSPECIFIED_COLOR ? + ReturnLayerColor( LAYER_PINNUM ) : Color ); /* Create the pin num string */ ReturnPinStringNum( StringPinNum ); diff --git a/eeschema/libedit_onleftclick.cpp b/eeschema/libedit_onleftclick.cpp index a572957f5e..6e566a096c 100644 --- a/eeschema/libedit_onleftclick.cpp +++ b/eeschema/libedit_onleftclick.cpp @@ -75,7 +75,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) switch( item->Type() ) { case LIB_PIN_T: - PlacePin( DC ); + PlacePin(); break; default: @@ -89,7 +89,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) if( no_item_edited ) CreatePin( DC ); else - PlacePin( DC ); + PlacePin(); break; case ID_LIBEDIT_BODY_LINE_BUTT: diff --git a/eeschema/libeditframe.h b/eeschema/libeditframe.h index d8358874a6..75c585cda6 100644 --- a/eeschema/libeditframe.h +++ b/eeschema/libeditframe.h @@ -584,7 +584,12 @@ public: */ virtual bool HandleBlockEnd( wxDC* DC ); - void PlacePin( wxDC* DC ); + /** + * Function PlacePin + * Place at cursor location the pin currently moved (i.e. pin pointed by m_drawItem) + * (and the linked pins, if any) + */ + void PlacePin(); /** * Function GlobalSetPins diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index fd31892c07..98a5fce4ff 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -195,7 +195,7 @@ static void AbortPinMove( EDA_DRAW_PANEL* Panel, wxDC* DC ) /** * Managed cursor callback for placing component pins. */ -void LIB_EDIT_FRAME::PlacePin( wxDC* DC ) +void LIB_EDIT_FRAME::PlacePin() { LIB_PIN* Pin; LIB_PIN* CurrentPin = (LIB_PIN*) m_drawItem; @@ -268,13 +268,9 @@ another pin. Continue?" ) ); Pin->ClearFlags(); } - m_canvas->CrossHairOff( DC ); - bool showPinText = true; - CurrentPin->Draw( m_canvas, DC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, GR_DEFAULT_DRAWMODE, - &showPinText, DefaultTransform ); - m_canvas->CrossHairOn( DC ); - m_drawItem = NULL; + + m_canvas->Refresh(); } @@ -286,42 +282,44 @@ another pin. Continue?" ) ); */ void LIB_EDIT_FRAME::StartMovePin( wxDC* DC ) { - LIB_PIN* Pin; - LIB_PIN* CurrentPin = (LIB_PIN*) m_drawItem; + LIB_PIN* currentPin = (LIB_PIN*) m_drawItem; wxPoint startPos; TempCopyComponent(); // Mark pins for moving. - Pin = m_component->GetNextPin(); + LIB_PIN* pin = m_component->GetNextPin(); - for( ; Pin != NULL; Pin = m_component->GetNextPin( Pin ) ) + for( ; pin != NULL; pin = m_component->GetNextPin( pin ) ) { - Pin->ClearFlags(); + pin->ClearFlags(); - if( Pin == CurrentPin ) + if( pin == currentPin ) continue; - if( ( Pin->GetPosition() == CurrentPin->GetPosition() ) - && ( Pin->GetOrientation() == CurrentPin->GetOrientation() ) + if( ( pin->GetPosition() == currentPin->GetPosition() ) + && ( pin->GetOrientation() == currentPin->GetOrientation() ) && SynchronizePins() ) - Pin->SetFlags( IS_LINKED | IS_MOVED ); + pin->SetFlags( IS_LINKED | IS_MOVED ); } - CurrentPin->SetFlags( IS_LINKED | IS_MOVED ); - PinPreviousPos = OldPos = CurrentPin->GetPosition(); - + currentPin->SetFlags( IS_LINKED | IS_MOVED ); + PinPreviousPos = OldPos = currentPin->GetPosition(); startPos.x = OldPos.x; startPos.y = -OldPos.y; - m_canvas->CrossHairOff( DC ); +// m_canvas->CrossHairOff( DC ); GetScreen()->SetCrossHairPosition( startPos ); m_canvas->MoveCursorToCrossHair(); MSG_PANEL_ITEMS items; - CurrentPin->GetMsgPanelInfo( items ); + currentPin->GetMsgPanelInfo( items ); SetMsgPanel( items ); m_canvas->SetMouseCapture( DrawMovePin, AbortPinMove ); - m_canvas->CrossHairOn( DC ); +// m_canvas->CrossHairOn( DC ); + + // Refresh the screen to avoid color artifacts when drawing + // the pin in Edit mode and moving it from its start position + m_canvas->Refresh(); } @@ -353,7 +351,8 @@ static void DrawMovePin( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosi // Redraw pin in new position CurrentPin->SetPosition( aPanel->GetScreen()->GetCrossHairPosition( true ) ); - CurrentPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, &showPinText, DefaultTransform ); + CurrentPin->Draw( aPanel, aDC, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, + &showPinText, DefaultTransform ); PinPreviousPos = CurrentPin->GetPosition(); @@ -558,12 +557,13 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin ) wxPoint savepos = GetScreen()->GetCrossHairPosition(); m_canvas->CrossHairOff( DC ); - GetScreen()->SetCrossHairPosition( wxPoint( Pin->GetPosition().x, -Pin->GetPosition().y ) ); + GetScreen()->SetCrossHairPosition( wxPoint( Pin->GetPosition().x, + -Pin->GetPosition().y ) ); // Add this new pin in list, and creates pins for others parts if needed m_drawItem = Pin; ClearTempCopyComponent(); - PlacePin( DC ); + PlacePin(); m_lastDrawItem = Pin; GetScreen()->SetCrossHairPosition( savepos ); diff --git a/include/class_title_block.h b/include/class_title_block.h index dfd46d467e..59c66eba1b 100644 --- a/include/class_title_block.h +++ b/include/class_title_block.h @@ -44,6 +44,8 @@ class TITLE_BLOCK { public: // TITLE_BLOCK(); + virtual ~TITLE_BLOCK() {}; // a virtual dtor seems needed to build + // python lib without warning void SetTitle( const wxString& aTitle ) { m_title = aTitle; } const wxString& GetTitle() const { return m_title; } diff --git a/include/plot_common.h b/include/plot_common.h index a5cfd1dd5d..8f191506c6 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -61,14 +61,7 @@ public: PLOTTER( ); - virtual ~PLOTTER() - { - // Emergency cleanup - if( outputFile ) - { - fclose( outputFile ); - } - } + virtual ~PLOTTER(); /** * Returns the effective plot engine in use. It's not very OO but for diff --git a/pcbnew/connect.cpp b/pcbnew/connect.cpp index d95995dc73..04a9c7045f 100644 --- a/pcbnew/connect.cpp +++ b/pcbnew/connect.cpp @@ -575,7 +575,7 @@ void CONNECTIONS::Propagate_SubNets() pad->SetSubNet( curr_pad->GetSubNet() ); } } - else // the track segment is not attached to a cluster + else // the current pad is not attached to a cluster { if( pad->GetSubNet() > 0 ) { @@ -599,7 +599,7 @@ void CONNECTIONS::Propagate_SubNets() if( curr_track ) curr_track->SetSubNet( sub_netcode ); - // Examine connections between trcaks and pads + // Examine connections between tracks and pads for( ; curr_track != NULL; curr_track = curr_track->Next() ) { // First: handling connections to pads