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.

1144 lines
43 KiB

17 years ago
17 years ago
17 years ago
16 years ago
17 years ago
17 years ago
17 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 OnExportVRML
  402. * will export the current BOARD to a VRML file.
  403. */
  404. void OnExportVRML( wxCommandEvent& event );
  405. /**
  406. * Function ExportVRML_File
  407. * Creates the file(s) exporting current BOARD to a VRML file.
  408. * @param aFullFileName = the full filename of the file to create
  409. * @param aScale = the general scaling factor. 1.0 to export in inches
  410. * @param aExport3DFiles = true to copy 3D shapes in the subir a3D_Subdir
  411. * @param a3D_Subdir = sub directory where 3D sahpes files are copied
  412. * used only when aExport3DFiles == true
  413. * @return true if Ok.
  414. */
  415. bool ExportVRML_File( const wxString & aFullFileName, double aScale,
  416. bool aExport3DFiles, const wxString & a3D_Subdir );
  417. /**
  418. * Function ExporttoSPECCTRA
  419. * will export the current BOARD to a specctra dsn file. See
  420. * See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the
  421. * specification.
  422. */
  423. void ExportToSpecctra( wxCommandEvent& event );
  424. /**
  425. * Function ImportSpecctraSession
  426. * will import a specctra *.ses file and use it to relocate MODULEs and
  427. * to replace all vias and tracks in an existing and loaded BOARD.
  428. * See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the
  429. * specification.
  430. */
  431. void ImportSpecctraSession( wxCommandEvent& event );
  432. /**
  433. * Function ImportSpecctraDesign
  434. * will import a specctra *.dsn file and use it to replace an entire BOARD.
  435. * The new board will not have any graphics, only components, tracks and
  436. * vias.
  437. * See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the
  438. * specification.
  439. */
  440. void ImportSpecctraDesign( wxCommandEvent& event );
  441. /**
  442. * Function Access_to_External_Tool
  443. * Run an external tool (like freeroute )
  444. */
  445. void Access_to_External_Tool( wxCommandEvent& event );
  446. MODULE* ListAndSelectModuleName();
  447. /** Function ListNetsAndSelect
  448. * called by a command event
  449. * displays the sorted list of nets in a dialog frame
  450. * If a net is selected, it is highlighted
  451. */
  452. void ListNetsAndSelect( wxCommandEvent& event );
  453. void Swap_Layers( wxCommandEvent& event );
  454. void Install_Test_DRC_Frame( wxDC* DC );
  455. // Handling texts on the board
  456. void Rotate_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC );
  457. TEXTE_PCB* Create_Texte_Pcb( wxDC* DC );
  458. void Delete_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC );
  459. void StartMoveTextePcb( TEXTE_PCB* TextePcb, wxDC* DC );
  460. void Place_Texte_Pcb( TEXTE_PCB* TextePcb, wxDC* DC );
  461. void InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, wxDC* DC );
  462. // Graphic Segments type DRAWSEGMENT
  463. void Start_Move_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC );
  464. void Place_DrawItem( DRAWSEGMENT* drawitem, wxDC* DC );
  465. void InstallGraphicItemPropertiesDialog( DRAWSEGMENT* aItem,
  466. wxDC* aDC );
  467. // Footprint edition (see also WinEDA_BasePcbFrame)
  468. void InstallModuleOptionsFrame( MODULE* Module, wxDC* DC );
  469. void StartMove_Module( MODULE* module, wxDC* DC );
  470. bool Delete_Module( MODULE* module,
  471. wxDC* DC,
  472. bool aAskBeforeDeleting );
  473. void Change_Side_Module( MODULE* Module, wxDC* DC );
  474. void InstallExchangeModuleFrame( MODULE* ExchangeModuleModule );
  475. /** function Exchange_Module
  476. * Replaces OldModule by NewModule, using OldModule settings:
  477. * position, orientation, pad netnames ...)
  478. * OldModule is deleted or put in undo list.
  479. * @param aOldModule = footprint to replace
  480. * @param aNewModule = footprint to put
  481. * @param aUndoPickList = the undo list used to save OldModule. If null,
  482. * OldModule is deleted
  483. */
  484. void Exchange_Module( MODULE* aOldModule,
  485. MODULE* aNewModule,
  486. PICKED_ITEMS_LIST* aUndoPickList );
  487. // loading modules: see WinEDA_BasePcbFrame
  488. // Board handling
  489. void RemoveStruct( BOARD_ITEM* Item, wxDC* DC );
  490. // Highlight functions:
  491. int Select_High_Light( wxDC* DC );
  492. void High_Light( wxDC* DC );
  493. // Track and via edition:
  494. void Via_Edit_Control( wxCommandEvent& event );
  495. /* Return true if a microvia can be put on board
  496. * A microvia is a small via restricted to 2 near neighbor layers
  497. * because its is hole is made by laser which can penetrate only one layer
  498. * It is mainly used to connect BGA to the first inner layer
  499. * And it is allowed from an external layer to the first inner layer
  500. */
  501. bool IsMicroViaAcceptable( void );
  502. /**
  503. * Function Other_Layer_Route
  504. * operates in one of two ways. If argument track is NULL, then swap the
  505. * active layer between m_Route_Layer_TOP and m_Route_Layer_BOTTOM. If a
  506. * track is in progress (track is not NULL), and if DRC allows it, place
  507. * a via on the end of the current track, and then swap the current active
  508. * layer and start a new segment on the new layer.
  509. * @param track A TRACK* to append the via to or NULL.
  510. * @param DC A device context to draw on.
  511. * @return bool - true if the operation was successful, else false such as
  512. * the case where DRC would not allow a via.
  513. */
  514. bool Other_Layer_Route( TRACK* track, wxDC* DC );
  515. void Affiche_PadsNoConnect( wxDC* DC );
  516. void Affiche_Status_Net( wxDC* DC );
  517. TRACK* Delete_Segment( wxDC* DC, TRACK* Track );
  518. void Delete_Track( wxDC* DC, TRACK* Track );
  519. void Delete_net( wxDC* DC, TRACK* Track );
  520. void Remove_One_Track( wxDC* DC, TRACK* pt_segm );
  521. /** function Reset_All_Tracks_And_Vias_To_Netclass_Values
  522. * Reset all tracks width and/or vias diameters and drill
  523. * to their default Netclass value
  524. * @param aTrack : bool true to modify tracks
  525. * @param aVia : bool true to modify vias
  526. */
  527. bool Reset_All_Tracks_And_Vias_To_Netclass_Values( bool aTrack,
  528. bool aVia );
  529. /** function Change_Net_Tracks_And_Vias_Sizes
  530. * Reset all tracks width and vias diameters and drill
  531. * to their default Netclass value or current values
  532. * @param aNetcode : the netcode of the net to edit
  533. * @param aUseNetclassValue : bool. True to use netclass values, false to
  534. * use current values
  535. */
  536. bool Change_Net_Tracks_And_Vias_Sizes( int aNetcode,
  537. bool aUseNetclassValue );
  538. /** Function Edit_Track_Width
  539. * Modify a full track width (using DRC control).
  540. * a full track is the set of track segments between 2 ends: pads or a
  541. * point that has more than 2 segments ends connected
  542. * @param DC = the curred device context (can be NULL)
  543. * @param aTrackSegment = a segment or via on the track to change
  544. */
  545. void Edit_Track_Width( wxDC* DC, TRACK* Track );
  546. /** Function Edit_TrackSegm_Width
  547. * Modify one track segment width or one via diameter (using DRC control).
  548. * @param DC = the current device context (can be NULL)
  549. * @param aTrackItem = the track segment or via to modify
  550. */
  551. void Edit_TrackSegm_Width( wxDC* DC, TRACK* segm );
  552. TRACK* Begin_Route( TRACK* track, wxDC* DC );
  553. void End_Route( TRACK* track, wxDC* DC );
  554. void ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC );
  555. void Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On );
  556. void Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On );
  557. void Attribut_net( wxDC* DC, int net_code, bool Flag_On );
  558. void Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int command );
  559. bool PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC );
  560. bool MergeCollinearTracks( TRACK* track, wxDC* DC, int end );
  561. void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC );
  562. void SwitchLayer( wxDC* DC, int layer );
  563. bool Add_45_degrees_Segment( wxDC* DC );
  564. bool Genere_Pad_Connexion( wxDC* DC, int layer );
  565. /** function EraseRedundantTrack
  566. * Called after creating a track
  567. * Remove (if exists) the old track that have the same starting and the
  568. * same ending point as the new created track
  569. * (this is the redunding track)
  570. * @param aDC = the current device context (can be NULL)
  571. * @param aNewTrack = the new created track (a pointer to a segment of the
  572. * track list)
  573. * @param aNewTrackSegmentsCount = number of segments in this new track
  574. * @param aItemsListPicker = the list picker to use for an undo command
  575. * (can be NULL)
  576. */
  577. int EraseRedundantTrack( wxDC* aDC,
  578. TRACK* aNewTrack,
  579. int aNewTrackSegmentsCount,
  580. PICKED_ITEMS_LIST* aItemsListPicker );
  581. /** Function SetTrackSegmentWidth
  582. * Modify one track segment width or one via diameter (using DRC control).
  583. * Basic routine used by other routines when editing tracks or vias
  584. * @param aTrackItem = the track segment or via to modify
  585. * @param aItemsListPicker = the list picker to use for an undo command
  586. * (can be NULL)
  587. * @param aUseNetclassValue = true to use NetClass value, false to use
  588. * current designSettings value
  589. * @return true if done, false if no not change (because DRC error)
  590. */
  591. bool SetTrackSegmentWidth( TRACK* aTrackItem,
  592. PICKED_ITEMS_LIST* aItemsListPicker,
  593. bool aUseNetclassValue );
  594. // zone handling
  595. /** Function Delete_Zone_Fill
  596. * Remove the zone filling which include the segment aZone, or the zone
  597. * which have the given time stamp. A zone is a group of segments which
  598. * have the same TimeStamp
  599. * @param aZone = zone segment within the zone to delete. Can be NULL
  600. * @param aTimestamp = Timestamp for the zone to delete, used if aZone ==
  601. * NULL
  602. */
  603. void Delete_Zone_Fill( SEGZONE* Track, long aTimestamp = 0 );
  604. /** Function Delete_LastCreatedCorner
  605. * Used only while creating a new zone outline
  606. * Remove and delete the current outline segment in progress
  607. * @return 0 if no corner in list, or corner number
  608. */
  609. int Delete_LastCreatedCorner( wxDC* DC );
  610. /**
  611. * Function Begin_Zone
  612. * initiates a zone edge creation process,
  613. * or terminates the current zone edge and creates a new zone edge stub
  614. */
  615. int Begin_Zone( wxDC* DC );
  616. /**
  617. * Function End_Zone
  618. * terminates (if no DRC error ) the zone edge creation process
  619. * @param DC = current Device Context
  620. * @return true if Ok, false if DRC error
  621. */
  622. bool End_Zone( wxDC* DC );
  623. /** Function Fill_Zone()
  624. * Calculate the zone filling for the outline zone_container
  625. * The zone outline is a frontier, and can be complex (with holes)
  626. * The filling starts from starting points like pads, tracks.
  627. * If exists the old filling is removed
  628. * @param zone_container = zone to fill
  629. * @param verbose = true to show error messages
  630. * @return error level (0 = no error)
  631. */
  632. int Fill_Zone( ZONE_CONTAINER* zone_container, bool verbose = TRUE );
  633. /** Function Fill_All_Zones()
  634. * Fill all zones on the board
  635. * The old fillings are removed
  636. * @param verbose = true to show error messages
  637. * @return error level (0 = no error)
  638. */
  639. int Fill_All_Zones( bool verbose = TRUE );
  640. /**
  641. * Function Add_Zone_Cutout
  642. * Add a cutout zone to a given zone outline
  643. * @param DC = current Device Context
  644. * @param zone_container = parent zone outline
  645. */
  646. void Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container );
  647. /**
  648. * Function Add_Similar_Zone
  649. * Add a zone to a given zone outline.
  650. * if the zones are overlapping they will be merged
  651. * @param DC = current Device Context
  652. * @param zone_container = parent zone outline
  653. */
  654. void Add_Similar_Zone( wxDC* DC, ZONE_CONTAINER* zone_container );
  655. /**
  656. * Function Edit_Zone_Params
  657. * Edit params (layer, clearance, ...) for a zone outline
  658. */
  659. void Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container );
  660. /**
  661. * Function Start_Move_Zone_Corner
  662. * Prepares a move corner in a zone outline,
  663. * called from a move corner command (IsNewCorner = false),
  664. * or a create new cornet command (IsNewCorner = true )
  665. */
  666. void Start_Move_Zone_Corner( wxDC* DC,
  667. ZONE_CONTAINER* zone_container,
  668. int corner_id,
  669. bool IsNewCorner );
  670. /**
  671. * Function Start_Move_Zone_Corner
  672. * Prepares a drag edge in an existing zone outline,
  673. */
  674. void Start_Move_Zone_Drag_Outline_Edge(
  675. wxDC* DC,
  676. ZONE_CONTAINER*
  677. zone_container,
  678. int corner_id );
  679. /**
  680. * Function End_Move_Zone_Corner_Or_Outlines
  681. * Terminates a move corner in a zone outline, or a move zone outlines
  682. * @param DC = current Device Context (can be NULL)
  683. * @param zone_container: the given zone
  684. */
  685. void End_Move_Zone_Corner_Or_Outlines(
  686. wxDC* DC,
  687. ZONE_CONTAINER*
  688. zone_container );
  689. /**
  690. * Function End_Move_Zone_Corner_Or_Outlines
  691. * Remove the currently selected corner in a zone outline
  692. * the .m_CornerSelection is used as corner selection
  693. */
  694. void Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container );
  695. /** Function Delete_Zone
  696. * Remove the zone which include the segment aZone, or the zone which have
  697. * the given time stamp. A zone is a group of segments which have the
  698. * same TimeStamp
  699. * @param DC = current Device Context (can be NULL)
  700. * @param zone_container = zone to modify
  701. * the member .m_CornerSelection is used to find the outline to remove.
  702. * if the outline is the main outline, all the zone is removed
  703. * otherwise, the hole is deleted
  704. */
  705. void Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_container );
  706. /**
  707. * Function Start_Move_Zone_Outlines
  708. * Initialize parameters to move an existing zone outlines.
  709. * @param DC = current Device Context (can be NULL)
  710. * @param zone_container: the given zone to move
  711. */
  712. void Start_Move_Zone_Outlines( wxDC* DC,
  713. ZONE_CONTAINER* zone_container );
  714. // Target handling
  715. MIREPCB* Create_Mire( wxDC* DC );
  716. void Delete_Mire( MIREPCB* MirePcb, wxDC* DC );
  717. void StartMove_Mire( MIREPCB* MirePcb, wxDC* DC );
  718. void Place_Mire( MIREPCB* MirePcb, wxDC* DC );
  719. void InstallMireOptionsFrame( MIREPCB* MirePcb,
  720. wxDC* DC,
  721. const wxPoint& pos );
  722. // Graphic segments type DRAWSEGMENT handling:
  723. DRAWSEGMENT* Begin_DrawSegment( DRAWSEGMENT* Segment, int shape, wxDC* DC );
  724. void End_Edge( DRAWSEGMENT* Segment, wxDC* DC );
  725. void Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC );
  726. void Delete_Drawings_All_Layer( int aLayer );
  727. // Dimension handling:
  728. void Install_Edit_Cotation( COTATION* Cotation,
  729. wxDC* DC,
  730. const wxPoint& pos );
  731. COTATION* Begin_Cotation( COTATION* Cotation, wxDC* DC );
  732. void Delete_Cotation( COTATION* Cotation, wxDC* DC );
  733. // netlist handling:
  734. void InstallNetlistFrame( wxDC* DC, const wxPoint& pos );
  735. /** Function ReadPcbNetlist
  736. * Update footprints (load missing footprints and delete on request extra
  737. * footprints)
  738. * Update connectivity info ( Net Name list )
  739. * Update Reference, value and "TIME STAMP"
  740. * @param aNetlistFullFilename = netlist file name (*.net)
  741. * @param aCmpFullFileName = cmp/footprint list file name (*.cmp) if not found,
  742. * only the netlist will be used
  743. * @return true if Ok
  744. *
  745. * the format of the netlist is something like:
  746. # EESchema Netlist Version 1.0 generee le 18/5/2005-12:30:22
  747. * (
  748. * ( 40C08647 $noname R20 4,7K {Lib=R}
  749. * ( 1 VCC )
  750. * ( 2 MODB_1 )
  751. * )
  752. * ( 40C0863F $noname R18 4,7_k {Lib=R}
  753. * ( 1 VCC )
  754. * ( 2 MODA_1 )
  755. * )
  756. * }
  757. * #End
  758. */
  759. bool ReadPcbNetlist(
  760. const wxString& aNetlistFullFilename,
  761. const wxString& aCmpFullFileName,
  762. wxTextCtrl* aMessageWindow,
  763. bool aChangeFootprint,
  764. bool aDeleteBadTracks,
  765. bool aDeleteExtraFootprints,
  766. bool aSelect_By_Timestamp );
  767. /** Function RemoveMisConnectedTracks
  768. * finds all track segments which are mis-connected (to more than one net).
  769. * When such a bad segment is found, mark it as needing to be removed.
  770. * and remove all tracks having at least one flagged segment.
  771. * @param aDC = the current device context (can be NULL)
  772. * @param aDisplayActivity = true to display activity on the frame status bar and message panel
  773. * @return true if any change is made
  774. */
  775. bool RemoveMisConnectedTracks( wxDC* aDC, bool aDisplayActivity );
  776. // Autoplacement:
  777. void AutoPlace( wxCommandEvent& event );
  778. /** function OnOrientFootprints
  779. * install the dialog box for the common Orient Footprints
  780. */
  781. void OnOrientFootprints( void );
  782. /** function ReOrientModules
  783. * Set the orientation of footprints
  784. * @param ModuleMask = mask (wildcard allowed) selection
  785. * @param Orient = new orientation
  786. * @param include_fixe = true to orient locked footprints
  787. */
  788. void ReOrientModules( const wxString& ModuleMask, int Orient,
  789. bool include_fixe );
  790. void FixeModule( MODULE* Module, bool Fixe );
  791. void AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb );
  792. bool SetBoardBoundaryBoxFromEdgesOnly();
  793. void AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC );
  794. int RecherchePlacementModule( MODULE* Module, wxDC* DC );
  795. void GenModuleOnBoard( MODULE* Module );
  796. float Compute_Ratsnest_PlaceModule( wxDC* DC );
  797. int GenPlaceBoard();
  798. void DrawInfoPlace( wxDC* DC );
  799. // Autorouting:
  800. int Solve( wxDC* DC, int two_sides );
  801. void Reset_Noroutable( wxDC* DC );
  802. void Autoroute( wxDC* DC, int mode );
  803. void ReadAutoroutedTracks( wxDC* DC );
  804. void GlobalRoute( wxDC* DC );
  805. void Show_1_Ratsnest( EDA_BaseStruct* item, wxDC* DC );
  806. void Clean_Pcb( wxDC* DC );
  807. void InstallFindFrame( const wxPoint& pos, wxDC* DC );
  808. /**
  809. * Function SendMessageToEESCHEMA
  810. * sends a message to the schematic editor so that it may move its cursor
  811. * to a part with the same reference as the objectToSync
  812. * @param objectToSync The object whose reference is used to synchronize
  813. * eeschema.
  814. */
  815. void SendMessageToEESCHEMA( BOARD_ITEM* objectToSync );
  816. /* Micro waves functions */
  817. void Edit_Gap( wxDC* DC, MODULE* Module );
  818. MODULE* Create_MuWaveBasicShape( const wxString& name, int pad_count );
  819. MODULE* Create_MuWaveComponent( int shape_type );
  820. MODULE* Create_MuWavePolygonShape();
  821. void Begin_Self( wxDC* DC );
  822. MODULE* Genere_Self( wxDC* DC );
  823. /**
  824. * Load applications settings specific to the PCBNew.
  825. *
  826. * This overrides the base class WinEDA_BasePcbFrame::LoadSettings() to
  827. * handle settings specific common to the PCB layout application. It
  828. * calls down to the base class to load settings common to all PCB type
  829. * drawing frames. Please put your application settings for PCBNew here
  830. * to avoid having application settings loaded all over the place.
  831. */
  832. virtual void LoadSettings();
  833. /**
  834. * Save applications settings common to PCB draw frame objects.
  835. *
  836. * This overrides the base class WinEDA_BasePcbFrame::SaveSettings() to
  837. * save settings specific to the PCB layout application main window. It
  838. * calls down to the base class to save settings common to all PCB type
  839. * drawing frames. Please put your application settings for PCBNew here
  840. * to avoid having application settings saved all over the place.
  841. */
  842. virtual void SaveSettings();
  843. /** function SetLanguage
  844. * called on a language menu selection
  845. */
  846. virtual void SetLanguage( wxCommandEvent& event );
  847. DECLARE_EVENT_TABLE()
  848. };
  849. /*********************************************************/
  850. /* class WinEDA_ModuleEditFrame: public WinEDA_DrawFrame */
  851. /* Class for the footprint editor */
  852. /*********************************************************/
  853. class WinEDA_ModuleEditFrame : public WinEDA_BasePcbFrame
  854. {
  855. public:
  856. MODULE* CurrentModule;
  857. wxString m_CurrentLib;
  858. public:
  859. WinEDA_ModuleEditFrame( wxWindow* father,
  860. const wxString& title,
  861. const wxPoint& pos, const wxSize& size,
  862. long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
  863. ~WinEDA_ModuleEditFrame();
  864. void InstallOptionsFrame( const wxPoint& pos );
  865. void OnCloseWindow( wxCloseEvent& Event );
  866. void Process_Special_Functions( wxCommandEvent& event );
  867. void RedrawActiveWindow( wxDC* DC, bool EraseBg );
  868. void ReCreateHToolbar();
  869. void ReCreateVToolbar();
  870. void ReCreateOptToolbar();
  871. void ReCreateAuxiliaryToolbar();
  872. void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
  873. void OnLeftDClick( wxDC* DC, const wxPoint& MousePos );
  874. bool OnRightClick( const wxPoint& MousePos, wxMenu* PopMenu );
  875. void SetToolbars();
  876. void ReCreateMenuBar();
  877. void ToolOnRightClick( wxCommandEvent& event );
  878. void OnSelectOptionToolbar( wxCommandEvent& event );
  879. void OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct );
  880. void Show3D_Frame( wxCommandEvent& event );
  881. void GeneralControle( wxDC* DC, wxPoint Mouse );
  882. void LoadModuleFromBoard( wxCommandEvent& event );
  883. /** function ToPrinter
  884. * Install the print dialog
  885. */
  886. void ToPrinter( wxCommandEvent& event );
  887. /** Virtual function PrintPage
  888. * used to print a page
  889. * Print the page pointed by ActiveScreen, set by the calling print function
  890. * @param aDC = wxDC given by the calling print function
  891. * @param aPrint_Sheet_Ref = true to print page references
  892. * @param aPrintMask = not used here
  893. * @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
  894. * @param aData = a pointer on an auxiliary data (NULL if not used)
  895. */
  896. virtual void PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref,
  897. int aPrintMask, bool aPrintMirrorMode,
  898. void * aData = NULL);
  899. // BOARD handling
  900. /** function Clear_Pcb()
  901. * delete all and reinitialize the current board
  902. * @param aQuery = true to prompt user for confirmation, false to
  903. * initialize silently
  904. */
  905. bool Clear_Pcb( bool aQuery );
  906. /* handlers for block commands */
  907. int ReturnBlockCommand( int key );
  908. virtual void HandleBlockPlace( wxDC* DC );
  909. virtual int HandleBlockEnd( wxDC* DC );
  910. BOARD_ITEM* ModeditLocateAndDisplay( int aHotKeyCode = 0 );
  911. /* Undo and redo functions */
  912. public:
  913. /** Function SaveCopyInUndoList.
  914. * Creates a new entry in undo list of commands.
  915. * add a picker to handle aItemToCopy
  916. * @param aItem = the board item modified by the command to undo
  917. * @param aTypeCommand = command type (see enum UndoRedoOpType)
  918. * @param aTransformPoint = the reference point of the transformation, for
  919. * commands like move
  920. */
  921. virtual void SaveCopyInUndoList( BOARD_ITEM* aItem,
  922. UndoRedoOpType aTypeCommand,
  923. const wxPoint& aTransformPoint =
  924. wxPoint( 0, 0 ) );
  925. /** Function SaveCopyInUndoList (overloaded).
  926. * Creates a new entry in undo list of commands.
  927. * add a list of pickers to handle a list of items
  928. * @param aItemsList = the list of items modified by the command to undo
  929. * @param aTypeCommand = command type (see enum UndoRedoOpType)
  930. * @param aTransformPoint = the reference point of the transformation, for
  931. * commands like move
  932. */
  933. virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
  934. UndoRedoOpType aTypeCommand,
  935. const wxPoint& aTransformPoint =
  936. wxPoint( 0, 0 ) );
  937. private:
  938. void GetComponentFromUndoList( wxCommandEvent& event );
  939. void GetComponentFromRedoList( wxCommandEvent& event );
  940. public:
  941. // Footprint edition
  942. void Place_Ancre( MODULE* module );
  943. void RemoveStruct( EDA_BaseStruct* Item );
  944. void Transform( MODULE* module, int transform );
  945. // loading Footprint
  946. MODULE* Import_Module( wxDC* DC );
  947. void Export_Module( MODULE* ptmod, bool createlib );
  948. void Load_Module_From_BOARD( MODULE* Module );
  949. // functions to edit footprint edges
  950. /**
  951. * Function Edit_Edge_Width
  952. * changes the width of module perimeter lines, EDGE_MODULEs.
  953. * @param ModuleSegmentWidth (global) = new width
  954. * @param Edge = edge to edit, or NULL. If Edge == NULL change
  955. * the width of all the footprint's edges
  956. * @param DC = current Device Context
  957. */
  958. void Edit_Edge_Width( EDGE_MODULE* Edge );
  959. void Edit_Edge_Layer( EDGE_MODULE* Edge );
  960. void Delete_Edge_Module( EDGE_MODULE* Edge );
  961. EDGE_MODULE* Begin_Edge_Module( EDGE_MODULE* Edge, wxDC* DC, int type_edge );
  962. void End_Edge_Module( EDGE_MODULE* Edge, wxDC* DC );
  963. void Enter_Edge_Width( EDGE_MODULE* Edge, wxDC* DC );
  964. void Start_Move_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC );
  965. void Place_EdgeMod( EDGE_MODULE* drawitem, wxDC* DC );
  966. // handlers for libraries:
  967. void Delete_Module_In_Library( const wxString& libname );
  968. int Create_Librairie( const wxString& LibName );
  969. void Select_Active_Library();
  970. DECLARE_EVENT_TABLE()
  971. };
  972. #endif /* WXPCB_STRUCT_H */