From 3132c70e54a0c5a61110eab7662e288398145c15 Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Tue, 11 Feb 2014 21:54:30 +0000 Subject: [PATCH] * Apply Henner Zeller's patch to add connecting line from reference and labels to component position whilst moving to help identify which component the reference or label belongs too --- eeschema/sch_field.cpp | 10 ++++++++++ eeschema/schedit.cpp | 6 ++++++ eeschema/schframe.cpp | 4 ++++ include/base_struct.h | 4 +++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index af21d0add0..71886a0205 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -199,6 +199,16 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, LineWidth, m_Italic, m_Bold ); + // While moving: don't loose visual contact to which component this label belongs. + if ( IsWireImage() ) + { + const wxPoint origin = parentComponent->GetPosition(); + textpos = m_Pos - origin; + textpos = parentComponent->GetScreenCoord( textpos ); + textpos += parentComponent->GetPosition(); + GRLine( clipbox, DC, origin.x, origin.y, textpos.x, textpos.y, 2, DARKGRAY ); + } + /* Enable this to draw the bounding box around the text field to validate * the bounding box calculations. */ diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 8f3d425bb1..3bfeba654b 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -653,6 +653,7 @@ static void moveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPositio item->SetPosition( aPanel->GetParent()->GetCrossHairPosition() ); // Draw the item item at it's new position. + item->SetWireImage(); // While moving, the item may choose to render differently item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); } @@ -697,6 +698,11 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC ) // Never delete existing item, because it can be referenced by an undo/redo command // Just restore its data currentItem->SwapData( oldItem ); + + // Erase the wire representation before the 'normal' view is drawn. + if ( item->IsWireImage() ) + item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); + item->ClearFlags(); } diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index f69760a292..ffa575f7f8 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -973,6 +973,10 @@ void SCH_EDIT_FRAME::addCurrentItemToList( wxDC* aDC ) SaveUndoItemInUndoList( undoItem ); } + // Erase the wire representation before the 'normal' view is drawn. + if ( item->IsWireImage() ) + item->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); + item->ClearFlags(); screen->SetModify(); screen->SetCurItem( NULL ); diff --git a/include/base_struct.h b/include/base_struct.h index 90e3b4b67a..8679cfdd5b 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -298,7 +298,7 @@ public: #define IS_RESIZED (1 << 5) ///< Item being resized #define IS_DRAGGED (1 << 6) ///< Item being dragged #define IS_DELETED (1 << 7) -#define IS_WIRE_IMAGE (1 << 8) +#define IS_WIRE_IMAGE (1 << 8) ///< Item to be drawn as wireframe while editing #define STARTPOINT (1 << 9) #define ENDPOINT (1 << 10) #define SELECTED (1 << 11) @@ -389,11 +389,13 @@ public: inline bool IsModified() const { return m_Flags & IS_CHANGED; } inline bool IsMoving() const { return m_Flags & IS_MOVED; } inline bool IsDragging() const { return m_Flags & IS_DRAGGED; } + inline bool IsWireImage() const { return m_Flags & IS_WIRE_IMAGE; } inline bool IsSelected() const { return m_Flags & SELECTED; } inline bool IsResized() const { return m_Flags & IS_RESIZED; } inline bool IsHighlighted() const { return m_Flags & HIGHLIGHTED; } inline bool IsBrightened() const { return m_Flags & BRIGHTENED; } + inline void SetWireImage() { SetFlags( IS_WIRE_IMAGE ); } inline void SetSelected() { SetFlags( SELECTED ); ViewUpdate( COLOR ); } inline void SetHighlighted() { SetFlags( HIGHLIGHTED ); ViewUpdate( COLOR ); } inline void SetBrightened() { SetFlags( BRIGHTENED ); }