Footprint editor: add save view to PNG file.

Factor out save current canvas view to image file code from symbol editor
code so it can be used anywhere.

Add ability to save to any image format supported by wxBitmapType.  See
https://docs.wxwidgets.org/3.0/gdicmn_8h.html#a90a1eb6d85b5044a99b706fd979f27f5.
Currently only PNG output is implemented.

Please note that there is a minor bug that appears to be due to the
scroll bars which causes unfilled areas on the right and bottom edges
of the image.  This always existed in the save symbol editor view
image but it was not as noticeable because by default the background
color is white.  It is very noticeable in the footprint editor with
a black background.

The usual smattering of coding policy and comment fixes.

Fixes lp:1802127

https://bugs.launchpad.net/kicad/+bug/1802127
This commit is contained in:
Wayne Stambaugh 2018-11-09 08:32:13 -05:00
parent 6860320b1b
commit f1f4473d8b
11 changed files with 317 additions and 281 deletions

View File

@ -38,6 +38,7 @@
#include <bitmaps.h>
#include <pgm_base.h>
#include <eda_base_frame.h>
#include <draw_frame.h>
struct SCALED_BITMAP_ID {
@ -191,6 +192,34 @@ wxBitmap* KiBitmapNew( BITMAP_DEF aBitmap )
}
bool SaveCanvasImageToFile( EDA_DRAW_FRAME* aFrame, const wxString& aFileName,
wxBitmapType aBitmapType )
{
wxCHECK( aFrame != nullptr, false );
bool retv = true;
// Make a screen copy of the canvas:
wxSize image_size = aFrame->GetGalCanvas()->GetClientSize();
wxClientDC dc( aFrame->GetGalCanvas() );
wxBitmap bitmap( image_size.x, image_size.y );
wxMemoryDC memdc;
memdc.SelectObject( bitmap );
memdc.Blit( 0, 0, image_size.x, image_size.y, &dc, 0, 0 );
memdc.SelectObject( wxNullBitmap );
wxImage image = bitmap.ConvertToImage();
if( !image.SaveFile( aFileName, aBitmapType ) )
retv = false;
image.Destroy();
return retv;
}
wxMenuItem* AddMenuItem( wxMenu* aMenu, int aId, const wxString& aText,
const wxBitmap& aImage, wxItemKind aType = wxITEM_NORMAL )
{

View File

@ -273,6 +273,7 @@ void EDA_DRAW_FRAME::unitsChangeRefresh()
UpdateMsgPanel();
}
void EDA_DRAW_FRAME::CommonSettingsChanged()
{
EDA_BASE_FRAME::CommonSettingsChanged();
@ -348,6 +349,7 @@ void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
m_canvas->Refresh();
}
bool EDA_DRAW_FRAME::GetToolToggled( int aToolId )
{
// Checks all the toolbars and returns true if the given tool id is toggled.
@ -463,7 +465,9 @@ bool EDA_DRAW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
return false;
}
int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName )
int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
wxString* aFullFileName )
{
int result = EDA_BASE_FRAME::WriteHotkeyConfig( aDescList, aFullFileName );
@ -473,6 +477,7 @@ int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxSt
return result;
}
void EDA_DRAW_FRAME::ToolOnRightClick( wxCommandEvent& event )
{
}
@ -634,6 +639,7 @@ void EDA_DRAW_FRAME::SetNoToolSelected()
SetToolID( ID_NO_TOOL_SELECTED, defaultCursor, wxEmptyString );
}
wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
{
wxPoint pos = aPosition;
@ -743,6 +749,7 @@ void EDA_DRAW_FRAME::UpdateStatusBar()
DisplayUnitsMsg();
}
const wxString EDA_DRAW_FRAME::GetZoomLevelIndicator() const
{
wxString Line;
@ -873,6 +880,7 @@ void EDA_DRAW_FRAME::UpdateMsgPanel()
SetMsgPanel( item );
}
// FIXME: There needs to be a better way for child windows to load preferences.
// This function pushes four preferences from a parent window to a child window
// i.e. from eeschema to the schematic symbol editor
@ -882,6 +890,7 @@ void EDA_DRAW_FRAME::PushPreferences( const EDA_DRAW_PANEL* aParentCanvas )
m_canvas->SetEnableAutoPan( aParentCanvas->GetEnableAutoPan() );
}
bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
int aExplicitCommand )
{
@ -1085,7 +1094,8 @@ wxPoint EDA_DRAW_FRAME::GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize
}
wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize ) const
wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition,
wxRealPoint* aGridSize ) const
{
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->getNearestGridPosition( aPosition, GetGridOrigin(), aGridSize );
@ -1156,6 +1166,7 @@ void EDA_DRAW_FRAME::RefreshCrossHair( const wxPoint &aOldPos,
#endif
}
bool EDA_DRAW_FRAME::GeneralControlKeyMovement( int aHotKey, wxPoint *aPos,
bool aSnapToGrid )
{
@ -1265,11 +1276,13 @@ bool EDA_DRAW_FRAME::isBusy() const
|| ( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK );
}
const BOX2I EDA_DRAW_FRAME::GetDocumentExtents() const
{
return BOX2I();
}
void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
{
}
@ -1541,6 +1554,7 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
AddMenuItem( MasterMenu, ID_POPUP_CANCEL, _( "Close" ), KiBitmap( cancel_xpm ) );
}
static bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame );
@ -1775,3 +1789,9 @@ bool EDA_DRAW_FRAME::LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
return true;
}
bool EDA_DRAW_FRAME::saveCanvasImageToFile( const wxString& aFileName, wxBitmapType aBitmapType )
{
return SaveCanvasImageToFile( this, aFileName, aBitmapType );
}

View File

@ -351,6 +351,7 @@ void EDA_DRAW_FRAME::OnToggleGridState( wxCommandEvent& aEvent )
m_canvas->Refresh();
}
bool EDA_DRAW_FRAME::GetToolToggled( int aToolId )
{
// Checks all the toolbars and returns true if the given tool id is toggled.
@ -467,7 +468,8 @@ bool EDA_DRAW_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
return false;
}
int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName )
int EDA_DRAW_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
wxString* aFullFileName )
{
int result = EDA_BASE_FRAME::WriteHotkeyConfig( aDescList, aFullFileName );
@ -608,7 +610,6 @@ void EDA_DRAW_FRAME::DisplayUnitsMsg()
}
void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
{
m_FrameSize = GetClientSize( );
@ -657,6 +658,7 @@ void EDA_DRAW_FRAME::SetNoToolSelected()
SetToolID( ID_NO_TOOL_SELECTED, defaultCursor, wxEmptyString );
}
wxPoint EDA_DRAW_FRAME::GetGridPosition( const wxPoint& aPosition ) const
{
wxPoint pos = aPosition;
@ -762,6 +764,7 @@ void EDA_DRAW_FRAME::UpdateStatusBar()
DisplayUnitsMsg();
}
const wxString EDA_DRAW_FRAME::GetZoomLevelIndicator() const
{
wxString Line;
@ -900,6 +903,7 @@ void EDA_DRAW_FRAME::UpdateMsgPanel()
SetMsgPanel( item );
}
// FIXME: There needs to be a better way for child windows to load preferences.
// This function pushes four preferences from a parent window to a child window
// i.e. from eeschema to the schematic symbol editor
@ -909,8 +913,9 @@ void EDA_DRAW_FRAME::PushPreferences( const EDA_DRAW_PANEL* aParentCanvas )
m_canvas->SetEnableAutoPan( aParentCanvas->GetEnableAutoPan() );
}
bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& aPosition,
int aExplicitCommand )
int aExplicitCommand )
{
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
@ -1560,6 +1565,7 @@ bool EDA_DRAW_FRAME::isBusy() const
|| ( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK );
}
void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
{
if( IsGalCanvasActive() )
@ -1856,8 +1862,10 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
AddMenuItem( MasterMenu, ID_POPUP_CANCEL, _( "Close" ), KiBitmap( cancel_xpm ) );
}
static bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame );
void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event )
{
DrawPageOnClipboard( this );
@ -1903,6 +1911,7 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
wxSize dcsize = DrawArea.GetSize();
int maxdim = std::max( dcsize.x, dcsize.y );
// the max size in pixels of the bitmap used to byuild the sheet copy
const int maxbitmapsize = 3000;
@ -2006,8 +2015,8 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox,
void EDA_DRAW_FRAME::DrawWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth,
double aScalar, const wxString &aFilename,
const wxString &aSheetLayer )
double aScalar, const wxString &aFilename,
const wxString &aSheetLayer )
{
if( !m_showBorderAndTitleBlock )
return;
@ -2055,9 +2064,16 @@ wxString EDA_DRAW_FRAME::GetScreenDesc() const
return wxEmptyString;
}
const BOX2I EDA_DRAW_FRAME::GetDocumentExtents() const
{
BOX2I rv;
rv.SetMaximum();
return rv;
}
bool EDA_DRAW_FRAME::saveCanvasImageToFile( const wxString& aFileName, wxBitmapType aBitmapType )
{
return SaveCanvasImageToFile( this, aFileName, aBitmapType );
}

View File

@ -672,11 +672,12 @@ public:
void RepeatPinItem( wxDC* DC, LIB_PIN* Pin );
/**
* Creates an image (screenshot) of the current component in PNG or JPEG format.
* Creates an image (screenshot) of the current symbol.
*
* @param aFileName = the full filename
* @param aFmt_jpeg = true to use JPEG file format, false to use PNG file format
* @param aBitmapType = bitmap file format
*/
void CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg );
void CreateImageFile( const wxString& aFileName, wxBitmapType aBitmapType = wxBITMAP_TYPE_PNG );
/**
* Print a page

View File

@ -35,6 +35,7 @@
#include <gestfich.h>
#include <eeschema_id.h>
#include <sch_screen.h>
#include <wildcards_and_files_ext.h>
#include <general.h>
#include <lib_edit_frame.h>
@ -59,87 +60,68 @@ void LIB_EDIT_FRAME::OnPlotCurrentComponent( wxCommandEvent& event )
switch( event.GetId() )
{
case ID_LIBEDIT_GEN_PNG_FILE:
{
bool fmt_is_jpeg = false; // could be selectable later. so keep this option.
{
mask = wxT( "*." ) + file_ext;
wxFileName fn( part->GetName() );
fn.SetExt( "png" );
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
mask = wxT( "*." ) + file_ext;
wxFileName fn( part->GetName() );
fn.SetExt( file_ext );
wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
wxFileDialog dlg( this, _( "Image File Name" ), projectPath,
fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
fullFileName = EDA_FILE_SELECTOR( _( "Filename:" ), pro_dir,
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, true );
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
return;
if( fullFileName.IsEmpty() )
return;
// calling wxYield is mandatory under Linux, after closing the file selector dialog
// to refresh the screen before creating the PNG or JPEG image from screen
wxYield();
CreatePNGorJPEGFile( fullFileName, fmt_is_jpeg );
}
// calling wxYield is mandatory under Linux, after closing the file selector dialog
// to refresh the screen before creating the PNG or JPEG image from screen
wxYield();
CreateImageFile( dlg.GetPath(), wxBITMAP_TYPE_PNG );
}
break;
case ID_LIBEDIT_GEN_SVG_FILE:
{
file_ext = wxT( "svg" );
mask = wxT( "*." ) + file_ext;
wxFileName fn( part->GetName() );
fn.SetExt( file_ext );
{
file_ext = wxT( "svg" );
mask = wxT( "*." ) + file_ext;
wxFileName fn( part->GetName() );
fn.SetExt( file_ext );
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() );
fullFileName = EDA_FILE_SELECTOR( _( "Filename:" ), pro_dir,
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, true );
fullFileName = EDA_FILE_SELECTOR( _( "Filename:" ), pro_dir,
fn.GetFullName(), file_ext, mask, this,
wxFD_SAVE, true );
if( fullFileName.IsEmpty() )
return;
if( fullFileName.IsEmpty() )
return;
PAGE_INFO pageSave = GetScreen()->GetPageSettings();
PAGE_INFO pageTemp = pageSave;
PAGE_INFO pageSave = GetScreen()->GetPageSettings();
PAGE_INFO pageTemp = pageSave;
wxSize componentSize = part->GetUnitBoundingBox( m_unit, m_convert ).GetSize();
wxSize componentSize = part->GetUnitBoundingBox( m_unit, m_convert ).GetSize();
// Add a small margin to the plot bounding box
pageTemp.SetWidthMils( int( componentSize.x * 1.2 ) );
pageTemp.SetHeightMils( int( componentSize.y * 1.2 ) );
// Add a small margin to the plot bounding box
pageTemp.SetWidthMils( int( componentSize.x * 1.2 ) );
pageTemp.SetHeightMils( int( componentSize.y * 1.2 ) );
GetScreen()->SetPageSettings( pageTemp );
SVG_PlotComponent( fullFileName );
GetScreen()->SetPageSettings( pageSave );
}
GetScreen()->SetPageSettings( pageTemp );
SVG_PlotComponent( fullFileName );
GetScreen()->SetPageSettings( pageSave );
}
break;
}
}
void LIB_EDIT_FRAME::CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_jpeg )
void LIB_EDIT_FRAME::CreateImageFile( const wxString& aFileName, wxBitmapType aBitmapType )
{
// Make a screen copy of the canvas:
wxSize image_size = GetGalCanvas()->GetClientSize();
wxClientDC dc( GetGalCanvas() );
wxBitmap bitmap( image_size.x, image_size.y );
wxMemoryDC memdc;
memdc.SelectObject( bitmap );
memdc.Blit( 0, 0, image_size.x, image_size.y, &dc, 0, 0 );
memdc.SelectObject( wxNullBitmap );
wxImage image = bitmap.ConvertToImage();
if( !image.SaveFile( aFileName, aFmt_jpeg ? wxBITMAP_TYPE_JPEG : wxBITMAP_TYPE_PNG ) )
if( !saveCanvasImageToFile( aFileName, aBitmapType ) )
{
wxString msg;
msg.Printf( _( "Can't save file \"%s\"" ), GetChars( aFileName ) );
msg.Printf( _( "Can't save file \"%s\"." ), aFileName );
wxMessageBox( msg );
}
image.Destroy();
}
@ -192,7 +174,8 @@ void LIB_EDIT_FRAME::SVG_PlotComponent( const wxString& aFullFileName )
delete plotter;
}
void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData)
void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMode, void* aData )
{
LIB_PART* part = GetCurPart();
@ -206,8 +189,8 @@ void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, LSET aPrintMask, bool aPrintMirrorMod
* So we must plot it with an offset = pagesize/2.
*/
wxPoint plot_offset;
plot_offset.x = pagesize.x/2;
plot_offset.y = pagesize.y/2;
plot_offset.x = pagesize.x / 2;
plot_offset.y = pagesize.y / 2;
part->Draw( m_canvas, aDC, plot_offset, m_unit, m_convert, PART_DRAW_OPTIONS::Default() );
}

View File

@ -31,10 +31,12 @@
// #include <wx/bitmap.h> // only to define wxBitmap
class wxBitmap; // only to define wxBitmap
class EDA_BASE_FRAME;
class EDA_DRAW_FRAME;
class wxWindow;
class wxAuiToolBar;
#include <config.h>
#include <wx/gdicmn.h> // wxBitmapType
/// PNG memory record (file in memory).
@ -46,7 +48,7 @@ struct BITMAP_OPAQUE
};
// declared as single element _array_, so its name assigns to pointer
#define EXTERN_BITMAP(x) extern const BITMAP_OPAQUE x[1];
#define EXTERN_BITMAP( x ) extern const BITMAP_OPAQUE x[1];
/// a BITMAP_DEF is really a const pointer to an opaque
@ -55,16 +57,14 @@ typedef const BITMAP_OPAQUE *BITMAP_DEF;
/**
* Function KiBitmap
* constructs a wxBitmap from a memory record, held in a
* BITMAP_DEF.
* Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
*/
wxBitmap KiBitmap( BITMAP_DEF aBitmap );
/**
* Function KiScaledBitmap
* Constructs a wxBitmap from a memory record, scaling it if device DPI demands it.
* Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
*
* Internally this may use caching to avoid scaling the same image twice. If caching
* is used, it's guaranteed threadsafe.
*
@ -74,8 +74,7 @@ wxBitmap KiBitmap( BITMAP_DEF aBitmap );
wxBitmap KiScaledBitmap( BITMAP_DEF aBitmap, EDA_BASE_FRAME* aWindow );
/**
* Function KiScaledBitmap
* Overload of the above function that takes another wxBitmap as a parameter
* Overload of the above function that takes another wxBitmap as a parameter.
*
* @param aBitmap bitmap definition
* @param aWindow target window for scaling context
@ -83,27 +82,32 @@ wxBitmap KiScaledBitmap( BITMAP_DEF aBitmap, EDA_BASE_FRAME* aWindow );
wxBitmap KiScaledBitmap( const wxBitmap& aBitmap, EDA_BASE_FRAME* aWindow );
/**
* Function KiScaledSeparator
* Adds a separator to the given toolbar scaled the same way as KiScaledBitmap.
* Add a separator to the given toolbar scaled the same way as KiScaledBitmap.
*/
void KiScaledSeparator( wxAuiToolBar* aToolbar, EDA_BASE_FRAME* aWindow );
/**
* Function KiIconScale
* Returns the automatic scale factor that would be used for a given window by
* Return the automatic scale factor that would be used for a given window by
* KiScaledBitmap and KiScaledSeparator.
*/
int KiIconScale( wxWindow* aWindow );
/**
* Function KiBitmapNew
* allocates a wxBitmap on heap from a memory record, held in a
* BITMAP_DEF.
* Allocate a wxBitmap on heap from a memory record, held in a BITMAP_DEF.
*
* @return wxBitmap* - caller owns it.
*/
wxBitmap* KiBitmapNew( BITMAP_DEF aBitmap );
/**
* Save the current view as an image file.
*
* @param aFrame The current draw frame view to save.
* @param aFileName The file name to save the image. This will overwrite an exisiting file.
* @param aBitmapType The type of bitmap create as defined by wxImage.
* @return True if the file was successfully saved or false if the file failed to be saved.
*/
bool SaveCanvasImageToFile( EDA_DRAW_FRAME* aFrame, const wxString& aFileName,
wxBitmapType aBitmapType = wxBITMAP_TYPE_PNG );
#endif // BITMAP_TYPES_H_

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2009 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -72,8 +72,7 @@ static const wxString LastGridSizeIdKeyword( wxT( "_LastGridSize" ) );
/**
* Class EDA_DRAW_FRAME
* is the base class for create windows for drawing purpose. The Eeschema, Pcbnew and
* The base class for create windows for drawing purpose. The Eeschema, Pcbnew and
* GerbView main windows are just a few examples of classes derived from EDA_DRAW_FRAME.
*/
class EDA_DRAW_FRAME : public KIWAY_PLAYER
@ -184,8 +183,7 @@ protected:
double bestZoom( double sizeX, double sizeY, double scaleFactor, wxPoint centre );
/**
* Function unitsChangeRefresh
* is called when when the units setting has changed to allow for any derived classes
* Called when when the units setting has changed to allow for any derived classes
* to handle refreshing and controls that have units based measurements in them. The
* default version only updates the status bar. Don't forget to call the default
* in your derived class or the status bar will not get updated properly.
@ -195,22 +193,21 @@ protected:
void CommonSettingsChanged() override;
/**
* Function LibraryFileBrowser
* @param doOpen if true runs an Open Library browser, otherwise New Library
* @param aFilename for New may contain a default name; in both cases return the chosen
* filename.
* @param wildcard a wildcard to filter the displayed files
* @param ext the library file extension
* @param isDirectory indicates the library files are directories
* @return true for OK; false for Cancel.
*/
* @param doOpen if true runs an Open Library browser, otherwise New Library
* @param aFilename for New may contain a default name; in both cases return the chosen
* filename.
* @param wildcard a wildcard to filter the displayed files
* @param ext the library file extension
* @param isDirectory indicates the library files are directories
* @return true for OK; false for Cancel.
*/
bool LibraryFileBrowser( bool doOpen, wxFileName& aFilename,
const wxString& wildcard, const wxString& ext, bool isDirectory );
/**
* Function GeneralControlKeyMovement
* Handle the common part of GeneralControl dedicated to global
* cursor keys (i.e. cursor movement by keyboard)
*
* @param aHotKey is the hotkey code
* @param aPos is the position of the cursor (initial then new)
* @param aSnapToGrid = true to force the cursor position on grid
@ -233,6 +230,9 @@ protected:
*/
bool saveCanvasTypeSetting( EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType );
bool saveCanvasImageToFile( const wxString& aFileName,
wxBitmapType aBitmapType = wxBITMAP_TYPE_PNG );
///> Key in KifaceSettings to store the canvas type.
static const wxChar CANVAS_TYPE_KEY[];
@ -246,7 +246,9 @@ public:
~EDA_DRAW_FRAME();
/** this function capture the key event before it is sent to the GUI.
/**
* Capture the key event before it is sent to the GUI.
*
* the basic frame does not capture this event.
* editor frames should override this event function to capture and filter
* these keys when they are used as hotkeys, and skip it if the key is not
@ -255,15 +257,14 @@ public:
virtual void OnCharHook( wxKeyEvent& event );
/**
* Function LockFile
* marks a schematic file as being in use. Use ReleaseFile() to undo this.
* Mark a schematic file as being in use. Use ReleaseFile() to undo this.
*
* @param aFileName = full path to the file.
* @return false if the file was already locked, true otherwise.
*/
bool LockFile( const wxString& aFileName );
/**
* Function ReleaseFile
* Release the current file marked in use. See m_file_checker.
*/
void ReleaseFile();
@ -272,29 +273,25 @@ public:
virtual const PAGE_INFO& GetPageSettings() const = 0;
/**
* Function GetPageSizeIU
* works off of GetPageSettings() to return the size of the paper page in
* Works off of GetPageSettings() to return the size of the paper page in
* the internal units of this particular view.
*/
virtual const wxSize GetPageSizeIU() const = 0;
/**
* Function GetUserUnits
* returns the user units currently in use
* Return the user units currently in use.
*/
EDA_UNITS_T GetUserUnits() const override { return m_UserUnits; }
void SetUserUnits( EDA_UNITS_T aUnits ) { m_UserUnits = aUnits; }
/**
* Function GetAuxOrigin
* returns the origin of the axis used for plotting and various exports.
* Return the origin of the axis used for plotting and various exports.
*/
virtual const wxPoint& GetAuxOrigin() const = 0;
virtual void SetAuxOrigin( const wxPoint& aPosition ) = 0;
/**
* Function GetGridOrigin
* returns the absolute coordinates of the origin of the snap grid. This is
* Return the absolute coordinates of the origin of the snap grid. This is
* treated as a relative offset, and snapping will occur at multiples of the grid
* size relative to this point.
*/
@ -306,26 +303,25 @@ public:
//-----<BASE_SCREEN API moved here>------------------------------------------
/**
* Function GetCrossHairPosition
* return the current cross hair position in logical (drawing) coordinates.
* Return the current cross hair position in logical (drawing) coordinates.
*
* @param aInvertY Inverts the Y axis position.
* @return The cross hair position in drawing coordinates.
*/
wxPoint GetCrossHairPosition( bool aInvertY = false ) const;
/**
* Function SetCrossHairPosition
* sets the screen cross hair position to \a aPosition in logical (drawing) units.
* Set the screen cross hair position to \a aPosition in logical (drawing) units.
*
* @param aPosition The new cross hair position.
* @param aSnapToGrid Sets the cross hair position to the nearest grid position to
* \a aPosition.
*
*/
void SetCrossHairPosition( const wxPoint& aPosition, bool aSnapToGrid = true );
/**
* Function GetCursorPosition
* returns the current cursor position in logical (drawing) units.
* Return the current cursor position in logical (drawing) units.
*
* @param aOnGrid Returns the nearest grid position at the current cursor position.
* @param aGridSize Custom grid size instead of the current grid size. Only valid
* if \a aOnGrid is true.
@ -334,8 +330,8 @@ public:
wxPoint GetCursorPosition( bool aOnGrid, wxRealPoint* aGridSize = NULL ) const;
/**
* Function GetNearestGridPosition
* returns the nearest \a aGridSize location to \a aPosition.
* Return the nearest \a aGridSize location to \a aPosition.
*
* @param aPosition The position to check.
* @param aGridSize The grid size to locate to if provided. If NULL then the current
* grid size is used.
@ -344,8 +340,8 @@ public:
wxPoint GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize = NULL ) const;
/**
* Function GetCursorScreenPosition
* returns the cross hair position in device (display) units.b
* Return the cross hair position in device (display) units.b
*
* @return The current cross hair position.
*/
wxPoint GetCrossHairScreenPosition() const;
@ -353,7 +349,6 @@ public:
void SetMousePosition( const wxPoint& aPosition );
/**
* Function RefPos
* Return the reference position, coming from either the mouse position
* or the cursor position.
*
@ -369,7 +364,6 @@ public:
//-----</BASE_SCREEN API moved here>-----------------------------------------
virtual const TITLE_BLOCK& GetTitleBlock() const = 0;
virtual void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) = 0;
@ -396,8 +390,7 @@ public:
virtual wxString GetScreenDesc() const;
/**
* Function GetScreen
* returns a pointer to a BASE_SCREEN or one of its
* Return a pointer to a BASE_SCREEN or one of its
* derivatives. It is overloaded by derived classes to return
* SCH_SCREEN or PCB_SCREEN.
*/
@ -418,8 +411,7 @@ public:
void OnMouseEvent( wxMouseEvent& event );
/**
* function SkipNextLeftButtonReleaseEvent
* after calling this function, if the left mouse button
* After calling this function, if the left mouse button
* is down, the next left mouse button release event will be ignored.
* It is is usefull for instance when closing a dialog on a mouse click,
* to skip the next mouse left button release event
@ -434,14 +426,12 @@ public:
int WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName = NULL ) override;
/**
* Function GetHotkeyConfig()
* Returns a structure containing currently used hotkey mapping.
* Return a structure containing currently used hotkey mapping.
*/
EDA_HOTKEY_CONFIG* GetHotkeyConfig() const { return m_hotkeysDescrList; }
/**
* Function GetHotKeyDescription
* Searches lists of hot key identifiers (HK_xxx) used in the frame to find a matching
* Search lists of hot key identifiers (HK_xxx) used in the frame to find a matching
* hot key descriptor.
* @param aCommand is the hot key identifier.
* @return Hot key descriptor or NULL if none found.
@ -452,7 +442,6 @@ public:
EDA_ITEM* aItem = NULL );
/**
* Function AddMenuZoomAndGrid (virtual)
* Add standard zoom commands and submenu zoom and grid selection to a popup menu
* uses zoom hotkeys info base to add hotkeys info to menu commands
* @param aMasterMenu = the menu to populate.
@ -460,8 +449,7 @@ public:
virtual void AddMenuZoomAndGrid( wxMenu* aMasterMenu );
/**
* Function GetZoomLevelIndicator
* returns a human readable value which can be displayed as zoom
* Return a human readable value which can be displayed as zoom
* level indicator in dialogs.
* this can be a percentage or other indicator.
* it is virtual because it could be different for pcbnew, gerbview or eeschema
@ -471,8 +459,7 @@ public:
virtual const wxString GetZoomLevelIndicator() const;
/**
* Function GetZoomLevelCoeff
* returns the coefficient to convert internal display scale factor to zoom level.
* Return the coefficient to convert internal display scale factor to zoom level.
*/
inline double GetZoomLevelCoeff() const { return m_zoomLevelCoeff; }
@ -505,12 +492,13 @@ public:
wxAuiToolBarItem* GetToolbarTool( int aToolId );
/**
* Function SetToolID
* sets the tool command ID to \a aId and sets the cursor to \a aCursor. The
* command ID must be greater or equal ::ID_NO_TOOL_SELECTED. If the command
* Set the tool command ID to \a aId and sets the cursor to \a aCursor.
*
* The command ID must be greater or equal ::ID_NO_TOOL_SELECTED. If the command
* ID is less than ::ID_NO_TOOL_SELECTED, the tool command ID is set to
* ::ID_NO_TOOL_SELECTED. On debug builds, an assertion will be raised when
* \a aId is invalid.
*
* @param aId New tool command ID if greater than or equal to ::ID_NO_TOOL_SELECTED.
If less than zero, the current tool command ID is retained.
* @param aCursor Sets the cursor shape if greater than or equal to zero.
@ -535,7 +523,6 @@ public:
* These parameters are saved in KiCad config for each main frame
*/
/**
* Function IsGridVisible() , virtual
* @return true if the grid must be shown
*/
virtual bool IsGridVisible() const
@ -544,7 +531,6 @@ public:
}
/**
* Function SetGridVisibility() , virtual
* It may be overloaded by derived classes
* @param aVisible = true if the grid must be shown
*/
@ -554,7 +540,6 @@ public:
}
/**
* Function GetGridColor() , virtual
* @return the color of the grid
*/
virtual COLOR4D GetGridColor()
@ -563,7 +548,6 @@ public:
}
/**
* Function SetGridColor() , virtual
* @param aColor = the new color of the grid
*/
virtual void SetGridColor( COLOR4D aColor )
@ -572,9 +556,9 @@ public:
}
/**
* Function GetGridPosition
* returns the nearest grid position to \a aPosition if a screen is defined and snap to
* Return the nearest grid position to \a aPosition if a screen is defined and snap to
* grid is enabled. Otherwise, the original positions is returned.
*
* @see m_snapToGrid and m_BaseScreen members.
* @param aPosition The position to test.
* @return The wxPoint of the appropriate cursor position.
@ -582,20 +566,18 @@ public:
wxPoint GetGridPosition( const wxPoint& aPosition ) const;
/**
* Function SetNextGrid()
* changes the grid size settings to the next one available.
* Change the grid size settings to the next one available.
*/
virtual void SetNextGrid();
/**
* Function SetPrevGrid()
* changes the grid size settings to the previous one available.
* Change the grid size settings to the previous one available.
*/
virtual void SetPrevGrid();
/**
* Function SetPresetGrid()
* changes the grid size to one of the preset values.
* Change the grid size to one of the preset values.
*
* @param aIndex is the index from the list.
*/
void SetPresetGrid( int aIndex );
@ -613,8 +595,8 @@ public:
virtual void OnSelectGrid( wxCommandEvent& event );
/**
* Functions OnSelectZoom
* sets the zoom factor when selected by the zoom list box in the main tool bar.
* Set the zoom factor when selected by the zoom list box in the main tool bar.
*
* @note List position 0 is fit to page
* List position >= 1 = zoom (1 to zoom max)
* Last list position is custom zoom not in zoom list.
@ -635,8 +617,7 @@ public:
void OnUpdateCrossHairStyle( wxUpdateUIEvent& aEvent );
/**
* Function GeneralControl
* performs application specific control using \a aDC at \a aPosition in logical units.
* Perform application specific control using \a aDC at \a aPosition in logical units.
* <p>
* Override this function for application specific control. This function gets
* called on every mouse and key event.
@ -652,8 +633,7 @@ public:
}
/**
* Function OnSize
* recalculates the size of toolbars and display panel when the frame size changes.
* Recalculate the size of toolbars and display panel when the frame size changes.
*/
virtual void OnSize( wxSizeEvent& event );
@ -662,65 +642,63 @@ public:
virtual void OnZoom( wxCommandEvent& event );
/**
* Function SetNextZoom()
* changes the zoom to the next one available.
* Change the zoom to the next one available.
*/
void SetNextZoom();
/**
* changes the zoom to the next one available redraws the screen
* Change the zoom to the next one available redraws the screen
* and warp the mouse pointer on request.
*
* @param aCenterPoint is the reference point for zooming
* @param aWarpPointer = true to move the pointer to the aCenterPoint
*/
void SetNextZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer );
/**
* Function SetPrevZoom()
* changes the zoom to the previous one available.
* Change the zoom to the previous one available.
*/
void SetPrevZoom();
/**
* changes the zoom to the previous one available redraws the screen
* Change the zoom to the previous one available redraws the screen
* and warp the mouse pointer on request.
*
* @param aCenterPoint is the reference point for zooming
* @param aWarpPointer = true to move the pointer to the aCenterPoint
*/
void SetPreviousZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer );
/**
* Function SetPresetZoom()
* changes zoom to one of the preset values.
* Change zoom to one of the preset values.
*
* @param aIndex is the zoom index from the list.
*/
void SetPresetZoom( int aIndex );
/**
* Function RedrawScreen
* redraws the entire screen area by updating the scroll bars and mouse pointer in
* Redraw the entire screen area by updating the scroll bars and mouse pointer in
* order to have \a aCenterPoint at the center of the screen.
*
* @param aCenterPoint The position in logical units to center the scroll bars.
* @param aWarpPointer Moves the mouse cursor to \a aCenterPoint if true.
*/
virtual void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer );
/**
* Function RedrawScreen2
* puts the crosshair back to the screen position it had before zooming
* Put the crosshair back to the screen position it had before zooming.
*
* @param posBefore screen position of the crosshair before zooming
*/
virtual void RedrawScreen2( const wxPoint& posBefore );
/**
* Function HardRedraw
* rebuilds the GAL and redraws the screen. Call when something went wrong.
* Rebuild 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
* Redraw the screen with best zoom level and the best centering
* that shows all the page or the board
*/
virtual void Zoom_Automatique( bool aWarpPointer );
@ -732,14 +710,13 @@ public:
virtual double BestZoom() = 0;
/**
* Function GetZoom
* @return The current zoom level.
*/
double GetZoom();
/**
* Function DrawWorkSheet
* Draws on screen the page layout with the frame and the basic inscriptions.
*
* @param aDC The device context.
* @param aScreen screen to draw
* @param aLineWidth The pen width to use to draw the layout.
@ -760,16 +737,15 @@ public:
void AdjustScrollBars( const wxPoint& aCenterPosition );
/**
* Function OnActivate (virtual)
* is called when activating the frame.
* Called when activating the frame.
*
* In derived classes with a overriding OnActivate function,
* do not forget to call this EDA_DRAW_FRAME::OnActivate( event ) basic function.
*/
virtual void OnActivate( wxActivateEvent& event );
/**
* Function UpdateStatusBar
* updates the status bar information.
* Update the status bar information.
*
* The base method updates the absolute and relative coordinates and the
* zoom information. If you override this virtual method, make sure to call
@ -783,8 +759,7 @@ public:
virtual void UpdateStatusBar();
/**
* Function DisplayUnitsMsg
* displays current unit pane on the status bar.
* Display current unit pane on the status bar.
*/
void DisplayUnitsMsg();
@ -804,8 +779,7 @@ public:
int aExplicitCommand = 0 );
/**
* Function BlockCommand
* Returns the block command code (BLOCK_MOVE, BLOCK_COPY...) corresponding to the
* Return the block command code (BLOCK_MOVE, BLOCK_COPY...) corresponding to the
* keys pressed (ALT, SHIFT, SHIFT ALT ..) when block command is started by dragging
* the mouse.
*
@ -815,7 +789,6 @@ public:
virtual int BlockCommand( EDA_KEY aKey );
/**
* Function HandleBlockPlace( )
* Called after HandleBlockEnd, when a block command needs to be
* executed after the block is moved to its new place
* (bloc move, drag, copy .. )
@ -824,7 +797,6 @@ public:
virtual void HandleBlockPlace( wxDC* DC );
/**
* Function HandleBlockEnd( )
* Handle the "end" of a block command,
* i.e. is called at the end of the definition of the area of a block.
* depending on the current block command, this command is executed
@ -836,8 +808,7 @@ public:
virtual bool HandleBlockEnd( wxDC* DC );
/**
* Function CopyToClipboard
* copies the current page or the current block to the clipboard.
* Copy the current page or the current block to the clipboard.
*/
void CopyToClipboard( wxCommandEvent& event );
@ -871,8 +842,7 @@ public:
void ClearMsgPanel( void );
/**
* Function SetMsgPanel
* clears the message panel and populates it with the contents of \a aList.
* Clear the message panel and populates it with the contents of \a aList.
*
* @param aList is the list of #MSG_PANEL_ITEM objects to fill the message panel.
*/
@ -881,14 +851,12 @@ public:
void SetMsgPanel( EDA_ITEM* aItem );
/**
* Function UpdateMsgPanel
* redraws the message panel.
* Redraw the message panel.
*/
virtual void UpdateMsgPanel();
/**
* Function PushPreferences
* Pushes a few preferences from a parent window to a child window.
* Push preferences from a parent window to a child window.
* (i.e. from eeschema to schematic symbol editor)
*
* @param aParentCanvas is the parent canvas to push preferences from.
@ -896,9 +864,8 @@ public:
void PushPreferences( const EDA_DRAW_PANEL* aParentCanvas );
/**
* Function PrintPage
* used to print a page
* Print the page pointed by current screen, set by the calling print function
* Print the page pointed by current screen, set by the calling print function.
*
* @param aDC = wxDC given by the calling print function
* @param aPrintMask = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
@ -912,8 +879,7 @@ public:
static EDA_DRAW_PANEL_GAL::GAL_TYPE LoadCanvasTypeSetting();
/**
* Function UseGalCanvas
* used to switch between standard and GAL-based canvas.
* Use to switch between standard and GAL-based canvas.
*
* @param aEnable True for GAL-based canvas, false for standard canvas.
*/
@ -935,8 +901,7 @@ public:
bool IsGalCanvasActive() const { return m_galCanvasActive; }
/**
* Function GetGalCanvas
* returns a pointer to GAL-based canvas of given EDA draw frame.
* Return a pointer to GAL-based canvas of given EDA draw frame.
*
* @return Pointer to GAL-based canvas.
*/
@ -944,13 +909,11 @@ public:
void SetGalCanvas( EDA_DRAW_PANEL_GAL* aPanel ) { m_galCanvas = aPanel; }
/**
* Function GetToolManager
* returns the tool manager instance, if any.
* Return the tool manager instance, if any.
*/
TOOL_MANAGER* GetToolManager() const { return m_toolManager; }
/**
* Function GetDisplayOptions
* A way to pass info to draw functions. the base class has no knowledge about
* these options. It is virtual because this function must be overloaded to
* pass usefull info.
@ -958,14 +921,12 @@ public:
virtual void* GetDisplayOptions() { return NULL; }
/**
* Function GetGalDisplayOptions
* Returns a reference to the gal rendering options used by GAL for rendering.
* Return a reference to the gal rendering options used by GAL for rendering.
*/
KIGFX::GAL_DISPLAY_OPTIONS& GetGalDisplayOptions() { return m_galDisplayOptions; }
/**
* Function SyncMenusAndToolbars
* Updates the toolbars and menus (mostly settings/check buttons/checkboxes)
* Update the toolbars and menus (mostly settings/check buttons/checkboxes)
* with the current controller state
*/
virtual void SyncMenusAndToolbars( wxEvent& aEvent ) {};

View File

@ -99,6 +99,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
EVT_TOOL( ID_MODEDIT_SAVE_AS, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_REVERT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_OPEN_MODULE_VIEWER, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_SAVE_PNG, FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng )
EVT_TOOL( ID_MODEDIT_CUT_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
EVT_TOOL( ID_MODEDIT_COPY_PART, FOOTPRINT_EDIT_FRAME::Process_Special_Functions )
@ -952,7 +953,8 @@ void FOOTPRINT_EDIT_FRAME::ProcessPreferences( wxCommandEvent& event )
break;
case wxID_PREFERENCES:
ShowPreferences( g_Pcbnew_Editor_Hotkeys_Descr, g_Module_Editor_Hotkeys_Descr, wxT( "pcbnew" ) );
ShowPreferences( g_Pcbnew_Editor_Hotkeys_Descr, g_Module_Editor_Hotkeys_Descr,
wxT( "pcbnew" ) );
break;
default:
@ -1062,3 +1064,32 @@ void FOOTPRINT_EDIT_FRAME::UpdateMsgPanel()
ClearMsgPanel();
}
void FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng( wxCommandEvent& event )
{
wxString fullFileName;
LIB_ID id = GetLoadedFPID();
if( id.empty() )
{
wxMessageBox( _( "No footprint selected." ) );
return;
}
wxFileName fn( id.GetLibItemName() );
fn.SetExt( "png" );
wxString projectPath = wxPathOnly( Prj().GetProjectFullName() );
wxFileDialog dlg( this, _( "Footprint Image File Name" ), projectPath,
fn.GetFullName(), PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetPath().IsEmpty() )
return;
// calling wxYield is mandatory under Linux, after closing the file selector dialog
// to refresh the screen before creating the PNG or JPEG image from screen
wxYield();
saveCanvasImageToFile( dlg.GetPath() );
}

View File

@ -79,8 +79,7 @@ public:
double BestZoom() override;
/**
* Function GetConfigurationSettings
* returns the footpr<EFBFBD>int editor settings list.
* Return the footprint editor settings list.
*
* Currently, only the settings that are needed at start
* up by the main window are defined here. There are other locally used
@ -112,14 +111,12 @@ public:
void ProcessPreferences( wxCommandEvent& event );
/**
* Function RedrawActiveWindoow
* draws the footprint editor BOARD, and others elements such as axis and grid.
* Draw the footprint editor BOARD, and others elements such as axis and grid.
*/
void RedrawActiveWindow( wxDC* DC, bool EraseBg ) override;
/**
* Function ReCreateHToolbar
* create the main horizontal toolbar for the footprint editor
* Create the main horizontal toolbar for the footprint editor.
*/
void ReCreateHToolbar() override;
@ -128,17 +125,16 @@ public:
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ) override;
/**
* Function OnLeftDClick
* handles the double click in the footprint editor:
* Handle the double click in the footprint editor.
*
* If the double clicked item is editable: call the corresponding editor.
*/
void OnLeftDClick( wxDC* DC, const wxPoint& MousePos ) override;
/**
* Function OnRightClick
* handles the right mouse click in the footprint editor:
* Create the pop up menu
* After this menu is built, the standard ZOOM menu is added
* Handle the right mouse click in the footprint editor.
*
* Create the pop up menu. After this menu is built, the standard ZOOM menu is added
*/
bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu ) override;
@ -155,11 +151,12 @@ public:
void OnConfigurePaths( wxCommandEvent& aEvent );
void OnToggleSearchTree( wxCommandEvent& event );
void OnSaveFootprintAsPng( wxCommandEvent& event );
bool IsSearchTreeShown();
/**
* Function SaveLibraryAs
* saves a library to a new name and/or library type.
* Save a library to a new name and/or library type.
*
* @note Saving as a new library type requires the plug-in to support saving libraries
* @see PLUGIN::FootprintSave and PLUGIN::FootprintLibCreate
@ -170,8 +167,7 @@ public:
EDA_HOTKEY* GetHotKeyDescription( int aCommand ) const override;
/**
* Function OnHotKey
* handle hot key events.
* Handle hot key events.
* <p>
* Some commands are relative to the item under the mouse cursor. Commands are
* case insensitive
@ -189,8 +185,7 @@ public:
bool OnHotkeyDuplicateItem( int aIdCommand );
/**
* Function Show3D_Frame
* displays 3D view of the footprint (module) being edited.
* Display 3D view of the footprint (module) being edited.
*/
void Show3D_Frame( wxCommandEvent& event ) override;
@ -198,12 +193,12 @@ public:
void OnVerticalToolbar( wxCommandEvent& aEvent );
/**
* handle ID_ZOOM_SELECTION and ID_NO_TOOL_SELECTED tools
* Handle ID_ZOOM_SELECTION and ID_NO_TOOL_SELECTED tools
*/
void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
/**
* handle most of tools og the vertical right toolbar ("Tools" toolbar)
* Handle most of tools og the vertical right toolbar ("Tools" toolbar)
*/
void OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent );
@ -219,8 +214,7 @@ public:
void OnEditItemRequest( wxDC* aDC, BOARD_ITEM* aItem ) override;
/**
* Function LoadModuleFromBoard
* called from the main toolbar to load a footprint from board mainly to edit it.
* Called from the main toolbar to load a footprint from board mainly to edit it.
*/
void LoadModuleFromBoard( wxCommandEvent& event );
@ -232,8 +226,8 @@ public:
LIB_TREE_MODEL_ADAPTER::PTR& GetLibTreeAdapter() { return m_adapter; }
/**
* Function SaveFootprint
* Save in an existing library a given footprint
* Save in an existing library a given footprint.
*
* @param aModule = the given footprint
* @return : true if OK, false if abort
*/
@ -243,7 +237,6 @@ public:
bool RevertFootprint();
/**
* Virtual Function OnModify()
* Must be called after a footprint change
* in order to set the "modify" flag of the current screen
* and prepare, if needed the refresh of the 3D frame showing the footprint
@ -252,7 +245,6 @@ public:
virtual void OnModify() override;
/**
* Function ToPrinter
* Install the print dialog
*/
void ToPrinter( wxCommandEvent& event );
@ -260,8 +252,8 @@ public:
// BOARD handling
/**
* Function Clear_Pcb
* delete all and reinitialize the current board
* Delete all and reinitialize the current board.
*
* @param aQuery = true to prompt user for confirmation, false to initialize silently
*/
bool Clear_Pcb( bool aQuery );
@ -270,8 +262,8 @@ public:
virtual int BlockCommand( EDA_KEY key ) override;
/**
* Function HandleBlockPlace
* handles the BLOCK PLACE command
* Handle the BLOCK PLACE command.
*
* Last routine for block operation for:
* - block move & drag
* - block copy & paste
@ -279,7 +271,6 @@ public:
virtual void HandleBlockPlace( wxDC* DC ) override;
/**
* Function HandleBlockEnd( )
* Handle the "end" of a block command,
* i.e. is called at the end of the definition of the area of a block.
* depending on the current block command, this command is executed
@ -301,15 +292,14 @@ public:
void RemoveStruct( EDA_ITEM* Item );
/**
* Function Transform
* performs a geometric transform on the current footprint.
* Perform a geometric transform on the current footprint.
*/
void Transform( MODULE* module, int transform );
// importing / exporting Footprint
/**
* Function Export_Module
* Create a file containing only one footprint.
*
* Used to export a footprint
* Exported files have the standard ext .emp
* This is the same format as .mod files but restricted to only one footprint
@ -320,27 +310,27 @@ public:
void Export_Module( MODULE* aModule );
/**
* Function Import_Module
* Read a file containing only one footprint.
*
* Used to import (after exporting) a footprint
* Exported files have the standard ext .emp
* This is the same format as .mod files but restricted to only one footprint
* The import function can also read gpcb footprint file, in Newlib format
* (One footprint per file, Newlib files have no special ext.)
*/
MODULE* Import_Module( const wxString& aName = wxT("") );
MODULE* Import_Module( const wxString& aName = wxT("") );
/**
* Function Load_Module_From_BOARD
* load in Modedit a footprint from the main board
* Load in Modedit a footprint from the main board.
*
* @param Module = the module to load. If NULL, a module reference will we asked to user
* @return true if a module isloaded, false otherwise.
*/
bool Load_Module_From_BOARD( MODULE* Module );
/**
* Function SelectFootprint
* Display the list of modules currently existing on the BOARD
* Display the list of modules currently existing on the BOARD.
*
* @return a pointer to a module if this module is selected or NULL otherwise
* @param aPcb = the board from modules can be loaded
*/
@ -349,8 +339,8 @@ public:
// functions to edit footprint edges
/**
* Function Edit_Edge_Width
* changes the width of module perimeter lines, EDGE_MODULEs.
* Change the width of module perimeter lines, EDGE_MODULEs.
*
* param ModuleSegmentWidth (global) = new width
* @param aEdge = edge to edit, or NULL. If aEdge == NULL change
* the width of all footprint's edges
@ -358,25 +348,24 @@ public:
void Edit_Edge_Width( EDGE_MODULE* aEdge );
/**
* Function Edit_Edge_Layer
* changes the EDGE_MODULE Edge layer, (The new layer will be asked)
* Change the EDGE_MODULE Edge layer, (The new layer will be asked)
* if Edge == NULL change the layer of the entire footprint edges
*
* @param Edge = edge to edit, or NULL
*/
void Edit_Edge_Layer( EDGE_MODULE* Edge );
/**
* Function Delete_Edge_Module
* deletes EDGE_MODULE Edge
* Delete EDGE_MODULE ddge.
*
* @param Edge = edge to delete
*/
void Delete_Edge_Module( EDGE_MODULE* Edge );
/**
* Function Begin_Edge_Module
* creates a new edge item (line, arc ..).
* @param Edge = if NULL: create new edge else terminate edge and create a
* new edge
* Creates a new edge item (line, arc ..).
*
* @param Edge = if NULL: create new edge else terminate edge and create a new edge
* @param DC = current Device Context
* @param type_edge = S_SEGMENT,S_ARC ..
* @return the new created edge.
@ -384,8 +373,7 @@ public:
EDGE_MODULE* Begin_Edge_Module( EDGE_MODULE* Edge, wxDC* DC, STROKE_T type_edge );
/**
* Function End_Edge_Module
* terminates a move or create edge function
* Terminate a move or create edge function.
*/
void End_Edge_Module( EDGE_MODULE* Edge );
@ -396,8 +384,7 @@ public:
void Place_EdgeMod( EDGE_MODULE* drawitem );
/**
* Function DlgGlobalChange_PadSettings
* changes pad characteristics for the given footprint
* Change pad characteristics for the given footprint
* or all footprints which look like the given footprint.
* Options are set by the opened dialog.
* @param aPad is the pattern. The given footprint is the parent of this pad
@ -405,15 +392,15 @@ public:
void PushPadProperties( D_PAD* aPad );
/**
* Function DeleteModuleFromLibrary
* deletes the given module from its library.
* Delete the given module from its library.
*/
bool DeleteModuleFromLibrary( const LIB_ID& aFPID, bool aConfirm );
/**
* Function IsElementVisible
* tests whether a given element category is visible. Keep this as an
* inline function.
* Test whether a given element category is visible.
*
* Keep this as an inline function.
*
* @param aElement is from the enum by the same name
* @return bool - true if the element is visible.
* @see enum PCB_LAYER_ID
@ -430,13 +417,11 @@ public:
void SetElementVisibility( GAL_LAYER_ID aElement, bool aNewState );
/**
* Function IsGridVisible() , virtual
* @return true if the grid must be shown
*/
virtual bool IsGridVisible() const override;
/**
* Function SetGridVisibility() , virtual
* It may be overloaded by derived classes
* if you want to store/retrieve the grid visibility in configuration.
* @param aVisible = true if the grid must be shown
@ -444,7 +429,6 @@ public:
virtual void SetGridVisibility( bool aVisible ) override;
/**
* Function GetGridColor() , virtual
* @return the color of the grid
*/
virtual COLOR4D GetGridColor() override;
@ -459,8 +443,7 @@ public:
virtual void UseGalCanvas( bool aEnable ) override;
/**
* Function OpenProjectFiles (was LoadOnePcbFile)
* loads a KiCad board (.kicad_pcb) from \a aFileName.
* Load a KiCad board (.kicad_pcb) from \a aFileName.
*
* @param aFileSet - hold the BOARD file to load, a vector of one element.
*
@ -505,7 +488,8 @@ public:
void SyncLibraryTree( bool aProgress );
/**
* redraws the message panel.
* Redraw the message panel.
*
* If a item is currently selected, displays the item info.
* If nothing selected, display the current footprint info, or
* clear the message panel if nothing is edited
@ -533,8 +517,7 @@ protected:
void initLibraryTree();
/**
* Function UpdateTitle
* updates window title according to getLibNickName().
* Updates window title according to getLibNickName().
*/
void updateTitle();
@ -562,15 +545,14 @@ private:
bool saveFootprintInLibrary( MODULE* aModule, const wxString& aLibraryName );
/**
* Function moveExact
* Move the selected item exactly, popping up a dialog to allow the
* user the enter the move delta
*/
void moveExact();
/**
* Function duplicateItems
* Duplicate the item under the cursor
*
* @param aIncrement increment the number of pad (if that is what is selected)
*/
void duplicateItems( bool aIncrement ) override;

View File

@ -121,6 +121,14 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AppendSeparator();
AddMenuItem( fileMenu,
ID_MODEDIT_SAVE_PNG,
_( "Export View as PN&G..." ),
_( "Create a PNG file from the current view" ),
KiBitmap( plot_xpm ) );
fileMenu->AppendSeparator();
// Close editor
AddMenuItem( fileMenu, wxID_EXIT,
_( "&Exit" ),

View File

@ -350,6 +350,7 @@ enum pcbnew_ids
ID_MODEDIT_ADD_LIBRARY,
ID_MODEDIT_SAVE,
ID_MODEDIT_SAVE_AS,
ID_MODEDIT_SAVE_PNG,
ID_MODEDIT_REVERT_PART,
ID_MODEDIT_DELETE_PART,
ID_MODEDIT_COPY_PART,