Fix bugs in block operations.

1) when duplicating don’t keep original hidden until end of drag
2) reset selectionArea when showing it so it doesn’t flash in its previous location
3) center a pasted block on the cursor
4) don’t draw the source selectionArea when pasting a block
5) implement selection-style highlighting for contents of blocks
6) add pasted items to view so they don’t disappear when the block is placed

Fixes: lp:1747197
* https://bugs.launchpad.net/kicad/+bug/1747197
This commit is contained in:
Jeff Young 2018-09-05 23:17:22 +01:00
parent 27df8937b8
commit 7216eda202
11 changed files with 191 additions and 111 deletions

View File

@ -1331,6 +1331,11 @@ void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore )
}
void EDA_DRAW_FRAME::HardRedraw()
{
}
// Factor out the calculation portion of the various BestZoom() implementations.
//
// Note that like it's forerunners this routine has an intentional side-effect: it
@ -1421,7 +1426,7 @@ void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
case ID_POPUP_ZOOM_REDRAW:
case ID_ZOOM_REDRAW:
// This usually means something went wrong. Do a hard refresh.
SetScreen( GetScreen() );
HardRedraw();
break;
case ID_POPUP_ZOOM_CENTER:

View File

@ -1603,6 +1603,13 @@ void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore )
}
void EDA_DRAW_FRAME::HardRedraw()
{
m_canvas->Refresh();
m_canvas->Update();
}
// Factor out the calculation portion of the various BestZoom() implementations.
//
// Note that like it's forerunners this routine has an intentional side-effect: it

View File

@ -270,8 +270,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
{
nextcmd = true;
GetScreen()->SelectBlockItems();
if( block->GetCommand() != BLOCK_DUPLICATE )
block->SetFlags( IS_MOVED );
block->SetFlags( IS_MOVED );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
@ -431,7 +430,9 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
SCH_ITEM *copy = static_cast<SCH_ITEM*>( schitem->Clone() );
copy->Move( block->GetMoveVector() );
preview->Add( copy );
view->Hide( schitem );
if( block->GetCommand() != BLOCK_DUPLICATE )
view->Hide( schitem );
}
view->Update( preview );
@ -544,14 +545,19 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
{
( (SCH_SHEET*) item )->SetTimeStamp( GetNewTimeStamp() );
}
SetSchItemParent( item, GetScreen() );
AddToScreen( item );
}
SaveCopyInUndoList( picklist, UR_NEW );
MoveItemsInList( picklist, GetScreen()->m_BlockLocate.GetMoveVector() );
for( i = 0; i < picklist.GetCount(); ++i )
{
item = (SCH_ITEM*) picklist.GetPickedItem( i );
item->Move( GetScreen()->m_BlockLocate.GetMoveVector() );
SetSchItemParent( item, GetScreen() );
AddToScreen( item );
}
if( hasSheetPasted )
{
@ -565,8 +571,6 @@ void SCH_EDIT_FRAME::PasteListOfItems( wxDC* DC )
GetScreen()->ClearDrawingState();
OnModify();
return;
}
void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
@ -588,7 +592,7 @@ void DrawAndSizingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoin
panel->GetView()->ClearHiddenFlags();
area->SetOrigin( block->GetOrigin() );;
area->SetEnd( block->GetEnd() );
area->SetEnd( block->GetEnd() );
panel->GetView()->SetVisible( area );
panel->GetView()->Hide( area, false );

View File

@ -232,7 +232,7 @@ void SCH_EDIT_FRAME::DeleteItem( SCH_ITEM* aItem, bool aAppend )
void SCH_EDIT_FRAME::DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST& aItemsList,
const wxPoint& aMoveVector )
const wxPoint& aMoveVector )
{
SCH_ITEM* newitem;
@ -285,13 +285,13 @@ void SCH_EDIT_FRAME::DuplicateItemsInList( SCH_SCREEN* screen, PICKED_ITEMS_LIST
break;
}
newitem->Move( aMoveVector );
SetSchItemParent( newitem, screen );
AddToScreen( newitem );
}
}
MoveItemsInList( aItemsList, aMoveVector );
if( hasSheetCopied )
{
// We clear annotation of new sheet paths.

View File

@ -29,7 +29,7 @@
#include <sch_painter.h>
#include <gal/graphics_abstraction_layer.h>
#include <confirm.h>
#include <preview_items/selection_area.h>
#include <class_library.h>
#include <eeschema_id.h>
#include <lib_edit_frame.h>
@ -437,6 +437,14 @@ void SCH_BASE_FRAME::RedrawScreen2( const wxPoint& posBefore )
GetGalCanvas()->Refresh();
}
void SCH_BASE_FRAME::HardRedraw()
{
GetCanvas()->DisplaySheet( GetScreen() );
GetCanvas()->Refresh();
}
SCH_DRAW_PANEL* SCH_BASE_FRAME::GetCanvas() const
{
return static_cast<SCH_DRAW_PANEL*>( GetGalCanvas() );
@ -489,14 +497,17 @@ bool SCH_BASE_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& a
break;
case BLOCK_PASTE:
{
block->InitData( m_canvas, aPosition );
GetCanvas()->GetView()->ShowSelectionArea();
block->SetLastCursorPosition( wxPoint( 0, 0 ) );
InitBlockPasteInfos();
KIGFX::PREVIEW::SELECTION_AREA* sel = GetCanvas()->GetView()->GetSelectionArea();
VECTOR2I offsetToCenter = ( sel->GetOrigin() - sel->GetEnd() ) / 2;
block->SetLastCursorPosition( wxPoint( offsetToCenter.x, offsetToCenter.y ) );
if( block->GetCount() == 0 ) // No data to paste
{
DisplayError( this, wxT( "No block to paste" ), 20 );
DisplayError( this, _( "Nothing to paste" ), 20 );
GetScreen()->m_BlockLocate.SetCommand( BLOCK_IDLE );
m_canvas->SetMouseCaptureCallback( NULL );
block->SetState( STATE_NO_BLOCK );
@ -507,24 +518,21 @@ bool SCH_BASE_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& a
if( !m_canvas->IsMouseCaptured() )
{
block->ClearItemsList();
DisplayError( this,
wxT( "EDA_DRAW_FRAME::HandleBlockBegin() Err: m_mouseCaptureCallback NULL" ) );
wxFAIL_MSG( "SCH_BASE_FRAME::HandleBlockBegin() error: m_mouseCaptureCallback NULL" );
block->SetState( STATE_NO_BLOCK );
block->SetMessageBlock( this );
return true;
}
block->SetState( STATE_BLOCK_MOVE );
block->SetFlags( IS_MOVED );
m_canvas->CallMouseCapture( aDC, aPosition, false );
}
break;
default:
{
wxString msg;
msg << wxT( "EDA_DRAW_FRAME::HandleBlockBegin() error: Unknown command " ) <<
block->GetCommand();
DisplayError( this, msg );
}
wxFAIL_MSG( wxString::Format( "SCH_BASE_FRAME::HandleBlockBegin() unknown command: %s",
block->GetCommand() ) );
break;
}

View File

@ -286,6 +286,8 @@ public:
virtual void RedrawScreen2( const wxPoint& posBefore ) override;
virtual void HardRedraw() override;
void AddToScreen( SCH_ITEM* aItem );
void AddToScreen( DLIST<SCH_ITEM>& aItems );
void RemoveFromScreen( SCH_ITEM* aItem );

View File

@ -59,21 +59,8 @@
#include <draw_graphic_text.h>
namespace KIGFX {
struct COLOR_DEF
{
std::string configName;
SCH_LAYER_ID layer;
COLOR4D color;
COLOR_DEF( std::string name, SCH_LAYER_ID layer_, COLOR4D color_ )
{
configName = name;
layer = layer_;
color = color_;
}
};
namespace KIGFX
{
SCH_RENDER_SETTINGS::SCH_RENDER_SETTINGS() :
m_ShowUnit( 0 ),
@ -103,6 +90,12 @@ const COLOR4D& SCH_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer
}
static COLOR4D selectedBrightening( const COLOR4D& aColor )
{
return aColor.Brightened( 0.5 );
}
/**
* Used when a LIB_PART is not found in library to draw a dummy shape.
* This component is a 400 mils square with the text "??"
@ -183,30 +176,31 @@ bool SCH_PAINTER::Draw( const VIEW_ITEM *aItem, int aLayer )
HANDLE_ITEM(LIB_ALIAS_T, LIB_ALIAS);
HANDLE_ITEM(LIB_PART_T, LIB_PART);
HANDLE_ITEM(LIB_RECTANGLE_T, LIB_RECTANGLE);
HANDLE_ITEM(LIB_POLYLINE_T, LIB_POLYLINE);
HANDLE_ITEM(LIB_CIRCLE_T, LIB_CIRCLE);
HANDLE_ITEM(LIB_PIN_T, LIB_PIN);
HANDLE_ITEM(LIB_ARC_T, LIB_ARC);
HANDLE_ITEM(LIB_FIELD_T, LIB_FIELD);
HANDLE_ITEM(LIB_TEXT_T, LIB_TEXT);
HANDLE_ITEM(SCH_COMPONENT_T, SCH_COMPONENT);
HANDLE_ITEM(SCH_JUNCTION_T, SCH_JUNCTION);
HANDLE_ITEM(SCH_LINE_T, SCH_LINE);
HANDLE_ITEM(SCH_TEXT_T, SCH_TEXT);
HANDLE_ITEM(SCH_LABEL_T, SCH_TEXT);
HANDLE_ITEM(SCH_FIELD_T, SCH_FIELD);
HANDLE_ITEM(SCH_HIERARCHICAL_LABEL_T, SCH_HIERLABEL);
HANDLE_ITEM(SCH_GLOBAL_LABEL_T, SCH_GLOBALLABEL);
HANDLE_ITEM(SCH_SHEET_T, SCH_SHEET);
HANDLE_ITEM(SCH_NO_CONNECT_T, SCH_NO_CONNECT);
HANDLE_ITEM(SCH_BUS_WIRE_ENTRY_T, SCH_BUS_ENTRY_BASE);
HANDLE_ITEM(SCH_BUS_BUS_ENTRY_T, SCH_BUS_ENTRY_BASE);
HANDLE_ITEM(SCH_BITMAP_T, SCH_BITMAP);
HANDLE_ITEM(SCH_MARKER_T, SCH_MARKER);
default:
return false;
HANDLE_ITEM(LIB_POLYLINE_T, LIB_POLYLINE);
HANDLE_ITEM(LIB_CIRCLE_T, LIB_CIRCLE);
HANDLE_ITEM(LIB_PIN_T, LIB_PIN);
HANDLE_ITEM(LIB_ARC_T, LIB_ARC);
HANDLE_ITEM(LIB_FIELD_T, LIB_FIELD);
HANDLE_ITEM(LIB_TEXT_T, LIB_TEXT);
HANDLE_ITEM(SCH_COMPONENT_T, SCH_COMPONENT);
HANDLE_ITEM(SCH_JUNCTION_T, SCH_JUNCTION);
HANDLE_ITEM(SCH_LINE_T, SCH_LINE);
HANDLE_ITEM(SCH_TEXT_T, SCH_TEXT);
HANDLE_ITEM(SCH_LABEL_T, SCH_TEXT);
HANDLE_ITEM(SCH_FIELD_T, SCH_FIELD);
HANDLE_ITEM(SCH_HIERARCHICAL_LABEL_T, SCH_HIERLABEL);
HANDLE_ITEM(SCH_GLOBAL_LABEL_T, SCH_GLOBALLABEL);
HANDLE_ITEM(SCH_SHEET_T, SCH_SHEET);
HANDLE_ITEM(SCH_NO_CONNECT_T, SCH_NO_CONNECT);
HANDLE_ITEM(SCH_BUS_WIRE_ENTRY_T, SCH_BUS_ENTRY_BASE);
HANDLE_ITEM(SCH_BUS_BUS_ENTRY_T, SCH_BUS_ENTRY_BASE);
HANDLE_ITEM(SCH_BITMAP_T, SCH_BITMAP);
HANDLE_ITEM(SCH_MARKER_T, SCH_MARKER);
default:
return false;
}
return false;
}
@ -264,7 +258,7 @@ void SCH_PAINTER::draw( LIB_PART *aComp, int aLayer, bool aDrawFields, int aUnit
if( danglingPinFlags && pinIndex < danglingPinFlags->size() )
dangling = (*danglingPinFlags)[ pinIndex ];
draw( pin, aLayer, dangling );
draw( pin, aLayer, dangling, aComp->IsMoving() );
pinIndex++;
}
else
@ -329,13 +323,16 @@ void SCH_PAINTER::triLine ( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D
}
void SCH_PAINTER::defaultColors ( const LIB_ITEM *aItem )
void SCH_PAINTER::defaultColors( const LIB_ITEM *aItem )
{
COLOR4D fg = m_schSettings.GetLayerColor( LAYER_DEVICE );
COLOR4D bg = m_schSettings.GetLayerColor( LAYER_DEVICE_BACKGROUND );
if( aItem->IsMoving() )
{
fg = selectedBrightening( fg );
bg = bg.Saturate( 0.7 ).WithAlpha( 0.66 );
}
m_gal->SetIsStroke( true );
m_gal->SetStrokeColor( fg );
@ -415,6 +412,10 @@ void SCH_PAINTER::draw( LIB_FIELD *aField, int aLayer )
else
return;
}
else if( aField->IsMoving() )
{
color = selectedBrightening( color );
}
int linewidth = aField->GetPenSize();
@ -463,14 +464,19 @@ void SCH_PAINTER::draw( LIB_TEXT *aText, int aLayer )
if( !isUnitAndConversionShown( aText ) )
return;
COLOR4D color;
COLOR4D color = m_schSettings.GetLayerColor( LAYER_NOTES );
if( aText->IsVisible() )
color = m_schSettings.GetLayerColor( LAYER_NOTES );
else if( m_schSettings.m_ShowHiddenText )
if( !aText->IsVisible() )
{
color = m_schSettings.GetLayerColor( LAYER_HIDDEN );
else
return;
if( !m_schSettings.m_ShowHiddenText )
return;
}
else if( aText->IsMoving() )
{
color = selectedBrightening( color );
}
int w = aText->GetPenSize();
EDA_RECT bBox = aText->GetBoundingBox();
@ -505,7 +511,7 @@ static int ExternalPinDecoSize( const LIB_PIN &aPin )
}
void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer, bool isDangling )
void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer, bool isDangling, bool isMoving )
{
if( !isUnitAndConversionShown( aPin ) )
return;
@ -519,6 +525,10 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer, bool isDangling )
if( !m_schSettings.m_ShowHiddenPins )
return;
}
else if( isMoving )
{
color = selectedBrightening( color );
}
VECTOR2I pos = mapCoords( aPin->GetPosition() );
VECTOR2I p0, dir;
@ -643,7 +653,7 @@ void SCH_PAINTER::draw( LIB_PIN *aPin, int aLayer, bool isDangling )
pos + VECTOR2D( -1, 1 ) * TARGET_PIN_RADIUS );
}
if( isDangling && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
if( ( isDangling || isMoving ) && ( aPin->IsVisible() || aPin->IsPowerConnection() ) )
{
m_gal->SetLineWidth ( 1.0 );
m_gal->DrawCircle( pos, TARGET_PIN_RADIUS );
@ -859,7 +869,10 @@ static void drawDanglingSymbol( GAL* aGal, const wxPoint& aPos )
void SCH_PAINTER::draw( SCH_JUNCTION *aJct, int aLayer )
{
const COLOR4D& color = m_schSettings.GetLayerColor( LAYER_JUNCTION );
COLOR4D color = m_schSettings.GetLayerColor( LAYER_JUNCTION );
if( aJct->IsMoving() )
color = selectedBrightening( color );
m_gal->SetIsStroke(true);
m_gal->SetIsFill(true);
@ -871,7 +884,13 @@ void SCH_PAINTER::draw( SCH_JUNCTION *aJct, int aLayer )
void SCH_PAINTER::draw( SCH_LINE *aLine, int aLayer )
{
COLOR4D color = GetLayerColor( aLine->GetState( BRIGHTENED ) ? LAYER_BRIGHTENED : LAYER_WIRE );
COLOR4D color = m_schSettings.GetLayerColor( LAYER_WIRE );
if( aLine->GetState( BRIGHTENED ) )
color = m_schSettings.GetLayerColor( LAYER_BRIGHTENED );
else if( aLine->IsMoving() )
color = selectedBrightening( color );
int width = aLine->GetPenSize();
m_gal->SetIsStroke(true);
@ -900,11 +919,15 @@ void SCH_PAINTER::draw( SCH_TEXT *aText, int aLayer )
if( !aText->IsVisible() )
{
if( m_schSettings.m_ShowHiddenText )
color = m_schSettings.GetLayerColor( LAYER_HIDDEN );
else
color = m_schSettings.GetLayerColor( LAYER_HIDDEN );
if( !m_schSettings.m_ShowHiddenText )
return;
}
else if( aText->IsMoving() )
{
color = selectedBrightening( color );
}
if( aText->IsDangling() )
drawDanglingSymbol( m_gal, aText->GetTextPos());
@ -1002,10 +1025,8 @@ void SCH_PAINTER::draw( SCH_COMPONENT *aComp, int aLayer )
item.Move( wxPoint( rp.x + ip.x, ip.y - rp.y ) );
}
// Always draw dangling pin targets when dragging
std::vector<bool>* pinFlags = aComp->IsMoving() ? nullptr : aComp->GetDanglingPinFlags();
draw( ptrans.get(), aLayer, false, aComp->GetUnit(), aComp->GetConvert(), pinFlags );
draw( ptrans.get(), aLayer, false,
aComp->GetUnit(), aComp->GetConvert(), aComp->GetDanglingPinFlags() );
// The fields are SCH_COMPONENT-specific and so don't need to be copied/
// oriented/translated.
@ -1037,11 +1058,15 @@ void SCH_PAINTER::draw( SCH_FIELD *aField, int aLayer )
if( !aField->IsVisible() )
{
if( m_schSettings.m_ShowHiddenText )
color = m_schSettings.GetLayerColor( LAYER_HIDDEN );
else
color = m_schSettings.GetLayerColor( LAYER_HIDDEN );
if( !m_schSettings.m_ShowHiddenText )
return;
}
else if( aField->IsMoving() )
{
color = selectedBrightening( color );
}
if( aField->IsVoid() )
return;
@ -1093,6 +1118,11 @@ void SCH_PAINTER::draw( SCH_FIELD *aField, int aLayer )
void SCH_PAINTER::draw( SCH_GLOBALLABEL *aLabel, int aLayer )
{
COLOR4D color = m_schSettings.GetLayerColor( LAYER_GLOBLABEL );
if( aLabel->IsMoving() )
color = selectedBrightening( color );
std::vector<wxPoint> pts;
std::deque<VECTOR2D> pts2;
@ -1104,7 +1134,7 @@ void SCH_PAINTER::draw( SCH_GLOBALLABEL *aLabel, int aLayer )
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true );
m_gal->SetLineWidth( aLabel->GetThickness() );
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_GLOBLABEL ) );
m_gal->SetStrokeColor( color );
m_gal->DrawPolyline( pts2 );
draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
@ -1113,6 +1143,11 @@ void SCH_PAINTER::draw( SCH_GLOBALLABEL *aLabel, int aLayer )
void SCH_PAINTER::draw( SCH_HIERLABEL *aLabel, int aLayer )
{
COLOR4D color = m_schSettings.GetLayerColor( LAYER_SHEETLABEL );
if( aLabel->IsMoving() )
color = selectedBrightening( color );
std::vector<wxPoint> pts;
std::deque<VECTOR2D> pts2;
@ -1124,13 +1159,13 @@ void SCH_PAINTER::draw( SCH_HIERLABEL *aLabel, int aLayer )
m_gal->SetIsFill( false );
m_gal->SetIsStroke( true );
m_gal->SetLineWidth( aLabel->GetThickness() );
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_SHEETLABEL ) );
m_gal->SetStrokeColor( color );
m_gal->DrawPolyline( pts2 );
draw( static_cast<SCH_TEXT*>( aLabel ), aLayer );
}
void SCH_PAINTER::draw ( SCH_SHEET *aSheet, int aLayer )
void SCH_PAINTER::draw( SCH_SHEET *aSheet, int aLayer )
{
VECTOR2D pos_sheetname = aSheet->GetSheetNamePosition();
VECTOR2D pos_filename = aSheet->GetFileNamePosition();
@ -1171,7 +1206,6 @@ void SCH_PAINTER::draw ( SCH_SHEET *aSheet, int aLayer )
text = wxT( "File: " ) + aSheet->GetFileName();
m_gal->StrokeText( text, pos_filename, nameAngle );
for( auto& sheetPin : aSheet->GetPins() )
draw( static_cast<SCH_HIERLABEL*>( &sheetPin ), aLayer );
}
@ -1182,7 +1216,7 @@ void SCH_PAINTER::draw( SCH_NO_CONNECT *aNC, int aLayer )
int delta = aNC->GetSize().x / 2;
int width = GetDefaultLineThickness();
m_gal->SetStrokeColor( GetLayerColor( LAYER_NOCONNECT ) );
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_NOCONNECT ) );
m_gal->SetIsStroke( true );
m_gal->SetIsFill( false );
m_gal->SetLineWidth( width );
@ -1196,7 +1230,12 @@ void SCH_PAINTER::draw( SCH_NO_CONNECT *aNC, int aLayer )
void SCH_PAINTER::draw( SCH_BUS_ENTRY_BASE *aEntry, int aLayer )
{
m_gal->SetStrokeColor( GetLayerColor( LAYER_BUS ) );
COLOR4D color = m_schSettings.GetLayerColor( LAYER_BUS );
if( aEntry->IsMoving() )
color = selectedBrightening( color );
m_gal->SetStrokeColor( color );
m_gal->SetIsStroke( true );
m_gal->SetLineWidth( aEntry->GetPenSize() );
m_gal->SetIsFill( false );
@ -1206,6 +1245,8 @@ void SCH_PAINTER::draw( SCH_BUS_ENTRY_BASE *aEntry, int aLayer )
m_gal->DrawLine( pos, endPos );
m_gal->SetStrokeColor( m_schSettings.GetLayerColor( LAYER_BUS ) );
if( aEntry->IsDanglingStart() )
m_gal->DrawCircle( pos, TARGET_BUSENTRY_RADIUS );
@ -1240,10 +1281,10 @@ void SCH_PAINTER::draw( SCH_MARKER *aMarker, int aLayer )
VECTOR2D( 0 * scale, 0 * scale )
};
COLOR4D color = GetLayerColor( LAYER_ERC_WARN );
COLOR4D color = m_schSettings.GetLayerColor( LAYER_ERC_WARN );
if( aMarker->GetErrorLevel() == MARKER_BASE::MARKER_SEVERITY_ERROR )
color = GetLayerColor( LAYER_ERC_ERR );
color = m_schSettings.GetLayerColor( LAYER_ERC_ERR );
m_gal->Save();
m_gal->Translate( aMarker->GetPosition() );

View File

@ -118,7 +118,7 @@ public:
private:
void draw( LIB_RECTANGLE *, int );
void draw( LIB_PIN *, int, bool isDangling = true );
void draw( LIB_PIN *, int, bool isDangling = true, bool isMoving = false );
void draw( LIB_CIRCLE *, int );
void draw( LIB_ITEM *, int );
void draw( LIB_PART *, int, bool aDrawFields = true, int aUnit = 0, int aConvert = 0,

View File

@ -162,6 +162,14 @@ void SCH_VIEW::AddToPreview( EDA_ITEM *aItem, bool owned )
void SCH_VIEW::ShowSelectionArea( bool aShow )
{
if( aShow )
{
// Reset seleciton area so the previous one doesn't flash before the first
// mouse move updates it
m_selectionArea->SetOrigin( VECTOR2I() );
m_selectionArea->SetEnd( VECTOR2I() );
}
SetVisible( m_selectionArea.get(), aShow );
}

View File

@ -267,6 +267,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRedoCommand )
{
SCH_ITEM* item;
SCH_ITEM* next_item;
SCH_ITEM* alt_item;
// Exchange the current wires, buses, and junctions with the copy save by the last edit.
@ -275,9 +276,6 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
PICKED_ITEMS_LIST oldItems;
oldItems.m_Status = UR_WIRE_IMAGE;
SCH_ITEM* item;
SCH_ITEM* next_item;
// Remove all of the wires, buses, and junctions from the current screen.
for( item = GetScreen()->GetDrawItems(); item; item = next_item )
{
@ -295,10 +293,9 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
// Copy the saved wires, buses, and junctions to the current screen.
for( unsigned int i = 0; i < aList->GetCount(); i++ )
{
auto item = static_cast<SCH_ITEM*>( aList->GetPickedItem( i ) );
item = static_cast<SCH_ITEM*>( aList->GetPickedItem( i ) );
AddToScreen( item );
GetCanvas()->GetView()->Add( item );
}
// Copy the previous wires, buses, and junctions to the picked item list for the
@ -310,36 +307,36 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
// Undo in the reverse order of list creation: (this can allow stacked changes like the
// same item can be changes and deleted in the same complex command.
for( int ii = aList->GetCount() - 1; ii >= 0; ii-- )
for( int ii = aList->GetCount() - 1; ii >= 0; ii-- )
{
item = (SCH_ITEM*) aList->GetPickedItem( ii );
item = (SCH_ITEM*) aList->GetPickedItem( (unsigned) ii );
wxASSERT( item );
item->ClearFlags();
SCH_ITEM* image = (SCH_ITEM*) aList->GetPickedItemLink( ii );
SCH_ITEM* image = (SCH_ITEM*) aList->GetPickedItemLink( (unsigned) ii );
switch( aList->GetPickedItemStatus( ii ) )
switch( aList->GetPickedItemStatus( (unsigned) ii ) )
{
case UR_CHANGED: /* Exchange old and new data for each item */
item->SwapData( image );
break;
case UR_NEW: /* new items are deleted */
aList->SetPickedItemStatus( UR_DELETED, ii );
aList->SetPickedItemStatus( UR_DELETED, (unsigned) ii );
RemoveFromScreen( item );
//schprintf("UndoRemFroMscreen %p %s\n", item, (const char *)item->GetClass().c_str() );
break;
case UR_DELETED: /* deleted items are put in the draw item list, as new items */
aList->SetPickedItemStatus( UR_NEW, ii );
aList->SetPickedItemStatus( UR_NEW, (unsigned) ii );
AddToScreen( item );
break;
case UR_MOVED:
item->ClearFlags();
item->SetFlags( aList->GetPickerFlags( ii ) );
item->SetFlags( aList->GetPickerFlags( (unsigned) ii ) );
item->Move( aRedoCommand ? aList->m_TransformPoint : -aList->m_TransformPoint );
item->ClearFlags();
break;
@ -366,18 +363,20 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
break;
case UR_EXCHANGE_T:
alt_item = (SCH_ITEM*) aList->GetPickedItemLink( ii );
alt_item = (SCH_ITEM*) aList->GetPickedItemLink( (unsigned) ii );
alt_item->SetNext( NULL );
alt_item->SetBack( NULL );
RemoveFromScreen( item );
AddToScreen( alt_item );
aList->SetPickedItem( alt_item, ii );
aList->SetPickedItemLink( item, ii );
aList->SetPickedItem( alt_item, (unsigned) ii );
aList->SetPickedItemLink( item, (unsigned) ii );
break;
default:
wxFAIL_MSG( wxString::Format( wxT( "Unknown undo/redo command %d" ),
aList->GetPickedItemStatus( ii ) ) );
aList->GetPickedItemStatus( (unsigned) ii ) ) );
break;
}
}

View File

@ -680,6 +680,12 @@ public:
*/
virtual void RedrawScreen2( const wxPoint& posBefore );
/**
* Function HardRedraw
* rebuilds the GAL and redraws the screen. Call when something went wrong.
*/
virtual void HardRedraw();
/**
* Function Zoom_Automatique
* redraws the screen with best zoom level and the best centering