From 8ea015aaab1df0e9c03e64dc90179dbf1d7d2ea3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 11 Sep 2013 17:30:21 +0200 Subject: [PATCH] Eeschema: fix compatibility with old schematic files, which can contain markers. Pcbnew: better test for allowed layers when creating/editing Dimensions and some other Graphic items Drc: fix comments and messages for some drc tests. To do: fix issues in active layer selection when creating a track and layer pair selection dialog --- eeschema/load_one_schematic_file.cpp | 4 + include/layers_id_colors_and_visibility.h | 39 ++++++-- include/wxBasePcbFrame.h | 18 +++- pcbnew/class_drc_item.cpp | 6 +- .../dialog_graphic_item_properties.cpp | 1 + .../dialogs/dialog_layer_selection_base.cpp | 17 ++-- .../dialogs/dialog_layer_selection_base.fbp | 96 +------------------ pcbnew/dialogs/dialog_layer_selection_base.h | 9 +- pcbnew/dimension.cpp | 8 +- pcbnew/drc_clearance_test_functions.cpp | 16 +++- pcbnew/drc_stuff.h | 10 +- pcbnew/edgemod.cpp | 41 +++++--- pcbnew/edit.cpp | 10 +- pcbnew/onleftclick.cpp | 5 +- pcbnew/sel_layer.cpp | 71 +++++--------- pcbnew/swap_layers.cpp | 31 ++---- 16 files changed, 159 insertions(+), 223 deletions(-) diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index 9ca2183bba..8aa9243d79 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -194,6 +194,7 @@ again." ); case 'K': // It is a Marker item. // Markers are no more read from file. they are only created on // demand in schematic + itemLoaded = true; // Just skip descr and disable err message break; case 'N': // It is a NoConnect item. @@ -242,6 +243,9 @@ again." ); if( !itemLoaded ) { + msgDiag.Printf( _( "Eeschema file object not loaded at line %d, aborted" ), + reader.LineNumber() ); + msgDiag << wxT( "\n" ) << FROM_UTF8( line ); DisplayError( this, msgDiag ); break; } diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index 1dd41130f0..dc8185896a 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -139,14 +139,35 @@ typedef unsigned LAYER_MSK; #define NO_LAYERS 0x00000000 -/** return a one bit layer mask from a layer number - * aLayerNumber = the layer number to convert (0 .. LAYERS-1) +/** + * @return a one bit layer mask from a layer number + * @param aLayerNumber = the layer number to convert (0 .. LAYERS-1) */ inline LAYER_MSK GetLayerMask( LAYER_NUM aLayerNumber ) { return 1 << aLayerNumber; } +/** + * @return bool if aLayerNumber is a layer contained in aMask + * @param aMask = a layer mask + * @param aLayerNumber is the layer id to test + */ +inline bool IsLayerInList( LAYER_MSK aMask, LAYER_NUM aLayerNumber ) +{ + return (aMask & GetLayerMask( aLayerNumber )) != 0; +} + +/** + * @return bool if 2 layer masks have a comman layer + * @param aMask1 = a layer mask + * @param aMask2 = an other layer mask + */ +inline bool IsLayerMasksIntersect( LAYER_MSK aMask1, LAYER_MSK aMask2 ) +{ + return (aMask1 & aMask2) != 0; +} + /** * Count the number of set layers in the mask */ @@ -244,11 +265,11 @@ inline bool IsPcbLayer( LAYER_NUM aLayer ) * Function IsCopperLayer * tests whether a layer is a copper layer * @param aLayer = Layer to test - * @return true if aLayer is a valid copper layer + * @return true if aLayer is a valid copper layer */ inline bool IsCopperLayer( LAYER_NUM aLayer ) { - return aLayer >= FIRST_COPPER_LAYER + return aLayer >= FIRST_COPPER_LAYER && aLayer <= LAST_COPPER_LAYER; } @@ -269,12 +290,12 @@ inline bool IsNonCopperLayer( LAYER_NUM aLayer ) So a layer can be: - Front - Back - - Neither (internal or auxiliary) - + - Neither (internal or auxiliary) + The check most frequent is for back layers, since it involves flips */ -/** +/** * Layer classification: check if it's a front layer */ inline bool IsFrontLayer( LAYER_NUM aLayer ) @@ -286,7 +307,7 @@ inline bool IsFrontLayer( LAYER_NUM aLayer ) aLayer == SOLDERPASTE_N_FRONT ); } -/** +/** * Layer classification: check if it's a back layer */ inline bool IsBackLayer( LAYER_NUM aLayer ) @@ -314,7 +335,7 @@ LAYER_MSK FlipLayerMask( LAYER_MSK aMask ); /** * Extract the set layer from a mask. Returns UNDEFINED_LAYER if more - * than one is set or UNSELECTED_LAYER if none is + * than one is set or UNSELECTED_LAYER if none is */ LAYER_NUM ExtractLayer( LAYER_MSK aMask ); diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index 12843befbe..b74c6165e5 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -639,11 +639,19 @@ public: const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0; - // layerhandling: - // (See pcbnew/sel_layer.cpp for description of why null_layer parameter - // is provided) - LAYER_NUM SelectLayer( LAYER_NUM default_layer, LAYER_NUM min_layer, LAYER_NUM max_layer, bool null_layer = false ); - void SelectLayerPair(); + /** Install the dialog box for layer selection + * @param aDefaultLayer = Preselection (NB_PCB_LAYERS for "(Deselect)" layer) + * @param aNotAllowedLayersMask = a layer mask for not allowed layers + * (= 0 to show all layers in use) + * @return the selected layer id + */ + LAYER_NUM SelectLayer( LAYER_NUM aDefaultLayer, LAYER_MSK aNotAllowedLayersMask = 0 ); + + /* Display a list of two copper layers to choose a pair of copper layers + * the layer pair is used to fast switch between copper layers when placing vias + */ + void SelectCopperLayerPair(); + virtual void SwitchLayer( wxDC* DC, LAYER_NUM layer ); /** diff --git a/pcbnew/class_drc_item.cpp b/pcbnew/class_drc_item.cpp index edbdf94308..b70d98d3c2 100644 --- a/pcbnew/class_drc_item.cpp +++ b/pcbnew/class_drc_item.cpp @@ -60,9 +60,9 @@ wxString DRC_ITEM::GetErrorText() const case DRCE_ENDS_PROBLEM3: case DRCE_ENDS_PROBLEM4: case DRCE_ENDS_PROBLEM5: - return wxString( _("Two track ends") ); - case DRCE_TRACK_UNKNOWN1: - return wxString( _("This looks bad") ); ///< @todo check source code and change this comment + return wxString( _("Two track ends too close") ); + case DRCE_TRACK_SEGMENTS_TOO_CLOSE: + return wxString( _("Two parallel track segments too close") ); case DRCE_TRACKS_CROSSING: return wxString( _("Tracks crossing") ); case DRCE_PAD_NEAR_PAD1: diff --git a/pcbnew/dialogs/dialog_graphic_item_properties.cpp b/pcbnew/dialogs/dialog_graphic_item_properties.cpp index c4271c7b1c..561c29fa2a 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties.cpp @@ -165,6 +165,7 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg( ) m_LayerSelectionCtrl->SetLayerMask( ALL_CU_LAYERS ); m_LayerSelectionCtrl->SetBoardFrame( m_parent ); m_LayerSelectionCtrl->Resync(); + if( m_LayerSelectionCtrl->SetLayerSelection( m_Item->GetLayer() ) < 0 ) { wxMessageBox( _("This item has an illegal layer id.\n" diff --git a/pcbnew/dialogs/dialog_layer_selection_base.cpp b/pcbnew/dialogs/dialog_layer_selection_base.cpp index 37e90f562b..363bcac26a 100644 --- a/pcbnew/dialogs/dialog_layer_selection_base.cpp +++ b/pcbnew/dialogs/dialog_layer_selection_base.cpp @@ -77,9 +77,6 @@ DIALOG_LAYER_SELECTION_BASE::DIALOG_LAYER_SELECTION_BASE( wxWindow* parent, wxWi bSizerMain->Add( bSizerUpper, 1, wxEXPAND, 5 ); - m_buttonClear = new wxButton( this, wxID_ANY, _("Clear Selection"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerMain->Add( m_buttonClear, 0, wxALL|wxALIGN_RIGHT, 5 ); - this->SetSizer( bSizerMain ); this->Layout(); @@ -87,17 +84,19 @@ DIALOG_LAYER_SELECTION_BASE::DIALOG_LAYER_SELECTION_BASE( wxWindow* parent, wxWi this->Centre( wxBOTH ); // Connect Events - m_leftGridLayers->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_LAYER_SELECTION_BASE::OnLeftGridClick ), NULL, this ); - m_rightGridLayers->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_LAYER_SELECTION_BASE::OnRightGridClick ), NULL, this ); - m_buttonClear->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LAYER_SELECTION_BASE::OnClearSelection ), NULL, this ); + m_leftGridLayers->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_LAYER_SELECTION_BASE::OnLeftGridCellClick ), NULL, this ); + m_leftGridLayers->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_LAYER_SELECTION_BASE::OnLeftButtonReleased ), NULL, this ); + m_rightGridLayers->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_LAYER_SELECTION_BASE::OnRightGridCellClick ), NULL, this ); + m_rightGridLayers->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_LAYER_SELECTION_BASE::OnLeftButtonReleased ), NULL, this ); } DIALOG_LAYER_SELECTION_BASE::~DIALOG_LAYER_SELECTION_BASE() { // Disconnect Events - m_leftGridLayers->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_LAYER_SELECTION_BASE::OnLeftGridClick ), NULL, this ); - m_rightGridLayers->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_LAYER_SELECTION_BASE::OnRightGridClick ), NULL, this ); - m_buttonClear->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LAYER_SELECTION_BASE::OnClearSelection ), NULL, this ); + m_leftGridLayers->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_LAYER_SELECTION_BASE::OnLeftGridCellClick ), NULL, this ); + m_leftGridLayers->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_LAYER_SELECTION_BASE::OnLeftButtonReleased ), NULL, this ); + m_rightGridLayers->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_LAYER_SELECTION_BASE::OnRightGridCellClick ), NULL, this ); + m_rightGridLayers->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_LAYER_SELECTION_BASE::OnLeftButtonReleased ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_layer_selection_base.fbp b/pcbnew/dialogs/dialog_layer_selection_base.fbp index 2a702b9e3c..5b93df5788 100644 --- a/pcbnew/dialogs/dialog_layer_selection_base.fbp +++ b/pcbnew/dialogs/dialog_layer_selection_base.fbp @@ -190,7 +190,7 @@ - OnLeftGridClick + OnLeftGridCellClick @@ -227,7 +227,7 @@ - + OnLeftButtonReleased @@ -333,7 +333,7 @@ - OnRightGridClick + OnRightGridCellClick @@ -370,7 +370,7 @@ - + OnLeftButtonReleased @@ -388,94 +388,6 @@ - - 5 - wxALL|wxALIGN_RIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Clear Selection - - 0 - - - 0 - - 1 - m_buttonClear - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnClearSelection - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pcbnew/dialogs/dialog_layer_selection_base.h b/pcbnew/dialogs/dialog_layer_selection_base.h index 4a2b40f2ac..af475aa160 100644 --- a/pcbnew/dialogs/dialog_layer_selection_base.h +++ b/pcbnew/dialogs/dialog_layer_selection_base.h @@ -18,10 +18,10 @@ #include #include #include -#include #include #include #include +#include /////////////////////////////////////////////////////////////////////////// @@ -38,12 +38,11 @@ class DIALOG_LAYER_SELECTION_BASE : public wxDialog protected: wxGrid* m_leftGridLayers; wxGrid* m_rightGridLayers; - wxButton* m_buttonClear; // Virtual event handlers, overide them in your derived class - virtual void OnLeftGridClick( wxGridEvent& event ) { event.Skip(); } - virtual void OnRightGridClick( wxGridEvent& event ) { event.Skip(); } - virtual void OnClearSelection( wxCommandEvent& event ) { event.Skip(); } + virtual void OnLeftGridCellClick( wxGridEvent& event ) { event.Skip(); } + virtual void OnLeftButtonReleased( wxMouseEvent& event ) { event.Skip(); } + virtual void OnRightGridCellClick( wxGridEvent& event ) { event.Skip(); } public: diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp index ab07b66fdb..819c1a3110 100644 --- a/pcbnew/dimension.cpp +++ b/pcbnew/dimension.cpp @@ -138,7 +138,13 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent, m_SelLayerBox->SetLayerMask( ALL_CU_LAYERS | EDGE_LAYER ); m_SelLayerBox->SetBoardFrame( m_Parent ); m_SelLayerBox->Resync(); - m_SelLayerBox->SetLayerSelection( aDimension->GetLayer() ); + + if( m_SelLayerBox->SetLayerSelection( aDimension->GetLayer() ) < 0 ) + { + wxMessageBox( _("This item has an illegal layer id.\n" + "Now, forced on the drawings layer. Please, fix it") ); + m_SelLayerBox->SetLayerSelection( DRAW_N ); + } GetSizer()->Fit( this ); GetSizer()->SetSizeHints( this ); diff --git a/pcbnew/drc_clearance_test_functions.cpp b/pcbnew/drc_clearance_test_functions.cpp index b0d1d01a56..43d96d11d1 100644 --- a/pcbnew/drc_clearance_test_functions.cpp +++ b/pcbnew/drc_clearance_test_functions.cpp @@ -420,6 +420,10 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) if( segStartPoint.x > (-w_dist) && segStartPoint.x < (m_segmLength + w_dist) ) /* possible error drc */ { + // the start point is inside the reference range + // X........ + // O--REF--+ + // Fine test : we consider the rounded shape of each end of the track segment: if( segStartPoint.x >= 0 && segStartPoint.x <= m_segmLength ) { @@ -438,7 +442,10 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) if( segEndPoint.x > (-w_dist) && segEndPoint.x < (m_segmLength + w_dist) ) { - /* Fine test : we consider the rounded shape of the ends */ + // the end point is inside the reference range + // .....X + // O--REF--+ + // Fine test : we consider the rounded shape of the ends if( segEndPoint.x >= 0 && segEndPoint.x <= m_segmLength ) { m_currentMarker = fillMarker( aRefSeg, track, @@ -456,8 +463,13 @@ bool DRC::doTrackDrc( TRACK* aRefSeg, TRACK* aStart, bool testPads ) if( segStartPoint.x <=0 && segEndPoint.x >= 0 ) { + // the segment straddles the reference range (this actually only + // checks if it straddles the origin, because the other cases where already + // handled) + // X.............X + // O--REF--+ m_currentMarker = fillMarker( aRefSeg, track, - DRCE_TRACK_UNKNOWN1, m_currentMarker ); + DRCE_TRACK_SEGMENTS_TOO_CLOSE, m_currentMarker ); return false; } } diff --git a/pcbnew/drc_stuff.h b/pcbnew/drc_stuff.h index e031cdc20a..f2daee5b95 100644 --- a/pcbnew/drc_stuff.h +++ b/pcbnew/drc_stuff.h @@ -44,11 +44,11 @@ #define DRCE_TRACK_NEAR_VIA 5 ///< track too close to via #define DRCE_VIA_NEAR_VIA 6 ///< via too close to via #define DRCE_VIA_NEAR_TRACK 7 ///< via too close to track -#define DRCE_TRACK_ENDS1 8 ///< @todo say what this problem is -#define DRCE_TRACK_ENDS2 9 ///< @todo say what this problem is -#define DRCE_TRACK_ENDS3 10 ///< @todo say what this problem is -#define DRCE_TRACK_ENDS4 11 ///< @todo say what this problem is -#define DRCE_TRACK_UNKNOWN1 12 ///< @todo check source code and change this comment +#define DRCE_TRACK_ENDS1 8 ///< 2 parallel track segments too close: fine start point test +#define DRCE_TRACK_ENDS2 9 ///< 2 parallel track segments too close: fine start point test +#define DRCE_TRACK_ENDS3 10 ///< 2 parallel track segments too close: fine end point test +#define DRCE_TRACK_ENDS4 11 ///< 2 parallel track segments too close: fine end point test +#define DRCE_TRACK_SEGMENTS_TOO_CLOSE 12 ///< 2 parallel track segments too close: segm ends between segref ends #define DRCE_TRACKS_CROSSING 13 ///< tracks are crossing #define DRCE_ENDS_PROBLEM1 14 ///< track ends are too close #define DRCE_ENDS_PROBLEM2 15 ///< track ends are too close diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp index 870e9e710a..14843623a1 100644 --- a/pcbnew/edgemod.cpp +++ b/pcbnew/edgemod.cpp @@ -1,10 +1,10 @@ /* * 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) 2012 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2012 Wayne Stambaugh - * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2013 Wayne Stambaugh + * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.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 @@ -190,16 +190,19 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Width( EDGE_MODULE* aEdge ) void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* aEdge ) { + // note: if aEdge == NULL, all outline segments will be modified + MODULE* module = GetBoard()->m_Modules; - LAYER_NUM new_layer = SILKSCREEN_N_FRONT; + LAYER_NUM layer = SILKSCREEN_N_FRONT; + bool modified = false; if( aEdge ) - new_layer = aEdge->GetLayer(); + layer = aEdge->GetLayer(); // Ask for the new layer - new_layer = SelectLayer( new_layer, FIRST_COPPER_LAYER, ECO2_N ); + LAYER_NUM new_layer = SelectLayer(layer, EDGE_LAYER ); - if( new_layer < 0 ) + if( layer < 0 ) return; if( IsCopperLayer( new_layer ) ) @@ -211,8 +214,6 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* aEdge ) return; } - SaveCopyInUndoList( module, UR_MODEDIT ); - if( aEdge == NULL ) { aEdge = (EDGE_MODULE*) (BOARD_ITEM*) module->GraphicalItems(); @@ -222,17 +223,27 @@ void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* aEdge ) if( aEdge->Type() != PCB_MODULE_EDGE_T ) continue; - aEdge->SetLayer( new_layer ); + if( aEdge->GetLayer() != new_layer ) + { + if( ! modified ) // save only once + SaveCopyInUndoList( module, UR_MODEDIT ); + aEdge->SetLayer( new_layer ); + modified = true; + } } } - else + else if( aEdge->GetLayer() != new_layer ) { + SaveCopyInUndoList( module, UR_MODEDIT ); aEdge->SetLayer( new_layer ); + modified = true; } - OnModify(); - module->CalculateBoundingBox(); - module->SetLastEditTime(); + if( modified ) + { + module->CalculateBoundingBox(); + module->SetLastEditTime(); + } } diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index ae445f1d8b..3524e584f3 100755 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -922,7 +922,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_SELECT_LAYER: - itmp = SelectLayer( getActiveLayer(), UNDEFINED_LAYER, UNDEFINED_LAYER ); + itmp = SelectLayer( getActiveLayer() ); if( itmp >= 0 ) { @@ -939,11 +939,11 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_AUX_TOOLBAR_PCB_SELECT_LAYER_PAIR: - SelectLayerPair(); + SelectCopperLayerPair(); break; case ID_POPUP_PCB_SELECT_NO_CU_LAYER: - itmp = SelectLayer( getActiveLayer(), FIRST_NON_COPPER_LAYER, UNDEFINED_LAYER ); + itmp = SelectLayer( getActiveLayer(), ALL_CU_LAYERS ); if( itmp >= 0 ) setActiveLayer( itmp ); @@ -952,7 +952,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_SELECT_CU_LAYER: - itmp = SelectLayer( getActiveLayer(), UNDEFINED_LAYER, LAST_COPPER_LAYER ); + itmp = SelectLayer( getActiveLayer(), ALL_NO_CU_LAYERS ); if( itmp >= 0 ) setActiveLayer( itmp ); @@ -960,7 +960,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) break; case ID_POPUP_PCB_SELECT_LAYER_PAIR: - SelectLayerPair(); + SelectCopperLayerPair(); m_canvas->MoveCursorToCrossHair(); break; diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index 53703e3166..5c79ce4962 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -367,9 +367,10 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) break; case ID_PCB_DIMENSION_BUTT: - if( IsCopperLayer( getActiveLayer() ) ) + if( IsLayerInList( EDGE_LAYER|ALL_CU_LAYERS ,getActiveLayer() ) ) { - DisplayError( this, _( "Dimension not allowed on Copper layers" ) ); + DisplayError( this, + _( "Dimension not allowed on Copper or Edge Cut layers" ) ); break; } diff --git a/pcbnew/sel_layer.cpp b/pcbnew/sel_layer.cpp index fc8ebc10e1..28a9e3f327 100644 --- a/pcbnew/sel_layer.cpp +++ b/pcbnew/sel_layer.cpp @@ -74,30 +74,25 @@ protected: }; /* - * This class display a pcb layers list in adialog, + * This class display a pcb layers list in a dialog, * to select one layer from this list */ class PCB_ONE_LAYER_SELECTOR : public PCB_LAYER_SELECTOR, public DIALOG_LAYER_SELECTION_BASE { LAYER_NUM m_layerSelected; - LAYER_NUM m_minLayer; - LAYER_NUM m_maxLayer; + LAYER_MSK m_notAllowedLayersMask; std::vector m_layersIdLeftColumn; std::vector m_layersIdRightColumn; public: PCB_ONE_LAYER_SELECTOR( wxWindow* aParent, BOARD * aBrd, LAYER_NUM aDefaultLayer, - LAYER_NUM aMinLayer = -1, LAYER_NUM aMaxLayer = -1, - bool aClearTool = false ) + LAYER_MSK aNotAllowedLayersMask ) :PCB_LAYER_SELECTOR( aBrd ), DIALOG_LAYER_SELECTION_BASE( aParent ) { m_layerSelected = (int) aDefaultLayer; - // When not needed, remove the "Clear" button - m_buttonClear->Show( aClearTool ); - m_minLayer = aMinLayer; - m_maxLayer = aMaxLayer; + m_notAllowedLayersMask = aNotAllowedLayersMask; BuildList(); Layout(); GetSizer()->SetSizeHints(this); @@ -108,13 +103,8 @@ public: private: // Event handlers - void OnLeftGridClick( wxGridEvent& event ); - void OnRightGridClick( wxGridEvent& event ); - void OnClearSelection( wxCommandEvent& event ) - { - m_layerSelected = NB_PCB_LAYERS; - EndModal( NB_PCB_LAYERS ); - } + void OnLeftGridCellClick( wxGridEvent& event ); + void OnRightGridCellClick( wxGridEvent& event ); void BuildList(); }; @@ -146,10 +136,7 @@ void PCB_ONE_LAYER_SELECTOR::BuildList() if( ! IsLayerEnabled( layerid ) ) continue; - if( m_minLayer >= 0 && layerid < m_minLayer ) - continue; - - if( m_maxLayer >= 0 && layerid > m_maxLayer ) + if( (m_notAllowedLayersMask & GetLayerMask( layerid )) != 0 ) continue; wxColour color = MakeColour( GetLayerColor( layerid ) ); @@ -214,43 +201,31 @@ void PCB_ONE_LAYER_SELECTOR::BuildList() m_rightGridLayers->AutoSizeColumn(SELECT_COLNUM); } -void PCB_ONE_LAYER_SELECTOR::OnLeftGridClick( wxGridEvent& event ) +void PCB_ONE_LAYER_SELECTOR::OnLeftGridCellClick( wxGridEvent& event ) { m_layerSelected = m_layersIdLeftColumn[ event.GetRow() ]; + m_leftGridLayers->SetGridCursor( event.GetRow(), LAYERNAME_COLNUM ); EndModal( 1 ); } -void PCB_ONE_LAYER_SELECTOR::OnRightGridClick( wxGridEvent& event ) +void PCB_ONE_LAYER_SELECTOR::OnRightGridCellClick( wxGridEvent& event ) { m_layerSelected = m_layersIdRightColumn[ event.GetRow() ]; + m_rightGridLayers->SetGridCursor( event.GetRow(), LAYERNAME_COLNUM ); EndModal( 2 ); } /** Install the dialog box for layer selection * @param aDefaultLayer = Preselection (NB_PCB_LAYERS for "(Deselect)" layer) - * @param aMinlayer = min layer id value (-1 if no min value) - * @param aMaxLayer = max layer id value (-1 if no max value) - * @param aDeselectTool = display a "Clear" button when true - * @return new layer value (NB_PCB_LAYERS when "(Deselect)" radiobutton selected), - * or -1 if canceled - * - * Providing the option to also display a "Clear" button makes the - * "Swap Layers" command more "user friendly", - * by permitting any layer to be "deselected" immediately after its - * corresponding radiobutton has been clicked on. (It would otherwise be - * necessary to first cancel the "Select Layer:" dialog box (invoked after a - * different radiobutton is clicked on) prior to then clicking on the - * "Clear" button provided within the "Swap Layers:" - * or "Layer selection:" dialog box). + * @param aNotAllowedLayers = a layer mask for not allowed layers + * (= 0 to show all layers in use) + * @return the selected layer id */ LAYER_NUM PCB_BASE_FRAME::SelectLayer( LAYER_NUM aDefaultLayer, - LAYER_NUM aMinlayer, - LAYER_NUM aMaxLayer, - bool aDeselectTool ) + LAYER_MSK aNotAllowedLayersMask ) { PCB_ONE_LAYER_SELECTOR dlg( this, GetBoard(), - aDefaultLayer, aMinlayer, aMaxLayer, - aDeselectTool ); + aDefaultLayer, aNotAllowedLayersMask ); dlg.ShowModal(); LAYER_NUM layer = dlg.GetLayerSelection(); return layer; @@ -283,8 +258,8 @@ public: } private: - void OnLeftGridClick( wxGridEvent& event ); - void OnRightGridClick( wxGridEvent& event ); + void OnLeftGridCellClick( wxGridEvent& event ); + void OnRightGridCellClick( wxGridEvent& event ); void OnOkClick( wxCommandEvent& event ) { @@ -300,10 +275,10 @@ private: }; -/* Display a list of two copper layers to choose a pair of layers - * for auto-routing, vias ... +/* Display a list of two copper layers to choose a pair of copper layers + * the layer pair is used to fast switch between copper layers when placing vias */ -void PCB_BASE_FRAME::SelectLayerPair() +void PCB_BASE_FRAME::SelectCopperLayerPair() { PCB_SCREEN* screen = GetScreen(); SELECT_COPPER_LAYERS_PAIR_DIALOG dlg( this, GetBoard(), @@ -411,7 +386,7 @@ void SELECT_COPPER_LAYERS_PAIR_DIALOG::BuildList() m_rightGridLayers->AutoSizeColumn(SELECT_COLNUM); } -void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnLeftGridClick( wxGridEvent& event ) +void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnLeftGridCellClick( wxGridEvent& event ) { int row = event.GetRow(); LAYER_NUM layer = m_layersId[row]; @@ -434,7 +409,7 @@ void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnLeftGridClick( wxGridEvent& event ) m_leftGridLayers->SetGridCursor( row, LAYERNAME_COLNUM ); } -void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnRightGridClick( wxGridEvent& event ) +void SELECT_COPPER_LAYERS_PAIR_DIALOG::OnRightGridCellClick( wxGridEvent& event ) { int row = event.GetRow(); LAYER_NUM layer = m_layersId[row]; diff --git a/pcbnew/swap_layers.cpp b/pcbnew/swap_layers.cpp index 545c063770..10847c99c5 100644 --- a/pcbnew/swap_layers.cpp +++ b/pcbnew/swap_layers.cpp @@ -195,12 +195,11 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( PCB_BASE_FRAME* parent ) : item_ID = ID_TEXT_0 + ii; /* When the first of these text strings is being added, determine - * what size is necessary to to be able to display any possible - * string without it being truncated. Then specify that size as the - * minimum size for all of these text strings. (If this minimum - * size is not determined in this fashion, then it is possible for - * the display of one or more of these strings to be truncated after - * different layers are selected.) + * what size is necessary to to be able to display the longest + * string without truncation. Then use that size as the + * minimum size for all text strings. (If the minimum + * size is not this size, strings can be truncated after + * some other layer is selected.) */ if( ii == 0 ) { @@ -235,8 +234,8 @@ WinEDA_SwapLayerFrame::WinEDA_SwapLayerFrame( PCB_BASE_FRAME* parent ) : } /* Provide spacers to occupy otherwise blank cells within the second - * FlexGrid sizer. (As it incorporates three columns, three spacers - * are thus required for each otherwise unused row.) + * FlexGrid sizer. (Becuse there are three columns, three spacers + * are thus required for each unused row.) */ for( int ii = 3 * NB_PCB_LAYERS; ii < 96; ii++ ) { @@ -289,28 +288,16 @@ void WinEDA_SwapLayerFrame::Sel_Layer( wxCommandEvent& event ) if( (jj < 0) || (jj > NB_PCB_LAYERS) ) jj = LAYER_NO_CHANGE; // (Defaults to "No Change".) - jj = m_Parent->SelectLayer( jj, UNDEFINED_LAYER, UNDEFINED_LAYER, true ); + jj = m_Parent->SelectLayer( jj ); if( !IsValidLayer( jj ) ) return; - // No change if the selected layer matches the layer being edited. - // (Hence the only way to restore a layer to the "No Change" - // state is by specifically deselecting it; any attempt - // to select the same layer (instead) will be ignored.) - if( jj == ii ) - { - wxString msg; - msg = _( "Deselect this layer to select the No Change state" ); - DisplayInfoMessage( this, msg ); - return; - } - if( jj != New_Layer[ii] ) { New_Layer[ii] = jj; - if( jj >= LAYER_NO_CHANGE ) + if( jj >= LAYER_NO_CHANGE || jj == ii ) { layer_list[ii]->SetLabel( _( "No Change" ) );