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.

452 lines
12 KiB

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
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
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
  5. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 1992-2012 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. /**
  26. * @file class_module.cpp
  27. * @brief TEXT_MODULE class implementation.
  28. */
  29. #include <fctsys.h>
  30. #include <gr_basic.h>
  31. #include <wxstruct.h>
  32. #include <trigo.h>
  33. #include <class_drawpanel.h>
  34. #include <drawtxt.h>
  35. #include <kicad_string.h>
  36. #include <pcbcommon.h>
  37. #include <colors_selection.h>
  38. #include <richio.h>
  39. #include <macros.h>
  40. #include <wxBasePcbFrame.h>
  41. #include <msgpanel.h>
  42. #include <base_units.h>
  43. #include <class_board.h>
  44. #include <class_module.h>
  45. #include <pcbnew.h>
  46. TEXTE_MODULE::TEXTE_MODULE( MODULE* parent, TEXT_TYPE text_type ) :
  47. BOARD_ITEM( parent, PCB_MODULE_TEXT_T ),
  48. EDA_TEXT()
  49. {
  50. MODULE* module = (MODULE*) m_Parent;
  51. m_Type = text_type;
  52. m_NoShow = false;
  53. // Set text tickness to a default value
  54. m_Thickness = Millimeter2iu( 0.15 );
  55. SetLayer( SILKSCREEN_N_FRONT );
  56. if( module && ( module->Type() == PCB_MODULE_T ) )
  57. {
  58. m_Pos = module->GetPosition();
  59. if( IsBackLayer( module->GetLayer() ) )
  60. {
  61. SetLayer( SILKSCREEN_N_BACK );
  62. m_Mirror = true;
  63. }
  64. else
  65. {
  66. SetLayer( SILKSCREEN_N_FRONT );
  67. m_Mirror = false;
  68. }
  69. }
  70. }
  71. TEXTE_MODULE::~TEXTE_MODULE()
  72. {
  73. }
  74. void TEXTE_MODULE::Rotate( const wxPoint& aRotCentre, double aAngle )
  75. {
  76. RotatePoint( &m_Pos, aRotCentre, aAngle );
  77. m_Orient += aAngle;
  78. NORMALIZE_ANGLE_360( m_Orient );
  79. }
  80. void TEXTE_MODULE::Flip(const wxPoint& aCentre )
  81. {
  82. m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y );
  83. SetLayer( FlipLayer( GetLayer() ) );
  84. m_Mirror = !m_Mirror;
  85. }
  86. void TEXTE_MODULE::Copy( TEXTE_MODULE* source )
  87. {
  88. if( source == NULL )
  89. return;
  90. m_Pos = source->m_Pos;
  91. SetLayer( source->GetLayer() );
  92. m_Mirror = source->m_Mirror;
  93. m_NoShow = source->m_NoShow;
  94. m_Type = source->m_Type;
  95. m_Orient = source->m_Orient;
  96. m_Pos0 = source->m_Pos0;
  97. m_Size = source->m_Size;
  98. m_Thickness = source->m_Thickness;
  99. m_Italic = source->m_Italic;
  100. m_Bold = source->m_Bold;
  101. m_Text = source->m_Text;
  102. }
  103. int TEXTE_MODULE::GetLength() const
  104. {
  105. return m_Text.Len();
  106. }
  107. // Update draw coordinates
  108. void TEXTE_MODULE::SetDrawCoord()
  109. {
  110. MODULE* module = (MODULE*) m_Parent;
  111. m_Pos = m_Pos0;
  112. if( module == NULL )
  113. return;
  114. double angle = module->GetOrientation();
  115. RotatePoint( &m_Pos.x, &m_Pos.y, angle );
  116. m_Pos += module->GetPosition();
  117. }
  118. // Update "local" coordinates (coordinates relatives to the footprint
  119. // anchor point)
  120. void TEXTE_MODULE::SetLocalCoord()
  121. {
  122. MODULE* module = (MODULE*) m_Parent;
  123. if( module == NULL )
  124. {
  125. m_Pos0 = m_Pos;
  126. return;
  127. }
  128. m_Pos0 = m_Pos - module->GetPosition();
  129. double angle = module->GetOrientation();
  130. RotatePoint( &m_Pos0.x, &m_Pos0.y, -angle );
  131. }
  132. bool TEXTE_MODULE::HitTest( const wxPoint& aPosition )
  133. {
  134. wxPoint rel_pos;
  135. EDA_RECT area = GetTextBox( -1, -1 );
  136. /* Rotate refPos to - angle
  137. * to test if refPos is within area (which is relative to an horizontal
  138. * text)
  139. */
  140. rel_pos = aPosition;
  141. RotatePoint( &rel_pos, m_Pos, -GetDrawRotation() );
  142. if( area.Contains( rel_pos ) )
  143. return true;
  144. return false;
  145. }
  146. /*
  147. * Function GetBoundingBox (virtual)
  148. * returns the bounding box of this Text (according to text and footprint
  149. * orientation)
  150. */
  151. const EDA_RECT TEXTE_MODULE::GetBoundingBox() const
  152. {
  153. double angle = GetDrawRotation();
  154. EDA_RECT text_area = GetTextBox( -1, -1 );
  155. if( angle )
  156. text_area = text_area.GetBoundingBoxRotated( m_Pos, m_Orient );
  157. return text_area;
  158. }
  159. /**
  160. * Function Draw
  161. * Draw the text according to the footprint pos and orient
  162. * @param panel = draw panel, Used to know the clip box
  163. * @param DC = Current Device Context
  164. * @param offset = draw offset (usually wxPoint(0,0)
  165. * @param draw_mode = GR_OR, GR_XOR..
  166. */
  167. void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
  168. const wxPoint& offset )
  169. {
  170. MODULE* module = (MODULE*) m_Parent;
  171. /* parent must *not* be NULL (a module text without a footprint
  172. parent has no sense) */
  173. wxASSERT( module );
  174. if( panel == NULL )
  175. return;
  176. BOARD* brd = GetBoard( );
  177. EDA_COLOR_T color;
  178. // Determine the element color or suppress it element if hidden
  179. switch( module->GetLayer() )
  180. {
  181. case LAYER_N_BACK:
  182. if( !brd->IsElementVisible( MOD_TEXT_BK_VISIBLE ) )
  183. return;
  184. color = brd->GetVisibleElementColor( MOD_TEXT_BK_VISIBLE );
  185. break;
  186. case LAYER_N_FRONT:
  187. if( !brd->IsElementVisible( MOD_TEXT_FR_VISIBLE ) )
  188. return;
  189. color = brd->GetVisibleElementColor( MOD_TEXT_FR_VISIBLE );
  190. break;
  191. default:
  192. color = brd->GetLayerColor( module->GetLayer() );
  193. }
  194. // 'Ghost' the element if forced show
  195. if( m_NoShow )
  196. {
  197. if( !brd->IsElementVisible( MOD_TEXT_INVISIBLE ) )
  198. return;
  199. color = brd->GetVisibleElementColor( MOD_TEXT_INVISIBLE );
  200. }
  201. // Draw mode compensation for the width
  202. PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
  203. int width = m_Thickness;
  204. if( ( frame->m_DisplayModText == LINE )
  205. || ( DC->LogicalToDeviceXRel( width ) <= MIN_DRAW_WIDTH ) )
  206. width = 0;
  207. else if( frame->m_DisplayModText == SKETCH )
  208. width = -width;
  209. GRSetDrawMode( DC, draw_mode );
  210. wxPoint pos( m_Pos.x - offset.x,
  211. m_Pos.y - offset.y);
  212. // Draw the text anchor point
  213. if( brd->IsElementVisible( ANCHOR_VISIBLE ) )
  214. {
  215. EDA_COLOR_T anchor_color = brd->GetVisibleElementColor(ANCHOR_VISIBLE);
  216. GRDrawAnchor( panel->GetClipBox(), DC, pos.x, pos.y,
  217. DIM_ANCRE_TEXTE, anchor_color );
  218. }
  219. // Draw the text proper, with the right attributes
  220. wxSize size = m_Size;
  221. double orient = GetDrawRotation();
  222. // If the text is mirrored : negate size.x (mirror / Y axis)
  223. if( m_Mirror )
  224. size.x = -size.x;
  225. EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
  226. DrawGraphicText( clipbox, DC, pos, color, m_Text, orient,
  227. size, m_HJustify, m_VJustify, width, m_Italic, m_Bold );
  228. // Enable these line to draw the bounding box (debug tests purposes only)
  229. #if 0
  230. {
  231. EDA_RECT BoundaryBox = GetBoundingBox();
  232. GRRect( clipbox, DC, BoundaryBox, 0, BROWN );
  233. }
  234. #endif
  235. }
  236. /* Draws a line from the TEXTE_MODULE origin to parent MODULE origin.
  237. */
  238. void TEXTE_MODULE::DrawUmbilical( EDA_DRAW_PANEL* aPanel,
  239. wxDC* aDC,
  240. GR_DRAWMODE aDrawMode,
  241. const wxPoint& aOffset )
  242. {
  243. MODULE* parent = (MODULE*) GetParent();
  244. if( !parent )
  245. return;
  246. GRSetDrawMode( aDC, GR_XOR );
  247. GRLine( aPanel->GetClipBox(), aDC,
  248. parent->GetPosition(), GetTextPosition() + aOffset,
  249. 0, UMBILICAL_COLOR);
  250. }
  251. /* Return text rotation for drawings and plotting
  252. */
  253. double TEXTE_MODULE::GetDrawRotation() const
  254. {
  255. MODULE* module = (MODULE*) m_Parent;
  256. double rotation = m_Orient;
  257. if( module )
  258. rotation += module->GetOrientation();
  259. NORMALIZE_ANGLE_POS( rotation );
  260. // For angle = 0 .. 180 deg
  261. while( rotation > 900 )
  262. rotation -= 1800;
  263. return rotation;
  264. }
  265. // see class_text_mod.h
  266. void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
  267. {
  268. MODULE* module = (MODULE*) m_Parent;
  269. if( module == NULL ) // Happens in modedit, and for new texts
  270. return;
  271. wxString msg, Line;
  272. static const wxString text_type_msg[3] =
  273. {
  274. _( "Ref." ), _( "Value" ), _( "Text" )
  275. };
  276. Line = module->GetReference();
  277. aList.push_back( MSG_PANEL_ITEM( _( "Module" ), Line, DARKCYAN ) );
  278. Line = m_Text;
  279. aList.push_back( MSG_PANEL_ITEM( _( "Text" ), Line, BROWN ) );
  280. wxASSERT( m_Type >= TEXT_is_REFERENCE && m_Type <= TEXT_is_DIVERS );
  281. aList.push_back( MSG_PANEL_ITEM( _( "Type" ), text_type_msg[m_Type], DARKGREEN ) );
  282. if( m_NoShow )
  283. msg = _( "No" );
  284. else
  285. msg = _( "Yes" );
  286. aList.push_back( MSG_PANEL_ITEM( _( "Display" ), msg, DARKGREEN ) );
  287. // Display text layer
  288. aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), DARKGREEN ) );
  289. if( m_Mirror )
  290. msg = _( " Yes" );
  291. else
  292. msg = _( " No" );
  293. aList.push_back( MSG_PANEL_ITEM( _( "Mirror" ), msg, DARKGREEN ) );
  294. msg.Printf( wxT( "%.1f" ), m_Orient / 10.0 );
  295. aList.push_back( MSG_PANEL_ITEM( _( "Orient" ), msg, DARKGREEN ) );
  296. msg = ::CoordinateToString( m_Thickness );
  297. aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, DARKGREEN ) );
  298. msg = ::CoordinateToString( m_Size.x );
  299. aList.push_back( MSG_PANEL_ITEM( _( "H Size" ), msg, RED ) );
  300. msg = ::CoordinateToString( m_Size.y );
  301. aList.push_back( MSG_PANEL_ITEM( _( "V Size" ), msg, RED ) );
  302. }
  303. wxString TEXTE_MODULE::GetSelectMenuText() const
  304. {
  305. wxString text;
  306. switch( m_Type )
  307. {
  308. case TEXT_is_REFERENCE:
  309. text.Printf( _( "Reference %s" ), GetChars( m_Text ) );
  310. break;
  311. case TEXT_is_VALUE:
  312. text.Printf( _( "Value %s of %s" ), GetChars( m_Text ),
  313. GetChars( ( (MODULE*) GetParent() )->GetReference() ) );
  314. break;
  315. default: // wrap this one in quotes:
  316. text.Printf( _( "Text \"%s\" on %s of %s" ), GetChars( m_Text ),
  317. GetChars( GetLayerName() ),
  318. GetChars( ( (MODULE*) GetParent() )->GetReference() ) );
  319. break;
  320. }
  321. return text;
  322. }
  323. EDA_ITEM* TEXTE_MODULE::Clone() const
  324. {
  325. return new TEXTE_MODULE( *this );
  326. }
  327. void TEXTE_MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
  328. {
  329. if( m_NoShow ) // Hidden text
  330. {
  331. aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_INVISIBLE );
  332. }
  333. else
  334. {
  335. switch( m_Type )
  336. {
  337. case TEXT_is_REFERENCE:
  338. aLayers[0] = ITEM_GAL_LAYER( MOD_REFERENCES_VISIBLE );
  339. break;
  340. case TEXT_is_VALUE:
  341. aLayers[0] = ITEM_GAL_LAYER( MOD_VALUES_VISIBLE );
  342. break;
  343. default:
  344. switch( GetParent()->GetLayer() )
  345. {
  346. case LAYER_N_BACK:
  347. aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_BK_VISIBLE ); // how about SILKSCREEN_N_BACK?
  348. break;
  349. case LAYER_N_FRONT:
  350. aLayers[0] = ITEM_GAL_LAYER( MOD_TEXT_FR_VISIBLE ); // how about SILKSCREEN_N_FRONT?
  351. break;
  352. }
  353. break;
  354. }
  355. }
  356. aCount = 1;
  357. }