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 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 
30 #include <fctsys.h>
31 #include <kiface_i.h>
32 #include <class_drawpanel.h>
33 #include <build_version.h>
34 #include <macros.h>
35 #include <base_units.h>
36 #include <msgpanel.h>
37 #include <bitmaps.h>
38 
39 #include <pl_editor_frame.h>
40 #include <pl_editor_id.h>
41 #include <hotkeys.h>
42 #include <pl_editor_screen.h>
44 #include <worksheet_dataitem.h>
45 #include <design_tree_frame.h>
46 #include <properties_frame.h>
47 
49 #include <confirm.h>
50 
51 /*************************/
52 /* class PL_EDITOR_FRAME */
53 /*************************/
54 
55 PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
56  EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ),
57  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME )
58 {
59  m_zoomLevelCoeff = 290.0; // Adjusted to roughly displays zoom level = 1
60  // when the screen shows a 1:1 image
61  // obviously depends on the monitor,
62  // but this is an acceptable value
63 
64  m_showAxis = false; // true to show X and Y axis on screen
65  m_showGridAxis = true;
66  m_showBorderAndTitleBlock = true; // true for reference drawings.
69  SetDrawBgColor( WHITE ); // default value, user option (WHITE/BLACK)
70  SetShowPageLimits( true );
71 
72  m_designTreeWidth = 150;
74 
75  if( m_canvas )
77 
78  // Give an icon
79  wxIcon icon;
80  icon.CopyFromBitmap( KiBitmap( icon_pagelayout_editor_xpm ) );
81  SetIcon( icon );
82  wxSize pageSizeIU = GetPageLayout().GetPageSettings().GetSizeIU();
83  SetScreen( new PL_EDITOR_SCREEN( pageSizeIU ) );
84 
85  LoadSettings( config() );
86  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
87 
88  if( ! GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) )
90 
91  GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 );
92 
96 
97  wxWindow* stsbar = GetStatusBar();
98  int dims[] = {
99 
100  // balance of status bar on far left is set to a default or whatever is left over.
101  -1,
102 
103  // When using GetTextSize() remember the width of '1' is not the same
104  // as the width of '0' unless the font is fixed width, and it usually won't be.
105 
106  // zoom:
107  GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
108 
109  // cursor coords
110  GetTextSize( wxT( "X 0234.567 Y 0234.567" ), stsbar ).x + 10,
111 
112  // delta distances
113  GetTextSize( wxT( "dx 0234.567 dx 0234.567" ), stsbar ).x + 10,
114 
115  // Coord origin (use the bigger message)
116  GetTextSize( _( "coord origin: Right Bottom page corner" ), stsbar ).x + 10,
117 
118  // units display, Inches is bigger than mm
119  GetTextSize( _( "Inches" ), stsbar ).x + 10
120  };
121 
122  SetStatusWidths( DIM( dims ), dims );
123 
124 
125  m_auimgr.SetManagedWindow( this );
126 
127  EDA_PANEINFO horiz;
128  horiz.HorizontalToolbarPane();
129 
130  EDA_PANEINFO vert;
131  vert.VerticalToolbarPane();
132 
133  EDA_PANEINFO mesg;
134  mesg.MessageToolbarPane();
135 
137  EDA_PANEINFO props;
138  props.LayersToolbarPane();
139  props.MinSize( m_propertiesPagelayout->GetMinSize() );
140  props.BestSize( m_propertiesFrameWidth, -1 );
141  props.Caption( _( "Properties" ) );
142 
143  m_treePagelayout = new DESIGN_TREE_FRAME( this );
144  EDA_PANEINFO tree;
145  tree.LayersToolbarPane();
146  tree.MinSize( m_treePagelayout->GetMinSize() );
147  tree.BestSize( m_designTreeWidth, -1 );
148  tree.Caption( _( "Design" ) );
149 
150  if( m_mainToolBar )
151  m_auimgr.AddPane( m_mainToolBar,
152  wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) );
153 
154  if( m_drawToolBar )
155  m_auimgr.AddPane( m_drawToolBar,
156  wxAuiPaneInfo( vert ).Name( wxT( "m_drawToolBar" ) ).Right().Row( 1 ) );
157 
159  props.Name( wxT( "m_propertiesPagelayout" ) ).Right().Layer( 1 ) );
160 
161  m_auimgr.AddPane( m_treePagelayout,
162  tree.Name( wxT( "m_treePagelayout" ) ).Left().Layer( 0 ) );
163 
164  if( m_optionsToolBar )
165  m_auimgr.AddPane( m_optionsToolBar,
166  wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left() );
167 
168  if( m_canvas )
169  m_auimgr.AddPane( m_canvas,
170  wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane().Layer( 5 ) );
171 
172  if( m_messagePanel )
173  m_auimgr.AddPane( m_messagePanel,
174  wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer( 10 ) );
175 
176  m_auimgr.Update();
177 
178  // Initialize the current page layout
180 #if 0 //start with empty layout
181  pglayout.AllowVoidList( true );
182  pglayout.ClearList();
183 #else // start with the default Kicad layout
184  pglayout.SetPageLayout();
185 #endif
186  OnNewPageLayout();
187 }
188 
189 
191 {
192 }
193 
194 
195 bool PL_EDITOR_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
196 {
197  wxString fn = aFileSet[0];
198 
199  if( !LoadPageLayoutDescrFile( fn ) )
200  {
201  wxString msg = wxString::Format(
202  _( "Error when loading file \"%s\"" ),
203  GetChars( fn )
204  );
205 
206  wxMessageBox( msg );
207  return false;
208  }
209  else
210  {
211  OnNewPageLayout();
212  return true;
213  }
214 }
215 
216 
217 void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& Event )
218 {
219  if( GetScreen()->IsModify() )
220  {
221  wxString msg;
222  wxString filename = GetCurrFileName();
223 
224  if( filename.IsEmpty() )
225  msg = _( "Save changes in a new file before closing?" );
226  else
227  msg.Printf( _( "Save the changes in\n\"%s\"\nbefore closing?" ),
228  GetChars( filename ) );
229 
230  int ii = DisplayExitDialog( this, msg );
231 
232  switch( ii )
233  {
234  case wxID_CANCEL:
235  Event.Veto();
236  return;
237 
238  case wxID_NO:
239  break;
240 
241  case wxID_OK:
242  case wxID_YES:
243  {
244  if( filename.IsEmpty() )
245  {
246  wxFileDialog openFileDialog( this, _( "Save As" ), wxEmptyString, wxEmptyString,
247  PageLayoutDescrFileWildcard(), wxFD_SAVE );
248 
249  if(openFileDialog.ShowModal() == wxID_CANCEL )
250  return;
251 
252  filename = openFileDialog.GetPath();
253  }
254 
255  if( !SavePageLayoutDescrFile( filename ) )
256  {
257  msg.Printf( _( "Unable to create \"%s\"" ), GetChars( filename ) );
258  wxMessageBox( msg );
259  }
260  }
261  break;
262  }
263  }
264 
265  // do not show the window because we do not want any paint event
266  Show( false );
267 
268  // was: Pgm().SaveCurrentSetupValues( m_configSettings );
269  wxConfigSaveSetups( Kiface().KifaceSettings(), m_configSettings );
270 
271  // On Linux, m_propertiesPagelayout must be destroyed
272  // before deleting the main frame to avoid a crash when closing
273  m_propertiesPagelayout->Destroy();
274  Destroy();
275 }
276 
277 
279 {
280  double sizeX = (double) GetPageLayout().GetPageSettings().GetWidthIU();
281  double sizeY = (double) GetPageLayout().GetPageSettings().GetHeightIU();
282  wxPoint centre( sizeX / 2, sizeY / 2 );
283 
284  // The sheet boundary already affords us some margin, so add only an
285  // additional 5%.
286  double margin_scale_factor = 1.05;
287 
288  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
289 }
290 
291 
292 static const wxChar designTreeWidthKey[] = wxT( "DesignTreeWidth" );
293 static const wxChar propertiesFrameWidthKey[] = wxT( "PropertiesFrameWidth" );
294 static const wxChar cornerOriginChoiceKey[] = wxT( "CornerOriginChoice" );
295 static const wxChar blackBgColorKey[] = wxT( "BlackBgColor" );
296 
297 
298 void PL_EDITOR_FRAME::LoadSettings( wxConfigBase* aCfg )
299 {
301 
302  aCfg->Read( designTreeWidthKey, &m_designTreeWidth, 100);
305  bool tmp;
306  aCfg->Read( blackBgColorKey, &tmp, false );
307  SetDrawBgColor( tmp ? BLACK : WHITE );
308 }
309 
310 
311 void PL_EDITOR_FRAME::SaveSettings( wxConfigBase* aCfg )
312 {
314 
315  m_designTreeWidth = m_treePagelayout->GetSize().x;
317 
318  aCfg->Write( designTreeWidthKey, m_designTreeWidth);
321  aCfg->Write( blackBgColorKey, GetDrawBgColor() == BLACK );
322 
323  // was: wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
325 }
326 
327 
329 {
330  wxString title;
331  wxString file = GetCurrFileName();
332 
333  title.Printf( _( "Page Layout Editor" ) + wxT( " \u2014 %s" ),
334  file.Length() ? file : _( "no file selected" ) );
335  SetTitle( title );
336 }
337 
338 
339 const wxString& PL_EDITOR_FRAME::GetCurrFileName() const
340 {
342 }
343 
344 
345 void PL_EDITOR_FRAME::SetCurrFileName( const wxString& aName )
346 {
348 }
349 
350 
351 void PL_EDITOR_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
352 {
353  m_pageLayout.SetPageSettings( aPageSettings );
354 
355  if( GetScreen() )
356  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
357 }
358 
359 
361 {
362  return m_pageLayout.GetPageSettings();
363 }
364 
365 
366 const wxSize PL_EDITOR_FRAME::GetPageSizeIU() const
367 {
368  // this function is only needed because EDA_DRAW_FRAME is not compiled
369  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
370  // into an application specific source file.
371  return m_pageLayout.GetPageSettings().GetSizeIU();
372 }
373 
374 
376 {
377  return GetPageLayout().GetTitleBlock();
378 }
379 
380 
381 void PL_EDITOR_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
382 {
383  m_pageLayout.SetTitleBlock( aTitleBlock );
384 }
385 
386 
388 {
390 
391  if( !screen )
392  return;
393 
394  // Display Zoom level:
396 
397  // coodinate origin can be the paper Top Left corner,
398  // or each of 4 page corners
399  // We know the origin, and the orientation of axis
400  wxPoint originCoord;
401  int Xsign = 1;
402  int Ysign = 1;
403 
405 
406  switch( m_originSelectChoice )
407  {
408  default:
409  case 0: // Origin = paper Left Top corner
410  break;
411 
412  case 1: // Origin = page Right Bottom corner
413  Xsign = -1;
414  Ysign = -1;
415  dummy.SetStart( 0, 0, RB_CORNER );
416  originCoord = dummy.GetStartPosUi();
417  break;
418 
419  case 2: // Origin = page Left Bottom corner
420  Ysign = -1;
421  dummy.SetStart( 0, 0, LB_CORNER );
422  originCoord = dummy.GetStartPosUi();
423  break;
424 
425  case 3: // Origin = page Right Top corner
426  Xsign = -1;
427  dummy.SetStart( 0, 0, RT_CORNER );
428  originCoord = dummy.GetStartPosUi();
429  break;
430 
431  case 4: // Origin = page Left Top corner
432  dummy.SetStart( 0, 0, LT_CORNER );
433  originCoord = dummy.GetStartPosUi();
434  break;
435  }
436 
437  SetGridOrigin( originCoord );
438 
439  // Display absolute coordinates:
440  wxPoint coord = GetCrossHairPosition() - originCoord;
441  double dXpos = To_User_Unit( g_UserUnit, coord.x*Xsign );
442  double dYpos = To_User_Unit( g_UserUnit, coord.y*Ysign );
443 
444  wxString pagesizeformatter = _( "Page size: width %.4g height %.4g" );
445  wxString absformatter = wxT( "X %.4g Y %.4g" );
446  wxString locformatter = wxT( "dx %.4g dy %.4g" );
447 
448  switch( g_UserUnit )
449  {
450  case INCHES: // Should not be used in page layout editor
451  SetStatusText( _("inches"), 5 );
452  break;
453 
454  case MILLIMETRES:
455  SetStatusText( _("mm"), 5 );
456  break;
457 
458  case UNSCALED_UNITS:
459  SetStatusText( wxEmptyString, 5 );
460  break;
461 
462  case DEGREES:
463  wxASSERT( false );
464  break;
465  }
466 
467  wxString line;
468 
469  // Display page size
470  #define milsTomm (25.4/1000)
471  DSIZE size = GetPageSettings().GetSizeMils();
472  size = size * milsTomm;
473  line.Printf( pagesizeformatter, size.x, size.y );
474  SetStatusText( line, 0 );
475 
476  // Display abs coordinates
477  line.Printf( absformatter, dXpos, dYpos );
478  SetStatusText( line, 2 );
479 
480  // Display relative coordinates:
481  int dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
482  int dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
483  dXpos = To_User_Unit( g_UserUnit, dx * Xsign );
484  dYpos = To_User_Unit( g_UserUnit, dy * Ysign );
485  line.Printf( locformatter, dXpos, dYpos );
486  SetStatusText( line, 3 );
487 
488  // Display corner reference for coord origin
489  line.Printf( _("coord origin: %s"),
490  m_originSelectBox->GetString( m_originSelectChoice ). GetData() );
491  SetStatusText( line, 4 );
492 
493  // Display units
494 }
495 
496 
497 void PL_EDITOR_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
498  bool aPrintMirrorMode, void * aData )
499 {
500  GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
501  DrawWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, wxEmptyString );
502 }
503 
504 
505 void PL_EDITOR_FRAME::RedrawActiveWindow( wxDC* aDC, bool aEraseBg )
506 {
507 
508  GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
509 
510  if( aEraseBg )
511  m_canvas->EraseScreen( aDC );
512 
513  m_canvas->DrawBackGround( aDC );
514 
516  WORKSHEET_DATAITEM* selecteditem = GetSelectedItem();
517 
518  // the color to draw selected items
519  if( GetDrawBgColor() == WHITE )
521  else
523 
524  for( unsigned ii = 0; ; ii++ )
525  {
526  WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
527 
528  if( item == NULL )
529  break;
530 
531  item->SetSelected( item == selecteditem );
532  }
533 
534  DrawWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, GetCurrFileName() );
535 
536 #ifdef USE_WX_OVERLAY
537  if( IsShown() )
538  {
539  m_overlay.Reset();
540  wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)aDC );
541  overlaydc.Clear();
542  }
543 #endif
544 
545  if( m_canvas->IsMouseCaptured() )
546  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
547 
548  m_canvas->DrawCrossHair( aDC );
549 
550  // Display the filename
552 }
553 
554 
556 {
558  int rectId = 0;
559  int lineId = 0;
560  int textId = 0;
561  int polyId = 0;
562  int bitmapId = 0;
563 
564  for( unsigned ii = 0; ii < pglayout.GetCount(); ii++ )
565  {
566  WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
567  switch( item->GetType() )
568  {
570  item->m_Name = wxString::Format( wxT( "text%d:%s" ), ++textId,
571  GetChars(item->GetClassName()) );
572  break;
573 
575  item->m_Name = wxString::Format( wxT( "segm%d:%s" ), ++lineId,
576  GetChars(item->GetClassName()) );
577  break;
578 
580  item->m_Name = wxString::Format( wxT( "rect%d:%s" ), ++rectId,
581  GetChars(item->GetClassName()) );
582  break;
583 
585  item->m_Name = wxString::Format( wxT( "poly%d:%s" ), ++polyId,
586  GetChars(item->GetClassName()) );
587  break;
588 
590  item->m_Name = wxString::Format( wxT( "bm%d:%s" ), ++bitmapId,
591  GetChars(item->GetClassName()) );
592  break;
593  }
594  }
595 
597 }
598 
599 
601 {
602  WORKSHEET_DATAITEM * item = NULL;
603 
604  switch( aType )
605  {
607  item = new WORKSHEET_DATAITEM_TEXT( wxT( "Text") );
608  break;
609 
612  break;
613 
616  break;
617 
619  item = new WORKSHEET_DATAITEM_POLYPOLYGON();
620  break;
621 
623  {
624  wxFileDialog fileDlg( this, _( "Choose Image" ), wxEmptyString, wxEmptyString,
625  _( "Image Files " ) + wxImage::GetImageExtWildcard(),
626  wxFD_OPEN );
627 
628  if( fileDlg.ShowModal() != wxID_OK )
629  return NULL;
630 
631  wxString fullFilename = fileDlg.GetPath();
632 
633  if( !wxFileExists( fullFilename ) )
634  {
635  wxMessageBox( _( "Couldn't load image from \"%s\"" ), GetChars( fullFilename ) );
636  break;
637  }
638 
639  BITMAP_BASE* image = new BITMAP_BASE();
640 
641  if( !image->ReadImageFile( fullFilename ) )
642  {
643  wxMessageBox( _( "Couldn't load image from \"%s\"" ),
644  GetChars( fullFilename ) );
645  delete image;
646  break;
647  }
648 
649  item = new WORKSHEET_DATAITEM_BITMAP( image );
650  }
651  break;
652  }
653 
654  if( item == NULL )
655  return NULL;
656 
658  pglayout.Insert( item, aIdx );
660 
661  return item;
662 }
663 
664 
666 {
668  return item;
669 }
670 
671 
673 {
674  const PAGE_INFO& pageInfo = GetPageSettings();
675  TITLE_BLOCK t_block = GetTitleBlock();
676  COLOR4D color = COLOR4D( RED ); // Needed, not used
678 
679  screen-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
680 
681  WS_DRAW_ITEM_LIST drawList;
682  drawList.SetPenSize( 0 );
683  drawList.SetMilsToIUfactor( IU_PER_MILS );
684  drawList.SetSheetNumber( screen->m_ScreenNumber );
685  drawList.SetSheetCount( screen->m_NumberOfScreens );
686  drawList.SetFileName( GetCurrFileName() );
687  // GetScreenDesc() returns a temporary string. Store it to avoid issues.
688  wxString descr = GetScreenDesc();
689  drawList.SetSheetName( descr );
690 
691  drawList.BuildWorkSheetGraphicList( pageInfo, t_block, color, color );
692 
693  // locate items.
694  // We do not use here the COLLECTOR classes in use in pcbnew and eeschema
695  // because the locate requirements are very basic.
696  std::vector <WS_DRAW_ITEM_BASE*> list;
697  drawList.Locate( list, aPosition );
698 
699  if( list.size() == 0 )
700  return NULL;
701 
702  WS_DRAW_ITEM_BASE* drawitem = list[0];
703 
704  // Choose item in list if more than 1 item
705  if( list.size() > 1 )
706  {
707  wxArrayString choices;
708  wxString text;
709  wxPoint cursPos = GetCrossHairPosition();
710 
711  for( unsigned ii = 0; ii < list.size(); ++ii )
712  {
713  drawitem = list[ii];
714  text = drawitem->GetParent()->m_Name;
715 
716  if( (drawitem->m_Flags & (LOCATE_STARTPOINT|LOCATE_ENDPOINT))
718  text << wxT( " " ) << _( "(start or end point)" );
719  else
720  {
721  if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
722  text << wxT( " " ) << _( "(start point)" );
723 
724  if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
725  text << wxT( " " ) << _( "(end point)" );
726  }
727 
728  if( ! drawitem->GetParent()->m_Info.IsEmpty() )
729  text << wxT( " \"" ) << drawitem->GetParent()->m_Info << wxT( "\"" );
730 
731  choices.Add( text );
732  }
733 
734  int selection = wxGetSingleChoiceIndex ( wxEmptyString,
735  _( "Selection Clarification" ),
736  choices, this );
737  if( selection < 0 )
738  return NULL;
739 
740  SetCrossHairPosition( cursPos );
742  drawitem = list[selection];
743  }
744 
745  WORKSHEET_DATAITEM* item = drawitem->GetParent();
747 
748  if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
749  item->SetFlags( LOCATE_STARTPOINT );
750 
751  if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
752  item->SetFlags( LOCATE_ENDPOINT );
753 
754  return item;
755 }
756 
757 
759 {
761  GetScreen()->ClrModify();
764  Zoom_Automatique( false );
765  m_canvas->Refresh();
766 }
767 
768 
770 {
772 }
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
#define DIM(x)
of elements in an array
Definition: macros.h:98
static COLOR4D m_SelectedColor
wxString PageLayoutDescrFileWildcard()
PARAM_CFG_ARRAY m_configSettings
int m_ScreenNumber
Definition: base_screen.h:216
const PL_EDITOR_LAYOUT & GetPageLayout() const
void AllowVoidList(bool Allow)
In Kicad applications, a page layout description is needed So if the list is empty, a default description is loaded, the first time a page layout is drawn.
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
void SetPenSize(int aPenSize)
Function SetPenSize Set the default pen size to draw/plot lines and texts.
const PAGE_INFO & GetPageSettings() const override
bool m_showAxis
True shows the X and Y axis indicators.
Definition: draw_frame.h:116
virtual const wxString GetZoomLevelIndicator() const
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Definition: draw_frame.cpp:735
static const wxChar cornerOriginChoiceKey[]
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:338
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.
const TITLE_BLOCK & GetTitleBlock() const
double bestZoom(double sizeX, double sizeY, double scaleFactor, wxPoint centre)
Definition: zoom.cpp:90
WORKSHEET_DATAITEM * AddPageLayoutItem(int aType, int aIdx=-1)
Function AddPageLayoutItem Add a new item to the page layout item list.
void SetScreen(BASE_SCREEN *aScreen)
Definition: draw_frame.h:167
void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
Class PROPERTIES_FRAME display properties of the current item.
void UpdateStatusBar() override
Function UpdateStatusBar updates the status bar information.
int color
Definition: DXF_plotter.cpp:62
void DrawCrossHair(wxDC *aDC, COLOR4D aColor=COLOR4D::WHITE)
Function DrawCrossHair draws the user cross hair.
Definition: draw_panel.cpp:221
#define PL_EDITOR_FRAME_NAME
Definition: draw_frame.h:51
#define LOCATE_STARTPOINT
virtual void SetDrawBgColor(COLOR4D aColor)
Definition: draw_frame.h:351
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
void OnCloseWindow(wxCloseEvent &Event)
void ClearFlags(int aMask)
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
wxAuiManager m_auimgr
void BuildWorkSheetGraphicList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock, COLOR4D aColor, COLOR4D aAltColor)
Function BuildWorkSheetGraphicList is a core function for drawing or plotting the page layout with th...
wxSize GetMinSize() const override
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:63
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:360
EDA_PANEINFO & LayersToolbarPane()
Function LayersToolbarPane Change *this to a layers toolbar for KiCad.
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
Definition: title_block.h:39
const wxSize GetPageSizeIU() const override
Function GetPageSizeIU works off of GetPageSettings() to return the size of the paper page in the int...
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
const wxPoint GetStartPosUi(int ii=0) const
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
Definition: draw_frame.cpp:792
Specialization of the wxAuiPaneInfo class for KiCad panels.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
#define LOCATE_ENDPOINT
static WORKSHEET_LAYOUT & GetTheInstance()
static function: returns the instance of WORKSHEET_LAYOUT used in the application ...
This file contains miscellaneous commonly used macros and functions.
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:87
const wxSize & GetSizeMils() const
Definition: page_info.h:137
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:44
PARAM_CFG_ARRAY & GetConfigurationSettings(void)
Populates the applicatios settings list.
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
Definition: base_screen.h:180
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
Definition: base_screen.cpp:69
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Function KiBitmap constructs a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:78
void Zoom_Automatique(bool aWarpPointer)
Function Zoom_Automatique redraws the screen with best zoom level and the best centering that shows a...
Definition: zoom.cpp:106
EDA_PANEINFO & VerticalToolbarPane()
Function VerticalToolbarPane Change *this to a vertical toolbar for KiCad.
void RedrawActiveWindow(wxDC *DC, bool EraseBg) override
void SetFlags(int aMask)
void Locate(std::vector< WS_DRAW_ITEM_BASE * > &aList, const wxPoint &aPosition)
Locate graphic items in m_graphicList at location aPosition.
Class DESIGN_TREE_FRAME is the left window showing the list of items.
#define milsTomm
void SetPageSettings(const PAGE_INFO &) override
Class LSET is a set of PCB_LAYER_IDs.
wxAuiToolBar * m_optionsToolBar
The options tool bar typcially located on the left edge of the main window.
Definition: draw_frame.h:146
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:346
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:89
WORKSHEET_DATAITEM * GetItem(unsigned aIdx) const
virtual wxString GetScreenDesc() const
Definition: worksheet.cpp:119
PL_EDITOR_FRAME(KIWAY *aKiway, wxWindow *aParent)
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
void SetSheetCount(int aSheetCount)
Function SetSheetCount Set the value of the count of sheets, for basic inscriptions.
bool IsMouseCaptured() const
void SetSelected(bool aState)
Function SetSelected Toggles on/off the selected flag (used in edition functions. ...
EDA_MSG_PANEL * m_messagePanel
Panel used to display information at the bottom of the main window.
Definition: draw_frame.h:149
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:49
bool m_showBorderAndTitleBlock
True shows the drawing border and title block.
Definition: draw_frame.h:126
Definition: common.h:146
WORKSHEET_DATAITEM * GetParent() const
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
void ClearList()
erase the list of items
void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
void SetMilsToIUfactor(double aScale)
Function SetMilsToIUfactor Set the scalar to convert pages units ( mils) to draw/plot units...
WORKSHEET_DATAITEM * Locate(const wxPoint &aPosition)
Function Locate.
void OnNewPageLayout()
Must be called to initialize parameters when a new page layout description is loaded.
The common library.
description of graphic items and texts to build a title block
bool m_showGridAxis
True shows the grid axis indicators.
Definition: draw_frame.h:119
PL_EDITOR_SCREEN * GetScreen() const override
Function GetScreen returns 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:258
const TITLE_BLOCK & GetTitleBlock() const override
wxSize GetMinSize() const override
bool SavePageLayoutDescrFile(const wxString &aFullFileName)
Function SavePageLayoutDescrFile Save the current layout in a .kicad_wks page layout descr file...
Definition: colors.h:60
#define KICAD_DEFAULT_DRAWFRAME_STYLE
static const wxChar blackBgColorKey[]
PL_EDITOR_LAYOUT m_pageLayout
const PAGE_INFO & GetPageSettings() const
int m_LastGridSizeId
Definition: draw_frame.h:91
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:143
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
const wxString GetZoomLevelIndicator() const override
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
Definition: draw_frame.cpp:760
WORKSHEET_LAYOUT handles the graphic items list to draw/plot the title block and other items (page re...
unsigned GetCount() const
double BestZoom() override
Return the zoom level which displays the full page on screen.
EDA_UNITS_T g_UserUnit
Global variables definitions.
Definition: common.cpp:57
static const wxChar designTreeWidthKey[]
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:106
void SetPageSettings(const PAGE_INFO &aPageSettings)
bool GetPageNumberOption() const
Page layout editor can show the title block using a page number 1 or another number.
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
int DisplayExitDialog(wxWindow *parent, const wxString &aMessage)
Function DisplayExitDialog displays a dialog with 3 buttons: Save and Exit Cancel Exit without save...
Definition: confirm.cpp:173
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:99
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.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
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
Function SaveSettings saves common frame parameters to a configuration data file. ...
WORKSHEET_DATAITEM * GetSelectedItem()
Function GetSelectedItem.
void SetSheetNumber(int aSheetNumber)
Function SetSheetNumber Set the value of the sheet number, for basic inscriptions.
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
void SetCurrFileName(const wxString &aName)
Stores the current layout descr file filename.
void ReCreateOptToolbar()
Create or update the left vertical toolbar (option toolbar.
PROPERTIES_FRAME * m_propertiesPagelayout
void SetGridOrigin(const wxPoint &aPoint) override
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
WS_ItemType GetType() const
struct EDA_HOTKEY_CONFIG PlEditorHokeysDescr[]
void SetStart(double aPosx, double aPosy, enum corner_anchor aAnchor=RB_CORNER)
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:325
Definition: colors.h:49
void SetEnableBlockCommands(bool aEnable)
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
void RebuildDesignTree()
Function RebuildDesignTree Re creates the design graphic tree list items, and ensures each item has a...
int m_NumberOfScreens
Definition: base_screen.h:217
double To_User_Unit(EDA_UNITS_T aUnit, double aValue)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:91
bool ReadImageFile(const wxString &aFullFilename)
Function ReadImageFile Reads and stores in memory an image file.
Definition: bitmap_base.cpp:82
void DrawBackGround(wxDC *DC)
Function DrawBackGround.
Definition: draw_panel.cpp:694
classes and function to generate graphics to plt or draw titles blocks and frame references ...
void CopyPrmsFromGeneralToPanel()
void DrawWorkSheet(wxDC *aDC, BASE_SCREEN *aScreen, int aLineWidth, double aScale, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Function DrawWorkSheet Draws on screen the page layout with the frame and the basic inscriptions...
Definition: worksheet.cpp:76
Definition: colors.h:45
void SetShowPageLimits(bool aShow)
Definition: draw_frame.h:357
virtual void PrintPage(wxDC *aDC, LSET aPrintMasklayer, bool aPrintMirrorMode, void *aData) override
Virtual function PrintPage used to print a page.
void SetCrossHairPosition(const wxPoint &aPosition, bool aSnapToGrid=true)
Function SetCrossHairPosition sets the screen cross hair position to aPosition in logical (drawing) u...
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
Message panel definition file.
void EraseScreen(wxDC *DC)
Definition: draw_panel.cpp:574
Definition: colors.h:68
virtual void UpdateStatusBar()
Function UpdateStatusBar updates the status bar information.
Definition: draw_frame.cpp:724
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
void ReCreateHToolbar() override
wxChoice * m_originSelectBox
const wxString & GetCurrFileName() const
void Insert(WORKSHEET_DATAITEM *aItem, unsigned aIdx)
Insert an item to the list of items at position aIdx.
const wxString GetClassName() const
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...
WORKSHEET_DATAITEM * GetPageLayoutSelectedItem() const
DESIGN_TREE_FRAME * m_treePagelayout
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.