KiCad PCB EDA Suite
pl_editor_frame.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2013 CERN
5  * Copyright (C) 2017-2019 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <fctsys.h>
27 #include <kiface_i.h>
28 #include <pgm_base.h>
29 #include <base_units.h>
30 #include <msgpanel.h>
31 #include <bitmaps.h>
32 #include <pl_editor_frame.h>
33 #include <pl_editor_id.h>
34 #include <pl_draw_panel_gal.h>
35 #include <pl_editor_screen.h>
36 #include <ws_data_model.h>
37 #include <properties_frame.h>
38 #include <widgets/paged_dialog.h>
39 #include <panel_display_options.h>
40 #include <panel_hotkeys_editor.h>
41 #include <view/view.h>
42 #include <confirm.h>
43 #include <tool/selection.h>
44 #include <tool/action_toolbar.h>
45 #include <tool/tool_dispatcher.h>
46 #include <tool/tool_manager.h>
47 #include <tool/common_control.h>
48 #include <tool/common_tools.h>
49 #include <tool/picker_tool.h>
50 #include <tool/zoom_tool.h>
51 #include <tools/pl_actions.h>
53 #include <tools/pl_drawing_tools.h>
54 #include <tools/pl_edit_tool.h>
55 #include <tools/pl_point_editor.h>
58 
59 BEGIN_EVENT_TABLE( PL_EDITOR_FRAME, EDA_DRAW_FRAME )
61  EVT_MENU( wxID_CLOSE, PL_EDITOR_FRAME::OnExit )
62  EVT_MENU( wxID_EXIT, PL_EDITOR_FRAME::OnExit )
63 
64  EVT_MENU( wxID_FILE, PL_EDITOR_FRAME::Files_io )
65 
67 
72 
75 END_EVENT_TABLE()
76 
77 
78 PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
79  EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ),
80  wxDefaultPosition, wxDefaultSize,
82 {
83  m_userUnits = MILLIMETRES;
84  m_zoomLevelCoeff = 290.0; // Adjusted to roughly displays zoom level = 1
85  // when the screen shows a 1:1 image
86  // obviously depends on the monitor,
87  // but this is an acceptable value
88 
89  m_showBorderAndTitleBlock = true; // true for reference drawings.
90  m_originSelectChoice = 0;
91  SetDrawBgColor( WHITE ); // default value, user option (WHITE/BLACK)
93  SetShowPageLimits( true );
94  m_AboutTitle = "PlEditor";
95 
96  m_propertiesFrameWidth = 200;
97 
98  // Give an icon
99  wxIcon icon;
100  icon.CopyFromBitmap( KiBitmap( icon_pagelayout_editor_xpm ) );
101  SetIcon( icon );
102 
103  // Create GAL canvas
104 #ifdef __WXMAC__
105  // Cairo renderer doesn't handle Retina displays
107 #else
108  m_canvasType = EDA_DRAW_PANEL_GAL::GAL_TYPE_CAIRO;
109 #endif
110 
111  auto* drawPanel = new PL_DRAW_PANEL_GAL( this, -1, wxPoint( 0, 0 ), m_FrameSize,
112  GetGalDisplayOptions(), m_canvasType );
113  SetCanvas( drawPanel );
114 
115  LoadSettings( config() );
116  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
117 
118  wxSize pageSizeIU = GetPageLayout().GetPageSettings().GetSizeIU();
119  SetScreen( new PL_EDITOR_SCREEN( pageSizeIU ) );
120 
121  setupTools();
122  ReCreateMenuBar();
123  ReCreateHToolbar();
124  ReCreateVToolbar();
125 
126  wxWindow* stsbar = GetStatusBar();
127  int dims[] = {
128 
129  // balance of status bar on far left is set to a default or whatever is left over.
130  -1,
131 
132  // When using GetTextSize() remember the width of '1' is not the same
133  // as the width of '0' unless the font is fixed width, and it usually won't be.
134 
135  // zoom:
136  GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
137 
138  // cursor coords
139  GetTextSize( wxT( "X 0234.567 Y 0234.567" ), stsbar ).x + 10,
140 
141  // delta distances
142  GetTextSize( wxT( "dx 0234.567 dx 0234.567" ), stsbar ).x + 10,
143 
144  // grid size
145  GetTextSize( wxT( "grid 0234.567" ), stsbar ).x + 10,
146 
147  // Coord origin (use the bigger message)
148  GetTextSize( _( "coord origin: Right Bottom page corner" ), stsbar ).x + 10,
149 
150  // units display, Inches is bigger than mm
151  GetTextSize( _( "Inches" ), stsbar ).x + 20
152  };
153 
154  SetStatusWidths( arrayDim( dims ), dims );
155 
156  m_auimgr.SetManagedWindow( this );
157 
158  m_propertiesPagelayout = new PROPERTIES_FRAME( this );
159 
160  // Horizontal items; layers 4 - 6
161  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
162  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
163 
164  // Vertical items; layers 1 - 3
165  m_auimgr.AddPane( m_drawToolBar, EDA_PANE().VToolbar().Name( "ToolsToolbar" ).Right().Layer(1) );
166 
167  m_auimgr.AddPane( m_propertiesPagelayout, EDA_PANE().Palette().Name( "Props" ).Right().Layer(2)
168  .Caption( _( "Properties" ) ).MinSize( m_propertiesPagelayout->GetMinSize() )
169  .BestSize( m_propertiesFrameWidth, -1 ) );
170 
171  m_auimgr.AddPane( GetCanvas(), EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
172 
173  GetCanvas()->GetView()->SetScale( GetZoomLevelCoeff() / GetScreen()->GetZoom() );
174  ActivateGalCanvas();
175 
176  m_auimgr.Update();
177 
178  // Add the exit key handler
179  InitExitKey();
180 
181  wxPoint originCoord = ReturnCoordOriginCorner();
182  SetGridOrigin( originCoord );
183 
184  if( !GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) )
186 
187  GetToolManager()->RunAction( "common.Control.gridPreset", true, m_LastGridSizeId );
188 
189  // Initialize the current page layout
191 #if 0 //start with empty layout
192  pglayout.AllowVoidList( true );
193  pglayout.ClearList();
194 #else // start with the default Kicad layout
195  pglayout.SetPageLayout();
196 #endif
197  OnNewPageLayout();
198 }
199 
200 
202 {
203  // Since the file menu contains file history menus, we must ensure that the menu
204  // destructor is called before the file history objects are deleted since their destructor
205  // unregisters the menu from the history.
206  wxMenu* fileMenu = GetMenuBar()->Remove( 0 );
207  delete fileMenu;
208 }
209 
211 {
212  // Create the manager and dispatcher & route draw panel events to the dispatcher
214  m_toolManager->SetEnvironment( nullptr, GetCanvas()->GetView(),
215  GetCanvas()->GetViewControls(), this );
216  m_actions = new PL_ACTIONS();
218 
220 
221  // Register tools
232 
233  // Run the selection tool, it is supposed to be always active
234  m_toolManager->InvokeTool( "plEditor.InteractiveSelection" );
235 }
236 
237 
238 bool PL_EDITOR_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
239 {
240  wxString fn = aFileSet[0];
241 
242  if( !LoadPageLayoutDescrFile( fn ) )
243  {
244  wxMessageBox( wxString::Format( _( "Error when loading file \"%s\"" ), fn ) );
245  return false;
246  }
247  else
248  {
249  OnNewPageLayout();
250  return true;
251  }
252 }
253 
254 
255 void PL_EDITOR_FRAME::OnExit( wxCommandEvent& aEvent )
256 {
257  if( aEvent.GetId() == wxID_EXIT )
258  Kiway().OnKiCadExit();
259 
260  if( aEvent.GetId() == wxID_CLOSE || Kiface().IsSingle() )
261  Close( false );
262 }
263 
264 
265 void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
266 {
267  if( GetScreen()->IsModify() )
268  {
269  wxFileName filename = GetCurrFileName();
270  wxString msg = _( "Save changes to \"%s\" before closing?" );
271 
272  if( !HandleUnsavedChanges( this, wxString::Format( msg, filename.GetFullName() ),
273  [&]()->bool { return saveCurrentPageLayout(); } ) )
274  {
275  aEvent.Veto();
276  return;
277  }
278  }
279 
280  // do not show the window because we do not want any paint event
281  Show( false );
282 
283  wxConfigSaveSetups( Kiface().KifaceSettings(), m_configSettings );
284 
285  // On Linux, m_propertiesPagelayout must be destroyed
286  // before deleting the main frame to avoid a crash when closing
287  m_propertiesPagelayout->Destroy();
288  Destroy();
289 }
290 
291 
292 /* Handles the selection of tools, menu, and popup menu commands.
293  */
294 void PL_EDITOR_FRAME::OnSelectPage( wxCommandEvent& event )
295 {
296  KIGFX::VIEW* view = GetCanvas()->GetView();
297  view->SetLayerVisible( LAYER_WORKSHEET_PAGE1, m_pageSelectBox->GetSelection() == 0 );
298  view->SetLayerVisible( LAYER_WORKSHEET_PAGEn, m_pageSelectBox->GetSelection() == 1 );
299  GetCanvas()->Refresh();
300 }
301 
302 
303 /* called when the user select one of the 4 page corner as corner
304  * reference (or the left top paper corner)
305  */
306 void PL_EDITOR_FRAME::OnSelectCoordOriginCorner( wxCommandEvent& event )
307 {
308  m_originSelectChoice = m_originSelectBox->GetSelection();
309  UpdateStatusBar(); // Update grid origin
311  GetCanvas()->Refresh();
312 }
313 
314 
316 {
318  HardRedraw();
319 }
320 
321 
322 void PL_EDITOR_FRAME::ToPrinter( bool doPreview )
323 {
324  // static print data and page setup data, to remember settings during the session
325  static wxPrintData* s_PrintData;
326  static wxPageSetupDialogData* s_pageSetupData = (wxPageSetupDialogData*) NULL;
327 
328  const PAGE_INFO& pageInfo = GetPageSettings();
329 
330  if( s_PrintData == NULL ) // First print
331  {
332  s_PrintData = new wxPrintData();
333  s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGH;
334  }
335 
336  if( !s_PrintData->Ok() )
337  {
338  wxMessageBox( _( "Error Init Printer info" ) );
339  return;
340  }
341 
342  if( s_pageSetupData == NULL )
343  s_pageSetupData = new wxPageSetupDialogData( *s_PrintData );
344 
345  s_pageSetupData->SetPaperId( pageInfo.GetPaperId() );
346  s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
347 
348  if( pageInfo.IsCustom() )
349  {
350  if( pageInfo.IsPortrait() )
351  s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetWidthMils() ),
352  Mils2mm( pageInfo.GetHeightMils() ) ) );
353  else
354  s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetHeightMils() ),
355  Mils2mm( pageInfo.GetWidthMils() ) ) );
356  }
357 
358  *s_PrintData = s_pageSetupData->GetPrintData();
359 
360  if( doPreview )
361  InvokeDialogPrintPreview( this, s_PrintData );
362  else
363  InvokeDialogPrint( this, s_PrintData, s_pageSetupData );
364 }
365 
366 
368 {
369  event.Check( WS_DATA_MODEL::GetTheInstance().m_EditMode == false );
370 }
371 
372 
374 {
375  event.Check( WS_DATA_MODEL::GetTheInstance().m_EditMode == true );
376 }
377 
378 
380 {
381  BOX2I rv( VECTOR2I( 0, 0 ), GetPageLayout().GetPageSettings().GetSizeIU() );
382  return rv;
383 }
384 
385 
387  PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
388 {
389  wxTreebook* book = aParent->GetTreebook();
390 
391  book->AddPage( new PANEL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
392 
393  aHotkeysPanel->AddHotKeys( GetToolManager() );
394 }
395 
396 
397 static const wxChar propertiesFrameWidthKey[] = wxT( "PropertiesFrameWidth" );
398 static const wxChar cornerOriginChoiceKey[] = wxT( "CornerOriginChoice" );
399 static const wxChar blackBgColorKey[] = wxT( "BlackBgColor" );
400 static const wxChar lastUsedPaperSizeKey[] = wxT( "LastUsedPaperSize" );
401 static const wxChar lastUsedCustomWidthKey[] = wxT( "LastUsedCustomWidth" );
402 static const wxChar lastUsedCustomHeightKey[] = wxT( "LastUsedCustomHeight" );
403 static const wxChar lastUsedPortraitKey[] = wxT( "LastUsedWasPortrait" );
404 
405 
406 void PL_EDITOR_FRAME::LoadSettings( wxConfigBase* aCfg )
407 {
409 
410  aCfg->Read( propertiesFrameWidthKey, &m_propertiesFrameWidth, 150 );
412 
413  bool flag;
414  aCfg->Read( blackBgColorKey, &flag, false );
415  SetDrawBgColor( flag ? BLACK : WHITE );
416 
417  int i;
418  aCfg->Read( lastUsedCustomWidthKey, &i, 17000 );
420  aCfg->Read( lastUsedCustomHeightKey, &i, 11000 );
422 
423  PAGE_INFO pageInfo = GetPageSettings();
424  wxString msg;
425  aCfg->Read( lastUsedPaperSizeKey, &msg, "A3" );
426  aCfg->Read( lastUsedPortraitKey, &flag, false );
427  pageInfo.SetType( msg, flag );
428  SetPageSettings( pageInfo );
429 }
430 
431 
432 void PL_EDITOR_FRAME::SaveSettings( wxConfigBase* aCfg )
433 {
435 
437 
440  aCfg->Write( blackBgColorKey, GetDrawBgColor() == BLACK );
441  aCfg->Write( lastUsedPaperSizeKey, GetPageSettings().GetType() );
442  aCfg->Write( lastUsedPortraitKey, GetPageSettings().IsPortrait() );
445 
447 }
448 
449 
451 {
452  wxString title;
453  wxString file = GetCurrFileName();
454 
455  title.Printf( _( "Page Layout Editor" ) + wxT( " \u2014 %s" ),
456  file.Length() ? file : _( "no file selected" ) );
457  SetTitle( title );
458 }
459 
460 
461 const wxString& PL_EDITOR_FRAME::GetCurrFileName() const
462 {
464 }
465 
466 
467 void PL_EDITOR_FRAME::SetCurrFileName( const wxString& aName )
468 {
470 }
471 
472 
473 void PL_EDITOR_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
474 {
475  m_pageLayout.SetPageSettings( aPageSettings );
476 
477  if( GetScreen() )
478  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
479 }
480 
481 
483 {
484  return m_pageLayout.GetPageSettings();
485 }
486 
487 
488 const wxSize PL_EDITOR_FRAME::GetPageSizeIU() const
489 {
490  // this function is only needed because EDA_DRAW_FRAME is not compiled
491  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
492  // into an application specific source file.
493  return m_pageLayout.GetPageSettings().GetSizeIU();
494 }
495 
496 
498 {
499  return GetPageLayout().GetTitleBlock();
500 }
501 
502 
503 void PL_EDITOR_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
504 {
505  m_pageLayout.SetTitleBlock( aTitleBlock );
506 }
507 
508 
510 {
511  // calculate the position (in page, in iu) of the corner used as coordinate origin
512  // coordinate origin can be the paper Top Left corner, or each of 4 page corners
513  wxPoint originCoord;
514 
515  // To avoid duplicate code, we use a dummy segment starting at 0,0 in relative coord
517 
518  switch( m_originSelectChoice )
519  {
520  default:
521  case 0: // Origin = paper Left Top corner
522  break;
523 
524  case 1: // Origin = page Right Bottom corner
525  dummy.SetStart( 0, 0, RB_CORNER );
526  originCoord = dummy.GetStartPosUi();
527  break;
528 
529  case 2: // Origin = page Left Bottom corner
530  dummy.SetStart( 0, 0, LB_CORNER );
531  originCoord = dummy.GetStartPosUi();
532  break;
533 
534  case 3: // Origin = page Right Top corner
535  dummy.SetStart( 0, 0, RT_CORNER );
536  originCoord = dummy.GetStartPosUi();
537  break;
538 
539  case 4: // Origin = page Left Top corner
540  dummy.SetStart( 0, 0, LT_CORNER );
541  originCoord = dummy.GetStartPosUi();
542  break;
543  }
544 
545  return originCoord;
546 }
547 
548 
549 /*
550  * Display the grid status.
551  */
553 {
554  wxString line;
555  wxString gridformatter;
556 
557  switch( m_userUnits )
558  {
559  case INCHES: gridformatter = "grid %.3f"; break;
560  case MILLIMETRES: gridformatter = "grid %.4f"; break;
561  default: gridformatter = "grid %f"; break;
562  }
563 
564  wxRealPoint curr_grid_size = GetScreen()->GetGridSize();
565  double grid = To_User_Unit( m_userUnits, curr_grid_size.x );
566  line.Printf( gridformatter, grid );
567 
568  SetStatusText( line, 4 );
569 }
570 
571 
573 {
575 
576  if( !screen )
577  return;
578 
579  // Display Zoom level:
581 
582  // coordinate origin can be the paper Top Left corner, or each of 4 page corners
583  wxPoint originCoord = ReturnCoordOriginCorner();
584  SetGridOrigin( originCoord );
585 
586  // We need the orientation of axis (sign of coordinates)
587  int Xsign = 1;
588  int Ysign = 1;
589 
590  switch( m_originSelectChoice )
591  {
592  default:
593  case 0: // Origin = paper Left Top corner
594  break;
595 
596  case 1: // Origin = page Right Bottom corner
597  Xsign = -1;
598  Ysign = -1;
599  break;
600 
601  case 2: // Origin = page Left Bottom corner
602  Ysign = -1;
603  break;
604 
605  case 3: // Origin = page Right Top corner
606  Xsign = -1;
607  break;
608 
609  case 4: // Origin = page Left Top corner
610  break;
611  }
612 
613  // Display absolute coordinates:
615  VECTOR2D coord = cursorPos - originCoord;
616  double dXpos = To_User_Unit( GetUserUnits(), coord.x * Xsign );
617  double dYpos = To_User_Unit( GetUserUnits(), coord.y * Ysign );
618 
619  wxString pagesizeformatter = _( "Page size: width %.4g height %.4g" );
620  wxString absformatter = wxT( "X %.4g Y %.4g" );
621  wxString locformatter = wxT( "dx %.4g dy %.4g" );
622 
623  switch( GetUserUnits() )
624  {
625  case INCHES: SetStatusText( _("inches"), 6 ); break;
626  case MILLIMETRES: SetStatusText( _("mm"), 6 ); break;
627  case UNSCALED_UNITS: SetStatusText( wxEmptyString, 6 ); break;
628  default: wxASSERT( false ); break;
629  }
630 
631  wxString line;
632 
633  // Display page size
634  #define MILS_TO_MM (25.4/1000)
635  DSIZE size = GetPageSettings().GetSizeMils();
636  size = size * MILS_TO_MM;
637  line.Printf( pagesizeformatter, size.x, size.y );
638  SetStatusText( line, 0 );
639 
640  // Display abs coordinates
641  line.Printf( absformatter, dXpos, dYpos );
642  SetStatusText( line, 2 );
643 
644  // Display relative coordinates:
645  double dx = cursorPos.x - screen->m_LocalOrigin.x;
646  double dy = cursorPos.y - screen->m_LocalOrigin.y;
647  dXpos = To_User_Unit( GetUserUnits(), dx * Xsign );
648  dYpos = To_User_Unit( GetUserUnits(), dy * Ysign );
649  line.Printf( locformatter, dXpos, dYpos );
650  SetStatusText( line, 3 );
651 
652  DisplayGridMsg();
653 
654  // Display corner reference for coord origin
655  line.Printf( _("coord origin: %s"),
656  m_originSelectBox->GetString( m_originSelectChoice ).GetData() );
657  SetStatusText( line, 5 );
658 
659  // Display units
660 }
661 
662 
663 void PL_EDITOR_FRAME::PrintPage( wxDC* aDC )
664 {
666  PrintWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, wxEmptyString );
667 }
668 
669 
671 {
672  return static_cast<PL_DRAW_PANEL_GAL*>( EDA_DRAW_FRAME::GetCanvas() );
673 }
674 
675 
677 {
679 
681  PL_SELECTION& selection = selTool->GetSelection();
682  WS_DATA_ITEM* item = nullptr;
683 
684  if( selection.GetSize() == 1 )
685  item = static_cast<WS_DRAW_ITEM_BASE*>( selection.Front() )->GetPeer();
686 
689  GetCanvas()->Refresh();
690 }
691 
692 
694 {
695  WS_DATA_ITEM * item = NULL;
696 
697  switch( aType )
698  {
700  item = new WS_DATA_ITEM_TEXT( wxT( "Text") );
701  break;
702 
705  break;
706 
708  item = new WS_DATA_ITEM( WS_DATA_ITEM::WS_RECT );
709  break;
710 
712  item = new WS_DATA_ITEM_POLYGONS();
713  break;
714 
716  {
717  wxFileDialog fileDlg( this, _( "Choose Image" ), wxEmptyString, wxEmptyString,
718  _( "Image Files " ) + wxImage::GetImageExtWildcard(), wxFD_OPEN );
719 
720  if( fileDlg.ShowModal() != wxID_OK )
721  return NULL;
722 
723  wxString fullFilename = fileDlg.GetPath();
724 
725  if( !wxFileExists( fullFilename ) )
726  {
727  wxMessageBox( _( "Couldn't load image from \"%s\"" ), fullFilename );
728  break;
729  }
730 
731  BITMAP_BASE* image = new BITMAP_BASE();
732 
733  if( !image->ReadImageFile( fullFilename ) )
734  {
735  wxMessageBox( _( "Couldn't load image from \"%s\"" ), fullFilename );
736  delete image;
737  break;
738  }
739 
740  item = new WS_DATA_ITEM_BITMAP( image );
741  }
742  break;
743  }
744 
745  if( item == NULL )
746  return NULL;
747 
749  item->SyncDrawItems( nullptr, GetCanvas()->GetView() );
750 
751  return item;
752 }
753 
754 
756 {
758  GetScreen()->ClrModify();
760 
763 
765 
767 }
768 
769 
771 {
773 }
774 
WS_DATA_MODEL handles the graphic items list to draw/plot the frame and title block.
Definition: ws_data_model.h:39
void OnFileHistory(wxCommandEvent &event)
void ToPrinter(bool doPreview)
Function ToPrinter Open a dialog frame to print layers.
const wxRealPoint & GetGridSize() const
Return the grid size of the currently selected grid.
Definition: base_screen.h:279
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:201
void PrintWorkSheet(wxDC *aDC, BASE_SCREEN *aScreen, int aLineWidth, double aScale, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString, COLOR4D aColor=COLOR4D::UNSPECIFIED)
Prints the page layout with the frame and the basic inscriptions.
PARAM_CFG_ARRAY m_configSettings
int m_ScreenNumber
Definition: base_screen.h:135
void OnKiCadExit()
Definition: kiway.cpp:522
EVT_UPDATE_UI(ID_MODEDIT_LOAD_MODULE_FROM_BOARD, FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard) EVT_UPDATE_UI(ID_ADD_FOOTPRINT_TO_BOARD
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
void HardRedraw() override
Refresh the library tree and redraw the window.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Function GetViewControls() Returns a pointer to the VIEW_CONTROLS instance used in the panel.
wxPrintOrientation GetWxOrientation() const
Function GetWxOrientation.
Definition: page_info.h:127
for pageLayout editor previewing
PL_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
const PAGE_INFO & GetPageSettings() const override
static int GetCustomHeightMils()
Function GetCustomHeightMils.
Definition: page_info.h:176
Work sheet structure type definitions.
Definition: ws_data_item.h:93
static const wxChar cornerOriginChoiceKey[]
Implementation of conversion functions that require both schematic and board internal units.
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
This file is part of the common library.
TOOL_DISPATCHER * m_toolDispatcher
const wxString & GetCurrFileName() const
Definition: id.h:90
int GetHeightMils() const
Definition: page_info.h:140
wxPoint ReturnCoordOriginCorner() const
calculate the position (in page, in iu) of the corner used as coordinate origin of items
Class PROPERTIES_FRAME display properties of the current item.
Class PL_EDITOR_FRAME is the main window used in the page layout editor.
void UpdateStatusBar() override
Update the status bar information.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
int InvokeDialogPrint(PL_EDITOR_FRAME *aCaller, wxPrintData *aPrintData, wxPageSetupDialogData *aPageSetupData)
Create and show a print dialog returns 1 if OK, 0 , there is a problem.
ACTIONS * m_actions
static void SetCustomWidthMils(int aWidthInMils)
Function SetCustomWidthMils sets the width of Custom page in mils, for any custom page constructed or...
Definition: page_info.cpp:227
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Function SetType sets the name of the page type and also the sizes and margins commonly associated wi...
Definition: page_info.cpp:117
virtual void SetDrawBgColor(COLOR4D aColor)
static TOOL_ACTION zoomFitScreen
Definition: actions.h:93
int InvokeDialogPrintPreview(PL_EDITOR_FRAME *aCaller, wxPrintData *aPrintData)
Create and show a print preview dialog returns 1 if OK, 0 , there is a problem.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
#define PL_EDITOR_FRAME_NAME
void AddHotKeys(TOOL_MANAGER *aToolMgr)
void SetPageLayout(const wxString &aFullFileName=wxEmptyString, bool Append=false)
Populates the list with a custom layout, or the default layout, if no custom layout available.
Class PL_ACTIONS.
Definition: pl_actions.h:41
bool IsCustom() const
Function IsCustom returns true if the type is Custom.
Definition: page_info.cpp:176
const BOX2I GetDocumentExtents() const override
The base class for create windows for drawing purpose.
void DisplayWorksheet()
Build and update the list of WS_DRAW_ITEM_xxx showing the frame layout.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot,...
Definition: title_block.h:40
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
PAGE_INFO & GetPageSettings()
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.
PL_SELECTION & GetSelection()
Function GetSelection()
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
void ClearList()
erase the list of items
wxPaperSize GetPaperId() const
Function GetPaperId.
Definition: page_info.h:134
wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
Definition: common.cpp:115
static WS_DATA_MODEL & GetTheInstance()
static function: returns the instance of WS_DATA_MODEL used in the application
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:51
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:109
wxTreebook * GetTreebook()
Definition: paged_dialog.h:43
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:63
Class TOOL_MANAGER.
Definition: tool_manager.h:50
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
void SetPageSettings(const PAGE_INFO &) override
void AllowVoidList(bool Allow)
In Kicad applications, a page layout description is needed So if the list is empty,...
bool IsSingle() const
Function IsSingle is this KIFACE_I running under single_top?
Definition: kiface_i.h:115
TITLE_BLOCK & GetTitleBlock()
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
void CopyPrmsFromItemToPanel(WS_DATA_ITEM *aItem)
WS_DATA_ITEM * AddPageLayoutItem(int aType)
Function AddPageLayoutItem Add a new item to the page layout item list.
void OnExit(wxCommandEvent &aEvent)
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
double To_User_Unit(EDA_UNITS_T aUnit, double aValue, bool aUseMils)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:93
void OnSelectCoordOriginCorner(wxCommandEvent &event)
called when the user select one of the 4 page corner as corner reference (or the left top paper corne...
Definition: common.h:134
int Mils2mm(double x)
Convert mils to mm.
Definition: base_units.h:54
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
static const wxChar lastUsedCustomWidthKey[]
void OnNewPageLayout()
Must be called to initialize parameters when a new page layout description is loaded.
PL_EDITOR_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:274
const TITLE_BLOCK & GetTitleBlock() const override
HOLDER_TYPE GetType()
Definition: kiway_holder.h:49
virtual KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
void SetLayerVisible(int aLayer, bool aVisible=true)
Function SetLayerVisible() Controls the visibility of a particular layer.
Definition: view.h:399
#define KICAD_DEFAULT_DRAWFRAME_STYLE
static const wxChar lastUsedCustomHeightKey[]
static const wxChar blackBgColorKey[]
const wxSize & GetSizeMils() const
Definition: page_info.h:142
PL_EDITOR_LAYOUT m_pageLayout
bool GetPageNumberOption() const
Page layout editor can show the title block using a page number 1 or another number.
PARAM_CFG_ARRAY & GetConfigurationSettings()
Populates the applicatios settings list.
Class COMMON_CONTROL.
#define _(s)
Specialization of the wxAuiPaneInfo class for KiCad panels.
void OnSelectPage(wxCommandEvent &event)
const wxString GetZoomLevelIndicator() const override
Function GetZoomLevelIndicator returns a human readable value which can be displayed in dialogs.
EVT_MENU_RANGE(ID_LANGUAGE_CHOICE, ID_LANGUAGE_CHOICE_END, KICAD_MANAGER_FRAME::language_change) KICAD_MANAGER_FRAME
void LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
Class COMMON_TOOLS.
Definition: common_tools.h:38
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Function InstallPreferences Allow a frame to load its preference panels (if any) into the preferences...
Class TOOL_DISPATCHER.
wxChoice * m_pageSelectBox
virtual const wxString GetZoomLevelIndicator() const
Return a human readable value which can be displayed as zoom level indicator in dialogs.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108
void SetPageSettings(const PAGE_INFO &aPageSettings)
virtual void SyncDrawItems(WS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView)
void wxConfigSaveSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigSaveSetups writes aList of PARAM_CFG_ARRAY elements to save configuration values to ...
void UpdateTitleAndInfo()
Displays the short filename (if exists) loaded file on the caption of the main window.
void OnUpdateTitleBlockDisplayEditMode(wxUpdateUIEvent &event)
see class PGM_BASE
EDA_UNITS_T m_userUnits
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
static const wxChar lastUsedPortraitKey[]
bool IsPortrait() const
Definition: page_info.h:121
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Function SetEventDispatcher() Sets a dispatcher that processes events and forwards them to tools.
void SetCurrFileName(const wxString &aName)
Stores the current layout descr file filename.
PROPERTIES_FRAME * m_propertiesPagelayout
void SetGridOrigin(const wxPoint &aPoint) override
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
size_t i
Definition: json11.cpp:649
Class PL_DRAWING_TOOLS.
static const wxChar propertiesFrameWidthKey[]
bool LoadPageLayoutDescrFile(const wxString &aFullFileName)
Function LoadPageLayoutDescrFile Loads a .kicad_wks page layout descr file.
void ClrModify()
Definition: base_screen.h:225
#define IU_PER_MILS
Definition: plotter.cpp:136
void SetEnvironment(EDA_ITEM *aModel, KIGFX::VIEW *aView, KIGFX::VIEW_CONTROLS *aViewControls, EDA_BASE_FRAME *aFrame)
Sets the work environment (model, view, view controls and the parent window).
Class PL_EDITOR_CONTROL.
static int GetCustomWidthMils()
Function GetCustomWidthMils.
Definition: page_info.h:170
Definition: colors.h:49
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
void Append(WS_DATA_ITEM *aItem)
bool ReadImageFile(const wxString &aFullFilename)
Reads and stores in memory an image file.
Definition: id.h:89
virtual COLOR4D GetDrawBgColor() const
void CopyPrmsFromGeneralToPanel()
TOOL_MANAGER * m_toolManager
void UpdateStatusBar() override
Update the status bar information.
static const wxChar lastUsedPaperSizeKey[]
Definition: colors.h:45
void InitTools()
Function InitTools() Initializes all registered tools.
Class VIEW.
Definition: view.h:61
virtual void PrintPage(wxDC *aDC) override
Virtual function PrintPage used to print a page.
Message panel definition file.
for pageLayout editor previewing
const PL_EDITOR_LAYOUT & GetPageLayout() const
void OnUpdateTitleBlockDisplayNormalMode(wxUpdateUIEvent &event)
void OnSelectTitleBlockDisplayMode(wxCommandEvent &event)
Toggle the display mode between the normal mode and the editor mode: In normal mode,...
void OnCloseWindow(wxCloseEvent &aEvent)
wxChoice * m_originSelectBox
static void SetCustomHeightMils(int aHeightInMils)
Function SetCustomHeightMils sets the height of Custom page in mils, for any custom page constructed ...
Definition: page_info.cpp:233
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
int GetWidthMils() const
Definition: page_info.h:137
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:114
void RegisterTool(TOOL_BASE *aTool)
Function RegisterTool() Adds a tool to the manager set and sets it up.
Class PL_POINT_EDITOR.
void Files_io(wxCommandEvent &event)
#define MILS_TO_MM
void LoadSettings(wxConfigBase *aCfg) override
Load common frame parameters from a configuration file.