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.
This commit is contained in:
John Beard 2017-02-13 19:53:58 +08:00 committed by Maciej Suminski
parent ddded86a06
commit 7ad30b7167
14 changed files with 171 additions and 154 deletions

View File

@ -458,6 +458,3 @@ void EDA_DRAW_PANEL_GAL::onShowTimer( wxTimerEvent& aEvent )
OnShow();
}
}
const wxChar EDA_DRAW_PANEL_GAL::GRID_STYLE_CFG[] = wxT( "GridStyle" );

View File

@ -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<long*>( &gl_antialiasing_mode ),
static_cast<long>( KIGFX::OPENGL_ANTIALIASING_MODE::NONE ) );
aCfg->Read( aBaseName + GalGridStyleConfig,
reinterpret_cast<long*>( &m_gridStyle ),
static_cast<long>( 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<long>( gl_antialiasing_mode ) );
aCfg->Write( aBaseName + GalGridStyleConfig,
static_cast<long>( m_gridStyle ) );
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> 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;
}

View File

@ -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

View File

@ -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;
};
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2012 Torsten Hueter, torstenhtr <at> 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.
*

View File

@ -44,6 +44,19 @@
#include <gal/gal_display_options.h>
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<KIGFX::PCB_RENDER_SETTINGS*>( painter->GetSettings() );
settings->LoadDisplayOptions( displ_opts );
view->RecacheAllItems();
view->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
m_Parent->GetCanvas()->Refresh();

View File

@ -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 );

View File

@ -113,7 +113,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxALL</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
@ -304,8 +304,8 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">OpenGL Rendering:</property>
@ -405,6 +405,111 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Grid Display (OpenGL &amp;&amp; Cairo)</property>
<property name="minimum_size"></property>
<property name="name">sGridSettings</property>
<property name="orient">wxVERTICAL</property>
<property name="parent">1</property>
<property name="permission">none</property>
<event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxRadioBox" expanded="1">
<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="choices">&quot;Dots&quot; &quot;Lines&quot;</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">1</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">Grid Style</property>
<property name="majorDimension">1</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_gridStyle</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="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
<property name="subclass"></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="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"></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="OnRadioBox"></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>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">

View File

@ -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;

View File

@ -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 ) );

View File

@ -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 );

View File

@ -1394,6 +1394,8 @@
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCombobox"></event>
<event name="OnComboboxCloseup"></event>
<event name="OnComboboxDropdown"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
@ -1568,6 +1570,8 @@
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnCombobox"></event>
<event name="OnComboboxCloseup"></event>
<event name="OnComboboxDropdown"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
@ -1600,96 +1604,6 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxRadioBox" 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="choices">&quot;Dots&quot; &quot;Lines&quot;</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">1</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">Style (OpenGL &amp;&amp; Cairo)</property>
<property name="majorDimension">1</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_Style</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="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
<property name="subclass"></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="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"></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="OnRadioBox"></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>
</object>
<object class="sizeritem" expanded="1">

View File

@ -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;