Enable plot in clipboard on Linux and OSX in eeschema, and copy in clipboard in 3d viewer ( was existing on Windows, but disabled on other OS ).

Minor other fixes (duplicate hot key in eeschema, which fixes Bug #1460359)
This commit is contained in:
jean-pierre charras 2015-05-31 13:51:50 +02:00
commit 0cab3e47ad
6 changed files with 95 additions and 91 deletions

View File

@ -700,17 +700,15 @@ void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event )
if( event.GetId() == ID_TOOL_SCREENCOPY_TOCLIBBOARD )
{
wxBitmapDataObject* dobjBmp = new wxBitmapDataObject;
dobjBmp->SetBitmap( bitmap );
if( wxTheClipboard->Open() )
{
wxBitmapDataObject* dobjBmp = new wxBitmapDataObject( bitmap );
if( !wxTheClipboard->SetData( dobjBmp ) )
wxMessageBox( _( "Failed to copy image to clipboard" ) );
wxTheClipboard->Flush(); /* the data in clipboard will stay
* available after the
* application exits */
* available after the application exits */
wxTheClipboard->Close();
}
}

View File

@ -51,15 +51,11 @@ void EDA_3D_FRAME::ReCreateMainToolbar()
m_mainToolBar->AddTool( ID_RELOAD3D_BOARD, wxEmptyString,
KiBitmap( import3d_xpm ), _( "Reload board" ) );
#if (defined(__WINDOWS__) || defined(__APPLE__ ) )
// Does not work properly under linux
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_TOOL_SCREENCOPY_TOCLIBBOARD, wxEmptyString,
KiBitmap( copy_button_xpm ),
_( "Copy 3D Image to Clipboard" ) );
#endif
m_mainToolBar->AddSeparator();
@ -141,11 +137,8 @@ void EDA_3D_FRAME::CreateMenuBar()
fileMenu->Append( ID_MENU_SCREENCOPY_PNG, _( "Create Image (png format)" ) );
fileMenu->Append( ID_MENU_SCREENCOPY_JPEG, _( "Create Image (jpeg format)" ) );
#if (defined(__WINDOWS__) || defined(__APPLE__ ) )
// Does not work properly under linux
fileMenu->AppendSeparator();
fileMenu->Append( ID_TOOL_SCREENCOPY_TOCLIBBOARD, _( "Copy 3D Image to Clipboard" ) );
#endif
fileMenu->AppendSeparator();
fileMenu->Append( wxID_EXIT, _( "&Exit" ) );

View File

@ -566,76 +566,77 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event )
return;
}
wxString tmp;
wxString msg_version;
wxPlatformInfo info;
tmp = wxT( "Application: " ) + Pgm().App().GetAppName() + wxT( "\n" );
tmp << wxT( "Version: " ) << GetBuildVersion()
msg_version = wxT( "Application: " ) + Pgm().App().GetAppName() + wxT( "\n" );
msg_version << wxT( "Version: " ) << GetBuildVersion()
#ifdef DEBUG
<< wxT( " debug" )
<< wxT( " debug" )
#else
<< wxT( " release" )
<< wxT( " release" )
#endif
<< wxT( " build\n" );
tmp << wxT( "wxWidgets: Version " ) << FROM_UTF8( wxVERSION_NUM_DOT_STRING )
<< FROM_UTF8( KICAD_BUILD_OPTIONS_SIGNATURE() ) << wxT( "\n" )
<< wxT( "Platform: " ) << wxGetOsDescription() << wxT( ", " )
<< info.GetArchName() << wxT( ", " ) << info.GetEndiannessName() << wxT( ", " )
<< info.GetPortIdName() << wxT( "\n" );
<< wxT( " build\n" );
msg_version << wxT( "wxWidgets: Version " ) << FROM_UTF8( wxVERSION_NUM_DOT_STRING )
<< FROM_UTF8( KICAD_BUILD_OPTIONS_SIGNATURE() ) << wxT( "\n" )
<< wxT( "Platform: " ) << wxGetOsDescription() << wxT( ", " )
<< info.GetArchName() << wxT( ", " ) << info.GetEndiannessName()
<< wxT( ", " ) << info.GetPortIdName() << wxT( "\n" );
// Just in case someone builds KiCad with the platform native of Boost instead of
// the version included with the KiCad source.
tmp << wxT( "Boost version: " ) << ( BOOST_VERSION / 100000 ) << wxT( "." )
<< ( BOOST_VERSION / 100 % 1000 ) << wxT( "." ) << ( BOOST_VERSION % 100 ) << wxT( "\n" );
msg_version << wxT( "Boost version: " ) << ( BOOST_VERSION / 100000 ) << wxT( "." )
<< ( BOOST_VERSION / 100 % 1000 ) << wxT( "." )
<< ( BOOST_VERSION % 100 ) << wxT( "\n" );
tmp << wxT( " USE_WX_GRAPHICS_CONTEXT=" );
msg_version << wxT( " USE_WX_GRAPHICS_CONTEXT=" );
#ifdef USE_WX_GRAPHICS_CONTEXT
tmp << wxT( "ON\n" );
msg_version << wxT( "ON\n" );
#else
tmp << wxT( "OFF\n" );
msg_version << wxT( "OFF\n" );
#endif
tmp << wxT( " USE_WX_OVERLAY=" );
msg_version << wxT( " USE_WX_OVERLAY=" );
#ifdef USE_WX_OVERLAY
tmp << wxT( "ON\n" );
msg_version << wxT( "ON\n" );
#else
tmp << wxT( "OFF\n" );
msg_version << wxT( "OFF\n" );
#endif
tmp << wxT( " KICAD_SCRIPTING=" );
msg_version << wxT( " KICAD_SCRIPTING=" );
#ifdef KICAD_SCRIPTING
tmp << wxT( "ON\n" );
msg_version << wxT( "ON\n" );
#else
tmp << wxT( "OFF\n" );
msg_version << wxT( "OFF\n" );
#endif
tmp << wxT( " KICAD_SCRIPTING_MODULES=" );
msg_version << wxT( " KICAD_SCRIPTING_MODULES=" );
#ifdef KICAD_SCRIPTING_MODULES
tmp << wxT( "ON\n" );
msg_version << wxT( "ON\n" );
#else
tmp << wxT( "OFF\n" );
msg_version << wxT( "OFF\n" );
#endif
tmp << wxT( " KICAD_SCRIPTING_WXPYTHON=" );
msg_version << wxT( " KICAD_SCRIPTING_WXPYTHON=" );
#ifdef KICAD_SCRIPTING_WXPYTHON
tmp << wxT( "ON\n" );
msg_version << wxT( "ON\n" );
#else
tmp << wxT( "OFF\n" );
msg_version << wxT( "OFF\n" );
#endif
tmp << wxT( " USE_FP_LIB_TABLE=HARD_CODED_ON\n" );
msg_version << wxT( " USE_FP_LIB_TABLE=HARD_CODED_ON\n" );
tmp << wxT( " BUILD_GITHUB_PLUGIN=" );
msg_version << wxT( " BUILD_GITHUB_PLUGIN=" );
#ifdef BUILD_GITHUB_PLUGIN
tmp << wxT( "ON\n" );
msg_version << wxT( "ON\n" );
#else
tmp << wxT( "OFF\n" );
msg_version << wxT( "OFF\n" );
#endif
wxMessageBox( tmp, _( "Version Information (copied to the clipboard)" ) );
wxTheClipboard->SetData( new wxTextDataObject( tmp ) );
wxTheClipboard->SetData( new wxTextDataObject( msg_version ) );
wxTheClipboard->Close();
wxMessageBox( msg_version, _( "Version Information (copied to the clipboard)" ) );
}

View File

@ -26,7 +26,8 @@
* @file copy_to_clipboard.cpp
*/
#include <wx/metafile.h>
#include <wx/clipbrd.h>
//#include <wx/metafile.h>
#include <fctsys.h>
#include <gr_basic.h>
#include <common.h>
@ -59,21 +60,10 @@ void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event )
*/
bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
{
bool success = true;
#ifdef __WINDOWS__
int tmpzoom;
wxPoint tmp_startvisu;
wxPoint old_org;
wxPoint DrawOffset;
int ClipboardSizeX, ClipboardSizeY;
bool DrawBlock = false;
wxRect DrawArea;
BASE_SCREEN* screen = aFrame->GetCanvas()->GetScreen();
// scale is the ratio resolution/internal units
double scale = 82.0 / 1000.0 / (double) screen->MilsToIuScalar();
if( screen->IsBlockActive() )
{
DrawBlock = true;
@ -82,52 +72,88 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
DrawArea.SetWidth( screen->m_BlockLocate.GetWidth() );
DrawArea.SetHeight( screen->m_BlockLocate.GetHeight() );
}
else
DrawArea.SetSize( aFrame->GetPageSizeIU() );
/* Change frames and local settings. */
tmp_startvisu = screen->m_StartVisu;
tmpzoom = screen->GetZoom();
old_org = screen->m_DrawOrg;
// Calculate a reasonable dc size, in pixels, and the dc scale to fit
// the drawings into the dc size
// scale is the ratio resolution (in PPI) / internal units
double ppi = 300; // Use 300 pixels per inch to create bitmap images on start
double inch2Iu = 1000.0 * (double) screen->MilsToIuScalar();
double scale = ppi / inch2Iu;
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;
while( int( maxdim * scale ) > maxbitmapsize )
{
ppi = ppi / 1.5;
scale = ppi / inch2Iu;
}
dcsize.x *= scale;
dcsize.y *= scale;
// Set draw offset, zoom... to values needed to draw in the memory DC
// after saving initial values:
wxPoint tmp_startvisu = screen->m_StartVisu;
double tmpzoom = screen->GetZoom();
wxPoint old_org = screen->m_DrawOrg;
screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
screen->SetZoom( 1 );
screen->SetZoom( 1 ); // we use zoom = 1 in draw functions.
wxMetafileDC dc;
wxMemoryDC dc;
wxBitmap image( dcsize );
dc.SelectObject( image );
EDA_RECT tmp = *aFrame->GetCanvas()->GetClipBox();
GRResetPenAndBrush( &dc );
const bool plotBlackAndWhite = false;
GRForceBlackPen( plotBlackAndWhite );
GRForceBlackPen( false );
screen->m_IsPrinting = true;
dc.SetUserScale( scale, scale );
ClipboardSizeX = dc.MaxX() + 10;
ClipboardSizeY = dc.MaxY() + 10;
aFrame->GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) );
aFrame->GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ),
wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) );
if( DrawBlock )
{
dc.SetClippingRegion( DrawArea );
}
dc.Clear();
aFrame->GetCanvas()->EraseScreen( &dc );
const LSET allLayersMask = LSET().set();
aFrame->PrintPage( &dc, allLayersMask, false );
screen->m_IsPrinting = false;
aFrame->GetCanvas()->SetClipBox( tmp );
wxMetafile* mf = dc.Close();
if( mf )
bool success = true;
if( wxTheClipboard->Open() )
{
success = mf->SetClipboard( ClipboardSizeX, ClipboardSizeY );
delete mf;
// This data objects are held by the clipboard,
// so do not delete them in the app.
wxBitmapDataObject* clipbrd_data = new wxBitmapDataObject( image );
wxTheClipboard->SetData( clipbrd_data );
wxTheClipboard->Close();
}
else
success = false;
// Deselect Bitmap from DC in order to delete the MemoryDC safely
// without deleting the bitmap
dc.SelectObject( wxNullBitmap );
GRForceBlackPen( false );
screen->m_StartVisu = tmp_startvisu;
screen->m_DrawOrg = old_org;
screen->SetZoom( tmpzoom );
#endif
return success;
}

View File

@ -143,7 +143,7 @@ static EDA_HOTKEY HkEndLineWireBus( _HKI( "End Line Wire Bus" ), HK_END_CURR_LIN
static EDA_HOTKEY HkAddLabel( _HKI( "Add Label" ), HK_ADD_LABEL, 'L', ID_LABEL_BUTT );
static EDA_HOTKEY HkAddHierarchicalLabel( _HKI( "Add Hierarchical Label" ), HK_ADD_HLABEL, 'H',
ID_HIERLABEL_BUTT );
static EDA_HOTKEY HkAddGlobalLabel( _HKI( "Add Global Label" ), HK_ADD_GLABEL, GR_KB_CTRL + 'L',
static EDA_HOTKEY HkAddGlobalLabel( _HKI( "Add Global Label" ), HK_ADD_GLABEL, GR_KB_CTRL + 'H',
ID_GLABEL_BUTT );
static EDA_HOTKEY HkAddJunction( _HKI( "Add Junction" ), HK_ADD_JUNCTION, 'J', ID_JUNCTION_BUTT );
static EDA_HOTKEY HkAddComponent( _HKI( "Add Component" ), HK_ADD_NEW_COMPONENT, 'A',

View File

@ -144,8 +144,6 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
_( "Print schematic sheet" ),
KiBitmap( print_button_xpm ) );
#ifdef __WINDOWS__ // __WINDOWS__
// Plot submenu
wxMenu* choice_plot_fmt = new wxMenu;
AddMenuItem( choice_plot_fmt, ID_GEN_PLOT_SCHEMATIC,
@ -153,8 +151,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
_( "Plot schematic sheet in PostScript, PDF, SVG, DXF or HPGL format" ),
KiBitmap( plot_xpm ) );
// Plot to Clipboard (Windows only)
// Plot to Clipboard
AddMenuItem( choice_plot_fmt, ID_GEN_COPY_SHEET_TO_CLIPBOARD,
_( "Plot to C&lipboard" ),
_( "Export drawings to clipboard" ),
@ -166,17 +163,6 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
_( "Plot schematic sheet in HPGL, PostScript or SVG format" ),
KiBitmap( plot_xpm ) );
#else // Other
// Plot
AddMenuItem( fileMenu,
ID_GEN_PLOT_SCHEMATIC,
_( "&Plot" ),
_( "Plot schematic sheet in HPGL, PostScript or SVG format" ),
KiBitmap( plot_xpm ) );
#endif
// Separator
fileMenu->AppendSeparator();