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 <class_pl_editor_screen.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  int dx, dy;
281  wxSize size;
282 
283  dx = GetPageLayout().GetPageSettings().GetWidthIU();
284  dy = GetPageLayout().GetPageSettings().GetHeightIU();
285 
286  size = m_canvas->GetClientSize();
287 
288  // Reserve no margin because best zoom shows the full page
289  // and margins are already included in function that draws the sheet refernces
290  double margin_scale_factor = 1.0;
291  double zx =(double) dx / ( margin_scale_factor * (double)size.x );
292  double zy = (double) dy / ( margin_scale_factor * (double)size.y );
293 
294  double bestzoom = std::max( zx, zy );
295 
296  SetScrollCenterPosition( wxPoint( dx / 2, dy / 2 ) );
297 
298  return bestzoom;
299 }
300 
301 
302 static const wxChar designTreeWidthKey[] = wxT( "DesignTreeWidth" );
303 static const wxChar propertiesFrameWidthKey[] = wxT( "PropertiesFrameWidth" );
304 static const wxChar cornerOriginChoiceKey[] = wxT( "CornerOriginChoice" );
305 static const wxChar blackBgColorKey[] = wxT( "BlackBgColor" );
306 
307 
308 void PL_EDITOR_FRAME::LoadSettings( wxConfigBase* aCfg )
309 {
311 
312  aCfg->Read( designTreeWidthKey, &m_designTreeWidth, 100);
315  bool tmp;
316  aCfg->Read( blackBgColorKey, &tmp, false );
317  SetDrawBgColor( tmp ? BLACK : WHITE );
318 }
319 
320 
321 void PL_EDITOR_FRAME::SaveSettings( wxConfigBase* aCfg )
322 {
324 
325  m_designTreeWidth = m_treePagelayout->GetSize().x;
327 
328  aCfg->Write( designTreeWidthKey, m_designTreeWidth);
331  aCfg->Write( blackBgColorKey, GetDrawBgColor() == BLACK );
332 
333  // was: wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
335 }
336 
337 
339 {
340  wxString title;
341  wxString file = GetCurrFileName();
342 
343  title.Printf( _( "Page Layout Editor" ) + L" \u2014 %s",
344  !!file ? file : _( "no file selected" ) );
345  SetTitle( title );
346 }
347 
348 
349 const wxString& PL_EDITOR_FRAME::GetCurrFileName() const
350 {
352 }
353 
354 
355 void PL_EDITOR_FRAME::SetCurrFileName( const wxString& aName )
356 {
358 }
359 
360 
361 void PL_EDITOR_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
362 {
363  m_pageLayout.SetPageSettings( aPageSettings );
364 
365  if( GetScreen() )
366  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
367 }
368 
369 
371 {
372  return m_pageLayout.GetPageSettings();
373 }
374 
375 
376 const wxSize PL_EDITOR_FRAME::GetPageSizeIU() const
377 {
378  // this function is only needed because EDA_DRAW_FRAME is not compiled
379  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
380  // into an application specific source file.
381  return m_pageLayout.GetPageSettings().GetSizeIU();
382 }
383 
384 
386 {
387  return GetPageLayout().GetTitleBlock();
388 }
389 
390 
391 void PL_EDITOR_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
392 {
393  m_pageLayout.SetTitleBlock( aTitleBlock );
394 }
395 
396 
398 {
400 
401  if( !screen )
402  return;
403 
404  // Display Zoom level:
406 
407  // coodinate origin can be the paper Top Left corner,
408  // or each of 4 page corners
409  // We know the origin, and the orientation of axis
410  wxPoint originCoord;
411  int Xsign = 1;
412  int Ysign = 1;
413 
415 
416  switch( m_originSelectChoice )
417  {
418  default:
419  case 0: // Origin = paper Left Top corner
420  break;
421 
422  case 1: // Origin = page Right Bottom corner
423  Xsign = -1;
424  Ysign = -1;
425  dummy.SetStart( 0, 0, RB_CORNER );
426  originCoord = dummy.GetStartPosUi();
427  break;
428 
429  case 2: // Origin = page Left Bottom corner
430  Ysign = -1;
431  dummy.SetStart( 0, 0, LB_CORNER );
432  originCoord = dummy.GetStartPosUi();
433  break;
434 
435  case 3: // Origin = page Right Top corner
436  Xsign = -1;
437  dummy.SetStart( 0, 0, RT_CORNER );
438  originCoord = dummy.GetStartPosUi();
439  break;
440 
441  case 4: // Origin = page Left Top corner
442  dummy.SetStart( 0, 0, LT_CORNER );
443  originCoord = dummy.GetStartPosUi();
444  break;
445  }
446 
447  SetGridOrigin( originCoord );
448 
449  // Display absolute coordinates:
450  wxPoint coord = GetCrossHairPosition() - originCoord;
451  double dXpos = To_User_Unit( g_UserUnit, coord.x*Xsign );
452  double dYpos = To_User_Unit( g_UserUnit, coord.y*Ysign );
453 
454  wxString pagesizeformatter = _( "Page size: width %.4g height %.4g" );
455  wxString absformatter = wxT( "X %.4g Y %.4g" );
456  wxString locformatter = wxT( "dx %.4g dy %.4g" );
457 
458  switch( g_UserUnit )
459  {
460  case INCHES: // Should not be used in page layout editor
461  SetStatusText( _("inches"), 5 );
462  break;
463 
464  case MILLIMETRES:
465  SetStatusText( _("mm"), 5 );
466  break;
467 
468  case UNSCALED_UNITS:
469  SetStatusText( wxEmptyString, 5 );
470  break;
471 
472  case DEGREES:
473  wxASSERT( false );
474  break;
475  }
476 
477  wxString line;
478 
479  // Display page size
480  #define milsTomm (25.4/1000)
481  DSIZE size = GetPageSettings().GetSizeMils();
482  size = size * milsTomm;
483  line.Printf( pagesizeformatter, size.x, size.y );
484  SetStatusText( line, 0 );
485 
486  // Display abs coordinates
487  line.Printf( absformatter, dXpos, dYpos );
488  SetStatusText( line, 2 );
489 
490  // Display relative coordinates:
491  int dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
492  int dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
493  dXpos = To_User_Unit( g_UserUnit, dx * Xsign );
494  dYpos = To_User_Unit( g_UserUnit, dy * Ysign );
495  line.Printf( locformatter, dXpos, dYpos );
496  SetStatusText( line, 3 );
497 
498  // Display corner reference for coord origin
499  line.Printf( _("coord origin: %s"),
500  m_originSelectBox->GetString( m_originSelectChoice ). GetData() );
501  SetStatusText( line, 4 );
502 
503  // Display units
504 }
505 
506 
507 void PL_EDITOR_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
508  bool aPrintMirrorMode, void * aData )
509 {
510  GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
511  DrawWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, wxEmptyString );
512 }
513 
514 
515 void PL_EDITOR_FRAME::RedrawActiveWindow( wxDC* aDC, bool aEraseBg )
516 {
517 
518  GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
519 
520  if( aEraseBg )
521  m_canvas->EraseScreen( aDC );
522 
523  m_canvas->DrawBackGround( aDC );
524 
526  WORKSHEET_DATAITEM* selecteditem = GetSelectedItem();
527 
528  // the color to draw selected items
529  if( GetDrawBgColor() == WHITE )
531  else
533 
534  for( unsigned ii = 0; ; ii++ )
535  {
536  WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
537 
538  if( item == NULL )
539  break;
540 
541  item->SetSelected( item == selecteditem );
542  }
543 
544  DrawWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, GetCurrFileName() );
545 
546 #ifdef USE_WX_OVERLAY
547  if( IsShown() )
548  {
549  m_overlay.Reset();
550  wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)aDC );
551  overlaydc.Clear();
552  }
553 #endif
554 
555  if( m_canvas->IsMouseCaptured() )
556  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
557 
558  m_canvas->DrawCrossHair( aDC );
559 
560  // Display the filename
562 }
563 
564 
566 {
568  int rectId = 0;
569  int lineId = 0;
570  int textId = 0;
571  int polyId = 0;
572  int bitmapId = 0;
573 
574  for( unsigned ii = 0; ii < pglayout.GetCount(); ii++ )
575  {
576  WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
577  switch( item->GetType() )
578  {
580  item->m_Name = wxString::Format( wxT( "text%d:%s" ), ++textId,
581  GetChars(item->GetClassName()) );
582  break;
583 
585  item->m_Name = wxString::Format( wxT( "segm%d:%s" ), ++lineId,
586  GetChars(item->GetClassName()) );
587  break;
588 
590  item->m_Name = wxString::Format( wxT( "rect%d:%s" ), ++rectId,
591  GetChars(item->GetClassName()) );
592  break;
593 
595  item->m_Name = wxString::Format( wxT( "poly%d:%s" ), ++polyId,
596  GetChars(item->GetClassName()) );
597  break;
598 
600  item->m_Name = wxString::Format( wxT( "bm%d:%s" ), ++bitmapId,
601  GetChars(item->GetClassName()) );
602  break;
603  }
604  }
605 
607 }
608 
609 
611 {
612  WORKSHEET_DATAITEM * item = NULL;
613 
614  switch( aType )
615  {
617  item = new WORKSHEET_DATAITEM_TEXT( wxT( "Text") );
618  break;
619 
622  break;
623 
626  break;
627 
629  item = new WORKSHEET_DATAITEM_POLYPOLYGON();
630  break;
631 
633  {
634  wxFileDialog fileDlg( this, _( "Choose Image" ), wxEmptyString, wxEmptyString,
635  _( "Image Files " ) + wxImage::GetImageExtWildcard(),
636  wxFD_OPEN );
637 
638  if( fileDlg.ShowModal() != wxID_OK )
639  return NULL;
640 
641  wxString fullFilename = fileDlg.GetPath();
642 
643  if( !wxFileExists( fullFilename ) )
644  {
645  wxMessageBox( _( "Couldn't load image from <%s>" ), GetChars( fullFilename ) );
646  break;
647  }
648 
649  BITMAP_BASE* image = new BITMAP_BASE();
650 
651  if( !image->ReadImageFile( fullFilename ) )
652  {
653  wxMessageBox( _( "Couldn't load image from <%s>" ),
654  GetChars( fullFilename ) );
655  delete image;
656  break;
657  }
658 
659  item = new WORKSHEET_DATAITEM_BITMAP( image );
660  }
661  break;
662  }
663 
664  if( item == NULL )
665  return NULL;
666 
668  pglayout.Insert( item, aIdx );
670 
671  return item;
672 }
673 
674 
676 {
678  return item;
679 }
680 
681 
683 {
684  const PAGE_INFO& pageInfo = GetPageSettings();
685  TITLE_BLOCK t_block = GetTitleBlock();
686  COLOR4D color = COLOR4D( RED ); // Needed, not used
688 
689  screen-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
690 
691  WS_DRAW_ITEM_LIST drawList;
692  drawList.SetPenSize( 0 );
693  drawList.SetMilsToIUfactor( IU_PER_MILS );
694  drawList.SetSheetNumber( screen->m_ScreenNumber );
695  drawList.SetSheetCount( screen->m_NumberOfScreens );
696  drawList.SetFileName( GetCurrFileName() );
697  // GetScreenDesc() returns a temporary string. Store it to avoid issues.
698  wxString descr = GetScreenDesc();
699  drawList.SetSheetName( descr );
700 
701  drawList.BuildWorkSheetGraphicList( pageInfo, t_block, color, color );
702 
703  // locate items.
704  // We do not use here the COLLECTOR classes in use in pcbnew and eeschema
705  // because the locate requirements are very basic.
706  std::vector <WS_DRAW_ITEM_BASE*> list;
707  drawList.Locate( list, aPosition );
708 
709  if( list.size() == 0 )
710  return NULL;
711 
712  WS_DRAW_ITEM_BASE* drawitem = list[0];
713 
714  // Choose item in list if more than 1 item
715  if( list.size() > 1 )
716  {
717  wxArrayString choices;
718  wxString text;
719  wxPoint cursPos = GetCrossHairPosition();
720 
721  for( unsigned ii = 0; ii < list.size(); ++ii )
722  {
723  drawitem = list[ii];
724  text = drawitem->GetParent()->m_Name;
725 
726  if( (drawitem->m_Flags & (LOCATE_STARTPOINT|LOCATE_ENDPOINT))
728  text << wxT( " " ) << _( "(start or end point)" );
729  else
730  {
731  if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
732  text << wxT( " " ) << _( "(start point)" );
733 
734  if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
735  text << wxT( " " ) << _( "(end point)" );
736  }
737 
738  if( ! drawitem->GetParent()->m_Info.IsEmpty() )
739  text << wxT( " \"" ) << drawitem->GetParent()->m_Info << wxT( "\"" );
740 
741  choices.Add( text );
742  }
743 
744  int selection = wxGetSingleChoiceIndex ( wxEmptyString,
745  _( "Selection Clarification" ),
746  choices, this );
747  if( selection < 0 )
748  return NULL;
749 
750  SetCrossHairPosition( cursPos );
752  drawitem = list[selection];
753  }
754 
755  WORKSHEET_DATAITEM* item = drawitem->GetParent();
757 
758  if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
759  item->SetFlags( LOCATE_STARTPOINT );
760 
761  if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
762  item->SetFlags( LOCATE_ENDPOINT );
763 
764  return item;
765 }
766 
767 
769 {
771  GetScreen()->ClrModify();
774  Zoom_Automatique( false );
775  m_canvas->Refresh();
776 }
777 
778 
780 {
782 }
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:487
#define DIM(x)
of elements in an array
Definition: macros.h:98
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Definition: wxstruct.h:55
wxString PageLayoutDescrFileWildcard()
PARAM_CFG_ARRAY m_configSettings
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:103
virtual const wxString GetZoomLevelIndicator() const
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Definition: draw_frame.cpp:691
static const wxChar cornerOriginChoiceKey[]
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
Definition: draw_panel.cpp:325
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
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:141
void ReCreateMenuBar() override
Function ReCreateMenuBar Creates recreates the menu bar.
Class PROPERTIES_FRAME display properties of the current item.
void SetScrollCenterPosition(const wxPoint &aPoint)
void UpdateStatusBar() override
Function UpdateStatusBar updates the status bar information.
void DrawCrossHair(wxDC *aDC, COLOR4D aColor=COLOR4D::WHITE)
Function DrawCrossHair draws the user cross hair.
Definition: draw_panel.cpp:215
virtual void SetDrawBgColor(COLOR4D aColor)
Definition: draw_frame.h:329
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
void OnCloseWindow(wxCloseEvent &Event)
description of graphic items and texts to build a title block
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
Definition: basicframe.cpp:380
wxAuiManager m_auimgr
Definition: wxstruct.h:149
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:54
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:347
EDA_PANEINFO & LayersToolbarPane()
Function LayersToolbarPane Change *this to a layers toolbar for KiCad.
Definition: wxstruct.h:539
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot, printout, or editing view.
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.
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:746
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:478
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
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)
Function GetTextSize returns the size of aSingleLine of text when it is rendered in aWindow using wha...
Definition: common.cpp:93
const wxSize & GetSizeMils() const
This class handle bitmap images in KiCad.
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
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:36
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:77
EDA_PANEINFO & VerticalToolbarPane()
Function VerticalToolbarPane Change *this to a vertical toolbar for KiCad.
Definition: wxstruct.h:505
void RedrawActiveWindow(wxDC *DC, bool EraseBg) override
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:126
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:324
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:77
WORKSHEET_DATAITEM * GetItem(unsigned aIdx) const
virtual wxString GetScreenDesc() const
Definition: worksheet.cpp:120
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:129
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
bool m_showBorderAndTitleBlock
True shows the drawing border and title block.
Definition: draw_frame.h:113
Definition: common.h:144
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.
bool m_showGridAxis
True shows the grid axis indicators.
Definition: draw_frame.h:106
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:257
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
wxPoint m_FramePos
Definition: wxstruct.h:139
static const wxChar blackBgColorKey[]
PL_EDITOR_LAYOUT m_pageLayout
const PAGE_INFO & GetPageSettings() const
#define PL_EDITOR_FRAME_NAME
Class PL_EDITOR_FRAME is the main window used in the page layout editor.
int m_LastGridSizeId
Definition: draw_frame.h:78
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:123
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:145
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:716
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:56
#define LOCATE_STARTPOINT
static const wxChar designTreeWidthKey[]
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:93
void SetPageSettings(const PAGE_INFO &aPageSettings)
bool GetPageNumberOption() const
Page layout editor can show the title block using a page number 1 or an other number.
EDA_PANEINFO & MessageToolbarPane()
Function MessageToolbarPane Change *this to a message pane for KiCad.
Definition: wxstruct.h:524
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:61
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:86
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...
#define max(a, b)
Definition: auxiliary.h:86
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.
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...
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:90
bool ReadImageFile(const wxString &aFullFilename)
Function ReadImageFile Reads and stores in memory an image file.
void DrawBackGround(wxDC *DC)
Function DrawBackGround.
Definition: draw_panel.cpp:665
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:77
wxSize m_FrameSize
Definition: wxstruct.h:140
Definition: colors.h:45
void SetShowPageLimits(bool aShow)
Definition: draw_frame.h:335
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:553
#define LOCATE_ENDPOINT
Definition: colors.h:68
virtual void UpdateStatusBar()
Function UpdateStatusBar updates the status bar information.
Definition: draw_frame.cpp:680
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.