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

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

Collaboration diagram for Slic3r::GUI::ProjectDirtyStateManager:

Classes

class  NotificationSuppressor

Public Member Functions

void update_from_undo_redo_stack (bool dirty)
void update_from_presets ()
void reset_after_save ()
void reset_initial_presets ()
void set_plater_dirty (bool is_dirty)
bool is_dirty () const
bool is_presets_dirty () const

Private Member Functions

void notify_dirty_change (bool was_dirty, const char *source)
void begin_suppress_notifications ()
void end_suppress_notifications ()

Private Attributes

bool m_plater_dirty { false }
bool m_presets_dirty { false }
bool m_project_config_dirty { false }
int m_suppress_depth { 0 }
bool m_suppress_entry_dirty { false }
std::array< std::string, Preset::TYPE_COUNT > m_initial_presets
DynamicPrintConfig m_initial_project_config
std::vector< std::string > m_initial_filament_presets_names
std::vector< std::string > m_initial_filament_presets_colors

Detailed Description

Member Function Documentation

◆ begin_suppress_notifications()

void Slic3r::GUI::ProjectDirtyStateManager::begin_suppress_notifications ( )
private
95{
96 if (m_suppress_depth == 0)
99}
bool is_dirty() const
Definition ProjectDirtyStateManager.hpp:23
int m_suppress_depth
Definition ProjectDirtyStateManager.hpp:56
bool m_suppress_entry_dirty
Definition ProjectDirtyStateManager.hpp:57

References is_dirty(), m_suppress_depth, and m_suppress_entry_dirty.

Here is the call graph for this function:

◆ end_suppress_notifications()

void Slic3r::GUI::ProjectDirtyStateManager::end_suppress_notifications ( )
private
102{
103 assert(m_suppress_depth > 0);
104 if (m_suppress_depth > 0)
106 if (m_suppress_depth == 0)
108}
void notify_dirty_change(bool was_dirty, const char *source)
Definition ProjectDirtyStateManager.cpp:78

References m_suppress_depth, m_suppress_entry_dirty, and notify_dirty_change().

Here is the call graph for this function:

◆ is_dirty()

bool Slic3r::GUI::ProjectDirtyStateManager::is_dirty ( ) const
inline
bool m_project_config_dirty
Definition ProjectDirtyStateManager.hpp:54
bool m_plater_dirty
Definition ProjectDirtyStateManager.hpp:50
bool m_presets_dirty
Definition ProjectDirtyStateManager.hpp:52

References m_plater_dirty, m_presets_dirty, and m_project_config_dirty.

Referenced by begin_suppress_notifications(), notify_dirty_change(), reset_after_save(), set_plater_dirty(), update_from_presets(), and update_from_undo_redo_stack().

Here is the caller graph for this function:

◆ is_presets_dirty()

bool Slic3r::GUI::ProjectDirtyStateManager::is_presets_dirty ( ) const
inline
24{ return m_presets_dirty; }

References m_presets_dirty.

◆ notify_dirty_change()

void Slic3r::GUI::ProjectDirtyStateManager::notify_dirty_change ( bool was_dirty,
const char * source )
private
79{
80 if (m_suppress_depth > 0)
81 return;
82
83 const bool dirty = is_dirty();
84 if (was_dirty == dirty)
85 return;
86
87 LifecycleEventContext ctx;
88 ctx.code = LifecycleEvtCode::Ok;
89 ctx.dirty = dirty;
90 ctx.source = source;
92}
@ ProjectDirtyChanged
Definition LifecycleEvents.hpp:26
@ Ok
Definition LifecycleEvents.hpp:68
void fire_lifecycle_event(LifecycleEvent event, const LifecycleEventContext &ctx)
Definition LifecycleEvents.hpp:234

References Slic3r::LifecycleEventContext::code, Slic3r::LifecycleEventContext::dirty, Slic3r::fire_lifecycle_event(), is_dirty(), m_suppress_depth, Slic3r::Ok, Slic3r::ProjectDirtyChanged, and Slic3r::LifecycleEventContext::source.

Referenced by end_suppress_notifications(), reset_after_save(), set_plater_dirty(), update_from_presets(), and update_from_undo_redo_stack().

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

◆ reset_after_save()

void Slic3r::GUI::ProjectDirtyStateManager::reset_after_save ( )
68{
69 const bool was_dirty = is_dirty();
71 m_plater_dirty = false;
72 m_presets_dirty = false;
74 notify_dirty_change(was_dirty, "save");
75 wxGetApp().mainframe->update_title();
76}
void reset_initial_presets()
Definition ProjectDirtyStateManager.cpp:110

References is_dirty(), m_plater_dirty, m_presets_dirty, m_project_config_dirty, notify_dirty_change(), and reset_initial_presets().

Here is the call graph for this function:

◆ reset_initial_presets()

void Slic3r::GUI::ProjectDirtyStateManager::reset_initial_presets ( )
111{
112 m_initial_presets.fill(std::string{});
113 GUI_App &app = wxGetApp();
114 for (const auto &[type, name] : app.get_selected_presets()) {
115 if (type == Preset::Type::TYPE_FILAMENT) {
116 m_initial_filament_presets_names = wxGetApp().preset_bundle->filament_presets;
117 if (ConfigOption *color_option = wxGetApp().preset_bundle->project_config.option("filament_colour")) {
118 auto colors = static_cast<ConfigOptionStrings *>(color_option->clone());
119 m_initial_filament_presets_colors = colors->values;
120 delete colors;
121 }
122 } else {
123 m_initial_presets[type] = name;
124 }
125 }
126 m_initial_project_config = app.preset_bundle->project_config;
127}
std::vector< std::string > m_initial_filament_presets_colors
Definition ProjectDirtyStateManager.hpp:64
DynamicPrintConfig m_initial_project_config
Definition ProjectDirtyStateManager.hpp:60
std::vector< std::string > m_initial_filament_presets_names
Definition ProjectDirtyStateManager.hpp:63
std::array< std::string, Preset::TYPE_COUNT > m_initial_presets
Definition ProjectDirtyStateManager.hpp:59
@ TYPE_FILAMENT
Definition Preset.hpp:248

References Slic3r::GUI::GUI_App::get_selected_presets(), m_initial_filament_presets_colors, m_initial_filament_presets_names, m_initial_presets, m_initial_project_config, Slic3r::GUI::GUI_App::preset_bundle, Slic3r::PresetBundle::project_config, and Slic3r::Preset::TYPE_FILAMENT.

Referenced by reset_after_save().

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

◆ set_plater_dirty()

void Slic3r::GUI::ProjectDirtyStateManager::set_plater_dirty ( bool is_dirty)
33{
34 const bool was_dirty = this->is_dirty();
36 notify_dirty_change(was_dirty, "plater");
37}

References is_dirty(), m_plater_dirty, and notify_dirty_change().

Here is the call graph for this function:

◆ update_from_presets()

void Slic3r::GUI::ProjectDirtyStateManager::update_from_presets ( )
40{
41 const bool was_dirty = is_dirty();
42 m_presets_dirty = false;
43 // check switching of the presets only for exist/loaded project, but not for new
44 GUI_App &app = wxGetApp();
45 if (!app.plater()->get_project_filename().IsEmpty()) {
46 for (const auto &[type, name] : app.get_selected_presets()) {
47 if (type == Preset::Type::TYPE_FILAMENT) {
48 m_presets_dirty |= m_initial_filament_presets_names != wxGetApp().preset_bundle->filament_presets;
49 if (ConfigOption *color_option = wxGetApp().preset_bundle->project_config.option("filament_colour")) {
50 auto colors = static_cast<ConfigOptionStrings *>(color_option->clone());
52 delete colors;
53 }
54 } else {
55 m_presets_dirty |= !m_initial_presets[type].empty() && m_initial_presets[type] != name;
56 }
57 }
58 } else {
59 BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "project file name is empty";
60 }
61 m_presets_dirty |= app.has_unsaved_preset_changes();
62 m_project_config_dirty = m_initial_project_config != app.preset_bundle->project_config;
63 notify_dirty_change(was_dirty, "presets");
64 app.mainframe->update_title();
65}

References Slic3r::GUI::Plater::get_project_filename(), Slic3r::GUI::GUI_App::get_selected_presets(), Slic3r::GUI::GUI_App::has_unsaved_preset_changes(), is_dirty(), m_initial_filament_presets_colors, m_initial_filament_presets_names, m_initial_presets, m_initial_project_config, m_presets_dirty, m_project_config_dirty, Slic3r::GUI::GUI_App::mainframe, notify_dirty_change(), Slic3r::GUI::GUI_App::plater(), Slic3r::GUI::GUI_App::preset_bundle, Slic3r::PresetBundle::project_config, Slic3r::Preset::TYPE_FILAMENT, and Slic3r::GUI::MainFrame::update_title().

Here is the call graph for this function:

◆ update_from_undo_redo_stack()

void Slic3r::GUI::ProjectDirtyStateManager::update_from_undo_redo_stack ( bool dirty)
24{
25 const bool was_dirty = is_dirty();
26 m_plater_dirty = dirty;
27 notify_dirty_change(was_dirty, "undo_redo");
28 if (const Plater *plater = wxGetApp().plater(); plater && wxGetApp().initialized())
29 wxGetApp().mainframe->update_title();
30}
static Plater * plater()
Definition GUI_Factories.cpp:400
@ Plater
Definition Shortcuts.hpp:21

References is_dirty(), m_plater_dirty, notify_dirty_change(), and Slic3r::GUI::plater().

Here is the call graph for this function:

Member Data Documentation

◆ m_initial_filament_presets_colors

std::vector<std::string> Slic3r::GUI::ProjectDirtyStateManager::m_initial_filament_presets_colors
private

◆ m_initial_filament_presets_names

std::vector<std::string> Slic3r::GUI::ProjectDirtyStateManager::m_initial_filament_presets_names
private

◆ m_initial_presets

std::array<std::string, Preset::TYPE_COUNT> Slic3r::GUI::ProjectDirtyStateManager::m_initial_presets
private

◆ m_initial_project_config

DynamicPrintConfig Slic3r::GUI::ProjectDirtyStateManager::m_initial_project_config
private

◆ m_plater_dirty

bool Slic3r::GUI::ProjectDirtyStateManager::m_plater_dirty { false }
private

◆ m_presets_dirty

bool Slic3r::GUI::ProjectDirtyStateManager::m_presets_dirty { false }
private

◆ m_project_config_dirty

bool Slic3r::GUI::ProjectDirtyStateManager::m_project_config_dirty { false }
private
54{ false };

Referenced by is_dirty(), reset_after_save(), and update_from_presets().

◆ m_suppress_depth

int Slic3r::GUI::ProjectDirtyStateManager::m_suppress_depth { 0 }
private

◆ m_suppress_entry_dirty

bool Slic3r::GUI::ProjectDirtyStateManager::m_suppress_entry_dirty { false }
private

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