OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::ModelNode Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/UnsavedChangesDialog.hpp>

Collaboration diagram for Slic3r::GUI::ModelNode:

Public Member Functions

 ModelNode (Preset::Type preset_type, wxWindow *parent_win, const wxString &text, const std::string &icon_name)
 ModelNode (ModelNode *parent, const wxString &text, const std::string &icon_name)
 ModelNode (ModelNode *parent, const wxString &text)
 ModelNode (ModelNode *parent, const wxString &text, const wxString &old_value, const wxString &new_value)
bool IsContainer () const
bool IsToggled () const
void Toggle (bool toggle=true)
bool IsRoot () const
Preset::Type type () const
const wxString & text () const
ModelNode * GetParent ()
ModelNodePtrArray & GetChildren ()
ModelNode * GetNthChild (unsigned int n)
unsigned int GetChildCount () const
void Append (std::unique_ptr< ModelNode > child)
void UpdateEnabling ()
void UpdateIcons ()

Public Attributes

bool m_toggle {true}
wxBitmap m_icon
wxBitmap m_old_color_bmp
wxBitmap m_new_color_bmp
wxString m_text
wxString m_old_value
wxString m_new_value
bool m_container {true}

Private Member Functions

wxBitmap get_bitmap (const wxString &color)

Private Attributes

wxWindow * m_parent_win { nullptr }
ModelNode * m_parent
ModelNodePtrArray m_children
wxBitmap m_empty_bmp
Preset::Type m_preset_type {Preset::TYPE_INVALID}
std::string m_icon_name
wxString m_old_color
wxString m_new_color

Detailed Description

Constructor & Destructor Documentation

◆ ModelNode() [1/4]

Slic3r::GUI::ModelNode::ModelNode ( Preset::Type preset_type,
wxWindow * parent_win,
const wxString & text,
const std::string & icon_name )
120 :
121 m_parent_win(parent_win),
122 m_parent(nullptr),
123 m_preset_type(preset_type),
124 m_icon_name(icon_name),
125 m_text(text)
126{
127 UpdateIcons();
128}
Preset::Type m_preset_type
Definition UnsavedChangesDialog.hpp:60
ModelNode * m_parent
Definition UnsavedChangesDialog.hpp:57
const wxString & text() const
Definition UnsavedChangesDialog.hpp:117
std::string m_icon_name
Definition UnsavedChangesDialog.hpp:62
wxString m_text
Definition UnsavedChangesDialog.hpp:85
wxWindow * m_parent_win
Definition UnsavedChangesDialog.hpp:55
void UpdateIcons()
Definition UnsavedChangesDialog.cpp:239

References m_icon_name, m_parent, m_parent_win, m_preset_type, m_text, text(), and UpdateIcons().

Referenced by ModelNode(), ModelNode(), ModelNode(), GetNthChild(), and GetParent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ModelNode() [2/4]

Slic3r::GUI::ModelNode::ModelNode ( ModelNode * parent,
const wxString & text,
const std::string & icon_name )
131 :
132 m_parent_win(parent->m_parent_win),
133 m_parent(parent),
134 m_icon_name(icon_name),
135 m_text(text)
136{
137 UpdateIcons();
138}

References ModelNode(), m_icon_name, m_parent, m_parent_win, m_text, text(), and UpdateIcons().

Here is the call graph for this function:

◆ ModelNode() [3/4]

Slic3r::GUI::ModelNode::ModelNode ( ModelNode * parent,
const wxString & text )
141 :
142 m_parent_win(parent->m_parent_win),
143 m_parent(parent),
144 m_icon_name("node_dot"),
145 m_text(text)
146{
147 UpdateIcons();
148}

References ModelNode(), m_icon_name, m_parent, m_parent_win, m_text, text(), and UpdateIcons().

Here is the call graph for this function:

◆ ModelNode() [4/4]

Slic3r::GUI::ModelNode::ModelNode ( ModelNode * parent,
const wxString & text,
const wxString & old_value,
const wxString & new_value )
178 :
179 m_parent(parent),
180 m_old_color(old_value.StartsWith("#") ? old_value : ""),
181 m_new_color(new_value.StartsWith("#") ? new_value : ""),
182 m_icon_name("empty"),
183 m_text(text),
184 m_old_value(old_value),
185 m_new_value(new_value),
186 m_container(false)
187{
188 // check if old/new_value is color
189 if (m_old_color.IsEmpty()) {
190 if (!m_new_color.IsEmpty())
191 m_old_value = _L("Undefined");
192 }
193 else {
195 m_old_value.Clear();
196 }
197
198 if (m_new_color.IsEmpty()) {
199 if (!m_old_color.IsEmpty())
200 m_new_value = _L("Undefined");
201 }
202 else {
204 m_new_value.Clear();
205 }
206
207 // "color" strings
210
211 UpdateIcons();
212}
#define _L(s)
Definition OBJ.cpp:34
wxString m_new_color
Definition UnsavedChangesDialog.hpp:65
wxString m_old_color
Definition UnsavedChangesDialog.hpp:64
wxString m_old_value
Definition UnsavedChangesDialog.hpp:86
wxBitmap m_new_color_bmp
Definition UnsavedChangesDialog.hpp:83
wxString m_new_value
Definition UnsavedChangesDialog.hpp:87
bool m_container
Definition UnsavedChangesDialog.hpp:98
wxBitmap get_bitmap(const wxString &color)
Definition UnsavedChangesDialog.cpp:153
wxBitmap m_old_color_bmp
Definition UnsavedChangesDialog.hpp:82
static std::string def_text_color()
Definition UnsavedChangesDialog.cpp:97
static std::string orange
Definition UnsavedChangesDialog.cpp:103
static void color_string(wxString &str, const std::string &color)
Definition UnsavedChangesDialog.cpp:105

References ModelNode(), Slic3r::GUI::color_string(), Slic3r::GUI::def_text_color(), m_container, m_icon_name, m_new_color, m_new_value, m_old_color, m_old_value, m_parent, m_text, Slic3r::GUI::orange, text(), and UpdateIcons().

Here is the call graph for this function:

Member Function Documentation

◆ Append()

void Slic3r::GUI::ModelNode::Append ( std::unique_ptr< ModelNode > child)
inline
124{ m_children.emplace_back(std::move(child)); }
ModelNodePtrArray m_children
Definition UnsavedChangesDialog.hpp:58

References m_children.

Referenced by Slic3r::GUI::DiffModel::AddOption(), Slic3r::GUI::DiffModel::AddOptionWithGroup(), and Slic3r::GUI::DiffModel::AddOptionWithGroupAndCategory().

Here is the caller graph for this function:

◆ get_bitmap()

wxBitmap Slic3r::GUI::ModelNode::get_bitmap ( const wxString & color)
private
155{
156 /* It's supposed that standard size of an icon is 48px*16px for 100% scaled display.
157 * So set sizes for solid_colored icons used for filament preset
158 * and scale them in respect to em_unit value
159 */
160 const double em = em_unit(m_parent_win);
161 const int icon_width = lround(6.4 * em);
162 const int icon_height = lround(1.6 * em);
163
164 BitmapCache bmp_cache;
165 ColorRGB rgb;
166 decode_color(into_u8(color), rgb);
167 // there is no need to scale created solid bitmap
168#ifndef __linux__
169 return bmp_cache.mksolid(icon_width, icon_height, rgb, true);
170#else
171 wxIcon icon;
172 icon.CopyFromBitmap(bmp_cache.mksolid(icon_width, icon_height, rgb, true));
173 return icon;
174#endif // __linux__
175}
std::string into_u8(const wxString &str)
Definition GUI.cpp:549
static wxColour decode_color(const std::string &color)
Definition SliceInfoPanel.cpp:51
int em_unit(wxWindow *win)
Definition wxExtensions.cpp:424

References Slic3r::GUI::decode_color(), em_unit(), Slic3r::GUI::into_u8(), m_parent_win, and Slic3r::GUI::BitmapCache::mksolid().

Referenced by UpdateIcons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChildCount()

unsigned int Slic3r::GUI::ModelNode::GetChildCount ( ) const
inline
122{ return (unsigned int)(m_children.size()); }

References m_children.

◆ GetChildren()

ModelNodePtrArray & Slic3r::GUI::ModelNode::GetChildren ( )
inline

◆ GetNthChild()

ModelNode * Slic3r::GUI::ModelNode::GetNthChild ( unsigned int n)
inline
121{ return m_children[n].get(); }

References ModelNode(), and m_children.

Here is the call graph for this function:

◆ GetParent()

ModelNode * Slic3r::GUI::ModelNode::GetParent ( )
inline
119{ return m_parent; }

References ModelNode(), and m_parent.

Referenced by Slic3r::GUI::DiffModel::Delete(), Slic3r::GUI::DiffModel::GetParent(), and Slic3r::GUI::update_parents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsContainer()

bool Slic3r::GUI::ModelNode::IsContainer ( ) const
inline
112{ return m_container; }

References m_container.

Referenced by Slic3r::GUI::DiffModel::IsContainer(), Slic3r::GUI::rescale_children(), and Slic3r::GUI::update_children().

Here is the caller graph for this function:

◆ IsRoot()

bool Slic3r::GUI::ModelNode::IsRoot ( ) const
inline
115{ return m_parent == nullptr; }

References m_parent.

Referenced by Slic3r::GUI::DiffModel::GetParent().

Here is the caller graph for this function:

◆ IsToggled()

bool Slic3r::GUI::ModelNode::IsToggled ( ) const
inline
113{ return m_toggle; }
bool m_toggle
Definition UnsavedChangesDialog.hpp:75

References m_toggle.

Referenced by Slic3r::GUI::DiffModel::IsEnabledItem(), and Slic3r::GUI::update_children().

Here is the caller graph for this function:

◆ text()

const wxString & Slic3r::GUI::ModelNode::text ( ) const
inline
117{ return m_text; }

References m_text.

Referenced by ModelNode(), ModelNode(), ModelNode(), and ModelNode().

Here is the caller graph for this function:

◆ Toggle()

void Slic3r::GUI::ModelNode::Toggle ( bool toggle = true)
inline
114{ m_toggle = toggle; }

References m_toggle.

Referenced by Slic3r::GUI::update_parents().

Here is the caller graph for this function:

◆ type()

Preset::Type Slic3r::GUI::ModelNode::type ( ) const
inline
116{ return m_preset_type; }

References m_preset_type.

◆ UpdateEnabling()

void Slic3r::GUI::ModelNode::UpdateEnabling ( )
215{
216 auto change_text_color = [](wxString& str, const std::string& clr_from, const std::string& clr_to)
217 {
218#if defined(SUPPORTS_MARKUP) && !defined(__APPLE__)
219 std::string old_val = into_u8(str);
220 boost::replace_all(old_val, clr_from, clr_to);
221 str = from_u8(old_val);
222#endif
223 };
224
225 if (!m_toggle) {
226 change_text_color(m_text, def_text_color(), grey);
227 change_text_color(m_old_value, def_text_color(), grey);
228 change_text_color(m_new_value, orange,grey);
229 }
230 else {
231 change_text_color(m_text, grey, def_text_color());
232 change_text_color(m_old_value, grey, def_text_color());
233 change_text_color(m_new_value, grey, orange);
234 }
235 // update icons for the colors
236 UpdateIcons();
237}
static std::string grey
Definition UnsavedChangesDialog.cpp:102
wxString from_u8(const std::string &str)
Definition GUI.cpp:544

References Slic3r::GUI::def_text_color(), Slic3r::GUI::from_u8(), Slic3r::GUI::grey, Slic3r::GUI::into_u8(), m_new_value, m_old_value, m_text, m_toggle, Slic3r::GUI::orange, and UpdateIcons().

Referenced by Slic3r::GUI::update_parents(), and Slic3r::GUI::DiffModel::UpdateItemEnabling().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateIcons()

void Slic3r::GUI::ModelNode::UpdateIcons ( )
240{
241 // update icons for the colors, if any exists
242 if (!m_old_color.IsEmpty())
243 m_old_color_bmp = get_bitmap(m_toggle ? m_old_color : wxString::FromUTF8(grey.c_str()));
244 if (!m_new_color.IsEmpty())
245 m_new_color_bmp = get_bitmap(m_toggle ? m_new_color : wxString::FromUTF8(grey.c_str()));
246
247 // update main icon, if any exists
248 if (m_icon_name.empty())
249 return;
250
251#ifdef __linux__
253#else
255#endif //__linux__
256}
wxBitmap m_icon
Definition UnsavedChangesDialog.hpp:81
wxBitmap create_scaled_bitmap(const std::string &bmp_name_in, wxWindow *win, const int px_cnt, const bool grayscale, const std::string &new_color, const bool menu_bitmap, const bool resize, const bool bitmap2, const std::vector< std::string > &array_new_color)
Definition wxExtensions.cpp:448

References create_scaled_bitmap(), get_bitmap(), Slic3r::GUI::grey, m_icon, m_icon_name, m_new_color, m_new_color_bmp, m_old_color, m_old_color_bmp, m_parent_win, and m_toggle.

Referenced by ModelNode(), ModelNode(), ModelNode(), ModelNode(), and UpdateEnabling().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_children

ModelNodePtrArray Slic3r::GUI::ModelNode::m_children
private

◆ m_container

bool Slic3r::GUI::ModelNode::m_container {true}
98{true};

Referenced by ModelNode(), and IsContainer().

◆ m_empty_bmp

wxBitmap Slic3r::GUI::ModelNode::m_empty_bmp
private

◆ m_icon

wxBitmap Slic3r::GUI::ModelNode::m_icon

◆ m_icon_name

std::string Slic3r::GUI::ModelNode::m_icon_name
private

◆ m_new_color

wxString Slic3r::GUI::ModelNode::m_new_color
private

Referenced by ModelNode(), and UpdateIcons().

◆ m_new_color_bmp

wxBitmap Slic3r::GUI::ModelNode::m_new_color_bmp

◆ m_new_value

wxString Slic3r::GUI::ModelNode::m_new_value

◆ m_old_color

wxString Slic3r::GUI::ModelNode::m_old_color
private

Referenced by ModelNode(), and UpdateIcons().

◆ m_old_color_bmp

wxBitmap Slic3r::GUI::ModelNode::m_old_color_bmp

◆ m_old_value

wxString Slic3r::GUI::ModelNode::m_old_value

◆ m_parent

ModelNode* Slic3r::GUI::ModelNode::m_parent
private

◆ m_parent_win

wxWindow* Slic3r::GUI::ModelNode::m_parent_win { nullptr }
private
55{ nullptr };

Referenced by ModelNode(), ModelNode(), ModelNode(), get_bitmap(), and UpdateIcons().

◆ m_preset_type

Preset::Type Slic3r::GUI::ModelNode::m_preset_type {Preset::TYPE_INVALID}
private
@ TYPE_INVALID
Definition Preset.hpp:245

Referenced by ModelNode(), and type().

◆ m_text

◆ m_toggle

bool Slic3r::GUI::ModelNode::m_toggle {true}

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