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.

289 lines
8.5 KiB

17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
17 years ago
18 years ago
  1. /*****************************************************************************
  2. * Program to draw EE diagrams. *
  3. * This module redraw/draw all structs. *
  4. *****************************************************************************/
  5. #include "fctsys.h"
  6. #include "gr_basic.h"
  7. #include "common.h"
  8. #include "class_drawpanel.h"
  9. #include "appl_wxstruct.h"
  10. #include "program.h"
  11. #include "libcmp.h"
  12. #include "general.h"
  13. #include "protos.h"
  14. static EDA_BaseStruct* HighLightStruct = NULL;
  15. void DrawDanglingSymbol( WinEDA_DrawPanel* panel, wxDC* DC,
  16. const wxPoint& pos, int Color )
  17. {
  18. BASE_SCREEN* screen = panel->GetScreen();
  19. if( !screen->m_IsPrinting ) /* Draw but do not print the Dangling Symbol */
  20. {
  21. GRRect( &panel->m_ClipBox, DC,
  22. pos.x - DANGLING_SYMBOL_SIZE, pos.y - DANGLING_SYMBOL_SIZE,
  23. pos.x + DANGLING_SYMBOL_SIZE, pos.y + DANGLING_SYMBOL_SIZE,
  24. 0, Color );
  25. }
  26. }
  27. void SetHighLightStruct( EDA_BaseStruct* HighLight )
  28. {
  29. HighLightStruct = HighLight;
  30. }
  31. /*
  32. * Redraws only the active window which is assumed to be whole visible.
  33. */
  34. void WinEDA_SchematicFrame::RedrawActiveWindow( wxDC* DC, bool EraseBg )
  35. {
  36. wxString title;
  37. if( GetScreen() == NULL )
  38. return;
  39. ActiveScreen = GetScreen();
  40. /* Reinit draw and pen parameters */
  41. GRResetPenAndBrush( DC );
  42. DC->SetBackground( *wxBLACK_BRUSH );
  43. DC->SetBackgroundMode( wxTRANSPARENT );
  44. DrawPanel->CursorOff( DC ); // effacement curseur
  45. if( DrawPanel->ManageCurseur )
  46. {
  47. DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
  48. }
  49. if( EraseBg )
  50. DrawPanel->EraseScreen( DC );
  51. DrawPanel->DrawBackGround( DC );
  52. RedrawStructList( DrawPanel, DC, GetScreen()->EEDrawList,
  53. GR_DEFAULT_DRAWMODE );
  54. TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness );
  55. DrawPanel->CursorOn( DC ); // reaffichage curseur
  56. if( DrawPanel->ManageCurseur )
  57. {
  58. DrawPanel->ManageCurseur( DrawPanel, DC, FALSE );
  59. }
  60. GetScreen()->ClrRefreshReq();
  61. // Display the sheet filename, and the sheet path, for non root sheets
  62. if( GetScreen()->m_FileName == m_DefaultSchematicFileName )
  63. {
  64. wxString msg = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
  65. title.Printf( wxT( "%s [%s]" ), msg.GetData(),
  66. GetScreen()->m_FileName.GetData() );
  67. SetTitle( title );
  68. }
  69. else
  70. {
  71. title = wxT( "[" );
  72. title << GetScreen()->m_FileName << wxT( "] " ) << _( "Sheet" );
  73. title << wxT( " " ) << m_CurrentSheet->PathHumanReadable();
  74. SetTitle( title );
  75. }
  76. }
  77. /**
  78. * PrintPage
  79. * used to print a page.
  80. * Print the page pointed by ActiveScreen, set by the calling print function
  81. * @param DC = wxDC given by the calling print function
  82. * @param Print_Sheet_Ref = true to print page references
  83. * @param PrintMask = not used here
  84. * @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
  85. */
  86. void WinEDA_DrawPanel::PrintPage( wxDC* DC, bool Print_Sheet_Ref,
  87. int PrintMask, bool aPrintMirrorMode )
  88. {
  89. wxBeginBusyCursor();
  90. RedrawStructList( this, DC, ActiveScreen->EEDrawList, GR_COPY );
  91. if( Print_Sheet_Ref )
  92. m_Parent->TraceWorkSheet( DC, ActiveScreen, g_DrawDefaultLineThickness );
  93. wxEndBusyCursor();
  94. }
  95. /*****************************************************************************
  96. * Routine to redraw list of structs. *
  97. * If the list is of DrawPickStruct types then the picked item are drawn. *
  98. *****************************************************************************/
  99. void RedrawStructList( WinEDA_DrawPanel* panel, wxDC* DC,
  100. SCH_ITEM* Structlist, int DrawMode, int Color )
  101. {
  102. while( Structlist )
  103. {
  104. if( !(Structlist->m_Flags & IS_MOVED) )
  105. {
  106. // uncomment line below when there is a virtual EDA_BaseStruct::GetBoundingBox()
  107. // if( panel->m_ClipBox.Intersects( Structs->GetBoundingBox() ) )
  108. RedrawOneStruct( panel, DC, Structlist, DrawMode, Color );
  109. }
  110. Structlist = Structlist->Next();
  111. }
  112. }
  113. /*****************************************************************************
  114. * Routine to redraw list of structs. *
  115. *****************************************************************************/
  116. void RedrawOneStruct( WinEDA_DrawPanel* panel, wxDC* DC,
  117. SCH_ITEM* Struct, int DrawMode, int Color )
  118. {
  119. if( Struct == NULL )
  120. return;
  121. if( HighLightStruct == Struct )
  122. Color = HIGHLIGHT_COLOR;
  123. Struct->Draw( panel, DC, wxPoint( 0, 0 ), DrawMode, Color );
  124. }
  125. /* Routine de redessin en mode fantome (Dessin simplifie en g_XorMode et
  126. * g_GhostColor
  127. * de structures.
  128. * Utilisee dans les deplacements de blocs
  129. */
  130. void DrawStructsInGhost( WinEDA_DrawPanel * aPanel, wxDC * aDC, SCH_ITEM * aItem, const wxPoint & aOffset )
  131. {
  132. int DrawMode = g_XorMode;
  133. int width = g_DrawDefaultLineThickness;
  134. GRSetDrawMode( aDC, DrawMode );
  135. switch( aItem->Type() )
  136. {
  137. case DRAW_POLYLINE_STRUCT_TYPE:
  138. {
  139. DrawPolylineStruct* Struct = (DrawPolylineStruct*) aItem;
  140. GRMoveTo( Struct->m_PolyPoints[0].x + aOffset.x,
  141. Struct->m_PolyPoints[0].y + aOffset.y );
  142. for( unsigned ii = 1; ii < Struct->GetCornerCount(); ii++ )
  143. GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_PolyPoints[ii].x + aOffset.x,
  144. Struct->m_PolyPoints[ii].y + aOffset.y, width, g_GhostColor );
  145. break;
  146. }
  147. case DRAW_SEGMENT_STRUCT_TYPE:
  148. {
  149. EDA_DrawLineStruct* Struct;
  150. Struct = (EDA_DrawLineStruct*) aItem;
  151. if( (Struct->m_Flags & STARTPOINT) == 0 )
  152. {
  153. GRMoveTo( Struct->m_Start.x + aOffset.x, Struct->m_Start.y + aOffset.y );
  154. }
  155. else
  156. {
  157. GRMoveTo( Struct->m_Start.x, Struct->m_Start.y );
  158. }
  159. if( (Struct->m_Flags & ENDPOINT) == 0 )
  160. {
  161. GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_End.x + aOffset.x,
  162. Struct->m_End.y + aOffset.y, width, g_GhostColor );
  163. }
  164. else
  165. {
  166. GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_End.x,
  167. Struct->m_End.y, width, g_GhostColor );
  168. }
  169. break;
  170. }
  171. case DRAW_BUSENTRY_STRUCT_TYPE:
  172. {
  173. DrawBusEntryStruct* Struct = (DrawBusEntryStruct*) aItem;
  174. wxPoint start = Struct->m_Pos + aOffset;
  175. GRMoveTo( start.x, start.y );
  176. GRLineTo( &aPanel->m_ClipBox, aDC, Struct->m_Size.x + start.x,
  177. Struct->m_Size.y + start.y, width, g_GhostColor );
  178. break;
  179. }
  180. case DRAW_JUNCTION_STRUCT_TYPE:
  181. {
  182. DrawJunctionStruct* Struct;
  183. Struct = (DrawJunctionStruct*) aItem;
  184. Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
  185. break;
  186. }
  187. case TYPE_SCH_TEXT:
  188. {
  189. SCH_TEXT* Struct;
  190. Struct = (SCH_TEXT*) aItem;
  191. Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
  192. break;
  193. }
  194. case TYPE_SCH_LABEL:
  195. case TYPE_SCH_GLOBALLABEL:
  196. case TYPE_SCH_HIERLABEL:
  197. {
  198. SCH_LABEL* Struct;
  199. Struct = (SCH_LABEL*) aItem;
  200. Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
  201. break;
  202. }
  203. case DRAW_NOCONNECT_STRUCT_TYPE:
  204. {
  205. DrawNoConnectStruct* Struct;
  206. Struct = (DrawNoConnectStruct*) aItem;
  207. Struct->Draw( aPanel, aDC, aOffset, DrawMode, g_GhostColor );
  208. break;
  209. }
  210. case TYPE_SCH_COMPONENT:
  211. {
  212. EDA_LibComponentStruct* LibEntry;
  213. SCH_COMPONENT* Struct;
  214. Struct = (SCH_COMPONENT*) aItem;
  215. LibEntry = FindLibPart( Struct->m_ChipName.GetData(), wxEmptyString,
  216. FIND_ROOT );
  217. if( LibEntry == NULL )
  218. break;
  219. DrawingLibInGhost( aPanel, aDC, LibEntry, Struct, Struct->m_Pos.x + aOffset.x,
  220. Struct->m_Pos.y + aOffset.y, Struct->m_Multi,
  221. Struct->m_Convert, g_GhostColor, FALSE );
  222. break;
  223. }
  224. case DRAW_SHEET_STRUCT_TYPE:
  225. {
  226. DrawSheetStruct* Struct = (DrawSheetStruct*) aItem;
  227. GRRect( &aPanel->m_ClipBox, aDC, Struct->m_Pos.x + aOffset.x,
  228. Struct->m_Pos.y + aOffset.y, Struct->m_Pos.x + Struct->m_Size.x + aOffset.x,
  229. Struct->m_Pos.y + Struct->m_Size.y + aOffset.y, width, g_GhostColor );
  230. break;
  231. }
  232. case DRAW_HIERARCHICAL_PIN_SHEET_STRUCT_TYPE:
  233. case DRAW_MARKER_STRUCT_TYPE:
  234. break;
  235. default:
  236. break;
  237. }
  238. }