Eeschema: Fix a (minor but annoying) bug detected by coverity which prevent Eeschema to draw components in "fast mode" (i;e. without pin texts) when they are moved, due to a draw parameter which was incorrectly used.

Move items rework: enhancements: for some items (sheets, components, bus entries) the mouse cursor is no more wrapped to the anchor. For large symbols, this is better: they are more easy to place.
There is also a change when starting a move item command: the full screen is redraw, and therefore there is no artifact due to the XOR draw mode.
Some other minor coverity fixes (uninitialized members).
This commit is contained in:
jean-pierre charras 2015-02-28 17:56:09 +01:00
parent 2101324691
commit 00f8994ee1
27 changed files with 293 additions and 196 deletions

View File

@ -1,9 +1,9 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2009-2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2009-2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -397,6 +397,11 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
for( unsigned ii = 0; ii < block->GetCount(); ii++ ) for( unsigned ii = 0; ii < block->GetCount(); ii++ )
{ {
schitem = (SCH_ITEM*) block->GetItem( ii ); schitem = (SCH_ITEM*) block->GetItem( ii );
if( schitem->Type() == SCH_COMPONENT_T )
((SCH_COMPONENT*)schitem)->Draw( aPanel, aDC, block->GetMoveVector(),
g_XorMode, g_GhostColor, false );
else
schitem->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, g_GhostColor ); schitem->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, g_GhostColor );
} }
} }
@ -408,6 +413,11 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
for( unsigned ii = 0; ii < block->GetCount(); ii++ ) for( unsigned ii = 0; ii < block->GetCount(); ii++ )
{ {
schitem = (SCH_ITEM*) block->GetItem( ii ); schitem = (SCH_ITEM*) block->GetItem( ii );
if( schitem->Type() == SCH_COMPONENT_T )
((SCH_COMPONENT*)schitem)->Draw( aPanel, aDC, block->GetMoveVector(),
g_XorMode, g_GhostColor, false );
else
schitem->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, g_GhostColor ); schitem->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, g_GhostColor );
} }
} }

View File

@ -442,7 +442,7 @@ void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
( (SCH_COMPONENT*) my_clone )->SetTimeStamp( GetNewTimeStamp() ); ( (SCH_COMPONENT*) my_clone )->SetTimeStamp( GetNewTimeStamp() );
my_clone->Move( pos ); my_clone->Move( pos );
my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode ); my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
MoveItem( my_clone, DC ); PrepareMoveItem( my_clone, DC );
} }
else else
{ {

View File

@ -4,11 +4,11 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2012 Jean-Pierre Charras <jp.charras at wanadoo.fr * Copyright (C) 1992-2015 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2010 Lorenzo Marcantonio * Copyright (C) 1992-2010 Lorenzo Marcantonio
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* *
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -343,7 +343,15 @@ wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( wxTextCtrl* aOutputDirecto
wxString plotFileName = Prj().AbsolutePath( aPlotFileName + wxT(".") + aExtension); wxString plotFileName = Prj().AbsolutePath( aPlotFileName + wxT(".") + aExtension);
EnsureFileDirectoryExists( &outputDir, plotFileName, aReporter ); if( !EnsureFileDirectoryExists( &outputDir, plotFileName, aReporter ) )
{
wxString msg;
msg.Printf( _( "Could not write plot files to folder \"%s\"." ),
GetChars( outputDir.GetPath() ) );
msg << wxT( "\n" );
aReporter->Report( msg );
}
wxFileName fn( plotFileName ); wxFileName fn( plotFileName );
fn.SetPath( outputDir.GetFullPath() ); fn.SetPath( outputDir.GetFullPath() );
return fn; return fn;

View File

@ -123,7 +123,7 @@ SCH_TEXT* SCH_EDIT_FRAME::CreateNewText( wxDC* aDC, int aType )
// Prepare display to move the new item // Prepare display to move the new item
textItem->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); textItem->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
MoveItem( (SCH_ITEM*) textItem, aDC ); PrepareMoveItem( (SCH_ITEM*) textItem, aDC );
return textItem; return textItem;
} }

View File

@ -56,7 +56,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
newitem->SetFlags( IS_NEW ); newitem->SetFlags( IS_NEW );
// Draw the new part, MoveItem() expects it to be already on screen. // Draw the new part, MoveItem() expects it to be already on screen.
newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode ); newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
MoveItem( newitem, &dc ); PrepareMoveItem( newitem, &dc );
} }
break; break;
@ -69,7 +69,7 @@ void SCH_EDIT_FRAME::OnCopySchematicItemRequest( wxCommandEvent& event )
newitem->SetFlags( IS_NEW ); newitem->SetFlags( IS_NEW );
// Draw the new item, MoveItem() expects it to be already on screen. // Draw the new item, MoveItem() expects it to be already on screen.
newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode ); newitem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), g_XorMode );
MoveItem( newitem, &dc ); PrepareMoveItem( newitem, &dc );
} }
break; break;

View File

@ -222,7 +222,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aDC,
SetMsgPanel( items ); SetMsgPanel( items );
component->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); component->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
component->SetFlags( IS_NEW ); component->SetFlags( IS_NEW );
MoveItem( (SCH_ITEM*) component, aDC ); PrepareMoveItem( (SCH_ITEM*) component, aDC );
return component; return component;
} }

View File

@ -56,7 +56,8 @@ class TreeItemData : public wxTreeItemData
{ {
public: public:
SCH_SHEET_PATH m_SheetPath; SCH_SHEET_PATH m_SheetPath;
TreeItemData( SCH_SHEET_PATH sheet ) : wxTreeItemData()
TreeItemData( SCH_SHEET_PATH& sheet ) : wxTreeItemData()
{ {
m_SheetPath = sheet; m_SheetPath = sheet;
} }

View File

@ -1,8 +1,9 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View File

@ -1,8 +1,9 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View File

@ -1,8 +1,9 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -834,11 +835,12 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel,
aColor = GetInvisibleItemColor(); aColor = GetInvisibleItemColor();
} }
LIB_PART* Entry = GetParent(); // aData is used here as bool: if not null, draw pin texts
bool DrawPinText = true; //(i.e = true to draw pin texts, false to draw only the pin shape, which
// is useful to draw moving component in fast mode)
if( ( aData != NULL ) && ( (bool*) aData == false ) ) LIB_PART* Entry = GetParent();
DrawPinText = false; bool drawPinText = aData ? true : false;
/* Calculate pin orient taking in account the component orientation. */ /* Calculate pin orient taking in account the component orientation. */
int orient = PinDrawOrient( aTransform ); int orient = PinDrawOrient( aTransform );
@ -849,7 +851,7 @@ void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel,
/* Drawing from the pin and the special symbol combination */ /* Drawing from the pin and the special symbol combination */
DrawPinSymbol( aPanel, aDC, pos1, orient, aDrawMode, aColor ); DrawPinSymbol( aPanel, aDC, pos1, orient, aDrawMode, aColor );
if( DrawPinText ) if( drawPinText )
{ {
DrawPinTexts( aPanel, aDC, pos1, orient, Entry->GetPinNameOffset(), DrawPinTexts( aPanel, aDC, pos1, orient, Entry->GetPinNameOffset(),
Entry->ShowPinNumbers(), Entry->ShowPinNames(), Entry->ShowPinNumbers(), Entry->ShowPinNames(),

View File

@ -1,8 +1,9 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras at wanadoo.fr
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -98,8 +99,21 @@ class LIB_PIN : public LIB_ITEM
///< "G6", or "12". It is stored as "12\0\0" and does not ///< "G6", or "12". It is stored as "12\0\0" and does not
///< depend on endian type. ///< depend on endian type.
int m_numTextSize; int m_numTextSize;
int m_nameTextSize; /* Pin num and Pin name sizes */ int m_nameTextSize; ///< Pin num and Pin name sizes
/**
* Draw a pin, with or without the pin texts
*
* @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes.
* @param aDC Device Context (can be null)
* @param aOffset Offset to draw
* @param aColor -1 to use the normal body item color, or use this color if >= 0
* @param aDrawMode GR_OR, GR_XOR, ...
* @param aData = used here as bool: if not null, draw pin texts
* (i.e = true to draw pin texts, false to draw only the pin shape, which
* is useful to draw moving component in fast mode)
* @param aTransform Transform Matrix (rotation, mirror ..)
*/
void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData, EDA_COLOR_T aColor, GR_DRAWMODE aDrawMode, void* aData,
const TRANSFORM& aTransform ); const TRANSFORM& aTransform );

View File

@ -51,6 +51,14 @@ public:
~SCH_BUS_ENTRY_BASE() { } ~SCH_BUS_ENTRY_BASE() { }
/**
* Virtual function IsMovableFromAnchorPoint
* Return true for items which are moved with the anchor point at mouse cursor
* and false for items moved with no reference to anchor
* @return false for a bus entry
*/
bool IsMovableFromAnchorPoint() { return false; }
wxPoint m_End() const; wxPoint m_End() const;
/** /**

View File

@ -1,8 +1,8 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -327,23 +327,26 @@ int SCH_COMPONENT::GetUnitCount() const
} }
void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset, void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE DrawMode, EDA_COLOR_T Color, bool DrawPinText ) GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor,
bool aDrawPinText )
{ {
if( PART_SPTR part = m_part.lock() ) if( PART_SPTR part = m_part.lock() )
{ {
part->Draw( panel, DC, m_Pos + offset, m_unit, m_convert, DrawMode, Color, m_transform, DrawPinText, false ); part->Draw( aPanel, aDC, m_Pos + aOffset, m_unit, m_convert, aDrawMode, aColor,
m_transform, aDrawPinText, false );
} }
else // Use dummy() part if the actual cannot be found. else // Use dummy() part if the actual cannot be found.
{ {
dummy()->Draw( panel, DC, m_Pos + offset, 0, 0, DrawMode, Color, m_transform, DrawPinText, false ); dummy()->Draw( aPanel, aDC, m_Pos + aOffset, 0, 0, aDrawMode, aColor,
m_transform, aDrawPinText, false );
} }
SCH_FIELD* field = GetField( REFERENCE ); SCH_FIELD* field = GetField( REFERENCE );
if( field->IsVisible() && !field->IsMoving() ) if( field->IsVisible() && !field->IsMoving() )
{ {
field->Draw( panel, DC, offset, DrawMode ); field->Draw( aPanel, aDC, aOffset, aDrawMode );
} }
for( int ii = VALUE; ii < GetFieldCount(); ii++ ) for( int ii = VALUE; ii < GetFieldCount(); ii++ )
@ -353,26 +356,26 @@ void SCH_COMPONENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset
if( field->IsMoving() ) if( field->IsMoving() )
continue; continue;
field->Draw( panel, DC, offset, DrawMode ); field->Draw( aPanel, aDC, aOffset, aDrawMode );
} }
#if 0 #if 0
// Draw the component bounding box // Only for testing purposes, draw the component bounding box
{ {
EDA_RECT boundingBox = GetBoundingBox(); EDA_RECT boundingBox = GetBoundingBox();
GRRect( panel->GetClipBox(), DC, boundingBox, 0, BROWN ); GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
#if 1 #if 1
if( GetField( REFERENCE )->IsVisible() ) if( GetField( REFERENCE )->IsVisible() )
{ {
boundingBox = GetField( REFERENCE )->GetBoundingBox(); boundingBox = GetField( REFERENCE )->GetBoundingBox();
GRRect( panel->GetClipBox(), DC, boundingBox, 0, BROWN ); GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
} }
if( GetField( VALUE )->IsVisible() ) if( GetField( VALUE )->IsVisible() )
{ {
boundingBox = GetField( VALUE )->GetBoundingBox(); boundingBox = GetField( VALUE )->GetBoundingBox();
GRRect( panel->GetClipBox(), DC, boundingBox, 0, BROWN ); GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
} }
#endif #endif
} }

View File

@ -1,8 +1,10 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2014 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -133,6 +135,16 @@ public:
return wxT( "SCH_COMPONENT" ); return wxT( "SCH_COMPONENT" );
} }
/**
* Virtual function IsMovableFromAnchorPoint
* Return true for items which are moved with the anchor point at mouse cursor
* and false for items moved with no reference to anchor
* Usually return true for small items (labels, junctions) and false for
* items which can be large (hierarchical sheets, compoments)
* @return false for a componant
*/
bool IsMovableFromAnchorPoint() { return false; }
void SetPartName( const wxString& aName, PART_LIBS* aLibs=NULL ); void SetPartName( const wxString& aName, PART_LIBS* aLibs=NULL );
const wxString& GetPartName() const { return m_part_name; } const wxString& GetPartName() const { return m_part_name; }
@ -287,21 +299,30 @@ public:
*/ */
LIB_PIN* GetPin( const wxString& number ); LIB_PIN* GetPin( const wxString& number );
void Draw( EDA_DRAW_PANEL* panel, /**
wxDC* DC, * Virtual function, from the base class SCH_ITEM::Draw
const wxPoint& offset, */
GR_DRAWMODE draw_mode, void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
EDA_COLOR_T Color = UNSPECIFIED_COLOR ) GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR )
{ {
Draw( panel, DC, offset, draw_mode, Color, true ); Draw( aPanel, aDC, aOffset, aDrawMode, aColor, true );
} }
void Draw( EDA_DRAW_PANEL* panel, /**
wxDC* DC, * Function Draw, specific to components.
const wxPoint& offset, * Draw a component, with or without pin texts.
GR_DRAWMODE draw_mode, * @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes.
EDA_COLOR_T Color, * @param aDC Device Context (can be null)
bool DrawPinText ); * @param aOffset drawing Offset (usually wxPoint(0,0),
* but can be different when moving an object)
* @param aDrawMode GR_OR, GR_XOR, ...
* @param aColor UNSPECIFIED_COLOR to use the normal body item color, or use this color if >= 0
* @param aDrawPinText = true to draw pin texts, false to draw only the pin shape
* usually false to draw a component when moving it, and true otherwise.
*/
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor,
bool aDrawPinText );
void SwapData( SCH_ITEM* aItem ); void SwapData( SCH_ITEM* aItem );

View File

@ -1,8 +1,8 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2014 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -114,8 +114,8 @@ int SCH_FIELD::GetPenSize() const
} }
void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, void SCH_FIELD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
const wxPoint& offset, GR_DRAWMODE DrawMode, EDA_COLOR_T Color ) GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor )
{ {
int orient; int orient;
EDA_COLOR_T color; EDA_COLOR_T color;
@ -131,14 +131,13 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
LineWidth = GetDefaultLineThickness(); LineWidth = GetDefaultLineThickness();
} }
// Clip pen size for small texts: // Clip pen size for small texts:
LineWidth = Clamp_Text_PenSize( LineWidth, m_Size, m_Bold ); LineWidth = Clamp_Text_PenSize( LineWidth, m_Size, m_Bold );
if( ((m_Attributs & TEXT_NO_VISIBLE) && !m_forceVisible) || IsVoid() ) if( ((m_Attributs & TEXT_NO_VISIBLE) && !m_forceVisible) || IsVoid() )
return; return;
GRSetDrawMode( DC, DrawMode ); GRSetDrawMode( aDC, aDrawMode );
// Calculate the text orientation according to the component orientation. // Calculate the text orientation according to the component orientation.
orient = m_Orient; orient = m_Orient;
@ -163,7 +162,7 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
* and use GetBoundaryBox to know the text coordinate considered as centered * and use GetBoundaryBox to know the text coordinate considered as centered
*/ */
EDA_RECT boundaryBox = GetBoundingBox(); EDA_RECT boundaryBox = GetBoundingBox();
textpos = boundaryBox.Centre(); textpos = boundaryBox.Centre() + aOffset;
if( m_forceVisible ) if( m_forceVisible )
{ {
@ -179,8 +178,8 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
color = GetLayerColor( LAYER_FIELDS ); color = GetLayerColor( LAYER_FIELDS );
} }
EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL; EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL;
DrawGraphicText( clipbox, DC, textpos, color, GetFullyQualifiedText(), orient, m_Size, DrawGraphicText( clipbox, aDC, textpos, color, GetFullyQualifiedText(), orient, m_Size,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
LineWidth, m_Italic, m_Bold ); LineWidth, m_Italic, m_Bold );
@ -191,7 +190,7 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
textpos = m_Pos - origin; textpos = m_Pos - origin;
textpos = parentComponent->GetScreenCoord( textpos ); textpos = parentComponent->GetScreenCoord( textpos );
textpos += parentComponent->GetPosition(); textpos += parentComponent->GetPosition();
GRLine( clipbox, DC, origin, textpos, 2, DARKGRAY ); GRLine( clipbox, aDC, origin, textpos, 2, DARKGRAY );
} }
/* Enable this to draw the bounding box around the text field to validate /* Enable this to draw the bounding box around the text field to validate
@ -200,7 +199,7 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
#if 0 #if 0
// Draw boundary box: // Draw boundary box:
GRRect( panel->GetClipBox(), DC, boundaryBox, 0, BROWN ); GRRect( aPanel->GetClipBox(), aDC, boundaryBox, 0, BROWN );
// Draw the text anchor point // Draw the text anchor point
@ -210,9 +209,9 @@ void SCH_FIELD::Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
textpos = parentComponent->GetScreenCoord( textpos ); textpos = parentComponent->GetScreenCoord( textpos );
textpos += parentComponent->GetPosition(); textpos += parentComponent->GetPosition();
const int len = 10; const int len = 10;
GRLine( clipbox, DC, GRLine( clipbox, aDC,
textpos.x - len, textpos.y, textpos.x + len, textpos.y, 0, BLUE ); textpos.x - len, textpos.y, textpos.x + len, textpos.y, 0, BLUE );
GRLine( clipbox, DC, GRLine( clipbox, aDC,
textpos.x, textpos.y - len, textpos.x, textpos.y + len, 0, BLUE ); textpos.x, textpos.y - len, textpos.x, textpos.y + len, 0, BLUE );
#endif #endif
} }

View File

@ -1,8 +1,8 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -134,11 +134,8 @@ public:
return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false; return (m_Attributs & TEXT_NO_VISIBLE) == 0 ? true : false;
} }
void Draw( EDA_DRAW_PANEL* aPanel, void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
const wxPoint& aOffset,
GR_DRAWMODE aDrawMode,
EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
bool Save( FILE* aFile ) const; bool Save( FILE* aFile ) const;

View File

@ -117,6 +117,8 @@ class SCH_ITEM : public EDA_ITEM
protected: protected:
LAYERSCH_ID m_Layer; LAYERSCH_ID m_Layer;
EDA_ITEMS m_connections; ///< List of items connected to this item. EDA_ITEMS m_connections; ///< List of items connected to this item.
wxPoint m_storedPos; ///< a temporary variable used in some move commands
///> to store a initial pos (of the item or mouse cursor)
public: public:
SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType ); SCH_ITEM( EDA_ITEM* aParent, KICAD_T aType );
@ -141,6 +143,19 @@ public:
SCH_ITEM* Next() const { return static_cast<SCH_ITEM*>( Pnext ); } SCH_ITEM* Next() const { return static_cast<SCH_ITEM*>( Pnext ); }
SCH_ITEM* Back() const { return static_cast<SCH_ITEM*>( Pback ); } SCH_ITEM* Back() const { return static_cast<SCH_ITEM*>( Pback ); }
/**
* Virtual function IsMovableFromAnchorPoint
* @return true for items which are moved with the anchor point at mouse cursor
* and false for items moved with no reference to anchor
* Usually return true for small items (labels, junctions) and false for
* items which can be large (hierarchical sheets, compoments)
*/
virtual bool IsMovableFromAnchorPoint() { return true; }
wxPoint& GetStoredPos() { return m_storedPos; }
void SetStoredPos( wxPoint aPos ) { m_storedPos = aPos; }
/** /**
* Function GetLayer * Function GetLayer
* returns the layer this item is on. * returns the layer this item is on.
@ -162,12 +177,17 @@ public:
/** /**
* Function Draw * Function Draw
* Draw a schematic item. Each schematic item should have its own method
* @param aPanel DrawPanel to use (can be null) mainly used for clipping purposes.
* @param aDC Device Context (can be null)
* @param aOffset drawing Offset (usually wxPoint(0,0),
* but can be different when moving an object)
* @param aDrawMode GR_OR, GR_XOR, ...
* @param aColor UNSPECIFIED_COLOR to use the normal body item color,
* or force this color if it is a valid color
*/ */
virtual void Draw( EDA_DRAW_PANEL* aPanel, virtual void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) = 0;
const wxPoint& aOffset,
GR_DRAWMODE aDrawMode,
EDA_COLOR_T aColor = UNSPECIFIED_COLOR ) = 0;
/** /**
* Function Move * Function Move

View File

@ -887,6 +887,14 @@ void SCH_SHEET::MirrorY( int aYaxis_position )
} }
} }
void SCH_SHEET::SetPosition( const wxPoint& aPosition )
{
// Remember the sheet and all pin sheet positions must be
// modified. So use Move function to do that.
Move( aPosition - m_pos );
}
void SCH_SHEET::Resize( const wxSize& aSize ) void SCH_SHEET::Resize( const wxSize& aSize )
{ {

View File

@ -1,8 +1,8 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -95,11 +95,16 @@ public:
bool operator ==( const SCH_SHEET_PIN* aPin ) const; bool operator ==( const SCH_SHEET_PIN* aPin ) const;
void Draw( EDA_DRAW_PANEL* aPanel, /**
wxDC* aDC, * Virtual function IsMovableFromAnchorPoint
const wxPoint& aOffset, * Return true for items which are moved with the anchor point at mouse cursor
GR_DRAWMODE aDraw_mode, * and false for items moved with no reference to anchor
EDA_COLOR_T aColor = UNSPECIFIED_COLOR ); * @return false for a hierarchical sheet pin
*/
bool IsMovableFromAnchorPoint() { return false; }
void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
/** /**
* Function CreateGraphicShape (virtual) * Function CreateGraphicShape (virtual)
@ -247,6 +252,15 @@ public:
return wxT( "SCH_SHEET" ); return wxT( "SCH_SHEET" );
} }
/**
* Virtual function IsMovableFromAnchorPoint
* Return true for items which are moved with the anchor point at mouse cursor
* and false for items moved with no reference to anchor
* Usually return true for small items (labels, junctions) and false for
* items which can be large (hierarchical sheets, compoments)
* @return false for a hierarchical sheet
*/
bool IsMovableFromAnchorPoint() { return false; }
wxString GetName() const { return m_name; } wxString GetName() const { return m_name; }
@ -392,11 +406,8 @@ public:
int GetPenSize() const; int GetPenSize() const;
void Draw( EDA_DRAW_PANEL* aPanel, void Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
wxDC* aDC, GR_DRAWMODE aDrawMode, EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
const wxPoint& aOffset,
GR_DRAWMODE aDrawMode,
EDA_COLOR_T aColor = UNSPECIFIED_COLOR );
EDA_RECT const GetBoundingBox() const; EDA_RECT const GetBoundingBox() const;
@ -549,7 +560,7 @@ public:
wxPoint GetPosition() const { return m_pos; } wxPoint GetPosition() const { return m_pos; }
void SetPosition( const wxPoint& aPosition ) { m_pos = aPosition; } void SetPosition( const wxPoint& aPosition );
bool HitTest( const wxPoint& aPosition, int aAccuracy ) const; bool HitTest( const wxPoint& aPosition, int aAccuracy ) const;

View File

@ -1,8 +1,8 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -131,11 +131,8 @@ public:
*/ */
virtual wxPoint GetSchematicTextOffset() const; virtual wxPoint GetSchematicTextOffset() const;
virtual void Draw( EDA_DRAW_PANEL* panel, virtual void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
wxDC* DC, GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR );
const wxPoint& offset,
GR_DRAWMODE draw_mode,
EDA_COLOR_T Color = UNSPECIFIED_COLOR );
/** /**
* Function CreateGraphicShape * Function CreateGraphicShape
@ -230,11 +227,8 @@ public:
~SCH_LABEL() { } ~SCH_LABEL() { }
void Draw( EDA_DRAW_PANEL* panel, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
wxDC* DC, GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR );
const wxPoint& offset,
GR_DRAWMODE draw_mode,
EDA_COLOR_T Color = UNSPECIFIED_COLOR );
wxString GetClass() const wxString GetClass() const
{ {
@ -279,11 +273,8 @@ public:
~SCH_GLOBALLABEL() { } ~SCH_GLOBALLABEL() { }
void Draw( EDA_DRAW_PANEL* panel, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
wxDC* DC, GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR );
const wxPoint& offset,
GR_DRAWMODE draw_mode,
EDA_COLOR_T Color = UNSPECIFIED_COLOR );
wxString GetClass() const wxString GetClass() const
{ {
@ -332,11 +323,8 @@ public:
~SCH_HIERLABEL() { } ~SCH_HIERLABEL() { }
void Draw( EDA_DRAW_PANEL* panel, void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, const wxPoint& offset,
wxDC* DC, GR_DRAWMODE draw_mode, EDA_COLOR_T Color = UNSPECIFIED_COLOR );
const wxPoint& offset,
GR_DRAWMODE draw_mode,
EDA_COLOR_T Color = UNSPECIFIED_COLOR );
wxString GetClass() const wxString GetClass() const
{ {

View File

@ -443,21 +443,26 @@ void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
case SCH_COMPONENT_T: case SCH_COMPONENT_T:
case SCH_SHEET_PIN_T: case SCH_SHEET_PIN_T:
case SCH_FIELD_T: case SCH_FIELD_T:
MoveItem( item, &dc ); case SCH_SHEET_T:
PrepareMoveItem( item, &dc );
break; break;
case SCH_BITMAP_T: case SCH_BITMAP_T:
// move an image is a special case:
// we cannot undraw/redraw a bitmap just using our xor mode
// the MoveImage function handle this undraw/redraw difficulty
// By redrawing the full bounding box
MoveImage( (SCH_BITMAP*) item, &dc ); MoveImage( (SCH_BITMAP*) item, &dc );
break; break;
case SCH_SHEET_T:
StartMoveSheet( (SCH_SHEET*) item, &dc );
break;
case SCH_MARKER_T: case SCH_MARKER_T:
default: // Moving a marker has no sense
wxFAIL_MSG( wxString::Format( wxT( "Cannot move item type %s" ), wxFAIL_MSG( wxString::Format( wxT( "Cannot move item type %s" ),
GetChars( item->GetClass() ) ) ); GetChars( item->GetClass() ) ) );
default:
// Unknown items cannot be moved
wxFAIL_MSG( wxString::Format(
wxT( "Cannot move unknown item type %d" ), item->Type() ) );
break; break;
} }
@ -640,24 +645,43 @@ bool SCH_EDIT_FRAME::DeleteItemAtCrossHair( wxDC* DC )
return false; return false;
} }
// This function is a callback function, called by the mouse cursor movin event
static void moveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, bool aErase ) // when an item is currently moved
static void moveItemWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase )
{ {
SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen(); SCH_SCREEN* screen = (SCH_SCREEN*) aPanel->GetScreen();
SCH_ITEM* item = screen->GetCurItem(); SCH_ITEM* item = screen->GetCurItem();
wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) ); wxCHECK_RET( (item != NULL), wxT( "Cannot move invalid schematic item." ) );
SCH_COMPONENT* cmp = NULL;
if( item->Type() == SCH_COMPONENT_T )
cmp = static_cast< SCH_COMPONENT* >( item );
#ifndef USE_WX_OVERLAY #ifndef USE_WX_OVERLAY
// Erase the current item at its current position. // Erase the current item at its current position.
if( aErase ) if( aErase )
{
if( cmp ) // Use fast mode (do not draw pin texts)
cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, UNSPECIFIED_COLOR, false );
else
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
}
#endif #endif
item->SetPosition( aPanel->GetParent()->GetCrossHairPosition() ); wxPoint cpos = aPanel->GetParent()->GetCrossHairPosition();
cpos -= item->GetStoredPos();
item->SetPosition( cpos );
// Draw the item item at it's new position. // Draw the item item at it's new position.
item->SetWireImage(); // While moving, the item may choose to render differently item->SetWireImage(); // While moving, the item may choose to render differently
if( cmp ) // Use fast mode (do not draw pin texts)
cmp->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, UNSPECIFIED_COLOR, false );
else
item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); item->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
} }
@ -714,7 +738,7 @@ static void abortMoveItem( EDA_DRAW_PANEL* aPanel, wxDC* aDC )
} }
void SCH_EDIT_FRAME::MoveItem( SCH_ITEM* aItem, wxDC* aDC ) void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC )
{ {
wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) ); wxCHECK_RET( aItem != NULL, wxT( "Cannot move invalid schematic item" ) );
@ -729,22 +753,27 @@ void SCH_EDIT_FRAME::MoveItem( SCH_ITEM* aItem, wxDC* aDC )
} }
aItem->SetFlags( IS_MOVED ); aItem->SetFlags( IS_MOVED );
#ifdef USE_WX_OVERLAY
this->Refresh();
this->Update();
#endif
m_canvas->CrossHairOff( aDC );
if( aItem->Type() != SCH_SHEET_PIN_T ) // For some items, moving the cursor to anchor is not good
// (for instance large hierarchical sheets od componants can have
// the anchor position outside the canvas)
// these items return IsMovableFromAnchorPoint() == false
// For these items, do not wrap the cursor
if( aItem->IsMovableFromAnchorPoint() )
{
SetCrossHairPosition( aItem->GetPosition() ); SetCrossHairPosition( aItem->GetPosition() );
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
aItem->SetStoredPos( wxPoint( 0,0 ) );
}
else
aItem->SetStoredPos( GetCrossHairPosition() - aItem->GetPosition() );
OnModify(); OnModify();
m_canvas->SetMouseCapture( moveItem, abortMoveItem ); m_canvas->SetMouseCapture( moveItemWithMouseCursor, abortMoveItem );
GetScreen()->SetCurItem( aItem ); GetScreen()->SetCurItem( aItem );
moveItem( m_canvas, aDC, wxDefaultPosition, true );
m_canvas->CrossHairOn( aDC ); m_canvas->Refresh();
} }

View File

@ -846,13 +846,13 @@ private:
SCH_JUNCTION* AddJunction( wxDC* aDC, const wxPoint& aPosition, bool aPutInUndoList = false ); SCH_JUNCTION* AddJunction( wxDC* aDC, const wxPoint& aPosition, bool aPutInUndoList = false );
/** /**
* Function MoveItem * Function PrepareMoveItem
* start moving \a aItem using the mouse. * start moving \a aItem using the mouse.
* *
* @param aItem A pointer to an SCH_ITEM to move. * @param aItem A pointer to an SCH_ITEM to move.
* @param aDC The device context to draw \a aItem. * @param aDC The device context to draw \a aItem.
*/ */
void MoveItem( SCH_ITEM* aItem, wxDC* aDC ); void PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC );
// Text, label, glabel // Text, label, glabel
SCH_TEXT* CreateNewText( wxDC* aDC, int aType ); SCH_TEXT* CreateNewText( wxDC* aDC, int aType );
@ -947,8 +947,6 @@ public:
wxPoint GetLastSheetPinPosition() const { return m_lastSheetPinPosition; } wxPoint GetLastSheetPinPosition() const { return m_lastSheetPinPosition; }
private: private:
void StartMoveSheet( SCH_SHEET* sheet, wxDC* DC );
/** /**
* Function CreateSheetPin * Function CreateSheetPin
* creates a new SCH_SHEET_PIN object and add it to \a aSheet at the current cursor position. * creates a new SCH_SHEET_PIN object and add it to \a aSheet at the current cursor position.

View File

@ -251,9 +251,11 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
/* Move selected sheet with the cursor. /* Move selected sheet with the cursor.
* Callback function use by m_mouseCaptureCallback. * Callback function used by m_mouseCaptureCallback.
* Note also now this function is aclled only when resizing the sheet
* But the (very small code) relative to sheet move is still present here
*/ */
static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition, static void resizeSheetWithMouseCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
bool aErase ) bool aErase )
{ {
wxPoint moveVector; wxPoint moveVector;
@ -265,8 +267,6 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
wxPoint pos = sheet->GetPosition(); wxPoint pos = sheet->GetPosition();
if( sheet->IsResized() )
{
int width = aPanel->GetParent()->GetCrossHairPosition().x - sheet->GetPosition().x; int width = aPanel->GetParent()->GetCrossHairPosition().x - sheet->GetPosition().x;
int height = aPanel->GetParent()->GetCrossHairPosition().y - sheet->GetPosition().y; int height = aPanel->GetParent()->GetCrossHairPosition().y - sheet->GetPosition().y;
@ -289,12 +289,6 @@ static void MoveOrResizeSheet( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint&
wxPoint grid = aPanel->GetParent()->GetNearestGridPosition( wxPoint grid = aPanel->GetParent()->GetNearestGridPosition(
wxPoint( pos.x + width, pos.y + height ) ); wxPoint( pos.x + width, pos.y + height ) );
sheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) ); sheet->Resize( wxSize( grid.x - pos.x, grid.y - pos.y ) );
}
else if( sheet->IsMoving() )
{
moveVector = aPanel->GetParent()->GetCrossHairPosition() - pos;
sheet->Move( moveVector );
}
sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode ); sheet->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode );
} }
@ -360,7 +354,7 @@ SCH_SHEET* SCH_EDIT_FRAME::CreateSheet( wxDC* aDC )
// also need to update the hierarchy, if we are adding // also need to update the hierarchy, if we are adding
// a sheet to a screen that already has multiple instances (!) // a sheet to a screen that already has multiple instances (!)
GetScreen()->SetCurItem( sheet ); GetScreen()->SetCurItem( sheet );
m_canvas->SetMouseCapture( MoveOrResizeSheet, ExitSheet ); m_canvas->SetMouseCapture( resizeSheetWithMouseCursor, ExitSheet );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false ); m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
m_canvas->CrossHairOff( aDC ); m_canvas->CrossHairOff( aDC );
@ -390,28 +384,10 @@ void SCH_EDIT_FRAME::ReSizeSheet( SCH_SHEET* aSheet, wxDC* aDC )
SetUndoItem( aSheet ); SetUndoItem( aSheet );
aSheet->SetFlags( IS_RESIZED ); aSheet->SetFlags( IS_RESIZED );
m_canvas->SetMouseCapture( MoveOrResizeSheet, ExitSheet ); m_canvas->SetMouseCapture( resizeSheetWithMouseCursor, ExitSheet );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, true ); m_canvas->CallMouseCapture( aDC, wxDefaultPosition, true );
if( aSheet->IsNew() ) // not already in edit, save a copy for undo/redo if( aSheet->IsNew() ) // not already in edit, save a copy for undo/redo
SetUndoItem( aSheet ); SetUndoItem( aSheet );
} }
void SCH_EDIT_FRAME::StartMoveSheet( SCH_SHEET* aSheet, wxDC* aDC )
{
if( ( aSheet == NULL ) || ( aSheet->Type() != SCH_SHEET_T ) )
return;
m_canvas->CrossHairOff( aDC );
SetCrossHairPosition( aSheet->GetPosition() );
m_canvas->MoveCursorToCrossHair();
if( !aSheet->IsNew() )
SetUndoItem( aSheet );
aSheet->SetFlags( IS_MOVED );
m_canvas->SetMouseCapture( MoveOrResizeSheet, ExitSheet );
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, true );
m_canvas->CrossHairOn( aDC );
}

View File

@ -128,7 +128,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::CreateSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
sheetPin->SetPosition( GetCrossHairPosition() ); sheetPin->SetPosition( GetCrossHairPosition() );
sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
MoveItem( (SCH_ITEM*) sheetPin, aDC ); PrepareMoveItem( (SCH_ITEM*) sheetPin, aDC );
OnModify(); OnModify();
return sheetPin; return sheetPin;
@ -174,7 +174,7 @@ SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
sheetPin->SetPosition( GetCrossHairPosition() ); sheetPin->SetPosition( GetCrossHairPosition() );
sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
MoveItem( (SCH_ITEM*) sheetPin, aDC ); PrepareMoveItem( (SCH_ITEM*) sheetPin, aDC );
return sheetPin; return sheetPin;
} }

View File

@ -1,7 +1,7 @@
bom_?.py are some python scripts which read a generic xml netlist from eeschema, bom_?.py are some python scripts which read a generic xml netlist from eeschema,
and create a bom. and create a bom.
All examples use ky_netlist_reader.py, which is a python utility to read All examples use kicad_netlist_reader.py, which is a python utility to read
and parse this generic xml netlist and create the corresponding data and parse this generic xml netlist and create the corresponding data
used to build the bom. used to build the bom.

View File

@ -3,11 +3,12 @@
# #
""" """
@package @package
Generate a csv list file. Generate a BOM list file.
Components are sorted by ref and grouped by value Components are sorted by ref
One component per line One component per line
Fields are (if exist) Fields are (if exist)
Ref, Quantity, value, Part, footprint, 'Description', 'Vendor' Ref, Quantity, value, Part, footprint, 'Description', 'Vendor'
Fields are separated by tabs
""" """
from __future__ import print_function from __future__ import print_function
@ -38,7 +39,8 @@ out = csv.writer(f, lineterminator='\n', delimiter='\t', quoting=csv.QUOTE_NONE)
def writerow( acsvwriter, columns ): def writerow( acsvwriter, columns ):
utf8row = [] utf8row = []
for col in columns: for col in columns:
utf8row.append( str(col).encode('utf8') ) txt=str(col);
utf8row.append( txt.encode('utf-8') )
acsvwriter.writerow( utf8row ) acsvwriter.writerow( utf8row )
components = net.getInterestingComponents() components = net.getInterestingComponents()

View File

@ -7,7 +7,7 @@
""" """
@package @package
Generate a csv list file. Generate a csv list file.
Components are sorted by ref and grouped by value Components are sorted by ref
One component per line One component per line
Fields are (if exist) Fields are (if exist)
Ref, value, Part, footprint, Datasheet, Manufacturer, Vendor Ref, value, Part, footprint, Datasheet, Manufacturer, Vendor