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
This commit is contained in:
jean-pierre charras 2013-09-11 17:30:21 +02:00
parent 230c5f8f5a
commit c029dc398b
16 changed files with 159 additions and 223 deletions

View File

@ -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;
}

View File

@ -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 );

View File

@ -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 );
/**

View File

@ -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:

View File

@ -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"

View File

@ -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 );
}

View File

@ -190,7 +190,7 @@
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnGridCellChange"></event>
<event name="OnGridCellLeftClick">OnLeftGridClick</event>
<event name="OnGridCellLeftClick">OnLeftGridCellClick</event>
<event name="OnGridCellLeftDClick"></event>
<event name="OnGridCellRightClick"></event>
<event name="OnGridCellRightDClick"></event>
@ -227,7 +227,7 @@
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnLeftUp">OnLeftButtonReleased</event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
@ -333,7 +333,7 @@
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnGridCellChange"></event>
<event name="OnGridCellLeftClick">OnRightGridClick</event>
<event name="OnGridCellLeftClick">OnRightGridCellClick</event>
<event name="OnGridCellLeftDClick"></event>
<event name="OnGridCellRightClick"></event>
<event name="OnGridCellRightDClick"></event>
@ -370,7 +370,7 @@
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnLeftUp">OnLeftButtonReleased</event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
@ -388,94 +388,6 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_RIGHT</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Clear Selection</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_buttonClear</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnClearSelection</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="Dialog" expanded="1">

View File

@ -18,10 +18,10 @@
#include <wx/grid.h>
#include <wx/gdicmn.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
#include <wx/stattext.h>
#include <wx/statline.h>
#include <wx/button.h>
///////////////////////////////////////////////////////////////////////////
@ -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:

View File

@ -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 );

View File

@ -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;
}
}

View File

@ -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

View File

@ -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 <dick@softplc.com>
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
* 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 <dick@softplc.com>
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
* 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();
}
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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<LAYER_NUM> m_layersIdLeftColumn;
std::vector<LAYER_NUM> 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];

View File

@ -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" ) );