From d3b31316ba9bec7bf2d8350e37f4d40c68e34c36 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 16 Jun 2015 17:03:36 +0200 Subject: [PATCH] Fixed module text visibility settings (GAL). --- common/draw_panel_gal.cpp | 2 +- pcbnew/class_module.cpp | 2 ++ pcbnew/class_text_mod.cpp | 45 ++++++++++++++++++++++------------- pcbnew/class_text_mod.h | 3 +++ pcbnew/pcb_draw_panel_gal.cpp | 15 ++++++++---- pcbnew/pcb_painter.cpp | 3 +++ 6 files changed, 48 insertions(+), 22 deletions(-) diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index caf381f2b9..71e27050e5 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -85,7 +85,7 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin wxEVT_MOTION, wxEVT_MOUSEWHEEL, wxEVT_CHAR, #ifdef USE_OSX_MAGNIFY_EVENT wxEVT_MAGNIFY, -#endif +#endif KIGFX::WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE }; diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 9c5201524d..e8e6944120 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -881,6 +881,7 @@ unsigned int MODULE::ViewGetLOD( int aLayer ) const return 30; } + const BOX2I MODULE::ViewBBox() const { EDA_RECT fpRect = GetFootprintRect(); @@ -888,6 +889,7 @@ const BOX2I MODULE::ViewBBox() const return BOX2I( VECTOR2I( fpRect.GetOrigin() ), VECTOR2I( fpRect.GetSize() ) ); } + /* Test for validity of the name in a library of the footprint * ( no spaces, dir separators ... ) * return true if the given name is valid diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 26b0374d33..9a7c237f59 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -476,29 +476,40 @@ const BOX2I TEXTE_MODULE::ViewBBox() const void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const { if( m_NoShow ) // Hidden text - { aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_INVISIBLE ); - } + //else if( IsFrontLayer( m_Layer ) ) + //aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ); + //else if( IsBackLayer( m_Layer ) ) + //aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ); else - { - switch( m_Type ) - { - case TEXT_is_REFERENCE: - aLayers[0] = ITEM_GAL_LAYER( MOD_REFERENCES_VISIBLE ); - break; - - case TEXT_is_VALUE: - aLayers[0] = ITEM_GAL_LAYER( MOD_VALUES_VISIBLE ); - break; - - case TEXT_is_DIVERS: - aLayers[0] = GetLayer(); - } - } + aLayers[0] = GetLayer(); aCount = 1; } + +unsigned int TEXTE_MODULE::ViewGetLOD( int aLayer ) const +{ + const int MAX = std::numeric_limits::max(); + + if( m_Type == TEXT_is_VALUE && !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_VALUES_VISIBLE ) ) ) + return MAX; + + if( m_Type == TEXT_is_REFERENCE && !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_REFERENCES_VISIBLE ) ) ) + return MAX; + + if( IsFrontLayer( m_Layer ) && ( !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ) ) || + !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_FR_VISIBLE ) ) ) ) + return MAX; + + if( IsBackLayer( m_Layer ) && ( !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ) ) || + !m_view->IsLayerVisible( ITEM_GAL_LAYER( MOD_BK_VISIBLE ) ) ) ) + return MAX; + + return 0; +} + + /** * Macro-expansion for text in library modules */ diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index 4ade64b213..16f263b7b4 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -181,6 +181,9 @@ public: /// @copydoc VIEW_ITEM::ViewGetLayers() virtual void ViewGetLayers( int aLayers[], int& aCount ) const; + /// @copydoc VIEW_ITEM::ViewGetLOD() + virtual unsigned int ViewGetLOD( int aLayer ) const; + #if defined(DEBUG) virtual void Show( int nestLevel, std::ostream& os ) const { ShowDummy( os ); } // override #endif diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index 15c6a92b99..ea3a8d3fad 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -135,18 +135,25 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aGalType ) m_view->SetRequired( ITEM_GAL_LAYER( PADS_HOLES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ) ); m_view->SetRequired( NETNAMES_GAL_LAYER( PADS_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PADS_VISIBLE ) ); + // Front modules + m_view->SetRequired( ITEM_GAL_LAYER( PAD_FR_VISIBLE ), ITEM_GAL_LAYER( MOD_FR_VISIBLE ) ); + m_view->SetRequired( ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ), ITEM_GAL_LAYER( MOD_FR_VISIBLE ) ); m_view->SetRequired( NETNAMES_GAL_LAYER( PAD_FR_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_FR_VISIBLE ) ); m_view->SetRequired( F_Adhes, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) ); m_view->SetRequired( F_Paste, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) ); m_view->SetRequired( F_Mask, ITEM_GAL_LAYER( PAD_FR_VISIBLE ) ); + m_view->SetRequired( F_CrtYd, ITEM_GAL_LAYER( MOD_FR_VISIBLE ) ); + m_view->SetRequired( F_Fab, ITEM_GAL_LAYER( MOD_FR_VISIBLE ) ); + // Back modules + m_view->SetRequired( ITEM_GAL_LAYER( PAD_BK_VISIBLE ), ITEM_GAL_LAYER( MOD_BK_VISIBLE ) ); + m_view->SetRequired( ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ), ITEM_GAL_LAYER( MOD_BK_VISIBLE ) ); m_view->SetRequired( NETNAMES_GAL_LAYER( PAD_BK_NETNAMES_VISIBLE ), ITEM_GAL_LAYER( PAD_BK_VISIBLE ) ); m_view->SetRequired( B_Adhes, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) ); m_view->SetRequired( B_Paste, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) ); m_view->SetRequired( B_Mask, ITEM_GAL_LAYER( PAD_BK_VISIBLE ) ); - - m_view->SetRequired( ITEM_GAL_LAYER( PAD_FR_VISIBLE ), ITEM_GAL_LAYER( MOD_FR_VISIBLE ) ); - m_view->SetRequired( ITEM_GAL_LAYER( PAD_BK_VISIBLE ), ITEM_GAL_LAYER( MOD_BK_VISIBLE ) ); + m_view->SetRequired( B_CrtYd, ITEM_GAL_LAYER( MOD_BK_VISIBLE ) ); + m_view->SetRequired( B_Fab, ITEM_GAL_LAYER( MOD_BK_VISIBLE ) ); m_view->SetLayerTarget( ITEM_GAL_LAYER( GP_OVERLAY ), KIGFX::TARGET_OVERLAY ); m_view->SetLayerDisplayOnly( ITEM_GAL_LAYER( GP_OVERLAY ) ); @@ -160,7 +167,7 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aGalType ) // Load display options (such as filled/outline display of items). // Can be made only if the parent windos is a EDA_DRAW_FRAME (or a derived class) // which is not always the case (namely when it is used from a wxDialog like the pad editor) - EDA_DRAW_FRAME* frame = dynamic_cast ( aParentWindow ); + EDA_DRAW_FRAME* frame = dynamic_cast( aParentWindow ); if( frame ) { diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 5c21908600..bd7775b2b5 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -71,6 +71,9 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSet m_layerColors[ITEM_GAL_LAYER( i )] = m_legacyColorMap[aSettings->GetItemColor( i )]; } + m_layerColors[ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE )] = m_layerColors[F_SilkS]; + m_layerColors[ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE )] = m_layerColors[B_SilkS]; + // Default colors for specific layers m_layerColors[ITEM_GAL_LAYER( VIAS_HOLES_VISIBLE )] = COLOR4D( 0.5, 0.4, 0.0, 0.8 ); m_layerColors[ITEM_GAL_LAYER( PADS_HOLES_VISIBLE )] = COLOR4D( 0.0, 0.5, 0.5, 0.8 );