mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 22:23:43 +00:00
Cleanup ViewGetLayers()
Old style c-array replaced with vector returns
This commit is contained in:
parent
838c3c2503
commit
9dfcb6a362
common
eeschema
sch_bitmap.cppsch_bitmap.hsch_bus_entry.cppsch_bus_entry.hsch_field.cppsch_field.hsch_item.cppsch_item.hsch_junction.cppsch_junction.hsch_label.cppsch_label.hsch_line.cppsch_line.hsch_marker.cppsch_marker.hsch_no_connect.cppsch_no_connect.hsch_painter.cppsch_pin.cppsch_pin.hsch_rule_area.cppsch_rule_area.hsch_shape.cppsch_shape.hsch_sheet.cppsch_sheet.hsch_table.cppsch_table.hsch_text.cppsch_text.hsymbol.cppsymbol.h
gerbview
include
board_item.h
drawing_sheet
eda_item.hlayer_range.horigin_viewitem.hpreview_items
anchor_debug.harc_assistant.hbezier_assistant.hconstruction_geom.hruler_item.hsimple_overlay_item.htwo_point_assistant.h
tool
view
pcbnew
board_item.cppfootprint.cppfootprint.h
generators
pad.cpppad.hpcb_group.cpppcb_group.hpcb_marker.cpppcb_marker.hpcb_reference_image.cpppcb_reference_image.hpcb_shape.cpppcb_shape.hpcb_text.cpppcb_text.hpcb_textbox.cpppcb_textbox.hpcb_track.cpppcb_track.hratsnest
router
zone.cppzone.hzone_manager
qa/tools/gal/gal_pixel_alignment
@ -69,24 +69,24 @@ const KIFONT::METRICS& DS_DRAW_ITEM_BASE::GetFontMetrics() const
|
||||
}
|
||||
|
||||
|
||||
void DS_DRAW_ITEM_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> DS_DRAW_ITEM_BASE::ViewGetLayers() const
|
||||
{
|
||||
aCount = 1;
|
||||
std::vector<int> layers( 1 );
|
||||
|
||||
DS_DATA_ITEM* dataItem = GetPeer();
|
||||
|
||||
if( !dataItem ) // No peer: this item is like a DS_DRAW_ITEM_PAGE
|
||||
if( m_peer == nullptr )
|
||||
{
|
||||
aLayers[0] = LAYER_DRAWINGSHEET;
|
||||
return;
|
||||
layers[0] = LAYER_DRAWINGSHEET;
|
||||
return layers;
|
||||
}
|
||||
|
||||
if( dataItem->GetPage1Option() == FIRST_PAGE_ONLY )
|
||||
aLayers[0] = LAYER_DRAWINGSHEET_PAGE1;
|
||||
else if( dataItem->GetPage1Option() == SUBSEQUENT_PAGES )
|
||||
aLayers[0] = LAYER_DRAWINGSHEET_PAGEn;
|
||||
if( m_peer->GetPage1Option() == FIRST_PAGE_ONLY )
|
||||
layers[0] = LAYER_DRAWINGSHEET_PAGE1;
|
||||
else if( m_peer->GetPage1Option() == SUBSEQUENT_PAGES )
|
||||
layers[0] = LAYER_DRAWINGSHEET_PAGEn;
|
||||
else
|
||||
aLayers[0] = LAYER_DRAWINGSHEET;
|
||||
layers[0] = LAYER_DRAWINGSHEET;
|
||||
|
||||
return layers;
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,10 +147,10 @@ void DS_PROXY_VIEW_ITEM::ViewDraw( int aLayer, VIEW* aView ) const
|
||||
}
|
||||
|
||||
|
||||
void DS_PROXY_VIEW_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> DS_PROXY_VIEW_ITEM::ViewGetLayers() const
|
||||
{
|
||||
aCount = 1;
|
||||
aLayers[0] = LAYER_DRAWINGSHEET;
|
||||
std::vector<int> layer{ LAYER_DRAWINGSHEET };
|
||||
return layer;
|
||||
}
|
||||
|
||||
|
||||
|
@ -280,11 +280,11 @@ const BOX2I EDA_ITEM::ViewBBox() const
|
||||
}
|
||||
|
||||
|
||||
void EDA_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> EDA_ITEM::ViewGetLayers() const
|
||||
{
|
||||
// Basic fallback
|
||||
aCount = 1;
|
||||
aLayers[0] = 0;
|
||||
std::vector<int> layers{ 1 };
|
||||
return layers;
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,10 +51,9 @@ const BOX2I ANCHOR_DEBUG::ViewBBox() const
|
||||
return bbox;
|
||||
}
|
||||
|
||||
void ANCHOR_DEBUG::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> ANCHOR_DEBUG::ViewGetLayers() const
|
||||
{
|
||||
aLayers[0] = LAYER_GP_OVERLAY;
|
||||
aCount = 1;
|
||||
return { LAYER_GP_OVERLAY };
|
||||
}
|
||||
|
||||
void ANCHOR_DEBUG::ClearAnchors()
|
||||
|
@ -157,8 +157,8 @@ void CONSTRUCTION_GEOM::ViewDraw( int aLayer, VIEW* aView ) const
|
||||
}
|
||||
}
|
||||
|
||||
void CONSTRUCTION_GEOM::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> CONSTRUCTION_GEOM::ViewGetLayers() const
|
||||
{
|
||||
aLayers[0] = LAYER_GP_OVERLAY;
|
||||
aCount = 1;
|
||||
std::vector<int> layers{ LAYER_GP_OVERLAY };
|
||||
return layers;
|
||||
}
|
@ -292,11 +292,10 @@ const BOX2I RULER_ITEM::ViewBBox() const
|
||||
}
|
||||
|
||||
|
||||
void RULER_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> RULER_ITEM::ViewGetLayers() const
|
||||
{
|
||||
aLayers[0] = LAYER_SELECT_OVERLAY;
|
||||
aLayers[1] = LAYER_GP_OVERLAY;
|
||||
aCount = 2;
|
||||
std::vector<int> layers{ LAYER_SELECT_OVERLAY, LAYER_GP_OVERLAY };
|
||||
return layers;
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,12 +48,10 @@ void SIMPLE_OVERLAY_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
|
||||
}
|
||||
|
||||
|
||||
void SIMPLE_OVERLAY_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> SIMPLE_OVERLAY_ITEM::ViewGetLayers() const
|
||||
{
|
||||
static const int SelectionLayer = LAYER_GP_OVERLAY;
|
||||
|
||||
aLayers[0] = SelectionLayer;
|
||||
aCount = 1;
|
||||
std::vector<int> aLayers{ LAYER_GP_OVERLAY };
|
||||
return aLayers;
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,22 +74,6 @@ public:
|
||||
private:
|
||||
friend class VIEW;
|
||||
|
||||
/**
|
||||
* Return layer numbers used by the item.
|
||||
*
|
||||
* @param aLayers[]: output layer index array
|
||||
* @param aCount: number of layer indices in aLayers[]
|
||||
*/
|
||||
void getLayers( int* aLayers, int& aCount ) const
|
||||
{
|
||||
int* layersPtr = aLayers;
|
||||
|
||||
for( int layer : m_layers )
|
||||
*layersPtr++ = layer;
|
||||
|
||||
aCount = m_layers.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return number of the group id for the given layer, or -1 in case it was not cached before.
|
||||
*
|
||||
@ -188,16 +172,15 @@ private:
|
||||
* @param aLayers is an array containing layer numbers to be saved.
|
||||
* @param aCount is the size of the array.
|
||||
*/
|
||||
void saveLayers( int* aLayers, int aCount )
|
||||
void saveLayers( const std::vector<int>& aLayers )
|
||||
{
|
||||
m_layers.clear();
|
||||
|
||||
for( int i = 0; i < aCount; ++i )
|
||||
for( int layer : aLayers )
|
||||
{
|
||||
// this fires on some eagle board after PCB_IO_EAGLE::Load()
|
||||
wxASSERT( unsigned( aLayers[i] ) <= unsigned( VIEW::VIEW_MAX_LAYERS ) );
|
||||
|
||||
m_layers.push_back( aLayers[i] );
|
||||
wxCHECK2_MSG( layer >= 0 && layer < VIEW::VIEW_MAX_LAYERS, continue,
|
||||
wxT( "Invalid layer number" ) );
|
||||
m_layers.push_back( layer );
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,8 +299,6 @@ VIEW::~VIEW()
|
||||
|
||||
void VIEW::Add( VIEW_ITEM* aItem, int aDrawPriority )
|
||||
{
|
||||
int layers[VIEW_MAX_LAYERS], layers_count;
|
||||
|
||||
if( aDrawPriority < 0 )
|
||||
aDrawPriority = m_nextDrawPriority++;
|
||||
|
||||
@ -334,17 +315,17 @@ void VIEW::Add( VIEW_ITEM* aItem, int aDrawPriority )
|
||||
aItem->m_viewPrivData->m_bbox = bbox;
|
||||
aItem->m_viewPrivData->m_cachedIndex = m_allItems->size();
|
||||
|
||||
aItem->ViewGetLayers( layers, layers_count );
|
||||
aItem->viewPrivData()->saveLayers( layers, layers_count );
|
||||
std::vector<int> layers = aItem->ViewGetLayers();
|
||||
aItem->viewPrivData()->saveLayers( layers );
|
||||
|
||||
m_allItems->push_back( aItem );
|
||||
|
||||
for( int i = 0; i < layers_count; ++i )
|
||||
for( int layer : layers )
|
||||
{
|
||||
wxCHECK2_MSG( layers[i] >= 0 && static_cast<unsigned>( layers[i] ) < m_layers.size(),
|
||||
wxCHECK2_MSG( layer >= 0 && static_cast<unsigned>( layer ) < m_layers.size(),
|
||||
continue, wxS( "Invalid layer" ) );
|
||||
|
||||
VIEW_LAYER& l = m_layers[layers[i]];
|
||||
VIEW_LAYER& l = m_layers[layer];
|
||||
l.items->Insert( aItem, bbox );
|
||||
MarkTargetDirty( l.target );
|
||||
}
|
||||
@ -399,18 +380,16 @@ void VIEW::Remove( VIEW_ITEM* aItem )
|
||||
}
|
||||
}
|
||||
|
||||
int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
|
||||
aItem->m_viewPrivData->getLayers( layers, layers_count );
|
||||
const BOX2I* bbox = &aItem->m_viewPrivData->m_bbox;
|
||||
|
||||
for( int i = 0; i < layers_count; ++i )
|
||||
for( int layer : aItem->m_viewPrivData->m_layers )
|
||||
{
|
||||
VIEW_LAYER& l = m_layers[layers[i]];
|
||||
VIEW_LAYER& l = m_layers[layer];
|
||||
l.items->Remove( aItem, bbox );
|
||||
MarkTargetDirty( l.target );
|
||||
|
||||
// Clear the GAL cache
|
||||
int prevGroup = aItem->m_viewPrivData->getGroup( layers[i] );
|
||||
int prevGroup = aItem->m_viewPrivData->getGroup( layer );
|
||||
|
||||
if( prevGroup >= 0 )
|
||||
m_gal->DeleteGroup( prevGroup );
|
||||
@ -684,31 +663,13 @@ int VIEW::GetLayerOrder( int aLayer ) const
|
||||
}
|
||||
|
||||
|
||||
void VIEW::SortLayers( int aLayers[], int& aCount ) const
|
||||
void VIEW::SortLayers( std::vector<int> aLayers ) const
|
||||
{
|
||||
int maxLay, maxOrd, maxIdx;
|
||||
|
||||
for( int i = 0; i < aCount; ++i )
|
||||
{
|
||||
maxLay = aLayers[i];
|
||||
maxOrd = GetLayerOrder( maxLay );
|
||||
maxIdx = i;
|
||||
|
||||
// Look for the max element in the range (j..aCount)
|
||||
for( int j = i; j < aCount; ++j )
|
||||
{
|
||||
if( maxOrd < GetLayerOrder( aLayers[j] ) )
|
||||
{
|
||||
maxLay = aLayers[j];
|
||||
maxOrd = GetLayerOrder( maxLay );
|
||||
maxIdx = j;
|
||||
}
|
||||
}
|
||||
|
||||
// Swap elements
|
||||
aLayers[maxIdx] = aLayers[i];
|
||||
aLayers[i] = maxLay;
|
||||
}
|
||||
std::sort( aLayers.begin(), aLayers.end(),
|
||||
[this]( int a, int b )
|
||||
{
|
||||
return GetLayerOrder( a ) < GetLayerOrder( b );
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
@ -739,10 +700,8 @@ void VIEW::ReorderLayerData( std::unordered_map<int, int> aReorderMap )
|
||||
if( !viewData )
|
||||
continue;
|
||||
|
||||
int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
|
||||
|
||||
item->ViewGetLayers( layers, layers_count );
|
||||
viewData->saveLayers( layers, layers_count );
|
||||
std::vector<int> layers = item->ViewGetLayers();
|
||||
viewData->saveLayers( layers );
|
||||
|
||||
viewData->reorderGroups( aReorderMap );
|
||||
|
||||
@ -817,13 +776,10 @@ void VIEW::UpdateAllLayersColor()
|
||||
if( !viewData )
|
||||
continue;
|
||||
|
||||
int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
|
||||
viewData->getLayers( layers, layers_count );
|
||||
|
||||
for( int i = 0; i < layers_count; ++i )
|
||||
for( int layer : viewData->m_layers )
|
||||
{
|
||||
const COLOR4D color = m_painter->GetSettings()->GetColor( item, layers[i] );
|
||||
int group = viewData->getGroup( layers[i] );
|
||||
const COLOR4D color = m_painter->GetSettings()->GetColor( item, layer );
|
||||
int group = viewData->getGroup( layer );
|
||||
|
||||
if( group >= 0 )
|
||||
m_gal->ChangeGroupColor( group, color );
|
||||
@ -953,15 +909,12 @@ void VIEW::UpdateAllLayersOrder()
|
||||
if( !viewData )
|
||||
continue;
|
||||
|
||||
int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
|
||||
viewData->getLayers( layers, layers_count );
|
||||
|
||||
for( int i = 0; i < layers_count; ++i )
|
||||
for( int layer : viewData->m_layers )
|
||||
{
|
||||
int group = viewData->getGroup( layers[i] );
|
||||
int group = viewData->getGroup( layer );
|
||||
|
||||
if( group >= 0 )
|
||||
m_gal->ChangeGroupDepth( group, m_layers[layers[i]].renderingOrder );
|
||||
m_gal->ChangeGroupDepth( group, m_layers[layer].renderingOrder );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1109,17 +1062,15 @@ void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate )
|
||||
|
||||
void VIEW::draw( VIEW_ITEM* aItem, bool aImmediate )
|
||||
{
|
||||
int layers[VIEW_MAX_LAYERS], layers_count;
|
||||
|
||||
aItem->ViewGetLayers( layers, layers_count );
|
||||
std::vector<int> layers = aItem->ViewGetLayers();
|
||||
|
||||
// Sorting is needed for drawing order dependent GALs (like Cairo)
|
||||
SortLayers( layers, layers_count );
|
||||
SortLayers( layers );
|
||||
|
||||
for( int i = 0; i < layers_count; ++i )
|
||||
for( int layer : layers )
|
||||
{
|
||||
m_gal->SetLayerDepth( m_layers.at( layers[i] ).renderingOrder );
|
||||
draw( aItem, layers[i], aImmediate );
|
||||
m_gal->SetLayerDepth( m_layers.at( layer ).renderingOrder );
|
||||
draw( aItem, layer, aImmediate );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1278,24 +1229,21 @@ void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
|
||||
updateBbox( aItem );
|
||||
}
|
||||
|
||||
int layers[VIEW_MAX_LAYERS], layers_count;
|
||||
aItem->ViewGetLayers( layers, layers_count );
|
||||
std::vector<int> layers = aItem->ViewGetLayers();
|
||||
|
||||
// Iterate through layers used by the item and recache it immediately
|
||||
for( int i = 0; i < layers_count; ++i )
|
||||
for( int layer : layers )
|
||||
{
|
||||
int layerId = layers[i];
|
||||
|
||||
if( IsCached( layerId ) )
|
||||
if( IsCached( layer ) )
|
||||
{
|
||||
if( aUpdateFlags & ( GEOMETRY | LAYERS | REPAINT ) )
|
||||
updateItemGeometry( aItem, layerId );
|
||||
updateItemGeometry( aItem, layer );
|
||||
else if( aUpdateFlags & COLOR )
|
||||
updateItemColor( aItem, layerId );
|
||||
updateItemColor( aItem, layer );
|
||||
}
|
||||
|
||||
// Mark those layers as dirty, so the VIEW will be refreshed
|
||||
MarkTargetDirty( m_layers[layerId].target );
|
||||
MarkTargetDirty( m_layers[layer].target );
|
||||
}
|
||||
|
||||
aItem->viewPrivData()->clearUpdateFlags();
|
||||
@ -1368,18 +1316,17 @@ void VIEW::updateItemGeometry( VIEW_ITEM* aItem, int aLayer )
|
||||
|
||||
void VIEW::updateBbox( VIEW_ITEM* aItem )
|
||||
{
|
||||
int layers[VIEW_MAX_LAYERS], layers_count;
|
||||
std::vector<int> layers = aItem->ViewGetLayers();
|
||||
|
||||
aItem->ViewGetLayers( layers, layers_count );
|
||||
wxASSERT( aItem->m_viewPrivData ); //must have a viewPrivData
|
||||
|
||||
const BOX2I new_bbox = aItem->ViewBBox();
|
||||
const BOX2I* old_bbox = &aItem->m_viewPrivData->m_bbox;
|
||||
aItem->m_viewPrivData->m_bbox = new_bbox;
|
||||
|
||||
for( int i = 0; i < layers_count; ++i )
|
||||
for( int layer : layers )
|
||||
{
|
||||
VIEW_LAYER& l = m_layers[layers[i]];
|
||||
VIEW_LAYER& l = m_layers[layer];
|
||||
l.items->Remove( aItem, old_bbox );
|
||||
l.items->Insert( aItem, new_bbox );
|
||||
MarkTargetDirty( l.target );
|
||||
@ -1390,25 +1337,23 @@ void VIEW::updateBbox( VIEW_ITEM* aItem )
|
||||
void VIEW::updateLayers( VIEW_ITEM* aItem )
|
||||
{
|
||||
VIEW_ITEM_DATA* viewData = aItem->viewPrivData();
|
||||
int layers[VIEW_MAX_LAYERS], layers_count;
|
||||
|
||||
if( !viewData )
|
||||
return;
|
||||
|
||||
// Remove the item from previous layer set
|
||||
viewData->getLayers( layers, layers_count );
|
||||
const BOX2I* old_bbox = &aItem->m_viewPrivData->m_bbox;
|
||||
|
||||
for( int i = 0; i < layers_count; ++i )
|
||||
for( int layer : aItem->m_viewPrivData->m_layers )
|
||||
{
|
||||
VIEW_LAYER& l = m_layers[layers[i]];
|
||||
VIEW_LAYER& l = m_layers[layer];
|
||||
l.items->Remove( aItem, old_bbox );
|
||||
MarkTargetDirty( l.target );
|
||||
|
||||
if( IsCached( l.id ) )
|
||||
{
|
||||
// Redraw the item from scratch
|
||||
int prevGroup = viewData->getGroup( layers[i] );
|
||||
int prevGroup = viewData->getGroup( layer );
|
||||
|
||||
if( prevGroup >= 0 )
|
||||
{
|
||||
@ -1422,12 +1367,12 @@ void VIEW::updateLayers( VIEW_ITEM* aItem )
|
||||
aItem->m_viewPrivData->m_bbox = new_bbox;
|
||||
|
||||
// Add the item to new layer set
|
||||
aItem->ViewGetLayers( layers, layers_count );
|
||||
viewData->saveLayers( layers, layers_count );
|
||||
std::vector<int> layers = aItem->ViewGetLayers();
|
||||
viewData->saveLayers( layers );
|
||||
|
||||
for( int i = 0; i < layers_count; i++ )
|
||||
for( int layer : layers )
|
||||
{
|
||||
VIEW_LAYER& l = m_layers[layers[i]];
|
||||
VIEW_LAYER& l = m_layers[layer];
|
||||
l.items->Insert( aItem, new_bbox );
|
||||
MarkTargetDirty( l.target );
|
||||
}
|
||||
@ -1510,7 +1455,6 @@ void VIEW::UpdateItems()
|
||||
if( ratio > 0.3 )
|
||||
{
|
||||
auto allItems = *m_allItems;
|
||||
int layers[VIEW_MAX_LAYERS], layers_count;
|
||||
|
||||
// kill all Rtrees
|
||||
for( VIEW_LAYER& layer : m_layers )
|
||||
@ -1525,14 +1469,14 @@ void VIEW::UpdateItems()
|
||||
const BOX2I bbox = item->ViewBBox();
|
||||
item->m_viewPrivData->m_bbox = bbox;
|
||||
|
||||
item->ViewGetLayers( layers, layers_count );
|
||||
item->viewPrivData()->saveLayers( layers, layers_count );
|
||||
std::vector<int> layers = item->ViewGetLayers();
|
||||
item->viewPrivData()->saveLayers( layers );
|
||||
|
||||
for( int i = 0; i < layers_count; ++i )
|
||||
for( int layer : layers )
|
||||
{
|
||||
wxCHECK2_MSG( layers[i] >= 0 && static_cast<unsigned>( layers[i] ) < m_layers.size(),
|
||||
wxCHECK2_MSG( layer >= 0 && static_cast<unsigned>( layer ) < m_layers.size(),
|
||||
continue, wxS( "Invalid layer" ) );
|
||||
VIEW_LAYER& l = m_layers[layers[i]];
|
||||
VIEW_LAYER& l = m_layers[layer];
|
||||
l.items->Insert( item, bbox );
|
||||
MarkTargetDirty( l.target );
|
||||
}
|
||||
|
@ -122,35 +122,32 @@ void VIEW_GROUP::ViewDraw( int aLayer, VIEW* aView ) const
|
||||
if( aView->IsHiddenOnOverlay( item ) )
|
||||
continue;
|
||||
|
||||
int item_layers[VIEW::VIEW_MAX_LAYERS], item_layers_count;
|
||||
item->ViewGetLayers( item_layers, item_layers_count );
|
||||
std::vector<int> layers = item->ViewGetLayers();
|
||||
|
||||
for( int i = 0; i < item_layers_count; i++ )
|
||||
for( auto layer : layers )
|
||||
{
|
||||
wxCHECK2_MSG( item_layers[i] <= LAYER_ID_COUNT, continue, wxT( "Invalid item layer" ) );
|
||||
layer_item_map[ item_layers[i] ].push_back( item );
|
||||
wxCHECK2_MSG( layer <= LAYER_ID_COUNT, continue, wxT( "Invalid item layer" ) );
|
||||
layer_item_map[ layer ].push_back( item );
|
||||
}
|
||||
}
|
||||
|
||||
int layers[VIEW::VIEW_MAX_LAYERS] = { 0 };
|
||||
int layers_count = 0;
|
||||
|
||||
for( const std::pair<const int, std::vector<VIEW_ITEM*>>& entry : layer_item_map )
|
||||
layers[ layers_count++ ] = entry.first;
|
||||
|
||||
if( layers_count == 0 )
|
||||
if( layer_item_map.empty() )
|
||||
return;
|
||||
|
||||
aView->SortLayers( layers, layers_count );
|
||||
std::vector<int> layers;
|
||||
layers.reserve( layer_item_map.size() );
|
||||
|
||||
for( const std::pair<const int, std::vector<VIEW_ITEM*>>& entry : layer_item_map )
|
||||
layers.push_back( entry.first );
|
||||
|
||||
aView->SortLayers( layers );
|
||||
|
||||
// Now draw the layers in sorted order
|
||||
|
||||
GAL_SCOPED_ATTRS scopedAttrs( *gal, GAL_SCOPED_ATTRS::LAYER_DEPTH );
|
||||
|
||||
for( int i = 0; i < layers_count; i++ )
|
||||
for( int layer : layers )
|
||||
{
|
||||
int layer = layers[i];
|
||||
|
||||
if( IsZoneFillLayer( layer ) )
|
||||
layer = layer - LAYER_ZONE_START;
|
||||
|
||||
@ -173,26 +170,25 @@ void VIEW_GROUP::ViewDraw( int aLayer, VIEW* aView ) const
|
||||
{
|
||||
gal->AdvanceDepth();
|
||||
|
||||
for( VIEW_ITEM* item : layer_item_map[ layers[i] ] )
|
||||
for( VIEW_ITEM* item : layer_item_map[ layer ] )
|
||||
{
|
||||
// Ignore LOD scale for selected items, but don't ignore things explicitly
|
||||
// hidden.
|
||||
if( item->ViewGetLOD( layer, aView ) == HIDE )
|
||||
continue;
|
||||
|
||||
if( !painter->Draw( item, layers[i] ) )
|
||||
item->ViewDraw( layers[i], aView ); // Alternative drawing method
|
||||
if( !painter->Draw( item, layer ) )
|
||||
item->ViewDraw( layer, aView ); // Alternative drawing method
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VIEW_GROUP::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> VIEW_GROUP::ViewGetLayers() const
|
||||
{
|
||||
// Everything is displayed on a single layer
|
||||
aLayers[0] = m_layer;
|
||||
aCount = 1;
|
||||
return { m_layer };
|
||||
}
|
||||
|
||||
|
||||
|
@ -308,10 +308,9 @@ void VIEW_OVERLAY::ViewDraw( int aLayer, VIEW* aView ) const
|
||||
}
|
||||
|
||||
|
||||
void VIEW_OVERLAY::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> VIEW_OVERLAY::ViewGetLayers() const
|
||||
{
|
||||
aLayers[0] = LAYER_GP_OVERLAY;
|
||||
aCount = 1;
|
||||
return { LAYER_GP_OVERLAY };
|
||||
}
|
||||
|
||||
|
||||
|
@ -205,11 +205,9 @@ void SCH_BITMAP::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
|
||||
}
|
||||
|
||||
|
||||
void SCH_BITMAP::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> SCH_BITMAP::ViewGetLayers() const
|
||||
{
|
||||
aCount = 2;
|
||||
aLayers[0] = LAYER_DRAW_BITMAPS;
|
||||
aLayers[1] = LAYER_SELECTION_SHADOWS;
|
||||
return { LAYER_DRAW_BITMAPS, LAYER_SELECTION_SHADOWS };
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
void SwapData( SCH_ITEM* aItem ) override;
|
||||
|
||||
/// @copydoc VIEW_ITEM::ViewGetLayers()
|
||||
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
virtual std::vector<int> ViewGetLayers() const override;
|
||||
|
||||
void Move( const VECTOR2I& aMoveVector ) override;
|
||||
|
||||
|
@ -151,13 +151,12 @@ void SCH_BUS_ENTRY_BASE::SwapData( SCH_ITEM* aItem )
|
||||
}
|
||||
|
||||
|
||||
void SCH_BUS_ENTRY_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> SCH_BUS_ENTRY_BASE::ViewGetLayers() const
|
||||
{
|
||||
aCount = 4;
|
||||
aLayers[0] = LAYER_DANGLING;
|
||||
aLayers[1] = Type() == SCH_BUS_BUS_ENTRY_T ? LAYER_BUS : LAYER_WIRE;
|
||||
aLayers[2] = LAYER_NET_COLOR_HIGHLIGHT;
|
||||
aLayers[3] = LAYER_SELECTION_SHADOWS;
|
||||
if( Type() == SCH_BUS_BUS_ENTRY_T )
|
||||
return { LAYER_BUS, LAYER_NET_COLOR_HIGHLIGHT, LAYER_SELECTION_SHADOWS };
|
||||
|
||||
return { LAYER_WIRE, LAYER_NET_COLOR_HIGHLIGHT, LAYER_SELECTION_SHADOWS };
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,7 +89,7 @@ public:
|
||||
|
||||
void SwapData( SCH_ITEM* aItem ) override;
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
std::vector<int> ViewGetLayers() const override;
|
||||
|
||||
const BOX2I GetBoundingBox() const override;
|
||||
|
||||
|
@ -555,11 +555,9 @@ COLOR4D SCH_FIELD::GetFieldColor() const
|
||||
}
|
||||
|
||||
|
||||
void SCH_FIELD::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> SCH_FIELD::ViewGetLayers() const
|
||||
{
|
||||
aCount = 2;
|
||||
aLayers[0] = GetDefaultLayer();
|
||||
aLayers[1] = LAYER_SELECTION_SHADOWS;
|
||||
return { GetDefaultLayer(), LAYER_SELECTION_SHADOWS };
|
||||
}
|
||||
|
||||
|
||||
|
@ -181,7 +181,7 @@ public:
|
||||
m_lastResolvedColor = aField->m_lastResolvedColor;
|
||||
}
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
std::vector<int> ViewGetLayers() const override;
|
||||
|
||||
SCH_LAYER_ID GetDefaultLayer() const;
|
||||
|
||||
|
@ -199,13 +199,10 @@ SYMBOL* SCH_ITEM::GetParentSymbol()
|
||||
}
|
||||
|
||||
|
||||
void SCH_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> SCH_ITEM::ViewGetLayers() const
|
||||
{
|
||||
// Basic fallback
|
||||
aCount = 3;
|
||||
aLayers[0] = LAYER_DEVICE;
|
||||
aLayers[1] = LAYER_DEVICE_BACKGROUND;
|
||||
aLayers[2] = LAYER_SELECTION_SHADOWS;
|
||||
return { LAYER_DEVICE, LAYER_DEVICE_BACKGROUND, LAYER_SELECTION_SHADOWS };
|
||||
}
|
||||
|
||||
|
||||
|
@ -284,7 +284,7 @@ public:
|
||||
/**
|
||||
* Return the layers the item is drawn on (which may be more than its "home" layer)
|
||||
*/
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
std::vector<int> ViewGetLayers() const override;
|
||||
|
||||
/**
|
||||
* @return the size of the "pen" that be used to draw or plot this item
|
||||
|
@ -72,11 +72,9 @@ void SCH_JUNCTION::SwapData( SCH_ITEM* aItem )
|
||||
}
|
||||
|
||||
|
||||
void SCH_JUNCTION::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> SCH_JUNCTION::ViewGetLayers() const
|
||||
{
|
||||
aCount = 2;
|
||||
aLayers[0] = m_layer;
|
||||
aLayers[1] = LAYER_SELECTION_SHADOWS;
|
||||
return { m_layer, LAYER_SELECTION_SHADOWS };
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,7 +65,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
std::vector<int> ViewGetLayers() const override;
|
||||
|
||||
const BOX2I GetBoundingBox() const override;
|
||||
|
||||
|
@ -899,14 +899,10 @@ std::vector<VECTOR2I> SCH_LABEL_BASE::GetConnectionPoints() const
|
||||
}
|
||||
|
||||
|
||||
void SCH_LABEL_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> SCH_LABEL_BASE::ViewGetLayers() const
|
||||
{
|
||||
aCount = 5;
|
||||
aLayers[0] = LAYER_DANGLING;
|
||||
aLayers[1] = LAYER_DEVICE;
|
||||
aLayers[2] = LAYER_NETCLASS_REFS;
|
||||
aLayers[3] = LAYER_FIELDS;
|
||||
aLayers[4] = LAYER_SELECTION_SHADOWS;
|
||||
return { LAYER_DANGLING, LAYER_DEVICE, LAYER_NETCLASS_REFS, LAYER_FIELDS,
|
||||
LAYER_SELECTION_SHADOWS };
|
||||
}
|
||||
|
||||
|
||||
@ -1920,15 +1916,10 @@ bool SCH_GLOBALLABEL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* tok
|
||||
}
|
||||
|
||||
|
||||
void SCH_GLOBALLABEL::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> SCH_GLOBALLABEL::ViewGetLayers() const
|
||||
{
|
||||
aCount = 6;
|
||||
aLayers[0] = LAYER_DANGLING;
|
||||
aLayers[1] = LAYER_DEVICE;
|
||||
aLayers[2] = LAYER_INTERSHEET_REFS;
|
||||
aLayers[3] = LAYER_NETCLASS_REFS;
|
||||
aLayers[4] = LAYER_FIELDS;
|
||||
aLayers[5] = LAYER_SELECTION_SHADOWS;
|
||||
return { LAYER_GLOBLABEL, LAYER_DEVICE, LAYER_INTERSHEET_REFS,
|
||||
LAYER_NETCLASS_REFS, LAYER_FIELDS, LAYER_SELECTION_SHADOWS };
|
||||
}
|
||||
|
||||
|
||||
|
@ -324,7 +324,7 @@ public:
|
||||
bool IsDangling() const override { return m_isDangling; }
|
||||
void SetIsDangling( bool aIsDangling ) { m_isDangling = aIsDangling; }
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
std::vector<int> ViewGetLayers() const override;
|
||||
|
||||
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
||||
|
||||
@ -545,7 +545,7 @@ public:
|
||||
|
||||
bool IsConnectable() const override { return true; }
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
std::vector<int> ViewGetLayers() const override;
|
||||
|
||||
wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
|
||||
|
||||
|
@ -188,14 +188,10 @@ void SCH_LINE::Show( int nestLevel, std::ostream& os ) const
|
||||
#endif
|
||||
|
||||
|
||||
void SCH_LINE::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> SCH_LINE::ViewGetLayers() const
|
||||
{
|
||||
aCount = 5;
|
||||
aLayers[0] = LAYER_DANGLING;
|
||||
aLayers[1] = m_layer;
|
||||
aLayers[2] = LAYER_SELECTION_SHADOWS;
|
||||
aLayers[3] = LAYER_NET_COLOR_HIGHLIGHT;
|
||||
aLayers[4] = LAYER_OP_VOLTAGES;
|
||||
return { LAYER_DANGLING, m_layer, LAYER_SELECTION_SHADOWS, LAYER_NET_COLOR_HIGHLIGHT,
|
||||
LAYER_OP_VOLTAGES };
|
||||
}
|
||||
|
||||
|
||||
|
@ -200,7 +200,7 @@ public:
|
||||
|| ( style_a == LINE_STYLE::SOLID && style_b == LINE_STYLE::DEFAULT );
|
||||
}
|
||||
|
||||
void ViewGetLayers( int aLayers[], int& aCount ) const override;
|
||||
std::vector<int> ViewGetLayers() const override;
|
||||
|
||||
double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
|
||||
|
||||
|
@ -270,9 +270,9 @@ void SCH_MARKER::Show( int nestLevel, std::ostream& os ) const
|
||||
#endif
|
||||
|
||||
|
||||
void SCH_MARKER::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
std::vector<int> SCH_MARKER::ViewGetLayers() const
|
||||
{
|
||||
wxCHECK_RET( Schematic(), "No SCHEMATIC set for SCH_MARKER!" );
|
||||
wxCHECK2_MSG( Schematic(), return {}, "No SCHEMATIC set for SCH_MARKER!" );
|
||||
|
||||
// Don't display sheet-specific markers when SCH_SHEET_PATHs do not match
|
||||
std::shared_ptr<ERC_ITEM> ercItem = std::static_pointer_cast<ERC_ITEM>( GetRCItem() );
|
||||
@ -280,27 +280,27 @@ void SCH_MARKER::ViewGetLayers( int aLayers[], int& aCount ) const
|
||||
if( ercItem->IsSheetSpecific()
|
||||
&& ( ercItem->GetSpecificSheetPath() != Schematic()->CurrentSheet() ) )
|
||||
{
|
||||
aCount = 0;
|
||||
return;
|
||||
return {};
|
||||
}
|
||||
|
||||
aCount = 2;
|
||||
std::vector<int> layers( 2 );
|
||||
|
||||
if( IsExcluded() )
|
||||
{
|
||||
aLayers[0] = LAYER_ERC_EXCLUSION;
|
||||
layers[0] = LAYER_ERC_EXCLUSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch( Schematic()->ErcSettings().GetSeverity( m_rcItem->GetErrorCode() ) )
|
||||
{
|
||||
default:
|
||||
case SEVERITY::RPT_SEVERITY_ERROR: aLayers[0] = LAYER_ERC_ERR; break;
|
||||
case SEVERITY::RPT_SEVERITY_WARNING: aLayers[0] = LAYER_ERC_WARN; break;
|
||||
case SEVERITY::RPT_SEVERITY_ERROR: layers[0] = LAYER_ERC_ERR; break;
|
||||
case SEVERITY::RPT_SEVERITY_WARNING: layers[0] = LAYER_ERC_WARN; break;
|
||||
}
|
||||
}
|
||||
|
||||
aLayers[1] = LAYER_SELECTION_SHADOWS;
|
||||
layers[1] = LAYER_SELECTION_SHADOWS;
|
||||
return layers;
|
||||
}
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user