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
|
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>
|
|
|
|
#include <worksheet_viewitem.h>
|
|
|
|
#include <ratsnest_viewitem.h>
|
2015-07-03 18:58:12 +00:00
|
|
|
#include <ratsnest_data.h>
|
2017-11-15 17:33:06 +00:00
|
|
|
#include <connectivity_data.h>
|
2014-07-09 08:57:32 +00:00
|
|
|
|
2018-01-31 08:23:20 +00:00
|
|
|
#include <colors_design_settings.h>
|
2014-07-09 08:57:32 +00:00
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_track.h>
|
2017-11-29 02:57:28 +00:00
|
|
|
#include <class_marker_pcb.h>
|
2018-01-29 15:39:40 +00:00
|
|
|
#include <pcb_base_frame.h>
|
2018-01-17 07:58:44 +00:00
|
|
|
#include <confirm.h>
|
2014-07-09 08:57:32 +00:00
|
|
|
|
2017-08-04 12:43:02 +00:00
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
|
|
|
|
2016-06-29 10:23:11 +00:00
|
|
|
#include <functional>
|
|
|
|
using namespace std::placeholders;
|
2014-07-09 08:57:32 +00:00
|
|
|
|
|
|
|
const LAYER_NUM GAL_LAYER_ORDER[] =
|
|
|
|
{
|
2017-04-25 09:47:21 +00:00
|
|
|
LAYER_GP_OVERLAY,
|
2017-03-13 03:19:33 +00:00
|
|
|
LAYER_DRC,
|
2017-04-25 09:47:21 +00:00
|
|
|
LAYER_PADS_NETNAMES, LAYER_VIAS_NETNAMES,
|
2014-07-09 08:57:32 +00:00
|
|
|
Dwgs_User, Cmts_User, Eco1_User, Eco2_User, Edge_Cuts,
|
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
LAYER_MOD_TEXT_FR,
|
|
|
|
LAYER_MOD_REFERENCES, LAYER_MOD_VALUES,
|
|
|
|
|
|
|
|
LAYER_RATSNEST, LAYER_ANCHOR,
|
2017-11-29 08:48:41 +00:00
|
|
|
LAYER_VIAS_HOLES, LAYER_PADS_PLATEDHOLES, LAYER_NON_PLATEDHOLES,
|
2017-03-13 03:19:33 +00:00
|
|
|
LAYER_VIA_THROUGH, LAYER_VIA_BBLIND,
|
2017-11-29 08:48:41 +00:00
|
|
|
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,
|
2017-03-13 03:19:33 +00:00
|
|
|
NETNAMES_LAYER_INDEX( F_Cu ), F_Cu, F_Mask, F_SilkS, F_Paste, F_Adhes,
|
|
|
|
|
|
|
|
NETNAMES_LAYER_INDEX( In1_Cu ), In1_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In2_Cu ), In2_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In3_Cu ), In3_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In4_Cu ), In4_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In5_Cu ), In5_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In6_Cu ), In6_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In7_Cu ), In7_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In8_Cu ), In8_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In9_Cu ), In9_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In10_Cu ), In10_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In11_Cu ), In11_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In12_Cu ), In12_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In13_Cu ), In13_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In14_Cu ), In14_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In15_Cu ), In15_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In16_Cu ), In16_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In17_Cu ), In17_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In18_Cu ), In18_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In19_Cu ), In19_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In20_Cu ), In20_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In21_Cu ), In21_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In22_Cu ), In22_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In23_Cu ), In23_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In24_Cu ), In24_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In25_Cu ), In25_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In26_Cu ), In26_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In27_Cu ), In27_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In28_Cu ), In28_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In29_Cu ), In29_Cu,
|
|
|
|
NETNAMES_LAYER_INDEX( In30_Cu ), In30_Cu,
|
|
|
|
|
2017-04-01 22:55:35 +00:00
|
|
|
LAYER_PAD_BK_NETNAMES, LAYER_PAD_BK,
|
2017-03-13 03:19:33 +00:00
|
|
|
NETNAMES_LAYER_INDEX( B_Cu ), B_Cu, B_Mask, B_Adhes, B_Paste, B_SilkS,
|
|
|
|
|
|
|
|
LAYER_MOD_TEXT_BK,
|
|
|
|
LAYER_WORKSHEET
|
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 ) :
|
|
|
|
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
|
|
|
|
2017-10-30 08:36:31 +00:00
|
|
|
m_painter.reset( new KIGFX::PCB_PAINTER( m_gal ) );
|
|
|
|
m_view->SetPainter( m_painter.get() );
|
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)
|
2016-05-02 14:15:26 +00:00
|
|
|
EDA_DRAW_FRAME* frame = GetParentEDAFrame();
|
2015-01-10 10:27:49 +00:00
|
|
|
|
|
|
|
if( frame )
|
|
|
|
{
|
2017-10-30 19:17:23 +00:00
|
|
|
auto opts = (PCB_DISPLAY_OPTIONS*) frame->GetDisplayOptions();
|
|
|
|
static_cast<KIGFX::PCB_VIEW*>( m_view )->UpdateDisplayOptions( opts );
|
2015-01-10 10:27:49 +00:00
|
|
|
}
|
2014-07-09 08:57:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PCB_DRAW_PANEL_GAL::~PCB_DRAW_PANEL_GAL()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-23 16:20:27 +00:00
|
|
|
void PCB_DRAW_PANEL_GAL::DisplayBoard( BOARD* aBoard )
|
2014-07-09 08:57:32 +00:00
|
|
|
{
|
|
|
|
m_view->Clear();
|
|
|
|
|
|
|
|
// Load zones
|
2017-11-23 16:20:27 +00:00
|
|
|
for( auto zone : aBoard->Zones() )
|
|
|
|
{
|
|
|
|
zone->CacheTriangulation();
|
|
|
|
m_view->Add( zone );
|
|
|
|
}
|
2014-07-09 08:57:32 +00:00
|
|
|
|
|
|
|
// Load drawings
|
2017-03-22 13:11:08 +00:00
|
|
|
for( auto drawing : const_cast<BOARD*>(aBoard)->Drawings() )
|
2014-07-09 08:57:32 +00:00
|
|
|
m_view->Add( drawing );
|
|
|
|
|
|
|
|
// Load tracks
|
|
|
|
for( TRACK* track = aBoard->m_Track; track; track = track->Next() )
|
|
|
|
m_view->Add( track );
|
|
|
|
|
|
|
|
// Load modules and its additional elements
|
|
|
|
for( MODULE* module = aBoard->m_Modules; module; module = module->Next() )
|
|
|
|
m_view->Add( module );
|
|
|
|
|
|
|
|
// Segzones (equivalent of ZONE_CONTAINER for legacy boards)
|
|
|
|
for( SEGZONE* zone = aBoard->m_Zone; zone; zone = zone->Next() )
|
|
|
|
m_view->Add( zone );
|
|
|
|
|
2017-11-29 02:57:28 +00:00
|
|
|
// DRC markers
|
|
|
|
for( int marker_idx = 0; marker_idx < aBoard->GetMARKERCount(); ++marker_idx )
|
|
|
|
{
|
|
|
|
m_view->Add( aBoard->GetMARKER( marker_idx ) );
|
|
|
|
}
|
|
|
|
|
2014-07-09 08:57:32 +00:00
|
|
|
// Ratsnest
|
2017-03-22 13:43:10 +00:00
|
|
|
m_ratsnest.reset( new KIGFX::RATSNEST_VIEWITEM( aBoard->GetConnectivity() ) );
|
2017-03-02 22:57:13 +00:00
|
|
|
m_view->Add( m_ratsnest.get() );
|
2014-07-09 08:57:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PCB_DRAW_PANEL_GAL::SetWorksheet( KIGFX::WORKSHEET_VIEWITEM* aWorksheet )
|
|
|
|
{
|
2017-03-02 22:57:13 +00:00
|
|
|
m_worksheet.reset( aWorksheet );
|
|
|
|
m_view->Add( m_worksheet.get() );
|
2014-07-09 08:57:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 09:22:42 +00:00
|
|
|
void PCB_DRAW_PANEL_GAL::UseColorScheme( const COLORS_DESIGN_SETTINGS* aSettings )
|
|
|
|
{
|
|
|
|
KIGFX::PCB_RENDER_SETTINGS* rs;
|
|
|
|
rs = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( m_view->GetPainter()->GetSettings() );
|
|
|
|
rs->ImportLegacyColors( aSettings );
|
2018-02-15 19:24:24 +00:00
|
|
|
m_gal->SetGridColor( aSettings->GetLayerColor( LAYER_GRID ) );
|
2017-08-04 12:43:02 +00:00
|
|
|
m_gal->SetCursorColor( aSettings->GetItemColor( LAYER_CURSOR ) );
|
2014-07-09 09:22:42 +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->ClearActiveLayers();
|
|
|
|
rSettings->SetActiveLayer( aLayer );
|
|
|
|
|
|
|
|
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..
|
|
|
|
LAYER_NUM layers[] = {
|
2017-04-25 09:47:21 +00:00
|
|
|
GetNetnameLayer( aLayer ),
|
|
|
|
LAYER_VIA_THROUGH, LAYER_VIAS_HOLES, LAYER_VIAS_NETNAMES,
|
2017-11-29 08:48:41 +00:00
|
|
|
LAYER_PADS_TH, LAYER_PADS_PLATEDHOLES, LAYER_PADS_NETNAMES,
|
2018-01-06 14:58:29 +00:00
|
|
|
LAYER_NON_PLATEDHOLES, LAYER_GP_OVERLAY, LAYER_RATSNEST,
|
|
|
|
LAYER_CURSOR
|
2014-07-09 08:57:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for( unsigned int i = 0; i < sizeof( layers ) / sizeof( LAYER_NUM ); ++i )
|
|
|
|
rSettings->SetActiveLayer( layers[i] );
|
|
|
|
|
|
|
|
// Pads should be shown too
|
|
|
|
if( aLayer == B_Cu )
|
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
rSettings->SetActiveLayer( LAYER_PAD_BK );
|
|
|
|
rSettings->SetActiveLayer( LAYER_MOD_BK );
|
|
|
|
rSettings->SetActiveLayer( LAYER_PAD_BK_NETNAMES );
|
2014-07-09 08:57:32 +00:00
|
|
|
}
|
|
|
|
else if( aLayer == F_Cu )
|
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
rSettings->SetActiveLayer( LAYER_PAD_FR );
|
|
|
|
rSettings->SetActiveLayer( LAYER_MOD_FR );
|
|
|
|
rSettings->SetActiveLayer( LAYER_PAD_FR_NETNAMES );
|
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
|
|
|
|
const LAYER_NUM layers[] = {
|
2017-04-25 09:47:21 +00:00
|
|
|
LAYER_VIA_THROUGH, LAYER_VIAS_HOLES, LAYER_VIAS_NETNAMES,
|
2017-11-29 08:48:41 +00:00
|
|
|
LAYER_PADS_TH, LAYER_PADS_PLATEDHOLES, LAYER_PADS_NETNAMES,
|
|
|
|
LAYER_NON_PLATEDHOLES, LAYER_GP_OVERLAY, LAYER_RATSNEST,
|
2017-03-13 03:19:33 +00:00
|
|
|
LAYER_DRC
|
2015-09-06 10:58:46 +00:00
|
|
|
};
|
2014-07-09 08:57:32 +00:00
|
|
|
|
2015-09-06 10:58:46 +00:00
|
|
|
for( unsigned int i = 0; i < sizeof( layers ) / sizeof( LAYER_NUM ); ++i )
|
|
|
|
m_view->SetTopLayer( layers[i] );
|
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
|
2015-09-05 17:00:54 +00:00
|
|
|
const LAYER_NUM frontLayers[] = {
|
2017-03-13 03:19:33 +00:00
|
|
|
F_Cu, F_Adhes, F_Paste, F_SilkS, F_Mask, F_CrtYd, F_Fab, LAYER_PAD_FR,
|
|
|
|
LAYER_PAD_FR_NETNAMES, NETNAMES_LAYER_INDEX( F_Cu ), -1
|
2015-09-05 17:00:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const LAYER_NUM backLayers[] = {
|
2017-03-13 03:19:33 +00:00
|
|
|
B_Cu, B_Adhes, B_Paste, B_SilkS, B_Mask, B_CrtYd, B_Fab, LAYER_PAD_BK,
|
|
|
|
LAYER_PAD_BK_NETNAMES, NETNAMES_LAYER_INDEX( B_Cu ), -1
|
2015-09-05 17:00:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const LAYER_NUM* extraLayers = NULL;
|
|
|
|
|
|
|
|
// Bring a few more extra layers to the top depending on the selected board side
|
|
|
|
if( IsFrontLayer( aLayer ) )
|
|
|
|
extraLayers = frontLayers;
|
|
|
|
else if( IsBackLayer( aLayer ) )
|
|
|
|
extraLayers = backLayers;
|
|
|
|
|
|
|
|
if( extraLayers )
|
|
|
|
{
|
|
|
|
const LAYER_NUM* l = extraLayers;
|
|
|
|
|
|
|
|
while( *l >= 0 )
|
2015-09-06 10:58:46 +00:00
|
|
|
m_view->SetTopLayer( *l++ );
|
2015-09-05 17:00:54 +00:00
|
|
|
|
2015-09-06 10:58:46 +00:00
|
|
|
// Move the active layer to the top
|
2015-09-05 17:00:54 +00:00
|
|
|
if( !IsCopperLayer( aLayer ) )
|
2015-09-06 10:58:46 +00:00
|
|
|
m_view->SetLayerOrder( aLayer, m_view->GetLayerOrder( GAL_LAYER_ORDER[0] ) );
|
|
|
|
}
|
|
|
|
else if( IsCopperLayer( aLayer ) )
|
|
|
|
{
|
|
|
|
// Display labels for copper layers on the top
|
|
|
|
m_view->SetTopLayer( GetNetnameLayer( aLayer ) );
|
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
|
2017-03-13 03:19:33 +00:00
|
|
|
for( LAYER_NUM i = 0; i < PCB_LAYER_ID_COUNT; ++i )
|
|
|
|
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
|
|
|
|
|
|
|
// Always enable netname layers, as their visibility is controlled by layer dependencies
|
|
|
|
for( LAYER_NUM i = NETNAMES_LAYER_ID_START; i < NETNAMES_LAYER_ID_END; ++i )
|
|
|
|
m_view->SetLayerVisible( i, true );
|
2014-07-09 09:24:56 +00:00
|
|
|
|
|
|
|
// Enable some layers that are GAL specific
|
2017-11-29 08:48:41 +00:00
|
|
|
m_view->SetLayerVisible( LAYER_PADS_PLATEDHOLES, true );
|
2017-03-13 03:19:33 +00:00
|
|
|
m_view->SetLayerVisible( LAYER_VIAS_HOLES, true );
|
2017-04-01 22:55:35 +00:00
|
|
|
m_view->SetLayerVisible( LAYER_GP_OVERLAY, true );
|
2014-07-09 09:24:56 +00:00
|
|
|
}
|
2015-07-03 18:58:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
void PCB_DRAW_PANEL_GAL::GetMsgPanelInfo( std::vector<MSG_PANEL_ITEM>& aList )
|
|
|
|
{
|
|
|
|
BOARD* board = static_cast<PCB_BASE_FRAME*>( m_parent )->GetBoard();
|
|
|
|
wxString txt;
|
|
|
|
int viasCount = 0;
|
|
|
|
int trackSegmentsCount = 0;
|
|
|
|
|
|
|
|
for( const BOARD_ITEM* item = board->m_Track; item; item = item->Next() )
|
|
|
|
{
|
|
|
|
if( item->Type() == PCB_VIA_T )
|
|
|
|
viasCount++;
|
|
|
|
else
|
|
|
|
trackSegmentsCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
txt.Printf( wxT( "%d" ), board->GetPadCount() );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Pads" ), txt, DARKGREEN ) );
|
|
|
|
|
|
|
|
txt.Printf( wxT( "%d" ), viasCount );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Vias" ), txt, DARKGREEN ) );
|
|
|
|
|
|
|
|
txt.Printf( wxT( "%d" ), trackSegmentsCount );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Track Segments" ), txt, DARKGREEN ) );
|
|
|
|
|
|
|
|
txt.Printf( wxT( "%d" ), board->GetNodesCount() );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Nodes" ), txt, DARKCYAN ) );
|
|
|
|
|
|
|
|
txt.Printf( wxT( "%d" ), board->GetNetCount() );
|
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Nets" ), txt, RED ) );
|
|
|
|
|
2017-03-22 13:43:10 +00:00
|
|
|
txt.Printf( wxT( "%d" ), board->GetConnectivity()->GetUnconnectedCount() );
|
2015-07-03 18:58:12 +00:00
|
|
|
aList.push_back( MSG_PANEL_ITEM( _( "Unconnected" ), txt, BLUE ) );
|
|
|
|
}
|
2015-09-05 17:00:54 +00:00
|
|
|
|
|
|
|
|
2016-05-09 15:23:01 +00:00
|
|
|
void PCB_DRAW_PANEL_GAL::OnShow()
|
|
|
|
{
|
|
|
|
PCB_BASE_FRAME* frame = dynamic_cast<PCB_BASE_FRAME*>( GetParent() );
|
|
|
|
|
2018-01-17 07:58:44 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// Check if the current rendering backend can be properly initialized
|
|
|
|
m_view->UpdateItems();
|
|
|
|
}
|
|
|
|
catch( const std::runtime_error& e )
|
|
|
|
{
|
|
|
|
// Fallback to software renderer
|
|
|
|
DisplayError( frame, e.what() );
|
|
|
|
bool use_gal = SwitchBackend( GAL_TYPE_CAIRO );
|
|
|
|
frame->UseGalCanvas( use_gal );
|
|
|
|
}
|
|
|
|
|
2016-05-09 15:23:01 +00:00
|
|
|
if( frame )
|
|
|
|
{
|
|
|
|
SetTopLayer( frame->GetActiveLayer() );
|
2017-10-30 17:21:07 +00:00
|
|
|
PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) frame->GetDisplayOptions();
|
2016-05-09 15:23:01 +00:00
|
|
|
static_cast<KIGFX::PCB_RENDER_SETTINGS*>(
|
|
|
|
m_view->GetPainter()->GetSettings() )->LoadDisplayOptions( displ_opts );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_view->RecacheAllItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-09-05 17:00:54 +00:00
|
|
|
void PCB_DRAW_PANEL_GAL::setDefaultLayerOrder()
|
|
|
|
{
|
|
|
|
for( LAYER_NUM i = 0; (unsigned) i < sizeof( GAL_LAYER_ORDER ) / sizeof( LAYER_NUM ); ++i )
|
|
|
|
{
|
|
|
|
LAYER_NUM layer = GAL_LAYER_ORDER[i];
|
|
|
|
wxASSERT( layer < KIGFX::VIEW::VIEW_MAX_LAYERS );
|
|
|
|
|
|
|
|
m_view->SetLayerOrder( layer, i );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
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
|
|
|
|
{
|
|
|
|
if( m_worksheet )
|
|
|
|
return m_worksheet->ViewBBox();
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
2015-09-05 17:00:54 +00:00
|
|
|
for( LAYER_NUM i = 0; (unsigned) i < sizeof( GAL_LAYER_ORDER ) / sizeof( LAYER_NUM ); ++i )
|
|
|
|
{
|
|
|
|
LAYER_NUM layer = GAL_LAYER_ORDER[i];
|
|
|
|
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 ) )
|
|
|
|
m_view->SetRequired( GetNetnameLayer( layer ), layer );
|
|
|
|
else if( IsNetnameLayer( layer ) )
|
|
|
|
m_view->SetLayerDisplayOnly( layer );
|
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
|
|
|
|
|
|
|
// Some more required layers settings
|
2017-03-13 03:19:33 +00:00
|
|
|
m_view->SetRequired( LAYER_VIAS_HOLES, LAYER_VIA_THROUGH );
|
2017-04-25 09:47:21 +00:00
|
|
|
m_view->SetRequired( LAYER_VIAS_NETNAMES, LAYER_VIA_THROUGH );
|
2017-11-29 08:48:41 +00:00
|
|
|
m_view->SetRequired( LAYER_PADS_PLATEDHOLES, LAYER_PADS_TH );
|
|
|
|
m_view->SetRequired( LAYER_NON_PLATEDHOLES, LAYER_PADS_TH );
|
|
|
|
m_view->SetRequired( LAYER_PADS_NETNAMES, LAYER_PADS_TH );
|
2015-09-05 17:00:54 +00:00
|
|
|
|
|
|
|
// Front modules
|
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_MOD_TEXT_FR, LAYER_MOD_FR );
|
|
|
|
m_view->SetRequired( LAYER_PAD_FR_NETNAMES, LAYER_PAD_FR );
|
2015-09-05 17:00:54 +00:00
|
|
|
|
|
|
|
// Back modules
|
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_MOD_TEXT_BK, LAYER_MOD_BK );
|
|
|
|
m_view->SetRequired( LAYER_PAD_BK_NETNAMES, LAYER_PAD_BK );
|
|
|
|
|
|
|
|
m_view->SetLayerTarget( LAYER_GP_OVERLAY , KIGFX::TARGET_OVERLAY );
|
|
|
|
m_view->SetLayerDisplayOnly( LAYER_GP_OVERLAY ) ;
|
|
|
|
m_view->SetLayerTarget( LAYER_RATSNEST, KIGFX::TARGET_OVERLAY );
|
|
|
|
m_view->SetLayerDisplayOnly( LAYER_RATSNEST );
|
|
|
|
|
|
|
|
m_view->SetLayerDisplayOnly( LAYER_WORKSHEET ) ;
|
|
|
|
m_view->SetLayerDisplayOnly( LAYER_GRID );
|
|
|
|
m_view->SetLayerDisplayOnly( LAYER_DRC );
|
2015-09-05 17:00:54 +00:00
|
|
|
}
|
2017-10-30 19:17:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
KIGFX::PCB_VIEW* PCB_DRAW_PANEL_GAL::view() const
|
|
|
|
{
|
|
|
|
return static_cast<KIGFX::PCB_VIEW*>( m_view );
|
|
|
|
}
|