61#include <wx/filedlg.h>
63#include <wx/treebook.h>
85 wxDefaultPosition, wxDefaultSize,
87 m_propertiesPagelayout(
nullptr ),
88 m_propertiesFrameWidth( 200 ),
89 m_originSelectBox(
nullptr ),
90 m_originSelectChoice( 0 ),
91 m_pageSelectBox(
nullptr ),
92 m_mruImagePath( wxEmptyString )
94 m_maximizeByDefault =
true;
97 m_showBorderAndTitleBlock =
true;
99 m_aboutTitle =
_HKI(
"KiCad Drawing Sheet Editor" );
103 wxIconBundle icon_bundle;
106 icon_bundle.AddIcon( icon );
108 icon_bundle.AddIcon( icon );
110 icon_bundle.AddIcon( icon );
112 icon_bundle.AddIcon( icon );
114 icon_bundle.AddIcon( icon );
116 SetIcons( icon_bundle );
120 GetGalDisplayOptions(),
122 SetCanvas( drawPanel );
127 DragAcceptFiles(
true );
137 ReCreateOptToolbar();
139 wxWindow* stsbar = GetStatusBar();
163 KIUI::GetTextSize(
_(
"coord origin: Right Bottom page corner" ), stsbar ).x + spacer,
172 SetStatusWidths(
arrayDim( dims ), dims );
174 m_auimgr.SetManagedWindow(
this );
180 m_auimgr.AddPane( m_mainToolBar,
EDA_PANE().HToolbar().Name(
"MainToolbar" )
182 m_auimgr.AddPane( m_optionsToolBar,
EDA_PANE().VToolbar().Name(
"OptToolbar" )
183 .Left().Layer( 3 ) );
184 m_auimgr.AddPane( m_messagePanel,
EDA_PANE().Messages().Name(
"MsgPanel" )
185 .Bottom().Layer( 6 ) );
188 m_auimgr.AddPane( m_drawToolBar,
EDA_PANE().VToolbar().Name(
"ToolsToolbar" )
189 .Right().Layer( 2 ) );
191 m_auimgr.AddPane( m_propertiesPagelayout,
EDA_PANE().Palette().Name(
"Props" )
193 .Caption(
_(
"Properties" ) )
194 .MinSize( m_propertiesPagelayout->GetMinSize() )
195 .BestSize( m_propertiesFrameWidth, -1 ) );
198 m_auimgr.AddPane( GetCanvas(),
EDA_PANE().Canvas().Name(
"DrawFrame" )
201 FinishAUIInitialization();
204 SwitchCanvas( m_canvasType );
209 VECTOR2I originCoord = ReturnCoordOriginCorner();
210 SetGridOrigin( originCoord );
229 UpdateToolbarControlSizes();
282#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
283#define CHECK( x ) ACTION_CONDITIONS().Check( x )
320 auto titleBlockNormalMode =
326 auto titleBlockEditMode =
342 wxString fn = aFileSet[0];
346 wxMessageBox( wxString::Format(
_(
"Error loading drawing sheet '%s'." ), fn ) );
377 if( aEvent.GetId() == wxID_EXIT )
380 if( aEvent.GetId() == wxID_CLOSE ||
Kiface().IsSingle() )
389 && aEvent.GetId() == wxEVT_QUERY_END_SESSION
398 wxString msg =
_(
"Save changes to '%s' before closing?" );
403 return saveCurrentPageLayout();
450 static wxPrintData* s_PrintData;
451 static wxPageSetupDialogData* s_pageSetupData =
nullptr;
455 if( s_PrintData ==
nullptr )
457 s_PrintData =
new wxPrintData();
458 s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH );
461 if( !s_PrintData->Ok() )
463 wxMessageBox(
_(
"Error Init Printer info" ) );
467 if( s_pageSetupData ==
nullptr )
468 s_pageSetupData =
new wxPageSetupDialogData( *s_PrintData );
470 s_pageSetupData->SetPaperId( pageInfo.
GetPaperId() );
471 s_pageSetupData->GetPrintData().SetOrientation( pageInfo.
GetWxOrientation() );
483 *s_PrintData = s_pageSetupData->GetPrintData();
506 GRID{ wxEmptyString, wxS(
"2.50 mm" ), wxS(
"2.50 mm" ) },
507 GRID{ wxEmptyString, wxS(
"2.00 mm" ), wxS(
"2.00 mm" ) },
508 GRID{ wxEmptyString, wxS(
"1.00 mm" ), wxS(
"1.00 mm" ) },
509 GRID{ wxEmptyString, wxS(
"0.50 mm" ), wxS(
"0.50 mm" ) },
510 GRID{ wxEmptyString, wxS(
"0.25 mm" ), wxS(
"0.25 mm" ) },
511 GRID{ wxEmptyString, wxS(
"0.20 mm" ), wxS(
"0.20 mm" ) },
512 GRID{ wxEmptyString, wxS(
"0.10 mm" ), wxS(
"0.10 mm" ) } };
566 title += file.GetName();
568 title +=
_(
"[no drawing sheet loaded]" );
570 title += wxT(
" \u2014 " ) +
_(
"Drawing Sheet Editor" ),
663 originCoord =
dummy.GetStartPosIU();
668 originCoord =
dummy.GetStartPosIU();
673 originCoord =
dummy.GetStartPosIU();
678 originCoord =
dummy.GetStartPosIU();
689 wxString gridformatter;
693 case EDA_UNITS::INCHES: gridformatter = wxS(
"grid %.3f" );
break;
694 case EDA_UNITS::MILLIMETRES: gridformatter = wxS(
"grid %.4f" );
break;
695 default: gridformatter = wxS(
"grid %f" );
break;
699 GetCanvas()->GetGAL()->GetGridSize().x );
700 line.Printf( gridformatter,
grid );
702 SetStatusText( line, 4 );
744 VECTOR2D coord = cursorPos - originCoord;
750 wxString absformatter = wxT(
"X %.4g Y %.4g" );
751 wxString locformatter = wxT(
"dx %.4g dy %.4g" );
755 case EDA_UNITS::INCHES: SetStatusText(
_(
"inches" ), 6 );
break;
756 case EDA_UNITS::MILS: SetStatusText(
_(
"mils" ), 6 );
break;
757 case EDA_UNITS::MILLIMETRES: SetStatusText(
_(
"mm" ), 6 );
break;
758 case EDA_UNITS::UNSCALED: SetStatusText( wxEmptyString, 6 );
break;
759 default: wxASSERT(
false );
break;
765 line.Printf( absformatter, dXpos, dYpos );
766 SetStatusText( line, 2 );
775 line.Printf( locformatter, dXpos, dYpos );
776 SetStatusText( line, 3 );
782 line.Printf(
_(
"coord origin: %s"),
784 SetStatusText( line, 5 );
831 if( selection.GetSize() == 1 )
865 wxFileDialog fileDlg(
this,
_(
"Choose Image" ),
m_mruImagePath, wxEmptyString,
866 _(
"Image Files" ) + wxS(
" " ) + wxImage::GetImageExtWildcard(),
869 if( fileDlg.ShowModal() != wxID_OK )
872 wxString fullFilename = fileDlg.GetPath();
875 if( !wxFileExists( fullFilename ) )
877 wxMessageBox(
_(
"Could not load image from '%s'." ), fullFilename );
883 if( !
image->ReadImageFile( fullFilename ) )
885 wxMessageBox(
_(
"Could not load image from '%s'." ), fullFilename );
897 if( item ==
nullptr )
934 if( aItemCount == 0 )
945 for(
int ii = 0; ii < aItemCount; ii++ )
973 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
GERBVIEW_FRAME::OnZipFileHistory GERBVIEW_FRAME::OnSelectDisplayMode EVT_CHOICE(ID_GBR_AUX_TOOLBAR_PCB_APERATTRIBUTES_CHOICE, GERBVIEW_FRAME::OnSelectHighlightChoice) EVT_UPDATE_UI(ID_TOOLBARH_GERBVIEW_SELECT_ACTIVE_LAYER
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