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) 2016 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, _("Create file"), wxEmptyString,
247  wxEmptyString, 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 static const wxChar designTreeWidthKey[] = wxT("DesignTreeWidth");
302 static const wxChar propertiesFrameWidthKey[] = wxT("PropertiesFrameWidth");
303 static const wxChar cornerOriginChoiceKey[] = wxT("CornerOriginChoice");
304 static const wxChar blackBgColorKey[] = wxT( "BlackBgColor" );
305 
306 void PL_EDITOR_FRAME::LoadSettings( wxConfigBase* aCfg )
307 {
309 
310  aCfg->Read( designTreeWidthKey, &m_designTreeWidth, 100);
313  bool tmp;
314  aCfg->Read( blackBgColorKey, &tmp, false );
315  SetDrawBgColor( tmp ? BLACK : WHITE );
316 }
317 
318 
319 void PL_EDITOR_FRAME::SaveSettings( wxConfigBase* aCfg )
320 {
322 
323  m_designTreeWidth = m_treePagelayout->GetSize().x;
325 
326  aCfg->Write( designTreeWidthKey, m_designTreeWidth);
329  aCfg->Write( blackBgColorKey, GetDrawBgColor() == BLACK );
330 
331  // was: wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
333 }
334 
335 
336 /*
337  * Function UpdateTitleAndInfo
338  * displays the filename (if exists) of the current page layout descr file.
339  */
341 {
342  wxString title;
343  wxString file = GetCurrFileName();
344 
345  title.Printf( _( "Page Layout Editor" ) + L" \u2014 %s",
346  !!file ? file : _( "no file selected" ) );
347  SetTitle( title );
348 }
349 
350 /* return the filename of the current layout descr file
351  */
352 const wxString& PL_EDITOR_FRAME::GetCurrFileName() const
353 {
355 }
356 
357 /* Stores the current layout descr file filename
358  */
359 void PL_EDITOR_FRAME::SetCurrFileName( const wxString& aName )
360 {
362 }
363 
364 void PL_EDITOR_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
365 {
366  m_pageLayout.SetPageSettings( aPageSettings );
367 
368  if( GetScreen() )
369  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
370 }
371 
372 
374 {
375  return m_pageLayout.GetPageSettings();
376 }
377 
378 
379 const wxSize PL_EDITOR_FRAME::GetPageSizeIU() const
380 {
381  // this function is only needed because EDA_DRAW_FRAME is not compiled
382  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
383  // into an application specific source file.
384  return m_pageLayout.GetPageSettings().GetSizeIU();
385 }
386 
387 
389 {
390  return GetPageLayout().GetTitleBlock();
391 }
392 
393 
394 void PL_EDITOR_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
395 {
396  m_pageLayout.SetTitleBlock( aTitleBlock );
397 }
398 
399 
400 /*
401  * Update the status bar information.
402  */
404 {
406 
407  if( !screen )
408  return;
409 
410  // Display Zoom level:
412 
413  // coodinate origin can be the paper Top Left corner,
414  // or each of 4 page corners
415  // We know the origin, and the orientation of axis
416  wxPoint originCoord;
417  int Xsign = 1;
418  int Ysign = 1;
419 
421 
422  switch( m_originSelectChoice )
423  {
424  default:
425  case 0: // Origin = paper Left Top corner
426  break;
427 
428  case 1: // Origin = page Right Bottom corner
429  Xsign = -1;
430  Ysign = -1;
431  dummy.SetStart( 0, 0, RB_CORNER );
432  originCoord = dummy.GetStartPosUi();
433  break;
434 
435  case 2: // Origin = page Left Bottom corner
436  Ysign = -1;
437  dummy.SetStart( 0, 0, LB_CORNER );
438  originCoord = dummy.GetStartPosUi();
439  break;
440 
441  case 3: // Origin = page Right Top corner
442  Xsign = -1;
443  dummy.SetStart( 0, 0, RT_CORNER );
444  originCoord = dummy.GetStartPosUi();
445  break;
446 
447  case 4: // Origin = page Left Top corner
448  dummy.SetStart( 0, 0, LT_CORNER );
449  originCoord = dummy.GetStartPosUi();
450  break;
451  }
452 
453  SetGridOrigin( originCoord );
454 
455  // Display absolute coordinates:
456  wxPoint coord = GetCrossHairPosition() - originCoord;
457  double dXpos = To_User_Unit( g_UserUnit, coord.x*Xsign );
458  double dYpos = To_User_Unit( g_UserUnit, coord.y*Ysign );
459 
460  wxString pagesizeformatter = _( "Page size: width %.4g height %.4g" );
461  wxString absformatter = wxT( "X %.4g Y %.4g" );
462  wxString locformatter = wxT( "dx %.4g dy %.4g" );
463 
464  switch( g_UserUnit )
465  {
466  case INCHES: // Should not be used in page layout editor
467  SetStatusText( _("inches"), 5 );
468  break;
469 
470  case MILLIMETRES:
471  SetStatusText( _("mm"), 5 );
472  break;
473 
474  case UNSCALED_UNITS:
475  SetStatusText( wxEmptyString, 5 );
476  break;
477 
478  case DEGREES:
479  wxASSERT( false );
480  break;
481  }
482 
483  wxString line;
484 
485  // Display page size
486  #define milsTomm (25.4/1000)
487  DSIZE size = GetPageSettings().GetSizeMils();
488  size = size * milsTomm;
489  line.Printf( pagesizeformatter, size.x, size.y );
490  SetStatusText( line, 0 );
491 
492  // Display abs coordinates
493  line.Printf( absformatter, dXpos, dYpos );
494  SetStatusText( line, 2 );
495 
496  // Display relative coordinates:
497  int dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
498  int dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
499  dXpos = To_User_Unit( g_UserUnit, dx * Xsign );
500  dYpos = To_User_Unit( g_UserUnit, dy * Ysign );
501  line.Printf( locformatter, dXpos, dYpos );
502  SetStatusText( line, 3 );
503 
504  // Display corner reference for coord origin
505  line.Printf( _("coord origin: %s"),
506  m_originSelectBox->GetString( m_originSelectChoice ). GetData() );
507  SetStatusText( line, 4 );
508 
509  // Display units
510 }
511 
512 void PL_EDITOR_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
513  bool aPrintMirrorMode, void * aData )
514 {
515  GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
516  DrawWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, wxEmptyString );
517 }
518 
519 void PL_EDITOR_FRAME::RedrawActiveWindow( wxDC* aDC, bool aEraseBg )
520 {
521 
522  GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
523 
524  if( aEraseBg )
525  m_canvas->EraseScreen( aDC );
526 
527  m_canvas->DrawBackGround( aDC );
528 
530  WORKSHEET_DATAITEM* selecteditem = GetSelectedItem();
531 
532  // the color to draw selected items
533  if( GetDrawBgColor() == WHITE )
535  else
537 
538  for( unsigned ii = 0; ; ii++ )
539  {
540  WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
541 
542  if( item == NULL )
543  break;
544 
545  item->SetSelected( item == selecteditem );
546  }
547 
548  DrawWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, GetCurrFileName() );
549 
550 #ifdef USE_WX_OVERLAY
551  if( IsShown() )
552  {
553  m_overlay.Reset();
554  wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)aDC );
555  overlaydc.Clear();
556  }
557 #endif
558 
559  if( m_canvas->IsMouseCaptured() )
560  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
561 
562  m_canvas->DrawCrossHair( aDC );
563 
564  // Display the filename
566 }
567 
569 {
571  int rectId = 0;
572  int lineId = 0;
573  int textId = 0;
574  int polyId = 0;
575  int bitmapId = 0;
576 
577  for( unsigned ii = 0; ii < pglayout.GetCount(); ii++ )
578  {
579  WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
580  switch( item->GetType() )
581  {
583  item->m_Name = wxString::Format( wxT("text%d:%s"), ++textId,
584  GetChars(item->GetClassName()) );
585  break;
586 
588  item->m_Name = wxString::Format( wxT("segm%d:%s"), ++lineId,
589  GetChars(item->GetClassName()) );
590  break;
591 
593  item->m_Name = wxString::Format( wxT("rect%d:%s"), ++rectId,
594  GetChars(item->GetClassName()) );
595  break;
596 
598  item->m_Name = wxString::Format( wxT("poly%d:%s"), ++polyId,
599  GetChars(item->GetClassName()) );
600  break;
601 
603  item->m_Name = wxString::Format( wxT("bm%d:%s"), ++bitmapId,
604  GetChars(item->GetClassName()) );
605  break;
606  }
607  }
608 
610 }
611 
612 /* Add a new item to the page layout item list.
613  * aType = WS_TEXT, WS_SEGMENT, WS_RECT, WS_POLYPOLYGON
614  */
616 {
617  WORKSHEET_DATAITEM * item = NULL;
618 
619  switch( aType )
620  {
622  item = new WORKSHEET_DATAITEM_TEXT( wxT("Text") );
623  break;
624 
627  break;
628 
631  break;
632 
634  item = new WORKSHEET_DATAITEM_POLYPOLYGON();
635  break;
636 
638  {
639  wxFileDialog fileDlg( this, _( "Choose Image" ), wxEmptyString, wxEmptyString,
640  _( "Image Files " ) + wxImage::GetImageExtWildcard(),
641  wxFD_OPEN );
642 
643  if( fileDlg.ShowModal() != wxID_OK )
644  return NULL;
645 
646  wxString fullFilename = fileDlg.GetPath();
647 
648  if( !wxFileExists( fullFilename ) )
649  {
650  wxMessageBox( _( "Couldn't load image from <%s>" ), GetChars( fullFilename ) );
651  break;
652  }
653  BITMAP_BASE* image = new BITMAP_BASE();
654 
655  if( !image->ReadImageFile( fullFilename ) )
656  {
657  wxMessageBox( _( "Couldn't load image from <%s>" ),
658  GetChars( fullFilename ) );
659  delete image;
660  break;
661  }
662  item = new WORKSHEET_DATAITEM_BITMAP( image );
663  }
664  break;
665  }
666 
667  if( item == NULL )
668  return NULL;
669 
671  pglayout.Insert( item, aIdx );
673 
674  return item;
675 }
676 
677 /* returns the current selected item, or NULL
678  */
680 {
682  return item;
683 }
684 
685 /* return the page layout item found at position aPosition
686  * aPosition = the position (in user units) of the reference point
687  */
689 {
690  const PAGE_INFO& pageInfo = GetPageSettings();
691  TITLE_BLOCK t_block = GetTitleBlock();
692  COLOR4D color = COLOR4D( RED ); // Needed, not used
694 
695  screen-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
696 
697  WS_DRAW_ITEM_LIST drawList;
698  drawList.SetPenSize( 0 );
699  drawList.SetMilsToIUfactor( IU_PER_MILS );
700  drawList.SetSheetNumber( screen->m_ScreenNumber );
701  drawList.SetSheetCount( screen->m_NumberOfScreens );
702  drawList.SetFileName( GetCurrFileName() );
703  // GetScreenDesc() returns a temporary string. Store it to avoid issues.
704  wxString descr = GetScreenDesc();
705  drawList.SetSheetName( descr );
706 
707  drawList.BuildWorkSheetGraphicList( pageInfo, t_block, color, color );
708 
709  // locate items.
710  // We do not use here the COLLECTOR classes in use in pcbnew and eeschema
711  // because the locate requirements are very basic.
712  std::vector <WS_DRAW_ITEM_BASE*> list;
713  drawList.Locate( list, aPosition );
714 
715  if( list.size() == 0 )
716  return NULL;
717 
718  WS_DRAW_ITEM_BASE* drawitem = list[0];
719 
720  // Choose item in list if more than 1 item
721  if( list.size() > 1 )
722  {
723  wxArrayString choices;
724  wxString text;
725  wxPoint cursPos = GetCrossHairPosition();
726 
727  for( unsigned ii = 0; ii < list.size(); ++ii )
728  {
729  drawitem = list[ii];
730  text = drawitem->GetParent()->m_Name;
731 
732  if( (drawitem->m_Flags & (LOCATE_STARTPOINT|LOCATE_ENDPOINT))
734  text << wxT(" ") << _("(start or end point)");
735  else
736  {
737  if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
738  text << wxT(" ") << _("(start point)");
739 
740  if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
741  text << wxT(" ") << _("(end point)");
742  }
743 
744  if( ! drawitem->GetParent()->m_Info.IsEmpty() )
745  text << wxT(" \"") << drawitem->GetParent()->m_Info << wxT("\"");
746 
747  choices.Add( text );
748  }
749  int selection = wxGetSingleChoiceIndex ( wxEmptyString,
750  _( "Selection Clarification" ),
751  choices, this );
752  if( selection < 0 )
753  return NULL;
754 
755  SetCrossHairPosition( cursPos );
757  drawitem = list[selection];
758  }
759 
760  WORKSHEET_DATAITEM* item = drawitem->GetParent();
762 
763  if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
764  item->SetFlags( LOCATE_STARTPOINT );
765 
766  if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
767  item->SetFlags( LOCATE_ENDPOINT );
768 
769  return item;
770 }
771 
772 /* Must be called to initialize parameters when a new page layout
773  * description is loaded
774  */
776 {
778  GetScreen()->ClrModify();
781  Zoom_Automatique( false );
782  m_canvas->Refresh();
783 }
784 
785 
787 {
789 }
EDA_PANEINFO & HorizontalToolbarPane()
Function HorizontalToolbarPane Change *this to a horizontal toolbar for KiCad.
Definition: wxstruct.h:474
#define DIM(x)
of elements in an array
Definition: macros.h:98
#define KICAD_DEFAULT_DRAWFRAME_STYLE
Definition: wxstruct.h:55
const 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:102
virtual const wxString GetZoomLevelIndicator() const
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
Definition: draw_frame.cpp:661
static const wxChar cornerOriginChoiceKey[]
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL) override
Definition: draw_panel.cpp:326
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:140
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:216
virtual void SetDrawBgColor(COLOR4D aColor)
Definition: draw_frame.h:291
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:361
wxAuiManager m_auimgr
Definition: wxstruct.h:139
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:53
void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Definition: draw_panel.cpp:348
EDA_PANEINFO & LayersToolbarPane()
Function LayersToolbarPane Change *this to a layers toolbar for KiCad.
Definition: wxstruct.h:526
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:716
Specialization of the wxAuiPaneInfo class for KiCad panels.
Definition: wxstruct.h:465
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:492
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:125
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:286
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:76
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:128
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:112
Definition: common.h:145
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:105
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:129
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:77
wxAuiToolBar * m_drawToolBar
The tool bar that contains the buttons for quick access to the application draw tools.
Definition: draw_frame.h:122
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
Definition: wxstruct.h:135
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:686
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:92
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:511
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:58
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:85
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:666
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:130
Definition: colors.h:45
void SetShowPageLimits(bool aShow)
Definition: draw_frame.h:297
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:554
#define LOCATE_ENDPOINT
Definition: colors.h:68
virtual void UpdateStatusBar()
Function UpdateStatusBar updates the status bar information.
Definition: draw_frame.cpp:650
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.