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.

678 lines
22 KiB

18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
  1. /******************************************************************/
  2. /* schframe.cpp - fonctions des classes du type WinEDA_DrawFrame */
  3. /******************************************************************/
  4. #ifdef __GNUG__
  5. #pragma implementation
  6. #endif
  7. #include "fctsys.h"
  8. #include "appl_wxstruct.h"
  9. #include "common.h"
  10. #include "class_drawpanel.h"
  11. #include "gestfich.h"
  12. #include "program.h"
  13. #include "libcmp.h"
  14. #include "general.h"
  15. #include "bitmaps.h"
  16. #include "protos.h"
  17. #include "id.h"
  18. #include "netlist.h"
  19. #include "annotate_dialog.h"
  20. #include "dialog_build_BOM.h"
  21. #include "dialog_erc.h"
  22. #include "dialog_find.h"
  23. #include "netlist_control.h"
  24. /*******************************/
  25. /* class WinEDA_SchematicFrame */
  26. /*******************************/
  27. BEGIN_EVENT_TABLE( WinEDA_SchematicFrame, WinEDA_DrawFrame )
  28. EVT_SOCKET( ID_EDA_SOCKET_EVENT_SERV,
  29. WinEDA_DrawFrame::OnSockRequestServer )
  30. EVT_SOCKET( ID_EDA_SOCKET_EVENT, WinEDA_DrawFrame::OnSockRequest )
  31. EVT_CLOSE( WinEDA_SchematicFrame::OnCloseWindow )
  32. EVT_SIZE( WinEDA_SchematicFrame::OnSize )
  33. EVT_MENU( ID_NEW_PROJECT, WinEDA_SchematicFrame::OnNewProject )
  34. EVT_MENU( ID_LOAD_PROJECT, WinEDA_SchematicFrame::OnLoadProject )
  35. EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, WinEDA_SchematicFrame::OnLoadFile )
  36. EVT_TOOL( ID_NEW_PROJECT, WinEDA_SchematicFrame::OnNewProject )
  37. EVT_TOOL( ID_LOAD_PROJECT, WinEDA_SchematicFrame::OnLoadProject )
  38. EVT_TOOL_RANGE( ID_SCHEMATIC_MAIN_TOOLBAR_START,
  39. ID_SCHEMATIC_MAIN_TOOLBAR_END,
  40. WinEDA_SchematicFrame::Process_Special_Functions )
  41. EVT_MENU_RANGE( ID_PREFERENCES_FONT_INFOSCREEN, ID_PREFERENCES_FONT_END,
  42. WinEDA_DrawFrame::ProcessFontPreferences )
  43. EVT_MENU( ID_SAVE_PROJECT, WinEDA_SchematicFrame::Save_File )
  44. EVT_MENU( ID_SAVE_ONE_SHEET, WinEDA_SchematicFrame::Save_File )
  45. EVT_MENU( ID_SAVE_ONE_SHEET_AS, WinEDA_SchematicFrame::Save_File )
  46. EVT_TOOL( ID_SAVE_PROJECT, WinEDA_SchematicFrame::Save_File )
  47. EVT_MENU( ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter )
  48. EVT_MENU( ID_GEN_PLOT_PS, WinEDA_SchematicFrame::ToPlot_PS )
  49. EVT_MENU( ID_GEN_PLOT_HPGL, WinEDA_SchematicFrame::ToPlot_HPGL )
  50. EVT_MENU( ID_GEN_PLOT_SVG, WinEDA_DrawFrame::SVG_Print )
  51. EVT_MENU( ID_GEN_COPY_SHEET_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard )
  52. EVT_MENU( ID_GEN_COPY_BLOCK_TO_CLIPBOARD, WinEDA_DrawFrame::CopyToClipboard )
  53. EVT_MENU( ID_EXIT, WinEDA_SchematicFrame::OnExit )
  54. EVT_MENU_RANGE( ID_CONFIG_AND_PREFERENCES_START,
  55. ID_CONFIG_AND_PREFERENCES_END,
  56. WinEDA_SchematicFrame::Process_Config )
  57. EVT_TOOL( ID_COLORS_SETUP, WinEDA_SchematicFrame::Process_Config )
  58. EVT_TOOL( ID_OPTIONS_SETUP, WinEDA_SchematicFrame::Process_Config )
  59. EVT_MENU_RANGE( ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END,
  60. WinEDA_DrawFrame::SetLanguage )
  61. EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_SchematicFrame::OnZoom )
  62. EVT_TOOL( ID_TO_LIBRARY, WinEDA_SchematicFrame::OnOpenLibraryEditor )
  63. EVT_TOOL( ID_TO_LIBVIEW, WinEDA_SchematicFrame::OnOpenLibraryViewer )
  64. EVT_TOOL( ID_TO_PCB, WinEDA_SchematicFrame::OnOpenPcbnew )
  65. EVT_TOOL( ID_TO_CVPCB, WinEDA_SchematicFrame::OnOpenCvpcb )
  66. EVT_TOOL( ID_SHEET_SET, WinEDA_DrawFrame::Process_PageSettings )
  67. EVT_TOOL( ID_HIERARCHY, WinEDA_SchematicFrame::Process_Special_Functions )
  68. EVT_TOOL( wxID_CUT, WinEDA_SchematicFrame::Process_Special_Functions )
  69. EVT_TOOL( wxID_COPY, WinEDA_SchematicFrame::Process_Special_Functions )
  70. EVT_TOOL( wxID_PASTE, WinEDA_SchematicFrame::Process_Special_Functions )
  71. EVT_TOOL( ID_UNDO_BUTT, WinEDA_SchematicFrame::Process_Special_Functions )
  72. EVT_TOOL( ID_GET_ANNOTATE, WinEDA_SchematicFrame::OnAnnotate )
  73. EVT_TOOL( ID_GEN_PRINT, WinEDA_SchematicFrame::ToPrinter )
  74. EVT_TOOL( ID_GET_ERC, WinEDA_SchematicFrame::OnErc )
  75. EVT_TOOL( ID_GET_NETLIST, WinEDA_SchematicFrame::OnCreateNetlist )
  76. EVT_TOOL( ID_GET_TOOLS, WinEDA_SchematicFrame::OnCreateBillOfMaterials )
  77. EVT_TOOL( ID_FIND_ITEMS, WinEDA_SchematicFrame::OnFindItems )
  78. EVT_TOOL( ID_BACKANNO_ITEMS, WinEDA_SchematicFrame::OnLoadStuffFile )
  79. EVT_MENU( ID_GENERAL_HELP, WinEDA_DrawFrame::GetKicadHelp )
  80. EVT_MENU( ID_KICAD_ABOUT, WinEDA_DrawFrame::GetKicadAbout )
  81. // Tools et boutons de Schematique, Vertical toolbar:
  82. EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START,
  83. ID_SCHEMATIC_VERTICAL_TOOLBAR_END,
  84. WinEDA_SchematicFrame::Process_Special_Functions )
  85. EVT_TOOL_RCLICKED( ID_LABEL_BUTT, WinEDA_SchematicFrame::ToolOnRightClick )
  86. EVT_TOOL_RCLICKED( ID_GLABEL_BUTT, WinEDA_SchematicFrame::ToolOnRightClick )
  87. EVT_TOOL_RCLICKED( ID_HIERLABEL_BUTT,
  88. WinEDA_SchematicFrame::ToolOnRightClick )
  89. EVT_MENU_RANGE( ID_POPUP_START_RANGE, ID_POPUP_END_RANGE,
  90. WinEDA_SchematicFrame::Process_Special_Functions )
  91. // Tools et boutons de Schematique, Options toolbar:
  92. EVT_TOOL_RANGE( ID_TB_OPTIONS_START, ID_TB_OPTIONS_END,
  93. WinEDA_SchematicFrame::OnSelectOptionToolbar )
  94. EVT_MENU_RANGE( ID_POPUP_GENERAL_START_RANGE, ID_POPUP_GENERAL_END_RANGE,
  95. WinEDA_SchematicFrame::Process_Special_Functions )
  96. END_EVENT_TABLE()
  97. /****************/
  98. /* Constructor */
  99. /****************/
  100. WinEDA_SchematicFrame::WinEDA_SchematicFrame( wxWindow* father,
  101. const wxString& title,
  102. const wxPoint& pos,
  103. const wxSize& size,
  104. long style ) :
  105. WinEDA_DrawFrame( father, SCHEMATIC_FRAME, title, pos, size, style )
  106. {
  107. wxConfig* config = wxGetApp().m_EDA_Config;
  108. m_FrameName = wxT( "SchematicFrame" );
  109. m_Draw_Axis = FALSE; // TRUE to show axis
  110. m_Draw_Grid = g_ShowGrid; // TRUE to show a grid
  111. m_Draw_Sheet_Ref = TRUE; // TRUE to show sheet references
  112. m_CurrentSheet = new DrawSheetPath();
  113. m_CurrentField = NULL;
  114. m_Multiflag = 0;
  115. m_TextFieldSize = DEFAULT_SIZE_TEXT;
  116. m_LibeditFrame = NULL; // Component editor frame.
  117. m_ViewlibFrame = NULL; // Frame for browsing component libraries
  118. CreateScreens();
  119. // Give an icon
  120. #ifdef __WINDOWS__
  121. SetIcon( wxICON( a_icon_eeschema ) );
  122. #else
  123. SetIcon( wxICON( icon_eeschema ) );
  124. #endif
  125. g_ItemToRepeat = NULL;
  126. /* Get config */
  127. GetSettings();
  128. if( config )
  129. {
  130. g_DrawMinimunLineWidth = config->Read( MINI_DRAW_LINE_WIDTH_KEY,
  131. (long) 0 );
  132. g_PlotLine_Width = config->Read( OPTKEY_PLOT_LINEWIDTH_VALUE,
  133. (long) 4 );
  134. }
  135. SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
  136. if( DrawPanel )
  137. DrawPanel->m_Block_Enable = TRUE;
  138. ReCreateMenuBar();
  139. ReCreateHToolbar();
  140. ReCreateVToolbar();
  141. ReCreateOptToolbar();
  142. }
  143. /***************/
  144. /* Destructor */
  145. /***************/
  146. WinEDA_SchematicFrame::~WinEDA_SchematicFrame()
  147. {
  148. extern PARAM_CFG_BASE* ParamCfgList[];
  149. wxGetApp().SaveCurrentSetupValues( ParamCfgList );
  150. SAFE_DELETE( g_RootSheet );
  151. SAFE_DELETE( m_CurrentSheet ); //a DrawSheetPath, on the heap.
  152. m_CurrentSheet = NULL;
  153. }
  154. BASE_SCREEN* WinEDA_SchematicFrame::GetBaseScreen() const
  155. {
  156. return GetScreen();
  157. }
  158. /***************/
  159. /* utility functions */
  160. /***************/
  161. DrawSheetPath* WinEDA_SchematicFrame::GetSheet()
  162. {
  163. return m_CurrentSheet;
  164. }
  165. /****************************************************/
  166. void WinEDA_SchematicFrame::SetSheetNumberAndCount()
  167. /****************************************************/
  168. /** Function SetSheetNumberAndCount
  169. * Set the m_ScreenNumber and m_NumberOfScreen members for screens
  170. * must be called after a delete or add sheet command, and when entering a sheet
  171. */
  172. {
  173. SCH_SCREEN* screen = GetScreen();
  174. EDA_ScreenList s_list;
  175. /* Set the sheet count, and the sheet number (1 for root sheet)
  176. */
  177. int sheet_count = g_RootSheet->CountSheets();
  178. int SheetNumber = 1;
  179. wxString current_sheetpath = m_CurrentSheet->Path();
  180. EDA_SheetList SheetList;
  181. // Examine all sheets path to find the current sheets path,
  182. // and count them from root to the current scheet path:
  183. DrawSheetPath* sheet;
  184. for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
  185. {
  186. wxString sheetpath = sheet->Path();
  187. if( sheetpath == current_sheetpath ) // Current sheet path found
  188. break;
  189. SheetNumber++; // not found, increment sheet number before this current path
  190. }
  191. for( screen = s_list.GetFirst(); screen != NULL; screen = s_list.GetNext() )
  192. {
  193. screen->m_NumberOfScreen = sheet_count;
  194. }
  195. GetScreen()->m_ScreenNumber = SheetNumber;
  196. }
  197. /***************************************************/
  198. SCH_SCREEN* WinEDA_SchematicFrame::GetScreen() const
  199. /***************************************************/
  200. {
  201. return m_CurrentSheet->LastScreen();
  202. }
  203. wxString WinEDA_SchematicFrame::GetScreenDesc()
  204. {
  205. wxString s = m_CurrentSheet->PathHumanReadable();
  206. return s;
  207. }
  208. void WinEDA_SchematicFrame::CreateScreens()
  209. {
  210. /* creation des ecrans Sch , Lib */
  211. if( g_RootSheet == NULL )
  212. {
  213. g_RootSheet = new DrawSheetStruct();
  214. }
  215. if( g_RootSheet->m_AssociatedScreen == NULL )
  216. {
  217. g_RootSheet->m_AssociatedScreen = new SCH_SCREEN();
  218. g_RootSheet->m_AssociatedScreen->m_RefCount++;
  219. }
  220. g_RootSheet->m_AssociatedScreen->m_FileName = g_DefaultSchematicFileName;
  221. g_RootSheet->m_AssociatedScreen->m_Date = GenDate();
  222. m_CurrentSheet->Clear();
  223. m_CurrentSheet->Push( g_RootSheet );
  224. if( g_ScreenLib == NULL )
  225. g_ScreenLib = new SCH_SCREEN();
  226. g_ScreenLib->SetZoom( 4 * g_ScreenLib->m_ZoomScalar );
  227. g_ScreenLib->m_UndoRedoCountMax = 10;
  228. }
  229. /*****************************************************************/
  230. void WinEDA_SchematicFrame::OnCloseWindow( wxCloseEvent& Event )
  231. /*****************************************************************/
  232. {
  233. DrawSheetPath* sheet;
  234. wxConfig* config = wxGetApp().m_EDA_Config;
  235. if( m_LibeditFrame ) // Can close component editor ?
  236. {
  237. if( !m_LibeditFrame->Close() )
  238. return;
  239. }
  240. EDA_SheetList SheetList;
  241. for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
  242. {
  243. if( sheet->LastScreen() && sheet->LastScreen()->IsModify() )
  244. break;
  245. }
  246. if( sheet )
  247. {
  248. unsigned ii;
  249. wxMessageDialog dialog( this,
  250. _( "Schematic modified, Save before exit ?" ),
  251. _( "Confirmation" ), wxYES_NO | wxCANCEL |
  252. wxICON_EXCLAMATION | wxYES_DEFAULT );
  253. ii = dialog.ShowModal();
  254. switch( ii )
  255. {
  256. case wxID_CANCEL:
  257. Event.Veto();
  258. return;
  259. case wxID_NO:
  260. break;
  261. case wxID_OK:
  262. case wxID_YES:
  263. SaveProject();
  264. break;
  265. }
  266. }
  267. for( sheet = SheetList.GetFirst(); sheet != NULL; sheet = SheetList.GetNext() )
  268. {
  269. if( sheet->LastScreen() )
  270. {
  271. sheet->LastScreen()->ClrModify();
  272. }
  273. }
  274. if( !g_RootSheet->m_AssociatedScreen->m_FileName.IsEmpty()
  275. && (g_RootSheet->m_AssociatedScreen->EEDrawList != NULL) )
  276. SetLastProject( g_RootSheet->m_AssociatedScreen->m_FileName );
  277. ClearProjectDrawList( g_RootSheet->m_AssociatedScreen, TRUE );
  278. /* allof sub sheets are deleted, only the main sheet is useable */
  279. m_CurrentSheet->Clear();
  280. SaveSettings();
  281. if( config )
  282. {
  283. config->Write( MINI_DRAW_LINE_WIDTH_KEY, (long) g_DrawMinimunLineWidth );
  284. config->Write( OPTKEY_PLOT_LINEWIDTH_VALUE, (long) g_PlotLine_Width );
  285. }
  286. Destroy();
  287. }
  288. /*****************************************************************************
  289. * Enable or disable some tools according to current conditions
  290. *****************************************************************************/
  291. void WinEDA_SchematicFrame::SetToolbars()
  292. {
  293. if( m_HToolBar )
  294. {
  295. if( GetScreen() && GetScreen()->BlockLocate.m_Command == BLOCK_MOVE )
  296. {
  297. m_HToolBar->EnableTool( wxID_CUT, TRUE );
  298. m_HToolBar->EnableTool( wxID_COPY, TRUE );
  299. }
  300. else
  301. {
  302. m_HToolBar->EnableTool( wxID_CUT, FALSE );
  303. m_HToolBar->EnableTool( wxID_COPY, FALSE );
  304. }
  305. if( g_BlockSaveDataList )
  306. m_HToolBar->EnableTool( wxID_PASTE, TRUE );
  307. else
  308. m_HToolBar->EnableTool( wxID_PASTE, FALSE );
  309. wxMenuBar* menuBar = GetMenuBar();
  310. if( GetScreen() && GetScreen()->m_RedoList )
  311. {
  312. m_HToolBar->EnableTool( ID_SCHEMATIC_REDO, TRUE );
  313. menuBar->Enable( ID_SCHEMATIC_REDO, TRUE );
  314. }
  315. else
  316. {
  317. m_HToolBar->EnableTool( ID_SCHEMATIC_REDO, FALSE );
  318. menuBar->Enable( ID_SCHEMATIC_REDO, FALSE );
  319. }
  320. if( GetScreen() && GetScreen()->m_UndoList )
  321. {
  322. m_HToolBar->EnableTool( ID_SCHEMATIC_UNDO, TRUE );
  323. menuBar->Enable( ID_SCHEMATIC_UNDO, TRUE );
  324. }
  325. else
  326. {
  327. m_HToolBar->EnableTool( ID_SCHEMATIC_UNDO, FALSE );
  328. menuBar->Enable( ID_SCHEMATIC_UNDO, FALSE );
  329. }
  330. }
  331. if( m_OptionsToolBar )
  332. {
  333. m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_GRID, m_Draw_Grid );
  334. m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_GRID,
  335. m_Draw_Grid ? _( "Grid not show" ) : _( "Show Grid" ) );
  336. m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM,
  337. g_UnitMetric == MILLIMETRE ? TRUE : FALSE );
  338. m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
  339. g_UnitMetric == INCHES ? TRUE : FALSE );
  340. m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_CURSOR,
  341. g_CursorShape );
  342. m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_HIDDEN_PINS, g_ShowAllPins );
  343. m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_HIDDEN_PINS,
  344. g_ShowAllPins ? _( "No show Hidden Pins" ) : _(
  345. "Show Hidden Pins" ) );
  346. m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_BUS_WIRES_ORIENT,
  347. g_HVLines );
  348. m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_BUS_WIRES_ORIENT,
  349. g_HVLines ? _( "Allows any direction for wires and busses" ) :
  350. _( "Allows horizontal and vertical wires and busses only" ) );
  351. }
  352. DisplayUnitsMsg();
  353. }
  354. /************************************/
  355. int WinEDA_SchematicFrame::BestZoom()
  356. /************************************/
  357. {
  358. int dx, dy, ii, jj;
  359. int bestzoom;
  360. wxSize size;
  361. dx = GetScreen()->m_CurrentSheetDesc->m_Size.x;
  362. dy = GetScreen()->m_CurrentSheetDesc->m_Size.y;
  363. size = DrawPanel->GetClientSize();
  364. ii = dx / size.x;
  365. jj = dy / size.y;
  366. bestzoom = MAX( ii, jj ) + 1;
  367. GetScreen()->m_Curseur.x = dx / 2;
  368. GetScreen()->m_Curseur.y = dy / 2;
  369. return bestzoom * GetScreen()->m_ZoomScalar;
  370. }
  371. /*******************************************************************/
  372. wxString WinEDA_SchematicFrame::GetUniqueFilenameForCurrentSheet( )
  373. /*******************************************************************/
  374. /** Function GetUniqueFilenameForCurrentSheet
  375. * @return a filename that can be used in plot and print functions
  376. * for the current screen anad sheet path.
  377. * This filename is unique and must be used insteed of the sreen filename
  378. * (or scheen filename) when one must creates file for each sheet in the heierarchy.
  379. * because in complex hierarchies a sheet and a SCH_SCREEN is used more than once
  380. * Name is <root sheet filename>-<sheet path>
  381. * and has no extension.
  382. * However if filename is too long name is <sheet filename>-<sheet number>
  383. */
  384. {
  385. wxString filename;
  386. wxSplitPath( g_RootSheet->GetFileName().GetData(), (wxString*) NULL,
  387. &filename, (wxString*) NULL );
  388. if ( (filename.Len() + m_CurrentSheet->PathHumanReadable().Len() ) < 50 )
  389. {
  390. filename += m_CurrentSheet->PathHumanReadable();
  391. filename.Replace( wxT( "/" ), wxT( "-" ) );
  392. filename.RemoveLast();
  393. }
  394. else
  395. {
  396. wxSplitPath( g_RootSheet->GetFileName().GetData(), (wxString*) NULL,
  397. &filename, (wxString*) NULL );
  398. filename << wxT("-") << GetScreen()->m_ScreenNumber;
  399. }
  400. return filename;
  401. }
  402. /**************************************************************/
  403. void WinEDA_SchematicFrame::OnAnnotate( wxCommandEvent& event )
  404. /**************************************************************/
  405. {
  406. WinEDA_AnnotateFrame* dlg = new WinEDA_AnnotateFrame( this );
  407. dlg->ShowModal();
  408. dlg->Destroy();
  409. }
  410. /*********************************************************/
  411. void WinEDA_SchematicFrame::OnErc( wxCommandEvent& event )
  412. /*********************************************************/
  413. {
  414. WinEDA_ErcFrame* dlg = new WinEDA_ErcFrame( this );
  415. dlg->ShowModal();
  416. dlg->Destroy();
  417. }
  418. /*******************************************************************/
  419. void WinEDA_SchematicFrame::OnCreateNetlist( wxCommandEvent& event )
  420. /*******************************************************************/
  421. {
  422. int i;
  423. if( g_NetFormat < NET_TYPE_PCBNEW )
  424. g_NetFormat = NET_TYPE_PCBNEW;
  425. do
  426. {
  427. WinEDA_NetlistFrame* dlg = new WinEDA_NetlistFrame( this );
  428. i = dlg->ShowModal();
  429. dlg->Destroy();
  430. } while( i == NET_PLUGIN_CHANGE );
  431. // If a plugin is removed or added, rebuild and reopen the new dialog
  432. }
  433. /**********************************************************************/
  434. void WinEDA_SchematicFrame::OnCreateBillOfMaterials( wxCommandEvent& )
  435. /**********************************************************************/
  436. {
  437. DIALOG_BUILD_BOM* dlg = new DIALOG_BUILD_BOM( this );
  438. dlg->ShowModal();
  439. dlg->Destroy();
  440. }
  441. /*******************************************************************/
  442. void WinEDA_SchematicFrame::OnFindItems( wxCommandEvent& event )
  443. /*******************************************************************/
  444. {
  445. this->DrawPanel->m_IgnoreMouseEvents = TRUE;
  446. WinEDA_FindFrame* dlg = new WinEDA_FindFrame( this );
  447. dlg->ShowModal();
  448. dlg->Destroy();
  449. this->DrawPanel->m_IgnoreMouseEvents = FALSE;
  450. }
  451. /***************************************************************/
  452. void WinEDA_SchematicFrame::OnLoadFile( wxCommandEvent& event )
  453. /***************************************************************/
  454. {
  455. wxString fn;
  456. fn = GetFileFromHistory( event.GetId(), _( "Schematic" ) );
  457. if( fn != wxEmptyString )
  458. {
  459. LoadOneEEProject( fn, false );
  460. SetToolbars();
  461. }
  462. }
  463. /*******************************************************************/
  464. void WinEDA_SchematicFrame::OnLoadStuffFile( wxCommandEvent& event )
  465. /*******************************************************************/
  466. {
  467. ReadInputStuffFile();
  468. DrawPanel->Refresh();
  469. }
  470. /****************************************************************/
  471. void WinEDA_SchematicFrame::OnNewProject( wxCommandEvent& event )
  472. /****************************************************************/
  473. {
  474. LoadOneEEProject( wxEmptyString, true );
  475. }
  476. /*****************************************************************/
  477. void WinEDA_SchematicFrame::OnLoadProject( wxCommandEvent& event )
  478. /*****************************************************************/
  479. {
  480. LoadOneEEProject( wxEmptyString, false );
  481. }
  482. /****************************************************************/
  483. void WinEDA_SchematicFrame::OnOpenPcbnew( wxCommandEvent& event )
  484. /****************************************************************/
  485. {
  486. wxString Line = g_RootSheet->m_AssociatedScreen->m_FileName;
  487. if( Line != wxEmptyString )
  488. {
  489. AddDelimiterString( Line );
  490. ChangeFileNameExt( Line, wxEmptyString );
  491. ExecuteFile( this, PCBNEW_EXE, Line );
  492. }
  493. else
  494. ExecuteFile( this, PCBNEW_EXE );
  495. }
  496. /***************************************************************/
  497. void WinEDA_SchematicFrame::OnOpenCvpcb( wxCommandEvent& event )
  498. /***************************************************************/
  499. {
  500. wxString Line = g_RootSheet->m_AssociatedScreen->m_FileName;
  501. if( Line != wxEmptyString )
  502. {
  503. AddDelimiterString( Line );
  504. ChangeFileNameExt( Line, wxEmptyString );
  505. ExecuteFile( this, CVPCB_EXE, Line );
  506. }
  507. else
  508. ExecuteFile( this, CVPCB_EXE );
  509. }
  510. /*************************************************************************/
  511. void WinEDA_SchematicFrame::OnOpenLibraryViewer( wxCommandEvent& event )
  512. /*************************************************************************/
  513. {
  514. if( m_ViewlibFrame )
  515. {
  516. m_ViewlibFrame->Show( TRUE );
  517. }
  518. else
  519. {
  520. m_ViewlibFrame = new WinEDA_ViewlibFrame( this );
  521. m_ViewlibFrame->AdjustScrollBars();
  522. }
  523. }
  524. /*************************************************************************/
  525. void WinEDA_SchematicFrame::OnOpenLibraryEditor( wxCommandEvent& event )
  526. /*************************************************************************/
  527. {
  528. if( m_LibeditFrame )
  529. {
  530. m_LibeditFrame->Show( TRUE );
  531. }
  532. else
  533. {
  534. m_LibeditFrame = new WinEDA_LibeditFrame( this,
  535. wxT( "Library Editor" ),
  536. wxPoint( -1, -1 ),
  537. wxSize( 600, 400 ) );
  538. ActiveScreen = g_ScreenLib;
  539. m_LibeditFrame->AdjustScrollBars();
  540. }
  541. }
  542. void WinEDA_SchematicFrame::OnExit( wxCommandEvent& event )
  543. {
  544. Close( true );
  545. }