kicad/cvpcb/display_footprints_frame.cpp

585 lines
17 KiB
C++
Raw Normal View History

/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2007-2017 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
* 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
*/
/**
* @file display_footprints_frame.cpp
*/
2007-05-06 16:03:28 +00:00
#include <fctsys.h>
#include <common.h>
#include <class_drawpanel.h>
#include <class_draw_panel_gal.h>
#include <confirm.h>
#include <macros.h>
#include <bitmaps.h>
#include <msgpanel.h>
#include <wildcards_and_files_ext.h>
#include <lib_id.h>
#include <fp_lib_table.h>
#include <io_mgr.h>
#include <class_module.h>
#include <class_board.h>
#include <cvpcb_mainframe.h>
#include <display_footprints_frame.h>
#include <cvpcb_id.h>
#include <listboxes.h>
2007-05-06 16:03:28 +00:00
#include <3d_viewer/eda_3d_viewer.h>
// Colors for layers and items
COLORS_DESIGN_SETTINGS g_ColorsSettings( FRAME_CVPCB_DISPLAY );
BEGIN_EVENT_TABLE( DISPLAY_FOOTPRINTS_FRAME, PCB_BASE_FRAME )
2010-02-01 21:23:27 +00:00
EVT_CLOSE( DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow )
EVT_SIZE( DISPLAY_FOOTPRINTS_FRAME::OnSize )
EVT_TOOL( ID_OPTIONS_SETUP, DISPLAY_FOOTPRINTS_FRAME::InstallOptionsDisplay )
EVT_TOOL( ID_CVPCB_SHOW3D_FRAME, DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame )
EVT_TOOL( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH,
DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar)
EVT_TOOL( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH,
DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar)
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH,
DISPLAY_FOOTPRINTS_FRAME::OnUpdateTextDrawMode )
EVT_UPDATE_UI( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH,
DISPLAY_FOOTPRINTS_FRAME::OnUpdateLineDrawMode )
END_EVENT_TABLE()
2007-05-06 16:03:28 +00:00
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, CVPCB_MAINFRAME* aParent ) :
PCB_BASE_FRAME( aKiway, aParent, FRAME_CVPCB_DISPLAY, _( "Footprint Viewer" ),
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
wxDefaultPosition, wxDefaultSize,
KICAD_DEFAULT_DRAWFRAME_STYLE, FOOTPRINTVIEWER_FRAME_NAME )
{
m_showAxis = true; // true to draw axis.
// Give an icon
wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_cvpcb_xpm ) );
SetIcon( icon );
2007-05-06 16:03:28 +00:00
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
SetBoard( new BOARD() );
2012-01-04 06:18:38 +00:00
SetScreen( new PCB_SCREEN( GetPageSizeIU() ) );
2007-05-06 16:03:28 +00:00
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
LoadSettings( config() );
// Initialize grid id to a default value if not found in config or incorrect:
if( !( GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) ) )
2009-10-15 11:35:53 +00:00
m_LastGridSizeId = ID_POPUP_GRID_LEVEL_500 - ID_POPUP_GRID_LEVEL_1000;
GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 );
// Initialize some display options
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
displ_opts->m_DisplayPadIsol = false; // Pad clearance has no meaning here
// Track and via clearance has no meaning here.
displ_opts->m_ShowTrackClearanceMode = PCB_DISPLAY_OPTIONS::DO_NOT_SHOW_CLEARANCE;
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
ReCreateHToolbar();
ReCreateVToolbar();
ReCreateOptToolbar();
m_auimgr.SetManagedWindow( this );
EDA_PANEINFO horiz;
horiz.HorizontalToolbarPane();
EDA_PANEINFO vert;
vert.VerticalToolbarPane();
EDA_PANEINFO mesg;
mesg.MessageToolbarPane();
m_auimgr.AddPane( m_mainToolBar,
wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top(). Row( 0 ) );
if( m_drawToolBar ) // Currently, no vertical right toolbar.
m_auimgr.AddPane( m_drawToolBar,
wxAuiPaneInfo( vert ).Name( wxT( "m_drawToolBar" ) ).Right() );
m_auimgr.AddPane( m_canvas,
wxAuiPaneInfo().Name( wxT( "DisplayFrame" ) ).CentrePane() );
m_auimgr.AddPane( m_messagePanel,
wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) );
m_auimgr.AddPane( m_optionsToolBar,
wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left() );
m_auimgr.Update();
Show( true );
2007-05-06 16:03:28 +00:00
}
2010-02-01 21:23:27 +00:00
DISPLAY_FOOTPRINTS_FRAME::~DISPLAY_FOOTPRINTS_FRAME()
2007-05-06 16:03:28 +00:00
{
delete GetScreen();
SetScreen( NULL ); // Be sure there is no double deletion
2007-05-06 16:03:28 +00:00
}
2012-02-07 17:36:24 +00:00
2010-02-01 21:23:27 +00:00
void DISPLAY_FOOTPRINTS_FRAME::OnCloseWindow( wxCloseEvent& event )
2007-05-06 16:03:28 +00:00
{
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
if( draw3DFrame )
draw3DFrame->Close( true );
Destroy();
2007-05-06 16:03:28 +00:00
}
2010-02-01 21:23:27 +00:00
void DISPLAY_FOOTPRINTS_FRAME::ReCreateVToolbar()
2007-05-06 16:03:28 +00:00
{
// Currently, no vertical right toolbar.
// So do nothing
2007-05-06 16:03:28 +00:00
}
void DISPLAY_FOOTPRINTS_FRAME::ReCreateOptToolbar()
{
if( m_optionsToolBar )
return;
// Create options tool bar.
m_optionsToolBar = new wxAuiToolBar( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_GRID, wxEmptyString, KiBitmap( grid_xpm ),
_( "Hide grid" ), wxITEM_CHECK );
m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_POLAR_COORD, wxEmptyString,
KiBitmap( polar_coord_xpm ),
_( "Display polar coordinates" ), wxITEM_CHECK );
m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, wxEmptyString,
KiBitmap( unit_inch_xpm ),
_( "Set units to inches" ), wxITEM_CHECK );
m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_UNIT_MM, wxEmptyString,
KiBitmap( unit_mm_xpm ),
_( "Set units to millimeters" ), wxITEM_CHECK );
#ifndef __APPLE__
m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
KiBitmap( cursor_shape_xpm ),
_( "Change cursor shape" ), wxITEM_CHECK );
#else
m_optionsToolBar->AddTool( ID_TB_OPTIONS_SELECT_CURSOR, wxEmptyString,
KiBitmap( cursor_shape_xpm ),
_( "Change cursor shape (not supported in Legacy Toolset)" ),
wxITEM_CHECK );
#endif
m_optionsToolBar->AddSeparator();
m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH, wxEmptyString,
KiBitmap( pad_sketch_xpm ),
_( "Show pads in outline mode" ), wxITEM_CHECK );
m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, wxEmptyString,
KiBitmap( text_sketch_xpm ),
_( "Show texts in line mode" ), wxITEM_CHECK );
m_optionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, wxEmptyString,
KiBitmap( show_mod_edge_xpm ),
_( "Show outlines in line mode" ), wxITEM_CHECK );
m_optionsToolBar->Realize();
}
2010-02-01 21:23:27 +00:00
void DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar()
2007-05-06 16:03:28 +00:00
{
if( m_mainToolBar != NULL )
return;
m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
2007-05-06 16:03:28 +00:00
m_mainToolBar->AddTool( ID_OPTIONS_SETUP, wxEmptyString, KiBitmap( display_options_xpm ),
_( "Display options" ) );
2007-05-06 16:03:28 +00:00
m_mainToolBar->AddSeparator();
2007-05-06 16:03:28 +00:00
m_mainToolBar->AddTool( ID_ZOOM_IN, wxEmptyString, KiBitmap( zoom_in_xpm ),
_( "Zoom in (F1)" ) );
2007-05-06 16:03:28 +00:00
m_mainToolBar->AddTool( ID_ZOOM_OUT, wxEmptyString, KiBitmap( zoom_out_xpm ),
_( "Zoom out (F2)" ) );
2007-05-06 16:03:28 +00:00
m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString, KiBitmap( zoom_redraw_xpm ),
_( "Redraw view (F3)" ) );
2007-05-06 16:03:28 +00:00
m_mainToolBar->AddTool( ID_ZOOM_PAGE, wxEmptyString, KiBitmap( zoom_fit_in_page_xpm ),
_( "Zoom auto (Home)" ) );
2007-05-06 16:03:28 +00:00
m_mainToolBar->AddSeparator();
m_mainToolBar->AddTool( ID_CVPCB_SHOW3D_FRAME, wxEmptyString, KiBitmap( three_d_xpm ),
_( "3D Display (Alt+3)" ) );
2007-05-06 16:03:28 +00:00
// after adding the buttons to the toolbar, must call Realize() to reflect
// the changes
m_mainToolBar->Realize();
2007-05-06 16:03:28 +00:00
}
void DISPLAY_FOOTPRINTS_FRAME::OnUpdateTextDrawMode( wxUpdateUIEvent& aEvent )
2007-05-06 16:03:28 +00:00
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
wxString msgTextsFill[2] = { _( "Show texts in filled mode" ),
_( "Show texts in sketch mode" ) };
unsigned i = displ_opts->m_DisplayModTextFill == SKETCH ? 0 : 1;
aEvent.Check( displ_opts->m_DisplayModTextFill == SKETCH );
m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH, msgTextsFill[i] );
}
void DISPLAY_FOOTPRINTS_FRAME::OnUpdateLineDrawMode( wxUpdateUIEvent& aEvent )
{
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
wxString msgEdgesFill[2] = { _( "Show outlines in filled mode" ),
_( "Show outlines in sketch mode" ) };
int i = displ_opts->m_DisplayModEdgeFill == SKETCH ? 0 : 1;
aEvent.Check( displ_opts->m_DisplayModEdgeFill == SKETCH );
m_optionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH, msgEdgesFill[i] );
2007-05-06 16:03:28 +00:00
}
2010-02-01 21:23:27 +00:00
void DISPLAY_FOOTPRINTS_FRAME::OnLeftClick( wxDC* DC, const wxPoint& MousePos )
2007-05-06 16:03:28 +00:00
{
}
2010-02-01 21:23:27 +00:00
void DISPLAY_FOOTPRINTS_FRAME::OnLeftDClick( wxDC* DC, const wxPoint& MousePos )
2007-05-06 16:03:28 +00:00
{
}
bool DISPLAY_FOOTPRINTS_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu )
2007-05-06 16:03:28 +00:00
{
return true;
2007-05-06 16:03:28 +00:00
}
void DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
{
int id = event.GetId();
auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions();
switch( id )
{
case ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH:
displ_opts->m_DisplayModTextFill = displ_opts->m_DisplayModTextFill == FILLED ? SKETCH : FILLED;
m_canvas->Refresh( );
break;
case ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH:
displ_opts->m_DisplayModEdgeFill = displ_opts->m_DisplayModEdgeFill == FILLED ? SKETCH : FILLED;
m_canvas->Refresh();
break;
default:
DisplayError( this,
wxT( "DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar error" ) );
break;
}
}
2007-05-06 16:03:28 +00:00
bool DISPLAY_FOOTPRINTS_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition,
EDA_KEY aHotKey )
2007-05-06 16:03:28 +00:00
{
bool eventHandled = true;
// Filter out the 'fake' mouse motion after a keyboard movement
if( !aHotKey && m_movingCursorWithKeyboard )
{
m_movingCursorWithKeyboard = false;
return false;
}
2009-01-07 15:59:49 +00:00
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
wxPoint pos = aPosition;
wxPoint oldpos = GetCrossHairPosition();
GeneralControlKeyMovement( aHotKey, &pos, true );
switch( aHotKey )
{
case WXK_F1:
cmd.SetId( ID_KEY_ZOOM_IN );
GetEventHandler()->ProcessEvent( cmd );
break;
case WXK_F2:
cmd.SetId( ID_KEY_ZOOM_OUT );
GetEventHandler()->ProcessEvent( cmd );
break;
case WXK_F3:
cmd.SetId( ID_ZOOM_REDRAW );
GetEventHandler()->ProcessEvent( cmd );
break;
case WXK_F4:
cmd.SetId( ID_POPUP_ZOOM_CENTER );
GetEventHandler()->ProcessEvent( cmd );
break;
2009-09-27 14:09:26 +00:00
case WXK_HOME:
cmd.SetId( ID_ZOOM_PAGE );
GetEventHandler()->ProcessEvent( cmd );
break;
case ' ':
GetScreen()->m_O_Curseur = GetCrossHairPosition();
break;
case GR_KB_ALT + '3':
cmd.SetId( ID_CVPCB_SHOW3D_FRAME );
GetEventHandler()->ProcessEvent( cmd );
break;
default:
eventHandled = false;
}
SetCrossHairPosition( pos );
RefreshCrossHair( oldpos, aPosition, aDC );
UpdateStatusBar(); /* Display new cursor coordinates */
return eventHandled;
2007-05-06 16:03:28 +00:00
}
2010-02-01 21:23:27 +00:00
void DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame( wxCommandEvent& event )
{
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
if( draw3DFrame )
{
// Raising the window does not show the window on Windows if iconized.
// This should work on any platform.
if( draw3DFrame->IsIconized() )
draw3DFrame->Iconize( false );
draw3DFrame->Raise();
// Raising the window does not set the focus on Linux. This should work on any platform.
if( wxWindow::FindFocus() != draw3DFrame )
draw3DFrame->SetFocus();
return;
}
draw3DFrame = new EDA_3D_VIEWER( &Kiway(), this, _( "3D Viewer" ) );
draw3DFrame->Raise(); // Needed with some Window Managers
draw3DFrame->Show( true );
}
/**
* Virtual function needed by the PCB_SCREEN class derived from BASE_SCREEN
* this is a virtual pure function in BASE_SCREEN
* do nothing in Cvpcb
* could be removed later
*/
void PCB_SCREEN::ClearUndoORRedoList( UNDO_REDO_CONTAINER&, int )
{
}
2010-02-01 21:23:27 +00:00
bool DISPLAY_FOOTPRINTS_FRAME::IsGridVisible() const
2010-02-01 21:23:27 +00:00
{
return m_drawGrid;
2010-02-01 21:23:27 +00:00
}
2010-02-01 21:23:27 +00:00
void DISPLAY_FOOTPRINTS_FRAME::SetGridVisibility(bool aVisible)
{
m_drawGrid = aVisible;
2010-02-01 21:23:27 +00:00
}
COLOR4D DISPLAY_FOOTPRINTS_FRAME::GetGridColor()
2010-02-01 21:23:27 +00:00
{
return COLOR4D( DARKGRAY );
2010-02-01 21:23:27 +00:00
}
MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
{
MODULE* footprint = NULL;
try
{
LIB_ID fpid;
if( fpid.Parse( aFootprintName ) >= 0 )
{
DisplayInfoMessage( this, wxString::Format( wxT( "Footprint ID \"%s\" is not valid." ),
GetChars( aFootprintName ) ) );
return NULL;
}
std::string nickname = fpid.GetLibNickname();
std::string fpname = fpid.GetLibItemName();
wxLogDebug( wxT( "Load footprint \"%s\" from library \"%s\"." ),
fpname.c_str(), nickname.c_str() );
footprint = Prj().PcbFootprintLibs( Kiway() )->FootprintLoad(
FROM_UTF8( nickname.c_str() ), FROM_UTF8( fpname.c_str() ) );
}
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.What() );
return NULL;
}
if( footprint )
{
footprint->SetParent( (EDA_ITEM*) GetBoard() );
footprint->SetPosition( wxPoint( 0, 0 ) );
return footprint;
}
wxString msg = wxString::Format( _( "Footprint \"%s\" not found" ), aFootprintName.GetData() );
DisplayError( this, msg );
return NULL;
}
void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
{
wxString msg;
CVPCB_MAINFRAME* parentframe = (CVPCB_MAINFRAME *) GetParent();
wxString footprintName = parentframe->GetSelectedFootprint();
if( !footprintName.IsEmpty() )
{
msg.Printf( _( "Footprint: %s" ), GetChars( footprintName ) );
SetTitle( msg );
const FOOTPRINT_INFO* module_info =
parentframe->m_FootprintsList->GetModuleInfo( footprintName );
const wxChar* libname;
if( module_info )
libname = GetChars( module_info->GetNickname() );
else
libname = GetChars( wxT( "???" ) );
msg.Printf( _( "Lib: %s" ), libname );
SetStatusText( msg, 0 );
if( GetBoard()->m_Modules.GetCount() )
{
// there is only one module in the list
GetBoard()->m_Modules.DeleteAll();
}
MODULE* module = Get_Module( footprintName );
if( module )
GetBoard()->m_Modules.PushBack( module );
Zoom_Automatique( false );
}
else // No footprint to display. Erase old footprint, if any
{
if( GetBoard()->m_Modules.GetCount() )
{
GetBoard()->m_Modules.DeleteAll();
Zoom_Automatique( false );
SetStatusText( wxEmptyString, 0 );
}
}
// Display new cursor coordinates and zoom value:
UpdateStatusBar();
GetCanvas()->Refresh();
EDA_3D_VIEWER* draw3DFrame = Get3DViewerFrame();
if( draw3DFrame )
draw3DFrame->NewDisplay( true );
}
void DISPLAY_FOOTPRINTS_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
if( !GetBoard() )
return;
m_canvas->DrawBackGround( DC );
GetBoard()->Draw( m_canvas, DC, GR_COPY );
MODULE* Module = GetBoard()->m_Modules;
if ( Module )
{
MSG_PANEL_ITEMS items;
Module->GetMsgPanelInfo( items );
SetMsgPanel( items );
}
m_canvas->DrawCrossHair( DC );
}
/*
* Redraw the BOARD items but not cursors, axis or grid.
*/
void BOARD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
GR_DRAWMODE aDrawMode, const wxPoint& aOffset )
{
if( m_Modules )
{
m_Modules->Draw( aPanel, aDC, GR_COPY );
}
}