Pcbnew: delete objects from removed layers.
This fixes potential DRC false positive bugs that occur when inner layers are removed from the board but the actual objects on contained on those layers remain in the board. Since Pcbnew does not handle odd number layers, this is not a perfect fix. When the user chooses the front or back layer only options from the layer setup dialog, objects on the copper layers will not be removed. This will not cause the false positive issue described above. Get rid of dialog OK and cancel button event handlers and use the proper TranferData(To/From)Window for handling control data. Add PCB_LAYER_COLLECTOR for collecting board objects by layer. Factor out redundant [] operators into base PCB_COLLECTOR object. Fixes lp:893950 https://bugs.launchpad.net/kicad/+bug/893950
This commit is contained in:
parent
517921e2e1
commit
ded4ad9b17
|
@ -126,9 +126,8 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Operator []
|
||||
* overloads COLLECTOR::operator[](int) to return a SCH_ITEM* instead of
|
||||
* an EDA_ITEM* type.
|
||||
* Overload COLLECTOR::operator[](int) to return a SCH_ITEM instead of an EDA_ITEM.
|
||||
*
|
||||
* @param aIndex The index into the list.
|
||||
* @return SCH_ITEM* at \a aIndex or NULL.
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2004-2007 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2004-2007 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -31,12 +31,11 @@
|
|||
#include <class_marker_pcb.h>
|
||||
|
||||
|
||||
/* This module contains out of line member functions for classes given in
|
||||
* collectors.h. Those classes augment the functionality of class PCB_EDIT_FRAME.
|
||||
/* This module contains out of line member functions for classes given in
|
||||
* collectors.h. Those classes augment the functionality of class PCB_EDIT_FRAME.
|
||||
*/
|
||||
|
||||
|
||||
// see collectors.h
|
||||
const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
|
||||
// there are some restrictions on the order of items in the general case.
|
||||
// all items in m_Drawings for instance should be contiguous.
|
||||
|
@ -57,17 +56,19 @@ const KICAD_T GENERAL_COLLECTOR::AllBoardItems[] = {
|
|||
};
|
||||
|
||||
|
||||
/*
|
||||
* const KICAD_T GENERAL_COLLECTOR::PrimaryItems[] = {
|
||||
* PCB_TEXT_T,
|
||||
* PCB_LINE_T,
|
||||
* PCB_DIMENSION_T,
|
||||
* PCB_VIA_T,
|
||||
* PCB_TRACE_T,
|
||||
* PCB_MODULE_T,
|
||||
* EOT
|
||||
* };
|
||||
*/
|
||||
const KICAD_T GENERAL_COLLECTOR::BoardLevelItems[] = {
|
||||
PCB_MARKER_T,
|
||||
PCB_TEXT_T,
|
||||
PCB_LINE_T,
|
||||
PCB_DIMENSION_T,
|
||||
PCB_TARGET_T,
|
||||
PCB_VIA_T,
|
||||
PCB_TRACE_T,
|
||||
PCB_MODULE_T,
|
||||
PCB_ZONE_T,
|
||||
PCB_ZONE_AREA_T,
|
||||
EOT
|
||||
};
|
||||
|
||||
|
||||
const KICAD_T GENERAL_COLLECTOR::AllButZones[] = {
|
||||
|
@ -140,18 +141,6 @@ const KICAD_T GENERAL_COLLECTOR::Zones[] = {
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* Function Inspect
|
||||
* is the examining function within the INSPECTOR which is passed to the
|
||||
* Iterate function. Searches and collects all the objects that the old
|
||||
* function PcbGeneralLocateAndDisplay() would find, except that it keeps all
|
||||
* that it finds and does not do any displaying.
|
||||
*
|
||||
* @param testItem An EDA_ITEM to examine.
|
||||
* @param testData not used here.
|
||||
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
||||
* else SCAN_CONTINUE;
|
||||
*/
|
||||
SEARCH_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
||||
{
|
||||
BOARD_ITEM* item = (BOARD_ITEM*) testItem;
|
||||
|
@ -443,7 +432,6 @@ exit:
|
|||
}
|
||||
|
||||
|
||||
// see collectors.h
|
||||
void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
|
||||
const wxPoint& aRefPos, const COLLECTORS_GUIDE& aGuide )
|
||||
{
|
||||
|
@ -474,10 +462,9 @@ void GENERAL_COLLECTOR::Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
|
|||
}
|
||||
|
||||
|
||||
// see collectors.h
|
||||
SEARCH_RESULT PCB_TYPE_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
||||
{
|
||||
// The Vist() function only visits the testItem if its type was in the
|
||||
// The Visit() function only visits the testItem if its type was in the
|
||||
// the scanList, so therefore we can collect anything given to us here.
|
||||
Append( testItem );
|
||||
|
||||
|
@ -491,3 +478,22 @@ void PCB_TYPE_COLLECTOR::Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[]
|
|||
|
||||
aBoard->Visit( m_inspector, NULL, aScanList );
|
||||
}
|
||||
|
||||
|
||||
SEARCH_RESULT PCB_LAYER_COLLECTOR::Inspect( EDA_ITEM* testItem, void* testData )
|
||||
{
|
||||
BOARD_ITEM* item = (BOARD_ITEM*) testItem;
|
||||
|
||||
if( item->GetLayer() == m_layer_id )
|
||||
Append( testItem );
|
||||
|
||||
return SEARCH_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
void PCB_LAYER_COLLECTOR::Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[] )
|
||||
{
|
||||
Empty();
|
||||
|
||||
aBoard->Visit( m_inspector, NULL, aScanList );
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2004-2007 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2004-2017 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -31,8 +31,8 @@
|
|||
|
||||
|
||||
/* This module contains a number of COLLECTOR implementations which are used
|
||||
to augment the functionality of class PCB_EDIT_FRAME.
|
||||
*/
|
||||
* to augment the functionality of class PCB_EDIT_FRAME.
|
||||
*/
|
||||
|
||||
|
||||
#include <class_collector.h>
|
||||
|
@ -43,8 +43,7 @@ class BOARD_ITEM;
|
|||
|
||||
|
||||
/**
|
||||
* Class COLLECTORS_GUIDE
|
||||
* is an abstract base class whose derivatives may be passed to a GENERAL_COLLECTOR,
|
||||
* An abstract base class whose derivatives may be passed to a GENERAL_COLLECTOR,
|
||||
* telling GENERAL_COLLECTOR what should be collected (aside from HitTest()ing
|
||||
* and KICAD_T scanTypes[], information which are provided to the GENERAL_COLLECTOR
|
||||
* through attributes or arguments separately).
|
||||
|
@ -58,7 +57,7 @@ class BOARD_ITEM;
|
|||
* GENERAL_COLLECTOR::Inspect() can be kept as simple as possible, and insulated
|
||||
* from changes in global preference storage (and even then it is
|
||||
* not simple enough).
|
||||
* <p>
|
||||
* </p>
|
||||
* This class introduces the notion of layer locking.
|
||||
*/
|
||||
class COLLECTORS_GUIDE
|
||||
|
@ -68,106 +67,85 @@ public:
|
|||
virtual ~COLLECTORS_GUIDE() {}
|
||||
|
||||
/**
|
||||
* Function IsLayerLocked
|
||||
* @return bool - true if the given layer is locked, else false.
|
||||
*/
|
||||
virtual bool IsLayerLocked( PCB_LAYER_ID layer ) const = 0;
|
||||
|
||||
/**
|
||||
* Function IsLayerVisible
|
||||
* @return bool - true if the given layer is visible, else false.
|
||||
*/
|
||||
virtual bool IsLayerVisible( PCB_LAYER_ID layer ) const = 0;
|
||||
|
||||
/**
|
||||
* Function IgnoreLockedLayers
|
||||
* @return bool - true if should ignore locked layers, else false.
|
||||
*/
|
||||
virtual bool IgnoreLockedLayers() const = 0;
|
||||
|
||||
/**
|
||||
* Function IgnoredNonVisibleLayers
|
||||
* @return bool - true if should ignore non-visible layers, else false.
|
||||
*/
|
||||
virtual bool IgnoreNonVisibleLayers() const = 0;
|
||||
|
||||
/**
|
||||
* Function GetPreferredLayer
|
||||
* @return int - the preferred layer for HitTest()ing.
|
||||
*/
|
||||
virtual PCB_LAYER_ID GetPreferredLayer() const = 0;
|
||||
|
||||
/**
|
||||
* Function IgnorePreferredLayer
|
||||
* provides wildcard behavior regarding the preferred layer.
|
||||
* Provide wildcard behavior regarding the preferred layer.
|
||||
*
|
||||
* @return bool - true if should ignore preferred layer, else false.
|
||||
*/
|
||||
virtual bool IgnorePreferredLayer() const = 0;
|
||||
|
||||
/**
|
||||
* Function IgnoreLockedItems
|
||||
* @return bool - true if should ignore locked items, else false.
|
||||
*/
|
||||
virtual bool IgnoreLockedItems() const = 0;
|
||||
|
||||
/**
|
||||
* Function IncludeSecondary
|
||||
* determines if the secondary criteria, or 2nd choice items should be
|
||||
* included.
|
||||
* Determine if the secondary criteria or 2nd choice items should be included.
|
||||
*
|
||||
* @return bool - true if should include, else false.
|
||||
*/
|
||||
virtual bool IncludeSecondary() const = 0;
|
||||
|
||||
/**
|
||||
* Function IgnoreMTextsMarkedNoShow
|
||||
* @return bool - true if MTexts marked as "no show" should be ignored.
|
||||
*/
|
||||
virtual bool IgnoreMTextsMarkedNoShow() const = 0;
|
||||
|
||||
/**
|
||||
* Function IgnoreZones
|
||||
* @return bool - true if should ignore zones.
|
||||
virtual bool IgnoreZones() const = 0;
|
||||
can simply omit from scanTypes[] PCB_ZONE_T */
|
||||
|
||||
/**
|
||||
* Function IgnoreMTextsOnBack
|
||||
* @return bool - true if should ignore MTexts on back layers
|
||||
*/
|
||||
virtual bool IgnoreMTextsOnBack() const = 0;
|
||||
|
||||
/**
|
||||
* Function IgnoreMTextsOnFront
|
||||
* @return bool - true if should ignore MTexts on front layers.
|
||||
*/
|
||||
virtual bool IgnoreMTextsOnFront() const = 0;
|
||||
|
||||
/**
|
||||
* Function IgnoreModulesOnBack
|
||||
* @return bool - true if should ignore MODULEs on Back Side.
|
||||
*/
|
||||
virtual bool IgnoreModulesOnBack() const = 0;
|
||||
|
||||
/**
|
||||
* Function IgnoreModulesOnFront
|
||||
* @return bool - ture if should ignore MODULEs on Front Side.
|
||||
*/
|
||||
virtual bool IgnoreModulesOnFront() const = 0;
|
||||
|
||||
/**
|
||||
* Function IgnorePadsOnBack
|
||||
* @return bool - true if should ignore Pads on Back Side.
|
||||
*/
|
||||
virtual bool IgnorePadsOnBack() const = 0;
|
||||
|
||||
/**
|
||||
* Function IgnorePadsOnFront
|
||||
* @return bool - ture if should ignore PADSs on Front Side.
|
||||
*/
|
||||
virtual bool IgnorePadsOnFront() const = 0;
|
||||
|
||||
/**
|
||||
* Function IgnorePads
|
||||
* @return bool - true if should ignore PADSs on Front side and Back side.
|
||||
*/
|
||||
virtual bool IgnorePads() const
|
||||
|
@ -176,19 +154,16 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function IgnoreModulesVals
|
||||
* @return bool - true if should ignore modules values.
|
||||
*/
|
||||
virtual bool IgnoreModulesVals() const = 0;
|
||||
|
||||
/**
|
||||
* Function IgnoreModulesRefs
|
||||
* @return bool - true if should ignore module references.
|
||||
*/
|
||||
virtual bool IgnoreModulesRefs() const = 0;
|
||||
|
||||
/**
|
||||
* Function UseHitTesting
|
||||
* @return bool - true if Inspect() should use BOARD_ITEM::HitTest()
|
||||
* or false if Inspect() should use BOARD_ITEM::BoundsTest().
|
||||
virtual bool UseHitTesting() const = 0;
|
||||
|
@ -198,17 +173,43 @@ public:
|
|||
|
||||
|
||||
/**
|
||||
* Class GENERAL_COLLECTOR
|
||||
* is intended for use when the right click button is pressed, or when the
|
||||
* plain "arrow" tool is in effect. This class can be used by window classes
|
||||
* such as PCB_EDIT_FRAME.
|
||||
* Collect #BOARD_ITEM objects.
|
||||
*
|
||||
* All this object really does is override the [] operator and return a #BOARD_ITEM instead
|
||||
* of a #EDA_ITEM. Derive all board collector objects from this class instead of the base
|
||||
* #COLLECTOR object.
|
||||
*
|
||||
* @see class COLLECTOR
|
||||
*/
|
||||
class PCB_COLLECTOR : public COLLECTOR
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Overload the COLLECTOR::operator[](int) to return a #BOARD_ITEM instead of an #EDA_ITEM.
|
||||
*
|
||||
* @param ndx The index into the list.
|
||||
* @return BOARD_ITEM* - or something derived from it, or NULL.
|
||||
*/
|
||||
BOARD_ITEM* operator[]( int ndx ) const
|
||||
{
|
||||
if( (unsigned)ndx < (unsigned)GetCount() )
|
||||
return (BOARD_ITEM*) m_List[ ndx ];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Used when the right click button is pressed, or when the select tool is in effect.
|
||||
* This class can be used by window classes such as PCB_EDIT_FRAME.
|
||||
*
|
||||
* Philosophy: this class knows nothing of the context in which a BOARD is used
|
||||
* and that means it knows nothing about which layers are visible or current,
|
||||
* but can handle those concerns by the SetPreferredLayer() function and the
|
||||
* SetLayerSet() function.
|
||||
*/
|
||||
class GENERAL_COLLECTOR : public COLLECTOR
|
||||
class GENERAL_COLLECTOR : public PCB_COLLECTOR
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
|
@ -219,20 +220,17 @@ protected:
|
|||
*/
|
||||
std::vector<BOARD_ITEM*> m_List2nd;
|
||||
|
||||
|
||||
/**
|
||||
* Determines which items are to be collected by Inspect()
|
||||
*/
|
||||
const COLLECTORS_GUIDE* m_Guide;
|
||||
|
||||
|
||||
/**
|
||||
* The number of items that were originally in the primary list before the
|
||||
* m_List2nd was concatenated onto the end of it.
|
||||
*/
|
||||
int m_PrimaryLength;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -240,7 +238,6 @@ public:
|
|||
*/
|
||||
static const KICAD_T AllBoardItems[];
|
||||
|
||||
|
||||
/**
|
||||
* A scan list for all editable board items, except zones
|
||||
*/
|
||||
|
@ -251,20 +248,17 @@ public:
|
|||
*/
|
||||
static const KICAD_T Zones[];
|
||||
|
||||
|
||||
/**
|
||||
* A scan list for all primary board items, omitting items which are subordinate to
|
||||
* a MODULE, such as D_PAD and TEXTEMODULE.
|
||||
static const KICAD_T PrimaryItems[];
|
||||
*/
|
||||
|
||||
static const KICAD_T BoardLevelItems[];
|
||||
|
||||
/**
|
||||
* A scan list for only MODULEs
|
||||
*/
|
||||
static const KICAD_T Modules[];
|
||||
|
||||
|
||||
/**
|
||||
* A scan list for PADs or MODULEs
|
||||
*/
|
||||
|
@ -275,25 +269,21 @@ public:
|
|||
*/
|
||||
static const KICAD_T PadsTracksOrZones[];
|
||||
|
||||
|
||||
/**
|
||||
* A scan list for MODULEs and their items (for Modedit)
|
||||
*/
|
||||
static const KICAD_T ModulesAndTheirItems[];
|
||||
|
||||
|
||||
/**
|
||||
* A scan list for primary module items.
|
||||
*/
|
||||
static const KICAD_T ModuleItems[];
|
||||
|
||||
|
||||
/**
|
||||
* A scan list for only TRACKS
|
||||
*/
|
||||
static const KICAD_T Tracks[];
|
||||
|
||||
|
||||
/**
|
||||
* Constructor GENERALCOLLECTOR
|
||||
*/
|
||||
|
@ -314,39 +304,23 @@ public:
|
|||
m_List2nd.push_back( item );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function SetGuide
|
||||
* records which COLLECTORS_GUIDE to use.
|
||||
* Record which COLLECTORS_GUIDE to use.
|
||||
*
|
||||
* @param aGuide Which guide to use in the collection.
|
||||
*/
|
||||
void SetGuide( const COLLECTORS_GUIDE* aGuide ) { m_Guide = aGuide; }
|
||||
|
||||
|
||||
/**
|
||||
* Function operator[int]
|
||||
* overloads COLLECTOR::operator[](int) to return a BOARD_ITEM* instead of
|
||||
* an EDA_ITEM* type.
|
||||
* @param ndx The index into the list.
|
||||
* @return BOARD_ITEM* - or something derived from it, or NULL.
|
||||
*/
|
||||
BOARD_ITEM* operator[]( int ndx ) const
|
||||
{
|
||||
if( (unsigned)ndx < (unsigned)GetCount() )
|
||||
return (BOARD_ITEM*) m_List[ ndx ];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function GetPrimaryCount
|
||||
* @return int - The number if items which met the primary search criteria
|
||||
*/
|
||||
int GetPrimaryCount() { return m_PrimaryLength; }
|
||||
|
||||
/**
|
||||
* Function Inspect
|
||||
* is the examining function within the INSPECTOR which is passed to the
|
||||
* Iterate function.
|
||||
* The examining function within the INSPECTOR which is passed to the Iterate function.
|
||||
*
|
||||
* Searches and collects all the objects that the old function PcbGeneralLocateAndDisplay()
|
||||
* would find, except that it keeps all that it finds and does not do any displaying.
|
||||
*
|
||||
* @param testItem An EDA_ITEM to examine.
|
||||
* @param testData is not used in this class.
|
||||
|
@ -356,8 +330,8 @@ public:
|
|||
SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
||||
|
||||
/**
|
||||
* Function Collect
|
||||
* scans a BOARD_ITEM using this class's Inspector method, which does the collection.
|
||||
* Scan a BOARD_ITEM using this class's Inspector method, which does the collection.
|
||||
*
|
||||
* @param aItem A BOARD_ITEM to scan, may be a BOARD or MODULE, or whatever.
|
||||
* @param aScanList A list of KICAD_Ts with a terminating EOT, that specs
|
||||
* what is to be collected and the priority order of the resultant
|
||||
|
@ -371,8 +345,7 @@ public:
|
|||
|
||||
|
||||
/**
|
||||
* Class GENERAL_COLLECTORS_GUIDE
|
||||
* is a general implementation of a COLLECTORS_GUIDE. One of its constructors is
|
||||
* A general implementation of a COLLECTORS_GUIDE. One of its constructors is
|
||||
* entitled to grab information from the program's global preferences.
|
||||
*/
|
||||
class GENERAL_COLLECTORS_GUIDE : public COLLECTORS_GUIDE
|
||||
|
@ -406,9 +379,10 @@ private:
|
|||
public:
|
||||
|
||||
/**
|
||||
* Constructor GENERAL_COLLECTORS_GUIDE
|
||||
* grabs stuff from global preferences and uses reasonable defaults.
|
||||
* Grab stuff from global preferences and uses reasonable defaults.
|
||||
*
|
||||
* Add more constructors as needed.
|
||||
*
|
||||
* @param aVisibleLayerMask = current visible layers (bit mask)
|
||||
* @param aPreferredLayer = the layer to search first
|
||||
*/
|
||||
|
@ -440,9 +414,7 @@ public:
|
|||
m_IgnoreModulesRefs = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function IsLayerLocked
|
||||
* @return bool - true if the given layer is locked, else false.
|
||||
*/
|
||||
bool IsLayerLocked( PCB_LAYER_ID aLayerId ) const override
|
||||
|
@ -456,7 +428,6 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function IsLayerVisible
|
||||
* @return bool - true if the given layer is visible, else false.
|
||||
*/
|
||||
bool IsLayerVisible( PCB_LAYER_ID aLayerId ) const override
|
||||
|
@ -470,114 +441,94 @@ public:
|
|||
void SetLayerVisibleBits( LSET aLayerBits ) { m_LayerVisible = aLayerBits; }
|
||||
|
||||
/**
|
||||
* Function IgnoreLockedLayers
|
||||
* @return bool - true if should ignore locked layers, else false.
|
||||
*/
|
||||
bool IgnoreLockedLayers() const override { return m_IgnoreLockedLayers; }
|
||||
void SetIgnoreLockedLayers( bool ignore ) { m_IgnoreLockedLayers = ignore; }
|
||||
|
||||
|
||||
/**
|
||||
* Function IgnoredNonVisibleLayers
|
||||
* @return bool - true if should ignore non-visible layers, else false.
|
||||
*/
|
||||
bool IgnoreNonVisibleLayers() const override { return m_IgnoreNonVisibleLayers; }
|
||||
void SetIgnoreNonVisibleLayers( bool ignore ) { m_IgnoreLockedLayers = ignore; }
|
||||
|
||||
|
||||
/**
|
||||
* Function GetPreferredLayer
|
||||
* @return int - the preferred layer for HitTest()ing.
|
||||
*/
|
||||
PCB_LAYER_ID GetPreferredLayer() const override { return m_PreferredLayer; }
|
||||
void SetPreferredLayer( PCB_LAYER_ID aLayer ) { m_PreferredLayer = aLayer; }
|
||||
|
||||
|
||||
/**
|
||||
* Function IgnorePreferredLayer
|
||||
* provides wildcard behavior regarding the preferred layer.
|
||||
* Provide wildcard behavior regarding the preferred layer.
|
||||
*
|
||||
* @return bool - true if should ignore preferred layer, else false.
|
||||
*/
|
||||
bool IgnorePreferredLayer() const override { return m_IgnorePreferredLayer; }
|
||||
void SetIgnorePreferredLayer( bool ignore ) { m_IgnorePreferredLayer = ignore; }
|
||||
|
||||
|
||||
/**
|
||||
* Function IgnoreLockedItems
|
||||
* @return bool - true if should ignore locked items, else false.
|
||||
*/
|
||||
bool IgnoreLockedItems() const override { return m_IgnoreLockedItems; }
|
||||
void SetIgnoreLockedItems( bool ignore ) { m_IgnoreLockedItems = ignore; }
|
||||
|
||||
|
||||
/**
|
||||
* Function IncludeSecondary
|
||||
* determines if the secondary criteria, or 2nd choice items should be
|
||||
* included.
|
||||
* Determine if the secondary criteria, or 2nd choice items should be included.
|
||||
*
|
||||
* @return bool - true if should include, else false.
|
||||
*/
|
||||
bool IncludeSecondary() const override { return m_IncludeSecondary; }
|
||||
void SetIncludeSecondary( bool include ) { m_IncludeSecondary = include; }
|
||||
|
||||
|
||||
/**
|
||||
* Function IgnoreMTextsMarkedNoShow
|
||||
* @return bool - true if MTexts marked as "no show" should be ignored.
|
||||
*/
|
||||
bool IgnoreMTextsMarkedNoShow() const override { return m_IgnoreMTextsMarkedNoShow; }
|
||||
void SetIgnoreMTextsMarkedNoShow( bool ignore ) { m_IgnoreMTextsMarkedNoShow = ignore; }
|
||||
|
||||
/**
|
||||
* Function IgnoreMTextsOnCu
|
||||
* @return bool - true if should ignore MTexts on back layers
|
||||
*/
|
||||
bool IgnoreMTextsOnBack() const override { return m_IgnoreMTextsOnBack; }
|
||||
void SetIgnoreMTextsOnBack( bool ignore ) { m_IgnoreMTextsOnBack = ignore; }
|
||||
|
||||
/**
|
||||
* Function IgnoreMTextsOnFront
|
||||
* @return bool - true if should ignore MTexts on front layers
|
||||
*/
|
||||
bool IgnoreMTextsOnFront() const override { return m_IgnoreMTextsOnFront; }
|
||||
void SetIgnoreMTextsOnFront( bool ignore ) { m_IgnoreMTextsOnFront = ignore; }
|
||||
|
||||
/**
|
||||
* Function IgnoreModulesOnBack
|
||||
* @return bool - true if should ignore MODULEs on the back side
|
||||
*/
|
||||
bool IgnoreModulesOnBack() const override { return m_IgnoreModulesOnBack; }
|
||||
void SetIgnoreModulesOnBack( bool ignore ) { m_IgnoreModulesOnBack = ignore; }
|
||||
|
||||
/**
|
||||
* Function IgnoreModulesOnFront
|
||||
* @return bool - true if should ignore MODULEs on component layer.
|
||||
*/
|
||||
bool IgnoreModulesOnFront() const override { return m_IgnoreModulesOnFront; }
|
||||
void SetIgnoreModulesOnFront( bool ignore ) { m_IgnoreModulesOnFront = ignore; }
|
||||
|
||||
/**
|
||||
* Function IgnorePadsOnBack
|
||||
* @return bool - true if should ignore Pads on Back Side.
|
||||
*/
|
||||
bool IgnorePadsOnBack() const override { return m_IgnorePadsOnBack; }
|
||||
void SetIgnorePadsOnBack(bool ignore) { m_IgnorePadsOnBack = ignore; }
|
||||
|
||||
/**
|
||||
* Function IgnorePadsOnFront
|
||||
* @return bool - true if should ignore PADSs on Front Side.
|
||||
*/
|
||||
bool IgnorePadsOnFront() const override { return m_IgnorePadsOnFront; }
|
||||
void SetIgnorePadsOnFront(bool ignore) { m_IgnorePadsOnFront = ignore; }
|
||||
|
||||
/**
|
||||
* Function IgnoreModulesVals
|
||||
* @return bool - true if should ignore modules values.
|
||||
*/
|
||||
bool IgnoreModulesVals() const override { return m_IgnoreModulesVals; }
|
||||
void SetIgnoreModulesVals(bool ignore) { m_IgnoreModulesVals = ignore; }
|
||||
|
||||
/**
|
||||
* Function IgnoreModulesRefs
|
||||
* @return bool - true if should ignore modules references.
|
||||
*/
|
||||
bool IgnoreModulesRefs() const override { return m_IgnoreModulesRefs; }
|
||||
|
@ -586,32 +537,16 @@ public:
|
|||
|
||||
|
||||
/**
|
||||
* Class PCB_TYPE_COLLECTOR
|
||||
* merely gathers up all BOARD_ITEMs of a given set of KICAD_T type(s).
|
||||
* Collect all #BOARD_ITEM objects of a given set of #KICAD_T type(s).
|
||||
*
|
||||
* @see class COLLECTOR
|
||||
*/
|
||||
class PCB_TYPE_COLLECTOR : public COLLECTOR
|
||||
class PCB_TYPE_COLLECTOR : public PCB_COLLECTOR
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Function operator[int]
|
||||
* overloads COLLECTOR::operator[](int) to return a BOARD_ITEM* instead of
|
||||
* an EDA_ITEM* type.
|
||||
* @param ndx The index into the list.
|
||||
* @return BOARD_ITEM* - or something derived from it, or NULL.
|
||||
*/
|
||||
BOARD_ITEM* operator[]( int ndx ) const
|
||||
{
|
||||
if( (unsigned)ndx < (unsigned)GetCount() )
|
||||
return (BOARD_ITEM*) m_List[ ndx ];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function Inspect
|
||||
* is the examining function within the INSPECTOR which is passed to the
|
||||
* Iterate function.
|
||||
* The examining function within the INSPECTOR which is passed to the Iterate function.
|
||||
*
|
||||
* @param testItem An EDA_ITEM to examine.
|
||||
* @param testData is not used in this class.
|
||||
|
@ -621,9 +556,45 @@ public:
|
|||
SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
||||
|
||||
/**
|
||||
* Function Collect
|
||||
* scans a BOARD_ITEM using this class's Inspector method, which does
|
||||
* the collection.
|
||||
* Collect #BOARD_ITEM objects using this class's Inspector method, which does the collection.
|
||||
*
|
||||
* @param aBoard The BOARD_ITEM to scan.
|
||||
* @param aScanList The KICAD_Ts to gather up.
|
||||
*/
|
||||
void Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[] );
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Collect all #BOARD_ITEM objects on a given layer.
|
||||
*
|
||||
* This only uses the primary object layer for comparison.
|
||||
*/
|
||||
class PCB_LAYER_COLLECTOR : public PCB_COLLECTOR
|
||||
{
|
||||
PCB_LAYER_ID m_layer_id;
|
||||
|
||||
public:
|
||||
PCB_LAYER_COLLECTOR( PCB_LAYER_ID aLayerId = UNDEFINED_LAYER ) :
|
||||
m_layer_id( aLayerId )
|
||||
{
|
||||
}
|
||||
|
||||
void SetLayerId( PCB_LAYER_ID aLayerId ) { m_layer_id = aLayerId; }
|
||||
|
||||
/**
|
||||
* The examining function within the INSPECTOR which is passed to the iterate function.
|
||||
*
|
||||
* @param testItem An EDA_ITEM to examine.
|
||||
* @param testData is not used in this class.
|
||||
* @return SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan,
|
||||
* else SCAN_CONTINUE;
|
||||
*/
|
||||
SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
|
||||
|
||||
/**
|
||||
* Tests a BOARD_ITEM using this class's Inspector method, which does the collection.
|
||||
*
|
||||
* @param aBoard The BOARD_ITEM to scan.
|
||||
* @param aScanList The KICAD_Ts to gather up.
|
||||
*/
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009 Isaac Marino Bavaresco, isaacbavaresco@yahoo.com.br
|
||||
* Copyright (C) 2009 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2009 - 2015 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2009-2017 KiCad Developers, see change_log.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -32,6 +32,7 @@
|
|||
#include <invoke_pcb_dialog.h>
|
||||
|
||||
#include <class_board.h>
|
||||
#include <collectors.h>
|
||||
|
||||
#include <dialog_layers_setup_base.h>
|
||||
|
||||
|
@ -49,12 +50,12 @@
|
|||
|
||||
|
||||
/**
|
||||
* Struct CTLs
|
||||
* holds the 3 ui control pointers for a single board layer.
|
||||
* Holds the 3 UI control pointers for a single board layer.
|
||||
*/
|
||||
struct CTLs
|
||||
{
|
||||
CTLs( wxControl* aName, wxCheckBox* aCheckBox, wxControl* aChoiceOrDesc, wxPanel * aPanel = NULL)
|
||||
CTLs( wxControl* aName, wxCheckBox* aCheckBox, wxControl* aChoiceOrDesc,
|
||||
wxPanel* aPanel = NULL )
|
||||
{
|
||||
name = aName;
|
||||
checkbox = aCheckBox;
|
||||
|
@ -158,24 +159,28 @@ private:
|
|||
void showLayerTypes();
|
||||
void showPresets( LSET enabledLayerMask );
|
||||
|
||||
/** return the selected layer mask within the UI checkboxes */
|
||||
/** Return the selected layer mask within the UI checkboxes */
|
||||
LSET getUILayerMask();
|
||||
wxString getLayerName( LAYER_NUM layer );
|
||||
int getLayerTypeIndex( LAYER_NUM layer );
|
||||
|
||||
|
||||
void OnCancelButtonClick( wxCommandEvent& event ) override;
|
||||
void OnOkButtonClick( wxCommandEvent& event ) override;
|
||||
void OnInitDialog( wxInitDialogEvent& aEvent ) override;
|
||||
void OnCheckBox( wxCommandEvent& event ) override;
|
||||
void DenyChangeCheckBox( wxCommandEvent& event ) override;
|
||||
void OnPresetsChoice( wxCommandEvent& event ) override;
|
||||
void OnCopperLayersChoice( wxCommandEvent& event ) override;
|
||||
bool TransferDataToWindow() override;
|
||||
bool TransferDataFromWindow() override;
|
||||
|
||||
bool testLayerNames();
|
||||
|
||||
/**
|
||||
* Function getCTLs
|
||||
* maps \a aLayerNumber to the wx IDs for that layer which are
|
||||
* Return a list of layers removed from the board that contain items.
|
||||
*/
|
||||
LSEQ getRemovedLayersWithItems();
|
||||
|
||||
/**
|
||||
* Map \a aLayerNumber to the wx IDs for that layer which are
|
||||
* the layer name control ID, checkbox control ID, and choice control ID
|
||||
*/
|
||||
CTLs getCTLs( LAYER_NUM aLayerNumber );
|
||||
|
@ -236,7 +241,8 @@ static const LSET presets[] =
|
|||
LSET( 4, F_Cu, B_Cu, In1_Cu, In2_Cu ) | LSET::FrontTechMask() | LSET::UserMask(),
|
||||
|
||||
// "Four layers, parts on Front and Back"
|
||||
LSET( 4, F_Cu, B_Cu, In1_Cu, In2_Cu ) | LSET::FrontTechMask() | LSET::BackTechMask() | LSET::UserMask(),
|
||||
LSET( 4, F_Cu, B_Cu, In1_Cu, In2_Cu ) | LSET::FrontTechMask() | LSET::BackTechMask() |
|
||||
LSET::UserMask(),
|
||||
|
||||
// "All layers on",
|
||||
LSET().set(),
|
||||
|
@ -320,30 +326,27 @@ DIALOG_LAYERS_SETUP::DIALOG_LAYERS_SETUP( wxTopLevelWindow* aParent, BOARD* aBoa
|
|||
m_pcb = aBoard;
|
||||
|
||||
m_copperLayerCount = m_pcb->GetCopperLayerCount();
|
||||
showCopperChoice( m_copperLayerCount );
|
||||
setCopperLayerCheckBoxes( m_copperLayerCount );
|
||||
m_staticTextBrdThicknessUnit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
||||
PutValueInLocalUnits( *m_textCtrlBrdThickness,
|
||||
m_pcb->GetDesignSettings().GetBoardThickness() );
|
||||
|
||||
showBoardLayerNames();
|
||||
|
||||
m_enabledLayers = m_pcb->GetEnabledLayers();
|
||||
showSelectedLayerCheckBoxes( m_enabledLayers );
|
||||
showPresets( m_enabledLayers );
|
||||
|
||||
showLayerTypes();
|
||||
|
||||
SetAutoLayout( true );
|
||||
|
||||
// these 3 controls are handled outside wxformbuilder so that we can add
|
||||
// them without a sizer. Then we position them manually based on the column
|
||||
// widths from m_LayerListFlexGridSizer->GetColWidths()
|
||||
m_nameStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _("Name"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_nameStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _( "Name" ),
|
||||
wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
||||
m_enabledStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _("Enabled"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_enabledStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _( "Enabled" ),
|
||||
wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
||||
m_typeStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _("Type"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_typeStaticText = new wxStaticText( m_TitlePanel, wxID_ANY, _( "Type" ),
|
||||
wxDefaultPosition, wxDefaultSize, 0 );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_LAYERS_SETUP::OnInitDialog( wxInitDialogEvent& aEvent )
|
||||
{
|
||||
wxWindowBase::OnInitDialog( aEvent );
|
||||
|
||||
// set the height of the title panel to be the size of any wxStaticText object
|
||||
// plus 10 so we can have a border of 5 on both top and bottom.
|
||||
|
@ -353,20 +356,43 @@ DIALOG_LAYERS_SETUP::DIALOG_LAYERS_SETUP( wxTopLevelWindow* aParent, BOARD* aBoa
|
|||
|
||||
Layout();
|
||||
Fit();
|
||||
moveTitles();
|
||||
|
||||
Center();
|
||||
|
||||
m_sdbSizerOK->SetFocus();
|
||||
m_sdbSizerOK->SetDefault();
|
||||
|
||||
// OnSize() will fix the title spacing.
|
||||
QueueEvent( new wxSizeEvent( GetSize() ) );
|
||||
}
|
||||
|
||||
|
||||
bool DIALOG_LAYERS_SETUP::TransferDataToWindow()
|
||||
{
|
||||
if( !wxDialog::TransferDataToWindow() )
|
||||
return false;
|
||||
|
||||
showCopperChoice( m_copperLayerCount );
|
||||
setCopperLayerCheckBoxes( m_copperLayerCount );
|
||||
m_staticTextBrdThicknessUnit->SetLabel( GetAbbreviatedUnitsLabel( g_UserUnit ) );
|
||||
PutValueInLocalUnits( *m_textCtrlBrdThickness,
|
||||
m_pcb->GetDesignSettings().GetBoardThickness() );
|
||||
|
||||
showBoardLayerNames();
|
||||
showSelectedLayerCheckBoxes( m_enabledLayers );
|
||||
showPresets( m_enabledLayers );
|
||||
showLayerTypes();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_LAYERS_SETUP::OnSize( wxSizeEvent& event )
|
||||
{
|
||||
moveTitles();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_LAYERS_SETUP::showCopperChoice( int copperCount )
|
||||
{
|
||||
if( copperCount > MAX_CU_LAYERS )
|
||||
|
@ -405,9 +431,8 @@ void DIALOG_LAYERS_SETUP::showBoardLayerNames()
|
|||
if( ctl )
|
||||
{
|
||||
wxString lname = m_pcb->GetLayerName( layer );
|
||||
//D(printf("layerName[%d]=%s\n", layer, TO_UTF8( lname ) );)
|
||||
|
||||
if( ctl->IsKindOf( CLASSINFO(wxTextCtrl) ) )
|
||||
if( ctl->IsKindOf( CLASSINFO( wxTextCtrl ) ) )
|
||||
((wxTextCtrl*)ctl)->SetValue( lname ); // wxTextCtrl
|
||||
else
|
||||
ctl->SetLabel( lname ); // wxStaticText
|
||||
|
@ -431,7 +456,7 @@ void DIALOG_LAYERS_SETUP::showPresets( LSET enabledLayers )
|
|||
{
|
||||
int presetsNdx = 0; // the "Custom" setting, matches nothing
|
||||
|
||||
for( unsigned i=1; i<DIM(presets); ++i )
|
||||
for( unsigned i=1; i<DIM( presets ); ++i )
|
||||
{
|
||||
if( enabledLayers == presets[i] )
|
||||
{
|
||||
|
@ -584,49 +609,80 @@ void DIALOG_LAYERS_SETUP::OnCopperLayersChoice( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void DIALOG_LAYERS_SETUP::OnCancelButtonClick( wxCommandEvent& event )
|
||||
bool DIALOG_LAYERS_SETUP::TransferDataFromWindow()
|
||||
{
|
||||
EndModal( wxID_CANCEL );
|
||||
}
|
||||
if( !wxWindow::TransferDataFromWindow() || !testLayerNames() )
|
||||
return false;
|
||||
|
||||
wxString msg;
|
||||
|
||||
void DIALOG_LAYERS_SETUP::OnOkButtonClick( wxCommandEvent& event )
|
||||
{
|
||||
if( testLayerNames() )
|
||||
// Make sure the board thickness is sane.
|
||||
int thickness = ValueFromTextCtrl( *m_textCtrlBrdThickness );
|
||||
|
||||
if( thickness < Millimeter2iu( 0.1 ) || thickness > Millimeter2iu( 10.0 ) )
|
||||
{
|
||||
wxString name;
|
||||
msg.Printf( _( "Board thickness %s is out of range." ),
|
||||
StringFromValue( g_UserUnit, thickness, true ) );
|
||||
DisplayError( this, msg );
|
||||
return false;
|
||||
}
|
||||
|
||||
m_enabledLayers = getUILayerMask();
|
||||
m_pcb->SetEnabledLayers( m_enabledLayers );
|
||||
// Check for removed layers with items which will get deleted from the board.
|
||||
LSEQ removedLayers = getRemovedLayersWithItems();
|
||||
|
||||
/* Ensure enabled layers are also visible
|
||||
* This is mainly to avoid mistakes if some enabled
|
||||
* layers are not visible when exiting this dialog
|
||||
*/
|
||||
m_pcb->SetVisibleLayers( m_enabledLayers );
|
||||
if( !removedLayers.empty()
|
||||
&& !IsOK( this, _( "Items have been found on removed layers. This operation will delete "
|
||||
"all items from removed layers and cannot be undone. Do you wish to "
|
||||
"continue?" ) ) )
|
||||
return false;
|
||||
|
||||
for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
|
||||
// Delete all objects on layers that have been removed. Leaving them in copper layers
|
||||
// can (will?) result in DRC errors and it pollutes the board file with cruft.
|
||||
if( !removedLayers.empty() )
|
||||
{
|
||||
PCB_LAYER_COLLECTOR collector;
|
||||
|
||||
for( auto layer_id : removedLayers )
|
||||
{
|
||||
PCB_LAYER_ID layer = *seq;
|
||||
collector.SetLayerId( layer_id );
|
||||
collector.Collect( m_pcb, GENERAL_COLLECTOR::BoardLevelItems );
|
||||
|
||||
if( m_enabledLayers[layer] )
|
||||
// Bye-bye items on on removed layer.
|
||||
if( collector.GetCount() != 0 )
|
||||
{
|
||||
name = getLayerName( layer );
|
||||
m_pcb->SetLayerName( layer, name );
|
||||
LAYER_T t = (LAYER_T) getLayerTypeIndex( layer );
|
||||
m_pcb->SetLayerType( layer, t );
|
||||
for( int i = 0; i < collector.GetCount(); i++ )
|
||||
m_pcb->Remove( collector[i] );
|
||||
}
|
||||
}
|
||||
|
||||
int thickness = ValueFromTextCtrl( *m_textCtrlBrdThickness );
|
||||
|
||||
// Clamp the value between reasonable values
|
||||
|
||||
thickness = Clamp( Millimeter2iu( 0.1 ), thickness, Millimeter2iu( 10.0 ) );
|
||||
m_pcb->GetDesignSettings().SetBoardThickness( thickness );
|
||||
|
||||
EndModal( wxID_OK );
|
||||
}
|
||||
|
||||
wxString name;
|
||||
|
||||
m_enabledLayers = getUILayerMask();
|
||||
m_pcb->SetEnabledLayers( m_enabledLayers );
|
||||
|
||||
/* Ensure enabled layers are also visible
|
||||
* This is mainly to avoid mistakes if some enabled
|
||||
* layers are not visible when exiting this dialog
|
||||
*/
|
||||
m_pcb->SetVisibleLayers( m_enabledLayers );
|
||||
|
||||
for( LSEQ seq = LSET::AllCuMask().Seq(); seq; ++seq )
|
||||
{
|
||||
PCB_LAYER_ID layer = *seq;
|
||||
|
||||
if( m_enabledLayers[layer] )
|
||||
{
|
||||
name = getLayerName( layer );
|
||||
m_pcb->SetLayerName( layer, name );
|
||||
LAYER_T t = (LAYER_T) getLayerTypeIndex( layer );
|
||||
m_pcb->SetLayerType( layer, t );
|
||||
}
|
||||
}
|
||||
|
||||
m_pcb->GetDesignSettings().SetBoardThickness( thickness );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -657,8 +713,11 @@ wxString DIALOG_LAYERS_SETUP::getLayerName( LAYER_NUM aLayer )
|
|||
static bool hasOneOf( const wxString& str, const wxString& chars )
|
||||
{
|
||||
for( unsigned i=0; i<chars.Len(); ++i )
|
||||
{
|
||||
if( str.Find( chars[i] ) != wxNOT_FOUND )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -679,8 +738,6 @@ bool DIALOG_LAYERS_SETUP::testLayerNames()
|
|||
|
||||
wxString name = getLayerName( layer );
|
||||
|
||||
//D(printf("name[%d]=%s\n", layer, TO_UTF8(name) );)
|
||||
|
||||
ctl = (wxTextCtrl*) getName( layer );
|
||||
|
||||
// check name for legality.
|
||||
|
@ -691,27 +748,27 @@ bool DIALOG_LAYERS_SETUP::testLayerNames()
|
|||
// 5) must be unique.
|
||||
// 6) cannot have illegal chars in filenames ( some filenames are built from layer names )
|
||||
// like : % $ \ " / :
|
||||
|
||||
wxString badchars = wxFileName::GetForbiddenChars(wxPATH_DOS);
|
||||
wxString badchars = wxFileName::GetForbiddenChars( wxPATH_DOS );
|
||||
badchars.Append( '%' );
|
||||
|
||||
if( !name )
|
||||
{
|
||||
DisplayError( this, _("Layer name may not be empty" ) );
|
||||
DisplayError( this, _( "Layer name may not be empty." ) );
|
||||
ctl->SetFocus(); // on the bad name
|
||||
return false;
|
||||
}
|
||||
|
||||
if( hasOneOf( name, badchars ) )
|
||||
{
|
||||
DisplayError( this, _("Layer name has an illegal character, one of: '") + badchars + wxT("'") );
|
||||
DisplayError( this, _( "Layer name has an illegal character, one of: '" ) +
|
||||
badchars + wxT( "'" ) );
|
||||
ctl->SetFocus(); // on the bad name
|
||||
return false;
|
||||
}
|
||||
|
||||
if( name == wxT("signal") )
|
||||
if( name == wxT( "signal" ) )
|
||||
{
|
||||
DisplayError( this, _("'signal' is a reserved layer name") );
|
||||
DisplayError( this, _( "Layer name 'signal' is reserved." ) );
|
||||
ctl->SetFocus(); // on the bad name
|
||||
return false;
|
||||
}
|
||||
|
@ -720,7 +777,7 @@ bool DIALOG_LAYERS_SETUP::testLayerNames()
|
|||
{
|
||||
if( name == *it )
|
||||
{
|
||||
DisplayError( this, _("Layer name is a duplicate of another") );
|
||||
DisplayError( this, _( "Duplicate layer names are not permitted." ) );
|
||||
ctl->SetFocus(); // on the bad name
|
||||
return false;
|
||||
}
|
||||
|
@ -733,6 +790,35 @@ bool DIALOG_LAYERS_SETUP::testLayerNames()
|
|||
}
|
||||
|
||||
|
||||
LSEQ DIALOG_LAYERS_SETUP::getRemovedLayersWithItems()
|
||||
{
|
||||
LSEQ removedLayers;
|
||||
LSET newLayers = getUILayerMask();
|
||||
LSET curLayers = m_pcb->GetEnabledLayers();
|
||||
|
||||
if( newLayers == curLayers )
|
||||
return removedLayers;
|
||||
|
||||
PCB_LAYER_COLLECTOR collector;
|
||||
LSEQ newLayerSeq = newLayers.Seq();
|
||||
std::vector< PCB_LAYER_ID >::iterator it;
|
||||
|
||||
for( auto layer_id : curLayers.Seq() )
|
||||
{
|
||||
if( std::find( newLayerSeq.begin(), newLayerSeq.end(), layer_id ) == newLayerSeq.end() )
|
||||
{
|
||||
collector.SetLayerId( layer_id );
|
||||
collector.Collect( m_pcb, GENERAL_COLLECTOR::BoardLevelItems );
|
||||
|
||||
if( collector.GetCount() != 0 )
|
||||
removedLayers.push_back( layer_id );
|
||||
}
|
||||
}
|
||||
|
||||
return removedLayers;
|
||||
}
|
||||
|
||||
|
||||
bool InvokeLayerSetup( wxTopLevelWindow* aCaller, BOARD* aBoard )
|
||||
{
|
||||
DIALOG_LAYERS_SETUP dlg( aCaller, aBoard );
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version May 6 2016)
|
||||
// C++ code generated with wxFormBuilder (version Aug 29 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
|
@ -1746,6 +1746,7 @@ DIALOG_LAYERS_SETUP_BASE::DIALOG_LAYERS_SETUP_BASE( wxWindow* parent, wxWindowID
|
|||
this->Layout();
|
||||
|
||||
// Connect Events
|
||||
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_LAYERS_SETUP_BASE::OnInitDialog ) );
|
||||
this->Connect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_LAYERS_SETUP_BASE::OnSize ) );
|
||||
m_PresetsChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_LAYERS_SETUP_BASE::OnPresetsChoice ), NULL, this );
|
||||
m_CopperLayersChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_LAYERS_SETUP_BASE::OnCopperLayersChoice ), NULL, this );
|
||||
|
@ -1799,13 +1800,12 @@ DIALOG_LAYERS_SETUP_BASE::DIALOG_LAYERS_SETUP_BASE( wxWindow* parent, wxWindowID
|
|||
m_Eco2CheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LAYERS_SETUP_BASE::OnCheckBox ), NULL, this );
|
||||
m_CommentsCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LAYERS_SETUP_BASE::OnCheckBox ), NULL, this );
|
||||
m_DrawingsCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LAYERS_SETUP_BASE::OnCheckBox ), NULL, this );
|
||||
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LAYERS_SETUP_BASE::OnCancelButtonClick ), NULL, this );
|
||||
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LAYERS_SETUP_BASE::OnOkButtonClick ), NULL, this );
|
||||
}
|
||||
|
||||
DIALOG_LAYERS_SETUP_BASE::~DIALOG_LAYERS_SETUP_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_LAYERS_SETUP_BASE::OnInitDialog ) );
|
||||
this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( DIALOG_LAYERS_SETUP_BASE::OnSize ) );
|
||||
m_PresetsChoice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_LAYERS_SETUP_BASE::OnPresetsChoice ), NULL, this );
|
||||
m_CopperLayersChoice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_LAYERS_SETUP_BASE::OnCopperLayersChoice ), NULL, this );
|
||||
|
@ -1859,7 +1859,5 @@ DIALOG_LAYERS_SETUP_BASE::~DIALOG_LAYERS_SETUP_BASE()
|
|||
m_Eco2CheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LAYERS_SETUP_BASE::OnCheckBox ), NULL, this );
|
||||
m_CommentsCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LAYERS_SETUP_BASE::OnCheckBox ), NULL, this );
|
||||
m_DrawingsCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_LAYERS_SETUP_BASE::OnCheckBox ), NULL, this );
|
||||
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LAYERS_SETUP_BASE::OnCancelButtonClick ), NULL, this );
|
||||
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LAYERS_SETUP_BASE::OnOkButtonClick ), NULL, this );
|
||||
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
<property name="minimum_size">550,600</property>
|
||||
<property name="name">DIALOG_LAYERS_SETUP_BASE</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">550,1580</property>
|
||||
<property name="size">550,600</property>
|
||||
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
|
||||
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
|
||||
<property name="title">Layer Setup</property>
|
||||
|
@ -67,7 +67,7 @@
|
|||
<event name="OnHibernate"></event>
|
||||
<event name="OnIconize"></event>
|
||||
<event name="OnIdle"></event>
|
||||
<event name="OnInitDialog"></event>
|
||||
<event name="OnInitDialog">OnInitDialog</event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
|
@ -937,7 +937,7 @@
|
|||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
|
||||
<property name="proportion">1</property>
|
||||
|
@ -18487,11 +18487,11 @@
|
|||
<property name="name">m_sdbSizer</property>
|
||||
<property name="permission">protected</property>
|
||||
<event name="OnApplyButtonClick"></event>
|
||||
<event name="OnCancelButtonClick">OnCancelButtonClick</event>
|
||||
<event name="OnCancelButtonClick"></event>
|
||||
<event name="OnContextHelpButtonClick"></event>
|
||||
<event name="OnHelpButtonClick"></event>
|
||||
<event name="OnNoButtonClick"></event>
|
||||
<event name="OnOKButtonClick">OnOkButtonClick</event>
|
||||
<event name="OnOKButtonClick"></event>
|
||||
<event name="OnSaveButtonClick"></event>
|
||||
<event name="OnYesButtonClick"></event>
|
||||
</object>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version May 6 2016)
|
||||
// C++ code generated with wxFormBuilder (version Aug 29 2017)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
|
@ -404,18 +404,17 @@ class DIALOG_LAYERS_SETUP_BASE : public DIALOG_SHIM
|
|||
wxButton* m_sdbSizerCancel;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); }
|
||||
virtual void OnSize( wxSizeEvent& event ) { event.Skip(); }
|
||||
virtual void OnPresetsChoice( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnCopperLayersChoice( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnCheckBox( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void DenyChangeCheckBox( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnCancelButtonClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnOkButtonClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
||||
DIALOG_LAYERS_SETUP_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Layer Setup"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 550,1580 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
DIALOG_LAYERS_SETUP_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Layer Setup"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 550,600 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~DIALOG_LAYERS_SETUP_BASE();
|
||||
|
||||
};
|
||||
|
|
|
@ -101,13 +101,14 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
|||
cur_layer = F_Cu;
|
||||
|
||||
SetActiveLayer( cur_layer );
|
||||
|
||||
OnModify();
|
||||
ReCreateLayerBox();
|
||||
ReFillLayerWidget();
|
||||
|
||||
if( IsGalCanvasActive() )
|
||||
static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->SyncLayersVisibility( GetBoard() );
|
||||
|
||||
GetCanvas()->Refresh();
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue