On 5/23/19 1:59 PM, Wayne Stambaugh wrote:
> Hey Steve,
>
> Adding "grid" to the coordinates in the status bar is not correct.
> These are the cursor coordinates not the grid coordinates. To add the
> current grid size to the status bar, you would need to add another pane
> to status bar and fetch the current grid setting from the current SCREEN
> object.
In the attached patch I tried to make the changes you suggested, Wayne. Please
let me know if it is ok, or if there are still problems.
I find the panes confusing, because mainframe.cpp allocates 3 panes via
"CreateStatusBar( 3 );", but I see higher numbers elsewhere in the code, such
as EDA_DRAW_FRAME::DisplayToolMsg which uses "SetStatusText( msg, 5 );". I
increased the count in mainframe.cpp to 4 to cover the my new grid pane, but I
don't know if I really needed to do that.
Steve
diff --git a/common/legacy_gal/eda_draw_frame.cpp b/common/legacy_gal/eda_draw_frame.cpp
index f7408d35b..ddafae691 100644
--- a/common/legacy_gal/eda_draw_frame.cpp
+++ b/common/legacy_gal/eda_draw_frame.cpp
@@ -638,6 +638,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/common/legacy_wx/eda_draw_frame.cpp b/common/legacy_wx/eda_draw_frame.cpp
index 35088a374..ccb28cd30 100644
--- a/common/legacy_wx/eda_draw_frame.cpp
+++ b/common/legacy_wx/eda_draw_frame.cpp
@@ -582,6 +582,61 @@ 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( msg, 5 );
+}
+
+
+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 14910f86e..3eddf8007 100644
--- a/eeschema/sch_base_frame.cpp
+++ b/eeschema/sch_base_frame.cpp
@@ -297,6 +297,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 fcf16d738..2f33d1673 100644
--- a/include/draw_frame.h
+++ b/include/draw_frame.h
@@ -793,6 +793,11 @@ public:
*/
void DisplayUnitsMsg();
+ /**
+ * Display current grid pane on the status bar.
+ */
+ void DisplayGridMsg();
+
/* Handlers for block commands */
virtual void InitBlockPasteInfos();
diff --git a/kicad/mainframe.cpp b/kicad/mainframe.cpp
index 5554cd791..5735344af 100644
--- a/kicad/mainframe.cpp
+++ b/kicad/mainframe.cpp
@@ -66,10 +66,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;
_______________________________________________
Mailing list: https://launchpad.net/~kicad-developers
Post to : [email protected]
Unsubscribe : https://launchpad.net/~kicad-developers
More help : https://help.launchpad.net/ListHelp