Remove some more legacy code.

This commit is contained in:
Jeff Young 2019-05-28 19:44:14 +01:00
parent 0260b32125
commit 9d29e94cb5
20 changed files with 98 additions and 792 deletions

View File

@ -349,7 +349,6 @@ set( COMMON_SRCS
richio.cpp
search_stack.cpp
searchhelpfilefullpath.cpp
selcolor.cpp
settings.cpp
status_popup.cpp
systemdirsappend.cpp

View File

@ -383,18 +383,6 @@ wxPoint BASE_SCREEN::getCursorPosition( bool aOnGrid, const wxPoint& aGridOrigin
}
wxPoint BASE_SCREEN::getCrossHairScreenPosition() const
{
wxPoint pos = m_crossHairPosition - m_DrawOrg;
double scalar = GetScalingFactor();
pos.x = KiROUND( (double) pos.x * scalar );
pos.y = KiROUND( (double) pos.y * scalar );
return pos;
}
void BASE_SCREEN::setCrossHairPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin,
bool aSnapToGrid )
{

View File

@ -462,24 +462,6 @@ void EDA_DRAW_FRAME::SetNoToolSelected()
}
void EDA_DRAW_FRAME::SetNextGrid()
{
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
}
void EDA_DRAW_FRAME::SetPrevGrid()
{
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
}
void EDA_DRAW_FRAME::SetPresetGrid( int aIndex )
{
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
}
void EDA_DRAW_FRAME::UpdateStatusBar()
{
SetStatusText( GetZoomLevelIndicator(), 1 );
@ -744,13 +726,6 @@ wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition,
}
wxPoint EDA_DRAW_FRAME::GetCrossHairScreenPosition() const
{
wxFAIL_MSG( "Obsolete; use VIEW_CONTROLS instead" );
return wxPoint();
}
void EDA_DRAW_FRAME::SetMousePosition( const wxPoint& aPosition )
{
BASE_SCREEN* screen = GetScreen(); // virtual call
@ -889,18 +864,9 @@ const BOX2I EDA_DRAW_FRAME::GetDocumentExtents() const
}
void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
{
}
void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore )
{
}
void EDA_DRAW_FRAME::HardRedraw()
{
// To be implemented by subclasses.
}
@ -921,12 +887,6 @@ void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
}
void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
{
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
}
void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
{
wxFAIL_MSG( "Obsolete! Should go through COMMON_TOOLS." );
@ -969,107 +929,6 @@ void EDA_DRAW_FRAME::FocusOnLocation( const wxPoint& aPos, bool aWarpCursor, boo
}
static bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame );
void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event )
{
DrawPageOnClipboard( this );
}
/* copy the current page or block to the clipboard ,
* to export drawings to other applications (word processing ...)
* This is not suitable for copy command within Eeschema or Pcbnew
*/
bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
{
bool DrawBlock = false;
wxRect DrawArea;
BASE_SCREEN* screen = aFrame->GetCanvas()->GetScreen();
DrawArea.SetSize( aFrame->GetPageSizeIU() );
// 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 ); // we use zoom = 1 in draw functions.
wxMemoryDC dc;
wxBitmap image( dcsize );
dc.SelectObject( image );
EDA_RECT tmp = *aFrame->GetCanvas()->GetClipBox();
GRResetPenAndBrush( &dc );
GRForceBlackPen( false );
screen->m_IsPrinting = true;
dc.SetUserScale( scale, scale );
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 );
bool success = true;
if( wxTheClipboard->Open() )
{
// 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 );
return success;
}
static const wxString productName = wxT( "KiCad E.D.A. " );
void DrawPageLayout( wxDC* aDC,

View File

@ -100,10 +100,6 @@ BEGIN_EVENT_TABLE( EDA_DRAW_FRAME, KIWAY_PLAYER )
EVT_MENU_CLOSE( EDA_DRAW_FRAME::OnMenuOpen )
EVT_MENU_HIGHLIGHT_ALL( EDA_DRAW_FRAME::OnMenuOpen )
EVT_ACTIVATE( EDA_DRAW_FRAME::OnActivate )
EVT_MENU_RANGE( ID_ZOOM_BEGIN, ID_ZOOM_END, EDA_DRAW_FRAME::OnZoom )
EVT_MENU_RANGE( ID_POPUP_ZOOM_START_RANGE, ID_POPUP_ZOOM_END_RANGE,
EDA_DRAW_FRAME::OnZoom )
EVT_MENU_RANGE( ID_POPUP_GRID_LEVEL_1000, ID_POPUP_GRID_USER,
EDA_DRAW_FRAME::OnSelectGrid )
@ -493,17 +489,9 @@ void EDA_DRAW_FRAME::DisplayUnitsMsg()
switch( m_UserUnits )
{
case INCHES:
msg = _( "Inches" );
break;
case MILLIMETRES:
msg = _( "mm" );
break;
default:
msg = _( "Units" );
break;
case INCHES: msg = _( "Inches" ); break;
case MILLIMETRES: msg = _( "mm" ); break;
default: msg = _( "Units" ); break;
}
SetStatusText( msg, 4 );
@ -556,71 +544,6 @@ void EDA_DRAW_FRAME::SetNoToolSelected()
}
void EDA_DRAW_FRAME::SetNextGrid()
{
BASE_SCREEN * screen = GetScreen();
int new_grid_cmd = screen->GetGridCmdId();
// if the grid id is the not the last, increment it
if( screen->GridExists( new_grid_cmd + 1 ) )
new_grid_cmd += 1;
SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
}
void EDA_DRAW_FRAME::SetPrevGrid()
{
BASE_SCREEN * screen = GetScreen();
int new_grid_cmd = screen->GetGridCmdId();
// if the grid id is the not the first, increment it
if( screen->GridExists( new_grid_cmd - 1 ) )
new_grid_cmd -= 1;
SetPresetGrid( new_grid_cmd - ID_POPUP_GRID_LEVEL_1000 );
}
void EDA_DRAW_FRAME::SetPresetGrid( int aIndex )
{
BASE_SCREEN * screen = GetScreen();
if( ! screen->GridExists( aIndex + ID_POPUP_GRID_LEVEL_1000 ) )
aIndex = screen->GetGrids()[0].m_CmdId;
// aIndex is a Command Id relative to ID_POPUP_GRID_LEVEL_1000 comand id code.
// we need an index in grid list (the cmd id in list is is screen->GetGrids()[0].m_CmdId):
int glistIdx = aIndex + ID_POPUP_GRID_LEVEL_1000 - screen->GetGrids()[0].m_CmdId;
if( m_gridSelectBox )
{
int highestGrid = ( int )m_gridSelectBox->GetCount();
// GerbView does not support the user grid setting
if( m_Ident != FRAME_GERBER )
highestGrid -= 2;
if( glistIdx < 0 || glistIdx >= highestGrid )
{
wxASSERT_MSG( false, "Invalid grid index" );
return;
}
m_gridSelectBox->SetSelection( glistIdx );
}
// Be sure m_LastGridSizeId is up to date.
m_LastGridSizeId = aIndex;
GetScreen()->SetGrid( aIndex + ID_POPUP_GRID_LEVEL_1000 );
// Put cursor on new grid
SetCrossHairPosition( RefPos( true ) );
}
void EDA_DRAW_FRAME::UpdateStatusBar()
{
SetStatusText( GetZoomLevelIndicator(), 1 );
@ -921,13 +844,6 @@ wxPoint EDA_DRAW_FRAME::GetNearestGridPosition( const wxPoint& aPosition, wxReal
}
wxPoint EDA_DRAW_FRAME::GetCrossHairScreenPosition() const
{
BASE_SCREEN* screen = GetScreen(); // virtual call
return screen->getCrossHairScreenPosition();
}
void EDA_DRAW_FRAME::SetMousePosition( const wxPoint& aPosition )
{
BASE_SCREEN* screen = GetScreen(); // virtual call
@ -1123,18 +1039,6 @@ bool EDA_DRAW_FRAME::GeneralControlKeyMovement( int aHotKey, wxPoint *aPos, bool
}
void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
{
// JEY TODO: OBSOLETE
}
void EDA_DRAW_FRAME::RedrawScreen2( const wxPoint& posBefore )
{
// JEY TODO: OBSOLETE
}
void EDA_DRAW_FRAME::HardRedraw()
{
m_canvas->Refresh();
@ -1183,119 +1087,6 @@ void EDA_DRAW_FRAME::Zoom_Automatique( bool aWarpPointer )
}
void EDA_DRAW_FRAME::OnZoom( wxCommandEvent& event )
{
if( m_canvas == NULL )
return;
int id = event.GetId();
bool zoom_at_cursor = false;
BASE_SCREEN* screen = GetScreen();
wxPoint center = GetScrollCenterPosition();
if ( id == ID_KEY_ZOOM_IN )
{
id = GetCanvas()->GetEnableZoomNoCenter() ?
ID_OFFCENTER_ZOOM_IN : ID_POPUP_ZOOM_IN;
}
else if ( id == ID_KEY_ZOOM_OUT )
{
id = GetCanvas()->GetEnableZoomNoCenter() ?
ID_OFFCENTER_ZOOM_OUT : ID_POPUP_ZOOM_OUT;
}
switch( id )
{
case ID_OFFCENTER_ZOOM_IN:
center = m_canvas->ToDeviceXY( GetCrossHairPosition() );
if( screen->SetPreviousZoom() )
RedrawScreen2( center );
break;
case ID_POPUP_ZOOM_IN:
zoom_at_cursor = true;
center = GetCrossHairPosition();
// fall thru
case ID_VIEWER_ZOOM_IN:
case ID_ZOOM_IN:
if( screen->SetPreviousZoom() )
RedrawScreen( center, zoom_at_cursor );
break;
case ID_OFFCENTER_ZOOM_OUT:
center = m_canvas->ToDeviceXY( GetCrossHairPosition() );
if( screen->SetNextZoom() )
RedrawScreen2( center );
break;
case ID_POPUP_ZOOM_OUT:
zoom_at_cursor = true;
center = GetCrossHairPosition();
// fall thru
case ID_VIEWER_ZOOM_OUT:
case ID_ZOOM_OUT:
if( screen->SetNextZoom() )
RedrawScreen( center, zoom_at_cursor );
break;
case ID_VIEWER_ZOOM_REDRAW:
case ID_POPUP_ZOOM_REDRAW:
case ID_ZOOM_REDRAW:
// This usually means something went wrong. Do a hard refresh.
SetScreen( GetScreen() );
break;
case ID_POPUP_ZOOM_CENTER:
center = GetCrossHairPosition();
RedrawScreen( center, true );
break;
case ID_POPUP_ZOOM_PAGE:
case ID_VIEWER_ZOOM_PAGE:
case ID_ZOOM_PAGE:
Zoom_Automatique( false );
break;
case ID_POPUP_ZOOM_SELECT:
break;
case ID_POPUP_CANCEL:
m_canvas->MoveCursorToCrossHair();
break;
default:
SetPresetZoom( id - ID_POPUP_ZOOM_LEVEL_START );
}
UpdateStatusBar();
}
void EDA_DRAW_FRAME::SetPresetZoom( int aIndex )
{
BASE_SCREEN* screen = GetScreen();
if( aIndex >= (int) screen->m_ZoomList.size() )
{
wxLogDebug( wxT( "%s %d: index %d is outside the bounds of the zoom list." ),
__TFILE__, __LINE__, aIndex );
return;
}
if( m_zoomSelectBox )
m_zoomSelectBox->SetSelection( aIndex );
if( screen->SetZoom( screen->m_ZoomList[aIndex] ) )
RedrawScreen( GetScrollCenterPosition(), true );
UpdateStatusBar();
}
void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu )
{
int maxZoomIds;
@ -1397,105 +1188,6 @@ void EDA_DRAW_FRAME::FocusOnLocation( const wxPoint& aPos, bool aWarpCursor, boo
}
static bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame );
void EDA_DRAW_FRAME::CopyToClipboard( wxCommandEvent& event )
{
DrawPageOnClipboard( this );
}
/* copy the current page or block to the clipboard ,
* to export drawings to other applications (word processing ...)
* This is not suitable for copy command within Eeschema or Pcbnew
*/
bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
{
wxRect DrawArea;
BASE_SCREEN* screen = aFrame->GetCanvas()->GetScreen();
DrawArea.SetSize( aFrame->GetPageSizeIU() );
// 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 ); // we use zoom = 1 in draw functions.
wxMemoryDC dc;
wxBitmap image( dcsize );
dc.SelectObject( image );
EDA_RECT tmp = *aFrame->GetCanvas()->GetClipBox();
GRResetPenAndBrush( &dc );
GRForceBlackPen( false );
screen->m_IsPrinting = true;
dc.SetUserScale( scale, scale );
aFrame->GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) );
dc.Clear();
aFrame->GetCanvas()->EraseScreen( &dc );
const LSET allLayersMask = LSET().set();
aFrame->PrintPage( &dc, allLayersMask, false );
screen->m_IsPrinting = false;
aFrame->GetCanvas()->SetClipBox( tmp );
bool success = true;
if( wxTheClipboard->Open() )
{
// 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 );
return success;
}
void DrawPageLayout( wxDC* aDC,
EDA_RECT* aClipBox,
const PAGE_INFO& aPageInfo,

View File

@ -926,7 +926,6 @@ void EDA_DRAW_PANEL::OnMouseWheel( wxMouseEvent& event )
GetParent()->SetScrollCenterPosition( center );
GetParent()->SetCrossHairPosition( center, true );
GetParent()->RedrawScreen( center, false );
}
}
else if( wheelRotation > 0 )
@ -977,10 +976,6 @@ void EDA_DRAW_PANEL::OnMagnify( wxMouseEvent& event )
SetZoom(scaleFactor);
// Recenter the window along our scaled vector such that the
// cursor becomes our scale axis, remaining fixed on screen
GetParent()->RedrawScreen( cursorPosition + vector, warpCursor );
event.Skip();
}
#endif

View File

@ -1,205 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* Dialog for selecting color from the palette of available colors.
*/
// LEGACY TODO: obsolete once legacy canvas removed
#include <fctsys.h>
#include <common.h>
#include <gal/color4d.h>
#include <wx/statline.h>
#include <algorithm>
using KIGFX::COLOR4D;
enum colors_id {
ID_COLOR_BLACK = 2000 // colors_id = ID_COLOR_BLACK a ID_COLOR_BLACK + NBCOLORS-1
};
class CHOOSE_COLOR_DLG : public wxDialog
{
public:
CHOOSE_COLOR_DLG( wxWindow* aParent, COLOR4D aOldColor );
~CHOOSE_COLOR_DLG() {};
COLOR4D GetSelectedColor() { return m_color; }
private:
void init_Dialog();
void selColor( wxCommandEvent& event );
COLOR4D m_color;
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE( CHOOSE_COLOR_DLG, wxDialog )
EVT_COMMAND_RANGE( ID_COLOR_BLACK, ID_COLOR_BLACK + NBCOLORS,
wxEVT_COMMAND_BUTTON_CLICKED,
CHOOSE_COLOR_DLG::selColor )
END_EVENT_TABLE()
COLOR4D DisplayColorFrame( wxWindow* aParent, COLOR4D aOldColor )
{
CHOOSE_COLOR_DLG dlg( aParent, aOldColor );
if( dlg.ShowModal() == wxID_OK )
{
return dlg.GetSelectedColor();
}
return COLOR4D::UNSPECIFIED;
}
CHOOSE_COLOR_DLG::CHOOSE_COLOR_DLG( wxWindow* aParent, COLOR4D aOldColor ) :
wxDialog( aParent, wxID_ANY, _( "Colors" ), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
{
m_color = aOldColor;
init_Dialog();
// Resize the dialog
GetSizer()->SetSizeHints( this );
Centre();
}
void CHOOSE_COLOR_DLG::init_Dialog()
{
wxFlexGridSizer* FlexColumnBoxSizer = NULL;
wxBitmapButton* focusedButton = NULL;
const int w = 20, h = 20;
wxBoxSizer* OuterBoxSizer = new wxBoxSizer( wxVERTICAL );
SetSizer( OuterBoxSizer );
wxBoxSizer*MainBoxSizer = new wxBoxSizer( wxHORIZONTAL );
OuterBoxSizer->Add( MainBoxSizer, 1, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
for( int ii = 0; ii < NBCOLORS; ++ii )
{
// Provide a separate column for every six buttons (and their
// associated text strings), so provide a FlexGrid Sizer with
// six rows and two columns.
if( ii % 6 == 0 )
{
FlexColumnBoxSizer = new wxFlexGridSizer( 6, 2, 0, 0 );
// Specify that all of the rows can be expanded.
for( int kk = 0; kk < 6; kk++ )
{
FlexColumnBoxSizer->AddGrowableRow( kk );
}
// Specify that the second column can also be expanded.
FlexColumnBoxSizer->AddGrowableCol( 1 );
MainBoxSizer->Add( FlexColumnBoxSizer, 1, wxGROW | wxTOP, 5 );
}
int butt_ID = ID_COLOR_BLACK + ii;
wxMemoryDC iconDC;
wxBitmap ButtBitmap( w, h );
wxBrush brush;
iconDC.SelectObject( ButtBitmap );
COLOR4D buttcolor = COLOR4D( g_ColorRefs[ii].m_Numcolor );
iconDC.SetPen( *wxBLACK_PEN );
brush.SetColour( buttcolor.ToColour() );
brush.SetStyle( wxBRUSHSTYLE_SOLID );
iconDC.SetBrush( brush );
iconDC.SetBackground( *wxGREY_BRUSH );
iconDC.Clear();
iconDC.DrawRoundedRectangle( 0, 0, w, h, (double) h / 3 );
wxBitmapButton* bitmapButton = new wxBitmapButton( this, butt_ID, ButtBitmap,
wxDefaultPosition, wxSize( w+8, h+6 ) );
FlexColumnBoxSizer->Add( bitmapButton, 0,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
wxLEFT | wxBOTTOM, 5 );
// Set focus to this button if its color matches the
// color which had been selected previously (for
// whichever layer's color is currently being edited).
if( m_color == buttcolor )
focusedButton = bitmapButton;
EDA_COLOR_T edaColor = ColorFindNearest( buttcolor.ToColour() );
wxStaticText* label = new wxStaticText( this, -1, wxGetTranslation( ColorGetName( edaColor ) ),
wxDefaultPosition, wxDefaultSize, 0 );
FlexColumnBoxSizer->Add( label, 1,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
wxLEFT | wxRIGHT | wxBOTTOM, 5 );
}
// Provide a Cancel button as well, so that this dialog
// box can also be canceled by pressing the Esc key
// (and also provide a horizontal static line to separate
// that button from all of the other buttons).
wxStaticLine* sline = new wxStaticLine( this, -1, wxDefaultPosition,
wxDefaultSize, wxLI_HORIZONTAL );
OuterBoxSizer->Add( sline, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
wxStdDialogButtonSizer* stdDialogButtonSizer = new wxStdDialogButtonSizer;
OuterBoxSizer->Add( stdDialogButtonSizer, 0, wxGROW | wxALL, 10 );
wxButton* cancelButton = new wxButton( this, wxID_CANCEL, _( "Cancel" ),
wxDefaultPosition, wxDefaultSize, 0 );
stdDialogButtonSizer->AddButton( cancelButton );
stdDialogButtonSizer->Realize();
// Set focus to the Cancel button if the currently selected color
// does not match any of the colors provided by this dialog box.
// (That shouldn't ever happen in practice though.)
if( focusedButton )
focusedButton->SetFocus();
else
cancelButton->SetFocus();
}
void CHOOSE_COLOR_DLG::selColor( wxCommandEvent& event )
{
int id = event.GetId();
m_color = EDA_COLOR_T( id - ID_COLOR_BLACK );
// Close the dialog by calling the default dialog handler for a wxID_OK event
event.SetId( wxID_OK );
event.Skip();
}

View File

@ -446,7 +446,6 @@ void CVPCB_MAINFRAME::OnEditFootprintLibraryTable( wxCommandEvent& aEvent )
void CVPCB_MAINFRAME::DisplayModule( wxCommandEvent& event )
{
CreateScreenCmp();
GetFootprintViewerFrame()->RedrawScreen( wxPoint( 0, 0 ), false );
}

View File

@ -354,20 +354,6 @@ void SCH_BASE_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointe
}
void SCH_BASE_FRAME::RedrawScreen2( const wxPoint& posBefore )
{
KIGFX::GAL* gal = GetCanvas()->GetGAL();
double selectedZoom = GetScreen()->GetZoom();
double zoomFactor = gal->GetWorldScale() / gal->GetZoomFactor();
double scale = 1.0 / ( zoomFactor * selectedZoom );
GetCanvas()->GetView()->SetScale( scale );
GetGalCanvas()->Refresh();
}
void SCH_BASE_FRAME::CenterScreen( const wxPoint& aCenterPoint, bool aWarpPointer )
{
GetCanvas()->GetView()->SetCenter( aCenterPoint );

View File

@ -300,13 +300,11 @@ public:
const LIB_ID& aPreselectedLibid,
int aUnit, int aConvert );
virtual void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) override;
virtual void RedrawScreen2( const wxPoint& posBefore ) override;
virtual void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer );
virtual void CenterScreen( const wxPoint& aCenterPoint, bool aWarpPointer );
virtual void HardRedraw() override;
void HardRedraw() override;
/**
* Add an item to the screen (and view)

View File

@ -221,7 +221,7 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_MENU( ID_APPEND_PROJECT, SCH_EDIT_FRAME::OnAppendProject )
EVT_MENU( ID_IMPORT_NON_KICAD_SCH, SCH_EDIT_FRAME::OnImportProject )
EVT_MENU( ID_GEN_COPY_SHEET_TO_CLIPBOARD, EDA_DRAW_FRAME::CopyToClipboard )
EVT_MENU( ID_GEN_COPY_SHEET_TO_CLIPBOARD, SCH_EDIT_FRAME::DrawCurrentSheetToClipboard )
EVT_MENU( wxID_EXIT, SCH_EDIT_FRAME::OnExit )
EVT_MENU( ID_CONFIG_SAVE, SCH_EDIT_FRAME::Process_Config )

View File

@ -566,6 +566,12 @@ public:
*/
void DisplayCurrentSheet();
/**
* Use the wxWidgets print code to draw an image of the current sheet onto
* the clipboard.
*/
void DrawCurrentSheetToClipboard( wxCommandEvent& event );
/**
* Called when modifying the page settings.
* In derived classes it can be used to modify parameters like draw area size,

View File

@ -28,6 +28,7 @@
#include <kiface_i.h>
#include <project.h>
#include <wildcards_and_files_ext.h>
#include <wx/clipbrd.h>
#include <sch_edit_frame.h>
#include <sch_legacy_plugin.h>
#include <sch_sheet.h>
@ -402,3 +403,87 @@ SCH_HIERLABEL* SCH_EDIT_FRAME::ImportHierLabel( SCH_SHEET* aSheet )
return nullptr;
}
/*
* Copy the current page or block to the clipboard, to export drawings to other applications
* (word processing ...) This is not suitable for copy command within Eeschema or Pcbnew.
*/
void SCH_EDIT_FRAME::DrawCurrentSheetToClipboard( wxCommandEvent& aEvt )
{
wxRect DrawArea;
BASE_SCREEN* screen = GetCanvas()->GetScreen();
DrawArea.SetSize( GetPageSizeIU() );
// 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 * IU_PER_MILS;
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 ); // we use zoom = 1 in draw functions.
wxMemoryDC dc;
wxBitmap image( dcsize );
dc.SelectObject( image );
EDA_RECT tmp = *GetCanvas()->GetClipBox();
GRResetPenAndBrush( &dc );
GRForceBlackPen( false );
screen->m_IsPrinting = true;
dc.SetUserScale( scale, scale );
GetCanvas()->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) );
dc.Clear();
GetCanvas()->EraseScreen( &dc );
const LSET allLayersMask = LSET().set();
PrintPage( &dc, allLayersMask, false );
screen->m_IsPrinting = false;
GetCanvas()->SetClipBox( tmp );
if( wxTheClipboard->Open() )
{
// 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();
}
// Deselect Bitmap from DC in order to delete the MemoryDC
dc.SelectObject( wxNullBitmap );
GRForceBlackPen( false );
screen->m_StartVisu = tmp_startvisu;
screen->m_DrawOrg = old_org;
screen->SetZoom( tmpzoom );
}

View File

@ -123,13 +123,6 @@ GBR_SCREEN::~GBR_SCREEN()
}
// virtual function
int GBR_SCREEN::MilsToIuScalar()
{
return (int)IU_PER_MILS;
}
/* Virtual function needed by classes derived from BASE_SCREEN
* this is a virtual pure function in BASE_SCREEN
* do nothing in GerbView

View File

@ -50,8 +50,6 @@ public:
GBR_SCREEN* Next() const { return static_cast<GBR_SCREEN*>( Pnext ); }
virtual int MilsToIuScalar() override;
/**
* Function ClearUndoORRedoList
* virtual pure in BASE_SCREEN, so it must be defined here

View File

@ -121,13 +121,6 @@ private:
*/
void setCrossHairPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin, bool aSnapToGrid );
/**
* Function getCursorScreenPosition
* returns the cross hair position in device (display) units.b
* @return The current cross hair position.
*/
wxPoint getCrossHairScreenPosition() const;
/**
* Function getNearestGridPosition
* returns the nearest \a aGridSize location to \a aPosition.
@ -229,16 +222,6 @@ public:
void InitDataPoints( const wxSize& aPageSizeInternalUnits );
/**
* Function MilsToIuScalar
* returns the scalar required to convert mils to internal units.
*
* @note This is a temporary hack until the derived objects SCH_SCREEN and PCB_SCREEN
* no longer need to be derived from BASE_SCREEN. I does allow removal of the
* obsolete GetInternalUnits function.
*/
virtual int MilsToIuScalar() { return 1; }
/* general Undo/Redo command control */
/**

View File

@ -356,13 +356,6 @@ public:
*/
wxPoint GetNearestGridPosition( const wxPoint& aPosition, wxRealPoint* aGridSize = NULL ) const;
/**
* Return the cross hair position in device (display) units.b
*
* @return The current cross hair position.
*/
wxPoint GetCrossHairScreenPosition() const;
void SetMousePosition( const wxPoint& aPosition );
/**
@ -561,23 +554,6 @@ public:
m_gridColor = aColor;
}
/**
* Change the grid size settings to the next one available.
*/
virtual void SetNextGrid();
/**
* Change the grid size settings to the previous one available.
*/
virtual void SetPrevGrid();
/**
* Change the grid size to one of the preset values.
*
* @param aIndex is the index from the list.
*/
void SetPresetGrid( int aIndex );
/**
* Command event handler for selecting grid sizes.
*
@ -612,8 +588,6 @@ public:
void OnEraseBackground( wxEraseEvent& SizeEvent );
virtual void OnZoom( wxCommandEvent& event );
/**
* Change the zoom to the next one available redraws the screen
* and warp the mouse pointer on request.
@ -632,29 +606,6 @@ public:
*/
void SetPreviousZoomAndRedraw( const wxPoint& aCenterPoint, bool aWarpPointer );
/**
* Change zoom to one of the preset values.
*
* @param aIndex is the zoom index from the list.
*/
void SetPresetZoom( int aIndex );
/**
* 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 );
/**
* 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 );
/**
* Rebuild the GAL and redraws the screen. Call when something went wrong.
*/
@ -738,11 +689,6 @@ public:
*/
void DisplayUnitsMsg();
/**
* Copy the current page or the current block to the clipboard.
*/
void CopyToClipboard( wxCommandEvent& event );
/* interprocess communication */
void CreateServer( int service, bool local = true );
void OnSockRequest( wxSocketEvent& evt );

View File

@ -57,8 +57,6 @@ public:
PCB_SCREEN* Next() const { return static_cast<PCB_SCREEN*>( Pnext ); }
virtual int MilsToIuScalar() override;
/**
* Function GetCurItem
* returns the currently selected BOARD_ITEM, overriding

View File

@ -101,12 +101,6 @@ PL_EDITOR_SCREEN::~PL_EDITOR_SCREEN()
}
int PL_EDITOR_SCREEN::MilsToIuScalar()
{
return (int)IU_PER_MILS;
}
void PL_EDITOR_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
{
if( aItemCount == 0 )

View File

@ -48,8 +48,6 @@ public:
~PL_EDITOR_SCREEN();
virtual int MilsToIuScalar() override;
/**
* Function ClearUndoORRedoList
* virtual pure in BASE_SCREEN, so it must be defined here

View File

@ -177,9 +177,3 @@ PCB_SCREEN::~PCB_SCREEN()
{
ClearUndoRedoList();
}
int PCB_SCREEN::MilsToIuScalar()
{
return static_cast<int>( IU_PER_MILS );
}