From eb053cac2bcec8765ae9f7e3ee719ea5847df0a0 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 3 Feb 2014 13:08:01 +0100 Subject: [PATCH] Changed BOARD_DESIGN_SETTINGS::m_VisibleElements from int to long, to assure at least 32 bits length (without depending on the platfrom int size). --- include/class_board_design_settings.h | 18 ++++++++++-------- pcbnew/kicad_plugin.cpp | 2 +- pcbnew/legacy_plugin.cpp | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/include/class_board_design_settings.h b/include/class_board_design_settings.h index 9b516308b2..579d7dad38 100644 --- a/include/class_board_design_settings.h +++ b/include/class_board_design_settings.h @@ -100,7 +100,7 @@ public: * returns a bit-mask of all the element categories that are visible * @return int - the visible element categories in bit-mapped form. */ - int GetVisibleElements() const + long GetVisibleElements() const { return m_VisibleElements; } @@ -110,7 +110,7 @@ public: * changes the bit-mask of visible element categories * @param aMask = The new bit-mask of visible element categories */ - void SetVisibleElements( int aMask ) + void SetVisibleElements( long aMask ) { m_VisibleElements = aMask; } @@ -119,23 +119,25 @@ public: * Function IsElementVisible * tests whether a given element category is visible. Keep this as an * inline function. - * @param aPCB_VISIBLE is from the enum by the same name + * @param aElementCategory is from the enum by the same name * @return bool - true if the element is visible. * @see enum PCB_VISIBLE */ - bool IsElementVisible( int aPCB_VISIBLE ) const + bool IsElementVisible( int aElementCategory ) const { - return bool( m_VisibleElements & (1 << aPCB_VISIBLE) ); + assert( aElementCategory >= 0 && aElementCategory < END_PCB_VISIBLE_LIST ); + + return ( m_VisibleElements & ( 1 << aElementCategory ) ); } /** * Function SetElementVisibility * changes the visibility of an element category - * @param aPCB_VISIBLE is from the enum by the same name + * @param aElementCategory is from the enum by the same name * @param aNewState = The new visibility state of the element category * @see enum PCB_VISIBLE */ - void SetElementVisibility( int aPCB_VISIBLE, bool aNewState ); + void SetElementVisibility( int aElementCategory, bool aNewState ); /** * Function GetEnabledLayers @@ -196,7 +198,7 @@ private: int m_CopperLayerCount; ///< Number of copper layers for this design LAYER_MSK m_EnabledLayers; ///< Bit-mask for layer enabling LAYER_MSK m_VisibleLayers; ///< Bit-mask for layer visibility - int m_VisibleElements; ///< Bit-mask for element category visibility + long m_VisibleElements; ///< Bit-mask for element category visibility int m_boardThickness; ///< Board thickness for 3D viewer }; diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 99211a7e4d..2121c98e61 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -647,7 +647,7 @@ void PCB_IO::format( BOARD* aBoard, int aNestLevel ) const FMTIU( aBoard->GetGridOrigin().x ).c_str(), FMTIU( aBoard->GetGridOrigin().y ).c_str() ); - m_out->Print( aNestLevel+1, "(visible_elements %X)\n", + m_out->Print( aNestLevel+1, "(visible_elements %lX)\n", aBoard->GetDesignSettings().GetVisibleElements() ); aBoard->GetPlotOptions().Format( m_out, aNestLevel+1 ); diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index a1fd78a9b0..1c1a920bf8 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -870,7 +870,7 @@ void LEGACY_PLUGIN::loadSETUP() else if( TESTLINE( "VisibleElements" ) ) { - int visibleElements = hexParse( line + SZ( "VisibleElements" ) ); + long visibleElements = hexParse( line + SZ( "VisibleElements" ) ); bds.SetVisibleElements( visibleElements ); } @@ -3071,7 +3071,7 @@ void LEGACY_PLUGIN::saveSETUP( const BOARD* aBoard ) const fprintf( m_fp, "GridOrigin %s\n", fmtBIUPoint( aBoard->GetGridOrigin() ).c_str() ); fprintf( m_fp, "AuxiliaryAxisOrg %s\n", fmtBIUPoint( aBoard->GetAuxOrigin() ).c_str() ); - fprintf( m_fp, "VisibleElements %X\n", bds.GetVisibleElements() ); + fprintf( m_fp, "VisibleElements %lX\n", bds.GetVisibleElements() ); { STRING_FORMATTER sf;