* Add PCB_EDIT_FRAME::syncLayerVisibilities(), PCB_LAYER_MANAGER::SyncLayerVisibilities().
* Save all visibilities, layer and render, in BOARD and restore on load.
This commit is contained in:
parent
3976d5087e
commit
2e29b4f152
|
@ -4,6 +4,13 @@ KiCad ChangeLog 2012
|
|||
Please add newer entries at the top, list the date and your name with
|
||||
email address.
|
||||
|
||||
2012-Mar-11 UPDATE Dick Hollenbeck <dick@softplc.com>
|
||||
================================================================================
|
||||
++pcbnew
|
||||
* Add PCB_EDIT_FRAME::syncLayerVisibilities, PCB_LAYER_MANAGER::SyncLayerVisibilities().
|
||||
* Save all visibilities, layer and render, in BOARD and restore on load.
|
||||
|
||||
|
||||
2012-Feb-19 UPDATE Dick Hollenbeck <dick@softplc.com>
|
||||
================================================================================
|
||||
++pcbnew
|
||||
|
|
|
@ -265,7 +265,7 @@ wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, int aInternal_Uni
|
|||
|
||||
value_to_print = To_User_Unit( aUnit, aValue, aInternal_Unit );
|
||||
|
||||
/* Yet another 'if Pcbnew' :( */
|
||||
// Yet another 'if Pcbnew' :(
|
||||
StringValue.Printf( ( aInternal_Unit > 1000 ) ? wxT( "%.4f" ) : wxT( "%.3f" ),
|
||||
value_to_print );
|
||||
|
||||
|
@ -293,12 +293,12 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Int
|
|||
int Value;
|
||||
double dtmp = 0;
|
||||
|
||||
/* Acquire the 'right' decimal point separator */
|
||||
// Acquire the 'right' decimal point separator
|
||||
const struct lconv* lc = localeconv();
|
||||
wxChar decimal_point = lc->decimal_point[0];
|
||||
wxString buf( TextValue.Strip( wxString::both ) );
|
||||
|
||||
/* Convert the period in decimal point */
|
||||
// Convert the period in decimal point
|
||||
buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
|
||||
|
||||
// An ugly fix needed by WxWidgets 2.9.1 that sometimes
|
||||
|
@ -306,7 +306,7 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Int
|
|||
// TODO: remove this line if WxWidgets 2.9.2 fixes this issue
|
||||
buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );
|
||||
|
||||
/* Find the end of the numeric part */
|
||||
// Find the end of the numeric part
|
||||
unsigned brk_point = 0;
|
||||
|
||||
while( brk_point < buf.Len() )
|
||||
|
@ -321,10 +321,10 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Int
|
|||
++brk_point;
|
||||
}
|
||||
|
||||
/* Extract the numeric part */
|
||||
// Extract the numeric part
|
||||
buf.Left( brk_point ).ToDouble( &dtmp );
|
||||
|
||||
/* Check the optional unit designator (2 ch significant) */
|
||||
// Check the optional unit designator (2 ch significant)
|
||||
wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() );
|
||||
|
||||
if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
|
||||
|
@ -335,7 +335,7 @@ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Int
|
|||
{
|
||||
aUnit = MILLIMETRES;
|
||||
}
|
||||
else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) /* Mils or thous */
|
||||
else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) // Mils or thous
|
||||
{
|
||||
aUnit = INCHES;
|
||||
dtmp /= 1000;
|
||||
|
|
|
@ -207,6 +207,7 @@ static void InitKiCadAboutNew( AboutAppInfo& info )
|
|||
info.AddDeveloper( new Contributor( wxT( "Jean-Pierre Charras" ),
|
||||
wxT( "jean-pierre.charras@gipsa-lab.inpg.fr" ) ) );
|
||||
info.AddDeveloper( new Contributor( wxT( "Dick Hollenbeck" ), wxT( "dick@softplc.com" ) ) );
|
||||
info.AddDeveloper( new Contributor( wxT( "Frank Bennett" ), wxT( "bennett78@lpbroadband.net" ) ) );
|
||||
info.AddDeveloper( new Contributor( wxT( "Hauptmech" ), wxT( "hauptmech@gmail.com" ) ) );
|
||||
info.AddDeveloper( new Contributor( wxT( "Jerry Jacobs" ),
|
||||
wxT( "xor.gate.engineering@gmail.com" ) ) );
|
||||
|
|
|
@ -155,7 +155,7 @@ public:
|
|||
|
||||
/**
|
||||
* Function IsCustom
|
||||
* returns true if the type is "User"
|
||||
* returns true if the type is Custom
|
||||
*/
|
||||
bool IsCustom() const;
|
||||
|
||||
|
@ -196,8 +196,6 @@ public:
|
|||
const wxSize GetSizeIU() const { return wxSize( GetWidthIU(), GetHeightIU() ); }
|
||||
#endif
|
||||
|
||||
// wxPoint GetOffsetMils() const { return m_Offset; }
|
||||
|
||||
int GetLeftMarginMils() const { return m_left_margin; }
|
||||
int GetRightMarginMils() const { return m_right_margin; }
|
||||
int GetTopMarginMils() const { return m_top_margin; }
|
||||
|
@ -268,12 +266,12 @@ private:
|
|||
};
|
||||
|
||||
|
||||
extern wxString g_ProductName;
|
||||
extern wxString g_ProductName;
|
||||
|
||||
/// Default user lib path can be left void, if the standard lib path is used
|
||||
extern wxString g_UserLibDirBuffer;
|
||||
extern wxString g_UserLibDirBuffer;
|
||||
|
||||
extern bool g_ShowPageLimits; ///< true to display the page limits
|
||||
extern bool g_ShowPageLimits; ///< true to display the page limits
|
||||
|
||||
/// Name of default configuration file. (kicad.pro)
|
||||
extern wxString g_Prj_Default_Config_FullFilename;
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <boost/ptr_container/ptr_vector.hpp>
|
||||
|
||||
|
||||
|
||||
|
||||
/** Type of parameter in the configuration file */
|
||||
enum paramcfg_id {
|
||||
PARAM_INT,
|
||||
|
@ -31,11 +33,15 @@ enum paramcfg_id {
|
|||
#define INT_MAXVAL 0x7FFFFFFF
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Class PARAM_CFG_BASE
|
||||
* is a base class which establishes the virtual functions ReadParam and SaveParam,
|
||||
* which are re-implemented by a number of base classes, and these function's
|
||||
* is a base class which establishes the interface functions ReadParam and SaveParam,
|
||||
* which are implemented by a number of derived classes, and these function's
|
||||
* doxygen comments are inherited also.
|
||||
* <p>
|
||||
* See kicad.odt or kicad.pdf, chapter 2 :
|
||||
* "Installation and configuration/Initialization of the default config".
|
||||
*/
|
||||
class PARAM_CFG_BASE
|
||||
{
|
||||
|
|
|
@ -133,8 +133,8 @@ protected:
|
|||
|
||||
/**
|
||||
* Function syncLayerWidgetLayer
|
||||
* updates the currently "selected" layer within the PCB_LAYER_WIDGET.
|
||||
* The currently active layer is defined by the return value of getActiveLayer().
|
||||
* updates the currently layer "selection" within the PCB_LAYER_WIDGET.
|
||||
* The currently selected layer is defined by the return value of getActiveLayer().
|
||||
* <p>
|
||||
* This function cannot be inline without including layer_widget.h in
|
||||
* here and we do not want to do that.
|
||||
|
@ -150,6 +150,14 @@ protected:
|
|||
*/
|
||||
void syncRenderStates();
|
||||
|
||||
/**
|
||||
* Function syncLayerVisibilities
|
||||
* updates each "Layer" checkbox in the layer widget according
|
||||
* to each layer's current visibility determined by IsLayerVisible(), and is
|
||||
* helpful immediately after loading a BOARD which may have state information in it.
|
||||
*/
|
||||
void syncLayerVisibilities();
|
||||
|
||||
virtual void unitsChangeRefresh();
|
||||
|
||||
/**
|
||||
|
|
|
@ -516,18 +516,15 @@ void BOARD::SetVisibleLayers( int aLayerMask )
|
|||
}
|
||||
|
||||
|
||||
// these are not tidy, since there are PCB_VISIBLEs that are not stored in the bitmap.
|
||||
|
||||
void BOARD::SetVisibleElements( int aMask )
|
||||
{
|
||||
/* Call SetElementVisibility for each item,
|
||||
* to ensure specific calculations that can be needed by some items
|
||||
* just change the visibility flags could be not sufficient
|
||||
*/
|
||||
// Call SetElementVisibility for each item
|
||||
// to ensure specific calculations that can be needed by some items,
|
||||
// just changing the visibility flags could be not sufficient.
|
||||
for( int ii = 0; ii < PCB_VISIBLE( END_PCB_VISIBLE_LIST ); ii++ )
|
||||
{
|
||||
int item_mask = 1 << ii;
|
||||
SetElementVisibility( ii, aMask & item_mask );
|
||||
SetElementVisibility( ii, bool( aMask & item_mask ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -563,8 +560,8 @@ void BOARD::SetElementVisibility( int aPCB_VISIBLE, bool isEnabled )
|
|||
{
|
||||
case RATSNEST_VISIBLE:
|
||||
|
||||
// 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
|
||||
// we must clear or set the CH_VISIBLE flags to hide/show ratsnest
|
||||
// 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
|
||||
if( IsElementVisible( RATSNEST_VISIBLE ) )
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include <pcbnew_id.h>
|
||||
|
||||
|
||||
// this is a read only template that is copied and modified before adding to LAYER_WIDGET
|
||||
/// This is a read only template that is copied and modified before adding to LAYER_WIDGET
|
||||
const LAYER_WIDGET::ROW PCB_LAYER_WIDGET::s_render_rows[] = {
|
||||
|
||||
#define RR LAYER_WIDGET::ROW // Render Row abreviation to reduce source width
|
||||
|
@ -221,8 +221,30 @@ void PCB_LAYER_WIDGET::SyncRenderStates()
|
|||
|
||||
for( unsigned row=0; row<DIM(s_render_rows); ++row )
|
||||
{
|
||||
// this does not fire an event
|
||||
SetRenderState( s_render_rows[row].id, board->IsElementVisible( s_render_rows[row].id ) );
|
||||
int rowId = s_render_rows[row].id;
|
||||
|
||||
// this does not fire a UI event
|
||||
SetRenderState( rowId, board->IsElementVisible( rowId ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PCB_LAYER_WIDGET::SyncLayerVisibilities()
|
||||
{
|
||||
BOARD* board = myframe->GetBoard();
|
||||
int count = GetLayerRowCount();
|
||||
|
||||
for( int row=0; row<count; ++row )
|
||||
{
|
||||
// this utilizes more implementation knowledge than ideal, eventually
|
||||
// add member ROW getRow() or similar to base LAYER_WIDGET.
|
||||
|
||||
wxWindow* w = getLayerComp( row, 0 );
|
||||
|
||||
int layerId = getDecodedId( w->GetId() );
|
||||
|
||||
// this does not fire a UI event
|
||||
SetLayerVisible( layerId, board->IsLayerVisible( layerId ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,14 @@ public:
|
|||
*/
|
||||
void SyncRenderStates();
|
||||
|
||||
/**
|
||||
* Function SyncLayerVisibilities
|
||||
* updates each "Layer" checkbox in this layer widget according
|
||||
* to each layer's current visibility determined by IsLayerVisible(), and is
|
||||
* helpful immediately after loading a BOARD which may have state information in it.
|
||||
*/
|
||||
void SyncLayerVisibilities();
|
||||
|
||||
/**
|
||||
* Function SetLayersManagerTabsText
|
||||
* Update the layer manager tabs labels
|
||||
|
|
|
@ -370,10 +370,17 @@ this file again." ) );
|
|||
ReFillLayerWidget();
|
||||
|
||||
ReCreateLayerBox( NULL );
|
||||
syncLayerWidgetLayer();
|
||||
|
||||
// upate the layer widget to match board visibility states, both layers and render columns.
|
||||
syncLayerVisibilities();
|
||||
syncLayerWidgetLayer();
|
||||
syncRenderStates();
|
||||
|
||||
// Update the RATSNEST items, which were not loaded at the time
|
||||
// BOARD::SetVisibleElements() was called from within any PLUGIN.
|
||||
// See case RATSNEST_VISIBLE: in BOARD::SetElementVisibility()
|
||||
GetBoard()->SetVisibleElements( GetBoard()->GetVisibleElements() );
|
||||
|
||||
updateTraceWidthSelectBox();
|
||||
updateViaSizeSelectBox();
|
||||
|
||||
|
|
|
@ -217,12 +217,25 @@ int PCB_BASE_FRAME::ReadGeneralDescrPcb( LINE_READER* aReader )
|
|||
data = strtok( NULL, delims );
|
||||
sscanf( data, "%X", &enabledLayers );
|
||||
|
||||
// Setup layer visibility
|
||||
// layer usage
|
||||
GetBoard()->SetEnabledLayers( enabledLayers );
|
||||
|
||||
// layer visibility equals layer usage, unless overridden later via "VisibleLayers"
|
||||
GetBoard()->SetVisibleLayers( enabledLayers );
|
||||
continue;
|
||||
}
|
||||
|
||||
if( stricmp( data, "VisibleLayers" ) == 0 )
|
||||
{
|
||||
int visibleLayers = -1;
|
||||
|
||||
data = strtok( NULL, delims );
|
||||
sscanf( data, "%X", &visibleLayers );
|
||||
|
||||
GetBoard()->SetVisibleLayers( visibleLayers );
|
||||
continue;
|
||||
}
|
||||
|
||||
if( strncmp( data, "Ly", 2 ) == 0 ) // Old format for Layer count
|
||||
{
|
||||
int Masque_Layer = 1, ii;
|
||||
|
@ -634,7 +647,13 @@ int PCB_BASE_FRAME::ReadSetup( LINE_READER* aReader )
|
|||
|
||||
GetScreen()->m_GridOrigin.x = Ox;
|
||||
GetScreen()->m_GridOrigin.y = Oy;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( stricmp( line, "VisibleElements" ) == 0 )
|
||||
{
|
||||
int visibleElements = strtoul( data, 0, 16 );
|
||||
bds.SetVisibleElements( visibleElements );
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
@ -778,6 +797,8 @@ static int WriteSetup( FILE* aFile, PCB_EDIT_FRAME* aFrame, BOARD* aBoard )
|
|||
aFrame->GetOriginAxisPosition().x,
|
||||
aFrame->GetOriginAxisPosition().y );
|
||||
|
||||
fprintf( aFile, "VisibleElements %X\n", bds.GetVisibleElements() );
|
||||
|
||||
STRING_FORMATTER sf;
|
||||
|
||||
g_PcbPlotOptions.Format( &sf, 0 );
|
||||
|
@ -810,7 +831,12 @@ bool PCB_EDIT_FRAME::WriteGeneralDescrPcb( FILE* File )
|
|||
fprintf( File,
|
||||
"Ly %8X\n",
|
||||
g_TabAllCopperLayerMask[NbLayers - 1] | ALL_NO_CU_LAYERS );
|
||||
|
||||
fprintf( File, "EnabledLayers %08X\n", GetBoard()->GetEnabledLayers() );
|
||||
|
||||
if( GetBoard()->GetEnabledLayers() != GetBoard()->GetVisibleLayers() )
|
||||
fprintf( File, "VisibleLayers %08X\n", GetBoard()->GetVisibleLayers() );
|
||||
|
||||
fprintf( File, "Links %d\n", GetBoard()->GetRatsnestsCount() );
|
||||
fprintf( File, "NoConn %d\n", GetBoard()->m_NbNoconnect );
|
||||
|
||||
|
|
|
@ -356,11 +356,19 @@ void KICAD_PLUGIN::loadGENERAL()
|
|||
{
|
||||
int enabledLayers = hexParse( line + SZ( "EnabledLayers" ) );
|
||||
|
||||
// Setup layer visibility
|
||||
// layer usage
|
||||
m_board->SetEnabledLayers( enabledLayers );
|
||||
|
||||
// layer visibility equals layer usage, unless overridden later via "VisibleLayers"
|
||||
m_board->SetVisibleLayers( enabledLayers );
|
||||
}
|
||||
|
||||
else if( TESTLINE( "VisibleLayers" ) )
|
||||
{
|
||||
int visibleLayers = hexParse( line + SZ( "VisibleLayers" ) );
|
||||
m_board->SetVisibleLayers( visibleLayers );
|
||||
}
|
||||
|
||||
else if( TESTLINE( "Ly" ) ) // Old format for Layer count
|
||||
{
|
||||
int layer_mask = hexParse( line + SZ( "Ly" ) );
|
||||
|
@ -607,18 +615,6 @@ void KICAD_PLUGIN::loadSETUP()
|
|||
}
|
||||
}
|
||||
|
||||
/* no more used
|
||||
else if( TESTLINE( "TrackWidth" ) )
|
||||
{
|
||||
}
|
||||
else if( TESTLINE( "ViaSize" ) )
|
||||
{
|
||||
}
|
||||
else if( TESTLINE( "MicroViaSize" ) )
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
else if( TESTLINE( "TrackWidthList" ) )
|
||||
{
|
||||
BIU tmp = biuParse( line + SZ( "TrackWidthList" ) );
|
||||
|
@ -794,6 +790,12 @@ void KICAD_PLUGIN::loadSETUP()
|
|||
*/
|
||||
}
|
||||
|
||||
else if( TESTLINE( "VisibleElements" ) )
|
||||
{
|
||||
int visibleElements = hexParse( line + SZ( "VisibleElements" ) );
|
||||
bds.SetVisibleElements( visibleElements );
|
||||
}
|
||||
|
||||
else if( TESTLINE( "$EndSETUP" ) )
|
||||
{
|
||||
m_board->SetDesignSettings( bds );
|
||||
|
@ -2765,6 +2767,10 @@ void KICAD_PLUGIN::saveGENERAL() const
|
|||
*/
|
||||
|
||||
fprintf( m_fp, "EnabledLayers %08X\n", m_board->GetEnabledLayers() );
|
||||
|
||||
if( m_board->GetEnabledLayers() != m_board->GetVisibleLayers() )
|
||||
fprintf( m_fp, "VisibleLayers %08X\n", m_board->GetVisibleLayers() );
|
||||
|
||||
fprintf( m_fp, "Links %d\n", m_board->GetRatsnestsCount() );
|
||||
fprintf( m_fp, "NoConn %d\n", m_board->m_NbNoconnect );
|
||||
|
||||
|
@ -2918,6 +2924,8 @@ void KICAD_PLUGIN::saveSETUP() const
|
|||
}
|
||||
*/
|
||||
|
||||
fprintf( m_fp, "VisibleElements %X\n", bds.GetVisibleElements() );
|
||||
|
||||
fprintf( m_fp, "$EndSETUP\n\n" );
|
||||
}
|
||||
|
||||
|
|
|
@ -200,6 +200,7 @@ wxBitmap LAYER_WIDGET::makeBitmap( int aColor )
|
|||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
wxBitmapButton* LAYER_WIDGET::makeColorButton( wxWindow* aParent, int aColor, int aID )
|
||||
{
|
||||
// dynamically make a wxBitMap and brush it with the appropriate color,
|
||||
|
@ -218,6 +219,7 @@ wxBitmapButton* LAYER_WIDGET::makeColorButton( wxWindow* aParent, int aColor, in
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void LAYER_WIDGET::OnLeftDownLayers( wxMouseEvent& event )
|
||||
{
|
||||
int row;
|
||||
|
@ -325,6 +327,7 @@ void LAYER_WIDGET::OnMiddleDownRenderColor( wxMouseEvent& event )
|
|||
passOnFocus();
|
||||
}
|
||||
|
||||
|
||||
void LAYER_WIDGET::OnRenderCheckBox( wxCommandEvent& event )
|
||||
{
|
||||
wxCheckBox* eventSource = (wxCheckBox*) event.GetEventObject();
|
||||
|
@ -457,7 +460,7 @@ void LAYER_WIDGET::insertRenderRow( int aRow, const ROW& aSpec )
|
|||
else // == -1, no color selection wanted
|
||||
{
|
||||
// need a place holder within the sizer to keep grid full.
|
||||
wxPanel* invisible = new wxPanel( m_RenderScrolledWindow );
|
||||
wxPanel* invisible = new wxPanel( m_RenderScrolledWindow, encodeId( col, aSpec.id ) );
|
||||
m_RenderFlexGridSizer->wxSizer::Insert( index+col, invisible, 0, flags );
|
||||
}
|
||||
|
||||
|
|
|
@ -166,11 +166,12 @@ protected:
|
|||
|
||||
/**
|
||||
* Function getLayerComp
|
||||
* returns the component within the m_LayersFlexGridSizer at aRow and aCol
|
||||
* or NULL if \a these parameters are out of range.
|
||||
* returns the component within the m_LayersFlexGridSizer at @a aRow and @a aCol
|
||||
* or NULL if these parameters are out of range.
|
||||
*
|
||||
* @param aRow is the row index
|
||||
* @param aColumn is the column
|
||||
* @return wxWindow - the component installed within the sizer at given grid coordinate.
|
||||
*/
|
||||
wxWindow* getLayerComp( int aRow, int aColumn );
|
||||
wxWindow* getRenderComp( int aRow, int aColumn );
|
||||
|
@ -278,7 +279,6 @@ public:
|
|||
AppendRenderRow( aRowsArray[row] );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function ClearRenderRows
|
||||
* empties out the render rows.
|
||||
|
@ -419,5 +419,4 @@ public:
|
|||
//-----</abstract functions>------------------------------------------
|
||||
};
|
||||
|
||||
|
||||
#endif // LAYERWIDGET_H_
|
||||
|
|
|
@ -653,6 +653,12 @@ void PCB_EDIT_FRAME::syncRenderStates()
|
|||
}
|
||||
|
||||
|
||||
void PCB_EDIT_FRAME::syncLayerVisibilities()
|
||||
{
|
||||
m_Layers->SyncLayerVisibilities();
|
||||
}
|
||||
|
||||
|
||||
void PCB_EDIT_FRAME::unitsChangeRefresh()
|
||||
{
|
||||
PCB_BASE_FRAME::unitsChangeRefresh(); // Update the grid size select box.
|
||||
|
|
Loading…
Reference in New Issue