From 27ee815742c307246ba6a98797f2166daed7566b Mon Sep 17 00:00:00 2001 From: Lorenzo Marcantonio Date: Sat, 30 Mar 2013 20:55:26 +0100 Subject: [PATCH] Minor flags and layer mask cleanup --- common/base_struct.cpp | 2 +- common/copy_to_clipboard.cpp | 3 +-- common/pcbcommon.cpp | 27 ----------------------- eeschema/lib_pin.cpp | 12 +++++----- eeschema/onrightclick.cpp | 3 +-- eeschema/sch_bitmap.cpp | 4 ++-- eeschema/sch_component.cpp | 4 ++-- eeschema/sch_junction.cpp | 4 ++-- eeschema/sch_line.cpp | 14 ++++++------ eeschema/sch_marker.cpp | 4 ++-- eeschema/sch_no_connect.cpp | 4 ++-- eeschema/sch_sheet.cpp | 4 ++-- eeschema/sch_text.cpp | 6 ++--- gerbview/class_gbr_layout.cpp | 2 +- gerbview/class_gerber_draw_item.cpp | 2 +- include/layers_id_colors_and_visibility.h | 1 + pcbnew/legacy_plugin.cpp | 4 ++-- 17 files changed, 35 insertions(+), 65 deletions(-) diff --git a/common/base_struct.cpp b/common/base_struct.cpp index 3b9cb8d3e6..37969c81fe 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -90,7 +90,7 @@ void EDA_ITEM::InitVars() void EDA_ITEM::SetModified() { - m_Flags |= IS_CHANGED; + SetFlags( IS_CHANGED ); // If this a child object, then the parent modification state also needs to be set. if( m_Parent ) diff --git a/common/copy_to_clipboard.cpp b/common/copy_to_clipboard.cpp index 973768033f..95ff829288 100644 --- a/common/copy_to_clipboard.cpp +++ b/common/copy_to_clipboard.cpp @@ -109,8 +109,7 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame ) dc.SetClippingRegion( DrawArea ); } - const int maskLayer = 0xFFFFFFFF; - aFrame->PrintPage( &dc, maskLayer, false ); + aFrame->PrintPage( &dc, FULL_LAYERS, false ); screen->m_IsPrinting = false; aFrame->GetCanvas()->SetClipBox( tmp ); wxMetafile* mf = dc.Close(); diff --git a/common/pcbcommon.cpp b/common/pcbcommon.cpp index 58441b01c5..70b8473508 100644 --- a/common/pcbcommon.cpp +++ b/common/pcbcommon.cpp @@ -42,33 +42,6 @@ class MODULE; -/* return a one bit layer mask from a layer number - * aLayerNumber = the layer number to convert (0 .. LAYER_COUNT-1) - */ -int GetLayerMask( int aLayerNumber ) -{ - wxASSERT( aLayerNumber < LAYER_COUNT && aLayerNumber >= 0 ); - -#if 0 - // Look up Table for conversion one layer number -> one bit layer mask: - static int tabOneLayerMask[LAYER_COUNT] = - { - 0x00000001, 0x00000002, 0x00000004, 0x00000008, - 0x00000010, 0x00000020, 0x00000040, 0x00000080, - 0x00000100, 0x00000200, 0x00000400, 0x00000800, - 0x00001000, 0x00002000, 0x00004000, 0x00008000, - 0x00010000, 0x00020000, 0x00040000, 0x00080000, - 0x00100000, 0x00200000, 0x00400000, 0x00800000, - 0x01000000, 0x02000000, 0x04000000, 0x08000000, - 0x10000000, 0x20000000, 0x40000000, 0x80000000 - }; - - return( tabOneLayerMask[aLayerNumber] ); -#else - return 1 << aLayerNumber; -#endif -} - /* Look up Table for conversion copper layer count -> general copper layer * mask: */ LAYER_MSK g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = { diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 9f8848a244..a7e636c020 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -262,9 +262,7 @@ void LIB_PIN::SetNumber( const wxString& number ) SetPinNumFromString( tmp ); if( m_number != oldNumber ) - { - m_Flags |= IS_CHANGED; - } + SetFlags( IS_CHANGED ); /* Others pin numbers marked by EnableEditMode() are not modified * because each pin has its own number @@ -437,7 +435,7 @@ void LIB_PIN::SetConversion( int style ) return; m_Convert = style; - m_Flags |= IS_CHANGED; + SetFlags( IS_CHANGED ); if( style == 0 ) { @@ -514,9 +512,9 @@ void LIB_PIN::EnableEditMode( bool enable, bool editPinByPin ) && !IsNew() && editPinByPin == false && enable ) - pinList[i]->m_Flags |= IS_LINKED | IN_EDIT; + pinList[i]->SetFlags( IS_LINKED | IN_EDIT ); else - pinList[i]->m_Flags &= ~( IS_LINKED | IN_EDIT ); + pinList[i]->ClearFlags( IS_LINKED | IN_EDIT ); } } @@ -650,7 +648,7 @@ bool LIB_PIN::Save( OUTPUTFORMATTER& aFormatter ) if( aFormatter.Print( 0, "\n" ) < 0 ) return false; - m_Flags &= ~IS_CHANGED; + ClearFlags( IS_CHANGED ); return true; } diff --git a/eeschema/onrightclick.cpp b/eeschema/onrightclick.cpp index cb2669f975..9f59ce816f 100644 --- a/eeschema/onrightclick.cpp +++ b/eeschema/onrightclick.cpp @@ -205,8 +205,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) return true; } - int flags = item->GetFlags(); - bool is_new = (flags & IS_NEW) ? true : false; + bool is_new = item->IsNew(); switch( item->Type() ) { diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index 49a4a1c9ec..7cce2b7d3b 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.cpp @@ -255,9 +255,9 @@ bool SCH_BITMAP::IsSelectStateChanged( const wxRect& aRect ) bool previousState = IsSelected(); if( aRect.Contains( m_Pos ) ) - m_Flags |= SELECTED; + SetFlags( SELECTED ); else - m_Flags &= ~SELECTED; + ClearFlags( SELECTED ); return previousState != IsSelected(); } diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 2cfe36af41..c6efcda0dd 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -1607,9 +1607,9 @@ bool SCH_COMPONENT::IsSelectStateChanged( const wxRect& aRect ) EDA_RECT boundingBox = GetBoundingBox(); if( aRect.Intersects( boundingBox ) ) - m_Flags |= SELECTED; + SetFlags( SELECTED ); else - m_Flags &= ~SELECTED; + ClearFlags( SELECTED ); return previousState != IsSelected(); } diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 07c81f3cac..4e715aa247 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -168,9 +168,9 @@ bool SCH_JUNCTION::IsSelectStateChanged( const wxRect& aRect ) bool previousState = IsSelected(); if( aRect.Contains( m_pos ) ) - m_Flags |= SELECTED; + SetFlags( SELECTED ); else - m_Flags &= ~SELECTED; + ClearFlags( SELECTED ); return previousState != IsSelected(); } diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index c9d4bfdad5..7977e87770 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -436,22 +436,22 @@ bool SCH_LINE::IsSelectStateChanged( const wxRect& aRect ) if( aRect.Contains( m_start ) && aRect.Contains( m_end ) ) { - m_Flags |= SELECTED; - m_Flags &= ~(STARTPOINT | ENDPOINT); + SetFlags( SELECTED ); + ClearFlags( STARTPOINT | ENDPOINT ); } else if( aRect.Contains( m_start ) ) { - m_Flags &= ~STARTPOINT; - m_Flags |= ( SELECTED | ENDPOINT ); + ClearFlags( STARTPOINT ); + SetFlags( SELECTED | ENDPOINT ); } else if( aRect.Contains( m_end ) ) { - m_Flags &= ~ENDPOINT; - m_Flags |= ( SELECTED | STARTPOINT ); + ClearFlags( ENDPOINT ); + SetFlags( SELECTED | STARTPOINT ); } else { - m_Flags &= ~( SELECTED | STARTPOINT | ENDPOINT ); + ClearFlags( SELECTED | STARTPOINT | ENDPOINT ); } return previousState != IsSelected(); diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp index c6a6354edb..c559c7449c 100644 --- a/eeschema/sch_marker.cpp +++ b/eeschema/sch_marker.cpp @@ -193,9 +193,9 @@ bool SCH_MARKER::IsSelectStateChanged( const wxRect& aRect ) bool previousState = IsSelected(); if( aRect.Contains( m_Pos ) ) - m_Flags |= SELECTED; + SetFlags( SELECTED ); else - m_Flags &= ~SELECTED; + ClearFlags( SELECTED ); return previousState != IsSelected(); } diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index 4d88f7824f..d375f842d1 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -174,9 +174,9 @@ bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect ) bool previousState = IsSelected(); if( aRect.Contains( m_pos ) ) - m_Flags |= SELECTED; + SetFlags( SELECTED ); else - m_Flags &= ~SELECTED; + ClearFlags( SELECTED ); return previousState != IsSelected(); } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index ba9ad92b4f..9335ce4eca 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -992,9 +992,9 @@ bool SCH_SHEET::IsSelectStateChanged( const wxRect& aRect ) EDA_RECT boundingBox = GetBoundingBox(); if( aRect.Intersects( boundingBox ) ) - m_Flags |= SELECTED; + SetFlags( SELECTED ); else - m_Flags &= ~SELECTED; + ClearFlags( SELECTED ); return previousState != IsSelected(); } diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 7cfa12c7fa..3cdf203175 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -543,7 +543,7 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi break; } - if( m_isDangling == false ) + if( !m_isDangling ) break; } @@ -556,9 +556,9 @@ bool SCH_TEXT::IsSelectStateChanged( const wxRect& aRect ) bool previousState = IsSelected(); if( aRect.Contains( m_Pos ) ) - m_Flags |= SELECTED; + SetFlags( SELECTED ); else - m_Flags &= ~SELECTED; + SetFlags( SELECTED ); return previousState != IsSelected(); } diff --git a/gerbview/class_gbr_layout.cpp b/gerbview/class_gbr_layout.cpp index a503a03a98..abd461876a 100644 --- a/gerbview/class_gbr_layout.cpp +++ b/gerbview/class_gbr_layout.cpp @@ -14,7 +14,7 @@ GBR_LAYOUT::GBR_LAYOUT() { PAGE_INFO pageInfo( wxT( "GERBER" ) ); SetPageSettings( pageInfo ); - m_printLayersMask = -1; + m_printLayersMask = FULL_LAYERS; } diff --git a/gerbview/class_gerber_draw_item.cpp b/gerbview/class_gerber_draw_item.cpp index 1e80c9ebb2..f9fb900284 100644 --- a/gerbview/class_gerber_draw_item.cpp +++ b/gerbview/class_gerber_draw_item.cpp @@ -621,7 +621,7 @@ void GERBER_DRAW_ITEM::Show( int nestLevel, std::ostream& os ) const " layer=\"" << m_Layer << '"' << " size=\"" << m_Size << '"' << " flags=\"" << m_Flags << '"' << - " status=\"" << GetState( -1 ) << '"' << + " status=\"" << GetStatus() << '"' << "" << ""; diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index 70038f0299..f2e4da7c56 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -100,6 +100,7 @@ typedef unsigned LAYER_MSK; */ inline LAYER_MSK GetLayerMask( unsigned aLayerNumber ) { + wxASSERT( aLayerNumber < LAYER_COUNT && aLayerNumber >= 0 ); return 1 << aLayerNumber; } diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index fa681a52c0..3a945691a3 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -1730,7 +1730,7 @@ void LEGACY_PLUGIN::loadPCB_LINE() case 4: int state; state = hexParse( data ); - dseg->SetState( state, ON ); + dseg->SetState( state, true ); break; // Bezier Control Points @@ -2046,7 +2046,7 @@ void LEGACY_PLUGIN::loadTrackList( int aStructType ) } newTrack->SetNet( net_code ); - newTrack->SetState( flags, ON ); + newTrack->SetState( flags, true ); } THROW_IO_ERROR( "Missing '$EndTRACK'" );