diff --git a/src/slic3r/GUI/DailyTips.cpp b/src/slic3r/GUI/DailyTips.cpp index 69df98a01..5aba7762f 100644 --- a/src/slic3r/GUI/DailyTips.cpp +++ b/src/slic3r/GUI/DailyTips.cpp @@ -84,6 +84,12 @@ void DailyTipsDataRenderer::open_wiki() const if (!m_data.wiki_url.empty()) { wxGetApp().open_browser_with_warning_dialog(m_data.wiki_url); + NetworkAgent* agent = wxGetApp().getAgent(); + if (agent) { + json j; + j["dayil_tips"] = m_data.wiki_url; + agent->track_event("dayil_tips", j.dump()); + } } } diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index ac4223144..0423845b6 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2984,7 +2984,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt) //BBS: add orient deactivate logic if (keyCode == WXK_ESCAPE - && (_deactivate_arrange_menu() || _deactivate_orient_menu())) + && (_deactivate_arrange_menu() || _deactivate_orient_menu() || _deactivate_layersediting_menu())) return; if (m_gizmos.on_char(evt)) @@ -6242,6 +6242,7 @@ bool GLCanvas3D::_init_main_toolbar() return res; }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_layers_editing(); }; + item.left.toggable = true; if (!m_main_toolbar.add_item(item)) return false; @@ -7802,6 +7803,27 @@ void GLCanvas3D::_render_return_toolbar() const wxPostEvent(m_canvas, SimpleEvent(EVT_GLVIEWTOOLBAR_3D)); const_cast(&m_gizmos)->reset_all_states(); wxGetApp().plater()->get_view3D_canvas3D()->get_gizmos_manager().reset_all_states(); + { + GLCanvas3D* view_3d = wxGetApp().plater()->get_view3D_canvas3D(); + GLToolbarItem* assembly_item = view_3d->m_assemble_view_toolbar.get_item("assembly_view"); + std::chrono::system_clock::time_point end = std::chrono::system_clock::now(); + std::chrono::duration duration = std::chrono::duration_cast>(end - assembly_item->get_start_time_point()); + float times = duration.count(); + + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) { + std::string name = assembly_item->get_name() + "_duration"; + std::string value = ""; + float existing_time = 0; + + agent->track_get_property(name, value); + if (value != "") { + existing_time = std::stof(value); + } + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " tool name:" << name << " duration: " << times + existing_time; + agent->track_update_property(name, std::to_string(times + existing_time)); + } + } } ImGui::PopStyleColor(5); ImGui::PopStyleVar(1); diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index 6a78edd90..e185a13fc 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -96,6 +96,39 @@ GLToolbarItem::GLToolbarItem(GLToolbarItem::EType type, const GLToolbarItem::Dat render_left_pos = 0.0f; } +void GLToolbarItem::set_state(EState state) +{ + if (m_data.name == "arrange" || m_data.name == "layersediting" || m_data.name == "assembly_view") { + if (m_state == Hover && state == HoverPressed) { + start = std::chrono::system_clock::now(); + } + else if ((m_state == HoverPressed && state == Hover) || + (m_state == Pressed && state == Normal) || + (m_state == HoverPressed && state == Normal)) { + if (m_data.name != "assembly_view") { + std::chrono::system_clock::time_point end = std::chrono::system_clock::now(); + std::chrono::duration duration = std::chrono::duration_cast>(end - start); + float times = duration.count(); + + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) { + std::string name = m_data.name + "_duration"; + std::string value = ""; + float existing_time = 0; + + agent->track_get_property(name, value); + if (value != "") { + existing_time = std::stof(value); + } + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " tool name:" << name << " duration: " << times + existing_time; + agent->track_update_property(name, std::to_string(times + existing_time)); + } + } + } + } + m_state = state; +} + bool GLToolbarItem::update_visibility() { bool visible = m_data.visibility_callback(); diff --git a/src/slic3r/GUI/GLToolbar.hpp b/src/slic3r/GUI/GLToolbar.hpp index 09da22d3c..aaccd98f3 100644 --- a/src/slic3r/GUI/GLToolbar.hpp +++ b/src/slic3r/GUI/GLToolbar.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "GLTexture.hpp" #include "Event.hpp" @@ -57,7 +58,6 @@ wxDECLARE_EVENT(EVT_GLVIEWTOOLBAR_PREVIEW, SimpleEvent); wxDECLARE_EVENT(EVT_GLVIEWTOOLBAR_ASSEMBLE, SimpleEvent); - class GLToolbarItem { public: @@ -172,14 +172,19 @@ private: Data m_data; EActionType m_last_action_type; EHighlightState m_highlight_state; + std::chrono::system_clock::time_point start; + public: + // remember left position for rendering menu mutable float render_left_pos; + std::chrono::system_clock::time_point get_start_time_point() const { return start; } + GLToolbarItem(EType type, const Data& data); EState get_state() const { return m_state; } - void set_state(EState state) { m_state = state; } + void set_state(EState state); EHighlightState get_highlight() const { return m_highlight_state; } void set_highlight(EHighlightState state) { m_highlight_state = state; } diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 996fe2445..405cafeec 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -3964,6 +3964,11 @@ std::string GUI_App::handle_web_request(std::string cmd) boost::optional path = data_node.get_optional("url"); if (path.has_value()) { wxLaunchDefaultBrowser(path.value()); + if (m_agent) { + json j; + j["user_guide"] = path.value(); + m_agent->track_event("user_guide", j.dump()); + } } } } diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index 7a8fcdf4b..e5153b271 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -1294,6 +1294,10 @@ void MenuFactory::update() wxMenu* MenuFactory::default_menu() { + { + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) agent->track_update_property("default_menu", std::to_string(++default_menu_count)); + } return &m_default_menu; } @@ -1303,6 +1307,10 @@ wxMenu* MenuFactory::object_menu() append_menu_items_flush_options(&m_object_menu); append_menu_item_invalidate_cut_info(&m_object_menu); append_menu_item_change_filament(&m_object_menu); + { + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) agent->track_update_property("object_menu", std::to_string(++object_menu_count)); + } return &m_object_menu; } @@ -1311,7 +1319,10 @@ wxMenu* MenuFactory::sla_object_menu() append_menu_items_convert_unit(&m_sla_object_menu); append_menu_item_settings(&m_sla_object_menu); //update_menu_items_instance_manipulation(mtObjectSLA); - + { + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) agent->track_update_property("sla_object_menu", std::to_string(++sla_obj_menu_count)); + } return &m_sla_object_menu; } @@ -1320,16 +1331,28 @@ wxMenu* MenuFactory::part_menu() append_menu_items_convert_unit(&m_part_menu); append_menu_item_change_filament(&m_part_menu); append_menu_item_per_object_settings(&m_part_menu); + { + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) agent->track_update_property("part_menu", std::to_string(++part_menu_count)); + } return &m_part_menu; } wxMenu* MenuFactory::instance_menu() { + { + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) agent->track_update_property("instance_menu", std::to_string(++instance_menu_count)); + } return &m_instance_menu; } wxMenu* MenuFactory::layer_menu() { + { + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) agent->track_update_property("layer_menu", std::to_string(++layer_menu_count)); + } MenuWithSeparators* menu = new MenuWithSeparators(); append_menu_item_settings(menu); @@ -1392,6 +1415,11 @@ wxMenu* MenuFactory::multi_selection_menu() []() { return plater()->can_split(true); }, m_parent); } } + + { + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) agent->track_update_property("multi_selection_menu", std::to_string(++multi_selection_menu_count)); + } return menu; } @@ -1412,6 +1440,10 @@ wxMenu* MenuFactory::assemble_multi_selection_menu() append_menu_item_delete(menu); menu->AppendSeparator(); append_menu_item_change_extruder(menu); + { + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) agent->track_update_property("asseble_mulit_selection_menu", std::to_string(++assemble_mulit_selection_menu_count)); + } return menu; } @@ -1421,6 +1453,10 @@ wxMenu* MenuFactory::plate_menu() { append_menu_item_locked(&m_plate_menu); append_menu_item_plate_name(&m_plate_menu); + { + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) agent->track_update_property("plate_menu", std::to_string(++plate_menu_count)); + } return &m_plate_menu; } @@ -1441,6 +1477,10 @@ wxMenu* MenuFactory::assemble_object_menu() append_menu_item_change_extruder(menu); //// Enter per object parameters //append_menu_item_per_object_settings(menu); + { + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) agent->track_update_property("assemble_object_menu", std::to_string(++assemble_object_menu_ocunt)); + } return menu; } @@ -1455,6 +1495,10 @@ wxMenu* MenuFactory::assemble_part_menu() append_menu_item_change_extruder(menu); //append_menu_item_per_object_settings(menu); + { + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) agent->track_update_property("assemble_part_menu", std::to_string(++assemble_part_menu_count)); + } return menu; } diff --git a/src/slic3r/GUI/GUI_Factories.hpp b/src/slic3r/GUI/GUI_Factories.hpp index 31e6ef8c5..0164ef6af 100644 --- a/src/slic3r/GUI/GUI_Factories.hpp +++ b/src/slic3r/GUI/GUI_Factories.hpp @@ -93,7 +93,18 @@ private: MenuWithSeparators m_plate_menu; MenuWithSeparators m_assemble_object_menu; MenuWithSeparators m_assemble_part_menu; - + + int object_menu_count{ 0 }; + int part_menu_count{ 0 }; + int sla_obj_menu_count{ 0 }; + int default_menu_count{ 0 }; + int instance_menu_count{ 0 }; + int plate_menu_count{ 0 }; + int layer_menu_count{ 0 }; + int multi_selection_menu_count{ 0 }; + int assemble_object_menu_ocunt{ 0 }; + int assemble_part_menu_count{ 0 }; + int assemble_mulit_selection_menu_count{ 0 }; // Removed/Prepended Items according to the view mode std::array items_increase; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.hpp b/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.hpp index 0e274da38..f18754067 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoAdvancedCut.hpp @@ -225,6 +225,7 @@ protected: virtual void on_save(cereal::BinaryOutputArchive &ar) const override; virtual void data_changed(bool is_serializing) override; virtual std::string on_get_name() const; + virtual std::string on_get_name_str() override { return "Cut"; } virtual void on_set_state(); virtual bool on_is_activable() const; virtual CommonGizmosDataID on_get_requirements() const override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp index c9182d0ac..4e6553c25 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp @@ -166,6 +166,38 @@ GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, u m_cylinder.init_from(its_make_cylinder(1., 1., 2 * PI / 24.)); } +void GLGizmoBase::set_state(EState state) +{ + std::string name = on_get_name_str(); + if (name != "") { + if (m_state == Off && state == On) { + start = std::chrono::system_clock::now(); + } + else if (m_state == On && state == Off) { + std::chrono::system_clock::time_point end = std::chrono::system_clock::now(); + std::chrono::duration duration = std::chrono::duration_cast>(end - start); + float times = duration.count(); + + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) { + std::string full_name = name + "_duration"; + std::string value = ""; + float existing_time = 0; + + agent->track_get_property(full_name, value); + if (value != "") { + existing_time = std::stof(value); + } + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " tool name:" << full_name << " duration: " << times + existing_time; + agent->track_update_property(full_name, std::to_string(times + existing_time)); + } + } + } + + m_state = state; + on_set_state(); +} + void GLGizmoBase::set_icon_filename(const std::string &filename) { m_icon_filename = filename; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp index 76e78c018..6117e931c 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.hpp @@ -128,6 +128,8 @@ protected: bool m_is_dark_mode = false; + std::chrono::system_clock::time_point start; + public: GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, @@ -145,8 +147,7 @@ public: void set_group_id(int id) { m_group_id = id; } EState get_state() const { return m_state; } - void set_state(EState state) { m_state = state; on_set_state(); } - + void set_state(EState state); int get_shortcut_key() const { return m_shortcut_key; } const std::string& get_icon_filename() const { return m_icon_filename; } @@ -195,7 +196,6 @@ public: /// virtual void data_changed(bool is_serializing){}; int get_count() { return ++count; } - std::string get_gizmo_name() { return on_get_name(); } protected: float last_input_window_width = 0; @@ -203,6 +203,7 @@ protected: virtual void on_load(cereal::BinaryInputArchive& ar) {} virtual void on_save(cereal::BinaryOutputArchive& ar) const {} virtual std::string on_get_name() const = 0; + virtual std::string on_get_name_str() { return ""; } virtual void on_set_state() {} virtual void on_set_hover_id() {} virtual bool on_is_activable() const { return true; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFaceDetector.hpp b/src/slic3r/GUI/Gizmos/GLGizmoFaceDetector.hpp index c20cf4c20..4d199ad5d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFaceDetector.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFaceDetector.hpp @@ -19,6 +19,7 @@ protected: void on_render_for_picking() override {} void on_render_input_window(float x, float y, float bottom_limit) override; std::string on_get_name() const override; + std::string on_get_name_str() override { return "Face recognition"; } void on_set_state() override; bool on_is_activable() const override; CommonGizmosDataID on_get_requirements() const override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp index 6960a81dc..ee19b416b 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFdmSupports.hpp @@ -30,6 +30,7 @@ public: protected: void on_render_input_window(float x, float y, float bottom_limit) override; std::string on_get_name() const override; + std::string on_get_name_str() override { return "Supports Painting"; } // BBS void render_triangles(const Selection& selection) const override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFlatten.hpp b/src/slic3r/GUI/Gizmos/GLGizmoFlatten.hpp index ab3c2c7ba..b7f341c9e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFlatten.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFlatten.hpp @@ -51,6 +51,7 @@ public: protected: virtual bool on_init() override; virtual std::string on_get_name() const override; + virtual std::string on_get_name_str() override { return "Lay on face"; } virtual bool on_is_activable() const override; virtual void on_start_dragging() override; virtual void on_render() override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp b/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp index 2cf08de2a..cc9c14471 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoHollow.hpp @@ -97,6 +97,7 @@ protected: virtual CommonGizmosDataID on_get_requirements() const override; std::string on_get_name() const override; + virtual std::string on_get_name_str() override { return "Hollow and drill"; } bool on_is_activable() const override; bool on_is_selectable() const override; void on_load(cereal::BinaryInputArchive& ar) override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeshBoolean.hpp b/src/slic3r/GUI/Gizmos/GLGizmoMeshBoolean.hpp index 42fa97eed..66ca0d86b 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeshBoolean.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeshBoolean.hpp @@ -60,6 +60,7 @@ public: protected: virtual bool on_init() override; virtual std::string on_get_name() const override; + virtual std::string on_get_name_str() override { return "Mesh Boolean"; } virtual bool on_is_activable() const override; virtual void on_render() override; virtual void on_render_for_picking() override {} diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp index 6b5cde25c..a825be3a3 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp @@ -95,6 +95,7 @@ protected: void on_render_input_window(float x, float y, float bottom_limit) override; std::string on_get_name() const override; + std::string on_get_name_str() override { return "Color Painting"; } void show_tooltip_information(float caption_max, float x, float y); bool on_is_selectable() const override; bool on_is_activable() const override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMove.hpp b/src/slic3r/GUI/Gizmos/GLGizmoMove.hpp index 21d19b446..c772cbcd3 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMove.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMove.hpp @@ -44,6 +44,7 @@ public: protected: virtual bool on_init() override; virtual std::string on_get_name() const override; + std::string on_get_name_str() override { return "Move"; } virtual bool on_is_activable() const override; virtual void on_start_dragging() override; virtual void on_stop_dragging() override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp b/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp index 9862ec290..c59fef472 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp @@ -114,6 +114,7 @@ public: protected: bool on_init() override; std::string on_get_name() const override; + std::string on_get_name_str() override { return "Rotate"; } void on_set_state() override { for (GLGizmoRotate& g : m_gizmos) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoScale.hpp b/src/slic3r/GUI/Gizmos/GLGizmoScale.hpp index 839c7f682..a89189b88 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoScale.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoScale.hpp @@ -59,6 +59,7 @@ public: protected: virtual bool on_init() override; virtual std::string on_get_name() const override; + virtual std::string on_get_name_str() override { return "Scale"; } virtual bool on_is_activable() const override; virtual void on_start_dragging() override; virtual void on_update(const UpdateData& data) override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSeam.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSeam.hpp index 3f724deaf..12b19d462 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSeam.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSeam.hpp @@ -22,6 +22,7 @@ protected: wchar_t m_current_tool = 0; void on_render_input_window(float x, float y, float bottom_limit) override; std::string on_get_name() const override; + std::string on_get_name_str() override { return "Seam painting"; } PainterGizmoType get_painter_type() const override; void render_triangles(const Selection &selection) const override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.hpp index 39093e14d..be667e465 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.hpp @@ -29,6 +29,7 @@ public: protected: virtual std::string on_get_name() const override; + virtual std::string on_get_name_str() override { return "Simplify"; } virtual void on_render_input_window(float x, float y, float bottom_limit) override; virtual bool on_is_activable() const override; virtual bool on_is_selectable() const override { return false; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp index 8dd76336a..3c9871f33 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.hpp @@ -136,6 +136,7 @@ protected: void on_render_input_window(float x, float y, float bottom_limit) override; std::string on_get_name() const override; + std::string on_get_name_str() override { return "SLA Support Points"; } bool on_is_activable() const override; bool on_is_selectable() const override; virtual CommonGizmosDataID on_get_requirements() const override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoText.hpp b/src/slic3r/GUI/Gizmos/GLGizmoText.hpp index 53b792364..8196d2414 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoText.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoText.hpp @@ -89,6 +89,7 @@ public: protected: virtual bool on_init() override; virtual std::string on_get_name() const override; + virtual std::string on_get_name_str() override { return "Text shape"; } virtual bool on_is_activable() const override; virtual void on_render() override; virtual void on_render_for_picking() override; diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 22f9242af..6907d0409 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -529,6 +529,104 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_ j["assembly_view"] = value; agent->track_event("key_func", j.dump()); + + j.clear(); + value = ""; + agent->track_get_property("arrange_duration", value); + j["auto_arrange"] = value; + value = ""; + agent->track_get_property("layersediting_duration", value); + j["custom_height"] = value; + + value = ""; + agent->track_get_property("Move_duration", value); + j["move"] = value; + value = ""; + agent->track_get_property("Rotate_duration", value); + j["rotate"] = value; + agent->track_get_property("Scale_duration", value); + j["scale"] = value; + agent->track_get_property("Lay on face_duration", value); + j["flatten"] = value; + value = ""; + agent->track_get_property("Cut_duration", value); + j["cut"] = value; + value = ""; + agent->track_get_property("Mesh Boolean_duration", value); + j["mesh_boolean"] = value; + value = ""; + agent->track_get_property("Supports Painting_duration", value); + j["custom_support"] = value; + value = ""; + agent->track_get_property("Seam painting_duration", value); + j["custom_seam"] = value; + value = ""; + agent->track_get_property("Text shape_duration", value); + j["text_shape"] = value; + value = ""; + agent->track_get_property("Color Painting_duration", value); + j["color_painting"] = value; + value = ""; + agent->track_get_property("assembly_view_duration", value); + j["assembly_view"] = value; + + agent->track_event("key_func_duration", j.dump()); + + j.clear(); + value = ""; + agent->track_get_property("default_menu", value); + j["default_menu"] = value; + value = ""; + agent->track_get_property("object_menu", value); + j["object_menu"] = value; + value = ""; + agent->track_get_property("sla_object_menu", value); + j["sla_object_menu"] = value; + value = ""; + agent->track_get_property("part_menu", value); + j["part_menu"] = value; + value = ""; + agent->track_get_property("instance_menu", value); + j["instance_menu"] = value; + value = ""; + agent->track_get_property("layer_menu", value); + j["layer_menu"] = value; + value = ""; + agent->track_get_property("multi_selection_menu", value); + j["multi_selection_menu"] = value; + value = ""; + agent->track_get_property("plate_menu", value); + j["plate_menu"] = value; + value = ""; + agent->track_get_property("assemble_object_menu", value); + j["assemble_object_menu"] = value; + value = ""; + agent->track_get_property("assemble_part_menu", value); + j["assemble_part_menu"] = value; + value = ""; + agent->track_get_property("assemble_mulit_selection_menu", value); + j["assemble_mulit_selection_menu"] = value; + value = ""; + agent->track_event("menu_click", j.dump()); + + j.clear(); + value = ""; + agent->track_get_property("select_device_page", value); + j["device_page"] = value; + value = ""; + agent->track_get_property("Status", value); + j["status"] = value; + value = ""; + agent->track_get_property("MicroSD Card", value); + j["MicroSD_card"] = value; + value = ""; + agent->track_get_property("Update", value); + j["update"] = value; + value = ""; + agent->track_get_property("HMS", value); + j["HMS"] = value; + value = ""; + agent->track_event("device_ctrl", j.dump()); } } @@ -1070,6 +1168,9 @@ void MainFrame::init_tabpanel() // m_param_panel->OnActivate(); else if (panel == m_monitor) { //monitor + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) + agent->track_update_property("select_device_page", std::to_string(++select_device_page_count)); } #ifndef __APPLE__ if (sel == tp3DEditor) { diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index 6be554deb..da8071bc1 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -393,6 +393,8 @@ public: void update_side_button_style(); void update_slice_print_status(SlicePrintEventType event, bool can_slice = true, bool can_print = true); + int select_device_page_count{ 0 }; + #ifdef __APPLE__ std::unique_ptr m_taskbar_icon; #endif // __APPLE__ diff --git a/src/slic3r/GUI/Monitor.cpp b/src/slic3r/GUI/Monitor.cpp index 41b718534..e9863a37f 100644 --- a/src/slic3r/GUI/Monitor.cpp +++ b/src/slic3r/GUI/Monitor.cpp @@ -171,6 +171,26 @@ MonitorPanel::~MonitorPanel() m_media_file_panel->SwitchStorage(title == _L("SD Card")); } page->SetFocus(); + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << __LINE__ << " select :" << m_tabpanel->GetPageText(m_tabpanel->GetSelection()); + NetworkAgent* agent = GUI::wxGetApp().getAgent(); + if (agent) { + std::string name = m_tabpanel->GetPageText(m_tabpanel->GetSelection()).ToStdString(); + if (name != "") { + std::string value = ""; + agent->track_get_property(name, value); + int count = 0; + if (value != "") { + try { + count = std::stoi(value); + } + catch (...) { + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << __LINE__ << " String to integer error!"; + count = 0; + } + } + agent->track_update_property(name, std::to_string(++count)); + } + } }, m_tabpanel->GetId()); //m_status_add_machine_panel = new AddMachinePanel(m_tabpanel); diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index 3727184ef..dc04cb290 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -3002,6 +3002,39 @@ void PartPlate::print() const return; } +std::map PartPlate::get_diff_object_setting() +{ + std::map out; + for (auto it = obj_to_instance_set.cbegin(); it != obj_to_instance_set.cend(); ++it) { + const ModelConfigObject& different_object_config = m_model->objects[it->first]->config; + for (auto iter = different_object_config.cbegin(); iter != different_object_config.cend(); ++iter) { + std::string config_name = iter->first; + std::string config_value = iter->second->serialize(); + if (out.find(config_name) == out.end()) { + out[config_name] = config_value; + } + } + } + return out; +} + +std::map PartPlate::get_diff_plate_setting() +{ + std::map out; + for (auto it = m_config.cbegin(); it != m_config.cend(); ++it) { + std::string diff_config_name = it->first; + std::string diff_config_value; + if (diff_config_name == "first_layer_print_sequence") { + diff_config_value = "cutomize"; + } + else { + diff_config_value = it->second->serialize(); + } + out[diff_config_name] = diff_config_value; + } + return out; +} + /* PartPlate List related functions*/ PartPlateList::PartPlateList(int width, int depth, int height, Plater* platerObj, Model* modelObj, PrinterTechnology tech) :m_plate_width(width), m_plate_depth(depth), m_plate_height(height), m_plater(platerObj), m_model(modelObj), printer_technology(tech), diff --git a/src/slic3r/GUI/PartPlate.hpp b/src/slic3r/GUI/PartPlate.hpp index af93c3a02..49b57c0e6 100644 --- a/src/slic3r/GUI/PartPlate.hpp +++ b/src/slic3r/GUI/PartPlate.hpp @@ -482,6 +482,9 @@ public: void print() const; + std::map get_diff_object_setting(); + std::map get_diff_plate_setting(); + friend class cereal::access; friend class UndoRedo::StackImpl; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 874aa2bc5..a02ed6420 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2039,6 +2039,7 @@ struct Plater::priv bool m_need_update{false}; //BBS: add popup object table logic //ObjectTableDialog* m_popup_table{ nullptr }; + std::chrono::system_clock::time_point start; #if ENABLE_ENVIRONMENT_MAP GLTexture environment_texture; @@ -4082,6 +4083,31 @@ std::vector Plater::priv::load_files(const std::vector& input_ if (msg.ShowModal() == wxID_YES) {} } } + std::chrono::system_clock::time_point default_time; + if (start == default_time) { + start = std::chrono::system_clock::now(); + } + NetworkAgent* agent = wxGetApp().getAgent(); + if (agent) { + if (!input_files.empty()) { + auto path = input_files.front(); + std::string extension = path.extension().string(); + + std::string value = ""; + agent->track_get_property("file_type", value); + if (value == "") { + value = extension; + agent->track_update_property("file_type", value); + } + + if (model.model_info == nullptr) { + agent->track_update_property("is_mw", "false"); + } + else { + agent->track_update_property("is_mw", "true"); + } + } + } return obj_idxs; } @@ -8142,9 +8168,90 @@ void Plater::priv::record_start_print_preset(std::string action) { j["process_preset"] = print_preset.config.opt_string("inherits"); } + json j_system; + if (background_process.fff_print()) { + const DynamicPrintConfig& full_config = background_process.fff_print()->full_print_config(); + if (full_config.has("different_settings_to_system")) { + std::vector different_values = full_config.option("different_settings_to_system")->values; + std::vector values; + boost::split(values, different_values.front(), boost::is_any_of(";")); + for (int i = 0; i < values.size(); ++i) { + std::string str = values[i]; + const ConfigOption* config = full_config.option(str); + j_system[str] = config->serialize(); + } + } + } + j["global_diff"] = j_system; + + PartPlate* curr_plate = partplate_list.get_curr_plate(); + + json j_object; + if (action == "print_plate") { + std::map modify_object_setting = curr_plate->get_diff_object_setting(); + for (auto it = modify_object_setting.cbegin(); it != modify_object_setting.cend(); ++it) { + j_object[it->first] = it->second; + } + } + else { + for (int i = 0; i < model.objects.size(); ++i) { + const ModelConfigObject& diff_object_config = model.objects[i]->config; + for (auto it = diff_object_config.cbegin(); it != diff_object_config.cend(); ++it) { + std::string config_name = it->first; + std::string config_value = it->second->serialize(); + if (j_object.find(config_name) == j_object.end()) { + j_object[config_name] = config_value; + } + } + } + } + j["object_diff"] = j_object; + + json j_plate; + if (action == "print_plate") { + std::map diff_plate_setting = curr_plate->get_diff_plate_setting(); + for (auto it = diff_plate_setting.cbegin(); it != diff_plate_setting.cend(); ++it) { + j_plate["plate_" + std::to_string(curr_plate->get_index())][it->first] = it->second; + } + } + else { + for (int i = 0; i < plate_count; ++i) { + std::string key = "plate_" + std::to_string(i); + DynamicPrintConfig* diff_plate_config = partplate_list.get_plate(i)->config(); + for (auto it = diff_plate_config->cbegin(); it != diff_plate_config->cend(); ++it) { + std::string diff_config_name = it->first; + std::string diff_config_value; + if (diff_config_name == "first_layer_print_sequence") { + diff_config_value = "cutomize"; + } + else { + diff_config_value = it->second->serialize(); + } + j_plate[key][diff_config_name] = diff_config_value; + } + } + } + j["plate_diff"] = j_plate; + + json j_workflow_debug; + std::chrono::system_clock::time_point end = std::chrono::system_clock::now(); + std::chrono::duration duration = std::chrono::duration_cast>(end - start); + float times = duration.count(); + j_workflow_debug["duration"] = times; + j["record_event"] = action; NetworkAgent* agent = wxGetApp().getAgent(); - if (agent) agent->track_event("user_start_print", j.dump()); + if (agent) { + std::string value = ""; + agent->track_get_property("file_type", value); + j_workflow_debug["file_type"] = value; + value = ""; + agent->track_get_property("is_mw", value); + j_workflow_debug["is_mw"] = value; + + agent->track_event("user_start_print", j.dump()); + agent->track_event("workflow_debug", j_workflow_debug.dump()); + } } catch (...) { return; @@ -11318,8 +11425,10 @@ void Plater::record_slice_preset(std::string action) j["record_event"] = action; NetworkAgent* agent = wxGetApp().getAgent(); - if (agent) + if (agent) { agent->track_event("slice_completed", j.dump()); + agent->track_update_property("different_settings_to_system", j["different_set_to_system"]); + } } catch (...) {