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.

1155 lines
43 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_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 PCB_BASE_FRAME(): Basic class for pcbnew and gerbview.
  38. */
  39. /*****************************************************/
  40. /* class PCB_EDIT_FRAME: the main frame for Pcbnew */
  41. /*****************************************************/
  42. class PCB_EDIT_FRAME : public PCB_BASE_FRAME
  43. {
  44. friend class PCB_LAYER_WIDGET;
  45. void updateTraceWidthSelectBox();
  46. void updateViaSizeSelectBox();
  47. void updateDesignRulesSelectBoxes();
  48. protected:
  49. PCB_LAYER_WIDGET* m_Layers;
  50. DRC* m_drc; ///< the DRC controller, see drc.cpp
  51. PARAM_CFG_ARRAY m_projectFileParams; ///< List of PCBNew project file settings.
  52. PARAM_CFG_ARRAY m_configSettings; ///< List of PCBNew configuration settings.
  53. wxString m_lastNetListRead; ///< Last net list read with relative path.
  54. // we'll use lower case function names for private member functions.
  55. void createPopUpMenuForZones( ZONE_CONTAINER* edge_zone, wxMenu* aPopMenu );
  56. void createPopUpMenuForFootprints( MODULE* aModule, wxMenu* aPopMenu );
  57. void createPopUpMenuForFpTexts( TEXTE_MODULE* aText, wxMenu* aPopMenu );
  58. void createPopUpMenuForFpPads( D_PAD* aPad, wxMenu* aPopMenu );
  59. void createPopupMenuForTracks( TRACK* aTrack, wxMenu* aPopMenu );
  60. void createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu );
  61. void createPopUpBlockMenu( wxMenu* menu );
  62. void createPopUpMenuForMarkers( MARKER_PCB* aMarker, wxMenu* aPopMenu );
  63. /**
  64. * Function setActiveLayer
  65. * will change the currently active layer to \a aLayer and also
  66. * update the PCB_LAYER_WIDGET.
  67. */
  68. void setActiveLayer( int aLayer, bool doLayerWidgetUpdate = true )
  69. {
  70. ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer = aLayer;
  71. if( doLayerWidgetUpdate )
  72. syncLayerWidget();
  73. }
  74. /**
  75. * Function getActiveLayer
  76. * returns the active layer
  77. */
  78. int getActiveLayer()
  79. {
  80. return ( (PCB_SCREEN*) GetScreen() )->m_Active_Layer;
  81. }
  82. /**
  83. * Function syncLayerWidget
  84. * updates the currently "selected" layer within the PCB_LAYER_WIDGET.
  85. * The currently active layer is defined by the return value of getActiveLayer().
  86. * <p>
  87. * This function cannot be inline without including layer_widget.h in
  88. * here and we do not want to do that.
  89. * </p>
  90. */
  91. void syncLayerWidget( );
  92. virtual void unitsChangeRefresh();
  93. public:
  94. WinEDALayerChoiceBox* m_SelLayerBox; // a combo box to display and
  95. // select active layer
  96. WinEDAChoiceBox* m_SelTrackWidthBox; // a combo box to display and
  97. // select current track width
  98. WinEDAChoiceBox* m_SelViaSizeBox; // a combo box to display and
  99. // select current via diameter
  100. wxTextCtrl* m_ClearanceBox; // a text ctrl to display the
  101. // current tracks and vias
  102. // clearance
  103. wxTextCtrl* m_NetClassSelectedBox; // a text ctrl to display the
  104. // current NetClass
  105. bool m_TrackAndViasSizesList_Changed;
  106. bool m_show_microwave_tools;
  107. bool m_show_layer_manager_tools;
  108. public:
  109. PCB_EDIT_FRAME( wxWindow* father, const wxString& title,
  110. const wxPoint& pos, const wxSize& size,
  111. long style = KICAD_DEFAULT_DRAWFRAME_STYLE );
  112. ~PCB_EDIT_FRAME();
  113. void OnQuit( wxCommandEvent& event );
  114. /**
  115. * Function ToPlotter
  116. * Open a dialog frame to create plot and drill files
  117. * relative to the current board
  118. */
  119. void ToPlotter( wxCommandEvent& event );
  120. /**
  121. * Function ToPrinter
  122. * Install the print dialog
  123. */
  124. void ToPrinter( wxCommandEvent& event );
  125. void SVG_Print( wxCommandEvent& event );
  126. // User interface update command event handlers.
  127. void OnUpdateSave( wxUpdateUIEvent& aEvent );
  128. void OnUpdateLayerPair( wxUpdateUIEvent& aEvent );
  129. void OnUpdateLayerSelectBox( wxUpdateUIEvent& aEvent );
  130. void OnUpdateDrcEnable( wxUpdateUIEvent& aEvent );
  131. void OnUpdateShowBoardRatsnest( wxUpdateUIEvent& aEvent );
  132. void OnUpdateShowModuleRatsnest( wxUpdateUIEvent& aEvent );
  133. void OnUpdateAutoDeleteTrack( wxUpdateUIEvent& aEvent );
  134. void OnUpdateViaDrawMode( wxUpdateUIEvent& aEvent );
  135. void OnUpdateTraceDrawMode( wxUpdateUIEvent& aEvent );
  136. void OnUpdateHighContrastDisplayMode( wxUpdateUIEvent& aEvent );
  137. void OnUpdateShowLayerManager( wxUpdateUIEvent& aEvent );
  138. void OnUpdateVerticalToolbar( wxUpdateUIEvent& aEvent );
  139. void OnUpdateSelectViaSize( wxUpdateUIEvent& aEvent );
  140. void OnUpdateZoneDisplayStyle( wxUpdateUIEvent& aEvent );
  141. void OnUpdateSelectTrackWidth( wxUpdateUIEvent& aEvent );
  142. void OnUpdateSelectAutoTrackWidth( wxUpdateUIEvent& aEvent );
  143. /**
  144. * Function PrintPage , virtual
  145. * used to print a page
  146. * Print the page pointed by the current screen, set by the calling print function
  147. * @param aDC = wxDC given by the calling print function
  148. * @param aPrintMaskLayer = a 32 bits mask: bit n = 1 -> layer n is printed
  149. * @param aPrintMirrorMode = true to plot mirrored
  150. * @param aData = a pointer on an auxiliary data (NULL if not used)
  151. */
  152. virtual void PrintPage( wxDC* aDC,
  153. int aPrintMaskLayer, bool aPrintMirrorMode,
  154. void * aData = NULL );
  155. void GetKicadAbout( wxCommandEvent& event );
  156. /**
  157. * Function IsGridVisible() , virtual
  158. * @return true if the grid must be shown
  159. */
  160. virtual bool IsGridVisible();
  161. /**
  162. * Function SetGridVisibility() , virtual
  163. * It may be overloaded by derived classes
  164. * if you want to store/retrieve the grid visibility in configuration.
  165. * @param aVisible = true if the grid must be shown
  166. */
  167. virtual void SetGridVisibility( bool aVisible );
  168. /**
  169. * Function GetGridColor() , virtual
  170. * @return the color of the grid
  171. */
  172. virtual int GetGridColor();
  173. /**
  174. * Function SetGridColor() , virtual
  175. * @param aColor = the new color of the grid
  176. */
  177. virtual void SetGridColor(int aColor);
  178. // Configurations:
  179. void InstallConfigFrame( const wxPoint& pos );
  180. void Process_Config( wxCommandEvent& event );
  181. PARAM_CFG_ARRAY& GetProjectFileParameters();
  182. void SaveProjectSettings();
  183. /**
  184. * Load the project file configuration settings.
  185. *
  186. * @param aProjectFileName = The project filename.
  187. * if not found use kicad.pro and initialize default values
  188. * @return always returns true.
  189. */
  190. bool LoadProjectSettings( const wxString& aProjectFileName );
  191. /**
  192. * Get the list of application specific settings.
  193. *
  194. * @return - Reference to the list of applications settings.
  195. */
  196. PARAM_CFG_ARRAY& GetConfigurationSettings();
  197. /**
  198. * Load applications settings specific to PCBNew.
  199. *
  200. * This overrides the base class PCB_BASE_FRAME::LoadSettings() to
  201. * handle settings specific common to the PCB layout application. It
  202. * calls down to the base class to load settings common to all PCB type
  203. * drawing frames. Please put your application settings for PCBNew here
  204. * to avoid having application settings loaded all over the place.
  205. */
  206. virtual void LoadSettings();
  207. /**
  208. * Save applications settings common to PCBNew.
  209. *
  210. * This overrides the base class PCB_BASE_FRAME::SaveSettings() to
  211. * save settings specific to the PCB layout application main window. It
  212. * calls down to the base class to save settings common to all PCB type
  213. * drawing frames. Please put your application settings for PCBNew here
  214. * to avoid having application settings saved all over the place.
  215. */
  216. virtual void SaveSettings();
  217. /**
  218. * Get the last net list read with the net list dialog box.
  219. *
  220. * @return - Absolute path and file name of the last net list file successfully read.
  221. */
  222. wxString GetLastNetListRead();
  223. /**
  224. * Set the last net list successfully read by the net list dialog box.
  225. *
  226. * Note: the file path is converted to a path relative to the project file path. If
  227. * the path cannot be made relative, than m_lastNetListRead is set to and empty
  228. * string. This could happen when the net list file is on a different drive than
  229. * the project file. The advantage of relative paths is that is more likely to
  230. * work when opening the same project from both Windows and Linux.
  231. *
  232. * @param aNetListFile - The last net list file with full path successfully read.
  233. */
  234. void SetLastNetListRead( const wxString& aNetListFile );
  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. WinEDALayerChoiceBox* ReCreateLayerBox( WinEDA_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 UndoRedoOpType)
  354. * @param aTransformPoint = the reference point of the transformation, for
  355. * commands like move
  356. */
  357. virtual void SaveCopyInUndoList( BOARD_ITEM* aItemToCopy,
  358. UndoRedoOpType 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 UndoRedoOpType)
  366. * @param aTransformPoint = the reference point of the transformation, for
  367. * commands like move
  368. */
  369. virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList,
  370. UndoRedoOpType 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. TRACK* Begin_Route( TRACK* track, wxDC* DC );
  705. void End_Route( TRACK* track, wxDC* DC );
  706. void ExChange_Track_Layer( TRACK* pt_segm, wxDC* DC );
  707. void Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On );
  708. void Attribut_Track( TRACK* track, wxDC* DC, bool Flag_On );
  709. void Attribut_net( wxDC* DC, int net_code, bool Flag_On );
  710. void Start_MoveOneNodeOrSegment( TRACK* track, wxDC* DC, int command );
  711. bool PlaceDraggedOrMovedTrackSegment( TRACK* Track, wxDC* DC );
  712. bool MergeCollinearTracks( TRACK* track, wxDC* DC, int end );
  713. void Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC );
  714. void SwitchLayer( wxDC* DC, int layer );
  715. bool Add_45_degrees_Segment( wxDC* DC );
  716. bool Genere_Pad_Connexion( wxDC* DC, int layer );
  717. /**
  718. * Function EraseRedundantTrack
  719. * Called after creating a track
  720. * Remove (if exists) the old track that have the same starting and the
  721. * same ending point as the new created track
  722. * (this is the redunding track)
  723. * @param aDC = the current device context (can be NULL)
  724. * @param aNewTrack = the new created track (a pointer to a segment of the
  725. * track list)
  726. * @param aNewTrackSegmentsCount = number of segments in this new track
  727. * @param aItemsListPicker = the list picker to use for an undo command
  728. * (can be NULL)
  729. */
  730. int EraseRedundantTrack( wxDC* aDC,
  731. TRACK* aNewTrack,
  732. int aNewTrackSegmentsCount,
  733. PICKED_ITEMS_LIST* aItemsListPicker );
  734. /**
  735. * Function SetTrackSegmentWidth
  736. * Modify one track segment width or one via diameter (using DRC control).
  737. * Basic routine used by other routines when editing tracks or vias
  738. * @param aTrackItem = the track segment or via to modify
  739. * @param aItemsListPicker = the list picker to use for an undo command
  740. * (can be NULL)
  741. * @param aUseNetclassValue = true to use NetClass value, false to use
  742. * current designSettings value
  743. * @return true if done, false if no not change (because DRC error)
  744. */
  745. bool SetTrackSegmentWidth( TRACK* aTrackItem,
  746. PICKED_ITEMS_LIST* aItemsListPicker,
  747. bool aUseNetclassValue );
  748. // zone handling
  749. /**
  750. * Function Delete_Zone_Fill (obsolete)
  751. * Remove the zone filling which include the segment aZone, or the zone
  752. * which have the given time stamp. A zone is a group of segments which
  753. * have the same TimeStamp
  754. * @param aZone = zone segment within the zone to delete. Can be NULL
  755. * @param aTimestamp = Timestamp for the zone to delete, used if aZone ==
  756. * NULL
  757. */
  758. void Delete_Zone_Fill( SEGZONE* aZone, long aTimestamp = 0 );
  759. /**
  760. * Function Delete_LastCreatedCorner
  761. * Used only while creating a new zone outline
  762. * Remove and delete the current outline segment in progress
  763. * @return 0 if no corner in list, or corner number
  764. */
  765. int Delete_LastCreatedCorner( wxDC* DC );
  766. /**
  767. * Function Begin_Zone
  768. * initiates a zone edge creation process,
  769. * or terminates the current zone edge and creates a new zone edge stub
  770. */
  771. int Begin_Zone( wxDC* DC );
  772. /**
  773. * Function End_Zone
  774. * terminates (if no DRC error ) the zone edge creation process
  775. * @param DC = current Device Context
  776. * @return true if Ok, false if DRC error
  777. */
  778. bool End_Zone( wxDC* DC );
  779. /**
  780. * Function Fill_Zone
  781. * Calculate the zone filling for the outline zone_container
  782. * The zone outline is a frontier, and can be complex (with holes)
  783. * The filling starts from starting points like pads, tracks.
  784. * If exists the old filling is removed
  785. * @param zone_container = zone to fill
  786. * @param verbose = true to show error messages
  787. * @return error level (0 = no error)
  788. */
  789. int Fill_Zone( ZONE_CONTAINER* zone_container, bool verbose = TRUE );
  790. /**
  791. * Function Fill_All_Zones
  792. * Fill all zones on the board
  793. * The old fillings are removed
  794. * @param verbose = true to show error messages
  795. * @return error level (0 = no error)
  796. */
  797. int Fill_All_Zones( bool verbose = TRUE );
  798. /**
  799. * Function Add_Zone_Cutout
  800. * Add a cutout zone to a given zone outline
  801. * @param DC = current Device Context
  802. * @param zone_container = parent zone outline
  803. */
  804. void Add_Zone_Cutout( wxDC* DC, ZONE_CONTAINER* zone_container );
  805. /**
  806. * Function Add_Similar_Zone
  807. * Add a zone to a given zone outline.
  808. * if the zones are overlapping they will be merged
  809. * @param DC = current Device Context
  810. * @param zone_container = parent zone outline
  811. */
  812. void Add_Similar_Zone( wxDC* DC, ZONE_CONTAINER* zone_container );
  813. /**
  814. * Function Edit_Zone_Params
  815. * Edit params (layer, clearance, ...) for a zone outline
  816. */
  817. void Edit_Zone_Params( wxDC* DC, ZONE_CONTAINER* zone_container );
  818. /**
  819. * Function Start_Move_Zone_Corner
  820. * Prepares a move corner in a zone outline,
  821. * called from a move corner command (IsNewCorner = false),
  822. * or a create new cornet command (IsNewCorner = true )
  823. */
  824. void Start_Move_Zone_Corner( wxDC* DC,
  825. ZONE_CONTAINER* zone_container,
  826. int corner_id,
  827. bool IsNewCorner );
  828. /**
  829. * Function Start_Move_Zone_Corner
  830. * Prepares a drag edge in an existing zone outline,
  831. */
  832. void Start_Move_Zone_Drag_Outline_Edge( wxDC* DC,
  833. ZONE_CONTAINER* zone_container,
  834. int corner_id );
  835. /**
  836. * Function End_Move_Zone_Corner_Or_Outlines
  837. * Terminates a move corner in a zone outline, or a move zone outlines
  838. * @param DC = current Device Context (can be NULL)
  839. * @param zone_container: the given zone
  840. */
  841. void End_Move_Zone_Corner_Or_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container );
  842. /**
  843. * Function End_Move_Zone_Corner_Or_Outlines
  844. * Remove the currently selected corner in a zone outline
  845. * the .m_CornerSelection is used as corner selection
  846. */
  847. void Remove_Zone_Corner( wxDC* DC, ZONE_CONTAINER* zone_container );
  848. /**
  849. * Function Delete_Zone
  850. * Remove the zone which include the segment aZone, or the zone which have
  851. * the given time stamp. A zone is a group of segments which have the
  852. * same TimeStamp
  853. * @param DC = current Device Context (can be NULL)
  854. * @param zone_container = zone to modify
  855. * the member .m_CornerSelection is used to find the outline to remove.
  856. * if the outline is the main outline, all the zone is removed
  857. * otherwise, the hole is deleted
  858. */
  859. void Delete_Zone_Contour( wxDC* DC, ZONE_CONTAINER* zone_container );
  860. /**
  861. * Function Start_Move_Zone_Outlines
  862. * Initialize parameters to move an existing zone outlines.
  863. * @param DC = current Device Context (can be NULL)
  864. * @param zone_container: the given zone to move
  865. */
  866. void Start_Move_Zone_Outlines( wxDC* DC, ZONE_CONTAINER* zone_container );
  867. // Target handling
  868. MIREPCB* Create_Mire( wxDC* DC );
  869. void Delete_Mire( MIREPCB* MirePcb, wxDC* DC );
  870. void StartMove_Mire( MIREPCB* MirePcb, wxDC* DC );
  871. void Place_Mire( MIREPCB* MirePcb, wxDC* DC );
  872. void InstallMireOptionsFrame( MIREPCB* MirePcb, wxDC* DC );
  873. // Graphic segments type DRAWSEGMENT handling:
  874. DRAWSEGMENT* Begin_DrawSegment( DRAWSEGMENT* Segment, int shape, wxDC* DC );
  875. void End_Edge( DRAWSEGMENT* Segment, wxDC* DC );
  876. void Delete_Segment_Edge( DRAWSEGMENT* Segment, wxDC* DC );
  877. void Delete_Drawings_All_Layer( int aLayer );
  878. // Dimension handling:
  879. void Install_Edit_Dimension( DIMENSION* Dimension, wxDC* DC );
  880. DIMENSION* Begin_Dimension( DIMENSION* Dimension, wxDC* DC );
  881. void Delete_Dimension( DIMENSION* Dimension, wxDC* DC );
  882. // netlist handling:
  883. void InstallNetlistFrame( wxDC* DC, const wxPoint& pos );
  884. /**
  885. * Function ReadPcbNetlist
  886. * Update footprints (load missing footprints and delete on request extra
  887. * footprints)
  888. * Update connectivity info ( Net Name list )
  889. * Update Reference, value and "TIME STAMP"
  890. * @param aNetlistFullFilename = netlist file name (*.net)
  891. * @param aCmpFullFileName = cmp/footprint list file name (*.cmp) if not found,
  892. * only the netlist will be used
  893. * @param aMessageWindow = a reference to a wxTextCtrl where to display messages.
  894. * can be NULL
  895. * @param aChangeFootprint if true, footprints that have changed in netlist will be changed
  896. * @param aDeleteBadTracks if true, erroneous tracks will be deleted
  897. * @param aDeleteExtraFootprints if true, remove unlocked footprints that are not in netlist
  898. * @param aSelect_By_Timestamp if true, use timestamp instead of reference to identify
  899. * footprints from components (use after reannotation of the
  900. * schematic)
  901. * @return true if Ok
  902. *
  903. * the format of the netlist is something like:
  904. # EESchema Netlist Version 1.0 generee le 18/5/2005-12:30:22
  905. * (
  906. * ( 40C08647 $noname R20 4,7K {Lib=R}
  907. * ( 1 VCC )
  908. * ( 2 MODB_1 )
  909. * )
  910. * ( 40C0863F $noname R18 4,7_k {Lib=R}
  911. * ( 1 VCC )
  912. * ( 2 MODA_1 )
  913. * )
  914. * }
  915. * #End
  916. */
  917. bool ReadPcbNetlist( const wxString& aNetlistFullFilename,
  918. const wxString& aCmpFullFileName,
  919. wxTextCtrl* aMessageWindow,
  920. bool aChangeFootprint,
  921. bool aDeleteBadTracks,
  922. bool aDeleteExtraFootprints,
  923. bool aSelect_By_Timestamp );
  924. /**
  925. * Function RemoveMisConnectedTracks
  926. * finds all track segments which are mis-connected (to more than one net).
  927. * When such a bad segment is found, mark it as needing to be removed.
  928. * and remove all tracks having at least one flagged segment.
  929. * @param aDC = the current device context (can be NULL)
  930. * @return true if any change is made
  931. */
  932. bool RemoveMisConnectedTracks( wxDC* aDC );
  933. // Autoplacement:
  934. void AutoPlace( wxCommandEvent& event );
  935. /**
  936. * Function OnOrientFootprints
  937. * install the dialog box for the common Orient Footprints
  938. */
  939. void OnOrientFootprints( wxCommandEvent& event );
  940. /**
  941. * Function ReOrientModules
  942. * Set the orientation of footprints
  943. * @param ModuleMask = mask (wildcard allowed) selection
  944. * @param Orient = new orientation
  945. * @param include_fixe = true to orient locked footprints
  946. * @return true if some footprints modified, false if no change
  947. */
  948. bool ReOrientModules( const wxString& ModuleMask, int Orient,
  949. bool include_fixe );
  950. void FixeModule( MODULE* Module, bool Fixe );
  951. void AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb );
  952. void AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC );
  953. int RecherchePlacementModule( MODULE* Module, wxDC* DC );
  954. void GenModuleOnBoard( MODULE* Module );
  955. float Compute_Ratsnest_PlaceModule( wxDC* DC );
  956. int GenPlaceBoard();
  957. void DrawInfoPlace( wxDC* DC );
  958. // Autorouting:
  959. int Solve( wxDC* DC, int two_sides );
  960. void Reset_Noroutable( wxDC* DC );
  961. void Autoroute( wxDC* DC, int mode );
  962. void ReadAutoroutedTracks( wxDC* DC );
  963. void GlobalRoute( wxDC* DC );
  964. void Show_1_Ratsnest( EDA_ITEM* item, wxDC* DC );
  965. void Clean_Pcb( wxDC* DC );
  966. void InstallFindFrame( const wxPoint& pos, wxDC* DC );
  967. /**
  968. * Function SendMessageToEESCHEMA
  969. * sends a message to the schematic editor so that it may move its cursor
  970. * to a part with the same reference as the objectToSync
  971. * @param objectToSync The object whose reference is used to synchronize
  972. * eeschema.
  973. */
  974. void SendMessageToEESCHEMA( BOARD_ITEM* objectToSync );
  975. /* Micro waves functions */
  976. void Edit_Gap( wxDC* DC, MODULE* Module );
  977. MODULE* Create_MuWaveBasicShape( const wxString& name, int pad_count );
  978. MODULE* Create_MuWaveComponent( int shape_type );
  979. MODULE* Create_MuWavePolygonShape();
  980. void Begin_Self( wxDC* DC );
  981. MODULE* Genere_Self( wxDC* DC );
  982. /**
  983. * Function SetLanguage
  984. * called on a language menu selection
  985. */
  986. virtual void SetLanguage( wxCommandEvent& event );
  987. DECLARE_EVENT_TABLE()
  988. };
  989. #endif /* WXPCB_STRUCT_H */