62#include <wx/filedlg.h>
64#include <wx/treebook.h>
87 wxDefaultPosition, wxDefaultSize,
89 m_propertiesPagelayout(
nullptr ),
90 m_propertiesFrameWidth( 200 ),
91 m_originSelectBox(
nullptr ),
92 m_originSelectChoice( 0 ),
93 m_pageSelectBox(
nullptr ),
94 m_mruImagePath( wxEmptyString )
96 m_maximizeByDefault =
true;
99 m_showBorderAndTitleBlock =
true;
101 m_aboutTitle =
_HKI(
"KiCad Drawing Sheet Editor" );
105 wxIconBundle icon_bundle;
108 icon_bundle.AddIcon( icon );
110 icon_bundle.AddIcon( icon );
112 icon_bundle.AddIcon( icon );
114 icon_bundle.AddIcon( icon );
116 icon_bundle.AddIcon( icon );
118 SetIcons( icon_bundle );
122 GetGalDisplayOptions(),
124 SetCanvas( drawPanel );
129 DragAcceptFiles(
true );
139 ReCreateOptToolbar();
141 wxWindow* stsbar = GetStatusBar();
165 KIUI::GetTextSize(
_(
"coord origin: Right Bottom page corner" ), stsbar ).x + spacer,
174 SetStatusWidths(
arrayDim( dims ), dims );
176 m_auimgr.SetManagedWindow(
this );
182 m_auimgr.AddPane( m_mainToolBar,
EDA_PANE().HToolbar().Name(
"MainToolbar" )
184 m_auimgr.AddPane( m_optionsToolBar,
EDA_PANE().VToolbar().Name(
"OptToolbar" )
185 .Left().Layer( 3 ) );
186 m_auimgr.AddPane( m_messagePanel,
EDA_PANE().Messages().Name(
"MsgPanel" )
187 .Bottom().Layer( 6 ) );
190 m_auimgr.AddPane( m_drawToolBar,
EDA_PANE().VToolbar().Name(
"ToolsToolbar" )
191 .Right().Layer( 2 ) );
193 m_auimgr.AddPane( m_propertiesPagelayout,
EDA_PANE().Palette().Name(
"Props" )
195 .Caption(
_(
"Properties" ) )
196 .MinSize( m_propertiesPagelayout->GetMinSize() )
197 .BestSize( m_propertiesFrameWidth, -1 ) );
200 m_auimgr.AddPane( GetCanvas(),
EDA_PANE().Canvas().Name(
"DrawFrame" )
203 FinishAUIInitialization();
206 SwitchCanvas( m_canvasType );
211 VECTOR2I originCoord = ReturnCoordOriginCorner();
212 SetGridOrigin( originCoord );
231 UpdateToolbarControlSizes();
284#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
285#define CHECK( x ) ACTION_CONDITIONS().Check( x )
322 auto titleBlockNormalMode =
328 auto titleBlockEditMode =
344 wxString fn = aFileSet[0];
348 wxMessageBox( wxString::Format(
_(
"Error loading drawing sheet '%s'." ), fn ) );
379 if( aEvent.GetId() == wxID_EXIT )
382 if( aEvent.GetId() == wxID_CLOSE ||
Kiface().IsSingle() )
391 && aEvent.GetId() == wxEVT_QUERY_END_SESSION
400 wxString msg =
_(
"Save changes to '%s' before closing?" );
405 return saveCurrentPageLayout();
452 static wxPrintData* s_PrintData;
453 static wxPageSetupDialogData* s_pageSetupData =
nullptr;
457 if( s_PrintData ==
nullptr )
459 s_PrintData =
new wxPrintData();
460 s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH );
463 if( !s_PrintData->Ok() )
465 wxMessageBox(
_(
"Error Init Printer info" ) );
469 if( s_pageSetupData ==
nullptr )
470 s_pageSetupData =
new wxPageSetupDialogData( *s_PrintData );
472 s_pageSetupData->SetPaperId( pageInfo.
GetPaperId() );
473 s_pageSetupData->GetPrintData().SetOrientation( pageInfo.
GetWxOrientation() );
485 *s_PrintData = s_pageSetupData->GetPrintData();
508 GRID{ wxEmptyString, wxS(
"2.50 mm" ), wxS(
"2.50 mm" ) },
509 GRID{ wxEmptyString, wxS(
"2.00 mm" ), wxS(
"2.00 mm" ) },
510 GRID{ wxEmptyString, wxS(
"1.00 mm" ), wxS(
"1.00 mm" ) },
511 GRID{ wxEmptyString, wxS(
"0.50 mm" ), wxS(
"0.50 mm" ) },
512 GRID{ wxEmptyString, wxS(
"0.25 mm" ), wxS(
"0.25 mm" ) },
513 GRID{ wxEmptyString, wxS(
"0.20 mm" ), wxS(
"0.20 mm" ) },
514 GRID{ wxEmptyString, wxS(
"0.10 mm" ), wxS(
"0.10 mm" ) } };
568 title += file.GetName();
570 title +=
_(
"[no drawing sheet loaded]" );
572 title += wxT(
" \u2014 " ) +
_(
"Drawing Sheet Editor" ),
665 originCoord =
dummy.GetStartPosIU();
670 originCoord =
dummy.GetStartPosIU();
675 originCoord =
dummy.GetStartPosIU();
680 originCoord =
dummy.GetStartPosIU();
691 wxString gridformatter;
695 case EDA_UNITS::INCHES: gridformatter = wxS(
"grid %.3f" );
break;
696 case EDA_UNITS::MILLIMETRES: gridformatter = wxS(
"grid %.4f" );
break;
697 default: gridformatter = wxS(
"grid %f" );
break;
701 GetCanvas()->GetGAL()->GetGridSize().x );
702 line.Printf( gridformatter,
grid );
704 SetStatusText( line, 4 );
746 VECTOR2D coord = cursorPos - originCoord;
752 wxString absformatter = wxT(
"X %.4g Y %.4g" );
753 wxString locformatter = wxT(
"dx %.4g dy %.4g" );
757 case EDA_UNITS::INCHES: SetStatusText(
_(
"inches" ), 6 );
break;
758 case EDA_UNITS::MILS: SetStatusText(
_(
"mils" ), 6 );
break;
759 case EDA_UNITS::MILLIMETRES: SetStatusText(
_(
"mm" ), 6 );
break;
760 case EDA_UNITS::UNSCALED: SetStatusText( wxEmptyString, 6 );
break;
761 default: wxASSERT(
false );
break;
767 line.Printf( absformatter, dXpos, dYpos );
768 SetStatusText( line, 2 );
777 line.Printf( locformatter, dXpos, dYpos );
778 SetStatusText( line, 3 );
784 line.Printf(
_(
"coord origin: %s"),
786 SetStatusText( line, 5 );
833 if( selection.GetSize() == 1 )
867 wxFileDialog fileDlg(
this,
_(
"Choose Image" ),
m_mruImagePath, wxEmptyString,
868 _(
"Image Files" ) + wxS(
" " ) + wxImage::GetImageExtWildcard(),
871 if( fileDlg.ShowModal() != wxID_OK )
874 wxString fullFilename = fileDlg.GetPath();
877 if( !wxFileExists( fullFilename ) )
879 wxMessageBox(
_(
"Could not load image from '%s'." ), fullFilename );
885 if( !
image->ReadImageFile( fullFilename ) )
887 wxMessageBox(
_(
"Could not load image from '%s'." ), fullFilename );
899 if( item ==
nullptr )
936 if( aItemCount == 0 )
947 for(
int ii = 0; ii < aItemCount; ii++ )
975 std::vector<MSG_PANEL_ITEM> msgItems;
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
constexpr EDA_IU_SCALE drawSheetIUScale
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
@ icon_pagelayout_editor_16
@ icon_pagelayout_editor_32
static TOOL_ACTION toggleGrid
static TOOL_ACTION millimetersUnits
static TOOL_ACTION milsUnits
static TOOL_ACTION inchesUnits
static TOOL_ACTION toggleCursorStyle
static TOOL_ACTION doDelete
static TOOL_ACTION selectionTool
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION deleteTool
static TOOL_ACTION zoomTool
Manage TOOL_ACTION objects.
void SetConditions(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Set the conditions the UI elements for activating a specific tool action should use for determining t...
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
wxString m_ColorTheme
Active color theme name.
Handles how to draw a screen (a board, a schematic ...)
bool IsContentModified() const
void SetVirtualPageNumber(int aPageNumber)
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
void SetContentModified(bool aModified=true)
void InitDataPoints(const VECTOR2I &aPageSizeInternalUnits)
This class handle bitmap images in KiCad.
void SetPixelSizeIu(double aPixSize)
Color settings are a bit different than most of the settings objects in that there can be more than o...
Handle actions that are shared between different applications.
Drawing sheet structure type definitions.
virtual void SyncDrawItems(DS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView)
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 Append(DS_DATA_ITEM *aItem)
void AllowVoidList(bool Allow)
In KiCad applications, a drawing sheet is needed So if the list is empty, a default drawing sheet is ...
void ClearList()
Erase the list of items.
std::vector< DS_DATA_ITEM * > & GetItems()
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.
Base class to handle basic graphic items.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
UNDO_REDO_CONTAINER m_undoList
virtual void setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
UNDO_REDO_LIST
Specifies whether we are interacting with the undo or redo stacks.
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
UNDO_REDO_CONTAINER m_redoList
virtual void OnDropFiles(wxDropFilesEvent &aEvent)
Handles event fired when a file is dropped to the window.
The base class for create windows for drawing purpose.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
const wxString GetZoomLevelIndicator() const
Return a human readable value for display in dialogs.
GAL_DISPLAY_OPTIONS_IMPL & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
virtual void SetDrawBgColor(const COLOR4D &aColor)
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, const std::map< wxString, wxString > *aProperties, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the drawing-sheet (frame and title block).
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual COLOR4D GetDrawBgColor() const
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
void ForceRefresh()
Force a redraw.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
@ GAL_TYPE_NONE
GAL not used (the legacy wxDC engine is used)
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
A base class for most all the KiCad significant classes used in schematics and boards.
Specialization of the wxAuiPaneInfo class for KiCad panels.
Class that groups generic conditions for editor states.
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
virtual SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
virtual void LoadColors(const COLOR_SETTINGS *aSettings)
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Describe the page size and margins of a paper page on which to eventually print or plot.
static void SetCustomWidthMils(double aWidthInMils)
Set the width of Custom page in mils for any custom page constructed or made via SetType() after maki...
wxPrintOrientation GetWxOrientation() const
static double GetCustomHeightMils()
const VECTOR2D GetSizeIU(double aIUScale) const
Gets the page size in internal units.
double GetHeightMils() const
wxPaperSize GetPaperId() const
const wxString & GetType() const
double GetWidthMils() const
static double GetCustomWidthMils()
static void SetCustomHeightMils(double aHeightInMils)
Set the height of Custom page in mils for any custom page constructed or made via SetType() after mak...
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 SETTINGS_MANAGER & GetSettingsManager() const
A holder to handle information on schematic or board items.
void ClearListAndDeleteItems(std::function< void(EDA_ITEM *)> aItemDeleter)
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...
Gather all the actions that are shared by tools.
static TOOL_ACTION placeImage
static TOOL_ACTION drawRectangle
static TOOL_ACTION layoutNormalMode
static TOOL_ACTION placeText
static TOOL_ACTION layoutEditMode
static TOOL_ACTION appendImportedDrawingSheet
static TOOL_ACTION drawLine
void DisplayDrawingSheet()
Build and update the list of WS_DRAW_ITEM_xxx showing the frame layout.
Handle actions specific to the drawing sheet editor.
The main window used in the drawing sheet editor.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Open a project or set of files given by aFileList.
void OnNewDrawingSheet()
Must be called to initialize parameters when a new drawing sheet is loaded.
void OnModify() override
Must be called after a change in order to set the "modify" flag.
void SetCurrentFileName(const wxString &aName)
Store the current layout description file filename.
bool IsContentModified() const override
Get if the drawing sheet has been modified but not saved.
void Files_io(wxCommandEvent &event)
void ToPrinter(bool doPreview)
Open a dialog frame to print layers.
void UpdateMsgPanelInfo()
Display the size of the sheet to the message panel.
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
void doCloseWindow() override
VECTOR2I ReturnCoordOriginCorner() const
Calculate the position (in page, in iu) of the corner used as coordinate origin of items.
void OnClearFileHistory(wxCommandEvent &aEvent)
void SetPageSettings(const PAGE_INFO &) override
DS_DATA_ITEM * AddDrawingSheetItem(int aType)
Add a new item to the drawing sheet item list.
wxString GetCurrentFileName() const override
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
void OnFileHistory(wxCommandEvent &event)
void UpdateStatusBar() override
Update the status bar information.
void SetGridOrigin(const VECTOR2I &aPoint) override
int m_propertiesFrameWidth
void OnSelectPage(wxCommandEvent &event)
const TITLE_BLOCK & GetTitleBlock() const override
void UpdateTitleAndInfo()
Display the short filename (if exists) loaded file on the caption of the main window.
const VECTOR2I GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
virtual void PrintPage(const RENDER_SETTINGS *aSettings) override
Print a page.
void OnSelectCoordOriginCorner(wxCommandEvent &event)
Called when the user select one of the 4 page corner as corner reference (or the left top paper corne...
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
PL_EDITOR_LAYOUT m_pageLayout
bool GetPageNumberOption() const
Drawing sheet editor can show the title block using a page number 1 or another number.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void HardRedraw() override
Refresh the library tree and redraw the window.
void DisplayGridMsg() override
Display current grid size in the status bar.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
wxChoice * m_originSelectBox
const PAGE_INFO & GetPageSettings() const override
const PL_EDITOR_LAYOUT & GetPageLayout() const
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
PROPERTIES_FRAME * m_propertiesPagelayout
The last filename chosen to be proposed to the user.
wxChoice * m_pageSelectBox
PL_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void ClearUndoORRedoList(UNDO_REDO_LIST whichList, int aItemCount=-1) override
Remove the aItemCount of old commands from aList and delete commands, pickers and picked items if nee...
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
void OnExit(wxCommandEvent &aEvent)
Event handler for the wxID_EXIT and wxID_CLOSE events.
bool LoadDrawingSheetFile(const wxString &aFullFileName)
Load a .kicad_wks drawing sheet file.
void SetPageSettings(const PAGE_INFO &aPageSettings)
TITLE_BLOCK & GetTitleBlock()
PAGE_INFO & GetPageSettings()
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
int m_PropertiesFrameWidth
Tool that displays edit points allowing to modify items by dragging the points.
PROPERTIES_FRAME display properties of the current item.
void CopyPrmsFromItemToPanel(DS_DATA_ITEM *aItem)
void CopyPrmsFromGeneralToPanel()
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
static bool ShowNever(const SELECTION &aSelection)
Always returns false.
T * GetAppSettings()
Returns a handle to the a given settings by type If the settings have already been loaded,...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
A holder to handle a list of undo (or redo) commands.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
EDA_UNITS GetUserUnits() const
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
This file is part of the common library.
int InvokeDialogPrintPreview(PL_EDITOR_FRAME *aCaller, wxPrintData *aPrintData)
Create and show a print preview dialog returns 1 if OK, 0 , there is a problem.
int InvokeDialogPrint(PL_EDITOR_FRAME *aCaller, wxPrintData *aPrintData, wxPageSetupDialogData *aPageSetupData)
Create and show a print dialog returns 1 if OK, 0 , there is a problem.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define PL_EDITOR_FRAME_NAME
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
static const std::string DrawingSheetFileExtension
@ LAYER_DRAWINGSHEET_PAGEn
for drawingsheetEditor previewing
@ LAYER_DRAWINGSHEET_PAGE1
for drawingsheetEditor previewing
KICOMMON_API double ToUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
KICOMMON_API int Mils2mm(double aVal)
Convert mils to mm.
@ COLOR
Color has changed.
KICOMMON_API wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Return the size of aSingleLine of text when it is rendered in aWindow using whatever font is currentl...
PGM_BASE & Pgm()
The global Program "get" accessor.
@ ID_SELECT_COORDINATE_ORIGIN
KIWAY Kiway(KFCTL_STANDALONE)
std::vector< FAB_LAYER_COLOR > dummy
std::vector< GRID > grids
Common grid settings, available to every frame.
std::vector< double > zoom_factors
Definition of file extensions used in Kicad.
#define ZOOM_LIST_PL_EDITOR