← Back to team overview

kicad-developers team mailing list archive

[PATCH] Gerbview Worksheet Display Setting

 

Hi everyone,

I noticed recently that worksheets are now displayed in the Gerbview GAL
rendering engine. It appears this behavior was added to GAL in the
following commit:

https://github.com/KiCad/kicad-source-mirror/commit/9a228d8e
c9eff6fcfc0651a3f98414f95ba8fe69#diff-65128126b95a4ffc3801d22ac0150f48


The above commit changes behavior from the legacy rendering engine, where
the default option "Full size without limits" hides the worksheet from
display. Recently this dialog option was deleted in the commit below (this
makes sense it didn't do anything at the time; it was broken):

https://github.com/KiCad/kicad-source-mirror/commit/
7841f8a466d47a8db44d1701ea7366d6e0560ff3


I put together a change that restores the old behavior (GAL and Legacy) and
makes the settings more clear in the dialog. Two check boxes are created
because m_showBorderAndTitleBlock,  and m_showPageLimits are technically
two separate settings in EDA_DRAW_FRAME. Since a border cannot be displayed
without the worksheet, the first checkbox disables the other.




If this looks worthwhile, let me know what branch to patch against (5.1 vs
Master). I can address any comments and generate a proper patch file with
commit message.

Cheers,
John
diff --git a/gerbview/dialogs/panel_gerbview_settings.cpp b/gerbview/dialogs/panel_gerbview_settings.cpp
--- a/gerbview/dialogs/panel_gerbview_settings.cpp
+++ b/gerbview/dialogs/panel_gerbview_settings.cpp
@@ -34,12 +34,22 @@
 {
 }
 
+void PANEL_GERBVIEW_SETTINGS::OnShowWorksheetClick( wxMouseEvent& event )
+{
+    // Checked state is not yet updated by click event, inverted logic.
+    m_ShowPageLimitsOpt->Enable( !m_ShowWorksheet->GetValue() );
+}
 
 bool PANEL_GERBVIEW_SETTINGS::TransferDataToWindow( )
 {
     m_PolarDisplay->SetSelection( m_Parent->m_DisplayOptions.m_DisplayPolarCood ? 1 : 0 );
     m_BoxUnits->SetSelection( m_Parent->GetUserUnits() ? 1 : 0 );
-    m_ShowPageLimitsOpt->SetValue( m_Parent->m_DisplayOptions.m_DisplayPageLimits );
+    m_ShowPageLimitsOpt->SetValue( m_Parent->ShowPageLimits() );
+    m_ShowWorksheet->SetValue( m_Parent->GetShowBorderAndTitleBlock() );
+
+    // Page borders cannot be displayed without the worksheet setting enabled, so the
+    // worksheet checkbox should disable the page border checkbox to inform users.
+    m_ShowPageLimitsOpt->Enable( m_Parent->GetShowBorderAndTitleBlock() );
 
     for( unsigned i = 0;  i < DIM( g_GerberPageSizeList );  ++i )
     {
@@ -58,7 +68,8 @@
 {
     m_Parent->m_DisplayOptions.m_DisplayPolarCood = ( m_PolarDisplay->GetSelection() != 0 );
     m_Parent->SetUserUnits( m_BoxUnits->GetSelection() == 0 ? INCHES : MILLIMETRES );
-    m_Parent->m_DisplayOptions.m_DisplayPageLimits = m_ShowPageLimitsOpt->GetValue();
+    m_Parent->SetShowPageLimits( m_ShowPageLimitsOpt->GetValue() );
+    m_Parent->SetShowBorderAndTitleBlock( m_ShowWorksheet->GetValue() );
 
     PAGE_INFO pageInfo( g_GerberPageSizeList[ m_PageSize->GetSelection() ] );
     m_Parent->SetPageSettings( pageInfo );
diff --git a/gerbview/dialogs/panel_gerbview_settings.h b/gerbview/dialogs/panel_gerbview_settings.h
--- a/gerbview/dialogs/panel_gerbview_settings.h
+++ b/gerbview/dialogs/panel_gerbview_settings.h
@@ -38,6 +38,9 @@
     PANEL_GERBVIEW_SETTINGS( GERBVIEW_FRAME* aFrame, wxWindow* aWindow );
     ~PANEL_GERBVIEW_SETTINGS() {};
 
+protected:
+    void OnShowWorksheetClick( wxMouseEvent& event ) override;
+
 private:
     bool TransferDataToWindow() override;
     bool TransferDataFromWindow() override;
diff --git a/gerbview/dialogs/panel_gerbview_settings_base.cpp b/gerbview/dialogs/panel_gerbview_settings_base.cpp
--- a/gerbview/dialogs/panel_gerbview_settings_base.cpp
+++ b/gerbview/dialogs/panel_gerbview_settings_base.cpp
@@ -1,8 +1,8 @@
 ///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Dec 30 2017)
+// C++ code generated with wxFormBuilder (version May  8 2018)
 // http://www.wxformbuilder.org/
 //
-// PLEASE DO *NOT* EDIT THIS FILE!
+// PLEASE DO "NOT" EDIT THIS FILE!
 ///////////////////////////////////////////////////////////////////////////
 
 #include "panel_gerbview_settings_base.h"
@@ -37,7 +37,12 @@
 	m_PageSize->SetSelection( 0 );
 	bLeftSizer->Add( m_PageSize, 0, wxEXPAND|wxTOP|wxLEFT, 5 );
 	
+	m_ShowWorksheet = new wxCheckBox( this, wxID_ANY, _("Show worksheet"), wxDefaultPosition, wxDefaultSize, 0 );
+	bLeftSizer->Add( m_ShowWorksheet, 0, wxALL, 10 );
+	
 	m_ShowPageLimitsOpt = new wxCheckBox( this, wxID_ANY, _("Show page limits"), wxDefaultPosition, wxDefaultSize, 0 );
+	m_ShowPageLimitsOpt->Enable( false );
+	
 	bLeftSizer->Add( m_ShowPageLimitsOpt, 0, wxALL, 10 );
 	
 	
@@ -50,8 +55,14 @@
 	this->SetSizer( bDialogSizer );
 	this->Layout();
 	bDialogSizer->Fit( this );
+	
+	// Connect Events
+	m_ShowWorksheet->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( PANEL_GERBVIEW_SETTINGS_BASE::OnShowWorksheetClick ), NULL, this );
 }
 
 PANEL_GERBVIEW_SETTINGS_BASE::~PANEL_GERBVIEW_SETTINGS_BASE()
 {
+	// Disconnect Events
+	m_ShowWorksheet->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( PANEL_GERBVIEW_SETTINGS_BASE::OnShowWorksheetClick ), NULL, this );
+	
 }
diff --git a/gerbview/dialogs/panel_gerbview_settings_base.fbp b/gerbview/dialogs/panel_gerbview_settings_base.fbp
--- a/gerbview/dialogs/panel_gerbview_settings_base.fbp
+++ b/gerbview/dialogs/panel_gerbview_settings_base.fbp
@@ -101,11 +101,11 @@
                                 <property name="name">bLeftSizer</property>
                                 <property name="orient">wxVERTICAL</property>
                                 <property name="permission">none</property>
-                                <object class="sizeritem" expanded="1">
+                                <object class="sizeritem" expanded="0">
                                     <property name="border">5</property>
                                     <property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxLEFT</property>
                                     <property name="proportion">0</property>
-                                    <object class="wxRadioBox" expanded="1">
+                                    <object class="wxRadioBox" expanded="0">
                                         <property name="BottomDockable">1</property>
                                         <property name="LeftDockable">1</property>
                                         <property name="RightDockable">1</property>
@@ -191,11 +191,11 @@
                                         <event name="OnUpdateUI"></event>
                                     </object>
                                 </object>
-                                <object class="sizeritem" expanded="1">
+                                <object class="sizeritem" expanded="0">
                                     <property name="border">5</property>
                                     <property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxLEFT</property>
                                     <property name="proportion">0</property>
-                                    <object class="wxRadioBox" expanded="1">
+                                    <object class="wxRadioBox" expanded="0">
                                         <property name="BottomDockable">1</property>
                                         <property name="LeftDockable">1</property>
                                         <property name="RightDockable">1</property>
@@ -281,11 +281,11 @@
                                         <event name="OnUpdateUI"></event>
                                     </object>
                                 </object>
-                                <object class="sizeritem" expanded="1">
+                                <object class="sizeritem" expanded="0">
                                     <property name="border">5</property>
                                     <property name="flag">wxEXPAND|wxTOP|wxLEFT</property>
                                     <property name="proportion">0</property>
-                                    <object class="wxRadioBox" expanded="1">
+                                    <object class="wxRadioBox" expanded="0">
                                         <property name="BottomDockable">1</property>
                                         <property name="LeftDockable">1</property>
                                         <property name="RightDockable">1</property>
@@ -371,11 +371,11 @@
                                         <event name="OnUpdateUI"></event>
                                     </object>
                                 </object>
-                                <object class="sizeritem" expanded="1">
+                                <object class="sizeritem" expanded="0">
                                     <property name="border">10</property>
                                     <property name="flag">wxALL</property>
                                     <property name="proportion">0</property>
-                                    <object class="wxCheckBox" expanded="1">
+                                    <object class="wxCheckBox" expanded="0">
                                         <property name="BottomDockable">1</property>
                                         <property name="LeftDockable">1</property>
                                         <property name="RightDockable">1</property>
@@ -404,6 +404,94 @@
                                         <property name="gripper">0</property>
                                         <property name="hidden">0</property>
                                         <property name="id">wxID_ANY</property>
+                                        <property name="label">Show worksheet</property>
+                                        <property name="max_size"></property>
+                                        <property name="maximize_button">0</property>
+                                        <property name="maximum_size"></property>
+                                        <property name="min_size"></property>
+                                        <property name="minimize_button">0</property>
+                                        <property name="minimum_size"></property>
+                                        <property name="moveable">1</property>
+                                        <property name="name">m_ShowWorksheet</property>
+                                        <property name="pane_border">1</property>
+                                        <property name="pane_position"></property>
+                                        <property name="pane_size"></property>
+                                        <property name="permission">protected</property>
+                                        <property name="pin_button">1</property>
+                                        <property name="pos"></property>
+                                        <property name="resize">Resizable</property>
+                                        <property name="show">1</property>
+                                        <property name="size"></property>
+                                        <property name="style"></property>
+                                        <property name="subclass">; forward_declare</property>
+                                        <property name="toolbar_pane">0</property>
+                                        <property name="tooltip"></property>
+                                        <property name="validator_data_type"></property>
+                                        <property name="validator_style">wxFILTER_NONE</property>
+                                        <property name="validator_type">wxDefaultValidator</property>
+                                        <property name="validator_variable"></property>
+                                        <property name="window_extra_style"></property>
+                                        <property name="window_name"></property>
+                                        <property name="window_style"></property>
+                                        <event name="OnChar"></event>
+                                        <event name="OnCheckBox"></event>
+                                        <event name="OnEnterWindow"></event>
+                                        <event name="OnEraseBackground"></event>
+                                        <event name="OnKeyDown"></event>
+                                        <event name="OnKeyUp"></event>
+                                        <event name="OnKillFocus"></event>
+                                        <event name="OnLeaveWindow"></event>
+                                        <event name="OnLeftDClick"></event>
+                                        <event name="OnLeftDown"></event>
+                                        <event name="OnLeftUp">OnShowWorksheetClick</event>
+                                        <event name="OnMiddleDClick"></event>
+                                        <event name="OnMiddleDown"></event>
+                                        <event name="OnMiddleUp"></event>
+                                        <event name="OnMotion"></event>
+                                        <event name="OnMouseEvents"></event>
+                                        <event name="OnMouseWheel"></event>
+                                        <event name="OnPaint"></event>
+                                        <event name="OnRightDClick"></event>
+                                        <event name="OnRightDown"></event>
+                                        <event name="OnRightUp"></event>
+                                        <event name="OnSetFocus"></event>
+                                        <event name="OnSize"></event>
+                                        <event name="OnUpdateUI"></event>
+                                    </object>
+                                </object>
+                                <object class="sizeritem" expanded="0">
+                                    <property name="border">10</property>
+                                    <property name="flag">wxALL</property>
+                                    <property name="proportion">0</property>
+                                    <object class="wxCheckBox" expanded="0">
+                                        <property name="BottomDockable">1</property>
+                                        <property name="LeftDockable">1</property>
+                                        <property name="RightDockable">1</property>
+                                        <property name="TopDockable">1</property>
+                                        <property name="aui_layer"></property>
+                                        <property name="aui_name"></property>
+                                        <property name="aui_position"></property>
+                                        <property name="aui_row"></property>
+                                        <property name="best_size"></property>
+                                        <property name="bg"></property>
+                                        <property name="caption"></property>
+                                        <property name="caption_visible">1</property>
+                                        <property name="center_pane">0</property>
+                                        <property name="checked">0</property>
+                                        <property name="close_button">1</property>
+                                        <property name="context_help"></property>
+                                        <property name="context_menu">1</property>
+                                        <property name="default_pane">0</property>
+                                        <property name="dock">Dock</property>
+                                        <property name="dock_fixed">0</property>
+                                        <property name="docking">Left</property>
+                                        <property name="enabled">0</property>
+                                        <property name="fg"></property>
+                                        <property name="floatable">1</property>
+                                        <property name="font"></property>
+                                        <property name="gripper">0</property>
+                                        <property name="hidden">0</property>
+                                        <property name="id">wxID_ANY</property>
                                         <property name="label">Show page limits</property>
                                         <property name="max_size"></property>
                                         <property name="maximize_button">0</property>
diff --git a/gerbview/dialogs/panel_gerbview_settings_base.h b/gerbview/dialogs/panel_gerbview_settings_base.h
--- a/gerbview/dialogs/panel_gerbview_settings_base.h
+++ b/gerbview/dialogs/panel_gerbview_settings_base.h
@@ -1,8 +1,8 @@
 ///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Dec 30 2017)
+// C++ code generated with wxFormBuilder (version May  8 2018)
 // http://www.wxformbuilder.org/
 //
-// PLEASE DO *NOT* EDIT THIS FILE!
+// PLEASE DO "NOT" EDIT THIS FILE!
 ///////////////////////////////////////////////////////////////////////////
 
 #ifndef __PANEL_GERBVIEW_SETTINGS_BASE_H__
@@ -36,7 +36,12 @@
 		wxRadioBox* m_PolarDisplay;
 		wxRadioBox* m_BoxUnits;
 		wxRadioBox* m_PageSize;
+		wxCheckBox* m_ShowWorksheet;
 		wxCheckBox* m_ShowPageLimitsOpt;
+		
+		// Virtual event handlers, overide them in your derived class
+		virtual void OnShowWorksheetClick( wxMouseEvent& event ) { event.Skip(); wxASSERT_MSG(false, "BASE"); }
+		
 	
 	public:
 		
diff --git a/gerbview/gbr_display_options.h b/gerbview/gbr_display_options.h
--- a/gerbview/gbr_display_options.h
+++ b/gerbview/gbr_display_options.h
@@ -44,7 +44,6 @@
     bool    m_DisplayPolygonsFill;      ///< Option to draw polygons (filled/sketch)
     bool    m_DisplayPolarCood;         ///< Option to display coordinates in status bar in X,Y or Polar coords
     bool    m_DisplayDCodes;            ///< Option to show dcode values on items drawn with a dcode tool
-    bool    m_DisplayPageLimits;
     bool    m_DisplayNegativeObjects;   ///< Option to draw negative objects in a specific color
     bool    m_IsPrinting;               ///< true when printing a page, false when drawing on screen
     bool    m_ForceBlackAndWhite;       ///< Option print in blackand white (ont used id draw mode
@@ -63,7 +62,6 @@
         m_DisplayPolygonsFill = true;
         m_DisplayPolarCood = false;
         m_DisplayDCodes = false;
-        m_DisplayPageLimits = false;
         m_IsPrinting = false;
         m_DisplayNegativeObjects = false;
         m_ForceBlackAndWhite = false;
diff --git a/gerbview/gerbview_draw_panel_gal.cpp b/gerbview/gerbview_draw_panel_gal.cpp
--- a/gerbview/gerbview_draw_panel_gal.cpp
+++ b/gerbview/gerbview_draw_panel_gal.cpp
@@ -146,7 +146,12 @@
 void GERBVIEW_DRAW_PANEL_GAL::SetWorksheet( KIGFX::WORKSHEET_VIEWITEM* aWorksheet )
 {
     m_worksheet.reset( aWorksheet );
-    m_view->Add( m_worksheet.get() );
+
+    // The worksheet display layer can be disabled by the user, check setting
+    if( m_edaFrame && m_edaFrame->GetShowBorderAndTitleBlock() )
+    {
+        m_view->Add( m_worksheet.get() );
+    }
 }
 
 
diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp
--- a/gerbview/gerbview_frame.cpp
+++ b/gerbview/gerbview_frame.cpp
@@ -59,6 +59,7 @@
 static const wxString   cfgShowDCodes( wxT( "ShowDCodesOpt" ) );
 static const wxString   cfgShowNegativeObjects( wxT( "ShowNegativeObjectsOpt" ) );
 static const wxString   cfgShowBorderAndTitleBlock( wxT( "ShowBorderAndTitleBlock" ) );
+static const wxString   cfgShowPageLimits( wxT( "ShowPageLimits" ) );
 
 // Colors for layers and items
 COLORS_DESIGN_SETTINGS g_ColorsSettings( FRAME_GERBER );
@@ -384,6 +385,7 @@
     wxConfigLoadSetups( aCfg, GetConfigurationSettings() );
 
     aCfg->Read( cfgShowBorderAndTitleBlock, &m_showBorderAndTitleBlock, false );
+    aCfg->Read( cfgShowPageLimits, &m_showPageLimits, false );
 
     PAGE_INFO pageInfo( wxT( "GERBER" ) );
     wxString pageType;
@@ -427,6 +429,7 @@
 
     aCfg->Write( cfgShowPageSizeOption, GetPageSettings().GetType() );
     aCfg->Write( cfgShowBorderAndTitleBlock, m_showBorderAndTitleBlock );
+    aCfg->Write( cfgShowPageLimits, m_showPageLimits);
     aCfg->Write( cfgShowDCodes, IsElementVisible( LAYER_DCODES ) );
     aCfg->Write( cfgShowNegativeObjects, IsElementVisible( LAYER_NEGATIVE_OBJECTS ) );
 
diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp
--- a/gerbview/gerbview_painter.cpp
+++ b/gerbview/gerbview_painter.cpp
@@ -90,7 +90,6 @@
     m_showCodes         = aOptions->m_DisplayDCodes;
     m_diffMode          = aOptions->m_DiffMode;
     m_hiContrastEnabled = aOptions->m_HighContrastMode;
-    m_showPageLimits    = aOptions->m_DisplayPageLimits;
     m_backgroundColor   = aOptions->m_BgDrawColor;
 
     update();
diff --git a/include/draw_frame.h b/include/draw_frame.h
--- a/include/draw_frame.h
+++ b/include/draw_frame.h
@@ -363,10 +363,24 @@
      */
     virtual void SetDrawBgColor( COLOR4D aColor) { m_drawBgColor= aColor ; }
 
+    /**
+     * Display a worksheet page in the frame
+     */
     bool GetShowBorderAndTitleBlock() const { return m_showBorderAndTitleBlock; }
 
+    /**
+     * Set worksheet page display setting
+     */
     void SetShowBorderAndTitleBlock( bool aShow ) { m_showBorderAndTitleBlock = aShow; }
+
+    /**
+     * Display a page border in the frame
+     */
     bool ShowPageLimits() const { return m_showPageLimits; }
+
+    /**
+     * Set page border display setting
+     */
     void SetShowPageLimits( bool aShow ) { m_showPageLimits = aShow; }
 
     EDA_DRAW_PANEL* GetCanvas() { return m_canvas; }

Follow ups