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.

1068 lines
40 KiB

17 years ago
17 years ago
17 years ago
16 years ago
16 years ago
16 years ago
16 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
16 years ago
  1. /***********************************************************/
  2. /* wxPcbStruct.h */
  3. /***********************************************************/
  4. #ifndef WXPCB_STRUCT_H
  5. #define WXPCB_STRUCT_H
  6. #include "wxstruct.h"
  7. #include "base_struct.h"
  8. #ifndef PCB_INTERNAL_UNIT
  9. #define PCB_INTERNAL_UNIT 10000
  10. #endif
  11. /* Forward declarations of classes. */
  12. class PCB_SCREEN;
  13. class WinEDA_Toolbar;
  14. class WinEDA_ModuleEditFrame;
  15. class BOARD;
  16. class TEXTE_PCB;
  17. class MODULE;
  18. class TRACK;
  19. class SEGZONE;
  20. class SEGVIA;
  21. class D_PAD;
  22. class TEXTE_MODULE;
  23. class MIREPCB;
  24. class COTATION;
  25. class EDGE_MODULE;
  26. class WinEDA3D_DrawFrame;
  27. class DRC;
  28. class ZONE_CONTAINER;
  29. class DRAWSEGMENT;
  30. class GENERAL_COLLECTOR;
  31. class GENERAL_COLLECTORS_GUIDE;
  32. class PCB_LAYER_WIDGET;
  33. /**
  34. * @info see also class WinEDA_BasePcbFrame: Basic class for pcbnew and
  35. *gerbview
  36. */
  37. /*****************************************************/
  38. /* class WinEDA_PcbFrame: the main frame for Pcbnew */
  39. /*****************************************************/
  40. class WinEDA_PcbFrame : public WinEDA_BasePcbFrame
  41. {
  42. friend class PCB_LAYER_WIDGET;
  43. protected:
  44. PCB_LAYER_WIDGET* m_Layers;
  45. DRC* m_drc; ///< the DRC controller, see drc.cpp
  46. // we'll use lower case function names for private member functions.
  47. void createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu );
  48. void createPopUpMenuForFootprints( MODULE* aModule, wxMenu* aPopMenu );
  49. void createPopUpMenuForFpTexts( TEXTE_MODULE* aText, wxMenu* aPopMenu );
  50. void createPopUpMenuForFpPads( D_PAD* aPad, wxMenu* aPopMenu );
  51. void createPopupMenuForTracks( TRACK* aTrack, wxMenu* aPopMenu );
  52. void createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu );
  53. void createPopUpBlockMenu( wxMenu* menu );
  54. void createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aPopMenu );
  55. /**
  56. * Function setActiveLayer
  57. * will change the currently active layer to \a aLayer and also
  58. * update the PCB_LAYER_WIDGET.
  59. */
  60. void setActiveLayer( int aLayer, bool doLayerWidgetUpdate = true )
  61. {
  62. ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
  63. if( doLayerWidgetUpdate )
  64. syncLayerWidget();
  65. }
  66. /**
  67. * Function getActiveLayer
  68. * returns the active layer
  69. */
  70. int getActiveLayer()
  71. {
  72. return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
  73. }
  74. /**
  75. * Function syncLayerWidget
  76. * updates the currently "selected" layer within the PCB_LAYER_WIDGET.
  77. * The currently active layer is defined by the return value of getActiveLayer().
  78. * <p>
  79. * This function cannot be inline without including layer_widget.h in
  80. * here and we do not want to do that.
  81. */
  82. void syncLayerWidget( );
  83. /**
  84. * Function syncLayerBox
  85. * updates the currently "selected" layer within m_SelLayerBox
  86. * The currently active layer, as defined by the return value of
  87. * getActiveLayer(). And updates the colored icon in the toolbar.
  88. */
  89. void syncLayerBox();
  90. public:
  91. WinEDAChoiceBox* m_SelLayerBox; // a combo box to display and
  92. // select active layer
  93. WinEDAChoiceBox* m_SelTrackWidthBox; // a combo box to display and
  94. // select current track width
  95. WinEDAChoiceBox* m_SelViaSizeBox; // a combo box to display and
  96. // select current via diameter
  97. wxTextCtrl* m_ClearanceBox; // a text ctrl to display the
  98. // current tracks and vias
  99. // clearance
  100. wxTextCtrl* m_NetClassSelectedBox; // a text ctrl to display the
  101. // current NetClass
  102. bool m_TrackAndViasSizesList_Changed;
  103. bool m_show_microwave_tools;
  104. bool m_show_layer_manager_tools;
  105. public:
  106. WinEDA_PcbFrame( wxWindow* father, const wxString& title,
  107. const wxPoint& pos, const wxSize& size,
  108. long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
  109. ~WinEDA_PcbFrame();
  110. void OnQuit( wxCommandEvent & WXUNUSED(event) );
  111. /** Function ToPlotter
  112. * Open a dialog frame to create plot and drill files
  113. * relative to the current board
  114. */
  115. void ToPlotter( wxCommandEvent& event );
  116. /** function ToPrinter
  117. * Install the print dialog
  118. */
  119. void ToPrinter( wxCommandEvent& event );
  120. /** Virtual function PrintPage
  121. * used to print a page
  122. * Print the page pointed by ActiveScreen, set by the calling print function
  123. * @param aDC = wxDC given by the calling print function
  124. * @param aPrint_Sheet_Ref = true to print page references
  125. * @param aPrintMask = not used here
  126. * @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
  127. * @param aData = a pointer on an auxiliary data (NULL if not used)
  128. */
  129. virtual void PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref,
  130. int aPrintMask, bool aPrintMirrorMode,
  131. void * aData = NULL);
  132. void GetKicadAbout( wxCommandEvent& event );
  133. /** Function IsGridVisible() , virtual
  134. * @return true if the grid must be shown
  135. */
  136. virtual bool IsGridVisible();
  137. /** Function SetGridVisibility() , virtual
  138. * It may be overloaded by derived classes
  139. * if you want to store/retrieve the grid visiblity in configuration.
  140. * @param aVisible = true if the grid must be shown
  141. */
  142. virtual void SetGridVisibility(bool aVisible);
  143. /** Function GetGridColor() , virtual
  144. * @return the color of the grid
  145. */
  146. virtual int GetGridColor();
  147. /** Function SetGridColor() , virtual
  148. * @param aColor = the new color of the grid
  149. */
  150. virtual void SetGridColor(int aColor);
  151. // Configurations:
  152. void InstallConfigFrame( const wxPoint& pos );
  153. void Process_Config( wxCommandEvent& event );
  154. void Update_config( wxWindow* displayframe );
  155. /** Function Read_Config
  156. * Read the project configuration file
  157. * @param projectFileName = the config filename
  158. * if not found use kicad.pro
  159. * if not found : initialize default values
  160. * @return true if the current config is modified, false if no change
  161. */
  162. bool Read_Config( const wxString& projectFileName );
  163. void OnHotKey( wxDC* DC,
  164. int hotkey,
  165. EDA_BaseStruct* DrawStruct );
  166. bool OnHotkeyDeleteItem( wxDC* DC, EDA_BaseStruct* DrawStruct );
  167. void OnCloseWindow( wxCloseEvent& Event );
  168. void Process_Special_Functions( wxCommandEvent& event );
  169. void Tracks_and_Vias_Size_Event( wxCommandEvent& event );
  170. void ProcessMuWaveFunctions( wxCommandEvent& event );
  171. void MuWaveCommand( wxDC* DC, const wxPoint& MousePos );
  172. void RedrawActiveWindow( wxDC* DC, bool EraseBg );
  173. void ReCreateHToolbar();
  174. void ReCreateAuxiliaryToolbar();
  175. void ReCreateVToolbar();
  176. void ReCreateAuxVToolbar();
  177. void ReCreateOptToolbar();
  178. void ReCreateMenuBar();
  179. WinEDAChoiceBox* ReCreateLayerBox( WinEDA_Toolbar* parent );
  180. /**
  181. * Function IsElementVisible
  182. * tests whether a given element category is visible. Keep this as an
  183. * inline function.
  184. * @param aPCB_VISIBLE is from the enum by the same name
  185. * @return bool - true if the element is visible.
  186. * @see enum PCB_VISIBLE
  187. */
  188. bool IsElementVisible( int aPCB_VISIBLE )
  189. {
  190. return GetBoard()->IsElementVisible( aPCB_VISIBLE );
  191. }
  192. /**
  193. * Function SetElementVisibility
  194. * changes the visibility of an element category
  195. * @param aPCB_VISIBLE is from the enum by the same name
  196. * @param aNewState = The new visibility state of the element category
  197. * @see enum PCB_VISIBLE
  198. */
  199. void SetElementVisibility( int aPCB_VISIBLE, bool aNewState );
  200. /**
  201. * Function SetVisibleAlls
  202. * Set the status of all visible element categories and layers to VISIBLE
  203. */
  204. void SetVisibleAlls( );
  205. /**
  206. * Function ReFillLayerWidget
  207. * changes out all the layers in m_Layers and may be called upon
  208. * loading a new BOARD.
  209. */
  210. void ReFillLayerWidget();
  211. void Show3D_Frame( wxCommandEvent& event );
  212. void GeneralControle( wxDC* DC, wxPoint Mouse );
  213. /** function ShowDesignRulesEditor
  214. * Display the Design Rules Editor.
  215. */
  216. void ShowDesignRulesEditor( wxCommandEvent& event );
  217. /* toolbars update UI functions: */
  218. void PrepareLayerIndicator();
  219. /**
  220. * Function AuxiliaryToolBar_Update_UI
  221. * update the displayed values on auxiliary horizontal toolbar
  222. * (track width, via sizes, clearance ...
  223. */
  224. void AuxiliaryToolBar_Update_UI();
  225. /**
  226. * Function AuxiliaryToolBar_DesignRules_Update_UI
  227. * update the displayed values: track width, via sizes, clearance
  228. * used when a new netclass is selected
  229. */
  230. void AuxiliaryToolBar_DesignRules_Update_UI();
  231. /* mouse functions events: */
  232. void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
  233. void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
  234. /**
  235. * Function OnRightClick
  236. * populates a popup menu with the choices appropriate for the current
  237. *context.
  238. * The caller will add the ZOOM menu choices afterwards.
  239. * @param aMousePos The current mouse position
  240. * @param aPopMenu The menu to add to.
  241. */
  242. bool OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu );
  243. void OnSelectOptionToolbar( wxCommandEvent& event );
  244. void ToolOnRightClick( wxCommandEvent& event );
  245. /** Function SaveCopyInUndoList.
  246. * Creates a new entry in undo list of commands.
  247. * add a picker to handle aItemToCopy
  248. * @param aItemToCopy = the board item modified by the command to undo
  249. * @param aTypeCommand = command type (see enum UndoRedoOpType)
  250. * @param aTransformPoint = the reference point of the transformation, for
  251. *commands like move
  252. */
  253. virtual void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy,
  254. UndoRedoOpType aTypeCommand,
  255. const wxPoint& aTransformPoint =
  256. wxPoint( 0, 0 ) );
  257. /** Function SaveCopyInUndoList (overloaded).
  258. * Creates a new entry in undo list of commands.
  259. * add a list of pickers to handle a list of items
  260. * @param aItemsList = the list of items modified by the command to undo
  261. * @param aTypeCommand = command type (see enum UndoRedoOpType)
  262. * @param aTransformPoint = the reference point of the transformation, for
  263. *commands like move
  264. */
  265. virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
  266. UndoRedoOpType aTypeCommand,
  267. const wxPoint& aTransformPoint =
  268. wxPoint( 0, 0 ) );
  269. /** Function PutDataInPreviousState()
  270. * Used in undo or redo command.
  271. * Put data pointed by List in the previous state, i.e. the state memorized
  272. * by List
  273. * @param aList = a PICKED_ITEMS_LIST pointer to the list of items to
  274. * undo/redo
  275. * @param aRedoCommand = a bool: true for redo, false for undo
  276. * @param aRebuildRatsnet = a bool: true to rebuild ratsnet (normal use),
  277. * false
  278. * to just retrieve las state (used in abort commands that do not need to
  279. * rebuild ratsnest)
  280. */
  281. void PutDataInPreviousState( PICKED_ITEMS_LIST* aList,
  282. bool aRedoCommand,
  283. bool aRebuildRatsnet = true );
  284. /** Function GetBoardFromRedoList
  285. * Redo the last edition:
  286. * - Save the current board in Undo list
  287. * - Get an old version of the board from Redo list
  288. * @return none
  289. */
  290. void GetBoardFromRedoList( wxCommandEvent& event );
  291. /** Function GetBoardFromUndoList
  292. * Undo the last edition:
  293. * - Save the current board in Redo list
  294. * - Get an old version of the board from Undo list
  295. * @return none
  296. */
  297. void GetBoardFromUndoList( wxCommandEvent& event );
  298. /* Block operations: */
  299. int ReturnBlockCommand( int key );
  300. void HandleBlockPlace( wxDC* DC );
  301. int HandleBlockEnd( wxDC* DC );
  302. /**
  303. * Function Block_SelectItems
  304. * Uses GetScreen()->m_BlockLocate
  305. * select items within the selected block.
  306. * selected items are put in the pick list
  307. * @param none
  308. */
  309. void Block_SelectItems();
  310. /**
  311. * Function Block_Delete
  312. * deletes all items within the selected block.
  313. * @param none
  314. */
  315. void Block_Delete();
  316. /**
  317. * Function Block_Rotate
  318. * Rotate all items within the selected block.
  319. * The rotation center is the center of the block
  320. * @param none
  321. */
  322. void Block_Rotate();
  323. /**
  324. * Function Block_Flip
  325. * Flip items within the selected block.
  326. * The flip center is the center of the block
  327. * @param none
  328. */
  329. void Block_Flip();
  330. /**
  331. * Function Block_Move
  332. * move all items within the selected block.
  333. * New location is determined by the current offset from the selected
  334. *block's original location.
  335. * @param none
  336. */
  337. void Block_Move();
  338. /**
  339. * Function Block_Mirror_X
  340. * mirrors all items within the currently selected block in the X axis.
  341. * @param none
  342. */
  343. void Block_Mirror_X();
  344. /**
  345. * Function Block_Duplicate
  346. * Duplicate all items within the selected block.
  347. * New location is determined by the current offset from the selected
  348. * block's original location.
  349. * @param none
  350. */
  351. void Block_Duplicate();
  352. void SetToolbars();
  353. void Process_Settings( wxCommandEvent& event );
  354. void InstallPcbOptionsFrame( int id );
  355. void InstallDisplayOptionsDialog( wxCommandEvent& aEvent );
  356. void InstallPcbGlobalDeleteFrame( const wxPoint& pos );
  357. void GenModulesPosition( wxCommandEvent& event );
  358. void GenModuleReport( wxCommandEvent& event );
  359. void InstallDrillFrame( wxCommandEvent& event );
  360. void ToPostProcess( wxCommandEvent& event );
  361. void OnFileHistory( wxCommandEvent& event );
  362. void Files_io( wxCommandEvent& event );
  363. bool LoadOnePcbFile( const wxString& FileName, bool Append );
  364. /**
  365. * Function ReadPcbFile
  366. * reads a board file <file>.brd
  367. * @param Append if 0: a previously loaded board is deleted before loading
  368. * the file else all items of the board file are added to the
  369. * existing board
  370. */
  371. int ReadPcbFile( FILE* File, bool Append );
  372. bool SavePcbFile( const wxString& FileName );
  373. int SavePcbFormatAscii( FILE* File );
  374. bool WriteGeneralDescrPcb( FILE* File );
  375. // BOARD handling
  376. /** function Clear_Pcb()
  377. * delete all and reinitialize the current board
  378. * @param aQuery = true to prompt user for confirmation, false to
  379. * initialize silently
  380. */
  381. bool Clear_Pcb( bool aQuery );
  382. // Drc control
  383. /* function GetDrcController
  384. * @return the DRC controller
  385. */
  386. DRC* GetDrcController() { return m_drc; }
  387. /**
  388. * Function RecreateBOMFileFromBoard
  389. * Recreates a .cmp file from the current loaded board
  390. * this is the same as created by cvpcb.
  391. * can be used if this file is lost
  392. */
  393. void RecreateCmpFileFromBoard( wxCommandEvent& aEvent );
  394. /**
  395. * Function RecreateBOMFileFromBoard
  396. * Creates a BOM file from the current loaded board
  397. */
  398. void RecreateBOMFileFromBoard( wxCommandEvent& aEvent );
  399. void ExportToGenCAD( wxCommandEvent& event );
  400. /**
  401. * Function ExporttoSPECCTRA
  402. * will export the current BOARD to a specctra dsn file. See
  403. * See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the
  404. * specification.
  405. */
  406. void ExportToSpecctra( wxCommandEvent& event );
  407. /**
  408. * Function ImportSpecctraSession
  409. * will import a specctra *.ses file and use it to relocate MODULEs and
  410. * to replace all vias and tracks in an existing and loaded BOARD.
  411. * See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the
  412. * specification.
  413. */
  414. void ImportSpecctraSession( wxCommandEvent& event );
  415. /**
  416. * Function ImportSpecctraDesign
  417. * will import a specctra *.dsn file and use it to replace an entire BOARD.
  418. * The new board will not have any graphics, only components, tracks and
  419. * vias.
  420. * See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the
  421. * specification.
  422. */
  423. void ImportSpecctraDesign( wxCommandEvent& event );
  424. /**
  425. * Function Access_to_External_Tool
  426. * Run an external tool (like freeroute )
  427. */
  428. void Access_to_External_Tool( wxCommandEvent& event );
  429. MODULE* ListAndSelectModuleName();
  430. /** Function ListNetsAndSelect
  431. * called by a command event
  432. * displays the sorted list of nets in a dialog frame
  433. * If a net is selected, it is highlighted
  434. */
  435. void ListNetsAndSelect( wxCommandEvent& event );
  436. void Swap_Layers( wxCommandEvent& event );
  437. void Install_Test_DRC_Frame( wxDC* DC );
  438. // Handling texts on the board
  439. void Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC );
  440. TEXTE_PCB* Create_Texte_Pcb( wxDC* DC );
  441. void Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC );
  442. void StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC );
  443. void Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC );
  444. void InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, wxDC* DC );
  445. // Graphic Segments type DRAWSEGMENT
  446. void Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC );
  447. void Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC );
  448. void InstallGraphicItemPropertiesDialog( DRAWSEGMENT* aItem,
  449. wxDC* aDC );
  450. // Footprint edition (see also WinEDA_BasePcbFrame)
  451. void InstallModuleOptionsFrame( MODULE* Module, wxDC* DC );
  452. void StartMove_Module( MODULE* module, wxDC* DC );
  453. bool Delete_Module( MODULE* module,
  454. wxDC* DC,
  455. bool aAskBeforeDeleting );
  456. void Change_Side_Module( MODULE* Module, wxDC* DC );
  457. void InstallExchangeModuleFrame( MODULE* ExchangeModuleModule );
  458. /** function Exchange_Module
  459. * Replaces OldModule by NewModule, using OldModule settings:
  460. * position, orientation, pad netnames ...)
  461. * OldModule is deleted or put in undo list.
  462. * @param aOldModule = footprint to replace
  463. * @param aNewModule = footprint to put
  464. * @param aUndoPickList = the undo list used to save OldModule. If null,
  465. * OldModule is deleted
  466. */
  467. void Exchange_Module( MODULE* aOldModule,
  468. MODULE* aNewModule,
  469. PICKED_ITEMS_LIST* aUndoPickList );
  470. // loading modules: see WinEDA_BasePcbFrame
  471. // Board handling
  472. void RemoveStruct( BOARD_ITEM* Item, wxDC* DC );
  473. // Highlight functions:
  474. int Select_High_Light( wxDC* DC );
  475. void High_Light( wxDC* DC );
  476. // Track and via edition:
  477. void Via_Edit_Control( wxCommandEvent& event );
  478. /* Return true if a microvia can be put on board
  479. * A microvia is a small via restricted to 2 near neighbor layers
  480. * because its is hole is made by laser which can penetrate only one layer
  481. * It is mainly used to connect BGA to the first inner layer
  482. * And it is allowed from an external layer to the first inner layer
  483. */
  484. bool IsMicroViaAcceptable( void );
  485. /**
  486. * Function Other_Layer_Route
  487. * operates in one of two ways. If argument track is NULL, then swap the
  488. * active layer between m_Route_Layer_TOP and m_Route_Layer_BOTTOM. If a
  489. * track is in progress (track is not NULL), and if DRC allows it, place
  490. * a via on the end of the current track, and then swap the current active
  491. * layer and start a new segment on the new layer.
  492. * @param track A TRACK* to append the via to or NULL.
  493. * @param DC A device context to draw on.
  494. * @return bool - true if the operation was successful, else false such as
  495. * the case where DRC would not allow a via.
  496. */
  497. bool Other_Layer_Route( TRACK* track, wxDC* DC );
  498. void Affiche_PadsNoConnect( wxDC* DC );
  499. void Affiche_Status_Net( wxDC* DC );
  500. TRACK* Delete_Segment( wxDC* DC, TRACK* Track );
  501. void Delete_Track( wxDC* DC, TRACK* Track );
  502. void Delete_net( wxDC* DC, TRACK* Track );
  503. void Remove_One_Track( wxDC* DC, TRACK* pt_segm );
  504. /** function Reset_All_Tracks_And_Vias_To_Netclass_Values
  505. * Reset all tracks width and/or vias diameters and drill
  506. * to their default Netclass value
  507. * @param aTrack : bool true to modify tracks
  508. * @param aVia : bool true to modify vias
  509. */
  510. bool Reset_All_Tracks_And_Vias_To_Netclass_Values( bool aTrack,
  511. bool aVia );
  512. /** function Change_Net_Tracks_And_Vias_Sizes
  513. * Reset all tracks width and vias diameters and drill
  514. * to their default Netclass value or current values
  515. * @param aNetcode : the netcode of the net to edit
  516. * @param aUseNetclassValue : bool. True to use netclass values, false to
  517. * use current values
  518. */
  519. bool Change_Net_Tracks_And_Vias_Sizes( int aNetcode,
  520. bool aUseNetclassValue );
  521. /** Function Edit_Track_Width
  522. * Modify a full track width (using DRC control).
  523. * a full track is the set of track segments between 2 ends: pads or a
  524. * point that has more than 2 segments ends connected
  525. * @param DC = the curred device context (can be NULL)
  526. * @param aTrackSegment = a segment or via on the track to change
  527. */
  528. void Edit_Track_Width( wxDC* DC, TRACK* Track );
  529. /** Function Edit_TrackSegm_Width
  530. * Modify one track segment width or one via diameter (using DRC control).
  531. * @param DC = the current device context (can be NULL)
  532. * @param aTrackItem = the track segment or via to modify
  533. */
  534. void Edit_TrackSegm_Width( wxDC* DC, TRACK* segm );
  535. TRACK* Begin_Route( TRACK* track, wxDC* DC );
  536. void End_Route( TRACK* track, wxDC* DC );
  537. void ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC );
  538. void Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On );
  539. void Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On );
  540. void Attribut_net( wxDC* DC, int net_code, bool Flag_On );
  541. void Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int command );
  542. bool PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC );
  543. bool MergeCollinearTracks( TRACK* track, wxDC* DC, int end );
  544. void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC );
  545. void SwitchLayer( wxDC* DC, int layer );
  546. bool Add_45_degrees_Segment( wxDC* DC );
  547. bool Genere_Pad_Connexion( wxDC* DC, int layer );
  548. /** function EraseRedundantTrack
  549. * Called after creating a track
  550. * Remove (if exists) the old track that have the same starting and the
  551. * same ending point as the new created track
  552. * (this is the redunding track)
  553. * @param aDC = the current device context (can be NULL)
  554. * @param aNewTrack = the new created track (a pointer to a segment of the
  555. * track list)
  556. * @param aNewTrackSegmentsCount = number of segments in this new track
  557. * @param aItemsListPicker = the list picker to use for an undo command
  558. * (can be NULL)
  559. */
  560. int EraseRedundantTrack( wxDC* aDC,
  561. TRACK* aNewTrack,
  562. int aNewTrackSegmentsCount,
  563. PICKED_ITEMS_LIST* aItemsListPicker );
  564. /** Function SetTrackSegmentWidth
  565. * Modify one track segment width or one via diameter (using DRC control).
  566. * Basic routine used by other routines when editing tracks or vias
  567. * @param aTrackItem = the track segment or via to modify
  568. * @param aItemsListPicker = the list picker to use for an undo command
  569. * (can be NULL)
  570. * @param aUseNetclassValue = true to use NetClass value, false to use
  571. * current designSettings value
  572. * @return true if done, false if no not change (because DRC error)
  573. */
  574. bool SetTrackSegmentWidth( TRACK* aTrackItem,
  575. PICKED_ITEMS_LIST* aItemsListPicker,
  576. bool aUseNetclassValue );
  577. // zone handling
  578. /** Function Delete_Zone_Fill
  579. * Remove the zone filling which include the segment aZone, or the zone
  580. * which have the given time stamp. A zone is a group of segments which
  581. * have the same TimeStamp
  582. * @param aZone = zone segment within the zone to delete. Can be NULL
  583. * @param aTimestamp = Timestamp for the zone to delete, used if aZone ==
  584. * NULL
  585. */
  586. void Delete_Zone_Fill( SEGZONE* Track, long aTimestamp = 0 );
  587. /** Function Delete_LastCreatedCorner
  588. * Used only while creating a new zone outline
  589. * Remove and delete the current outline segment in progress
  590. * @return 0 if no corner in list, or corner number
  591. */
  592. int Delete_LastCreatedCorner( wxDC* DC );
  593. /**
  594. * Function Begin_Zone
  595. * initiates a zone edge creation process,
  596. * or terminates the current zone edge and creates a new zone edge stub
  597. */
  598. int Begin_Zone( wxDC* DC );
  599. /**
  600. * Function End_Zone
  601. * terminates (if no DRC error ) the zone edge creation process
  602. * @param DC = current Device Context
  603. * @return true if Ok, false if DRC error
  604. */
  605. bool End_Zone( wxDC* DC );
  606. /** Function Fill_Zone()
  607. * Calculate the zone filling for the outline zone_container
  608. * The zone outline is a frontier, and can be complex (with holes)
  609. * The filling starts from starting points like pads, tracks.
  610. * If exists the old filling is removed
  611. * @param zone_container = zone to fill
  612. * @param verbose = true to show error messages
  613. * @return error level (0 = no error)
  614. */
  615. int Fill_Zone( ZONE_CONTAINER* zone_container, bool verbose = TRUE );
  616. /** Function Fill_All_Zones()
  617. * Fill all zones on the board
  618. * The old fillings are removed
  619. * @param verbose = true to show error messages
  620. * @return error level (0 = no error)
  621. */
  622. int Fill_All_Zones( bool verbose = TRUE );
  623. /**
  624. * Function Add_Zone_Cutout
  625. * Add a cutout zone to a given zone outline
  626. * @param DC = current Device Context
  627. * @param zone_container = parent zone outline
  628. */
  629. void Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container );
  630. /**
  631. * Function Add_Similar_Zone
  632. * Add a zone to a given zone outline.
  633. * if the zones are overlapping they will be merged
  634. * @param DC = current Device Context
  635. * @param zone_container = parent zone outline
  636. */
  637. void Add_Similar_Zone( wxDC* DC, ZONE_CONTAINER* zone_container );
  638. /**
  639. * Function Edit_Zone_Params
  640. * Edit params (layer, clearance, ...) for a zone outline
  641. */
  642. void Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container );
  643. /**
  644. * Function Start_Move_Zone_Corner
  645. * Prepares a move corner in a zone outline,
  646. * called from a move corner command (IsNewCorner = false),
  647. * or a create new cornet command (IsNewCorner = true )
  648. */
  649. void Start_Move_Zone_Corner( wxDC* DC,
  650. ZONE_CONTAINER* zone_container,
  651. int corner_id,
  652. bool IsNewCorner );
  653. /**
  654. * Function Start_Move_Zone_Corner
  655. * Prepares a drag edge in an existing zone outline,
  656. */
  657. void Start_Move_Zone_Drag_Outline_Edge(
  658. wxDC* DC,
  659. ZONE_CONTAINER*
  660. zone_container,
  661. int corner_id );
  662. /**
  663. * Function End_Move_Zone_Corner_Or_Outlines
  664. * Terminates a move corner in a zone outline, or a move zone outlines
  665. * @param DC = current Device Context (can be NULL)
  666. * @param zone_container: the given zone
  667. */
  668. void End_Move_Zone_Corner_Or_Outlines(
  669. wxDC* DC,
  670. ZONE_CONTAINER*
  671. zone_container );
  672. /**
  673. * Function End_Move_Zone_Corner_Or_Outlines
  674. * Remove the currently selected corner in a zone outline
  675. * the .m_CornerSelection is used as corner selection
  676. */
  677. void Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container );
  678. /** Function Delete_Zone
  679. * Remove the zone which include the segment aZone, or the zone which have
  680. * the given time stamp. A zone is a group of segments which have the
  681. * same TimeStamp
  682. * @param DC = current Device Context (can be NULL)
  683. * @param zone_container = zone to modify
  684. * the member .m_CornerSelection is used to find the outline to remove.
  685. * if the outline is the main outline, all the zone is removed
  686. * otherwise, the hole is deleted
  687. */
  688. void Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_container );
  689. /**
  690. * Function Start_Move_Zone_Outlines
  691. * Initialize parameters to move an existing zone outlines.
  692. * @param DC = current Device Context (can be NULL)
  693. * @param zone_container: the given zone to move
  694. */
  695. void Start_Move_Zone_Outlines( wxDC* DC,
  696. ZONE_CONTAINER* zone_container );
  697. // Target handling
  698. MIREPCB* Create_Mire( wxDC* DC );
  699. void Delete_Mire( MIREPCB* MirePcb, wxDC* DC );
  700. void StartMove_Mire( MIREPCB* MirePcb, wxDC* DC );
  701. void Place_Mire( MIREPCB* MirePcb, wxDC* DC );
  702. void InstallMireOptionsFrame( MIREPCB* MirePcb,
  703. wxDC* DC,
  704. const wxPoint& pos );
  705. // Graphic segments type DRAWSEGMENT handling:
  706. DRAWSEGMENT* Begin_DrawSegment( DRAWSEGMENT* Segment, int shape, wxDC* DC );
  707. void End_Edge( DRAWSEGMENT* Segment, wxDC* DC );
  708. void Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC );
  709. void Delete_Drawings_All_Layer( int aLayer );
  710. // Dimension handling:
  711. void Install_Edit_Cotation( COTATION* Cotation,
  712. wxDC* DC,
  713. const wxPoint& pos );
  714. COTATION* Begin_Cotation( COTATION* Cotation, wxDC* DC );
  715. void Delete_Cotation( COTATION* Cotation, wxDC* DC );
  716. // netlist handling:
  717. void InstallNetlistFrame( wxDC* DC, const wxPoint& pos );
  718. // Autoplacement:
  719. void AutoPlace( wxCommandEvent& event );
  720. /** function OnOrientFootprints
  721. * install the dialog box for the common Orient Footprints
  722. */
  723. void OnOrientFootprints( void );
  724. /** function ReOrientModules
  725. * Set the orientation of footprints
  726. * @param ModuleMask = mask (wildcard allowed) selection
  727. * @param Orient = new orientation
  728. * @param include_fixe = true to orient locked footprints
  729. */
  730. void ReOrientModules( const wxString& ModuleMask, int Orient,
  731. bool include_fixe );
  732. void FixeModule( MODULE* Module, bool Fixe );
  733. void AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb );
  734. bool SetBoardBoundaryBoxFromEdgesOnly();
  735. void AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC );
  736. int RecherchePlacementModule( MODULE* Module, wxDC* DC );
  737. void GenModuleOnBoard( MODULE* Module );
  738. float Compute_Ratsnest_PlaceModule( wxDC* DC );
  739. int GenPlaceBoard();
  740. void DrawInfoPlace( wxDC* DC );
  741. // Autorouting:
  742. int Solve( wxDC* DC, int two_sides );
  743. void Reset_Noroutable( wxDC* DC );
  744. void Autoroute( wxDC* DC, int mode );
  745. void ReadAutoroutedTracks( wxDC* DC );
  746. void GlobalRoute( wxDC* DC );
  747. void Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC );
  748. void Clean_Pcb( wxDC* DC );
  749. void InstallFindFrame( const wxPoint& pos, wxDC* DC );
  750. /**
  751. * Function SendMessageToEESCHEMA
  752. * sends a message to the schematic editor so that it may move its cursor
  753. * to a part with the same reference as the objectToSync
  754. * @param objectToSync The object whose reference is used to synchronize
  755. * eeschema.
  756. */
  757. void SendMessageToEESCHEMA( BOARD_ITEM* objectToSync );
  758. /* Micro waves functions */
  759. void Edit_Gap( wxDC* DC, MODULE* Module );
  760. MODULE* Create_MuWaveBasicShape( const wxString& name, int pad_count );
  761. MODULE* Create_MuWaveComponent( int shape_type );
  762. MODULE* Create_MuWavePolygonShape();
  763. void Begin_Self( wxDC* DC );
  764. MODULE* Genere_Self( wxDC* DC );
  765. /**
  766. * Load applications settings specific to the PCBNew.
  767. *
  768. * This overrides the base class WinEDA_BasePcbFrame::LoadSettings() to
  769. * handle settings specific common to the PCB layout application. It
  770. * calls down to the base class to load settings common to all PCB type
  771. * drawing frames. Please put your application settings for PCBNew here
  772. * to avoid having application settings loaded all over the place.
  773. */
  774. virtual void LoadSettings();
  775. /**
  776. * Save applications settings common to PCB draw frame objects.
  777. *
  778. * This overrides the base class WinEDA_BasePcbFrame::SaveSettings() to
  779. * save settings specific to the PCB layout application main window. It
  780. * calls down to the base class to save settings common to all PCB type
  781. * drawing frames. Please put your application settings for PCBNew here
  782. * to avoid having application settings saved all over the place.
  783. */
  784. virtual void SaveSettings();
  785. /** function SetLanguage
  786. * called on a language menu selection
  787. */
  788. virtual void SetLanguage( wxCommandEvent& event );
  789. DECLARE_EVENT_TABLE()
  790. };
  791. /*********************************************************/
  792. /* class WinEDA_ModuleEditFrame: public WinEDA_DrawFrame */
  793. /* Class for the footprint editor */
  794. /*********************************************************/
  795. class WinEDA_ModuleEditFrame : public WinEDA_BasePcbFrame
  796. {
  797. public:
  798. MODULE* CurrentModule;
  799. wxString m_CurrentLib;
  800. public:
  801. WinEDA_ModuleEditFrame( wxWindow* father,
  802. const wxString& title,
  803. const wxPoint& pos, const wxSize& size,
  804. long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
  805. ~WinEDA_ModuleEditFrame();
  806. void InstallOptionsFrame( const wxPoint& pos );
  807. void OnCloseWindow( wxCloseEvent& Event );
  808. void Process_Special_Functions( wxCommandEvent& event );
  809. void RedrawActiveWindow( wxDC* DC, bool EraseBg );
  810. void ReCreateHToolbar();
  811. void ReCreateVToolbar();
  812. void ReCreateOptToolbar();
  813. void ReCreateAuxiliaryToolbar();
  814. void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
  815. void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
  816. bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
  817. void SetToolbars();
  818. void ReCreateMenuBar();
  819. void ToolOnRightClick( wxCommandEvent& event );
  820. void OnSelectOptionToolbar( wxCommandEvent& event );
  821. void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct );
  822. void Show3D_Frame( wxCommandEvent& event );
  823. void GeneralControle( wxDC* DC, wxPoint Mouse );
  824. void LoadModuleFromBoard( wxCommandEvent& event );
  825. /** function ToPrinter
  826. * Install the print dialog
  827. */
  828. void ToPrinter( wxCommandEvent& event );
  829. // BOARD handling
  830. /** function Clear_Pcb()
  831. * delete all and reinitialize the current board
  832. * @param aQuery = true to prompt user for confirmation, false to
  833. * initialize silently
  834. */
  835. bool Clear_Pcb( bool aQuery );
  836. /* handlers for block commands */
  837. int ReturnBlockCommand( int key );
  838. virtual void HandleBlockPlace( wxDC* DC );
  839. virtual int HandleBlockEnd( wxDC* DC );
  840. BOARD_ITEM* ModeditLocateAndDisplay( int aHotKeyCode = 0 );
  841. /* Undo and redo functions */
  842. public:
  843. /** Function SaveCopyInUndoList.
  844. * Creates a new entry in undo list of commands.
  845. * add a picker to handle aItemToCopy
  846. * @param aItem = the board item modified by the command to undo
  847. * @param aTypeCommand = command type (see enum UndoRedoOpType)
  848. * @param aTransformPoint = the reference point of the transformation, for
  849. * commands like move
  850. */
  851. virtual void SaveCopyInUndoList( BOARD_ITEM* aItem,
  852. UndoRedoOpType aTypeCommand,
  853. const wxPoint& aTransformPoint =
  854. wxPoint( 0, 0 ) );
  855. /** Function SaveCopyInUndoList (overloaded).
  856. * Creates a new entry in undo list of commands.
  857. * add a list of pickers to handle a list of items
  858. * @param aItemsList = the list of items modified by the command to undo
  859. * @param aTypeCommand = command type (see enum UndoRedoOpType)
  860. * @param aTransformPoint = the reference point of the transformation, for
  861. * commands like move
  862. */
  863. virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
  864. UndoRedoOpType aTypeCommand,
  865. const wxPoint& aTransformPoint =
  866. wxPoint( 0, 0 ) );
  867. private:
  868. void GetComponentFromUndoList( wxCommandEvent& event );
  869. void GetComponentFromRedoList( wxCommandEvent& event );
  870. public:
  871. // Footprint edition
  872. void Place_Ancre( MODULE* module );
  873. void RemoveStruct( EDA_BaseStruct* Item );
  874. void Transform( MODULE* module, int transform );
  875. // loading Footprint
  876. MODULE* Import_Module( wxDC* DC );
  877. void Export_Module( MODULE* ptmod, bool createlib );
  878. void Load_Module_From_BOARD( MODULE* Module );
  879. // functions to edit footprint edges
  880. /**
  881. * Function Edit_Edge_Width
  882. * changes the width of module perimeter lines, EDGE_MODULEs.
  883. * @param ModuleSegmentWidth (global) = new width
  884. * @param Edge = edge to edit, or NULL. If Edge == NULL change
  885. * the width of all the footprint's edges
  886. * @param DC = current Device Context
  887. */
  888. void Edit_Edge_Width( EDGE_MODULE* Edge );
  889. void Edit_Edge_Layer( EDGE_MODULE* Edge );
  890. void Delete_Edge_Module( EDGE_MODULE* Edge );
  891. EDGE_MODULE* Begin_Edge_Module( EDGE_MODULE* Edge, wxDC* DC, int type_edge );
  892. void End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC );
  893. void Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC );
  894. void Start_Move_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC );
  895. void Place_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC );
  896. // handlers for libraries:
  897. void Delete_Module_In_Library( const wxString& libname );
  898. int Create_Librairie( const wxString& LibName );
  899. void Select_Active_Library();
  900. DECLARE_EVENT_TABLE()
  901. };
  902. #endif /* WXPCB_STRUCT_H */