62#include <wx/filedlg.h> 
   64#include <wx/treebook.h> 
  109    wxIconBundle icon_bundle;
 
  112    icon_bundle.AddIcon( icon );
 
  114    icon_bundle.AddIcon( icon );
 
  116    icon_bundle.AddIcon( icon );
 
  118    icon_bundle.AddIcon( icon );
 
  120    icon_bundle.AddIcon( icon );
 
  122    SetIcons( icon_bundle );
 
  133    DragAcceptFiles( 
true );
 
  146    wxWindow* stsbar = GetStatusBar();
 
  170        KIUI::GetTextSize( 
_( 
"coord origin: Right Bottom page corner" ), stsbar ).x + spacer,
 
  179    SetStatusWidths( 
arrayDim( dims ), dims );
 
  190                      .Left().Layer( 3 ) );
 
  192                      .Bottom().Layer( 6 ) );
 
  196                      .Right().Layer( 2 ) );
 
  200                      .Caption( 
_( 
"Properties" ) )
 
  253    catch( 
const std::system_error& e )
 
  255        wxLogTrace( wxT( 
"KI_TRACE_NAVLIB" ), e.what() );
 
 
  308#define ENABLE( x ) ACTION_CONDITIONS().Enable( x ) 
  309#define CHECK( x )  ACTION_CONDITIONS().Check( x ) 
  342    auto titleBlockNormalMode =
 
  348    auto titleBlockEditMode =
 
 
  364    wxString fn = aFileSet[0];
 
  368        wxMessageBox( wxString::Format( 
_( 
"Error loading drawing sheet '%s'." ), fn ) );
 
 
  402    if( aEvent.GetId() == wxID_EXIT )
 
  405    if( aEvent.GetId() == wxID_CLOSE || 
Kiface().IsSingle() )
 
 
  414            && aEvent.GetId() == wxEVT_QUERY_END_SESSION
 
  423        wxString   msg      = 
_( 
"Save changes to '%s' before closing?" );
 
  428                                       return saveCurrentPageLayout();
 
 
  475    static wxPrintData* s_PrintData;
 
  476    static wxPageSetupDialogData* s_pageSetupData = 
nullptr;
 
  480    if( s_PrintData == 
nullptr )  
 
  482        s_PrintData = 
new wxPrintData();
 
  483        s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH );      
 
  486    if( !s_PrintData->Ok() )
 
  488        wxMessageBox( 
_( 
"Error Init Printer info" ) );
 
  492    if( s_pageSetupData == 
nullptr )
 
  493        s_pageSetupData = 
new wxPageSetupDialogData( *s_PrintData );
 
  495    s_pageSetupData->SetPaperId( pageInfo.
GetPaperId() );
 
  496    s_pageSetupData->GetPrintData().SetOrientation( pageInfo.
GetWxOrientation() );
 
  508    *s_PrintData = s_pageSetupData->GetPrintData();
 
 
  572        title += file.GetName();
 
  574        title += 
_( 
"[no drawing sheet loaded]" );
 
  576    title += wxT( 
" \u2014 " ) + 
_( 
"Drawing Sheet Editor" ),
 
 
  668        originCoord = 
dummy.GetStartPosIU();
 
  673        originCoord = 
dummy.GetStartPosIU();
 
  678        originCoord = 
dummy.GetStartPosIU();
 
  683        originCoord = 
dummy.GetStartPosIU();
 
 
  694    wxString gridformatter;
 
  699    case EDA_UNITS::MM:   gridformatter = wxS( 
"grid %.4f" ); 
break;
 
  700    default:              gridformatter = wxS( 
"grid %f" );   
break;
 
  704                                                  GetCanvas()->GetGAL()->GetGridSize().x );
 
  705    line.Printf( gridformatter, 
grid );
 
  707    SetStatusText( line, 4 );
 
 
  749    VECTOR2D coord = cursorPos - originCoord;
 
  755    wxString absformatter = wxT( 
"X %.4g  Y %.4g" );
 
  756    wxString locformatter = wxT( 
"dx %.4g  dy %.4g" );
 
  764    default:                  wxASSERT( 
false );                 
break;
 
  770    line.Printf( absformatter, dXpos, dYpos );
 
  771    SetStatusText( line, 2 );
 
  780        line.Printf( locformatter, dXpos, dYpos );
 
  781        SetStatusText( line, 3 );
 
  787    line.Printf( 
_(
"coord origin: %s"),
 
  789    SetStatusText( line, 5 );
 
 
  813    if( selection.GetSize() == 1 )
 
 
  847        wxFileDialog fileDlg( 
this, 
_( 
"Choose Image" ), 
m_mruImagePath, wxEmptyString,
 
  848                              _( 
"Image Files" ) + wxS( 
" " ) + wxImage::GetImageExtWildcard(),
 
  851        if( fileDlg.ShowModal() != wxID_OK )
 
  854        wxString fullFilename = fileDlg.GetPath();
 
  857        if( !wxFileExists( fullFilename ) )
 
  859            wxMessageBox( 
_( 
"Could not load image from '%s'." ), fullFilename );
 
  865        if( !
image->ReadImageFile( fullFilename ) )
 
  867            wxMessageBox( 
_( 
"Could not load image from '%s'." ), fullFilename );
 
  879    if( item == 
nullptr )
 
 
  916    if( aItemCount == 0 )
 
  923        list.ClearCommandList();
 
  927        for( 
int ii = 0; ii < aItemCount; ii++ )
 
  929            if( list.m_CommandsList.size() == 0 )
 
  933            list.m_CommandsList.erase( list.m_CommandsList.begin() );
 
 
  955    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
 
constexpr EDA_IU_SCALE pcbIUScale
 
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 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
 
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.
 
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)
 
bool LoadDrawingSheet(const wxString &aFullFileName, wxString *aMsg, bool aAppend=false)
Populate the list with a custom layout or the default layout if no custom layout is available.
 
static DS_DATA_MODEL & GetTheInstance()
Return 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.
 
Base class to handle basic graphic items.
 
DS_DATA_ITEM * GetPeer() const
 
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
 
virtual void handleIconizeEvent(wxIconizeEvent &aEvent)
Handle a window iconize event.
 
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
Specify 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...
 
ACTION_TOOLBAR * m_tbRight
 
TOOLBAR_SETTINGS * m_toolbarSettings
 
void FinishAUIInitialization()
 
virtual void RecreateToolbars()
 
UNDO_REDO_CONTAINER m_redoList
 
ACTION_TOOLBAR * m_tbLeft
 
virtual void OnDropFiles(wxDropFilesEvent &aEvent)
Handle event fired when a file is dropped to the window.
 
std::map< const wxString, TOOL_ACTION * > m_acceptedExts
Associate file extensions with action to execute.
 
ACTION_TOOLBAR * m_tbTopMain
 
bool m_isClosing
Set by the close window event handler after frames are asked if they can close.
 
void ReCreateMenuBar()
Recreate the menu bar.
 
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
The current canvas type.
 
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
 
void setupUnits(APP_SETTINGS_BASE *aCfg)
 
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.
 
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Change the current rendering backend.
 
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.
 
virtual void resolveCanvasType()
Determine the canvas type to load (with prompt if required) and initializes m_canvasType.
 
EDA_MSG_PANEL * m_messagePanel
 
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
 
virtual void SetScreen(BASE_SCREEN *aScreen)
 
EDA_DRAW_FRAME(KIWAY *aKiway, wxWindow *aParent, FRAME_T aFrameType, const wxString &aTitle, const wxPoint &aPos, const wxSize &aSize, long aStyle, const wxString &aFrameName, const EDA_IU_SCALE &aIuScale)
 
virtual void handleActivateEvent(wxActivateEvent &aEvent)
Handle a window activation event.
 
virtual void SetDrawBgColor(const COLOR4D &aColor)
 
virtual COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const
Returns a pointer to the active color theme settings.
 
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(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
 
bool m_showBorderAndTitleBlock
 
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 NoActiveTool()
Create a functor testing if there are no tools active in the frame.
 
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 GridVisible()
Create a functor testing if the grid is visible 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.
 
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.
 
wxString GetTypeAsString() const
 
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...
 
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
 
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...
 
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.
 
std::unique_ptr< NL_PL_EDITOR_PLUGIN > m_spaceMouse
 
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 configureToolbars() override
 
void ToPrinter(bool doPreview)
Open a dialog frame to print layers.
 
PL_EDITOR_FRAME(KIWAY *aKiway, wxWindow *aParent)
 
void UpdateMsgPanelInfo()
Display the size of the sheet to the message panel.
 
const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const override
Return bounding box 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...
 
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 handleActivateEvent(wxActivateEvent &aEvent) override
Handle a window activation event.
 
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 UpdateToolbarControlSizes() override
Update the sizes of any controls in the toolbars of the frame.
 
void CommonSettingsChanged(int aFlags) override
Notification event that some of the common (suite-wide) settings have changed.
 
void handleIconizeEvent(wxIconizeEvent &aEvent) override
Handle a window iconize event.
 
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.
 
TITLE_BLOCK & GetTitleBlock()
 
int m_PropertiesFrameWidth
 
Tool that displays edit points allowing to modify items by dragging the points.
 
PROPERTIES_FRAME display properties of the current item.
 
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.
 
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.
 
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
 
void SetUserUnits(EDA_UNITS aUnits)
 
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
Sheet Editor previewing pages after first page.
 
@ LAYER_DRAWINGSHEET_PAGE1
Sheet Editor previewing first page.
 
KICOMMON_API double ToUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
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...
 
@ ID_SELECT_COORDINATE_ORIGIN
 
T * GetToolbarSettings(const wxString &aFilename)
 
T * GetAppSettings(const char *aFilename)
 
KIWAY Kiway(KFCTL_STANDALONE)
 
std::vector< FAB_LAYER_COLOR > dummy
 
VECTOR2< int32_t > VECTOR2I
 
VECTOR2< double > VECTOR2D
 
Definition of file extensions used in Kicad.