Commit 69816d87 authored by Maciej Suminski's avatar Maciej Suminski
Browse files

The GAL view uses colors settings from the legacy canvas.

Minor refactoring of PAINTER & RENDER_SETTINGS classes.
parent 07877f90
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -100,12 +100,13 @@ void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor
 * @return the color for an item which is one of the item indices given
 * in pcbstruct.h, enum PCB_VISIBLE or in schematic
 */
EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx )
EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) const
{
    if( (unsigned) aItemIdx < DIM( m_ItemsColors ) )
    {
        return m_ItemsColors[aItemIdx];
    }

    return UNSPECIFIED_COLOR;
}

+0 −6
Original line number Diff line number Diff line
@@ -73,9 +73,3 @@ PAINTER::PAINTER( GAL* aGal ) :
PAINTER::~PAINTER()
{
}


void PAINTER::SetGAL( GAL* aGal )
{
    m_gal = aGal;
}
+3 −3
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public:
     * @return the color for an item which is one of the item indices given
     * in pcbstruct.h, enum PCB_VISIBLE or in schematic
     */
    EDA_COLOR_T GetItemColor( int aItemIdx );
    EDA_COLOR_T GetItemColor( int aItemIdx ) const;

    /**
     * Function SetItemColor
+20 −26
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ public:
     * Loads a list of color settings for layers.
     * @param aSettings is a list of color settings.
     */
    virtual void ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings ) = 0;
    virtual void ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings ) = 0;

    /**
     * Function SetActiveLayer
@@ -114,7 +114,7 @@ public:
     * Returns current highlight setting.
     * @return True if highlight is enabled, false otherwise.
     */
    bool GetHighlight() const
    inline bool GetHighlight() const
    {
        return m_highlightEnabled;
    }
@@ -124,7 +124,7 @@ public:
     * Returns netcode of currently highlighted net.
     * @return Netcode of currently highlighted net.
     */
    int GetHighlightNetCode() const
    inline int GetHighlightNetCode() const
    {
        return m_highlightNetcode;
    }
@@ -182,7 +182,7 @@ public:
     * Returns the color responding to the one of EDA_COLOR_T enum values.
     * @param EDA_COLOR_T color equivalent.
     */
    const COLOR4D& TranslateColor( EDA_COLOR_T aColor ) 
    inline const COLOR4D& TranslateColor( EDA_COLOR_T aColor )
    {
        return m_legacyColorMap[aColor];
    }
@@ -192,7 +192,7 @@ public:
     * Returns current background color settings.
     * @return Background color.
     */
    const COLOR4D& GetBackgroundColor() const
    inline const COLOR4D& GetBackgroundColor() const
    {
        return m_backgroundColor;
    }
@@ -202,7 +202,7 @@ public:
     * Sets new color for background.
     * @param aColor is the new background color.
     */
    void SetBackgroundColor( const COLOR4D& aColor )
    inline void SetBackgroundColor( const COLOR4D& aColor )
    {
        m_backgroundColor = aColor;
    }
@@ -210,12 +210,12 @@ public:
protected:
    /**
     * Function update
     * Precalculates extra colors for layers (eg. highlighted, darkened and any needed version
     * Precalculates extra colors for layers (e.g. highlighted, darkened and any needed version
     * of base colors).
     */
    virtual void update();

    std::set<unsigned int> m_activeLayers; /// Stores active layers number
    std::set<unsigned int> m_activeLayers; ///< Stores active layers number

    /// Parameters for display modes
    bool    m_hiContrastEnabled;    ///< High contrast display mode on/off
@@ -268,31 +268,28 @@ public:
    virtual ~PAINTER();

    /**
     * Function ApplySettings
     * Loads colors and display modes settings that are going to be used when drawing items.
     * @param aSettings are settings to be applied.
     * Function SetGAL
     * Changes Graphics Abstraction Layer used for drawing items for a new one.
     * @param aGal is the new GAL instance.
     */
    virtual void ApplySettings( RENDER_SETTINGS* aSettings )
    void SetGAL( GAL* aGal )
    {
        m_settings.reset( aSettings );
        m_gal = aGal;
    }

    /**
     * Function SetGAL
     * Changes Graphics Abstraction Layer used for drawing items for a new one.
     * @param aGal is the new GAL instance.
     * Function ApplySettings
     * Loads colors and display modes settings that are going to be used when drawing items.
     * @param aSettings are settings to be applied.
     */
    void SetGAL( GAL* aGal );
    virtual void ApplySettings( const RENDER_SETTINGS* aSettings ) = 0;

    /**
     * Function GetSettings
     * Returns pointer to current settings that are going to be used when drawing items.
     * @return Current rendering settings.
     */
    virtual RENDER_SETTINGS* GetSettings() const
    {
        return m_settings.get();
    }
    virtual RENDER_SETTINGS* GetSettings() = 0;

    /**
     * Function Draw
@@ -309,9 +306,6 @@ protected:
    /// commands used to draw (eg. DrawLine, DrawCircle, etc.)
    GAL* m_gal;

    /// Colors and display modes settings that are going to be used when drawing items.
    boost::shared_ptr<RENDER_SETTINGS> m_settings;

    /// Color of brightened item frame
    COLOR4D m_brightenedColor;
};
+0 −13
Original line number Diff line number Diff line
@@ -855,19 +855,6 @@ void PCB_BASE_FRAME::LoadSettings( wxConfigBase* aCfg )
    view->SetLayerTarget( ITEM_GAL_LAYER( GP_OVERLAY ), KIGFX::TARGET_OVERLAY );
    view->SetLayerTarget( ITEM_GAL_LAYER( RATSNEST_VISIBLE ), KIGFX::TARGET_OVERLAY );

    // Apply layer coloring scheme & display options
    if( view->GetPainter() )
    {
        KIGFX::PCB_RENDER_SETTINGS* settings = new KIGFX::PCB_RENDER_SETTINGS();

        // Load layers' colors from PCB data
        settings->ImportLegacyColors( m_Pcb->GetColorsSettings() );
        view->GetPainter()->ApplySettings( settings );

        // Load display options (such as filled/outline display of items)
        settings->LoadDisplayOptions( DisplayOpt );
    }

    // WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" )
    // when reading doubles in config,
    // but forget to back to current locale. So we call SetLocaleTo_Default
Loading