Minor flags and layer mask cleanup

This commit is contained in:
Lorenzo Marcantonio 2013-03-30 20:55:26 +01:00
parent c650c378c0
commit 27ee815742
17 changed files with 35 additions and 65 deletions

View File

@ -90,7 +90,7 @@ void EDA_ITEM::InitVars()
void EDA_ITEM::SetModified() 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 this a child object, then the parent modification state also needs to be set.
if( m_Parent ) if( m_Parent )

View File

@ -109,8 +109,7 @@ bool DrawPageOnClipboard( EDA_DRAW_FRAME* aFrame )
dc.SetClippingRegion( DrawArea ); dc.SetClippingRegion( DrawArea );
} }
const int maskLayer = 0xFFFFFFFF; aFrame->PrintPage( &dc, FULL_LAYERS, false );
aFrame->PrintPage( &dc, maskLayer, false );
screen->m_IsPrinting = false; screen->m_IsPrinting = false;
aFrame->GetCanvas()->SetClipBox( tmp ); aFrame->GetCanvas()->SetClipBox( tmp );
wxMetafile* mf = dc.Close(); wxMetafile* mf = dc.Close();

View File

@ -42,33 +42,6 @@
class MODULE; 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 /* Look up Table for conversion copper layer count -> general copper layer
* mask: */ * mask: */
LAYER_MSK g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = { LAYER_MSK g_TabAllCopperLayerMask[NB_COPPER_LAYERS] = {

View File

@ -262,9 +262,7 @@ void LIB_PIN::SetNumber( const wxString& number )
SetPinNumFromString( tmp ); SetPinNumFromString( tmp );
if( m_number != oldNumber ) if( m_number != oldNumber )
{ SetFlags( IS_CHANGED );
m_Flags |= IS_CHANGED;
}
/* Others pin numbers marked by EnableEditMode() are not modified /* Others pin numbers marked by EnableEditMode() are not modified
* because each pin has its own number * because each pin has its own number
@ -437,7 +435,7 @@ void LIB_PIN::SetConversion( int style )
return; return;
m_Convert = style; m_Convert = style;
m_Flags |= IS_CHANGED; SetFlags( IS_CHANGED );
if( style == 0 ) if( style == 0 )
{ {
@ -514,9 +512,9 @@ void LIB_PIN::EnableEditMode( bool enable, bool editPinByPin )
&& !IsNew() && !IsNew()
&& editPinByPin == false && editPinByPin == false
&& enable ) && enable )
pinList[i]->m_Flags |= IS_LINKED | IN_EDIT; pinList[i]->SetFlags( IS_LINKED | IN_EDIT );
else 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 ) if( aFormatter.Print( 0, "\n" ) < 0 )
return false; return false;
m_Flags &= ~IS_CHANGED; ClearFlags( IS_CHANGED );
return true; return true;
} }

View File

@ -205,8 +205,7 @@ bool SCH_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu )
return true; return true;
} }
int flags = item->GetFlags(); bool is_new = item->IsNew();
bool is_new = (flags & IS_NEW) ? true : false;
switch( item->Type() ) switch( item->Type() )
{ {

View File

@ -255,9 +255,9 @@ bool SCH_BITMAP::IsSelectStateChanged( const wxRect& aRect )
bool previousState = IsSelected(); bool previousState = IsSelected();
if( aRect.Contains( m_Pos ) ) if( aRect.Contains( m_Pos ) )
m_Flags |= SELECTED; SetFlags( SELECTED );
else else
m_Flags &= ~SELECTED; ClearFlags( SELECTED );
return previousState != IsSelected(); return previousState != IsSelected();
} }

View File

@ -1607,9 +1607,9 @@ bool SCH_COMPONENT::IsSelectStateChanged( const wxRect& aRect )
EDA_RECT boundingBox = GetBoundingBox(); EDA_RECT boundingBox = GetBoundingBox();
if( aRect.Intersects( boundingBox ) ) if( aRect.Intersects( boundingBox ) )
m_Flags |= SELECTED; SetFlags( SELECTED );
else else
m_Flags &= ~SELECTED; ClearFlags( SELECTED );
return previousState != IsSelected(); return previousState != IsSelected();
} }

View File

@ -168,9 +168,9 @@ bool SCH_JUNCTION::IsSelectStateChanged( const wxRect& aRect )
bool previousState = IsSelected(); bool previousState = IsSelected();
if( aRect.Contains( m_pos ) ) if( aRect.Contains( m_pos ) )
m_Flags |= SELECTED; SetFlags( SELECTED );
else else
m_Flags &= ~SELECTED; ClearFlags( SELECTED );
return previousState != IsSelected(); return previousState != IsSelected();
} }

View File

@ -436,22 +436,22 @@ bool SCH_LINE::IsSelectStateChanged( const wxRect& aRect )
if( aRect.Contains( m_start ) && aRect.Contains( m_end ) ) if( aRect.Contains( m_start ) && aRect.Contains( m_end ) )
{ {
m_Flags |= SELECTED; SetFlags( SELECTED );
m_Flags &= ~(STARTPOINT | ENDPOINT); ClearFlags( STARTPOINT | ENDPOINT );
} }
else if( aRect.Contains( m_start ) ) else if( aRect.Contains( m_start ) )
{ {
m_Flags &= ~STARTPOINT; ClearFlags( STARTPOINT );
m_Flags |= ( SELECTED | ENDPOINT ); SetFlags( SELECTED | ENDPOINT );
} }
else if( aRect.Contains( m_end ) ) else if( aRect.Contains( m_end ) )
{ {
m_Flags &= ~ENDPOINT; ClearFlags( ENDPOINT );
m_Flags |= ( SELECTED | STARTPOINT ); SetFlags( SELECTED | STARTPOINT );
} }
else else
{ {
m_Flags &= ~( SELECTED | STARTPOINT | ENDPOINT ); ClearFlags( SELECTED | STARTPOINT | ENDPOINT );
} }
return previousState != IsSelected(); return previousState != IsSelected();

View File

@ -193,9 +193,9 @@ bool SCH_MARKER::IsSelectStateChanged( const wxRect& aRect )
bool previousState = IsSelected(); bool previousState = IsSelected();
if( aRect.Contains( m_Pos ) ) if( aRect.Contains( m_Pos ) )
m_Flags |= SELECTED; SetFlags( SELECTED );
else else
m_Flags &= ~SELECTED; ClearFlags( SELECTED );
return previousState != IsSelected(); return previousState != IsSelected();
} }

View File

@ -174,9 +174,9 @@ bool SCH_NO_CONNECT::IsSelectStateChanged( const wxRect& aRect )
bool previousState = IsSelected(); bool previousState = IsSelected();
if( aRect.Contains( m_pos ) ) if( aRect.Contains( m_pos ) )
m_Flags |= SELECTED; SetFlags( SELECTED );
else else
m_Flags &= ~SELECTED; ClearFlags( SELECTED );
return previousState != IsSelected(); return previousState != IsSelected();
} }

View File

@ -992,9 +992,9 @@ bool SCH_SHEET::IsSelectStateChanged( const wxRect& aRect )
EDA_RECT boundingBox = GetBoundingBox(); EDA_RECT boundingBox = GetBoundingBox();
if( aRect.Intersects( boundingBox ) ) if( aRect.Intersects( boundingBox ) )
m_Flags |= SELECTED; SetFlags( SELECTED );
else else
m_Flags &= ~SELECTED; ClearFlags( SELECTED );
return previousState != IsSelected(); return previousState != IsSelected();
} }

View File

@ -543,7 +543,7 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi
break; break;
} }
if( m_isDangling == false ) if( !m_isDangling )
break; break;
} }
@ -556,9 +556,9 @@ bool SCH_TEXT::IsSelectStateChanged( const wxRect& aRect )
bool previousState = IsSelected(); bool previousState = IsSelected();
if( aRect.Contains( m_Pos ) ) if( aRect.Contains( m_Pos ) )
m_Flags |= SELECTED; SetFlags( SELECTED );
else else
m_Flags &= ~SELECTED; SetFlags( SELECTED );
return previousState != IsSelected(); return previousState != IsSelected();
} }

View File

@ -14,7 +14,7 @@ GBR_LAYOUT::GBR_LAYOUT()
{ {
PAGE_INFO pageInfo( wxT( "GERBER" ) ); PAGE_INFO pageInfo( wxT( "GERBER" ) );
SetPageSettings( pageInfo ); SetPageSettings( pageInfo );
m_printLayersMask = -1; m_printLayersMask = FULL_LAYERS;
} }

View File

@ -621,7 +621,7 @@ void GERBER_DRAW_ITEM::Show( int nestLevel, std::ostream& os ) const
" layer=\"" << m_Layer << '"' << " layer=\"" << m_Layer << '"' <<
" size=\"" << m_Size << '"' << " size=\"" << m_Size << '"' <<
" flags=\"" << m_Flags << '"' << " flags=\"" << m_Flags << '"' <<
" status=\"" << GetState( -1 ) << '"' << " status=\"" << GetStatus() << '"' <<
"<start" << m_Start << "/>" << "<start" << m_Start << "/>" <<
"<end" << m_End << "/>"; "<end" << m_End << "/>";

View File

@ -100,6 +100,7 @@ typedef unsigned LAYER_MSK;
*/ */
inline LAYER_MSK GetLayerMask( unsigned aLayerNumber ) inline LAYER_MSK GetLayerMask( unsigned aLayerNumber )
{ {
wxASSERT( aLayerNumber < LAYER_COUNT && aLayerNumber >= 0 );
return 1 << aLayerNumber; return 1 << aLayerNumber;
} }

View File

@ -1730,7 +1730,7 @@ void LEGACY_PLUGIN::loadPCB_LINE()
case 4: case 4:
int state; int state;
state = hexParse( data ); state = hexParse( data );
dseg->SetState( state, ON ); dseg->SetState( state, true );
break; break;
// Bezier Control Points // Bezier Control Points
@ -2046,7 +2046,7 @@ void LEGACY_PLUGIN::loadTrackList( int aStructType )
} }
newTrack->SetNet( net_code ); newTrack->SetNet( net_code );
newTrack->SetState( flags, ON ); newTrack->SetState( flags, true );
} }
THROW_IO_ERROR( "Missing '$EndTRACK'" ); THROW_IO_ERROR( "Missing '$EndTRACK'" );