Break out eda_item_flags.h, fix the typedef to std::uint32_t, fix some signed vars

This commit is contained in:
Marek Roszko 2021-06-07 23:06:11 -04:00
parent cc4d38d347
commit 6e01ce84b9
14 changed files with 125 additions and 96 deletions

View File

@ -86,7 +86,7 @@ void DS_DATA_ITEM::SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aV
if( pensize == 0 )
pensize = aCollector ? aCollector->GetDefaultPenSize() : 0;
std::map<int, STATUS_FLAGS> itemFlags;
std::map<size_t, EDA_ITEM_FLAGS> itemFlags;
DS_DRAW_ITEM_BASE* item = nullptr;
for( size_t i = 0; i < m_drawItems.size(); ++i )
@ -105,7 +105,7 @@ void DS_DATA_ITEM::SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aV
m_drawItems.clear();
for( int j = 0; j < m_RepeatCount; j++ )
for( size_t j = 0; j < m_RepeatCount; j++ )
{
if( j && ! IsInsidePage( j ) )
continue;
@ -387,7 +387,7 @@ DS_DATA_ITEM_POLYGONS::DS_DATA_ITEM_POLYGONS() :
void DS_DATA_ITEM_POLYGONS::SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
{
std::map<int, STATUS_FLAGS> itemFlags;
std::map<int, EDA_ITEM_FLAGS> itemFlags;
DS_DRAW_ITEM_BASE* item = nullptr;
for( size_t i = 0; i < m_drawItems.size(); ++i )
@ -559,7 +559,7 @@ void DS_DATA_ITEM_TEXT::SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIE
if( m_Bold )
pensize = GetPenSizeForBold( std::min( textsize.x, textsize.y ) );
std::map<int, STATUS_FLAGS> itemFlags;
std::map<size_t, EDA_ITEM_FLAGS> itemFlags;
DS_DRAW_ITEM_TEXT* text = nullptr;
for( size_t i = 0; i < m_drawItems.size(); ++i )
@ -578,7 +578,7 @@ void DS_DATA_ITEM_TEXT::SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIE
m_drawItems.clear();
for( int j = 0; j < m_RepeatCount; ++j )
for( size_t j = 0; j < m_RepeatCount; ++j )
{
if( j > 0 && !IsInsidePage( j ) )
continue;
@ -715,7 +715,7 @@ void DS_DATA_ITEM_TEXT::SetConstrainedTextSize()
void DS_DATA_ITEM_BITMAP::SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::VIEW* aView )
{
std::map<int, STATUS_FLAGS> itemFlags;
std::map<size_t, EDA_ITEM_FLAGS> itemFlags;
DS_DRAW_ITEM_BASE* item = nullptr;
for( size_t i = 0; i < m_drawItems.size(); ++i )
@ -740,7 +740,7 @@ void DS_DATA_ITEM_BITMAP::SyncDrawItems( DS_DRAW_ITEM_LIST* aCollector, KIGFX::V
m_drawItems.clear();
for( int j = 0; j < m_RepeatCount; j++ )
for( size_t j = 0; j < m_RepeatCount; j++ )
{
if( j && !IsInsidePage( j ) )
continue;

View File

@ -42,7 +42,7 @@ ORIGIN_VIEWITEM::ORIGIN_VIEWITEM( const COLOR4D& aColor, MARKER_STYLE aStyle, in
}
ORIGIN_VIEWITEM::ORIGIN_VIEWITEM( const VECTOR2D& aPosition, STATUS_FLAGS flags ) :
ORIGIN_VIEWITEM::ORIGIN_VIEWITEM( const VECTOR2D& aPosition, EDA_ITEM_FLAGS flags ) :
EDA_ITEM( nullptr, NOT_USED ), // this item is never added to a BOARD/SCHEMATIC so it needs no type
m_position( aPosition ),
m_size( NOT_USED ),

View File

@ -199,7 +199,7 @@ UNDO_REDO PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx ) const
}
STATUS_FLAGS PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx ) const
EDA_ITEM_FLAGS PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx ) const
{
if( aIdx < m_ItemsList.size() )
return m_ItemsList[aIdx].GetFlags();
@ -257,7 +257,7 @@ bool PICKED_ITEMS_LIST::SetPickedItemStatus( UNDO_REDO aStatus, unsigned aIdx )
}
bool PICKED_ITEMS_LIST::SetPickerFlags( STATUS_FLAGS aFlags, unsigned aIdx )
bool PICKED_ITEMS_LIST::SetPickerFlags( EDA_ITEM_FLAGS aFlags, unsigned aIdx )
{
if( aIdx < m_ItemsList.size() )
{

View File

@ -617,7 +617,7 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow()
GetParent()->SaveCopyInUndoList( currentScreen, m_comp, UNDO_REDO::CHANGED, false );
// Save current flags which could be modified by next change settings
STATUS_FLAGS flags = m_comp->GetFlags();
EDA_ITEM_FLAGS flags = m_comp->GetFlags();
// For symbols with multiple shapes (De Morgan representation) Set the selected shape:
if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() )

View File

@ -210,7 +210,7 @@ void SCH_EDIT_FRAME::SelectUnit( SCH_COMPONENT* aSymbol, int aUnit )
if( aUnit > unitCount )
aUnit = unitCount;
STATUS_FLAGS savedFlags = aSymbol->GetFlags();
EDA_ITEM_FLAGS savedFlags = aSymbol->GetFlags();
if( !aSymbol->GetEditFlags() ) // No command in progress: save in undo list
SaveCopyInUndoList( GetScreen(), aSymbol, UNDO_REDO::CHANGED, false );
@ -251,7 +251,7 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* aSymbol )
return;
}
STATUS_FLAGS savedFlags = aSymbol->GetFlags();
EDA_ITEM_FLAGS savedFlags = aSymbol->GetFlags();
aSymbol->SetConvert( aSymbol->GetConvert() + 1 );

View File

@ -30,6 +30,7 @@
#include <deque>
#include <core/typeinfo.h>
#include <eda_item_flags.h>
#include <view/view_item.h>
#include <kiid.h>
@ -63,7 +64,6 @@ enum FIND_REPLACE_FLAGS
class wxFindReplaceData;
class EDA_ITEM;
class EDA_DRAW_FRAME;
class EDA_RECT;
class MSG_PANEL_ITEM;
@ -94,55 +94,6 @@ typedef std::function< SEARCH_RESULT ( EDA_ITEM* aItem, void* aTestData ) > INSP
typedef const INSPECTOR_FUNC& INSPECTOR;
// These define are used for the .m_flags and .m_UndoRedoStatus member of the
// class EDA_ITEM
//
// NB: DO NOT ADD FLAGS ANYWHERE BUT AT THE END: THE FLAG-SET IS STORED AS AN INTEGER IN FILES.
//
#define IS_CHANGED (1 << 0) ///< Item was edited, and modified
#define IS_LINKED (1 << 1) ///< Used in calculation to mark linked items (temporary use)
#define IN_EDIT (1 << 2) ///< Item currently edited
#define IS_MOVING (1 << 3) ///< Item being moved
#define IS_NEW (1 << 4) ///< New item, just created
#define IS_RESIZING (1 << 5) ///< Item being resized
#define IS_DRAGGING (1 << 6) ///< Item being dragged
#define IS_DELETED (1 << 7)
#define IS_WIRE_IMAGE (1 << 8) ///< Item to be drawn as wireframe while editing
#define STARTPOINT (1 << 9) ///< When a line is selected, these flags indicate which
#define ENDPOINT (1 << 10) ///< ends. (Used to support dragging.)
#define SELECTED (1 << 11)
#define TEMP_SELECTED (1 << 12) ///< flag indicating that the structure has already selected
#define STRUCT_DELETED (1 << 13) ///< flag indication structures to be erased
#define CANDIDATE (1 << 14) ///< flag indicating that the structure is connected
#define SKIP_STRUCT (1 << 15) ///< flag indicating that the structure should be ignored
#define DO_NOT_DRAW (1 << 16) ///< Used to disable draw function
#define IS_PASTED (1 << 17) ///< Modifier on IS_NEW which indicates it came from clipboard
#define LOCKED (1 << 18) ///< Pcbnew: locked from movement and deletion
///< NB: stored in m_status flags, NOT m_flags.
#define UNUSED (1 << 19)
#define MALFORMED_F_COURTYARD (1 << 20)
#define MALFORMED_B_COURTYARD (1 << 21)
#define MALFORMED_COURTYARDS ( MALFORMED_F_COURTYARD | MALFORMED_B_COURTYARD )
#define BEGIN_ONPAD (1 << 22) ///< Pcbnew: flag set for track segment starting on a pad
#define END_ONPAD (1 << 23) ///< Pcbnew: flag set for track segment ending on a pad
#define HOLE_PROXY (1 << 24) ///< Indicates the BOARD_ITEM is a proxy for its hole
#define IS_ROLLOVER (1 << 25) ///< Rollover active. Used for hyperlink highlighting.
#define BRIGHTENED (1 << 26) ///< item is drawn with a bright contour
#define DP_COUPLED (1 << 27) ///< item is coupled with another item making a differential pair
///< (applies to segments only)
#define UR_TRANSIENT (1 << 28) ///< indicates the item is owned by the undo/redo stack
#define IS_DANGLING (1 << 29) ///< indicates a pin is dangling
#define ENTERED (1 << 30) ///< indicates a group has been entered
// WARNING: if you add flags, you'll probably need to adjust the masks in GetEditFlags() and
// ClearTempFlags().
#define EDA_ITEM_ALL_FLAGS -1
typedef unsigned STATUS_FLAGS;
/**
* A base class for most all the KiCad significant classes used in schematics and boards.
*/
@ -183,12 +134,12 @@ public:
void SetModified();
int GetState( int type ) const
int GetState( EDA_ITEM_FLAGS type ) const
{
return m_status & type;
}
void SetState( int type, bool state )
void SetState( EDA_ITEM_FLAGS type, bool state )
{
if( state )
m_status |= type; // state = ON or OFF
@ -196,15 +147,15 @@ public:
m_status &= ~type;
}
STATUS_FLAGS GetStatus() const { return m_status; }
void SetStatus( STATUS_FLAGS aStatus ) { m_status = aStatus; }
EDA_ITEM_FLAGS GetStatus() const { return m_status; }
void SetStatus( EDA_ITEM_FLAGS aStatus ) { m_status = aStatus; }
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; }
bool HasFlag( STATUS_FLAGS aFlag ) const { return ( m_flags & aFlag ) == aFlag; }
void SetFlags( EDA_ITEM_FLAGS aMask ) { m_flags |= aMask; }
void ClearFlags( EDA_ITEM_FLAGS aMask = EDA_ITEM_ALL_FLAGS ) { m_flags &= ~aMask; }
EDA_ITEM_FLAGS GetFlags() const { return m_flags; }
bool HasFlag( EDA_ITEM_FLAGS aFlag ) const { return ( m_flags & aFlag ) == aFlag; }
STATUS_FLAGS GetEditFlags() const
EDA_ITEM_FLAGS GetEditFlags() const
{
constexpr int mask = ( IS_NEW | IS_PASTED | IS_MOVING | IS_RESIZING | IS_DRAGGING
| IS_WIRE_IMAGE | STRUCT_DELETED );
@ -524,10 +475,10 @@ public:
const KIID m_Uuid;
protected:
STATUS_FLAGS m_status;
EDA_ITEM* m_parent; ///< Linked list: Link (parent struct)
bool m_forceVisible;
STATUS_FLAGS m_flags;
EDA_ITEM_FLAGS m_status;
EDA_ITEM* m_parent; ///< Linked list: Link (parent struct)
bool m_forceVisible;
EDA_ITEM_FLAGS m_flags;
private:
/**

79
include/eda_item_flags.h Normal file
View File

@ -0,0 +1,79 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef EDA_ITEM_FLAGS_H
#define EDA_ITEM_FLAGS_H
// These define are used for the .m_flags and .m_UndoRedoStatus member of the
// class EDA_ITEM
//
// NB: DO NOT ADD FLAGS ANYWHERE BUT AT THE END: THE FLAG-SET IS STORED AS AN INTEGER IN FILES.
//
#define IS_CHANGED (1 << 0) ///< Item was edited, and modified
#define IS_LINKED (1 << 1) ///< Used in calculation to mark linked items (temporary use)
#define IN_EDIT (1 << 2) ///< Item currently edited
#define IS_MOVING (1 << 3) ///< Item being moved
#define IS_NEW (1 << 4) ///< New item, just created
#define IS_RESIZING (1 << 5) ///< Item being resized
#define IS_DRAGGING (1 << 6) ///< Item being dragged
#define IS_DELETED (1 << 7)
#define IS_WIRE_IMAGE (1 << 8) ///< Item to be drawn as wireframe while editing
#define STARTPOINT (1 << 9) ///< When a line is selected, these flags indicate which
#define ENDPOINT (1 << 10) ///< ends. (Used to support dragging.)
#define SELECTED (1 << 11)
#define TEMP_SELECTED (1 << 12) ///< flag indicating that the structure has already selected
#define STRUCT_DELETED (1 << 13) ///< flag indication structures to be erased
#define CANDIDATE (1 << 14) ///< flag indicating that the structure is connected
#define SKIP_STRUCT (1 << 15) ///< flag indicating that the structure should be ignored
#define DO_NOT_DRAW (1 << 16) ///< Used to disable draw function
#define IS_PASTED (1 << 17) ///< Modifier on IS_NEW which indicates it came from clipboard
#define LOCKED (1 << 18) ///< Pcbnew: locked from movement and deletion
///< NB: stored in m_status flags, NOT m_flags.
#define UNUSED (1 << 19)
#define MALFORMED_F_COURTYARD (1 << 20)
#define MALFORMED_B_COURTYARD (1 << 21)
#define MALFORMED_COURTYARDS ( MALFORMED_F_COURTYARD | MALFORMED_B_COURTYARD )
#define BEGIN_ONPAD (1 << 22) ///< Pcbnew: flag set for track segment starting on a pad
#define END_ONPAD (1 << 23) ///< Pcbnew: flag set for track segment ending on a pad
#define HOLE_PROXY (1 << 24) ///< Indicates the BOARD_ITEM is a proxy for its hole
#define IS_ROLLOVER (1 << 25) ///< Rollover active. Used for hyperlink highlighting.
#define BRIGHTENED (1 << 26) ///< item is drawn with a bright contour
#define DP_COUPLED (1 << 27) ///< item is coupled with another item making a differential pair
///< (applies to segments only)
#define UR_TRANSIENT (1 << 28) ///< indicates the item is owned by the undo/redo stack
#define IS_DANGLING (1 << 29) ///< indicates a pin is dangling
#define ENTERED (1 << 30) ///< indicates a group has been entered
// WARNING: if you add flags, you'll probably need to adjust the masks in GetEditFlags() and
// ClearTempFlags().
#define EDA_ITEM_ALL_FLAGS UINT32_MAX
typedef std::uint32_t EDA_ITEM_FLAGS;
#endif

View File

@ -51,7 +51,7 @@ public:
MARKER_STYLE aStyle = CIRCLE_X, int aSize = 16,
const VECTOR2D& aPosition = VECTOR2D( 0, 0 ) );
ORIGIN_VIEWITEM( const VECTOR2D& aPosition, STATUS_FLAGS flags );
ORIGIN_VIEWITEM( const VECTOR2D& aPosition, EDA_ITEM_FLAGS flags );
ORIGIN_VIEWITEM* Clone() const override;

View File

@ -27,14 +27,13 @@
#define _CLASS_UNDOREDO_CONTAINER_H
#include <core/typeinfo.h>
#include <eda_item_flags.h>
#include <vector>
class EDA_ITEM;
class PICKED_ITEMS_LIST;
class BASE_SCREEN;
// forward declaration to avoid eda_item.h for now
typedef unsigned STATUS_FLAGS;
/**
* Undo Redo considerations:
@ -92,9 +91,9 @@ public:
UNDO_REDO GetStatus() const { return m_undoRedoStatus; }
void SetFlags( STATUS_FLAGS aFlags ) { m_pickerFlags = aFlags; }
void SetFlags( EDA_ITEM_FLAGS aFlags ) { m_pickerFlags = aFlags; }
STATUS_FLAGS GetFlags() const { return m_pickerFlags; }
EDA_ITEM_FLAGS GetFlags() const { return m_pickerFlags; }
void SetLink( EDA_ITEM* aItem ) { m_link = aItem; }
@ -103,7 +102,7 @@ public:
BASE_SCREEN* GetScreen() const { return m_screen; }
private:
STATUS_FLAGS m_pickerFlags; /* a copy of m_flags member. useful in mode/drag
EDA_ITEM_FLAGS m_pickerFlags; /* a copy of m_flags member. useful in mode/drag
* undo/redo commands */
UNDO_REDO 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
@ -227,7 +226,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.
*/
STATUS_FLAGS GetPickerFlags( unsigned aIdx ) const;
EDA_ITEM_FLAGS GetPickerFlags( unsigned aIdx ) const;
/**
* @param aItem A pointer to the item to pick.
@ -269,7 +268,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( STATUS_FLAGS aFlags, unsigned aIdx );
bool SetPickerFlags( EDA_ITEM_FLAGS aFlags, unsigned aIdx );
/**
* Remove one entry (one picker) from the list of picked items.

View File

@ -2454,7 +2454,7 @@ PCB_SHAPE* PCB_PARSER::parsePCB_SHAPE()
// We continue to parse the status field but it is no longer written
case T_status:
shape->SetStatus( static_cast<STATUS_FLAGS>( parseHex() ) );
shape->SetStatus( static_cast<EDA_ITEM_FLAGS>( parseHex() ) );
NeedRIGHT();
break;
@ -3705,7 +3705,7 @@ FP_SHAPE* PCB_PARSER::parseFP_SHAPE()
// We continue to parse the status field but it is no longer written
case T_status:
shape->SetStatus( static_cast<STATUS_FLAGS>( parseHex() ) );
shape->SetStatus( static_cast<EDA_ITEM_FLAGS>( parseHex() ) );
NeedRIGHT();
break;
@ -4429,7 +4429,7 @@ ARC* PCB_PARSER::parseARC()
// We continue to parse the status field but it is no longer written
case T_status:
arc->SetStatus( static_cast<STATUS_FLAGS>( parseHex() ) );
arc->SetStatus( static_cast<EDA_ITEM_FLAGS>( parseHex() ) );
break;
// Continue to process "(locked)" format which was output during 5.99 development
@ -4507,7 +4507,7 @@ TRACK* PCB_PARSER::parseTRACK()
// We continue to parse the status field but it is no longer written
case T_status:
track->SetStatus( static_cast<STATUS_FLAGS>( parseHex() ) );
track->SetStatus( static_cast<EDA_ITEM_FLAGS>( parseHex() ) );
break;
// Continue to process "(locked)" format which was output during 5.99 development
@ -4620,7 +4620,7 @@ VIA* PCB_PARSER::parseVIA()
// We continue to parse the status field but it is no longer written
case T_status:
via->SetStatus( static_cast<STATUS_FLAGS>( parseHex() ) );
via->SetStatus( static_cast<EDA_ITEM_FLAGS>( parseHex() ) );
NeedRIGHT();
break;

View File

@ -1973,8 +1973,8 @@ void LEGACY_PLUGIN::loadPCB_LINE()
const_cast<KIID&>( dseg->m_Uuid ) = KIID( data );
break;
case 4:
STATUS_FLAGS state;
state = static_cast<STATUS_FLAGS>( hexParse( data ) );
EDA_ITEM_FLAGS state;
state = static_cast<EDA_ITEM_FLAGS>( hexParse( data ) );
dseg->SetState( state, true );
break;
@ -2249,7 +2249,7 @@ void LEGACY_PLUGIN::loadTrackList( int aStructType )
char* uuid = strtok_r( (char*) data, delims, (char**) &data );
int flags_int = intParse( data, (const char**) &data );
STATUS_FLAGS flags = static_cast<STATUS_FLAGS>( flags_int );
EDA_ITEM_FLAGS flags = static_cast<EDA_ITEM_FLAGS>( flags_int );
if( aStructType == PCB_TRACE_T )
{

View File

@ -1504,7 +1504,7 @@ void ROUTER_TOOL::NeighboringSegmentFilter( const VECTOR2I& aPt, GENERAL_COLLECT
int refNet = reference->GetNetCode();
wxPoint refPoint( aPt.x, aPt.y );
STATUS_FLAGS flags = reference->IsPointOnEnds( refPoint, -1 );
EDA_ITEM_FLAGS flags = reference->IsPointOnEnds( refPoint, -1 );
if( flags & STARTPOINT )
refPoint = reference->GetStart();

View File

@ -204,9 +204,9 @@ int VIA::GetDrillValue() const
}
STATUS_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) const
EDA_ITEM_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) const
{
STATUS_FLAGS result = 0;
EDA_ITEM_FLAGS result = 0;
if( min_dist < 0 )
min_dist = m_Width / 2;

View File

@ -159,7 +159,7 @@ public:
* (dist = min_dist) both ends, or 0 if none of the above.
* if min_dist < 0: min_dist = track_width/2
*/
STATUS_FLAGS IsPointOnEnds( const wxPoint& point, int min_dist = 0 ) const;
EDA_ITEM_FLAGS IsPointOnEnds( const wxPoint& point, int min_dist = 0 ) const;
/**
* Function IsNull