1st installment of project dirty state manager
This commit is contained in:
parent
04526d5c28
commit
144e37c274
7 changed files with 113 additions and 4 deletions
|
@ -58,5 +58,10 @@
|
|||
// Enable exporting lines M73 for remaining time to next printer stop to gcode
|
||||
#define ENABLE_EXTENDED_M73_LINES (1 && ENABLE_VALIDATE_CUSTOM_GCODE)
|
||||
|
||||
// Enable project dirty state manager
|
||||
#define ENABLE_PROJECT_DIRTY_STATE (1 && ENABLE_2_4_0_ALPHA0)
|
||||
// Enable project dirty state manager debug window
|
||||
#define ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW (1 && ENABLE_PROJECT_DIRTY_STATE)
|
||||
|
||||
|
||||
#endif // _prusaslicer_technologies_h_
|
||||
|
|
|
@ -189,6 +189,8 @@ set(SLIC3R_GUI_SOURCES
|
|||
GUI/UnsavedChangesDialog.hpp
|
||||
GUI/ExtraRenderers.cpp
|
||||
GUI/ExtraRenderers.hpp
|
||||
GUI/ProjectDirtyStateManager.hpp
|
||||
GUI/ProjectDirtyStateManager.cpp
|
||||
Utils/Http.cpp
|
||||
Utils/Http.hpp
|
||||
Utils/FixModelByWin10.cpp
|
||||
|
|
|
@ -1718,6 +1718,11 @@ void GLCanvas3D::render()
|
|||
}
|
||||
#endif // ENABLE_RENDER_STATISTICS
|
||||
|
||||
#if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
|
||||
if (wxGetApp().is_editor() && wxGetApp().plater()->is_view3D_shown())
|
||||
wxGetApp().plater()->render_project_state_debug_window();
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
|
||||
|
||||
#if ENABLE_CAMERA_STATISTICS
|
||||
camera.debug_render();
|
||||
#endif // ENABLE_CAMERA_STATISTICS
|
||||
|
|
|
@ -81,6 +81,9 @@
|
|||
#include "InstanceCheck.hpp"
|
||||
#include "NotificationManager.hpp"
|
||||
#include "PresetComboBoxes.hpp"
|
||||
#if ENABLE_PROJECT_DIRTY_STATE
|
||||
#include "ProjectDirtyStateManager.hpp"
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "Gizmos/GLGizmosManager.hpp"
|
||||
|
@ -1434,6 +1437,10 @@ struct Plater::priv
|
|||
Preview *preview;
|
||||
NotificationManager* notification_manager { nullptr };
|
||||
|
||||
#if ENABLE_PROJECT_DIRTY_STATE
|
||||
ProjectDirtyStateManager dirty_state;
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE
|
||||
|
||||
BackgroundSlicingProcess background_process;
|
||||
bool suppressed_backround_processing_update { false };
|
||||
|
||||
|
@ -1504,6 +1511,10 @@ struct Plater::priv
|
|||
priv(Plater *q, MainFrame *main_frame);
|
||||
~priv();
|
||||
|
||||
#if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
|
||||
void render_project_state_debug_window() const { dirty_state.render_debug_window(); }
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
|
||||
|
||||
enum class UpdateParams {
|
||||
FORCE_FULL_SCREEN_REFRESH = 1,
|
||||
FORCE_BACKGROUND_PROCESSING_UPDATE = 2,
|
||||
|
@ -4418,9 +4429,9 @@ Plater::Plater(wxWindow *parent, MainFrame *main_frame)
|
|||
// Initialization performed in the private c-tor
|
||||
}
|
||||
|
||||
Plater::~Plater()
|
||||
{
|
||||
}
|
||||
#if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
|
||||
void Plater::render_project_state_debug_window() const { p->render_project_state_debug_window(); }
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
|
||||
|
||||
Sidebar& Plater::sidebar() { return *p->sidebar; }
|
||||
Model& Plater::model() { return p->model; }
|
||||
|
|
|
@ -128,7 +128,11 @@ public:
|
|||
Plater(const Plater &) = delete;
|
||||
Plater &operator=(Plater &&) = delete;
|
||||
Plater &operator=(const Plater &) = delete;
|
||||
~Plater();
|
||||
~Plater() = default;
|
||||
|
||||
#if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
|
||||
void render_project_state_debug_window() const;
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
|
||||
|
||||
Sidebar& sidebar();
|
||||
Model& model();
|
||||
|
|
47
src/slic3r/GUI/ProjectDirtyStateManager.cpp
Normal file
47
src/slic3r/GUI/ProjectDirtyStateManager.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include "libslic3r/libslic3r.h"
|
||||
#include "ProjectDirtyStateManager.hpp"
|
||||
#include "ImGuiWrapper.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
|
||||
#if ENABLE_PROJECT_DIRTY_STATE
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
#if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
|
||||
void ProjectDirtyStateManager::render_debug_window() const
|
||||
{
|
||||
auto color = [](bool value) {
|
||||
return value ? ImVec4(1.0f, 0.49f, 0.216f, 1.0f) : ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
};
|
||||
auto text = [](bool value) {
|
||||
return value ? "true" : "false";
|
||||
};
|
||||
|
||||
std::string title = "Project dirty state statistics";
|
||||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||
imgui.begin(title, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||
|
||||
bool dirty = is_dirty();
|
||||
imgui.text_colored(color(dirty), "State:");
|
||||
ImGui::SameLine();
|
||||
imgui.text_colored(color(dirty), text(dirty));
|
||||
|
||||
ImGui::Separator();
|
||||
imgui.text_colored(color(m_state.plater), "Plater:");
|
||||
ImGui::SameLine();
|
||||
imgui.text_colored(color(m_state.plater), text(m_state.plater));
|
||||
|
||||
imgui.text_colored(color(m_state.presets), "Presets:");
|
||||
ImGui::SameLine();
|
||||
imgui.text_colored(color(m_state.presets), text(m_state.presets));
|
||||
|
||||
imgui.end();
|
||||
}
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE
|
||||
|
35
src/slic3r/GUI/ProjectDirtyStateManager.hpp
Normal file
35
src/slic3r/GUI/ProjectDirtyStateManager.hpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
#ifndef slic3r_ProjectDirtyStateManager_hpp_
|
||||
#define slic3r_ProjectDirtyStateManager_hpp_
|
||||
|
||||
#if ENABLE_PROJECT_DIRTY_STATE
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
class ProjectDirtyStateManager
|
||||
{
|
||||
struct DirtyState
|
||||
{
|
||||
bool plater{ false };
|
||||
bool presets{ false };
|
||||
|
||||
bool is_dirty() const { return plater || presets; }
|
||||
};
|
||||
|
||||
DirtyState m_state;
|
||||
|
||||
public:
|
||||
bool is_dirty() const { return m_state.is_dirty(); }
|
||||
|
||||
#if ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
|
||||
void render_debug_window() const;
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // ENABLE_PROJECT_DIRTY_STATE
|
||||
|
||||
#endif // slic3r_ProjectDirtyStateManager_hpp_
|
||||
|
Loading…
Add table
Reference in a new issue