2013-07-19 18:27:22 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2013-08-13 17:51:22 +00:00
|
|
|
* Copyright (C) 2013 CERN
|
2023-02-07 16:34:46 +00:00
|
|
|
* Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-08-13 17:51:22 +00:00
|
|
|
* @author Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2013-07-19 18:27:22 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2019-05-24 13:37:55 +00:00
|
|
|
#include <pgm_base.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2020-11-18 01:21:04 +00:00
|
|
|
#include <core/arraydim.h>
|
2021-02-22 23:47:17 +00:00
|
|
|
#include <drawing_sheet/ds_data_item.h>
|
|
|
|
#include <drawing_sheet/ds_data_model.h>
|
2019-08-18 21:48:52 +00:00
|
|
|
#include <panel_hotkeys_editor.h>
|
2013-07-19 18:27:22 +00:00
|
|
|
#include <confirm.h>
|
2020-09-01 10:14:51 +00:00
|
|
|
#include <kiplatform/app.h>
|
2020-10-14 11:29:36 +00:00
|
|
|
#include <painter.h>
|
2022-09-14 22:28:09 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2019-05-20 10:23:32 +00:00
|
|
|
#include <tool/selection.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/action_toolbar.h>
|
2020-07-29 23:50:25 +00:00
|
|
|
#include <tool/editor_conditions.h>
|
2019-05-20 10:23:32 +00:00
|
|
|
#include <tool/tool_dispatcher.h>
|
|
|
|
#include <tool/tool_manager.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/common_control.h>
|
2019-05-20 10:23:32 +00:00
|
|
|
#include <tool/common_tools.h>
|
2019-07-15 23:44:01 +00:00
|
|
|
#include <tool/picker_tool.h>
|
2019-05-20 10:23:32 +00:00
|
|
|
#include <tool/zoom_tool.h>
|
2020-08-02 17:42:35 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2020-10-13 05:04:31 +00:00
|
|
|
#include "pl_editor_frame.h"
|
|
|
|
#include "pl_editor_id.h"
|
|
|
|
#include "pl_editor_settings.h"
|
|
|
|
#include "properties_frame.h"
|
|
|
|
#include "tools/pl_actions.h"
|
|
|
|
#include "tools/pl_selection_tool.h"
|
|
|
|
#include "tools/pl_drawing_tools.h"
|
|
|
|
#include "tools/pl_edit_tool.h"
|
|
|
|
#include "tools/pl_point_editor.h"
|
|
|
|
#include "invoke_pl_editor_dialog.h"
|
|
|
|
#include "tools/pl_editor_control.h"
|
2020-12-01 19:27:42 +00:00
|
|
|
#include <zoom_defines.h>
|
2020-10-13 05:04:31 +00:00
|
|
|
|
2021-06-03 01:19:20 +00:00
|
|
|
#include <wx/filedlg.h>
|
2021-06-03 22:32:32 +00:00
|
|
|
#include <wx/print.h>
|
2021-06-03 15:41:26 +00:00
|
|
|
#include <wx/treebook.h>
|
2021-06-03 01:19:20 +00:00
|
|
|
|
2020-10-18 20:30:37 +00:00
|
|
|
|
2019-05-24 13:37:55 +00:00
|
|
|
BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME )
|
2019-08-02 08:35:26 +00:00
|
|
|
EVT_MENU( wxID_CLOSE, PL_EDITOR_FRAME::OnExit )
|
|
|
|
EVT_MENU( wxID_EXIT, PL_EDITOR_FRAME::OnExit )
|
|
|
|
|
2019-05-24 13:37:55 +00:00
|
|
|
EVT_MENU( wxID_FILE, PL_EDITOR_FRAME::Files_io )
|
|
|
|
|
|
|
|
EVT_MENU_RANGE( ID_FILE1, ID_FILEMAX, PL_EDITOR_FRAME::OnFileHistory )
|
2020-02-25 15:46:56 +00:00
|
|
|
EVT_MENU( ID_FILE_LIST_CLEAR, PL_EDITOR_FRAME::OnClearFileHistory )
|
2019-05-24 13:37:55 +00:00
|
|
|
|
2023-04-29 17:16:34 +00:00
|
|
|
EVT_MENU( ID_GRID_SETTINGS, PL_EDITOR_FRAME::OnGridSettings )
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
EVT_CHOICE( ID_SELECT_COORDINATE_ORIGIN, PL_EDITOR_FRAME::OnSelectCoordOriginCorner )
|
|
|
|
EVT_CHOICE( ID_SELECT_PAGE_NUMBER, PL_EDITOR_FRAME::OnSelectPage )
|
2022-09-14 22:28:09 +00:00
|
|
|
|
|
|
|
// Drop files event
|
|
|
|
EVT_DROP_FILES( PL_EDITOR_FRAME::OnDropFiles )
|
2019-05-24 13:37:55 +00:00
|
|
|
END_EVENT_TABLE()
|
2013-07-19 18:27:22 +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
|
|
|
PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
2019-05-20 10:23:32 +00:00
|
|
|
EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2022-09-16 04:38:10 +00:00
|
|
|
KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME, drawSheetIUScale ),
|
2021-06-08 19:39:47 +00:00
|
|
|
m_propertiesPagelayout( nullptr ),
|
2020-10-01 18:50:09 +00:00
|
|
|
m_propertiesFrameWidth( 200 ),
|
|
|
|
m_originSelectBox( nullptr ),
|
|
|
|
m_originSelectChoice( 0 ),
|
2022-02-25 21:18:43 +00:00
|
|
|
m_pageSelectBox( nullptr ),
|
|
|
|
m_mruImagePath( wxEmptyString )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2020-10-18 18:38:40 +00:00
|
|
|
m_maximizeByDefault = true;
|
2022-09-26 16:54:42 +00:00
|
|
|
SetUserUnits( EDA_UNITS::MILLIMETRES );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2014-06-20 11:13:04 +00:00
|
|
|
m_showBorderAndTitleBlock = true; // true for reference drawings.
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_MODEL::GetTheInstance().m_EditMode = true;
|
2022-12-31 23:39:04 +00:00
|
|
|
m_aboutTitle = _HKI( "KiCad Drawing Sheet Editor" );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Give an icon
|
|
|
|
wxIcon icon;
|
2020-12-22 19:41:32 +00:00
|
|
|
wxIconBundle icon_bundle;
|
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pagelayout_editor ) );
|
2020-12-22 19:41:32 +00:00
|
|
|
icon_bundle.AddIcon( icon );
|
2021-03-08 02:59:07 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pagelayout_editor_32 ) );
|
2020-12-22 19:41:32 +00:00
|
|
|
icon_bundle.AddIcon( icon );
|
2021-03-08 02:59:07 +00:00
|
|
|
icon.CopyFromBitmap( KiBitmap( BITMAPS::icon_pagelayout_editor_16 ) );
|
2020-12-22 19:41:32 +00:00
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
|
|
|
|
SetIcons( icon_bundle );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
// Create GAL canvas
|
2020-11-16 11:16:44 +00:00
|
|
|
auto* drawPanel = new PL_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
|
2020-11-29 10:49:02 +00:00
|
|
|
GetGalDisplayOptions(),
|
|
|
|
EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
|
2019-06-13 17:28:55 +00:00
|
|
|
SetCanvas( drawPanel );
|
2013-07-19 18:27:22 +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() );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2022-09-14 22:28:09 +00:00
|
|
|
m_acceptedExts.emplace( DrawingSheetFileExtension, nullptr );
|
|
|
|
DragAcceptFiles( true );
|
|
|
|
|
2022-09-16 23:25:07 +00:00
|
|
|
wxSize pageSizeIU = GetPageLayout().GetPageSettings().GetSizeIU( drawSheetIUScale.IU_PER_MILS );
|
2020-07-13 11:21:40 +00:00
|
|
|
SetScreen( new BASE_SCREEN( pageSizeIU ) );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
setupTools();
|
2020-07-29 23:50:25 +00:00
|
|
|
setupUIConditions();
|
2013-07-19 18:27:22 +00:00
|
|
|
ReCreateMenuBar();
|
|
|
|
ReCreateHToolbar();
|
2019-05-20 10:23:32 +00:00
|
|
|
ReCreateVToolbar();
|
2020-12-09 01:50:03 +00:00
|
|
|
ReCreateOptToolbar();
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
wxWindow* stsbar = GetStatusBar();
|
2021-10-30 19:19:08 +00:00
|
|
|
int spacer = KIUI::GetTextSize( wxT( "M" ), stsbar ).x * 2;
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
int dims[] = {
|
|
|
|
|
|
|
|
// balance of status bar on far left is set to a default or whatever is left over.
|
|
|
|
-1,
|
|
|
|
|
|
|
|
// When using GetTextSize() remember the width of '1' is not the same
|
|
|
|
// as the width of '0' unless the font is fixed width, and it usually won't be.
|
|
|
|
|
|
|
|
// zoom:
|
2021-10-30 19:19:08 +00:00
|
|
|
KIUI::GetTextSize( wxT( "Z 762000" ), stsbar ).x + spacer,
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// cursor coords
|
2021-10-30 19:19:08 +00:00
|
|
|
KIUI::GetTextSize( wxT( "X 0234.567 Y 0234.567" ), stsbar ).x + spacer,
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// delta distances
|
2021-10-30 19:19:08 +00:00
|
|
|
KIUI::GetTextSize( wxT( "dx 0234.567 dx 0234.567" ), stsbar ).x + spacer,
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2019-05-24 13:55:33 +00:00
|
|
|
// grid size
|
2021-10-30 19:19:08 +00:00
|
|
|
KIUI::GetTextSize( wxT( "grid 0234.567" ), stsbar ).x + spacer,
|
2019-05-24 13:55:33 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// Coord origin (use the bigger message)
|
2021-10-30 19:19:08 +00:00
|
|
|
KIUI::GetTextSize( _( "coord origin: Right Bottom page corner" ), stsbar ).x + spacer,
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// units display, Inches is bigger than mm
|
2021-10-30 19:19:08 +00:00
|
|
|
KIUI::GetTextSize( _( "Inches" ), stsbar ).x + spacer,
|
|
|
|
|
|
|
|
// constraint mode
|
|
|
|
KIUI::GetTextSize( _( "Constrain to H, V, 45" ), stsbar ).x + spacer
|
2013-07-19 18:27:22 +00:00
|
|
|
};
|
|
|
|
|
2019-01-06 16:43:12 +00:00
|
|
|
SetStatusWidths( arrayDim( dims ), dims );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
m_auimgr.SetManagedWindow( this );
|
|
|
|
|
2020-12-22 21:35:25 +00:00
|
|
|
CreateInfoBar();
|
2013-07-19 18:27:22 +00:00
|
|
|
m_propertiesPagelayout = new PROPERTIES_FRAME( this );
|
|
|
|
|
2020-12-11 12:09:37 +00:00
|
|
|
// Rows; layers 4 - 6
|
|
|
|
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" )
|
|
|
|
.Top().Layer( 6 ) );
|
|
|
|
m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" )
|
|
|
|
.Left().Layer( 3 ) );
|
|
|
|
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" )
|
|
|
|
.Bottom().Layer( 6 ) );
|
|
|
|
|
|
|
|
// Columns; layers 1 - 3
|
|
|
|
m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" )
|
|
|
|
.Right().Layer( 2 ) );
|
|
|
|
|
|
|
|
m_auimgr.AddPane( m_propertiesPagelayout, EDA_PANE().Palette().Name( "Props" )
|
|
|
|
.Right().Layer( 3 )
|
|
|
|
.Caption( _( "Properties" ) )
|
|
|
|
.MinSize( m_propertiesPagelayout->GetMinSize() )
|
2018-08-11 16:04:46 +00:00
|
|
|
.BestSize( m_propertiesFrameWidth, -1 ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-12-11 12:09:37 +00:00
|
|
|
// Center
|
|
|
|
m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" )
|
|
|
|
.Center() );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2020-12-22 21:35:25 +00:00
|
|
|
FinishAUIInitialization();
|
2014-06-07 16:20:23 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
resolveCanvasType();
|
2020-10-31 21:16:48 +00:00
|
|
|
SwitchCanvas( m_canvasType );
|
|
|
|
|
2019-08-02 08:35:26 +00:00
|
|
|
// Add the exit key handler
|
2020-10-05 19:26:33 +00:00
|
|
|
setupUnits( config() );
|
2019-08-02 08:35:26 +00:00
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I originCoord = ReturnCoordOriginCorner();
|
2019-06-07 10:42:28 +00:00
|
|
|
SetGridOrigin( originCoord );
|
|
|
|
|
2021-05-30 22:56:24 +00:00
|
|
|
// Initialize the current drawing sheet
|
2014-06-07 16:20:23 +00:00
|
|
|
#if 0 //start with empty layout
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_MODEL::GetTheInstance().AllowVoidList( true );
|
|
|
|
DS_DATA_MODEL::GetTheInstance().ClearList();
|
2021-06-08 19:39:47 +00:00
|
|
|
#else // start with the default KiCad layout
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet();
|
2014-06-07 16:20:23 +00:00
|
|
|
#endif
|
2021-05-30 22:56:24 +00:00
|
|
|
OnNewDrawingSheet();
|
2020-04-17 23:32:29 +00:00
|
|
|
|
|
|
|
// Ensure the window is on top
|
|
|
|
Raise();
|
2021-03-27 21:49:38 +00:00
|
|
|
|
|
|
|
// Register a call to update the toolbar sizes. It can't be done immediately because
|
|
|
|
// it seems to require some sizes calculated that aren't yet (at least on GTK).
|
|
|
|
CallAfter( [&]()
|
|
|
|
{
|
|
|
|
// Ensure the controls on the toolbars all are correctly sized
|
|
|
|
UpdateToolbarControlSizes();
|
|
|
|
} );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-23 16:54:48 +00:00
|
|
|
PL_EDITOR_FRAME::~PL_EDITOR_FRAME()
|
|
|
|
{
|
2021-06-19 08:11:49 +00:00
|
|
|
// Ensure m_canvasType is up to date, to save it in config
|
|
|
|
m_canvasType = GetCanvas()->GetBackend();
|
|
|
|
|
2020-02-03 14:00:48 +00:00
|
|
|
// Shutdown all running tools
|
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->ShutdownAllTools();
|
2019-11-23 16:54:48 +00:00
|
|
|
}
|
|
|
|
|
2020-10-18 20:30:37 +00:00
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
void PL_EDITOR_FRAME::setupTools()
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2019-05-20 10:23:32 +00:00
|
|
|
// Create the manager and dispatcher & route draw panel events to the dispatcher
|
|
|
|
m_toolManager = new TOOL_MANAGER;
|
2019-06-13 17:28:55 +00:00
|
|
|
m_toolManager->SetEnvironment( nullptr, GetCanvas()->GetView(),
|
2020-06-12 10:58:56 +00:00
|
|
|
GetCanvas()->GetViewControls(), config(), this );
|
2019-05-20 10:23:32 +00:00
|
|
|
m_actions = new PL_ACTIONS();
|
2021-03-27 20:02:34 +00:00
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->SetEventDispatcher( m_toolDispatcher );
|
2019-05-20 10:23:32 +00:00
|
|
|
|
|
|
|
// Register tools
|
2019-06-09 21:57:23 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_CONTROL );
|
2019-05-20 10:23:32 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
|
|
|
m_toolManager->RegisterTool( new ZOOM_TOOL );
|
|
|
|
m_toolManager->RegisterTool( new PL_SELECTION_TOOL );
|
2019-05-25 00:34:44 +00:00
|
|
|
m_toolManager->RegisterTool( new PL_EDITOR_CONTROL );
|
2019-05-20 10:23:32 +00:00
|
|
|
m_toolManager->RegisterTool( new PL_DRAWING_TOOLS );
|
|
|
|
m_toolManager->RegisterTool( new PL_EDIT_TOOL );
|
|
|
|
m_toolManager->RegisterTool( new PL_POINT_EDITOR );
|
2019-07-15 23:44:01 +00:00
|
|
|
m_toolManager->RegisterTool( new PICKER_TOOL );
|
2019-05-20 10:23:32 +00:00
|
|
|
m_toolManager->InitTools();
|
|
|
|
|
|
|
|
// Run the selection tool, it is supposed to be always active
|
|
|
|
m_toolManager->InvokeTool( "plEditor.InteractiveSelection" );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
void PL_EDITOR_FRAME::setupUIConditions()
|
|
|
|
{
|
2020-08-06 23:03:58 +00:00
|
|
|
EDA_DRAW_FRAME::setupUIConditions();
|
2020-07-29 23:50:25 +00:00
|
|
|
|
|
|
|
ACTION_MANAGER* mgr = m_toolManager->GetActionManager();
|
|
|
|
EDITOR_CONDITIONS cond( this );
|
|
|
|
|
|
|
|
wxASSERT( mgr );
|
|
|
|
|
2020-08-05 22:00:26 +00:00
|
|
|
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
|
|
|
|
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
|
2020-07-29 23:50:25 +00:00
|
|
|
|
2021-02-18 15:49:35 +00:00
|
|
|
mgr->SetConditions( ACTIONS::save, ENABLE( SELECTION_CONDITIONS::ShowAlways ) );
|
2020-08-05 22:00:26 +00:00
|
|
|
mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
|
2020-07-29 23:50:25 +00:00
|
|
|
|
2020-08-05 22:00:26 +00:00
|
|
|
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
|
2020-10-05 19:22:57 +00:00
|
|
|
mgr->SetConditions( ACTIONS::millimetersUnits, CHECK( cond.Units( EDA_UNITS::MILLIMETRES ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
|
2020-07-29 23:50:25 +00:00
|
|
|
|
2021-05-31 01:25:42 +00:00
|
|
|
mgr->SetConditions( ACTIONS::cut, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
|
|
|
|
mgr->SetConditions( ACTIONS::copy, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
|
|
|
|
mgr->SetConditions( ACTIONS::paste, ENABLE( SELECTION_CONDITIONS::Idle ) );
|
|
|
|
mgr->SetConditions( ACTIONS::doDelete, ENABLE( SELECTION_CONDITIONS::NotEmpty ) );
|
2020-07-29 23:50:25 +00:00
|
|
|
|
2021-06-08 19:39:47 +00:00
|
|
|
mgr->SetConditions( ACTIONS::zoomTool,
|
|
|
|
CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::selectionTool,
|
|
|
|
CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::deleteTool,
|
|
|
|
CHECK( cond.CurrentTool( ACTIONS::deleteTool ) ) );
|
|
|
|
|
|
|
|
mgr->SetConditions( PL_ACTIONS::drawLine,
|
|
|
|
CHECK( cond.CurrentTool( PL_ACTIONS::drawLine ) ) );
|
|
|
|
mgr->SetConditions( PL_ACTIONS::drawRectangle,
|
|
|
|
CHECK( cond.CurrentTool( PL_ACTIONS::drawRectangle ) ) );
|
|
|
|
mgr->SetConditions( PL_ACTIONS::placeText,
|
|
|
|
CHECK( cond.CurrentTool( PL_ACTIONS::placeText ) ) );
|
|
|
|
mgr->SetConditions( PL_ACTIONS::placeImage,
|
|
|
|
CHECK( cond.CurrentTool( PL_ACTIONS::placeImage ) ) );
|
2020-07-29 23:50:25 +00:00
|
|
|
|
|
|
|
// Not a tool, just a way to activate the action
|
2021-06-08 19:39:47 +00:00
|
|
|
mgr->SetConditions( PL_ACTIONS::appendImportedDrawingSheet,
|
|
|
|
CHECK( SELECTION_CONDITIONS::ShowNever ) );
|
2020-07-29 23:50:25 +00:00
|
|
|
|
|
|
|
auto titleBlockNormalMode =
|
|
|
|
[] ( const SELECTION& )
|
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
return DS_DATA_MODEL::GetTheInstance().m_EditMode == false;
|
2020-07-29 23:50:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto titleBlockEditMode =
|
|
|
|
[] ( const SELECTION& )
|
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
return DS_DATA_MODEL::GetTheInstance().m_EditMode == true;
|
2020-07-29 23:50:25 +00:00
|
|
|
};
|
|
|
|
|
2020-08-05 22:00:26 +00:00
|
|
|
mgr->SetConditions( PL_ACTIONS::layoutNormalMode, CHECK( titleBlockNormalMode ) );
|
|
|
|
mgr->SetConditions( PL_ACTIONS::layoutEditMode, CHECK( titleBlockEditMode ) );
|
2020-07-29 23:50:25 +00:00
|
|
|
|
2020-08-05 22:00:26 +00:00
|
|
|
#undef CHECK
|
|
|
|
#undef ENABLE
|
2020-07-29 23:50:25 +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
|
|
|
bool PL_EDITOR_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
|
|
|
|
{
|
|
|
|
wxString fn = aFileSet[0];
|
|
|
|
|
2021-05-30 22:56:24 +00:00
|
|
|
if( !LoadDrawingSheetFile( fn ) )
|
* 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
|
|
|
{
|
2021-06-26 11:33:37 +00:00
|
|
|
wxMessageBox( wxString::Format( _( "Error loading drawing sheet '%s'." ), fn ) );
|
* 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
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-05-30 22:56:24 +00:00
|
|
|
OnNewDrawingSheet();
|
* 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
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-07 16:34:46 +00:00
|
|
|
void PL_EDITOR_FRAME::OnModify()
|
|
|
|
{
|
|
|
|
// Must be called after a change in order to set the "modify" flag and update
|
|
|
|
// the frame title.
|
|
|
|
EDA_BASE_FRAME::OnModify();
|
|
|
|
|
|
|
|
GetScreen()->SetContentModified();
|
|
|
|
|
|
|
|
UpdateTitleAndInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-27 23:07:48 +00:00
|
|
|
bool PL_EDITOR_FRAME::IsContentModified() const
|
2019-12-19 15:34:01 +00:00
|
|
|
{
|
2021-05-28 19:07:04 +00:00
|
|
|
return GetScreen() && GetScreen()->IsContentModified();
|
2019-12-19 15:34:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-02 08:35:26 +00:00
|
|
|
void PL_EDITOR_FRAME::OnExit( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( aEvent.GetId() == wxID_EXIT )
|
|
|
|
Kiway().OnKiCadExit();
|
|
|
|
|
|
|
|
if( aEvent.GetId() == wxID_CLOSE || Kiface().IsSingle() )
|
|
|
|
Close( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
bool PL_EDITOR_FRAME::canCloseWindow( wxCloseEvent& aEvent )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2019-12-19 14:11:11 +00:00
|
|
|
// Shutdown blocks must be determined and vetoed as early as possible
|
2020-11-29 10:49:02 +00:00
|
|
|
if( KIPLATFORM::APP::SupportsShutdownBlockReason()
|
|
|
|
&& aEvent.GetId() == wxEVT_QUERY_END_SESSION
|
2019-12-19 15:34:01 +00:00
|
|
|
&& IsContentModified() )
|
2019-12-19 14:11:11 +00:00
|
|
|
{
|
2020-08-24 02:01:14 +00:00
|
|
|
return false;
|
2019-12-19 14:11:11 +00:00
|
|
|
}
|
|
|
|
|
2019-12-19 15:34:01 +00:00
|
|
|
if( IsContentModified() )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2020-05-16 23:08:01 +00:00
|
|
|
wxFileName filename = GetCurrentFileName();
|
2021-06-28 23:44:07 +00:00
|
|
|
wxString msg = _( "Save changes to '%s' before closing?" );
|
2019-06-17 15:59:39 +00:00
|
|
|
|
|
|
|
if( !HandleUnsavedChanges( this, wxString::Format( msg, filename.GetFullName() ),
|
2020-11-29 10:49:02 +00:00
|
|
|
[&]() -> bool
|
|
|
|
{
|
|
|
|
return saveCurrentPageLayout();
|
|
|
|
} ) )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2020-08-24 02:01:14 +00:00
|
|
|
return false;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PL_EDITOR_FRAME::doCloseWindow()
|
|
|
|
{
|
2013-07-19 18:27:22 +00:00
|
|
|
// do not show the window because we do not want any paint event
|
|
|
|
Show( false );
|
2013-08-19 07:08:13 +00:00
|
|
|
|
2020-07-16 22:54:12 +00:00
|
|
|
// clean up the data before the view is destroyed
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_MODEL::GetTheInstance().ClearList();
|
2020-07-16 22:54:12 +00:00
|
|
|
|
2013-08-19 07:08:13 +00:00
|
|
|
// On Linux, m_propertiesPagelayout must be destroyed
|
|
|
|
// before deleting the main frame to avoid a crash when closing
|
|
|
|
m_propertiesPagelayout->Destroy();
|
2013-07-19 18:27:22 +00:00
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
void PL_EDITOR_FRAME::OnSelectPage( wxCommandEvent& event )
|
2019-05-24 13:37:55 +00:00
|
|
|
{
|
2019-06-13 17:28:55 +00:00
|
|
|
KIGFX::VIEW* view = GetCanvas()->GetView();
|
2021-02-22 16:37:43 +00:00
|
|
|
view->SetLayerVisible( LAYER_DRAWINGSHEET_PAGE1, m_pageSelectBox->GetSelection() == 0 );
|
|
|
|
view->SetLayerVisible( LAYER_DRAWINGSHEET_PAGEn, m_pageSelectBox->GetSelection() == 1 );
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->Refresh();
|
2019-05-24 13:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PL_EDITOR_FRAME::OnSelectCoordOriginCorner( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
m_originSelectChoice = m_originSelectBox->GetSelection();
|
|
|
|
UpdateStatusBar(); // Update grid origin
|
2021-05-30 22:56:24 +00:00
|
|
|
GetCanvas()->DisplayDrawingSheet();
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->Refresh();
|
2019-05-24 13:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-25 00:34:44 +00:00
|
|
|
void PL_EDITOR_FRAME::ToPrinter( bool doPreview )
|
2019-05-24 13:37:55 +00:00
|
|
|
{
|
|
|
|
// static print data and page setup data, to remember settings during the session
|
|
|
|
static wxPrintData* s_PrintData;
|
2020-05-25 07:42:03 +00:00
|
|
|
static wxPageSetupDialogData* s_pageSetupData = nullptr;
|
2019-05-24 13:37:55 +00:00
|
|
|
|
|
|
|
const PAGE_INFO& pageInfo = GetPageSettings();
|
|
|
|
|
2021-06-08 19:39:47 +00:00
|
|
|
if( s_PrintData == nullptr ) // First print
|
2019-05-24 13:37:55 +00:00
|
|
|
{
|
|
|
|
s_PrintData = new wxPrintData();
|
|
|
|
s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !s_PrintData->Ok() )
|
|
|
|
{
|
|
|
|
wxMessageBox( _( "Error Init Printer info" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-08 19:39:47 +00:00
|
|
|
if( s_pageSetupData == nullptr )
|
2019-05-24 13:37:55 +00:00
|
|
|
s_pageSetupData = new wxPageSetupDialogData( *s_PrintData );
|
|
|
|
|
|
|
|
s_pageSetupData->SetPaperId( pageInfo.GetPaperId() );
|
|
|
|
s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
|
|
|
|
|
|
|
|
if( pageInfo.IsCustom() )
|
|
|
|
{
|
|
|
|
if( pageInfo.IsPortrait() )
|
2022-08-29 23:30:25 +00:00
|
|
|
s_pageSetupData->SetPaperSize( wxSize( EDA_UNIT_UTILS::Mils2mm( pageInfo.GetWidthMils() ),
|
|
|
|
EDA_UNIT_UTILS::Mils2mm( pageInfo.GetHeightMils() ) ) );
|
2019-05-24 13:37:55 +00:00
|
|
|
else
|
2022-08-29 23:30:25 +00:00
|
|
|
s_pageSetupData->SetPaperSize( wxSize( EDA_UNIT_UTILS::Mils2mm( pageInfo.GetHeightMils() ),
|
|
|
|
EDA_UNIT_UTILS::Mils2mm( pageInfo.GetWidthMils() ) ) );
|
2019-05-24 13:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*s_PrintData = s_pageSetupData->GetPrintData();
|
|
|
|
|
2019-05-25 00:34:44 +00:00
|
|
|
if( doPreview )
|
2019-05-24 13:37:55 +00:00
|
|
|
InvokeDialogPrintPreview( this, s_PrintData );
|
|
|
|
else
|
|
|
|
InvokeDialogPrint( this, s_PrintData, s_pageSetupData );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-25 07:31:56 +00:00
|
|
|
const BOX2I PL_EDITOR_FRAME::GetDocumentExtents( bool aIncludeAllVisible ) const
|
2019-05-20 10:23:32 +00:00
|
|
|
{
|
2022-09-16 23:25:07 +00:00
|
|
|
BOX2I rv( VECTOR2I( 0, 0 ), GetPageLayout().GetPageSettings().GetSizeIU( drawSheetIUScale.IU_PER_MILS ) );
|
2019-05-20 10:23:32 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void PL_EDITOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
2013-07-19 18:27:22 +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
|
|
|
EDA_DRAW_FRAME::LoadSettings( aCfg );
|
|
|
|
|
2020-06-13 21:09:02 +00:00
|
|
|
if( aCfg->m_Window.grid.sizes.empty() )
|
|
|
|
{
|
2021-10-30 19:31:48 +00:00
|
|
|
aCfg->m_Window.grid.sizes = { "5.00 mm",
|
|
|
|
"2.50 mm",
|
|
|
|
"2.00 mm",
|
|
|
|
"1.00 mm",
|
2020-06-13 21:09:02 +00:00
|
|
|
"0.50 mm",
|
|
|
|
"0.25 mm",
|
|
|
|
"0.20 mm",
|
|
|
|
"0.10 mm" };
|
|
|
|
}
|
2020-06-12 10:58:56 +00:00
|
|
|
|
2020-12-02 14:34:05 +00:00
|
|
|
// Currently values read from config file are not used because the user cannot
|
|
|
|
// change this config
|
|
|
|
// if( aCfg->m_Window.zoom_factors.empty() )
|
2020-06-12 10:58:56 +00:00
|
|
|
{
|
2020-12-02 14:34:05 +00:00
|
|
|
aCfg->m_Window.zoom_factors = { ZOOM_LIST_PL_EDITOR };
|
2020-06-12 10:58:56 +00:00
|
|
|
}
|
2019-07-10 22:15:57 +00:00
|
|
|
|
2020-06-13 21:09:02 +00:00
|
|
|
PL_EDITOR_SETTINGS* cfg = dynamic_cast<PL_EDITOR_SETTINGS*>( aCfg );
|
|
|
|
wxCHECK( cfg, /*void*/ );
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_propertiesFrameWidth = cfg->m_PropertiesFrameWidth;
|
|
|
|
m_originSelectChoice = cfg->m_CornerOrigin;
|
2019-07-10 22:15:57 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
SetDrawBgColor( cfg->m_BlackBackground ? BLACK : WHITE );
|
|
|
|
|
|
|
|
PAGE_INFO::SetCustomWidthMils( cfg->m_LastCustomWidth );
|
|
|
|
PAGE_INFO::SetCustomHeightMils( cfg->m_LastCustomHeight );
|
2019-07-10 22:15:57 +00:00
|
|
|
|
|
|
|
PAGE_INFO pageInfo = GetPageSettings();
|
2020-01-13 01:44:19 +00:00
|
|
|
pageInfo.SetType( cfg->m_LastPaperSize, cfg->m_LastWasPortrait );
|
2019-07-10 22:15:57 +00:00
|
|
|
SetPageSettings( pageInfo );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void PL_EDITOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
2013-07-19 18:27:22 +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
|
|
|
EDA_DRAW_FRAME::SaveSettings( aCfg );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
auto cfg = static_cast<PL_EDITOR_SETTINGS*>( aCfg );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_propertiesFrameWidth = m_propertiesPagelayout->GetSize().x;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
cfg->m_PropertiesFrameWidth = m_propertiesFrameWidth;
|
|
|
|
cfg->m_CornerOrigin = m_originSelectChoice;
|
|
|
|
cfg->m_BlackBackground = GetDrawBgColor() == BLACK;
|
|
|
|
cfg->m_LastPaperSize = GetPageSettings().GetType();
|
|
|
|
cfg->m_LastWasPortrait = GetPageSettings().IsPortrait();
|
|
|
|
cfg->m_LastCustomWidth = PAGE_INFO::GetCustomWidthMils();
|
|
|
|
cfg->m_LastCustomHeight = PAGE_INFO::GetCustomHeightMils();
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PL_EDITOR_FRAME::UpdateTitleAndInfo()
|
|
|
|
{
|
|
|
|
wxString title;
|
2020-09-03 13:36:03 +00:00
|
|
|
wxFileName file( GetCurrentFileName() );
|
2016-09-26 17:15:33 +00:00
|
|
|
|
2023-02-07 16:34:46 +00:00
|
|
|
if( IsContentModified() )
|
|
|
|
title = wxT( "*" );
|
|
|
|
|
2021-06-20 21:46:41 +00:00
|
|
|
if( file.IsOk() )
|
2023-02-07 16:34:46 +00:00
|
|
|
title += file.GetName();
|
2021-06-20 21:46:41 +00:00
|
|
|
else
|
2023-02-07 16:34:46 +00:00
|
|
|
title += _( "[no drawing sheet loaded]" );
|
2021-06-20 21:46:41 +00:00
|
|
|
|
|
|
|
title += wxT( " \u2014 " ) + _( "Drawing Sheet Editor" ),
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
SetTitle( title );
|
|
|
|
}
|
|
|
|
|
2017-11-12 00:31:38 +00:00
|
|
|
|
2020-05-16 23:08:01 +00:00
|
|
|
wxString PL_EDITOR_FRAME::GetCurrentFileName() const
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2021-05-30 22:56:24 +00:00
|
|
|
return BASE_SCREEN::m_DrawingSheetFileName;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 00:31:38 +00:00
|
|
|
|
2020-05-16 23:08:01 +00:00
|
|
|
void PL_EDITOR_FRAME::SetCurrentFileName( const wxString& aName )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2021-05-30 22:56:24 +00:00
|
|
|
BASE_SCREEN::m_DrawingSheetFileName = aName;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 00:31:38 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
void PL_EDITOR_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
|
|
|
|
{
|
|
|
|
m_pageLayout.SetPageSettings( aPageSettings );
|
|
|
|
|
|
|
|
if( GetScreen() )
|
2022-09-16 23:25:07 +00:00
|
|
|
GetScreen()->InitDataPoints( aPageSettings.GetSizeIU( drawSheetIUScale.IU_PER_MILS ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const PAGE_INFO& PL_EDITOR_FRAME::GetPageSettings() const
|
|
|
|
{
|
|
|
|
return m_pageLayout.GetPageSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const wxSize PL_EDITOR_FRAME::GetPageSizeIU() const
|
|
|
|
{
|
|
|
|
// this function is only needed because EDA_DRAW_FRAME is not compiled
|
|
|
|
// with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
|
|
|
|
// into an application specific source file.
|
2022-09-16 23:25:07 +00:00
|
|
|
return m_pageLayout.GetPageSettings().GetSizeIU( drawSheetIUScale.IU_PER_MILS );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const TITLE_BLOCK& PL_EDITOR_FRAME::GetTitleBlock() const
|
|
|
|
{
|
|
|
|
return GetPageLayout().GetTitleBlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PL_EDITOR_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
|
|
|
|
{
|
|
|
|
m_pageLayout.SetTitleBlock( aTitleBlock );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-02 17:42:35 +00:00
|
|
|
void PL_EDITOR_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
|
|
|
|
|
|
|
SETTINGS_MANAGER& settingsManager = Pgm().GetSettingsManager();
|
|
|
|
PL_EDITOR_SETTINGS* cfg = settingsManager.GetAppSettings<PL_EDITOR_SETTINGS>();
|
|
|
|
COLOR_SETTINGS* colors = settingsManager.GetColorSettings( cfg->m_ColorTheme );
|
|
|
|
|
2022-12-29 16:33:41 +00:00
|
|
|
// Update gal display options like cursor shape, grid options:
|
|
|
|
GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
|
|
|
|
|
2020-08-02 17:42:35 +00:00
|
|
|
GetCanvas()->GetView()->GetPainter()->GetSettings()->LoadColors( colors );
|
|
|
|
|
|
|
|
GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
|
2021-08-29 23:33:08 +00:00
|
|
|
GetCanvas()->ForceRefresh();
|
2020-10-01 18:50:09 +00:00
|
|
|
|
|
|
|
RecreateToolbars();
|
|
|
|
Layout();
|
|
|
|
SendSizeEvent();
|
2020-08-02 17:42:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I PL_EDITOR_FRAME::ReturnCoordOriginCorner() const
|
2019-06-07 10:42:28 +00:00
|
|
|
{
|
|
|
|
// calculate the position (in page, in iu) of the corner used as coordinate origin
|
|
|
|
// coordinate origin can be the paper Top Left corner, or each of 4 page corners
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I originCoord;
|
2019-06-07 10:42:28 +00:00
|
|
|
|
|
|
|
// To avoid duplicate code, we use a dummy segment starting at 0,0 in relative coord
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_ITEM dummy( DS_DATA_ITEM::DS_SEGMENT );
|
2019-06-07 10:42:28 +00:00
|
|
|
|
|
|
|
switch( m_originSelectChoice )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 0: // Origin = paper Left Top corner
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // Origin = page Right Bottom corner
|
|
|
|
dummy.SetStart( 0, 0, RB_CORNER );
|
|
|
|
originCoord = dummy.GetStartPosUi();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // Origin = page Left Bottom corner
|
|
|
|
dummy.SetStart( 0, 0, LB_CORNER );
|
|
|
|
originCoord = dummy.GetStartPosUi();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: // Origin = page Right Top corner
|
|
|
|
dummy.SetStart( 0, 0, RT_CORNER );
|
|
|
|
originCoord = dummy.GetStartPosUi();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: // Origin = page Left Top corner
|
|
|
|
dummy.SetStart( 0, 0, LT_CORNER );
|
|
|
|
originCoord = dummy.GetStartPosUi();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return originCoord;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-24 13:55:33 +00:00
|
|
|
void PL_EDITOR_FRAME::DisplayGridMsg()
|
|
|
|
{
|
|
|
|
wxString line;
|
|
|
|
wxString gridformatter;
|
|
|
|
|
2022-09-26 16:54:42 +00:00
|
|
|
switch( GetUserUnits() )
|
2019-05-24 13:55:33 +00:00
|
|
|
{
|
2023-01-17 00:07:41 +00:00
|
|
|
case EDA_UNITS::INCHES: gridformatter = wxS( "grid %.3f" ); break;
|
|
|
|
case EDA_UNITS::MILLIMETRES: gridformatter = wxS( "grid %.4f" ); break;
|
|
|
|
default: gridformatter = wxS( "grid %f" ); break;
|
2019-05-24 13:55:33 +00:00
|
|
|
}
|
|
|
|
|
2022-09-26 16:54:42 +00:00
|
|
|
double grid = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, GetUserUnits(),
|
2022-09-16 04:38:10 +00:00
|
|
|
GetCanvas()->GetGAL()->GetGridSize().x );
|
2019-05-24 13:55:33 +00:00
|
|
|
line.Printf( gridformatter, grid );
|
|
|
|
|
|
|
|
SetStatusText( line, 4 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
void PL_EDITOR_FRAME::UpdateStatusBar()
|
|
|
|
{
|
2015-01-06 07:38:58 +00:00
|
|
|
// Display Zoom level:
|
2020-12-09 00:47:14 +00:00
|
|
|
SetStatusText( GetZoomLevelIndicator(), 1 );
|
2015-01-06 07:38:58 +00:00
|
|
|
|
2019-05-25 13:56:52 +00:00
|
|
|
// coordinate origin can be the paper Top Left corner, or each of 4 page corners
|
2022-01-01 06:04:08 +00:00
|
|
|
VECTOR2I originCoord = ReturnCoordOriginCorner();
|
2019-06-07 10:42:28 +00:00
|
|
|
SetGridOrigin( originCoord );
|
|
|
|
|
|
|
|
// We need the orientation of axis (sign of coordinates)
|
2013-07-19 18:27:22 +00:00
|
|
|
int Xsign = 1;
|
|
|
|
int Ysign = 1;
|
2013-08-03 05:15:23 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
switch( m_originSelectChoice )
|
|
|
|
{
|
2013-08-03 05:15:23 +00:00
|
|
|
default:
|
|
|
|
case 0: // Origin = paper Left Top corner
|
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case 1: // Origin = page Right Bottom corner
|
|
|
|
Xsign = -1;
|
|
|
|
Ysign = -1;
|
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case 2: // Origin = page Left Bottom corner
|
|
|
|
Ysign = -1;
|
2019-06-07 10:42:28 +00:00
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case 3: // Origin = page Right Top corner
|
|
|
|
Xsign = -1;
|
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2013-08-03 05:15:23 +00:00
|
|
|
case 4: // Origin = page Left Top corner
|
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Display absolute coordinates:
|
2019-06-13 17:28:55 +00:00
|
|
|
VECTOR2D cursorPos = GetCanvas()->GetViewControls()->GetCursorPosition();
|
2019-06-13 13:34:38 +00:00
|
|
|
VECTOR2D coord = cursorPos - originCoord;
|
2022-09-16 04:38:10 +00:00
|
|
|
double dXpos =
|
|
|
|
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, GetUserUnits(), coord.x * Xsign );
|
|
|
|
double dYpos =
|
|
|
|
EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, GetUserUnits(), coord.y * Ysign );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2013-07-26 12:50:29 +00:00
|
|
|
wxString absformatter = wxT( "X %.4g Y %.4g" );
|
|
|
|
wxString locformatter = wxT( "dx %.4g dy %.4g" );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2018-06-14 08:26:11 +00:00
|
|
|
switch( GetUserUnits() )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2020-07-13 11:21:40 +00:00
|
|
|
case EDA_UNITS::INCHES: SetStatusText( _( "inches" ), 6 ); break;
|
2020-10-04 15:29:18 +00:00
|
|
|
case EDA_UNITS::MILS: SetStatusText( _( "mils" ), 6 ); break;
|
2020-07-13 11:21:40 +00:00
|
|
|
case EDA_UNITS::MILLIMETRES: SetStatusText( _( "mm" ), 6 ); break;
|
|
|
|
case EDA_UNITS::UNSCALED: SetStatusText( wxEmptyString, 6 ); break;
|
|
|
|
default: wxASSERT( false ); break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString line;
|
2013-07-24 15:11:35 +00:00
|
|
|
|
|
|
|
// Display abs coordinates
|
2013-07-19 18:27:22 +00:00
|
|
|
line.Printf( absformatter, dXpos, dYpos );
|
|
|
|
SetStatusText( line, 2 );
|
|
|
|
|
|
|
|
// Display relative coordinates:
|
2020-07-13 11:21:40 +00:00
|
|
|
if( GetScreen() )
|
|
|
|
{
|
|
|
|
double dx = cursorPos.x - GetScreen()->m_LocalOrigin.x;
|
|
|
|
double dy = cursorPos.y - GetScreen()->m_LocalOrigin.y;
|
2022-09-16 04:38:10 +00:00
|
|
|
dXpos = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, GetUserUnits(), dx * Xsign );
|
|
|
|
dYpos = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, GetUserUnits(), dy * Ysign );
|
2020-07-13 11:21:40 +00:00
|
|
|
line.Printf( locformatter, dXpos, dYpos );
|
|
|
|
SetStatusText( line, 3 );
|
|
|
|
}
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2019-05-24 13:55:33 +00:00
|
|
|
DisplayGridMsg();
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// Display corner reference for coord origin
|
|
|
|
line.Printf( _("coord origin: %s"),
|
2020-11-29 10:49:02 +00:00
|
|
|
m_originSelectBox->GetString( m_originSelectChoice ).GetData() );
|
2019-05-24 13:55:33 +00:00
|
|
|
SetStatusText( line, 5 );
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 00:31:38 +00:00
|
|
|
|
2020-12-20 18:18:54 +00:00
|
|
|
void PL_EDITOR_FRAME::PrintPage( const RENDER_SETTINGS* aSettings )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2020-10-18 20:30:37 +00:00
|
|
|
GetScreen()->SetVirtualPageNumber( GetPageNumberOption() ? 1 : 2 );
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance();
|
2020-05-25 07:42:03 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
for( DS_DATA_ITEM* dataItem : model.GetItems() )
|
2020-05-25 07:42:03 +00:00
|
|
|
{
|
|
|
|
// Ensure the scaling factor (used only in printing) of bitmaps is up to date
|
2021-02-22 23:47:17 +00:00
|
|
|
if( dataItem->GetType() == DS_DATA_ITEM::DS_BITMAP )
|
2020-11-29 10:49:02 +00:00
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
BITMAP_BASE* bitmap = static_cast<DS_DATA_ITEM_BITMAP*>( dataItem )->m_ImageBitmap;
|
2022-09-16 23:25:07 +00:00
|
|
|
bitmap->SetPixelSizeIu( drawSheetIUScale.IU_PER_MILS * 1000 / bitmap->GetPPI() );
|
2020-11-29 10:49:02 +00:00
|
|
|
}
|
2020-05-25 07:42:03 +00:00
|
|
|
}
|
|
|
|
|
2022-09-20 14:25:03 +00:00
|
|
|
PrintDrawingSheet( aSettings, GetScreen(), nullptr, drawSheetIUScale.IU_PER_MILS,
|
|
|
|
wxEmptyString );
|
2020-05-25 07:42:03 +00:00
|
|
|
|
2021-05-30 22:56:24 +00:00
|
|
|
GetCanvas()->DisplayDrawingSheet();
|
2020-05-25 07:42:03 +00:00
|
|
|
GetCanvas()->Refresh();
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 00:31:38 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
PL_DRAW_PANEL_GAL* PL_EDITOR_FRAME::GetCanvas() const
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2019-06-13 17:28:55 +00:00
|
|
|
return static_cast<PL_DRAW_PANEL_GAL*>( EDA_DRAW_FRAME::GetCanvas() );
|
|
|
|
}
|
|
|
|
|
2019-05-24 10:11:18 +00:00
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
SELECTION& PL_EDITOR_FRAME::GetCurrentSelection()
|
|
|
|
{
|
|
|
|
return m_toolManager->GetTool<PL_SELECTION_TOOL>()->GetSelection();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
void PL_EDITOR_FRAME::HardRedraw()
|
|
|
|
{
|
2021-05-30 22:56:24 +00:00
|
|
|
GetCanvas()->DisplayDrawingSheet();
|
2019-05-24 10:11:18 +00:00
|
|
|
|
|
|
|
PL_SELECTION_TOOL* selTool = m_toolManager->GetTool<PL_SELECTION_TOOL>();
|
2019-06-09 21:57:23 +00:00
|
|
|
PL_SELECTION& selection = selTool->GetSelection();
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_ITEM* item = nullptr;
|
2019-05-24 10:11:18 +00:00
|
|
|
|
|
|
|
if( selection.GetSize() == 1 )
|
2021-02-22 23:47:17 +00:00
|
|
|
item = static_cast<DS_DRAW_ITEM_BASE*>( selection.Front() )->GetPeer();
|
2019-05-24 10:11:18 +00:00
|
|
|
|
|
|
|
m_propertiesPagelayout->CopyPrmsFromItemToPanel( item );
|
2019-05-20 10:23:32 +00:00
|
|
|
m_propertiesPagelayout->CopyPrmsFromGeneralToPanel();
|
2022-03-02 09:01:54 +00:00
|
|
|
UpdateMsgPanelInfo();
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->Refresh();
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 00:31:38 +00:00
|
|
|
|
2021-05-30 22:56:24 +00:00
|
|
|
DS_DATA_ITEM* PL_EDITOR_FRAME::AddDrawingSheetItem( int aType )
|
2013-07-19 18:27:22 +00:00
|
|
|
{
|
2021-06-08 19:39:47 +00:00
|
|
|
DS_DATA_ITEM * item = nullptr;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
switch( aType )
|
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
case DS_DATA_ITEM::DS_TEXT:
|
|
|
|
item = new DS_DATA_ITEM_TEXT( wxT( "Text") );
|
2017-11-12 00:31:38 +00:00
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
case DS_DATA_ITEM::DS_SEGMENT:
|
|
|
|
item = new DS_DATA_ITEM( DS_DATA_ITEM::DS_SEGMENT );
|
2017-11-12 00:31:38 +00:00
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
case DS_DATA_ITEM::DS_RECT:
|
|
|
|
item = new DS_DATA_ITEM( DS_DATA_ITEM::DS_RECT );
|
2017-11-12 00:31:38 +00:00
|
|
|
break;
|
2013-10-18 17:38:03 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
case DS_DATA_ITEM::DS_POLYPOLYGON:
|
|
|
|
item = new DS_DATA_ITEM_POLYGONS();
|
2017-11-12 00:31:38 +00:00
|
|
|
break;
|
2013-10-18 17:38:03 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
case DS_DATA_ITEM::DS_BITMAP:
|
2017-11-12 00:31:38 +00:00
|
|
|
{
|
2022-02-25 21:18:43 +00:00
|
|
|
wxFileDialog fileDlg( this, _( "Choose Image" ), m_mruImagePath, wxEmptyString,
|
2020-11-29 10:49:02 +00:00
|
|
|
_( "Image Files" ) + wxS( " " ) + wxImage::GetImageExtWildcard(),
|
|
|
|
wxFD_OPEN );
|
2013-10-18 17:38:03 +00:00
|
|
|
|
2017-11-12 00:31:38 +00:00
|
|
|
if( fileDlg.ShowModal() != wxID_OK )
|
2021-06-08 19:39:47 +00:00
|
|
|
return nullptr;
|
2013-10-18 17:38:03 +00:00
|
|
|
|
2017-11-12 00:31:38 +00:00
|
|
|
wxString fullFilename = fileDlg.GetPath();
|
2022-02-25 21:18:43 +00:00
|
|
|
m_mruImagePath = wxPathOnly( fullFilename );
|
2013-10-18 17:38:03 +00:00
|
|
|
|
2017-11-12 00:31:38 +00:00
|
|
|
if( !wxFileExists( fullFilename ) )
|
|
|
|
{
|
2021-06-28 23:44:07 +00:00
|
|
|
wxMessageBox( _( "Could not load image from '%s'." ), fullFilename );
|
2017-11-12 00:31:38 +00:00
|
|
|
break;
|
2013-10-18 17:38:03 +00:00
|
|
|
}
|
2017-11-12 00:31:38 +00:00
|
|
|
|
|
|
|
BITMAP_BASE* image = new BITMAP_BASE();
|
|
|
|
|
|
|
|
if( !image->ReadImageFile( fullFilename ) )
|
|
|
|
{
|
2021-06-28 23:44:07 +00:00
|
|
|
wxMessageBox( _( "Could not load image from '%s'." ), fullFilename );
|
2017-11-12 00:31:38 +00:00
|
|
|
delete image;
|
2013-10-18 17:38:03 +00:00
|
|
|
break;
|
2017-11-12 00:31:38 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 19:39:47 +00:00
|
|
|
// Set the scale factor for pl_editor (it is set for Eeschema by default)
|
2022-09-16 23:25:07 +00:00
|
|
|
image->SetPixelSizeIu( drawSheetIUScale.IU_PER_MILS * 1000.0 / image->GetPPI() );
|
2021-02-22 23:47:17 +00:00
|
|
|
item = new DS_DATA_ITEM_BITMAP( image );
|
2017-11-12 00:31:38 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-07-19 18:27:22 +00:00
|
|
|
}
|
|
|
|
|
2021-06-08 19:39:47 +00:00
|
|
|
if( item == nullptr )
|
|
|
|
return nullptr;
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
DS_DATA_MODEL::GetTheInstance().Append( item );
|
2019-06-13 17:28:55 +00:00
|
|
|
item->SyncDrawItems( nullptr, GetCanvas()->GetView() );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
2013-07-20 19:36:19 +00:00
|
|
|
|
2017-11-12 00:31:38 +00:00
|
|
|
|
2021-05-30 22:56:24 +00:00
|
|
|
void PL_EDITOR_FRAME::OnNewDrawingSheet()
|
2013-07-20 19:36:19 +00:00
|
|
|
{
|
2020-07-13 11:21:40 +00:00
|
|
|
ClearUndoRedoList();
|
2021-05-28 19:07:04 +00:00
|
|
|
GetScreen()->SetContentModified( false );
|
2021-05-30 22:56:24 +00:00
|
|
|
GetCanvas()->DisplayDrawingSheet();
|
2019-05-20 10:23:32 +00:00
|
|
|
|
2019-05-24 12:24:43 +00:00
|
|
|
m_propertiesPagelayout->CopyPrmsFromItemToPanel( nullptr );
|
2013-07-20 19:36:19 +00:00
|
|
|
m_propertiesPagelayout->CopyPrmsFromGeneralToPanel();
|
2019-05-24 19:57:50 +00:00
|
|
|
|
|
|
|
UpdateTitleAndInfo();
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
2019-12-19 14:11:11 +00:00
|
|
|
|
2020-05-16 23:08:01 +00:00
|
|
|
if( GetCurrentFileName().IsEmpty() )
|
2019-12-19 14:11:11 +00:00
|
|
|
{
|
|
|
|
// Default shutdown reason until a file is loaded
|
2021-05-30 22:56:24 +00:00
|
|
|
KIPLATFORM::APP::SetShutdownBlockReason( this, _( "New drawing sheet file is unsaved" ) );
|
2019-12-19 14:11:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-05-30 22:56:24 +00:00
|
|
|
KIPLATFORM::APP::SetShutdownBlockReason( this, _( "Drawing sheet changes are unsaved" ) );
|
2019-12-19 14:11:11 +00:00
|
|
|
}
|
2013-07-20 19:36:19 +00:00
|
|
|
}
|
2015-01-06 07:38:58 +00:00
|
|
|
|
|
|
|
|
2020-07-13 13:50:35 +00:00
|
|
|
void PL_EDITOR_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount )
|
2020-07-13 11:21:40 +00:00
|
|
|
{
|
|
|
|
if( aItemCount == 0 )
|
|
|
|
return;
|
|
|
|
|
2020-07-13 13:50:35 +00:00
|
|
|
UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
|
|
|
|
unsigned icnt = list.m_CommandsList.size();
|
2020-07-13 11:21:40 +00:00
|
|
|
|
|
|
|
if( aItemCount > 0 )
|
|
|
|
icnt = aItemCount;
|
|
|
|
|
|
|
|
for( unsigned ii = 0; ii < icnt; ii++ )
|
|
|
|
{
|
2020-07-13 13:50:35 +00:00
|
|
|
if( list.m_CommandsList.size() == 0 )
|
2020-07-13 11:21:40 +00:00
|
|
|
break;
|
|
|
|
|
2020-07-13 13:50:35 +00:00
|
|
|
PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
|
|
|
|
list.m_CommandsList.erase( list.m_CommandsList.begin() );
|
2020-07-13 11:21:40 +00:00
|
|
|
|
2022-11-15 23:51:42 +00:00
|
|
|
curr_cmd->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
|
|
|
|
{
|
|
|
|
delete aItem;
|
|
|
|
} );
|
2020-07-13 11:21:40 +00:00
|
|
|
delete curr_cmd; // Delete command
|
|
|
|
}
|
|
|
|
}
|
2021-06-03 11:49:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool PL_EDITOR_FRAME::GetPageNumberOption() const
|
|
|
|
{
|
|
|
|
return m_pageSelectBox->GetSelection() == 0;
|
2021-06-03 15:41:26 +00:00
|
|
|
}
|
2022-03-02 09:01:54 +00:00
|
|
|
|
|
|
|
#if 1
|
|
|
|
void PL_EDITOR_FRAME::UpdateMsgPanelInfo()
|
|
|
|
{
|
2022-09-16 23:25:07 +00:00
|
|
|
VECTOR2D size = GetPageSettings().GetSizeIU( drawSheetIUScale.IU_PER_MILS );
|
2022-03-02 09:01:54 +00:00
|
|
|
|
|
|
|
std::vector<MSG_PANEL_ITEM> msgItems;
|
2022-09-19 09:25:20 +00:00
|
|
|
msgItems.emplace_back( _( "Page Width" ), MessageTextFromValue( size.x ) );
|
|
|
|
msgItems.emplace_back( _( "Page Height" ), MessageTextFromValue( size.y ) );
|
2022-03-02 09:01:54 +00:00
|
|
|
|
|
|
|
SetMsgPanel( msgItems );
|
|
|
|
}
|
|
|
|
#endif
|