2011-09-23 20:00:30 +00:00
|
|
|
/*
|
2011-09-30 18:15:37 +00:00
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
2011-09-23 20:00:30 +00:00
|
|
|
*
|
2014-11-23 11:41:57 +00:00
|
|
|
* Copyright (C) 2004-2010 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2011-09-23 20:00:30 +00:00
|
|
|
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2023-09-07 09:20:42 +00:00
|
|
|
* Copyright (C) 2018-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-09-23 20:00:30 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2021-06-07 22:29:40 +00:00
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/filedlg.h>
|
2021-03-07 20:31:19 +00:00
|
|
|
#include <bitmaps.h>
|
2018-02-28 09:21:37 +00:00
|
|
|
#include <menus_helpers.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <gerbview.h>
|
2021-06-06 22:36:31 +00:00
|
|
|
#include "gerbview_draw_panel_gal.h"
|
2014-06-27 17:07:42 +00:00
|
|
|
#include <gerbview_frame.h>
|
2018-01-29 12:26:58 +00:00
|
|
|
#include <gerber_file_image_list.h>
|
2020-11-18 01:21:04 +00:00
|
|
|
#include <core/arraydim.h>
|
2017-09-17 22:43:20 +00:00
|
|
|
#include <view/view.h>
|
|
|
|
#include <gerbview_painter.h>
|
|
|
|
#include <gal/graphics_abstraction_layer.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2022-07-25 14:02:17 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/gerbview_actions.h>
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2020-11-16 12:13:08 +00:00
|
|
|
#include "layer_widget.h"
|
|
|
|
#include "gbr_layer_box_selector.h"
|
|
|
|
#include "gerbview_layer_widget.h"
|
2021-03-13 17:45:33 +00:00
|
|
|
#include "dcode_selection_box.h"
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
|
2018-05-02 14:46:09 +00:00
|
|
|
GERBER_LAYER_WIDGET::GERBER_LAYER_WIDGET( GERBVIEW_FRAME* aParent, wxWindow* aFocusOwner ) :
|
|
|
|
LAYER_WIDGET( aParent, aFocusOwner ),
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame( aParent )
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
2013-04-06 12:01:53 +00:00
|
|
|
m_alwaysShowActiveLayer = false;
|
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
ReFillRender();
|
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
// Update default tabs labels for GerbView
|
2011-09-23 20:00:30 +00:00
|
|
|
SetLayersManagerTabsText( );
|
|
|
|
|
|
|
|
// handle the popup menu over the layer window.
|
|
|
|
m_LayerScrolledWindow->Connect( wxEVT_RIGHT_DOWN,
|
2021-07-16 20:13:26 +00:00
|
|
|
wxMouseEventHandler( GERBER_LAYER_WIDGET::onRightDownLayers ),
|
|
|
|
nullptr, this );
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
// since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
|
|
|
|
// and not m_LayerScrolledWindow->Connect()
|
2021-07-16 20:13:26 +00:00
|
|
|
Connect( ID_LAYER_MANAGER_START, ID_LAYER_MANAGER_END, wxEVT_COMMAND_MENU_SELECTED,
|
|
|
|
wxCommandEventHandler( GERBER_LAYER_WIDGET::onPopupSelection ), nullptr, this );
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2016-06-17 18:00:29 +00:00
|
|
|
GERBER_FILE_IMAGE_LIST* GERBER_LAYER_WIDGET::GetImagesList()
|
|
|
|
{
|
|
|
|
return &GERBER_FILE_IMAGE_LIST::GetImagesList();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
void GERBER_LAYER_WIDGET::SetLayersManagerTabsText()
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
2021-07-16 20:13:26 +00:00
|
|
|
m_notebook->SetPageText( 0, _( "Layers" ) );
|
|
|
|
m_notebook->SetPageText( 1, _( "Items" ) );
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 12:38:33 +00:00
|
|
|
|
|
|
|
void GERBER_LAYER_WIDGET::CollectCurrentColorSettings( COLOR_SETTINGS* aColorSettings )
|
|
|
|
{
|
|
|
|
std::vector<int>render_layers{ LAYER_DCODES, LAYER_NEGATIVE_OBJECTS, LAYER_GERBVIEW_GRID,
|
|
|
|
LAYER_GERBVIEW_DRAWINGSHEET, LAYER_GERBVIEW_PAGE_LIMITS,
|
|
|
|
LAYER_GERBVIEW_BACKGROUND };
|
|
|
|
|
|
|
|
for( int layer: render_layers )
|
|
|
|
{
|
|
|
|
int row = findRenderRow( layer );
|
|
|
|
|
|
|
|
if( row < 0 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
COLOR4D color = GetRenderColor( row );
|
|
|
|
|
|
|
|
if( color != COLOR4D::UNSPECIFIED )
|
|
|
|
aColorSettings->SetColor( layer, color );
|
|
|
|
}
|
|
|
|
|
|
|
|
for( int layer = GERBVIEW_LAYER_ID_START; layer < GERBVIEW_LAYER_ID_START + GERBER_DRAWLAYERS_COUNT; layer++ )
|
|
|
|
{
|
|
|
|
int row = findLayerRow( layer - GERBVIEW_LAYER_ID_START );
|
|
|
|
|
|
|
|
if( row < 0 ) // Not existing in layer list
|
|
|
|
continue;
|
|
|
|
|
|
|
|
COLOR4D color = GetLayerColor( row );
|
|
|
|
|
|
|
|
if( color != COLOR4D::UNSPECIFIED )
|
|
|
|
aColorSettings->SetColor( layer, color );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
void GERBER_LAYER_WIDGET::ReFillRender()
|
|
|
|
{
|
|
|
|
ClearRenderRows();
|
|
|
|
|
|
|
|
// Fixed "Rendering" tab rows within the LAYER_WIDGET, only the initial color
|
|
|
|
// is changed before appending to the LAYER_WIDGET. This is an automatic variable
|
|
|
|
// not a static variable, change the color & state after copying from code to renderRows
|
|
|
|
// on the stack.
|
2022-03-24 14:10:47 +00:00
|
|
|
LAYER_WIDGET::ROW renderRows[7] = {
|
2011-09-23 20:00:30 +00:00
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
#define RR LAYER_WIDGET::ROW // Render Row abbreviation to reduce source width
|
2011-09-23 20:00:30 +00:00
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
RR( _( "DCodes" ), LAYER_DCODES, WHITE,
|
|
|
|
_( "Show DCodes identification" ) ),
|
|
|
|
RR( _( "Negative Objects" ), LAYER_NEGATIVE_OBJECTS, DARKGRAY,
|
|
|
|
_( "Show negative objects in this color" ) ),
|
2018-07-07 08:50:13 +00:00
|
|
|
RR(),
|
2021-07-16 20:13:26 +00:00
|
|
|
RR( _( "Grid" ), LAYER_GERBVIEW_GRID, WHITE,
|
|
|
|
_( "Show the (x,y) grid dots" ) ),
|
|
|
|
RR( _( "Drawing Sheet" ), LAYER_GERBVIEW_DRAWINGSHEET, DARKRED,
|
|
|
|
_( "Show drawing sheet border and title block") ),
|
2022-03-24 14:10:47 +00:00
|
|
|
RR( _( "Page Limits" ), LAYER_GERBVIEW_PAGE_LIMITS, WHITE,
|
|
|
|
_( "Show drawing sheet page limits" ) ),
|
2021-07-16 20:13:26 +00:00
|
|
|
RR( _( "Background" ), LAYER_GERBVIEW_BACKGROUND, BLACK,
|
|
|
|
_( "PCB Background" ), true, false )
|
2011-09-23 20:00:30 +00:00
|
|
|
};
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
for( unsigned row = 0; row < arrayDim( renderRows ); ++row )
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
2017-02-20 17:48:27 +00:00
|
|
|
if( renderRows[row].color != COLOR4D::UNSPECIFIED ) // does this row show a color?
|
2021-06-06 22:57:10 +00:00
|
|
|
renderRows[row].color = m_frame->GetVisibleElementColor( renderRows[row].id );
|
2018-07-29 16:26:13 +00:00
|
|
|
|
|
|
|
if( renderRows[row].id ) // if not the separator
|
2021-06-06 22:57:10 +00:00
|
|
|
renderRows[row].state = m_frame->IsElementVisible( renderRows[row].id );
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
|
2019-01-06 16:43:12 +00:00
|
|
|
AppendRenderRows( renderRows, arrayDim(renderRows) );
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-28 09:21:37 +00:00
|
|
|
void GERBER_LAYER_WIDGET::AddRightClickMenuItems( wxMenu* aMenu )
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
2014-11-22 11:52:57 +00:00
|
|
|
// Remember: menu text is capitalized (see our rules_for_capitalization_in_Kicad_UI.txt)
|
2018-02-28 09:21:37 +00:00
|
|
|
AddMenuItem( aMenu, ID_SHOW_ALL_LAYERS, _( "Show All Layers" ),
|
2021-03-08 02:59:07 +00:00
|
|
|
KiBitmap( BITMAPS::show_all_layers ) );
|
2012-02-17 19:43:43 +00:00
|
|
|
|
2018-02-28 09:21:37 +00:00
|
|
|
AddMenuItem( aMenu, ID_SHOW_NO_LAYERS_BUT_ACTIVE,
|
|
|
|
_( "Hide All Layers But Active" ),
|
2021-03-08 02:59:07 +00:00
|
|
|
KiBitmap( BITMAPS::select_w_layer ) );
|
2011-09-23 20:00:30 +00:00
|
|
|
|
2018-02-28 09:21:37 +00:00
|
|
|
AddMenuItem( aMenu, ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE,
|
|
|
|
_( "Always Hide All Layers But Active" ),
|
2021-03-08 02:59:07 +00:00
|
|
|
KiBitmap( BITMAPS::select_w_layer ) );
|
2013-04-06 12:01:53 +00:00
|
|
|
|
2018-02-28 09:21:37 +00:00
|
|
|
AddMenuItem( aMenu, ID_SHOW_NO_LAYERS, _( "Hide All Layers" ),
|
2021-03-08 02:59:07 +00:00
|
|
|
KiBitmap( BITMAPS::show_no_layers ) );
|
2011-09-23 20:00:30 +00:00
|
|
|
|
2018-02-28 09:21:37 +00:00
|
|
|
aMenu->AppendSeparator();
|
2021-08-02 20:00:34 +00:00
|
|
|
|
|
|
|
AddMenuItem( aMenu, ID_SORT_GBR_LAYERS_X2, _( "Sort Layers if X2 Mode" ),
|
|
|
|
KiBitmap( BITMAPS::reload ) );
|
|
|
|
|
|
|
|
AddMenuItem( aMenu, ID_SORT_GBR_LAYERS_FILE_EXT, _( "Sort Layers by File Extension" ),
|
2021-03-08 02:59:07 +00:00
|
|
|
KiBitmap( BITMAPS::reload ) );
|
2021-08-04 18:47:26 +00:00
|
|
|
|
|
|
|
aMenu->AppendSeparator();
|
|
|
|
|
2023-09-07 09:20:42 +00:00
|
|
|
AddMenuItem( aMenu, ID_SET_GBR_LAYERS_DRAW_PRMS, _( "Layers Display Parameters: Offset and Rotation" ),
|
2023-09-06 16:54:54 +00:00
|
|
|
KiBitmap( BITMAPS::tools ) );
|
|
|
|
|
|
|
|
aMenu->AppendSeparator();
|
|
|
|
|
2021-08-04 18:47:26 +00:00
|
|
|
AddMenuItem( aMenu, ID_LAYER_MOVE_UP, _( "Move Current Layer Up" ), KiBitmap( BITMAPS::up ) );
|
|
|
|
|
|
|
|
AddMenuItem( aMenu, ID_LAYER_MOVE_DOWN, _( "Move Current Layer Down" ),
|
|
|
|
KiBitmap( BITMAPS::down ) );
|
|
|
|
|
|
|
|
AddMenuItem( aMenu, ID_LAYER_DELETE, _( "Clear Current Layer..." ),
|
|
|
|
KiBitmap( BITMAPS::delete_gerber ) );
|
2017-09-22 10:36:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GERBER_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
|
|
|
|
{
|
|
|
|
wxMenu menu;
|
|
|
|
|
2018-02-28 09:21:37 +00:00
|
|
|
AddRightClickMenuItems( &menu );
|
2011-09-23 20:00:30 +00:00
|
|
|
PopupMenu( &menu );
|
|
|
|
|
|
|
|
passOnFocus();
|
|
|
|
}
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
|
|
|
|
{
|
2021-08-04 18:47:26 +00:00
|
|
|
int layer;
|
2014-06-27 17:07:42 +00:00
|
|
|
int rowCount;
|
|
|
|
int menuId = event.GetId();
|
2015-01-17 08:01:16 +00:00
|
|
|
bool visible = (menuId == ID_SHOW_ALL_LAYERS) ? true : false;
|
2019-04-10 13:40:01 +00:00
|
|
|
LSET visibleLayers;
|
2013-04-06 12:01:53 +00:00
|
|
|
bool force_active_layer_visible;
|
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
switch( menuId )
|
|
|
|
{
|
2013-04-06 12:01:53 +00:00
|
|
|
case ID_SHOW_ALL_LAYERS:
|
|
|
|
case ID_SHOW_NO_LAYERS:
|
|
|
|
case ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE:
|
|
|
|
case ID_SHOW_NO_LAYERS_BUT_ACTIVE:
|
2018-02-28 09:21:37 +00:00
|
|
|
// Set the display layers options. Sorting layers has no effect to these options
|
|
|
|
m_alwaysShowActiveLayer = ( menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
|
|
|
|
force_active_layer_visible = ( menuId == ID_SHOW_NO_LAYERS_BUT_ACTIVE ||
|
|
|
|
menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
|
2019-04-10 13:40:01 +00:00
|
|
|
|
2018-02-28 09:21:37 +00:00
|
|
|
// Update icons and check boxes
|
2011-09-23 20:00:30 +00:00
|
|
|
rowCount = GetLayerRowCount();
|
2019-04-10 13:40:01 +00:00
|
|
|
|
|
|
|
for( int row = 0; row < rowCount; ++row )
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
2014-07-20 17:41:12 +00:00
|
|
|
wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
|
2021-08-04 18:47:26 +00:00
|
|
|
layer = getDecodedId( cb->GetId() );
|
2012-02-17 19:43:43 +00:00
|
|
|
bool loc_visible = visible;
|
2013-04-06 12:01:53 +00:00
|
|
|
|
2021-06-06 22:57:10 +00:00
|
|
|
if( force_active_layer_visible && (layer == m_frame->GetActiveLayer() ) )
|
2012-02-17 19:43:43 +00:00
|
|
|
loc_visible = true;
|
|
|
|
|
|
|
|
cb->SetValue( loc_visible );
|
2019-04-10 13:40:01 +00:00
|
|
|
visibleLayers[ row ] = loc_visible;
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame->SetVisibleLayers( visibleLayers );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
2011-09-23 20:00:30 +00:00
|
|
|
break;
|
2014-11-22 11:52:57 +00:00
|
|
|
|
2021-08-02 20:00:34 +00:00
|
|
|
case ID_SORT_GBR_LAYERS_X2:
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame->SortLayersByX2Attributes();
|
2014-11-22 11:52:57 +00:00
|
|
|
break;
|
2021-08-02 20:00:34 +00:00
|
|
|
|
|
|
|
case ID_SORT_GBR_LAYERS_FILE_EXT:
|
|
|
|
m_frame->SortLayersByFileExtension();
|
|
|
|
break;
|
2021-08-04 18:47:26 +00:00
|
|
|
|
2023-09-06 16:54:54 +00:00
|
|
|
case ID_SET_GBR_LAYERS_DRAW_PRMS:
|
|
|
|
m_frame->SetLayerDrawPrms();
|
|
|
|
break;
|
|
|
|
|
2021-08-04 18:47:26 +00:00
|
|
|
case ID_LAYER_MOVE_UP:
|
2023-06-26 22:16:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( GERBVIEW_ACTIONS::moveLayerUp );
|
2021-08-04 18:47:26 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LAYER_MOVE_DOWN:
|
2023-06-26 22:16:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( GERBVIEW_ACTIONS::moveLayerDown );
|
2021-08-04 18:47:26 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_LAYER_DELETE:
|
|
|
|
m_frame->Erase_Current_DrawLayer( false );
|
|
|
|
|
|
|
|
break;
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-06 12:01:53 +00:00
|
|
|
bool GERBER_LAYER_WIDGET::OnLayerSelected()
|
|
|
|
{
|
|
|
|
if( !m_alwaysShowActiveLayer )
|
|
|
|
return false;
|
|
|
|
|
2021-07-16 20:13:26 +00:00
|
|
|
// postprocess after active layer selection ensure active layer visible
|
2013-04-06 12:01:53 +00:00
|
|
|
wxCommandEvent event;
|
|
|
|
event.SetId( ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
|
|
|
|
onPopupSelection( event );
|
|
|
|
return true;
|
|
|
|
}
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
void GERBER_LAYER_WIDGET::ReFill()
|
|
|
|
{
|
2021-08-04 17:44:26 +00:00
|
|
|
ClearLayerRows();
|
|
|
|
|
2014-11-22 11:52:57 +00:00
|
|
|
Freeze();
|
|
|
|
|
2014-06-27 17:07:42 +00:00
|
|
|
for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
2021-08-04 17:44:26 +00:00
|
|
|
// Don't show inactive layers
|
|
|
|
if ( GetImagesList()->GetGbrImage(layer) == nullptr )
|
|
|
|
continue;
|
|
|
|
|
2020-05-02 20:09:43 +00:00
|
|
|
int aRow = findLayerRow( layer );
|
|
|
|
bool visible = true;
|
2021-06-06 22:57:10 +00:00
|
|
|
COLOR4D color = m_frame->GetLayerColor( GERBER_DRAW_LAYER( layer ) );
|
2021-07-31 09:30:31 +00:00
|
|
|
wxString msg = GetImagesList()->GetDisplayName( layer,
|
|
|
|
/* include layer number */ false,
|
2021-03-26 15:47:02 +00:00
|
|
|
/* Get the full name */ true );
|
2014-11-22 11:52:57 +00:00
|
|
|
|
2021-06-06 22:57:10 +00:00
|
|
|
if( m_frame->GetCanvas() )
|
|
|
|
visible = m_frame->GetCanvas()->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( layer ) );
|
2017-09-17 22:43:20 +00:00
|
|
|
else
|
2021-06-06 22:57:10 +00:00
|
|
|
visible = m_frame->IsLayerVisible( layer );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2020-05-02 20:09:43 +00:00
|
|
|
if( aRow >= 0 )
|
2021-07-31 09:30:31 +00:00
|
|
|
{
|
2020-05-02 20:09:43 +00:00
|
|
|
updateLayerRow( findLayerRow( layer ), msg );
|
2021-07-31 09:30:31 +00:00
|
|
|
SetLayerVisible( layer, visible );
|
|
|
|
}
|
2020-05-02 20:09:43 +00:00
|
|
|
else
|
|
|
|
AppendLayerRow( LAYER_WIDGET::ROW( msg, layer, color, wxEmptyString, visible, true ) );
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
|
2018-08-03 19:41:57 +00:00
|
|
|
UpdateLayouts();
|
2014-11-22 11:52:57 +00:00
|
|
|
Thaw();
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-22 10:36:47 +00:00
|
|
|
void GERBER_LAYER_WIDGET::OnLayerRightClick( wxMenu& aMenu )
|
|
|
|
{
|
2018-02-28 09:21:37 +00:00
|
|
|
AddRightClickMenuItems( &aMenu );
|
2017-09-22 10:36:47 +00:00
|
|
|
}
|
|
|
|
|
2018-03-04 04:43:16 +00:00
|
|
|
|
2021-07-26 17:28:37 +00:00
|
|
|
void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, const COLOR4D& aColor )
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
2018-03-04 04:43:16 +00:00
|
|
|
// NOTE: Active layer in GerbView is stored as 0-indexed, but layer color is
|
|
|
|
// stored according to the GERBER_DRAW_LAYER() offset.
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame->SetLayerColor( GERBER_DRAW_LAYER( aLayer ), aColor );
|
|
|
|
m_frame->m_SelLayerBox->ResyncBitmapOnly();
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2021-06-06 22:57:10 +00:00
|
|
|
KIGFX::VIEW* view = m_frame->GetCanvas()->GetView();
|
2022-09-11 12:38:33 +00:00
|
|
|
COLOR_SETTINGS* color_settings = m_frame->GetColorSettings();
|
|
|
|
color_settings->SetColor( aLayer, aColor );
|
|
|
|
|
|
|
|
view->GetPainter()->GetSettings()->LoadColors( color_settings );
|
2019-05-27 16:16:54 +00:00
|
|
|
view->UpdateLayerColor( GERBER_DRAW_LAYER( aLayer ) );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame->GetCanvas()->Refresh();
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
|
2018-03-04 04:43:16 +00:00
|
|
|
|
2014-06-27 17:07:42 +00:00
|
|
|
bool GERBER_LAYER_WIDGET::OnLayerSelect( int aLayer )
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
|
|
|
// the layer change from the GERBER_LAYER_WIDGET can be denied by returning
|
|
|
|
// false from this function.
|
2021-06-06 22:57:10 +00:00
|
|
|
int layer = m_frame->GetActiveLayer();
|
2018-03-04 04:43:16 +00:00
|
|
|
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame->SetActiveLayer( aLayer, false );
|
|
|
|
m_frame->syncLayerBox();
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2021-06-06 22:57:10 +00:00
|
|
|
if( layer != m_frame->GetActiveLayer() )
|
2013-04-06 12:01:53 +00:00
|
|
|
{
|
|
|
|
if( ! OnLayerSelected() )
|
2021-03-13 17:45:33 +00:00
|
|
|
{
|
|
|
|
auto settings = static_cast<KIGFX::GERBVIEW_PAINTER*>
|
2021-06-06 22:57:10 +00:00
|
|
|
( m_frame->GetCanvas()->GetView()->GetPainter() )->GetSettings();
|
|
|
|
int dcodeSelected = m_frame->m_DCodeSelector->GetSelectedDCodeId();
|
2021-03-13 17:45:33 +00:00
|
|
|
settings->m_dcodeHighlightValue = dcodeSelected;
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame->GetCanvas()->GetView()->UpdateAllItems( KIGFX::COLOR );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
2021-03-13 17:45:33 +00:00
|
|
|
}
|
2013-04-06 12:01:53 +00:00
|
|
|
}
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-03-04 04:43:16 +00:00
|
|
|
|
2014-06-27 17:07:42 +00:00
|
|
|
void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
2021-06-06 22:57:10 +00:00
|
|
|
LSET visibleLayers = m_frame->GetVisibleLayers();
|
2011-09-23 20:00:30 +00:00
|
|
|
|
2019-04-10 13:40:01 +00:00
|
|
|
visibleLayers[ aLayer ] = isVisible;
|
2011-09-23 20:00:30 +00:00
|
|
|
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame->SetVisibleLayers( visibleLayers );
|
2011-09-23 20:00:30 +00:00
|
|
|
|
|
|
|
if( isFinal )
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame->GetCanvas()->Refresh();
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
|
2021-06-06 22:36:31 +00:00
|
|
|
|
2021-07-26 17:28:37 +00:00
|
|
|
void GERBER_LAYER_WIDGET::OnRenderColorChange( int aId, const COLOR4D& aColor )
|
2011-09-23 20:00:30 +00:00
|
|
|
{
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame->SetVisibleElementColor( aId, aColor );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2021-06-06 22:57:10 +00:00
|
|
|
auto view = m_frame->GetCanvas()->GetView();
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2022-09-11 12:38:33 +00:00
|
|
|
COLOR_SETTINGS* color_settings = m_frame->GetColorSettings();
|
|
|
|
color_settings->SetColor( aId, aColor );
|
|
|
|
|
|
|
|
view->GetPainter()->GetSettings()->LoadColors( color_settings );
|
2019-05-27 16:16:54 +00:00
|
|
|
view->UpdateLayerColor( aId );
|
|
|
|
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
|
|
|
view->UpdateAllItems( KIGFX::COLOR );
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame->GetCanvas()->Refresh();
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|
|
|
|
|
2018-03-04 04:43:16 +00:00
|
|
|
|
2011-09-23 20:00:30 +00:00
|
|
|
void GERBER_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
|
|
|
|
{
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame->SetElementVisibility( aId, isEnabled );
|
2017-09-17 22:43:20 +00:00
|
|
|
|
2021-06-06 22:57:10 +00:00
|
|
|
if( m_frame->GetCanvas() )
|
2017-09-17 22:43:20 +00:00
|
|
|
{
|
|
|
|
if( aId == LAYER_GERBVIEW_GRID )
|
|
|
|
{
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame->GetCanvas()->GetGAL()->SetGridVisibility( m_frame->IsGridVisible() );
|
|
|
|
m_frame->GetCanvas()->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
|
2017-09-17 22:43:20 +00:00
|
|
|
}
|
|
|
|
else
|
2021-07-16 20:13:26 +00:00
|
|
|
{
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame->GetCanvas()->GetView()->SetLayerVisible( aId, isEnabled );
|
2021-07-16 20:13:26 +00:00
|
|
|
}
|
2017-09-17 22:43:20 +00:00
|
|
|
}
|
|
|
|
|
2021-06-06 22:57:10 +00:00
|
|
|
m_frame->GetCanvas()->Refresh();
|
2011-09-23 20:00:30 +00:00
|
|
|
}
|