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.

1159 lines
43 KiB

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