Better handling of disabled layers when editing a footprint (value, ref) from the board editor (avoid the "illegal layer" message box when possible).
This commit is contained in:
parent
7480bcf1ae
commit
dcdf9066b9
|
@ -7,9 +7,9 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1992-2012 Jean-Pierre Charras <jean-pierre.charras@ujf-grenoble.fr>
|
* Copyright (C) 1992-2015 Jean-Pierre Charras <jean-pierre.charras@ujf-grenoble.fr>
|
||||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
|
* Copyright (C) 1992-2015 KiCad Developers, see change_log.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -84,17 +84,25 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
|
||||||
|
|
||||||
const int BM_SIZE = 14;
|
const int BM_SIZE = 14;
|
||||||
|
|
||||||
LSET show = getEnabledLayers() & ~m_layerMaskDisable;
|
LSET show = LSET::AllLayersMask() & ~m_layerMaskDisable;
|
||||||
|
LSET activated = getEnabledLayers() & ~m_layerMaskDisable;
|
||||||
|
wxString layerstatus;
|
||||||
|
|
||||||
for( LSEQ seq = show.UIOrder(); seq; ++seq )
|
for( LSEQ seq = show.UIOrder(); seq; ++seq )
|
||||||
{
|
{
|
||||||
LAYER_ID layerid = *seq;
|
LAYER_ID layerid = *seq;
|
||||||
|
|
||||||
wxBitmap layerbmp( BM_SIZE, BM_SIZE );
|
if( !m_showNotEnabledBrdlayers && !activated[layerid] )
|
||||||
|
continue;
|
||||||
|
else if( !activated[layerid] )
|
||||||
|
layerstatus = wxT( " " ) + _( "(not activated)" );
|
||||||
|
else
|
||||||
|
layerstatus.Empty();
|
||||||
|
|
||||||
|
wxBitmap layerbmp( BM_SIZE, BM_SIZE );
|
||||||
SetBitmapLayer( layerbmp, layerid );
|
SetBitmapLayer( layerbmp, layerid );
|
||||||
|
|
||||||
wxString layername = GetLayerName( layerid );
|
wxString layername = GetLayerName( layerid ) + layerstatus;
|
||||||
|
|
||||||
if( m_layerhotkeys && m_hotkeys )
|
if( m_layerhotkeys && m_hotkeys )
|
||||||
{
|
{
|
||||||
|
@ -107,9 +115,7 @@ void PCB_LAYER_BOX_SELECTOR::Resync()
|
||||||
Append( layername, layerbmp, (void*)(intptr_t) layerid );
|
Append( layername, layerbmp, (void*)(intptr_t) layerid );
|
||||||
|
|
||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
dc.GetTextExtent ( layername, &w, &h );
|
dc.GetTextExtent ( layername, &w, &h );
|
||||||
|
|
||||||
minwidth = std::max( minwidth, w );
|
minwidth = std::max( minwidth, w );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2014 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
* Copyright (C) 2012-2015 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
||||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -36,7 +36,10 @@ class PCB_LAYER_BOX_SELECTOR : public LAYER_BOX_SELECTOR
|
||||||
{
|
{
|
||||||
PCB_BASE_FRAME* m_boardFrame;
|
PCB_BASE_FRAME* m_boardFrame;
|
||||||
|
|
||||||
LSET m_layerMaskDisable; // A mask to remove some layers from layer list
|
LSET m_layerMaskDisable; // A mask to remove some (not allowed) layers
|
||||||
|
// from layer list
|
||||||
|
bool m_showNotEnabledBrdlayers; // true to list all allowed layers
|
||||||
|
// (with not activated layers flagged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Hotkey Info
|
// Hotkey Info
|
||||||
|
@ -44,7 +47,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// If you are thinking the constructor is a bit curious,
|
// If you are thinking the constructor is a bit curious,
|
||||||
// just remember it is used by automaticallty generated by wxFormBuilder files,
|
// just remember it is used by automatically generated by wxFormBuilder files,
|
||||||
// and it should mimic the wxBitmapComboBox constructor.
|
// and it should mimic the wxBitmapComboBox constructor.
|
||||||
// Therefore, value, style are not yet used,
|
// Therefore, value, style are not yet used,
|
||||||
// but they are here for compatibility
|
// but they are here for compatibility
|
||||||
|
@ -57,6 +60,7 @@ public:
|
||||||
{
|
{
|
||||||
m_boardFrame = NULL;
|
m_boardFrame = NULL;
|
||||||
m_hotkeys = NULL;
|
m_hotkeys = NULL;
|
||||||
|
m_showNotEnabledBrdlayers = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
|
@ -67,13 +71,21 @@ public:
|
||||||
void SetBoardFrame( PCB_BASE_FRAME* aFrame ) { m_boardFrame = aFrame; };
|
void SetBoardFrame( PCB_BASE_FRAME* aFrame ) { m_boardFrame = aFrame; };
|
||||||
|
|
||||||
// SetLayerSet allows disableing some layers, which are not
|
// SetLayerSet allows disableing some layers, which are not
|
||||||
// shown in list;
|
// shown in list
|
||||||
void SetLayerSet( LSET aMask ) { m_layerMaskDisable = aMask; }
|
void SetLayerSet( LSET aMask ) { m_layerMaskDisable = aMask; }
|
||||||
|
|
||||||
// Reload the Layers names and bitmaps
|
// Reload the Layers names and bitmaps
|
||||||
// Virtual function
|
// Virtual function
|
||||||
void Resync();
|
void Resync();
|
||||||
|
|
||||||
|
// Allow (or not) the layers not activated for the current board to be shown
|
||||||
|
// in layer selector. Not actavated layers are flagged
|
||||||
|
// ( "(not activated)" added to the layer name )
|
||||||
|
void ShowNonActivatedLayers( bool aShow )
|
||||||
|
{
|
||||||
|
m_showNotEnabledBrdlayers = aShow;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Returns a color index from the layer id
|
// Returns a color index from the layer id
|
||||||
// Virtual function
|
// Virtual function
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Jean-Pierre Charras
|
* Copyright (C) 2015 Jean-Pierre Charras
|
||||||
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
|
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
|
||||||
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
|
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
|
||||||
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -43,6 +43,7 @@
|
||||||
|
|
||||||
#include <class_module.h>
|
#include <class_module.h>
|
||||||
#include <class_text_mod.h>
|
#include <class_text_mod.h>
|
||||||
|
#include <class_board.h>
|
||||||
|
|
||||||
#include <dialog_edit_module_text.h>
|
#include <dialog_edit_module_text.h>
|
||||||
|
|
||||||
|
@ -162,6 +163,11 @@ void DialogEditModuleText::initDlg( )
|
||||||
m_Show->SetSelection( 1 );
|
m_Show->SetSelection( 1 );
|
||||||
|
|
||||||
// Configure the layers list selector
|
// Configure the layers list selector
|
||||||
|
if( !m_parent->GetBoard()->IsLayerEnabled( m_currentText->GetLayer() ) )
|
||||||
|
// Footprints are built outside the current board, so items cann be
|
||||||
|
// on a not activated layer, therefore show it if happens.
|
||||||
|
m_LayerSelectionCtrl->ShowNonActivatedLayers( true );
|
||||||
|
|
||||||
m_LayerSelectionCtrl->SetLayersHotkeys( false );
|
m_LayerSelectionCtrl->SetLayersHotkeys( false );
|
||||||
m_LayerSelectionCtrl->SetLayerSet( forbiddenLayers );
|
m_LayerSelectionCtrl->SetLayerSet( forbiddenLayers );
|
||||||
m_LayerSelectionCtrl->SetBoardFrame( m_parent );
|
m_LayerSelectionCtrl->SetBoardFrame( m_parent );
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||||
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||||
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
@ -134,6 +134,11 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent,
|
||||||
AddUnitSymbol( *m_staticTextPosY );
|
AddUnitSymbol( *m_staticTextPosY );
|
||||||
|
|
||||||
// Configure the layers list selector
|
// Configure the layers list selector
|
||||||
|
if( !m_Parent->GetBoard()->IsLayerEnabled( aDimension->GetLayer() ) )
|
||||||
|
// Should not happens, because one acnnot select a board item on a
|
||||||
|
// not activated layer, but ...
|
||||||
|
m_SelLayerBox->ShowNonActivatedLayers( true );
|
||||||
|
|
||||||
m_SelLayerBox->SetLayersHotkeys( false );
|
m_SelLayerBox->SetLayersHotkeys( false );
|
||||||
m_SelLayerBox->SetLayerSet( LSET::AllCuMask().set( Edge_Cuts ) );
|
m_SelLayerBox->SetLayerSet( LSET::AllCuMask().set( Edge_Cuts ) );
|
||||||
m_SelLayerBox->SetBoardFrame( m_Parent );
|
m_SelLayerBox->SetBoardFrame( m_Parent );
|
||||||
|
@ -160,6 +165,15 @@ void DIALOG_DIMENSION_EDITOR::OnCancelClick( wxCommandEvent& event )
|
||||||
|
|
||||||
void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
|
void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
|
LAYER_ID newlayer = ToLAYER_ID( m_SelLayerBox->GetLayerSelection() );
|
||||||
|
|
||||||
|
if( !m_Parent->GetBoard()->IsLayerEnabled( newlayer ) )
|
||||||
|
{
|
||||||
|
wxMessageBox( _( "the layer currently selected is not enabled for this board\n"
|
||||||
|
"You cannot use it" ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef USE_WX_OVERLAY
|
#ifndef USE_WX_OVERLAY
|
||||||
if( m_DC ) // Delete old text.
|
if( m_DC ) // Delete old text.
|
||||||
{
|
{
|
||||||
|
@ -208,7 +222,7 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
|
||||||
|
|
||||||
CurrentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false );
|
CurrentDimension->Text().SetMirrored( ( m_rbMirror->GetSelection() == 1 ) ? true : false );
|
||||||
|
|
||||||
CurrentDimension->SetLayer( ToLAYER_ID( m_SelLayerBox->GetLayerSelection() ) );
|
CurrentDimension->SetLayer( newlayer );
|
||||||
#ifndef USE_WX_OVERLAY
|
#ifndef USE_WX_OVERLAY
|
||||||
if( m_DC ) // Display new text
|
if( m_DC ) // Display new text
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue