59 #include <wx/wupdlock.h> 70 m_TextInfo( nullptr ),
98 int fileHistorySize =
Pgm().GetCommonSettings()->m_System.file_history_size;
110 galCanvas->GetView()->UseDrawPriority(
true );
114 wxIconBundle icon_bundle;
117 icon_bundle.AddIcon( icon );
119 icon_bundle.AddIcon( icon );
121 icon_bundle.AddIcon( icon );
123 SetIcons( icon_bundle );
158 .Layer( 3 ).Caption(
_(
"Layers Manager" ) ).PaneBorder(
false )
163 m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR,
164 wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
165 m_auimgr.GetArtProvider()->SetColour( wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR,
166 wxSystemSettings::GetColour( wxSYS_COLOUR_BTNTEXT ) );
182 galOptions.m_axesEnabled =
true;
183 galOptions.NotifyChanged();
219 GetCanvas()->SetEvtHandlerEnabled(
false );
235 if( aFileSet.size() > 0 )
237 wxString path = aFileSet[0];
243 if( path.Last() == wxChar(
'\"' ) )
246 if( !wxFileExists( path ) && wxDirExists( path ) )
252 const unsigned limit = std::min(
unsigned( aFileSet.size() ),
257 for(
unsigned i = 0; i < limit; ++i, ++layer )
263 wxFileName fn( aFileSet[i] );
264 wxString ext = fn.GetExt();
267 ext ==
"nc" || ext ==
"xnc" )
352 Pgm().GetSettingsManager().SaveColorSettings( cs,
"gerbview" );
368 lyrs.MinSize( bestz );
369 lyrs.BestSize( bestz );
370 lyrs.FloatingSize( bestz );
372 if( lyrs.IsDocked() )
383 bool dcodes_changed =
false;
400 auto item = dynamic_cast<GERBER_DRAW_ITEM*>( aItem );
403 return ( item && item->GetLayerPolarity() );
420 wxFAIL_MSG(
wxString::Format(
"GERBVIEW_FRAME::SetElementVisibility(): bad arg %d",
432 view->SetLayerVisible( dcode_layer, aNewState && view->IsLayerVisible( layer ) );
443 auto painter = static_cast<KIGFX::GERBVIEW_PAINTER*>(
GetCanvas()->GetView()->GetPainter() );
481 if( aRebuildLayerBox )
486 int dcodeSelected = -1;
508 std::unordered_map<int, int> view_remapping;
510 for(
auto it : remapping )
541 auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
543 switch( item->m_Shape )
557 else if( update_lines )
561 auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
563 switch( item->m_Shape )
575 else if( update_polygons )
579 auto item = static_cast<GERBER_DRAW_ITEM*>( aItem );
597 SetTitle(
"GerbView" );
599 SetStatusText( wxEmptyString, 0 );
602 info.Printf(
_(
"Drawing layer %d not in use" ),
GetActiveLayer() + 1 );
616 title.Printf( wxT(
"%s%s \u2014 " ) +
_(
"Gerber Viewer" ),
617 filename.GetFullName(),
618 gerber->
m_IsX2_file ? wxS(
" " ) +
_(
"(with X2 attributes)" )
619 : wxString( wxEmptyString ) );
626 status.Printf(
_(
"Image name: \"%s\" Layer name: \"%s\"" ),
629 SetStatusText( status, 0 );
633 info.Printf( wxT(
"fmt: %s X%d.%d Y%d.%d no %cZ" ),
642 info << wxT(
" ") <<
_(
"X2 attr" );
663 wxFAIL_MSG(
wxString::Format(
"GERBVIEW_FRAME::IsElementVisible(): bad arg %d", aLayerID ) );
690 bool v = aLayerMask[i];
725 wxFAIL_MSG(
wxString::Format(
"GERBVIEW_FRAME::GetVisibleElementColor(): bad arg %d",
748 settings->
SetColor( aLayerID, aColor );
761 settings->
SetColor( aLayerID, aColor );
766 settings->
SetColor( aLayerID, aColor );
770 wxFAIL_MSG(
wxString::Format(
"GERBVIEW_FRAME::SetVisibleElementColor(): bad arg %d",
787 return Pgm().GetSettingsManager().GetColorSettings()->GetColor( aLayer );
793 Pgm().GetSettingsManager().GetColorSettings()->SetColor( aLayer, aColor );
802 if( doLayerWidgetUpdate )
872 return Pgm().GetSettingsManager().GetColorSettings()->GetColor(
LAYER_GRID );
878 Pgm().GetSettingsManager().GetColorSettings()->SetColor(
LAYER_GRID, aColor );
891 line.Printf(
"grid X %s Y %s",
895 SetStatusText( line, 4 );
913 double theta =
RAD2DEG( atan2( -dy, dx ) );
914 double ro = hypot( dx, dy );
916 line.Printf( wxT(
"r %s theta %s" ),
920 SetStatusText( line, 3 );
924 line.Printf( wxT(
"X %s Y %s" ),
927 SetStatusText( line, 2 );
935 line.Printf( wxT(
"dx %s dy %s dist %s" ),
939 SetStatusText( line, 3 );
1001 book->AddPage(
new wxPanel( book ),
_(
"GerbView" ) );
1042 #define ENABLE( x ) ACTION_CONDITIONS().Enable( x ) 1043 #define CHECK( x ) ACTION_CONDITIONS().Check( x ) 1063 auto flashedDisplayOutlinesCond =
1069 auto linesFillCond =
1075 auto polygonsFilledCond =
1081 auto negativeObjectsCond =
1099 auto highContrastModeCond =
1105 auto flipGerberCond =
1111 auto layersManagerShownCondition =
1118 CHECK( flashedDisplayOutlinesCond ) );
1127 CHECK( layersManagerShownCondition ) );
A list of GERBER_DRAW_ITEM objects currently loaded.
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock) override
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
static TOOL_ACTION layerChanged
void SetVisibleElementColor(int aLayerID, COLOR4D aColor)
void SortLayersByX2Attributes()
virtual void SetHighContrastLayer(int aLayer)
Take care of display settings for the given layer to be displayed in high contrast mode.
void ToggleLayerManager()
std::vector< wxString > m_JobFileHistory
KIGFX::VIEW_CONTROLS * GetViewControls() const
Return a pointer to the #VIEW_CONTROLS instance used in the panel.
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
const wxSize GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
KIGFX::GAL_DISPLAY_OPTIONS & GetGalDisplayOptions()
Return a reference to the gal rendering options used by GAL for rendering.
void SetColorLayer(int aLayerId)
Can be used to override which layer ID is used for worksheet item colors.
void setupUIConditions() override
Setup the UI conditions for the various actions and their controls in this frame.
bool m_isClosing
Set by NonUserClose() to indicate that the user did not request the current close.
SETTINGS_MANAGER * GetSettingsManager() const
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void UpdateStatusBar() override
Update the status bar information.
void DeleteAllImages()
remove all loaded data in list, and delete all images.
ACTION_TOOLBAR * m_auxiliaryToolBar
Implementation of conversion functions that require both schematic and board internal units.
COLOR4D GetNegativeItemsColor()
This is usually the background color, but can be another color in order to see negative objects.
SELECTION_CONDITION FullscreenCursor()
Create a functor testing if the cursor is full screen in a frame.
ACTION_TOOLBAR * m_optionsToolBar
void syncLayerBox(bool aRebuildLayerBox=false)
Update the currently "selected" layer within m_SelLayerBox.
const BITMAP_OPAQUE icon_gerbview_32_xpm[1]
virtual void SetScreen(BASE_SCREEN *aScreen)
COLOR4D GetVisibleElementColor(int aLayerID)
Return the color of a gerber visible element.
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
static TOOL_ACTION zoomTool
EDA_DRAW_PANEL_GAL::GAL_TYPE m_canvasType
FILE_HISTORY m_jobFileHistory
void SetPageSettings(const PAGE_INFO &aPageSettings) override
const TITLE_BLOCK & GetTitleBlock() const override
GERBER_LAYER_WIDGET * m_LayersManager
std::unordered_map< int, int > SortImagesByZOrder()
Sort loaded images by Z order priority, if they have the X2 FileFormat info (SortImagesByZOrder updat...
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void RecacheAllItems()
Rebuild GAL display lists.
double RAD2DEG(double rad)
void Save(APP_SETTINGS_BASE &aSettings)
Saves history into a JSON settings object.
SELECTION_CONDITION CurrentTool(const TOOL_ACTION &aTool)
Create a functor testing if the specified tool is the current active tool in the frame.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl) override
Open a project or set of files given by aFileList.
Hold the image data and parameters for one gerber file and layer parameters.
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
change the currently active layer to aLayer and update the GERBER_LAYER_WIDGET.
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
wxSize m_FmtLen
Image rotation (0, 90, 180, 270 only) in degrees.
GBR_LAYER_BOX_SELECTOR * m_SelLayerBox
void RecreateToolbars()
Rebuild all toolbars, and update the checked state of check tools.
void SetDCodeSelection(int aDCodeId)
Function SetDCodeSelection.
void resolveCanvasType()
Determines the Canvas type to load (with prompt if required) and initializes m_canvasType.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
void Load(const APP_SETTINGS_BASE &aSettings)
Loads history from a JSON settings object.
void AddHotKeys(TOOL_MANAGER *aToolMgr)
static TOOL_ACTION toggleLayerManager
const wxString & GetType() const
void SetSheetCount(int aSheetCount)
Changes the sheet-count number displayed in the title block.
bool m_HighContrastMode
High contrast mode (dim un-highlighted objects)
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
ACTION_TOOLBAR * m_mainToolBar
Manage TOOL_ACTION objects.
An abstract base class for deriving all objects that can be added to a VIEW.
The base class for create windows for drawing purpose.
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.
wxSize m_FmtScale
< Fmt 2.3: m_FmtScale = 3, fmt 3.4: m_FmtScale = 4.
Class that groups generic conditions for editor states.
std::vector< double > zoom_factors
static TOOL_ACTION dcodeDisplay
static TOOL_ACTION negativeObjectDisplay
wxChoice * m_SelNetnameBox
void ActivateGalCanvas() override
Use to start up the GAL drawing canvas.
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
void SetGridVisibility(bool aVisible) override
GERBVIEW_FRAME(KIWAY *aKiway, wxWindow *aParent)
Gather all the actions that are shared by tools.
Auxiliary rendering target (noncached)
static TOOL_ACTION toggleDiffMode
bool show_negative_objects
void ReCreateHToolbar() override
bool LoadGerberJobFile(const wxString &aFileName)
Load a Gerber job file, and load gerber files found in job files.
bool m_IsX2_file
< True if a X2 gerber attribute was found in file.
FILE_HISTORY m_zipFileHistory
wxTreebook * GetTreebook()
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Called after the preferences dialog is run.
#define GERBER_DCODE_LAYER(x)
void UpdateGridSelectBox()
Rebuild the grid combobox to respond to any changes in the GUI (units, user grid changes,...
void InitDataPoints(const wxSize &aPageSizeInternalUnits)
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
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.
static TOOL_ACTION measureTool
void SetGridColor(const COLOR4D &aGridColor)
Set the grid color.
static TOOL_ACTION flipGerberView
void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged) override
Notification event that some of the common (suite-wide) settings have changed.
void DisplayImageInfo(GERBVIEW_FRAME *aMainFrame)
Display information about image parameters in the status bar.
bool m_DiffMode
Display layers in diff mode.
Item needs to be redrawn.
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Save common frame parameters to a configuration data file.
void UpdateDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Update the display options and refreshes the view as needed.
LSET is a set of PCB_LAYER_IDs.
std::vector< wxString > sizes
unsigned ImagesMaxCount() const
The max number of file images.
COLOR4D GetGridColor() override
std::vector< wxString > m_DrillFileHistory
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.
void ReCreateAuxiliaryToolbar() override
void unitsChangeRefresh() override
Called when when the units setting has changed to allow for any derived classes to handle refreshing ...
#define GERBER_DRAWLAYERS_COUNT
SELECTION_CONDITION Units(EDA_UNITS aUnit)
Create a functor that tests if the frame has the specified units.
GERBER_FILE_IMAGE * GetGbrImage(int aIdx)
void MarkTargetDirty(int aTarget)
Set or clear target 'dirty' flag.
bool IsGridVisible() const
unsigned ImagesMaxCount()
#define NO_AVAILABLE_LAYERS
void Clear()
Remove all items from the view.
static TOOL_ACTION toggleGrid
bool LoadGerberFiles(const wxString &aFileName)
Load a photoplot (Gerber) file or many files.
void InstallPreferences(PAGED_DIALOG *aParent, PANEL_HOTKEYS_EDITOR *aHotkeysPanel) override
Allow Gerbview to install its preferences panels into the preferences dialog.
Represent a set of closed polygons.
EDA_MSG_PANEL * m_messagePanel
GAL not used (the legacy wxDC engine is used)
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
GERBER_FILE_IMAGE * GetGbrImage(int aIdx) const
Handles how to draw a screen (a board, a schematic ...)
static TOOL_ACTION linesDisplayOutlines
GBR_DISPLAY_OPTIONS m_DisplayOptions
void applyDisplaySettingsToGAL()
Updates the GAL with display settings changes.
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
static TOOL_ACTION togglePolarCoords
const std::string GerberJobFileExtension
TITLE_BLOCK & GetTitleBlock()
Definition of file extensions used in Kicad.
Base window classes and related definitions.
bool IsElementVisible(int aLayerID) const
Test whether a given element category is visible.
GBR_LAYOUT * m_gerberLayout
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
KIGFX::GAL * GetGAL() const
Return a pointer to the GAL instance used in the panel.
virtual KIGFX::VIEW * GetView() const
Return a pointer to the #VIEW instance used in the panel.
virtual void SetFocus() override
static LSET AllLayersMask()
void SetLayerVisible(int aLayer, bool aVisible=true)
Control the visibility of a particular layer.
void ReorderLayerData(std::unordered_map< int, int > aReorderMap)
Remap the data between layer ids without invalidating that data.
#define KICAD_DEFAULT_DRAWFRAME_STYLE
#define ZOOM_LIST_GERBVIEW
virtual void ActivateGalCanvas()
Use to start up the GAL drawing canvas.
void doCloseWindow() override
FILE_HISTORY m_drillFileHistory
GERBVIEW_RENDER_SETTINGS Stores GerbView specific render settings.
Handle actions that are shared between different applications.
virtual void ClearMsgPanel()
Clear all messages from the message panel.
bool EnsureTextCtrlWidth(wxTextCtrl *aCtrl, const wxString *aString=NULL)
Set the minimum pixel width on a text control in order to make a text string be fully visible within ...
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
#define GERBVIEW_FRAME_NAME
The main window used in GerbView.
Specialization of the wxAuiPaneInfo class for KiCad panels.
const BITMAP_OPAQUE icon_gerbview_xpm[1]
void StartDrawing()
Begin drawing if it was stopped previously.
SELECTION_CONDITION PolarCoordinates()
Create a functor testing if polar coordinates are current being used.
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...
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...
static TOOL_ACTION flashedDisplayOutlines
GBR_LAYOUT * GetGerberLayout() const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
DCODE_SELECTION_BOX * m_DCodeSelector
void DisplayGridMsg() override
Display the current grid pane on the status bar.
void SetCanvas(EDA_DRAW_PANEL_GAL *aPanel)
const PAGE_INFO & GetPageSettings() const override
COLOR4D GetColor(int aLayer) const
void SetMaxFiles(size_t aMaxFiles)
Update the number of files that will be contained inside the file history.
int GetActiveLayer() const
Return the active layer.
wxChoice * m_SelAperAttributesBox
void LoadColors(const COLOR_SETTINGS *aSettings) override
bool GetShowPolarCoords() const
For those frames that support polar coordinates.
std::vector< wxString > m_ZipFileHistory
virtual void SwitchCanvas(EDA_DRAW_PANEL_GAL::GAL_TYPE aCanvasType)
Changes the current rendering backend.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
void SetDrawingSheet(DS_PROXY_VIEW_ITEM *aDrawingSheet)
Set or update the drawing-sheet (borders and title block) used by the draw panel.
void SetEventDispatcher(TOOL_DISPATCHER *aEventDispatcher)
Set a dispatcher that processes events and forwards them to tools.
void setupUnits(APP_SETTINGS_BASE *aCfg)
#define DEFAULT_FILE_HISTORY_SIZE
IDs range for menuitems file history: The default range file history size is 9 (compatible with defau...
static TOOL_ACTION polygonsDisplayOutlines
COLOR4D GetLayerColor(int aLayer) const
GERBER_FILE_IMAGE_LIST * GetImagesList() const
EDA_UNITS m_userUnits
Map containing the UI update handlers registered with wx for each action.
void SetLayerColor(int aLayer, COLOR4D aColor)
wxStaticText * m_dcodeText
bool m_FlipGerberView
Display as a mirror image.
virtual void SetGridColor(COLOR4D aColor) override
void syncLayerWidget()
Update the currently "selected" layer within the GERBER_LAYER_WIDGET.
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
wxChoice * m_SelComponentBox
void updateDCodeSelectBox()
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Function LoadDisplayOptions Loads settings related to display options.
Color settings are a bit different than most of the settings objects in that there can be more than o...
void SetPageNumber(const std::string &aPageNumber)
Changes the page number displayed in the title block.
bool LoadExcellonFiles(const wxString &aFileName)
Load a drill (EXCELLON) file or many files.
virtual COLOR4D GetDrawBgColor() const
static TOOL_ACTION toggleCursorStyle
drawingsheet frame and titleblock
void UpdateStatusBar() override
Update the status bar information.
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
#define GERBER_DRAW_LAYER(x)
virtual COLOR_SETTINGS * GetColorSettings() const
Returns a pointer to the active color theme settings.
bool m_show_layer_manager_tools
void ReCreateMenuBar() override
Recreates the menu bar.
bool show_border_and_titleblock
wxStaticText * m_apertText
int getNextAvailableLayer(int aLayer=0) const
Find the next empty layer starting at aLayer and returns it to the caller.
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
BASE_SCREEN class implementation.
Message panel definition file.
const BITMAP_OPAQUE icon_gerbview_16_xpm[1]
void SetLayout(GBR_LAYOUT *aLayout)
Set the m_gerberLayout member in such as way as to ensure deleting any previous GBR_LAYOUT.
bool IsLayerVisible(int aLayer) const
Test whether a given layer is visible.
bool m_DisplayDCodes
Option to show dcode values on items drawn with a dcode tool.
static TOOL_ACTION highContrastMode
GERBER_FILE_IMAGE_LIST * GetImagesList() const
Accessors to GERBER_FILE_IMAGE_LIST and GERBER_FILE_IMAGE data.
virtual BASE_SCREEN * GetScreen() const
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetElementVisibility(int aLayerID, bool aNewState)
Change the visibility of an element category.
virtual void SetGridVisibility(bool aVisible)
void ReFillLayerWidget()
Change out all the layers in m_Layers; called upon loading new gerber files.
void UpdateTitleAndInfo()
Display the short filename (if exists) of the selected layer on the caption of the main GerbView wind...
void StopDrawing()
Prevent the GAL canvas from further drawing until it is recreated or StartDrawing() is called.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
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.
GERBER_LAYER & GetLayerParams()
const std::string DrillFileExtension
Handle actions that are shared between different frames in Pcbnew.
void SetColor(int aLayer, COLOR4D aColor)
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
A color representation with 4 components: red, green, blue, alpha.
void ReCreateOptToolbar() override
Create or update the left vertical toolbar (option toolbar)