Commit fef50dd8 authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Changed way of naming VIEW_ITEM update flags to be more explicit.

VIEW_ITEMs save the layer numbers they use, it allowed to speed up removal of items.
parent d0fc362e
Loading
Loading
Loading
Loading
+0 −9
Original line number Original line Diff line number Diff line
@@ -73,15 +73,6 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
    m_view->SetPainter( m_painter );
    m_view->SetPainter( m_painter );
    m_view->SetGAL( m_gal );
    m_view->SetGAL( m_gal );


    // View uses layers to display EDA_ITEMs (item may be displayed on several layers, for example
    // pad may be shown on pad, pad hole and solder paste layers). There are usual copper layers
    // (eg. F.Cu, B.Cu, internal and so on) and layers for displaying objects such as texts,
    // silkscreen, pads, vias, etc.
    for( int i = 0; i < TOTAL_LAYER_COUNT; i++ )
    {
        m_view->AddLayer( i );
    }

    m_viewControls = new KiGfx::WX_VIEW_CONTROLS( m_view, this );
    m_viewControls = new KiGfx::WX_VIEW_CONTROLS( m_view, this );


    Connect( wxEVT_PAINT,       wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
    Connect( wxEVT_PAINT,       wxPaintEventHandler( EDA_DRAW_PANEL_GAL::onPaint ), NULL, this );
+36 −18
Original line number Original line Diff line number Diff line
@@ -50,6 +50,15 @@ VIEW::VIEW( bool aIsDynamic ) :
    // Redraw everything at the beginning
    // Redraw everything at the beginning
    for( int i = 0; i < TARGETS_NUMBER; ++i )
    for( int i = 0; i < TARGETS_NUMBER; ++i )
        MarkTargetDirty( i );
        MarkTargetDirty( i );

    // View uses layers to display EDA_ITEMs (item may be displayed on several layers, for example
    // pad may be shown on pad, pad hole and solder paste layers). There are usual copper layers
    // (eg. F.Cu, B.Cu, internal and so on) and layers for displaying objects such as texts,
    // silkscreen, pads, vias, etc.
    for( int i = 0; i < VIEW_MAX_LAYERS; i++ )
    {
        AddLayer( i );
    }
}
}




@@ -85,6 +94,7 @@ void VIEW::Add( VIEW_ITEM* aItem )
    int layers[VIEW_MAX_LAYERS], layers_count;
    int layers[VIEW_MAX_LAYERS], layers_count;


    aItem->ViewGetLayers( layers, layers_count );
    aItem->ViewGetLayers( layers, layers_count );
    aItem->saveLayers( layers, layers_count );


    for( int i = 0; i < layers_count; i++ )
    for( int i = 0; i < layers_count; i++ )
    {
    {
@@ -103,12 +113,14 @@ void VIEW::Remove( VIEW_ITEM* aItem )
    if( m_dynamic )
    if( m_dynamic )
        aItem->m_view = NULL;
        aItem->m_view = NULL;


// fixme: this is so sloooow!
    int layers[VIEW::VIEW_MAX_LAYERS], layers_count;
    for( LayerMapIter i = m_layers.begin(); i != m_layers.end(); ++i )
    aItem->getLayers( layers, layers_count );

    for( int i = 0; i < layers_count; ++i )
    {
    {
        VIEW_LAYER* l = & ( ( *i ).second );
        VIEW_LAYER& l = m_layers[layers[i]];
        l->items->Remove( aItem );
        l.items->Remove( aItem );
        l->isDirty = true;
        l.isDirty = true;
    }
    }
}
}


@@ -595,7 +607,9 @@ void VIEW::draw( VIEW_ITEM* aItem, int aLayer, bool aImmediate ) const
void VIEW::draw( VIEW_ITEM* aItem, bool aImmediate ) const
void VIEW::draw( VIEW_ITEM* aItem, bool aImmediate ) const
{
{
    int layers[VIEW_MAX_LAYERS], layers_count;
    int layers[VIEW_MAX_LAYERS], layers_count;
    aItem->ViewGetLayers( layers, layers_count );

    aItem->getLayers( layers, layers_count );
    // Sorting is needed for drawing order dependent GALs (like Cairo)
    SortLayers( layers, layers_count );
    SortLayers( layers, layers_count );


    for( int i = 0; i < layers_count; ++i )
    for( int i = 0; i < layers_count; ++i )
@@ -773,26 +787,30 @@ void VIEW::clearGroupCache()
void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
void VIEW::invalidateItem( VIEW_ITEM* aItem, int aUpdateFlags )
{
{
    int layers[VIEW_MAX_LAYERS], layers_count;
    int layers[VIEW_MAX_LAYERS], layers_count;
    aItem->ViewGetLayers( layers, layers_count );
    aItem->getLayers( layers, layers_count );


    // Iterate through layers used by the item and recache it immediately
    // Iterate through layers used by the item and recache it immediately
    for( int i = 0; i < layers_count; i++ )
    for( int i = 0; i < layers_count; i++ )
    {
    {
        if( aUpdateFlags == VIEW_ITEM::APPEARANCE )
        int layerId = layers[i];
        {

            updateItemAppearance( aItem, layers[i] );
        if( aUpdateFlags & VIEW_ITEM::GEOMETRY )
        }
        else if( aUpdateFlags == VIEW_ITEM::GEOMETRY )
        {
        {
            // Reinsert item
            // Reinsert item in order to update bounding box
            Remove( aItem );
            Remove( aItem );
            Add( aItem );
            Add( aItem );
            updateItemGeometry( aItem, layers[i]);      /// TODO is it still necessary?

            if( isCached( layerId ) )
                updateItemGeometry( aItem, layerId );      /// TODO is it still necessary?
        }
        else if( aUpdateFlags & VIEW_ITEM::COLOR )
        {
            updateItemColor( aItem, layerId );
        }
        }


        // Mark those layers as dirty, so the VIEW will be refreshed
        // Mark those layers as dirty, so the VIEW will be refreshed
        m_layers[layers[i]].isDirty = true;
        m_layers[layerId].isDirty = true;
        MarkTargetDirty( m_layers[layers[i]].target );   // TODO remove?
        MarkTargetDirty( m_layers[layerId].target );   // TODO remove?
    }
    }
}
}


@@ -812,7 +830,7 @@ void VIEW::sortLayers()
}
}




void VIEW::updateItemAppearance( VIEW_ITEM* aItem, int aLayer )
void VIEW::updateItemColor( VIEW_ITEM* aItem, int aLayer )
{
{
    wxASSERT( (unsigned) aLayer < m_layers.size() );
    wxASSERT( (unsigned) aLayer < m_layers.size() );


@@ -875,13 +893,13 @@ void VIEW::RecacheAllItems( bool aImmediately )
    {
    {
        VIEW_LAYER* l = &( ( *i ).second );
        VIEW_LAYER* l = &( ( *i ).second );


        // Obviously, there is only one cached target that has to be recomputed
        if( isCached( l->id ) )
        if( isCached( l->id ) )
        {
        {
            m_gal->SetTarget( l->target );
            m_gal->SetTarget( l->target );
            m_gal->SetLayerDepth( l->renderingOrder );
            m_gal->SetLayerDepth( l->renderingOrder );
            recacheLayer visitor( this, m_gal, l->id, aImmediately );
            recacheLayer visitor( this, m_gal, l->id, aImmediately );
            l->items->Query( r, visitor );
            l->items->Query( r, visitor );
            l->isDirty = false;
        }
        }
    }
    }


+14 −0
Original line number Original line Diff line number Diff line
@@ -71,6 +71,20 @@ void VIEW_ITEM::ViewRelease()
}
}




void VIEW_ITEM::getLayers( int* aLayers, int& aCount ) const
{
    int* layersPtr = aLayers;
    for( int i = 0; i < m_layers.size(); ++i )
    {
        if( m_layers[i] )
            *layersPtr++ = i;

    }

    aCount = m_layers.count();
}


int VIEW_ITEM::getGroup( int aLayer ) const
int VIEW_ITEM::getGroup( int aLayer ) const
{
{
    for( int i = 0; i < m_groupsSize; ++i )
    for( int i = 0; i < m_groupsSize; ++i )
+6 −6
Original line number Original line Diff line number Diff line
@@ -472,13 +472,13 @@ public:
    inline bool IsHighlighted() const { return m_Flags & HIGHLIGHTED; }
    inline bool IsHighlighted() const { return m_Flags & HIGHLIGHTED; }
    inline bool IsBrightened() const { return m_Flags & BRIGHTENED; }
    inline bool IsBrightened() const { return m_Flags & BRIGHTENED; }


    inline void SetSelected() { SetFlags( SELECTED ); ViewUpdate( APPEARANCE ); }
    inline void SetSelected() { SetFlags( SELECTED ); ViewUpdate( COLOR ); }
    inline void SetHighlighted() { SetFlags( HIGHLIGHTED ); ViewUpdate( APPEARANCE ); }
    inline void SetHighlighted() { SetFlags( HIGHLIGHTED ); ViewUpdate( COLOR ); }
    inline void SetBrightened() { SetFlags( BRIGHTENED ); ViewUpdate( APPEARANCE ); }
    inline void SetBrightened() { SetFlags( BRIGHTENED ); ViewUpdate( COLOR ); }


    inline void ClearSelected() { ClearFlags( SELECTED ); ViewUpdate( APPEARANCE ); }
    inline void ClearSelected() { ClearFlags( SELECTED ); ViewUpdate( COLOR ); }
    inline void ClearHighlighted() { ClearFlags( HIGHLIGHTED ); ViewUpdate( APPEARANCE ); }
    inline void ClearHighlighted() { ClearFlags( HIGHLIGHTED ); ViewUpdate( COLOR ); }
    inline void ClearBrightened() { ClearFlags( BRIGHTENED ); ViewUpdate( APPEARANCE ); }
    inline void ClearBrightened() { ClearFlags( BRIGHTENED ); ViewUpdate( COLOR ); }


    void SetModified();
    void SetModified();


+1 −1
Original line number Original line Diff line number Diff line
@@ -510,7 +510,7 @@ private:
    void clearGroupCache();
    void clearGroupCache();


    /// Updates colors that are used for an item to be drawn
    /// Updates colors that are used for an item to be drawn
    void updateItemAppearance( VIEW_ITEM* aItem, int aLayer );
    void updateItemColor( VIEW_ITEM* aItem, int aLayer );


    /// Updates all informations needed to draw an item
    /// Updates all informations needed to draw an item
    void updateItemGeometry( VIEW_ITEM* aItem, int aLayer );
    void updateItemGeometry( VIEW_ITEM* aItem, int aLayer );
Loading