82 wxDefaultPosition, wxDefaultSize,
84 m_propertiesFrameWidth( 200 ),
85 m_originSelectBox(
nullptr ),
86 m_originSelectChoice( 0 ),
87 m_pageSelectBox(
nullptr ),
88 m_propertiesPagelayout(
nullptr )
90 m_maximizeByDefault =
true;
93 m_showBorderAndTitleBlock =
true;
95 SetShowPageLimits(
true );
96 m_aboutTitle =
_(
"KiCad Drawing Sheet Editor" );
100 wxIconBundle icon_bundle;
103 icon_bundle.AddIcon( icon );
105 icon_bundle.AddIcon( icon );
107 icon_bundle.AddIcon( icon );
109 SetIcons( icon_bundle );
113 GetGalDisplayOptions(),
115 SetCanvas( drawPanel );
117 LoadSettings( config() );
119 wxSize pageSizeIU = GetPageLayout().GetPageSettings().GetSizeIU();
127 ReCreateOptToolbar();
129 wxWindow* stsbar = GetStatusBar();
157 SetStatusWidths(
arrayDim( dims ), dims );
159 m_auimgr.SetManagedWindow(
this );
165 m_auimgr.AddPane( m_mainToolBar,
EDA_PANE().HToolbar().Name(
"MainToolbar" )
167 m_auimgr.AddPane( m_optionsToolBar,
EDA_PANE().VToolbar().Name(
"OptToolbar" )
168 .
Left().Layer( 3 ) );
169 m_auimgr.AddPane( m_messagePanel,
EDA_PANE().Messages().Name(
"MsgPanel" )
170 .Bottom().Layer( 6 ) );
173 m_auimgr.AddPane( m_drawToolBar,
EDA_PANE().VToolbar().Name(
"ToolsToolbar" )
174 .
Right().Layer( 2 ) );
176 m_auimgr.AddPane( m_propertiesPagelayout,
EDA_PANE().Palette().Name(
"Props" )
178 .Caption(
_(
"Properties" ) )
179 .MinSize( m_propertiesPagelayout->GetMinSize() )
180 .BestSize( m_propertiesFrameWidth, -1 ) );
183 m_auimgr.AddPane( GetCanvas(),
EDA_PANE().Canvas().Name(
"DrawFrame" )
186 FinishAUIInitialization();
189 SwitchCanvas( m_canvasType );
192 setupUnits( config() );
194 wxPoint originCoord = ReturnCoordOriginCorner();
195 SetGridOrigin( originCoord );
198 #if 0 //start with empty layout 201 #else // start with the default Kicad layout 256 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x ) 257 #define CHECK( x ) ACTION_CONDITIONS().Check( x ) 286 auto titleBlockNormalMode =
292 auto titleBlockEditMode =
308 wxString fn = aFileSet[0];
331 if( aEvent.GetId() == wxID_EXIT )
343 && aEvent.GetId() == wxEVT_QUERY_END_SESSION
352 wxString msg =
_(
"Save changes to \"%s\" before closing?" );
409 static wxPrintData* s_PrintData;
410 static wxPageSetupDialogData* s_pageSetupData =
nullptr;
414 if( s_PrintData ==
NULL )
416 s_PrintData =
new wxPrintData();
417 s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH );
420 if( !s_PrintData->Ok() )
422 wxMessageBox(
_(
"Error Init Printer info" ) );
426 if( s_pageSetupData ==
NULL )
427 s_pageSetupData =
new wxPageSetupDialogData( *s_PrintData );
429 s_pageSetupData->SetPaperId( pageInfo.
GetPaperId() );
430 s_pageSetupData->GetPrintData().SetOrientation( pageInfo.
GetWxOrientation() );
442 *s_PrintData = s_pageSetupData->GetPrintData();
463 book->AddPage(
new wxPanel( book ),
_(
"Drawing Sheet Editor" ) );
512 auto cfg = static_cast<PL_EDITOR_SETTINGS*>( aCfg );
531 title.Printf( wxT(
"%s \u2014 " ) +
_(
"Drawing Sheet Editor" ),
532 file.IsOk() ? file.GetName() :
_(
"no file selected" ) );
621 originCoord =
dummy.GetStartPosUi();
626 originCoord =
dummy.GetStartPosUi();
631 originCoord =
dummy.GetStartPosUi();
636 originCoord =
dummy.GetStartPosUi();
650 wxString gridformatter;
656 default: gridformatter =
"grid %f";
break;
660 line.Printf( gridformatter, grid );
662 SetStatusText( line, 4 );
704 VECTOR2D coord = cursorPos - originCoord;
708 wxString absformatter = wxT(
"X %.4g Y %.4g" );
709 wxString locformatter = wxT(
"dx %.4g dy %.4g" );
717 default: wxASSERT(
false );
break;
723 line.Printf( absformatter, dXpos, dYpos );
724 SetStatusText( line, 2 );
733 line.Printf( locformatter, dXpos, dYpos );
734 SetStatusText( line, 3 );
740 line.Printf(
_(
"coord origin: %s"),
742 SetStatusText( line, 5 );
758 BITMAP_BASE* bitmap = static_cast<DS_DATA_ITEM_BITMAP*>( dataItem )->m_ImageBitmap;
790 if( selection.GetSize() == 1 )
791 item = static_cast<DS_DRAW_ITEM_BASE*>( selection.Front() )->GetPeer();
823 wxFileDialog fileDlg(
this,
_(
"Choose Image" ), wxEmptyString, wxEmptyString,
824 _(
"Image Files" ) + wxS(
" " ) + wxImage::GetImageExtWildcard(),
827 if( fileDlg.ShowModal() != wxID_OK )
830 wxString fullFilename = fileDlg.GetPath();
832 if( !wxFileExists( fullFilename ) )
834 wxMessageBox(
_(
"Couldn't load image from \"%s\"" ), fullFilename );
842 wxMessageBox(
_(
"Couldn't load image from \"%s\"" ), fullFilename );
891 if( aItemCount == 0 )
900 for(
unsigned ii = 0; ii < icnt; ii++ )
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void OnFileHistory(wxCommandEvent &event)
void ToPrinter(bool doPreview)
Function ToPrinter Open a dialog frame to print layers.
void ClearList()
Erase the list of items.
virtual void PrintPage(const RENDER_SETTINGS *aSettings) override
Virtual function PrintPage used to print a page.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
bool IsContentModified() override
Get if the page layout has been modified but not saved.
for drawingsheetEditor previewing
Handle the graphic items list to draw/plot the frame and title block.
KIWAY & Kiway() const
Return a reference to the KIWAY that this object has an opportunity to participate in.
void HardRedraw() override
Refresh the library tree and redraw the window.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
wxPrintOrientation GetWxOrientation() const
void SetVirtualPageNumber(int aPageNumber)
PL_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void 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 PAGE_INFO & GetPageSettings() const override
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
static int GetCustomHeightMils()
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void ClearUndoORRedoList(UNDO_REDO_LIST whichList, int aItemCount=-1) override
Function ClearUndoORRedoList.
static TOOL_ACTION layoutEditMode
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
This file is part of the common library.
static TOOL_ACTION doDelete
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
static TOOL_ACTION drawLine
int GetHeightMils() const
UNDO_REDO_CONTAINER m_undoList
static TOOL_ACTION zoomTool
static TOOL_ACTION placeImage
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
wxPoint ReturnCoordOriginCorner() const
calculate the position (in page, in iu) of the corner used as coordinate origin of items
PROPERTIES_FRAME display properties of the current item.
PL_EDITOR_FRAME is the main window used in the drawing sheet editor.
void UpdateStatusBar() override
Update the status bar information.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
bool canCloseWindow(wxCloseEvent &aCloseEvent) override
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.
void OnClearFileHistory(wxCommandEvent &aEvent)
static void SetCustomWidthMils(int aWidthInMils)
Set the width of Custom page in mils for any custom page constructed or made via SetType() after maki...
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 setupUIConditions()
Setup the UI conditions for the various actions and their controls in this frame.
virtual void SetDrawBgColor(COLOR4D aColor)
static TOOL_ACTION zoomFitScreen
static TOOL_ACTION millimetersUnits
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
int InvokeDialogPrintPreview(PL_EDITOR_FRAME *aCaller, wxPrintData *aPrintData)
Create and show a print preview dialog returns 1 if OK, 0 , there is a problem.
std::vector< DS_DATA_ITEM * > & GetItems()
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
#define PL_EDITOR_FRAME_NAME
void AddHotKeys(TOOL_MANAGER *aToolMgr)
const wxString & GetType() const
SELECTION_CONDITION RedoAvailable()
Create a functor that tests if there are any items in the redo queue.
static TOOL_ACTION placeText
Manage TOOL_ACTION objects.
Gather all the actions that are shared by tools.
The base class for create windows for drawing purpose.
void DisplayWorksheet()
Build and update the list of WS_DRAW_ITEM_xxx showing the frame layout.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
Class that groups generic conditions for editor states.
std::vector< double > zoom_factors
PAGE_INFO & GetPageSettings()
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
wxPaperSize GetPaperId() const
virtual void SyncDrawItems(DS_DRAW_ITEM_LIST *aCollector, KIGFX::VIEW *aView)
This class handle bitmap images in KiCad.
static wxString m_PageLayoutDescrFileName
the name of the page layout descr file, or emty to used the default pagelayout
wxTreebook * GetTreebook()
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
EVT_MENU_RANGE(ID_GERBVIEW_DRILL_FILE1, ID_GERBVIEW_DRILL_FILEMAX, GERBVIEW_FRAME::OnDrlFileHistory) EVT_MENU_RANGE(ID_GERBVIEW_ZIP_FILE1
A holder to handle a list of undo (or redo) commands.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
wxString GetCurrentFileName() const override
void SetPageSettings(const PAGE_INFO &) override
std::vector< wxString > sizes
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
SELECTION_CONDITION GridVisible()
Create a functor testing if the grid is visible in a frame.
bool IsSingle() const
Is this KIFACE_I running under single_top?
void AllowVoidList(bool Allow)
In KiCad applications, a page layout description is needed So if the list is empty,...
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...
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
TITLE_BLOCK & GetTitleBlock()
const BITMAP_OPAQUE icon_pagelayout_editor_xpm[1]
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Open a project or set of files given by aFileList.
static TOOL_ACTION toggleGrid
GAL not used (the legacy wxDC engine is used)
void OnExit(wxCommandEvent &aEvent)
Describe the page size and margins of a paper page on which to eventually print or plot.
static TOOL_ACTION inchesUnits
Handles how to draw a screen (a board, a schematic ...)
bool saveCurrentPageLayout()
void OnSelectCoordOriginCorner(wxCommandEvent &event)
called when the user select one of the 4 page corner as corner reference (or the left top paper corne...
for drawingsheetEditor previewing
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
int Mils2mm(double x)
Convert mils to mm.
const BITMAP_OPAQUE icon_pagelayout_editor_16_xpm[1]
void OnNewPageLayout()
Must be called to initialize parameters when a new page layout description is loaded.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
const TITLE_BLOCK & GetTitleBlock() const override
int m_propertiesFrameWidth
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
AppSettings * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
static TOOL_ACTION drawRectangle
void doCloseWindow() override
const BITMAP_OPAQUE icon_pagelayout_editor_32_xpm[1]
A holder to handle information on schematic or board items.
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the drawing-sheet (frame and title block).
PL_EDITOR_LAYOUT m_pageLayout
bool GetPageNumberOption() const
Drawing sheet editor can show the title block using a page number 1 or another number.
Handle actions that are shared between different applications.
Specialization of the wxAuiPaneInfo class for KiCad panels.
void OnSelectPage(wxCommandEvent &event)
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...
UNDO_REDO_CONTAINER m_redoList
static TOOL_ACTION milsUnits
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void SetPixelSizeIu(double aPixSize)
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allow a frame to load its preference panels (if any) into the preferences dialog.
wxChoice * m_pageSelectBox
const wxString GetZoomLevelIndicator() const
Return a human readable value for display in dialogs.
UNDO_REDO_LIST
Remove the aItemCount of old commands from aList and delete commands, pickers and picked items if nee...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
void SetPageSettings(const PAGE_INFO &aPageSettings)
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
void SetCurrentFileName(const wxString &aName)
Stores the current layout descr file filename.
double To_User_Unit(EDA_UNITS aUnit, double aValue)
Function To_User_Unit convert aValue in internal units to the appropriate user units defined by aUnit...
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
void UpdateTitleAndInfo()
Displays the short filename (if exists) loaded file on the caption of the main window.
Drawing sheet structure type definitions.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
SELECTION_CONDITION UndoAvailable()
Create a functor that tests if there are any items in the undo queue.
PROPERTIES_FRAME * m_propertiesPagelayout
The last filename chosen to be proposed to the user.
void DisplayGridMsg() override
Display current grid size in the status bar.
void SetGridOrigin(const wxPoint &aPoint) override
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
bool LoadPageLayoutDescrFile(const wxString &aFullFileName)
Function LoadPageLayoutDescrFile Loads a .kicad_wks page layout descr file.
EDA_UNITS m_userUnits
Map containing the UI update handlers registered with wx for each action.
static bool ShowNever(const SELECTION &aSelection)
Always returns false.
Handle actions specific to the drawing sheet editor.
static int GetCustomWidthMils()
static TOOL_ACTION appendImportedWorksheet
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
int m_PropertiesFrameWidth
Color settings are a bit different than most of the settings objects in that there can be more than o...
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Returns bbox of document with option to not include some items.
bool ReadImageFile(const wxString &aFullFilename)
Reads and stores in memory an image file.
static TOOL_ACTION deleteTool
void CopyPrmsFromItemToPanel(DS_DATA_ITEM *aItem)
virtual COLOR4D GetDrawBgColor() const
void CopyPrmsFromGeneralToPanel()
static TOOL_ACTION layoutNormalMode
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
static TOOL_ACTION toggleCursorStyle
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
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
virtual void LoadColors(const COLOR_SETTINGS *aSettings)
DS_DATA_ITEM * AddPageLayoutItem(int aType)
Function AddPageLayoutItem Add a new item to the page layout item list.
const PL_EDITOR_LAYOUT & GetPageLayout() const
void Append(DS_DATA_ITEM *aItem)
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual void ClearUndoRedoList()
Clear the undo and redo list using ClearUndoORRedoList()
static VRML_COLOR colors[VRML_COLOR_LAST]
wxChoice * m_originSelectBox
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
static void SetCustomHeightMils(int aHeightInMils)
Set the height of Custom page in mils for any custom page constructed or made via SetType() after mak...
void ClearListAndDeleteItems()
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...
static TOOL_ACTION selectionTool
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
#define ZOOM_LIST_PL_EDITOR
Tool that displays edit points allowing to modify items by dragging the points.
wxString m_ColorTheme
Active color theme name.
void Files_io(wxCommandEvent &event)