From 7ad30b716715f6c10ebcbd4d2668c0806906c178 Mon Sep 17 00:00:00 2001 From: John Beard Date: Mon, 13 Feb 2017 19:53:58 +0800 Subject: [PATCH] Move Grid style to Graphics Options dialog This puts the graphical/display options with the other similar options in that dialog, rather than with the dimension options found in the Set Grid dialog, which is in the Dimensions menu. Also place the option itself in the GAL Display Options structure, so it can be updated using the observer mechanism there. The setter for the style in the GAL interface is removed, as the public interface for setting this option is now to modify the GAL_DISPLAY_OPTIONS structure and notify the GAL when done. --- common/draw_panel_gal.cpp | 3 - common/gal/gal_display_options.cpp | 11 +- common/gal/graphics_abstraction_layer.cpp | 10 +- include/class_draw_panel_gal.h | 3 - include/gal/gal_display_options.h | 5 +- include/gal/graphics_abstraction_layer.h | 20 +--- pcbnew/dialogs/dialog_display_options.cpp | 17 +++ .../dialogs/dialog_display_options_base.cpp | 18 ++- .../dialogs/dialog_display_options_base.fbp | 111 +++++++++++++++++- pcbnew/dialogs/dialog_display_options_base.h | 3 +- pcbnew/dialogs/dialog_set_grid.cpp | 19 --- pcbnew/dialogs/dialog_set_grid_base.cpp | 8 +- pcbnew/dialogs/dialog_set_grid_base.fbp | 94 +-------------- pcbnew/dialogs/dialog_set_grid_base.h | 3 +- 14 files changed, 171 insertions(+), 154 deletions(-) diff --git a/common/draw_panel_gal.cpp b/common/draw_panel_gal.cpp index 6b9ca44c79..26642eda8e 100644 --- a/common/draw_panel_gal.cpp +++ b/common/draw_panel_gal.cpp @@ -458,6 +458,3 @@ void EDA_DRAW_PANEL_GAL::onShowTimer( wxTimerEvent& aEvent ) OnShow(); } } - - -const wxChar EDA_DRAW_PANEL_GAL::GRID_STYLE_CFG[] = wxT( "GridStyle" ); diff --git a/common/gal/gal_display_options.cpp b/common/gal/gal_display_options.cpp index eeb4ec8216..0b94ae819c 100644 --- a/common/gal/gal_display_options.cpp +++ b/common/gal/gal_display_options.cpp @@ -30,10 +30,12 @@ using namespace KIGFX; * Config option strings */ static const wxString GalGLAntialiasingKeyword( "OpenGLAntialiasingMode" ); +static const wxString GalGridStyleConfig( "GridStyle" ); GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS() - : gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ) + : gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ), + m_gridStyle( GRID_STYLE_DOTS ) {} @@ -43,6 +45,10 @@ void GAL_DISPLAY_OPTIONS::ReadConfig( wxConfigBase* aCfg, wxString aBaseName ) reinterpret_cast( &gl_antialiasing_mode ), static_cast( KIGFX::OPENGL_ANTIALIASING_MODE::NONE ) ); + aCfg->Read( aBaseName + GalGridStyleConfig, + reinterpret_cast( &m_gridStyle ), + static_cast( KIGFX::GRID_STYLE::GRID_STYLE_DOTS ) ); + NotifyChanged(); } @@ -51,6 +57,9 @@ void GAL_DISPLAY_OPTIONS::WriteConfig( wxConfigBase* aCfg, wxString aBaseName ) { aCfg->Write( aBaseName + GalGLAntialiasingKeyword, static_cast( gl_antialiasing_mode ) ); + + aCfg->Write( aBaseName + GalGridStyleConfig, + static_cast( m_gridStyle ) ); } diff --git a/common/gal/graphics_abstraction_layer.cpp b/common/gal/graphics_abstraction_layer.cpp index 68de958532..9f33d68ef6 100644 --- a/common/gal/graphics_abstraction_layer.cpp +++ b/common/gal/graphics_abstraction_layer.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2012 Torsten Hueter, torstenhtr gmx.de - * Copyright (C) 2012 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 2012-2017 Kicad Developers, see change_log.txt for contributors. * * Graphics Abstraction Layer (GAL) - base class * @@ -58,10 +58,10 @@ GAL::GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions ) : // Set grid defaults SetGridVisibility( true ); - SetGridStyle( GRID_STYLE_LINES ); SetGridDrawThreshold( 10 ); SetCoarseGrid( 10 ); SetGridLineWidth( 0.5 ); + gridStyle = GRID_STYLE_LINES; // Initialize the cursor shape SetCursorColor( COLOR4D( 1.0, 1.0, 1.0, 1.0 ) ); @@ -92,6 +92,12 @@ bool GAL::updatedGalDisplayOptions( const GAL_DISPLAY_OPTIONS& aOptions ) { bool refresh = false; + if( options.m_gridStyle != gridStyle ) + { + gridStyle = options.m_gridStyle ; + refresh = true; + } + // tell the derived class if the base class needs an update or not return refresh; } diff --git a/include/class_draw_panel_gal.h b/include/class_draw_panel_gal.h index 9a682c6292..3ccd28c8de 100644 --- a/include/class_draw_panel_gal.h +++ b/include/class_draw_panel_gal.h @@ -240,9 +240,6 @@ protected: /// Flag to indicate that focus should be regained on the next mouse event. It is a workaround /// for cases when the panel loses keyboard focus, so it does not react to hotkeys anymore. bool m_lostFocus; - - /// Grid style setting string - static const wxChar GRID_STYLE_CFG[]; }; #endif diff --git a/include/gal/gal_display_options.h b/include/gal/gal_display_options.h index 98c53741f9..9c2c94c2d1 100644 --- a/include/gal/gal_display_options.h +++ b/include/gal/gal_display_options.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KICAD, a free EDA CAD application. * -* Copyright (C) 2016 Kicad Developers, see change_log.txt for contributors. +* Copyright (C) 2017 Kicad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -68,6 +68,9 @@ namespace KIGFX void NotifyChanged(); OPENGL_ANTIALIASING_MODE gl_antialiasing_mode; + + ///> The grid style to draw the grid in + KIGFX::GRID_STYLE m_gridStyle; }; } diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index c37c8671df..654fc413d5 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -2,7 +2,7 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2012 Torsten Hueter, torstenhtr gmx.de - * Copyright (C) 2016 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 2016-2017 Kicad Developers, see change_log.txt for contributors. * * Graphics Abstraction Layer (GAL) - base class * @@ -851,24 +851,6 @@ public: */ VECTOR2D GetGridPoint( const VECTOR2D& aPoint ) const; - /** - * @brief Change the grid display style. - * - * @param aGridStyle is the new style for grid. - */ - virtual void SetGridStyle( GRID_STYLE aGridStyle ) - { - gridStyle = aGridStyle; - } - - /** - * @brief Returns the current grid drawing style. - */ - virtual GRID_STYLE GetGridStyle() const - { - return gridStyle; - } - /** * @brief Compute the point position in world coordinates from given screen coordinates. * diff --git a/pcbnew/dialogs/dialog_display_options.cpp b/pcbnew/dialogs/dialog_display_options.cpp index e65332f88e..6df858cb44 100644 --- a/pcbnew/dialogs/dialog_display_options.cpp +++ b/pcbnew/dialogs/dialog_display_options.cpp @@ -44,6 +44,19 @@ #include +static void setRadioFromGridStyle( wxRadioBox& aRBox, + KIGFX::GRID_STYLE aStyle ) +{ + aRBox.SetSelection( aStyle != KIGFX::GRID_STYLE_DOTS ); +} + + +static KIGFX::GRID_STYLE getGridStyleFromRadio( const wxRadioBox& aRBox ) +{ + return aRBox.GetSelection() == 0 ? KIGFX::GRID_STYLE_DOTS : KIGFX::GRID_STYLE_LINES; +} + + void PCB_EDIT_FRAME::InstallDisplayOptionsDialog( wxCommandEvent& aEvent ) { DIALOG_DISPLAY_OPTIONS dlg( this ); @@ -131,6 +144,7 @@ void DIALOG_DISPLAY_OPTIONS::init() break; } + setRadioFromGridStyle( *m_gridStyle, gal_opts.m_gridStyle ); } @@ -213,6 +227,8 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event) break; } + gal_opts.m_gridStyle = getGridStyleFromRadio( *m_gridStyle ); + gal_opts.NotifyChanged(); // Apply changes to the GAL @@ -222,6 +238,7 @@ void DIALOG_DISPLAY_OPTIONS::OnOkClick(wxCommandEvent& event) static_cast( painter->GetSettings() ); settings->LoadDisplayOptions( displ_opts ); view->RecacheAllItems(); + view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); m_Parent->GetCanvas()->Refresh(); diff --git a/pcbnew/dialogs/dialog_display_options_base.cpp b/pcbnew/dialogs/dialog_display_options_base.cpp index a2424a079a..22f6fb07c3 100644 --- a/pcbnew/dialogs/dialog_display_options_base.cpp +++ b/pcbnew/dialogs/dialog_display_options_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 15 2016) +// C++ code generated with wxFormBuilder (version Jan 9 2017) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -32,7 +32,7 @@ DIALOG_DISPLAY_OPTIONS_BASE::DIALOG_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWi sSketchModeSizer->Add( m_OptDisplayVias, 0, wxALL, 5 ); - sLeftSizer->Add( sSketchModeSizer, 0, wxEXPAND|wxALL, 5 ); + sLeftSizer->Add( sSketchModeSizer, 0, wxALL|wxEXPAND, 5 ); wxStaticBoxSizer* sOpenGLRenderingSizer; sOpenGLRenderingSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("OpenGL Rendering:") ), wxVERTICAL ); @@ -44,7 +44,19 @@ DIALOG_DISPLAY_OPTIONS_BASE::DIALOG_DISPLAY_OPTIONS_BASE( wxWindow* parent, wxWi sOpenGLRenderingSizer->Add( m_choiceAntialiasing, 0, wxALL|wxEXPAND, 5 ); - sLeftSizer->Add( sOpenGLRenderingSizer, 1, wxEXPAND, 5 ); + sLeftSizer->Add( sOpenGLRenderingSizer, 0, wxALL|wxEXPAND, 5 ); + + wxStaticBoxSizer* sGridSettings; + sGridSettings = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Grid Display (OpenGL && Cairo)") ), wxVERTICAL ); + + wxString m_gridStyleChoices[] = { _("Dots"), _("Lines") }; + int m_gridStyleNChoices = sizeof( m_gridStyleChoices ) / sizeof( wxString ); + m_gridStyle = new wxRadioBox( sGridSettings->GetStaticBox(), wxID_ANY, _("Grid Style"), wxDefaultPosition, wxDefaultSize, m_gridStyleNChoices, m_gridStyleChoices, 1, wxRA_SPECIFY_COLS ); + m_gridStyle->SetSelection( 0 ); + sGridSettings->Add( m_gridStyle, 0, wxALL|wxEXPAND, 5 ); + + + sLeftSizer->Add( sGridSettings, 1, wxALL|wxEXPAND, 5 ); bupperSizer->Add( sLeftSizer, 1, wxEXPAND, 5 ); diff --git a/pcbnew/dialogs/dialog_display_options_base.fbp b/pcbnew/dialogs/dialog_display_options_base.fbp index 2e8ce0377f..570c33ba1a 100644 --- a/pcbnew/dialogs/dialog_display_options_base.fbp +++ b/pcbnew/dialogs/dialog_display_options_base.fbp @@ -113,7 +113,7 @@ none 5 - wxEXPAND|wxALL + wxALL|wxEXPAND 0 wxID_ANY @@ -304,8 +304,8 @@ 5 - wxEXPAND - 1 + wxALL|wxEXPAND + 0 wxID_ANY OpenGL Rendering: @@ -405,6 +405,111 @@ + + 5 + wxALL|wxEXPAND + 1 + + wxID_ANY + Grid Display (OpenGL && Cairo) + + sGridSettings + wxVERTICAL + 1 + none + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Dots" "Lines" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Grid Style + 1 + + 0 + + + 0 + + 1 + m_gridStyle + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/dialog_display_options_base.h b/pcbnew/dialogs/dialog_display_options_base.h index 1ca067434c..d97fd8d480 100644 --- a/pcbnew/dialogs/dialog_display_options_base.h +++ b/pcbnew/dialogs/dialog_display_options_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 15 2016) +// C++ code generated with wxFormBuilder (version Jan 9 2017) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -46,6 +46,7 @@ class DIALOG_DISPLAY_OPTIONS_BASE : public DIALOG_SHIM wxCheckBox* m_OptDisplayTracks; wxCheckBox* m_OptDisplayVias; wxChoice* m_choiceAntialiasing; + wxRadioBox* m_gridStyle; wxRadioBox* m_ShowNetNamesOption; wxRadioBox* m_OptDisplayTracksClearance; wxCheckBox* m_OptDisplayModOutlines; diff --git a/pcbnew/dialogs/dialog_set_grid.cpp b/pcbnew/dialogs/dialog_set_grid.cpp index 21bc280fcb..b2e4c8acdf 100644 --- a/pcbnew/dialogs/dialog_set_grid.cpp +++ b/pcbnew/dialogs/dialog_set_grid.cpp @@ -83,9 +83,6 @@ private: void setGridForFastSwitching( const wxArrayString& aGrids, int aGrid1, int aGrid2 ); void getGridForFastSwitching( int& aGrid1, int& aGrid2 ); - - void setGridStyle( KIGFX::GRID_STYLE aStyle ); - KIGFX::GRID_STYLE getGridStyle() const; }; @@ -162,9 +159,6 @@ bool DIALOG_SET_GRID::TransferDataFromWindow() mgr->ProcessEvent( gridOriginUpdate ); } - m_parent->GetGalCanvas()->GetGAL()->SetGridStyle( getGridStyle() ); - m_parent->GetCanvas()->Refresh(); - return wxDialog::TransferDataFromWindow(); } @@ -175,7 +169,6 @@ bool DIALOG_SET_GRID::TransferDataToWindow() setGridSize( m_parent->m_UserGridSize ); setGridOrigin( m_parent->GetGridOrigin() ); setGridForFastSwitching( m_fast_grid_opts, m_parent->m_FastGrid1, m_parent->m_FastGrid2 ); - setGridStyle( m_parent->GetGalCanvas()->GetGAL()->GetGridStyle() ); return wxDialog::TransferDataToWindow(); } @@ -292,18 +285,6 @@ void DIALOG_SET_GRID::getGridForFastSwitching( int& aGrid1, int& aGrid2 ) } -void DIALOG_SET_GRID::setGridStyle( KIGFX::GRID_STYLE aStyle ) -{ - m_Style->SetSelection( aStyle != KIGFX::GRID_STYLE_DOTS ); -} - - -KIGFX::GRID_STYLE DIALOG_SET_GRID::getGridStyle() const -{ - return m_Style->GetSelection() == 0 ? KIGFX::GRID_STYLE_DOTS : KIGFX::GRID_STYLE_LINES; -} - - void DIALOG_SET_GRID::OnResetGridOrgClick( wxCommandEvent& event ) { setGridOrigin( wxPoint( 0, 0 ) ); diff --git a/pcbnew/dialogs/dialog_set_grid_base.cpp b/pcbnew/dialogs/dialog_set_grid_base.cpp index 46d3ead722..f09e80a12a 100644 --- a/pcbnew/dialogs/dialog_set_grid_base.cpp +++ b/pcbnew/dialogs/dialog_set_grid_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version May 21 2016) +// C++ code generated with wxFormBuilder (version Jan 9 2017) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -129,12 +129,6 @@ DIALOG_SET_GRID_BASE::DIALOG_SET_GRID_BASE( wxWindow* parent, wxWindowID id, con bUpperSizer->Add( bSizer4, 1, wxEXPAND, 5 ); - wxString m_StyleChoices[] = { _("Dots"), _("Lines") }; - int m_StyleNChoices = sizeof( m_StyleChoices ) / sizeof( wxString ); - m_Style = new wxRadioBox( this, wxID_ANY, _("Style (OpenGL && Cairo)"), wxDefaultPosition, wxDefaultSize, m_StyleNChoices, m_StyleChoices, 1, wxRA_SPECIFY_COLS ); - m_Style->SetSelection( 0 ); - bUpperSizer->Add( m_Style, 0, wxALL|wxEXPAND, 5 ); - bSizerMain->Add( bUpperSizer, 1, wxEXPAND, 5 ); diff --git a/pcbnew/dialogs/dialog_set_grid_base.fbp b/pcbnew/dialogs/dialog_set_grid_base.fbp index 22da60d03f..3c51918791 100644 --- a/pcbnew/dialogs/dialog_set_grid_base.fbp +++ b/pcbnew/dialogs/dialog_set_grid_base.fbp @@ -1394,6 +1394,8 @@ + + @@ -1568,6 +1570,8 @@ + + @@ -1600,96 +1604,6 @@ - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Dots" "Lines" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Style (OpenGL && Cairo) - 1 - - 0 - - - 0 - - 1 - m_Style - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pcbnew/dialogs/dialog_set_grid_base.h b/pcbnew/dialogs/dialog_set_grid_base.h index 5880b593ac..2e901ffd88 100644 --- a/pcbnew/dialogs/dialog_set_grid_base.h +++ b/pcbnew/dialogs/dialog_set_grid_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version May 21 2016) +// C++ code generated with wxFormBuilder (version Jan 9 2017) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -55,7 +55,6 @@ class DIALOG_SET_GRID_BASE : public DIALOG_SHIM wxComboBox* m_comboBoxGrid1; wxStaticText* m_staticTextGrid2; wxComboBox* m_comboBoxGrid2; - wxRadioBox* m_Style; wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; wxButton* m_sdbSizerCancel;