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

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

Inheritance diagram for Slic3r::GUI::DiffViewCtrl:
Collaboration diagram for Slic3r::GUI::DiffViewCtrl:

Classes

struct  ItemData

Public Member Functions

 DiffViewCtrl (wxWindow *parent, wxSize size)
 ~DiffViewCtrl ()
void AppendBmpTextColumn (const wxString &label, unsigned model_column, int width, bool set_expander=false)
void AppendToggleColumn_ (const wxString &label, unsigned model_column, int width)
void Rescale (int em=0)
void Append (const std::string &opt_key, 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 Clear ()
wxString get_short_string (wxString full_string)
bool has_selection ()
void context_menu (wxDataViewEvent &event)
void item_value_changed (wxDataViewEvent &event)
void set_em_unit (int em)
bool has_unselected_options ()
std::vector< std::string > options (Preset::Type type, bool selected)
std::vector< std::string > selected_options ()

Public Attributes

DiffModel * model { nullptr }

Private Attributes

bool m_has_long_strings { false }
bool m_empty_selection { false }
int m_em_unit
std::map< wxDataViewItem, ItemData > m_items_map
std::map< unsigned int, int > m_columns_width

Detailed Description


Class Documentation

◆ Slic3r::GUI::DiffViewCtrl::ItemData

struct Slic3r::GUI::DiffViewCtrl::ItemData
Collaboration diagram for Slic3r::GUI::DiffViewCtrl::ItemData:
Class Members
bool is_long { false }
wxString new_val
wxString old_val
string opt_key
wxString opt_name
Type type

Constructor & Destructor Documentation

◆ DiffViewCtrl()

Slic3r::GUI::DiffViewCtrl::DiffViewCtrl ( wxWindow * parent,
wxSize size )
615 : wxDataViewCtrl(parent, wxID_ANY, wxDefaultPosition, size, wxDV_VARIABLE_LINE_HEIGHT | wxDV_ROW_LINES
616#ifdef _WIN32
617 | wxBORDER_SIMPLE
618#endif
619 ),
620 m_em_unit(em_unit(parent))
621{
622 SetBackgroundColour(wxColour("#FFFFFF"));
623 wxGetApp().UpdateDVCDarkUI(this);
624
625 model = new DiffModel(parent);
626 this->AssociateModel(model);
627 model->SetAssociatedControl(this);
628
629 this->Bind(wxEVT_DATAVIEW_ITEM_CONTEXT_MENU, &DiffViewCtrl::context_menu, this);
630 this->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, &DiffViewCtrl::context_menu, this);
631 this->Bind(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, &DiffViewCtrl::item_value_changed, this);
632}
void item_value_changed(wxDataViewEvent &event)
Definition UnsavedChangesDialog.cpp:752
int m_em_unit
Definition UnsavedChangesDialog.hpp:209
DiffModel * model
Definition UnsavedChangesDialog.hpp:229
void context_menu(wxDataViewEvent &event)
Definition UnsavedChangesDialog.cpp:714
int em_unit(wxWindow *win)
Definition wxExtensions.cpp:424

References context_menu(), em_unit(), item_value_changed(), m_em_unit, and model.

Here is the call graph for this function:

◆ ~DiffViewCtrl()

Slic3r::GUI::DiffViewCtrl::~DiffViewCtrl ( )
634 {
635 this->AssociateModel(nullptr);
636 delete model;
637}

References model.

Member Function Documentation

◆ Append()

void Slic3r::GUI::DiffViewCtrl::Append ( const std::string & opt_key,
Preset::Type type,
wxString category_name,
wxString group_name,
wxString option_name,
wxString old_value,
wxString new_value,
const std::string category_icon_name )
679{
680 ItemData item_data = { opt_key, option_name, old_value, new_value, type };
681
682 wxString old_val = get_short_string(item_data.old_val);
683 wxString new_val = get_short_string(item_data.new_val);
684 if (old_val != item_data.old_val || new_val != item_data.new_val)
685 item_data.is_long = true;
686
687 m_items_map.emplace(model->AddOption(type, category_name, group_name, option_name, old_val, new_val, category_icon_name), item_data);
688
689}
std::map< wxDataViewItem, ItemData > m_items_map
Definition UnsavedChangesDialog.hpp:222
wxString get_short_string(wxString full_string)
Definition UnsavedChangesDialog.cpp:697
Definition UnsavedChangesDialog.hpp:212
static const char * category_name(AuditEventCategory category)
Definition PluginAuditManager.cpp:348

References Slic3r::category_name(), get_short_string(), Slic3r::GUI::DiffViewCtrl::ItemData::is_long, m_items_map, model, Slic3r::GUI::DiffViewCtrl::ItemData::new_val, and Slic3r::GUI::DiffViewCtrl::ItemData::old_val.

Here is the call graph for this function:

◆ AppendBmpTextColumn()

void Slic3r::GUI::DiffViewCtrl::AppendBmpTextColumn ( const wxString & label,
unsigned model_column,
int width,
bool set_expander = false )
640{
641 m_columns_width.emplace(this->GetColumnCount(), width);
642#ifdef __linux__
643 wxDataViewIconTextRenderer* rd = new wxDataViewIconTextRenderer();
644#ifdef SUPPORTS_MARKUP
645 rd->EnableMarkup(true);
646#endif
647 wxDataViewColumn* column = new wxDataViewColumn(label, rd, model_column, width * m_em_unit, wxALIGN_TOP, wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_CELL_INERT);
648#else
649 wxDataViewColumn* column = new wxDataViewColumn(label, new BitmapTextRenderer(true, wxDATAVIEW_CELL_INERT), model_column, width * m_em_unit, wxALIGN_TOP, wxDATAVIEW_COL_RESIZABLE);
650#endif //__linux__
651 this->AppendColumn(column);
652 if (set_expander)
653 this->SetExpanderColumn(column);
654
655}
std::map< unsigned int, int > m_columns_width
Definition UnsavedChangesDialog.hpp:223

References m_columns_width, and m_em_unit.

◆ AppendToggleColumn_()

void Slic3r::GUI::DiffViewCtrl::AppendToggleColumn_ ( const wxString & label,
unsigned model_column,
int width )
658{
659 m_columns_width.emplace(this->GetColumnCount(), width);
660 AppendToggleColumn(label, model_column, wxDATAVIEW_CELL_ACTIVATABLE, width * m_em_unit);
661}

References m_columns_width, and m_em_unit.

◆ Clear()

void Slic3r::GUI::DiffViewCtrl::Clear ( )
692{
693 model->Clear();
694 m_items_map.clear();
695}

References m_items_map, and model.

◆ context_menu()

void Slic3r::GUI::DiffViewCtrl::context_menu ( wxDataViewEvent & event)
715{
717 return;
718
719 wxDataViewItem item = event.GetItem();
720 if (!item) {
721 wxPoint mouse_pos = wxGetMousePosition() - this->GetScreenPosition();
722 wxDataViewColumn* col = nullptr;
723 this->HitTest(mouse_pos, item, col);
724
725 if (!item)
726 item = this->GetSelection();
727
728 if (!item)
729 return;
730 }
731
732 auto it = m_items_map.find(item);
733 if (it == m_items_map.end() || !it->second.is_long)
734 return;
735
736 size_t column_cnt = this->GetColumnCount();
737 const wxString old_value_header = this->GetColumn(column_cnt - 2)->GetTitle();
738 const wxString new_value_header = this->GetColumn(column_cnt - 1)->GetTitle();
739 FullCompareDialog(it->second.opt_name, it->second.old_val, it->second.new_val,
740 old_value_header, new_value_header).ShowModal();
741
742#ifdef __WXOSX__
743 wxWindow* parent = this->GetParent();
744 if (parent && parent->IsShown()) {
745 // if this dialog is shown it have to be Hide and show again to be placed on the very Top of windows
746 parent->Hide();
747 parent->Show();
748 }
749#endif // __WXOSX__
750}
bool m_has_long_strings
Definition UnsavedChangesDialog.hpp:207

References m_has_long_strings, and m_items_map.

Referenced by DiffViewCtrl().

Here is the caller graph for this function:

◆ get_short_string()

wxString Slic3r::GUI::DiffViewCtrl::get_short_string ( wxString full_string)
698{
699 size_t max_len = 30;
700 if (full_string.IsEmpty() || full_string.StartsWith("#") ||
701 (full_string.Find("\n") == wxNOT_FOUND && full_string.Length() < max_len))
702 return full_string;
703
704 m_has_long_strings = true;
705
706 int n_pos = full_string.Find("\n");
707 if (n_pos != wxNOT_FOUND && n_pos < (int)max_len)
708 max_len = n_pos;
709
710 full_string.Truncate(max_len);
711 return full_string + dots;
712}
static wxString dots("...", wxConvUTF8)

References Slic3r::GUI::dots(), and m_has_long_strings.

Referenced by Append().

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

◆ has_selection()

bool Slic3r::GUI::DiffViewCtrl::has_selection ( )
inline
239{ return !m_empty_selection; }
bool m_empty_selection
Definition UnsavedChangesDialog.hpp:208

References m_empty_selection.

◆ has_unselected_options()

bool Slic3r::GUI::DiffViewCtrl::has_unselected_options ( )
767{
768 for (auto item : m_items_map)
769 if (!model->IsEnabledItem(item.first))
770 return true;
771
772 return false;
773}

References m_items_map, and model.

◆ item_value_changed()

void Slic3r::GUI::DiffViewCtrl::item_value_changed ( wxDataViewEvent & event)
753{
754 if (event.GetColumn() != DiffModel::colToggle)
755 return;
756
757 wxDataViewItem item = event.GetItem();
758
759 model->UpdateItemEnabling(item);
760 Refresh();
761
762 // update an enabling of the "save/move" buttons
764}
@ colToggle
Definition UnsavedChangesDialog.hpp:161
std::vector< std::string > selected_options()
Definition UnsavedChangesDialog.cpp:787

References Slic3r::GUI::DiffModel::colToggle, m_empty_selection, model, and selected_options().

Referenced by DiffViewCtrl().

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

◆ options()

std::vector< std::string > Slic3r::GUI::DiffViewCtrl::options ( Preset::Type type,
bool selected )
776{
777 std::vector<std::string> ret;
778
779 for (auto item : m_items_map) {
780 if (item.second.type == type && model->IsEnabledItem(item.first) == selected)
781 ret.emplace_back(get_pure_opt_key(item.second.opt_key));
782 }
783
784 return ret;
785}
std::string get_pure_opt_key(const std::string &opt_key)
Definition ConfigValueFormatter.cpp:24

References Slic3r::GUI::get_pure_opt_key(), m_items_map, and model.

Here is the call graph for this function:

◆ Rescale()

void Slic3r::GUI::DiffViewCtrl::Rescale ( int em = 0)
664{
665 if (em > 0) {
666 for (auto item : m_columns_width)
667 GetColumn(item.first)->SetWidth(item.second * em);
668 m_em_unit = em;
669 }
670
671 model->Rescale();
672 Refresh();
673}

References m_columns_width, m_em_unit, and model.

◆ selected_options()

std::vector< std::string > Slic3r::GUI::DiffViewCtrl::selected_options ( )
788{
789 std::vector<std::string> ret;
790
791 for (auto item : m_items_map)
792 if (model->IsEnabledItem(item.first))
793 ret.emplace_back(get_pure_opt_key(item.second.opt_key));
794
795 return ret;
796}

References Slic3r::GUI::get_pure_opt_key(), m_items_map, and model.

Referenced by item_value_changed().

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

◆ set_em_unit()

void Slic3r::GUI::DiffViewCtrl::set_em_unit ( int em)
inline
242{ m_em_unit = em; }

References m_em_unit.

Member Data Documentation

◆ m_columns_width

std::map<unsigned int, int> Slic3r::GUI::DiffViewCtrl::m_columns_width
private

◆ m_em_unit

int Slic3r::GUI::DiffViewCtrl::m_em_unit
private

◆ m_empty_selection

bool Slic3r::GUI::DiffViewCtrl::m_empty_selection { false }
private
208{ false };

Referenced by has_selection(), and item_value_changed().

◆ m_has_long_strings

bool Slic3r::GUI::DiffViewCtrl::m_has_long_strings { false }
private
207{ false };

Referenced by context_menu(), and get_short_string().

◆ m_items_map

std::map<wxDataViewItem, ItemData> Slic3r::GUI::DiffViewCtrl::m_items_map
private

◆ model


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