2014-07-09 08:57:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-03-02 22:57:13 +00:00
|
|
|
* Copyright (C) 2014-2017 CERN
|
2022-07-24 22:40:47 +00:00
|
|
|
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-07-09 08:57:32 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pcb_draw_panel_gal.h"
|
2017-10-30 19:17:23 +00:00
|
|
|
#include <pcb_view.h>
|
2014-07-09 08:57:32 +00:00
|
|
|
#include <view/wx_view_controls.h>
|
|
|
|
#include <pcb_painter.h>
|
2021-02-22 23:47:17 +00:00
|
|
|
#include <drawing_sheet/ds_proxy_view_item.h>
|
2018-10-12 06:17:15 +00:00
|
|
|
#include <connectivity/connectivity_data.h>
|
2014-07-09 08:57:32 +00:00
|
|
|
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
|
|
|
#include <footprint.h>
|
2021-06-11 21:07:02 +00:00
|
|
|
#include <pcb_track.h>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <macros.h>
|
2020-11-14 18:11:28 +00:00
|
|
|
#include <pcb_marker.h>
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2020-04-24 01:55:20 +00:00
|
|
|
#include <pcbnew_settings.h>
|
2020-06-16 18:15:14 +00:00
|
|
|
#include <ratsnest/ratsnest_data.h>
|
2021-02-22 23:47:17 +00:00
|
|
|
#include <ratsnest/ratsnest_view_item.h>
|
2020-06-16 18:15:14 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2018-01-17 07:58:44 +00:00
|
|
|
#include <confirm.h>
|
2021-11-25 16:19:03 +00:00
|
|
|
#include <progress_reporter.h>
|
2014-07-09 08:57:32 +00:00
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2020-12-02 17:33:59 +00:00
|
|
|
#include <zoom_defines.h>
|
2017-08-04 12:43:02 +00:00
|
|
|
|
2016-06-29 10:23:11 +00:00
|
|
|
#include <functional>
|
2019-12-05 13:43:55 +00:00
|
|
|
#include <memory>
|
2018-12-20 05:15:53 +00:00
|
|
|
#include <thread>
|
2020-12-02 17:33:59 +00:00
|
|
|
|
2016-06-29 10:23:11 +00:00
|
|
|
using namespace std::placeholders;
|
2014-07-09 08:57:32 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
const int GAL_LAYER_ORDER[] =
|
2014-07-09 08:57:32 +00:00
|
|
|
{
|
2017-04-25 09:47:21 +00:00
|
|
|
LAYER_GP_OVERLAY,
|
2018-08-28 21:57:31 +00:00
|
|
|
LAYER_SELECT_OVERLAY,
|
2022-05-20 09:08:33 +00:00
|
|
|
LAYER_CONFLICTS_SHADOW,
|
2020-10-12 22:24:35 +00:00
|
|
|
LAYER_DRC_ERROR, LAYER_DRC_WARNING, LAYER_DRC_EXCLUSION, LAYER_MARKER_SHADOWS,
|
2021-01-30 14:41:31 +00:00
|
|
|
LAYER_PAD_NETNAMES, LAYER_VIA_NETNAMES,
|
|
|
|
Dwgs_User,
|
|
|
|
Cmts_User,
|
|
|
|
Eco1_User, Eco2_User,
|
2021-02-13 15:40:09 +00:00
|
|
|
Edge_Cuts, Margin,
|
2021-01-30 14:41:31 +00:00
|
|
|
|
|
|
|
User_1, ZONE_LAYER_FOR( User_1 ),
|
|
|
|
User_2, ZONE_LAYER_FOR( User_2 ),
|
|
|
|
User_3, ZONE_LAYER_FOR( User_3 ),
|
|
|
|
User_4, ZONE_LAYER_FOR( User_4 ),
|
|
|
|
User_5, ZONE_LAYER_FOR( User_5 ),
|
|
|
|
User_6, ZONE_LAYER_FOR( User_6 ),
|
|
|
|
User_7, ZONE_LAYER_FOR( User_7 ),
|
|
|
|
User_8, ZONE_LAYER_FOR( User_8 ),
|
2020-09-26 03:10:52 +00:00
|
|
|
User_9, ZONE_LAYER_FOR( User_9 ),
|
|
|
|
|
2021-10-22 20:12:57 +00:00
|
|
|
LAYER_MOD_TEXT, LAYER_MOD_REFERENCES, LAYER_MOD_VALUES,
|
2017-03-13 03:19:33 +00:00
|
|
|
|
2021-01-30 14:41:31 +00:00
|
|
|
LAYER_RATSNEST,
|
|
|
|
LAYER_ANCHOR,
|
2022-03-06 19:11:03 +00:00
|
|
|
LAYER_LOCKED_ITEM_SHADOW,
|
2021-01-30 14:41:31 +00:00
|
|
|
LAYER_VIA_HOLES, LAYER_VIA_HOLEWALLS,
|
|
|
|
LAYER_PAD_PLATEDHOLES, LAYER_PAD_HOLEWALLS, LAYER_NON_PLATEDHOLES,
|
|
|
|
LAYER_VIA_THROUGH, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA,
|
|
|
|
LAYER_PADS_TH,
|
2017-03-13 03:19:33 +00:00
|
|
|
|
2017-04-01 22:55:35 +00:00
|
|
|
LAYER_PAD_FR_NETNAMES, LAYER_PAD_FR,
|
2020-07-11 17:42:00 +00:00
|
|
|
NETNAMES_LAYER_INDEX( F_Cu ), F_Cu, ZONE_LAYER_FOR( F_Cu ),
|
2020-09-26 03:10:52 +00:00
|
|
|
F_Mask, ZONE_LAYER_FOR( F_Mask ),
|
|
|
|
F_SilkS, ZONE_LAYER_FOR( F_SilkS ),
|
|
|
|
F_Paste, ZONE_LAYER_FOR( F_Paste ),
|
|
|
|
F_Adhes, ZONE_LAYER_FOR( F_Adhes ),
|
|
|
|
F_CrtYd, ZONE_LAYER_FOR( F_CrtYd ),
|
|
|
|
F_Fab, ZONE_LAYER_FOR( F_Fab ),
|
2020-07-11 17:42:00 +00:00
|
|
|
|
|
|
|
NETNAMES_LAYER_INDEX( In1_Cu ), In1_Cu, ZONE_LAYER_FOR( In1_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In2_Cu ), In2_Cu, ZONE_LAYER_FOR( In2_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In3_Cu ), In3_Cu, ZONE_LAYER_FOR( In3_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In4_Cu ), In4_Cu, ZONE_LAYER_FOR( In4_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In5_Cu ), In5_Cu, ZONE_LAYER_FOR( In5_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In6_Cu ), In6_Cu, ZONE_LAYER_FOR( In6_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In7_Cu ), In7_Cu, ZONE_LAYER_FOR( In7_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In8_Cu ), In8_Cu, ZONE_LAYER_FOR( In8_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In9_Cu ), In9_Cu, ZONE_LAYER_FOR( In9_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In10_Cu ), In10_Cu, ZONE_LAYER_FOR( In10_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In11_Cu ), In11_Cu, ZONE_LAYER_FOR( In11_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In12_Cu ), In12_Cu, ZONE_LAYER_FOR( In12_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In13_Cu ), In13_Cu, ZONE_LAYER_FOR( In13_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In14_Cu ), In14_Cu, ZONE_LAYER_FOR( In14_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In15_Cu ), In15_Cu, ZONE_LAYER_FOR( In15_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In16_Cu ), In16_Cu, ZONE_LAYER_FOR( In16_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In17_Cu ), In17_Cu, ZONE_LAYER_FOR( In17_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In18_Cu ), In18_Cu, ZONE_LAYER_FOR( In18_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In19_Cu ), In19_Cu, ZONE_LAYER_FOR( In19_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In20_Cu ), In20_Cu, ZONE_LAYER_FOR( In20_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In21_Cu ), In21_Cu, ZONE_LAYER_FOR( In21_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In22_Cu ), In22_Cu, ZONE_LAYER_FOR( In22_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In23_Cu ), In23_Cu, ZONE_LAYER_FOR( In23_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In24_Cu ), In24_Cu, ZONE_LAYER_FOR( In24_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In25_Cu ), In25_Cu, ZONE_LAYER_FOR( In25_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In26_Cu ), In26_Cu, ZONE_LAYER_FOR( In26_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In27_Cu ), In27_Cu, ZONE_LAYER_FOR( In27_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In28_Cu ), In28_Cu, ZONE_LAYER_FOR( In28_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In29_Cu ), In29_Cu, ZONE_LAYER_FOR( In29_Cu ),
|
|
|
|
NETNAMES_LAYER_INDEX( In30_Cu ), In30_Cu, ZONE_LAYER_FOR( In30_Cu ),
|
2017-03-13 03:19:33 +00:00
|
|
|
|
2017-04-01 22:55:35 +00:00
|
|
|
LAYER_PAD_BK_NETNAMES, LAYER_PAD_BK,
|
2020-07-11 17:42:00 +00:00
|
|
|
NETNAMES_LAYER_INDEX( B_Cu ), B_Cu, ZONE_LAYER_FOR( B_Cu ),
|
2020-09-26 03:10:52 +00:00
|
|
|
B_Mask, ZONE_LAYER_FOR( B_Mask ),
|
|
|
|
B_SilkS, ZONE_LAYER_FOR( B_SilkS ),
|
|
|
|
B_Paste, ZONE_LAYER_FOR( B_Paste ),
|
|
|
|
B_Adhes, ZONE_LAYER_FOR( B_Adhes ),
|
|
|
|
B_CrtYd, ZONE_LAYER_FOR( B_CrtYd ),
|
|
|
|
B_Fab, ZONE_LAYER_FOR( B_Fab ),
|
2017-03-13 03:19:33 +00:00
|
|
|
|
2022-06-27 18:07:52 +00:00
|
|
|
BITMAP_LAYER_FOR( Dwgs_User ),
|
|
|
|
BITMAP_LAYER_FOR( Cmts_User ),
|
|
|
|
BITMAP_LAYER_FOR( Eco1_User ), BITMAP_LAYER_FOR( Eco2_User ),
|
|
|
|
BITMAP_LAYER_FOR( Edge_Cuts ), BITMAP_LAYER_FOR( Margin ),
|
|
|
|
|
|
|
|
BITMAP_LAYER_FOR( User_1 ),
|
|
|
|
BITMAP_LAYER_FOR( User_2 ),
|
|
|
|
BITMAP_LAYER_FOR( User_3 ),
|
|
|
|
BITMAP_LAYER_FOR( User_4 ),
|
|
|
|
BITMAP_LAYER_FOR( User_5 ),
|
|
|
|
BITMAP_LAYER_FOR( User_6 ),
|
|
|
|
BITMAP_LAYER_FOR( User_7 ),
|
|
|
|
BITMAP_LAYER_FOR( User_8 ),
|
|
|
|
BITMAP_LAYER_FOR( User_9 ),
|
|
|
|
|
|
|
|
BITMAP_LAYER_FOR( F_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( F_Mask ),
|
|
|
|
BITMAP_LAYER_FOR( F_SilkS ),
|
|
|
|
BITMAP_LAYER_FOR( F_Paste ),
|
|
|
|
BITMAP_LAYER_FOR( F_Adhes ),
|
|
|
|
BITMAP_LAYER_FOR( F_CrtYd ),
|
|
|
|
BITMAP_LAYER_FOR( F_Fab ),
|
|
|
|
|
|
|
|
BITMAP_LAYER_FOR( In1_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In2_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In3_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In4_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In5_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In6_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In7_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In8_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In9_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In10_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In11_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In12_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In13_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In14_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In15_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In16_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In17_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In18_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In19_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In20_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In21_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In22_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In23_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In24_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In25_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In26_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In27_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In28_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In29_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( In30_Cu ),
|
|
|
|
|
|
|
|
BITMAP_LAYER_FOR( B_Cu ),
|
|
|
|
BITMAP_LAYER_FOR( B_Mask ),
|
|
|
|
BITMAP_LAYER_FOR( B_SilkS ),
|
|
|
|
BITMAP_LAYER_FOR( B_Paste ),
|
|
|
|
BITMAP_LAYER_FOR( B_Adhes ),
|
|
|
|
BITMAP_LAYER_FOR( B_CrtYd ),
|
|
|
|
BITMAP_LAYER_FOR( B_Fab ),
|
|
|
|
|
2021-02-22 16:37:43 +00:00
|
|
|
LAYER_DRAWINGSHEET
|
2014-07-09 08:57:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindowId,
|
|
|
|
const wxPoint& aPosition, const wxSize& aSize,
|
2017-01-02 06:13:45 +00:00
|
|
|
KIGFX::GAL_DISPLAY_OPTIONS& aOptions, GAL_TYPE aGalType ) :
|
2018-07-29 15:33:58 +00:00
|
|
|
EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalType )
|
2014-07-09 08:57:32 +00:00
|
|
|
{
|
2017-10-30 19:17:23 +00:00
|
|
|
m_view = new KIGFX::PCB_VIEW( true );
|
|
|
|
m_view->SetGAL( m_gal );
|
2014-07-09 08:57:32 +00:00
|
|
|
|
2022-07-24 22:40:47 +00:00
|
|
|
FRAME_T frameType = FRAME_FOOTPRINT_PREVIEW;
|
|
|
|
|
|
|
|
if( EDA_BASE_FRAME* frame = dynamic_cast<EDA_BASE_FRAME*>( aParentWindow ) )
|
|
|
|
frameType = frame->GetFrameType();
|
|
|
|
|
|
|
|
m_painter = std::make_unique<KIGFX::PCB_PAINTER>( m_gal, frameType );
|
2017-10-30 08:36:31 +00:00
|
|
|
m_view->SetPainter( m_painter.get() );
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-12-02 17:33:59 +00:00
|
|
|
// This fixes the zoom in and zoom out limits:
|
|
|
|
m_view->SetScaleLimits( ZOOM_MAX_LIMIT_PCBNEW, ZOOM_MIN_LIMIT_PCBNEW );
|
2017-02-16 02:06:05 +00:00
|
|
|
|
2017-10-30 19:17:23 +00:00
|
|
|
setDefaultLayerOrder();
|
|
|
|
setDefaultLayerDeps();
|
|
|
|
|
|
|
|
// View controls is the first in the event handler chain, so the Tool Framework operates
|
|
|
|
// on updated viewport data.
|
|
|
|
m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
|
|
|
|
|
2015-01-10 10:27:49 +00:00
|
|
|
// Load display options (such as filled/outline display of items).
|
2015-06-18 15:51:53 +00:00
|
|
|
// Can be made only if the parent window is an EDA_DRAW_FRAME (or a derived class)
|
2015-01-10 10:27:49 +00:00
|
|
|
// which is not always the case (namely when it is used from a wxDialog like the pad editor)
|
2020-09-02 20:56:31 +00:00
|
|
|
if( !IsDialogPreview() )
|
|
|
|
{
|
|
|
|
KIGFX::PCB_VIEW* view = static_cast<KIGFX::PCB_VIEW*>( m_view );
|
|
|
|
PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
|
2015-01-10 10:27:49 +00:00
|
|
|
|
2020-09-02 20:56:31 +00:00
|
|
|
if( frame )
|
|
|
|
view->UpdateDisplayOptions( frame->GetDisplayOptions() );
|
|
|
|
}
|
2014-07-09 08:57:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PCB_DRAW_PANEL_GAL::~PCB_DRAW_PANEL_GAL()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-25 16:19:03 +00:00
|
|
|
void PCB_DRAW_PANEL_GAL::DisplayBoard( BOARD* aBoard, PROGRESS_REPORTER* aReporter )
|
2014-07-09 08:57:32 +00:00
|
|
|
{
|
|
|
|
m_view->Clear();
|
|
|
|
|
2022-02-15 13:41:13 +00:00
|
|
|
aBoard->CacheTriangulation( aReporter );
|
2014-07-09 08:57:32 +00:00
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
if( m_drawingSheet )
|
|
|
|
m_drawingSheet->SetFileName( TO_UTF8( aBoard->GetFileName() ) );
|
2018-11-19 09:21:28 +00:00
|
|
|
|
2014-07-09 08:57:32 +00:00
|
|
|
// Load drawings
|
2020-11-13 02:57:11 +00:00
|
|
|
for( BOARD_ITEM* drawing : aBoard->Drawings() )
|
2014-07-09 08:57:32 +00:00
|
|
|
m_view->Add( drawing );
|
|
|
|
|
|
|
|
// Load tracks
|
2021-06-11 21:07:02 +00:00
|
|
|
for( PCB_TRACK* track : aBoard->Tracks() )
|
2014-07-09 08:57:32 +00:00
|
|
|
m_view->Add( track );
|
|
|
|
|
2020-10-21 03:48:06 +00:00
|
|
|
// Load footprints and its additional elements
|
2020-11-13 15:15:52 +00:00
|
|
|
for( FOOTPRINT* footprint : aBoard->Footprints() )
|
2020-11-13 02:57:11 +00:00
|
|
|
m_view->Add( footprint );
|
2014-07-09 08:57:32 +00:00
|
|
|
|
2017-11-29 02:57:28 +00:00
|
|
|
// DRC markers
|
2020-11-14 18:11:28 +00:00
|
|
|
for( PCB_MARKER* marker : aBoard->Markers() )
|
2020-02-28 00:05:40 +00:00
|
|
|
m_view->Add( marker );
|
2017-11-29 02:57:28 +00:00
|
|
|
|
2018-09-12 09:22:01 +00:00
|
|
|
// Load zones
|
2020-11-13 02:57:11 +00:00
|
|
|
for( ZONE* zone : aBoard->Zones() )
|
2018-09-12 09:22:01 +00:00
|
|
|
m_view->Add( zone );
|
|
|
|
|
2014-07-09 08:57:32 +00:00
|
|
|
// Ratsnest
|
2021-02-22 23:47:17 +00:00
|
|
|
m_ratsnest = std::make_unique<RATSNEST_VIEW_ITEM>( aBoard->GetConnectivity() );
|
2017-03-02 22:57:13 +00:00
|
|
|
m_view->Add( m_ratsnest.get() );
|
2014-07-09 08:57:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-22 23:47:17 +00:00
|
|
|
void PCB_DRAW_PANEL_GAL::SetDrawingSheet( DS_PROXY_VIEW_ITEM* aDrawingSheet )
|
2014-07-09 08:57:32 +00:00
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
m_drawingSheet.reset( aDrawingSheet );
|
|
|
|
m_view->Add( m_drawingSheet.get() );
|
2014-07-09 08:57:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void PCB_DRAW_PANEL_GAL::UpdateColors()
|
2014-07-09 09:22:42 +00:00
|
|
|
{
|
2020-04-24 01:55:20 +00:00
|
|
|
COLOR_SETTINGS* cs = nullptr;
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-09-02 20:56:31 +00:00
|
|
|
PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2020-04-24 01:55:20 +00:00
|
|
|
if( frame )
|
2020-05-06 01:45:48 +00:00
|
|
|
{
|
2020-05-16 17:15:43 +00:00
|
|
|
cs = frame->GetColorSettings();
|
2020-05-06 01:45:48 +00:00
|
|
|
}
|
2020-04-24 01:55:20 +00:00
|
|
|
else
|
2020-05-06 01:45:48 +00:00
|
|
|
{
|
|
|
|
PCBNEW_SETTINGS* app = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
|
2020-04-24 01:55:20 +00:00
|
|
|
|
2020-05-06 01:45:48 +00:00
|
|
|
if( app )
|
|
|
|
cs = Pgm().GetSettingsManager().GetColorSettings( app->m_ColorTheme );
|
|
|
|
else
|
|
|
|
cs = Pgm().GetSettingsManager().GetColorSettings();
|
|
|
|
}
|
2020-04-24 01:55:20 +00:00
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
wxCHECK_RET( cs, wxT( "null COLOR_SETTINGS" ) );
|
2014-07-09 09:22:42 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
auto rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( m_view->GetPainter()->GetSettings() );
|
|
|
|
rs->LoadColors( cs );
|
|
|
|
|
|
|
|
m_gal->SetGridColor( cs->GetColor( LAYER_GRID ) );
|
2020-10-14 01:26:56 +00:00
|
|
|
m_gal->SetAxesColor( cs->GetColor( LAYER_GRID_AXES ) );
|
2020-01-13 01:44:19 +00:00
|
|
|
m_gal->SetCursorColor( cs->GetColor( LAYER_CURSOR ) );
|
|
|
|
}
|
2014-07-09 09:22:42 +00:00
|
|
|
|
2020-04-24 01:55:20 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
void PCB_DRAW_PANEL_GAL::SetHighContrastLayer( PCB_LAYER_ID aLayer )
|
2014-07-09 08:57:32 +00:00
|
|
|
{
|
|
|
|
// Set display settings for high contrast mode
|
|
|
|
KIGFX::RENDER_SETTINGS* rSettings = m_view->GetPainter()->GetSettings();
|
|
|
|
|
|
|
|
SetTopLayer( aLayer );
|
|
|
|
rSettings->SetActiveLayer( aLayer );
|
|
|
|
|
2020-10-03 21:26:44 +00:00
|
|
|
rSettings->ClearHighContrastLayers();
|
|
|
|
rSettings->SetLayerIsHighContrast( aLayer );
|
|
|
|
|
2014-07-09 08:57:32 +00:00
|
|
|
if( IsCopperLayer( aLayer ) )
|
|
|
|
{
|
|
|
|
// Bring some other layers to the front in case of copper layers and make them colored
|
|
|
|
// fixme do not like the idea of storing the list of layers here,
|
|
|
|
// should be done in some other way I guess..
|
2021-07-21 23:14:56 +00:00
|
|
|
int layers[] = {
|
2022-05-20 09:08:33 +00:00
|
|
|
LAYER_CONFLICTS_SHADOW,
|
2021-01-30 14:41:31 +00:00
|
|
|
GetNetnameLayer( aLayer ), LAYER_VIA_NETNAMES,
|
|
|
|
LAYER_PAD_FR_NETNAMES, LAYER_PAD_BK_NETNAMES, LAYER_PAD_NETNAMES,
|
2020-07-11 17:42:00 +00:00
|
|
|
ZONE_LAYER_FOR( aLayer ),
|
2022-06-27 18:07:52 +00:00
|
|
|
BITMAP_LAYER_FOR( aLayer ),
|
2021-01-30 14:41:31 +00:00
|
|
|
LAYER_PADS_TH, LAYER_PAD_PLATEDHOLES, LAYER_PAD_HOLEWALLS, LAYER_NON_PLATEDHOLES,
|
2021-07-19 23:56:05 +00:00
|
|
|
LAYER_VIA_THROUGH, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, LAYER_VIA_HOLES,
|
|
|
|
LAYER_VIA_HOLEWALLS,
|
2020-11-03 17:28:09 +00:00
|
|
|
LAYER_DRC_ERROR, LAYER_DRC_WARNING, LAYER_DRC_EXCLUSION, LAYER_MARKER_SHADOWS,
|
|
|
|
LAYER_SELECT_OVERLAY, LAYER_GP_OVERLAY,
|
2022-03-06 19:11:03 +00:00
|
|
|
LAYER_RATSNEST, LAYER_CURSOR, LAYER_ANCHOR, LAYER_LOCKED_ITEM_SHADOW
|
2014-07-09 08:57:32 +00:00
|
|
|
};
|
|
|
|
|
2019-05-20 10:23:32 +00:00
|
|
|
for( unsigned int i : layers )
|
2020-10-03 21:26:44 +00:00
|
|
|
rSettings->SetLayerIsHighContrast( i );
|
2014-07-09 08:57:32 +00:00
|
|
|
|
|
|
|
// Pads should be shown too
|
|
|
|
if( aLayer == B_Cu )
|
|
|
|
{
|
2020-10-03 21:26:44 +00:00
|
|
|
rSettings->SetLayerIsHighContrast( LAYER_PAD_BK );
|
|
|
|
rSettings->SetLayerIsHighContrast( LAYER_MOD_BK );
|
2014-07-09 08:57:32 +00:00
|
|
|
}
|
|
|
|
else if( aLayer == F_Cu )
|
|
|
|
{
|
2020-10-03 21:26:44 +00:00
|
|
|
rSettings->SetLayerIsHighContrast( LAYER_PAD_FR );
|
|
|
|
rSettings->SetLayerIsHighContrast( LAYER_MOD_FR );
|
2014-07-09 08:57:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_view->UpdateAllLayersColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
void PCB_DRAW_PANEL_GAL::SetTopLayer( PCB_LAYER_ID aLayer )
|
2014-07-09 08:57:32 +00:00
|
|
|
{
|
|
|
|
m_view->ClearTopLayers();
|
2015-09-05 17:00:54 +00:00
|
|
|
setDefaultLayerOrder();
|
2014-07-09 08:57:32 +00:00
|
|
|
m_view->SetTopLayer( aLayer );
|
|
|
|
|
2015-09-06 10:58:46 +00:00
|
|
|
// Layers that should always have on-top attribute enabled
|
2021-07-21 23:14:56 +00:00
|
|
|
const std::vector<int> layers = {
|
2021-07-19 23:56:05 +00:00
|
|
|
LAYER_VIA_THROUGH, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, LAYER_VIA_HOLES,
|
|
|
|
LAYER_VIA_HOLEWALLS,
|
2021-01-30 14:41:31 +00:00
|
|
|
LAYER_VIA_NETNAMES,
|
|
|
|
LAYER_PADS_TH, LAYER_PAD_PLATEDHOLES, LAYER_PAD_HOLEWALLS, LAYER_NON_PLATEDHOLES,
|
|
|
|
LAYER_PAD_NETNAMES,
|
2020-11-03 17:28:09 +00:00
|
|
|
LAYER_SELECT_OVERLAY, LAYER_GP_OVERLAY,
|
|
|
|
LAYER_RATSNEST,
|
|
|
|
LAYER_DRC_ERROR, LAYER_DRC_WARNING, LAYER_DRC_EXCLUSION, LAYER_MARKER_SHADOWS
|
2015-09-06 10:58:46 +00:00
|
|
|
};
|
2014-07-09 08:57:32 +00:00
|
|
|
|
2019-02-03 08:42:04 +00:00
|
|
|
for( auto layer : layers )
|
|
|
|
m_view->SetTopLayer( layer );
|
2014-07-09 08:57:32 +00:00
|
|
|
|
2015-09-06 10:58:46 +00:00
|
|
|
// Extra layers that are brought to the top if a F.* or B.* is selected
|
2021-07-21 23:14:56 +00:00
|
|
|
const std::vector<int> frontLayers = {
|
2019-05-27 15:51:27 +00:00
|
|
|
F_Cu, F_Adhes, F_Paste, F_SilkS, F_Mask, F_Fab, F_CrtYd, LAYER_PAD_FR,
|
2020-09-26 03:10:52 +00:00
|
|
|
LAYER_PAD_FR_NETNAMES, NETNAMES_LAYER_INDEX( F_Cu )
|
2015-09-05 17:00:54 +00:00
|
|
|
};
|
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
const std::vector<int> backLayers = {
|
2019-05-27 15:51:27 +00:00
|
|
|
B_Cu, B_Adhes, B_Paste, B_SilkS, B_Mask, B_Fab, B_CrtYd, LAYER_PAD_BK,
|
2020-09-26 03:10:52 +00:00
|
|
|
LAYER_PAD_BK_NETNAMES, NETNAMES_LAYER_INDEX( B_Cu )
|
2015-09-05 17:00:54 +00:00
|
|
|
};
|
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
const std::vector<int>* extraLayers = nullptr;
|
2015-09-05 17:00:54 +00:00
|
|
|
|
|
|
|
// Bring a few more extra layers to the top depending on the selected board side
|
|
|
|
if( IsFrontLayer( aLayer ) )
|
2019-02-03 08:42:04 +00:00
|
|
|
extraLayers = &frontLayers;
|
2015-09-05 17:00:54 +00:00
|
|
|
else if( IsBackLayer( aLayer ) )
|
2019-02-03 08:42:04 +00:00
|
|
|
extraLayers = &backLayers;
|
2015-09-05 17:00:54 +00:00
|
|
|
|
|
|
|
if( extraLayers )
|
|
|
|
{
|
2019-02-03 08:42:04 +00:00
|
|
|
for( auto layer : *extraLayers )
|
2020-09-26 03:10:52 +00:00
|
|
|
{
|
2019-02-03 08:42:04 +00:00
|
|
|
m_view->SetTopLayer( layer );
|
2015-09-05 17:00:54 +00:00
|
|
|
|
2020-09-26 03:10:52 +00:00
|
|
|
if( layer < PCB_LAYER_ID_COUNT )
|
|
|
|
m_view->SetTopLayer( ZONE_LAYER_FOR( layer ) );
|
|
|
|
}
|
|
|
|
|
2020-12-24 03:09:09 +00:00
|
|
|
// Move the active layer to the top of the stack but below all the overlay layers
|
2015-09-05 17:00:54 +00:00
|
|
|
if( !IsCopperLayer( aLayer ) )
|
2020-09-26 03:10:52 +00:00
|
|
|
{
|
2020-12-24 03:09:09 +00:00
|
|
|
m_view->SetLayerOrder( aLayer, m_view->GetLayerOrder( LAYER_MARKER_SHADOWS ) + 1 );
|
2020-09-26 03:10:52 +00:00
|
|
|
m_view->SetLayerOrder( ZONE_LAYER_FOR( aLayer ),
|
2020-12-24 03:09:09 +00:00
|
|
|
m_view->GetLayerOrder( LAYER_MARKER_SHADOWS ) + 2 );
|
2020-12-29 23:31:44 +00:00
|
|
|
|
|
|
|
// Fix up pad and via netnames to be below. This is hacky, we need a rethink
|
|
|
|
// of layer ordering...
|
2021-01-30 14:41:31 +00:00
|
|
|
m_view->SetLayerOrder( LAYER_PAD_NETNAMES,
|
2020-12-29 23:31:44 +00:00
|
|
|
m_view->GetLayerOrder( LAYER_MARKER_SHADOWS ) + 3 );
|
2021-01-30 14:41:31 +00:00
|
|
|
m_view->SetLayerOrder( LAYER_VIA_NETNAMES,
|
2020-12-29 23:31:44 +00:00
|
|
|
m_view->GetLayerOrder( LAYER_MARKER_SHADOWS ) + 4 );
|
2020-09-26 03:10:52 +00:00
|
|
|
}
|
2015-09-06 10:58:46 +00:00
|
|
|
}
|
2021-10-24 10:14:54 +00:00
|
|
|
|
|
|
|
if( IsCopperLayer( aLayer ) )
|
2015-09-06 10:58:46 +00:00
|
|
|
{
|
2021-10-24 10:14:54 +00:00
|
|
|
m_view->SetTopLayer( ZONE_LAYER_FOR( aLayer ) );
|
|
|
|
|
2015-09-06 10:58:46 +00:00
|
|
|
// Display labels for copper layers on the top
|
|
|
|
m_view->SetTopLayer( GetNetnameLayer( aLayer ) );
|
2020-09-26 03:10:52 +00:00
|
|
|
}
|
2014-07-09 08:57:32 +00:00
|
|
|
|
2022-06-27 18:07:52 +00:00
|
|
|
m_view->SetTopLayer( BITMAP_LAYER_FOR( aLayer ) );
|
2019-02-03 10:21:28 +00:00
|
|
|
m_view->EnableTopLayer( true );
|
2014-07-09 08:57:32 +00:00
|
|
|
m_view->UpdateAllLayersOrder();
|
|
|
|
}
|
2014-07-09 09:24:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PCB_DRAW_PANEL_GAL::SyncLayersVisibility( const BOARD* aBoard )
|
|
|
|
{
|
|
|
|
// Load layer & elements visibility settings
|
2021-07-21 23:14:56 +00:00
|
|
|
for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
|
2017-03-13 03:19:33 +00:00
|
|
|
m_view->SetLayerVisible( i, aBoard->IsLayerVisible( PCB_LAYER_ID( i ) ) );
|
2014-07-09 09:24:56 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
for( GAL_LAYER_ID i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; ++i )
|
2017-04-01 22:55:35 +00:00
|
|
|
m_view->SetLayerVisible( i, aBoard->IsElementVisible( i ) );
|
2018-01-19 09:02:56 +00:00
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
// Via layers controlled by dependencies
|
|
|
|
m_view->SetLayerVisible( LAYER_VIA_MICROVIA, true );
|
|
|
|
m_view->SetLayerVisible( LAYER_VIA_BBLIND, true );
|
|
|
|
m_view->SetLayerVisible( LAYER_VIA_THROUGH, true );
|
|
|
|
|
|
|
|
// Pad layers controlled by dependencies
|
|
|
|
m_view->SetLayerVisible( LAYER_PAD_FR, true );
|
|
|
|
m_view->SetLayerVisible( LAYER_PAD_BK, true );
|
|
|
|
|
2018-01-19 09:02:56 +00:00
|
|
|
// Always enable netname layers, as their visibility is controlled by layer dependencies
|
2021-07-21 23:14:56 +00:00
|
|
|
for( int i = NETNAMES_LAYER_ID_START; i < NETNAMES_LAYER_ID_END; ++i )
|
2018-01-19 09:02:56 +00:00
|
|
|
m_view->SetLayerVisible( i, true );
|
2014-07-09 09:24:56 +00:00
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
for( int i = LAYER_ZONE_START; i < LAYER_ZONE_END; i++ )
|
2020-07-11 17:42:00 +00:00
|
|
|
m_view->SetLayerVisible( i, true );
|
|
|
|
|
2022-06-27 18:07:52 +00:00
|
|
|
for( int i = LAYER_BITMAP_START; i < LAYER_BITMAP_END; i++ )
|
|
|
|
m_view->SetLayerVisible( i, true );
|
|
|
|
|
2014-07-09 09:24:56 +00:00
|
|
|
// Enable some layers that are GAL specific
|
2021-01-30 14:41:31 +00:00
|
|
|
m_view->SetLayerVisible( LAYER_PAD_PLATEDHOLES, true );
|
|
|
|
m_view->SetLayerVisible( LAYER_PAD_HOLEWALLS, true );
|
|
|
|
m_view->SetLayerVisible( LAYER_VIA_HOLES, true );
|
|
|
|
m_view->SetLayerVisible( LAYER_VIA_HOLEWALLS, true );
|
2017-04-01 22:55:35 +00:00
|
|
|
m_view->SetLayerVisible( LAYER_GP_OVERLAY, true );
|
2018-08-28 21:57:31 +00:00
|
|
|
m_view->SetLayerVisible( LAYER_SELECT_OVERLAY, true );
|
2018-11-21 04:10:46 +00:00
|
|
|
m_view->SetLayerVisible( LAYER_RATSNEST, true );
|
2020-10-12 22:24:35 +00:00
|
|
|
m_view->SetLayerVisible( LAYER_MARKER_SHADOWS, true );
|
2014-07-09 09:24:56 +00:00
|
|
|
}
|
2015-07-03 18:58:12 +00:00
|
|
|
|
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
void PCB_DRAW_PANEL_GAL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
|
|
|
|
std::vector<MSG_PANEL_ITEM>& aList )
|
2015-07-03 18:58:12 +00:00
|
|
|
{
|
2021-09-28 09:41:39 +00:00
|
|
|
BOARD* board = static_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() )->GetBoard();
|
|
|
|
int padCount = 0;
|
|
|
|
int viaCount = 0;
|
|
|
|
int trackSegmentCount = 0;
|
|
|
|
std::set<int> netCodes;
|
2022-09-29 16:07:42 +00:00
|
|
|
int unconnected = board->GetConnectivity()->GetUnconnectedCount( true );
|
2015-07-03 18:58:12 +00:00
|
|
|
|
2021-06-11 21:07:02 +00:00
|
|
|
for( PCB_TRACK* item : board->Tracks() )
|
2015-07-03 18:58:12 +00:00
|
|
|
{
|
|
|
|
if( item->Type() == PCB_VIA_T )
|
2021-09-28 09:41:39 +00:00
|
|
|
viaCount++;
|
2015-07-03 18:58:12 +00:00
|
|
|
else
|
2021-09-28 09:41:39 +00:00
|
|
|
trackSegmentCount++;
|
2015-07-03 18:58:12 +00:00
|
|
|
|
2021-09-28 09:41:39 +00:00
|
|
|
if( item->GetNetCode() > 0 )
|
|
|
|
netCodes.insert( item->GetNetCode() );
|
|
|
|
}
|
2015-07-03 18:58:12 +00:00
|
|
|
|
2021-09-28 09:41:39 +00:00
|
|
|
for( FOOTPRINT* footprint : board->Footprints() )
|
|
|
|
{
|
|
|
|
for( PAD* pad : footprint->Pads() )
|
|
|
|
{
|
|
|
|
padCount++;
|
2015-07-03 18:58:12 +00:00
|
|
|
|
2021-09-28 09:41:39 +00:00
|
|
|
if( pad->GetNetCode() > 0 )
|
|
|
|
netCodes.insert( pad->GetNetCode() );
|
|
|
|
}
|
|
|
|
}
|
2015-07-03 18:58:12 +00:00
|
|
|
|
2022-02-04 22:44:59 +00:00
|
|
|
aList.emplace_back( _( "Pads" ), wxString::Format( wxT( "%d" ), padCount ) );
|
|
|
|
aList.emplace_back( _( "Vias" ), wxString::Format( wxT( "%d" ), viaCount ) );
|
|
|
|
aList.emplace_back( _( "Track Segments" ), wxString::Format( wxT( "%d" ), trackSegmentCount ) );
|
|
|
|
aList.emplace_back( _( "Nets" ), wxString::Format( wxT( "%d" ), (int) netCodes.size() ) );
|
|
|
|
aList.emplace_back( _( "Unrouted" ), wxString::Format( wxT( "%d" ), unconnected ) );
|
2015-07-03 18:58:12 +00:00
|
|
|
}
|
2015-09-05 17:00:54 +00:00
|
|
|
|
|
|
|
|
2016-05-09 15:23:01 +00:00
|
|
|
void PCB_DRAW_PANEL_GAL::OnShow()
|
|
|
|
{
|
2020-09-02 20:56:31 +00:00
|
|
|
PCB_BASE_FRAME* frame = nullptr;
|
|
|
|
|
|
|
|
if( !IsDialogPreview() )
|
|
|
|
frame = dynamic_cast<PCB_BASE_FRAME*>( GetParentEDAFrame() );
|
2016-05-09 15:23:01 +00:00
|
|
|
|
2018-01-17 07:58:44 +00:00
|
|
|
try
|
|
|
|
{
|
2021-07-19 23:56:05 +00:00
|
|
|
// Check if the current rendering back end can be properly initialized
|
2018-01-17 07:58:44 +00:00
|
|
|
m_view->UpdateItems();
|
|
|
|
}
|
|
|
|
catch( const std::runtime_error& e )
|
|
|
|
{
|
2020-05-19 22:54:05 +00:00
|
|
|
DisplayError( GetParent(), e.what() );
|
2018-10-09 16:05:14 +00:00
|
|
|
|
2020-08-31 17:47:44 +00:00
|
|
|
// Use the fallback if we have one
|
|
|
|
if( GAL_FALLBACK != m_backend )
|
|
|
|
{
|
|
|
|
SwitchBackend( GAL_FALLBACK );
|
|
|
|
|
|
|
|
if( frame )
|
|
|
|
frame->ActivateGalCanvas();
|
|
|
|
}
|
2018-01-17 07:58:44 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 15:23:01 +00:00
|
|
|
if( frame )
|
|
|
|
{
|
|
|
|
SetTopLayer( frame->GetActiveLayer() );
|
2018-07-01 08:24:57 +00:00
|
|
|
KIGFX::PAINTER* painter = m_view->GetPainter();
|
|
|
|
auto settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
|
2021-09-07 20:34:10 +00:00
|
|
|
settings->LoadDisplayOptions( frame->GetDisplayOptions() );
|
2016-05-09 15:23:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-05 17:00:54 +00:00
|
|
|
void PCB_DRAW_PANEL_GAL::setDefaultLayerOrder()
|
|
|
|
{
|
2021-07-21 23:14:56 +00:00
|
|
|
for( int i = 0; (unsigned) i < sizeof( GAL_LAYER_ORDER ) / sizeof( int ); ++i )
|
2015-09-05 17:00:54 +00:00
|
|
|
{
|
2021-07-21 23:14:56 +00:00
|
|
|
int layer = GAL_LAYER_ORDER[i];
|
2015-09-05 17:00:54 +00:00
|
|
|
wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
|
|
|
|
|
2022-06-27 18:07:52 +00:00
|
|
|
// MW: Gross hack to make SetTopLayer bring the correct bitmap layer to
|
|
|
|
// the top of the other bitmaps, but still below all the other layers
|
|
|
|
if( layer < LAYER_BITMAP_START )
|
|
|
|
m_view->SetLayerOrder( layer, i );
|
|
|
|
else
|
|
|
|
m_view->SetLayerOrder( layer, i - KIGFX::VIEW::TOP_LAYER_MODIFIER );
|
2015-09-05 17:00:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
|
2016-12-07 09:20:31 +00:00
|
|
|
bool PCB_DRAW_PANEL_GAL::SwitchBackend( GAL_TYPE aGalType )
|
|
|
|
{
|
2016-12-09 11:04:32 +00:00
|
|
|
bool rv = EDA_DRAW_PANEL_GAL::SwitchBackend( aGalType );
|
2016-12-07 09:20:31 +00:00
|
|
|
setDefaultLayerDeps();
|
2018-10-21 22:16:15 +00:00
|
|
|
m_gal->SetWorldUnitLength( 1e-9 /* 1 nm */ / 0.0254 /* 1 inch in meters */ );
|
2016-12-07 09:20:31 +00:00
|
|
|
return rv;
|
|
|
|
}
|
2015-09-05 17:00:54 +00:00
|
|
|
|
2016-12-09 11:04:32 +00:00
|
|
|
|
2017-08-01 13:20:40 +00:00
|
|
|
void PCB_DRAW_PANEL_GAL::RedrawRatsnest()
|
|
|
|
{
|
|
|
|
if( m_ratsnest )
|
|
|
|
m_view->Update( m_ratsnest.get() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-11 03:53:55 +00:00
|
|
|
BOX2I PCB_DRAW_PANEL_GAL::GetDefaultViewBBox() const
|
|
|
|
{
|
2021-02-22 23:47:17 +00:00
|
|
|
if( m_drawingSheet && m_view->IsLayerVisible( LAYER_DRAWINGSHEET ) )
|
|
|
|
return m_drawingSheet->ViewBBox();
|
2018-01-11 03:53:55 +00:00
|
|
|
|
|
|
|
return BOX2I();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-05 17:00:54 +00:00
|
|
|
void PCB_DRAW_PANEL_GAL::setDefaultLayerDeps()
|
|
|
|
{
|
2017-03-10 11:58:38 +00:00
|
|
|
// caching makes no sense for Cairo and other software renderers
|
|
|
|
auto target = m_backend == GAL_TYPE_OPENGL ? KIGFX::TARGET_CACHED : KIGFX::TARGET_NONCACHED;
|
|
|
|
|
|
|
|
for( int i = 0; i < KIGFX::VIEW::VIEW_MAX_LAYERS; i++ )
|
|
|
|
m_view->SetLayerTarget( i, target );
|
|
|
|
|
2021-07-21 23:14:56 +00:00
|
|
|
for( int i = 0; (unsigned) i < sizeof( GAL_LAYER_ORDER ) / sizeof( int ); ++i )
|
2015-09-05 17:00:54 +00:00
|
|
|
{
|
2021-07-21 23:14:56 +00:00
|
|
|
int layer = GAL_LAYER_ORDER[i];
|
2015-09-05 17:00:54 +00:00
|
|
|
wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
|
|
|
|
|
2016-05-02 14:04:45 +00:00
|
|
|
// Set layer display dependencies & targets
|
2015-09-05 17:00:54 +00:00
|
|
|
if( IsCopperLayer( layer ) )
|
2020-07-11 17:42:00 +00:00
|
|
|
{
|
|
|
|
m_view->SetRequired( ZONE_LAYER_FOR( layer ), layer );
|
2022-06-27 18:07:52 +00:00
|
|
|
m_view->SetRequired( BITMAP_LAYER_FOR( layer ), layer );
|
|
|
|
m_view->SetLayerTarget( BITMAP_LAYER_FOR( layer ), KIGFX::TARGET_NONCACHED );
|
2015-09-05 17:00:54 +00:00
|
|
|
m_view->SetRequired( GetNetnameLayer( layer ), layer );
|
2020-07-11 17:42:00 +00:00
|
|
|
}
|
2020-09-26 03:10:52 +00:00
|
|
|
else if( IsNonCopperLayer( layer ) )
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2020-09-26 03:10:52 +00:00
|
|
|
m_view->SetRequired( ZONE_LAYER_FOR( layer ), layer );
|
2022-06-27 18:07:52 +00:00
|
|
|
m_view->SetLayerTarget( BITMAP_LAYER_FOR( layer ), KIGFX::TARGET_NONCACHED );
|
|
|
|
m_view->SetRequired( BITMAP_LAYER_FOR( layer ), layer );
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2015-09-05 17:00:54 +00:00
|
|
|
else if( IsNetnameLayer( layer ) )
|
2021-07-19 23:56:05 +00:00
|
|
|
{
|
2015-09-05 17:00:54 +00:00
|
|
|
m_view->SetLayerDisplayOnly( layer );
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2016-12-07 09:20:31 +00:00
|
|
|
}
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
m_view->SetLayerTarget( LAYER_ANCHOR, KIGFX::TARGET_NONCACHED );
|
|
|
|
m_view->SetLayerDisplayOnly( LAYER_ANCHOR );
|
2015-09-05 17:00:54 +00:00
|
|
|
|
2022-03-07 17:03:06 +00:00
|
|
|
m_view->SetLayerTarget( LAYER_LOCKED_ITEM_SHADOW, KIGFX::TARGET_OVERLAY );
|
2022-05-20 09:08:33 +00:00
|
|
|
m_view->SetLayerTarget( LAYER_CONFLICTS_SHADOW, KIGFX::TARGET_OVERLAY );
|
|
|
|
|
2022-03-06 19:11:03 +00:00
|
|
|
m_view->SetLayerDisplayOnly( LAYER_LOCKED_ITEM_SHADOW );
|
2022-05-20 09:08:33 +00:00
|
|
|
m_view->SetLayerDisplayOnly( LAYER_CONFLICTS_SHADOW );
|
2022-03-06 19:11:03 +00:00
|
|
|
|
2015-09-05 17:00:54 +00:00
|
|
|
// Some more required layers settings
|
2021-01-30 14:41:31 +00:00
|
|
|
m_view->SetRequired( LAYER_VIA_NETNAMES, LAYER_VIAS );
|
|
|
|
m_view->SetRequired( LAYER_PAD_NETNAMES, LAYER_PADS );
|
2020-10-19 22:14:46 +00:00
|
|
|
|
|
|
|
// Holes can be independent of their host objects (cf: printing drill marks)
|
2021-01-30 14:41:31 +00:00
|
|
|
m_view->SetRequired( LAYER_VIA_HOLES, LAYER_VIAS );
|
|
|
|
m_view->SetRequired( LAYER_VIA_HOLEWALLS, LAYER_VIAS );
|
|
|
|
m_view->SetRequired( LAYER_PAD_PLATEDHOLES, LAYER_PADS );
|
|
|
|
m_view->SetRequired( LAYER_PAD_HOLEWALLS, LAYER_PADS );
|
2020-10-19 22:14:46 +00:00
|
|
|
m_view->SetRequired( LAYER_NON_PLATEDHOLES, LAYER_PADS );
|
2015-09-05 17:00:54 +00:00
|
|
|
|
2020-07-11 17:42:00 +00:00
|
|
|
// Via visibility
|
|
|
|
m_view->SetRequired( LAYER_VIA_MICROVIA, LAYER_VIAS );
|
|
|
|
m_view->SetRequired( LAYER_VIA_BBLIND, LAYER_VIAS );
|
|
|
|
m_view->SetRequired( LAYER_VIA_THROUGH, LAYER_VIAS );
|
|
|
|
|
|
|
|
// Pad visibility
|
|
|
|
m_view->SetRequired( LAYER_PADS_TH, LAYER_PADS );
|
|
|
|
m_view->SetRequired( LAYER_PAD_FR, LAYER_PADS );
|
|
|
|
m_view->SetRequired( LAYER_PAD_BK, LAYER_PADS );
|
|
|
|
|
2020-10-21 03:48:06 +00:00
|
|
|
// Front footprints
|
2018-02-17 22:53:44 +00:00
|
|
|
m_view->SetRequired( LAYER_PAD_FR, F_Cu );
|
2017-03-13 03:19:33 +00:00
|
|
|
m_view->SetRequired( LAYER_PAD_FR_NETNAMES, LAYER_PAD_FR );
|
2015-09-05 17:00:54 +00:00
|
|
|
|
2020-10-21 03:48:06 +00:00
|
|
|
// Back footprints
|
2018-02-17 22:53:44 +00:00
|
|
|
m_view->SetRequired( LAYER_PAD_BK, B_Cu );
|
2017-03-13 03:19:33 +00:00
|
|
|
m_view->SetRequired( LAYER_PAD_BK_NETNAMES, LAYER_PAD_BK );
|
|
|
|
|
2020-10-12 22:24:35 +00:00
|
|
|
m_view->SetLayerTarget( LAYER_SELECT_OVERLAY, KIGFX::TARGET_OVERLAY );
|
2018-08-28 21:57:31 +00:00
|
|
|
m_view->SetLayerDisplayOnly( LAYER_SELECT_OVERLAY ) ;
|
2020-10-12 22:24:35 +00:00
|
|
|
m_view->SetLayerTarget( LAYER_GP_OVERLAY, KIGFX::TARGET_OVERLAY );
|
2017-03-13 03:19:33 +00:00
|
|
|
m_view->SetLayerDisplayOnly( LAYER_GP_OVERLAY ) ;
|
|
|
|
m_view->SetLayerTarget( LAYER_RATSNEST, KIGFX::TARGET_OVERLAY );
|
|
|
|
m_view->SetLayerDisplayOnly( LAYER_RATSNEST );
|
|
|
|
|
2020-10-12 22:24:35 +00:00
|
|
|
m_view->SetLayerTarget( LAYER_DRC_ERROR, KIGFX::TARGET_OVERLAY );
|
|
|
|
m_view->SetLayerDisplayOnly( LAYER_DRC_ERROR );
|
|
|
|
m_view->SetLayerTarget( LAYER_DRC_WARNING, KIGFX::TARGET_OVERLAY );
|
|
|
|
m_view->SetLayerDisplayOnly( LAYER_DRC_WARNING );
|
|
|
|
m_view->SetLayerTarget( LAYER_DRC_EXCLUSION, KIGFX::TARGET_OVERLAY );
|
|
|
|
m_view->SetLayerDisplayOnly( LAYER_DRC_EXCLUSION );
|
|
|
|
m_view->SetLayerTarget( LAYER_MARKER_SHADOWS, KIGFX::TARGET_OVERLAY );
|
|
|
|
m_view->SetLayerDisplayOnly( LAYER_MARKER_SHADOWS );
|
|
|
|
|
2021-02-22 16:37:43 +00:00
|
|
|
m_view->SetLayerTarget( LAYER_DRAWINGSHEET, KIGFX::TARGET_NONCACHED );
|
|
|
|
m_view->SetLayerDisplayOnly( LAYER_DRAWINGSHEET ) ;
|
2017-03-13 03:19:33 +00:00
|
|
|
m_view->SetLayerDisplayOnly( LAYER_GRID );
|
2015-09-05 17:00:54 +00:00
|
|
|
}
|
2017-10-30 19:17:23 +00:00
|
|
|
|
|
|
|
|
2019-06-13 17:28:55 +00:00
|
|
|
KIGFX::PCB_VIEW* PCB_DRAW_PANEL_GAL::GetView() const
|
2017-10-30 19:17:23 +00:00
|
|
|
{
|
|
|
|
return static_cast<KIGFX::PCB_VIEW*>( m_view );
|
|
|
|
}
|