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

Added possibility to change cached layer color (for the purpose of high contrast display).

parent 0bac4a1e
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -801,6 +801,24 @@ void CAIRO_GAL::DrawGroup( int aGroupNumber )
}


void CAIRO_GAL::ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor )
{
    storePath();

    for( Group::iterator it = groups[aGroupNumber].begin();
         it != groups[aGroupNumber].end(); ++it )
    {
        if( it->command == CMD_SET_FILLCOLOR || it->command == CMD_SET_STROKECOLOR )
        {
            it->arguments[0] = aNewColor.r;
            it->arguments[1] = aNewColor.g;
            it->arguments[2] = aNewColor.b;
            it->arguments[3] = aNewColor.a;
        }
    }
}


void CAIRO_GAL::Flush()
{
    storePath();
+7 −0
Original line number Diff line number Diff line
@@ -1628,6 +1628,13 @@ void OPENGL_GAL::DrawGroup( int aGroupNumber )
}


void OPENGL_GAL::ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor )
{
    vboItems[aGroupNumber]->ChangeColor( aNewColor );
    vboNeedsUpdate = true;
}


void OPENGL_GAL::computeUnitCircle()
{
    displayListCircle = glGenLists( 1 );
+4 −5
Original line number Diff line number Diff line
@@ -79,18 +79,17 @@ VBO_VERTEX* VBO_ITEM::GetVertices()

void VBO_ITEM::ChangeColor( const COLOR4D& aColor )
{
    wxASSERT_MSG( false, wxT( "This was not tested yet" ) );

    if( m_isDirty )
        Finish();

    // Point to color of vertices
    VBO_VERTEX* vertexPtr = GetVertices();
    const GLfloat newColor[] = { aColor.r, aColor.g, aColor.b, aColor.a };

    for( unsigned int i = 0; i < m_size; ++i )
    {
        memcpy( &vertexPtr->r, newColor, ColorByteSize );
        vertexPtr->r = aColor.r;
        vertexPtr->g = aColor.g;
        vertexPtr->b = aColor.b;
        vertexPtr->a = aColor.a;

        // Move on to the next vertex
        vertexPtr++;
+51 −2
Original line number Diff line number Diff line
@@ -307,6 +307,55 @@ void VIEW::SetLayerOrder( int aLayer, int aRenderingOrder )
}


struct VIEW::updateItemsColor
{
    updateItemsColor( int aLayer, PAINTER* aPainter, GAL* aGal ) :
        layer( aLayer ), painter( aPainter), gal( aGal )
    {
    }

    void operator()( VIEW_ITEM* aItem )
    {
        // Obtain the color that should be used for coloring the item
        const COLOR4D color = painter->GetColor( aItem, layer );
        int group = aItem->getGroup( layer );

        gal->ChangeGroupColor( group, color );
    }

    int layer;
    PAINTER* painter;
    GAL* gal;
};


void VIEW::UpdateLayerColor( int aLayer )
{
    BOX2I r;

    r.SetMaximum();

    updateItemsColor visitor( aLayer, m_painter, m_gal );
    m_layers[aLayer].items->Query( r, visitor );
}


void VIEW::UpdateAllLayersColor()
{
    BOX2I r;

    r.SetMaximum();

    for( LayerMapIter i = m_layers.begin(); i != m_layers.end(); ++i )
    {
        VIEW_LAYER* l = &( ( *i ).second );
        updateItemsColor visitor( l->id, m_painter, m_gal );

        l->items->Query( r, visitor );
    }
}


void VIEW::SetTopLayer( int aLayer )
{
    // Restore previous order
@@ -561,13 +610,13 @@ void VIEW::clearGroupCache()
    BOX2I r;

    r.SetMaximum();
    clearItemCache visitor( this );

    for( LayerMapIter i = m_layers.begin(); i != m_layers.end(); ++i )
    {
        VIEW_LAYER* l = & ( ( *i ).second );
        clearItemCache visitor( this );
        l->items->Query( r, visitor );
    };
    }
}


+3 −0
Original line number Diff line number Diff line
@@ -209,6 +209,9 @@ public:
    /// @copydoc GAL::DrawGroup()
    virtual void DrawGroup( int aGroupNumber );

    /// @copydoc GAL::ChangeGroupColor()
    virtual void ChangeGroupColor( int aGroupNumber, const COLOR4D& aNewColor );

    /// @copydoc GAL::DeleteGroup()
    virtual void DeleteGroup( int aGroupNumber );

Loading