riCOM_cpp
This repository contains the C++ implementation of the riCOM (Real Time Centre Of Mass) algorithm for 4D Scanning electron microscopy.
Loading...
Searching...
No Matches
Functions | Variables
ImGuiINI Namespace Reference

Functions

void set_style (int style_idx)
 
bool ShowStyleSelector (const char *label, int &style_idx, mINI::INIStructure &ini_cfg)
 
bool ShowFontSelector (const char *label, int &selectedFont, mINI::INIStructure &ini_cfg)
 
void set_font (int font_idx)
 
template<typename T >
std::vector< T > split2T (std::string &s, char delimiter)
 
std::string ImVec2string (const ImVec4 &v)
 
std::string ImVec2string (const ImVec2 &v)
 
void check_ini_setting (mINI::INIStructure &ini_cfg, std::string section, std::string key, char *value)
 
void check_ini_setting (mINI::INIStructure &ini_cfg, std::string section, std::string key, std::string value)
 
template<typename T >
void check_ini_setting (mINI::INIStructure &ini_cfg, std::string section, std::string key, T &value)
 
void check_ini_setting (mINI::INIStructure &ini_cfg, std::string section, std::string key, ImVec4 &value)
 
void check_ini_setting (mINI::INIStructure &ini_cfg, std::string section, std::string key, ImVec2 &value)
 

Variables

const char * font_names [6]
 

Function Documentation

◆ check_ini_setting() [1/5]

void ImGuiINI::check_ini_setting ( mINI::INIStructure &  ini_cfg,
std::string  section,
std::string  key,
char *  value 
)

Definition at line 116 of file ImGuiINI.hpp.

117 {
118 if (ini_cfg.has(section))
119 {
120 if (ini_cfg[section].has(key))
121 {
122 value = &ini_cfg[section][key][0];
123 }
124 ini_cfg[section][key] = std::string(value);
125 }
126 }

◆ check_ini_setting() [2/5]

void ImGuiINI::check_ini_setting ( mINI::INIStructure &  ini_cfg,
std::string  section,
std::string  key,
ImVec2 &  value 
)

Definition at line 169 of file ImGuiINI.hpp.

170 {
171 if (ini_cfg.has(section))
172 {
173 if (ini_cfg[section].has(key))
174 {
175 std::vector<float> val_vec = split2T<float>(ini_cfg[section][key], ',');
176 value = ImVec2(val_vec[0], val_vec[1]);
177 }
178 ini_cfg[section][key] = ImVec2string(value);
179 }
180 }

◆ check_ini_setting() [3/5]

void ImGuiINI::check_ini_setting ( mINI::INIStructure &  ini_cfg,
std::string  section,
std::string  key,
ImVec4 &  value 
)

Definition at line 155 of file ImGuiINI.hpp.

156 {
157 if (ini_cfg.has(section))
158 {
159 if (ini_cfg[section].has(key))
160 {
161 std::vector<float> val_vec = split2T<float>(ini_cfg[section][key], ',');
162 value = ImVec4(val_vec[0], val_vec[1], val_vec[2], val_vec[3]);
163 }
164 ini_cfg[section][key] = ImVec2string(value);
165 }
166 }

◆ check_ini_setting() [4/5]

void ImGuiINI::check_ini_setting ( mINI::INIStructure &  ini_cfg,
std::string  section,
std::string  key,
std::string  value 
)

Definition at line 128 of file ImGuiINI.hpp.

129 {
130 if (ini_cfg.has(section))
131 {
132 if (ini_cfg[section].has(key))
133 {
134 value = ini_cfg[section][key];
135 }
136 ini_cfg[section][key] = value;
137 }
138 }

◆ check_ini_setting() [5/5]

template<typename T >
void ImGuiINI::check_ini_setting ( mINI::INIStructure &  ini_cfg,
std::string  section,
std::string  key,
T &  value 
)

Definition at line 142 of file ImGuiINI.hpp.

143 {
144 if (ini_cfg.has(section))
145 {
146 if (ini_cfg[section].has(key))
147 {
148 value = (T)stod(ini_cfg[section][key]);
149 }
150 ini_cfg[section][key] = std::to_string(value);
151 }
152 }

◆ ImVec2string() [1/2]

std::string ImGuiINI::ImVec2string ( const ImVec2 &  v)

Definition at line 108 of file ImGuiINI.hpp.

109 {
110 std::string s = std::to_string(v.x) + "," + std::to_string(v.y);
111 return s;
112 }

◆ ImVec2string() [2/2]

std::string ImGuiINI::ImVec2string ( const ImVec4 &  v)

Definition at line 102 of file ImGuiINI.hpp.

103 {
104 std::string s = std::to_string(v.x) + "," + std::to_string(v.y) + "," + std::to_string(v.z) + "," + std::to_string(v.w);
105 return s;
106 }

◆ set_font()

void ImGuiINI::set_font ( int  font_idx)

Definition at line 81 of file ImGuiINI.hpp.

82 {
83 ImGuiIO &io = ImGui::GetIO();
84 ImFont *font = io.Fonts->Fonts[font_idx];
85 io.FontDefault = font;
86 }

◆ set_style()

void ImGuiINI::set_style ( int  style_idx)

Definition at line 21 of file ImGuiINI.hpp.

22 {
23 switch (style_idx)
24 {
25 case 0:
26 ImGui::StyleColorsDark();
27 break;
28 case 1:
29 ImGui::StyleColorsLight();
30 break;
31 case 2:
32 ImGui::StyleColorsClassic();
33 break;
34 }
35 }

◆ ShowFontSelector()

bool ImGuiINI::ShowFontSelector ( const char *  label,
int &  selectedFont,
mINI::INIStructure &  ini_cfg 
)

Definition at line 57 of file ImGuiINI.hpp.

58 {
59 ImGuiIO &io = ImGui::GetIO();
60 ImFont *font_current = ImGui::GetFont();
61 if (ImGui::BeginCombo(label, font_names[selectedFont]))
62 {
63 for (int n = 0; n < io.Fonts->Fonts.Size; n++)
64 {
65 ImFont *font = io.Fonts->Fonts[n];
66 ImGui::PushID((void *)font);
67 if (ImGui::Selectable(font_names[n], font == font_current))
68 {
69 io.FontDefault = font;
70 selectedFont = n;
71 }
72 ImGui::PopID();
73 }
74 ImGui::EndCombo();
75 ini_cfg["Appearance"]["Font"] = std::to_string(selectedFont);
76 return true;
77 }
78 return false;
79 }

◆ ShowStyleSelector()

bool ImGuiINI::ShowStyleSelector ( const char *  label,
int &  style_idx,
mINI::INIStructure &  ini_cfg 
)

Definition at line 37 of file ImGuiINI.hpp.

38 {
39 if (ImGui::Combo(label, &style_idx, "Dark\0Light\0Classic\0"))
40 {
41 set_style(style_idx);
42 ini_cfg["Appearance"]["Style"] = std::to_string(style_idx);
43 return true;
44 }
45 return false;
46 }
void set_style(int style_idx)
Definition ImGuiINI.hpp:21

◆ split2T()

template<typename T >
std::vector< T > ImGuiINI::split2T ( std::string &  s,
char  delimiter 
)

Definition at line 90 of file ImGuiINI.hpp.

91 {
92 std::vector<T> values;
93 std::string token;
94 std::istringstream tokenStream(s);
95 while (std::getline(tokenStream, token, delimiter))
96 {
97 values.push_back((T)std::stod(token));
98 }
99 return values;
100 }

Variable Documentation

◆ font_names

const char* ImGuiINI::font_names[6]
Initial value:
= {
"Karla-Regular",
"Roboto-Medium",
"Cousine-Regular",
"DroidSans",
"ProggyClean",
"ProggyTiny"}

Definition at line 49 of file ImGuiINI.hpp.

49 {
50 "Karla-Regular",
51 "Roboto-Medium",
52 "Cousine-Regular",
53 "DroidSans",
54 "ProggyClean",
55 "ProggyTiny"};