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

Moved highlighted flag from VIEW_ITEM to EDA_ITEM. Added brightened and selected flag to EDA_ITEM.

parent 8753bef2
Loading
Loading
Loading
Loading
+0 −7
Original line number Original line Diff line number Diff line
@@ -136,10 +136,3 @@ bool VIEW_ITEM::storesGroups() const
{
{
    return ( m_groupsSize > 0 );
    return ( m_groupsSize > 0 );
}
}


void VIEW_ITEM::ViewSetHighlighted( bool aIsHighlighted )
{
    m_highlighted = aIsHighlighted;
    ViewUpdate( APPEARANCE | GEOMETRY );
}
+13 −0
Original line number Original line Diff line number Diff line
@@ -387,6 +387,9 @@ public:
#define END_ONPAD      (1 << 23)   ///< Pcbnew: flag set for track segment ending on a pad
#define END_ONPAD      (1 << 23)   ///< Pcbnew: flag set for track segment ending on a pad
#define BUSY           (1 << 24)   ///< Pcbnew: flag indicating that the structure has
#define BUSY           (1 << 24)   ///< Pcbnew: flag indicating that the structure has
                                   ///< already been edited, in some functions
                                   ///< already been edited, in some functions
#define HIGHLIGHTED    (1 << 25)   ///< item is drawn in normal colors, when the rest is darkened
#define BRIGHTENED     (1 << 26)   ///< item is drawn with a bright contour

#define EDA_ITEM_ALL_FLAGS -1
#define EDA_ITEM_ALL_FLAGS -1


typedef unsigned STATUS_FLAGS;
typedef unsigned STATUS_FLAGS;
@@ -466,6 +469,16 @@ public:
    inline bool IsDragging() const { return m_Flags & IS_DRAGGED; }
    inline bool IsDragging() const { return m_Flags & IS_DRAGGED; }
    inline bool IsSelected() const { return m_Flags & SELECTED; }
    inline bool IsSelected() const { return m_Flags & SELECTED; }
    inline bool IsResized() const { return m_Flags & IS_RESIZED; }
    inline bool IsResized() const { return m_Flags & IS_RESIZED; }
    inline bool IsHighlighted() const { return m_Flags & HIGHLIGHTED; }
    inline bool IsBrightened() const { return m_Flags & BRIGHTENED; }

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

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


    void SetModified();
    void SetModified();


+4 −4
Original line number Original line Diff line number Diff line
@@ -75,12 +75,12 @@ public:
#endif /* WX_COMPATIBLITY */
#endif /* WX_COMPATIBLITY */


    /**
    /**
     * Function Highlight
     * Function Brighten
     * Makes the color brighter by a given factor.
     * Makes the color brighter by a given factor.
     * @param aFactor Specifies how bright the color should become (valid values: 0.0 .. 1.0).
     * @param aFactor Specifies how bright the color should become (valid values: 0.0 .. 1.0).
     * @return COLOR4D& Brightened color.
     * @return COLOR4D& Brightened color.
     */
     */
    COLOR4D& Highlight( double aFactor )
    COLOR4D& Brighten( double aFactor )
    {
    {
        r = r * ( 1.0 - aFactor ) + aFactor;
        r = r * ( 1.0 - aFactor ) + aFactor;
        g = g * ( 1.0 - aFactor ) + aFactor;
        g = g * ( 1.0 - aFactor ) + aFactor;
@@ -119,12 +119,12 @@ public:
    }
    }


    /**
    /**
     * Function Highlighted
     * Function Brightened
     * Returns a color that is brighter by a given factor, without modifying object.
     * Returns a color that is brighter by a given factor, without modifying object.
     * @param aFactor Specifies how bright the color should become (valid values: 0.0 .. 1.0).
     * @param aFactor Specifies how bright the color should become (valid values: 0.0 .. 1.0).
     * @return COLOR4D Highlightedd color.
     * @return COLOR4D Highlightedd color.
     */
     */
    COLOR4D Highlighted( double aFactor ) const
    COLOR4D Brightened( double aFactor ) const
    {
    {
        return COLOR4D( r * ( 1.0 - aFactor ) + aFactor,
        return COLOR4D( r * ( 1.0 - aFactor ) + aFactor,
                        g * ( 1.0 - aFactor ) + aFactor,
                        g * ( 1.0 - aFactor ) + aFactor,
+1 −23
Original line number Original line Diff line number Diff line
@@ -67,8 +67,7 @@ public:
        ALL = 0xff
        ALL = 0xff
    };
    };


    VIEW_ITEM() : m_view( NULL ), m_visible( true ), m_highlighted( false ),
    VIEW_ITEM() : m_view( NULL ), m_visible( true ), m_groups( NULL ), m_groupsSize( 0 ) {}
            m_groups( NULL ), m_groupsSize( 0 ) {}


    /**
    /**
     * Destructor. For dynamic views, removes the item from the view.
     * Destructor. For dynamic views, removes the item from the view.
@@ -135,25 +134,6 @@ public:
        return m_visible;
        return m_visible;
    }
    }


    /**
     * Function ViewSetHighlighted()
     * Sets the item highlight.
     *
     * @param aIsHighlighted: whether the item is highlighted (on all layers), or not.
     */
    void ViewSetHighlighted( bool aIsHighlighted = true );

    /**
     * Function ViewIsHighlighted()
     * Returns if the item is highlighted (or not).
     *
     * @return when true, the item should be displayed as highlighted.
     */
    bool ViewIsHighlighted() const
    {
        return m_highlighted;
    }

    /**
    /**
     * Function ViewGetLOD()
     * Function ViewGetLOD()
     * Returns the level of detail of the item. A level of detail is the minimal VIEW scale that
     * Returns the level of detail of the item. A level of detail is the minimal VIEW scale that
@@ -191,7 +171,6 @@ protected:
     *
     *
     * @param aView[]: dynamic VIEW instance the item is being added to.
     * @param aView[]: dynamic VIEW instance the item is being added to.
     */
     */

    void viewAssign( VIEW* aView )
    void viewAssign( VIEW* aView )
    {
    {
        // release the item from a previously assigned dynamic view (if there is any)
        // release the item from a previously assigned dynamic view (if there is any)
@@ -202,7 +181,6 @@ protected:


    VIEW*   m_view;         ///* Current dynamic view the item is assigned to.
    VIEW*   m_view;         ///* Current dynamic view the item is assigned to.
    bool    m_visible;      ///* Are we visible in the current dynamic VIEW.
    bool    m_visible;      ///* Are we visible in the current dynamic VIEW.
    bool    m_highlighted;  ///* Should item be drawn as highlighted


private:
private:
    ///* Helper for storing cached items group ids
    ///* Helper for storing cached items group ids
+26 −25
Original line number Original line Diff line number Diff line
@@ -143,17 +143,17 @@ void PCB_RENDER_SETTINGS::Update()
    for( int i = 0; i < NB_LAYERS; i++ )
    for( int i = 0; i < NB_LAYERS; i++ )
    {
    {
        m_layerColors[i].a   = m_layerOpacity;
        m_layerColors[i].a   = m_layerOpacity;
        m_layerColorsHi[i]   = m_layerColors[i].Highlighted( m_highlightFactor );
        m_layerColorsHi[i]   = m_layerColors[i].Brightened( m_highlightFactor );
        m_layerColorsDark[i] = m_layerColors[i].Darkened( 1.0 - m_highlightFactor );
        m_layerColorsDark[i] = m_layerColors[i].Darkened( 1.0 - m_highlightFactor );
        m_layerColorsSel[i]  = m_layerColors[i].Highlighted( m_selectFactor );
        m_layerColorsSel[i]  = m_layerColors[i].Brightened( m_selectFactor );
    }
    }


    for( int i = 0; i < END_PCB_VISIBLE_LIST; i++ )
    for( int i = 0; i < END_PCB_VISIBLE_LIST; i++ )
    {
    {
        m_itemColors[i].a   = m_layerOpacity;
        m_itemColors[i].a   = m_layerOpacity;
        m_itemColorsHi[i]   = m_itemColors[i].Highlighted( m_highlightFactor );
        m_itemColorsHi[i]   = m_itemColors[i].Brightened( m_highlightFactor );
        m_itemColorsDark[i] = m_itemColors[i].Darkened( 1.0 - m_highlightFactor );
        m_itemColorsDark[i] = m_itemColors[i].Darkened( 1.0 - m_highlightFactor );
        m_itemColorsSel[i]  = m_itemColors[i].Highlighted( m_selectFactor );
        m_itemColorsSel[i]  = m_itemColors[i].Brightened( m_selectFactor );
    }
    }


    m_hiContrastColor = COLOR4D( m_hiContrastFactor, m_hiContrastFactor, m_hiContrastFactor,
    m_hiContrastColor = COLOR4D( m_hiContrastFactor, m_hiContrastFactor, m_hiContrastFactor,
@@ -176,22 +176,23 @@ const COLOR4D& PCB_PAINTER::GetColor( const VIEW_ITEM* aItem, int aLayer )
    if( item )
    if( item )
        netCode = item->GetNet();
        netCode = item->GetNet();


    return getLayerColor( aLayer, netCode, aItem->ViewIsHighlighted() );
    return getLayerColor( aLayer, netCode,
            static_cast<const BOARD_ITEM*>( aItem )->IsSelected() );
}
}




const COLOR4D& PCB_PAINTER::getLayerColor( int aLayer, int aNetCode, bool aHighlighted ) const
const COLOR4D& PCB_PAINTER::getLayerColor( int aLayer, int aNetCode, bool aSelected ) const
{
{
    // Return grayish color for non-highlightezd layers in the high contrast mode
    // Return grayish color for non-highlighted layers in the high contrast mode
    if( m_pcbSettings->m_hiContrastEnabled && m_pcbSettings->m_activeLayers.count( aLayer ) == 0 )
    if( m_pcbSettings->m_hiContrastEnabled && m_pcbSettings->m_activeLayers.count( aLayer ) == 0 )
        return m_pcbSettings->m_hiContrastColor;
        return m_pcbSettings->m_hiContrastColor;


    // For item layers (vias, texts, and so on)
    // For item layers (vias, texts, and so on)
    if( aLayer >= NB_LAYERS )
    if( aLayer >= NB_LAYERS )
        return getItemColor( aLayer - NB_LAYERS, aNetCode, aHighlighted );
        return getItemColor( aLayer - NB_LAYERS, aNetCode, aSelected );


    // Highlight per item basis
    // Highlight per item basis
    if( aHighlighted )
    if( aSelected )
        return m_pcbSettings->m_layerColorsHi[aLayer];
        return m_pcbSettings->m_layerColorsHi[aLayer];


    // Single net highlight mode
    // Single net highlight mode
@@ -208,10 +209,10 @@ const COLOR4D& PCB_PAINTER::getLayerColor( int aLayer, int aNetCode, bool aHighl
}
}




const COLOR4D& PCB_PAINTER::getItemColor( int aItemType, int aNetCode, bool aHighlighted ) const
const COLOR4D& PCB_PAINTER::getItemColor( int aItemType, int aNetCode, bool aSelected ) const
{
{
    // Highlight per item basis
    // Highlight per item basis
    if( aHighlighted )
    if( aSelected )
        return m_pcbSettings->m_itemColorsHi[aItemType];
        return m_pcbSettings->m_itemColorsHi[aItemType];


    if( m_pcbSettings->m_highlightEnabled )
    if( m_pcbSettings->m_highlightEnabled )
@@ -308,8 +309,8 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )


            // Set a proper color for the label
            // Set a proper color for the label
            color = getLayerColor( aTrack->GetLayer(), aTrack->GetNet(),
            color = getLayerColor( aTrack->GetLayer(), aTrack->GetNet(),
                                   aTrack->ViewIsHighlighted() );
                                   aTrack->IsSelected() );
            COLOR4D labelColor = getLayerColor( aLayer, 0, aTrack->ViewIsHighlighted() );
            COLOR4D labelColor = getLayerColor( aLayer, 0, aTrack->IsSelected() );


            if( color.GetBrightness() > 0.5 )
            if( color.GetBrightness() > 0.5 )
                m_gal->SetStrokeColor( labelColor.Inverted() );
                m_gal->SetStrokeColor( labelColor.Inverted() );
@@ -329,7 +330,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
    else if( IsCopperLayer( aLayer ))
    else if( IsCopperLayer( aLayer ))
    {
    {
        // Draw a regular track
        // Draw a regular track
        color = getLayerColor( aLayer, netNumber, aTrack->ViewIsHighlighted() );
        color = getLayerColor( aLayer, netNumber, aTrack->IsSelected() );
        m_gal->SetStrokeColor( color );
        m_gal->SetStrokeColor( color );
        m_gal->SetIsStroke( true );
        m_gal->SetIsStroke( true );


@@ -368,7 +369,7 @@ void PCB_PAINTER::draw( const SEGVIA* aVia, int aLayer )
    else
    else
        return;
        return;


    color = getLayerColor( aLayer, aVia->GetNet(), aVia->ViewIsHighlighted() );
    color = getLayerColor( aLayer, aVia->GetNet(), aVia->IsSelected() );


    if( m_pcbSettings->m_sketchModeSelect[VIAS_VISIBLE] )
    if( m_pcbSettings->m_sketchModeSelect[VIAS_VISIBLE] )
    {
    {
@@ -448,8 +449,8 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )


            // Set a proper color for the label
            // Set a proper color for the label
            color = getLayerColor( aPad->GetParent()->GetLayer(), aPad->GetNet(),
            color = getLayerColor( aPad->GetParent()->GetLayer(), aPad->GetNet(),
                                   aPad->ViewIsHighlighted() );
                                   aPad->IsSelected() );
            COLOR4D labelColor = getLayerColor( aLayer, 0, aPad->ViewIsHighlighted() );
            COLOR4D labelColor = getLayerColor( aLayer, 0, aPad->IsSelected() );


            if( color.GetBrightness() > 0.5 )
            if( color.GetBrightness() > 0.5 )
                m_gal->SetStrokeColor( labelColor.Inverted() );
                m_gal->SetStrokeColor( labelColor.Inverted() );
@@ -494,7 +495,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
        return;
        return;
    }
    }


    color = getLayerColor( aLayer, aPad->GetNet(), aPad->ViewIsHighlighted() );
    color = getLayerColor( aLayer, aPad->GetNet(), aPad->IsSelected() );
    if( m_pcbSettings->m_sketchModeSelect[PADS_VISIBLE] )
    if( m_pcbSettings->m_sketchModeSelect[PADS_VISIBLE] )
    {
    {
        // Outline mode
        // Outline mode
@@ -617,7 +618,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )


void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment )
void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment )
{
{
    COLOR4D color = getLayerColor( aSegment->GetLayer(), 0, aSegment->ViewIsHighlighted() );
    COLOR4D color = getLayerColor( aSegment->GetLayer(), 0, aSegment->IsSelected() );


    m_gal->SetIsFill( false );
    m_gal->SetIsFill( false );
    m_gal->SetIsStroke( true );
    m_gal->SetIsStroke( true );
@@ -691,7 +692,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText )
    if( aText->GetText().Length() == 0 )
    if( aText->GetText().Length() == 0 )
        return;
        return;


    COLOR4D  strokeColor = getLayerColor( aText->GetLayer(), 0, aText->ViewIsHighlighted() );
    COLOR4D  strokeColor = getLayerColor( aText->GetLayer(), 0, aText->IsSelected() );
    VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y );
    VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y );
    double   orientation = aText->GetOrientation() * M_PI / 1800.0;
    double   orientation = aText->GetOrientation() * M_PI / 1800.0;


@@ -707,13 +708,13 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
    if( aText->GetLength() == 0 )
    if( aText->GetLength() == 0 )
        return;
        return;


    COLOR4D  strokeColor = getLayerColor( aLayer, 0, aText->ViewIsHighlighted() );
    COLOR4D  strokeColor = getLayerColor( aLayer, 0, aText->IsSelected() );
    VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y);
    VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y);
    double   orientation = aText->GetDrawRotation() * M_PI / 1800.0;
    double   orientation = aText->GetDrawRotation() * M_PI / 1800.0;


    m_gal->PushDepth();
    m_gal->PushDepth();


    if(aText->ViewIsHighlighted())
    if(aText->IsSelected())
    {
    {
        EDA_RECT bb (aText->GetBoundingBox());
        EDA_RECT bb (aText->GetBoundingBox());
        VECTOR2D s (bb.GetOrigin());
        VECTOR2D s (bb.GetOrigin());
@@ -741,7 +742,7 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone )
void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone )
{
{
    COLOR4D color = getLayerColor( aZone->GetLayer(), aZone->GetNet(),
    COLOR4D color = getLayerColor( aZone->GetLayer(), aZone->GetNet(),
                                   aZone->ViewIsHighlighted() );
                                   aZone->IsSelected() );
    std::deque<VECTOR2D> corners;
    std::deque<VECTOR2D> corners;
    PCB_RENDER_SETTINGS::DisplayZonesMode displayMode = m_pcbSettings->m_displayZoneMode;
    PCB_RENDER_SETTINGS::DisplayZonesMode displayMode = m_pcbSettings->m_displayZoneMode;


@@ -811,7 +812,7 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone )
void PCB_PAINTER::draw( const DIMENSION* aDimension )
void PCB_PAINTER::draw( const DIMENSION* aDimension )
{
{
    COLOR4D strokeColor = getLayerColor( aDimension->GetLayer(), 0,
    COLOR4D strokeColor = getLayerColor( aDimension->GetLayer(), 0,
                                         aDimension->ViewIsHighlighted() );
                                         aDimension->IsSelected() );


    m_gal->SetStrokeColor( strokeColor );
    m_gal->SetStrokeColor( strokeColor );
    m_gal->SetIsFill( false );
    m_gal->SetIsFill( false );
@@ -834,7 +835,7 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension )


void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
{
{
    COLOR4D  strokeColor = getLayerColor( aTarget->GetLayer(), 0, aTarget->ViewIsHighlighted() );
    COLOR4D  strokeColor = getLayerColor( aTarget->GetLayer(), 0, aTarget->IsSelected() );
    VECTOR2D position( aTarget->GetPosition() );
    VECTOR2D position( aTarget->GetPosition() );
    double   size, radius;
    double   size, radius;


Loading