From 799ef3bc0d101d227cd2a1fcb0dd628b77358e89 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 20 Nov 2012 12:35:09 +0100 Subject: [PATCH] Eeschema: item drag command: Fix issue for overlapping items (from a Younes Manton's idea) Added: display info when clicking on labels. --- eeschema/block.cpp | 23 ++++++++++- eeschema/sch_text.cpp | 96 +++++++++++++++++++++++++++++++++++++++++++ eeschema/sch_text.h | 2 + eeschema/schedit.cpp | 1 + 4 files changed, 120 insertions(+), 2 deletions(-) diff --git a/eeschema/block.cpp b/eeschema/block.cpp index 0e0dc5bf7c..ad288b2538 100644 --- a/eeschema/block.cpp +++ b/eeschema/block.cpp @@ -186,12 +186,24 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC ) m_canvas->Refresh(); } - +/* + * HandleBlockEnd is called when: + * a block is defined + * or a schematic iten should be dragged + * When the block is defined, all items inside the block should be collected + * When a schematic iten should be dragged, only this item should be collected + * + * In all cases, connected items are collected when a drag command is activated + */ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) { bool nextcmd = false; bool zoom_command = false; BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate; + bool currItemOnly = false; + + if ( block->GetCommand() == BLOCK_DRAG && GetScreen()->GetCurItem() != NULL ) + currItemOnly = true; if( block->GetCount() ) { @@ -242,7 +254,14 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC ) case BLOCK_MOVE: case BLOCK_COPY: - GetScreen()->UpdatePickList(); + if( currItemOnly ) + { + ITEM_PICKER picker; + picker.SetItem( GetScreen()->GetCurItem() ); + block->PushItem( picker ); + } + else + GetScreen()->UpdatePickList(); // fall through case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/ diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index ad19911c6d..4602642516 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -729,6 +730,101 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter ) aPlotter->PlotPoly( Poly, NO_FILL ); } +/* + * Display the type, shape, size and some other props to the Message panel + */ +void SCH_TEXT::DisplayInfo( EDA_DRAW_FRAME* frame ) +{ + wxString msg; + + frame->ClearMsgPanel(); + + switch( Type() ) + { + case SCH_TEXT_T: + msg = _("Graphic text"); + break; + + case SCH_LABEL_T: + msg = _("Label"); + break; + + case SCH_GLOBAL_LABEL_T: + msg = _("Global label"); + break; + + case SCH_HIERARCHICAL_LABEL_T: + msg = _("Hierarchical label"); + break; + + case SCH_SHEET_PIN_T: + msg = _( "Hierarchical Sheet Pin" ); + break; + + default: + return; + } + + frame->AppendMsgPanel( msg, wxEmptyString, DARKCYAN ); + + switch( GetOrientation() ) + { + case 0: // horizontal text + msg = _("Horizontal"); + break; + + case 1: // Vert Orientation UP + msg = _("Vertical up"); + break; + + case 2: // invert horizontal text + msg = _("Horizontal invert"); + break; + + case 3: // Vert Orientation Down + msg = _("Vertical down");; + break; + + default: + msg = wxT("???"); + break; + } + + frame->AppendMsgPanel( _("Orientation"), msg, BROWN ); + + wxString textStyle[] = { _("Normal"), _("Italic"), _("Bold"), _("Bold Italic") }; + int style = 0; + + if( m_Italic ) + style = 1; + + if( m_Bold ) + style += 2; + + frame->AppendMsgPanel( _("Style"), textStyle[style], BROWN ); + + + // Display electricat type if it is relevant + if( (Type() == SCH_GLOBAL_LABEL_T) || + (Type() == SCH_HIERARCHICAL_LABEL_T ) || + (Type() == SCH_SHEET_PIN_T ) ) + { + switch( GetShape() ) + { + case NET_INPUT: msg = _("Input"); break; + case NET_OUTPUT: msg = _("Output"); break; + case NET_BIDI: msg = _("Bidirectional"); break; + case NET_TRISTATE: msg = _("Tri-State"); break; + case NET_UNSPECIFIED: msg = _("Passive"); break; + default: msg = wxT("???"); break; + } + frame->AppendMsgPanel( _("Type"), msg, BLUE ); + } + + // Display text size (X or Y value, with are the same value in Eeschema) + msg = ReturnStringFromValue( g_UserUnit, m_Size.x, true ); + frame->AppendMsgPanel( _("Size"), msg, RED ); +} #if defined(DEBUG) diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index f06ae636cf..4e2fe96190 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -212,6 +212,8 @@ public: virtual EDA_ITEM* Clone() const; + void DisplayInfo( EDA_DRAW_FRAME* frame ); // Virtual function + #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const; // override #endif diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index b52c3fe664..34ddb1dfd0 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -913,6 +913,7 @@ void SCH_EDIT_FRAME::OnDragItem( wxCommandEvent& aEvent ) // Fall thru if item is not on bus layer. case SCH_COMPONENT_T: + case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIERARCHICAL_LABEL_T: case SCH_SHEET_T: