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 #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 /* class PL_EDITOR_FRAME */
54 /*************************/
55 
56 PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
57  EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ),
58  wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME )
59 {
61  m_zoomLevelCoeff = 290.0; // Adjusted to roughly displays zoom level = 1
62  // when the screen shows a 1:1 image
63  // obviously depends on the monitor,
64  // but this is an acceptable value
65 
66  m_showAxis = false; // true to show X and Y axis on screen
67  m_showGridAxis = true;
68  m_showBorderAndTitleBlock = true; // true for reference drawings.
71  SetDrawBgColor( WHITE ); // default value, user option (WHITE/BLACK)
72  SetShowPageLimits( true );
73 
74  m_designTreeWidth = 150;
76 
77  if( m_canvas )
79 
80  // Give an icon
81  wxIcon icon;
82  icon.CopyFromBitmap( KiBitmap( icon_pagelayout_editor_xpm ) );
83  SetIcon( icon );
84  wxSize pageSizeIU = GetPageLayout().GetPageSettings().GetSizeIU();
85  SetScreen( new PL_EDITOR_SCREEN( pageSizeIU ) );
86 
87  LoadSettings( config() );
88  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
89 
90  if( ! GetScreen()->GridExists( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 ) )
92 
93  GetScreen()->SetGrid( m_LastGridSizeId + ID_POPUP_GRID_LEVEL_1000 );
94 
97 
98  wxWindow* stsbar = GetStatusBar();
99  int dims[] = {
100 
101  // balance of status bar on far left is set to a default or whatever is left over.
102  -1,
103 
104  // When using GetTextSize() remember the width of '1' is not the same
105  // as the width of '0' unless the font is fixed width, and it usually won't be.
106 
107  // zoom:
108  GetTextSize( wxT( "Z 762000" ), stsbar ).x + 10,
109 
110  // cursor coords
111  GetTextSize( wxT( "X 0234.567 Y 0234.567" ), stsbar ).x + 10,
112 
113  // delta distances
114  GetTextSize( wxT( "dx 0234.567 dx 0234.567" ), stsbar ).x + 10,
115 
116  // Coord origin (use the bigger message)
117  GetTextSize( _( "coord origin: Right Bottom page corner" ), stsbar ).x + 10,
118 
119  // units display, Inches is bigger than mm
120  GetTextSize( _( "Inches" ), stsbar ).x + 10
121  };
122 
123  SetStatusWidths( DIM( dims ), dims );
124 
125  m_auimgr.SetManagedWindow( this );
126  m_auimgr.SetArtProvider( new EDA_DOCKART( this ) );
127 
129  m_treePagelayout = new DESIGN_TREE_FRAME( this );
130 
131  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
132  m_auimgr.AddPane( m_messagePanel, EDA_PANE().Messages().Name( "MsgPanel" ).Bottom().Layer(6) );
133 
134  m_auimgr.AddPane( m_treePagelayout, EDA_PANE().Palette().Name( "Design" ).Left().Layer(1)
135  .Caption( _( "Design" ) ).MinSize( m_treePagelayout->GetMinSize() )
136  .BestSize( m_designTreeWidth, -1 ) );
137  m_auimgr.AddPane( m_propertiesPagelayout, EDA_PANE().Palette().Name( "Props" ).Right().Layer(1)
138  .Caption( _( "Properties" ) ).MinSize( m_propertiesPagelayout->GetMinSize() )
139  .BestSize( m_propertiesFrameWidth, -1 ) );
140 
141  m_auimgr.AddPane( m_canvas, EDA_PANE().Canvas().Name( "DrawFrame" ).Center() );
142 
143  m_auimgr.Update();
144 
145  // Initialize the current page layout
147 #if 0 //start with empty layout
148  pglayout.AllowVoidList( true );
149  pglayout.ClearList();
150 #else // start with the default Kicad layout
151  pglayout.SetPageLayout();
152 #endif
153  OnNewPageLayout();
154 }
155 
156 
158 {
159 }
160 
161 
162 bool PL_EDITOR_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl )
163 {
164  wxString fn = aFileSet[0];
165 
166  if( !LoadPageLayoutDescrFile( fn ) )
167  {
168  wxString msg = wxString::Format(
169  _( "Error when loading file \"%s\"" ),
170  GetChars( fn )
171  );
172 
173  wxMessageBox( msg );
174  return false;
175  }
176  else
177  {
178  OnNewPageLayout();
179  return true;
180  }
181 }
182 
183 
184 void PL_EDITOR_FRAME::OnCloseWindow( wxCloseEvent& Event )
185 {
186  if( GetScreen()->IsModify() )
187  {
188  if( !HandleUnsavedChanges( this, _( "The current page layout has been modified. Save changes?" ),
189  [&]()->bool { return saveCurrentPageLayout(); } ) )
190  {
191  Event.Veto();
192  return;
193  }
194  }
195 
196  // do not show the window because we do not want any paint event
197  Show( false );
198 
199  // was: Pgm().SaveCurrentSetupValues( m_configSettings );
200  wxConfigSaveSetups( Kiface().KifaceSettings(), m_configSettings );
201 
202  // On Linux, m_propertiesPagelayout must be destroyed
203  // before deleting the main frame to avoid a crash when closing
204  m_propertiesPagelayout->Destroy();
205  Destroy();
206 }
207 
208 
210 {
211  double sizeX = (double) GetPageLayout().GetPageSettings().GetWidthIU();
212  double sizeY = (double) GetPageLayout().GetPageSettings().GetHeightIU();
213  wxPoint centre( sizeX / 2, sizeY / 2 );
214 
215  // The sheet boundary already affords us some margin, so add only an
216  // additional 5%.
217  double margin_scale_factor = 1.05;
218 
219  return bestZoom( sizeX, sizeY, margin_scale_factor, centre );
220 }
221 
222 
223 static const wxChar designTreeWidthKey[] = wxT( "DesignTreeWidth" );
224 static const wxChar propertiesFrameWidthKey[] = wxT( "PropertiesFrameWidth" );
225 static const wxChar cornerOriginChoiceKey[] = wxT( "CornerOriginChoice" );
226 static const wxChar blackBgColorKey[] = wxT( "BlackBgColor" );
227 
228 
229 void PL_EDITOR_FRAME::LoadSettings( wxConfigBase* aCfg )
230 {
232 
233  aCfg->Read( designTreeWidthKey, &m_designTreeWidth, 100);
236  bool tmp;
237  aCfg->Read( blackBgColorKey, &tmp, false );
238  SetDrawBgColor( tmp ? BLACK : WHITE );
239 }
240 
241 
242 void PL_EDITOR_FRAME::SaveSettings( wxConfigBase* aCfg )
243 {
245 
246  m_designTreeWidth = m_treePagelayout->GetSize().x;
248 
249  aCfg->Write( designTreeWidthKey, m_designTreeWidth);
252  aCfg->Write( blackBgColorKey, GetDrawBgColor() == BLACK );
253 
254  // was: wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
256 }
257 
258 
260 {
261  wxString title;
262  wxString file = GetCurrFileName();
263 
264  title.Printf( _( "Page Layout Editor" ) + wxT( " \u2014 %s" ),
265  file.Length() ? file : _( "no file selected" ) );
266  SetTitle( title );
267 }
268 
269 
270 const wxString& PL_EDITOR_FRAME::GetCurrFileName() const
271 {
273 }
274 
275 
276 void PL_EDITOR_FRAME::SetCurrFileName( const wxString& aName )
277 {
279 }
280 
281 
282 void PL_EDITOR_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
283 {
284  m_pageLayout.SetPageSettings( aPageSettings );
285 
286  if( GetScreen() )
287  GetScreen()->InitDataPoints( aPageSettings.GetSizeIU() );
288 }
289 
290 
292 {
293  return m_pageLayout.GetPageSettings();
294 }
295 
296 
297 const wxSize PL_EDITOR_FRAME::GetPageSizeIU() const
298 {
299  // this function is only needed because EDA_DRAW_FRAME is not compiled
300  // with either -DPCBNEW or -DEESCHEMA, so the virtual is used to route
301  // into an application specific source file.
302  return m_pageLayout.GetPageSettings().GetSizeIU();
303 }
304 
305 
307 {
308  return GetPageLayout().GetTitleBlock();
309 }
310 
311 
312 void PL_EDITOR_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
313 {
314  m_pageLayout.SetTitleBlock( aTitleBlock );
315 }
316 
317 
319 {
321 
322  if( !screen )
323  return;
324 
325  // Display Zoom level:
327 
328  // coodinate origin can be the paper Top Left corner,
329  // or each of 4 page corners
330  // We know the origin, and the orientation of axis
331  wxPoint originCoord;
332  int Xsign = 1;
333  int Ysign = 1;
334 
336 
337  switch( m_originSelectChoice )
338  {
339  default:
340  case 0: // Origin = paper Left Top corner
341  break;
342 
343  case 1: // Origin = page Right Bottom corner
344  Xsign = -1;
345  Ysign = -1;
346  dummy.SetStart( 0, 0, RB_CORNER );
347  originCoord = dummy.GetStartPosUi();
348  break;
349 
350  case 2: // Origin = page Left Bottom corner
351  Ysign = -1;
352  dummy.SetStart( 0, 0, LB_CORNER );
353  originCoord = dummy.GetStartPosUi();
354  break;
355 
356  case 3: // Origin = page Right Top corner
357  Xsign = -1;
358  dummy.SetStart( 0, 0, RT_CORNER );
359  originCoord = dummy.GetStartPosUi();
360  break;
361 
362  case 4: // Origin = page Left Top corner
363  dummy.SetStart( 0, 0, LT_CORNER );
364  originCoord = dummy.GetStartPosUi();
365  break;
366  }
367 
368  SetGridOrigin( originCoord );
369 
370  // Display absolute coordinates:
371  wxPoint coord = GetCrossHairPosition() - originCoord;
372  double dXpos = To_User_Unit( GetUserUnits(), coord.x*Xsign );
373  double dYpos = To_User_Unit( GetUserUnits(), coord.y*Ysign );
374 
375  wxString pagesizeformatter = _( "Page size: width %.4g height %.4g" );
376  wxString absformatter = wxT( "X %.4g Y %.4g" );
377  wxString locformatter = wxT( "dx %.4g dy %.4g" );
378 
379  switch( GetUserUnits() )
380  {
381  case INCHES: // Should not be used in page layout editor
382  SetStatusText( _("inches"), 5 );
383  break;
384 
385  case MILLIMETRES:
386  SetStatusText( _("mm"), 5 );
387  break;
388 
389  case UNSCALED_UNITS:
390  SetStatusText( wxEmptyString, 5 );
391  break;
392 
393  case DEGREES:
394  wxASSERT( false );
395  break;
396  }
397 
398  wxString line;
399 
400  // Display page size
401  #define milsTomm (25.4/1000)
402  DSIZE size = GetPageSettings().GetSizeMils();
403  size = size * milsTomm;
404  line.Printf( pagesizeformatter, size.x, size.y );
405  SetStatusText( line, 0 );
406 
407  // Display abs coordinates
408  line.Printf( absformatter, dXpos, dYpos );
409  SetStatusText( line, 2 );
410 
411  // Display relative coordinates:
412  int dx = GetCrossHairPosition().x - screen->m_O_Curseur.x;
413  int dy = GetCrossHairPosition().y - screen->m_O_Curseur.y;
414  dXpos = To_User_Unit( GetUserUnits(), dx * Xsign );
415  dYpos = To_User_Unit( GetUserUnits(), dy * Ysign );
416  line.Printf( locformatter, dXpos, dYpos );
417  SetStatusText( line, 3 );
418 
419  // Display corner reference for coord origin
420  line.Printf( _("coord origin: %s"),
421  m_originSelectBox->GetString( m_originSelectChoice ). GetData() );
422  SetStatusText( line, 4 );
423 
424  // Display units
425 }
426 
427 
428 void PL_EDITOR_FRAME::PrintPage( wxDC* aDC, LSET aPrintMasklayer,
429  bool aPrintMirrorMode, void * aData )
430 {
431  GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
432  DrawWorkSheet( aDC, GetScreen(), 0, IU_PER_MILS, wxEmptyString );
433 }
434 
435 
436 void PL_EDITOR_FRAME::RedrawActiveWindow( wxDC* aDC, bool aEraseBg )
437 {
438 
439  GetScreen()-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
440 
441  if( aEraseBg )
442  m_canvas->EraseScreen( aDC );
443 
444  m_canvas->DrawBackGround( aDC );
445 
447  WORKSHEET_DATAITEM* selecteditem = GetSelectedItem();
448 
449  // the color to draw selected items
450  if( GetDrawBgColor() == WHITE )
452  else
454 
455  for( unsigned ii = 0; ; ii++ )
456  {
457  WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
458 
459  if( item == NULL )
460  break;
461 
462  item->SetSelected( item == selecteditem );
463  }
464 
466 
467 #ifdef USE_WX_OVERLAY
468  if( IsShown() )
469  {
470  m_overlay.Reset();
471  wxDCOverlay overlaydc( m_overlay, (wxWindowDC*)aDC );
472  overlaydc.Clear();
473  }
474 #endif
475 
476  if( m_canvas->IsMouseCaptured() )
477  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
478 
479  m_canvas->DrawCrossHair( aDC );
480 
481  // Display the filename
483 }
484 
485 
487 {
489  int rectId = 0;
490  int lineId = 0;
491  int textId = 0;
492  int polyId = 0;
493  int bitmapId = 0;
494 
495  for( unsigned ii = 0; ii < pglayout.GetCount(); ii++ )
496  {
497  WORKSHEET_DATAITEM* item = pglayout.GetItem( ii );
498  switch( item->GetType() )
499  {
501  item->m_Name = wxString::Format( wxT( "text%d:%s" ), ++textId,
502  GetChars(item->GetClassName()) );
503  break;
504 
506  item->m_Name = wxString::Format( wxT( "segm%d:%s" ), ++lineId,
507  GetChars(item->GetClassName()) );
508  break;
509 
511  item->m_Name = wxString::Format( wxT( "rect%d:%s" ), ++rectId,
512  GetChars(item->GetClassName()) );
513  break;
514 
516  item->m_Name = wxString::Format( wxT( "poly%d:%s" ), ++polyId,
517  GetChars(item->GetClassName()) );
518  break;
519 
521  item->m_Name = wxString::Format( wxT( "bm%d:%s" ), ++bitmapId,
522  GetChars(item->GetClassName()) );
523  break;
524  }
525  }
526 
528 }
529 
530 
532 {
533  WORKSHEET_DATAITEM * item = NULL;
534 
535  switch( aType )
536  {
538  item = new WORKSHEET_DATAITEM_TEXT( wxT( "Text") );
539  break;
540 
543  break;
544 
547  break;
548 
550  item = new WORKSHEET_DATAITEM_POLYPOLYGON();
551  break;
552 
554  {
555  wxFileDialog fileDlg( this, _( "Choose Image" ), wxEmptyString, wxEmptyString,
556  _( "Image Files " ) + wxImage::GetImageExtWildcard(),
557  wxFD_OPEN );
558 
559  if( fileDlg.ShowModal() != wxID_OK )
560  return NULL;
561 
562  wxString fullFilename = fileDlg.GetPath();
563 
564  if( !wxFileExists( fullFilename ) )
565  {
566  wxMessageBox( _( "Couldn't load image from \"%s\"" ), GetChars( fullFilename ) );
567  break;
568  }
569 
570  BITMAP_BASE* image = new BITMAP_BASE();
571 
572  if( !image->ReadImageFile( fullFilename ) )
573  {
574  wxMessageBox( _( "Couldn't load image from \"%s\"" ),
575  GetChars( fullFilename ) );
576  delete image;
577  break;
578  }
579 
580  item = new WORKSHEET_DATAITEM_BITMAP( image );
581  }
582  break;
583  }
584 
585  if( item == NULL )
586  return NULL;
587 
589  pglayout.Insert( item, aIdx );
591 
592  return item;
593 }
594 
595 
597 {
599  return item;
600 }
601 
602 
603 WORKSHEET_DATAITEM* PL_EDITOR_FRAME::Locate( wxDC* aDC, const wxPoint& aPosition )
604 {
605  const PAGE_INFO& pageInfo = GetPageSettings();
606  TITLE_BLOCK t_block = GetTitleBlock();
607  COLOR4D color = COLOR4D( RED ); // Needed, not used
609 
610  screen-> m_ScreenNumber = GetPageNumberOption() ? 1 : 2;
611 
612  WS_DRAW_ITEM_LIST drawList;
613  drawList.SetPenSize( 0 );
614  drawList.SetMilsToIUfactor( IU_PER_MILS );
615  drawList.SetSheetNumber( screen->m_ScreenNumber );
616  drawList.SetSheetCount( screen->m_NumberOfScreens );
617  drawList.SetFileName( GetCurrFileName() );
618  // GetScreenDesc() returns a temporary string. Store it to avoid issues.
619  wxString descr = GetScreenDesc();
620  drawList.SetSheetName( descr );
621 
622  drawList.BuildWorkSheetGraphicList( pageInfo, t_block, color, color );
623 
624  // locate items.
625  // We do not use here the COLLECTOR classes in use in pcbnew and eeschema
626  // because the locate requirements are very basic.
627  std::vector <WS_DRAW_ITEM_BASE*> list;
628  drawList.Locate( aDC, list, aPosition );
629 
630  if( list.size() == 0 )
631  return NULL;
632 
633  WS_DRAW_ITEM_BASE* drawitem = list[0];
634 
635  // Choose item in list if more than 1 item
636  if( list.size() > 1 )
637  {
638  wxArrayString choices;
639  wxString text;
640  wxPoint cursPos = GetCrossHairPosition();
641 
642  for( unsigned ii = 0; ii < list.size(); ++ii )
643  {
644  drawitem = list[ii];
645  text = drawitem->GetParent()->m_Name;
646 
647  if( (drawitem->m_Flags & (LOCATE_STARTPOINT|LOCATE_ENDPOINT))
649  text << wxT( " " ) << _( "(start or end point)" );
650  else
651  {
652  if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
653  text << wxT( " " ) << _( "(start point)" );
654 
655  if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
656  text << wxT( " " ) << _( "(end point)" );
657  }
658 
659  if( ! drawitem->GetParent()->m_Info.IsEmpty() )
660  text << wxT( " \"" ) << drawitem->GetParent()->m_Info << wxT( "\"" );
661 
662  choices.Add( text );
663  }
664 
665  int selection = wxGetSingleChoiceIndex ( wxEmptyString,
666  _( "Selection Clarification" ),
667  choices, this );
668  if( selection < 0 )
669  return NULL;
670 
671  SetCrossHairPosition( cursPos );
673  drawitem = list[selection];
674  }
675 
676  WORKSHEET_DATAITEM* item = drawitem->GetParent();
678 
679  if( (drawitem->m_Flags & LOCATE_STARTPOINT) )
680  item->SetFlags( LOCATE_STARTPOINT );
681 
682  if( (drawitem->m_Flags & LOCATE_ENDPOINT) )
683  item->SetFlags( LOCATE_ENDPOINT );
684 
685  return item;
686 }
687 
688 
690 {
692  GetScreen()->ClrModify();
695  Zoom_Automatique( false );
696  m_canvas->Refresh();
697 }
698 
699 
701 {
703 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
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:213
PARAM_CFG_ARRAY m_configSettings
int m_ScreenNumber
Definition: base_screen.h:216
const PL_EDITOR_LAYOUT & GetPageLayout() const
void AllowVoidList(bool Allow)
In Kicad applications, a page layout description is needed So if the list is empty, a default description is loaded, the first time a page layout is drawn.
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
void SetPenSize(int aPenSize)
Function SetPenSize Set the default pen size to draw/plot lines and texts.
const PAGE_INFO & GetPageSettings() const override
bool m_showAxis
True shows the X and Y axis indicators.
Definition: draw_frame.h:133
virtual const wxString GetZoomLevelIndicator() const
Return a human readable value which can be displayed as zoom level indicator in dialogs.
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.
const TITLE_BLOCK & GetTitleBlock() const
virtual void SetScreen(BASE_SCREEN *aScreen)
Definition: draw_frame.h:181
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
Function ReCreateMenuBar Creates 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:51
#define LOCATE_STARTPOINT
virtual void SetDrawBgColor(COLOR4D aColor)
Definition: draw_frame.h:380
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
void OnCloseWindow(wxCloseEvent &Event)
void ClearFlags(int aMask)
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
wxAuiManager m_auimgr
void BuildWorkSheetGraphicList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock, COLOR4D aColor, COLOR4D aAltColor)
Function BuildWorkSheetGraphicList is a core function for drawing or plotting the page layout with th...
wxSize GetMinSize() const override
The base class for create windows for drawing purpose.
Definition: draw_frame.h:78
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, printout, or editing view.
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
const wxPoint GetStartPosUi(int ii=0) const
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings 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:111
const wxSize & GetSizeMils() const
Definition: page_info.h:142
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.
virtual COLOR4D GetDrawBgColor() const
Definition: draw_frame.h:375
EDA_HOTKEY_CONFIG * m_hotkeysDescrList
Definition: draw_frame.h:105
WORKSHEET_DATAITEM * GetItem(unsigned aIdx) const
virtual wxString GetScreenDesc() const
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:163
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:143
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
Definition: common.h:160
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
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.
The common library.
description of graphic items and texts to build a title block
bool m_showGridAxis
True shows the grid axis indicators.
Definition: draw_frame.h:136
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
Definition: colors.h:60
WORKSHEET_DATAITEM * Locate(wxDC *aDC, const wxPoint &aPosition)
Function Locate.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
static const wxChar blackBgColorKey[]
PL_EDITOR_LAYOUT m_pageLayout
const PAGE_INFO & GetPageSettings() const
int m_LastGridSizeId
Definition: draw_frame.h:107
Specialization of the wxAuiPaneInfo class for KiCad panels.
wxAuiToolBar * m_mainToolBar
Standard horizontal Toolbar.
const wxString GetZoomLevelIndicator() const override
Function GetZoomLevelIndicator returns a human readable value which can be displayed as zoom level in...
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
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.
static const wxChar designTreeWidthKey[]
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:123
void SetPageSettings(const PAGE_INFO &aPageSettings)
bool GetPageNumberOption() const
Page layout editor can show the title block using a page number 1 or another number.
double m_zoomLevelCoeff
a suitable value to convert the internal zoom scaling factor
Definition: draw_frame.h:115
void wxConfigSaveSetups(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList)
Function wxConfigSaveSetups writes aList of PARAM_CFG_ARRAY elements to save configuration values to ...
void UpdateTitleAndInfo()
Displays the short filename (if exists) loaded file on the caption of the main window.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void SaveSettings(wxConfigBase *aCfg) override
Function SaveSettings saves common frame parameters to a configuration data file. ...
WORKSHEET_DATAITEM * GetSelectedItem()
Function GetSelectedItem.
void SetSheetNumber(int aSheetNumber)
Function SetSheetNumber Set the value of the sheet number, for basic inscriptions.
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
void SetCurrFileName(const wxString &aName)
Stores the current layout descr file filename.
PROPERTIES_FRAME * m_propertiesPagelayout
void SetGridOrigin(const wxPoint &aPoint) override
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
WS_ItemType GetType() const
struct EDA_HOTKEY_CONFIG PlEditorHokeysDescr[]
void SetStart(double aPosx, double aPosy, enum corner_anchor aAnchor=RB_CORNER)
static const wxChar propertiesFrameWidthKey[]
bool LoadPageLayoutDescrFile(const wxString &aFullFileName)
Function LoadPageLayoutDescrFile Loads a .kicad_wks page layout descr file.
void ClrModify()
Definition: base_screen.h:325
#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 ...
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:386
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.
virtual void EraseScreen(wxDC *DC)
Function OnMouseWheel handles mouse wheel events.
EDA_UNITS_T m_UserUnits
Definition: draw_frame.h:120
Definition: colors.h:68
virtual void UpdateStatusBar()
Update the status bar information.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
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.