← Back to team overview

kicad-developers team mailing list archive

Re: [PATCH] Show the current grid setting.

 

I've rebased my patch to show the current grid setting, and I've generated it both for the master branch and the 5.1 branch.  The attached patches were generated via git format-patch.

Please consider these patches for inclusion into KiCad, and please let me know if there is anything that I should change to make them acceptable.

	Thanks,
	Steve
>From 86c241349bfabfd4ff20ba4064ef0870243e1471 Mon Sep 17 00:00:00 2001
From: "Steven A. Falco" <stevenfalco@xxxxxxxxx>
Date: Mon, 10 Jun 2019 10:16:14 -0400
Subject: [PATCH] Show the current grid setting.

---
 common/legacy_gal/eda_draw_frame.cpp  | 38 ++++++++++++++++++++--
 common/legacy_wx/eda_draw_frame.cpp   | 38 ++++++++++++++++++++--
 eeschema/sch_base_frame.cpp           |  3 ++
 gerbview/gerbview_frame.cpp           | 38 ++++++++++++++++++++++
 gerbview/gerbview_frame.h             |  7 ++++
 include/draw_frame.h                  |  5 +++
 include/pcb_base_frame.h              |  7 ++++
 pagelayout_editor/pl_editor_frame.cpp | 46 ++++++++++++++++++++++++---
 pagelayout_editor/pl_editor_frame.h   |  2 ++
 pcbnew/pcb_base_frame.cpp             | 38 ++++++++++++++++++++++
 10 files changed, 213 insertions(+), 9 deletions(-)

diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp
index 058df54f8..877d16e10 100644
--- a/common/legacy_gal/eda_draw_frame.cpp
+++ b/common/legacy_gal/eda_draw_frame.cpp
@@ -169,7 +169,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
 
     m_auimgr.SetFlags(wxAUI_MGR_DEFAULT);
 
-    CreateStatusBar( 6 );
+    CreateStatusBar( 7 );
 
     // set the size of the status bar subwindows:
 
@@ -192,6 +192,9 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
         // delta distances
         GetTextSize( wxT( "dx 0234.567890  dx 0234.567890  d 0234.567890" ), stsbar ).x + 10,
 
+        // grid size
+        GetTextSize( wxT( "grid X 0234.567890  Y 0234.567890" ), stsbar ).x + 10,
+
         // units display, Inches is bigger than mm
         GetTextSize( _( "Inches" ), stsbar ).x + 10,
 
@@ -614,6 +617,37 @@ void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
 }
 
 
+/*
+ * Display the grid status.
+ */
+void EDA_DRAW_FRAME::DisplayGridMsg()
+{
+    wxString line;
+    wxString gridformatter;
+
+    switch( m_UserUnits )
+    {
+    case INCHES:
+        gridformatter = "grid %.3f";
+        break;
+
+    case MILLIMETRES:
+        gridformatter = "grid %.4f";
+        break;
+
+    default:
+        gridformatter = "grid %f";
+        break;
+    }
+
+    wxRealPoint curr_grid_size = GetScreen()->GetGridSize();
+    double grid = To_User_Unit( m_UserUnits, curr_grid_size.x );
+    line.Printf( gridformatter, grid );
+
+    SetStatusText( line, 4 );
+}
+
+
 void EDA_DRAW_FRAME::DisplayUnitsMsg()
 {
     wxString msg;
@@ -625,7 +659,7 @@ void EDA_DRAW_FRAME::DisplayUnitsMsg()
     default:          msg = _( "Units" );  break;
     }
 
-    SetStatusText( msg, 4 );
+    SetStatusText( msg, 5 );
 }
 
 
diff --git a/common/legacy_wx/eda_draw_frame.cpp b/common/legacy_wx/eda_draw_frame.cpp
index 3871cfb26..e54861459 100644
--- a/common/legacy_wx/eda_draw_frame.cpp
+++ b/common/legacy_wx/eda_draw_frame.cpp
@@ -172,7 +172,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
 
     m_auimgr.SetFlags(wxAUI_MGR_DEFAULT);
 
-    CreateStatusBar( 6 );
+    CreateStatusBar( 7 );
 
     // set the size of the status bar subwindows:
 
@@ -195,6 +195,9 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent,
         // delta distances
         GetTextSize( wxT( "dx 0234.567890  dx 0234.567890  d 0234.567890" ), stsbar ).x + 10,
 
+        // grid size
+        GetTextSize( wxT( "grid X 0234.567890  Y 0234.567890" ), stsbar ).x + 10,
+
         // units display, Inches is bigger than mm
         GetTextSize( _( "Inches" ), stsbar ).x + 10,
 
@@ -622,6 +625,37 @@ void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
 }
 
 
+/*
+ * Display the grid status.
+ */
+void EDA_DRAW_FRAME::DisplayGridMsg()
+{
+    wxString line;
+    wxString gridformatter;
+
+    switch( m_UserUnits )
+    {
+    case INCHES:
+        gridformatter = "grid %.3f";
+        break;
+
+    case MILLIMETRES:
+        gridformatter = "grid %.4f";
+        break;
+
+    default:
+        gridformatter = "grid %f";
+        break;
+    }
+
+    wxRealPoint curr_grid_size = GetScreen()->GetGridSize();
+    double grid = To_User_Unit( m_UserUnits, curr_grid_size.x );
+    line.Printf( gridformatter, grid );
+
+    SetStatusText( line, 4 );
+}
+
+
 void EDA_DRAW_FRAME::DisplayUnitsMsg()
 {
     wxString msg;
@@ -641,7 +675,7 @@ void EDA_DRAW_FRAME::DisplayUnitsMsg()
         break;
     }
 
-    SetStatusText( msg, 4 );
+    SetStatusText( msg, 5 );
 }
 
 
diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp
index 741ccaa59..923d4046d 100644
--- a/eeschema/sch_base_frame.cpp
+++ b/eeschema/sch_base_frame.cpp
@@ -284,6 +284,9 @@ void SCH_BASE_FRAME::UpdateStatusBar()
     line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
     SetStatusText( line, 3 );
 
+    // refresh grid display
+    DisplayGridMsg();
+
     // refresh units display
     DisplayUnitsMsg();
 }
diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp
index 8973744cd..b1e9b322b 100644
--- a/gerbview/gerbview_frame.cpp
+++ b/gerbview/gerbview_frame.cpp
@@ -1043,6 +1043,42 @@ void GERBVIEW_FRAME::SetGridColor( COLOR4D aColor )
 }
 
 
+/*
+ * Display the grid status.
+ */
+void GERBVIEW_FRAME::DisplayGridMsg()
+{
+    wxString line;
+    wxString gridformatter;
+
+    switch( m_UserUnits )
+    {
+    case INCHES:
+        gridformatter = "grid X %.6f  Y %.6f";
+        break;
+
+    case MILLIMETRES:
+        gridformatter = "grid X %.6f  Y %.6f";
+        break;
+
+    default:
+        gridformatter = "grid X %f  Y %f";
+        break;
+    }
+
+    BASE_SCREEN* screen = GetScreen();
+    wxArrayString gridsList;
+
+    int icurr = screen->BuildGridsChoiceList( gridsList, m_UserUnits != INCHES );
+    GRID_TYPE& grid = screen->GetGrid( icurr );
+    double grid_x = To_User_Unit( m_UserUnits, grid.m_Size.x );
+    double grid_y = To_User_Unit( m_UserUnits, grid.m_Size.y );
+    line.Printf( gridformatter, grid_x, grid_y );
+
+    SetStatusText( line, 4 );
+}
+
+
 void GERBVIEW_FRAME::UpdateStatusBar()
 {
     EDA_DRAW_FRAME::UpdateStatusBar();
@@ -1127,6 +1163,8 @@ void GERBVIEW_FRAME::UpdateStatusBar()
         line.Printf( relformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
         SetStatusText( line, 3 );
     }
+
+    DisplayGridMsg();
 }
 
 
diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h
index 3c291ef29..ade271963 100644
--- a/gerbview/gerbview_frame.h
+++ b/gerbview/gerbview_frame.h
@@ -402,6 +402,13 @@ public:
      */
     void UpdateTitleAndInfo();
 
+    /**
+     * Function DisplayGridMsg()
+     *
+     * Display the current grid pane on the status bar.
+     */
+    void DisplayGridMsg();
+
     /**
      * Function GetConfigurationSettings
      * Populates the GerbView applications settings list.
diff --git a/include/draw_frame.h b/include/draw_frame.h
index 464378c11..c0fb70e1a 100644
--- a/include/draw_frame.h
+++ b/include/draw_frame.h
@@ -840,6 +840,11 @@ public:
      */
     void CopyToClipboard( wxCommandEvent& event );
 
+    /**
+     * Display current grid pane on the status bar.
+     */
+    void DisplayGridMsg();
+
     /* interprocess communication */
     void CreateServer( int service, bool local = true );
     void OnSockRequest( wxSocketEvent& evt );
diff --git a/include/pcb_base_frame.h b/include/pcb_base_frame.h
index 92a390a81..1c6072191 100644
--- a/include/pcb_base_frame.h
+++ b/include/pcb_base_frame.h
@@ -611,6 +611,13 @@ public:
      */
     void SetPrevGrid() override;
 
+    /**
+     * Function DisplayGridMsg()
+     *
+     * Display the current grid pane on the status bar.
+     */
+    void DisplayGridMsg();
+
     ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas
     virtual void UseGalCanvas( bool aEnable ) override;
 
diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp
index a98316469..7563c64b6 100644
--- a/pagelayout_editor/pl_editor_frame.cpp
+++ b/pagelayout_editor/pl_editor_frame.cpp
@@ -111,11 +111,14 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
         // delta distances
         GetTextSize( wxT( "dx 0234.567  dx 0234.567" ), stsbar ).x + 10,
 
+        // grid size
+        GetTextSize( wxT( "grid 0234.567" ), stsbar ).x + 10,
+
         // Coord origin (use the bigger message)
         GetTextSize( _( "coord origin: Right Bottom page corner" ), stsbar ).x + 10,
 
         // units display, Inches is bigger than mm
-        GetTextSize( _( "Inches" ), stsbar ).x + 10
+        GetTextSize( _( "Inches" ), stsbar ).x + 20
     };
 
     SetStatusWidths( arrayDim( dims ), dims );
@@ -314,6 +317,37 @@ void PL_EDITOR_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock )
 }
 
 
+/*
+ * Display the grid status.
+ */
+void PL_EDITOR_FRAME::DisplayGridMsg()
+{
+    wxString line;
+    wxString gridformatter;
+
+    switch( m_UserUnits )
+    {
+    case INCHES:
+        gridformatter = "grid %.3f";
+        break;
+
+    case MILLIMETRES:
+        gridformatter = "grid %.4f";
+        break;
+
+    default:
+        gridformatter = "grid %f";
+        break;
+    }
+
+    wxRealPoint curr_grid_size = GetScreen()->GetGridSize();
+    double grid = To_User_Unit( m_UserUnits, curr_grid_size.x );
+    line.Printf( gridformatter, grid );
+
+    SetStatusText( line, 4 );
+}
+
+
 void PL_EDITOR_FRAME::UpdateStatusBar()
 {
     PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) GetScreen();
@@ -378,15 +412,15 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
     switch( GetUserUnits() )
     {
     case INCHES:        // Should not be used in page layout editor
-        SetStatusText( _("inches"), 5 );
+        SetStatusText( _("inches"), 6 );
         break;
 
     case MILLIMETRES:
-        SetStatusText( _("mm"), 5 );
+        SetStatusText( _("mm"), 6 );
         break;
 
     case UNSCALED_UNITS:
-        SetStatusText( wxEmptyString, 5 );
+        SetStatusText( wxEmptyString, 6 );
         break;
 
     case DEGREES:
@@ -415,10 +449,12 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
     line.Printf( locformatter, dXpos, dYpos );
     SetStatusText( line, 3 );
 
+    DisplayGridMsg();
+
     // Display corner reference for coord origin
     line.Printf( _("coord origin: %s"),
                 m_originSelectBox->GetString( m_originSelectChoice ). GetData() );
-    SetStatusText( line, 4 );
+    SetStatusText( line, 5 );
 
     // Display units
 }
diff --git a/pagelayout_editor/pl_editor_frame.h b/pagelayout_editor/pl_editor_frame.h
index f8bdce8e9..6b2246b39 100644
--- a/pagelayout_editor/pl_editor_frame.h
+++ b/pagelayout_editor/pl_editor_frame.h
@@ -142,6 +142,8 @@ public:
     const TITLE_BLOCK& GetTitleBlock() const override;
     void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
 
+    void DisplayGridMsg();
+
     void UpdateStatusBar() override;
 
     /**
diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp
index dcf825c2a..69109c1a9 100644
--- a/pcbnew/pcb_base_frame.cpp
+++ b/pcbnew/pcb_base_frame.cpp
@@ -820,6 +820,42 @@ void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
 }
 
 
+/*
+ * Display the grid status.
+ */
+void PCB_BASE_FRAME::DisplayGridMsg()
+{
+    wxString line;
+    wxString gridformatter;
+
+    switch( m_UserUnits )
+    {
+    case INCHES:
+        gridformatter = "grid X %.6f  Y %.6f";
+        break;
+
+    case MILLIMETRES:
+        gridformatter = "grid X %.6f  Y %.6f";
+        break;
+
+    default:
+        gridformatter = "grid X %f  Y %f";
+        break;
+    }
+
+    BASE_SCREEN* screen = GetScreen();
+    wxArrayString gridsList;
+
+    int icurr = screen->BuildGridsChoiceList( gridsList, m_UserUnits != INCHES );
+    GRID_TYPE& grid = screen->GetGrid( icurr );
+    double grid_x = To_User_Unit( m_UserUnits, grid.m_Size.x );
+    double grid_y = To_User_Unit( m_UserUnits, grid.m_Size.y );
+    line.Printf( gridformatter, grid_x, grid_y );
+
+    SetStatusText( line, 4 );
+}
+
+
 /*
  * Update the status bar information.
  */
@@ -913,6 +949,8 @@ void PCB_BASE_FRAME::UpdateStatusBar()
         line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
         SetStatusText( line, 3 );
     }
+
+    DisplayGridMsg();
 }
 
 
-- 
2.21.0

>From 037262312d0215c2ac86b999cace4425853a2ff6 Mon Sep 17 00:00:00 2001
From: "Steven A. Falco" <stevenfalco@xxxxxxxxx>
Date: Fri, 24 May 2019 09:55:33 -0400
Subject: [PATCH] Show the current grid setting.

---
 common/legacy_gal/eda_draw_frame.cpp  | 38 ++++++++++++++++++++--
 eeschema/sch_base_frame.cpp           |  3 ++
 gerbview/gerbview_frame.cpp           | 38 ++++++++++++++++++++++
 gerbview/gerbview_frame.h             |  7 ++++
 include/draw_frame.h                  |  5 +++
 include/pcb_base_frame.h              |  7 ++++
 pagelayout_editor/pl_editor_frame.cpp | 46 ++++++++++++++++++++++++---
 pagelayout_editor/pl_editor_frame.h   |  2 ++
 pcbnew/pcb_base_frame.cpp             | 38 ++++++++++++++++++++++
 9 files changed, 177 insertions(+), 7 deletions(-)

diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp
index 6c3a3a47b..f24534980 100644
--- a/common/legacy_gal/eda_draw_frame.cpp
+++ b/common/legacy_gal/eda_draw_frame.cpp
@@ -124,7 +124,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
 
     m_auimgr.SetFlags(wxAUI_MGR_DEFAULT);
 
-    CreateStatusBar( 6 );
+    CreateStatusBar( 7 );
 
     // set the size of the status bar subwindows:
 
@@ -147,6 +147,9 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
         // delta distances
         GetTextSize( wxT( "dx 0234.567890  dx 0234.567890  d 0234.567890" ), stsbar ).x + 10,
 
+        // grid size
+        GetTextSize( wxT( "grid X 0234.567890  Y 0234.567890" ), stsbar ).x + 10,
+
         // units display, Inches is bigger than mm
         GetTextSize( _( "Inches" ), stsbar ).x + 10,
 
@@ -417,6 +420,37 @@ void EDA_DRAW_FRAME::DisplayToolMsg( const wxString& msg )
 }
 
 
+/*
+ * Display the grid status.
+ */
+void EDA_DRAW_FRAME::DisplayGridMsg()
+{
+    wxString line;
+    wxString gridformatter;
+
+    switch( m_UserUnits )
+    {
+    case INCHES:
+        gridformatter = "grid %.3f";
+        break;
+
+    case MILLIMETRES:
+        gridformatter = "grid %.4f";
+        break;
+
+    default:
+        gridformatter = "grid %f";
+        break;
+    }
+
+    wxRealPoint curr_grid_size = GetScreen()->GetGridSize();
+    double grid = To_User_Unit( m_UserUnits, curr_grid_size.x );
+    line.Printf( gridformatter, grid );
+
+    SetStatusText( line, 4 );
+}
+
+
 void EDA_DRAW_FRAME::DisplayUnitsMsg()
 {
     wxString msg;
@@ -428,7 +462,7 @@ void EDA_DRAW_FRAME::DisplayUnitsMsg()
     default:          msg = _( "Units" );  break;
     }
 
-    SetStatusText( msg, 4 );
+    SetStatusText( msg, 5 );
 }
 
 
diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp
index e013d1789..72573884d 100644
--- a/eeschema/sch_base_frame.cpp
+++ b/eeschema/sch_base_frame.cpp
@@ -253,6 +253,9 @@ void SCH_BASE_FRAME::UpdateStatusBar()
     line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
     SetStatusText( line, 3 );
 
+    // refresh grid display
+    DisplayGridMsg();
+
     // refresh units display
     DisplayUnitsMsg();
 }
diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp
index d2c7d22e7..005abe000 100644
--- a/gerbview/gerbview_frame.cpp
+++ b/gerbview/gerbview_frame.cpp
@@ -986,6 +986,42 @@ void GERBVIEW_FRAME::SetGridColor( COLOR4D aColor )
 }
 
 
+/*
+ * Display the grid status.
+ */
+void GERBVIEW_FRAME::DisplayGridMsg()
+{
+    wxString line;
+    wxString gridformatter;
+
+    switch( m_UserUnits )
+    {
+    case INCHES:
+        gridformatter = "grid X %.6f  Y %.6f";
+        break;
+
+    case MILLIMETRES:
+        gridformatter = "grid X %.6f  Y %.6f";
+        break;
+
+    default:
+        gridformatter = "grid X %f  Y %f";
+        break;
+    }
+
+    BASE_SCREEN* screen = GetScreen();
+    wxArrayString gridsList;
+
+    int icurr = screen->BuildGridsChoiceList( gridsList, m_UserUnits != INCHES );
+    GRID_TYPE& grid = screen->GetGrid( icurr );
+    double grid_x = To_User_Unit( m_UserUnits, grid.m_Size.x );
+    double grid_y = To_User_Unit( m_UserUnits, grid.m_Size.y );
+    line.Printf( gridformatter, grid_x, grid_y );
+
+    SetStatusText( line, 4 );
+}
+
+
 void GERBVIEW_FRAME::UpdateStatusBar()
 {
     EDA_DRAW_FRAME::UpdateStatusBar();
@@ -1070,6 +1106,8 @@ void GERBVIEW_FRAME::UpdateStatusBar()
         line.Printf( relformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
         SetStatusText( line, 3 );
     }
+
+    DisplayGridMsg();
 }
 
 
diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h
index 6ff849fb6..08714c7e0 100644
--- a/gerbview/gerbview_frame.h
+++ b/gerbview/gerbview_frame.h
@@ -391,6 +391,13 @@ public:
      */
     void UpdateTitleAndInfo();
 
+    /**
+     * Function DisplayGridMsg()
+     *
+     * Display the current grid pane on the status bar.
+     */
+    void DisplayGridMsg();
+
     /**
      * Function GetConfigurationSettings
      * Populates the GerbView applications settings list.
diff --git a/include/draw_frame.h b/include/draw_frame.h
index 431c0d1d6..63aa3ab0e 100644
--- a/include/draw_frame.h
+++ b/include/draw_frame.h
@@ -628,6 +628,11 @@ public:
      */
     void DisplayUnitsMsg();
 
+    /**
+     * Display current grid pane on the status bar.
+     */
+    void DisplayGridMsg();
+
     /* interprocess communication */
     void CreateServer( int service, bool local = true );
     void OnSockRequest( wxSocketEvent& evt );
diff --git a/include/pcb_base_frame.h b/include/pcb_base_frame.h
index 87c0c7e27..e1c21f7ad 100644
--- a/include/pcb_base_frame.h
+++ b/include/pcb_base_frame.h
@@ -434,6 +434,13 @@ public:
      */
     void SetFastGrid2();
 
+    /**
+     * Function DisplayGridMsg()
+     *
+     * Display the current grid pane on the status bar.
+     */
+    void DisplayGridMsg();
+
     ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas
     virtual void ActivateGalCanvas() override;
 
diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp
index 17a4abd9b..5d435a44d 100644
--- a/pagelayout_editor/pl_editor_frame.cpp
+++ b/pagelayout_editor/pl_editor_frame.cpp
@@ -147,11 +147,14 @@ PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
         // delta distances
         GetTextSize( wxT( "dx 0234.567  dx 0234.567" ), stsbar ).x + 10,
 
+        // grid size
+        GetTextSize( wxT( "grid 0234.567" ), stsbar ).x + 10,
+
         // Coord origin (use the bigger message)
         GetTextSize( _( "coord origin: Right Bottom page corner" ), stsbar ).x + 10,
 
         // units display, Inches is bigger than mm
-        GetTextSize( _( "Inches" ), stsbar ).x + 10
+        GetTextSize( _( "Inches" ), stsbar ).x + 20
     };
 
     SetStatusWidths( arrayDim( dims ), dims );
@@ -525,6 +528,37 @@ wxPoint PL_EDITOR_FRAME::ReturnCoordOriginCorner() const
 }
 
 
+/*
+ * Display the grid status.
+ */
+void PL_EDITOR_FRAME::DisplayGridMsg()
+{
+    wxString line;
+    wxString gridformatter;
+
+    switch( m_UserUnits )
+    {
+    case INCHES:
+        gridformatter = "grid %.3f";
+        break;
+
+    case MILLIMETRES:
+        gridformatter = "grid %.4f";
+        break;
+
+    default:
+        gridformatter = "grid %f";
+        break;
+    }
+
+    wxRealPoint curr_grid_size = GetScreen()->GetGridSize();
+    double grid = To_User_Unit( m_UserUnits, curr_grid_size.x );
+    line.Printf( gridformatter, grid );
+
+    SetStatusText( line, 4 );
+}
+
+
 void PL_EDITOR_FRAME::UpdateStatusBar()
 {
     PL_EDITOR_SCREEN* screen = (PL_EDITOR_SCREEN*) GetScreen();
@@ -577,9 +611,9 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
 
     switch( GetUserUnits() )
     {
-    case INCHES:         SetStatusText( _("inches"), 5 );   break;
-    case MILLIMETRES:    SetStatusText( _("mm"), 5 );       break;
-    case UNSCALED_UNITS: SetStatusText( wxEmptyString, 5 ); break;
+    case INCHES:         SetStatusText( _("inches"), 6 );   break;
+    case MILLIMETRES:    SetStatusText( _("mm"), 6 );       break;
+    case UNSCALED_UNITS: SetStatusText( wxEmptyString, 6 ); break;
     case DEGREES:        wxASSERT( false );                 break;
     }
 
@@ -604,10 +638,12 @@ void PL_EDITOR_FRAME::UpdateStatusBar()
     line.Printf( locformatter, dXpos, dYpos );
     SetStatusText( line, 3 );
 
+    DisplayGridMsg();
+
     // Display corner reference for coord origin
     line.Printf( _("coord origin: %s"),
                 m_originSelectBox->GetString( m_originSelectChoice ). GetData() );
-    SetStatusText( line, 4 );
+    SetStatusText( line, 5 );
 
     // Display units
 }
diff --git a/pagelayout_editor/pl_editor_frame.h b/pagelayout_editor/pl_editor_frame.h
index 19c65021f..56f6759ff 100644
--- a/pagelayout_editor/pl_editor_frame.h
+++ b/pagelayout_editor/pl_editor_frame.h
@@ -141,6 +141,8 @@ public:
     const TITLE_BLOCK& GetTitleBlock() const override;
     void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) override;
 
+    void DisplayGridMsg();
+
     void UpdateStatusBar() override;
 
     /**
diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp
index 9a54fb332..05543209a 100644
--- a/pcbnew/pcb_base_frame.cpp
+++ b/pcbnew/pcb_base_frame.cpp
@@ -596,6 +596,42 @@ void PCB_BASE_FRAME::SetToolID( int aId, int aCursor, const wxString& aToolMsg )
 }
 
 
+/*
+ * Display the grid status.
+ */
+void PCB_BASE_FRAME::DisplayGridMsg()
+{
+    wxString line;
+    wxString gridformatter;
+
+    switch( m_UserUnits )
+    {
+    case INCHES:
+        gridformatter = "grid X %.6f  Y %.6f";
+        break;
+
+    case MILLIMETRES:
+        gridformatter = "grid X %.6f  Y %.6f";
+        break;
+
+    default:
+        gridformatter = "grid X %f  Y %f";
+        break;
+    }
+
+    BASE_SCREEN* screen = GetScreen();
+    wxArrayString gridsList;
+
+    int icurr = screen->BuildGridsChoiceList( gridsList, m_UserUnits != INCHES );
+    GRID_TYPE& grid = screen->GetGrid( icurr );
+    double grid_x = To_User_Unit( m_UserUnits, grid.m_Size.x );
+    double grid_y = To_User_Unit( m_UserUnits, grid.m_Size.y );
+    line.Printf( gridformatter, grid_x, grid_y );
+
+    SetStatusText( line, 4 );
+}
+
+
 /*
  * Update the status bar information.
  */
@@ -688,6 +724,8 @@ void PCB_BASE_FRAME::UpdateStatusBar()
         line.Printf( locformatter, dXpos, dYpos, hypot( dXpos, dYpos ) );
         SetStatusText( line, 3 );
     }
+
+    DisplayGridMsg();
 }
 
 
-- 
2.21.0


Follow ups

References