2011-12-12 14:02:37 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-03-19 09:39:11 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2023-06-12 21:33:55 +00:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-12-12 14:02:37 +00:00
|
|
|
*
|
2018-01-08 04:05:03 +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 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
2011-12-12 14:02:37 +00:00
|
|
|
*
|
2018-01-08 04:05:03 +00:00
|
|
|
* 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.
|
2011-12-12 14:02:37 +00:00
|
|
|
*
|
2018-01-08 04:05:03 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-12-12 14:02:37 +00:00
|
|
|
*/
|
|
|
|
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2022-08-27 17:23:43 +00:00
|
|
|
#include <base_units.h>
|
2015-09-25 19:41:14 +00:00
|
|
|
#include <pgm_base.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2017-08-19 16:28:11 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2014-06-27 17:07:42 +00:00
|
|
|
#include <gerbview_frame.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview_id.h>
|
2018-01-29 12:26:58 +00:00
|
|
|
#include <gerber_file_image.h>
|
|
|
|
#include <gerber_file_image_list.h>
|
2021-08-04 20:22:07 +00:00
|
|
|
#include <excellon_image.h>
|
2017-09-17 22:43:20 +00:00
|
|
|
#include <gerbview_draw_panel_gal.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <gerbview_settings.h>
|
2021-02-22 23:47:17 +00:00
|
|
|
#include <drawing_sheet/ds_proxy_view_item.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2017-09-17 22:43:20 +00:00
|
|
|
#include <tool/tool_manager.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/action_toolbar.h>
|
2017-09-17 22:43:20 +00:00
|
|
|
#include <tool/tool_dispatcher.h>
|
2019-06-09 21:57:23 +00:00
|
|
|
#include <tool/common_control.h>
|
2019-05-04 11:23:04 +00:00
|
|
|
#include <tool/common_tools.h>
|
2020-07-29 23:50:25 +00:00
|
|
|
#include <tool/editor_conditions.h>
|
2019-05-04 11:23:04 +00:00
|
|
|
#include <tool/zoom_tool.h>
|
2017-09-17 22:43:20 +00:00
|
|
|
#include <tools/gerbview_actions.h>
|
2020-10-08 22:59:16 +00:00
|
|
|
#include <tools/gerbview_inspection_tool.h>
|
2020-07-29 23:50:25 +00:00
|
|
|
#include <tools/gerbview_selection.h>
|
2019-05-04 11:23:04 +00:00
|
|
|
#include <tools/gerbview_selection_tool.h>
|
|
|
|
#include <tools/gerbview_control.h>
|
2020-10-14 03:37:48 +00:00
|
|
|
#include <trigo.h>
|
2017-09-17 22:43:20 +00:00
|
|
|
#include <view/view.h>
|
2020-06-13 21:09:02 +00:00
|
|
|
#include <base_screen.h>
|
2017-09-17 22:43:20 +00:00
|
|
|
#include <gerbview_painter.h>
|
2020-05-02 20:09:43 +00:00
|
|
|
#include <wx/wupdlock.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2020-11-16 12:13:08 +00:00
|
|
|
#include "widgets/gbr_layer_box_selector.h"
|
|
|
|
#include "widgets/gerbview_layer_widget.h"
|
|
|
|
#include "widgets/dcode_selection_box.h"
|
2023-09-06 16:54:54 +00:00
|
|
|
#include <dialog_draw_layers_settings.h>
|
2020-12-01 19:27:42 +00:00
|
|
|
#include <zoom_defines.h>
|
2020-11-16 12:13:08 +00:00
|
|
|
|
2020-10-18 20:30:37 +00:00
|
|
|
|
2020-02-25 15:46:56 +00:00
|
|
|
GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent )
|
|
|
|
: EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition,
|
2022-09-16 04:38:10 +00:00
|
|
|
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME,
|
|
|
|
gerbIUScale ),
|
2021-01-26 15:23:37 +00:00
|
|
|
m_TextInfo( nullptr ),
|
2020-02-25 15:46:56 +00:00
|
|
|
m_zipFileHistory( DEFAULT_FILE_HISTORY_SIZE, ID_GERBVIEW_ZIP_FILE1,
|
2021-07-16 20:13:26 +00:00
|
|
|
ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, _( "Clear Recent Zip Files" ) ),
|
2020-02-25 15:46:56 +00:00
|
|
|
m_drillFileHistory( DEFAULT_FILE_HISTORY_SIZE, ID_GERBVIEW_DRILL_FILE1,
|
2021-07-16 20:13:26 +00:00
|
|
|
ID_GERBVIEW_DRILL_FILE_LIST_CLEAR, _( "Clear Recent Drill Files" ) ),
|
2020-02-25 15:46:56 +00:00
|
|
|
m_jobFileHistory( DEFAULT_FILE_HISTORY_SIZE, ID_GERBVIEW_JOB_FILE1,
|
2021-07-16 20:13:26 +00:00
|
|
|
ID_GERBVIEW_JOB_FILE_LIST_CLEAR, _( "Clear Recent Job Files" ) ),
|
2021-01-26 15:23:37 +00:00
|
|
|
m_activeLayer( 0 )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-10-18 18:38:40 +00:00
|
|
|
m_maximizeByDefault = true;
|
2020-06-27 18:06:17 +00:00
|
|
|
m_gerberLayout = nullptr;
|
2010-02-03 14:05:17 +00:00
|
|
|
m_show_layer_manager_tools = true;
|
2015-05-19 16:39:05 +00:00
|
|
|
m_showBorderAndTitleBlock = false; // true for reference drawings.
|
2020-06-27 18:06:17 +00:00
|
|
|
m_SelLayerBox = nullptr;
|
|
|
|
m_DCodeSelector = nullptr;
|
2018-01-29 01:30:43 +00:00
|
|
|
m_SelComponentBox = nullptr;
|
|
|
|
m_SelNetnameBox = nullptr;
|
|
|
|
m_SelAperAttributesBox = nullptr;
|
2020-06-27 18:06:17 +00:00
|
|
|
m_cmpText = nullptr;
|
|
|
|
m_netText = nullptr;
|
|
|
|
m_apertText = nullptr;
|
|
|
|
m_dcodeText = nullptr;
|
2020-06-13 21:09:02 +00:00
|
|
|
m_displayMode = 0;
|
2022-12-31 23:39:04 +00:00
|
|
|
m_aboutTitle = _HKI( "KiCad Gerber Viewer" );
|
2018-08-20 13:46:38 +00:00
|
|
|
|
2019-06-16 18:35:32 +00:00
|
|
|
SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
|
|
|
|
// some methods in code and avoid link errors
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
int fileHistorySize = Pgm().GetCommonSettings()->m_System.file_history_size;
|
2018-08-20 13:46:38 +00:00
|
|
|
m_drillFileHistory.SetMaxFiles( fileHistorySize );
|
|
|
|
m_zipFileHistory.SetMaxFiles( fileHistorySize );
|
|
|
|
m_jobFileHistory.SetMaxFiles( fileHistorySize );
|
2010-07-27 12:47:08 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
auto* galCanvas = new GERBVIEW_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_frameSize,
|
2019-06-02 18:58:09 +00:00
|
|
|
GetGalDisplayOptions(),
|
|
|
|
EDA_DRAW_PANEL_GAL::GAL_TYPE_NONE );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
SetCanvas( galCanvas );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
|
|
|
// GerbView requires draw priority for rendering negative objects
|
|
|
|
galCanvas->GetView()->UseDrawPriority( true );
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
// Give an icon
|
2011-09-09 19:30:59 +00:00
|
|
|
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_gerbview ) );
|
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_gerbview_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_gerbview_16 ) );
|
2020-12-22 19:41:32 +00:00
|
|
|
icon_bundle.AddIcon( icon );
|
|
|
|
|
|
|
|
SetIcons( icon_bundle );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
2019-05-27 19:07:59 +00:00
|
|
|
// Be sure a page info is set. this default value will be overwritten later.
|
|
|
|
PAGE_INFO pageInfo( wxT( "GERBER" ) );
|
2012-05-04 17:44:42 +00:00
|
|
|
SetLayout( new GBR_LAYOUT() );
|
2019-05-27 19:07:59 +00:00
|
|
|
SetPageSettings( pageInfo );
|
2009-11-09 14:00:22 +00:00
|
|
|
|
2019-04-10 13:40:01 +00:00
|
|
|
SetVisibleLayers( LSET::AllLayersMask() ); // All draw layers visible.
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2022-09-16 23:25:07 +00:00
|
|
|
SetScreen( new BASE_SCREEN( GetPageSettings().GetSizeIU( gerbIUScale.IU_PER_MILS ) ) );
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
// Create the PCB_LAYER_WIDGET *after* SetLayout():
|
2019-06-13 17:28:55 +00:00
|
|
|
m_LayersManager = new GERBER_LAYER_WIDGET( this, GetCanvas() );
|
2010-02-03 14:05:17 +00:00
|
|
|
|
2021-03-26 15:47:02 +00:00
|
|
|
// Update the minimum string length in the layer panel with the length of the last default layer
|
2021-07-16 20:13:26 +00:00
|
|
|
wxString lyrName = GetImagesList()->GetDisplayName( GetImagesList()->ImagesMaxCount(),
|
|
|
|
false, true );
|
2021-03-26 15:47:02 +00:00
|
|
|
m_LayersManager->SetSmallestLayerString( lyrName );
|
|
|
|
|
2010-02-03 14:05:17 +00:00
|
|
|
// LoadSettings() *after* creating m_LayersManager, because LoadSettings()
|
|
|
|
// initialize parameters in m_LayersManager
|
* 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() );
|
|
|
|
|
2019-05-14 19:21:10 +00:00
|
|
|
setupTools();
|
2020-07-29 23:50:25 +00:00
|
|
|
setupUIConditions();
|
2008-04-17 16:25:29 +00:00
|
|
|
ReCreateMenuBar();
|
|
|
|
ReCreateHToolbar();
|
|
|
|
ReCreateOptToolbar();
|
2016-08-16 10:56:20 +00:00
|
|
|
ReCreateAuxiliaryToolbar();
|
2009-11-09 14:00:22 +00:00
|
|
|
|
2018-08-11 16:04:46 +00:00
|
|
|
m_auimgr.SetManagedWindow( this );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2021-01-26 15:23:37 +00:00
|
|
|
m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer( 6 ) );
|
|
|
|
m_auimgr.AddPane( m_auxiliaryToolBar, EDA_PANE().HToolbar().Name( "AuxToolbar" ).Top()
|
|
|
|
.Layer(4) );
|
|
|
|
m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom()
|
|
|
|
.Layer( 6 ) );
|
|
|
|
m_auimgr.AddPane( m_optionsToolBar, EDA_PANE().VToolbar().Name( "OptToolbar" ).Left()
|
|
|
|
.Layer( 3 ) );
|
|
|
|
m_auimgr.AddPane( m_LayersManager, EDA_PANE().Palette().Name( "LayersManager" ).Right()
|
|
|
|
.Layer( 3 ).Caption( _( "Layers Manager" ) ).PaneBorder( false )
|
2018-08-11 16:04:46 +00:00
|
|
|
.MinSize( 80, -1 ).BestSize( m_LayersManager->GetBestSize() ) );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
|
2009-11-02 22:24:55 +00:00
|
|
|
|
2011-04-07 19:17:51 +00:00
|
|
|
ReFillLayerWidget(); // this is near end because contents establish size
|
2009-11-02 22:24:55 +00:00
|
|
|
m_auimgr.Update();
|
2014-05-19 18:24:07 +00:00
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
SetActiveLayer( 0, true );
|
2023-06-26 22:16:51 +00:00
|
|
|
GetToolManager()->PostAction( ACTIONS::zoomFitScreen );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
resolveCanvasType();
|
2020-10-31 20:28:34 +00:00
|
|
|
|
|
|
|
SwitchCanvas( m_canvasType );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2020-10-05 19:26:33 +00:00
|
|
|
setupUnits( config() );
|
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
// Enable the axes to match legacy draw style
|
|
|
|
auto& galOptions = GetGalDisplayOptions();
|
|
|
|
galOptions.m_axesEnabled = true;
|
|
|
|
galOptions.NotifyChanged();
|
|
|
|
|
|
|
|
m_LayersManager->ReFill();
|
|
|
|
m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
|
2019-07-20 15:52:30 +00:00
|
|
|
|
2022-09-14 22:28:09 +00:00
|
|
|
// Drag and drop
|
2022-11-18 04:55:34 +00:00
|
|
|
// Note that all gerber files are aliased as GerberFileExtension
|
|
|
|
m_acceptedExts.emplace( GerberFileExtension, &GERBVIEW_ACTIONS::loadGerbFiles );
|
2022-09-14 22:28:09 +00:00
|
|
|
m_acceptedExts.emplace( ArchiveFileExtension, &GERBVIEW_ACTIONS::loadZipFile );
|
|
|
|
m_acceptedExts.emplace( DrillFileExtension, &GERBVIEW_ACTIONS::loadGerbFiles );
|
|
|
|
DragAcceptFiles( true );
|
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
GetToolManager()->RunAction( ACTIONS::zoomFitScreen );
|
2019-10-03 16:32:09 +00:00
|
|
|
|
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();
|
|
|
|
} );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
GERBVIEW_FRAME::~GERBVIEW_FRAME()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
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-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetView()->Clear();
|
2018-03-19 09:39:11 +00:00
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
GetGerberLayout()->GetImagesList()->DeleteAllImages();
|
2018-01-22 07:55:26 +00:00
|
|
|
delete m_gerberLayout;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-24 02:01:14 +00:00
|
|
|
void GERBVIEW_FRAME::doCloseWindow()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-08-24 02:01:14 +00:00
|
|
|
// No more vetos
|
|
|
|
m_isClosing = true;
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->StopDrawing();
|
|
|
|
GetCanvas()->GetView()->Clear();
|
2018-03-19 09:39:11 +00:00
|
|
|
|
2018-01-22 20:15:46 +00:00
|
|
|
if( m_toolManager )
|
|
|
|
m_toolManager->DeactivateTool();
|
|
|
|
|
2019-05-27 16:16:54 +00:00
|
|
|
// Be sure any OpenGL event cannot be fired after frame deletion:
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->SetEvtHandlerEnabled( false );
|
2018-01-22 20:15:46 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
Destroy();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-04-17 16:25:29 +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 GERBVIEW_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
|
|
|
|
{
|
2018-05-07 10:47:11 +00:00
|
|
|
// Ensure the frame is shown when opening the file(s), to avoid issues (crash) on GAL
|
|
|
|
// when trying to change the view if it is not fully initialized.
|
2021-01-26 15:23:37 +00:00
|
|
|
// It happens when starting GerbView with a gerber job file to load
|
2018-05-07 10:47:11 +00:00
|
|
|
if( !IsShown() )
|
|
|
|
Show();
|
|
|
|
|
2015-09-25 19:41:14 +00:00
|
|
|
// The current project path is also a valid command parameter. Check if a single path
|
2015-09-25 23:34:57 +00:00
|
|
|
// rather than a file name was passed to GerbView and use it as the initial MRU path.
|
|
|
|
if( aFileSet.size() > 0 )
|
2015-09-25 19:41:14 +00:00
|
|
|
{
|
2015-09-25 23:34:57 +00:00
|
|
|
wxString path = aFileSet[0];
|
2015-09-25 19:41:14 +00:00
|
|
|
|
2015-09-25 23:34:57 +00:00
|
|
|
// For some reason wxApp appears to leave the trailing double quote on quoted
|
|
|
|
// parameters which are required for paths with spaces. Maybe this should be
|
|
|
|
// pushed back into PGM_SINGLE_TOP::OnPgmInit() but that may cause other issues.
|
|
|
|
// We can't buy a break!
|
|
|
|
if( path.Last() == wxChar( '\"' ) )
|
|
|
|
path.RemoveLast();
|
* 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
|
|
|
|
2015-09-25 23:34:57 +00:00
|
|
|
if( !wxFileExists( path ) && wxDirExists( path ) )
|
|
|
|
{
|
|
|
|
m_mruPath = path;
|
|
|
|
return true;
|
|
|
|
}
|
* 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
|
|
|
|
2015-09-25 23:34:57 +00:00
|
|
|
const unsigned limit = std::min( unsigned( aFileSet.size() ),
|
|
|
|
unsigned( GERBER_DRAWLAYERS_COUNT ) );
|
|
|
|
|
2021-08-04 20:22:07 +00:00
|
|
|
for( unsigned i = 0; i < limit; ++i )
|
2015-09-25 23:34:57 +00:00
|
|
|
{
|
2021-08-04 20:22:07 +00:00
|
|
|
wxString ext = wxFileName( aFileSet[i] ).GetExt().Lower();
|
2016-06-05 12:26:39 +00:00
|
|
|
|
2022-02-21 10:32:36 +00:00
|
|
|
if( ext == ArchiveFileExtension )
|
2021-08-04 20:22:07 +00:00
|
|
|
LoadZipArchiveFile( aFileSet[i] );
|
2022-02-21 10:32:36 +00:00
|
|
|
else if( ext == GerberJobFileExtension )
|
2017-08-19 16:28:11 +00:00
|
|
|
LoadGerberJobFile( aFileSet[i] );
|
2016-06-05 12:26:39 +00:00
|
|
|
else
|
2021-08-04 20:22:07 +00:00
|
|
|
{
|
|
|
|
GERBER_ORDER_ENUM fnameLayer;
|
|
|
|
wxString fnameExtensionMatched;
|
|
|
|
|
|
|
|
GERBER_FILE_IMAGE_LIST::GetGerberLayerFromFilename( aFileSet[i], fnameLayer,
|
|
|
|
fnameExtensionMatched );
|
|
|
|
|
|
|
|
switch( fnameLayer )
|
|
|
|
{
|
|
|
|
case GERBER_ORDER_ENUM::GERBER_DRILL:
|
|
|
|
LoadExcellonFiles( aFileSet[i] );
|
|
|
|
break;
|
|
|
|
case GERBER_ORDER_ENUM::GERBER_LAYER_UNKNOWN:
|
2021-08-16 18:42:46 +00:00
|
|
|
LoadAutodetectedFiles( aFileSet[i] );
|
2021-08-04 20:22:07 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
LoadGerberFiles( aFileSet[i] );
|
|
|
|
}
|
|
|
|
}
|
2015-09-25 23:34:57 +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
|
|
|
}
|
|
|
|
|
|
|
|
Zoom_Automatique( true ); // Zoom fit in frame
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
GERBVIEW_SETTINGS* GERBVIEW_FRAME::gvconfig() const
|
|
|
|
{
|
|
|
|
return dynamic_cast<GERBVIEW_SETTINGS*>( config() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void GERBVIEW_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
2009-11-22 20:55:05 +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 );
|
2009-11-22 20:55:05 +00:00
|
|
|
|
2023-08-30 15:21:56 +00:00
|
|
|
if( aCfg->m_Window.grid.grids.empty() )
|
2020-06-13 21:09:02 +00:00
|
|
|
{
|
2023-08-30 15:21:56 +00:00
|
|
|
aCfg->m_Window.grid.grids = { GRID{ wxEmptyString, wxS( "100 mil" ), wxS( "100 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "50 mil" ), wxS( "50 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "25 mil" ), wxS( "25 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "20 mil" ), wxS( "20 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "10 mil" ), wxS( "10 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "5 mil" ), wxS( "5 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "2.5 mil" ), wxS( "2.5 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "2 mil" ), wxS( "2 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "1 mil" ), wxS( "1 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "0.5 mil" ), wxS( "0.5 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "0.2 mil" ), wxS( "0.2 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "0.1 mil" ), wxS( "0.1 mil" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "5.0 mm" ), wxS( "5.0 mm" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "1.5 mm" ), wxS( "2.5 mm" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "1.0 mm" ), wxS( "1.0 mm" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "0.5 mm" ), wxS( "0.5 mm" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "0.25 mm" ), wxS( "0.25 mm" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "0.2 mm" ), wxS( "0.2 mm" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "0.1 mm" ), wxS( "0.1 mm" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "0.05 mm" ), wxS( "0.0 mm" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "0.025 mm" ), wxS( "0.0 mm" ) },
|
|
|
|
GRID{ wxEmptyString, wxS( "0.01 mm" ), wxS( "0.0 mm" ) } };
|
2020-06-13 21:09:02 +00:00
|
|
|
}
|
2011-03-12 09:50:21 +00:00
|
|
|
|
2020-06-13 21:09:02 +00:00
|
|
|
if( aCfg->m_Window.zoom_factors.empty() )
|
2020-06-12 10:58:56 +00:00
|
|
|
{
|
2020-12-02 17:33:59 +00:00
|
|
|
aCfg->m_Window.zoom_factors = { ZOOM_LIST_GERBVIEW };
|
2020-06-12 10:58:56 +00:00
|
|
|
}
|
|
|
|
|
2020-06-13 21:09:02 +00:00
|
|
|
GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
|
|
|
|
wxCHECK( cfg, /*void*/ );
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
SetElementVisibility( LAYER_GERBVIEW_DRAWINGSHEET,
|
|
|
|
cfg->m_Appearance.show_border_and_titleblock );
|
2022-03-24 14:10:47 +00:00
|
|
|
SetElementVisibility( LAYER_GERBVIEW_PAGE_LIMITS,
|
|
|
|
cfg->m_Display.m_DisplayPageLimits );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2018-07-07 08:50:13 +00:00
|
|
|
PAGE_INFO pageInfo( wxT( "GERBER" ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
pageInfo.SetType( cfg->m_Appearance.page_type );
|
2011-12-22 21:57:50 +00:00
|
|
|
SetPageSettings( pageInfo );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
SetElementVisibility( LAYER_DCODES, cfg->m_Appearance.show_dcodes );
|
|
|
|
SetElementVisibility( LAYER_NEGATIVE_OBJECTS, cfg->m_Appearance.show_negative_objects );
|
|
|
|
|
|
|
|
m_drillFileHistory.Load( cfg->m_DrillFileHistory );
|
|
|
|
m_zipFileHistory.Load( cfg->m_ZipFileHistory );
|
|
|
|
m_jobFileHistory.Load( cfg->m_JobFileHistory );
|
2009-11-22 20:55:05 +00:00
|
|
|
}
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void GERBVIEW_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
2009-11-22 20:55:05 +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 );
|
2009-11-22 20:55:05 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
GERBVIEW_SETTINGS* cfg = dynamic_cast<GERBVIEW_SETTINGS*>( aCfg );
|
2020-03-22 08:45:51 +00:00
|
|
|
wxCHECK( cfg, /*void*/ );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
cfg->m_Appearance.page_type = GetPageSettings().GetType();
|
|
|
|
|
|
|
|
m_drillFileHistory.Save( &cfg->m_DrillFileHistory );
|
|
|
|
m_zipFileHistory.Save( &cfg->m_ZipFileHistory );
|
|
|
|
m_jobFileHistory.Save( &cfg->m_JobFileHistory );
|
|
|
|
|
|
|
|
COLOR_SETTINGS* cs = Pgm().GetSettingsManager().GetColorSettings();
|
|
|
|
Pgm().GetSettingsManager().SaveColorSettings( cs, "gerbview" );
|
2010-02-03 14:05:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-09-10 18:16:08 +00:00
|
|
|
COLOR_SETTINGS* GERBVIEW_FRAME::GetColorSettings( bool aForceRefresh ) const
|
|
|
|
{
|
2022-09-11 12:38:33 +00:00
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
GERBVIEW_SETTINGS* cfg = mgr.GetAppSettings<GERBVIEW_SETTINGS>();
|
2022-09-10 18:16:08 +00:00
|
|
|
wxString currentTheme = cfg->m_ColorTheme;
|
2022-09-11 12:38:33 +00:00
|
|
|
return mgr.GetColorSettings( currentTheme );
|
2022-09-10 18:16:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::ReFillLayerWidget()
|
2010-02-03 14:05:17 +00:00
|
|
|
{
|
2020-05-02 20:09:43 +00:00
|
|
|
wxWindowUpdateLocker no_update( m_LayersManager );
|
|
|
|
|
2010-02-03 14:05:17 +00:00
|
|
|
m_LayersManager->ReFill();
|
2016-05-23 15:47:16 +00:00
|
|
|
m_SelLayerBox->Resync();
|
2016-08-16 10:56:20 +00:00
|
|
|
ReCreateAuxiliaryToolbar();
|
2010-02-03 14:05:17 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
wxAuiPaneInfo& lyrs = m_auimgr.GetPane( m_LayersManager );
|
|
|
|
wxSize bestz = m_LayersManager->GetBestSize();
|
2016-05-23 15:47:16 +00:00
|
|
|
bestz.x += 5; // gives a little margin
|
2010-02-03 14:05:17 +00:00
|
|
|
|
|
|
|
lyrs.MinSize( bestz );
|
|
|
|
lyrs.BestSize( bestz );
|
|
|
|
lyrs.FloatingSize( bestz );
|
|
|
|
|
|
|
|
if( lyrs.IsDocked() )
|
|
|
|
m_auimgr.Update();
|
|
|
|
else
|
|
|
|
m_LayersManager->SetSize( bestz );
|
2010-02-14 18:14:33 +00:00
|
|
|
|
2010-05-17 20:35:46 +00:00
|
|
|
syncLayerWidget();
|
2010-02-03 14:05:17 +00:00
|
|
|
}
|
|
|
|
|
2015-09-25 23:34:57 +00:00
|
|
|
|
2018-07-07 08:50:13 +00:00
|
|
|
void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState )
|
2010-02-03 14:05:17 +00:00
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
KIGFX::VIEW* view = GetCanvas()->GetView();
|
2018-02-22 04:08:59 +00:00
|
|
|
|
2018-07-07 08:50:13 +00:00
|
|
|
switch( aLayerID )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
case LAYER_DCODES:
|
2021-09-07 20:34:10 +00:00
|
|
|
gvconfig()->m_Appearance.show_dcodes = aNewState;
|
|
|
|
|
|
|
|
for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
|
|
|
|
{
|
|
|
|
int layer = GERBER_DRAW_LAYER( i );
|
|
|
|
int dcode_layer = GERBER_DCODE_LAYER( layer );
|
|
|
|
view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
|
|
|
|
}
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
break;
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
case LAYER_NEGATIVE_OBJECTS:
|
2018-02-27 01:49:42 +00:00
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
gvconfig()->m_Appearance.show_negative_objects = aNewState;
|
2018-02-27 01:49:42 +00:00
|
|
|
|
2022-12-03 13:25:20 +00:00
|
|
|
view->UpdateAllItemsConditionally( KIGFX::REPAINT,
|
|
|
|
[]( KIGFX::VIEW_ITEM* aItem )
|
|
|
|
{
|
|
|
|
GERBER_DRAW_ITEM* item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
|
2018-02-27 01:49:42 +00:00
|
|
|
|
2022-12-03 13:25:20 +00:00
|
|
|
// GetLayerPolarity() returns true for negative items
|
|
|
|
return ( item && item->GetLayerPolarity() );
|
|
|
|
} );
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2013-01-06 13:31:49 +00:00
|
|
|
break;
|
2018-02-27 01:49:42 +00:00
|
|
|
}
|
2013-01-06 13:31:49 +00:00
|
|
|
|
2021-02-22 16:37:43 +00:00
|
|
|
case LAYER_GERBVIEW_DRAWINGSHEET:
|
2021-09-07 20:34:10 +00:00
|
|
|
gvconfig()->m_Appearance.show_border_and_titleblock = aNewState;
|
|
|
|
|
|
|
|
m_showBorderAndTitleBlock = gvconfig()->m_Appearance.show_border_and_titleblock;
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2021-02-22 16:37:43 +00:00
|
|
|
// NOTE: LAYER_DRAWINGSHEET always used for visibility, but the layer manager passes
|
|
|
|
// LAYER_GERBVIEW_DRAWINGSHEET because of independent color control
|
|
|
|
GetCanvas()->GetView()->SetLayerVisible( LAYER_DRAWINGSHEET, aNewState );
|
2018-07-07 08:50:13 +00:00
|
|
|
break;
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
case LAYER_GERBVIEW_GRID:
|
2012-05-04 17:44:42 +00:00
|
|
|
SetGridVisibility( aNewState );
|
|
|
|
break;
|
|
|
|
|
2022-03-24 14:10:47 +00:00
|
|
|
case LAYER_GERBVIEW_PAGE_LIMITS:
|
|
|
|
gvconfig()->m_Display.m_DisplayPageLimits = aNewState;
|
|
|
|
SetPageSettings( GetPageSettings() );
|
|
|
|
break;
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
default:
|
2022-02-05 19:31:22 +00:00
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::SetElementVisibility(): bad arg %d" ),
|
2020-08-18 14:17:16 +00:00
|
|
|
aLayerID ) );
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
2015-09-25 23:34:57 +00:00
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
ApplyDisplaySettingsToGAL();
|
2018-07-07 08:50:13 +00:00
|
|
|
m_LayersManager->SetRenderState( aLayerID, aNewState );
|
2009-11-22 20:55:05 +00:00
|
|
|
}
|
2010-02-04 09:08:08 +00:00
|
|
|
|
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
void GERBVIEW_FRAME::ApplyDisplaySettingsToGAL()
|
2017-09-17 22:43:20 +00:00
|
|
|
{
|
2019-06-13 17:28:55 +00:00
|
|
|
auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>( GetCanvas()->GetView()->GetPainter() );
|
2018-07-07 08:50:13 +00:00
|
|
|
KIGFX::GERBVIEW_RENDER_SETTINGS* settings = painter->GetSettings();
|
2022-07-25 19:43:11 +00:00
|
|
|
settings->SetHighContrast( gvconfig()->m_Display.m_HighContrastMode );
|
2022-09-10 18:16:08 +00:00
|
|
|
settings->LoadColors( GetColorSettings() );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
2017-09-17 22:43:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-08-16 13:52:25 +00:00
|
|
|
int GERBVIEW_FRAME::getNextAvailableLayer() const
|
2011-03-02 15:24:39 +00:00
|
|
|
{
|
2016-06-17 18:00:29 +00:00
|
|
|
for( unsigned i = 0; i < ImagesMaxCount(); ++i )
|
2011-03-02 15:24:39 +00:00
|
|
|
{
|
2021-08-16 13:52:25 +00:00
|
|
|
const GERBER_FILE_IMAGE* gerber = GetGbrImage( i );
|
2011-03-02 15:24:39 +00:00
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
if( gerber == nullptr ) // this graphic layer is available: use it
|
2021-08-16 13:52:25 +00:00
|
|
|
return i;
|
2011-03-02 15:24:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NO_AVAILABLE_LAYERS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::syncLayerWidget()
|
2010-02-04 09:08:08 +00:00
|
|
|
{
|
2017-09-17 22:43:20 +00:00
|
|
|
m_LayersManager->SelectLayer( GetActiveLayer() );
|
2010-02-04 09:08:08 +00:00
|
|
|
}
|
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
|
2016-05-23 15:47:16 +00:00
|
|
|
void GERBVIEW_FRAME::syncLayerBox( bool aRebuildLayerBox )
|
2010-02-04 09:08:08 +00:00
|
|
|
{
|
2016-05-23 15:47:16 +00:00
|
|
|
if( aRebuildLayerBox )
|
|
|
|
m_SelLayerBox->Resync();
|
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
m_SelLayerBox->SetSelection( GetActiveLayer() );
|
2014-11-22 11:52:57 +00:00
|
|
|
|
2016-06-17 18:00:29 +00:00
|
|
|
int dcodeSelected = -1;
|
2017-09-17 22:43:20 +00:00
|
|
|
GERBER_FILE_IMAGE* gerber = GetGbrImage( GetActiveLayer() );
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
if( gerber )
|
|
|
|
dcodeSelected = gerber->m_Selected_Tool;
|
2011-02-08 14:48:38 +00:00
|
|
|
|
2010-12-17 20:34:29 +00:00
|
|
|
if( m_DCodeSelector )
|
|
|
|
{
|
2016-08-17 08:19:10 +00:00
|
|
|
updateDCodeSelectBox();
|
2010-12-17 20:34:29 +00:00
|
|
|
m_DCodeSelector->SetDCodeSelection( dcodeSelected );
|
2021-07-16 20:13:26 +00:00
|
|
|
m_DCodeSelector->Enable( gerber != nullptr );
|
2010-12-17 20:34:29 +00:00
|
|
|
}
|
2010-02-04 09:08:08 +00:00
|
|
|
}
|
|
|
|
|
2015-09-25 23:34:57 +00:00
|
|
|
|
2021-08-02 20:00:34 +00:00
|
|
|
void GERBVIEW_FRAME::SortLayersByFileExtension()
|
|
|
|
{
|
|
|
|
RemapLayers( GetImagesList()->SortImagesByFileExtension() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-28 02:33:41 +00:00
|
|
|
void GERBVIEW_FRAME::SortLayersByX2Attributes()
|
|
|
|
{
|
2021-08-02 20:00:34 +00:00
|
|
|
RemapLayers( GetImagesList()->SortImagesByZOrder() );
|
|
|
|
}
|
|
|
|
|
2018-02-28 02:33:41 +00:00
|
|
|
|
2021-08-02 20:00:34 +00:00
|
|
|
void GERBVIEW_FRAME::RemapLayers( std::unordered_map<int, int> remapping )
|
|
|
|
{
|
2018-02-28 02:33:41 +00:00
|
|
|
ReFillLayerWidget();
|
|
|
|
syncLayerBox( true );
|
|
|
|
|
|
|
|
std::unordered_map<int, int> view_remapping;
|
|
|
|
|
2021-09-09 20:49:16 +00:00
|
|
|
for( const std::pair<const int, int>& entry : remapping )
|
2018-02-28 02:33:41 +00:00
|
|
|
{
|
2022-01-05 17:59:53 +00:00
|
|
|
view_remapping[ GERBER_DRAW_LAYER( entry.first ) ] = GERBER_DRAW_LAYER( entry.second );
|
2021-09-09 20:49:16 +00:00
|
|
|
view_remapping[ GERBER_DCODE_LAYER( entry.first ) ] = GERBER_DCODE_LAYER( entry.second );
|
2018-02-28 02:33:41 +00:00
|
|
|
}
|
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetView()->ReorderLayerData( view_remapping );
|
|
|
|
GetCanvas()->Refresh();
|
2018-02-28 02:33:41 +00:00
|
|
|
}
|
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
|
2023-09-06 16:54:54 +00:00
|
|
|
void GERBVIEW_FRAME::SetLayerDrawPrms()
|
|
|
|
{
|
|
|
|
// Adjust draw params: draw offset and draw rotation for a gerber file image
|
|
|
|
GERBER_FILE_IMAGE* gerber = GetGbrImage( GetActiveLayer() );
|
|
|
|
|
|
|
|
if( !gerber )
|
|
|
|
return;
|
|
|
|
|
|
|
|
DIALOG_DRAW_LAYERS_SETTINGS dlg( this );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
|
|
|
return;
|
|
|
|
|
|
|
|
KIGFX::VIEW* view = GetCanvas()->GetView();
|
|
|
|
|
|
|
|
view->RecacheAllItems();
|
|
|
|
view->MarkDirty();
|
|
|
|
view->UpdateAllItems( KIGFX::ALL );
|
|
|
|
|
|
|
|
GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-11-17 15:42:12 +00:00
|
|
|
void GERBVIEW_FRAME::UpdateXORLayers()
|
2021-08-24 16:00:46 +00:00
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
auto target = GetCanvas()->GetBackend() == GERBVIEW_DRAW_PANEL_GAL::GAL_TYPE_OPENGL
|
2021-08-24 16:00:46 +00:00
|
|
|
? KIGFX::TARGET_CACHED
|
|
|
|
: KIGFX::TARGET_NONCACHED;
|
2021-09-09 20:49:16 +00:00
|
|
|
KIGFX::VIEW* view = GetCanvas()->GetView();
|
2021-08-24 16:00:46 +00:00
|
|
|
|
|
|
|
int lastVisibleLayer = -1;
|
2021-09-07 20:34:10 +00:00
|
|
|
|
2021-08-24 16:00:46 +00:00
|
|
|
for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
|
|
|
|
{
|
2022-11-17 15:42:12 +00:00
|
|
|
view->SetLayerDiff( GERBER_DRAW_LAYER( i ), gvconfig()->m_Display.m_XORMode );
|
2021-09-07 20:34:10 +00:00
|
|
|
|
2022-12-19 15:58:40 +00:00
|
|
|
// Caching doesn't work with layered rendering of XOR'd layers
|
|
|
|
if( gvconfig()->m_Display.m_XORMode )
|
2021-09-07 20:34:10 +00:00
|
|
|
view->SetLayerTarget( GERBER_DRAW_LAYER( i ), KIGFX::TARGET_NONCACHED );
|
|
|
|
else
|
|
|
|
view->SetLayerTarget( GERBER_DRAW_LAYER( i ), target );
|
|
|
|
|
|
|
|
// We want the last visible layer, but deprioritize the active layer unless it's the
|
|
|
|
// only layer
|
2021-08-24 16:00:46 +00:00
|
|
|
if( ( lastVisibleLayer == -1 )
|
|
|
|
|| ( view->IsLayerVisible( GERBER_DRAW_LAYER( i ) ) && i != GetActiveLayer() ) )
|
2021-09-07 20:34:10 +00:00
|
|
|
{
|
2021-08-24 16:00:46 +00:00
|
|
|
lastVisibleLayer = i;
|
2021-09-07 20:34:10 +00:00
|
|
|
}
|
2021-08-24 16:00:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//We don't want to diff the last visible layer onto the background, etc.
|
|
|
|
if( lastVisibleLayer != -1 )
|
|
|
|
{
|
|
|
|
view->SetLayerTarget( GERBER_DRAW_LAYER( lastVisibleLayer ), target );
|
|
|
|
view->SetLayerDiff( GERBER_DRAW_LAYER( lastVisibleLayer ), false );
|
|
|
|
}
|
|
|
|
|
|
|
|
view->RecacheAllItems();
|
|
|
|
view->MarkDirty();
|
|
|
|
view->UpdateAllItems( KIGFX::ALL );
|
|
|
|
}
|
|
|
|
|
2018-02-28 02:33:41 +00:00
|
|
|
|
2011-03-12 09:50:21 +00:00
|
|
|
void GERBVIEW_FRAME::UpdateTitleAndInfo()
|
2010-10-06 17:28:07 +00:00
|
|
|
{
|
2017-09-17 22:43:20 +00:00
|
|
|
GERBER_FILE_IMAGE* gerber = GetGbrImage( GetActiveLayer() );
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-10-06 17:28:07 +00:00
|
|
|
// Display the gerber filename
|
2021-07-16 20:13:26 +00:00
|
|
|
if( gerber == nullptr )
|
2010-10-06 17:28:07 +00:00
|
|
|
{
|
2021-03-09 23:31:17 +00:00
|
|
|
SetTitle( _("Gerber Viewer") );
|
2016-09-26 17:15:33 +00:00
|
|
|
|
2010-10-06 17:28:07 +00:00
|
|
|
SetStatusText( wxEmptyString, 0 );
|
2016-05-27 08:20:17 +00:00
|
|
|
|
2016-09-26 17:15:33 +00:00
|
|
|
wxString info;
|
2021-08-04 17:44:26 +00:00
|
|
|
info.Printf( _( "Drawing layer not in use" ) );
|
2016-09-26 17:15:33 +00:00
|
|
|
m_TextInfo->SetValue( info );
|
|
|
|
|
2020-10-25 16:41:38 +00:00
|
|
|
if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
|
2016-05-27 08:20:17 +00:00
|
|
|
m_auimgr.Update();
|
|
|
|
|
2010-10-17 16:42:06 +00:00
|
|
|
ClearMsgPanel();
|
2010-10-06 17:28:07 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-09-26 17:15:33 +00:00
|
|
|
else
|
|
|
|
{
|
2021-06-20 21:46:41 +00:00
|
|
|
wxString title;
|
2020-09-03 13:36:03 +00:00
|
|
|
wxFileName filename( gerber->m_FileName );
|
|
|
|
|
2021-06-20 21:46:41 +00:00
|
|
|
title = filename.GetFullName();
|
|
|
|
|
|
|
|
if( gerber->m_IsX2_file )
|
|
|
|
title += wxS( " " ) + _( "(with X2 attributes)" );
|
|
|
|
|
|
|
|
title += wxT( " \u2014 " ) + _( "Gerber Viewer" );
|
2016-09-26 17:15:33 +00:00
|
|
|
SetTitle( title );
|
|
|
|
|
|
|
|
gerber->DisplayImageInfo( this );
|
|
|
|
|
|
|
|
// Display Image Name and Layer Name (from the current gerber data):
|
|
|
|
wxString status;
|
2017-12-15 11:37:46 +00:00
|
|
|
status.Printf( _( "Image name: \"%s\" Layer name: \"%s\"" ),
|
2018-07-07 08:50:13 +00:00
|
|
|
gerber->m_ImageName,
|
|
|
|
gerber->GetLayerParams().m_LayerName );
|
2016-09-26 17:15:33 +00:00
|
|
|
SetStatusText( status, 0 );
|
|
|
|
|
|
|
|
// Display data format like fmt in X3.4Y3.4 no LZ or fmt mm X2.3 Y3.5 no TZ in main toolbar
|
|
|
|
wxString info;
|
|
|
|
info.Printf( wxT( "fmt: %s X%d.%d Y%d.%d no %cZ" ),
|
2018-07-07 08:50:13 +00:00
|
|
|
gerber->m_GerbMetric ? wxT( "mm" ) : wxT( "in" ),
|
|
|
|
gerber->m_FmtLen.x - gerber->m_FmtScale.x,
|
|
|
|
gerber->m_FmtScale.x,
|
|
|
|
gerber->m_FmtLen.y - gerber->m_FmtScale.y,
|
|
|
|
gerber->m_FmtScale.y,
|
|
|
|
gerber->m_NoTrailingZeros ? 'T' : 'L' );
|
2016-09-26 17:15:33 +00:00
|
|
|
|
|
|
|
if( gerber->m_IsX2_file )
|
|
|
|
info << wxT(" ") << _( "X2 attr" );
|
|
|
|
|
|
|
|
m_TextInfo->SetValue( info );
|
|
|
|
|
2020-10-25 16:41:38 +00:00
|
|
|
if( KIUI::EnsureTextCtrlWidth( m_TextInfo, &info ) ) // Resized
|
2016-09-26 17:15:33 +00:00
|
|
|
m_auimgr.Update();
|
|
|
|
}
|
2010-10-06 17:28:07 +00:00
|
|
|
}
|
|
|
|
|
2015-09-25 23:34:57 +00:00
|
|
|
|
2018-07-07 08:50:13 +00:00
|
|
|
bool GERBVIEW_FRAME::IsElementVisible( int aLayerID ) const
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2018-07-07 08:50:13 +00:00
|
|
|
switch( aLayerID )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
case LAYER_DCODES: return gvconfig()->m_Appearance.show_dcodes;
|
|
|
|
case LAYER_NEGATIVE_OBJECTS: return gvconfig()->m_Appearance.show_negative_objects;
|
2021-02-22 16:37:43 +00:00
|
|
|
case LAYER_GERBVIEW_GRID: return IsGridVisible();
|
2021-09-07 20:34:10 +00:00
|
|
|
case LAYER_GERBVIEW_DRAWINGSHEET: return gvconfig()->m_Appearance.show_border_and_titleblock;
|
2022-03-24 14:10:47 +00:00
|
|
|
case LAYER_GERBVIEW_PAGE_LIMITS: return gvconfig()->m_Display.m_DisplayPageLimits;
|
2021-02-22 16:37:43 +00:00
|
|
|
case LAYER_GERBVIEW_BACKGROUND: return true;
|
2012-05-04 17:44:42 +00:00
|
|
|
|
|
|
|
default:
|
2022-02-05 19:31:22 +00:00
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::IsElementVisible(): bad arg %d" ),
|
|
|
|
aLayerID ) );
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-10 13:40:01 +00:00
|
|
|
LSET GERBVIEW_FRAME::GetVisibleLayers() const
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2019-04-10 13:40:01 +00:00
|
|
|
LSET visible = LSET::AllLayersMask();
|
2017-09-18 01:03:58 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
if( GetCanvas() )
|
2017-09-18 01:03:58 +00:00
|
|
|
{
|
|
|
|
for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
|
2019-06-13 17:28:55 +00:00
|
|
|
visible[i] = GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) );
|
2017-09-18 01:03:58 +00:00
|
|
|
}
|
2019-04-10 13:40:01 +00:00
|
|
|
|
|
|
|
return visible;
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-10 13:40:01 +00:00
|
|
|
void GERBVIEW_FRAME::SetVisibleLayers( LSET aLayerMask )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2019-06-13 17:28:55 +00:00
|
|
|
if( GetCanvas() )
|
2017-09-17 22:43:20 +00:00
|
|
|
{
|
|
|
|
for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ )
|
|
|
|
{
|
2019-04-10 13:40:01 +00:00
|
|
|
bool v = aLayerMask[i];
|
2017-09-17 22:43:20 +00:00
|
|
|
int layer = GERBER_DRAW_LAYER( i );
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetView()->SetLayerVisible( layer, v );
|
|
|
|
GetCanvas()->GetView()->SetLayerVisible( GERBER_DCODE_LAYER( layer ),
|
2021-09-07 20:34:10 +00:00
|
|
|
gvconfig()->m_Appearance.show_dcodes && v );
|
2017-09-17 22:43:20 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-27 17:07:42 +00:00
|
|
|
bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2018-09-28 08:10:08 +00:00
|
|
|
return m_LayersManager->IsLayerVisible( aLayer );
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-07 08:50:13 +00:00
|
|
|
COLOR4D GERBVIEW_FRAME::GetVisibleElementColor( int aLayerID )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2017-02-20 17:48:27 +00:00
|
|
|
COLOR4D color = COLOR4D::UNSPECIFIED;
|
2022-09-10 18:16:08 +00:00
|
|
|
COLOR_SETTINGS* settings = GetColorSettings();
|
2012-05-04 17:44:42 +00:00
|
|
|
|
2018-07-07 08:50:13 +00:00
|
|
|
switch( aLayerID )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
case LAYER_NEGATIVE_OBJECTS:
|
|
|
|
case LAYER_DCODES:
|
2021-02-22 16:37:43 +00:00
|
|
|
case LAYER_GERBVIEW_DRAWINGSHEET:
|
2022-03-24 14:10:47 +00:00
|
|
|
case LAYER_GERBVIEW_PAGE_LIMITS:
|
2020-01-13 01:44:19 +00:00
|
|
|
case LAYER_GERBVIEW_BACKGROUND:
|
2020-07-08 16:20:31 +00:00
|
|
|
color = settings->GetColor( aLayerID );
|
2012-05-04 17:44:42 +00:00
|
|
|
break;
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
case LAYER_GERBVIEW_GRID:
|
2012-05-04 17:44:42 +00:00
|
|
|
color = GetGridColor();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2022-02-05 19:31:22 +00:00
|
|
|
wxFAIL_MSG( wxString::Format( wxT( "GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d" ),
|
2020-08-18 14:17:16 +00:00
|
|
|
aLayerID ) );
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
2015-09-25 23:34:57 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
void GERBVIEW_FRAME::SetGridVisibility( bool aVisible )
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::SetGridVisibility( aVisible );
|
2017-03-13 03:19:33 +00:00
|
|
|
m_LayersManager->SetRenderState( LAYER_GERBVIEW_GRID, aVisible );
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-26 17:28:37 +00:00
|
|
|
void GERBVIEW_FRAME::SetVisibleElementColor( int aLayerID, const COLOR4D& aColor )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2022-09-10 18:16:08 +00:00
|
|
|
COLOR_SETTINGS* settings = GetColorSettings();
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2022-03-24 14:10:47 +00:00
|
|
|
settings->SetColor( aLayerID, aColor );
|
|
|
|
|
2018-07-07 08:50:13 +00:00
|
|
|
switch( aLayerID )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2021-02-22 16:37:43 +00:00
|
|
|
case LAYER_GERBVIEW_DRAWINGSHEET:
|
2022-03-24 14:10:47 +00:00
|
|
|
case LAYER_GERBVIEW_PAGE_LIMITS:
|
|
|
|
SetPageSettings( GetPageSettings() );
|
2020-07-08 16:20:31 +00:00
|
|
|
break;
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
case LAYER_GERBVIEW_GRID:
|
2012-05-04 17:44:42 +00:00
|
|
|
SetGridColor( aColor );
|
2018-07-07 08:50:13 +00:00
|
|
|
break;
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
case LAYER_GERBVIEW_BACKGROUND:
|
2018-07-07 08:50:13 +00:00
|
|
|
SetDrawBgColor( aColor );
|
2012-05-04 17:44:42 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2022-03-24 14:10:47 +00:00
|
|
|
break;
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-13 18:33:30 +00:00
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D GERBVIEW_FRAME::GetLayerColor( int aLayer ) const
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2022-09-10 18:16:08 +00:00
|
|
|
return GetColorSettings()->GetColor( aLayer );
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-26 17:28:37 +00:00
|
|
|
void GERBVIEW_FRAME::SetLayerColor( int aLayer, const COLOR4D& aColor )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2022-09-10 18:16:08 +00:00
|
|
|
GetColorSettings()->SetColor( aLayer, aColor );
|
2021-09-07 20:34:10 +00:00
|
|
|
ApplyDisplaySettingsToGAL();
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-17 22:43:20 +00:00
|
|
|
void GERBVIEW_FRAME::SetActiveLayer( int aLayer, bool doLayerWidgetUpdate )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2020-06-13 21:09:02 +00:00
|
|
|
m_activeLayer = aLayer;
|
2012-05-04 17:44:42 +00:00
|
|
|
|
2022-11-17 15:42:12 +00:00
|
|
|
if( gvconfig()->m_Display.m_XORMode )
|
|
|
|
UpdateXORLayers();
|
2021-08-24 16:00:46 +00:00
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
if( doLayerWidgetUpdate )
|
2020-05-02 20:09:43 +00:00
|
|
|
m_LayersManager->SelectLayer( aLayer );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2018-03-08 23:19:38 +00:00
|
|
|
UpdateTitleAndInfo();
|
|
|
|
|
2023-06-26 22:16:51 +00:00
|
|
|
m_toolManager->PostAction( GERBVIEW_ACTIONS::layerChanged ); // notify other tools
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->SetFocus(); // otherwise hotkeys are stuck somewhere
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->SetHighContrastLayer( GERBER_DRAW_LAYER( aLayer ) );
|
|
|
|
GetCanvas()->Refresh();
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GERBVIEW_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
|
|
|
|
{
|
2014-12-23 13:01:59 +00:00
|
|
|
m_paper = aPageSettings;
|
2018-06-01 07:11:43 +00:00
|
|
|
|
2020-06-13 21:09:02 +00:00
|
|
|
if( GetScreen() )
|
2022-09-16 23:25:07 +00:00
|
|
|
GetScreen()->InitDataPoints( aPageSettings.GetSizeIU( gerbIUScale.IU_PER_MILS ) );
|
2018-06-01 07:11:43 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
GERBVIEW_DRAW_PANEL_GAL* drawPanel = static_cast<GERBVIEW_DRAW_PANEL_GAL*>( GetCanvas() );
|
2018-06-01 07:11:43 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
// Prepare drawing-sheet template
|
2023-06-12 21:33:55 +00:00
|
|
|
DS_PROXY_VIEW_ITEM* drawingSheet = new DS_PROXY_VIEW_ITEM( gerbIUScale, &GetPageSettings(),
|
|
|
|
&Prj(), &GetTitleBlock(), nullptr );
|
2012-05-04 17:44:42 +00:00
|
|
|
|
2020-06-13 21:09:02 +00:00
|
|
|
if( GetScreen() )
|
2019-05-27 16:16:54 +00:00
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
drawingSheet->SetPageNumber( "1" );
|
|
|
|
drawingSheet->SetSheetCount( 1 );
|
2018-06-01 07:11:43 +00:00
|
|
|
}
|
2019-05-27 16:16:54 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
drawingSheet->SetColorLayer( LAYER_GERBVIEW_DRAWINGSHEET );
|
2022-03-24 14:10:47 +00:00
|
|
|
drawingSheet->SetPageBorderColorLayer( LAYER_GERBVIEW_PAGE_LIMITS );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
// Draw panel takes ownership of the drawing-sheet
|
|
|
|
drawPanel->SetDrawingSheet( drawingSheet );
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const PAGE_INFO& GERBVIEW_FRAME::GetPageSettings() const
|
|
|
|
{
|
2014-12-23 13:01:59 +00:00
|
|
|
return m_paper;
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-19 03:40:07 +00:00
|
|
|
const VECTOR2I GERBVIEW_FRAME::GetPageSizeIU() const
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
|
|
|
// 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 GetPageSettings().GetSizeIU( gerbIUScale.IU_PER_MILS );
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const TITLE_BLOCK& GERBVIEW_FRAME::GetTitleBlock() const
|
|
|
|
{
|
2013-06-27 19:12:01 +00:00
|
|
|
wxASSERT( m_gerberLayout );
|
|
|
|
return m_gerberLayout->GetTitleBlock();
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GERBVIEW_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
|
|
|
|
{
|
2013-06-27 19:12:01 +00:00
|
|
|
wxASSERT( m_gerberLayout );
|
|
|
|
m_gerberLayout->SetTitleBlock( aTitleBlock );
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-08 16:20:31 +00:00
|
|
|
COLOR4D GERBVIEW_FRAME::GetGridColor()
|
|
|
|
{
|
2022-09-10 18:16:08 +00:00
|
|
|
return GetColorSettings()->GetColor( LAYER_GERBVIEW_GRID );
|
2020-07-08 16:20:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-26 17:28:37 +00:00
|
|
|
void GERBVIEW_FRAME::SetGridColor( const COLOR4D& aColor )
|
2017-09-17 22:43:20 +00:00
|
|
|
{
|
2022-09-10 18:16:08 +00:00
|
|
|
GetColorSettings()->SetColor( LAYER_GERBVIEW_GRID, aColor );
|
2019-06-13 17:28:55 +00:00
|
|
|
GetCanvas()->GetGAL()->SetGridColor( aColor );
|
2017-09-17 22:43:20 +00:00
|
|
|
m_gridColor = aColor;
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
2018-03-13 21:59:46 +00:00
|
|
|
|
2019-05-24 13:55:33 +00:00
|
|
|
void GERBVIEW_FRAME::DisplayGridMsg()
|
|
|
|
{
|
2021-10-24 12:15:53 +00:00
|
|
|
VECTOR2D gridSize = GetCanvas()->GetGAL()->GetGridSize();
|
2019-05-24 13:55:33 +00:00
|
|
|
wxString line;
|
|
|
|
|
2022-02-05 19:31:22 +00:00
|
|
|
line.Printf( wxT( "grid X %s Y %s" ),
|
2022-09-19 09:25:20 +00:00
|
|
|
MessageTextFromValue( gridSize.x, false ),
|
|
|
|
MessageTextFromValue( gridSize.y, false ) );
|
2019-05-24 13:55:33 +00:00
|
|
|
|
|
|
|
SetStatusText( line, 4 );
|
2021-10-24 12:15:53 +00:00
|
|
|
SetStatusText( line, 4 );
|
2019-05-24 13:55:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
void GERBVIEW_FRAME::UpdateStatusBar()
|
|
|
|
{
|
|
|
|
EDA_DRAW_FRAME::UpdateStatusBar();
|
|
|
|
|
2020-06-13 21:09:02 +00:00
|
|
|
if( !GetScreen() )
|
2012-05-04 17:44:42 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
wxString line;
|
2019-06-13 17:28:55 +00:00
|
|
|
VECTOR2D cursorPos = GetCanvas()->GetViewControls()->GetCursorPosition();
|
2012-05-04 17:44:42 +00:00
|
|
|
|
2019-05-17 11:52:38 +00:00
|
|
|
if( GetShowPolarCoords() ) // display relative polar coordinates
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2022-01-18 23:20:48 +00:00
|
|
|
VECTOR2D v = cursorPos - GetScreen()->m_LocalOrigin;
|
|
|
|
EDA_ANGLE theta( VECTOR2D( v.x, -v.y ) );
|
|
|
|
double ro = hypot( v.x, v.y );
|
2012-05-04 17:44:42 +00:00
|
|
|
|
2020-10-06 10:47:01 +00:00
|
|
|
line.Printf( wxT( "r %s theta %s" ),
|
2022-09-19 09:25:20 +00:00
|
|
|
MessageTextFromValue( ro, false ),
|
|
|
|
MessageTextFromValue( theta, false ) );
|
2012-05-04 17:44:42 +00:00
|
|
|
|
|
|
|
SetStatusText( line, 3 );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Display absolute coordinates:
|
2020-10-06 10:47:01 +00:00
|
|
|
line.Printf( wxT( "X %s Y %s" ),
|
2022-09-19 09:25:20 +00:00
|
|
|
MessageTextFromValue( cursorPos.x, false ),
|
|
|
|
MessageTextFromValue( cursorPos.y, false ) );
|
2012-05-04 17:44:42 +00:00
|
|
|
SetStatusText( line, 2 );
|
|
|
|
|
2020-10-06 10:47:01 +00:00
|
|
|
if( !GetShowPolarCoords() )
|
2012-05-04 17:44:42 +00:00
|
|
|
{
|
2020-10-06 10:47:01 +00:00
|
|
|
// Display relative cartesian coordinates:
|
|
|
|
double dXpos = cursorPos.x - GetScreen()->m_LocalOrigin.x;
|
|
|
|
double dYpos = cursorPos.y - GetScreen()->m_LocalOrigin.y;
|
|
|
|
|
|
|
|
line.Printf( wxT( "dx %s dy %s dist %s" ),
|
2022-09-19 09:25:20 +00:00
|
|
|
MessageTextFromValue( dXpos, false ),
|
|
|
|
MessageTextFromValue( dYpos,false ),
|
|
|
|
MessageTextFromValue( hypot( dXpos, dYpos ), false ) );
|
2012-05-04 17:44:42 +00:00
|
|
|
SetStatusText( line, 3 );
|
|
|
|
}
|
2019-05-24 13:55:33 +00:00
|
|
|
|
|
|
|
DisplayGridMsg();
|
2012-05-04 17:44:42 +00:00
|
|
|
}
|
|
|
|
|
2015-01-06 07:38:58 +00:00
|
|
|
|
2016-06-17 18:00:29 +00:00
|
|
|
GERBER_FILE_IMAGE* GERBVIEW_FRAME::GetGbrImage( int aIdx ) const
|
|
|
|
{
|
|
|
|
return m_gerberLayout->GetImagesList()->GetGbrImage( aIdx );
|
|
|
|
}
|
|
|
|
|
2018-03-13 21:59:46 +00:00
|
|
|
|
2016-06-17 18:00:29 +00:00
|
|
|
unsigned GERBVIEW_FRAME::ImagesMaxCount() const
|
|
|
|
{
|
|
|
|
return m_gerberLayout->GetImagesList()->ImagesMaxCount();
|
|
|
|
}
|
|
|
|
|
2016-08-17 08:19:10 +00:00
|
|
|
|
|
|
|
void GERBVIEW_FRAME::unitsChangeRefresh()
|
2019-05-27 16:16:54 +00:00
|
|
|
{
|
|
|
|
// Called on units change (see EDA_DRAW_FRAME)
|
2016-08-17 08:19:10 +00:00
|
|
|
EDA_DRAW_FRAME::unitsChangeRefresh();
|
|
|
|
updateDCodeSelectBox();
|
2020-06-14 15:08:47 +00:00
|
|
|
UpdateGridSelectBox();
|
2016-09-26 17:15:33 +00:00
|
|
|
}
|
2017-09-17 22:43:20 +00:00
|
|
|
|
|
|
|
|
2019-05-30 12:25:08 +00:00
|
|
|
void GERBVIEW_FRAME::ActivateGalCanvas()
|
2017-09-17 22:43:20 +00:00
|
|
|
{
|
2019-05-30 12:25:08 +00:00
|
|
|
EDA_DRAW_FRAME::ActivateGalCanvas();
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
EDA_DRAW_PANEL_GAL* galCanvas = GetCanvas();
|
2017-09-17 22:43:20 +00:00
|
|
|
|
|
|
|
if( m_toolManager )
|
2019-05-28 13:51:47 +00:00
|
|
|
{
|
2019-06-13 17:28:55 +00:00
|
|
|
m_toolManager->SetEnvironment( m_gerberLayout, GetCanvas()->GetView(),
|
2020-06-12 10:58:56 +00:00
|
|
|
GetCanvas()->GetViewControls(), config(), this );
|
2019-05-28 13:51:47 +00:00
|
|
|
m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
|
2017-09-17 22:43:20 +00:00
|
|
|
}
|
|
|
|
|
2019-05-28 13:51:47 +00:00
|
|
|
galCanvas->GetGAL()->SetGridColor( GetLayerColor( LAYER_GERBVIEW_GRID ) );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2019-05-28 13:51:47 +00:00
|
|
|
SetPageSettings( GetPageSettings() );
|
|
|
|
|
|
|
|
galCanvas->GetView()->RecacheAllItems();
|
|
|
|
galCanvas->SetEventDispatcher( m_toolDispatcher );
|
|
|
|
galCanvas->StartDrawing();
|
2017-09-17 22:43:20 +00:00
|
|
|
|
|
|
|
m_LayersManager->ReFill();
|
|
|
|
m_LayersManager->ReFillRender();
|
|
|
|
|
|
|
|
ReCreateOptToolbar();
|
2018-03-13 21:59:46 +00:00
|
|
|
ReCreateMenuBar();
|
2017-09-17 22:43:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GERBVIEW_FRAME::setupTools()
|
|
|
|
{
|
|
|
|
// 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( m_gerberLayout, GetCanvas()->GetView(),
|
2020-06-12 10:58:56 +00:00
|
|
|
GetCanvas()->GetViewControls(), config(), this );
|
2017-09-17 22:43:20 +00:00
|
|
|
m_actions = new GERBVIEW_ACTIONS();
|
2021-03-27 20:02:34 +00:00
|
|
|
m_toolDispatcher = new TOOL_DISPATCHER( m_toolManager );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
|
|
|
// Register tools
|
2019-06-09 21:57:23 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_CONTROL );
|
2019-05-04 11:23:04 +00:00
|
|
|
m_toolManager->RegisterTool( new COMMON_TOOLS );
|
|
|
|
m_toolManager->RegisterTool( new GERBVIEW_SELECTION_TOOL );
|
|
|
|
m_toolManager->RegisterTool( new GERBVIEW_CONTROL );
|
2020-10-08 22:59:16 +00:00
|
|
|
m_toolManager->RegisterTool( new GERBVIEW_INSPECTION_TOOL );
|
2019-05-04 11:23:04 +00:00
|
|
|
m_toolManager->RegisterTool( new ZOOM_TOOL );
|
2017-09-17 22:43:20 +00:00
|
|
|
m_toolManager->InitTools();
|
|
|
|
|
|
|
|
// Run the selection tool, it is supposed to be always active
|
|
|
|
m_toolManager->InvokeTool( "gerbview.InteractiveSelection" );
|
|
|
|
}
|
|
|
|
|
2018-01-08 04:05:03 +00:00
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
void GERBVIEW_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
|
|
|
|
2022-03-24 14:10:47 +00:00
|
|
|
mgr->SetConditions( ACTIONS::zoomTool, CHECK( cond.CurrentTool( ACTIONS::zoomTool ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::selectionTool, CHECK( cond.CurrentTool( ACTIONS::selectionTool ) ) );
|
|
|
|
mgr->SetConditions( ACTIONS::measureTool, CHECK( cond.CurrentTool( ACTIONS::measureTool ) ) );
|
2020-07-29 23:50:25 +00:00
|
|
|
|
2022-03-24 14:10:47 +00:00
|
|
|
mgr->SetConditions( ACTIONS::toggleGrid, CHECK( cond.GridVisible() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::togglePolarCoords, CHECK( cond.PolarCoordinates() ) );
|
|
|
|
mgr->SetConditions( ACTIONS::toggleCursorStyle, CHECK( cond.FullscreenCursor() ) );
|
2020-07-29 23:50:25 +00:00
|
|
|
|
2022-03-24 14:10:47 +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
|
|
|
|
|
|
|
auto flashedDisplayOutlinesCond =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
return !gvconfig()->m_Display.m_DisplayFlashedItemsFill;
|
2020-07-29 23:50:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto linesFillCond =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
return !gvconfig()->m_Display.m_DisplayLinesFill;
|
2020-07-29 23:50:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto polygonsFilledCond =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
return !gvconfig()->m_Display.m_DisplayPolygonsFill;
|
2020-07-29 23:50:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto negativeObjectsCond =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
return gvconfig()->m_Appearance.show_negative_objects;
|
2020-07-29 23:50:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto dcodeCond =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
return gvconfig()->m_Appearance.show_dcodes;
|
2020-07-29 23:50:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto diffModeCond =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
return gvconfig()->m_Display.m_DiffMode;
|
2020-07-29 23:50:25 +00:00
|
|
|
};
|
|
|
|
|
2022-11-17 15:42:12 +00:00
|
|
|
auto xorModeCond =
|
2022-12-19 15:58:40 +00:00
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
|
|
|
return gvconfig()->m_Display.m_XORMode;
|
|
|
|
};
|
2022-11-17 15:42:12 +00:00
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
auto highContrastModeCond =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
return gvconfig()->m_Display.m_HighContrastMode;
|
2020-07-29 23:50:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
auto flipGerberCond =
|
|
|
|
[this] ( const SELECTION& )
|
|
|
|
{
|
2021-09-07 20:34:10 +00:00
|
|
|
return gvconfig()->m_Display.m_FlipGerberView;
|
2020-07-29 23:50:25 +00:00
|
|
|
};
|
|
|
|
|
2020-10-08 23:51:05 +00:00
|
|
|
auto layersManagerShownCondition =
|
|
|
|
[this] ( const SELECTION& aSel )
|
|
|
|
{
|
|
|
|
return m_show_layer_manager_tools;
|
|
|
|
};
|
|
|
|
|
2022-03-24 14:10:47 +00:00
|
|
|
mgr->SetConditions( GERBVIEW_ACTIONS::flashedDisplayOutlines, CHECK( flashedDisplayOutlinesCond ) );
|
2020-08-05 22:00:26 +00:00
|
|
|
mgr->SetConditions( GERBVIEW_ACTIONS::linesDisplayOutlines, CHECK( linesFillCond ) );
|
|
|
|
mgr->SetConditions( GERBVIEW_ACTIONS::polygonsDisplayOutlines, CHECK( polygonsFilledCond ) );
|
|
|
|
mgr->SetConditions( GERBVIEW_ACTIONS::negativeObjectDisplay, CHECK( negativeObjectsCond ) );
|
|
|
|
mgr->SetConditions( GERBVIEW_ACTIONS::dcodeDisplay, CHECK( dcodeCond ) );
|
|
|
|
mgr->SetConditions( GERBVIEW_ACTIONS::toggleDiffMode, CHECK( diffModeCond ) );
|
2022-11-17 15:42:12 +00:00
|
|
|
mgr->SetConditions( GERBVIEW_ACTIONS::toggleXORMode, CHECK( xorModeCond ) );
|
2020-08-05 22:00:26 +00:00
|
|
|
mgr->SetConditions( GERBVIEW_ACTIONS::flipGerberView, CHECK( flipGerberCond ) );
|
|
|
|
mgr->SetConditions( ACTIONS::highContrastMode, CHECK( highContrastModeCond ) );
|
2022-03-24 14:10:47 +00:00
|
|
|
mgr->SetConditions( GERBVIEW_ACTIONS::toggleLayerManager, CHECK( layersManagerShownCondition ) );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-07-17 20:04:14 +00:00
|
|
|
void GERBVIEW_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged )
|
2018-01-08 04:05:03 +00:00
|
|
|
{
|
2020-07-17 20:04:14 +00:00
|
|
|
EDA_DRAW_FRAME::CommonSettingsChanged( aEnvVarsChanged, aTextVarsChanged );
|
2018-01-08 04:05:03 +00:00
|
|
|
|
2022-12-29 16:33:41 +00:00
|
|
|
// Update gal display options like cursor shape, grid options:
|
|
|
|
GERBVIEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<GERBVIEW_SETTINGS>();
|
|
|
|
GetGalDisplayOptions().ReadWindowSettings( cfg->m_Window );
|
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
SetPageSettings( PAGE_INFO( gvconfig()->m_Appearance.page_type ) );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-11-17 15:42:12 +00:00
|
|
|
UpdateXORLayers();
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
SetElementVisibility( LAYER_DCODES, gvconfig()->m_Appearance.show_dcodes );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
|
|
|
GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
|
|
|
GetCanvas()->GetView()->UpdateAllItems( KIGFX::REPAINT );
|
|
|
|
GetCanvas()->ForceRefresh();
|
|
|
|
|
2019-07-20 15:52:30 +00:00
|
|
|
RecreateToolbars();
|
2022-09-10 18:16:08 +00:00
|
|
|
ReFillLayerWidget(); // Update the layers list
|
|
|
|
m_LayersManager->ReFillRender(); // Update colors in Render after the config is read
|
|
|
|
|
2018-01-08 04:05:03 +00:00
|
|
|
Layout();
|
|
|
|
SendSizeEvent();
|
|
|
|
}
|
2019-06-24 15:27:05 +00:00
|
|
|
|
2020-07-29 23:50:25 +00:00
|
|
|
|
|
|
|
SELECTION& GERBVIEW_FRAME::GetCurrentSelection()
|
|
|
|
{
|
|
|
|
return m_toolManager->GetTool<GERBVIEW_SELECTION_TOOL>()->GetSelection();
|
|
|
|
}
|
2020-10-08 23:51:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
void GERBVIEW_FRAME::ToggleLayerManager()
|
|
|
|
{
|
|
|
|
m_show_layer_manager_tools = !m_show_layer_manager_tools;
|
|
|
|
|
|
|
|
// show/hide auxiliary Vertical layers and visibility manager toolbar
|
|
|
|
m_auimgr.GetPane( "LayersManager" ).Show( m_show_layer_manager_tools );
|
|
|
|
m_auimgr.Update();
|
|
|
|
}
|