42#include <wx/tokenzr.h>
43#include <wx/filedlg.h>
44#include <wx/dcmemory.h>
46#define MAX_PAGE_EXAMPLE_SIZE 200
55#define _HKI( x ) wxT( x )
63 _HKI(
"A0 841x1189mm"),
69 _HKI(
"USLetter 8.5x11in"),
70 _HKI(
"USLegal 8.5x14in"),
71 _HKI(
"USLedger 11x17in"),
72 _HKI(
"User (Custom)"),
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 )
96 wxString serialization;
104 SetTitle(
_(
"Preview Settings" ) );
110 SetTitle(
_(
"Page Settings" ) );
134 for(
const wxString& pageFmt :
pageFmts )
148 wxCommandEvent
dummy;
199 GetSizer()->SetSizeHints(
this );
210 const wxString paperType =
m_pageFmt[idx];
243 const wxString paperType =
m_pageFmt[idx];
454 datetime.FormatISODate();
462 bool success =
false;
470 if( !fullFileName.IsEmpty() && !wxFileExists( fullFileName ) )
473 msg.Printf(
_(
"Drawing sheet file '%s' not found." ), fullFileName );
484 const wxString paperType =
m_pageFmt[idx];
544 wxFAIL_MSG(
"The translation for paper size must preserve original spellings" );
573 for(
unsigned i = 0; i <
m_pageFmt.GetCount(); ++i )
578 while( st.HasMoreTokens() )
580 if( st.GetNextToken() == aPaperSize )
592 int lyWidth, lyHeight;
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;
601 if( clamped_layout_size.x < clamped_layout_size.y )
604 lyWidth =
KiROUND( (
double) lyHeight / lyRatio );
609 lyHeight =
KiROUND( (
double) lyWidth / lyRatio );
618 m_pageBitmap =
new wxBitmap( lyWidth + 1, lyHeight + 1 );
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 );
627 wxSize example_size( lyWidth + 1, lyHeight + 1 );
630 memDC.SetClippingRegion( wxPoint( 0, 0 ), example_size );
643 wxString pageFmtName =
m_pageFmt[idx].BeforeFirst(
' ' );
644 bool portrait = clamped_layout_size.x < clamped_layout_size.y;
645 pageDUMMY.
SetType( pageFmtName, portrait );
681 memDC.SelectObject( wxNullBitmap );
697 const wxString paperType =
m_pageFmt[idx];
716 static const wxChar* papers[] = {
736 for( i=0; i <
arrayDim( papers ); ++i )
738 if( paperType.Contains( papers[i] ) )
768 customSizeX =
Clamp(
double( INT_MIN ), customSizeX,
double( INT_MAX ) );
769 customSizeY =
Clamp(
double( INT_MIN ), customSizeY,
double( INT_MAX ) );
777 wxString
name = fn.GetFullName();
780 if( fn.IsAbsolute() )
788 if( expanded.IsAbsolute() )
789 path = expanded.GetPath();
795 wxFileDialog fileDialog(
this,
_(
"Select Drawing Sheet File" ),
path,
name,
798 if( fileDialog.ShowModal() != wxID_OK )
801 wxString fileName = fileDialog.GetPath();
802 wxString shortFileName;
807 fn = wxFileName( fileName );
809 shortFileName = fn.GetFullPath();
814 shortFileName =
NormalizePath( fileName, &
Pgm().GetLocalEnvVariables(),
nullptr );
817 std::unique_ptr<DS_DATA_MODEL> ws = std::make_unique<DS_DATA_MODEL>();
819 if( ws->LoadDrawingSheet( fileName ) )
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
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...
int GetVirtualPageNumber() const
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
const wxString & GetPageNumber() const
void SetContentModified(bool aModified=true)
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.
wxTextCtrl * m_TextCompany
wxCheckBox * m_Comment3Export
wxCheckBox * m_Comment6Export
wxCheckBox * m_Comment7Export
wxCheckBox * m_Comment4Export
wxChoice * m_orientationComboBox
wxTextCtrl * m_TextComment4
wxChoice * m_paperSizeComboBox
wxTextCtrl * m_TextComment9
wxTextCtrl * m_TextRevision
wxStaticText * m_staticTextPaper
wxTextCtrl * m_TextComment2
wxCheckBox * m_PaperExport
wxTextCtrl * m_TextComment8
wxCheckBox * m_RevisionExport
wxStaticText * m_staticTextTitleBlock
wxCheckBox * m_DateExport
wxStaticText * m_TextSheetCount
wxStaticText * m_TextSheetNumber
wxStaticBitmap * m_PageLayoutExampleBitmap
STD_BITMAP_BUTTON * m_browseButton
wxTextCtrl * m_TextComment3
wxCheckBox * m_Comment9Export
wxTextCtrl * m_TextComment6
wxTextCtrl * m_TextComment5
wxDatePickerCtrl * m_PickDate
wxStaticText * m_staticTextCustSize
wxCheckBox * m_CompanyExport
wxTextCtrl * m_TextComment7
wxCheckBox * m_Comment2Export
wxTextCtrl * m_TextComment1
wxStaticText * m_staticTextOrient
wxCheckBox * m_Comment1Export
wxCheckBox * m_Comment8Export
wxCheckBox * m_TitleExport
wxCheckBox * m_Comment5Export
EDA_DRAW_FRAME * m_parent
bool m_initialized
list of page sizes (not translated)
void SetCurrentPageSizeSelection(const wxString &aPaperSize)
bool m_localPrjConfigChanged
void OnComment4TextUpdated(wxCommandEvent &event) override
void UpdateDrawingSheetExample()
void OnPageOrientationChoice(wxCommandEvent &event) override
void OnUserPageSizeYTextUpdated(wxCommandEvent &event) override
PAGE_INFO m_pageInfo
The max page size allowed by the caller frame.
void GetCustomSizeMilsFromDialog()
DS_DATA_MODEL * m_drawingSheet
Temporary title block (basic inscriptions).
void OnRevisionTextUpdated(wxCommandEvent &event) override
VECTOR2I m_maxPageSizeMils
Logical drawing sheet size.
UNIT_BINDER m_customSizeY
const wxString GetWksFileName()
bool LocalPrjConfigChanged()
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
DIALOG_PAGES_SETTINGS(EDA_DRAW_FRAME *aParent, double aIuPerMils, const VECTOR2I &aMaxUserSizeMils)
void OnComment3TextUpdated(wxCommandEvent &event) override
void OnCompanyTextUpdated(wxCommandEvent &event) override
VECTOR2I m_layout_size
Temporary bitmap for the drawing sheet example.
void OnUserPageSizeXTextUpdated(wxCommandEvent &event) override
void OnComment7TextUpdated(wxCommandEvent &event) override
virtual ~DIALOG_PAGES_SETTINGS()
void OnPaperSizeChoice(wxCommandEvent &event) override
virtual bool onSavePageSettings()
void GetPageLayoutInfoFromDialog()
virtual void onTransferDataToWindow()
void OnComment5TextUpdated(wxCommandEvent &event) override
void OnComment9TextUpdated(wxCommandEvent &event) override
UNIT_BINDER m_customSizeX
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
Handle the graphic items list to draw/plot the frame and title block.
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 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
A color representation with 4 components: red, green, blue, alpha.
Store page-layout-specific render settings.
void LoadColors(const COLOR_SETTINGS *aSettings) override
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.
static const wxChar USLedger[]
static const wxChar USLetter[]
static const wxChar USLegal[]
static void SetCustomWidthMils(int aWidthInMils)
Set the width of Custom page in mils for any custom page constructed or made via SetType() after maki...
void SetWidthMils(int aWidthInMils)
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
static const wxChar Custom[]
"User" defined page type
void SetHeightMils(int aHeightInMils)
static int GetCustomHeightMils()
static void SetCustomHeightMils(int aHeightInMils)
Set the height of Custom page in mils for any custom page constructed or made via SetType() after mak...
const VECTOR2I & GetSizeMils() const
int GetHeightMils() const
static const wxChar GERBER[]
const wxString & GetType() const
static int GetCustomWidthMils()
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.
virtual const wxString GetProjectPath() const
Return the full path of the project.
const wxString & GetCompany() const
void SetRevision(const wxString &aRevision)
void SetComment(int aIdx, const wxString &aComment)
const wxString & GetRevision() const
void SetTitle(const wxString &aTitle)
const wxString & GetDate() const
const wxString & GetComment(int aIdx) const
void SetCompany(const wxString &aCompany)
const wxString & GetTitle() const
void SetDate(const wxString &aDate)
Set the date field, and defaults to the current time and date.
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, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
This file is part of the common library.
#define MAX_PAGE_EXAMPLE_SIZE
static const wxString pageFmts[]
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.
@ FRAME_SCH_SYMBOL_EDITOR
void GRResetPenAndBrush(wxDC *DC)
void GRFilledRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
wxString DrawingSheetFileWildcard()
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
@ LAYER_SCHEMATIC_DRAWINGSHEET
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.
#define MIN_PAGE_SIZE_MILS
Min and max page sizes for clamping, in mils.
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
static const char * emptyString
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
std::vector< FAB_LAYER_COLOR > dummy
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
constexpr T Clamp(const T &lower, const T &value, const T &upper)
Limit value within the range lower <= value <= upper.
Definition of file extensions used in Kicad.