KiCad PCB EDA Suite
pl_editor_frame.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2013 CERN
5  * Copyright (C) 2017-2019 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Jean-Pierre Charras, jp.charras at wanadoo.fr
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
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 #include <eda_dockart.h>
39 
40 #include <pl_editor_frame.h>
41 #include <pl_editor_id.h>
42 #include <hotkeys.h>
43 #include <pl_editor_screen.h>
45 #include <worksheet_dataitem.h>
46 #include <design_tree_frame.h>
47 #include <properties_frame.h>
48 
50 #include <confirm.h>
51 
52 
53 PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
54  EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ),
55  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME )
56 {
58  m_zoomLevelCoeff = 290.0; // Adjusted to roughly displays zoom level = 1
59  // when the screen shows a 1:1 image
60  // obviously depends on the monitor,
61  // but this is an acceptable value
62 
63  m_showAxis = false; // true to show X and Y axis on screen
64  m_showGridAxis = true;
65  m_showBorderAndTitleBlock = true; // true for reference drawings.
68  SetDrawBgColor( WHITE ); // default value, user option (WHITE/BLACK)
69  SetShowPageLimits( true );
70  m_AboutTitle = "PlEditor";
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 
92 
95 
96  wxWindow* stsbar = GetStatusBar();
97  int dims[] = {
98 
99  // balance of status bar on far left is set to a default or whatever is left over.
100  -1,
101 
102  // When using GetTextSize() remember the width of '1' is not the same
103  // as the width of '0' unless the font is fixed width, and it usually won't be.
104 
105  // zoom:
106  GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
107 
108  // cursor coords
109  GetTextSize( wxT( "X 0234.567 Y 0234.567" ), stsbar ).x + 10,
110 
111  // delta distances
112  GetTextSize( wxT( "dx 0234.567 dx 0234.567" ), stsbar ).x + 10,
113 
114  // Coord origin (use the bigger message)
115  GetTextSize( _( "coord origin: Right Bottom page corner" ), stsbar ).x + 10,
116 
117  // units display, Inches is bigger than mm
118  GetTextSize( _( "Inches" ), stsbar ).x + 10
119  };
120 
121  SetStatusWidths( arrayDim( dims ), dims );
122 
123  m_auimgr.SetManagedWindow( this );
124  m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
125 
127  m_treePagelayout = new DESIGN_TREE_FRAME( this );
128 
129  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
130  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
131 
132  m_auimgr.AddPane( m_treePagelayout, EDA_PANE().Palette().Name( "Design" ).Left().Layer(1)
133  .Caption( _( "Design" ) ).MinSize( m_treePagelayout->GetMinSize() )
134  .BestSize( m_designTreeWidth, -1 ) );
135  m_auimgr.AddPane( m_propertiesPagelayout, EDA_PANE().Palette().Name( "Props" ).Right().Layer(1)
136  .Caption( _( "Properties" ) ).MinSize( m_propertiesPagelayout->GetMinSize() )
137  .BestSize( m_propertiesFrameWidth, -1 ) );
138 
139  m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
140 
141  m_auimgr.Update();
142 
143  // Initialize the current page layout
145 #if 0 //start with empty layout
146  pglayout.AllowVoidList( true );
147  pglayout.ClearList();
148 #else // start with the default Kicad layout
149  pglayout.SetPageLayout();
150 #endif
151  OnNewPageLayout();
152 }
153 
154 
156 {
157 }
158 
159 
160 bool PL_EDITOR_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
161 {
162  wxString fn = aFileSet[0];
163 
164  if( !LoadPageLayoutDescrFile( fn ) )
165  {
166  wxString msg = wxString::Format(
167  _( "Error when loading file \"%s\"" ),
168  GetChars( fn )
169  );
170 
171  wxMessageBox( msg );
172  return false;
173  }
174  else
175  {
176  OnNewPageLayout();
177  return true;
178  }
179 }
180 
181 
182 void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& Event )
183 {
184  if( GetScreen()->IsModify() )
185  {
186  if( !HandleUnsavedChanges( this,
187  _( "The current page layout has been modified. Save changes?" ),
188  [&]()->bool { return saveCurrentPageLayout(); } ) )
189  {
190  Event.Veto();
191  return;
192  }
193  }
194 
195  // do not show the window because we do not want any paint event
196  Show( false );
197 
198  // was: Pgm().SaveCurrentSetupValues( m_configSettings );
199  wxConfigSaveSetups( Kiface().KifaceSettings(), m_configSettings );
200 
201  // On Linux, m_propertiesPagelayout must be destroyed
202  // before deleting the main frame to avoid a crash when closing
203  m_propertiesPagelayout->Destroy();
204  Destroy();
205 }
206 
207 
209 {
210  double sizeX = (double) GetPageLayout().GetPageSettings().GetWidthIU();
211  double sizeY = (double) GetPageLayout().GetPageSettings().GetHeightIU();
212  wxPoint centre( sizeX / 2, sizeY / 2 );
213 
214  // The sheet boundary already affords us some margin, so add only an
215  // additional 5%.
216  double margin_scale_factor = 1.05;
217 
218  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
219 }
220 
221 
222 static const wxChar designTreeWidthKey[] = wxT( "DesignTreeWidth" );
223 static const wxChar propertiesFrameWidthKey[] = wxT( "PropertiesFrameWidth" );
224 static const wxChar cornerOriginChoiceKey[] = wxT( "CornerOriginChoice" );
225 static const wxChar blackBgColorKey[] = wxT( "BlackBgColor" );
226 
227 
228 void PL_EDITOR_FRAME::LoadSettings( wxConfigBase* aCfg )
229 {
231 
232  aCfg->Read( designTreeWidthKey, &m_designTreeWidth, 100);
235  bool tmp;
236  aCfg->Read( blackBgColorKey, &tmp, false );
237  SetDrawBgColor( tmp ? BLACK : WHITE );
238 }
239 
240 
241 void PL_EDITOR_FRAME::SaveSettings( wxConfigBase* aCfg )
242 {
244 
245  m_designTreeWidth = m_treePagelayout->GetSize().x;
247 
248  aCfg->Write( designTreeWidthKey, m_designTreeWidth);
251  aCfg->Write( blackBgColorKey, GetDrawBgColor() == BLACK );
252 
253  // was: wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
255 }
256 
257 
259 {
260  wxString title;
261  wxString file = GetCurrFileName();
262 
263  title.Printf( _( "Page Layout Editor" ) + wxT( " \u2014 %s" ),
264  file.Length() ? file : _( "no file selected" ) );
265  SetTitle( title );
266 }
267 
268 
269 const wxString& PL_EDITOR_FRAME::GetCurrFileName() const
270 {
272 }
273 
274 
275 void PL_EDITOR_FRAME::SetCurrFileName( const wxString& aName )
276 {
278 }
279 
280 
281 void PL_EDITOR_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
282 {
283  m_pageLayout.SetPageSettings( aPageSettings );
284 
285  if( GetScreen() )
286  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
287 }
288 
289 
291 {
292  return m_pageLayout.GetPageSettings();
293 }
294 
295 
296 const wxSize PL_EDITOR_FRAME::GetPageSizeIU() const
297 {
298  // this function is only needed because EDA_DRAW_FRAME is not compiled
299  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
300  // into an application specific source file.
301  return m_pageLayout.GetPageSettings().GetSizeIU();
302 }
303 
304 
306 {
307  return GetPageLayout().GetTitleBlock();
308 }
309 
310 
311 void PL_EDITOR_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
312 {
313  m_pageLayout.SetTitleBlock( aTitleBlock );
314 }
315 
316 
318 {
320 
321  if( !screen )
322  return;
323 
324  // Display Zoom level:
326 
327  // coordinate origin can be the paper Top Left corner,
328  // or each of 4 page corners
329  // We know the origin, and the orientation of axis
330  wxPoint originCoord;
331  int Xsign = 1;
332  int Ysign = 1;
333 
335 
336  switch( m_originSelectChoice )
337  {
338  default:
339  case 0: // Origin = paper Left Top corner
340  break;
341 
342  case 1: // Origin = page Right Bottom corner
343  Xsign = -1;
344  Ysign = -1;
345  dummy.SetStart( 0, 0, RB_CORNER );
346  originCoord = dummy.GetStartPosUi();
347  break;
348 
349  case 2: // Origin = page Left Bottom corner
350  Ysign = -1;
351  dummy.SetStart( 0, 0, LB_CORNER );
352  originCoord = dummy.GetStartPosUi();
353  break;
354 
355  case 3: // Origin = page Right Top corner
356  Xsign = -1;
357  dummy.SetStart( 0, 0, RT_CORNER );
358  originCoord = dummy.GetStartPosUi();
359  break;
360 
361  case 4: // Origin = page Left Top corner
362  dummy.SetStart( 0, 0, LT_CORNER );
363  originCoord = dummy.GetStartPosUi();
364  break;
365  }
366 
367  SetGridOrigin( originCoord );
368 
369  // Display absolute coordinates:
370  wxPoint coord = GetCrossHairPosition() - originCoord;
371  double dXpos = To_User_Unit( GetUserUnits(), coord.x*Xsign );
372  double dYpos = To_User_Unit( GetUserUnits(), coord.y*Ysign );
373 
374  wxString pagesizeformatter = _( "Page size: width %.4g height %.4g" );
375  wxString absformatter = wxT( "X %.4g Y %.4g" );
376  wxString locformatter = wxT( "dx %.4g dy %.4g" );
377 
378  switch( GetUserUnits() )
379  {
380  case INCHES: // Should not be used in page layout editor
381  SetStatusText( _("inches"), 5 );
382  break;
383 
384  case MILLIMETRES:
385  SetStatusText( _("mm"), 5 );
386  break;
387 
388  case UNSCALED_UNITS:
389  SetStatusText( wxEmptyString, 5 );
390  break;
391 
392  case DEGREES:
393  wxASSERT( false );
394  break;
395  }
396 
397  wxString line;
398 
399  // Display page size
400  #define milsTomm (25.4/1000)
401  DSIZE size = GetPageSettings().GetSizeMils();
402  size = size * milsTomm;
403  line.Printf( pagesizeformatter, size.x, size.y );
404  SetStatusText( line, 0 );
405 
406  // Display abs coordinates
407  line.Printf( absformatter, dXpos, dYpos );
408  SetStatusText( line, 2 );
409 
410  // Display relative coordinates:
411  int dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
412  int dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
413  dXpos = To_User_Unit( GetUserUnits(), dx * Xsign );
414  dYpos = To_User_Unit( GetUserUnits(), dy * Ysign );
415  line.Printf( locformatter, dXpos, dYpos );
416  SetStatusText( line, 3 );
417 
418  // Display corner reference for coord origin
419  line.Printf( _("coord origin: %s"),
420  m_originSelectBox->GetString( m_originSelectChoice ). GetData() );
421  SetStatusText( line, 4 );
422 
423  // Display units
424 }
425 
426 
427 void PL_EDITOR_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
428  bool aPrintMirrorMode, void * aData )
429 {
430  GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
431  DrawWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, wxEmptyString );
432 }
433 
434 
435 void PL_EDITOR_FRAME::RedrawActiveWindow( wxDC* aDC, bool aEraseBg )
436 {
437 
438  GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
439 
440  if( aEraseBg )
441  m_canvas->EraseScreen( aDC );
442 
443  m_canvas->DrawBackGround( aDC );
444 
446  WORKSHEET_DATAITEM* selecteditem = GetSelectedItem();
447 
448  // the color to draw selected items
449  if( GetDrawBgColor() == WHITE )
451  else
453 
454  for( unsigned ii = 0; ; ii++ )
455  {
456  WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
457 
458  if( item == NULL )
459  break;
460 
461  item->SetSelected( item == selecteditem );
462  }
463 
465 
466 #ifdef USE_WX_OVERLAY
467  if( IsShown() )
468  {
469  m_overlay.Reset();
470  wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)aDC );
471  overlaydc.Clear();
472  }
473 #endif
474 
475  if( m_canvas->IsMouseCaptured() )
476  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
477 
478  m_canvas->DrawCrossHair( aDC );
479 
480  // Display the filename
482 }
483 
484 
486 {
488  int rectId = 0;
489  int lineId = 0;
490  int textId = 0;
491  int polyId = 0;
492  int bitmapId = 0;
493 
494  for( unsigned ii = 0; ii < pglayout.GetCount(); ii++ )
495  {
496  WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
497  switch( item->GetType() )
498  {
500  item->m_Name = wxString::Format( wxT( "text%d:%s" ), ++textId,
501  GetChars(item->GetClassName()) );
502  break;
503 
505  item->m_Name = wxString::Format( wxT( "segm%d:%s" ), ++lineId,
506  GetChars(item->GetClassName()) );
507  break;
508 
510  item->m_Name = wxString::Format( wxT( "rect%d:%s" ), ++rectId,
511  GetChars(item->GetClassName()) );
512  break;
513 
515  item->m_Name = wxString::Format( wxT( "poly%d:%s" ), ++polyId,
516  GetChars(item->GetClassName()) );
517  break;
518 
520  item->m_Name = wxString::Format( wxT( "bm%d:%s" ), ++bitmapId,
521  GetChars(item->GetClassName()) );
522  break;
523  }
524  }
525 
527 }
528 
529 
531 {
532  WORKSHEET_DATAITEM * item = NULL;
533 
534  switch( aType )
535  {
537  item = new WORKSHEET_DATAITEM_TEXT( wxT( "Text") );
538  break;
539 
542  break;
543 
546  break;
547 
549  item = new WORKSHEET_DATAITEM_POLYPOLYGON();
550  break;
551 
553  {
554  wxFileDialog fileDlg( this, _( "Choose Image" ), wxEmptyString, wxEmptyString,
555  _( "Image Files " ) + wxImage::GetImageExtWildcard(),
556  wxFD_OPEN );
557 
558  if( fileDlg.ShowModal() != wxID_OK )
559  return NULL;
560 
561  wxString fullFilename = fileDlg.GetPath();
562 
563  if( !wxFileExists( fullFilename ) )
564  {
565  wxMessageBox( _( "Couldn't load image from \"%s\"" ), GetChars( fullFilename ) );
566  break;
567  }
568 
569  BITMAP_BASE* image = new BITMAP_BASE();
570 
571  if( !image->ReadImageFile( fullFilename ) )
572  {
573  wxMessageBox( _( "Couldn't load image from \"%s\"" ),
574  GetChars( fullFilename ) );
575  delete image;
576  break;
577  }
578 
579  item = new WORKSHEET_DATAITEM_BITMAP( image );
580  }
581  break;
582  }
583 
584  if( item == NULL )
585  return NULL;
586 
588  pglayout.Insert( item, aIdx );
590 
591  return item;
592 }
593 
594 
596 {
598  return item;
599 }
600 
601 
602 WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( wxDC* aDC, const wxPoint& aPosition )
603 {
604  const PAGE_INFO& pageInfo = GetPageSettings();
605  TITLE_BLOCK t_block = GetTitleBlock();
606  COLOR4D color = COLOR4D( RED ); // Needed, not used
608 
609  screen-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
610 
611  WS_DRAW_ITEM_LIST drawList;
612  drawList.SetPenSize( 0 );
613  drawList.SetMilsToIUfactor( IU_PER_MILS );
614  drawList.SetSheetNumber( screen->m_ScreenNumber );
615  drawList.SetSheetCount( screen->m_NumberOfScreens );
616  drawList.SetFileName( GetCurrFileName() );
617  // GetScreenDesc() returns a temporary string. Store it to avoid issues.
618  wxString descr = GetScreenDesc();
619  drawList.SetSheetName( descr );
620 
621  drawList.BuildWorkSheetGraphicList( pageInfo, t_block, color, color );
622 
623  // locate items.
624  // We do not use here the COLLECTOR classes in use in pcbnew and eeschema
625  // because the locate requirements are very basic.
626  std::vector <WS_DRAW_ITEM_BASE*> list;
627  drawList.Locate( aDC, list, aPosition );
628 
629  if( list.size() == 0 )
630  return NULL;
631 
632  WS_DRAW_ITEM_BASE* drawitem = list[0];
633 
634  // Choose item in list if more than 1 item
635  if( list.size() > 1 )
636  {
637  wxArrayString choices;
638  wxString text;
639  wxPoint cursPos = GetCrossHairPosition();
640 
641  for( unsigned ii = 0; ii < list.size(); ++ii )
642  {
643  drawitem = list[ii];
644  text = drawitem->GetParent()->m_Name;
645 
646  if( (drawitem->m_Flags & (LOCATE_STARTPOINT|LOCATE_ENDPOINT))
648  text << wxT( " " ) << _( "(start or end point)" );
649  else
650  {
651  if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
652  text << wxT( " " ) << _( "(start point)" );
653 
654  if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
655  text << wxT( " " ) << _( "(end point)" );
656  }
657 
658  if( ! drawitem->GetParent()->m_Info.IsEmpty() )
659  text << wxT( " \"" ) << drawitem->GetParent()->m_Info << wxT( "\"" );
660 
661  choices.Add( text );
662  }
663 
664  int selection = wxGetSingleChoiceIndex ( wxEmptyString,
665  _( "Selection Clarification" ),
666  choices, this );
667  if( selection < 0 )
668  return NULL;
669 
670  SetCrossHairPosition( cursPos );
672  drawitem = list[selection];
673  }
674 
675  WORKSHEET_DATAITEM* item = drawitem->GetParent();
677 
678  if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
679  item->SetFlags( LOCATE_STARTPOINT );
680 
681  if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
682  item->SetFlags( LOCATE_ENDPOINT );
683 
684  return item;
685 }
686 
687 
689 {
691  GetScreen()->ClrModify();
694  Zoom_Automatique( false );
695  m_canvas->Refresh();
696 }
697 
698 
700 {
702 }
static COLOR4D m_SelectedColor
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Function HandleUnsavedChanges displays a dialog with Save, Cancel and Discard Changes buttons.
Definition: confirm.cpp:212
unsigned GetCount() const
PARAM_CFG_ARRAY m_configSettings
int m_ScreenNumber
Definition: base_screen.h:216
void AllowVoidList(bool Allow)
In Kicad applications, a page layout description is needed So if the list is empty,...
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:138
static const wxChar cornerOriginChoiceKey[]
Implementation of conversion functions that require both schematic and board internal units.
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
This file is part of the common library.
WS_ItemType GetType() const
const wxString & GetCurrFileName() const
virtual void SetScreen(BASE_SCREEN *aScreen)
Definition: draw_frame.h:184
double bestZoom(double sizeX, double sizeY, double scaleFactor, wxPoint centre)
WORKSHEET_DATAITEM * AddPageLayoutItem(int aType, int aIdx=-1)
Function AddPageLayoutItem Add a new item to the page layout item list.
void ReCreateMenuBar() override
Recreates the menu bar.
Class PROPERTIES_FRAME display properties of the current item.
void UpdateStatusBar() override
Update the status bar information.
int color
Definition: DXF_plotter.cpp:62
#define PL_EDITOR_FRAME_NAME
Definition: draw_frame.h:52
#define LOCATE_STARTPOINT
virtual void SetDrawBgColor(COLOR4D aColor)
Definition: draw_frame.h:391
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
void OnCloseWindow(wxCloseEvent &Event)
wxString m_AboutTitle
Name of program displayed in About.
void ClearFlags(int aMask)
virtual wxConfigBase * config()
Return the wxConfigBase used in SaveSettings().
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...
ACTION_TOOLBAR * m_mainToolBar
Definition: draw_frame.h:156
wxSize GetMinSize() const override
The base class for create windows for drawing purpose.
Definition: draw_frame.h:82
virtual void MoveCursorToCrossHair()
Function MoveCursorToCrossHair warps the cursor to the current cross hair position.
Class TITLE_BLOCK holds the information shown in the lower right corner of a plot,...
Definition: title_block.h:40
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
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:115
WORKSHEET_DATAITEM * GetParent() const
This class handle bitmap images in KiCad.
Definition: bitmap_base.h:46
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:72
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
void RedrawActiveWindow(wxDC *DC, bool EraseBg) override
void SetFlags(int aMask)
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.
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:110
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.
void SetSelected(bool aState)
Function SetSelected Toggles on/off the selected flag (used in editing functions)
EDA_MSG_PANEL * m_messagePanel
Panel used to display information at the bottom of the main window.
Definition: draw_frame.h:169
Class PAGE_INFO describes the page size and margins of a paper page on which to eventually print or p...
Definition: page_info.h:54
double To_User_Unit(EDA_UNITS_T aUnit, double aValue, bool aUseMils)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
Definition: base_units.cpp:93
bool m_showBorderAndTitleBlock
True shows the drawing border and title block.
Definition: draw_frame.h:148
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:289
Definition: common.h:158
virtual void ClearUndoRedoList()
Function ClearUndoRedoList clear undo and redo list, using ClearUndoORRedoList() picked items are del...
struct EDA_HOTKEY_CONFIG PlEditorHotkeysDescr[]
void ClearList()
erase the list of items
virtual 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.
void OnNewPageLayout()
Must be called to initialize parameters when a new page layout description is loaded.
Definition of file extensions used in Kicad.
description of graphic items and texts to build a title block
bool m_showGridAxis
True shows the grid axis indicators.
Definition: draw_frame.h:141
const wxString GetClassName() const
PL_EDITOR_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:258
const TITLE_BLOCK & GetTitleBlock() const override
virtual void DrawCrossHair(wxDC *aDC=nullptr, COLOR4D aColor=COLOR4D::WHITE)
Function DrawCrossHair draws the user cross hair.
wxSize GetMinSize() const override
WORKSHEET_DATAITEM * GetItem(unsigned aIdx) const
Definition: colors.h:60
WORKSHEET_DATAITEM * Locate(wxDC *aDC, const wxPoint &aPosition)
Function Locate.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
static const wxChar blackBgColorKey[]
const wxSize & GetSizeMils() const
Definition: page_info.h:142
const PAGE_INFO & GetPageSettings() const
PL_EDITOR_LAYOUT m_pageLayout
bool GetPageNumberOption() const
Page layout editor can show the title block using a page number 1 or another number.
int m_LastGridSizeId
Definition: draw_frame.h:112
Specialization of the wxAuiPaneInfo class for KiCad panels.
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
Load common frame parameters from a configuration file.
WORKSHEET_LAYOUT handles the graphic items list to draw/plot the title block and other items (page re...
virtual const wxString GetZoomLevelIndicator() const
Return a human readable value which can be displayed as zoom level indicator in dialogs.
double BestZoom() override
Return the zoom level which displays the full page on screen.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:107
static const wxChar designTreeWidthKey[]
WORKSHEET_DATAITEM * GetPageLayoutSelectedItem() const
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:128
void SetPageSettings(const PAGE_INFO &aPageSettings)
const TITLE_BLOCK & GetTitleBlock() const
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:120
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:100
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void SaveSettings(wxConfigBase *aCfg) override
Saves common frame parameters to a configuration data file.
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.
PROPERTIES_FRAME * m_propertiesPagelayout
void SetGridOrigin(const wxPoint &aPoint) override
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
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
#define IU_PER_MILS
Definition: plotter.cpp:134
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...
void Locate(wxDC *aDC, std::vector< WS_DRAW_ITEM_BASE * > &aList, const wxPoint &aPosition)
Locate graphic items in m_graphicList at location aPosition.
int m_NumberOfScreens
Definition: base_screen.h:217
bool ReadImageFile(const wxString &aFullFilename)
Function ReadImageFile Reads and stores in memory an image file.
Definition: bitmap_base.cpp:81
virtual void DrawBackGround(wxDC *DC)
Function DrawBackGround.
classes and function to generate graphics to plt or draw titles blocks and frame references
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:386
void CopyPrmsFromGeneralToPanel()
void DrawWorkSheet(wxDC *aDC, BASE_SCREEN *aScreen, int aLineWidth, double aScale, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Draws on screen the page layout with the frame and the basic inscriptions.
Definition: colors.h:45
void SetShowPageLimits(bool aShow)
Definition: draw_frame.h:397
virtual void Refresh(bool eraseBackground=true, const wxRect *rect=NULL)
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)
Set the screen cross hair position to aPosition in logical (drawing) units.
int SetGrid(const wxRealPoint &size)
set the current grid size m_Grid.
Message panel definition file.
const PL_EDITOR_LAYOUT & GetPageLayout() const
virtual void EraseScreen(wxDC *DC)
Function OnMouseWheel handles mouse wheel events.
EDA_UNITS_T m_UserUnits
Definition: draw_frame.h:125
Definition: colors.h:68
virtual void UpdateStatusBar()
Update the status bar information.
void ReCreateHToolbar() override
wxChoice * m_originSelectBox
void Insert(WORKSHEET_DATAITEM *aItem, unsigned aIdx)
Insert an item to the list of items at position aIdx.
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.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
virtual wxString GetScreenDesc() 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
Load common frame parameters from a configuration file.