Commit 8753bef2 authored by Maciej Suminski's avatar Maciej Suminski

Moved VIEW_ITEM::ViewGetRequiredLayers() functionality to the VIEW class. Now...

Moved VIEW_ITEM::ViewGetRequiredLayers() functionality to the VIEW class. Now required layers are set per layer basis instead of per item.
parent 2c2e506e
......@@ -89,6 +89,22 @@ void VIEW::Remove( VIEW_ITEM* aItem )
}
void VIEW::SetRequired( int aLayerId, int aRequiredId, bool aRequired )
{
wxASSERT( (unsigned) aLayerId < m_layers.size() );
wxASSERT( (unsigned) aRequiredId < m_layers.size() );
if( aRequired )
{
m_layers[aLayerId].requiredLayers.insert( aRequiredId );
}
else
{
m_layers[aLayerId].requiredLayers.erase( aRequired );
}
}
// stupid C++... python lamda would do this in one line
template <class Container>
struct queryVisitor
......@@ -474,14 +490,9 @@ struct VIEW::drawItem
{
GAL* gal = view->GetGAL();
// Obtain layers that are required to be enabled for drawing an item
// (eg. there is no point in drawing track labels, if the track is not visible)
aItem->ViewGetRequiredLayers( layers, layersCount );
// Conditions that have te be fulfilled for an item to be drawn
bool drawCondition = aItem->ViewIsVisible() &&
aItem->ViewGetLOD( currentLayer->id ) < view->m_scale &&
view->isEveryLayerEnabled( layers, layersCount );
aItem->ViewGetLOD( currentLayer->id ) < view->m_scale;
if( !drawCondition )
return;
......@@ -521,7 +532,7 @@ void VIEW::redrawRect( const BOX2I& aRect )
{
BOOST_FOREACH( VIEW_LAYER* l, m_orderedLayers )
{
if( l->enabled )
if( l->enabled && areRequiredLayersEnabled( l->id ) )
{
drawItem drawFunc( this, l );
......@@ -537,7 +548,7 @@ bool VIEW::IsDirty()
{
BOOST_FOREACH( VIEW_LAYER* l, m_orderedLayers )
{
if(l->isDirty)
if( l->isDirty )
return true;
}
return false;
......@@ -698,11 +709,17 @@ void VIEW::clearGroupCache()
}
bool VIEW::isEveryLayerEnabled( const int aLayers[], int aCount ) const
bool VIEW::areRequiredLayersEnabled( int aLayerId ) const
{
for( int i = 0; i < aCount; ++i )
wxASSERT( (unsigned) aLayerId < m_layers.size() );
std::set<int>::iterator it, it_end;
for( it = m_layers.at( aLayerId ).requiredLayers.begin(), it_end = m_layers.at( aLayerId ).requiredLayers.end();
it != it_end; ++it )
{
if( !m_layers.at( aLayers[i] ).enabled )
// That is enough if just one layer is not enabled
if( !m_layers.at( *it ).enabled )
return false;
}
......
......@@ -48,13 +48,6 @@ void VIEW_ITEM::ViewSetVisible( bool aIsVisible )
}
void VIEW_ITEM::ViewGetRequiredLayers( int aLayers[], int& aCount ) const
{
// By default there is no layer required
aCount = 0;
}
void VIEW_ITEM::ViewUpdate( int aUpdateFlags, bool aForceImmediateRedraw )
{
if(!m_view)
......@@ -144,8 +137,9 @@ bool VIEW_ITEM::storesGroups() const
return ( m_groupsSize > 0 );
}
void VIEW_ITEM::ViewSetHighlighted( bool aIsHighlighted )
{
m_highlighted = aIsHighlighted;
ViewUpdate(APPEARANCE | GEOMETRY);
ViewUpdate( APPEARANCE | GEOMETRY );
}
......@@ -84,7 +84,8 @@ public:
*/
void Remove( VIEW_ITEM* aItem );
/** Function Query()
/**
* Function Query()
* Finds all visible items that touch or are within the rectangle aRect.
* @param aRect area to search for items
* @param aResult result of the search, containing VIEW_ITEMs associated with their layers.
......@@ -93,6 +94,16 @@ public:
*/
int Query( const BOX2I& aRect, std::vector<LayerItemPair>& aResult );
/**
* Function SetRequired()
* Marks the aRequiredId layer as required for the aLayerId layer. In order to display the
* layer, all of its required layers have to be enabled.
* @param aLayerId is the id of the layer for which we enable/disable the required layer.
* @param aRequiredId is the id of the required layer.
* @param aRequired tells if the required layer should be added or removed from the list.
*/
void SetRequired( int aLayerId, int aRequiredId, bool aRequired = true );
/**
* Function CopySettings()
* Copies layers and visibility settings from another view.
......@@ -377,6 +388,7 @@ private:
BOX2I extents; ///* sum of bboxes of all items on the layer
BOX2I dirtyExtents; ///* sum of bboxes of all dirty items on the layer
RenderTarget target; ///* where the layer should be rendered
std::set<int> requiredLayers; ///* layers that are required to be enabled to show the layer
};
// Convenience typedefs
......@@ -416,8 +428,8 @@ private:
return i->renderingOrder > j->renderingOrder;
}
/// Checks if every layer stored in aLayers array is enabled.
bool isEveryLayerEnabled( const int aLayers[], int aCount ) const;
/// Checks if every layer required by the aLayerId layer is enabled.
bool areRequiredLayersEnabled( int aLayerId ) const;
/// Contains set of possible displayed layers and its properties
LayerMap m_layers;
......
......@@ -115,16 +115,6 @@ public:
*/
virtual void ViewGetLayers( int aLayers[], int& aCount ) const = 0;
/**
* Function ViewGetRequiredLayers()
* Returns the all the layers that are required for an item to be drawn. Eg. there is no point
* to draw netnames, when the track is not visible - so track layer should be marked as
* required.
* @param aLayers[]: output layer index array
* @param aCount: number of layer indices in aLayers[]
*/
virtual void ViewGetRequiredLayers( int aLayers[], int& aCount ) const;
/**
* Function ViewSetVisible()
* Sets the item visibility.
......
......@@ -93,8 +93,8 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType,
EDA_DRAW_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
{
m_Pcb = NULL;
m_toolManager = NULL;
m_toolDispatcher = NULL;
m_toolManager = NULL;
m_toolDispatcher = NULL;
m_DisplayPadFill = true; // How to draw pads
m_DisplayViaFill = true; // How to draw vias
......@@ -806,15 +806,27 @@ void PCB_BASE_FRAME::LoadSettings()
view->SetLayerOrder( GalLayerOrder[i], i );
view->SetLayerTarget( i, KiGfx::TARGET_NONCACHED );
}
// Netnames are drawn only when scale is sufficient (level of details)
// so there is no point in caching them
for( LAYER_NUM layer = FIRST_NETNAME_LAYER; layer <= LAST_NETNAME_LAYER; ++layer )
{
view->SetLayerTarget( layer, KiGfx::TARGET_NONCACHED );
if( IsCopperLayer( i ) )
{
// Copper layers are required for netname layers
view->SetRequired( GetNetnameLayer( i ), i );
}
else
if( IsNetnameLayer( i ) )
{
// Netnames are drawn only when scale is sufficient (level of details)
// so there is no point in caching them
view->SetLayerTarget( i, KiGfx::TARGET_NONCACHED );
}
}
// Some more required layers settings
view->SetRequired( ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE ), ITEM_GAL_LAYER( VIAS_VISIBLE ) );
view->SetRequired( ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ) );
view->SetRequired( ITEM_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_FR_VISIBLE ) );
view->SetRequired( ITEM_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_BK_VISIBLE ) );
// Apply layer coloring scheme & display options
if( view->GetPainter() )
{
......
......@@ -850,27 +850,6 @@ void D_PAD::ViewGetLayers( int aLayers[], int& aCount ) const
}
void D_PAD::ViewGetRequiredLayers( int aLayers[], int& aCount ) const
{
ViewGetLayers( aLayers, aCount );
// Remove pad description layer & soldermask from the required layers group
if( IsOnLayer( LAYER_N_FRONT ) && IsOnLayer( LAYER_N_BACK ) )
{
// Multilayer pads have 2 soldermask layers (front and back), 2 solder paste layer
// (front and back) and one description layer that do not have to be enabled in order to
// display a pad.
aCount -= 5;
}
else
{
// Rest of pads have one soldermask layer, one solder paste layer and one description layer
// that are not necessary for pad to be displayed.
aCount -= 3;
}
}
unsigned int D_PAD::ViewGetLOD( int aLayer ) const
{
// Netnames and soldermasks will be shown only if zoom is appropriate
......
......@@ -436,9 +436,6 @@ public:
/// @copydoc VIEW_ITEM::ViewGetLayers()
virtual void ViewGetLayers( int aLayers[], int& aCount ) const;
/// @copydoc VIEW_ITEM::ViewGetRequiredLayers()
virtual void ViewGetRequiredLayers( int aLayers[], int& aCount ) const;
/// @copydoc VIEW_ITEM::ViewGetLOD()
virtual unsigned int ViewGetLOD( int aLayer ) const;
......
......@@ -760,14 +760,6 @@ void TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
}
void TRACK::ViewGetRequiredLayers( int aLayers[], int& aCount ) const
{
// The only required layer is the track layer itself
aLayers[0] = GetLayer();
aCount = 1;
}
unsigned int TRACK::ViewGetLOD( int aLayer ) const
{
// Netnames will be shown only if zoom is appropriate
......@@ -1004,14 +996,6 @@ void SEGVIA::ViewGetLayers( int aLayers[], int& aCount ) const
}
void SEGVIA::ViewGetRequiredLayers( int aLayers[], int& aCount ) const
{
// The only required layer is via itself, holes are optional
aLayers[0] = ITEM_GAL_LAYER( VIAS_VISIBLE );
aCount = 1;
}
// see class_track.h
void TRACK::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
{
......
......@@ -331,9 +331,6 @@ public:
/// @copydoc VIEW_ITEM::ViewGetLayers()
virtual void ViewGetLayers( int aLayers[], int& aCount ) const;
/// @copydoc VIEW_ITEM::ViewGetRequiredLayers()
virtual void ViewGetRequiredLayers( int aLayers[], int& aCount ) const;
/// @copydoc VIEW_ITEM::ViewGetLOD()
virtual unsigned int ViewGetLOD( int aLayer ) const;
......@@ -424,9 +421,6 @@ public:
/// @copydoc VIEW_ITEM::ViewGetLayers()
virtual void ViewGetLayers( int aLayers[], int& aCount ) const;
/// @copydoc VIEW_ITEM::ViewGetRequiredLayers()
virtual void ViewGetRequiredLayers( int aLayers[], int& aCount ) const;
#if defined (DEBUG)
virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override
#endif
......
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