KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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 <core/arraydim.h>
27#include <eda_draw_frame.h>
28#include <eda_item.h>
29#include <embedded_files.h>
30#include <filename_resolver.h>
31#include <gr_basic.h>
32#include <kiface_base.h>
33#include <macros.h>
34#include <math/util.h> // for KiROUND
35#include <project.h>
36#include <tool/actions.h>
37#include <tool/tool_manager.h>
41#include <string_utils.h>
44#include <wx/valgen.h>
45#include <wx/tokenzr.h>
46#include <wx/filedlg.h>
47#include <wx/dcmemory.h>
48#include <wx/msgdlg.h>
49#include <confirm.h>
50
51#define MAX_PAGE_EXAMPLE_SIZE 200
52
53
54// List of page formats.
55// they are prefixed by "_HKI" (already in use for hotkeys) instead of "_",
56// because we need both the translated and the not translated version.
57// when displayed in dialog we should explicitly call wxGetTranslation()
58// to show the translated version.
59// See hotkeys_basic.h for more info
60#define _HKI( x ) wxT( x )
61static const wxString pageFmts[] =
62{
63 _HKI("A5 148x210mm"),
64 _HKI("A4 210x297mm"),
65 _HKI("A3 297x420mm"),
66 _HKI("A2 420x594mm"),
67 _HKI("A1 594x841mm"),
68 _HKI("A0 841x1189mm"),
69 _HKI("A 8.5x11in"),
70 _HKI("B 11x17in"),
71 _HKI("C 17x22in"),
72 _HKI("D 22x34in"),
73 _HKI("E 34x44in"),
74 _HKI("USLetter 8.5x11in"), // USLetter without space is correct
75 _HKI("USLegal 8.5x14in"), // USLegal without space is correct
76 _HKI("USLedger 11x17in"), // USLedger without space is correct
77 _HKI("User (Custom)"), // size defined by user. The string must contain "Custom"
78 // to be recognized in code
79};
80
82 EMBEDDED_FILES* aEmbeddedFiles, double aIuPerMils,
83 const VECTOR2D& aMaxUserSizeMils ) :
85 m_parent( aParent ),
86 m_screen( m_parent->GetScreen() ),
87 m_initialized( false ),
88 m_pageBitmap( nullptr ),
89 m_iuPerMils( aIuPerMils ),
90 m_embeddedFiles( aEmbeddedFiles ),
91 m_customSizeX( aParent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits ),
92 m_customSizeY( aParent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits )
93{
95 m_browseButton->SetBitmap( KiBitmapBundle( BITMAPS::small_folder ) );
96
97 m_maxPageSizeMils = aMaxUserSizeMils;
99 m_customFmt = false;
101
103 wxString serialization;
105 m_drawingSheet->SetPageLayout( TO_UTF8( serialization ) );
106
107 m_PickDate->SetValue( wxDateTime::Now() );
108
109 if( m_parent->GetName() == PL_EDITOR_FRAME_NAME )
110 {
111 SetTitle( _( "Preview Settings" ) );
112 m_staticTextPaper->SetLabel( _( "Preview Paper" ) );
113 m_staticTextTitleBlock->SetLabel( _( "Preview Title Block Data" ) );
114 }
115 else
116 {
117 SetTitle( _( "Page Settings" ) );
118 m_staticTextPaper->SetLabel( _( "Paper" ) );
119 m_staticTextTitleBlock->SetLabel( _( "Title Block" ) );
120 }
121
125
127
128 Centre();
129}
130
131
133{
134 delete m_pageBitmap;
135 delete m_drawingSheet;
136}
137
138
140{
141 // initialize page format choice box and page format list.
142 // The first shows translated strings, the second contains not translated strings
143 m_paperSizeComboBox->Clear();
144
145 for( const wxString& pageFmt : pageFmts )
146 {
147 m_pageFmt.Add( pageFmt );
148 m_paperSizeComboBox->Append( wxGetTranslation( pageFmt ) );
149 }
150
151 // initialize the drawing sheet filename
153
157
158 // only a click fires the "selection changed" event, so have to fabricate this check
159 wxCommandEvent dummy;
161
162 if( m_customFmt )
163 {
166 }
167 else
168 {
171 }
172
173 m_TextRevision->SetValue( m_tb.GetRevision() );
174 m_TextDate->SetValue( m_tb.GetDate() );
175 m_TextTitle->SetValue( m_tb.GetTitle() );
176 m_TextCompany->SetValue( m_tb.GetCompany() );
177 m_TextComment1->SetValue( m_tb.GetComment( 0 ) );
178 m_TextComment2->SetValue( m_tb.GetComment( 1 ) );
179 m_TextComment3->SetValue( m_tb.GetComment( 2 ) );
180 m_TextComment4->SetValue( m_tb.GetComment( 3 ) );
181 m_TextComment5->SetValue( m_tb.GetComment( 4 ) );
182 m_TextComment6->SetValue( m_tb.GetComment( 5 ) );
183 m_TextComment7->SetValue( m_tb.GetComment( 6 ) );
184 m_TextComment8->SetValue( m_tb.GetComment( 7 ) );
185 m_TextComment9->SetValue( m_tb.GetComment( 8 ) );
186
187 // The default is to disable aall these fields for the "generic" dialog
188 m_TextSheetCount->Show( false );
189 m_TextSheetNumber->Show( false );
190 m_PaperExport->Show( false );
191 m_RevisionExport->Show( false );
192 m_DateExport->Show( false );
193 m_TitleExport->Show( false );
194 m_CompanyExport->Show( false );
195 m_Comment1Export->Show( false );
196 m_Comment2Export->Show( false );
197 m_Comment3Export->Show( false );
198 m_Comment4Export->Show( false );
199 m_Comment5Export->Show( false );
200 m_Comment6Export->Show( false );
201 m_Comment7Export->Show( false );
202 m_Comment8Export->Show( false );
203 m_Comment9Export->Show( false );
204
206
209
210 GetSizer()->SetSizeHints( this );
211
212 m_initialized = true;
213
214 return true;
215}
216
217
219{
220 int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
221 const wxString paperType = m_pageFmt[idx];
222
223 if( paperType.Contains( PAGE_INFO::Custom ) )
224 {
226 return false;
227
229 return false;
230 }
231
232 if( SavePageSettings() )
233 {
235
238
239 // Call the post processing (if any) after changes
241 }
242
243 return true;
244}
245
246
247void DIALOG_PAGES_SETTINGS::OnPaperSizeChoice( wxCommandEvent& event )
248{
249 int idx = m_paperSizeComboBox->GetSelection();
250
251 if( idx < 0 )
252 idx = 0;
253
254 const wxString paperType = m_pageFmt[idx];
255
256 if( paperType.Contains( PAGE_INFO::Custom ) )
257 {
258 m_staticTextOrient->Enable( false );
259 m_orientationComboBox->Enable( false );
260
261 m_staticTextCustSize->Enable( true );
262 m_customSizeX.Enable( true );
263 m_customSizeY.Enable( true );
264 m_customFmt = true;
265 }
266 else
267 {
268 m_staticTextOrient->Enable( true );
269 m_orientationComboBox->Enable( true );
270
271 m_staticTextCustSize->Enable( false );
272 m_customSizeX.Enable( false );
273 m_customSizeY.Enable( false );
274 m_customFmt = false;
275 }
276
279}
280
281
283{
284 if( m_initialized )
285 {
288 }
289}
290
291
293{
294 if( m_initialized )
295 {
298 }
299}
300
301
303{
304 if( m_initialized )
305 {
308 }
309}
310
311
313{
314 if( m_initialized && m_TextRevision->IsModified() )
315 {
317 m_tb.SetRevision( m_TextRevision->GetValue() );
319 }
320}
321
322
323void DIALOG_PAGES_SETTINGS::OnDateTextUpdated( wxCommandEvent& event )
324{
325 if( m_initialized && m_TextDate->IsModified() )
326 {
328 m_tb.SetDate( m_TextDate->GetValue() );
330 }
331}
332
333
334void DIALOG_PAGES_SETTINGS::OnTitleTextUpdated( wxCommandEvent& event )
335{
336 if( m_initialized && m_TextTitle->IsModified() )
337 {
339 m_tb.SetTitle( m_TextTitle->GetValue() );
341 }
342}
343
344
346{
347 if( m_initialized && m_TextCompany->IsModified() )
348 {
350 m_tb.SetCompany( m_TextCompany->GetValue() );
352 }
353}
354
355
357{
358 if( m_initialized && m_TextComment1->IsModified() )
359 {
361 m_tb.SetComment( 0, m_TextComment1->GetValue() );
363 }
364}
365
366
368{
369 if( m_initialized && m_TextComment2->IsModified() )
370 {
372 m_tb.SetComment( 1, m_TextComment2->GetValue() );
374 }
375}
376
377
379{
380 if( m_initialized && m_TextComment3->IsModified() )
381 {
383 m_tb.SetComment( 2, m_TextComment3->GetValue() );
385 }
386}
387
388
390{
391 if( m_initialized && m_TextComment4->IsModified() )
392 {
394 m_tb.SetComment( 3, m_TextComment4->GetValue() );
396 }
397}
398
399
401{
402 if( m_initialized && m_TextComment5->IsModified() )
403 {
405 m_tb.SetComment( 4, m_TextComment5->GetValue() );
407 }
408}
409
410
412{
413 if( m_initialized && m_TextComment6->IsModified() )
414 {
416 m_tb.SetComment( 5, m_TextComment6->GetValue() );
418 }
419}
420
421
423{
424 if( m_initialized && m_TextComment7->IsModified() )
425 {
427 m_tb.SetComment( 6, m_TextComment7->GetValue() );
429 }
430}
431
432
434{
435 if( m_initialized && m_TextComment8->IsModified() )
436 {
438 m_tb.SetComment( 7, m_TextComment8->GetValue() );
440 }
441}
442
443
445{
446 if( m_initialized && m_TextComment9->IsModified() )
447 {
449 m_tb.SetComment( 8, m_TextComment9->GetValue() );
451 }
452}
453
454
455void DIALOG_PAGES_SETTINGS::OnDateApplyClick( wxCommandEvent& event )
456{
457 wxDateTime datetime = m_PickDate->GetValue();
458 wxString date =
459 // We can choose different formats. Should probably be kept in sync with CURRENT_DATE
460 // formatting in TITLE_BLOCK.
461 //
462 // datetime.Format( wxLocale::GetInfo( wxLOCALE_SHORT_DATE_FMT ) );
463 // datetime.Format( wxLocale::GetInfo( wxLOCALE_LONG_DATE_FMT ) );
464 // datetime.Format( wxT("%Y-%b-%d") );
465 datetime.FormatISODate();
466
467 m_TextDate->SetValue( date );
468}
469
470
472{
473 bool success = false;
474 wxString msg;
475 wxString fileName = GetWksFileName();
476
477 wxString fullFileName = m_filenameResolver->ResolvePath( fileName, m_projectPath, { m_embeddedFiles } );
478
480
481 if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( fullFileName, &msg ) )
482 {
483 DisplayErrorMessage( this, wxString::Format( _( "Error loading drawing sheet '%s'." ), fullFileName ), msg );
484 }
485
487
488 int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
489 const wxString paperType = m_pageFmt[idx];
490
491 if( paperType.Contains( PAGE_INFO::Custom ) )
492 {
494
496
497 if( success )
498 {
501
504 }
505 }
506 else
507 {
508 // search for longest common string first, e.g. A4 before A
509 if( paperType.Contains( PAGE_INFO::USLetter ) )
511 else if( paperType.Contains( PAGE_INFO::USLegal ) )
513 else if( paperType.Contains( PAGE_INFO::USLedger ) )
515 else if( paperType.Contains( PAGE_INFO::GERBER ) )
517 else if( paperType.Contains( PAGE_INFO::A5 ) )
518 success = m_pageInfo.SetType( PAGE_INFO::A5 );
519 else if( paperType.Contains( PAGE_INFO::A4 ) )
520 success = m_pageInfo.SetType( PAGE_INFO::A4 );
521 else if( paperType.Contains( PAGE_INFO::A3 ) )
522 success = m_pageInfo.SetType( PAGE_INFO::A3 );
523 else if( paperType.Contains( PAGE_INFO::A2 ) )
524 success = m_pageInfo.SetType( PAGE_INFO::A2 );
525 else if( paperType.Contains( PAGE_INFO::A1 ) )
526 success = m_pageInfo.SetType( PAGE_INFO::A1 );
527 else if( paperType.Contains( PAGE_INFO::A0 ) )
528 success = m_pageInfo.SetType( PAGE_INFO::A0 );
529 else if( paperType.Contains( PAGE_INFO::A ) )
530 success = m_pageInfo.SetType( PAGE_INFO::A );
531 else if( paperType.Contains( PAGE_INFO::B ) )
532 success = m_pageInfo.SetType( PAGE_INFO::B );
533 else if( paperType.Contains( PAGE_INFO::C ) )
534 success = m_pageInfo.SetType( PAGE_INFO::C );
535 else if( paperType.Contains( PAGE_INFO::D ) )
536 success = m_pageInfo.SetType( PAGE_INFO::D );
537 else if( paperType.Contains( PAGE_INFO::E ) )
538 success = m_pageInfo.SetType( PAGE_INFO::E );
539
540 if( success )
541 {
542 int choice = m_orientationComboBox->GetSelection();
543 m_pageInfo.SetPortrait( choice != 0 );
544 }
545 }
546
547 if( !success )
548 {
549 wxFAIL_MSG( "The translation for paper size must preserve original spellings" );
551 }
552
554
555 m_tb.SetRevision( m_TextRevision->GetValue() );
556 m_tb.SetDate( m_TextDate->GetValue() );
557 m_tb.SetCompany( m_TextCompany->GetValue() );
558 m_tb.SetTitle( m_TextTitle->GetValue() );
559 m_tb.SetComment( 0, m_TextComment1->GetValue() );
560 m_tb.SetComment( 1, m_TextComment2->GetValue() );
561 m_tb.SetComment( 2, m_TextComment3->GetValue() );
562 m_tb.SetComment( 3, m_TextComment4->GetValue() );
563 m_tb.SetComment( 4, m_TextComment5->GetValue() );
564 m_tb.SetComment( 5, m_TextComment6->GetValue() );
565 m_tb.SetComment( 6, m_TextComment7->GetValue() );
566 m_tb.SetComment( 7, m_TextComment8->GetValue() );
567 m_tb.SetComment( 8, m_TextComment9->GetValue() );
568
570
571 return onSavePageSettings();
572}
573
574
576{
577 // search all the not translated label list containing our paper type
578 for( unsigned i = 0; i < m_pageFmt.GetCount(); ++i )
579 {
580 // parse each label looking for aPaperSize within it
581 wxStringTokenizer st( m_pageFmt[i] );
582
583 while( st.HasMoreTokens() )
584 {
585 if( st.GetNextToken() == aPaperSize )
586 {
587 m_paperSizeComboBox->SetSelection( i );
588 return;
589 }
590 }
591 }
592}
593
594
596{
597 int lyWidth, lyHeight;
598
599 VECTOR2D clamped_layout_size( std::clamp( m_layout_size.x, (double) MIN_PAGE_SIZE_MILS,
601 std::clamp( m_layout_size.y, (double) MIN_PAGE_SIZE_MILS,
603
604 double lyRatio = clamped_layout_size.x < clamped_layout_size.y ?
605 (double) clamped_layout_size.y / clamped_layout_size.x :
606 (double) clamped_layout_size.x / clamped_layout_size.y;
607
608 if( clamped_layout_size.x < clamped_layout_size.y )
609 {
610 lyHeight = MAX_PAGE_EXAMPLE_SIZE;
611 lyWidth = KiROUND( (double) lyHeight / lyRatio );
612 }
613 else
614 {
615 lyWidth = MAX_PAGE_EXAMPLE_SIZE;
616 lyHeight = KiROUND( (double) lyWidth / lyRatio );
617 }
618
619 if( m_pageBitmap )
620 {
621 m_PageLayoutExampleBitmap->SetBitmap( wxNullBitmap );
622 delete m_pageBitmap;
623 }
624
625 m_pageBitmap = new wxBitmap( lyWidth + 1, lyHeight + 1 );
626
627 if( m_pageBitmap->IsOk() )
628 {
629 double scaleW = (double) lyWidth / clamped_layout_size.x;
630 double scaleH = (double) lyHeight / clamped_layout_size.y;
631 double scale = std::min( scaleW, scaleH );
632
633 // Prepare DC.
634 wxSize example_size( lyWidth + 1, lyHeight + 1 );
635 wxMemoryDC memDC;
636 memDC.SelectObject( *m_pageBitmap );
637 memDC.SetClippingRegion( wxPoint( 0, 0 ), example_size );
638 memDC.Clear();
639 memDC.SetUserScale( scale, scale );
640
641 // Get logical page size and margins.
642 PAGE_INFO pageDUMMY;
643
644 // Get page type
645 int idx = m_paperSizeComboBox->GetSelection();
646
647 if( idx < 0 )
648 idx = 0;
649
650 wxString pageFmtName = m_pageFmt[idx].BeforeFirst( ' ' );
651 bool portrait = clamped_layout_size.x < clamped_layout_size.y;
652 pageDUMMY.SetType( pageFmtName, portrait );
653
654 if( m_customFmt )
655 {
656 pageDUMMY.SetWidthMils( clamped_layout_size.x );
657 pageDUMMY.SetHeightMils( clamped_layout_size.y );
658 }
659
660 // Draw layout preview.
661 KIGFX::DS_RENDER_SETTINGS renderSettings;
662 COLOR_SETTINGS* colorSettings = m_parent->GetColorSettings();
663 COLOR4D bgColor = m_parent->GetDrawBgColor();
664 wxString emptyString;
665
667 {
668 GRResetPenAndBrush( &memDC );
669 renderSettings.SetDefaultPenWidth( 1 );
670 renderSettings.LoadColors( colorSettings );
671 renderSettings.SetPrintDC( &memDC );
672
676 {
678 renderSettings.SetLayerColor( LAYER_DRAWINGSHEET, color );
679 }
680
681 GRFilledRect( &memDC, VECTOR2I( 0, 0 ), m_layout_size, 0, bgColor, bgColor );
682
683 PrintDrawingSheet( &renderSettings, pageDUMMY, emptyString, emptyString, emptyString,
685 1, &Prj(), wxEmptyString, m_screen->GetVirtualPageNumber() == 1 );
686
687 memDC.SelectObject( wxNullBitmap );
689 }
690
692
693 // Refresh the dialog.
694 Layout();
695 Refresh();
696 }
697}
698
699
701{
702 int idx = std::max( m_paperSizeComboBox->GetSelection(), 0 );
703 const wxString paperType = m_pageFmt[idx];
704
705 // here we assume translators will keep original paper size spellings
706 if( paperType.Contains( PAGE_INFO::Custom ) )
707 {
709
711 {
713 m_orientationComboBox->SetStringSelection( _( "Portrait" ) );
714 else
715 m_orientationComboBox->SetStringSelection( _( "Landscape" ) );
716 }
717 }
718 else
719 {
720 PAGE_INFO pageInfo; // SetType() later to lookup size
721
722 static const wxChar* papers[] = {
723 // longest common string first, since sequential search below
738 };
739
740 unsigned i;
741
742 for( i=0; i < arrayDim( papers ); ++i )
743 {
744 if( paperType.Contains( papers[i] ) )
745 {
746 pageInfo.SetType( papers[i] );
747 break;
748 }
749 }
750
751 wxASSERT( i != arrayDim(papers) ); // dialog UI match the above list?
752
753 VECTOR2D sz = pageInfo.GetSizeMils();
754 m_layout_size = VECTOR2D( sz.x, sz.y );
755
756 // swap sizes to match orientation
757 bool isPortrait = (bool) m_orientationComboBox->GetSelection();
758
759 if( ( isPortrait && m_layout_size.x >= m_layout_size.y ) ||
760 ( !isPortrait && m_layout_size.x < m_layout_size.y ) )
761 {
762 std::swap( m_layout_size.x, m_layout_size.y );
763 }
764 }
765}
766
767
769{
770 double customSizeX = (double) m_customSizeX.GetDoubleValue() / m_iuPerMils;
771 double customSizeY = (double) m_customSizeY.GetDoubleValue() / m_iuPerMils;
772
773 // Ensure layout size can be converted to int coordinates later
774 customSizeX = std::clamp( customSizeX, double( INT_MIN ), double( INT_MAX ) );
775 customSizeY = std::clamp( customSizeY, double( INT_MIN ), double( INT_MAX ) );
776 m_layout_size = VECTOR2D( customSizeX, customSizeY );
777}
778
779
780void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event )
781{
782 wxFileName fn = GetWksFileName();
783 wxString name = fn.GetFullName();
784 wxString path;
785 wxString msg;
786
787 if( fn.IsAbsolute() )
788 {
789 path = fn.GetPath();
790 }
791 else
792 {
793 wxFileName expanded( ExpandEnvVarSubstitutions( GetWksFileName(), &m_parentFrame->Prj() ) );
794
795 if( expanded.IsAbsolute() )
796 path = expanded.GetPath();
797 else
799 }
800
801 // Display a file picker dialog
802 FILEDLG_OPEN_EMBED_FILE customize;
803 wxFileDialog fileDialog( this, _( "Drawing Sheet File" ), path, name,
805 wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );
806
807 if( m_embeddedFiles )
808 fileDialog.SetCustomizeHook( customize );
809
810 if( fileDialog.ShowModal() != wxID_OK )
811 return;
812
813 wxString fileName = fileDialog.GetPath();
814 wxString shortFileName;
815
816 if( m_embeddedFiles && customize.GetEmbed() )
817 {
818 fn.Assign( fileName );
820 shortFileName = result->GetLink();
821 fileName = m_embeddedFiles->GetTemporaryFileName( result->name ).GetFullPath();
822 }
823 else if( !m_projectPath.IsEmpty() && fileName.StartsWith( m_projectPath ) )
824 {
825 // Try to use a project-relative path
826 fn = wxFileName( fileName );
827 fn.MakeRelativeTo( m_projectPath );
828 shortFileName = fn.GetFullPath();
829 }
830 else
831 {
832 // Failing that see if we can shorten it with env vars:
833 shortFileName = NormalizePath( fileName, &Pgm().GetLocalEnvVariables(), nullptr );
834 }
835
836 std::unique_ptr<DS_DATA_MODEL> ws = std::make_unique<DS_DATA_MODEL>();
837
838 if( !ws->LoadDrawingSheet( fileName, &msg ) )
839 {
841 wxString::Format( _( "Error loading drawing sheet '%s'.\n%s" ),
842 fileName ),
843 msg );
844 return;
845 }
846
847 delete m_drawingSheet;
848
849 m_drawingSheet = ws.release();
850
851 SetWksFileName( shortFileName );
852
855}
int color
Definition: DXF_plotter.cpp:63
const char * name
Definition: DXF_plotter.cpp:62
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
BASE_SCREEN class implementation.
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition: bitmap.cpp:110
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
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:70
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.
FILENAME_RESOLVER * m_filenameResolver
DS_DATA_MODEL * m_drawingSheet
Temporary title block (basic inscriptions).
DIALOG_PAGES_SETTINGS(EDA_DRAW_FRAME *aParent, EMBEDDED_FILES *aEmbeddedFiles, double aIuPerMils, const VECTOR2D &aMaxUserSizeMils)
void OnRevisionTextUpdated(wxCommandEvent &event) override
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
VECTOR2D m_layout_size
Temporary bitmap for the drawing sheet example.
void OnComment3TextUpdated(wxCommandEvent &event) override
void OnCompanyTextUpdated(wxCommandEvent &event) override
void OnUserPageSizeXTextUpdated(wxCommandEvent &event) override
void OnComment7TextUpdated(wxCommandEvent &event) override
EMBEDDED_FILES * m_embeddedFiles
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
VECTOR2D m_maxPageSizeMils
Logical drawing sheet size.
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:212
Handle the graphic items list to draw/plot the frame and title block.
Definition: ds_data_model.h:39
static DS_DATA_MODEL & GetTheInstance()
Return 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.
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
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
wxFileName GetTemporaryFileName(const wxString &aName) const
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Load a file from disk and adds it to the collection.
Provide an extensible class to resolve 3D model paths.
wxString ResolvePath(const wxString &aFileName, const wxString &aWorkingPath, std::vector< const EMBEDDED_FILES * > aEmbeddedFilesStack)
Determine the full path of the given file name.
void SetProgramBase(PGM_BASE *aBase)
Set a pointer to the application's PGM_BASE instance used to extract the local env vars.
bool SetProject(const PROJECT *aProject, bool *flgChanged=nullptr)
Set the current KiCad project directory as the first entry in the model path list.
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:59
static const wxChar A3[]
Definition: page_info.h:69
static const wxChar USLedger[]
Definition: page_info.h:81
static const wxChar USLetter[]
Definition: page_info.h:79
static const wxChar USLegal[]
Definition: page_info.h:80
static const wxChar A0[]
Definition: page_info.h:72
static const wxChar A4[]
Definition: page_info.h:68
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
Definition: page_info.cpp:189
static void SetCustomWidthMils(double aWidthInMils)
Set the width of Custom page in mils for any custom page constructed or made via SetType() after maki...
Definition: page_info.cpp:236
static const wxChar Custom[]
"User" defined page type
Definition: page_info.h:82
void SetHeightMils(double aHeightInMils)
Definition: page_info.cpp:262
static const wxChar A1[]
Definition: page_info.h:71
static const wxChar E[]
Definition: page_info.h:77
static const wxChar B[]
Definition: page_info.h:74
static const wxChar A2[]
Definition: page_info.h:70
const VECTOR2D & GetSizeMils() const
Definition: page_info.h:144
static double GetCustomHeightMils()
Definition: page_info.h:196
double GetHeightMils() const
Definition: page_info.h:141
static const wxChar GERBER[]
Definition: page_info.h:78
const wxString & GetType() const
Definition: page_info.h:99
double GetWidthMils() const
Definition: page_info.h:136
bool IsPortrait() const
Definition: page_info.h:122
static const wxChar D[]
Definition: page_info.h:76
static const wxChar C[]
Definition: page_info.h:75
void SetWidthMils(double aWidthInMils)
Definition: page_info.cpp:248
static double GetCustomWidthMils()
Definition: page_info.h:191
static void SetCustomHeightMils(double aHeightInMils)
Set the height of Custom page in mils for any custom page constructed or made via SetType() after mak...
Definition: page_info.cpp:242
static const wxChar A5[]
Definition: page_info.h:67
static const wxChar A[]
Definition: page_info.h:73
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:122
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:148
void SetBitmap(const wxBitmapBundle &aBmp)
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
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
virtual double GetDoubleValue()
Return the current value in Internal Units.
virtual void SetDoubleValue(double aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
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.
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition: common.cpp:355
The common library.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:194
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 &aSheetName, const wxString &aSheetPath, 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:73
Helper functions to substitute paths with environmental variables.
@ FRAME_SCH_SYMBOL_EDITOR
Definition: frame_type.h:35
@ FRAME_SCH_VIEWER
Definition: frame_type.h:36
@ FRAME_SCH
Definition: frame_type.h:34
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:73
void GRFilledRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
Definition: gr_basic.cpp:404
static wxString DrawingSheetFileWildcard()
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
Definition: layer_ids.h:277
@ LAYER_SCHEMATIC_DRAWINGSHEET
Definition: layer_ids.h:485
This file contains miscellaneous commonly used macros and functions.
#define MIN_PAGE_SIZE_MILS
Min and max page sizes for clamping, in mils.
Definition: page_info.h:38
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
PGM_BASE & Pgm()
The global program "get" accessor.
Definition: pgm_base.cpp:893
see class PGM_BASE
static const char * emptyString
const int scale
std::vector< FAB_LAYER_COLOR > dummy
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: string_utils.h:429
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695
VECTOR2< double > VECTOR2D
Definition: vector2d.h:694
Definition of file extensions used in Kicad.