58 #include <wx/snglinst.h> 62 #define FR_HISTORY_LIST_CNT 10 72 const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
73 long aStyle, const wxString & aFrameName ) :
74 KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
76 m_socketServer =
nullptr;
79 m_optionsToolBar =
NULL;
80 m_auxiliaryToolBar =
NULL;
81 m_gridSelectBox =
NULL;
82 m_zoomSelectBox =
NULL;
83 m_firstRunDialogSetting = 0;
88 m_toolDispatcher =
NULL;
89 m_messagePanel =
NULL;
90 m_currentScreen =
NULL;
91 m_showBorderAndTitleBlock =
false;
93 m_showPageLimits =
false;
96 m_colorSettings =
nullptr;
99 m_polarCoords =
false;
100 m_findReplaceData =
new wxFindReplaceData( wxFR_DOWN );
102 m_auimgr.SetFlags(wxAUI_MGR_DEFAULT);
104 CreateStatusBar( 7 );
108 wxWindow* stsbar = GetStatusBar();
125 KIUI::GetTextSize( wxT(
"dx 0234.567890 dx 0234.567890 d 0234.567890" ), stsbar ).x + 10,
137 SetStatusWidths(
arrayDim( dims ), dims );
140 GetClientSize( &m_frameSize.x, &m_frameSize.y );
141 m_framePos.x = m_framePos.y = 0;
142 m_frameSize.y -= m_msgFrameHeight;
144 m_messagePanel =
new EDA_MSG_PANEL(
this, -1, wxPoint( 0, m_frameSize.y ),
145 wxSize( m_frameSize.x, m_msgFrameHeight ) );
209 wxCommandEvent e( UNITS_CHANGED );
210 ProcessEventLocally( e );
246 wxArrayString gridsList;
250 for(
const wxString& grid : gridsList )
268 idx = std::max( 0, std::min( idx, (
int)
m_gridSelectBox->GetCount() - 1 ) );
277 wxMessageBox( wxT(
"EDA_DRAW_FRAME::PrintPage() error") );
294 wxUpdateUIEvent
dummy;
301 wxUpdateUIEvent
dummy;
304 wxCommandEvent dummy2;
321 if( dlg.ShowModal() == wxID_OK )
372 if( zoom == current )
390 if( std::fabs( zoom -
config()->m_Window.zoom_factors[i] ) < ( zoom / 100.0 ) )
428 wxSize clientSize = GetClientSize();
444 auto zoomMenu = std::make_shared<ZOOM_MENU>(
this );
445 zoomMenu->SetTool( commonTools );
448 auto gridMenu = std::make_shared<GRID_MENU>(
this );
449 gridMenu->SetTool( commonTools );
459 SetStatusText( msg, 6 );
467 line.Printf(
"grid %s",
470 SetStatusText( line, 4 );
483 default: msg =
_(
"Units" );
break;
486 SetStatusText( msg, 5 );
616 const wxString& aTextUpper,
const wxString& aTextLower,
int aPadding )
629 wxCHECK_RET( aItem, wxT(
"Invalid EDA_ITEM pointer. Bad programmer." ) );
645 GetCanvas()->SetEvtHandlerEnabled(
true );
702 bool allow_save =
false;
704 for(
unsigned ii = 0; ii <
arrayDim( allowed_frames ); ii++ )
706 if(
m_ident == allowed_frames[ii] )
737 double xOffset = fmod( gridOrigin.x, gridSize.
x );
738 int x =
KiROUND( (aPosition.x - xOffset) / gridSize.
x );
739 double yOffset = fmod( gridOrigin.y, gridSize.
y );
740 int y =
KiROUND( (aPosition.y - yOffset) / gridSize.
y );
742 return wxPoint(
KiROUND( x * gridSize.
x + xOffset ),
KiROUND( y * gridSize.
y + yOffset ) );
751 double xOffset = fmod( gridOrigin.x, gridSize.
x );
752 int x =
KiROUND( (aPosition.x - xOffset) / gridSize.
x );
753 double yOffset = fmod( gridOrigin.y, gridSize.
y );
754 int y =
KiROUND( (aPosition.y - yOffset) / gridSize.
y );
756 return wxPoint(
KiROUND( x * gridSize.
x + xOffset ),
KiROUND( y * gridSize.
y + yOffset ) );
781 for( wxWindow* window : aList )
783 if( dynamic_cast<DIALOG_SHIM*>( window ) )
792 bool centerView =
false;
802 wxWindow* dialog =
findDialog( GetChildren() );
806 wxRect dialogRect(
GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
808 dialogRect.Inflate( dialogRect.GetWidth() / 10 );
810 if( dialogRect.Contains( (wxPoint)
GetCanvas()->GetView()->ToScreen( aPos ) ) )
819 wxRect dialogRect(
GetCanvas()->ScreenToClient( dialog->GetScreenPosition() ),
834 const wxString& aFullSheetName,
const wxString& aFileName,
836 const wxString& aPageNumber,
double aMils2Iu,
const PROJECT* aProject,
837 const wxString& aSheetLayer,
bool aIsFirstPage )
854 drawList.
Print( aSettings );
859 double aMils2Iu,
const wxString &aFilename,
860 const wxString &aSheetLayer )
866 wxPoint origin = DC->GetDeviceOrigin();
870 DC->SetDeviceOrigin( 0, 0 );
871 DC->SetAxisOrientation(
true,
false );
880 DC->SetDeviceOrigin( origin.x, origin.y );
881 DC->SetAxisOrientation(
true,
true );
889 return wxEmptyString;
894 const wxString& wildcard,
const wxString& ext,
895 bool isDirectory,
bool aIsGlobal,
896 const wxString& aGlobalPath )
898 wxString prompt = doOpen ?
_(
"Select Library" ) :
_(
"New Library" );
899 aFilename.SetExt( ext );
901 wxString dir = aGlobalPath;
904 if( isDirectory && doOpen )
911 wxDirDialog dlg(
this, prompt, dir,
912 wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
914 if( dlg.ShowModal() == wxID_CANCEL )
917 aFilename = dlg.GetPath();
918 aFilename.SetExt( ext );
923 if( aFilename.GetName().empty() )
924 aFilename.SetName(
"Library" );
931 wxFileDialog dlg(
this, prompt, dir, aFilename.GetFullName(),
932 wildcard, doOpen ? wxFD_OPEN | wxFD_FILE_MUST_EXIST
933 : wxFD_SAVE | wxFD_CHANGE_DIR | wxFD_OVERWRITE_PROMPT );
935 if( dlg.ShowModal() == wxID_CANCEL )
938 aFilename = dlg.GetPath();
939 aFilename.SetExt( ext );
969 const_cast<EDA_DRAW_FRAME*>(
this )->m_colorSettings = colorSettings;
1032 _(
"KiCad can use your graphics card to give you a smoother " 1033 "and faster experience. This option is turned off by " 1034 "default since it is not compatible with all computers.\n\n" 1035 "Would you like to try enabling graphics acceleration?\n\n" 1036 "If you'd like to choose later, select Accelerated Graphics " 1037 "in the Preferences menu." );
1039 wxMessageDialog dlg(
this, msg,
_(
"Enable Graphics Acceleration" ), wxYES_NO );
1041 dlg.SetYesNoLabels(
_(
"&Enable Acceleration" ),
_(
"&No Thanks" ) );
1043 if( dlg.ShowModal() == wxID_YES )
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
virtual void ReCreateVToolbar()=0
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
void SetIsFirstPage(bool aIsFirstPage)
Set if the page is the first page.
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
Container for project specific data.
void SetMilsToIUfactor(double aMils2Iu)
Set the scalar to convert pages units (mils) to draw/plot units.
virtual const TITLE_BLOCK & GetTitleBlock() const =0
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
std::vector< wxString > find_history
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Save common frame parameters to a configuration data file.
ACTION_TOOLBAR * m_auxiliaryToolBar
This file is part of the common library.
ACTION_TOOLBAR * m_optionsToolBar
virtual bool SwitchBackend(GAL_TYPE aGalType)
Switch method of rendering graphics.
void SetDefaultPenSize(int aPenSize)
FRAME_T
The set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
void SetFileName(const wxString &aFileName)
Set the filename to draw/plot.
bool LibraryFileBrowser(bool doOpen, wxFileName &aFilename, const wxString &wildcard, const wxString &ext, bool isDirectory=false, bool aIsGlobal=false, const wxString &aGlobalPath=wxEmptyString)
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
int GetVirtualPageNumber() const
static constexpr GAL_TYPE GAL_FALLBACK
std::vector< wxSocketBase * > m_sockets
interprocess communication
static TOOL_ACTION zoomFitScreen
void OnMove(wxMoveEvent &aEvent) override
static TOOL_ACTION millimetersUnits
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
wxArrayString m_findStringHistoryList
void resolveCanvasType()
Determines the Canvas type to load (with prompt if required) and initializes m_canvasType.
APP_SETTINGS_BASE * KifaceSettings() const
void ReleaseFile()
Release the current file marked in use.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
wxPoint GetNearestHalfGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize / 2 location to aPosition.
void UpdateZoomSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
ACTION_TOOLBAR * m_mainToolBar
wxPoint GetNearestGridPosition(const wxPoint &aPosition) const
Return the nearest aGridSize location to aPosition.
EDA_MSG_PANEL is a panel to display various information messages.
Sentinel, do not use as a parameter.
The base class for create windows for drawing purpose.
#define DEFAULT_MAX_UNDO_ITEMS
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.
virtual const wxString GetProjectPath() const
Return the full path of the project.
wxChoice * m_gridSelectBox
virtual void LoadSettings()
std::unique_ptr< wxSingleInstanceChecker > m_file_checker
std::vector< double > zoom_factors
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
bool IsImperialUnit(EDA_UNITS aUnit)
Auxiliary rendering target (noncached)
This file contains miscellaneous commonly used macros and functions.
const wxString & GetPageNumber() const
void DisplayUnitsMsg()
Display current unit pane in the status bar.
EDA_DRAW_PANEL_GAL * m_canvas
This the frame's interface to setting GAL display options.
void Print(const RENDER_SETTINGS *aSettings)
Draws the item list created by BuildDrawItemsList.
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
virtual const PAGE_INFO & GetPageSettings() const =0
virtual void Zoom_Automatique(bool aWarpPointer)
Redraw the screen with best zoom level and the best centering that shows all the page or the board.
Stores the common settings that are saved and loaded for each window / frame.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
BASE_SCREEN * m_currentScreen
current used SCREEN
static TOOL_ACTION gridPreset
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
FIND_REPLACE m_FindReplace
wxArrayString m_replaceStringHistoryList
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...
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
bool IsGridVisible() const
void WriteConfig(WINDOW_SETTINGS &aCfg)
EDA_MSG_PANEL * m_messagePanel
GAL not used (the legacy wxDC engine is used)
void OnUpdateSelectGrid(wxUpdateUIEvent &aEvent)
Update the checked item in the grid combobox.
void SetPageNumber(const wxString &aPageNumber)
Set the value of the sheet number.
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 m_showBorderAndTitleBlock
static TOOL_ACTION inchesUnits
virtual void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Handles how to draw a screen (a board, a schematic ...)
coord_type GetWidth() const
wxChoice * m_zoomSelectBox
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, const PAGE_INFO &aPageInfo, const wxString &aFullSheetName, const wxString &aFileName, const TITLE_BLOCK &aTitleBlock, int aSheetCount, const wxString &aPageNumber, double aMils2Iu, const PROJECT *aProject, const wxString &aSheetLayer, bool aIsFirstPage)
Print the border and title block.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
bool Contains(const Vec &aPoint) const
Function Contains.
virtual void PrintPage(const RENDER_SETTINGS *aSettings)
Print the page pointed by current screen, set by the calling print function.
std::vector< wxString > replace_history
virtual WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg)
Return a pointer to the window settings for this frame.
void ReadCommonConfig(COMMON_SETTINGS &aCommonSettings, wxWindow *aWindow)
Read GAL config options from the common config store.
Functions to provide common constants and other functions to assist in making a consistent UI.
wxWindow * findDialog(wxWindowList &aList)
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
An interface for classes handling user events controlling the view behavior such as zooming,...
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
int GetMaxUndoItems() const
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.
double GetZoomFactor() const
Get the zoom factor.
wxLogTrace helper definitions.
virtual void OnSize(wxSizeEvent &event)
Recalculate the size of toolbars and display panel when the frame size changes.
wxDC * GetPrintDC() const
virtual const BOX2I GetDocumentExtents(bool aIncludeAllVisible=true) const
Returns bbox of document with option to not include some items.
virtual void SetCrossHairCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Move the graphic crosshair cursor to the requested position expressed in world coordinates.
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
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).
#define FR_HISTORY_LIST_CNT
Maximum size of the find/replace history stacks.
virtual const wxPoint & GetGridOrigin() const =0
Return the absolute coordinates of the origin of the snap grid.
virtual void ClearMsgPanel()
Clear all messages from the message panel.
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
virtual void ResizeScreen(int aWidth, int aHeight)
Resize the canvas.
void StartDrawing()
Begin drawing if it was stopped previously.
virtual void ReCreateOptToolbar()=0
static TOOL_ACTION milsUnits
void SetSheetName(const wxString &aSheetName)
Set the sheet name to draw/plot.
virtual void HardRedraw()
Rebuild the GAL and redraws the screen.
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...
COLOR_SETTINGS * m_colorSettings
The current canvas type.
const wxString GetZoomLevelIndicator() const
Return a human readable value for display in dialogs.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
wxSocketServer * m_socketServer
const VECTOR2D & GetGridSize() const
Return the grid size.
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
EDA_DRAW_PANEL_GAL::GAL_TYPE loadCanvasTypeSetting()
Returns the canvas type stored in the application settings.
void BuildDrawItemsList(const PAGE_INFO &aPageInfo, const TITLE_BLOCK &aTitleBlock)
Drawing or plot the page layout.
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
void SetAutoSaveInterval(int aInterval)
static TOOL_ACTION updateUnits
virtual void ReCreateHToolbar()=0
void OnSelectGrid(wxCommandEvent &event)
Command event handler for selecting grid sizes.
void SetSheetLayer(const wxString &aSheetLayer)
Set the sheet layer to draw/plot.
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions
Default display origin transforms object.
void setupUnits(APP_SETTINGS_BASE *aCfg)
void SetProject(const PROJECT *aProject)
void ReadConfig(COMMON_SETTINGS &aCommonConfig, WINDOW_SETTINGS &aWindowConfig, wxWindow *aWindow)
Read application and common configs.
EDA_UNITS m_userUnits
Map containing the UI update handlers registered with wx for each action.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
A base class for most all the KiCad significant classes used in schematics and boards.
virtual void ReCreateAuxiliaryToolbar()
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
void SetGridVisibility(bool aVisibility)
Set the visibility setting of the grid.
wxFindReplaceData * m_findReplaceData
void SetSheetCount(int aSheetCount)
Set the value of the count of sheets, for basic inscriptions.
int GetDefaultPenWidth() const
Color settings are a bit different than most of the settings objects in that there can be more than o...
Store the list of graphic items: rect, lines, polygons and texts to draw/plot the title block and fra...
void SetUserUnits(EDA_UNITS aUnits)
void OnGridSettings(wxCommandEvent &event)
GAL_TYPE GetBackend() const
Return the type of backend currently used by GAL canvas.
void UpdateStatusBar() override
Update the status bar information.
virtual COLOR_SETTINGS * GetColorSettings() const
Returns a pointer to the active color theme settings.
void OnUpdateSelectZoom(wxUpdateUIEvent &aEvent)
Update the checked item in the zoom combobox.
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
void AppendMessage(const wxString &aUpperText, const wxString &aLowerText, int aPadding=6)
Function AppendMessage appends a message to the message panel.
bool saveCanvasTypeSetting(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Stores the canvas type in the application settings.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
virtual void DisplayGridMsg()
Display current grid size in the status bar.
BASE_SCREEN class implementation.
Message panel definition file.
void FocusOnLocation(const wxPoint &aPos)
Useful to focus on a particular location, in find functions.
void ToggleUserUnits() override
static int GetRequiredHeight()
Function GetRequiredHeight returns the required height (in pixels) of a EDA_MSG_PANEL.
virtual void SetGridVisibility(bool aVisible)
void GetUnitPair(EDA_UNITS &aPrimaryUnit, EDA_UNITS &aSecondaryUnits)
Get the pair or units in current use.
long m_firstRunDialogSetting
void MarkDirty()
Force redraw of view on the next rendering.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
virtual void OnSelectZoom(wxCommandEvent &event)
Set the zoom factor when selected by the zoom list box in the main tool bar.
bool LockFile(const wxString &aFileName)
Mark a schematic file as being in use.
void DisplayToolMsg(const wxString &msg) override
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
virtual void UpdateMsgPanel()
Redraw the message panel.
virtual wxString GetScreenDesc() const
void AppendMsgPanel(const wxString &aTextUpper, const wxString &aTextLower, int aPadding=6)
Append a message to the message panel.
static const wxString productName
A color representation with 4 components: red, green, blue, alpha.
ACTION_TOOLBAR * m_drawToolBar