Flags cleanup.

Remove extraneous use of FLAG0 from tracks cleaner (it was checked but
never set).

Fix issue in expand connections where two parts of it couldn't agree
on the same flag (BUSY vs SKIP_STRUCT), and where the second part was
clearing the flag instead of setting it.

Remove obsolete HIGHLIGHT infrastructure (we now use selection).

Remove extraneous use of BUSY flag in several places (it was never
set).
This commit is contained in:
Jeff Young 2020-06-27 17:06:01 +01:00
parent da2b7071b4
commit 32c3ea4edd
21 changed files with 47 additions and 208 deletions

View File

@ -33,7 +33,6 @@ RENDER_SETTINGS::RENDER_SETTINGS() :
// Set the default initial values
m_highlightFactor = 0.5f;
m_selectFactor = 0.5f;
m_highlightItems = false;
m_highlightEnabled = false;
m_hiContrastEnabled = false;
m_hiContrastFactor = 0.2f; //TODO: Make this user-configurable

View File

@ -182,12 +182,7 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
if( strcmp( idcmd, "$CLEAR:" ) == 0 )
{
if( text && strcmp( text, "HIGHLIGHTED" ) == 0 )
{
GetCanvas()->GetView()->HighlightItem( nullptr, nullptr );
GetCanvas()->Refresh();
}
// Cross-probing is now done through selection so we no longer need a clear command
return;
}

View File

@ -821,10 +821,6 @@ DIALOG_FIELDS_EDITOR_GLOBAL::~DIALOG_FIELDS_EDITOR_GLOBAL()
m_grid->PopEventHandler( true );
// we gave ownership of m_dataModel to the wxGrid...
// Clear highlighted symbols, if any
m_parent->GetCanvas()->GetView()->HighlightItem( nullptr, nullptr );
m_parent->GetCanvas()->Refresh();
}
@ -1130,10 +1126,6 @@ void DIALOG_FIELDS_EDITOR_GLOBAL::OnTableCellClick( wxGridEvent& event )
m_grid->ClearSelection();
m_grid->SetGridCursor( event.GetRow(), event.GetCol() );
// Clear highlighted symbols, if any
m_parent->GetCanvas()->GetView()->HighlightItem( nullptr, nullptr );
m_parent->GetCanvas()->Refresh();
m_dataModel->ExpandCollapseRow( event.GetRow() );
std::vector<SCH_REFERENCE> refs = m_dataModel->GetRowReferences( event.GetRow() );

View File

@ -1756,58 +1756,3 @@ void SCH_COMPONENT::BrightenPin( LIB_PIN* aPin )
}
void SCH_COMPONENT::ClearHighlightedPins()
{
for( auto& pin : m_pins )
pin->ClearHighlighted();
}
bool SCH_COMPONENT::HasHighlightedPins()
{
for( const auto& pin : m_pins )
{
if( pin->IsHighlighted() )
return true;
}
return false;
}
void SCH_COMPONENT::HighlightPin( LIB_PIN* aPin )
{
if( m_pinMap.count( aPin ) )
m_pins[ m_pinMap.at( aPin ) ]->SetHighlighted();
}
bool SCH_COMPONENT::ClearAllHighlightFlags()
{
bool retVal = false;
if( IsHighlighted() )
{
ClearFlags( HIGHLIGHTED );
retVal = true;
}
// Clear the HIGHLIGHTED flag of pins
if( HasHighlightedPins() )
{
ClearHighlightedPins();
retVal = true;
}
// Clear the HIGHLIGHTED flag of other items, currently only fields
for( SCH_FIELD& each_field : m_Fields )
{
if( each_field.IsHighlighted() )
{
each_field.ClearFlags( HIGHLIGHTED );
retVal = true;
}
}
return retVal;
}

View File

@ -674,12 +674,6 @@ public:
void BrightenPin( LIB_PIN* aPin );
void ClearHighlightedPins();
bool HasHighlightedPins();
void HighlightPin( LIB_PIN* aPin );
bool GetIncludeInBom() const { return m_inBom; }
void SetIncludeInBom( bool aIncludeInBom ) { m_inBom = aIncludeInBom; }

View File

@ -82,17 +82,17 @@ SCH_ITEM* SCH_ITEM::Duplicate( bool doClone ) const
if( !doClone )
const_cast<KIID&>( newItem->m_Uuid ) = KIID();
newItem->ClearFlags( SELECTED | HIGHLIGHTED | BRIGHTENED );
newItem->ClearFlags( SELECTED | BRIGHTENED );
if( newItem->Type() == SCH_COMPONENT_T )
{
SCH_COMPONENT* component = (SCH_COMPONENT*) newItem;
for( SCH_PIN* pin : component->GetSchPins() )
pin->ClearFlags( SELECTED | HIGHLIGHTED | BRIGHTENED );
pin->ClearFlags( SELECTED | BRIGHTENED );
for( SCH_FIELD& field : component->GetFields() )
field.ClearFlags( SELECTED | HIGHLIGHTED | BRIGHTENED );
field.ClearFlags( SELECTED | BRIGHTENED );
}
if( newItem->Type() == SCH_SHEET_T )
@ -100,10 +100,10 @@ SCH_ITEM* SCH_ITEM::Duplicate( bool doClone ) const
SCH_SHEET* sheet = (SCH_SHEET*) newItem;
for( SCH_FIELD& field : sheet->GetFields() )
field.ClearFlags( SELECTED | HIGHLIGHTED | BRIGHTENED );
field.ClearFlags( SELECTED | BRIGHTENED );
for( SCH_SHEET_PIN* pin : sheet->GetPins() )
pin->ClearFlags( SELECTED | HIGHLIGHTED | BRIGHTENED );
pin->ClearFlags( SELECTED | BRIGHTENED );
}
return newItem;

View File

@ -1783,7 +1783,7 @@ void SCH_PAINTER::draw( SCH_BITMAP *aBitmap, int aLayer )
if( aLayer == LAYER_SELECTION_SHADOWS )
{
if( aBitmap->IsSelected() || aBitmap->IsBrightened() || aBitmap->IsHighlighted() )
if( aBitmap->IsSelected() || aBitmap->IsBrightened() )
{
COLOR4D color = getRenderColor( aBitmap, LAYER_DRAW_BITMAPS, true );
m_gal->SetIsStroke( true );

View File

@ -225,42 +225,4 @@ void SCH_VIEW::HideWorksheet()
}
void SCH_VIEW::HighlightItem( EDA_ITEM *aItem, LIB_PIN* aPin )
{
if( aItem && aItem->Type() == SCH_COMPONENT_T && aPin )
{
static_cast<SCH_COMPONENT*>( aItem )->HighlightPin( aPin );
Update( aItem, REPAINT );
}
else if( aItem )
{
aItem->SetFlags( HIGHLIGHTED );
Update( aItem, REPAINT );
}
else
{
for( auto item : *m_allItems )
{
// Not all view items can be highlighted, only EDA_ITEMs
// So clear flag of only EDA_ITEMs.
EDA_ITEM* eitem = dynamic_cast<EDA_ITEM*>( item );
if( eitem )
{
if( eitem->IsHighlighted() )
{
eitem->ClearFlags( HIGHLIGHTED );
Update( eitem, REPAINT );
}
if( eitem->Type() == SCH_COMPONENT_T )
{
// Items inside a component (pins, fields can be highlighted.
static_cast<SCH_COMPONENT*>( eitem )->ClearAllHighlightFlags();
}
}
}
}
}
}; // namespace KIGFX

View File

@ -100,8 +100,6 @@ public:
WS_PROXY_VIEW_ITEM* GetWorksheet() const { return m_worksheet.get(); }
void HighlightItem( EDA_ITEM *aItem, LIB_PIN* aPin = nullptr );
private:
SCH_BASE_FRAME* m_frame; // The frame using this view. Can be null. Used mainly
// to know the sheet path name when drawing the page layout

View File

@ -130,13 +130,12 @@ typedef const INSPECTOR_FUNC& INSPECTOR; /// std::function passed to nested u
#define IS_PASTED (1 << 17) ///< Modifier on IS_NEW which indicates it came from clipboard
#define TRACK_LOCKED (1 << 18) ///< Pcbnew: track locked: protected from global deletion
#define TRACK_AR (1 << 19) ///< Pcbnew: autorouted track
#define FLAG1 (1 << 20) ///< Pcbnew: flag used in local computations
#define FLAG0 (1 << 21) ///< Pcbnew: flag used in local computations
#define OBSOLETE_1 (1 << 20) ///< Not presently used
#define OBSOLETE_2 (1 << 21) ///< Not presently used
#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 BUSY (1 << 24) ///< Pcbnew: flag indicating that the structure has
///< already been edited, in some functions
#define HIGHLIGHTED (1 << 25) ///< item is drawn in normal colors, when the rest is darkened
#define OBSOLETE_3 (1 << 24) ///< Not presently used
#define OBSOLETE_4 (1 << 25) ///< Not presently used
#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
@ -148,9 +147,6 @@ typedef const INSPECTOR_FUNC& INSPECTOR; /// std::function passed to nested u
// WARNING: if you add flags, you'll probably need to adjust the masks in GetEditFlags() and
// ClearTempFlags().
// NOTE: The HIGHLIGHTED flag is basically deprecated, it was used for cross-probing before eeschema
// supported real object selection.
#define EDA_ITEM_ALL_FLAGS -1
typedef unsigned STATUS_FLAGS;
@ -206,16 +202,13 @@ public:
inline bool IsWireImage() const { return m_Flags & IS_WIRE_IMAGE; }
inline bool IsSelected() const { return m_Flags & SELECTED; }
inline bool IsResized() const { return m_Flags & IS_RESIZED; }
inline bool IsHighlighted() const { return m_Flags & HIGHLIGHTED; }
inline bool IsBrightened() const { return m_Flags & BRIGHTENED; }
inline void SetWireImage() { SetFlags( IS_WIRE_IMAGE ); }
inline void SetSelected() { SetFlags( SELECTED ); }
inline void SetHighlighted() { SetFlags( HIGHLIGHTED ); }
inline void SetBrightened() { SetFlags( BRIGHTENED ); }
inline void ClearSelected() { ClearFlags( SELECTED ); }
inline void ClearHighlighted() { ClearFlags( HIGHLIGHTED ); }
inline void ClearBrightened() { ClearFlags( BRIGHTENED ); }
void SetModified();
@ -252,7 +245,7 @@ public:
void ClearTempFlags()
{
ClearFlags( STARTPOINT | ENDPOINT | CANDIDATE | TEMP_SELECTED | IS_LINKED | SKIP_STRUCT |
DO_NOT_DRAW | FLAG0 | FLAG1 | BUSY );
DO_NOT_DRAW );
}
void ClearEditFlags()

View File

@ -123,14 +123,12 @@ public:
/**
* Function SetHighlight
* Turns on/off highlighting - it may be done for the active layer, the specified net, or
* items with their HIGHLIGHTED flags set.
* Turns on/off highlighting - it may be done for the active layer or the specified net(s).
* @param aEnabled tells if highlighting should be enabled.
* @param aNetcode is optional and if specified, turns on higlighting only for the net with
* number given as the parameter.
*/
inline void SetHighlight( bool aEnabled, int aNetcode = -1, bool aHighlightItems = false,
bool aMulti = false )
inline void SetHighlight( bool aEnabled, int aNetcode = -1, bool aMulti = false )
{
m_highlightEnabled = aEnabled;
@ -143,8 +141,6 @@ public:
}
else
m_highlightNetcodes.clear();
m_highlightItems = aEnabled ? aHighlightItems : false;
}
/**
@ -261,10 +257,7 @@ protected:
float m_hiContrastFactor; // Factor used for computing high contrast color
bool m_highlightEnabled; // Highlight display mode on/off
std::set<int> m_highlightNetcodes; // Set of net cods to be highlighted
bool m_highlightItems; // Highlight items with their HIGHLIGHT flags set
float m_highlightFactor; // Factor used for computing highlight color
float m_selectFactor; // Specifies how color of selected items is changed

View File

@ -1226,8 +1226,8 @@ int BOARD::SortedNetnamesList( wxArrayString& aNames, bool aSortbyPadsCount )
}
ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer, int aNetCode )
ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos, PCB_LAYER_ID aStartLayer,
PCB_LAYER_ID aEndLayer, int aNetCode )
{
if( aEndLayer < 0 )
aEndLayer = aStartLayer;
@ -1240,10 +1240,6 @@ ZONE_CONTAINER* BOARD::HitTestForAnyFilledArea( const wxPoint& aRefPos,
if( area->GetLayer() < aStartLayer || area->GetLayer() > aEndLayer )
continue;
// In locate functions we must skip tagged items with BUSY flag set.
if( area->GetState( BUSY ) )
continue;
if( aNetCode >= 0 && area->GetNetCode() != aNetCode )
continue;

View File

@ -859,7 +859,6 @@ public:
* Function HitTestForAnyFilledArea
* tests if the given wxPoint is within the bounds of a filled area of this zone.
* the test is made on zones on layer from aStartLayer to aEndLayer
* Note: if a zone has its flag BUSY (in .m_State) is set, it is ignored.
* @param aRefPos A wxPoint to test
* @param aStartLayer the first layer to test
* @param aEndLayer the last layer to test

View File

@ -972,21 +972,12 @@ wxString TRACK::ShowState( int stateBits )
if( stateBits & IS_DELETED )
ret << wxT( " | IS_DELETED" );
if( stateBits & BUSY )
ret << wxT( " | BUSY" );
if( stateBits & END_ONPAD )
ret << wxT( " | END_ONPAD" );
if( stateBits & BEGIN_ONPAD )
ret << wxT( " | BEGIN_ONPAD" );
if( stateBits & FLAG0 )
ret << wxT( " | FLAG0" );
if( stateBits & FLAG1 )
ret << wxT( " | FLAG1" );
return ret;
}

View File

@ -238,7 +238,7 @@ public:
/**
* Function ShowState
* converts a set of state bits to a wxString
* @param stateBits Is an OR-ed together set of bits like BUSY, EDIT, etc.
* @param stateBits Is an OR-ed together set of bits like IN_EDIT, etc.
*/
static wxString ShowState( int stateBits );

View File

@ -127,7 +127,7 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
else
{
pcb->SetHighLightNet( netinfo->GetNet(), true );
renderSettings->SetHighlight( true, netinfo->GetNet(), false, true );
renderSettings->SetHighlight( true, netinfo->GetNet(), true );
}
}
}

View File

@ -167,7 +167,7 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP
if( aPad )
{
*m_dummyPad = *aPad;
m_dummyPad->ClearFlags( SELECTED|HIGHLIGHTED|BRIGHTENED );
m_dummyPad->ClearFlags( SELECTED|BRIGHTENED );
}
else // We are editing a "master" pad, i.e. a template to create new pads
*m_dummyPad = *m_padMaster;

View File

@ -33,7 +33,6 @@
#include <class_marker_pcb.h>
#include <class_dimension.h>
#include <class_pcb_target.h>
#include <class_marker_pcb.h>
#include <layers_id_colors_and_visibility.h>
#include <pcb_painter.h>
@ -46,7 +45,6 @@
#include <geometry/shape_line_chain.h>
#include <geometry/shape_segment.h>
#include <geometry/shape_circle.h>
#include <geometry/shape_simple.h>
using namespace KIGFX;
@ -240,14 +238,6 @@ const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer
return m_layerColorsSel[aLayer];
}
if( m_highlightEnabled && m_highlightItems )
{
if( item->IsHighlighted() )
return m_layerColorsHi[aLayer];
else
return m_layerColorsDark[aLayer];
}
// Try to obtain the netcode for the item
if( const BOARD_CONNECTED_ITEM* conItem = dyn_cast<const BOARD_CONNECTED_ITEM*> ( item ) )
netCode = conItem->GetNetCode();
@ -762,15 +752,9 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
// Hole color is the background color for plated holes, but only if the pad size is greater than the hole size.
// ( Don't let pads that *should* be NPTH get lost )
if( ( aLayer == LAYER_PADS_PLATEDHOLES ) && !aPad->PadShouldBeNPTH() )
{
color = m_pcbSettings.GetBackgroundColor();
}
else
{
color = m_pcbSettings.GetColor( aPad, aLayer );
}
VECTOR2D size;
if( m_pcbSettings.m_sketchMode[LAYER_PADS_TH] )
{

View File

@ -733,9 +733,9 @@ static void moveNoFlagToVector( std::deque<T>& aList, std::vector<BOARD_ITEM*>&
std::copy_if( aList.begin(), aList.end(), std::back_inserter( aTarget ),
[aIsNew]( T aItem )
{
bool doCopy = ( aItem->GetFlags() & FLAG0 ) == 0;
bool doCopy = ( aItem->GetFlags() & SKIP_STRUCT ) == 0;
aItem->ClearFlags( FLAG0 );
aItem->ClearFlags( SKIP_STRUCT );
aItem->SetFlags( aIsNew ? IS_NEW : 0 );
return doCopy;
@ -746,7 +746,8 @@ static void moveNoFlagToVector( std::deque<T>& aList, std::vector<BOARD_ITEM*>&
}
static void moveNoFlagToVector( ZONE_CONTAINERS& aList, std::vector<BOARD_ITEM*>& aTarget, bool aIsNew )
static void moveNoFlagToVector( ZONE_CONTAINERS& aList, std::vector<BOARD_ITEM*>& aTarget,
bool aIsNew )
{
if( aList.size() == 0 )
return;
@ -762,8 +763,8 @@ static void moveNoFlagToVector( ZONE_CONTAINERS& aList, std::vector<BOARD_ITEM*
for( ; obj ; )
{
if( obj->HasFlag( FLAG0 ) )
obj->ClearFlags( FLAG0 );
if( obj->HasFlag( SKIP_STRUCT ) )
obj->ClearFlags( SKIP_STRUCT );
else
aTarget.push_back( obj );
@ -858,16 +859,16 @@ int PCBNEW_CONTROL::AppendBoard( PLUGIN& pi, wxString& fileName )
// Mark existing items, in order to know what are the new items so we can select only
// the new items after loading
for( auto track : brd->Tracks() )
track->SetFlags( FLAG0 );
track->SetFlags( SKIP_STRUCT );
for( auto module : brd->Modules() )
module->SetFlags( FLAG0 );
module->SetFlags( SKIP_STRUCT );
for( auto drawing : brd->Drawings() )
drawing->SetFlags( FLAG0 );
drawing->SetFlags( SKIP_STRUCT );
for( auto zone : brd->Zones() )
zone->SetFlags( FLAG0 );
zone->SetFlags( SKIP_STRUCT );
// Keep also the count of copper layers, to adjust if necessary
int initialCopperLayerCount = brd->GetCopperLayerCount();

View File

@ -819,16 +819,15 @@ int SELECTION_TOOL::expandConnection( const TOOL_EVENT& aEvent )
// copy the selection, since we're going to iterate and modify
std::deque<EDA_ITEM*> selectedItems = m_selection.GetItems();
// We use the BUSY flag to mark connections
for( EDA_ITEM* item : selectedItems )
item->SetState( BUSY, false );
item->ClearTempFlags();
for( EDA_ITEM* item : selectedItems )
{
TRACK* trackItem = dynamic_cast<TRACK*>( item );
// Track items marked BUSY have already been visited
if( trackItem && !trackItem->GetState( BUSY ) )
// Track items marked SKIP_STRUCT have already been visited
if( trackItem && !( trackItem->GetFlags() & SKIP_STRUCT ) )
selectConnectedTracks( *trackItem, stopCondition );
}
@ -884,7 +883,7 @@ void SELECTION_TOOL::selectConnectedTracks( BOARD_CONNECTED_ITEM& aStartItem,
break;
}
item->SetState( SKIP_STRUCT, false );
item->SetFlags( SKIP_STRUCT );
}
std::vector<wxPoint> activePts;

View File

@ -104,9 +104,7 @@ void TRACKS_CLEANER::removeBadTrackSegments()
for( TRACK* segment : m_brd->Tracks() )
{
segment->SetState( FLAG0, false );
for( auto testedPad : connectivity->GetConnectedPads( segment ) )
for( D_PAD* testedPad : connectivity->GetConnectedPads( segment ) )
{
if( segment->GetNetCode() != testedPad->GetNetCode() )
{
@ -120,7 +118,7 @@ void TRACKS_CLEANER::removeBadTrackSegments()
for( TRACK* testedTrack : connectivity->GetConnectedTracks( segment ) )
{
if( segment->GetNetCode() != testedTrack->GetNetCode() && !testedTrack->GetState( FLAG0 ) )
if( segment->GetNetCode() != testedTrack->GetNetCode() )
{
CLEANUP_ITEM* item = new CLEANUP_ITEM( CLEANUP_SHORT );
item->SetItems( segment );