45#include <wx/tokenzr.h>
46#include <wx/filedlg.h>
47#include <wx/dcmemory.h>
51#define MAX_PAGE_EXAMPLE_SIZE 200
55 double aIuPerMils,
const VECTOR2D& aMaxUserSizeMils ) :
75 wxString serialization;
83 SetTitle(
_(
"Preview Settings" ) );
89 SetTitle(
_(
"Page Settings" ) );
117 int selectedIdx = -1;
122 int idx =
m_paperSizeComboBox->Append( wxGetTranslation( pageFmt.GetPageFormatDescription() ),
123 reinterpret_cast<void*
>(
static_cast<intptr_t
>( pageFmt.GetType() ) ) );
125 if( pageFmt.GetType() ==
m_pageInfo.GetType() )
139 wxCommandEvent
dummy;
190 GetSizer()->SetSizeHints(
this );
447 datetime.FormatISODate();
455 bool success =
false;
464 DisplayErrorMessage(
this, wxString::Format(
_(
"Error loading drawing sheet '%s'." ), fullFileName ), msg );
500 wxFAIL_MSG(
"The translation for paper size must preserve original spellings" );
528 int lyWidth, lyHeight;
535 double lyRatio = clamped_layout_size.
x < clamped_layout_size.
y ?
536 (double) clamped_layout_size.
y / clamped_layout_size.
x :
537 (double) clamped_layout_size.
x / clamped_layout_size.
y;
539 if( clamped_layout_size.
x < clamped_layout_size.
y )
542 lyWidth =
KiROUND( (
double) lyHeight / lyRatio );
547 lyHeight =
KiROUND( (
double) lyWidth / lyRatio );
556 m_pageBitmap =
new wxBitmap( lyWidth + 1, lyHeight + 1 );
560 double scaleW = (double) lyWidth / clamped_layout_size.
x;
561 double scaleH = (double) lyHeight / clamped_layout_size.
y;
562 double scale = std::min( scaleW, scaleH );
565 wxSize example_size( lyWidth + 1, lyHeight + 1 );
568 memDC.SetClippingRegion( wxPoint( 0, 0 ), example_size );
584 bool portrait = clamped_layout_size.
x < clamped_layout_size.
y;
585 pageDUMMY.
SetType( pageType, portrait );
618 1, &
Prj(), wxEmptyString,
m_screen->GetVirtualPageNumber() == 1 );
620 memDC.SelectObject( wxNullBitmap );
678 customSizeX = std::clamp( customSizeX,
double( INT_MIN ),
double( INT_MAX ) );
679 customSizeY = std::clamp( customSizeY,
double( INT_MIN ),
double( INT_MAX ) );
687 wxString
name = fn.GetFullName();
691 if( fn.IsAbsolute() )
699 if( expanded.IsAbsolute() )
700 path = expanded.GetPath();
708 wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );
711 fileDialog.SetCustomizeHook( customize );
713 if( fileDialog.ShowModal() != wxID_OK )
716 wxString fileName = fileDialog.GetPath();
717 wxString shortFileName;
721 fn.Assign( fileName );
723 shortFileName =
result->GetLink();
729 fn = wxFileName( fileName );
731 shortFileName = fn.GetFullPath();
736 shortFileName =
NormalizePath( fileName, &
Pgm().GetLocalEnvVariables(),
nullptr );
739 std::unique_ptr<DS_DATA_MODEL> ws = std::make_unique<DS_DATA_MODEL>();
741 if( !ws->LoadDrawingSheet( fileName, &msg ) )
744 wxString::Format(
_(
"Error loading drawing sheet '%s'.\n%s" ),
BASE_SCREEN class implementation.
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
Color settings are a bit different than most of the settings objects in that there can be more than o...
wxTextCtrl * m_TextCompany
wxCheckBox * m_Comment3Export
wxStaticText * m_userSizeXLabel
wxCheckBox * m_Comment6Export
wxCheckBox * m_Comment7Export
DIALOG_PAGES_SETTINGS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Page Settings"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxStaticText * m_userSizeXUnits
wxCheckBox * m_Comment4Export
wxChoice * m_orientationComboBox
wxTextCtrl * m_TextComment4
wxChoice * m_paperSizeComboBox
wxTextCtrl * m_TextComment9
wxTextCtrl * m_TextRevision
wxStaticText * m_staticTextPaper
wxTextCtrl * m_TextComment2
wxStaticText * m_userSizeYUnits
wxCheckBox * m_PaperExport
wxTextCtrl * m_TextComment8
wxCheckBox * m_RevisionExport
wxStaticText * m_staticTextTitleBlock
wxStaticText * m_userSizeYLabel
wxCheckBox * m_DateExport
wxStaticText * m_TextSheetCount
wxStaticText * m_TextSheetNumber
wxStaticBitmap * m_PageLayoutExampleBitmap
STD_BITMAP_BUTTON * m_browseButton
wxTextCtrl * m_TextComment3
wxTextCtrl * m_userSizeXCtrl
wxCheckBox * m_Comment9Export
wxTextCtrl * m_TextComment6
wxTextCtrl * m_TextComment5
wxDatePickerCtrl * m_PickDate
wxTextCtrl * m_userSizeYCtrl
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_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()
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
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
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
virtual ~DIALOG_PAGES_SETTINGS()
EMBEDDED_FILES * m_embeddedFiles
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
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
Handle the graphic items list to draw/plot the frame and title block.
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.
static void SetAltInstance(DS_DATA_MODEL *aLayout=nullptr)
Set an alternate instance of DS_DATA_MODEL.
The base class for create windows for drawing purpose.
Provide an extensible class to resolve 3D model paths.
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.
bool SetType(PAGE_SIZE_TYPE aPageSize, bool aIsPortrait=false)
Set the name of the page type and also the sizes and margins commonly associated with that type name.
static void SetCustomWidthMils(double aWidthInMils)
Set the width of Custom page in mils for any custom page constructed or made via SetType() after maki...
void SetHeightMils(double aHeightInMils)
static const std::vector< PAGE_INFO > & GetPageFormatsList()
const VECTOR2D & GetSizeMils() const
void SetWidthMils(double aWidthInMils)
static void SetCustomHeightMils(double aHeightInMils)
Set the height of Custom page in mils for any custom page constructed or made via SetType() after mak...
virtual const wxString GetProjectPath() const
Return the full path of the project.
const wxString ExpandEnvVarSubstitutions(const wxString &aString, const PROJECT *aProject)
Replace any environment variable & text variable references with their values.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
#define MAX_PAGE_EXAMPLE_SIZE
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.
Helper functions to substitute paths with environmental variables.
@ 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)
static wxString DrawingSheetFileWildcard()
@ LAYER_DRAWINGSHEET
Sheet frame and title block.
@ LAYER_SCHEMATIC_DRAWINGSHEET
This file contains miscellaneous commonly used macros and functions.
#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...
PGM_BASE & Pgm()
The global program "get" accessor.
static const char * emptyString
std::vector< FAB_LAYER_COLOR > dummy
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
wxString result
Test unit parsing edge cases and error handling.
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
Definition of file extensions used in Kicad.