You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

512 lines
14 KiB

10 years ago
Introduction of Graphics Abstraction Layer based rendering for pcbnew. New classes: - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.) - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes). - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL). - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries. - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc. - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods. - STROKE_FONT - Implements stroke font drawing using GAL methods. Most important changes to Kicad original code: * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects. * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime. * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew) * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom. * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime. * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods. * Removed tools/class_painter.h, as now it is extended and included in source code. Build changes: * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL. * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required. * GAL-related code is compiled into a static library (common/libgal). * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS). More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
13 years ago
Introduction of Graphics Abstraction Layer based rendering for pcbnew. New classes: - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.) - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes). - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL). - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries. - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc. - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods. - STROKE_FONT - Implements stroke font drawing using GAL methods. Most important changes to Kicad original code: * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects. * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime. * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew) * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom. * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime. * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods. * Removed tools/class_painter.h, as now it is extended and included in source code. Build changes: * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL. * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required. * GAL-related code is compiled into a static library (common/libgal). * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS). More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
13 years ago
9 years ago
Introduction of Graphics Abstraction Layer based rendering for pcbnew. New classes: - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.) - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes). - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL). - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries. - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc. - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods. - STROKE_FONT - Implements stroke font drawing using GAL methods. Most important changes to Kicad original code: * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects. * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime. * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew) * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom. * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime. * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods. * Removed tools/class_painter.h, as now it is extended and included in source code. Build changes: * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL. * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required. * GAL-related code is compiled into a static library (common/libgal). * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS). More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
13 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. #include <fctsys.h>
  26. #include <gr_basic.h>
  27. #include <trigo.h>
  28. #include <gr_text.h>
  29. #include <kicad_string.h>
  30. #include <common.h>
  31. #include <richio.h>
  32. #include <macros.h>
  33. #include <pcb_edit_frame.h>
  34. #include <msgpanel.h>
  35. #include <base_units.h>
  36. #include <bitmaps.h>
  37. #include <class_board.h>
  38. #include <class_module.h>
  39. #include <view/view.h>
  40. #include <pcbnew.h>
  41. #include <pgm_base.h>
  42. #include <settings/color_settings.h>
  43. #include <settings/settings_manager.h>
  44. #include <kiway.h>
  45. TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, TEXT_TYPE text_type ) :
  46. BOARD_ITEM( parent, PCB_MODULE_TEXT_T ),
  47. EDA_TEXT()
  48. {
  49. MODULE* module = static_cast<MODULE*>( m_Parent );
  50. m_Type = text_type;
  51. m_keepUpright = true;
  52. // Set text thickness to a default value
  53. SetThickness( Millimeter2iu( DEFAULT_TEXT_WIDTH ) );
  54. SetLayer( F_SilkS );
  55. // Set position and give a default layer if a valid parent footprint exists
  56. if( module && ( module->Type() == PCB_MODULE_T ) )
  57. {
  58. SetTextPos( module->GetPosition() );
  59. if( IsBackLayer( module->GetLayer() ) )
  60. {
  61. SetLayer( B_SilkS );
  62. SetMirrored( true );
  63. }
  64. }
  65. SetDrawCoord();
  66. }
  67. TEXTE_MODULE::~TEXTE_MODULE()
  68. {
  69. }
  70. void TEXTE_MODULE::SetTextAngle( double aAngle )
  71. {
  72. EDA_TEXT::SetTextAngle( NormalizeAngle360Min( aAngle ) );
  73. }
  74. bool TEXTE_MODULE::TextHitTest( const wxPoint& aPoint, int aAccuracy ) const
  75. {
  76. EDA_RECT rect = GetTextBox( -1 );
  77. wxPoint location = aPoint;
  78. rect.Inflate( aAccuracy );
  79. RotatePoint( &location, GetTextPos(), -GetDrawRotation() );
  80. return rect.Contains( location );
  81. }
  82. bool TEXTE_MODULE::TextHitTest( const EDA_RECT& aRect, bool aContains, int aAccuracy ) const
  83. {
  84. EDA_RECT rect = aRect;
  85. rect.Inflate( aAccuracy );
  86. if( aContains )
  87. return rect.Contains( GetBoundingBox() );
  88. else
  89. return rect.Intersects( GetTextBox( -1 ), GetDrawRotation() );
  90. }
  91. void TEXTE_MODULE::KeepUpright( double aOldOrientation, double aNewOrientation )
  92. {
  93. if( !IsKeepUpright() )
  94. return;
  95. double currentAngle = GetTextAngle() + aOldOrientation;
  96. double newAngle = GetTextAngle() + aNewOrientation;
  97. NORMALIZE_ANGLE_POS( currentAngle );
  98. NORMALIZE_ANGLE_POS( newAngle );
  99. bool isFlipped = currentAngle >= 1800.0;
  100. bool needsFlipped = newAngle >= 1800.0;
  101. if( isFlipped != needsFlipped )
  102. {
  103. if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT )
  104. SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
  105. else if( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
  106. SetHorizJustify(GR_TEXT_HJUSTIFY_LEFT );
  107. SetTextAngle( GetTextAngle() + 1800.0 );
  108. SetDrawCoord();
  109. }
  110. }
  111. void TEXTE_MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
  112. {
  113. // Used in footprint editing
  114. // Note also in module editor, m_Pos0 = m_Pos
  115. wxPoint pt = GetTextPos();
  116. RotatePoint( &pt, aRotCentre, aAngle );
  117. SetTextPos( pt );
  118. SetTextAngle( GetTextAngle() + aAngle );
  119. SetLocalCoord();
  120. }
  121. void TEXTE_MODULE::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
  122. {
  123. // flipping the footprint is relative to the X axis
  124. if( aFlipLeftRight )
  125. SetTextX( ::Mirror( GetTextPos().x, aCentre.x ) );
  126. else
  127. SetTextY( ::Mirror( GetTextPos().y, aCentre.y ) );
  128. SetTextAngle( -GetTextAngle() );
  129. SetLayer( FlipLayer( GetLayer() ) );
  130. SetMirrored( IsBackLayer( GetLayer() ) );
  131. SetLocalCoord();
  132. // adjust justified text for mirroring
  133. if( GetHorizJustify() == GR_TEXT_HJUSTIFY_LEFT || GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT )
  134. {
  135. if( ( GetHorizJustify() == GR_TEXT_HJUSTIFY_RIGHT ) == IsMirrored() )
  136. SetHorizJustify( (EDA_TEXT_HJUSTIFY_T)-GetHorizJustify() );
  137. else
  138. SetHorizJustify( (EDA_TEXT_HJUSTIFY_T)-GetHorizJustify() );
  139. SetDrawCoord();
  140. }
  141. }
  142. bool TEXTE_MODULE::IsParentFlipped() const
  143. {
  144. if( GetParent() && GetParent()->GetLayer() == B_Cu )
  145. return true;
  146. return false;
  147. }
  148. void TEXTE_MODULE::Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis )
  149. {
  150. // Used in modedit, to transform the footprint
  151. // the mirror is around the Y axis or X axis if aMirrorAroundXAxis = true
  152. // the position is mirrored, but the text itself is not mirrored
  153. if( aMirrorAroundXAxis )
  154. SetTextY( ::Mirror( GetTextPos().y, aCentre.y ) );
  155. else
  156. SetTextX( ::Mirror( GetTextPos().x, aCentre.x ) );
  157. SetLocalCoord();
  158. }
  159. void TEXTE_MODULE::Move( const wxPoint& aMoveVector )
  160. {
  161. Offset( aMoveVector );
  162. SetLocalCoord();
  163. }
  164. int TEXTE_MODULE::GetLength() const
  165. {
  166. return GetText().Len();
  167. }
  168. void TEXTE_MODULE::SetDrawCoord()
  169. {
  170. const MODULE* module = static_cast<const MODULE*>( m_Parent );
  171. SetTextPos( m_Pos0 );
  172. if( module )
  173. {
  174. double angle = module->GetOrientation();
  175. wxPoint pt = GetTextPos();
  176. RotatePoint( &pt, angle );
  177. SetTextPos( pt );
  178. Offset( module->GetPosition() );
  179. }
  180. }
  181. void TEXTE_MODULE::SetLocalCoord()
  182. {
  183. const MODULE* module = static_cast<const MODULE*>( m_Parent );
  184. if( module )
  185. {
  186. m_Pos0 = GetTextPos() - module->GetPosition();
  187. double angle = module->GetOrientation();
  188. RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle );
  189. }
  190. else
  191. {
  192. m_Pos0 = GetTextPos();
  193. }
  194. }
  195. const EDA_RECT TEXTE_MODULE::GetBoundingBox() const
  196. {
  197. double angle = GetDrawRotation();
  198. EDA_RECT text_area = GetTextBox( -1, -1 );
  199. if( angle )
  200. text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle );
  201. return text_area;
  202. }
  203. void TEXTE_MODULE::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
  204. {
  205. /* parent must *not* be NULL (a footprint text without a footprint parent has no sense) */
  206. wxASSERT( m_Parent );
  207. BOARD* brd = GetBoard( );
  208. KIGFX::COLOR4D color = Pgm().GetSettingsManager().GetColorSettings()->GetColor( GetLayer() );
  209. PCB_LAYER_ID text_layer = GetLayer();
  210. if( !brd->IsLayerVisible( m_Layer )
  211. || ( IsFrontLayer( text_layer ) && !brd->IsElementVisible( LAYER_MOD_TEXT_FR ) )
  212. || ( IsBackLayer( text_layer ) && !brd->IsElementVisible( LAYER_MOD_TEXT_BK ) ) )
  213. return;
  214. if( !brd->IsElementVisible( LAYER_MOD_REFERENCES ) && GetText() == wxT( "${REFERENCE}" ) )
  215. return;
  216. if( !brd->IsElementVisible( LAYER_MOD_VALUES ) && GetText() == wxT( "${VALUE}" ) )
  217. return;
  218. // Invisible texts are still drawn (not plotted) in LAYER_MOD_TEXT_INVISIBLE
  219. // Just because we must have to edit them (at least to make them visible)
  220. if( !IsVisible() )
  221. {
  222. if( !brd->IsElementVisible( LAYER_MOD_TEXT_INVISIBLE ) )
  223. return;
  224. color = Pgm().GetSettingsManager().GetColorSettings()->GetColor( LAYER_MOD_TEXT_INVISIBLE );
  225. }
  226. // Draw mode compensation for the width
  227. int width = GetThickness();
  228. if( aFrame->GetDisplayOptions().m_DisplayModTextFill == SKETCH )
  229. width = -width;
  230. wxPoint pos = GetTextPos() - aOffset;
  231. // Draw the text proper, with the right attributes
  232. wxSize size = GetTextSize();
  233. double orient = GetDrawRotation();
  234. // If the text is mirrored : negate size.x (mirror / Y axis)
  235. if( IsMirrored() )
  236. size.x = -size.x;
  237. GRText( aDC, pos, color, GetShownText(), orient, size, GetHorizJustify(), GetVertJustify(),
  238. width, IsItalic(), IsBold() );
  239. }
  240. double TEXTE_MODULE::GetDrawRotation() const
  241. {
  242. MODULE* module = (MODULE*) m_Parent;
  243. double rotation = GetTextAngle();
  244. if( module )
  245. rotation += module->GetOrientation();
  246. if( m_keepUpright )
  247. {
  248. // Keep angle between -90 .. 90 deg. Otherwise the text is not easy to read
  249. while( rotation > 900 )
  250. rotation -= 1800;
  251. while( rotation < -900 )
  252. rotation += 1800;
  253. }
  254. else
  255. {
  256. NORMALIZE_ANGLE_POS( rotation );
  257. }
  258. return rotation;
  259. }
  260. // see class_text_mod.h
  261. void TEXTE_MODULE::GetMsgPanelInfo( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList )
  262. {
  263. MODULE* module = (MODULE*) m_Parent;
  264. if( module == NULL ) // Happens in modedit, and for new texts
  265. return;
  266. wxString msg, Line;
  267. static const wxString text_type_msg[3] =
  268. {
  269. _( "Ref." ), _( "Value" ), _( "Text" )
  270. };
  271. Line = module->GetReference();
  272. aList.emplace_back( _( "Footprint" ), Line, DARKCYAN );
  273. Line = GetShownText();
  274. aList.emplace_back( _( "Text" ), Line, BROWN );
  275. wxASSERT( m_Type >= TEXT_is_REFERENCE && m_Type <= TEXT_is_DIVERS );
  276. aList.emplace_back( _( "Type" ), text_type_msg[m_Type], DARKGREEN );
  277. if( !IsVisible() )
  278. msg = _( "No" );
  279. else
  280. msg = _( "Yes" );
  281. aList.emplace_back( _( "Display" ), msg, DARKGREEN );
  282. // Display text layer
  283. aList.emplace_back( _( "Layer" ), GetLayerName(), DARKGREEN );
  284. if( IsMirrored() )
  285. msg = _( "Yes" );
  286. else
  287. msg = _( "No" );
  288. aList.emplace_back( _( "Mirror" ), msg, DARKGREEN );
  289. msg.Printf( wxT( "%.1f" ), GetTextAngleDegrees() );
  290. aList.emplace_back( _( "Angle" ), msg, DARKGREEN );
  291. msg = MessageTextFromValue( aUnits, GetThickness(), true );
  292. aList.emplace_back( _( "Thickness" ), msg, DARKGREEN );
  293. msg = MessageTextFromValue( aUnits, GetTextWidth(), true );
  294. aList.emplace_back( _( "Width" ), msg, RED );
  295. msg = MessageTextFromValue( aUnits, GetTextHeight(), true );
  296. aList.emplace_back( _( "Height" ), msg, RED );
  297. }
  298. wxString TEXTE_MODULE::GetSelectMenuText( EDA_UNITS aUnits ) const
  299. {
  300. switch( m_Type )
  301. {
  302. case TEXT_is_REFERENCE:
  303. return wxString::Format( _( "Reference %s" ),
  304. static_cast<MODULE*>( GetParent() )->GetReference() );
  305. case TEXT_is_VALUE:
  306. return wxString::Format( _( "Value %s of %s" ),
  307. GetShownText(),
  308. static_cast<MODULE*>( GetParent() )->GetReference() );
  309. default: // wrap this one in quotes:
  310. return wxString::Format( _( "Text \"%s\" of %s on %s" ),
  311. ShortenedShownText(),
  312. static_cast<MODULE*>( GetParent() )->GetReference(),
  313. GetLayerName() );
  314. }
  315. }
  316. BITMAP_DEF TEXTE_MODULE::GetMenuImage() const
  317. {
  318. return footprint_text_xpm;
  319. }
  320. EDA_ITEM* TEXTE_MODULE::Clone() const
  321. {
  322. return new TEXTE_MODULE( *this );
  323. }
  324. const BOX2I TEXTE_MODULE::ViewBBox() const
  325. {
  326. double angle = GetDrawRotation();
  327. EDA_RECT text_area = GetTextBox( -1, -1 );
  328. if( angle )
  329. text_area = text_area.GetBoundingBoxRotated( GetTextPos(), angle );
  330. return BOX2I( text_area.GetPosition(), text_area.GetSize() );
  331. }
  332. void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
  333. {
  334. if( IsVisible() )
  335. aLayers[0] = GetLayer();
  336. else
  337. aLayers[0] = LAYER_MOD_TEXT_INVISIBLE;
  338. aCount = 1;
  339. }
  340. unsigned int TEXTE_MODULE::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
  341. {
  342. const int HIDE = std::numeric_limits<unsigned int>::max();
  343. if( !aView )
  344. return 0;
  345. // Hidden text gets put on the LAYER_MOD_TEXT_INVISIBLE for rendering, but
  346. // should only render if its native layer is visible.
  347. if( !aView->IsLayerVisible( GetLayer() ) )
  348. return HIDE;
  349. // Handle Render tab switches
  350. if( ( m_Type == TEXT_is_VALUE || GetText() == wxT( "${VALUE}" ) )
  351. && !aView->IsLayerVisible( LAYER_MOD_VALUES ) )
  352. return HIDE;
  353. if( ( m_Type == TEXT_is_REFERENCE || GetText() == wxT( "${REFERENCE}" ) )
  354. && !aView->IsLayerVisible( LAYER_MOD_REFERENCES ) )
  355. return HIDE;
  356. if( !IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) )
  357. return HIDE;
  358. if( IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_BK ) )
  359. return HIDE;
  360. if( IsFrontLayer( m_Layer ) && !aView->IsLayerVisible( LAYER_MOD_TEXT_FR ) )
  361. return HIDE;
  362. if( IsBackLayer( m_Layer ) && !aView->IsLayerVisible( LAYER_MOD_TEXT_BK ) )
  363. return HIDE;
  364. // Other layers are shown without any conditions
  365. return 0;
  366. }
  367. wxString TEXTE_MODULE::GetShownText( int aDepth ) const
  368. {
  369. const MODULE* module = static_cast<MODULE*>( GetParent() );
  370. wxASSERT( module );
  371. std::function<bool( wxString* )> moduleResolver =
  372. [&]( wxString* token ) -> bool
  373. {
  374. return module && module->ResolveTextVar( token, aDepth );
  375. };
  376. PROJECT* project = nullptr;
  377. wxString text = EDA_TEXT::GetShownText( aDepth );
  378. if( module && module->GetParent() )
  379. project = static_cast<BOARD*>( module->GetParent() )->GetProject();
  380. if( aDepth < 10 )
  381. text = ExpandTextVars( text, &moduleResolver, project );
  382. return text;
  383. }