← Back to team overview

kicad-developers team mailing list archive

Re: Show grid in eeschema status line

 

On 6/3/19 10:42 AM, Wayne Stambaugh wrote:
> Hi Steve,
> 
> Your patch no longer applies cleanly as there has been some serious
> refactoring and legacy code removal.  I think your patch is a good idea
> but it will need to be fixed.  I do have a few comments from your
> original patch:
> 
> * Please use `git commit` to commit your code to your local repo and
> `git format-patch` to create patches to send to the mailing list.

Thanks for the review, and for your patience as I "learn the ropes" Wayne.

I've attached a rebased patch using "git format-patch".  I generated it both for master and for 5.1, in case you want it in both branches.  Personally, I'd like it in both.

> * There tabs and indentation errors in your original patch.

I think I've fixed all of those.  If I missed any, please let me know.

> * I don't think you need to make the precision of millimeter grid units
> 4.  2 should be more than acceptable given that you are using 3 for
> inches units.  You may want to increase this by one for the board
> editor.  The board editor has far greater precision than the schematic
> editor.

I chose 4 decimal places because the eeschema grid seems to be in English units internally, even when I switch the UI to metric.  I.e., when I switch eeschema to metric, the finest grid in the pull-down menu is shown as "0.0254 mm (1.00 mils)".  I don't see a way to set the eeschema grid to a round number of mm.  I will be happy to change the display to 2 places if you still want that, but then the status line will show 0.02 mm rather than 0.0254 mm.  Please confirm which way you want it.

	Steve


From 9c652a1a9c7a60927d1f9d043b00d15d809848cc 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 | 28 ++++++++++++++++++++++++++++
 eeschema/sch_base_frame.cpp          |  3 +++
 include/draw_frame.h                 |  5 +++++
 kicad/mainframe.cpp                  |  6 +++---
 4 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp
index 6c3a3a47b..d02837ff6 100644
--- a/common/legacy_gal/eda_draw_frame.cpp
+++ b/common/legacy_gal/eda_draw_frame.cpp
@@ -546,6 +546,34 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
     m_galDisplayOptions.WriteConfig( *aCfg, baseCfgName );
 }
 
+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( GetUserUnits(), curr_grid_size.x );
+    line.Printf( gridformatter, grid );
+
+    SetStatusText( line, 5 );
+}
+
+
 
 void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper, const wxString& textLower,
                                      COLOR4D color, int pad )
diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp
index 28b664f77..5b2bd0dbc 100644
--- a/eeschema/sch_base_frame.cpp
+++ b/eeschema/sch_base_frame.cpp
@@ -259,6 +259,9 @@ void SCH_BASE_FRAME::UpdateStatusBar()
 
     // refresh units display
     DisplayUnitsMsg();
+
+    // refresh grid display
+    DisplayGridMsg();
 }
 
 
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/kicad/mainframe.cpp b/kicad/mainframe.cpp
index 0d1bdd3cd..95d352bde 100644
--- a/kicad/mainframe.cpp
+++ b/kicad/mainframe.cpp
@@ -67,10 +67,10 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent,
     m_AboutTitle = "KiCad";
 
     // Create the status line (bottom of the frame)
-    static const int dims[3] = { -1, -1, 100 };
+    static const int dims[4] = { -1, -1, -1, 100 };
 
-    CreateStatusBar( 3 );
-    SetStatusWidths( 3, dims );
+    CreateStatusBar( 4 );
+    SetStatusWidths( 4, dims );
 
     // Give an icon
     wxIcon icon;
-- 
2.21.0

From b9ce731455b69db76749e74c066257a4a1218ecf 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 | 28 ++++++++++++++++++++++++++++
 common/legacy_wx/eda_draw_frame.cpp  | 28 ++++++++++++++++++++++++++++
 eeschema/sch_base_frame.cpp          |  3 +++
 include/draw_frame.h                 |  5 +++++
 kicad/mainframe.cpp                  |  6 +++---
 5 files changed, 67 insertions(+), 3 deletions(-)

diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp
index 058df54f8..3bf70affe 100644
--- a/common/legacy_gal/eda_draw_frame.cpp
+++ b/common/legacy_gal/eda_draw_frame.cpp
@@ -857,6 +857,34 @@ void EDA_DRAW_FRAME::SaveSettings( wxConfigBase* aCfg )
     m_galDisplayOptions.WriteConfig( *aCfg, baseCfgName );
 }
 
+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( GetUserUnits(), curr_grid_size.x );
+    line.Printf( gridformatter, grid );
+
+    SetStatusText( line, 5 );
+}
+
+
 
 void EDA_DRAW_FRAME::AppendMsgPanel( const wxString& textUpper,
                                      const wxString& textLower,
diff --git a/common/legacy_wx/eda_draw_frame.cpp b/common/legacy_wx/eda_draw_frame.cpp
index 3871cfb26..3b3d991ac 100644
--- a/common/legacy_wx/eda_draw_frame.cpp
+++ b/common/legacy_wx/eda_draw_frame.cpp
@@ -645,6 +645,34 @@ void EDA_DRAW_FRAME::DisplayUnitsMsg()
 }
 
 
+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( GetUserUnits(), curr_grid_size.x );
+    line.Printf( gridformatter, grid );
+
+    SetStatusText( line, 5 );
+}
+
+
 void EDA_DRAW_FRAME::OnSize( wxSizeEvent& SizeEv )
 {
     m_FrameSize = GetClientSize( );
diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp
index 741ccaa59..14cae0eb7 100644
--- a/eeschema/sch_base_frame.cpp
+++ b/eeschema/sch_base_frame.cpp
@@ -286,6 +286,9 @@ void SCH_BASE_FRAME::UpdateStatusBar()
 
     // refresh units display
     DisplayUnitsMsg();
+
+    // refresh grid display
+    DisplayGridMsg();
 }
 
 
diff --git a/include/draw_frame.h b/include/draw_frame.h
index 464378c11..c39071e5e 100644
--- a/include/draw_frame.h
+++ b/include/draw_frame.h
@@ -835,6 +835,11 @@ public:
      */
     virtual bool HandleBlockEnd( wxDC* DC );
 
+    /**
+     * Display current grid pane on the status bar.
+     */
+    void DisplayGridMsg();
+
     /**
      * Copy the current page or the current block to the clipboard.
      */
diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp
index 65868028a..560d4c7ae 100644
--- a/kicad/mainframe.cpp
+++ b/kicad/mainframe.cpp
@@ -65,10 +65,10 @@ KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent,
     m_AboutTitle = "KiCad";
 
     // Create the status line (bottom of the frame)
-    static const int dims[3] = { -1, -1, 100 };
+    static const int dims[4] = { -1, -1, -1, 100 };
 
-    CreateStatusBar( 3 );
-    SetStatusWidths( 3, dims );
+    CreateStatusBar( 4 );
+    SetStatusWidths( 4, dims );
 
     // Give an icon
     wxIcon icon;
-- 
2.21.0


Follow ups

References