KiCad PCB EDA Suite
KIGFX::GAL_DISPLAY_OPTIONS Class Reference

#include <gal_display_options.h>

Inheritance diagram for KIGFX::GAL_DISPLAY_OPTIONS:
UTIL::OBSERVABLE< GAL_DISPLAY_OPTIONS_OBSERVER > UTIL::DETAIL::OBSERVABLE_BASE

Public Member Functions

 GAL_DISPLAY_OPTIONS ()
 
void ReadAppConfig (wxConfigBase &aCfg, const wxString &aBaseName)
 Read GAL config options from applicaton-level config. More...
 
void ReadCommonConfig (wxConfigBase &aCommonConfig, wxWindow *aWindow)
 Read GAL config options from the common config store. More...
 
void ReadConfig (wxConfigBase &aCommonConfig, wxConfigBase &aAppCondfig, const wxString &aBaseCfgName, wxWindow *aWindow)
 Read application and common configs. More...
 
void WriteConfig (wxConfigBase &aCfg, const wxString &aBaseName)
 
void NotifyChanged ()
 
void SubscribeUnmanaged (GAL_DISPLAY_OPTIONS_OBSERVER *aObserver)
 Function SubscribeUnmanaged adds a subscription without RAII link. More...
 
LINK Subscribe (GAL_DISPLAY_OPTIONS_OBSERVER *aObserver)
 Function Subscribe adds a subscription returning an RAII link. More...
 
void Unsubscribe (GAL_DISPLAY_OPTIONS_OBSERVER *aObserver)
 Function Unsubscribe cancels the subscription of a subscriber. More...
 
void Notify (void(GAL_DISPLAY_OPTIONS_OBSERVER ::*Ptr)(Args1...), Args2 &&... aArgs)
 Function Notify Notifies event to all subscribed observers. More...
 
void NotifyIgnore (void(GAL_DISPLAY_OPTIONS_OBSERVER ::*Ptr)(Args1...), GAL_DISPLAY_OPTIONS_OBSERVER *aIgnore, Args2 &&... aArgs)
 Function Notify Notifies event to all subscribed observers but one to be ignore. More...
 
size_t size () const
 

Public Attributes

OPENGL_ANTIALIASING_MODE gl_antialiasing_mode
 
CAIRO_ANTIALIASING_MODE cairo_antialiasing_mode
 
KIGFX::GRID_STYLE m_gridStyle
 

The grid style to draw the grid in

More...
 
double m_gridLineWidth
 

Thickness to render grid lines/dots

More...
 
double m_gridMinSpacing
 

Minimum pixel distance between displayed grid lines

More...
 
bool m_axesEnabled
 

Whether or not to draw the coordinate system axes

More...
 
bool m_fullscreenCursor
 

Fullscreen crosshair or small cross

More...
 
bool m_forceDisplayCursor
 

Force cursor display

More...
 
double m_scaleFactor
 

The pixel scale factor (>1 for hi-DPI scaled displays)

More...
 

Protected Member Functions

void on_observers_empty ()
 
void enter_iteration ()
 
void leave_iteration ()
 
void add_observer (void *observer)
 
void remove_observer (void *observer)
 

Protected Attributes

std::shared_ptr< IMPLimpl_
 

Detailed Description

Definition at line 74 of file gal_display_options.h.

Constructor & Destructor Documentation

◆ GAL_DISPLAY_OPTIONS()

GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS ( )

Definition at line 64 of file gal_display_options.cpp.

68  m_gridLineWidth( 1.0 ),
69  m_gridMinSpacing( 10.0 ),
70  m_axesEnabled( false ),
71  m_fullscreenCursor( false ),
72  m_forceDisplayCursor( false ),
74 {}
KIGFX::GRID_STYLE m_gridStyle
The grid style to draw the grid in
bool m_forceDisplayCursor
Force cursor display
double m_gridMinSpacing
Minimum pixel distance between displayed grid lines
static double GetDefaultScaleFactor()
Get the "default" scaling factor to use if not other config is available.
OPENGL_ANTIALIASING_MODE gl_antialiasing_mode
bool m_axesEnabled
Whether or not to draw the coordinate system axes
CAIRO_ANTIALIASING_MODE cairo_antialiasing_mode
Use dots for the grid.
double m_scaleFactor
The pixel scale factor (>1 for hi-DPI scaled displays)
double m_gridLineWidth
Thickness to render grid lines/dots
bool m_fullscreenCursor
Fullscreen crosshair or small cross

References KIGFX::DOTS.

Member Function Documentation

◆ add_observer()

void UTIL::DETAIL::OBSERVABLE_BASE::add_observer ( void *  observer)
protectedinherited

Definition at line 216 of file observable.cpp.

217  {
218  allocate_impl();
219  impl_->add_observer( observer );
220  }
std::shared_ptr< IMPL > impl_
Definition: observable.h:93

References UTIL::DETAIL::OBSERVABLE_BASE::allocate_impl(), and UTIL::DETAIL::OBSERVABLE_BASE::impl_.

◆ enter_iteration()

void UTIL::DETAIL::OBSERVABLE_BASE::enter_iteration ( )
protectedinherited

Definition at line 230 of file observable.cpp.

231  {
232  if( impl_ )
233  impl_->enter_iteration();
234  }
std::shared_ptr< IMPL > impl_
Definition: observable.h:93

References UTIL::DETAIL::OBSERVABLE_BASE::impl_.

Referenced by UTIL::OBSERVABLE< GAL_DISPLAY_OPTIONS_OBSERVER >::Notify(), and UTIL::OBSERVABLE< GAL_DISPLAY_OPTIONS_OBSERVER >::NotifyIgnore().

◆ leave_iteration()

void UTIL::DETAIL::OBSERVABLE_BASE::leave_iteration ( )
protectedinherited

Definition at line 237 of file observable.cpp.

238  {
239  if( impl_)
240  {
241  impl_->leave_iteration();
242 
243  if( !impl_->is_iterating() && !impl_->is_shared() && impl_.use_count() == 1 )
244  impl_.reset();
245  }
246  }
std::shared_ptr< IMPL > impl_
Definition: observable.h:93

References UTIL::DETAIL::OBSERVABLE_BASE::impl_.

Referenced by UTIL::OBSERVABLE< GAL_DISPLAY_OPTIONS_OBSERVER >::Notify(), and UTIL::OBSERVABLE< GAL_DISPLAY_OPTIONS_OBSERVER >::NotifyIgnore().

◆ Notify()

void UTIL::OBSERVABLE< GAL_DISPLAY_OPTIONS_OBSERVER >::Notify ( void(GAL_DISPLAY_OPTIONS_OBSERVER ::*)(Args1...)  Ptr,
Args2 &&...  aArgs 
)
inlineinherited

Function Notify Notifies event to all subscribed observers.

Parameters
Ptrpointer to method of the Observer-interface
aArgslist of arguments to each notification call, will be perfectly forwarded.

Definition at line 183 of file observable.h.

184  {
185  static_assert(sizeof...(Args1) == sizeof...(Args2), "argument counts don't match");
186 
187  if( impl_ )
188  {
189  enter_iteration();
190  try {
191  for( auto* void_ptr : impl_->observers_ )
192  {
193  if( void_ptr )
194  {
195  auto* typed_ptr = static_cast<ObserverInterface*>(void_ptr);
196  (typed_ptr->*Ptr)(std::forward<Args2>( aArgs )...);
197  }
198  }
199  }
200  catch(...)
201  {
202  leave_iteration();
203  throw;
204  }
205 
206  leave_iteration();
207  }
208  }
std::shared_ptr< IMPL > impl_
Definition: observable.h:93

◆ NotifyChanged()

void GAL_DISPLAY_OPTIONS::NotifyChanged ( )

Definition at line 149 of file gal_display_options.cpp.

150 {
151  wxLogTrace( traceGalDispOpts, "Change notification" );
152 
154 }
static const wxChar * traceGalDispOpts
Flag to enable GAL_DISPLAY_OPTIONS loggin.
void Notify(void(GAL_DISPLAY_OPTIONS_OBSERVER ::*Ptr)(Args1...), Args2 &&... aArgs)
Function Notify Notifies event to all subscribed observers.
Definition: observable.h:183
virtual void OnGalDisplayOptionsChanged(const GAL_DISPLAY_OPTIONS &)=0

References UTIL::OBSERVABLE< GAL_DISPLAY_OPTIONS_OBSERVER >::Notify(), KIGFX::GAL_DISPLAY_OPTIONS_OBSERVER::OnGalDisplayOptionsChanged(), and traceGalDispOpts.

Referenced by ReadAppConfig(), ReadCommonConfig(), EDA_DRAW_PANEL_GAL::SwitchBackend(), COMMON_TOOLS::ToggleCursorStyle(), and GAL_OPTIONS_PANEL::TransferDataFromWindow().

◆ NotifyIgnore()

void UTIL::OBSERVABLE< GAL_DISPLAY_OPTIONS_OBSERVER >::NotifyIgnore ( void(GAL_DISPLAY_OPTIONS_OBSERVER ::*)(Args1...)  Ptr,
GAL_DISPLAY_OPTIONS_OBSERVER *  aIgnore,
Args2 &&...  aArgs 
)
inlineinherited

Function Notify Notifies event to all subscribed observers but one to be ignore.

Parameters
Ptrpointer to method of the Observer-interface
aIgnoreobserver to ignore during this notification
aArgslist of arguments to each notification call, will be perfectly forwarded.

Definition at line 218 of file observable.h.

220  {
221  static_assert(sizeof...(Args1) == sizeof...(Args2), "argument counts don't match");
222 
223  if( impl_ )
224  {
225  enter_iteration();
226 
227  try
228  {
229  for(auto* void_ptr : impl_->observers_)
230  {
231  if( void_ptr && void_ptr != aIgnore )
232  {
233  auto* typed_ptr = static_cast<ObserverInterface*>(void_ptr);
234  (typed_ptr->*Ptr)(std::forward<Args2>( aArgs )...);
235  }
236  }
237  }
238  catch(...)
239  {
240  leave_iteration();
241  throw;
242  }
243 
244  leave_iteration();
245  }
246  }
std::shared_ptr< IMPL > impl_
Definition: observable.h:93

◆ on_observers_empty()

void UTIL::DETAIL::OBSERVABLE_BASE::on_observers_empty ( )
protectedinherited

Definition at line 258 of file observable.cpp.

259  {
260  // called by an impl that is owned by this, ie. it is a non-shared impl
261  // also it is not iterating
262  deallocate_impl();
263  }

References UTIL::DETAIL::OBSERVABLE_BASE::deallocate_impl().

◆ ReadAppConfig()

void GAL_DISPLAY_OPTIONS::ReadAppConfig ( wxConfigBase &  aCfg,
const wxString &  aBaseName 
)

Read GAL config options from applicaton-level config.

Parameters
aCfgthe application config base
aBaseNamethe application's GAL options key prefix

Definition at line 77 of file gal_display_options.cpp.

78 {
79  const wxString baseName = aBaseName + GAL_DISPLAY_OPTIONS_KEY;
80 
81  wxLogTrace( traceGalDispOpts, "Reading options with base name '%s'", baseName );
82 
83  long readLong; // Temp value buffer
84 
85  aCfg.Read( baseName + GalGridStyleConfig, &readLong,
86  static_cast<long>( KIGFX::GRID_STYLE::DOTS ) );
88 
89  aCfg.Read( baseName + GalGridLineWidthConfig, &m_gridLineWidth, 1.0 );
90  aCfg.Read( baseName + GalGridMaxDensityConfig, &m_gridMinSpacing, 10 );
91  aCfg.Read( baseName + GalGridAxesEnabledConfig, &m_axesEnabled, false );
92  aCfg.Read( baseName + GalFullscreenCursorConfig, &m_fullscreenCursor, false );
93  aCfg.Read( baseName + GalForceDisplayCursorConfig, &m_forceDisplayCursor, true );
94 
95  NotifyChanged();
96 }
static const wxString GalGridAxesEnabledConfig("GridAxesEnabled")
static const wxString GalGridLineWidthConfig("GridLineWidth")
static const wxString GalGridStyleConfig("GridStyle")
static const wxString GalForceDisplayCursorConfig("ForceDisplayCursor")
KIGFX::GRID_STYLE m_gridStyle
The grid style to draw the grid in
static const UTIL::CFG_MAP< KIGFX::GRID_STYLE > gridStyleConfigVals
static const wxChar * traceGalDispOpts
Flag to enable GAL_DISPLAY_OPTIONS loggin.
bool m_forceDisplayCursor
Force cursor display
double m_gridMinSpacing
Minimum pixel distance between displayed grid lines
bool m_axesEnabled
Whether or not to draw the coordinate system axes
#define GAL_DISPLAY_OPTIONS_KEY
Definition: pgm_base.h:54
static const wxString GalGridMaxDensityConfig("GridMaxDensity")
static CFG_NATIVE_VAL< MAP > GetValFromConfig(const MAP &aMap, long aConf)
Get the native value corresponding to the config value (read from file or UI, probably) and find it i...
Definition: config_map.h:96
Use dots for the grid.
static const wxString GalFullscreenCursorConfig("CursorFullscreen")
double m_gridLineWidth
Thickness to render grid lines/dots
bool m_fullscreenCursor
Fullscreen crosshair or small cross

References KIGFX::DOTS, GAL_DISPLAY_OPTIONS_KEY, GalForceDisplayCursorConfig(), GalFullscreenCursorConfig(), GalGridAxesEnabledConfig(), GalGridLineWidthConfig(), GalGridMaxDensityConfig(), GalGridStyleConfig(), UTIL::GetValFromConfig(), gridStyleConfigVals, m_axesEnabled, m_forceDisplayCursor, m_fullscreenCursor, m_gridLineWidth, m_gridMinSpacing, m_gridStyle, NotifyChanged(), and traceGalDispOpts.

Referenced by LIB_VIEW_FRAME::LoadSettings(), FOOTPRINT_VIEWER_FRAME::LoadSettings(), and ReadConfig().

◆ ReadCommonConfig()

void GAL_DISPLAY_OPTIONS::ReadCommonConfig ( wxConfigBase &  aCommonConfig,
wxWindow *  aWindow 
)

Read GAL config options from the common config store.

Parameters
aCommonConfigthe common config store
aWindowthe wx parent window (used for DPI scaling)

Definition at line 99 of file gal_display_options.cpp.

100 {
101  wxLogTrace( traceGalDispOpts, "Reading common config" );
102 
103  int temp;
104  aCommonConfig.Read(
107 
108  aCommonConfig.Read(
111 
112  {
113  const DPI_SCALING dpi{ &aCommonConfig, aWindow };
114  m_scaleFactor = dpi.GetScaleFactor();
115  }
116 
117  NotifyChanged();
118 }
static const wxChar * traceGalDispOpts
Flag to enable GAL_DISPLAY_OPTIONS loggin.
OPENGL_ANTIALIASING_MODE gl_antialiasing_mode
Class to handle configuration and automatic determination of the DPI scale to use for canvases.
Definition: dpi_scaling.h:35
CAIRO_ANTIALIASING_MODE cairo_antialiasing_mode
#define GAL_ANTIALIASING_MODE_KEY
Definition: pgm_base.h:55
double m_scaleFactor
The pixel scale factor (>1 for hi-DPI scaled displays)
#define CAIRO_ANTIALIASING_MODE_KEY
Definition: pgm_base.h:56

References cairo_antialiasing_mode, CAIRO_ANTIALIASING_MODE_KEY, GAL_ANTIALIASING_MODE_KEY, gl_antialiasing_mode, m_scaleFactor, KIGFX::NONE, NotifyChanged(), and traceGalDispOpts.

Referenced by EDA_DRAW_FRAME::CommonSettingsChanged(), and ReadConfig().

◆ ReadConfig()

void GAL_DISPLAY_OPTIONS::ReadConfig ( wxConfigBase &  aCommonConfig,
wxConfigBase &  aAppCondfig,
const wxString &  aBaseCfgName,
wxWindow *  aWindow 
)

Read application and common configs.

Parameters
aCommonConfigthe common config store
aCfgthe application config base
aBaseNamethe application's GAL options key prefix
aWindowthe wx parent window (used for DPI scaling)

Definition at line 121 of file gal_display_options.cpp.

123 {
124  wxLogTrace( traceGalDispOpts, "Reading common and app config (%s)", aBaseCfgName );
125 
126  ReadAppConfig( aAppConfig, aBaseCfgName );
127 
128  ReadCommonConfig( aCommonConfig, aWindow );
129 }
void ReadCommonConfig(wxConfigBase &aCommonConfig, wxWindow *aWindow)
Read GAL config options from the common config store.
static const wxChar * traceGalDispOpts
Flag to enable GAL_DISPLAY_OPTIONS loggin.
void ReadAppConfig(wxConfigBase &aCfg, const wxString &aBaseName)
Read GAL config options from applicaton-level config.

References ReadAppConfig(), ReadCommonConfig(), and traceGalDispOpts.

Referenced by EDA_DRAW_FRAME::LoadSettings(), and SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET().

◆ remove_observer()

void UTIL::DETAIL::OBSERVABLE_BASE::remove_observer ( void *  observer)
protectedinherited

Definition at line 223 of file observable.cpp.

224  {
225  assert( impl_ );
226  impl_->remove_observer( observer );
227  }
std::shared_ptr< IMPL > impl_
Definition: observable.h:93

References UTIL::DETAIL::OBSERVABLE_BASE::impl_.

◆ size()

size_t UTIL::DETAIL::OBSERVABLE_BASE::size ( ) const
inherited

Definition at line 249 of file observable.cpp.

250  {
251  if( impl_ )
252  return impl_->observers_.size();
253  else
254  return 0;
255  }
std::shared_ptr< IMPL > impl_
Definition: observable.h:93

References UTIL::DETAIL::OBSERVABLE_BASE::impl_.

◆ Subscribe()

LINK UTIL::OBSERVABLE< GAL_DISPLAY_OPTIONS_OBSERVER >::Subscribe ( GAL_DISPLAY_OPTIONS_OBSERVER *  aObserver)
inlineinherited

Function Subscribe adds a subscription returning an RAII link.

Parameters
aObserverobserver to subscribe
Returns
RAII link controlling the lifetime of the subscription

Definition at line 161 of file observable.h.

161  {
162  OBSERVABLE_BASE::add_observer( static_cast<void*>(aObserver) );
163  return LINK( impl_, static_cast<void*>(aObserver) );
164  }
std::shared_ptr< IMPL > impl_
Definition: observable.h:93

◆ SubscribeUnmanaged()

void UTIL::OBSERVABLE< GAL_DISPLAY_OPTIONS_OBSERVER >::SubscribeUnmanaged ( GAL_DISPLAY_OPTIONS_OBSERVER *  aObserver)
inlineinherited

Function SubscribeUnmanaged adds a subscription without RAII link.

Parameters
aObserverObserver to subscribe

Definition at line 150 of file observable.h.

151  {
152  OBSERVABLE_BASE::add_observer( static_cast<void*>(aObserver) );
153  }

◆ Unsubscribe()

void UTIL::OBSERVABLE< GAL_DISPLAY_OPTIONS_OBSERVER >::Unsubscribe ( GAL_DISPLAY_OPTIONS_OBSERVER *  aObserver)
inlineinherited

Function Unsubscribe cancels the subscription of a subscriber.

Can be called during notification calls.

Parameters
aObserverobserver to remove from the subscription list

Definition at line 171 of file observable.h.

172  {
173  OBSERVABLE_BASE::remove_observer( static_cast<void*>(aObserver) );
174  }

◆ WriteConfig()

void GAL_DISPLAY_OPTIONS::WriteConfig ( wxConfigBase &  aCfg,
const wxString &  aBaseName 
)

Definition at line 132 of file gal_display_options.cpp.

133 {
134  const wxString baseName = aBaseName + GAL_DISPLAY_OPTIONS_KEY;
135 
136  wxLogTrace( traceGalDispOpts, "Writing app config (%s)", baseName );
137 
138  aCfg.Write( baseName + GalGridStyleConfig,
140 
141  aCfg.Write( baseName + GalGridLineWidthConfig, m_gridLineWidth );
142  aCfg.Write( baseName + GalGridMaxDensityConfig, m_gridMinSpacing );
143  aCfg.Write( baseName + GalGridAxesEnabledConfig, m_axesEnabled );
144  aCfg.Write( baseName + GalFullscreenCursorConfig, m_fullscreenCursor );
145  aCfg.Write( baseName + GalForceDisplayCursorConfig, m_forceDisplayCursor );
146 }
static const wxString GalGridAxesEnabledConfig("GridAxesEnabled")
static const wxString GalGridLineWidthConfig("GridLineWidth")
static const wxString GalGridStyleConfig("GridStyle")
static const wxString GalForceDisplayCursorConfig("ForceDisplayCursor")
KIGFX::GRID_STYLE m_gridStyle
The grid style to draw the grid in
static const UTIL::CFG_MAP< KIGFX::GRID_STYLE > gridStyleConfigVals
static const wxChar * traceGalDispOpts
Flag to enable GAL_DISPLAY_OPTIONS loggin.
bool m_forceDisplayCursor
Force cursor display
double m_gridMinSpacing
Minimum pixel distance between displayed grid lines
bool m_axesEnabled
Whether or not to draw the coordinate system axes
#define GAL_DISPLAY_OPTIONS_KEY
Definition: pgm_base.h:54
static const wxString GalGridMaxDensityConfig("GridMaxDensity")
static const wxString GalFullscreenCursorConfig("CursorFullscreen")
double m_gridLineWidth
Thickness to render grid lines/dots
bool m_fullscreenCursor
Fullscreen crosshair or small cross
static long GetConfigForVal(const MAP &aMap, CFG_NATIVE_VAL< MAP > aVal)
Get the mapped config value (the one to write to file, or use in an index) from the given native (pro...
Definition: config_map.h:69

References GAL_DISPLAY_OPTIONS_KEY, GalForceDisplayCursorConfig(), GalFullscreenCursorConfig(), GalGridAxesEnabledConfig(), GalGridLineWidthConfig(), GalGridMaxDensityConfig(), GalGridStyleConfig(), UTIL::GetConfigForVal(), gridStyleConfigVals, m_axesEnabled, m_forceDisplayCursor, m_fullscreenCursor, m_gridLineWidth, m_gridMinSpacing, m_gridStyle, and traceGalDispOpts.

Referenced by EDA_DRAW_FRAME::SaveSettings().

Member Data Documentation

◆ cairo_antialiasing_mode

CAIRO_ANTIALIASING_MODE KIGFX::GAL_DISPLAY_OPTIONS::cairo_antialiasing_mode

◆ gl_antialiasing_mode

OPENGL_ANTIALIASING_MODE KIGFX::GAL_DISPLAY_OPTIONS::gl_antialiasing_mode

◆ impl_

◆ m_axesEnabled

bool KIGFX::GAL_DISPLAY_OPTIONS::m_axesEnabled

Whether or not to draw the coordinate system axes

Definition at line 121 of file gal_display_options.h.

Referenced by FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), ReadAppConfig(), KIGFX::GAL::updatedGalDisplayOptions(), and WriteConfig().

◆ m_forceDisplayCursor

bool KIGFX::GAL_DISPLAY_OPTIONS::m_forceDisplayCursor

◆ m_fullscreenCursor

◆ m_gridLineWidth

double KIGFX::GAL_DISPLAY_OPTIONS::m_gridLineWidth

◆ m_gridMinSpacing

double KIGFX::GAL_DISPLAY_OPTIONS::m_gridMinSpacing

◆ m_gridStyle

KIGFX::GRID_STYLE KIGFX::GAL_DISPLAY_OPTIONS::m_gridStyle

◆ m_scaleFactor

double KIGFX::GAL_DISPLAY_OPTIONS::m_scaleFactor

The pixel scale factor (>1 for hi-DPI scaled displays)

Definition at line 130 of file gal_display_options.h.

Referenced by ReadCommonConfig(), and KIGFX::OPENGL_GAL::updatedGalDisplayOptions().


The documentation for this class was generated from the following files: