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.

1165 lines
44 KiB

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