KiCad PCB EDA Suite
dialog_page_settings.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) 2021 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <env_paths.h>
21#include <pgm_base.h>
22#include <bitmaps.h>
23#include <base_screen.h>
24#include <common.h> // ExpandEnvVarSubstitutions
25#include <confirm.h>
26#include <core/arraydim.h>
28#include <eda_draw_frame.h>
29#include <eda_item.h>
30#include <gr_basic.h>
31#include <kiface_base.h>
32#include <macros.h>
33#include <math/util.h> // for KiROUND, Clamp
34#include <project.h>
35#include <title_block.h>
36#include <tool/actions.h>
37#include <tool/tool_manager.h>
41#include <wx/valgen.h>
42#include <wx/tokenzr.h>
43#include <wx/filedlg.h>
44#include <wx/dcmemory.h>
45
46#define MAX_PAGE_EXAMPLE_SIZE 200
47
48
49// List of page formats.
50// they are prefixed by "_HKI" (already in use for hotkeys) instead of "_",
51// because we need both the translated and the not translated version.
52// when displayed in dialog we should explicitly call wxGetTranslation()
53// to show the translated version.
54// See hotkeys_basic.h for more info
55#define _HKI( x ) wxT( x )
56static const wxString pageFmts[] =
57{
58 _HKI("A5 148x210mm"),
59 _HKI("A4 210x297mm"),
60 _HKI("A3 297x420mm"),
61 _HKI("A2 420x594mm"),
62 _HKI("A1 594x841mm"),
63 _HKI("A0 841x1189mm"),
64 _HKI("A 8.5x11in"),
65 _HKI("B 11x17in"),
66 _HKI("C 17x22in"),
67 _HKI("D 22x34in"),
68 _HKI("E 34x44in"),
69 _HKI("USLetter 8.5x11in"), // USLetter without space is correct
70 _HKI("USLegal 8.5x14in"), // USLegal without space is correct
71 _HKI("USLedger 11x17in"), // USLedger without space is correct
72 _HKI("User (Custom)"), // size defined by user. The string must contain "Custom"
73 // to be recognized in code
74};
75
77 const wxSize& aMaxUserSizeMils ) :
79 m_parent( aParent ),
80 m_screen( m_parent->GetScreen() ),
81 m_initialized( false ),
82 m_pageBitmap( nullptr ),
83 m_iuPerMils( aIuPerMils ),
84 m_customSizeX( aParent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits ),
85 m_customSizeY( aParent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits )
86{
89
90 m_maxPageSizeMils = aMaxUserSizeMils;
92 m_customFmt = false;
94
96 wxString serialization;
98 m_drawingSheet->SetPageLayout( TO_UTF8( serialization ) );
99
100 m_PickDate->SetValue( wxDateTime::Now() );
101
102 if( m_parent->GetName() == PL_EDITOR_FRAME_NAME )
103 {
104 SetTitle( _( "Preview Settings" ) );
105 m_staticTextPaper->SetLabel( _( "Preview Paper" ) );
106 m_staticTextTitleBlock->SetLabel( _( "Preview Title Block Data" ) );
107 }
108 else
109 {
110 SetTitle( _( "Page Settings" ) );
111 m_staticTextPaper->SetLabel( _( "Paper" ) );
112 m_staticTextTitleBlock->SetLabel( _( "Title Block" ) );
113 }
114
116
117 Centre();
118}
119
120
122{
123 delete m_pageBitmap;
124 delete m_drawingSheet;
125}
126
127
129{
130 // initialize page format choice box and page format list.
131 // The first shows translated strings, the second contains not translated strings
132 m_paperSizeComboBox->Clear();
133
134 for( const wxString& pageFmt : pageFmts )
135 {
136 m_pageFmt.Add( pageFmt );
137 m_paperSizeComboBox->Append( wxGetTranslation( pageFmt ) );
138 }
139
140 // initialize the drawing sheet filename
142
146
147 // only a click fires the "selection changed" event, so have to fabricate this check
148 wxCommandEvent dummy;
150
151 if( m_customFmt )
152 {
155 }
156 else
157 {
160 }
161
162 m_TextRevision->SetValue( m_tb.GetRevision() );
163 m_TextDate->SetValue( m_tb.GetDate() );
164 m_TextTitle->SetValue( m_tb.GetTitle() );
165 m_TextCompany->SetValue( m_tb.GetCompany() );
166 m_TextComment1->SetValue( m_tb.GetComment( 0 ) );
167 m_TextComment2->SetValue( m_tb.GetComment( 1 ) );
168 m_TextComment3->SetValue( m_tb.GetComment( 2 ) );
169 m_TextComment4->SetValue( m_tb.GetComment( 3 ) );
170 m_TextComment5->SetValue( m_tb.GetComment( 4 ) );
171 m_TextComment6->SetValue( m_tb.GetComment( 5 ) );
172 m_TextComment7->SetValue( m_tb.GetComment( 6 ) );
173 m_TextComment8->SetValue( m_tb.GetComment( 7 ) );
174 m_TextComment9->SetValue( m_tb.GetComment( 8 ) );
175
176 // The default is to disable aall these fields for the "generic" dialog
177 m_TextSheetCount->Show( false );
178 m_TextSheetNumber->Show( false );
179 m_PaperExport->Show( false );
180 m_RevisionExport->Show( false );
181 m_DateExport->Show( false );
182 m_TitleExport->Show( false );
183 m_CompanyExport->Show( false );
184 m_Comment1Export->Show( false );
185 m_Comment2Export->Show( false );
186 m_Comment3Export->Show( false );
187 m_Comment4Export->Show( false );
188 m_Comment5Export->Show( false );
189 m_Comment6Export->Show( false );
190 m_Comment7Export->Show( false );
191 m_Comment8Export->Show( false );
192 m_Comment9Export->Show( false );
193
195
198
199 GetSizer()->SetSizeHints( this );
200
201 m_initialized = true;
202
203 return true;
204}
205
206
208{
209 int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
210 const wxString paperType = m_pageFmt[idx];
211
212 if( paperType.Contains( PAGE_INFO::Custom ) )
213 {
215 return false;
216
218 return false;
219 }
220
221 if( SavePageSettings() )
222 {
224
227
228 // Call the post processing (if any) after changes
230 }
231
232 return true;
233}
234
235
236void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )
237{
238 int idx = m_paperSizeComboBox->GetSelection();
239
240 if( idx < 0 )
241 idx = 0;
242
243 const wxString paperType = m_pageFmt[idx];
244
245 if( paperType.Contains( PAGE_INFO::Custom ) )
246 {
247 m_staticTextOrient->Enable( false );
248 m_orientationComboBox->Enable( false );
249
250 m_staticTextCustSize->Enable( true );
251 m_customSizeX.Enable( true );
252 m_customSizeY.Enable( true );
253 m_customFmt = true;
254 }
255 else
256 {
257 m_staticTextOrient->Enable( true );
258 m_orientationComboBox->Enable( true );
259
260 m_staticTextCustSize->Enable( false );
261 m_customSizeX.Enable( false );
262 m_customSizeY.Enable( false );
263 m_customFmt = false;
264 }
265
268}
269
270
272{
273 if( m_initialized )
274 {
277 }
278}
279
280
282{
283 if( m_initialized )
284 {
287 }
288}
289
290
292{
293 if( m_initialized )
294 {
297 }
298}
299
300
302{
303 if( m_initialized && m_TextRevision->IsModified() )
304 {
306 m_tb.SetRevision( m_TextRevision->GetValue() );
308 }
309}
310
311
312void DIALOG_PAGES_SETTINGS::OnDateTextUpdated( wxCommandEvent& event )
313{
314 if( m_initialized && m_TextDate->IsModified() )
315 {
317 m_tb.SetDate( m_TextDate->GetValue() );
319 }
320}
321
322
323void DIALOG_PAGES_SETTINGS::OnTitleTextUpdated( wxCommandEvent& event )
324{
325 if( m_initialized && m_TextTitle->IsModified() )
326 {
328 m_tb.SetTitle( m_TextTitle->GetValue() );
330 }
331}
332
333
335{
336 if( m_initialized && m_TextCompany->IsModified() )
337 {
339 m_tb.SetCompany( m_TextCompany->GetValue() );
341 }
342}
343
344
346{
347 if( m_initialized && m_TextComment1->IsModified() )
348 {
350 m_tb.SetComment( 0, m_TextComment1->GetValue() );
352 }
353}
354
355
357{
358 if( m_initialized && m_TextComment2->IsModified() )
359 {
361 m_tb.SetComment( 1, m_TextComment2->GetValue() );
363 }
364}
365
366
368{
369 if( m_initialized && m_TextComment3->IsModified() )
370 {
372 m_tb.SetComment( 2, m_TextComment3->GetValue() );
374 }
375}
376
377
379{
380 if( m_initialized && m_TextComment4->IsModified() )
381 {
383 m_tb.SetComment( 3, m_TextComment4->GetValue() );
385 }
386}
387
388
390{
391 if( m_initialized && m_TextComment5->IsModified() )
392 {
394 m_tb.SetComment( 4, m_TextComment5->GetValue() );
396 }
397}
398
399
401{
402 if( m_initialized && m_TextComment6->IsModified() )
403 {
405 m_tb.SetComment( 5, m_TextComment6->GetValue() );
407 }
408}
409
410
412{
413 if( m_initialized && m_TextComment7->IsModified() )
414 {
416 m_tb.SetComment( 6, m_TextComment7->GetValue() );
418 }
419}
420
421
423{
424 if( m_initialized && m_TextComment8->IsModified() )
425 {
427 m_tb.SetComment( 7, m_TextComment8->GetValue() );
429 }
430}
431
432
434{
435 if( m_initialized && m_TextComment9->IsModified() )
436 {
438 m_tb.SetComment( 8, m_TextComment9->GetValue() );
440 }
441}
442
443
444void DIALOG_PAGES_SETTINGS::OnDateApplyClick( wxCommandEvent& event )
445{
446 wxDateTime datetime = m_PickDate->GetValue();
447 wxString date =
448 // We can choose different formats. Should probably be kept in sync with CURRENT_DATE
449 // formatting in TITLE_BLOCK.
450 //
451 // datetime.Format( wxLocale::GetInfo( wxLOCALE_SHORT_DATE_FMT ) );
452 // datetime.Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) );
453 // datetime.Format( wxT("%Y-%b-%d") );
454 datetime.FormatISODate();
455
456 m_TextDate->SetValue( date );
457}
458
459
461{
462 bool success = false;
463
464 wxString fileName = GetWksFileName();
465
467 {
468 wxString fullFileName = DS_DATA_MODEL::ResolvePath( fileName, m_projectPath );
469
470 if( !fullFileName.IsEmpty() && !wxFileExists( fullFileName ) )
471 {
472 wxString msg;
473 msg.Printf( _( "Drawing sheet file '%s' not found." ), fullFileName );
474 wxMessageBox( msg );
475 return false;
476 }
477
481 }
482
483 int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
484 const wxString paperType = m_pageFmt[idx];
485
486 if( paperType.Contains( PAGE_INFO::Custom ) )
487 {
489
491
492 if( success )
493 {
496
499 }
500 }
501 else
502 {
503 // search for longest common string first, e.g. A4 before A
504 if( paperType.Contains( PAGE_INFO::USLetter ) )
506 else if( paperType.Contains( PAGE_INFO::USLegal ) )
508 else if( paperType.Contains( PAGE_INFO::USLedger ) )
510 else if( paperType.Contains( PAGE_INFO::GERBER ) )
512 else if( paperType.Contains( PAGE_INFO::A5 ) )
513 success = m_pageInfo.SetType( PAGE_INFO::A5 );
514 else if( paperType.Contains( PAGE_INFO::A4 ) )
515 success = m_pageInfo.SetType( PAGE_INFO::A4 );
516 else if( paperType.Contains( PAGE_INFO::A3 ) )
517 success = m_pageInfo.SetType( PAGE_INFO::A3 );
518 else if( paperType.Contains( PAGE_INFO::A2 ) )
519 success = m_pageInfo.SetType( PAGE_INFO::A2 );
520 else if( paperType.Contains( PAGE_INFO::A1 ) )
521 success = m_pageInfo.SetType( PAGE_INFO::A1 );
522 else if( paperType.Contains( PAGE_INFO::A0 ) )
523 success = m_pageInfo.SetType( PAGE_INFO::A0 );
524 else if( paperType.Contains( PAGE_INFO::A ) )
525 success = m_pageInfo.SetType( PAGE_INFO::A );
526 else if( paperType.Contains( PAGE_INFO::B ) )
527 success = m_pageInfo.SetType( PAGE_INFO::B );
528 else if( paperType.Contains( PAGE_INFO::C ) )
529 success = m_pageInfo.SetType( PAGE_INFO::C );
530 else if( paperType.Contains( PAGE_INFO::D ) )
531 success = m_pageInfo.SetType( PAGE_INFO::D );
532 else if( paperType.Contains( PAGE_INFO::E ) )
533 success = m_pageInfo.SetType( PAGE_INFO::E );
534
535 if( success )
536 {
537 int choice = m_orientationComboBox->GetSelection();
538 m_pageInfo.SetPortrait( choice != 0 );
539 }
540 }
541
542 if( !success )
543 {
544 wxFAIL_MSG( "The translation for paper size must preserve original spellings" );
546 }
547
549
550 m_tb.SetRevision( m_TextRevision->GetValue() );
551 m_tb.SetDate( m_TextDate->GetValue() );
552 m_tb.SetCompany( m_TextCompany->GetValue() );
553 m_tb.SetTitle( m_TextTitle->GetValue() );
554 m_tb.SetComment( 0, m_TextComment1->GetValue() );
555 m_tb.SetComment( 1, m_TextComment2->GetValue() );
556 m_tb.SetComment( 2, m_TextComment3->GetValue() );
557 m_tb.SetComment( 3, m_TextComment4->GetValue() );
558 m_tb.SetComment( 4, m_TextComment5->GetValue() );
559 m_tb.SetComment( 5, m_TextComment6->GetValue() );
560 m_tb.SetComment( 6, m_TextComment7->GetValue() );
561 m_tb.SetComment( 7, m_TextComment8->GetValue() );
562 m_tb.SetComment( 8, m_TextComment9->GetValue() );
563
565
566 return onSavePageSettings();
567}
568
569
571{
572 // search all the not translated label list containing our paper type
573 for( unsigned i = 0; i < m_pageFmt.GetCount(); ++i )
574 {
575 // parse each label looking for aPaperSize within it
576 wxStringTokenizer st( m_pageFmt[i] );
577
578 while( st.HasMoreTokens() )
579 {
580 if( st.GetNextToken() == aPaperSize )
581 {
582 m_paperSizeComboBox->SetSelection( i );
583 return;
584 }
585 }
586 }
587}
588
589
591{
592 int lyWidth, lyHeight;
593
594 wxSize clamped_layout_size( Clamp( MIN_PAGE_SIZE_MILS, m_layout_size.x, m_maxPageSizeMils.x ),
596
597 double lyRatio = clamped_layout_size.x < clamped_layout_size.y ?
598 (double) clamped_layout_size.y / clamped_layout_size.x :
599 (double) clamped_layout_size.x / clamped_layout_size.y;
600
601 if( clamped_layout_size.x < clamped_layout_size.y )
602 {
603 lyHeight = MAX_PAGE_EXAMPLE_SIZE;
604 lyWidth = KiROUND( (double) lyHeight / lyRatio );
605 }
606 else
607 {
608 lyWidth = MAX_PAGE_EXAMPLE_SIZE;
609 lyHeight = KiROUND( (double) lyWidth / lyRatio );
610 }
611
612 if( m_pageBitmap )
613 {
614 m_PageLayoutExampleBitmap->SetBitmap( wxNullBitmap );
615 delete m_pageBitmap;
616 }
617
618 m_pageBitmap = new wxBitmap( lyWidth + 1, lyHeight + 1 );
619
620 if( m_pageBitmap->IsOk() )
621 {
622 double scaleW = (double) lyWidth / clamped_layout_size.x;
623 double scaleH = (double) lyHeight / clamped_layout_size.y;
624 double scale = std::min( scaleW, scaleH );
625
626 // Prepare DC.
627 wxSize example_size( lyWidth + 1, lyHeight + 1 );
628 wxMemoryDC memDC;
629 memDC.SelectObject( *m_pageBitmap );
630 memDC.SetClippingRegion( wxPoint( 0, 0 ), example_size );
631 memDC.Clear();
632 memDC.SetUserScale( scale, scale );
633
634 // Get logical page size and margins.
635 PAGE_INFO pageDUMMY;
636
637 // Get page type
638 int idx = m_paperSizeComboBox->GetSelection();
639
640 if( idx < 0 )
641 idx = 0;
642
643 wxString pageFmtName = m_pageFmt[idx].BeforeFirst( ' ' );
644 bool portrait = clamped_layout_size.x < clamped_layout_size.y;
645 pageDUMMY.SetType( pageFmtName, portrait );
646
647 if( m_customFmt )
648 {
649 pageDUMMY.SetWidthMils( clamped_layout_size.x );
650 pageDUMMY.SetHeightMils( clamped_layout_size.y );
651 }
652
653 // Draw layout preview.
654 KIGFX::DS_RENDER_SETTINGS renderSettings;
655 COLOR_SETTINGS* colorSettings = m_parent->GetColorSettings();
656 COLOR4D bgColor = m_parent->GetDrawBgColor();
657 wxString emptyString;
658
660 {
661 GRResetPenAndBrush( &memDC );
662 renderSettings.SetDefaultPenWidth( 1 );
663 renderSettings.LoadColors( colorSettings );
664 renderSettings.SetPrintDC( &memDC );
665
670 {
672 renderSettings.SetLayerColor( LAYER_DRAWINGSHEET, color );
673 }
674
675 GRFilledRect( &memDC, VECTOR2I( 0, 0 ), m_layout_size, 0, bgColor, bgColor );
676
677 PrintDrawingSheet( &renderSettings, pageDUMMY, emptyString, emptyString, m_tb,
678 nullptr, m_screen->GetPageCount(), m_screen->GetPageNumber(), 1,
679 &Prj(), wxEmptyString, m_screen->GetVirtualPageNumber() == 1 );
680
681 memDC.SelectObject( wxNullBitmap );
683 }
684
686
687 // Refresh the dialog.
688 Layout();
689 Refresh();
690 }
691}
692
693
695{
696 int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
697 const wxString paperType = m_pageFmt[idx];
698
699 // here we assume translators will keep original paper size spellings
700 if( paperType.Contains( PAGE_INFO::Custom ) )
701 {
703
704 if( m_layout_size.x && m_layout_size.y )
705 {
706 if( m_layout_size.x < m_layout_size.y )
707 m_orientationComboBox->SetStringSelection( _( "Portrait" ) );
708 else
709 m_orientationComboBox->SetStringSelection( _( "Landscape" ) );
710 }
711 }
712 else
713 {
714 PAGE_INFO pageInfo; // SetType() later to lookup size
715
716 static const wxChar* papers[] = {
717 // longest common string first, since sequential search below
732 };
733
734 unsigned i;
735
736 for( i=0; i < arrayDim( papers ); ++i )
737 {
738 if( paperType.Contains( papers[i] ) )
739 {
740 pageInfo.SetType( papers[i] );
741 break;
742 }
743 }
744
745 wxASSERT( i != arrayDim(papers) ); // dialog UI match the above list?
746
747 VECTOR2I sz = pageInfo.GetSizeMils();
748 m_layout_size = wxSize( sz.x, sz.y );
749
750 // swap sizes to match orientation
751 bool isPortrait = (bool) m_orientationComboBox->GetSelection();
752
753 if( ( isPortrait && m_layout_size.x >= m_layout_size.y ) ||
754 ( !isPortrait && m_layout_size.x < m_layout_size.y ) )
755 {
757 }
758 }
759}
760
761
763{
764 double customSizeX = (double) m_customSizeX.GetValue() / m_iuPerMils;
765 double customSizeY = (double) m_customSizeY.GetValue() / m_iuPerMils;
766
767 // Prepare to painless double -> int conversion.
768 customSizeX = Clamp( double( INT_MIN ), customSizeX, double( INT_MAX ) );
769 customSizeY = Clamp( double( INT_MIN ), customSizeY, double( INT_MAX ) );
770 m_layout_size = wxSize( KiROUND( customSizeX ), KiROUND( customSizeY ) );
771}
772
773
774void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event )
775{
776 wxFileName fn = GetWksFileName();
777 wxString name = fn.GetFullName();
778 wxString path;
779
780 if( fn.IsAbsolute() )
781 {
782 path = fn.GetPath();
783 }
784 else
785 {
786 wxFileName expanded( ExpandEnvVarSubstitutions( GetWksFileName(), &m_parentFrame->Prj() ) );
787
788 if( expanded.IsAbsolute() )
789 path = expanded.GetPath();
790 else
792 }
793
794 // Display a file picker dialog
795 wxFileDialog fileDialog( this, _( "Select Drawing Sheet File" ), path, name,
796 DrawingSheetFileWildcard(), wxFD_DEFAULT_STYLE|wxFD_FILE_MUST_EXIST );
797
798 if( fileDialog.ShowModal() != wxID_OK )
799 return;
800
801 wxString fileName = fileDialog.GetPath();
802 wxString shortFileName;
803
804 // Try to use a project-relative path first:
805 if( !m_projectPath.IsEmpty() && fileName.StartsWith( m_projectPath ) )
806 {
807 fn = wxFileName( fileName );
808 fn.MakeRelativeTo( m_projectPath );
809 shortFileName = fn.GetFullPath();
810 }
811 else
812 {
813 // Failing that see if we can shorten it with env vars:
814 shortFileName = NormalizePath( fileName, &Pgm().GetLocalEnvVariables(), nullptr );
815 }
816
817 std::unique_ptr<DS_DATA_MODEL> ws = std::make_unique<DS_DATA_MODEL>();
818
819 if( ws->LoadDrawingSheet( fileName ) )
820 {
821 delete m_drawingSheet;
822
823 m_drawingSheet = ws.release();
824
825 SetWksFileName( shortFileName );
826
829 }
830}
int color
Definition: DXF_plotter.cpp:57
const char * name
Definition: DXF_plotter.cpp:56
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
BASE_SCREEN class implementation.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
@ small_folder
int GetPageCount() const
Definition: base_screen.h:72
int GetVirtualPageNumber() const
Definition: base_screen.h:75
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
Definition: base_screen.h:85
const wxString & GetPageNumber() const
Definition: base_screen.cpp:71
void SetContentModified(bool aModified=true)
Definition: base_screen.h:59
Color settings are a bit different than most of the settings objects in that there can be more than o...
Class DIALOG_PAGES_SETTINGS_BASE.
bool m_initialized
list of page sizes (not translated)
void SetCurrentPageSizeSelection(const wxString &aPaperSize)
void OnComment4TextUpdated(wxCommandEvent &event) override
void OnPageOrientationChoice(wxCommandEvent &event) override
void OnUserPageSizeYTextUpdated(wxCommandEvent &event) override
PAGE_INFO m_pageInfo
The max page size allowed by the caller frame.
DS_DATA_MODEL * m_drawingSheet
Temporary title block (basic inscriptions).
wxSize m_maxPageSizeMils
Logical drawing sheet size.
wxSize m_layout_size
Temporary bitmap for the drawing sheet example.
void OnRevisionTextUpdated(wxCommandEvent &event) override
DIALOG_PAGES_SETTINGS(EDA_DRAW_FRAME *aParent, double aIuPerMils, const wxSize &aMaxUserSizeMils)
const wxString GetWksFileName()
void OnComment6TextUpdated(wxCommandEvent &event) override
void OnDateApplyClick(wxCommandEvent &event) override
TITLE_BLOCK m_tb
true if the page selection is custom
void OnDateTextUpdated(wxCommandEvent &event) override
void OnComment3TextUpdated(wxCommandEvent &event) override
void OnCompanyTextUpdated(wxCommandEvent &event) override
void OnUserPageSizeXTextUpdated(wxCommandEvent &event) override
void OnComment7TextUpdated(wxCommandEvent &event) override
void OnPaperSizeChoice(wxCommandEvent &event) override
virtual bool onSavePageSettings()
virtual void onTransferDataToWindow()
void OnComment5TextUpdated(wxCommandEvent &event) override
void OnComment9TextUpdated(wxCommandEvent &event) override
void OnComment1TextUpdated(wxCommandEvent &event) override
void OnComment8TextUpdated(wxCommandEvent &event) override
void OnWksFileSelection(wxCommandEvent &event) override
virtual bool TransferDataToWindow() override
virtual bool TransferDataFromWindow() override
void SetWksFileName(const wxString &aFilename)
bool m_customFmt
Temporary page info.
void OnComment2TextUpdated(wxCommandEvent &event) override
wxBitmap * m_pageBitmap
the page layuout filename was changed
void OnTitleTextUpdated(wxCommandEvent &event) override
void SetupStandardButtons(std::map< int, wxString > aLabels={})
EDA_BASE_FRAME * m_parentFrame
Definition: dialog_shim.h:220
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:39
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
void SaveInString(wxString *aOutputString)
Save the description in a buffer.
void SetPageLayout(const char *aPageLayout, bool aAppend=false, const wxString &aSource=wxT("Sexpr_string"))
Populate the list from a S expr description stored in a string.
static void SetAltInstance(DS_DATA_MODEL *aLayout=nullptr)
Set an alternate instance of DS_DATA_MODEL.
bool LoadDrawingSheet(const wxString &aFullFileName=wxEmptyString, bool Append=false)
Populates the list with a custom layout or the default layout if no custom layout is available.
static const wxString ResolvePath(const wxString &aPath, const wxString &aProjectPath)
Resolve a path which might be project-relative or contain env variable references.
virtual void SaveProjectSettings()
Save changes to the project settings to the project (.pro) file.
bool IsType(FRAME_T aType) const
The base class for create windows for drawing purpose.
virtual void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)=0
virtual const TITLE_BLOCK & GetTitleBlock() const =0
virtual const PAGE_INFO & GetPageSettings() const =0
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)=0
virtual COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const
Returns a pointer to the active color theme settings.
virtual void OnPageSettingsChange()
Called when modifying the page settings.
virtual COLOR4D GetDrawBgColor() const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Store page-layout-specific render settings.
Definition: ds_painter.h:46
void LoadColors(const COLOR_SETTINGS *aSettings) override
Definition: ds_painter.cpp:57
void SetDefaultPenWidth(int aWidth)
void SetLayerColor(int aLayer, const COLOR4D &aColor)
Change the color used to draw a layer.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
void SetPrintDC(wxDC *aDC)
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Describe the page size and margins of a paper page on which to eventually print or plot.
Definition: page_info.h:54
static const wxChar A3[]
Definition: page_info.h:64
static const wxChar USLedger[]
Definition: page_info.h:76
static const wxChar USLetter[]
Definition: page_info.h:74
static const wxChar USLegal[]
Definition: page_info.h:75
static const wxChar A0[]
Definition: page_info.h:67
static void SetCustomWidthMils(int aWidthInMils)
Set the width of Custom page in mils for any custom page constructed or made via SetType() after maki...
Definition: page_info.cpp:232
static const wxChar A4[]
Definition: page_info.h:63
void SetWidthMils(int aWidthInMils)
Definition: page_info.cpp:244
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
Definition: page_info.cpp:187
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:77
static const wxChar A1[]
Definition: page_info.h:66
static const wxChar E[]
Definition: page_info.h:72
void SetHeightMils(int aHeightInMils)
Definition: page_info.cpp:258
static int GetCustomHeightMils()
Definition: page_info.h:187
static void SetCustomHeightMils(int aHeightInMils)
Set the height of Custom page in mils for any custom page constructed or made via SetType() after mak...
Definition: page_info.cpp:238
const VECTOR2I & GetSizeMils() const
Definition: page_info.h:135
static const wxChar B[]
Definition: page_info.h:69
static const wxChar A2[]
Definition: page_info.h:65
int GetHeightMils() const
Definition: page_info.h:133
static const wxChar GERBER[]
Definition: page_info.h:73
int GetWidthMils() const
Definition: page_info.h:130
const wxString & GetType() const
Definition: page_info.h:94
bool IsPortrait() const
Definition: page_info.h:117
static const wxChar D[]
Definition: page_info.h:71
static const wxChar C[]
Definition: page_info.h:70
static const wxChar A5[]
Definition: page_info.h:62
static const wxChar A[]
Definition: page_info.h:68
static int GetCustomWidthMils()
Definition: page_info.h:182
bool SetType(const wxString &aStandardPageDescriptionName, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
Definition: page_info.cpp:120
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:126
const wxString & GetCompany() const
Definition: title_block.h:96
void SetRevision(const wxString &aRevision)
Definition: title_block.h:81
void SetComment(int aIdx, const wxString &aComment)
Definition: title_block.h:101
const wxString & GetRevision() const
Definition: title_block.h:86
void SetTitle(const wxString &aTitle)
Definition: title_block.h:58
const wxString & GetDate() const
Definition: title_block.h:76
const wxString & GetComment(int aIdx) const
Definition: title_block.h:107
void SetCompany(const wxString &aCompany)
Definition: title_block.h:91
const wxString & GetTitle() const
Definition: title_block.h:63
void SetDate(const wxString &aDate)
Set the date field, and defaults to the current time and date.
Definition: title_block.h:71
virtual long long int GetValue()
Return the current value in Internal Units.
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
virtual bool Validate(double aMin, double aMax, EDA_UNITS aUnits=EDA_UNITS::UNSCALED)
Validate the control against the given range, informing the user of any errors found.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
const wxString ExpandEnvVarSubstitutions(const wxString &aString, PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition: common.cpp:267
The common library.
This file is part of the common library.
#define _HKI(x)
#define MAX_PAGE_EXAMPLE_SIZE
static const wxString pageFmts[]
#define _(s)
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, const PAGE_INFO &aPageInfo, const wxString &aFullSheetName, const wxString &aFileName, const TITLE_BLOCK &aTitleBlock, const std::map< wxString, wxString > *aProperties, int aSheetCount, const wxString &aPageNumber, double aMils2Iu, const PROJECT *aProject, const wxString &aSheetLayer, bool aIsFirstPage)
Print the border and title block.
#define PL_EDITOR_FRAME_NAME
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalize a file path to an environmental variable, if possible.
Definition: env_paths.cpp:71
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
@ FRAME_SCH
Definition: frame_type.h:34
@ FRAME_SCH_VIEWER_MODAL
Definition: frame_type.h:37
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:72
void GRFilledRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
Definition: gr_basic.cpp:394
wxString DrawingSheetFileWildcard()
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
Definition: layer_ids.h:217
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition: layer_ids.h:382
This file contains miscellaneous commonly used macros and functions.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
#define MIN_PAGE_SIZE_MILS
Min and max page sizes for clamping, in mils.
Definition: page_info.h:39
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
see class PGM_BASE
static const char * emptyString
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
const int scale
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85
constexpr T Clamp(const T &lower, const T &value, const T &upper)
Limit value within the range lower <= value <= upper.
Definition: util.h:64
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618
Definition of file extensions used in Kicad.