diff --git a/common/eda_item.cpp b/common/eda_item.cpp index 6a44413d46..63c1a0dd74 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -37,7 +37,6 @@ EDA_ITEM::EDA_ITEM( EDA_ITEM* parent, KICAD_T idType ) : m_status( 0 ), m_parent( parent ), m_forceVisible( false ), - m_forceTransparency( 0.0 ), m_flags( 0 ), m_structType( idType ) { } @@ -47,7 +46,6 @@ EDA_ITEM::EDA_ITEM( KICAD_T idType ) : m_status( 0 ), m_parent( nullptr ), m_forceVisible( false ), - m_forceTransparency( 0.0 ), m_flags( 0 ), m_structType( idType ) { } @@ -58,10 +56,11 @@ EDA_ITEM::EDA_ITEM( const EDA_ITEM& base ) : m_status( base.m_status ), m_parent( base.m_parent ), m_forceVisible( base.m_forceVisible ), - m_forceTransparency( base.m_forceTransparency ), m_flags( base.m_flags ), m_structType( base.m_structType ) -{ } +{ + SetForcedTransparency( base.GetForcedTransparency() ); +} void EDA_ITEM::SetModified() @@ -244,12 +243,13 @@ EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem ) { // do not call initVars() - m_structType = aItem.m_structType; - m_flags = aItem.m_flags; - m_status = aItem.m_status; - m_parent = aItem.m_parent; - m_forceVisible = aItem.m_forceVisible; - m_forceTransparency = aItem.m_forceTransparency; + m_structType = aItem.m_structType; + m_flags = aItem.m_flags; + m_status = aItem.m_status; + m_parent = aItem.m_parent; + m_forceVisible = aItem.m_forceVisible; + + SetForcedTransparency( aItem.GetForcedTransparency() ); return *this; } diff --git a/common/view/view.cpp b/common/view/view.cpp index ef533aeeb5..b2578f47c4 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -927,7 +927,8 @@ struct VIEW::DRAW_ITEM_VISITOR view( aView ), layer( aLayer ), useDrawPriority( aUseDrawPriority ), - reverseDrawOrder( aReverseDrawOrder ) + reverseDrawOrder( aReverseDrawOrder ), + drawForcedTransparent( false ) { } @@ -935,6 +936,12 @@ struct VIEW::DRAW_ITEM_VISITOR { wxCHECK( aItem->viewPrivData(), false ); + if( aItem->m_forcedTransparency > 0 && !drawForcedTransparent ) + { + foundForcedTransparent = true; + return true; + } + // Conditions that have to be fulfilled for an item to be drawn bool drawCondition = aItem->viewPrivData()->isRenderable() && aItem->ViewGetLOD( layer, view ) < view->m_scale; @@ -976,6 +983,8 @@ struct VIEW::DRAW_ITEM_VISITOR int layer, layers[VIEW_MAX_LAYERS]; bool useDrawPriority, reverseDrawOrder; std::vector drawItems; + bool drawForcedTransparent; + bool foundForcedTransparent; }; @@ -997,7 +1006,6 @@ void VIEW::redrawRect( const BOX2I& aRect ) else if( l->hasNegatives ) m_gal->StartNegativesLayer(); - l->items->Query( aRect, drawFunc ); if( m_useDrawPriority ) @@ -1007,6 +1015,17 @@ void VIEW::redrawRect( const BOX2I& aRect ) m_gal->EndDiffLayer(); else if( l->hasNegatives ) m_gal->EndNegativesLayer(); + + if( drawFunc.foundForcedTransparent ) + { + drawFunc.drawForcedTransparent = true; + + m_gal->SetTarget( TARGET_NONCACHED ); + m_gal->EnableDepthTest( true ); + m_gal->SetLayerDepth( l->renderingOrder ); + + l->items->Query( aRect, drawFunc ); + } } } } diff --git a/common/widgets/footprint_diff_widget.cpp b/common/widgets/footprint_diff_widget.cpp index a44cdf2e01..545ab7bc13 100644 --- a/common/widgets/footprint_diff_widget.cpp +++ b/common/widgets/footprint_diff_widget.cpp @@ -95,12 +95,12 @@ void FOOTPRINT_DIFF_WIDGET::onSlider( wxScrollEvent& aEvent ) else val = ( pct - 0.5 ) * 2; - m_boardItemCopy->SetForceTransparency( val ); + m_boardItemCopy->SetForcedTransparency( val ); m_boardItemCopy->RunOnChildren( [&]( BOARD_ITEM* child ) { - child->SetForceTransparency( val ); + child->SetForcedTransparency( val ); } ); } @@ -113,12 +113,12 @@ void FOOTPRINT_DIFF_WIDGET::onSlider( wxScrollEvent& aEvent ) else val = 1.0 - ( pct * 2 ); - m_libraryItem->SetForceTransparency( val ); + m_libraryItem->SetForcedTransparency( val ); m_libraryItem->RunOnChildren( [&]( BOARD_ITEM* child ) { - child->SetForceTransparency( val ); + child->SetForcedTransparency( val ); } ); } diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index 3cf79f0b0e..c14487ffb2 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -498,8 +498,8 @@ COLOR4D SCH_PAINTER::getRenderColor( const EDA_ITEM *aItem, int aLayer, bool aDr color = color.Mix( sheetColour, 0.5f ); } - if( aItem->GetForceTransparency() > 0.0 ) - color = color.WithAlpha( color.a * ( 1.0 - aItem->GetForceTransparency() ) ); + if( aItem->GetForcedTransparency() > 0.0 ) + color = color.WithAlpha( color.a * ( 1.0 - aItem->GetForcedTransparency() ) ); return color; } diff --git a/eeschema/widgets/symbol_diff_widget.cpp b/eeschema/widgets/symbol_diff_widget.cpp index c26f176652..88f79b7eac 100644 --- a/eeschema/widgets/symbol_diff_widget.cpp +++ b/eeschema/widgets/symbol_diff_widget.cpp @@ -131,12 +131,12 @@ void SYMBOL_DIFF_WIDGET::onSlider( wxScrollEvent& aEvent ) else val = ( pct - 0.5 ) * 2; - m_previewItem->SetForceTransparency( val ); + m_previewItem->SetForcedTransparency( val ); view->Update( m_previewItem ); for( LIB_ITEM& child : m_previewItem->GetDrawItems() ) { - child.SetForceTransparency( val ); + child.SetForcedTransparency( val ); view->Update( &child ); } } @@ -150,12 +150,12 @@ void SYMBOL_DIFF_WIDGET::onSlider( wxScrollEvent& aEvent ) else val = 1.0 - ( pct * 2 ); - m_libraryItem->SetForceTransparency( val ); + m_libraryItem->SetForcedTransparency( val ); view->Update( m_libraryItem ); for( LIB_ITEM& child : m_libraryItem->GetDrawItems() ) { - child.SetForceTransparency( val ); + child.SetForcedTransparency( val ); view->Update( &child ); } } diff --git a/include/eda_item.h b/include/eda_item.h index 29973ba17b..fd2d4709ec 100644 --- a/include/eda_item.h +++ b/include/eda_item.h @@ -199,9 +199,6 @@ public: void SetForceVisible( bool aEnable ) { m_forceVisible = aEnable; } bool IsForceVisible() const { return m_forceVisible; } - void SetForceTransparency( double aTransparency ) { m_forceTransparency = aTransparency; } - double GetForceTransparency() const { return m_forceTransparency; } - /** * Populate \a aList of #MSG_PANEL_ITEM objects with it's internal state for display * purposes. @@ -497,7 +494,6 @@ protected: EDA_ITEM_FLAGS m_status; EDA_ITEM* m_parent; ///< Linked list: Link (parent struct) bool m_forceVisible; - double m_forceTransparency; EDA_ITEM_FLAGS m_flags; private: diff --git a/include/view/view_item.h b/include/view/view_item.h index 96edccdf0f..a23f4d30c9 100644 --- a/include/view/view_item.h +++ b/include/view/view_item.h @@ -76,7 +76,9 @@ enum VIEW_VISIBILITY_FLAGS { class VIEW_ITEM : public INSPECTABLE { public: - VIEW_ITEM() : m_viewPrivData( nullptr ) + VIEW_ITEM() : + m_viewPrivData( nullptr ), + m_forcedTransparency( 0.0 ) { } @@ -145,10 +147,21 @@ public: m_viewPrivData = nullptr; } + void SetForcedTransparency( double aForcedTransparency ) + { + m_forcedTransparency = aForcedTransparency; + } + + double GetForcedTransparency() const + { + return m_forcedTransparency; + } + private: friend class VIEW; VIEW_ITEM_DATA* m_viewPrivData; + double m_forcedTransparency; ///< Additional transparency for diff'ing items. }; } // namespace KIGFX diff --git a/pcbnew/footprint_preview_panel.cpp b/pcbnew/footprint_preview_panel.cpp index 337195581e..4b3639fe74 100644 --- a/pcbnew/footprint_preview_panel.cpp +++ b/pcbnew/footprint_preview_panel.cpp @@ -212,9 +212,8 @@ void FOOTPRINT_PREVIEW_PANEL::DisplayFootprints( std::shared_ptr aFoo fitToCurrentFootprint(); } - Show(); Layout(); - RefreshAll(); + Show(); } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index ed237d24f8..b5002264a3 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -434,8 +434,8 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons else if( item->Type() == PCB_BITMAP_T ) color.a *= m_imageOpacity; - if( item->GetForceTransparency() > 0.0 ) - color = color.WithAlpha( color.a * ( 1.0 - item->GetForceTransparency() ) ); + if( item->GetForcedTransparency() > 0.0 ) + color = color.WithAlpha( color.a * ( 1.0 - item->GetForcedTransparency() ) ); // No special modifiers enabled return color;