Commit 675f8d4a authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio

Typedef STATUS_FLAGS to encapsulate EDA_ITEM bitmapped flags

parent cd18ff17
......@@ -195,7 +195,7 @@ UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx )
}
int PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx )
STATUS_FLAGS PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx )
{
if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].GetFlags();
......@@ -253,7 +253,7 @@ bool PICKED_ITEMS_LIST::SetPickedItemStatus( UNDO_REDO_T aStatus, unsigned aIdx
}
bool PICKED_ITEMS_LIST::SetPickerFlags( int aFlags, unsigned aIdx )
bool PICKED_ITEMS_LIST::SetPickerFlags( STATUS_FLAGS aFlags, unsigned aIdx )
{
if( aIdx < m_ItemsList.size() )
{
......
......@@ -85,7 +85,7 @@ static void moveBitmap( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosit
dirty.Inflate( 4 ); // Give a margin
aPanel->SetMouseCapture( NULL, NULL ); // Avoid loop in redraw panel
int flgs = image->GetFlags();
STATUS_FLAGS flgs = image->GetFlags();
image->ClearFlags();
aPanel->RefreshDrawingRect( dirty );
image->SetFlags( flgs );
......
......@@ -360,7 +360,7 @@ void SCH_EDIT_FRAME::OnSelectUnit( wxCommandEvent& aEvent )
if( unit > unitCount )
unit = unitCount;
int flags = component->GetFlags();
STATUS_FLAGS flags = component->GetFlags();
if( !flags ) // No command in progress: save in undo list
SaveCopyInUndoList( component, UR_CHANGED );
......@@ -405,7 +405,7 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* DrawComponent, wxDC* DC )
return;
}
int flags = DrawComponent->GetFlags();
STATUS_FLAGS flags = DrawComponent->GetFlags();
if( DrawComponent->GetFlags() )
DrawComponent->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode, g_GhostColor );
......
......@@ -574,7 +574,7 @@ wxString LIB_ARC::GetSelectMenuText() const
}
void LIB_ARC::BeginEdit( int aEditMode, const wxPoint aPosition )
void LIB_ARC::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Invalid edit mode for LIB_ARC object." ) );
......
......@@ -110,7 +110,7 @@ public:
int GetPenSize() const;
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
bool ContinueEdit( const wxPoint aNextPoint );
......
......@@ -296,7 +296,7 @@ wxString LIB_CIRCLE::GetSelectMenuText() const
}
void LIB_CIRCLE::BeginEdit( int aEditMode, const wxPoint aPosition )
void LIB_CIRCLE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Invalid edit mode for LIB_CIRCLE object." ) );
......
......@@ -71,7 +71,7 @@ public:
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
bool ContinueEdit( const wxPoint aNextPoint );
......
......@@ -175,7 +175,7 @@ public:
* started. This may or may not be required depending on the item
* being edited and the edit mode.
*/
virtual void BeginEdit( int aEditMode, const wxPoint aPosition = wxPoint( 0, 0 ) ) {}
virtual void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition = wxPoint( 0, 0 ) ) {}
/**
* Continue an edit in progress at \a aPosition.
......
......@@ -659,7 +659,7 @@ wxString LIB_FIELD::GetSelectMenuText() const
}
void LIB_FIELD::BeginEdit( int aEditMode, const wxPoint aPosition )
void LIB_FIELD::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0,
wxT( "Invalid edit mode for LIB_FIELD object." ) );
......
......@@ -207,7 +207,7 @@ public:
EDA_COLOR_T GetDefaultColor();
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
bool ContinueEdit( const wxPoint aNextPoint );
......
......@@ -420,7 +420,7 @@ wxString LIB_POLYLINE::GetSelectMenuText() const
}
void LIB_POLYLINE::BeginEdit( int aEditMode, const wxPoint aPosition )
void LIB_POLYLINE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Invalid edit mode for LIB_POLYLINE object." ) );
......
......@@ -84,7 +84,7 @@ public:
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
bool ContinueEdit( const wxPoint aNextPoint );
......
......@@ -333,7 +333,7 @@ wxString LIB_RECTANGLE::GetSelectMenuText() const
}
void LIB_RECTANGLE::BeginEdit( int aEditMode, const wxPoint aPosition )
void LIB_RECTANGLE::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED | IS_RESIZED ) ) != 0,
wxT( "Invalid edit mode for LIB_RECTANGLE object." ) );
......
......@@ -75,7 +75,7 @@ public:
void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList );
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
bool ContinueEdit( const wxPoint aNextPoint );
......
......@@ -495,7 +495,7 @@ wxString LIB_TEXT::GetSelectMenuText() const
}
void LIB_TEXT::BeginEdit( int aEditMode, const wxPoint aPosition )
void LIB_TEXT::BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aPosition )
{
wxCHECK_RET( ( aEditMode & ( IS_NEW | IS_MOVED ) ) != 0,
wxT( "Invalid edit mode for LIB_TEXT object." ) );
......
......@@ -100,7 +100,7 @@ public:
void Rotate();
void BeginEdit( int aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) );
bool ContinueEdit( const wxPoint aNextPoint );
......
......@@ -754,7 +754,7 @@ void LIB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
m_canvas->MoveCursorToCrossHair();
int oldFlags = m_drawItem->GetFlags();
STATUS_FLAGS oldFlags = m_drawItem->GetFlags();
m_drawItem->ClearFlags();
m_drawItem->Draw( m_canvas, &dc, wxPoint( 0, 0 ), UNSPECIFIED_COLOR, g_XorMode, NULL, DefaultTransform );
( (LIB_POLYLINE*) m_drawItem )->DeleteSegment( GetScreen()->GetCrossHairPosition( true ) );
......
......@@ -72,7 +72,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
if( m_drawItem == NULL || m_drawItem->Type() != LIB_PIN_T )
return;
int item_flags = m_drawItem->GetFlags(); // save flags to restore them after editing
STATUS_FLAGS item_flags = m_drawItem->GetFlags(); // save flags to restore them after editing
LIB_PIN* pin = (LIB_PIN*) m_drawItem;
DIALOG_LIB_EDIT_PIN dlg( this, pin );
......
......@@ -383,6 +383,7 @@ public:
///< already been edited, in some functions
#define EDA_ITEM_ALL_FLAGS -1
typedef unsigned STATUS_FLAGS;
/**
* Class EDA_ITEM
......@@ -399,7 +400,7 @@ private:
* functions.
*/
KICAD_T m_StructType;
int m_Status;
STATUS_FLAGS m_Status;
protected:
EDA_ITEM* Pnext; ///< next in linked list
......@@ -414,7 +415,7 @@ protected:
bool m_forceVisible;
/// Flag bits for editing and other uses.
int m_Flags;
STATUS_FLAGS m_Flags;
// Link to an copy of the item use to save the item's state for undo/redo feature.
EDA_ITEM* m_Image;
......@@ -475,12 +476,12 @@ public:
m_Status &= ~type;
}
int GetStatus() const { return m_Status; }
void SetStatus( int aStatus ) { m_Status = aStatus; }
STATUS_FLAGS GetStatus() const { return m_Status; }
void SetStatus( STATUS_FLAGS aStatus ) { m_Status = aStatus; }
void SetFlags( int aMask ) { m_Flags |= aMask; }
void ClearFlags( int aMask = EDA_ITEM_ALL_FLAGS ) { m_Flags &= ~aMask; }
int GetFlags() const { return m_Flags; }
void SetFlags( STATUS_FLAGS aMask ) { m_Flags |= aMask; }
void ClearFlags( STATUS_FLAGS aMask = EDA_ITEM_ALL_FLAGS ) { m_Flags &= ~aMask; }
STATUS_FLAGS GetFlags() const { return m_Flags; }
void SetImage( EDA_ITEM* aItem ) { m_Image = aItem; }
......
......@@ -81,7 +81,7 @@ enum UNDO_REDO_T {
class ITEM_PICKER
{
private:
int m_pickerFlags; /* a copy of m_Flags member. useful in mode/drag
STATUS_FLAGS m_pickerFlags; /* a copy of m_Flags member. useful in mode/drag
* undo/redo commands */
UNDO_REDO_T m_undoRedoStatus; /* type of operation to undo/redo for this item */
EDA_ITEM* m_pickedItem; /* Pointer on the schematic or board item that is concerned
......@@ -113,9 +113,9 @@ public:
UNDO_REDO_T GetStatus() { return m_undoRedoStatus; }
void SetFlags( int aFlags ) { m_pickerFlags = aFlags; }
void SetFlags( STATUS_FLAGS aFlags ) { m_pickerFlags = aFlags; }
int GetFlags() { return m_pickerFlags; }
STATUS_FLAGS GetFlags() const { return m_pickerFlags; }
void SetLink( EDA_ITEM* aItem ) { m_link = aItem; }
......@@ -231,7 +231,7 @@ public:
* @param aIdx Index of the picker in the picked list
* @return The value stored in the picker, if the picker exists, or 0 if does not exist
*/
int GetPickerFlags( unsigned aIdx );
STATUS_FLAGS GetPickerFlags( unsigned aIdx );
/**
* Function SetPickedItem
......@@ -275,7 +275,7 @@ public:
* @param aIdx Index of the picker in the picked list
* @return True if the picker exists or false if does not exist
*/
bool SetPickerFlags( int aFlags, unsigned aIdx );
bool SetPickerFlags( STATUS_FLAGS aFlags, unsigned aIdx );
/**
* Function RemovePicker
......
......@@ -273,9 +273,9 @@ bool TRACK::IsNull()
}
int TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
STATUS_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
{
int result = 0;
STATUS_FLAGS result = 0;
if( min_dist < 0 )
min_dist = m_Width / 2;
......@@ -1408,15 +1408,15 @@ int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace )
if( via )
{
layerMask |= via->ReturnMaskLayer();
via->SetState( BUSY, ON );
via->SetState( BUSY, true );
}
Track->SetState( BUSY, ON );
Track->SetState( BUSY, true );
segm = ::GetTrace( this, TrackListEnd, Track->m_Start, layerMask );
Track->SetState( BUSY, OFF );
Track->SetState( BUSY, false );
if( via )
via->SetState( BUSY, OFF );
via->SetState( BUSY, false );
if( segm == NULL )
{
......@@ -1434,13 +1434,13 @@ int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace )
BeginPad = Track->GetState( BEGIN_ONPAD );
EndPad = Track->GetState( END_ONPAD );
Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
Track->SetState( BEGIN_ONPAD | END_ONPAD, false );
if( BeginPad )
Track->SetState( END_ONPAD, ON );
Track->SetState( END_ONPAD, true );
if( EndPad )
Track->SetState( BEGIN_ONPAD, ON );
Track->SetState( BEGIN_ONPAD, true );
EXCHG( Track->m_Start, Track->m_End );
EXCHG( Track->start, Track->end );
......@@ -1455,15 +1455,15 @@ int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace )
if( via )
{
layerMask |= via->ReturnMaskLayer();
via->SetState( BUSY, ON );
via->SetState( BUSY, true );
}
Track->SetState( BUSY, ON );
Track->SetState( BUSY, true );
segm = ::GetTrace( this, TrackListEnd, Track->m_End, layerMask );
Track->SetState( BUSY, OFF );
Track->SetState( BUSY, false );
if( via )
via->SetState( BUSY, OFF );
via->SetState( BUSY, false );
if( segm == NULL )
{
......@@ -1478,13 +1478,13 @@ int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace )
BeginPad = Track->GetState( BEGIN_ONPAD );
EndPad = Track->GetState( END_ONPAD );
Track->SetState( BEGIN_ONPAD | END_ONPAD, OFF );
Track->SetState( BEGIN_ONPAD | END_ONPAD, false );
if( BeginPad )
Track->SetState( END_ONPAD, ON );
Track->SetState( END_ONPAD, true );
if( EndPad )
Track->SetState( BEGIN_ONPAD, ON );
Track->SetState( BEGIN_ONPAD, true );
EXCHG( Track->m_Start, Track->m_End );
EXCHG( Track->start, Track->end );
......@@ -1543,7 +1543,7 @@ void TRACK::Show( int nestLevel, std::ostream& os ) const
" layer=\"" << m_Layer << '"' <<
" width=\"" << m_Width << '"' <<
" flags=\"" << m_Flags << '"' <<
" status=\"" << GetState( -1 ) << '"' <<
" status=\"" << GetStatus( ) << '"' <<
// " drill=\"" << GetDrillValue() << '"' <<
" netcode=\"" << GetNet() << "\">" <<
......
......@@ -229,7 +229,7 @@ public:
* (dist = min_dist) both ends, or 0 if none of the above.
* if min_dist < 0: min_dist = track_width/2
*/
int IsPointOnEnds( const wxPoint& point, int min_dist = 0 );
STATUS_FLAGS IsPointOnEnds( const wxPoint& point, int min_dist = 0 );
/**
* Function IsNull
......
......@@ -139,7 +139,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( )
if( m_DelTracks->GetValue() )
{
int track_mask_filter = 0;
STATUS_FLAGS track_mask_filter = 0;
if( !m_TrackFilterLocked->GetValue() )
track_mask_filter |= TRACK_LOCKED;
......
......@@ -350,7 +350,7 @@ void Collect_TrackSegmentsToDrag( BOARD* aPcb, const wxPoint& aRefPos, int aLaye
if( track->IsDragging() )
continue; // already put in list
int flag = 0;
STATUS_FLAGS flag = 0;
int maxdist = std::max( aMaxDist, track->GetWidth() / 2 );
if( (track->GetFlags() & STARTPOINT) == 0 )
......
......@@ -1990,11 +1990,14 @@ void LEGACY_PLUGIN::loadTrackList( int aStructType )
int makeType;
time_t timeStamp;
int layer, type, flags, net_code;
int layer, type, net_code, flags_int;
// parse the 2nd line to determine the type of object
// e.g. "De 15 1 7 0 0" for a via
sscanf( line + SZ( "De" ), " %d %d %d %lX %X", &layer, &type, &net_code, &timeStamp, &flags );
sscanf( line + SZ( "De" ), " %d %d %d %lX %X", &layer, &type, &net_code,
&timeStamp, &flags_int );
STATUS_FLAGS flags;
flags = static_cast<STATUS_FLAGS>( flags_int );
if( aStructType==PCB_TRACE_T && type==1 )
makeType = PCB_VIA_T;
......
......@@ -253,7 +253,7 @@ bool FOOTPRINT_EDIT_FRAME::OnRightClick( const wxPoint& MousePos, wxMenu* PopMen
if( item )
{
int flags = item->GetFlags();
STATUS_FLAGS flags = item->GetFlags();
switch( item->Type() )
{
case PCB_MODULE_T:
......
......@@ -637,7 +637,7 @@ void PCB_EDIT_FRAME::StartMoveOneNodeOrSegment( TRACK* aTrack, wxDC* aDC, int aC
}
else
{
int diag = aTrack->IsPointOnEnds( GetScreen()->GetCrossHairPosition(), -1 );
STATUS_FLAGS diag = aTrack->IsPointOnEnds( GetScreen()->GetCrossHairPosition(), -1 );
wxPoint pos;
switch( aCommand )
......@@ -766,7 +766,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
if( TrackToStartPoint )
{
int flag = STARTPOINT;
STATUS_FLAGS flag = STARTPOINT;
if( track->GetStart() != TrackToStartPoint->GetStart() )
flag = ENDPOINT;
......@@ -777,7 +777,7 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC
if( TrackToEndPoint )
{
int flag = STARTPOINT;
STATUS_FLAGS flag = STARTPOINT;
if( track->GetEnd() != TrackToEndPoint->GetStart() )
flag = ENDPOINT;
......
......@@ -53,7 +53,7 @@ static wxMenu* Append_Track_Width_List( BOARD* aBoard );
bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu )
{
wxString msg;
int flags = 0;
STATUS_FLAGS flags = 0;
bool locate_track = false;
bool blockActive = !GetScreen()->m_BlockLocate.IsIdle();
......
......@@ -1282,7 +1282,7 @@ DRAWSEGMENT* PCB_PARSER::parseDRAWSEGMENT() throw( IO_ERROR, PARSE_ERROR )
break;
case T_status:
segment->SetStatus( parseHex() );
segment->SetStatus( static_cast<STATUS_FLAGS>( parseHex() ) );
break;
default:
......@@ -1966,7 +1966,7 @@ EDGE_MODULE* PCB_PARSER::parseEDGE_MODULE() throw( IO_ERROR, PARSE_ERROR )
break;
case T_status:
segment->SetStatus( parseHex() );
segment->SetStatus( static_cast<STATUS_FLAGS>( parseHex() ) );
break;
default:
......@@ -2263,7 +2263,7 @@ TRACK* PCB_PARSER::parseTRACK() throw( IO_ERROR, PARSE_ERROR )
break;
case T_status:
track->SetStatus( parseHex() );
track->SetStatus( static_cast<STATUS_FLAGS>( parseHex() ) );
break;
default:
......@@ -2343,7 +2343,7 @@ SEGVIA* PCB_PARSER::parseSEGVIA() throw( IO_ERROR, PARSE_ERROR )
break;
case T_status:
via->SetStatus( parseHex() );
via->SetStatus( static_cast<STATUS_FLAGS>( parseHex() ) );
NeedRIGHT();
break;
......
......@@ -41,7 +41,8 @@
#include <protos.h>
static void ListSetState( EDA_ITEM* Start, int NbItem, int State, int onoff );
static void ListSetState( EDA_ITEM* Start, int NbItem, STATUS_FLAGS State,
bool onoff );
void DrawTraces( EDA_DRAW_PANEL* panel, wxDC* DC, TRACK* aTrackList, int nbsegment,
......@@ -311,7 +312,8 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC,
/* Set the bits of .m_State member to on/off value, using bit mask State
* of a list of EDA_ITEM
*/
static void ListSetState( EDA_ITEM* Start, int NbItem, int State, int onoff )
static void ListSetState( EDA_ITEM* Start, int NbItem, STATUS_FLAGS State,
bool onoff )
{
for( ; (Start != NULL ) && ( NbItem > 0 ); NbItem--, Start = Start->Next() )
{
......
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