40 #include <wx/valgen.h> 41 #include <wx/tokenzr.h> 42 #include <wx/filedlg.h> 43 #include <wx/dcmemory.h> 45 #define MAX_PAGE_EXAMPLE_SIZE 200 54 #define _HKI( x ) wxT( x ) 62 _HKI(
"A0 841x1189mm"),
68 _HKI(
"USLetter 8.5x11in"),
69 _HKI(
"USLegal 8.5x14in"),
70 _HKI(
"USLedger 11x17in"),
71 _HKI(
"User (Custom)"),
76 const wxSize& aMaxUserSizeMils ) :
79 m_screen( m_parent->GetScreen() ),
80 m_initialized( false ),
81 m_pageBitmap( nullptr ),
82 m_iuPerMils( aIuPerMils ),
83 m_customSizeX( aParent, m_userSizeXLabel, m_userSizeXCtrl, m_userSizeXUnits ),
84 m_customSizeY( aParent, m_userSizeYLabel, m_userSizeYCtrl, m_userSizeYUnits )
95 wxString serialization;
103 SetTitle(
_(
"Preview Settings" ) );
109 SetTitle(
_(
"Page Settings" ) );
133 for(
const wxString& pageFmt :
pageFmts )
147 wxCommandEvent
dummy;
198 GetSizer()->SetSizeHints(
this );
211 const wxString paperType =
m_pageFmt[idx];
244 const wxString paperType =
m_pageFmt[idx];
455 datetime.FormatISODate();
463 bool success =
false;
471 if( !fullFileName.IsEmpty() && !wxFileExists( fullFileName ) )
474 msg.Printf(
_(
"Drawing sheet file '%s' not found." ), fullFileName );
485 const wxString paperType =
m_pageFmt[idx];
546 _(
"the translation for paper size must preserve original spellings" ) );
575 for(
unsigned i = 0; i <
m_pageFmt.GetCount(); ++i )
580 while( st.HasMoreTokens() )
582 if( st.GetNextToken() == aPaperSize )
594 int lyWidth, lyHeight;
599 double lyRatio = clamped_layout_size.x < clamped_layout_size.y ?
600 (double) clamped_layout_size.y / clamped_layout_size.x :
601 (
double) clamped_layout_size.x / clamped_layout_size.y;
603 if( clamped_layout_size.x < clamped_layout_size.y )
606 lyWidth =
KiROUND( (
double) lyHeight / lyRatio );
611 lyHeight =
KiROUND( (
double) lyWidth / lyRatio );
620 m_pageBitmap =
new wxBitmap( lyWidth + 1, lyHeight + 1 );
624 double scaleW = (double) lyWidth / clamped_layout_size.x;
625 double scaleH = (
double) lyHeight / clamped_layout_size.y;
626 double scale = std::min( scaleW, scaleH );
629 wxSize example_size( lyWidth + 1, lyHeight + 1 );
632 memDC.SetClippingRegion( wxPoint( 0, 0 ), example_size );
645 wxString pageFmtName =
m_pageFmt[idx].BeforeFirst(
' ' );
646 bool portrait = clamped_layout_size.x < clamped_layout_size.y;
647 pageDUMMY.
SetType( pageFmtName, portrait );
684 memDC.SelectObject( wxNullBitmap );
700 const wxString paperType =
m_pageFmt[idx];
719 static const wxChar* papers[] = {
739 for( i=0; i <
arrayDim( papers ); ++i )
741 if( paperType.Contains( papers[i] ) )
770 customSizeX =
Clamp(
double( INT_MIN ), customSizeX,
double( INT_MAX ) );
771 customSizeY =
Clamp(
double( INT_MIN ), customSizeY,
double( INT_MAX ) );
782 if( fn.IsAbsolute() )
785 name = fn.GetFullName();
793 wxFileDialog fileDialog(
this,
_(
"Select Drawing Sheet File" ),
path,
name,
796 if( fileDialog.ShowModal() != wxID_OK )
799 wxString fileName = fileDialog.GetPath();
800 wxString shortFileName;
805 fn = wxFileName( fileName );
807 shortFileName = fn.GetFullPath();
812 shortFileName =
NormalizePath( fileName, &
Pgm().GetLocalEnvVariables(),
nullptr );
815 std::unique_ptr<DS_DATA_MODEL> ws = std::make_unique<DS_DATA_MODEL>();
817 if( ws->LoadDrawingSheet( fileName ) )
void OnDateApplyClick(wxCommandEvent &event) override
virtual void SetPageSettings(const PAGE_INFO &aPageSettings)=0
wxTextCtrl * m_TextComment6
void GRResetPenAndBrush(wxDC *DC)
virtual void onTransferDataToWindow()
wxBitmapButton * m_browseButton
Handle the graphic items list to draw/plot the frame and title block.
void OnComment5TextUpdated(wxCommandEvent &event) override
wxCheckBox * m_Comment7Export
wxChoice * m_orientationComboBox
wxSize m_maxPageSizeMils
Logical drawing sheet size.
virtual const TITLE_BLOCK & GetTitleBlock() const =0
static int GetCustomHeightMils()
void OnPageOrientationChoice(wxCommandEvent &event) override
wxTextCtrl * m_TextComment4
This file is part of the common library.
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, const COLOR4D &Color, const COLOR4D &BgColor)
virtual void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)=0
void SetRevision(const wxString &aRevision)
const wxString & GetComment(int aIdx) const
int GetHeightMils() const
wxStaticBitmap * m_PageLayoutExampleBitmap
void OnComment3TextUpdated(wxCommandEvent &event) override
static const wxChar GERBER[]
UNIT_BINDER m_customSizeX
TITLE_BLOCK m_tb
true if the page selection is custom
wxCheckBox * m_Comment9Export
void OnComment7TextUpdated(wxCommandEvent &event) override
int GetVirtualPageNumber() const
void SetWksFileName(const wxString &aFilename)
static void SetCustomWidthMils(int aWidthInMils)
Set the width of Custom page in mils for any custom page constructed or made via SetType() after maki...
virtual bool TransferDataFromWindow() override
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 void SaveProjectSettings()
Save changes to the project settings to the project (.pro) file.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
void SetDate(const wxString &aDate)
Set the date field, and defaults to the current time and date.
wxStaticText * m_staticTextTitleBlock
virtual bool TransferDataToWindow() override
static const char * emptyString
#define PL_EDITOR_FRAME_NAME
void OnUserPageSizeXTextUpdated(wxCommandEvent &event) override
static const wxChar Custom[]
"User" defined page type
const wxString & GetType() const
wxCheckBox * m_Comment5Export
#define MAX_PAGE_EXAMPLE_SIZE
const wxString GetWksFileName()
bool m_localPrjConfigChanged
bool m_initialized
list of page sizes (not translated)
The base class for create windows for drawing purpose.
#define MIN_PAGE_SIZE_MILS
Min and max page sizes for clamping, in mils.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
wxSize m_layout_size
Temporary bitmap for the drawing sheet example.
virtual const wxString GetProjectPath() const
Return the full path of the project.
This file contains miscellaneous commonly used macros and functions.
const wxString & GetPageNumber() const
void UpdateDrawingSheetExample()
Store page-layout-specific render settings.
DS_DATA_MODEL * m_drawingSheet
Temporary title block (basic inscriptions).
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
wxCheckBox * m_RevisionExport
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
virtual const PAGE_INFO & GetPageSettings() const =0
void OnComment8TextUpdated(wxCommandEvent &event) override
void GetCustomSizeMilsFromDialog()
static const wxString ResolvePath(const wxString &aPath, const wxString &aProjectPath)
Resolve a path which might be project-relative or contain env variable references.
wxCheckBox * m_Comment2Export
void OnComment1TextUpdated(wxCommandEvent &event) override
wxCheckBox * m_Comment6Export
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
static const wxChar USLegal[]
virtual bool onSavePageSettings()
void OnComment9TextUpdated(wxCommandEvent &event) override
void SetComment(int aIdx, const wxString &aComment)
wxTextCtrl * m_TextComment9
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
const wxString & GetRevision() const
Describe the page size and margins of a paper page on which to eventually print or plot.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
wxTextCtrl * m_TextComment8
const wxString & GetCompany() const
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, const PAGE_INFO &aPageInfo, const wxString &aFullSheetName, const wxString &aFileName, const TITLE_BLOCK &aTitleBlock, int aSheetCount, const wxString &aPageNumber, double aMils2Iu, const PROJECT *aProject, const wxString &aSheetLayer, bool aIsFirstPage)
Print the border and title block.
wxChoice * m_paperSizeComboBox
wxStaticText * m_staticTextPaper
void SetCompany(const wxString &aCompany)
Definition of file extensions used in Kicad.
static void SetAltInstance(DS_DATA_MODEL *aLayout=nullptr)
Set an alternate instance of DS_DATA_MODEL.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
void SetLayerColor(int aLayer, const COLOR4D &aColor)
Change the color used to draw a layer.
wxTextCtrl * m_TextComment1
const wxSize & GetSizeMils() const
drawingsheet frame and titleblock
wxCheckBox * m_Comment1Export
void OnDateTextUpdated(wxCommandEvent &event) override
void SetCurrentPageSizeSelection(const wxString &aPaperSize)
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
void SetTitle(const wxString &aTitle)
wxTextCtrl * m_TextRevision
void SetHeightMils(int aHeightInMils)
wxBitmap * m_pageBitmap
the page layuout filename was changed
static const wxChar USLedger[]
wxStaticText * m_TextSheetNumber
void OnWksFileSelection(wxCommandEvent &event) override
Class DIALOG_PAGES_SETTINGS_BASE.
void SetContentModified(bool aModified=true)
wxStaticText * m_staticTextCustSize
wxTextCtrl * m_TextComment3
EDA_DRAW_FRAME * m_parent
const wxString & GetDate() const
void GetPageLayoutInfoFromDialog()
void OnComment6TextUpdated(wxCommandEvent &event) override
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.
wxTextCtrl * m_TextComment5
static const wxChar USLetter[]
wxStaticText * m_staticTextOrient
virtual void OnPageSettingsChange()
Called when modifying the page settings.
bool LocalPrjConfigChanged()
PAGE_INFO m_pageInfo
The max page size allowed by the caller frame.
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.
void OnComment4TextUpdated(wxCommandEvent &event) override
wxCheckBox * m_Comment4Export
void OnUserPageSizeYTextUpdated(wxCommandEvent &event) override
wxCheckBox * m_TitleExport
bool IsType(FRAME_T aType) const
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
static const wxString pageFmts[]
void SetWidthMils(int aWidthInMils)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
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.
const T & Clamp(const T &lower, const T &value, const T &upper)
Limit value within the range lower <= value <= upper.
wxCheckBox * m_Comment8Export
static int GetCustomWidthMils()
void SaveInString(wxString *aOutputString)
Save the description in a buffer.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
virtual long long int GetValue()
Return the current value in Internal Units.
wxCheckBox * m_PaperExport
bool m_customFmt
Temporary page info.
virtual ~DIALOG_PAGES_SETTINGS()
Color settings are a bit different than most of the settings objects in that there can be more than o...
const wxString & GetTitle() const
virtual COLOR4D GetDrawBgColor() const
wxString DrawingSheetFileWildcard()
void OnComment2TextUpdated(wxCommandEvent &event) override
wxStaticText * m_TextSheetCount
wxTextCtrl * m_TextCompany
void OnPaperSizeChoice(wxCommandEvent &event) override
virtual COLOR_SETTINGS * GetColorSettings() const
Returns a pointer to the active color theme settings.
void OnTitleTextUpdated(wxCommandEvent &event) override
wxTextCtrl * m_TextComment7
void OnCompanyTextUpdated(wxCommandEvent &event) override
UNIT_BINDER m_customSizeY
void OnRevisionTextUpdated(wxCommandEvent &event) override
void SetDefaultPenWidth(int aWidth)
BASE_SCREEN class implementation.
DIALOG_PAGES_SETTINGS(EDA_DRAW_FRAME *aParent, double aIuPerMils, const wxSize &aMaxUserSizeMils)
void SetPortrait(bool aIsPortrait)
Rotate the paper page 90 degrees.
void LoadColors(const COLOR_SETTINGS *aSettings) override
wxCheckBox * m_Comment3Export
void SetPrintDC(wxDC *aDC)
wxCheckBox * m_CompanyExport
wxCheckBox * m_DateExport
wxDatePickerCtrl * m_PickDate
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalize a file path to an environmental variable, if possible.
static void SetCustomHeightMils(int aHeightInMils)
Set the height of Custom page in mils for any custom page constructed or made via SetType() after mak...
wxTextCtrl * m_TextComment2
A color representation with 4 components: red, green, blue, alpha.