Commit 6c04e605 authored by Dick Hollenbeck's avatar Dick Hollenbeck

see CHANGELOG.txt

parent 716d21d8
...@@ -4,6 +4,32 @@ KiCad ChangeLog 2012 ...@@ -4,6 +4,32 @@ KiCad ChangeLog 2012
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2012-Feb-5 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================
++pcbnew
* Changed classs ZONE_SETTING to class ZONE_SETTINGS, better English.
* Changed ZONE_SETTINGS::Import() to operator << ( ZONE_CONTAINER )
* move globals into BOARD:
bool g_Zone_45_Only, is now in BOARD::m_zoneSettings.m_Zone_45_Only
ZONE_SETTINGS g_Zone_Default_Setting is now in BOARD::m_zoneSettings
* Added BOARD::{Get,Set}ZoneSettings().
* Added PCB_BASE_FRAME::{Get,Set}ZoneSettings().
* Save/load BOARD::m_zoneSettings.m_Zone_45_Only to/from BOARD file.
* Removed PCB_EDIT_FRAME::InstallDialogNonCopperZonesEditor() in favor of
::InvokeNonCopperZonesEditor() declared in zones.h
* Added ::InvokeCopperZonesEditor() declared in zones.h
* Removed dialog_copper_zones.h since DIALOG class is now declared in *.cpp.
* Renamed to enum ZONE_EDIT_T in zones.h
* SetVisibleAlls() is not called as it was in two previous cases for several
reasons. BOARD_DESIGN_SETTINGS constructor controls what is visible initially.
and in the near future so will the *.brd file. I believe the user should
have visibility setting rentention accross editing sessions of zones,
fields, etc.
* BOARD_DESIGN_SETTINGS constructor initializes hidden text as not visible.
* Added PCB_EDIT_FRAME::SyncRenderStates() and PCB_LAYER_WIDGET::syncRenderStates()
so the checkboxes can be set after loading a BOARD file containing previous
visibility settings.
2012-Feb-2 UPDATE Dick Hollenbeck <dick@softplc.com> 2012-Feb-2 UPDATE Dick Hollenbeck <dick@softplc.com>
================================================================================ ================================================================================
++pcbnew ++pcbnew
......
...@@ -106,7 +106,7 @@ set(PCB_COMMON_SRCS ...@@ -106,7 +106,7 @@ set(PCB_COMMON_SRCS
../pcbnew/class_text_mod.cpp ../pcbnew/class_text_mod.cpp
../pcbnew/class_track.cpp ../pcbnew/class_track.cpp
../pcbnew/class_zone.cpp ../pcbnew/class_zone.cpp
../pcbnew/class_zone_setting.cpp ../pcbnew/class_zone_settings.cpp
../pcbnew/classpcb.cpp ../pcbnew/classpcb.cpp
../pcbnew/collectors.cpp ../pcbnew/collectors.cpp
../pcbnew/sel_layer.cpp ../pcbnew/sel_layer.cpp
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include <plot_common.h> #include <plot_common.h>
#include <class_pad.h> #include <class_pad.h>
#include <class_zone_setting.h> #include <class_zone_settings.h>
#include <class_board_design_settings.h> #include <class_board_design_settings.h>
...@@ -100,9 +100,6 @@ int g_PadCUColor = GREEN; ...@@ -100,9 +100,6 @@ int g_PadCUColor = GREEN;
int g_PadCMPColor = RED; int g_PadCMPColor = RED;
// Current design settings:
class BOARD_DESIGN_SETTINGS g_DesignSettings;
/** /**
* Used in track creation, a list of track segments currently being created, * Used in track creation, a list of track segments currently being created,
* with the newest track at the end of the list, sorted by new-ness. e.g. use * with the newest track at the end of the list, sorted by new-ness. e.g. use
...@@ -111,9 +108,4 @@ class BOARD_DESIGN_SETTINGS g_DesignSettings; ...@@ -111,9 +108,4 @@ class BOARD_DESIGN_SETTINGS g_DesignSettings;
*/ */
DLIST<TRACK> g_CurrentTrackList; DLIST<TRACK> g_CurrentTrackList;
bool g_Zone_45_Only = false;
// Default setting used when creating a new zone
ZONE_SETTING g_Zone_Default_Setting;
D_PAD g_Pad_Master( (MODULE*) NULL ); D_PAD g_Pad_Master( (MODULE*) NULL );
...@@ -10,13 +10,6 @@ ...@@ -10,13 +10,6 @@
// Class for handle current printed board design settings // Class for handle current printed board design settings
class BOARD_DESIGN_SETTINGS class BOARD_DESIGN_SETTINGS
{ {
protected:
int m_CopperLayerCount; ///< Number of copper layers for this design
int m_EnabledLayers; ///< Bit-mask for layer enabling
int m_VisibleLayers; ///< Bit-mask for layer visibility
int m_VisibleElements; ///< Bit-mask for element category visibility
public: public:
bool m_MicroViasAllowed; ///< true to allow micro vias bool m_MicroViasAllowed; ///< true to allow micro vias
int m_CurrentViaType; ///< via type (VIA_BLIND_BURIED, VIA_TROUGHT VIA_MICROVIA) int m_CurrentViaType; ///< via type (VIA_BLIND_BURIED, VIA_TROUGHT VIA_MICROVIA)
...@@ -57,9 +50,10 @@ public: ...@@ -57,9 +50,10 @@ public:
/** /**
* Function SetVisibleAlls * Function SetVisibleAlls
* Set the bit-mask of all visible elements categories, including layers * Set the bit-mask of all visible elements categories,
* including enabled layers
*/ */
void SetVisibleAlls( ); void SetVisibleAlls();
/** /**
* Function SetVisibleLayers * Function SetVisibleLayers
...@@ -177,6 +171,13 @@ public: ...@@ -177,6 +171,13 @@ public:
* @param aNewLayerCount = The new number of enabled copper layers * @param aNewLayerCount = The new number of enabled copper layers
*/ */
void SetCopperLayerCount( int aNewLayerCount ); void SetCopperLayerCount( int aNewLayerCount );
private:
int m_CopperLayerCount; ///< Number of copper layers for this design
int m_EnabledLayers; ///< Bit-mask for layer enabling
int m_VisibleLayers; ///< Bit-mask for layer visibility
int m_VisibleElements; ///< Bit-mask for element category visibility
}; };
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <richio.h> #include <richio.h>
#include <class_pcb_screen.h> #include <class_pcb_screen.h>
#ifndef PCB_INTERNAL_UNIT #ifndef PCB_INTERNAL_UNIT
#define PCB_INTERNAL_UNIT 10000 #define PCB_INTERNAL_UNIT 10000
#endif #endif
...@@ -56,6 +57,7 @@ class EDA_3D_FRAME; ...@@ -56,6 +57,7 @@ class EDA_3D_FRAME;
class GENERAL_COLLECTOR; class GENERAL_COLLECTOR;
class GENERAL_COLLECTORS_GUIDE; class GENERAL_COLLECTORS_GUIDE;
class BOARD_DESIGN_SETTINGS; class BOARD_DESIGN_SETTINGS;
class ZONE_SETTINGS;
/** /**
* class PCB_BASE_FRAME * class PCB_BASE_FRAME
...@@ -130,6 +132,9 @@ public: ...@@ -130,6 +132,9 @@ public:
virtual BOARD_DESIGN_SETTINGS& GetDesignSettings() const; virtual BOARD_DESIGN_SETTINGS& GetDesignSettings() const;
virtual void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings ); virtual void SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings );
const ZONE_SETTINGS& GetZoneSettings() const;
void SetZoneSettings( const ZONE_SETTINGS& aSettings );
/** /**
* Function SetBoard * Function SetBoard
* sets the m_Pcb member in such as way as to ensure deleting any previous * sets the m_Pcb member in such as way as to ensure deleting any previous
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <class_layer_box_selector.h> #include <class_layer_box_selector.h>
#include <class_macros_record.h> #include <class_macros_record.h>
#include <class_undoredo_container.h> #include <class_undoredo_container.h>
#include <zones.h>
#ifndef PCB_INTERNAL_UNIT #ifndef PCB_INTERNAL_UNIT
#define PCB_INTERNAL_UNIT 10000 #define PCB_INTERNAL_UNIT 10000
...@@ -119,7 +119,7 @@ protected: ...@@ -119,7 +119,7 @@ protected:
( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer; ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
if( doLayerWidgetUpdate ) if( doLayerWidgetUpdate )
syncLayerWidget(); syncLayerWidgetLayer();
} }
/** /**
...@@ -132,7 +132,7 @@ protected: ...@@ -132,7 +132,7 @@ protected:
} }
/** /**
* Function syncLayerWidget * Function syncLayerWidgetLayer
* updates the currently "selected" layer within the PCB_LAYER_WIDGET. * updates the currently "selected" layer within the PCB_LAYER_WIDGET.
* The currently active layer is defined by the return value of getActiveLayer(). * The currently active layer is defined by the return value of getActiveLayer().
* <p> * <p>
...@@ -140,7 +140,15 @@ protected: ...@@ -140,7 +140,15 @@ protected:
* here and we do not want to do that. * here and we do not want to do that.
* </p> * </p>
*/ */
void syncLayerWidget(); void syncLayerWidgetLayer();
/**
* Function syncRenderStates
* updates the "Render" checkboxes in the layer widget according
* to current toggle values determined by IsElementVisible(), and is helpful
* immediately after loading a BOARD which may have state information in it.
*/
void syncRenderStates();
virtual void unitsChangeRefresh(); virtual void unitsChangeRefresh();
...@@ -702,7 +710,7 @@ public: ...@@ -702,7 +710,7 @@ public:
void OnConfigurePcbOptions( wxCommandEvent& aEvent ); void OnConfigurePcbOptions( wxCommandEvent& aEvent );
void InstallDisplayOptionsDialog( wxCommandEvent& aEvent ); void InstallDisplayOptionsDialog( wxCommandEvent& aEvent );
void InstallPcbGlobalDeleteFrame( const wxPoint& pos ); void InstallPcbGlobalDeleteFrame( const wxPoint& pos );
bool InstallDialogNonCopperZonesEditor( ZONE_CONTAINER* aZone );
void InstallDialogLayerSetup(); void InstallDialogLayerSetup();
void GenModulesPosition( wxCommandEvent& event ); void GenModulesPosition( wxCommandEvent& event );
......
...@@ -194,6 +194,20 @@ void PCB_BASE_FRAME::SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings ) ...@@ -194,6 +194,20 @@ void PCB_BASE_FRAME::SetDesignSettings( const BOARD_DESIGN_SETTINGS& aSettings )
} }
const ZONE_SETTINGS& PCB_BASE_FRAME::GetZoneSettings() const
{
wxASSERT( m_Pcb );
return m_Pcb->GetZoneSettings();
}
void PCB_BASE_FRAME::SetZoneSettings( const ZONE_SETTINGS& aSettings )
{
wxASSERT( m_Pcb );
m_Pcb->SetZoneSettings( aSettings );
}
EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const EDA_RECT PCB_BASE_FRAME::GetBoardBoundingBox( bool aBoardEdgesOnly ) const
{ {
wxASSERT( m_Pcb ); wxASSERT( m_Pcb );
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <common.h> #include <common.h>
#include <pcbcommon.h> #include <pcbcommon.h>
#include <wxBasePcbFrame.h> #include <wxBasePcbFrame.h>
#include <build_version.h> // BOARD_FILE_VERSION
#include <pcbnew.h> #include <pcbnew.h>
#include <colors_selection.h> #include <colors_selection.h>
...@@ -52,16 +51,16 @@ BOARD::BOARD() : ...@@ -52,16 +51,16 @@ BOARD::BOARD() :
m_Layer[layer].m_Type = LT_SIGNAL; m_Layer[layer].m_Type = LT_SIGNAL;
} }
// Initial parameters for the default NETCLASS come from the global
// preferences within g_DesignSettings via the NETCLASS() constructor.
// Should user eventually load a board from a disk file, then these
// defaults will get overwritten during load.
m_NetClasses.GetDefault()->SetDescription( _( "This is the default net class." ) ); m_NetClasses.GetDefault()->SetDescription( _( "This is the default net class." ) );
m_ViaSizeSelector = 0; m_ViaSizeSelector = 0;
m_TrackWidthSelector = 0; m_TrackWidthSelector = 0;
/* Dick 5-Feb-2012: this seems unnecessary. I don't believe the comment in
near line 70 of class_netclass.cpp. I stepped through with debugger.
// Initialize default values in default netclass. // Initialize default values in default netclass.
m_NetClasses.GetDefault()->SetParams(); m_NetClasses.GetDefault()->SetParams();
*/
SetCurrentNetClass( m_NetClasses.GetDefault()->GetName() ); SetCurrentNetClass( m_NetClasses.GetDefault()->GetName() );
} }
...@@ -530,14 +529,14 @@ void BOARD::SetVisibleElements( int aMask ) ...@@ -530,14 +529,14 @@ void BOARD::SetVisibleElements( int aMask )
} }
} }
// these are not tidy, since there are PCB_VISIBLEs that are not stored in the bitmap. // these are not tidy, since there are PCB_VISIBLEs that are not stored in the bitmap.
void BOARD::SetVisibleAlls( ) void BOARD::SetVisibleAlls()
{ {
SetVisibleLayers( FULL_LAYERS ); SetVisibleLayers( FULL_LAYERS );
/* Call SetElementVisibility for each item, // Call SetElementVisibility for each item,
* to ensure specific calculations that can be needed by some items // to ensure specific calculations that can be needed by some items
*/
for( int ii = 0; ii < PCB_VISIBLE(END_PCB_VISIBLE_LIST); ii++ ) for( int ii = 0; ii < PCB_VISIBLE(END_PCB_VISIBLE_LIST); ii++ )
SetElementVisibility( ii, true ); SetElementVisibility( ii, true );
} }
...@@ -557,14 +556,16 @@ bool BOARD::IsElementVisible( int aPCB_VISIBLE ) const ...@@ -557,14 +556,16 @@ bool BOARD::IsElementVisible( int aPCB_VISIBLE ) const
void BOARD::SetElementVisibility( int aPCB_VISIBLE, bool isEnabled ) void BOARD::SetElementVisibility( int aPCB_VISIBLE, bool isEnabled )
{ {
m_designSettings.SetElementVisibility( aPCB_VISIBLE, isEnabled );
switch( aPCB_VISIBLE ) switch( aPCB_VISIBLE )
{ {
case RATSNEST_VISIBLE: case RATSNEST_VISIBLE:
m_designSettings.SetElementVisibility( aPCB_VISIBLE, isEnabled );
// we must clear or set the CH_VISIBLE flags to hide/show ratsnet // we must clear or set the CH_VISIBLE flags to hide/show ratsnet
// because we have a tool to show hide ratsnest relative to a pad or a module // because we have a tool to show hide ratsnest relative to a pad or a module
// so the hide/show option is a per item selection // so the hide/show option is a per item selection
if( IsElementVisible(RATSNEST_VISIBLE) ) if( IsElementVisible( RATSNEST_VISIBLE ) )
{ {
for( unsigned ii = 0; ii < GetRatsnestsCount(); ii++ ) for( unsigned ii = 0; ii < GetRatsnestsCount(); ii++ )
m_FullRatsnest[ii].m_Status |= CH_VISIBLE; m_FullRatsnest[ii].m_Status |= CH_VISIBLE;
...@@ -574,12 +575,10 @@ void BOARD::SetElementVisibility( int aPCB_VISIBLE, bool isEnabled ) ...@@ -574,12 +575,10 @@ void BOARD::SetElementVisibility( int aPCB_VISIBLE, bool isEnabled )
for( unsigned ii = 0; ii < GetRatsnestsCount(); ii++ ) for( unsigned ii = 0; ii < GetRatsnestsCount(); ii++ )
m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE; m_FullRatsnest[ii].m_Status &= ~CH_VISIBLE;
} }
break; break;
default: default:
m_designSettings.SetElementVisibility( aPCB_VISIBLE, isEnabled ); ;
} }
} }
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <class_board_design_settings.h> #include <class_board_design_settings.h>
#include <common.h> // PAGE_INFO #include <common.h> // PAGE_INFO
#include <class_title_block.h> #include <class_title_block.h>
#include <class_zone_settings.h>
class PCB_BASE_FRAME; class PCB_BASE_FRAME;
class PCB_EDIT_FRAME; class PCB_EDIT_FRAME;
...@@ -174,6 +176,7 @@ private: ...@@ -174,6 +176,7 @@ private:
NETINFO_LIST m_NetInfo; ///< net info list (name, design constraints .. NETINFO_LIST m_NetInfo; ///< net info list (name, design constraints ..
BOARD_DESIGN_SETTINGS m_designSettings; BOARD_DESIGN_SETTINGS m_designSettings;
ZONE_SETTINGS m_zoneSettings;
COLORS_DESIGN_SETTINGS* m_colorsSettings; COLORS_DESIGN_SETTINGS* m_colorsSettings;
PAGE_INFO m_paper; PAGE_INFO m_paper;
TITLE_BLOCK m_titles; ///< text in lower right of screen and plots TITLE_BLOCK m_titles; ///< text in lower right of screen and plots
...@@ -549,8 +552,11 @@ public: ...@@ -549,8 +552,11 @@ public:
TITLE_BLOCK& GetTitleBlock() { return m_titles; } TITLE_BLOCK& GetTitleBlock() { return m_titles; }
void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; } void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; }
const ZONE_SETTINGS& GetZoneSettings() const { return m_zoneSettings; }
void SetZoneSettings( const ZONE_SETTINGS& aSettings ) { m_zoneSettings = aSettings; }
/** /**
* Function SetBoardSettings * Function SetColorSettings
* @return the current COLORS_DESIGN_SETTINGS in use * @return the current COLORS_DESIGN_SETTINGS in use
*/ */
COLORS_DESIGN_SETTINGS* GetColorsSettings() const { return m_colorsSettings; } COLORS_DESIGN_SETTINGS* GetColorsSettings() const { return m_colorsSettings; }
......
...@@ -17,7 +17,11 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() ...@@ -17,7 +17,11 @@ BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS()
{ {
m_EnabledLayers = ALL_LAYERS; // All layers enabled at first. m_EnabledLayers = ALL_LAYERS; // All layers enabled at first.
// SetCopperLayerCount() will adjust this. // SetCopperLayerCount() will adjust this.
SetVisibleAlls(); // All layers and all elements visible at first.
SetVisibleLayers( FULL_LAYERS );
// set all but hidden text as visible.
m_VisibleElements = 0xFFFFFFFF & ~( 1 << MOD_TEXT_INVISIBLE );
SetCopperLayerCount( 2 ); // Default design is a double sided board SetCopperLayerCount( 2 ); // Default design is a double sided board
...@@ -62,11 +66,6 @@ int BOARD_DESIGN_SETTINGS::GetVisibleLayers() const ...@@ -62,11 +66,6 @@ int BOARD_DESIGN_SETTINGS::GetVisibleLayers() const
} }
/**
* Function SetVisibleAlls
* Set the bit-mask of all visible elements categories,
* including enabled layers
*/
void BOARD_DESIGN_SETTINGS::SetVisibleAlls() void BOARD_DESIGN_SETTINGS::SetVisibleAlls()
{ {
SetVisibleLayers( FULL_LAYERS ); SetVisibleLayers( FULL_LAYERS );
......
...@@ -66,13 +66,20 @@ void NETCLASS::SetParams( const NETCLASS* defaults ) ...@@ -66,13 +66,20 @@ void NETCLASS::SetParams( const NETCLASS* defaults )
SetuViaDrill( defaults->GetuViaDrill() ); SetuViaDrill( defaults->GetuViaDrill() );
} }
else else
{ // Note: {
/* Dick 5-Feb-2012: I do not believe this comment to be true with current code.
It is certainly not a constructor race.
// Note:
// We use m_Parent->GetDesignSettings() to get some default values // We use m_Parent->GetDesignSettings() to get some default values
// But when this function is called when instantiating a BOARD class, // But when this function is called when instantiating a BOARD class,
// by the NETCLASSES constructor that calls NETCLASS constructor, // by the NETCLASSES constructor that calls NETCLASS constructor,
// the BOARD constructor (see BOARD::BOARD) is not yet run, // the BOARD constructor (see BOARD::BOARD) is not yet run,
// and BOARD::m_designSettings contains not yet initialized values. // and BOARD::m_designSettings contains not yet initialized values.
// So inside the BOARD constructor itself, you SHOULD recall SetParams // So inside the BOARD constructor itself, you SHOULD recall SetParams
*/
const BOARD_DESIGN_SETTINGS& g = m_Parent->GetDesignSettings(); const BOARD_DESIGN_SETTINGS& g = m_Parent->GetDesignSettings();
SetTrackWidth( g.m_TrackMinWidth ); SetTrackWidth( g.m_TrackMinWidth );
......
...@@ -86,7 +86,7 @@ public: ...@@ -86,7 +86,7 @@ public:
* @param aParent = the parent board * @param aParent = the parent board
* @param aName = the name of this new netclass * @param aName = the name of this new netclass
* @param initialParameters is a NETCLASS to copy parameters from, or if * @param initialParameters is a NETCLASS to copy parameters from, or if
* NULL tells me to copy from g_DesignSettings. * NULL tells me to copy default settings from BOARD::m_designSettings.
*/ */
NETCLASS( BOARD* aParent, const wxString& aName, const NETCLASS* initialParameters = NULL ); NETCLASS( BOARD* aParent, const wxString& aName, const NETCLASS* initialParameters = NULL );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004-2010 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr * Copyright (C) 2004-2010 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -46,12 +46,32 @@ ...@@ -46,12 +46,32 @@
#include <pcbnew_id.h> #include <pcbnew_id.h>
/** // this is a read only template that is copied and modified before adding to LAYER_WIDGET
* Class PCB_LAYER_WIDGET const LAYER_WIDGET::ROW PCB_LAYER_WIDGET::s_render_rows[] = {
* is here to implement the abtract functions of LAYER_WIDGET so they
* may be tied into the PCB_EDIT_FRAME's data and so we can add a popup #define RR LAYER_WIDGET::ROW // Render Row abreviation to reduce source width
* menu which is specific to Pcbnew's needs.
*/ // text id color tooltip
RR( _( "Through Via" ), VIA_THROUGH_VISIBLE, WHITE, _( "Show through vias" ) ),
RR( _( "Bl/Buried Via" ), VIA_BBLIND_VISIBLE, WHITE, _( "Show blind or buried vias" ) ),
RR( _( "Micro Via" ), VIA_MICROVIA_VISIBLE, WHITE, _( "Show micro vias") ),
RR( _( "Ratsnest" ), RATSNEST_VISIBLE, WHITE, _( "Show unconnected nets as a ratsnest") ),
RR( _( "Pads Front" ), PAD_FR_VISIBLE, WHITE, _( "Show footprint pads on board's front" ) ),
RR( _( "Pads Back" ), PAD_BK_VISIBLE, WHITE, _( "Show footprint pads on board's back" ) ),
RR( _( "Text Front" ), MOD_TEXT_FR_VISIBLE, WHITE, _( "Show footprint text on board's back" ) ),
RR( _( "Text Back" ), MOD_TEXT_BK_VISIBLE, WHITE, _( "Show footprint text on board's back" ) ),
RR( _( "Hidden Text" ), MOD_TEXT_INVISIBLE, WHITE, _( "Show footprint text marked as invisible" ) ),
RR( _( "Anchors" ), ANCHOR_VISIBLE, WHITE, _( "Show footprint and text origins as a cross" ) ),
RR( _( "Grid" ), GRID_VISIBLE, WHITE, _( "Show the (x,y) grid dots" ) ),
RR( _( "No-Connects" ), NO_CONNECTS_VISIBLE, -1, _( "Show a marker on pads which have no net connected" ) ),
RR( _( "Modules Front" ), MOD_FR_VISIBLE, -1, _( "Show footprints that are on board's front") ),
RR( _( "Modules Back" ), MOD_BK_VISIBLE, -1, _( "Show footprints that are on board's back") ),
RR( _( "Values" ), MOD_VALUES_VISIBLE, -1, _( "Show footprint's values") ),
RR( _( "References" ), MOD_REFERENCES_VISIBLE, -1, _( "Show footprint's references") ),
};
PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_EDIT_FRAME* aParent, wxWindow* aFocusOwner, int aPointSize ) : PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_EDIT_FRAME* aParent, wxWindow* aFocusOwner, int aPointSize ) :
...@@ -61,7 +81,7 @@ PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_EDIT_FRAME* aParent, wxWindow* aFocusOwn ...@@ -61,7 +81,7 @@ PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_EDIT_FRAME* aParent, wxWindow* aFocusOwn
ReFillRender(); ReFillRender();
// Update default tabs labels for GerbView // Update default tabs labels for GerbView
SetLayersManagerTabsText( ); SetLayersManagerTabsText();
//-----<Popup menu>------------------------------------------------- //-----<Popup menu>-------------------------------------------------
// handle the popup menu over the layer window. // handle the popup menu over the layer window.
...@@ -100,17 +120,16 @@ void PCB_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event ) ...@@ -100,17 +120,16 @@ void PCB_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
// menu text is capitalized: // menu text is capitalized:
// http://library.gnome.org/devel/hig-book/2.20/design-text-labels.html.en#layout-capitalization // http://library.gnome.org/devel/hig-book/2.20/design-text-labels.html.en#layout-capitalization
menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_COPPERS, menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_COPPERS, _( "Show All Copper Layers" ) ) );
_("Show All Copper Layers") ) );
menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_COPPERS, menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_COPPERS, _( "Hide All Copper Layers" ) ) );
_( "Hide All Copper Layers" ) ) );
PopupMenu( &menu ); PopupMenu( &menu );
passOnFocus(); passOnFocus();
} }
void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
{ {
int rowCount; int rowCount;
...@@ -160,68 +179,48 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event ) ...@@ -160,68 +179,48 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
} }
} }
/**
* Function SetLayersManagerTabsText void PCB_LAYER_WIDGET::SetLayersManagerTabsText()
* Update the layer manager tabs labels
* Useful when changing Language or to set labels to a non default value
*/
void PCB_LAYER_WIDGET::SetLayersManagerTabsText( )
{ {
m_notebook->SetPageText(0, _("Layer") ); m_notebook->SetPageText( 0, _( "Layer" ) );
m_notebook->SetPageText(1, _("Render") ); m_notebook->SetPageText( 1, _( "Render" ) );
} }
/**
* Function ReFillRender
* Rebuild Render for instance after the config is read
*/
void PCB_LAYER_WIDGET::ReFillRender() void PCB_LAYER_WIDGET::ReFillRender()
{ {
BOARD* board = myframe->GetBoard(); BOARD* board = myframe->GetBoard();
ClearRenderRows(); ClearRenderRows();
// Fixed "Rendering" tab rows within the LAYER_WIDGET, only the initial color
// is changed before appending to the LAYER_WIDGET. This is an automatic variable
// not a static variable, change the color & state after copying from code to renderRows
// on the stack.
LAYER_WIDGET::ROW renderRows[16] = {
#define RR LAYER_WIDGET::ROW // Render Row abreviation to reduce source width // Add "Render" tab rows to LAYER_WIDGET, after setting color and checkbox state.
for( unsigned row=0; row<DIM(s_render_rows); ++row )
{
LAYER_WIDGET::ROW renderRow = s_render_rows[row];
// text id color tooltip checked if( renderRow.color != -1 ) // does this row show a color?
RR( _( "Through Via" ), VIA_THROUGH_VISIBLE, WHITE, _( "Show through vias" ) ), {
RR( _( "Bl/Buried Via" ), VIA_BBLIND_VISIBLE, WHITE, _( "Show blind or buried vias" ) ), // this window frame must have an established BOARD, i.e. after SetBoard()
RR( _( "Micro Via" ), VIA_MICROVIA_VISIBLE, WHITE, _( "Show micro vias") ), renderRow.color = board->GetVisibleElementColor( renderRow.id );
RR( _( "Ratsnest" ), RATSNEST_VISIBLE, WHITE, _( "Show unconnected nets as a ratsnest") ), }
renderRow.state = board->IsElementVisible( renderRow.id );
RR( _( "Pads Front" ), PAD_FR_VISIBLE, WHITE, _( "Show footprint pads on board's front" ) ), AppendRenderRow( renderRow );
RR( _( "Pads Back" ), PAD_BK_VISIBLE, WHITE, _( "Show footprint pads on board's back" ) ), }
}
RR( _( "Text Front" ), MOD_TEXT_FR_VISIBLE, WHITE, _( "Show footprint text on board's back" ) ),
RR( _( "Text Back" ), MOD_TEXT_BK_VISIBLE, WHITE, _( "Show footprint text on board's back" ) ),
RR( _( "Hidden Text" ), MOD_TEXT_INVISIBLE, WHITE, _( "Show footprint text marked as invisible" ) ),
RR( _( "Anchors" ), ANCHOR_VISIBLE, WHITE, _( "Show footprint and text origins as a cross" ) ), void PCB_LAYER_WIDGET::SyncRenderStates()
RR( _( "Grid" ), GRID_VISIBLE, WHITE, _( "Show the (x,y) grid dots" ) ), {
RR( _( "No-Connects" ), NO_CONNECTS_VISIBLE, -1, _( "Show a marker on pads which have no net connected" ) ), BOARD* board = myframe->GetBoard();
RR( _( "Modules Front" ), MOD_FR_VISIBLE, -1, _( "Show footprints that are on board's front") ),
RR( _( "Modules Back" ), MOD_BK_VISIBLE, -1, _( "Show footprints that are on board's back") ),
RR( _( "Values" ), MOD_VALUES_VISIBLE, -1, _( "Show footprint's values") ),
RR( _( "References" ), MOD_REFERENCES_VISIBLE, -1, _( "Show footprint's references") ),
};
for( unsigned row=0; row<DIM(renderRows); ++row ) for( unsigned row=0; row<DIM(s_render_rows); ++row )
{ {
if( renderRows[row].color != -1 ) // does this row show a color? // this does not fire an event
{ SetRenderState( s_render_rows[row].id, board->IsElementVisible( s_render_rows[row].id ) );
// this window frame must have an established BOARD, i.e. after SetBoard()
renderRows[row].color = board->GetVisibleElementColor( renderRows[row].id );
} }
renderRows[row].state = board->IsElementVisible( renderRows[row].id );
}
AppendRenderRows( renderRows, DIM(renderRows) );
} }
void PCB_LAYER_WIDGET::ReFill() void PCB_LAYER_WIDGET::ReFill()
{ {
BOARD* brd = myframe->GetBoard(); BOARD* brd = myframe->GetBoard();
...@@ -304,6 +303,7 @@ void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, int aColor ) ...@@ -304,6 +303,7 @@ void PCB_LAYER_WIDGET::OnLayerColorChange( int aLayer, int aColor )
myframe->GetCanvas()->Refresh(); myframe->GetCanvas()->Refresh();
} }
bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer ) bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer )
{ {
// the layer change from the PCB_LAYER_WIDGET can be denied by returning // the layer change from the PCB_LAYER_WIDGET can be denied by returning
...@@ -316,6 +316,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer ) ...@@ -316,6 +316,7 @@ bool PCB_LAYER_WIDGET::OnLayerSelect( int aLayer )
return true; return true;
} }
void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal ) void PCB_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
{ {
BOARD* brd = myframe->GetBoard(); BOARD* brd = myframe->GetBoard();
...@@ -369,5 +370,3 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled ) ...@@ -369,5 +370,3 @@ void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
} }
//-----</LAYER_WIDGET callbacks>------------------------------------------ //-----</LAYER_WIDGET callbacks>------------------------------------------
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
/* class_pcb_layer_widget.h : header for the layers manager */ /* class_pcb_layer_widget.h : header for the layers manager */
/************************************************************/ /************************************************************/
#ifndef _CLASS_PCB_LAYER_WIDGET_H_ #ifndef CLASS_PCB_LAYER_WIDGET_H_
#define _CLASS_PCB_LAYER_WIDGET_H_ #define CLASS_PCB_LAYER_WIDGET_H_
/** /**
* Class PCB_LAYER_WIDGET * Class PCB_LAYER_WIDGET
...@@ -39,24 +39,6 @@ ...@@ -39,24 +39,6 @@
*/ */
class PCB_LAYER_WIDGET : public LAYER_WIDGET class PCB_LAYER_WIDGET : public LAYER_WIDGET
{ {
PCB_EDIT_FRAME* myframe;
// popup menu ids.
#define ID_SHOW_ALL_COPPERS wxID_HIGHEST
#define ID_SHOW_NO_COPPERS (wxID_HIGHEST+1)
/**
* Function OnRightDownLayers
* puts up a popup menu for the layer panel.
*/
void onRightDownLayers( wxMouseEvent& event );
void onPopupSelection( wxCommandEvent& event );
/// this is for the popup menu, the right click handler has to be installed
/// on every child control within the layer panel.
void installRightLayerClickHandler();
public: public:
/** /**
...@@ -73,23 +55,54 @@ public: ...@@ -73,23 +55,54 @@ public:
/** /**
* Function ReFillRender * Function ReFillRender
* Rebuild Render for instance after the config is read * rebuilds Render for instance after the config is read
*/ */
void ReFillRender(); void ReFillRender();
/**
* Function SyncRenderStates
* updates the checkboxes (checked or not) to be consistent with the current state
* of the visibility of the visible rendering elements.
*/
void SyncRenderStates();
/**
* Function SetLayersManagerTabsText
* Update the layer manager tabs labels
* Useful when changing Language or to set labels to a non default value
*/
void SetLayersManagerTabsText();
//-----<implement LAYER_WIDGET abstract callback functions>----------- //-----<implement LAYER_WIDGET abstract callback functions>-----------
void OnLayerColorChange( int aLayer, int aColor ); void OnLayerColorChange( int aLayer, int aColor );
bool OnLayerSelect( int aLayer ); bool OnLayerSelect( int aLayer );
void OnLayerVisible( int aLayer, bool isVisible, bool isFinal ); void OnLayerVisible( int aLayer, bool isVisible, bool isFinal );
void OnRenderColorChange( int aId, int aColor ); void OnRenderColorChange( int aId, int aColor );
void OnRenderEnable( int aId, bool isEnabled ); void OnRenderEnable( int aId, bool isEnabled );
//-----</implement LAYER_WIDGET abstract callback functions>----------
protected:
static const LAYER_WIDGET::ROW s_render_rows[];
PCB_EDIT_FRAME* myframe;
// popup menu ids.
#define ID_SHOW_ALL_COPPERS wxID_HIGHEST
#define ID_SHOW_NO_COPPERS (wxID_HIGHEST+1)
/** /**
* Function SetLayersManagerTabsText * Function OnRightDownLayers
* Update the layer manager tabs labels * puts up a popup menu for the layer panel.
* Useful when changing Language or to set labels to a non default value
*/ */
void SetLayersManagerTabsText( ); void onRightDownLayers( wxMouseEvent& event );
//-----</implement LAYER_WIDGET abstract callback functions>----------
void onPopupSelection( wxCommandEvent& event );
/// this is for the popup menu, the right click handler has to be installed
/// on every child control within the layer panel.
void installRightLayerClickHandler();
}; };
#endif // _CLASS_PCB_LAYER_WIDGET_H_ #endif // CLASS_PCB_LAYER_WIDGET_H_
...@@ -48,8 +48,8 @@ ...@@ -48,8 +48,8 @@
#include <zones.h> #include <zones.h>
ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) : ZONE_CONTAINER::ZONE_CONTAINER( BOARD* aBoard ) :
BOARD_CONNECTED_ITEM( parent, PCB_ZONE_AREA_T ) BOARD_CONNECTED_ITEM( aBoard, PCB_ZONE_AREA_T )
{ {
SetNet( -1 ); // Net number for fast comparisons SetNet( -1 ); // Net number for fast comparisons
m_CornerSelection = -1; m_CornerSelection = -1;
...@@ -57,12 +57,12 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) : ...@@ -57,12 +57,12 @@ ZONE_CONTAINER::ZONE_CONTAINER( BOARD* parent ) :
m_FillMode = 0; // How to fill areas: 0 = use filled polygons, != 0 fill with segments m_FillMode = 0; // How to fill areas: 0 = use filled polygons, != 0 fill with segments
m_priority = 0; m_priority = 0;
smoothedPoly = NULL; smoothedPoly = NULL;
cornerSmoothingType = ZONE_SETTING::SMOOTHING_NONE; cornerSmoothingType = ZONE_SETTINGS::SMOOTHING_NONE;
cornerRadius = 0; cornerRadius = 0;
utility = 0; // flags used in polygon calculations utility = 0; // flags used in polygon calculations
utility2 = 0; // flags used in polygon calculations utility2 = 0; // flags used in polygon calculations
m_Poly = new CPolyLine(); // Outlines m_Poly = new CPolyLine(); // Outlines
g_Zone_Default_Setting.ExportSetting( *this ); aBoard->GetZoneSettings().ExportSetting( *this );
} }
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <class_board_connected_item.h> #include <class_board_connected_item.h>
#include <layers_id_colors_and_visibility.h> #include <layers_id_colors_and_visibility.h>
#include <PolyLine.h> #include <PolyLine.h>
#include <class_zone_setting.h> #include <class_zone_settings.h>
class EDA_RECT; class EDA_RECT;
......
/******************************************************/ /******************************************************/
/* class ZONE_SETTING used to handle zones parameters */ /* class ZONE_SETTINGS used to handle zones parameters */
/******************************************************/ /******************************************************/
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <class_zone.h> #include <class_zone.h>
ZONE_SETTING::ZONE_SETTING( void ) ZONE_SETTINGS::ZONE_SETTINGS()
{ {
m_ZonePriority = 0; m_ZonePriority = 0;
m_FillMode = 0; // Mode for filling zone : 1 use segments, 0 use polygons m_FillMode = 0; // Mode for filling zone : 1 use segments, 0 use polygons
...@@ -31,25 +31,24 @@ ZONE_SETTING::ZONE_SETTING( void ) ...@@ -31,25 +31,24 @@ ZONE_SETTING::ZONE_SETTING( void )
m_NetcodeSelection = 0; // Net code selection for the current zone m_NetcodeSelection = 0; // Net code selection for the current zone
m_CurrentZone_Layer = 0; // Layer used to create the current zone m_CurrentZone_Layer = 0; // Layer used to create the current zone
m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE; // Option to show the zone area (outlines only, short hatches or full hatches m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE; // Option to show the zone area (outlines only, short hatches or full hatches
m_ArcToSegmentsCount = ARC_APPROX_SEGMENTS_COUNT_LOW_DEF; /* Option to select number of segments to approximate a circle
* ARC_APPROX_SEGMENTS_COUNT_LOW_DEF m_ArcToSegmentsCount = ARC_APPROX_SEGMENTS_COUNT_LOW_DEF; // Option to select number of segments to approximate a circle
* or ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF segments */ // ARC_APPROX_SEGMENTS_COUNT_LOW_DEF
// or ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF segments
m_ThermalReliefGap = 200; // tickness of the gap in thermal reliefs m_ThermalReliefGap = 200; // tickness of the gap in thermal reliefs
m_ThermalReliefCopperBridge = 200; // tickness of the copper bridge in thermal reliefs m_ThermalReliefCopperBridge = 200; // tickness of the copper bridge in thermal reliefs
m_Zone_Pad_Options = THERMAL_PAD; // How pads are covered by copper in zone m_Zone_Pad_Options = THERMAL_PAD; // How pads are covered by copper in zone
m_Zone_45_Only = false;
cornerSmoothingType = SMOOTHING_NONE; cornerSmoothingType = SMOOTHING_NONE;
cornerRadius = 0; cornerRadius = 0;
} }
/** ZONE_SETTINGS& ZONE_SETTINGS::operator << ( const ZONE_CONTAINER& aSource )
* Function ImportSetting
* copy settings from a given zone
* @param aSource: the given zone
*/
void ZONE_SETTING::ImportSetting( const ZONE_CONTAINER& aSource )
{ {
m_ZonePriority = aSource.GetPriority(); m_ZonePriority = aSource.GetPriority();
m_FillMode = aSource.m_FillMode; m_FillMode = aSource.m_FillMode;
...@@ -64,19 +63,12 @@ void ZONE_SETTING::ImportSetting( const ZONE_CONTAINER& aSource ) ...@@ -64,19 +63,12 @@ void ZONE_SETTING::ImportSetting( const ZONE_CONTAINER& aSource )
m_Zone_Pad_Options = aSource.m_PadOption; m_Zone_Pad_Options = aSource.m_PadOption;
cornerSmoothingType = aSource.GetCornerSmoothingType(); cornerSmoothingType = aSource.GetCornerSmoothingType();
cornerRadius = aSource.GetCornerRadius(); cornerRadius = aSource.GetCornerRadius();
return *this;
} }
/** void ZONE_SETTINGS::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport ) const
* Function ExportSetting
* copy settings to a given zone
* @param aTarget: the given zone
* @param aFullExport: if false: some parameters are NOT exported
* because they must not be exported when export settings from a zone to others zones
* Currently:
* m_NetcodeSelection
*/
void ZONE_SETTING::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport )
{ {
aTarget.m_FillMode = m_FillMode; aTarget.m_FillMode = m_FillMode;
aTarget.m_ZoneClearance = m_ZoneClearance; aTarget.m_ZoneClearance = m_ZoneClearance;
...@@ -88,6 +80,7 @@ void ZONE_SETTING::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport ) ...@@ -88,6 +80,7 @@ void ZONE_SETTING::ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport )
aTarget.m_PadOption = m_Zone_Pad_Options; aTarget.m_PadOption = m_Zone_Pad_Options;
aTarget.SetCornerSmoothingType( cornerSmoothingType ); aTarget.SetCornerSmoothingType( cornerSmoothingType );
aTarget.SetCornerRadius( cornerRadius ); aTarget.SetCornerRadius( cornerRadius );
if( aFullExport ) if( aFullExport )
{ {
aTarget.SetPriority( m_ZonePriority ); aTarget.SetPriority( m_ZonePriority );
......
/** /**
* @file class_zone_setting.h * @file class_zone_settings.h
* @brief Class ZONE_SETTING used to handle zones parameters in dialogs. * @brief Class ZONE_SETTINGS used to handle zones parameters in dialogs.
*/ */
#ifndef ZONE_SETTING_H #ifndef ZONE_SETTINGS_H_
#define ZONE_SETTING_H #define ZONE_SETTINGS_H_
class ZONE_CONTAINER; class ZONE_CONTAINER;
...@@ -14,10 +14,10 @@ class ZONE_CONTAINER; ...@@ -14,10 +14,10 @@ class ZONE_CONTAINER;
/** /**
* Class ZONE_SETTING * Class ZONE_SETTINGS
* handles zones parameters. * handles zones parameters.
*/ */
class ZONE_SETTING class ZONE_SETTINGS
{ {
public: public:
enum { enum {
...@@ -27,39 +27,42 @@ public: ...@@ -27,39 +27,42 @@ public:
SMOOTHING_LAST SMOOTHING_LAST
}; };
// Mode for filling zone : 1 use segments, 0 use polygons /// Mode for filling zone : 1 use segments, 0 use polygons
int m_FillMode; int m_FillMode;
int m_ZonePriority; // Priority (0 ... N) of the zone int m_ZonePriority; ///< Priority (0 ... N) of the zone
int m_ZoneClearance; // Clearance value int m_ZoneClearance; ///< Clearance value
int m_ZoneMinThickness; // Min thickness value in filled areas int m_ZoneMinThickness; ///< Min thickness value in filled areas
int m_NetcodeSelection; // Net code selection for the current zone int m_NetcodeSelection; ///< Net code selection for the current zone
int m_CurrentZone_Layer; // Layer used to create the current zone int m_CurrentZone_Layer; ///< Layer used to create the current zone
// Option to show the zone area (outlines only, short hatches or full hatches /// Option to show the zone area (outlines only, short hatches or full hatches
int m_Zone_HatchingStyle; int m_Zone_HatchingStyle;
// Option to select number of segments to approximate a circle 16 or 32 segments. /// Option to select number of segments to approximate a circle 16 or 32 segments.
int m_ArcToSegmentsCount; int m_ArcToSegmentsCount;
long m_ThermalReliefGap; // thickness of the gap in thermal reliefs long m_ThermalReliefGap; ///< thickness of the gap in thermal reliefs
long m_ThermalReliefCopperBridge; // thickness of the copper bridge in thermal reliefs long m_ThermalReliefCopperBridge; ///< thickness of the copper bridge in thermal reliefs
int m_Zone_Pad_Options; // How pads are covered by copper in zone int m_Zone_Pad_Options; ///< How pads are covered by copper in zone
bool m_Zone_45_Only;
private: private:
int cornerSmoothingType; // Corner smoothing type int cornerSmoothingType; ///< Corner smoothing type
unsigned int cornerRadius; // Corner chamfer distance / fillet radius unsigned int cornerRadius; ///< Corner chamfer distance / fillet radius
public: public:
ZONE_SETTING( void ); ZONE_SETTINGS();
/** /**
* Function ImportSetting * operator << ( const ZONE_CONTAINER& )
* copy settings from a given zone * was Function ImportSetting
* copies settings from a given zone into this object.
* @param aSource: the given zone * @param aSource: the given zone
*/ */
void ImportSetting( const ZONE_CONTAINER& aSource ); ZONE_SETTINGS& operator << ( const ZONE_CONTAINER& aSource );
/** /**
* Function ExportSetting * Function ExportSetting
...@@ -70,7 +73,7 @@ public: ...@@ -70,7 +73,7 @@ public:
* Currently: * Currently:
* m_NetcodeSelection * m_NetcodeSelection
*/ */
void ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport = true); void ExportSetting( ZONE_CONTAINER& aTarget, bool aFullExport = true ) const;
void SetCornerSmoothingType( int aType) { cornerSmoothingType = aType; }; void SetCornerSmoothingType( int aType) { cornerSmoothingType = aType; };
...@@ -90,4 +93,4 @@ public: ...@@ -90,4 +93,4 @@ public:
}; };
#endif // ifndef ZONE_SETTING_H #endif // ZONE_SETTINGS_H_
...@@ -16,9 +16,89 @@ ...@@ -16,9 +16,89 @@
#include <trigo.h> #include <trigo.h>
#include <zones.h> #include <zones.h>
#include <dialog_copper_zones.h> #include <class_zone_settings.h>
#include <class_zone_setting.h>
#include <class_board.h> #include <class_board.h>
#include <dialog_copper_zones_base.h>
/**
* Class DIALOG_COPPER_ZONE
* is the derived class from dialog_copper_zone_frame created by wxFormBuilder
*/
class DIALOG_COPPER_ZONE : public DIALOG_COPPER_ZONE_BASE
{
public:
DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings );
private:
PCB_BASE_FRAME* m_Parent;
wxConfig* m_Config; ///< Current config
ZONE_EDIT_T m_OnExitCode; ///< exit code: ZONE_ABORT if no change,
///< ZONE_OK if new values accepted
///< ZONE_EXPORT_VALUES if values are exported to others zones
ZONE_SETTINGS m_settings;
ZONE_SETTINGS* m_ptr;
bool m_NetSortingByPadCount; ///< false = alphabetic sort.
///< true = pad count sort.
long m_NetFiltering;
std::vector<int> m_LayerId; ///< Handle the real layer number from layer
///< name position in m_LayerSelectionCtrl
static wxString m_netNameShowFilter; ///< the filter to show nets (default * "*").
///< static to keep this pattern for an entire pcbnew session
wxListView* m_LayerSelectionCtrl;
static wxPoint prevPosition; ///< Dialog position & size
static wxSize prevSize;
/**
* Function initDialog
* fills in the dialog controls using the current settings.
*/
void initDialog();
void OnButtonOkClick( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event );
void OnClose( wxCloseEvent& event );
void OnSize( wxSizeEvent& event );
void OnCornerSmoothingModeChoice( wxCommandEvent& event );
/**
* Function AcceptOptions
* @param aPromptForErrors is true to prompt user on incorrect params.
* @param aUseExportableSetupOnly is true to use exportable parametres only (used to export this setup to other zones).
* @return bool - false if incorrect options, true if ok.
*/
bool AcceptOptions( bool aPromptForErrors, bool aUseExportableSetupOnly = false );
void OnNetSortingOptionSelected( wxCommandEvent& event );
void ExportSetupToOtherCopperZones( wxCommandEvent& event );
void OnPadsInZoneClick( wxCommandEvent& event );
void OnRunFiltersButtonClick( wxCommandEvent& event );
void buildAvailableListOfNets();
/**
* Function initListNetsParams
* initializes m_NetSortingByPadCount and m_NetFiltering values
* according to m_NetDisplayOption selection.
*/
void initListNetsParams();
/**
* Function makeLayerBitmap
* creates the colored rectangle bitmaps used in the layer selection widget.
* @param aColor is the color to fill the rectangle with.
*/
wxBitmap makeLayerBitmap( int aColor );
};
#define LAYER_BITMAP_SIZE_X 20 #define LAYER_BITMAP_SIZE_X 20
...@@ -30,12 +110,27 @@ wxPoint DIALOG_COPPER_ZONE::prevPosition( -1, -1 ); ...@@ -30,12 +110,27 @@ wxPoint DIALOG_COPPER_ZONE::prevPosition( -1, -1 );
wxSize DIALOG_COPPER_ZONE::prevSize; wxSize DIALOG_COPPER_ZONE::prevSize;
DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE( PCB_EDIT_FRAME* parent, ZONE_SETTING* zone_setting ) : ZONE_EDIT_T InvokeCopperZonesEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings )
DIALOG_COPPER_ZONE_BASE( parent ) {
DIALOG_COPPER_ZONE dlg( aCaller, aSettings );
ZONE_EDIT_T result = ZONE_EDIT_T( dlg.ShowModal() );
// D(printf( "%s: result:%d\n", __FUNCTION__, result );)
return result;
}
DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings ) :
DIALOG_COPPER_ZONE_BASE( aParent )
{ {
m_Parent = parent; m_Parent = aParent;
m_Config = wxGetApp().GetSettings(); m_Config = wxGetApp().GetSettings();
m_Zone_Setting = zone_setting;
m_ptr = aSettings;
m_settings = *aSettings;
m_NetSortingByPadCount = true; // false = alphabetic sort, true = pad count sort m_NetSortingByPadCount = true; // false = alphabetic sort, true = pad count sort
m_OnExitCode = ZONE_ABORT; m_OnExitCode = ZONE_ABORT;
...@@ -76,24 +171,24 @@ void DIALOG_COPPER_ZONE::initDialog() ...@@ -76,24 +171,24 @@ void DIALOG_COPPER_ZONE::initDialog()
wxString msg; wxString msg;
if( g_Zone_45_Only ) if( m_settings.m_Zone_45_Only )
m_OrientEdgesOpt->SetSelection( 1 ); m_OrientEdgesOpt->SetSelection( 1 );
m_FillModeCtrl->SetSelection( m_Zone_Setting->m_FillMode ? 1 : 0 ); m_FillModeCtrl->SetSelection( m_settings.m_FillMode ? 1 : 0 );
AddUnitSymbol( *m_ClearanceValueTitle, g_UserUnit ); AddUnitSymbol( *m_ClearanceValueTitle, g_UserUnit );
msg = ReturnStringFromValue( g_UserUnit, msg = ReturnStringFromValue( g_UserUnit,
m_Zone_Setting->m_ZoneClearance, m_settings.m_ZoneClearance,
m_Parent->GetInternalUnits() ); m_Parent->GetInternalUnits() );
m_ZoneClearanceCtrl->SetValue( msg ); m_ZoneClearanceCtrl->SetValue( msg );
AddUnitSymbol( *m_MinThicknessValueTitle, g_UserUnit ); AddUnitSymbol( *m_MinThicknessValueTitle, g_UserUnit );
msg = ReturnStringFromValue( g_UserUnit, msg = ReturnStringFromValue( g_UserUnit,
m_Zone_Setting->m_ZoneMinThickness, m_settings.m_ZoneMinThickness,
m_Parent->GetInternalUnits() ); m_Parent->GetInternalUnits() );
m_ZoneMinThicknessCtrl->SetValue( msg ); m_ZoneMinThicknessCtrl->SetValue( msg );
switch( m_Zone_Setting->m_Zone_Pad_Options ) switch( m_settings.m_Zone_Pad_Options )
{ {
case PAD_NOT_IN_ZONE: // Pads are not covered case PAD_NOT_IN_ZONE: // Pads are not covered
m_PadInZoneOpt->SetSelection( 2 ); m_PadInZoneOpt->SetSelection( 2 );
...@@ -108,7 +203,7 @@ void DIALOG_COPPER_ZONE::initDialog() ...@@ -108,7 +203,7 @@ void DIALOG_COPPER_ZONE::initDialog()
break; break;
} }
if( m_Zone_Setting->m_Zone_Pad_Options != THERMAL_PAD ) if( m_settings.m_Zone_Pad_Options != THERMAL_PAD )
{ {
m_AntipadSizeValue->Enable( false ); m_AntipadSizeValue->Enable( false );
m_CopperWidthValue->Enable( false ); m_CopperWidthValue->Enable( false );
...@@ -119,24 +214,24 @@ void DIALOG_COPPER_ZONE::initDialog() ...@@ -119,24 +214,24 @@ void DIALOG_COPPER_ZONE::initDialog()
m_CopperWidthValue->Enable( true ); m_CopperWidthValue->Enable( true );
} }
m_PriorityLevelCtrl->SetValue( m_Zone_Setting->m_ZonePriority ); m_PriorityLevelCtrl->SetValue( m_settings.m_ZonePriority );
AddUnitSymbol( *m_AntipadSizeText, g_UserUnit ); AddUnitSymbol( *m_AntipadSizeText, g_UserUnit );
AddUnitSymbol( *m_CopperBridgeWidthText, g_UserUnit ); AddUnitSymbol( *m_CopperBridgeWidthText, g_UserUnit );
PutValueInLocalUnits( *m_AntipadSizeValue, PutValueInLocalUnits( *m_AntipadSizeValue,
m_Zone_Setting->m_ThermalReliefGap, m_settings.m_ThermalReliefGap,
PCB_INTERNAL_UNIT ); PCB_INTERNAL_UNIT );
PutValueInLocalUnits( *m_CopperWidthValue, PutValueInLocalUnits( *m_CopperWidthValue,
m_Zone_Setting->m_ThermalReliefCopperBridge, m_settings.m_ThermalReliefCopperBridge,
PCB_INTERNAL_UNIT ); PCB_INTERNAL_UNIT );
m_cornerSmoothingChoice->SetSelection( m_Zone_Setting->GetCornerSmoothingType() ); m_cornerSmoothingChoice->SetSelection( m_settings.GetCornerSmoothingType() );
PutValueInLocalUnits( *m_cornerSmoothingCtrl, PutValueInLocalUnits( *m_cornerSmoothingCtrl,
m_Zone_Setting->GetCornerRadius(), m_settings.GetCornerRadius(),
PCB_INTERNAL_UNIT ); PCB_INTERNAL_UNIT );
switch( m_Zone_Setting->m_Zone_HatchingStyle ) switch( m_settings.m_Zone_HatchingStyle )
{ {
case CPolyLine::NO_HATCH: case CPolyLine::NO_HATCH:
m_OutlineAppearanceCtrl->SetSelection( 0 ); m_OutlineAppearanceCtrl->SetSelection( 0 );
...@@ -152,7 +247,7 @@ void DIALOG_COPPER_ZONE::initDialog() ...@@ -152,7 +247,7 @@ void DIALOG_COPPER_ZONE::initDialog()
} }
m_ArcApproximationOpt->SetSelection( m_ArcApproximationOpt->SetSelection(
m_Zone_Setting->m_ArcToSegmentsCount == ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF ? 1 : 0 ); m_settings.m_ArcToSegmentsCount == ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF ? 1 : 0 );
// Build copper layer list and append to layer widget // Build copper layer list and append to layer widget
int layerCount = board->GetCopperLayerCount(); int layerCount = board->GetCopperLayerCount();
...@@ -175,7 +270,7 @@ void DIALOG_COPPER_ZONE::initDialog() ...@@ -175,7 +270,7 @@ void DIALOG_COPPER_ZONE::initDialog()
imageList->Add( makeLayerBitmap( layerColor ) ); imageList->Add( makeLayerBitmap( layerColor ) );
itemIndex = m_LayerSelectionCtrl->InsertItem( 0, msg, ii ); itemIndex = m_LayerSelectionCtrl->InsertItem( 0, msg, ii );
if( m_Zone_Setting->m_CurrentZone_Layer == layerNumber ) if( m_settings.m_CurrentZone_Layer == layerNumber )
m_LayerSelectionCtrl->Select( itemIndex ); m_LayerSelectionCtrl->Select( itemIndex );
} }
...@@ -206,11 +301,27 @@ void DIALOG_COPPER_ZONE::OnButtonCancelClick( wxCommandEvent& event ) ...@@ -206,11 +301,27 @@ void DIALOG_COPPER_ZONE::OnButtonCancelClick( wxCommandEvent& event )
Close( true ); Close( true );
} }
void DIALOG_COPPER_ZONE::OnButtonOkClick( wxCommandEvent& event )
{
m_netNameShowFilter = m_ShowNetNameFilter->GetValue();
prevPosition = GetPosition();
prevSize = GetSize();
if( AcceptOptions( true ) )
{
EndModal( ZONE_OK );
}
}
void DIALOG_COPPER_ZONE::OnClose( wxCloseEvent& event ) void DIALOG_COPPER_ZONE::OnClose( wxCloseEvent& event )
{ {
prevPosition = GetPosition(); prevPosition = GetPosition();
prevSize = GetSize(); prevSize = GetSize();
if( m_OnExitCode != ZONE_ABORT )
*m_ptr = m_settings;
EndModal( m_OnExitCode ); EndModal( m_OnExitCode );
} }
...@@ -225,126 +336,101 @@ void DIALOG_COPPER_ZONE::OnSize( wxSizeEvent& event ) ...@@ -225,126 +336,101 @@ void DIALOG_COPPER_ZONE::OnSize( wxSizeEvent& event )
} }
void DIALOG_COPPER_ZONE::OnCornerSmoothingModeChoice( wxCommandEvent& event )
{
int selection = m_cornerSmoothingChoice->GetSelection();
switch( selection )
{
case ZONE_SETTING::SMOOTHING_NONE:
m_cornerSmoothingTitle->Enable( false );
m_cornerSmoothingCtrl->Enable( false );
break;
case ZONE_SETTING::SMOOTHING_CHAMFER:
m_cornerSmoothingTitle->Enable( true );
m_cornerSmoothingCtrl->Enable( true );
m_cornerSmoothingTitle->SetLabel( _( "Chamfer distance" ) );
AddUnitSymbol( *m_cornerSmoothingTitle, g_UserUnit );
break;
case ZONE_SETTING::SMOOTHING_FILLET:
m_cornerSmoothingTitle->Enable( true );
m_cornerSmoothingCtrl->Enable( true );
m_cornerSmoothingTitle->SetLabel( _( "Fillet radius" ) );
AddUnitSymbol( *m_cornerSmoothingTitle, g_UserUnit );
break;
}
}
bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportableSetupOnly ) bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportableSetupOnly )
{ {
switch( m_PadInZoneOpt->GetSelection() ) switch( m_PadInZoneOpt->GetSelection() )
{ {
case 2: case 2:
m_Zone_Setting->m_Zone_Pad_Options = PAD_NOT_IN_ZONE; // Pads are not covered // Pads are not covered
m_settings.m_Zone_Pad_Options = PAD_NOT_IN_ZONE;
break; break;
case 1: case 1:
m_Zone_Setting->m_Zone_Pad_Options = THERMAL_PAD; // Use thermal relief for pads // Use thermal relief for pads
m_settings.m_Zone_Pad_Options = THERMAL_PAD;
break; break;
case 0: case 0:
m_Zone_Setting->m_Zone_Pad_Options = PAD_IN_ZONE; // pads are covered by copper // pads are covered by copper
m_settings.m_Zone_Pad_Options = PAD_IN_ZONE;
break; break;
} }
switch( m_OutlineAppearanceCtrl->GetSelection() ) switch( m_OutlineAppearanceCtrl->GetSelection() )
{ {
case 0: case 0:
m_Zone_Setting->m_Zone_HatchingStyle = CPolyLine::NO_HATCH; m_settings.m_Zone_HatchingStyle = CPolyLine::NO_HATCH;
break; break;
case 1: case 1:
m_Zone_Setting->m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE; m_settings.m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE;
break; break;
case 2: case 2:
m_Zone_Setting->m_Zone_HatchingStyle = CPolyLine::DIAGONAL_FULL; m_settings.m_Zone_HatchingStyle = CPolyLine::DIAGONAL_FULL;
break; break;
} }
m_Zone_Setting->m_ArcToSegmentsCount = m_ArcApproximationOpt->GetSelection() == 1 ? m_settings.m_ArcToSegmentsCount = m_ArcApproximationOpt->GetSelection() == 1 ?
ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF : ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF :
ARC_APPROX_SEGMENTS_COUNT_LOW_DEF; ARC_APPROX_SEGMENTS_COUNT_LOW_DEF;
if( m_Config ) if( m_Config )
{ {
m_Config->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY, m_Config->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY,
(long) m_Zone_Setting->m_Zone_HatchingStyle ); (long) m_settings.m_Zone_HatchingStyle );
wxString Filter = m_DoNotShowNetNameFilter->GetValue(); wxString filter = m_DoNotShowNetNameFilter->GetValue();
m_Config->Write( ZONE_NET_FILTER_STRING_KEY, Filter ); m_Config->Write( ZONE_NET_FILTER_STRING_KEY, filter );
} }
m_netNameShowFilter = m_ShowNetNameFilter->GetValue(); m_netNameShowFilter = m_ShowNetNameFilter->GetValue();
m_Zone_Setting->m_FillMode = (m_FillModeCtrl->GetSelection() == 0) ? 0 : 1; m_settings.m_FillMode = (m_FillModeCtrl->GetSelection() == 0) ? 0 : 1;
wxString txtvalue = m_ZoneClearanceCtrl->GetValue(); wxString txtvalue = m_ZoneClearanceCtrl->GetValue();
m_Zone_Setting->m_ZoneClearance = m_settings.m_ZoneClearance =
ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() ); ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() );
// Test if this is a reasonnable value for this parameter // Test if this is a reasonnable value for this parameter
// A too large value can hang Pcbnew // A too large value can hang Pcbnew
#define CLEARANCE_MAX_VALUE 5000 // in 1/10000 inch #define CLEARANCE_MAX_VALUE 5000 // in 1/10000 inch
if( m_Zone_Setting->m_ZoneClearance > CLEARANCE_MAX_VALUE ) if( m_settings.m_ZoneClearance > CLEARANCE_MAX_VALUE )
{ {
DisplayError( this, _( "Clearance must be smaller than 0.5\" / 12.7 mm." ) ); DisplayError( this, _( "Clearance must be smaller than 0.5\" / 12.7 mm." ) );
return false; return false;
} }
txtvalue = m_ZoneMinThicknessCtrl->GetValue(); txtvalue = m_ZoneMinThicknessCtrl->GetValue();
m_Zone_Setting->m_ZoneMinThickness = m_settings.m_ZoneMinThickness =
ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() ); ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() );
if( m_Zone_Setting->m_ZoneMinThickness < 10 ) if( m_settings.m_ZoneMinThickness < 10 )
{ {
DisplayError( this, DisplayError( this,
_( "Minimum width must be larger than 0.001\" / 0.0254 mm." ) ); _( "Minimum width must be larger than 0.001\" / 0.0254 mm." ) );
return false; return false;
} }
m_Zone_Setting->SetCornerSmoothingType( m_cornerSmoothingChoice->GetSelection() ); m_settings.SetCornerSmoothingType( m_cornerSmoothingChoice->GetSelection() );
txtvalue = m_cornerSmoothingCtrl->GetValue(); txtvalue = m_cornerSmoothingCtrl->GetValue();
m_Zone_Setting->SetCornerRadius( ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() ) ); m_settings.SetCornerRadius( ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() ) );
m_Zone_Setting->m_ZonePriority = m_PriorityLevelCtrl->GetValue(); m_settings.m_ZonePriority = m_PriorityLevelCtrl->GetValue();
if( m_OrientEdgesOpt->GetSelection() == 0 ) if( m_OrientEdgesOpt->GetSelection() == 0 )
g_Zone_45_Only = false; m_settings.m_Zone_45_Only = false;
else else
g_Zone_45_Only = true; m_settings.m_Zone_45_Only = true;
m_Zone_Setting->m_ThermalReliefGap = ReturnValueFromTextCtrl( *m_AntipadSizeValue, m_settings.m_ThermalReliefGap = ReturnValueFromTextCtrl( *m_AntipadSizeValue, PCB_INTERNAL_UNIT );
PCB_INTERNAL_UNIT );
m_Zone_Setting->m_ThermalReliefCopperBridge = ReturnValueFromTextCtrl( m_settings.m_ThermalReliefCopperBridge = ReturnValueFromTextCtrl(
*m_CopperWidthValue, *m_CopperWidthValue,
PCB_INTERNAL_UNIT ); PCB_INTERNAL_UNIT );
m_Config->Write( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, m_Config->Write( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, (long) m_settings.m_ThermalReliefGap );
(long) m_Zone_Setting->m_ThermalReliefGap );
m_Config->Write( m_Config->Write( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY, (long) m_settings.m_ThermalReliefCopperBridge );
ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY,
(long) m_Zone_Setting->m_ThermalReliefCopperBridge );
if( m_Zone_Setting->m_ThermalReliefCopperBridge <= m_Zone_Setting->m_ZoneMinThickness ) if( m_settings.m_ThermalReliefCopperBridge <= m_settings.m_ZoneMinThickness )
{ {
DisplayError( this, DisplayError( this,
_( "Thermal relief spoke width is larger than the minimum width." ) ); _( "Thermal relief spoke width is larger than the minimum width." ) );
...@@ -364,7 +450,7 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab ...@@ -364,7 +450,7 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab
return false; return false;
} }
m_Zone_Setting->m_CurrentZone_Layer = m_LayerId[ii]; m_settings.m_CurrentZone_Layer = m_LayerId[ii];
// Get the net name selection for this zone // Get the net name selection for this zone
ii = m_ListNetNameSelection->GetSelection(); ii = m_ListNetNameSelection->GetSelection();
...@@ -385,19 +471,44 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab ...@@ -385,19 +471,44 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab
wxString net_name = m_ListNetNameSelection->GetString( ii ); wxString net_name = m_ListNetNameSelection->GetString( ii );
g_Zone_Default_Setting.m_NetcodeSelection = 0; m_settings.m_NetcodeSelection = 0;
// Search net_code for this net, if a net was selected // Search net_code for this net, if a net was selected
if( m_ListNetNameSelection->GetSelection() > 0 ) if( m_ListNetNameSelection->GetSelection() > 0 )
{ {
NETINFO_ITEM* net = m_Parent->GetBoard()->FindNet( net_name ); NETINFO_ITEM* net = m_Parent->GetBoard()->FindNet( net_name );
if( net ) if( net )
g_Zone_Default_Setting.m_NetcodeSelection = net->GetNet(); m_settings.m_NetcodeSelection = net->GetNet();
} }
return true; return true;
} }
void DIALOG_COPPER_ZONE::OnCornerSmoothingModeChoice( wxCommandEvent& event )
{
int selection = m_cornerSmoothingChoice->GetSelection();
switch( selection )
{
case ZONE_SETTINGS::SMOOTHING_NONE:
m_cornerSmoothingTitle->Enable( false );
m_cornerSmoothingCtrl->Enable( false );
break;
case ZONE_SETTINGS::SMOOTHING_CHAMFER:
m_cornerSmoothingTitle->Enable( true );
m_cornerSmoothingCtrl->Enable( true );
m_cornerSmoothingTitle->SetLabel( _( "Chamfer distance" ) );
AddUnitSymbol( *m_cornerSmoothingTitle, g_UserUnit );
break;
case ZONE_SETTINGS::SMOOTHING_FILLET:
m_cornerSmoothingTitle->Enable( true );
m_cornerSmoothingCtrl->Enable( true );
m_cornerSmoothingTitle->SetLabel( _( "Fillet radius" ) );
AddUnitSymbol( *m_cornerSmoothingTitle, g_UserUnit );
break;
}
}
void DIALOG_COPPER_ZONE::OnNetSortingOptionSelected( wxCommandEvent& event ) void DIALOG_COPPER_ZONE::OnNetSortingOptionSelected( wxCommandEvent& event )
{ {
...@@ -414,17 +525,6 @@ void DIALOG_COPPER_ZONE::OnNetSortingOptionSelected( wxCommandEvent& event ) ...@@ -414,17 +525,6 @@ void DIALOG_COPPER_ZONE::OnNetSortingOptionSelected( wxCommandEvent& event )
} }
void DIALOG_COPPER_ZONE::OnButtonOkClick( wxCommandEvent& event )
{
m_netNameShowFilter = m_ShowNetNameFilter->GetValue();
prevPosition = GetPosition();
prevSize = GetSize();
if( AcceptOptions( true ) )
EndModal( ZONE_OK );
}
void DIALOG_COPPER_ZONE::ExportSetupToOtherCopperZones( wxCommandEvent& event ) void DIALOG_COPPER_ZONE::ExportSetupToOtherCopperZones( wxCommandEvent& event )
{ {
prevPosition = GetPosition(); prevPosition = GetPosition();
...@@ -438,7 +538,7 @@ void DIALOG_COPPER_ZONE::ExportSetupToOtherCopperZones( wxCommandEvent& event ) ...@@ -438,7 +538,7 @@ void DIALOG_COPPER_ZONE::ExportSetupToOtherCopperZones( wxCommandEvent& event )
for( int ii = 0; ii < pcb->GetAreaCount(); ii++ ) for( int ii = 0; ii < pcb->GetAreaCount(); ii++ )
{ {
ZONE_CONTAINER* zone = pcb->GetArea( ii ); ZONE_CONTAINER* zone = pcb->GetArea( ii );
m_Zone_Setting->ExportSetting( *zone, false ); // false = partiel export m_settings.ExportSetting( *zone, false ); // false = partial export
m_Parent->OnModify(); m_Parent->OnModify();
} }
...@@ -534,7 +634,7 @@ void DIALOG_COPPER_ZONE::buildAvailableListOfNets() ...@@ -534,7 +634,7 @@ void DIALOG_COPPER_ZONE::buildAvailableListOfNets()
// Ensure currently selected net for the zone is visible, regardless of filters // Ensure currently selected net for the zone is visible, regardless of filters
int selectedNetListNdx = -1; int selectedNetListNdx = -1;
int net_select = m_Zone_Setting->m_NetcodeSelection; int net_select = m_settings.m_NetcodeSelection;
if( net_select > 0 ) if( net_select > 0 )
{ {
......
/* dialog_copper_zones.h */
#ifndef DIALOG_COPPER_ZONES_
#define DIALOG_COPPER_ZONES_
#include <wx/wx.h>
#include <wx/listctrl.h>
#include <dialog_copper_zones_base.h>
/**
* Class DIALOG_COPPER_ZONE
* is the derivated class from dialog_copper_zone_frame created by wxFormBuilder
*/
class DIALOG_COPPER_ZONE : public DIALOG_COPPER_ZONE_BASE
{
private:
PCB_EDIT_FRAME* m_Parent;
wxConfig* m_Config; ///< Current config
int m_OnExitCode; ///< exit code: ZONE_ABORT if no change,
///< ZONE_OK if new values accepted
///< ZONE_EXPORT_VALUES if values are exported to others zones
ZONE_SETTING* m_Zone_Setting;
bool m_NetSortingByPadCount; ///< false = alphabetic sort.
///< true = pad count sort.
long m_NetFiltering;
std::vector<int> m_LayerId; ///< Handle the real layer number from layer
///< name position in m_LayerSelectionCtrl
static wxString m_netNameShowFilter; ///< the filter to show nets (default * "*").
///< static to keep this pattern for an entire pcbnew session
wxListView* m_LayerSelectionCtrl;
static wxPoint prevPosition; ///< Dialog position & size
static wxSize prevSize;
public:
DIALOG_COPPER_ZONE( PCB_EDIT_FRAME* parent, ZONE_SETTING* zone_setting );
private:
/**
* Function initDialog
* fills in the dialog controls using the current settings.
*/
void initDialog();
void OnButtonOkClick( wxCommandEvent& event );
void OnButtonCancelClick( wxCommandEvent& event );
void OnClose( wxCloseEvent& event );
void OnSize( wxSizeEvent& event );
void OnCornerSmoothingModeChoice( wxCommandEvent& event );
/**
* Function AcceptOptions
* @param aPromptForErrors is true to prompt user on incorrect params.
* @param aUseExportableSetupOnly is true to use exportable parametres only (used to export this setup to other zones).
* @return bool - false if incorrect options, true if ok.
*/
bool AcceptOptions( bool aPromptForErrors, bool aUseExportableSetupOnly = false );
void OnNetSortingOptionSelected( wxCommandEvent& event );
void ExportSetupToOtherCopperZones( wxCommandEvent& event );
void OnPadsInZoneClick( wxCommandEvent& event );
void OnRunFiltersButtonClick( wxCommandEvent& event );
void buildAvailableListOfNets();
/**
* Function initListNetsParams
* initializes m_NetSortingByPadCount and m_NetFiltering values
* according to m_NetDisplayOption selection.
*/
void initListNetsParams();
/**
* Function makeLayerBitmap
* creates the colored rectangle bitmaps used in the layer selection widget.
* @param aColor is the color to fill the rectangle with.
*/
wxBitmap makeLayerBitmap( int aColor );
};
#endif // DIALOG_COPPER_ZONES_
...@@ -191,7 +191,7 @@ void DRC::RunTests( wxTextCtrl* aMessages ) ...@@ -191,7 +191,7 @@ void DRC::RunTests( wxTextCtrl* aMessages )
if( !testNetClasses() ) if( !testNetClasses() )
{ {
// testing the netclasses is a special case because if the netclasses // testing the netclasses is a special case because if the netclasses
// do not pass the g_DesignSettings checks, then every member of a net // do not pass the BOARD_DESIGN_SETTINGS checks, then every member of a net
// class (a NET) will cause its items such as tracks, vias, and pads // class (a NET) will cause its items such as tracks, vias, and pads
// to also fail. So quit after *all* netclass errors have been reported. // to also fail. So quit after *all* netclass errors have been reported.
if( aMessages ) if( aMessages )
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* Basic routine used by other routines when editing tracks or vias * Basic routine used by other routines when editing tracks or vias
* @param aTrackItem = the track segment or via to modify * @param aTrackItem = the track segment or via to modify
* @param aItemsListPicker = the list picker to use for an undo command (can be NULL) * @param aItemsListPicker = the list picker to use for an undo command (can be NULL)
* @param aUseNetclassValue = true to use NetClass value, false to use g_DesignSettings value * @param aUseNetclassValue = true to use NetClass value, false to use BOARD::m_designSettings value
* @return true if done, false if no not change (because DRC error) * @return true if done, false if no not change (because DRC error)
*/ */
bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem, bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
...@@ -71,7 +71,7 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem, ...@@ -71,7 +71,7 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem,
aTrackItem->m_Width = new_width; aTrackItem->m_Width = new_width;
/* make a DRC test because the new size is bigger than the old size */ // make a DRC test because the new size is bigger than the old size
if( initial_width < new_width ) if( initial_width < new_width )
{ {
int diagdrc = OK_DRC; int diagdrc = OK_DRC;
...@@ -218,16 +218,16 @@ bool PCB_EDIT_FRAME::Change_Net_Tracks_And_Vias_Sizes( int aNetcode, bool aUseNe ...@@ -218,16 +218,16 @@ bool PCB_EDIT_FRAME::Change_Net_Tracks_And_Vias_Sizes( int aNetcode, bool aUseNe
if( aNetcode <= 0 ) if( aNetcode <= 0 )
return false; return false;
/* Examine segments */ // Examine segments
PICKED_ITEMS_LIST itemsListPicker; PICKED_ITEMS_LIST itemsListPicker;
bool change = false; bool change = false;
for( pt_segm = GetBoard()->m_Track; pt_segm != NULL; pt_segm = pt_segm->Next() ) for( pt_segm = GetBoard()->m_Track; pt_segm != NULL; pt_segm = pt_segm->Next() )
{ {
if( aNetcode != pt_segm->GetNet() ) /* not in net */ if( aNetcode != pt_segm->GetNet() ) // not in net
continue; continue;
/* we have found a item member of the net */ // we have found a item member of the net
if( SetTrackSegmentWidth( pt_segm, &itemsListPicker, aUseNetclassValue ) ) if( SetTrackSegmentWidth( pt_segm, &itemsListPicker, aUseNetclassValue ) )
change = true; change = true;
} }
...@@ -245,7 +245,7 @@ bool PCB_EDIT_FRAME::Reset_All_Tracks_And_Vias_To_Netclass_Values( bool aTrack, ...@@ -245,7 +245,7 @@ bool PCB_EDIT_FRAME::Reset_All_Tracks_And_Vias_To_Netclass_Values( bool aTrack,
{ {
TRACK* pt_segm; TRACK* pt_segm;
/* read and edit tracks and vias if required */ // read and edit tracks and vias if required
PICKED_ITEMS_LIST itemsListPicker; PICKED_ITEMS_LIST itemsListPicker;
bool change = false; bool change = false;
......
...@@ -217,7 +217,7 @@ the changes?" ) ) ) ...@@ -217,7 +217,7 @@ the changes?" ) ) )
FILTER_READER reader( fileReader ); FILTER_READER reader( fileReader );
/* Read header and TEST if it is a PCB file format */ // Read header and TEST if it is a PCB file format
reader.ReadLine(); reader.ReadLine();
if( strncmp( reader.Line(), "PCBNEW-BOARD", 12 ) != 0 ) if( strncmp( reader.Line(), "PCBNEW-BOARD", 12 ) != 0 )
...@@ -324,7 +324,7 @@ this file again." ) ); ...@@ -324,7 +324,7 @@ this file again." ) );
GetScreen()->ClrModify(); GetScreen()->ClrModify();
/* If append option: change the initial board name to <oldname>-append.brd */ // If append option: change the initial board name to <oldname>-append.brd
if( aAppend ) if( aAppend )
{ {
wxString new_filename = GetScreen()->GetFileName().BeforeLast( '.' ); wxString new_filename = GetScreen()->GetFileName().BeforeLast( '.' );
...@@ -343,9 +343,13 @@ this file again." ) ); ...@@ -343,9 +343,13 @@ this file again." ) );
UpdateTitle(); UpdateTitle();
UpdateFileHistory( GetScreen()->GetFileName() ); UpdateFileHistory( GetScreen()->GetFileName() );
/* Rebuild the new pad list (for drc and ratsnet control ...) */ // Rebuild the new pad list (for drc and ratsnet control ...)
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
// Dick 5-Feb-2012: I do not agree with this. The layer widget will show what
// is visible or not, and I want the board to look like it did when I saved
// it, immediately after loading.
#if 0
/* Reset the items visibility flag when loading a new config /* Reset the items visibility flag when loading a new config
* Because it could creates SERIOUS mistakes for the user, * Because it could creates SERIOUS mistakes for the user,
* if board items are not visible after loading a board... * if board items are not visible after loading a board...
...@@ -353,16 +357,21 @@ this file again." ) ); ...@@ -353,16 +357,21 @@ this file again." ) );
*/ */
bool showGrid = IsElementVisible( GRID_VISIBLE ); bool showGrid = IsElementVisible( GRID_VISIBLE );
bool showRats = IsElementVisible( RATSNEST_VISIBLE ); bool showRats = IsElementVisible( RATSNEST_VISIBLE );
SetVisibleAlls(); SetVisibleAlls();
SetElementVisibility( GRID_VISIBLE, showGrid ); SetElementVisibility( GRID_VISIBLE, showGrid );
SetElementVisibility( RATSNEST_VISIBLE, showRats ); SetElementVisibility( RATSNEST_VISIBLE, showRats );
#endif
// Update info shown by the horizontal toolbars // Update info shown by the horizontal toolbars
GetBoard()->SetCurrentNetClass( NETCLASS::Default ); GetBoard()->SetCurrentNetClass( NETCLASS::Default );
ReFillLayerWidget(); ReFillLayerWidget();
ReCreateLayerBox( NULL ); ReCreateLayerBox( NULL );
syncLayerWidget(); syncLayerWidgetLayer();
syncRenderStates();
updateTraceWidthSelectBox(); updateTraceWidthSelectBox();
updateViaSizeSelectBox(); updateViaSizeSelectBox();
...@@ -436,7 +445,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF ...@@ -436,7 +445,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
if( aCreateBackupFile ) if( aCreateBackupFile )
{ {
/* Get the backup file name */ // Get the backup file name
backupFileName = pcbFileName; backupFileName = pcbFileName;
backupFileName.SetExt( pcbBackupFileExtension ); backupFileName.SetExt( pcbBackupFileExtension );
...@@ -524,7 +533,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF ...@@ -524,7 +533,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
#endif #endif
/* Display the file names: */ // Display the file names:
m_messagePanel->EraseMsgBox(); m_messagePanel->EraseMsgBox();
if( saveok ) if( saveok )
......
...@@ -333,6 +333,7 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) ...@@ -333,6 +333,7 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
char* data; char* data;
NETCLASS* netclass_default = GetBoard()->m_NetClasses.GetDefault(); NETCLASS* netclass_default = GetBoard()->m_NetClasses.GetDefault();
ZONE_SETTINGS zoneInfo = GetBoard()->GetZoneSettings();
while( aReader->ReadLine() ) while( aReader->ReadLine() )
{ {
...@@ -380,6 +381,8 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) ...@@ -380,6 +381,8 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
// projects. // projects.
GetBoard()->m_NetClasses.GetDefault()->SetParams(); GetBoard()->m_NetClasses.GetDefault()->SetParams();
GetBoard()->SetZoneSettings( zoneInfo );
return 0; return 0;
} }
...@@ -459,7 +462,7 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader ) ...@@ -459,7 +462,7 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
if( stricmp( line, "ZoneClearence" ) == 0 ) if( stricmp( line, "ZoneClearence" ) == 0 )
{ {
g_Zone_Default_Setting.m_ZoneClearance = atoi( data ); zoneInfo.m_ZoneClearance = atoi( data );
continue; continue;
} }
...@@ -697,7 +700,7 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard ) ...@@ -697,7 +700,7 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard )
fprintf( aFile, "TrackClearence %d\n", netclass_default->GetClearance() ); fprintf( aFile, "TrackClearence %d\n", netclass_default->GetClearance() );
fprintf( aFile, "ZoneClearence %d\n", g_Zone_Default_Setting.m_ZoneClearance ); fprintf( aFile, "ZoneClearence %d\n", aBoard->GetZoneSettings().m_ZoneClearance );
fprintf( aFile, "TrackMinWidth %d\n", aBoard->GetDesignSettings().m_TrackMinWidth ); fprintf( aFile, "TrackMinWidth %d\n", aBoard->GetDesignSettings().m_TrackMinWidth );
fprintf( aFile, "DrawSegmWidth %d\n", aBoard->GetDesignSettings().m_DrawSegmentWidth ); fprintf( aFile, "DrawSegmWidth %d\n", aBoard->GetDesignSettings().m_DrawSegmentWidth );
......
...@@ -14,14 +14,6 @@ ...@@ -14,14 +14,6 @@
#include <macros.h> #include <macros.h>
#include <pcbcommon.h> #include <pcbcommon.h>
#ifdef PCBNEW
/**
* @todo Fix having to recompile the same file with a different defintion. This is
* what C++ derivation was designed to solve.
*/
//#include "zones.h"
#endif
#include <zones.h> #include <zones.h>
#ifdef CVPCB #ifdef CVPCB
...@@ -1825,7 +1817,7 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader ) ...@@ -1825,7 +1817,7 @@ int ZONE_CONTAINER::ReadDescr( LINE_READER* aReader )
if( ret < 2 ) if( ret < 2 )
return false; return false;
if( tempSmoothingType >= ZONE_SETTING::SMOOTHING_LAST) if( tempSmoothingType >= ZONE_SETTINGS::SMOOTHING_LAST )
return false; return false;
if( tempSmoothingType < 0 ) if( tempSmoothingType < 0 )
......
...@@ -558,6 +558,7 @@ void KICAD_PLUGIN::loadSETUP() ...@@ -558,6 +558,7 @@ void KICAD_PLUGIN::loadSETUP()
{ {
NETCLASS* netclass_default = m_board->m_NetClasses.GetDefault(); NETCLASS* netclass_default = m_board->m_NetClasses.GetDefault();
BOARD_DESIGN_SETTINGS bds = m_board->GetDesignSettings(); BOARD_DESIGN_SETTINGS bds = m_board->GetDesignSettings();
ZONE_SETTINGS zs = m_board->GetZoneSettings();
while( READLINE() ) while( READLINE() )
{ {
...@@ -638,7 +639,13 @@ void KICAD_PLUGIN::loadSETUP() ...@@ -638,7 +639,13 @@ void KICAD_PLUGIN::loadSETUP()
else if( TESTLINE( "ZoneClearence" ) ) else if( TESTLINE( "ZoneClearence" ) )
{ {
BIU tmp = biuParse( line + SZ( "ZoneClearence" ) ); BIU tmp = biuParse( line + SZ( "ZoneClearence" ) );
g_Zone_Default_Setting.m_ZoneClearance = tmp; zs.m_ZoneClearance = tmp;
}
else if( TESTLINE( "Zone_45_Only" ) )
{
bool tmp = (bool) intParse( line + SZ( "Zone_45_Only" ) );
zs.m_Zone_45_Only = tmp;
} }
else if( TESTLINE( "DrawSegmWidth" ) ) else if( TESTLINE( "DrawSegmWidth" ) )
...@@ -793,6 +800,7 @@ void KICAD_PLUGIN::loadSETUP() ...@@ -793,6 +800,7 @@ void KICAD_PLUGIN::loadSETUP()
else if( TESTLINE( "$EndSETUP" ) ) else if( TESTLINE( "$EndSETUP" ) )
{ {
m_board->SetDesignSettings( bds ); m_board->SetDesignSettings( bds );
m_board->SetZoneSettings( zs );
// Until such time as the *.brd file does not have the // Until such time as the *.brd file does not have the
// global parameters: // global parameters:
...@@ -2109,7 +2117,7 @@ void KICAD_PLUGIN::loadZONE_CONTAINER() ...@@ -2109,7 +2117,7 @@ void KICAD_PLUGIN::loadZONE_CONTAINER()
int smoothing = intParse( line + SZ( "ZSmoothing" ), &data ); int smoothing = intParse( line + SZ( "ZSmoothing" ), &data );
BIU cornerRadius = biuParse( data ); BIU cornerRadius = biuParse( data );
if( smoothing >= ZONE_SETTING::SMOOTHING_LAST || smoothing < 0 ) if( smoothing >= ZONE_SETTINGS::SMOOTHING_LAST || smoothing < 0 )
{ {
m_error.Printf( wxT( "Bad ZSmoothing for CZONE_CONTAINER '%s'" ), zc->GetNetName().GetData() ); m_error.Printf( wxT( "Bad ZSmoothing for CZONE_CONTAINER '%s'" ), zc->GetNetName().GetData() );
THROW_IO_ERROR( m_error ); THROW_IO_ERROR( m_error );
...@@ -2804,9 +2812,9 @@ void KICAD_PLUGIN::saveSETUP() const ...@@ -2804,9 +2812,9 @@ void KICAD_PLUGIN::saveSETUP() const
fprintf( m_fp, "TrackClearence %s\n", fmtBIU( netclass_default->GetClearance() ).c_str() ); fprintf( m_fp, "TrackClearence %s\n", fmtBIU( netclass_default->GetClearance() ).c_str() );
/* @todo no globals in a plugin. // ZONE_SETTINGS
fprintf( m_fp, "ZoneClearence %d\n", g_Zone_Default_Setting.m_ZoneClearance ); fprintf( m_fp, "ZoneClearence %s\n", fmtBIU( m_board->GetZoneSettings().m_ZoneClearance ).c_str() );
*/ fprintf( m_fp, "Zone_45_Only %d\n", m_board->GetZoneSettings().m_Zone_45_Only );
fprintf( m_fp, "TrackMinWidth %s\n", fmtBIU( bds.m_TrackMinWidth ).c_str() ); fprintf( m_fp, "TrackMinWidth %s\n", fmtBIU( bds.m_TrackMinWidth ).c_str() );
......
...@@ -49,8 +49,7 @@ ...@@ -49,8 +49,7 @@
/** /**
* Class LAYER_WIDGET * Class LAYER_WIDGET
* is abstract and is derived from a wxFormBuilder maintained class called * is abstract and is used to manage a list of layers, with the notion of
* LAYER_PANEL_BASE. It is used to manage a list of layers, with the notion of
* a "current" layer, and layer specific visibility control. You must derive from * a "current" layer, and layer specific visibility control. You must derive from
* it to use it so you can implement the abstract functions which recieve the * it to use it so you can implement the abstract functions which recieve the
* events. Each layer is given its own color, and that color can be changed * events. Each layer is given its own color, and that color can be changed
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#include <module_editor_frame.h> #include <module_editor_frame.h>
static PCB_SCREEN* s_screenModule = NULL; // the PCB_SCREEN used by the footprint editor static PCB_SCREEN* s_screenModule; // the PCB_SCREEN used by the footprint editor
wxString FOOTPRINT_EDIT_FRAME::m_CurrentLib = wxEmptyString; wxString FOOTPRINT_EDIT_FRAME::m_CurrentLib = wxEmptyString;
...@@ -157,16 +157,11 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent, ...@@ -157,16 +157,11 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent,
SetBoard( s_Pcb ); SetBoard( s_Pcb );
if( s_screenModule == NULL ) if( !s_screenModule )
s_screenModule = new PCB_SCREEN( GetPageSettings().GetSizeIU() ); s_screenModule = new PCB_SCREEN( GetPageSettings().GetSizeIU() );
SetScreen( s_screenModule ); SetScreen( s_screenModule );
/* not sure why this was here, formerly s_ModuleEditorDesignSetting, since
we get default BOARD_DESIGN_SETTINGS in BOARD's constructor.
GetBoard()->SetDesignSettings( BOARD_DESIGN_SETTINGS() );
*/
GetScreen()->SetCurItem( NULL ); GetScreen()->SetCurItem( NULL );
LoadSettings(); LoadSettings();
......
...@@ -403,8 +403,11 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title, ...@@ -403,8 +403,11 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) ); wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer(10) );
ReFillLayerWidget(); // this is near end because contents establish size ReFillLayerWidget(); // this is near end because contents establish size
m_Layers->ReFillRender(); // Update colors in Render after the config is read m_Layers->ReFillRender(); // Update colors in Render after the config is read
syncLayerWidget();
syncLayerWidgetLayer();
m_auimgr.Update(); m_auimgr.Update();
} }
...@@ -639,12 +642,18 @@ bool PCB_EDIT_FRAME::IsMicroViaAcceptable( void ) ...@@ -639,12 +642,18 @@ bool PCB_EDIT_FRAME::IsMicroViaAcceptable( void )
} }
void PCB_EDIT_FRAME::syncLayerWidget( ) void PCB_EDIT_FRAME::syncLayerWidgetLayer()
{ {
m_Layers->SelectLayer( getActiveLayer() ); m_Layers->SelectLayer( getActiveLayer() );
} }
void PCB_EDIT_FRAME::syncRenderStates()
{
m_Layers->SyncRenderStates();
}
void PCB_EDIT_FRAME::unitsChangeRefresh() void PCB_EDIT_FRAME::unitsChangeRefresh()
{ {
PCB_BASE_FRAME::unitsChangeRefresh(); // Update the grid size select box. PCB_BASE_FRAME::unitsChangeRefresh(); // Update the grid size select box.
...@@ -667,9 +676,9 @@ void PCB_EDIT_FRAME::SetElementVisibility( int aElement, bool aNewState ) ...@@ -667,9 +676,9 @@ void PCB_EDIT_FRAME::SetElementVisibility( int aElement, bool aNewState )
} }
void PCB_EDIT_FRAME::SetVisibleAlls( ) void PCB_EDIT_FRAME::SetVisibleAlls()
{ {
GetBoard()->SetVisibleAlls( ); GetBoard()->SetVisibleAlls();
for( int ii = 0; ii < PCB_VISIBLE( END_PCB_VISIBLE_LIST ); ii++ ) for( int ii = 0; ii < PCB_VISIBLE( END_PCB_VISIBLE_LIST ); ii++ )
m_Layers->SetRenderState( ii, true ); m_Layers->SetRenderState( ii, true );
......
...@@ -177,15 +177,25 @@ bool PCB_EDIT_FRAME::LoadProjectSettings( const wxString& aProjectFileName ) ...@@ -177,15 +177,25 @@ bool PCB_EDIT_FRAME::LoadProjectSettings( const wxString& aProjectFileName )
// User library path takes precedent over default library search paths. // User library path takes precedent over default library search paths.
wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 ); wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 );
// Dick 5-Feb-2012: I don't agree with this, the BOARD contents should dictate
// what is visible or not, even initially. And since PCB_EDIT_FRAME projects settings
// have no control over what is visible (see PCB_EDIT_FRAME::GetProjectFileParameters())
// this is recklessly turning on things the user may not want to see.
#if 0
/* Reset the items visibility flag when loading a new configuration because it could /* Reset the items visibility flag when loading a new configuration because it could
* create SERIOUS mistakes for the user f board items are not visible after loading * create SERIOUS mistakes for the user if board items are not visible after loading
* a board. Grid and ratsnest can be left to their previous state. * a board. Grid and ratsnest can be left to their previous state.
*/ */
bool showGrid = IsElementVisible( GRID_VISIBLE ); bool showGrid = IsElementVisible( GRID_VISIBLE );
bool showRats = IsElementVisible( RATSNEST_VISIBLE ); bool showRats = IsElementVisible( RATSNEST_VISIBLE );
SetVisibleAlls(); SetVisibleAlls();
SetElementVisibility( GRID_VISIBLE, showGrid ); SetElementVisibility( GRID_VISIBLE, showGrid );
SetElementVisibility( RATSNEST_VISIBLE, showRats ); SetElementVisibility( RATSNEST_VISIBLE, showRats );
#endif
return true; return true;
} }
......
...@@ -55,10 +55,10 @@ int ZONE_CONTAINER::BuildFilledPolysListData( BOARD* aPcb, std::vector <CPolyPt> ...@@ -55,10 +55,10 @@ int ZONE_CONTAINER::BuildFilledPolysListData( BOARD* aPcb, std::vector <CPolyPt>
switch( cornerSmoothingType ) switch( cornerSmoothingType )
{ {
case ZONE_SETTING::SMOOTHING_CHAMFER: case ZONE_SETTINGS::SMOOTHING_CHAMFER:
smoothedPoly = m_Poly->Chamfer( cornerRadius ); smoothedPoly = m_Poly->Chamfer( cornerRadius );
break; break;
case ZONE_SETTING::SMOOTHING_FILLET: case ZONE_SETTINGS::SMOOTHING_FILLET:
smoothedPoly = m_Poly->Fillet( cornerRadius, m_ArcToSegmentsCount ); smoothedPoly = m_Poly->Fillet( cornerRadius, m_ArcToSegmentsCount );
break; break;
default: default:
......
...@@ -2,12 +2,8 @@ ...@@ -2,12 +2,8 @@
/* constants used in zone dialogs and functions */ /* constants used in zone dialogs and functions */
/************************************************/ /************************************************/
#ifndef ZONES_H #ifndef ZONES_H_
#define ZONES_H #define ZONES_H_
#include <class_zone_setting.h>
// keys used to store net sort option in config file : // keys used to store net sort option in config file :
#define ZONE_NET_OUTLINES_HATCH_OPTION_KEY wxT( "Zone_Ouline_Hatch_Opt" ) #define ZONE_NET_OUTLINES_HATCH_OPTION_KEY wxT( "Zone_Ouline_Hatch_Opt" )
...@@ -16,28 +12,46 @@ ...@@ -16,28 +12,46 @@
#define ZONE_THERMAL_RELIEF_GAP_STRING_KEY wxT( "Zone_TH_Gap" ) #define ZONE_THERMAL_RELIEF_GAP_STRING_KEY wxT( "Zone_TH_Gap" )
#define ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY wxT( "Zone_TH_Copper_Width" ) #define ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY wxT( "Zone_TH_Copper_Width" )
// Exit codes for dialog edit zones /// Exit codes for zone editing dialogs
enum zone_cmd { enum ZONE_EDIT_T {
ZONE_ABORT, // if no change ZONE_ABORT, ///< if no change
ZONE_OK, // if new values accepted ZONE_OK, ///< if new values were accepted
ZONE_EXPORT_VALUES // if values are exported to others zones ZONE_EXPORT_VALUES ///< if values were exported to others zones
}; };
enum { // How pads are covered by copper in zone /// How pads are covered by copper in zone
PAD_NOT_IN_ZONE, // Pads are not covered enum {
THERMAL_PAD, // Use thermal relief for pads PAD_NOT_IN_ZONE, ///< Pads are not covered
PAD_IN_ZONE // pads are covered by copper THERMAL_PAD, ///< Use thermal relief for pads
PAD_IN_ZONE ///< pads are covered by copper
}; };
class ZONE_CONTAINER;
/************************************************/ class ZONE_SETTINGS;
/* variables used in zone dialogs and functions */ class PCB_BASE_FRAME;
/************************************************/
/**
extern bool g_Zone_45_Only; * Function InvokeNonCopperZonesEditor
* invokes up a modal dialog window for non-copper zone editing.
// Default setting used when creating a new zone *
extern ZONE_SETTING g_Zone_Default_Setting; * @param aCaller is the PCB_BASE_FRAME calling parent window for the modal dialog,
* and it gives access to the BOARD through PCB_BASE_FRAME::GetBoard().
#endif // ifndef ZONES_H * @param aZone is the ZONE_CONTAINER to edit.
* @param aSettings points to the ZONE_SETTINGS to edit.
* @return ZONE_EDIT_T - tells if user aborted, changed only one zone, or all of them.
*/
ZONE_EDIT_T InvokeNonCopperZonesEditor( PCB_BASE_FRAME* aCaller, ZONE_CONTAINER* aZone, ZONE_SETTINGS* aSettings );
/**
* Function InvokeCopperZonesEditor
* invokes up a modal dialog window for copper zone editing.
*
* @param aCaller is the PCB_BASE_FRAME calling parent window for the modal dialog,
* and it gives access to the BOARD through PCB_BASE_FRAME::GetBoard().
* @param aZone is the ZONE_CONTAINER to edit.
* @return ZONE_EDIT_T - tells if user aborted, changed only one zone, or all of them.
*/
ZONE_EDIT_T InvokeCopperZonesEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings );
#endif // ZONES_H_
...@@ -57,7 +57,7 @@ static void Show_Zone_Corner_Or_Outline_While_Move_Mouse( EDA_DRAW_PANEL* aPanel ...@@ -57,7 +57,7 @@ static void Show_Zone_Corner_Or_Outline_While_Move_Mouse( EDA_DRAW_PANEL* aPanel
const wxPoint& aPosition, const wxPoint& aPosition,
bool aErase ); bool aErase );
/* Local variables */ // Local variables
static wxPoint s_CornerInitialPosition; // Used to abort a move corner command static wxPoint s_CornerInitialPosition; // Used to abort a move corner command
static bool s_CornerIsNew; // Used to abort a move corner command (if it is a new corner, it must be deleted) static bool s_CornerIsNew; // Used to abort a move corner command (if it is a new corner, it must be deleted)
static bool s_AddCutoutToCurrentZone; // if true, the next outline will be added to s_CurrentZone static bool s_AddCutoutToCurrentZone; // if true, the next outline will be added to s_CurrentZone
...@@ -66,39 +66,41 @@ static wxPoint s_CursorLastPosition; // in move zone outline, las ...@@ -66,39 +66,41 @@ static wxPoint s_CursorLastPosition; // in move zone outline, las
static PICKED_ITEMS_LIST s_PickedList; // a picked list to save zones for undo/redo command static PICKED_ITEMS_LIST s_PickedList; // a picked list to save zones for undo/redo command
static PICKED_ITEMS_LIST _AuxiliaryList; // a picked list to store zones that are deleted or added when combined static PICKED_ITEMS_LIST _AuxiliaryList; // a picked list to store zones that are deleted or added when combined
#include <dialog_copper_zones.h>
void PCB_EDIT_FRAME::Add_Similar_Zone( wxDC* DC, ZONE_CONTAINER* aZone )
void PCB_EDIT_FRAME::Add_Similar_Zone( wxDC* DC, ZONE_CONTAINER* zone_container )
{ {
if ( zone_container == NULL ) if( !aZone )
return; return;
s_AddCutoutToCurrentZone = false; s_AddCutoutToCurrentZone = false;
s_CurrentZone = zone_container; s_CurrentZone = aZone;
/* set zones setup to the current zone */ // set zone settings to the current zone
g_Zone_Default_Setting.ImportSetting( *zone_container ); ZONE_SETTINGS zoneInfo = GetZoneSettings();
zoneInfo << *aZone;
SetZoneSettings( zoneInfo );
// Use the general event handle to set others params (like toolbar) */ // Use the general event handler to set others params (like toolbar)
wxCommandEvent evt; wxCommandEvent evt;
evt.SetId( ID_PCB_ZONES_BUTT ); evt.SetId( ID_PCB_ZONES_BUTT );
OnSelectTool( evt ); OnSelectTool( evt );
} }
void PCB_EDIT_FRAME::Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container ) void PCB_EDIT_FRAME::Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* aZone )
{ {
if ( zone_container == NULL ) if( !aZone )
return; return;
s_AddCutoutToCurrentZone = true; s_AddCutoutToCurrentZone = true;
s_CurrentZone = zone_container; s_CurrentZone = aZone;
/* set zones setup to the current zone */ // set zones setup to the current zone
g_Zone_Default_Setting.ImportSetting( *zone_container ); ZONE_SETTINGS zoneInfo = GetZoneSettings();
zoneInfo << *aZone;
SetZoneSettings( zoneInfo );
// Use the general event handle to set others params (like toolbar) */ // Use the general event handle to set others params (like toolbar)
wxCommandEvent evt; wxCommandEvent evt;
evt.SetId( ID_PCB_ZONES_BUTT ); evt.SetId( ID_PCB_ZONES_BUTT );
OnSelectTool( evt ); OnSelectTool( evt );
...@@ -109,10 +111,10 @@ int PCB_EDIT_FRAME::Delete_LastCreatedCorner( wxDC* DC ) ...@@ -109,10 +111,10 @@ int PCB_EDIT_FRAME::Delete_LastCreatedCorner( wxDC* DC )
{ {
ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour; ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour;
if( zone == NULL ) if( !zone )
return 0; return 0;
if( zone->GetNumCorners() == 0 ) if( !zone->GetNumCorners() )
return 0; return 0;
zone->DrawWhileCreateOutline( m_canvas, DC, GR_XOR ); zone->DrawWhileCreateOutline( m_canvas, DC, GR_XOR );
...@@ -159,18 +161,21 @@ static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC ) ...@@ -159,18 +161,21 @@ static void Abort_Zone_Create_Outline( EDA_DRAW_PANEL* Panel, wxDC* DC )
} }
void PCB_EDIT_FRAME::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container, void PCB_EDIT_FRAME::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* aZone,
int corner_id, bool IsNewCorner ) int corner_id, bool IsNewCorner )
{ {
if( zone_container->IsOnCopperLayer() ) /* Show the Net */ if( aZone->IsOnCopperLayer() ) // Show the Net
{ {
if( GetBoard()->IsHighLightNetON() && DC ) if( GetBoard()->IsHighLightNetON() && DC )
{ {
HighLight( DC ); // Remove old highlight selection HighLight( DC ); // Remove old highlight selection
} }
g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet(); ZONE_SETTINGS zoneInfo = GetZoneSettings();
GetBoard()->SetHighLightNet( zone_container->GetNet() ); zoneInfo.m_NetcodeSelection = aZone->GetNet();
SetZoneSettings( zoneInfo );
GetBoard()->SetHighLightNet( aZone->GetNet() );
if( DC ) if( DC )
HighLight( DC ); HighLight( DC );
...@@ -179,25 +184,25 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_cont ...@@ -179,25 +184,25 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_cont
// Prepare copy of old zones, for undo/redo. // Prepare copy of old zones, for undo/redo.
// if the corner is new, remove it from list, save and insert it in list // if the corner is new, remove it from list, save and insert it in list
int cx = zone_container->m_Poly->GetX( corner_id ); int cx = aZone->m_Poly->GetX( corner_id );
int cy = zone_container->m_Poly->GetY( corner_id ); int cy = aZone->m_Poly->GetY( corner_id );
if ( IsNewCorner ) if ( IsNewCorner )
zone_container->m_Poly->DeleteCorner( corner_id ); aZone->m_Poly->DeleteCorner( corner_id );
_AuxiliaryList.ClearListAndDeleteItems(); _AuxiliaryList.ClearListAndDeleteItems();
s_PickedList.ClearListAndDeleteItems(); s_PickedList.ClearListAndDeleteItems();
SaveCopyOfZones( s_PickedList, GetBoard(), zone_container->GetNet(), SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNet(),
zone_container->GetLayer() ); aZone->GetLayer() );
if ( IsNewCorner ) if ( IsNewCorner )
zone_container->m_Poly->InsertCorner(corner_id-1, cx, cy ); aZone->m_Poly->InsertCorner(corner_id-1, cx, cy );
zone_container->SetFlags( IN_EDIT ); aZone->SetFlags( IN_EDIT );
m_canvas->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse, m_canvas->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse,
Abort_Zone_Move_Corner_Or_Outlines ); Abort_Zone_Move_Corner_Or_Outlines );
s_CornerInitialPosition = zone_container->GetCornerPosition( corner_id ); s_CornerInitialPosition = aZone->GetCornerPosition( corner_id );
s_CornerIsNew = IsNewCorner; s_CornerIsNew = IsNewCorner;
s_AddCutoutToCurrentZone = false; s_AddCutoutToCurrentZone = false;
s_CurrentZone = NULL; s_CurrentZone = NULL;
...@@ -205,11 +210,11 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_cont ...@@ -205,11 +210,11 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_cont
void PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge( wxDC* DC, void PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge( wxDC* DC,
ZONE_CONTAINER* zone_container, ZONE_CONTAINER* aZone,
int corner_id ) int corner_id )
{ {
zone_container->SetFlags( IS_DRAGGED ); aZone->SetFlags( IS_DRAGGED );
zone_container->m_CornerSelection = corner_id; aZone->m_CornerSelection = corner_id;
m_canvas->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse, m_canvas->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse,
Abort_Zone_Move_Corner_Or_Outlines ); Abort_Zone_Move_Corner_Or_Outlines );
s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->GetCrossHairPosition(); s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->GetCrossHairPosition();
...@@ -218,32 +223,35 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge( wxDC* DC, ...@@ -218,32 +223,35 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge( wxDC* DC,
s_PickedList.ClearListAndDeleteItems(); s_PickedList.ClearListAndDeleteItems();
_AuxiliaryList.ClearListAndDeleteItems(); _AuxiliaryList.ClearListAndDeleteItems();
SaveCopyOfZones( s_PickedList, GetBoard(), zone_container->GetNet(), SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNet(),
zone_container->GetLayer() ); aZone->GetLayer() );
} }
void PCB_EDIT_FRAME::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container ) void PCB_EDIT_FRAME::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* aZone )
{ {
/* Show the Net */ // Show the Net
if( zone_container->IsOnCopperLayer() ) /* Show the Net */ if( aZone->IsOnCopperLayer() ) // Show the Net
{ {
if( GetBoard()->IsHighLightNetON() ) if( GetBoard()->IsHighLightNetON() )
{ {
HighLight( DC ); // Remove old highlight selection HighLight( DC ); // Remove old highlight selection
} }
g_Zone_Default_Setting.m_NetcodeSelection = zone_container->GetNet(); ZONE_SETTINGS zoneInfo = GetZoneSettings();
GetBoard()->SetHighLightNet( zone_container->GetNet() ); zoneInfo.m_NetcodeSelection = aZone->GetNet();
SetZoneSettings( zoneInfo );
GetBoard()->SetHighLightNet( aZone->GetNet() );
HighLight( DC ); HighLight( DC );
} }
s_PickedList.ClearListAndDeleteItems(); s_PickedList.ClearListAndDeleteItems();
_AuxiliaryList.ClearListAndDeleteItems(); _AuxiliaryList.ClearListAndDeleteItems();
SaveCopyOfZones( s_PickedList, GetBoard(), zone_container->GetNet(), SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNet(),
zone_container->GetLayer() ); aZone->GetLayer() );
zone_container->SetFlags( IS_MOVED ); aZone->SetFlags( IS_MOVED );
m_canvas->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse, m_canvas->SetMouseCapture( Show_Zone_Corner_Or_Outline_While_Move_Mouse,
Abort_Zone_Move_Corner_Or_Outlines ); Abort_Zone_Move_Corner_Or_Outlines );
s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->GetCrossHairPosition(); s_CursorLastPosition = s_CornerInitialPosition = GetScreen()->GetCrossHairPosition();
...@@ -253,13 +261,13 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_co ...@@ -253,13 +261,13 @@ void PCB_EDIT_FRAME::Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_co
} }
void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container ) void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* aZone )
{ {
zone_container->ClearFlags(); aZone->ClearFlags();
m_canvas->SetMouseCapture( NULL, NULL ); m_canvas->SetMouseCapture( NULL, NULL );
if( DC ) if( DC )
zone_container->Draw( m_canvas, DC, GR_OR ); aZone->Draw( m_canvas, DC, GR_OR );
OnModify(); OnModify();
s_AddCutoutToCurrentZone = false; s_AddCutoutToCurrentZone = false;
...@@ -267,22 +275,22 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* ...@@ -267,22 +275,22 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER*
SetCurItem( NULL ); // This outline can be deleted when merging outlines SetCurItem( NULL ); // This outline can be deleted when merging outlines
/* Combine zones if possible */ // Combine zones if possible
wxBusyCursor dummy; wxBusyCursor dummy;
GetBoard()->AreaPolygonModified( &_AuxiliaryList, zone_container, true, s_Verbose ); GetBoard()->AreaPolygonModified( &_AuxiliaryList, aZone, true, s_Verbose );
m_canvas->Refresh(); m_canvas->Refresh();
int ii = GetBoard()->GetAreaIndex( zone_container ); // test if zone_container exists int ii = GetBoard()->GetAreaIndex( aZone ); // test if aZone exists
if( ii < 0 ) if( ii < 0 )
zone_container = NULL; // was removed by combining zones aZone = NULL; // was removed by combining zones
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() ); UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED); SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( zone_container, true ); int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( aZone, true );
if( error_count ) if( error_count )
{ {
...@@ -291,25 +299,25 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* ...@@ -291,25 +299,25 @@ void PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER*
} }
void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container ) void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* aZone )
{ {
OnModify(); OnModify();
if( zone_container->m_Poly->GetNumCorners() <= 3 ) if( aZone->m_Poly->GetNumCorners() <= 3 )
{ {
m_canvas->RefreshDrawingRect( zone_container->GetBoundingBox() ); m_canvas->RefreshDrawingRect( aZone->GetBoundingBox() );
if( DC ) if( DC )
{ // Remove the full zone because this is no more an area { // Remove the full zone because this is no more an area
zone_container->UnFill(); aZone->UnFill();
zone_container->DrawFilledArea( m_canvas, DC, GR_XOR ); aZone->DrawFilledArea( m_canvas, DC, GR_XOR );
} }
GetBoard()->Delete( zone_container ); GetBoard()->Delete( aZone );
return; return;
} }
int layer = zone_container->GetLayer(); int layer = aZone->GetLayer();
if( DC ) if( DC )
{ {
...@@ -319,12 +327,12 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_containe ...@@ -319,12 +327,12 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_containe
_AuxiliaryList.ClearListAndDeleteItems(); _AuxiliaryList.ClearListAndDeleteItems();
s_PickedList. ClearListAndDeleteItems(); s_PickedList. ClearListAndDeleteItems();
SaveCopyOfZones( s_PickedList, GetBoard(), zone_container->GetNet(), SaveCopyOfZones( s_PickedList, GetBoard(), aZone->GetNet(),
zone_container->GetLayer() ); aZone->GetLayer() );
zone_container->m_Poly->DeleteCorner( zone_container->m_CornerSelection ); aZone->m_Poly->DeleteCorner( aZone->m_CornerSelection );
// modify zones outlines according to the new zone_container shape // modify zones outlines according to the new aZone shape
GetBoard()->AreaPolygonModified( &_AuxiliaryList, zone_container, true, s_Verbose ); GetBoard()->AreaPolygonModified( &_AuxiliaryList, aZone, true, s_Verbose );
if( DC ) if( DC )
{ {
...@@ -336,12 +344,12 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_containe ...@@ -336,12 +344,12 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_containe
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED); SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
int ii = GetBoard()->GetAreaIndex( zone_container ); // test if zone_container exists int ii = GetBoard()->GetAreaIndex( aZone ); // test if aZone exists
if( ii < 0 ) if( ii < 0 )
zone_container = NULL; // zone_container does not exist anymore, after combining zones aZone = NULL; // aZone does not exist anymore, after combining zones
int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( zone_container, true ); int error_count = GetBoard()->Test_Drc_Areas_Outlines_To_Areas_Outlines( aZone, true );
if( error_count ) if( error_count )
{ {
...@@ -357,30 +365,30 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_containe ...@@ -357,30 +365,30 @@ void PCB_EDIT_FRAME::Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_containe
void Abort_Zone_Move_Corner_Or_Outlines( EDA_DRAW_PANEL* Panel, wxDC* DC ) void Abort_Zone_Move_Corner_Or_Outlines( EDA_DRAW_PANEL* Panel, wxDC* DC )
{ {
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Panel->GetParent(); PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Panel->GetParent();
ZONE_CONTAINER* zone_container = (ZONE_CONTAINER*) pcbframe->GetCurItem(); ZONE_CONTAINER* zone = (ZONE_CONTAINER*) pcbframe->GetCurItem();
if( zone_container->IsMoving() ) if( zone->IsMoving() )
{ {
wxPoint offset; wxPoint offset;
offset = s_CornerInitialPosition - s_CursorLastPosition; offset = s_CornerInitialPosition - s_CursorLastPosition;
zone_container->Move( offset ); zone->Move( offset );
} }
else if( zone_container->IsDragging() ) else if( zone->IsDragging() )
{ {
wxPoint offset; wxPoint offset;
offset = s_CornerInitialPosition - s_CursorLastPosition; offset = s_CornerInitialPosition - s_CursorLastPosition;
zone_container->MoveEdge( offset ); zone->MoveEdge( offset );
} }
else else
{ {
if( s_CornerIsNew ) if( s_CornerIsNew )
{ {
zone_container->m_Poly->DeleteCorner( zone_container->m_CornerSelection ); zone->m_Poly->DeleteCorner( zone->m_CornerSelection );
} }
else else
{ {
wxPoint pos = s_CornerInitialPosition; wxPoint pos = s_CornerInitialPosition;
zone_container->m_Poly->MoveCorner( zone_container->m_CornerSelection, pos.x, pos.y ); zone->m_Poly->MoveCorner( zone->m_CornerSelection, pos.x, pos.y );
} }
} }
...@@ -390,21 +398,20 @@ void Abort_Zone_Move_Corner_Or_Outlines( EDA_DRAW_PANEL* Panel, wxDC* DC ) ...@@ -390,21 +398,20 @@ void Abort_Zone_Move_Corner_Or_Outlines( EDA_DRAW_PANEL* Panel, wxDC* DC )
Panel->Refresh(); Panel->Refresh();
pcbframe->SetCurItem( NULL ); pcbframe->SetCurItem( NULL );
zone_container->ClearFlags(); zone->ClearFlags();
s_AddCutoutToCurrentZone = false; s_AddCutoutToCurrentZone = false;
s_CurrentZone = NULL; s_CurrentZone = NULL;
} }
/* Redraws the zone outline when moving a corner according to the cursor position /// Redraws the zone outline when moving a corner according to the cursor position
*/
void Show_Zone_Corner_Or_Outline_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC, void Show_Zone_Corner_Or_Outline_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
const wxPoint& aPosition, bool aErase ) const wxPoint& aPosition, bool aErase )
{ {
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) aPanel->GetParent(); PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) aPanel->GetParent();
ZONE_CONTAINER* zone = (ZONE_CONTAINER*) pcbframe->GetCurItem(); ZONE_CONTAINER* zone = (ZONE_CONTAINER*) pcbframe->GetCurItem();
if( aErase ) /* Undraw edge in old position*/ if( aErase ) // Undraw edge in old position
{ {
zone->Draw( aPanel, aDC, GR_XOR ); zone->Draw( aPanel, aDC, GR_XOR );
} }
...@@ -437,9 +444,10 @@ void Show_Zone_Corner_Or_Outline_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* ...@@ -437,9 +444,10 @@ void Show_Zone_Corner_Or_Outline_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC*
int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
{ {
ZONE_SETTINGS zoneInfo = GetZoneSettings();
// verify if s_CurrentZone exists (could be deleted since last selection) : // verify if s_CurrentZone exists (could be deleted since last selection) :
int ii; int ii;
for( ii = 0; ii < GetBoard()->GetAreaCount(); ii++ ) for( ii = 0; ii < GetBoard()->GetAreaCount(); ii++ )
{ {
if( s_CurrentZone == GetBoard()->GetArea( ii ) ) if( s_CurrentZone == GetBoard()->GetArea( ii ) )
...@@ -453,16 +461,17 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) ...@@ -453,16 +461,17 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
} }
// If no zone contour in progress, a new zone is being created: // If no zone contour in progress, a new zone is being created:
if( GetBoard()->m_CurrentZoneContour == NULL ) if( !GetBoard()->m_CurrentZoneContour )
GetBoard()->m_CurrentZoneContour = new ZONE_CONTAINER( GetBoard() ); GetBoard()->m_CurrentZoneContour = new ZONE_CONTAINER( GetBoard() );
ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour; ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour;
if( zone->GetNumCorners() == 0 ) // Start a new contour: init zone params (net, layer ...) if( zone->GetNumCorners() == 0 ) // Start a new contour: init zone params (net, layer ...)
{ {
if( s_CurrentZone == NULL ) // A new outline is created, from scratch if( !s_CurrentZone ) // A new outline is created, from scratch
{ {
int diag; ZONE_EDIT_T edited;
// Init zone params to reasonable values // Init zone params to reasonable values
zone->SetLayer( getActiveLayer() ); zone->SetLayer( getActiveLayer() );
...@@ -470,59 +479,72 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) ...@@ -470,59 +479,72 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
m_canvas->SetIgnoreMouseEvents( true ); m_canvas->SetIgnoreMouseEvents( true );
if( zone->IsOnCopperLayer() ) if( zone->IsOnCopperLayer() )
{ // Put a zone on a copper layer
if ( GetBoard()->GetHighLightNetCode() > 0 )
{ {
g_Zone_Default_Setting.m_NetcodeSelection = GetBoard()->GetHighLightNetCode(); // Put a zone on a copper layer
if( GetBoard()->GetHighLightNetCode() > 0 )
{
zoneInfo.m_NetcodeSelection = GetBoard()->GetHighLightNetCode();
zone->SetNet( g_Zone_Default_Setting.m_NetcodeSelection ); zone->SetNet( zoneInfo.m_NetcodeSelection );
zone->SetNetNameFromNetCode( ); zone->SetNetNameFromNetCode( );
} }
wxGetApp().GetSettings()->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, wxGetApp().GetSettings()->Read( ZONE_THERMAL_RELIEF_GAP_STRING_KEY,
&g_Zone_Default_Setting.m_ThermalReliefGap ); &zoneInfo.m_ThermalReliefGap );
wxGetApp().GetSettings()->Read( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY, wxGetApp().GetSettings()->Read( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY,
&g_Zone_Default_Setting.m_ThermalReliefCopperBridge ); &zoneInfo.m_ThermalReliefCopperBridge );
g_Zone_Default_Setting.m_CurrentZone_Layer = zone->GetLayer(); zoneInfo.m_CurrentZone_Layer = zone->GetLayer();
DIALOG_COPPER_ZONE* frame = new DIALOG_COPPER_ZONE( this, &g_Zone_Default_Setting );
diag = frame->ShowModal(); edited = InvokeCopperZonesEditor( this, &zoneInfo );
frame->Destroy();
} }
else // Put a zone on a non copper layer (technical layer) else // Put a zone on a non copper layer (technical layer)
{ {
diag = InstallDialogNonCopperZonesEditor( zone ); zoneInfo.m_NetcodeSelection = 0; // No net for non copper zones
g_Zone_Default_Setting.m_NetcodeSelection = 0; // No net for non copper zones
edited = InvokeNonCopperZonesEditor( this, zone, &zoneInfo );
} }
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
m_canvas->SetIgnoreMouseEvents( false ); m_canvas->SetIgnoreMouseEvents( false );
if( diag == ZONE_ABORT ) if( edited == ZONE_ABORT )
return 0; return 0;
// Switch active layer to the selected zone layer // Switch active layer to the selected zone layer
setActiveLayer( g_Zone_Default_Setting.m_CurrentZone_Layer ); setActiveLayer( zoneInfo.m_CurrentZone_Layer );
SetZoneSettings( zoneInfo );
} }
else // Start a new contour: init zone params (net and layer) from an existing else
{ // zone (add cutout or similar zone) {
g_Zone_Default_Setting.m_CurrentZone_Layer = s_CurrentZone->GetLayer(); // Start a new contour: init zone params (net and layer) from an existing
// zone (add cutout or similar zone)
zoneInfo.m_CurrentZone_Layer = s_CurrentZone->GetLayer();
setActiveLayer( s_CurrentZone->GetLayer() ); setActiveLayer( s_CurrentZone->GetLayer() );
g_Zone_Default_Setting.ImportSetting( * s_CurrentZone);
zoneInfo << *s_CurrentZone;
SetZoneSettings( zoneInfo );
} }
/* Show the Net for zones on copper layers */ // Show the Net for zones on copper layers
if( g_Zone_Default_Setting.m_CurrentZone_Layer < FIRST_NO_COPPER_LAYER ) if( zoneInfo.m_CurrentZone_Layer < FIRST_NO_COPPER_LAYER )
{ {
if( s_CurrentZone ) if( s_CurrentZone )
g_Zone_Default_Setting.m_NetcodeSelection = s_CurrentZone->GetNet(); {
zoneInfo.m_NetcodeSelection = s_CurrentZone->GetNet();
GetBoard()->SetZoneSettings( zoneInfo );
}
if( GetBoard()->IsHighLightNetON() ) if( GetBoard()->IsHighLightNetON() )
{ {
HighLight( DC ); // Remove old highlight selection HighLight( DC ); // Remove old highlight selection
} }
GetBoard()->SetHighLightNet( g_Zone_Default_Setting.m_NetcodeSelection ); GetBoard()->SetHighLightNet( zoneInfo.m_NetcodeSelection );
HighLight( DC ); HighLight( DC );
} }
...@@ -535,11 +557,14 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) ...@@ -535,11 +557,14 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
{ {
zone->SetFlags( IS_NEW ); zone->SetFlags( IS_NEW );
zone->SetTimeStamp( GetNewTimeStamp() ); zone->SetTimeStamp( GetNewTimeStamp() );
g_Zone_Default_Setting.ExportSetting( *zone );
zone->m_Poly->Start( g_Zone_Default_Setting.m_CurrentZone_Layer, zoneInfo.ExportSetting( *zone );
zone->m_Poly->Start( zoneInfo.m_CurrentZone_Layer,
GetScreen()->GetCrossHairPosition().x, GetScreen()->GetCrossHairPosition().x,
GetScreen()->GetCrossHairPosition().y, GetScreen()->GetCrossHairPosition().y,
zone->GetHatchStyle() ); zone->GetHatchStyle() );
zone->AppendCorner( GetScreen()->GetCrossHairPosition() ); zone->AppendCorner( GetScreen()->GetCrossHairPosition() );
if( Drc_On && (m_drc->Drc( zone, 0 ) == BAD_DRC) && zone->IsOnCopperLayer() ) if( Drc_On && (m_drc->Drc( zone, 0 ) == BAD_DRC) && zone->IsOnCopperLayer() )
...@@ -563,11 +588,12 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC ) ...@@ -563,11 +588,12 @@ int PCB_EDIT_FRAME::Begin_Zone( wxDC* DC )
{ {
ii = zone->GetNumCorners() - 1; ii = zone->GetNumCorners() - 1;
/* edge in progress : the current corner coordinate was set by Show_New_Edge_While_Move_Mouse */ // edge in progress : the current corner coordinate was set by Show_New_Edge_While_Move_Mouse
if( zone->GetCornerPosition( ii - 1 ) != zone->GetCornerPosition( ii ) ) if( zone->GetCornerPosition( ii - 1 ) != zone->GetCornerPosition( ii ) )
{ {
if( !Drc_On || !zone->IsOnCopperLayer() || ( m_drc->Drc( zone, ii - 1 ) == OK_DRC ) ) if( !Drc_On || !zone->IsOnCopperLayer() || ( m_drc->Drc( zone, ii - 1 ) == OK_DRC ) )
{ // Ok, we can add a new corner {
// Ok, we can add a new corner
zone->AppendCorner( GetScreen()->GetCrossHairPosition() ); zone->AppendCorner( GetScreen()->GetCrossHairPosition() );
SetCurItem( zone ); // calls DisplayInfo(). SetCurItem( zone ); // calls DisplayInfo().
} }
...@@ -582,7 +608,7 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC ) ...@@ -582,7 +608,7 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC )
{ {
ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour; ZONE_CONTAINER* zone = GetBoard()->m_CurrentZoneContour;
if( zone == NULL ) if( !zone )
return true; return true;
// Validate the current outline: // Validate the current outline:
...@@ -624,12 +650,13 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC ) ...@@ -624,12 +650,13 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC )
s_PickedList.ClearListAndDeleteItems(); s_PickedList.ClearListAndDeleteItems();
SaveCopyOfZones(s_PickedList, GetBoard(), zone->GetNet(), zone->GetLayer() ); SaveCopyOfZones(s_PickedList, GetBoard(), zone->GetNet(), zone->GetLayer() );
/* Put new zone in list */ // Put new zone in list
if( s_CurrentZone == NULL ) if( !s_CurrentZone )
{ {
zone->m_Poly->Close(); // Close the current corner list zone->m_Poly->Close(); // Close the current corner list
GetBoard()->Add( zone ); GetBoard()->Add( zone );
GetBoard()->m_CurrentZoneContour = NULL; GetBoard()->m_CurrentZoneContour = NULL;
// Add this zone in picked list, as new item // Add this zone in picked list, as new item
ITEM_PICKER picker( zone, UR_NEW ); ITEM_PICKER picker( zone, UR_NEW );
s_PickedList.PushItem( picker ); s_PickedList.PushItem( picker );
...@@ -658,7 +685,7 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC ) ...@@ -658,7 +685,7 @@ bool PCB_EDIT_FRAME::End_Zone( wxDC* DC )
GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, layer ); GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, layer );
GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_OR, layer ); GetBoard()->RedrawFilledAreas( m_canvas, DC, GR_OR, layer );
int ii = GetBoard()->GetAreaIndex( zone ); // test if zone_container exists int ii = GetBoard()->GetAreaIndex( zone ); // test if zone exists
if( ii < 0 ) if( ii < 0 )
zone = NULL; // was removed by combining zones zone = NULL; // was removed by combining zones
...@@ -688,21 +715,21 @@ static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC, ...@@ -688,21 +715,21 @@ static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
wxPoint c_pos = pcbframe->GetScreen()->GetCrossHairPosition(); wxPoint c_pos = pcbframe->GetScreen()->GetCrossHairPosition();
ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour; ZONE_CONTAINER* zone = pcbframe->GetBoard()->m_CurrentZoneContour;
if( zone == NULL ) if( !zone )
return; return;
int icorner = zone->GetNumCorners() - 1; int icorner = zone->GetNumCorners() - 1;
if ( icorner < 1 ) if( icorner < 1 )
return; // We must have 2 (or more) corners return; // We must have 2 (or more) corners
if( aErase ) /* Undraw edge in old position*/ if( aErase ) // Undraw edge in old position
{ {
zone->DrawWhileCreateOutline( aPanel, aDC ); zone->DrawWhileCreateOutline( aPanel, aDC );
} }
/* Redraw the current edge in its new position */ // Redraw the current edge in its new position
if( g_Zone_45_Only ) if( pcbframe->GetZoneSettings().m_Zone_45_Only )
{ {
// calculate the new position as allowed // calculate the new position as allowed
wxPoint StartPoint = zone->GetCornerPosition( icorner - 1 ); wxPoint StartPoint = zone->GetCornerPosition( icorner - 1 );
...@@ -715,41 +742,45 @@ static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC, ...@@ -715,41 +742,45 @@ static void Show_New_Edge_While_Move_Mouse( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
} }
void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container ) void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* aZone )
{ {
int diag; ZONE_EDIT_T edited;
ZONE_SETTINGS zoneInfo = GetZoneSettings();
m_canvas->SetIgnoreMouseEvents( true ); m_canvas->SetIgnoreMouseEvents( true );
/* Save initial zones configuration, for undo/redo, before adding new zone // Save initial zones configuration, for undo/redo, before adding new zone
* note the net name and the layer can be changed, so we must save all zones // note the net name and the layer can be changed, so we must save all zones
*/
_AuxiliaryList.ClearListAndDeleteItems(); _AuxiliaryList.ClearListAndDeleteItems();
s_PickedList.ClearListAndDeleteItems(); s_PickedList.ClearListAndDeleteItems();
SaveCopyOfZones(s_PickedList, GetBoard(), -1, -1 ); SaveCopyOfZones(s_PickedList, GetBoard(), -1, -1 );
if( zone_container->GetLayer() < FIRST_NO_COPPER_LAYER ) if( aZone->GetLayer() < FIRST_NO_COPPER_LAYER )
{ // edit a zone on a copper layer {
g_Zone_Default_Setting.ImportSetting(*zone_container); // edit a zone on a copper layer
DIALOG_COPPER_ZONE* frame = new DIALOG_COPPER_ZONE( this, &g_Zone_Default_Setting );
diag = frame->ShowModal(); zoneInfo << *aZone;
frame->Destroy();
edited = InvokeCopperZonesEditor( this, &zoneInfo );
} }
else // edit a zone on a non copper layer (technical layer) else
{ {
diag = InstallDialogNonCopperZonesEditor( zone_container ); edited = InvokeNonCopperZonesEditor( this, aZone, &zoneInfo );
} }
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
m_canvas->SetIgnoreMouseEvents( false ); m_canvas->SetIgnoreMouseEvents( false );
if( diag == ZONE_ABORT ) if( edited == ZONE_ABORT )
{ {
_AuxiliaryList.ClearListAndDeleteItems(); _AuxiliaryList.ClearListAndDeleteItems();
s_PickedList.ClearListAndDeleteItems(); s_PickedList.ClearListAndDeleteItems();
return; return;
} }
if( diag == ZONE_EXPORT_VALUES ) SetZoneSettings( zoneInfo );
if( edited == ZONE_EXPORT_VALUES )
{ {
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() ); UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED); SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
...@@ -764,47 +795,49 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container ...@@ -764,47 +795,49 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container
edge_zone->Draw( m_canvas, DC, GR_XOR ); edge_zone->Draw( m_canvas, DC, GR_XOR );
} }
g_Zone_Default_Setting.ExportSetting( *zone_container); zoneInfo.ExportSetting( *aZone );
NETINFO_ITEM* net = GetBoard()->FindNet( g_Zone_Default_Setting.m_NetcodeSelection );
NETINFO_ITEM* net = GetBoard()->FindNet( zoneInfo.m_NetcodeSelection );
if( net ) // net == NULL should not occur if( net ) // net == NULL should not occur
zone_container->m_Netname = net->GetNetname(); aZone->m_Netname = net->GetNetname();
// Combine zones if possible : // Combine zones if possible
GetBoard()->AreaPolygonModified( &_AuxiliaryList, zone_container, true, s_Verbose ); GetBoard()->AreaPolygonModified( &_AuxiliaryList, aZone, true, s_Verbose );
// Redraw the real new zone outlines: // Redraw the real new zone outlines
GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, -1 ); GetBoard()->RedrawAreasOutlines( m_canvas, DC, GR_OR, -1 );
UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() ); UpdateCopyOfZonesList( s_PickedList, _AuxiliaryList, GetBoard() );
SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED); SaveCopyInUndoList(s_PickedList, UR_UNSPECIFIED);
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
s_PickedList.ClearItemsList(); // s_ItemsListPicker is no longer owner of picked items
OnModify(); OnModify();
} }
void PCB_EDIT_FRAME::Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_container ) void PCB_EDIT_FRAME::Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* aZone )
{ {
int ncont = zone_container->m_Poly->GetContour( zone_container->m_CornerSelection ); int ncont = aZone->m_Poly->GetContour( aZone->m_CornerSelection );
EDA_RECT dirty = zone_container->GetBoundingBox(); EDA_RECT dirty = aZone->GetBoundingBox();
// For compatibility with old boards: remove old SEGZONE fill segments // For compatibility with old boards: remove old SEGZONE fill segments
Delete_OldZone_Fill( NULL, zone_container->GetTimeStamp() ); Delete_OldZone_Fill( NULL, aZone->GetTimeStamp() );
// Remove current filling: // Remove current filling:
zone_container->UnFill(); aZone->UnFill();
if( ncont == 0 ) // This is the main outline: remove all if( ncont == 0 ) // This is the main outline: remove all
{ {
SaveCopyInUndoList( zone_container, UR_DELETED ); SaveCopyInUndoList( aZone, UR_DELETED );
GetBoard()->Remove( zone_container ); GetBoard()->Remove( aZone );
} }
else else
{ {
zone_container->m_Poly->RemoveContour( ncont ); aZone->m_Poly->RemoveContour( ncont );
} }
m_canvas->RefreshDrawingRect( dirty ); m_canvas->RefreshDrawingRect( dirty );
......
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <zones.h> #include <zones.h>
#define FORMAT_STRING _( "Filling zone %d out of %d (net %s)..." )
/** /**
* Function Delete_OldZone_Fill (obsolete) * Function Delete_OldZone_Fill (obsolete)
...@@ -70,7 +72,7 @@ void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, long aTimestamp ) ...@@ -70,7 +72,7 @@ void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, long aTimestamp )
if( zone->GetTimeStamp() == TimeStamp ) if( zone->GetTimeStamp() == TimeStamp )
{ {
modify = true; modify = true;
/* remove item from linked list and free memory */ // remove item from linked list and free memory
zone->DeleteStructure(); zone->DeleteStructure();
} }
} }
...@@ -83,15 +85,6 @@ void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, long aTimestamp ) ...@@ -83,15 +85,6 @@ void PCB_EDIT_FRAME::Delete_OldZone_Fill( SEGZONE* aZone, long aTimestamp )
} }
/**
* Function Fill_Zone
* Calculate the zone filling for the outline zone_container
* The zone outline is a frontier, and can be complex (with holes)
* The filling starts from starting points like pads, tracks.
* If exists, the old filling is removed
* @param aZone = zone to fill
* @return error level (0 = no error)
*/
int PCB_EDIT_FRAME::Fill_Zone( ZONE_CONTAINER* aZone ) int PCB_EDIT_FRAME::Fill_Zone( ZONE_CONTAINER* aZone )
{ {
wxString msg; wxString msg;
...@@ -99,7 +92,10 @@ int PCB_EDIT_FRAME::Fill_Zone( ZONE_CONTAINER* aZone ) ...@@ -99,7 +92,10 @@ int PCB_EDIT_FRAME::Fill_Zone( ZONE_CONTAINER* aZone )
ClearMsgPanel(); ClearMsgPanel();
// Shows the net // Shows the net
g_Zone_Default_Setting.m_NetcodeSelection = aZone->GetNet(); ZONE_SETTINGS zoneInfo = GetZoneSettings();
zoneInfo.m_NetcodeSelection = aZone->GetNet();
SetZoneSettings( zoneInfo );
msg = aZone->GetNetName(); msg = aZone->GetNetName();
if( msg.IsEmpty() ) if( msg.IsEmpty() )
...@@ -119,22 +115,12 @@ int PCB_EDIT_FRAME::Fill_Zone( ZONE_CONTAINER* aZone ) ...@@ -119,22 +115,12 @@ int PCB_EDIT_FRAME::Fill_Zone( ZONE_CONTAINER* aZone )
} }
/*
* Function Fill_All_Zones
* Fill all zones on the board
* The old fillings are removed
* aActiveWindow = the current active window, if a progress bar is shown
* = NULL to do not display a progress bar
* aVerbose = true to show error messages
* return error level (0 = no error)
*/
int PCB_EDIT_FRAME::Fill_All_Zones( wxWindow * aActiveWindow, bool aVerbose ) int PCB_EDIT_FRAME::Fill_All_Zones( wxWindow * aActiveWindow, bool aVerbose )
{ {
int errorLevel = 0; int errorLevel = 0;
int areaCount = GetBoard()->GetAreaCount(); int areaCount = GetBoard()->GetAreaCount();
wxBusyCursor dummyCursor; wxBusyCursor dummyCursor;
wxString msg; wxString msg;
#define FORMAT_STRING _( "Filling zone %d out of %d (net %s)..." )
wxProgressDialog * progressDialog = NULL; wxProgressDialog * progressDialog = NULL;
// Create a message with a long net name, and build a wxProgressDialog // Create a message with a long net name, and build a wxProgressDialog
......
...@@ -16,75 +16,78 @@ ...@@ -16,75 +16,78 @@
#include <dialog_non_copper_zones_properties_base.h> #include <dialog_non_copper_zones_properties_base.h>
/* Class DialogNonCopperZonesEditor /**
* Dialog editor for non copper zones properties * Class DIALOG_NON_COPPER_ZONES_EDITOR
* Derived from DialogNonCopperZonesPropertiesBase, created by wxFormBuilder * is a dialog editor for non copper zones properties,
* derived from DialogNonCopperZonesPropertiesBase, which is maintained and
* created by wxFormBuilder
*/ */
class DialogNonCopperZonesEditor : public DialogNonCopperZonesPropertiesBase class DIALOG_NON_COPPER_ZONES_EDITOR : public DialogNonCopperZonesPropertiesBase
{ {
private: private:
PCB_EDIT_FRAME* m_Parent; PCB_BASE_FRAME* m_Parent;
ZONE_CONTAINER* m_Zone_Container; ZONE_CONTAINER* m_zone;
ZONE_SETTING* m_Zone_Setting; ZONE_SETTINGS* m_ptr;
ZONE_SETTINGS m_settings;
private:
void OnOkClick( wxCommandEvent& event ); void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event );
void Init(); void Init();
public: public:
DialogNonCopperZonesEditor( PCB_EDIT_FRAME* parent, DIALOG_NON_COPPER_ZONES_EDITOR( PCB_BASE_FRAME* aParent,
ZONE_CONTAINER* zone_container, ZONE_CONTAINER* aZone, ZONE_SETTINGS* aSettings );
ZONE_SETTING* zone_setting );
~DialogNonCopperZonesEditor();
}; };
DialogNonCopperZonesEditor::DialogNonCopperZonesEditor( PCB_EDIT_FRAME* parent, ZONE_EDIT_T InvokeNonCopperZonesEditor( PCB_BASE_FRAME* aParent,
ZONE_CONTAINER* zone_container, ZONE_CONTAINER* aZone, ZONE_SETTINGS* aSettings )
ZONE_SETTING* zone_setting ) :
DialogNonCopperZonesPropertiesBase( parent )
{ {
m_Parent = parent; DIALOG_NON_COPPER_ZONES_EDITOR dlg( aParent, aZone, aSettings );
m_Zone_Container = zone_container;
m_Zone_Setting = zone_setting;
Init();
/* the size of some items has changed, so we must call SetSizeHints() */
GetSizer()->SetSizeHints( this );
}
ZONE_EDIT_T result = ZONE_EDIT_T( dlg.ShowModal() );
DialogNonCopperZonesEditor::~DialogNonCopperZonesEditor() // D(printf( "%s: result:%d\n", __FUNCTION__, result );)
{
return result;
} }
bool PCB_EDIT_FRAME::InstallDialogNonCopperZonesEditor( ZONE_CONTAINER* aZone ) DIALOG_NON_COPPER_ZONES_EDITOR::DIALOG_NON_COPPER_ZONES_EDITOR( PCB_BASE_FRAME* aParent,
ZONE_CONTAINER* aZone,
ZONE_SETTINGS* aSettings ) :
DialogNonCopperZonesPropertiesBase( aParent )
{ {
DialogNonCopperZonesEditor frame( this, aZone, &g_Zone_Default_Setting ); m_Parent = aParent;
bool diag = frame.ShowModal();
m_zone = aZone;
m_ptr = aSettings;
m_settings = *aSettings;
return diag; Init();
// the size of some items has changed, so we must call SetSizeHints()
GetSizer()->SetSizeHints( this );
} }
void DialogNonCopperZonesEditor::Init() void DIALOG_NON_COPPER_ZONES_EDITOR::Init()
{ {
SetFocus(); SetFocus();
SetReturnCode( ZONE_ABORT ); // Will be changed on buttons click SetReturnCode( ZONE_ABORT ); // Will be changed on button click
m_FillModeCtrl->SetSelection( m_Zone_Setting->m_FillMode ? 1 : 0 ); m_FillModeCtrl->SetSelection( m_settings.m_FillMode ? 1 : 0 );
AddUnitSymbol( *m_MinThicknessValueTitle, g_UserUnit ); AddUnitSymbol( *m_MinThicknessValueTitle, g_UserUnit );
wxString msg = ReturnStringFromValue( g_UserUnit, wxString msg = ReturnStringFromValue( g_UserUnit,
m_Zone_Setting->m_ZoneMinThickness, m_settings.m_ZoneMinThickness,
m_Parent->GetInternalUnits() ); m_Parent->GetInternalUnits() );
m_ZoneMinThicknessCtrl->SetValue( msg ); m_ZoneMinThicknessCtrl->SetValue( msg );
if( g_Zone_45_Only ) if( m_settings.m_Zone_45_Only )
m_OrientEdgesOpt->SetSelection( 1 ); m_OrientEdgesOpt->SetSelection( 1 );
switch( g_Zone_Default_Setting.m_Zone_HatchingStyle ) switch( m_settings.m_Zone_HatchingStyle )
{ {
case CPolyLine::NO_HATCH: case CPolyLine::NO_HATCH:
m_OutlineAppearanceCtrl->SetSelection( 0 ); m_OutlineAppearanceCtrl->SetSelection( 0 );
...@@ -108,9 +111,9 @@ void DialogNonCopperZonesEditor::Init() ...@@ -108,9 +111,9 @@ void DialogNonCopperZonesEditor::Init()
msg = m_Parent->GetBoard()->GetLayerName( layer_number ).Trim(); msg = m_Parent->GetBoard()->GetLayerName( layer_number ).Trim();
m_LayerSelectionCtrl->InsertItems( 1, &msg, ii ); m_LayerSelectionCtrl->InsertItems( 1, &msg, ii );
if( m_Zone_Container ) if( m_zone )
{ {
if( m_Zone_Container->GetLayer() == layer_number ) if( m_zone->GetLayer() == layer_number )
m_LayerSelectionCtrl->SetSelection( ii ); m_LayerSelectionCtrl->SetSelection( ii );
} }
else else
...@@ -122,48 +125,49 @@ void DialogNonCopperZonesEditor::Init() ...@@ -122,48 +125,49 @@ void DialogNonCopperZonesEditor::Init()
} }
void DialogNonCopperZonesEditor::OnOkClick( wxCommandEvent& event ) void DIALOG_NON_COPPER_ZONES_EDITOR::OnOkClick( wxCommandEvent& event )
{ {
wxString txtvalue = m_ZoneMinThicknessCtrl->GetValue(); wxString txtvalue = m_ZoneMinThicknessCtrl->GetValue();
m_Zone_Setting->m_ZoneMinThickness =
m_settings.m_ZoneMinThickness =
ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() ); ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() );
if( m_Zone_Setting->m_ZoneMinThickness < 10 ) if( m_settings.m_ZoneMinThickness < 10 )
{ {
DisplayError( this, DisplayError( this,
_( "Error :\nyou must choose a copper min thickness value bigger than 0.001 inch (or 0.0254 mm)" ) ); _( "Error :\nyou must choose a copper min thickness value bigger than 0.001 inch (or 0.0254 mm)" ) );
return; return;
} }
m_Zone_Setting->m_FillMode = (m_FillModeCtrl->GetSelection() == 0) ? 0 : 1; m_settings.m_FillMode = (m_FillModeCtrl->GetSelection() == 0) ? 0 : 1;
switch( m_OutlineAppearanceCtrl->GetSelection() ) switch( m_OutlineAppearanceCtrl->GetSelection() )
{ {
case 0: case 0:
g_Zone_Default_Setting.m_Zone_HatchingStyle = CPolyLine::NO_HATCH; m_settings.m_Zone_HatchingStyle = CPolyLine::NO_HATCH;
break; break;
case 1: case 1:
g_Zone_Default_Setting.m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE; m_settings.m_Zone_HatchingStyle = CPolyLine::DIAGONAL_EDGE;
break; break;
case 2: case 2:
g_Zone_Default_Setting.m_Zone_HatchingStyle = CPolyLine::DIAGONAL_FULL; m_settings.m_Zone_HatchingStyle = CPolyLine::DIAGONAL_FULL;
break; break;
} }
if( wxGetApp().GetSettings() ) if( wxGetApp().GetSettings() )
{ {
wxGetApp().GetSettings()->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY, wxGetApp().GetSettings()->Write( ZONE_NET_OUTLINES_HATCH_OPTION_KEY,
(long) g_Zone_Default_Setting.m_Zone_HatchingStyle ); (long) m_settings.m_Zone_HatchingStyle );
} }
if( m_OrientEdgesOpt->GetSelection() == 0 ) if( m_OrientEdgesOpt->GetSelection() == 0 )
g_Zone_45_Only = false; m_settings.m_Zone_45_Only = false;
else else
g_Zone_45_Only = true; m_settings.m_Zone_45_Only = true;
/* Get the layer selection for this zone */ // Get the layer selection for this zone
int ii = m_LayerSelectionCtrl->GetSelection(); int ii = m_LayerSelectionCtrl->GetSelection();
if( ii < 0 ) if( ii < 0 )
...@@ -172,12 +176,18 @@ void DialogNonCopperZonesEditor::OnOkClick( wxCommandEvent& event ) ...@@ -172,12 +176,18 @@ void DialogNonCopperZonesEditor::OnOkClick( wxCommandEvent& event )
return; return;
} }
g_Zone_Default_Setting.m_CurrentZone_Layer = ii + FIRST_NO_COPPER_LAYER; m_settings.m_CurrentZone_Layer = ii + FIRST_NO_COPPER_LAYER;
*m_ptr = m_settings;
EndModal( ZONE_OK ); EndModal( ZONE_OK );
} }
void DialogNonCopperZonesEditor::OnCancelClick( wxCommandEvent& event ) void DIALOG_NON_COPPER_ZONES_EDITOR::OnCancelClick( wxCommandEvent& event )
{ {
// do not save the edits.
EndModal( ZONE_ABORT ); EndModal( ZONE_ABORT );
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment