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

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

Inheritance diagram for Slic3r::GUI::DiffModel:
Collaboration diagram for Slic3r::GUI::DiffModel:

Public Types

enum  {
  colToggle , colIconText , colOldValue , colNewValue ,
  colMax
}

Public Member Functions

 DiffModel (wxWindow *parent)
 ~DiffModel () override=default
void SetAssociatedControl (wxDataViewCtrl *ctrl)
wxDataViewItem AddPreset (Preset::Type type, wxString preset_name, PrinterTechnology pt)
wxDataViewItem AddOption (Preset::Type type, wxString category_name, wxString group_name, wxString option_name, wxString old_value, wxString new_value, const std::string category_icon_name)
void UpdateItemEnabling (wxDataViewItem item)
bool IsEnabledItem (const wxDataViewItem &item)
unsigned int GetColumnCount () const override
wxString GetColumnType (unsigned int col) const override
void Rescale ()
wxDataViewItem Delete (const wxDataViewItem &item)
void Clear ()
wxDataViewItem GetParent (const wxDataViewItem &item) const override
unsigned int GetChildren (const wxDataViewItem &parent, wxDataViewItemArray &array) const override
void GetValue (wxVariant &variant, const wxDataViewItem &item, unsigned int col) const override
bool SetValue (const wxVariant &variant, const wxDataViewItem &item, unsigned int col) override
bool IsEnabled (const wxDataViewItem &item, unsigned int col) const override
bool IsContainer (const wxDataViewItem &item) const override
bool HasContainerColumns (const wxDataViewItem &WXUNUSED(item)) const override

Private Member Functions

ModelNode * AddOption (ModelNode *group_node, wxString option_name, wxString old_value, wxString new_value)
ModelNode * AddOptionWithGroup (ModelNode *category_node, wxString group_name, wxString option_name, wxString old_value, wxString new_value)
ModelNode * AddOptionWithGroupAndCategory (ModelNode *preset_node, wxString category_name, wxString group_name, wxString option_name, wxString old_value, wxString new_value, const std::string category_icon_name)

Private Attributes

wxWindow * m_parent_win { nullptr }
ModelNodePtrArray m_preset_nodes
wxDataViewCtrl * m_ctrl { nullptr }

Detailed Description

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
colToggle 
colIconText 
colOldValue 
colNewValue 
colMax 
160 {
161 colToggle,
165 colMax
166 };
@ colOldValue
Definition UnsavedChangesDialog.hpp:163
@ colIconText
Definition UnsavedChangesDialog.hpp:162
@ colToggle
Definition UnsavedChangesDialog.hpp:161
@ colNewValue
Definition UnsavedChangesDialog.hpp:164
@ colMax
Definition UnsavedChangesDialog.hpp:165

Constructor & Destructor Documentation

◆ DiffModel()

Slic3r::GUI::DiffModel::DiffModel ( wxWindow * parent)
263 :
264 m_parent_win(parent)
265{
266}
wxWindow * m_parent_win
Definition UnsavedChangesDialog.hpp:137

References m_parent_win.

◆ ~DiffModel()

Slic3r::GUI::DiffModel::~DiffModel ( )
overridedefault

Member Function Documentation

◆ AddOption() [1/2]

ModelNode * Slic3r::GUI::DiffModel::AddOption ( ModelNode * group_node,
wxString option_name,
wxString old_value,
wxString new_value )
private
285{
286 group_node->Append(std::make_unique<ModelNode>(group_node, option_name, old_value, new_value));
287 ModelNode* option = group_node->GetChildren().back().get();
288 wxDataViewItem group_item = wxDataViewItem((void*)group_node);
289 ItemAdded(group_item, wxDataViewItem((void*)option));
290
291 m_ctrl->Expand(group_item);
292 return option;
293}
wxDataViewCtrl * m_ctrl
Definition UnsavedChangesDialog.hpp:140

References Slic3r::GUI::ModelNode::Append(), Slic3r::GUI::ModelNode::GetChildren(), and m_ctrl.

Referenced by AddOption(), and AddOptionWithGroup().

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

◆ AddOption() [2/2]

wxDataViewItem Slic3r::GUI::DiffModel::AddOption ( Preset::Type type,
wxString category_name,
wxString group_name,
wxString option_name,
wxString old_value,
wxString new_value,
const std::string category_icon_name )
316{
317 // "color" strings
319 color_string(group_name, def_text_color());
320 color_string(option_name, def_text_color());
321
322 // "make" strings bold
324 make_string_bold(group_name);
325
326 // add items
327 for (std::unique_ptr<ModelNode>& preset : m_preset_nodes)
328 if (preset->type() == type)
329 {
330 for (std::unique_ptr<ModelNode> &category : preset->GetChildren())
331 if (category->text() == category_name)
332 {
333 for (std::unique_ptr<ModelNode> &group : category->GetChildren())
334 if (group->text() == group_name)
335 return wxDataViewItem((void*)AddOption(group.get(), option_name, old_value, new_value));
336
337 return wxDataViewItem((void*)AddOptionWithGroup(category.get(), group_name, option_name, old_value, new_value));
338 }
339
340 return wxDataViewItem((void*)AddOptionWithGroupAndCategory(preset.get(), category_name, group_name, option_name, old_value, new_value, category_icon_name));
341 }
342
343 return wxDataViewItem(nullptr);
344}
ModelNode * AddOptionWithGroupAndCategory(ModelNode *preset_node, wxString category_name, wxString group_name, wxString option_name, wxString old_value, wxString new_value, const std::string category_icon_name)
Definition UnsavedChangesDialog.cpp:304
ModelNode * AddOption(ModelNode *group_node, wxString option_name, wxString old_value, wxString new_value)
Definition UnsavedChangesDialog.cpp:284
ModelNode * AddOptionWithGroup(ModelNode *category_node, wxString group_name, wxString option_name, wxString old_value, wxString new_value)
Definition UnsavedChangesDialog.cpp:295
ModelNodePtrArray m_preset_nodes
Definition UnsavedChangesDialog.hpp:138
static std::string def_text_color()
Definition UnsavedChangesDialog.cpp:97
static void make_string_bold(wxString &str)
Definition UnsavedChangesDialog.cpp:112
static void color_string(wxString &str, const std::string &color)
Definition UnsavedChangesDialog.cpp:105
static const char * category_name(AuditEventCategory category)
Definition PluginAuditManager.cpp:348

References AddOption(), AddOptionWithGroup(), AddOptionWithGroupAndCategory(), Slic3r::category_name(), Slic3r::GUI::color_string(), Slic3r::GUI::def_text_color(), m_preset_nodes, and Slic3r::GUI::make_string_bold().

Here is the call graph for this function:

◆ AddOptionWithGroup()

ModelNode * Slic3r::GUI::DiffModel::AddOptionWithGroup ( ModelNode * category_node,
wxString group_name,
wxString option_name,
wxString old_value,
wxString new_value )
private
296{
297 category_node->Append(std::make_unique<ModelNode>(category_node, group_name));
298 ModelNode* group_node = category_node->GetChildren().back().get();
299 ItemAdded(wxDataViewItem((void*)category_node), wxDataViewItem((void*)group_node));
300
301 return AddOption(group_node, option_name, old_value, new_value);
302}

References AddOption(), Slic3r::GUI::ModelNode::Append(), and Slic3r::GUI::ModelNode::GetChildren().

Referenced by AddOption(), and AddOptionWithGroupAndCategory().

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

◆ AddOptionWithGroupAndCategory()

ModelNode * Slic3r::GUI::DiffModel::AddOptionWithGroupAndCategory ( ModelNode * preset_node,
wxString category_name,
wxString group_name,
wxString option_name,
wxString old_value,
wxString new_value,
const std::string category_icon_name )
private
306{
307 preset_node->Append(std::make_unique<ModelNode>(preset_node, category_name, category_icon_name));
308 ModelNode* category_node = preset_node->GetChildren().back().get();
309 ItemAdded(wxDataViewItem((void*)preset_node), wxDataViewItem((void*)category_node));
310
311 return AddOptionWithGroup(category_node, group_name, option_name, old_value, new_value);
312}

References AddOptionWithGroup(), Slic3r::GUI::ModelNode::Append(), Slic3r::category_name(), and Slic3r::GUI::ModelNode::GetChildren().

Referenced by AddOption().

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

◆ AddPreset()

wxDataViewItem Slic3r::GUI::DiffModel::AddPreset ( Preset::Type type,
wxString preset_name,
PrinterTechnology pt )
269{
270 // "color" strings
271 color_string(preset_name, def_text_color());
272 make_string_bold(preset_name);
273
274 auto preset = new ModelNode(type, m_parent_win, preset_name, get_icon_name(type, pt));
275 m_preset_nodes.emplace_back(preset);
276
277 wxDataViewItem child((void*)preset);
278 wxDataViewItem parent(nullptr);
279
280 ItemAdded(parent, child);
281 return child;
282}
static std::string get_icon_name(Preset::Type type, PrinterTechnology pt)
Definition UnsavedChangesDialog.cpp:93

References Slic3r::GUI::color_string(), Slic3r::GUI::def_text_color(), Slic3r::GUI::get_icon_name(), m_parent_win, m_preset_nodes, and Slic3r::GUI::make_string_bold().

Here is the call graph for this function:

◆ Clear()

void Slic3r::GUI::DiffModel::Clear ( )
604{
605 while (!m_preset_nodes.empty())
606 Delete(wxDataViewItem(m_preset_nodes.back().get()));
607}
wxDataViewItem Delete(const wxDataViewItem &item)
Definition UnsavedChangesDialog.cpp:562

References Delete(), and m_preset_nodes.

Here is the call graph for this function:

◆ Delete()

wxDataViewItem Slic3r::GUI::DiffModel::Delete ( const wxDataViewItem & item)
563{
564 auto ret_item = wxDataViewItem(nullptr);
565 ModelNode* node = static_cast<ModelNode*>(item.GetID());
566 if (!node) // happens if item.IsOk()==false
567 return ret_item;
568
569 // first remove the node from the parent's array of children;
570 // NOTE: m_preset_nodes is only a vector of _pointers_
571 // thus removing the node from it doesn't result in freeing it
572 ModelNodePtrArray& children = node->GetChildren();
573 // Delete all children
574 while (!children.empty())
575 Delete(wxDataViewItem(children.back().get()));
576
577 auto node_parent = node->GetParent();
578 wxDataViewItem parent(node_parent);
579
580 ModelNodePtrArray& parents_children = node_parent ? node_parent->GetChildren() : m_preset_nodes;
581 auto it = find_if(parents_children.begin(), parents_children.end(),
582 [node](std::unique_ptr<ModelNode>& child) { return child.get() == node; });
583 assert(it != parents_children.end());
584 it = parents_children.erase(it);
585
586 if (it != parents_children.end())
587 ret_item = wxDataViewItem(it->get());
588
589 // set m_container to FALSE if parent has no child
590 if (node_parent) {
591#ifndef __WXGTK__
592 if (node_parent->GetChildCount() == 0)
593 node_parent->m_container = false;
594#endif //__WXGTK__
595 ret_item = parent;
596 }
597
598 // notify control
599 ItemDeleted(parent, item);
600 return ret_item;
601}
std::vector< std::unique_ptr< ModelNode > > ModelNodePtrArray
Definition UnsavedChangesDialog.hpp:45

References Delete(), Slic3r::GUI::ModelNode::GetChildren(), Slic3r::GUI::ModelNode::GetParent(), and m_preset_nodes.

Referenced by Clear(), and Delete().

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

◆ GetChildren()

unsigned int Slic3r::GUI::DiffModel::GetChildren ( const wxDataViewItem & parent,
wxDataViewItemArray & array ) const
override
519{
520 ModelNode* parent_node = (ModelNode*)parent.GetID();
521
522 const ModelNodePtrArray& children = parent_node ? parent_node->GetChildren() : m_preset_nodes;
523 for (const std::unique_ptr<ModelNode>& child : children)
524 array.Add(wxDataViewItem((void*)child.get()));
525
526 return array.Count();
527}

References Slic3r::GUI::ModelNode::GetChildren(), and m_preset_nodes.

Here is the call graph for this function:

◆ GetColumnCount()

unsigned int Slic3r::GUI::DiffModel::GetColumnCount ( ) const
inlineoverride
180{ return colMax; }

References colMax.

◆ GetColumnType()

wxString Slic3r::GUI::DiffModel::GetColumnType ( unsigned int col) const
override
531{
532 switch (col)
533 {
534 case colToggle:
535 return "bool";
536 case colIconText:
537 case colOldValue:
538 case colNewValue:
539 default:
540 return "DataViewBitmapText";//"string";
541 }
542}

References colIconText, colNewValue, colOldValue, and colToggle.

◆ GetParent()

wxDataViewItem Slic3r::GUI::DiffModel::GetParent ( const wxDataViewItem & item) const
override
495{
496 // the invisible root node has no parent
497 if (!item.IsOk())
498 return wxDataViewItem(nullptr);
499
500 ModelNode* node = static_cast<ModelNode*>(item.GetID());
501
502 if (node->IsRoot())
503 return wxDataViewItem(nullptr);
504
505 return wxDataViewItem((void*)node->GetParent());
506}

References Slic3r::GUI::ModelNode::GetParent(), and Slic3r::GUI::ModelNode::IsRoot().

Here is the call graph for this function:

◆ GetValue()

void Slic3r::GUI::DiffModel::GetValue ( wxVariant & variant,
const wxDataViewItem & item,
unsigned int col ) const
override
393{
394 assert(item.IsOk());
395
396 ModelNode* node = static_cast<ModelNode*>(item.GetID());
397 switch (col)
398 {
399 case colToggle:
400 variant = node->m_toggle;
401 break;
402#ifdef __linux__
403 case colIconText:
404 variant << wxDataViewIconText(node->m_text, node->m_icon);
405 break;
406 case colOldValue:
407 variant << wxDataViewIconText(node->m_old_value, node->m_old_color_bmp);
408 break;
409 case colNewValue:
410 variant << wxDataViewIconText(node->m_new_value, node->m_new_color_bmp);
411 break;
412#else
413 case colIconText:
414 variant << DataViewBitmapText(node->m_text, node->m_icon);
415 break;
416 case colOldValue:
417 variant << DataViewBitmapText(node->m_old_value, node->m_old_color_bmp);
418 break;
419 case colNewValue:
420 variant << DataViewBitmapText(node->m_new_value, node->m_new_color_bmp);
421 break;
422#endif //__linux__
423
424 default:
425 wxLogError("DiffModel::GetValue: wrong column %d", col);
426 }
427}

References colIconText, colNewValue, colOldValue, colToggle, Slic3r::GUI::ModelNode::m_icon, Slic3r::GUI::ModelNode::m_new_color_bmp, Slic3r::GUI::ModelNode::m_new_value, Slic3r::GUI::ModelNode::m_old_color_bmp, Slic3r::GUI::ModelNode::m_old_value, Slic3r::GUI::ModelNode::m_text, and Slic3r::GUI::ModelNode::m_toggle.

◆ HasContainerColumns()

bool Slic3r::GUI::DiffModel::HasContainerColumns ( const wxDataViewItem & WXUNUSEDitem) const
inlineoverride
197{ return true; }

◆ IsContainer()

bool Slic3r::GUI::DiffModel::IsContainer ( const wxDataViewItem & item) const
override
509{
510 // the invisble root node can have children
511 if (!item.IsOk())
512 return true;
513
514 ModelNode* node = static_cast<ModelNode*>(item.GetID());
515 return node->IsContainer();
516}

References Slic3r::GUI::ModelNode::IsContainer().

Here is the call graph for this function:

◆ IsEnabled()

bool Slic3r::GUI::DiffModel::IsEnabled ( const wxDataViewItem & item,
unsigned int col ) const
override
485{
486 assert(item.IsOk());
487 if (col == colToggle)
488 return true;
489
490 // disable unchecked nodes
491 return (static_cast<ModelNode*>(item.GetID()))->IsToggled();
492}

References colToggle.

◆ IsEnabledItem()

bool Slic3r::GUI::DiffModel::IsEnabledItem ( const wxDataViewItem & item)
386{
387 assert(item.IsOk());
388 ModelNode* node = static_cast<ModelNode*>(item.GetID());
389 return node->IsToggled();
390}

References Slic3r::GUI::ModelNode::IsToggled().

Here is the call graph for this function:

◆ Rescale()

void Slic3r::GUI::DiffModel::Rescale ( )
555{
556 for (std::unique_ptr<ModelNode> &node : m_preset_nodes) {
557 node->UpdateIcons();
558 rescale_children(node.get());
559 }
560}
static void rescale_children(ModelNode *parent)
Definition UnsavedChangesDialog.cpp:544

References m_preset_nodes, and Slic3r::GUI::rescale_children().

Here is the call graph for this function:

◆ SetAssociatedControl()

void Slic3r::GUI::DiffModel::SetAssociatedControl ( wxDataViewCtrl * ctrl)
inline
171{ m_ctrl = ctrl; }

References m_ctrl.

◆ SetValue()

bool Slic3r::GUI::DiffModel::SetValue ( const wxVariant & variant,
const wxDataViewItem & item,
unsigned int col )
override
430{
431 assert(item.IsOk());
432
433 ModelNode* node = static_cast<ModelNode*>(item.GetID());
434 switch (col)
435 {
436 case colToggle:
437 node->m_toggle = variant.GetBool();
438 return true;
439#ifdef __linux__
440 case colIconText: {
441 wxDataViewIconText data;
442 data << variant;
443 node->m_icon = data.GetIcon();
444 node->m_text = data.GetText();
445 return true; }
446 case colOldValue: {
447 wxDataViewIconText data;
448 data << variant;
449 node->m_old_color_bmp = data.GetIcon();
450 node->m_old_value = data.GetText();
451 return true; }
452 case colNewValue: {
453 wxDataViewIconText data;
454 data << variant;
455 node->m_new_color_bmp = data.GetIcon();
456 node->m_new_value = data.GetText();
457 return true; }
458#else
459 case colIconText: {
460 DataViewBitmapText data;
461 data << variant;
462 node->m_icon = data.GetBitmap();
463 node->m_text = data.GetText();
464 return true; }
465 case colOldValue: {
466 DataViewBitmapText data;
467 data << variant;
468 node->m_old_color_bmp = data.GetBitmap();
469 node->m_old_value = data.GetText();
470 return true; }
471 case colNewValue: {
472 DataViewBitmapText data;
473 data << variant;
474 node->m_new_color_bmp = data.GetBitmap();
475 node->m_new_value = data.GetText();
476 return true; }
477#endif //__linux__
478 default:
479 wxLogError("DiffModel::SetValue: wrong column");
480 }
481 return false;
482}
const wxBitmap & GetBitmap() const
Definition ExtraRenderers.hpp:52
wxString GetText() const
Definition ExtraRenderers.hpp:50

References colIconText, colNewValue, colOldValue, colToggle, DataViewBitmapText::GetBitmap(), DataViewBitmapText::GetText(), Slic3r::GUI::ModelNode::m_icon, Slic3r::GUI::ModelNode::m_new_color_bmp, Slic3r::GUI::ModelNode::m_new_value, Slic3r::GUI::ModelNode::m_old_color_bmp, Slic3r::GUI::ModelNode::m_old_value, Slic3r::GUI::ModelNode::m_text, and Slic3r::GUI::ModelNode::m_toggle.

Here is the call graph for this function:

◆ UpdateItemEnabling()

void Slic3r::GUI::DiffModel::UpdateItemEnabling ( wxDataViewItem item)
376{
377 assert(item.IsOk());
378 ModelNode* node = static_cast<ModelNode*>(item.GetID());
379 node->UpdateEnabling();
380
381 update_children(node);
382 update_parents(node);
383}
static void update_parents(ModelNode *node)
Definition UnsavedChangesDialog.cpp:358
static void update_children(ModelNode *parent)
Definition UnsavedChangesDialog.cpp:346

References Slic3r::GUI::update_children(), Slic3r::GUI::update_parents(), and Slic3r::GUI::ModelNode::UpdateEnabling().

Here is the call graph for this function:

Member Data Documentation

◆ m_ctrl

wxDataViewCtrl* Slic3r::GUI::DiffModel::m_ctrl { nullptr }
private
140{ nullptr };

Referenced by AddOption(), and SetAssociatedControl().

◆ m_parent_win

wxWindow* Slic3r::GUI::DiffModel::m_parent_win { nullptr }
private
137{ nullptr };

Referenced by DiffModel(), and AddPreset().

◆ m_preset_nodes

ModelNodePtrArray Slic3r::GUI::DiffModel::m_preset_nodes
private

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