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.
 
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.
 
wxBitmap KiScaledBitmap (BITMAPS aBitmap, wxWindow *aWindow, int aHeight, bool aQuantized)
 Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
 
void ClearScaledBitmapCache ()
 Wipes out the scaled bitmap cache so that the icon theme can be changed.
 
wxBitmap KiScaledBitmap (const wxBitmap &aBitmap, wxWindow *aWindow)
 Overload of the above function that takes another wxBitmap as a parameter.
 
wxBitmap * KiBitmapNew (BITMAPS aBitmap)
 Allocate a wxBitmap on heap from a memory record, held in a BITMAPS.
 

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(), 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_SYNC_SHEET_PINS::DIALOG_SYNC_SHEET_PINS(), DIALOG_TABLE_PROPERTIES::DIALOG_TABLE_PROPERTIES(), DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME(), ACTION_MENU::DisplayTitle(), 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_GERBVIEW_PLUGIN_IMPL::exportCommandsAndImages(), NL_PL_EDITOR_PLUGIN_IMPL::exportCommandsAndImages(), NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages(), NL_FOOTPRINT_PROPERTIES_PLUGIN_IMPL::exportCommandsAndImages(), FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME(), GERBVIEW_FRAME::GERBVIEW_FRAME(), SCH_HIERLABEL_SYNCHRONIZATION_ITEM::GetBitmap(), SCH_SHEET_PIN_SYNCHRONIZATION_ITEM::GetBitmap(), ASSOCIATED_SCH_LABEL_PIN::GetBitmap(), HIERARCHY_PANE::HIERARCHY_PANE(), PROJECT_TREE::LoadIcons(), LISTBOX_TRICKS::OnListBoxRDown(), PROJECT_TREE_PANE::onRight(), LAYER_WIDGET::OnRightDownLayer(), LAYER_WIDGET::OnRightDownRender(), PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME(), PL_EDITOR_FRAME::PL_EDITOR_FRAME(), APPEARANCE_CONTROLS::rebuildLayerContextMenu(), 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(), and SYMBOL_VIEWER_FRAME::SYMBOL_VIEWER_FRAME().

◆ 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(), APPEARANCE_CONTROLS_3D::APPEARANCE_CONTROLS_3D(), GRID_CELL_ICON_TEXT_POPUP::Create(), PANEL_KICAD_LAUNCHER::CreateLaunchers(), DIALOG_ABOUT::DIALOG_ABOUT(), 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_DESIGN_BLOCK_PROPERTIES::DIALOG_DESIGN_BLOCK_PROPERTIES(), DIALOG_DIMENSION_PROPERTIES::DIALOG_DIMENSION_PROPERTIES(), DIALOG_EXCHANGE_FOOTPRINTS::DIALOG_EXCHANGE_FOOTPRINTS(), DIALOG_EXPORT_2581::DIALOG_EXPORT_2581(), DIALOG_EXPORT_ODBPP::DIALOG_EXPORT_ODBPP(), DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP(), DIALOG_EXPORT_SVG::DIALOG_EXPORT_SVG(), DIALOG_FIELD_PROPERTIES::DIALOG_FIELD_PROPERTIES(), DIALOG_FOOTPRINT_CHOOSER::DIALOG_FOOTPRINT_CHOOSER(), DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES(), DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR(), DIALOG_GIT_COMMIT::DIALOG_GIT_COMMIT(), 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_JOB_OUTPUT::DIALOG_JOB_OUTPUT(), DIALOG_LABEL_PROPERTIES::DIALOG_LABEL_PROPERTIES(), DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE(), DIALOG_LIB_SYMBOL_PROPERTIES::DIALOG_LIB_SYMBOL_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_OUTPUT_RUN_RESULTS::DIALOG_OUTPUT_RUN_RESULTS(), 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 >::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(), GRID_CELL_ICON_TEXT_RENDERER::Draw(), EDA_REORDERABLE_LIST_DIALOG::EDA_REORDERABLE_LIST_DIALOG(), FOOTPRINT_CHOOSER_FRAME::FOOTPRINT_CHOOSER_FRAME(), FOOTPRINT_DIFF_WIDGET::FOOTPRINT_DIFF_WIDGET(), GRID_CELL_ICON_TEXT_RENDERER::GetBestSize(), HIERARCHY_PANE::HIERARCHY_PANE(), 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(), PROJECT_TREE::LoadIcons(), NET_INSPECTOR_PANEL::NET_INSPECTOR_PANEL(), PANEL_BOM_PRESETS::PANEL_BOM_PRESETS(), PANEL_COMMON_SETTINGS::PANEL_COMMON_SETTINGS(), PANEL_DESIGN_BLOCK_LIB_TABLE::PANEL_DESIGN_BLOCK_LIB_TABLE(), PANEL_EESCHEMA_ANNOTATION_OPTIONS::PANEL_EESCHEMA_ANNOTATION_OPTIONS(), PANEL_ELECTRICAL_SPACING_IEC60664::PANEL_ELECTRICAL_SPACING_IEC60664(), PANEL_EMBEDDED_FILES::PANEL_EMBEDDED_FILES(), 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_JOB_OUTPUT::PANEL_JOB_OUTPUT(), PANEL_JOBS::PANEL_JOBS(), 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_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP(), 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_SYNC_SHEET_PINS::PANEL_SYNC_SHEET_PINS(), 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_3D::rebuildLayers(), APPEARANCE_CONTROLS::rebuildLayers(), PANEL_SETUP_PINMAP::reBuildMatrixPanel(), APPEARANCE_CONTROLS::rebuildNets(), APPEARANCE_CONTROLS::rebuildObjects(), PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar(), KICAD_MANAGER_FRAME::RecreateBaseLeftToolbar(), EDA_3D_VIEWER_FRAME::ReCreateMainToolbar(), ACTION_TOOLBAR::RefreshBitmaps(), SEARCH_PANE::SEARCH_PANE(), SELECT_COPPER_LAYERS_PAIR_DIALOG::SELECT_COPPER_LAYERS_PAIR_DIALOG(), PANEL_SETUP_PINMAP::setDRCMatrixButtonState(), DIALOG_PAD_PROPERTIES::Show(), PANEL_FP_EDITOR_DEFAULTS::Show(), SYMBOL_DIFF_WIDGET::SYMBOL_DIFF_WIDGET(), TEXT_BUTTON_FILE_BROWSER::TEXT_BUTTON_FILE_BROWSER(), TEXT_BUTTON_FP_CHOOSER::TEXT_BUTTON_FP_CHOOSER(), TEXT_BUTTON_SYMBOL_CHOOSER::TEXT_BUTTON_SYMBOL_CHOOSER(), 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(), TEXT_BUTTON_URL::UpdateButtonBitmaps(), DIALOG_UNUSED_PAD_LAYERS::updateImage(), DIALOG_PAD_PROPERTIES::updatePadSizeControls(), PANEL_JOB_OUTPUT::UpdateStatus(), 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(), COPPER_LAYERS_PAIR_PRESETS_UI::fillRowFromLayerPair(), 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(), DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar(), SYMBOL_VIEWER_FRAME::ReCreateHToolbar(), FOOTPRINT_EDIT_FRAME::ReCreateHToolbar(), and FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar().

◆ 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().