KiCad PCB EDA Suite
Loading...
Searching...
No Matches
bitmap.cpp File Reference
#include <wx/image.h>
#include <wx/bitmap.h>
#include <wx/gdicmn.h>
#include <wx/mstream.h>
#include <wx/menu.h>
#include <wx/menuitem.h>
#include <wx/aui/auibar.h>
#include <wx/dcclient.h>
#include <wx/dcmemory.h>
#include <cstdint>
#include <mutex>
#include <unordered_map>
#include <asset_archive.h>
#include <bitmaps.h>
#include <bitmap_store.h>
#include <pgm_base.h>
#include <paths.h>
#include <kiplatform/ui.h>
#include <math/util.h>
#include <settings/common_settings.h>

Go to the source code of this file.

Classes

struct  SCALED_BITMAP_ID
 
struct  std::hash< SCALED_BITMAP_ID >
 

Namespaces

namespace  std
 STL namespace.
 

Functions

BITMAP_STOREGetBitmapStore ()
 
wxBitmap KiBitmap (BITMAPS aBitmap, int aHeightTag)
 Construct a wxBitmap from an image identifier Returns the image from the active theme if the image has multiple theme variants. More...
 
wxBitmapBundle KiBitmapBundle (BITMAPS aBitmap)
 
wxBitmapBundle KiDisabledBitmapBundle (BITMAPS aBitmap)
 
int KiIconScale (wxWindow *aWindow)
 Return the automatic scale factor that would be used for a given window by KiScaledBitmap and KiScaledSeparator. More...
 
wxBitmap KiScaledBitmap (BITMAPS aBitmap, wxWindow *aWindow, int aHeight, bool aQuantized)
 Construct a wxBitmap from a memory record, scaling it if device DPI demands it. More...
 
void ClearScaledBitmapCache ()
 Wipes out the scaled bitmap cache so that the icon theme can be changed. More...
 
wxBitmap KiScaledBitmap (const wxBitmap &aBitmap, wxWindow *aWindow)
 Overload of the above function that takes another wxBitmap as a parameter. More...
 
wxBitmap * KiBitmapNew (BITMAPS aBitmap)
 Allocate a wxBitmap on heap from a memory record, held in a BITMAPS. More...
 

Variables

static std::unique_ptr< BITMAP_STOREs_BitmapStore
 
static std::unordered_map< SCALED_BITMAP_ID, wxBitmap > s_ScaledBitmapCache
 
static std::mutex s_BitmapCacheMutex
 

Function Documentation

◆ ClearScaledBitmapCache()

void ClearScaledBitmapCache ( )

Wipes out the scaled bitmap cache so that the icon theme can be changed.

TODO: move scaling system into BITMAP_STORE so this global doesn't need to exist

Definition at line 172 of file bitmap.cpp.

References s_BitmapCacheMutex, and s_ScaledBitmapCache.

Referenced by EDA_BASE_FRAME::ThemeChanged().

◆ GetBitmapStore()

◆ KiBitmap()

wxBitmap KiBitmap ( BITMAPS  aBitmap,
int  aHeightTag = -1 
)

Construct a wxBitmap from an image identifier Returns the image from the active theme if the image has multiple theme variants.

Parameters
aBitmapis from the BITMAPS enum in bitmaps_list.h
aHeightTagis the requested height tag for multi-res bitmaps (-1 for any)

Definition at line 104 of file bitmap.cpp.

References BITMAP_STORE::GetBitmap(), and GetBitmapStore().

Referenced by ACTION_MENU::Add(), CONDITIONAL_MENU::AddCheckItem(), CONDITIONAL_MENU::AddItem(), GERBER_LAYER_WIDGET::AddRightClickMenuItems(), APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D(), BITMAP2CMP_FRAME::BITMAP2CMP_FRAME(), PCB_EDIT_FRAME::buildActionPluginMenus(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), DIALOG_ABOUT::DIALOG_ABOUT(), DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(), DIALOG_GIT_COMMIT::DIALOG_GIT_COMMIT(), DIALOG_PCM::DIALOG_PCM(), DIALOG_TABLE_PROPERTIES::DIALOG_TABLE_PROPERTIES(), DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME(), ACTION_MENU::DisplayTitle(), GRID_CELL_ICON_TEXT_RENDERER::Draw(), CONDITIONAL_MENU::Evaluate(), EVT_GRID_CMD_CELL_CHANGED(), EVT_MENU_RANGE(), EVT_TOOL_RANGE(), EVT_UPDATE_UI_RANGE(), NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages(), NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages(), NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages(), FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME(), GERBVIEW_FRAME::GERBVIEW_FRAME(), GRID_CELL_ICON_TEXT_RENDERER::GetBestSize(), HIERARCHY_PANE::HIERARCHY_PANE(), PROJECT_TREE::LoadIcons(), PROJECT_TREE_PANE::onRight(), LAYER_WIDGET::OnRightDownLayer(), LAYER_WIDGET::OnRightDownRender(), PANEL_PCBNEW_ACTION_PLUGINS::PANEL_PCBNEW_ACTION_PLUGINS(), PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME(), PL_EDITOR_FRAME::PL_EDITOR_FRAME(), APPEARANCE_CONTROLS::rebuildLayerContextMenu(), APPEARANCE_CONTROLS_3D::rebuildLayers(), PANEL_SETUP_PINMAP::reBuildMatrixPanel(), FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar(), SCH_EDIT_FRAME::SCH_EDIT_FRAME(), PANEL_COLOR_SETTINGS::ShowColorContextMenu(), PGM_BASE::ShowSplash(), SIMULATOR_FRAME::SIMULATOR_FRAME(), SYMBOL_DIFF_FRAME::SYMBOL_DIFF_FRAME(), SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME(), SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME(), TEXT_BUTTON_FILE_BROWSER::TEXT_BUTTON_FILE_BROWSER(), TEXT_BUTTON_FP_CHOOSER::TEXT_BUTTON_FP_CHOOSER(), TEXT_BUTTON_SYMBOL_CHOOSER::TEXT_BUTTON_SYMBOL_CHOOSER(), and TEXT_BUTTON_URL::TEXT_BUTTON_URL().

◆ KiBitmapBundle()

wxBitmapBundle KiBitmapBundle ( BITMAPS  aBitmap)

Definition at line 110 of file bitmap.cpp.

References BITMAP_STORE::GetBitmapBundle(), and GetBitmapStore().

Referenced by ACTION_TOOLBAR::Add(), ACTION_TOOLBAR_PALETTE::AddAction(), ACTION_TOOLBAR::AddButton(), ACTION_TOOLBAR::AddGroup(), APPEARANCE_CONTROLS::APPEARANCE_CONTROLS(), GRID_CELL_ICON_TEXT_POPUP::Create(), DIALOG_ABOUT::createStaticBitmap(), DIALOG_BOARD_REANNOTATE::DIALOG_BOARD_REANNOTATE(), DIALOG_BOM::DIALOG_BOM(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES(), DIALOG_CONFIGURE_PATHS::DIALOG_CONFIGURE_PATHS(), DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES(), DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS(), DIALOG_EXPORT_2581::DIALOG_EXPORT_2581(), DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP(), DIALOG_EXPORT_SVG::DIALOG_EXPORT_SVG(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(), DIALOG_GLOBAL_EDIT_TEARDROPS::DIALOG_GLOBAL_EDIT_TEARDROPS(), DIALOG_GROUP_PROPERTIES::DIALOG_GROUP_PROPERTIES(), DIALOG_IMPORT_GFX_SCH::DIALOG_IMPORT_GFX_SCH(), DIALOG_IMPORT_GRAPHICS::DIALOG_IMPORT_GRAPHICS(), DIALOG_IMPORT_NETLIST::DIALOG_IMPORT_NETLIST(), DIALOG_IMPORT_SETTINGS::DIALOG_IMPORT_SETTINGS(), DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES(), DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE(), DIALOG_LIB_SHAPE_PROPERTIES::DIALOG_LIB_SHAPE_PROPERTIES(), DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_PROPERTIES(), DIALOG_LIB_TEXT_PROPERTIES::DIALOG_LIB_TEXT_PROPERTIES(), DIALOG_LIB_TEXTBOX_PROPERTIES::DIALOG_LIB_TEXTBOX_PROPERTIES(), DIALOG_LINE_PROPERTIES::DIALOG_LINE_PROPERTIES(), DIALOG_LOCKED_ITEMS_QUERY::DIALOG_LOCKED_ITEMS_QUERY(), DIALOG_MANAGE_REPOSITORIES::DIALOG_MANAGE_REPOSITORIES(), DIALOG_MIGRATE_SETTINGS::DIALOG_MIGRATE_SETTINGS(), DIALOG_NET_INSPECTOR::DIALOG_NET_INSPECTOR(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), DIALOG_PCM::DIALOG_PCM(), DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES(), DIALOG_PLOT::DIALOG_PLOT(), DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC(), DIALOG_PLUGIN_OPTIONS::DIALOG_PLUGIN_OPTIONS(), DIALOG_SCH_IMPORT_SETTINGS::DIALOG_SCH_IMPORT_SETTINGS(), DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES(), DIALOG_SHEET_PIN_PROPERTIES::DIALOG_SHEET_PIN_PROPERTIES(), DIALOG_SHEET_PROPERTIES::DIALOG_SHEET_PROPERTIES(), DIALOG_SIM_MODEL< T_symbol, T_field >::DIALOG_SIM_MODEL(), DIALOG_SYMBOL_FIELDS_TABLE::DIALOG_SYMBOL_FIELDS_TABLE(), DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES(), DIALOG_TABLECELL_PROPERTIES::DIALOG_TABLECELL_PROPERTIES(), DIALOG_TEMPLATE_SELECTOR::DIALOG_TEMPLATE_SELECTOR(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), DIALOG_TEXTBOX_PROPERTIES::DIALOG_TEXTBOX_PROPERTIES(), DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES(), DIALOG_TUNING_PATTERN_PROPERTIES::DIALOG_TUNING_PATTERN_PROPERTIES(), DIALOG_UNUSED_PAD_LAYERS::DIALOG_UNUSED_PAD_LAYERS(), DIALOG_USER_DEFINED_SIGNALS::DIALOG_USER_DEFINED_SIGNALS(), DIALOG_WIRE_BUS_PROPERTIES::DIALOG_WIRE_BUS_PROPERTIES(), ACTION_TOOLBAR::doSelectAction(), EDA_REORDERABLE_LIST_DIALOG::EDA_REORDERABLE_LIST_DIALOG(), DIALOG_FIELD_PROPERTIES::init(), DIALOG_PLOT::init_Dialog(), DIALOG_GEN_FOOTPRINT_POSITION::initDialog(), DIALOG_GENDRILL::InitDisplayParams(), DIALOG_ANNOTATE::InitValues(), KISTATUSBAR::KISTATUSBAR(), LIB_TREE::LIB_TREE(), PANEL_BOM_PRESETS::PANEL_BOM_PRESETS(), PANEL_COMMON_SETTINGS::PANEL_COMMON_SETTINGS(), PANEL_EESCHEMA_ANNOTATION_OPTIONS::PANEL_EESCHEMA_ANNOTATION_OPTIONS(), PANEL_ELECTRICAL_SPACING_IEC60664::PANEL_ELECTRICAL_SPACING_IEC60664(), PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE(), PANEL_FP_PROPERTIES_3D_MODEL::PANEL_FP_PROPERTIES_3D_MODEL(), PANEL_GIT_REPOS::PANEL_GIT_REPOS(), PANEL_GRID_SETTINGS::PANEL_GRID_SETTINGS(), PANEL_PCBNEW_ACTION_PLUGINS::PANEL_PCBNEW_ACTION_PLUGINS(), PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL(), PANEL_REGULATOR::PANEL_REGULATOR(), PANEL_RF_ATTENUATORS::PANEL_RF_ATTENUATORS(), PANEL_SETUP_BUSES::PANEL_SETUP_BUSES(), PANEL_SETUP_CONSTRAINTS::PANEL_SETUP_CONSTRAINTS(), PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES(), PANEL_SETUP_RULES::PANEL_SETUP_RULES(), PANEL_SETUP_TEARDROPS::PANEL_SETUP_TEARDROPS(), PANEL_SETUP_TRACKS_AND_VIAS::PANEL_SETUP_TRACKS_AND_VIAS(), PANEL_SETUP_TUNING_PATTERNS::PANEL_SETUP_TUNING_PATTERNS(), PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE(), PANEL_TEMPLATE_FIELDNAMES::PANEL_TEMPLATE_FIELDNAMES(), PANEL_TEXT_VARIABLES::PANEL_TEXT_VARIABLES(), PANEL_TRANSLINE::PANEL_TRANSLINE(), PANEL_VIA_SIZE::PANEL_VIA_SIZE(), PinShapeComboBox::PinShapeComboBox(), PinTypeComboBox::PinTypeComboBox(), PROPERTIES_FRAME::PROPERTIES_FRAME(), APPEARANCE_CONTROLS::rebuildLayers(), PANEL_SETUP_PINMAP::reBuildMatrixPanel(), APPEARANCE_CONTROLS::rebuildNets(), APPEARANCE_CONTROLS::rebuildObjects(), KICAD_MANAGER_FRAME::RecreateBaseHToolbar(), ACTION_TOOLBAR::RefreshBitmaps(), PANEL_SETUP_PINMAP::setDRCMatrixButtonState(), DIALOG_PAD_PROPERTIES::Show(), PANEL_FP_EDITOR_DEFAULTS::Show(), PANEL_COLOR_CODE::ThemeChanged(), PANEL_ELECTRICAL_SPACING_IEC60664::ThemeChanged(), PANEL_REGULATOR::ThemeChanged(), PANEL_RF_ATTENUATORS::ThemeChanged(), PANEL_TRANSLINE::ThemeChanged(), PANEL_VIA_SIZE::ThemeChanged(), PANEL_COLOR_CODE::ToleranceSelection(), PANEL_RF_ATTENUATORS::TransfAttenuatorDataToPanel(), PANEL_TRANSLINE::TranslineTypeSelection(), TUNER_SLIDER::TUNER_SLIDER(), DIALOG_UNUSED_PAD_LAYERS::updateImage(), DIALOG_PAD_PROPERTIES::updatePadSizeControls(), and PANEL_RF_ATTENUATORS::UpdateUI().

◆ KiBitmapNew()

wxBitmap * KiBitmapNew ( BITMAPS  aBitmap)

Allocate a wxBitmap on heap from a memory record, held in a BITMAPS.

Parameters
aBitmapis from the BITMAPS enum in bitmaps_list.h
Returns
wxBitmap* - caller owns it.

Definition at line 198 of file bitmap.cpp.

References GetBitmapStore().

Referenced by ABOUT_APP_INFO::CreateKiBitmap().

◆ KiDisabledBitmapBundle()

◆ KiIconScale()

int KiIconScale ( wxWindow *  aWindow)

Return the automatic scale factor that would be used for a given window by KiScaledBitmap and KiScaledSeparator.

Definition at line 122 of file bitmap.cpp.

Referenced by ACTION_TOOLBAR::AddScaledSeparator(), getGUIFont(), KiScaledBitmap(), and PCB_EDIT_FRAME::PrepareLayerIndicator().

◆ KiScaledBitmap() [1/2]

wxBitmap KiScaledBitmap ( BITMAPS  aBitmap,
wxWindow *  aWindow,
int  aHeight = -1,
bool  aQuantized = false 
)

Construct a wxBitmap from a memory record, scaling it if device DPI demands it.

Internally this may use caching to avoid scaling the same image twice. If caching is used, it's guaranteed threadsafe.

Parameters
aBitmapis from the BITMAPS enum in bitmaps_list.h
aWindowtarget window for scaling context
aHeightis the requested image height for the source bitmap, or -1 for any height
aQuantizedif true scaling will be rounded to integers (2X, 3X, etc.).

Definition at line 147 of file bitmap.cpp.

References BITMAP_STORE::GetBitmapScaled(), GetBitmapStore(), KiIconScale(), KiROUND(), s_BitmapCacheMutex, s_ScaledBitmapCache, and scale.

Referenced by PCB_EDIT_FRAME::AddActionPluginTools(), PANEL_KICAD_LAUNCHER::CreateLaunchers(), PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP(), PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar(), DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar(), SYMBOL_VIEWER_FRAME::ReCreateHToolbar(), FOOTPRINT_EDIT_FRAME::ReCreateHToolbar(), FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar(), and EDA_3D_VIEWER_FRAME::ReCreateMainToolbar().

◆ KiScaledBitmap() [2/2]

wxBitmap KiScaledBitmap ( const wxBitmap &  aBitmap,
wxWindow *  aWindow 
)

Overload of the above function that takes another wxBitmap as a parameter.

Parameters
aBitmapis the source bitmap to scale
aWindowtarget window for scaling context

Definition at line 179 of file bitmap.cpp.

References image, KiIconScale(), and scale.

Variable Documentation

◆ s_BitmapCacheMutex

std::mutex s_BitmapCacheMutex
static

Definition at line 89 of file bitmap.cpp.

Referenced by ClearScaledBitmapCache(), and KiScaledBitmap().

◆ s_BitmapStore

std::unique_ptr<BITMAP_STORE> s_BitmapStore
static

Definition at line 49 of file bitmap.cpp.

Referenced by GetBitmapStore().

◆ s_ScaledBitmapCache

std::unordered_map<SCALED_BITMAP_ID, wxBitmap> s_ScaledBitmapCache
static

Definition at line 87 of file bitmap.cpp.

Referenced by ClearScaledBitmapCache(), and KiScaledBitmap().