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.

948 lines
33 KiB

// Dick Hollenbeck's KiROUND R&D // This provides better project control over rounding to int from double // than wxRound() did. This scheme provides better logging in Debug builds // and it provides for compile time calculation of constants. #include <stdio.h> #include <assert.h> #include <limits.h> //-----<KiROUND KIT>------------------------------------------------------------ /** * KiROUND * rounds a floating point number to an int using * "round halfway cases away from zero". * In Debug build an assert fires if will not fit into an int. */ #if defined( DEBUG ) // DEBUG: a macro to capture line and file, then calls this inline static inline int KiRound( double v, int line, const char* filename ) { v = v < 0 ? v - 0.5 : v + 0.5; if( v > INT_MAX + 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v ); } else if( v < INT_MIN - 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v ); } return int( v ); } #define KiROUND( v ) KiRound( v, __LINE__, __FILE__ ) #else // RELEASE: a macro so compile can pre-compute constants. #define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 ) #endif //-----</KiROUND KIT>----------------------------------------------------------- // Only a macro is compile time calculated, an inline function causes a static constructor // in a situation like this. // Therefore the Release build is best done with a MACRO not an inline function. int Computed = KiROUND( 14.3 * 8 ); int main( int argc, char** argv ) { for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 ) { int i = KiROUND( d ); printf( "t: %d %.16g\n", i, d ); } return 0; }
14 years ago
// Dick Hollenbeck's KiROUND R&D // This provides better project control over rounding to int from double // than wxRound() did. This scheme provides better logging in Debug builds // and it provides for compile time calculation of constants. #include <stdio.h> #include <assert.h> #include <limits.h> //-----<KiROUND KIT>------------------------------------------------------------ /** * KiROUND * rounds a floating point number to an int using * "round halfway cases away from zero". * In Debug build an assert fires if will not fit into an int. */ #if defined( DEBUG ) // DEBUG: a macro to capture line and file, then calls this inline static inline int KiRound( double v, int line, const char* filename ) { v = v < 0 ? v - 0.5 : v + 0.5; if( v > INT_MAX + 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v ); } else if( v < INT_MIN - 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v ); } return int( v ); } #define KiROUND( v ) KiRound( v, __LINE__, __FILE__ ) #else // RELEASE: a macro so compile can pre-compute constants. #define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 ) #endif //-----</KiROUND KIT>----------------------------------------------------------- // Only a macro is compile time calculated, an inline function causes a static constructor // in a situation like this. // Therefore the Release build is best done with a MACRO not an inline function. int Computed = KiROUND( 14.3 * 8 ); int main( int argc, char** argv ) { for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 ) { int i = KiROUND( d ); printf( "t: %d %.16g\n", i, d ); } return 0; }
14 years ago
// Dick Hollenbeck's KiROUND R&D // This provides better project control over rounding to int from double // than wxRound() did. This scheme provides better logging in Debug builds // and it provides for compile time calculation of constants. #include <stdio.h> #include <assert.h> #include <limits.h> //-----<KiROUND KIT>------------------------------------------------------------ /** * KiROUND * rounds a floating point number to an int using * "round halfway cases away from zero". * In Debug build an assert fires if will not fit into an int. */ #if defined( DEBUG ) // DEBUG: a macro to capture line and file, then calls this inline static inline int KiRound( double v, int line, const char* filename ) { v = v < 0 ? v - 0.5 : v + 0.5; if( v > INT_MAX + 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v ); } else if( v < INT_MIN - 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v ); } return int( v ); } #define KiROUND( v ) KiRound( v, __LINE__, __FILE__ ) #else // RELEASE: a macro so compile can pre-compute constants. #define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 ) #endif //-----</KiROUND KIT>----------------------------------------------------------- // Only a macro is compile time calculated, an inline function causes a static constructor // in a situation like this. // Therefore the Release build is best done with a MACRO not an inline function. int Computed = KiROUND( 14.3 * 8 ); int main( int argc, char** argv ) { for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 ) { int i = KiROUND( d ); printf( "t: %d %.16g\n", i, d ); } return 0; }
14 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
14 years ago
12 years ago
// Dick Hollenbeck's KiROUND R&D // This provides better project control over rounding to int from double // than wxRound() did. This scheme provides better logging in Debug builds // and it provides for compile time calculation of constants. #include <stdio.h> #include <assert.h> #include <limits.h> //-----<KiROUND KIT>------------------------------------------------------------ /** * KiROUND * rounds a floating point number to an int using * "round halfway cases away from zero". * In Debug build an assert fires if will not fit into an int. */ #if defined( DEBUG ) // DEBUG: a macro to capture line and file, then calls this inline static inline int KiRound( double v, int line, const char* filename ) { v = v < 0 ? v - 0.5 : v + 0.5; if( v > INT_MAX + 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v ); } else if( v < INT_MIN - 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v ); } return int( v ); } #define KiROUND( v ) KiRound( v, __LINE__, __FILE__ ) #else // RELEASE: a macro so compile can pre-compute constants. #define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 ) #endif //-----</KiROUND KIT>----------------------------------------------------------- // Only a macro is compile time calculated, an inline function causes a static constructor // in a situation like this. // Therefore the Release build is best done with a MACRO not an inline function. int Computed = KiROUND( 14.3 * 8 ); int main( int argc, char** argv ) { for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 ) { int i = KiROUND( d ); printf( "t: %d %.16g\n", i, d ); } return 0; }
14 years ago
// Dick Hollenbeck's KiROUND R&D // This provides better project control over rounding to int from double // than wxRound() did. This scheme provides better logging in Debug builds // and it provides for compile time calculation of constants. #include <stdio.h> #include <assert.h> #include <limits.h> //-----<KiROUND KIT>------------------------------------------------------------ /** * KiROUND * rounds a floating point number to an int using * "round halfway cases away from zero". * In Debug build an assert fires if will not fit into an int. */ #if defined( DEBUG ) // DEBUG: a macro to capture line and file, then calls this inline static inline int KiRound( double v, int line, const char* filename ) { v = v < 0 ? v - 0.5 : v + 0.5; if( v > INT_MAX + 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' > 0 ' for int\n", __FUNCTION__, filename, line, v ); } else if( v < INT_MIN - 0.5 ) { printf( "%s: in file %s on line %d, val: %.16g too ' < 0 ' for int\n", __FUNCTION__, filename, line, v ); } return int( v ); } #define KiROUND( v ) KiRound( v, __LINE__, __FILE__ ) #else // RELEASE: a macro so compile can pre-compute constants. #define KiROUND( v ) int( (v) < 0 ? (v) - 0.5 : (v) + 0.5 ) #endif //-----</KiROUND KIT>----------------------------------------------------------- // Only a macro is compile time calculated, an inline function causes a static constructor // in a situation like this. // Therefore the Release build is best done with a MACRO not an inline function. int Computed = KiROUND( 14.3 * 8 ); int main( int argc, char** argv ) { for( double d = double(INT_MAX)-1; d < double(INT_MAX)+8; d += 2.0 ) { int i = KiROUND( d ); printf( "t: %d %.16g\n", i, d ); } return 0; }
14 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2017 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
  5. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
  7. * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. /**
  27. * @file class_pad_draw_functions.cpp
  28. */
  29. #include <fctsys.h>
  30. #include <gr_basic.h>
  31. #include <common.h>
  32. #include <trigo.h>
  33. #include <pcb_screen.h>
  34. #include <class_drawpanel.h>
  35. #include <draw_graphic_text.h>
  36. #include <layers_id_colors_and_visibility.h>
  37. #include <pcb_edit_frame.h>
  38. #include <pcbnew_id.h> // ID_TRACK_BUTT
  39. #include <pcbnew.h>
  40. #include <class_board.h>
  41. #include <convert_basic_shapes_to_polygon.h>
  42. /* uncomment this line to show this pad with its specfic size and color
  43. * when it is not on copper layers, and only one solder mask layer or solder paste layer
  44. * is displayed for this pad
  45. * After testing this feature,I am not sure this is a good idea
  46. * but the code is left here.
  47. */
  48. //#define SHOW_PADMASK_REAL_SIZE_AND_COLOR
  49. // Helper class to store parameters used to draw a pad
  50. PAD_DRAWINFO::PAD_DRAWINFO()
  51. {
  52. m_DrawPanel = NULL;
  53. m_DrawMode = GR_COPY;
  54. m_Color = BLACK;
  55. m_HoleColor = BLACK; // could be DARKGRAY;
  56. m_NPHoleColor = YELLOW;
  57. m_NoNetMarkColor = BLUE;
  58. m_PadClearance = 0;
  59. m_Display_padnum = true;
  60. m_Display_netname = true;
  61. m_ShowPadFilled = true;
  62. m_ShowNCMark = true;
  63. m_ShowNotPlatedHole = false;
  64. m_IsPrinting = false;
  65. }
  66. void D_PAD::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDraw_mode,
  67. const wxPoint& aOffset )
  68. {
  69. wxSize mask_margin; // margin (clearance) used for some non copper layers
  70. #ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
  71. int showActualMaskSize = 0; /* Layer number if the actual pad size on mask layer can
  72. * be displayed i.e. if only one layer is shown for this pad
  73. * and this layer is a mask (solder mask or solder paste
  74. */
  75. #endif
  76. if( m_Flags & DO_NOT_DRAW )
  77. return;
  78. PAD_DRAWINFO drawInfo;
  79. drawInfo.m_Offset = aOffset;
  80. /* We can show/hide pads from the layer manager.
  81. * options are show/hide pads on front and/or back side of the board
  82. * For through pads, we hide them only if both sides are hidden.
  83. * smd pads on back are hidden for all layers (copper and technical layers)
  84. * on back side of the board
  85. * smd pads on front are hidden for all layers (copper and technical layers)
  86. * on front side of the board
  87. * ECO, edge and Draw layers and not considered
  88. */
  89. BOARD* brd = GetBoard();
  90. auto frame = static_cast<PCB_EDIT_FRAME*> ( aPanel->GetParent() );
  91. const auto& cds = frame->Settings().Colors();
  92. bool frontVisible = brd->IsElementVisible( LAYER_PAD_FR );
  93. bool backVisible = brd->IsElementVisible( LAYER_PAD_BK );
  94. if( !frontVisible && !backVisible )
  95. return;
  96. // If pad is only on front side (no layer on back side)
  97. // and if hide front side pads is enabled, do not draw
  98. if( !frontVisible && !( m_layerMask & LSET::BackMask() ).any() )
  99. return;
  100. // If pad is only on back side (no layer on front side)
  101. // and if hide back side pads is enabled, do not draw
  102. if( !backVisible && !( m_layerMask & LSET::FrontMask() ).any() )
  103. return;
  104. wxCHECK_RET( frame != NULL, wxT( "Panel has no parent frame window." ) );
  105. auto displ_opts = (PCB_DISPLAY_OPTIONS*)( frame->GetDisplayOptions() );
  106. PCB_SCREEN* screen = frame->GetScreen();
  107. if( displ_opts && displ_opts->m_DisplayPadFill == SKETCH )
  108. drawInfo.m_ShowPadFilled = false;
  109. else
  110. drawInfo.m_ShowPadFilled = true;
  111. COLOR4D color = COLOR4D::BLACK;
  112. if( m_layerMask[F_Cu] )
  113. {
  114. color = cds.GetItemColor( LAYER_PAD_FR );
  115. }
  116. if( m_layerMask[B_Cu] )
  117. {
  118. color = color.LegacyMix( cds.GetItemColor( LAYER_PAD_BK ) );
  119. }
  120. if( color == BLACK ) // Not on a visible copper layer (i.e. still nothing to show)
  121. {
  122. // If the pad is on only one tech layer, use the layer color else use DARKGRAY
  123. LSET mask_non_copper_layers = m_layerMask & ~LSET::AllCuMask();
  124. #ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
  125. mask_non_copper_layers &= brd->GetVisibleLayers();
  126. #endif
  127. PCB_LAYER_ID pad_layer = mask_non_copper_layers.ExtractLayer();
  128. switch( (int) pad_layer )
  129. {
  130. case UNDEFINED_LAYER: // More than one layer
  131. color = DARKGRAY;
  132. break;
  133. case UNSELECTED_LAYER: // Shouldn't really happen...
  134. break;
  135. default:
  136. color = cds.GetLayerColor( pad_layer );
  137. #ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
  138. showActualMaskSize = pad_layer;
  139. #endif
  140. }
  141. }
  142. // if SMD or connector pad and high contrast mode
  143. if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) &&
  144. ( GetAttribute() == PAD_ATTRIB_SMD || GetAttribute() == PAD_ATTRIB_CONN ) &&
  145. displ_opts && displ_opts->m_ContrastModeDisplay )
  146. {
  147. // when routing tracks
  148. if( frame->GetToolId() == ID_TRACK_BUTT )
  149. {
  150. PCB_LAYER_ID routeTop = screen->m_Route_Layer_TOP;
  151. PCB_LAYER_ID routeBot = screen->m_Route_Layer_BOTTOM;
  152. // if routing between copper and component layers,
  153. // or the current layer is one of said 2 external copper layers,
  154. // then highlight only the current layer.
  155. if( ( screen->m_Active_Layer == F_Cu || screen->m_Active_Layer == B_Cu ) ||
  156. ( routeTop==F_Cu && routeBot==B_Cu ) ||
  157. ( routeTop==B_Cu && routeBot==F_Cu )
  158. )
  159. {
  160. if( !IsOnLayer( screen->m_Active_Layer ) )
  161. color = COLOR4D( DARKDARKGRAY );
  162. }
  163. // else routing between an internal signal layer and some other
  164. // layer. Grey out all PAD_ATTRIB_SMD pads not on current or the single
  165. // selected external layer.
  166. else if( !IsOnLayer( screen->m_Active_Layer )
  167. && !IsOnLayer( routeTop )
  168. && !IsOnLayer( routeBot ) )
  169. {
  170. color = COLOR4D( DARKDARKGRAY );
  171. }
  172. }
  173. // when not edting tracks, show PAD_ATTRIB_SMD components not on active layer
  174. // as greyed out
  175. else
  176. {
  177. if( !IsOnLayer( screen->m_Active_Layer ) )
  178. color = COLOR4D( DARKDARKGRAY );
  179. }
  180. }
  181. #ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
  182. if( showActualMaskSize )
  183. {
  184. switch( showActualMaskSize )
  185. {
  186. case B_Mask:
  187. case F_Mask:
  188. mask_margin.x = mask_margin.y = GetSolderMaskMargin();
  189. break;
  190. case B_Paste:
  191. case F_Paste:
  192. mask_margin = GetSolderPasteMargin();
  193. break;
  194. default:
  195. // Another layer which has no margin to handle
  196. break;
  197. }
  198. }
  199. #endif
  200. // if Contrast mode is ON and a technical layer active, show pads on this
  201. // layer so we can see pads on paste or solder layer and the size of the
  202. // mask
  203. if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) &&
  204. displ_opts && displ_opts->m_ContrastModeDisplay && !IsCopperLayer( screen->m_Active_Layer ) )
  205. {
  206. if( IsOnLayer( screen->m_Active_Layer ) )
  207. {
  208. color = cds.GetLayerColor( screen->m_Active_Layer );
  209. // In high contrast mode, and if the active layer is the mask
  210. // layer shows the pad size with the mask clearance
  211. switch( screen->m_Active_Layer )
  212. {
  213. case B_Mask:
  214. case F_Mask:
  215. mask_margin.x = mask_margin.y = GetSolderMaskMargin();
  216. break;
  217. case B_Paste:
  218. case F_Paste:
  219. mask_margin = GetSolderPasteMargin();
  220. break;
  221. default:
  222. break;
  223. }
  224. }
  225. else
  226. color = DARKDARKGRAY;
  227. }
  228. // If use asks for masks to be printed, then print them.
  229. else if( screen->m_IsPrinting )
  230. {
  231. if( ( IsOnLayer( B_Paste ) && brd->IsLayerVisible( B_Paste ) ) ||
  232. ( IsOnLayer( F_Paste ) && brd->IsLayerVisible( F_Paste ) ) )
  233. {
  234. mask_margin = GetSolderPasteMargin();
  235. }
  236. if( ( IsOnLayer( B_Mask ) && brd->IsLayerVisible( B_Mask ) ) ||
  237. ( IsOnLayer( F_Mask ) && brd->IsLayerVisible( F_Mask ) ) )
  238. {
  239. mask_margin.x = std::max( mask_margin.x, GetSolderMaskMargin() );
  240. mask_margin.y = std::max( mask_margin.y, GetSolderMaskMargin() );
  241. }
  242. }
  243. if( ( aDraw_mode & GR_HIGHLIGHT ) && !( aDraw_mode & GR_AND ) )
  244. color.SetToLegacyHighlightColor();
  245. bool DisplayIsol = displ_opts && displ_opts->m_DisplayPadIsol;
  246. if( !( m_layerMask & LSET::AllCuMask() ).any() )
  247. DisplayIsol = false;
  248. if( ( GetAttribute() == PAD_ATTRIB_HOLE_NOT_PLATED ) &&
  249. brd->IsElementVisible( LAYER_NON_PLATEDHOLES ) )
  250. {
  251. drawInfo.m_ShowNotPlatedHole = true;
  252. drawInfo.m_NPHoleColor = cds.GetItemColor( LAYER_NON_PLATEDHOLES );
  253. }
  254. // Don't let pads that *should* be NPTHs get lost
  255. else if ( PadShouldBeNPTH() )
  256. {
  257. drawInfo.m_ShowNotPlatedHole = true;
  258. drawInfo.m_NPHoleColor = cds.GetItemColor( LAYER_MOD_TEXT_INVISIBLE );
  259. }
  260. drawInfo.m_DrawMode = aDraw_mode;
  261. drawInfo.m_Color = color;
  262. drawInfo.m_NoNetMarkColor = cds.GetItemColor( LAYER_NO_CONNECTS );
  263. drawInfo.m_DrawPanel = aPanel;
  264. drawInfo.m_Mask_margin = mask_margin;
  265. drawInfo.m_ShowNCMark = brd->IsElementVisible( LAYER_NO_CONNECTS );
  266. drawInfo.m_IsPrinting = screen->m_IsPrinting;
  267. color.a = 0.666;
  268. /* Get the pad clearance. This has a meaning only for Pcbnew.
  269. * for CvPcb GetClearance() creates debug errors because
  270. * there is no net classes so a call to GetClearance() is made only when
  271. * needed (never needed in CvPcb)
  272. */
  273. drawInfo.m_PadClearance = DisplayIsol ? GetClearance() : 0;
  274. // Draw the pad number
  275. if( displ_opts && !displ_opts->m_DisplayPadNum )
  276. drawInfo.m_Display_padnum = false;
  277. if( displ_opts &&
  278. (( displ_opts ->m_DisplayNetNamesMode == 0 ) || ( displ_opts->m_DisplayNetNamesMode == 2 )) )
  279. drawInfo.m_Display_netname = false;
  280. // Display net names is restricted to pads that are on the active layer
  281. // in high contrast mode display
  282. if( ( aDraw_mode & GR_ALLOW_HIGHCONTRAST ) &&
  283. !IsOnLayer( screen->m_Active_Layer ) && displ_opts && displ_opts->m_ContrastModeDisplay )
  284. drawInfo.m_Display_netname = false;
  285. DrawShape( aPanel->GetClipBox(), aDC, drawInfo );
  286. }
  287. void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
  288. {
  289. wxPoint coord[12];
  290. double angle = m_Orient;
  291. int seg_width;
  292. GRSetDrawMode( aDC, aDrawInfo.m_DrawMode );
  293. // calculate pad shape position :
  294. wxPoint shape_pos = ShapePos() - aDrawInfo.m_Offset;
  295. wxSize halfsize = m_Size;
  296. halfsize.x >>= 1;
  297. halfsize.y >>= 1;
  298. switch( GetShape() )
  299. {
  300. case PAD_SHAPE_CIRCLE:
  301. if( aDrawInfo.m_ShowPadFilled )
  302. GRFilledCircle( aClipBox, aDC, shape_pos.x, shape_pos.y,
  303. halfsize.x + aDrawInfo.m_Mask_margin.x, 0,
  304. aDrawInfo.m_Color, aDrawInfo.m_Color );
  305. else
  306. GRCircle( aClipBox, aDC, shape_pos.x, shape_pos.y,
  307. halfsize.x + aDrawInfo.m_Mask_margin.x,
  308. m_PadSketchModePenSize, aDrawInfo.m_Color );
  309. if( aDrawInfo.m_PadClearance )
  310. {
  311. GRCircle( aClipBox,
  312. aDC, shape_pos.x, shape_pos.y,
  313. halfsize.x + aDrawInfo.m_PadClearance,
  314. 0, aDrawInfo.m_Color );
  315. }
  316. break;
  317. case PAD_SHAPE_OVAL:
  318. {
  319. wxPoint segStart, segEnd;
  320. seg_width = BuildSegmentFromOvalShape(segStart, segEnd, angle,
  321. aDrawInfo.m_Mask_margin);
  322. segStart += shape_pos;
  323. segEnd += shape_pos;
  324. if( aDrawInfo.m_ShowPadFilled )
  325. {
  326. GRFillCSegm( aClipBox, aDC, segStart.x, segStart.y, segEnd.x, segEnd.y,
  327. seg_width, aDrawInfo.m_Color );
  328. }
  329. else
  330. {
  331. GRCSegm( aClipBox, aDC, segStart.x, segStart.y, segEnd.x, segEnd.y,
  332. seg_width, m_PadSketchModePenSize, aDrawInfo.m_Color );
  333. }
  334. // Draw the clearance line
  335. if( aDrawInfo.m_PadClearance )
  336. {
  337. seg_width += 2 * aDrawInfo.m_PadClearance;
  338. GRCSegm( aClipBox, aDC, segStart.x, segStart.y, segEnd.x, segEnd.y,
  339. seg_width, aDrawInfo.m_Color );
  340. }
  341. }
  342. break;
  343. case PAD_SHAPE_RECT:
  344. case PAD_SHAPE_TRAPEZOID:
  345. BuildPadPolygon( coord, aDrawInfo.m_Mask_margin, angle );
  346. for( int ii = 0; ii < 4; ii++ )
  347. coord[ii] += shape_pos;
  348. GRClosedPoly( aClipBox, aDC, 4, coord, aDrawInfo.m_ShowPadFilled,
  349. aDrawInfo.m_ShowPadFilled ? 0 : m_PadSketchModePenSize,
  350. aDrawInfo.m_Color, aDrawInfo.m_Color );
  351. if( aDrawInfo.m_PadClearance )
  352. {
  353. #define SEGCOUNT 32 // number of segments to approximate a circle
  354. SHAPE_POLY_SET outline;
  355. TransformShapeWithClearanceToPolygon( outline, aDrawInfo.m_PadClearance, SEGCOUNT, 1.0 );
  356. // Draw the polygon: Inflate creates only one convex polygon
  357. if( outline.OutlineCount() > 0 )
  358. {
  359. SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
  360. if( poly.PointCount() > 0 )
  361. {
  362. GRClosedPoly( aClipBox, aDC, poly.PointCount(),
  363. (wxPoint*)&poly.Point( 0 ), false, 0,
  364. aDrawInfo.m_Color, aDrawInfo.m_Color );
  365. }
  366. }
  367. }
  368. break;
  369. case PAD_SHAPE_ROUNDRECT:
  370. {
  371. // Use solder[Paste/Mask]size or pad size to build pad shape to draw
  372. wxSize size( GetSize() );
  373. size += aDrawInfo.m_Mask_margin * 2;
  374. int corner_radius = GetRoundRectCornerRadius( size );
  375. // Draw the polygon: Inflate creates only one convex polygon
  376. SHAPE_POLY_SET outline;
  377. bool filled = aDrawInfo.m_ShowPadFilled;
  378. if( filled )
  379. {
  380. wxPoint centers[4];
  381. GetRoundRectCornerCenters( centers, corner_radius, shape_pos,
  382. size, GetOrientation() );
  383. GRClosedPoly( aClipBox, aDC, 4, centers, true, corner_radius*2,
  384. aDrawInfo.m_Color, aDrawInfo.m_Color );
  385. }
  386. else
  387. {
  388. TransformRoundRectToPolygon( outline, shape_pos, size, GetOrientation(),
  389. corner_radius, 64 );
  390. if( outline.OutlineCount() > 0 )
  391. {
  392. SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
  393. if( poly.PointCount() > 0 )
  394. {
  395. GRClosedPoly( aClipBox, aDC, poly.PointCount(),
  396. (wxPoint*)&poly.Point( 0 ), aDrawInfo.m_ShowPadFilled, 0,
  397. aDrawInfo.m_Color, aDrawInfo.m_Color );
  398. }
  399. }
  400. }
  401. if( aDrawInfo.m_PadClearance )
  402. {
  403. outline.RemoveAllContours();
  404. size = GetSize();
  405. size.x += aDrawInfo.m_PadClearance * 2;
  406. size.y += aDrawInfo.m_PadClearance * 2;
  407. corner_radius = GetRoundRectCornerRadius() + aDrawInfo.m_PadClearance;
  408. TransformRoundRectToPolygon( outline, shape_pos, size, GetOrientation(),
  409. corner_radius, 32 );
  410. if( outline.OutlineCount() > 0 )
  411. {
  412. // Draw the polygon: Inflate creates only one convex polygon
  413. SHAPE_LINE_CHAIN& clearance_poly = outline.Outline( 0 );
  414. if( clearance_poly.PointCount() > 0 )
  415. {
  416. GRClosedPoly( aClipBox, aDC, clearance_poly.PointCount(),
  417. (wxPoint*)&clearance_poly.Point( 0 ), false, 0,
  418. aDrawInfo.m_Color, aDrawInfo.m_Color );
  419. }
  420. }
  421. }
  422. }
  423. break;
  424. case PAD_SHAPE_CUSTOM:
  425. {
  426. // The full shape has 2 items
  427. // 1- The anchor pad: a round or rect pad located at pad position
  428. // 2- The custom complex shape
  429. // Note: The anchor pad shape is containing by the custom complex shape polygon
  430. // The anchor pad is shown to help user to see where is the anchor, only in sketch mode
  431. // (In filled mode, it is merged with the basic shapes)
  432. wxPoint pad_pos = GetPosition() - aDrawInfo.m_Offset;
  433. // In sketch mode only: Draw the anchor pad: a round or rect pad
  434. if( !aDrawInfo.m_ShowPadFilled )
  435. {
  436. if( GetAnchorPadShape() == PAD_SHAPE_RECT )
  437. {
  438. wxPoint poly[4];
  439. poly[0] = wxPoint( - halfsize.x, - halfsize.y );
  440. poly[1] = wxPoint( - halfsize.x, + halfsize.y );
  441. poly[2] = wxPoint( + halfsize.x, + halfsize.y );
  442. poly[3] = wxPoint( + halfsize.x, - halfsize.y );
  443. for( int ii = 0; ii < 4; ++ii )
  444. {
  445. RotatePoint( &poly[ii], m_Orient );
  446. poly[ii] += pad_pos;
  447. }
  448. GRClosedPoly( aClipBox, aDC, 4, poly, false, 0,
  449. aDrawInfo.m_Color, aDrawInfo.m_Color );
  450. }
  451. else
  452. {
  453. GRCircle( aClipBox, aDC, pad_pos.x, pad_pos.y,
  454. halfsize.x,
  455. m_PadSketchModePenSize, aDrawInfo.m_Color );
  456. }
  457. }
  458. SHAPE_POLY_SET outline; // Will contain the corners in board coordinates
  459. outline.Append( m_customShapeAsPolygon );
  460. CustomShapeAsPolygonToBoardPosition( &outline, pad_pos, GetOrientation() );
  461. SHAPE_LINE_CHAIN* poly;
  462. const int segmentToCircleCount = 32;
  463. if( aDrawInfo.m_Mask_margin.x )
  464. {
  465. SHAPE_POLY_SET clearance_outline;
  466. clearance_outline.Append( outline );
  467. clearance_outline.Inflate( aDrawInfo.m_Mask_margin.x, segmentToCircleCount );
  468. }
  469. else
  470. {
  471. // Draw the polygon: only one polygon is expected
  472. // However we provide a multi polygon shape drawing
  473. // ( for the future or to show a non expected shape )
  474. for( int jj = 0; jj < outline.OutlineCount(); ++jj )
  475. {
  476. poly = &outline.Outline( jj );
  477. GRClosedPoly( aClipBox, aDC, poly->PointCount(),
  478. (wxPoint*)&poly->Point( 0 ), aDrawInfo.m_ShowPadFilled, 0,
  479. aDrawInfo.m_Color, aDrawInfo.m_Color );
  480. }
  481. }
  482. if( aDrawInfo.m_PadClearance )
  483. {
  484. SHAPE_POLY_SET clearance_outline;
  485. clearance_outline.Append( outline );
  486. clearance_outline.Inflate( aDrawInfo.m_PadClearance, segmentToCircleCount );
  487. for( int jj = 0; jj < clearance_outline.OutlineCount(); ++jj )
  488. {
  489. poly = &clearance_outline.Outline( jj );
  490. if( poly->PointCount() > 0 )
  491. {
  492. GRClosedPoly( aClipBox, aDC, poly->PointCount(),
  493. (wxPoint*)&poly->Point( 0 ), false, 0,
  494. aDrawInfo.m_Color, aDrawInfo.m_Color );
  495. }
  496. }
  497. }
  498. break;
  499. }
  500. default:
  501. break;
  502. }
  503. // Draw the pad hole
  504. wxPoint holepos = m_Pos - aDrawInfo.m_Offset;
  505. int hole = m_Drill.x >> 1;
  506. bool drawhole = hole > 0;
  507. if( !aDrawInfo.m_ShowPadFilled && !aDrawInfo.m_ShowNotPlatedHole )
  508. drawhole = false;
  509. if( drawhole )
  510. {
  511. bool blackpenstate = false;
  512. COLOR4D fillcolor = aDrawInfo.m_ShowNotPlatedHole? aDrawInfo.m_NPHoleColor :
  513. aDrawInfo.m_HoleColor;
  514. COLOR4D hole_color = fillcolor;
  515. if( aDrawInfo.m_IsPrinting )
  516. {
  517. fillcolor = COLOR4D::WHITE;
  518. blackpenstate = GetGRForceBlackPenState();
  519. GRForceBlackPen( false );
  520. }
  521. else
  522. {
  523. GRSetDrawMode( aDC, ( aDrawInfo.m_DrawMode != GR_XOR ) ? GR_COPY : GR_XOR );
  524. }
  525. if( blackpenstate )
  526. hole_color = COLOR4D::BLACK;
  527. switch( GetDrillShape() )
  528. {
  529. case PAD_DRILL_SHAPE_CIRCLE:
  530. if( aDC->LogicalToDeviceXRel( hole ) > 1 ) // hole is drawn if hole > 1pixel
  531. GRFilledCircle( aClipBox, aDC, holepos.x, holepos.y, hole, 0,
  532. hole_color, fillcolor );
  533. break;
  534. case PAD_DRILL_SHAPE_OBLONG:
  535. {
  536. wxPoint drl_start, drl_end;
  537. GetOblongDrillGeometry( drl_start, drl_end, seg_width );
  538. drl_start += holepos;
  539. drl_end += holepos;
  540. GRFilledSegment( aClipBox, aDC, drl_start, drl_end, seg_width, fillcolor );
  541. GRCSegm( aClipBox, aDC, drl_start, drl_end, seg_width, hole_color );
  542. }
  543. break;
  544. default:
  545. break;
  546. }
  547. if( aDrawInfo.m_IsPrinting )
  548. GRForceBlackPen( blackpenstate );
  549. }
  550. GRSetDrawMode( aDC, aDrawInfo.m_DrawMode );
  551. // Draw "No connect" ( / or \ or cross X ) if necessary
  552. if( GetNetCode() == 0 && aDrawInfo.m_ShowNCMark )
  553. {
  554. int dx0 = std::min( halfsize.x, halfsize.y );
  555. if( m_layerMask[F_Cu] ) /* Draw \ */
  556. GRLine( aClipBox, aDC, holepos.x - dx0, holepos.y - dx0,
  557. holepos.x + dx0, holepos.y + dx0, 0, aDrawInfo.m_NoNetMarkColor );
  558. if( m_layerMask[B_Cu] ) // Draw /
  559. GRLine( aClipBox, aDC, holepos.x + dx0, holepos.y - dx0,
  560. holepos.x - dx0, holepos.y + dx0, 0, aDrawInfo.m_NoNetMarkColor );
  561. }
  562. if( !aDrawInfo.m_IsPrinting )
  563. GRSetDrawMode( aDC, ( aDrawInfo.m_DrawMode != GR_XOR ) ? GR_COPY : GR_XOR );
  564. // Draw the pad number
  565. if( !aDrawInfo.m_Display_padnum && !aDrawInfo.m_Display_netname )
  566. return;
  567. wxPoint tpos0 = shape_pos; // Position of the centre of text
  568. wxPoint tpos = tpos0;
  569. wxSize AreaSize; // size of text area, normalized to AreaSize.y < AreaSize.x
  570. int shortname_len = 0;
  571. if( aDrawInfo.m_Display_netname )
  572. shortname_len = GetShortNetname().Len();
  573. if( GetShape() == PAD_SHAPE_CIRCLE )
  574. angle = 0;
  575. AreaSize = m_Size;
  576. if( m_Size.y > m_Size.x )
  577. {
  578. angle += 900;
  579. AreaSize.x = m_Size.y;
  580. AreaSize.y = m_Size.x;
  581. }
  582. if( shortname_len > 0 ) // if there is a netname, provides room to display this netname
  583. {
  584. AreaSize.y /= 2; // Text used only the upper area of the
  585. // pad. The lower area displays the net name
  586. tpos.y -= AreaSize.y / 2;
  587. }
  588. // Calculate the position of text, that is the middle point of the upper
  589. // area of the pad
  590. RotatePoint( &tpos, shape_pos, angle );
  591. // Draw text with an angle between -90 deg and + 90 deg
  592. double t_angle = angle;
  593. NORMALIZE_ANGLE_90( t_angle );
  594. /* Note: in next calculations, texte size is calculated for 3 or more
  595. * chars. Of course, pads numbers and nets names can have less than 3
  596. * chars. but after some tries, i found this is gives the best look
  597. */
  598. constexpr int MIN_CHAR_COUNT = 3;
  599. unsigned int tsize;
  600. EDA_RECT* clipBox = aDrawInfo.m_DrawPanel?
  601. aDrawInfo.m_DrawPanel->GetClipBox() : NULL;
  602. if( aDrawInfo.m_Display_padnum )
  603. {
  604. int numpad_len = std::max( (int) m_name.Length(), MIN_CHAR_COUNT );
  605. tsize = std::min( (int) AreaSize.y, AreaSize.x / numpad_len );
  606. if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE ) // Not drawable when size too small.
  607. {
  608. // tsize reserve room for marges and segments thickness
  609. tsize = ( tsize * 7 ) / 10;
  610. DrawGraphicHaloText( clipBox, aDC, tpos,
  611. aDrawInfo.m_Color, BLACK, WHITE,
  612. m_name, t_angle,
  613. wxSize( tsize , tsize ), GR_TEXT_HJUSTIFY_CENTER,
  614. GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false );
  615. }
  616. }
  617. // display the short netname, if exists
  618. if( shortname_len == 0 )
  619. return;
  620. shortname_len = std::max( shortname_len, MIN_CHAR_COUNT );
  621. tsize = std::min( AreaSize.y, AreaSize.x / shortname_len );
  622. if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE ) // Not drawable in size too small.
  623. {
  624. tpos = tpos0;
  625. if( aDrawInfo.m_Display_padnum )
  626. tpos.y += AreaSize.y / 2;
  627. RotatePoint( &tpos, shape_pos, angle );
  628. // tsize reserve room for marges and segments thickness
  629. tsize = ( tsize * 7 ) / 10;
  630. DrawGraphicHaloText( clipBox, aDC, tpos,
  631. aDrawInfo.m_Color, BLACK, WHITE,
  632. GetShortNetname(), t_angle,
  633. wxSize( tsize, tsize ), GR_TEXT_HJUSTIFY_CENTER,
  634. GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false );
  635. }
  636. }
  637. /**
  638. * Function BuildSegmentFromOvalShape
  639. * Has meaning only for OVAL (and ROUND) pads.
  640. * Build an equivalent segment having the same shape as the OVAL shape,
  641. * aSegStart and aSegEnd are the ending points of the equivalent segment of the shape
  642. * aRotation is the asked rotation of the segment (usually m_Orient)
  643. */
  644. int D_PAD::BuildSegmentFromOvalShape(wxPoint& aSegStart, wxPoint& aSegEnd,
  645. double aRotation, const wxSize& aMargin) const
  646. {
  647. int width;
  648. if( m_Size.y < m_Size.x ) // Build an horizontal equiv segment
  649. {
  650. int delta = ( m_Size.x - m_Size.y ) / 2;
  651. aSegStart.x = -delta - aMargin.x;
  652. aSegStart.y = 0;
  653. aSegEnd.x = delta + aMargin.x;
  654. aSegEnd.y = 0;
  655. width = m_Size.y + ( aMargin.y * 2 );
  656. }
  657. else // Vertical oval: build a vertical equiv segment
  658. {
  659. int delta = ( m_Size.y -m_Size.x ) / 2;
  660. aSegStart.x = 0;
  661. aSegStart.y = -delta - aMargin.y;
  662. aSegEnd.x = 0;
  663. aSegEnd.y = delta + aMargin.y;
  664. width = m_Size.x + ( aMargin.x * 2 );
  665. }
  666. if( aRotation )
  667. {
  668. RotatePoint( &aSegStart, aRotation);
  669. RotatePoint( &aSegEnd, aRotation);
  670. }
  671. return width;
  672. }
  673. void D_PAD::BuildPadPolygon( wxPoint aCoord[4], wxSize aInflateValue,
  674. double aRotation ) const
  675. {
  676. wxSize delta;
  677. wxSize halfsize;
  678. halfsize.x = m_Size.x >> 1;
  679. halfsize.y = m_Size.y >> 1;
  680. switch( GetShape() )
  681. {
  682. case PAD_SHAPE_RECT:
  683. // For rectangular shapes, inflate is easy
  684. halfsize += aInflateValue;
  685. // Verify if do not deflate more than than size
  686. // Only possible for inflate negative values.
  687. if( halfsize.x < 0 )
  688. halfsize.x = 0;
  689. if( halfsize.y < 0 )
  690. halfsize.y = 0;
  691. break;
  692. case PAD_SHAPE_TRAPEZOID:
  693. // Trapezoidal pad: verify delta values
  694. delta.x = ( m_DeltaSize.x >> 1 );
  695. delta.y = ( m_DeltaSize.y >> 1 );
  696. // be sure delta values are not to large
  697. if( (delta.x < 0) && (delta.x <= -halfsize.y) )
  698. delta.x = -halfsize.y + 1;
  699. if( (delta.x > 0) && (delta.x >= halfsize.y) )
  700. delta.x = halfsize.y - 1;
  701. if( (delta.y < 0) && (delta.y <= -halfsize.x) )
  702. delta.y = -halfsize.x + 1;
  703. if( (delta.y > 0) && (delta.y >= halfsize.x) )
  704. delta.y = halfsize.x - 1;
  705. break;
  706. default: // is used only for rect and trap. pads
  707. return;
  708. }
  709. // Build the basic rectangular or trapezoid shape
  710. // delta is null for rectangular shapes
  711. aCoord[0].x = -halfsize.x - delta.y; // lower left
  712. aCoord[0].y = +halfsize.y + delta.x;
  713. aCoord[1].x = -halfsize.x + delta.y; // upper left
  714. aCoord[1].y = -halfsize.y - delta.x;
  715. aCoord[2].x = +halfsize.x - delta.y; // upper right
  716. aCoord[2].y = -halfsize.y + delta.x;
  717. aCoord[3].x = +halfsize.x + delta.y; // lower right
  718. aCoord[3].y = +halfsize.y - delta.x;
  719. // Offsetting the trapezoid shape id needed
  720. // It is assumed delta.x or/and delta.y == 0
  721. if( GetShape() == PAD_SHAPE_TRAPEZOID && (aInflateValue.x != 0 || aInflateValue.y != 0) )
  722. {
  723. double angle;
  724. wxSize corr;
  725. if( delta.y ) // lower and upper segment is horizontal
  726. {
  727. // Calculate angle of left (or right) segment with vertical axis
  728. angle = atan2( (double) m_DeltaSize.y, (double) m_Size.y );
  729. // left and right sides are moved by aInflateValue.x in their perpendicular direction
  730. // We must calculate the corresponding displacement on the horizontal axis
  731. // that is delta.x +- corr.x depending on the corner
  732. corr.x = KiROUND( tan( angle ) * aInflateValue.x );
  733. delta.x = KiROUND( aInflateValue.x / cos( angle ) );
  734. // Horizontal sides are moved up and down by aInflateValue.y
  735. delta.y = aInflateValue.y;
  736. // corr.y = 0 by the constructor
  737. }
  738. else if( delta.x ) // left and right segment is vertical
  739. {
  740. // Calculate angle of lower (or upper) segment with horizontal axis
  741. angle = atan2( (double) m_DeltaSize.x, (double) m_Size.x );
  742. // lower and upper sides are moved by aInflateValue.x in their perpendicular direction
  743. // We must calculate the corresponding displacement on the vertical axis
  744. // that is delta.y +- corr.y depending on the corner
  745. corr.y = KiROUND( tan( angle ) * aInflateValue.y );
  746. delta.y = KiROUND( aInflateValue.y / cos( angle ) );
  747. // Vertical sides are moved left and right by aInflateValue.x
  748. delta.x = aInflateValue.x;
  749. // corr.x = 0 by the constructor
  750. }
  751. else // the trapezoid is a rectangle
  752. {
  753. delta = aInflateValue; // this pad is rectangular (delta null).
  754. }
  755. aCoord[0].x += -delta.x - corr.x; // lower left
  756. aCoord[0].y += delta.y + corr.y;
  757. aCoord[1].x += -delta.x + corr.x; // upper left
  758. aCoord[1].y += -delta.y - corr.y;
  759. aCoord[2].x += delta.x - corr.x; // upper right
  760. aCoord[2].y += -delta.y + corr.y;
  761. aCoord[3].x += delta.x + corr.x; // lower right
  762. aCoord[3].y += delta.y - corr.y;
  763. /* test coordinates and clamp them if the offset correction is too large:
  764. * Note: if a coordinate is bad, the other "symmetric" coordinate is bad
  765. * So when a bad coordinate is found, the 2 symmetric coordinates
  766. * are set to the minimun value (0)
  767. */
  768. if( aCoord[0].x > 0 ) // lower left x coordinate must be <= 0
  769. aCoord[0].x = aCoord[3].x = 0;
  770. if( aCoord[1].x > 0 ) // upper left x coordinate must be <= 0
  771. aCoord[1].x = aCoord[2].x = 0;
  772. if( aCoord[0].y < 0 ) // lower left y coordinate must be >= 0
  773. aCoord[0].y = aCoord[1].y = 0;
  774. if( aCoord[3].y < 0 ) // lower right y coordinate must be >= 0
  775. aCoord[3].y = aCoord[2].y = 0;
  776. }
  777. if( aRotation )
  778. {
  779. for( int ii = 0; ii < 4; ii++ )
  780. RotatePoint( &aCoord[ii], aRotation );
  781. }
  782. }