mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	NotificationManager: Removed space reservation for "Slope visualization"
dialog, which is gone.
This commit is contained in:
		
							parent
							
								
									447f4b8303
								
							
						
					
					
						commit
						2aa76063a1
					
				
					 4 changed files with 33 additions and 43 deletions
				
			
		|  | @ -2088,7 +2088,7 @@ void GLCanvas3D::render() | |||
| 
 | ||||
|     wxGetApp().plater()->get_mouse3d_controller().render_settings_dialog(*this); | ||||
| 	 | ||||
| 	wxGetApp().plater()->get_notification_manager()->render_notifications(*this, get_overelay_window_width(), get_slope_window_width()); | ||||
| 	wxGetApp().plater()->get_notification_manager()->render_notifications(*this, get_overlay_window_width()); | ||||
| 
 | ||||
|     wxGetApp().imgui()->render(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -243,7 +243,7 @@ private: | |||
|         static bool bar_rect_contains(const GLCanvas3D& canvas, float x, float y); | ||||
|         static Rect get_bar_rect_screen(const GLCanvas3D& canvas); | ||||
|         static Rect get_bar_rect_viewport(const GLCanvas3D& canvas); | ||||
|         static float get_overelay_window_width() { return LayersEditing::s_overelay_window_width; } | ||||
|         static float get_overlay_window_width() { return LayersEditing::s_overelay_window_width; } | ||||
| 
 | ||||
|         float object_max_z() const { return m_object_max_z; } | ||||
| 
 | ||||
|  | @ -885,8 +885,7 @@ private: | |||
|     bool _activate_search_toolbar_item(); | ||||
|     bool _deactivate_collapse_toolbar_items(); | ||||
| 
 | ||||
|     float get_overelay_window_width() { return LayersEditing::get_overelay_window_width(); } | ||||
|     float get_slope_window_width()    { return Slope::get_window_width(); } | ||||
|     float get_overlay_window_width() { return LayersEditing::get_overlay_window_width(); } | ||||
| 
 | ||||
|     static std::vector<float> _parse_colors(const std::vector<std::string>& colors); | ||||
| 
 | ||||
|  |  | |||
|  | @ -12,13 +12,8 @@ | |||
| #include <wx/glcanvas.h> | ||||
| #include <iostream> | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| #define NOTIFICATION_MAX_MOVE 3.0f | ||||
| 
 | ||||
| #define GAP_WIDTH 10.0f | ||||
| #define SPACE_RIGHT_PANEL 10.0f | ||||
| static constexpr float GAP_WIDTH = 10.0f; | ||||
| static constexpr float SPACE_RIGHT_PANEL = 10.0f; | ||||
| 
 | ||||
| namespace Slic3r { | ||||
| namespace GUI { | ||||
|  | @ -28,7 +23,7 @@ wxDEFINE_EVENT(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED, ExportGcodeNotificationClic | |||
| wxDEFINE_EVENT(EVT_PRESET_UPDATE_AVAILABLE_CLICKED, PresetUpdateAvailableClickedEvent); | ||||
| 
 | ||||
| namespace Notifications_Internal{ | ||||
| 	void push_style_color(ImGuiCol idx, const ImVec4& col, bool fading_out, float current_fade_opacity) | ||||
| 	static inline void push_style_color(ImGuiCol idx, const ImVec4& col, bool fading_out, float current_fade_opacity) | ||||
| 	{ | ||||
| 		if (fading_out) | ||||
| 			ImGui::PushStyleColor(idx, ImVec4(col.x, col.y, col.z, col.w * current_fade_opacity)); | ||||
|  | @ -74,7 +69,7 @@ NotificationManager::PopNotification::PopNotification(const NotificationData &n, | |||
| { | ||||
| 	//init();
 | ||||
| } | ||||
| NotificationManager::PopNotification::RenderResult NotificationManager::PopNotification::render(GLCanvas3D& canvas, const float& initial_y, bool move_from_overlay, float overlay_width, bool move_from_slope, float slope_width) | ||||
| NotificationManager::PopNotification::RenderResult NotificationManager::PopNotification::render(GLCanvas3D& canvas, const float& initial_y, bool move_from_overlay, float overlay_width) | ||||
| { | ||||
| 	if (!m_initialized) { | ||||
| 		init(); | ||||
|  | @ -95,7 +90,7 @@ NotificationManager::PopNotification::RenderResult NotificationManager::PopNotif | |||
| 	ImGuiWrapper&   imgui = *wxGetApp().imgui(); | ||||
| 	bool            shown = true; | ||||
| 	ImVec2          mouse_pos = ImGui::GetMousePos(); | ||||
| 	float           right_gap = SPACE_RIGHT_PANEL + (move_from_overlay ? overlay_width + m_line_height * 5 : (move_from_slope ? slope_width /*+ m_line_height * 0.3f*/ : 0)); | ||||
| 	float           right_gap = SPACE_RIGHT_PANEL + (move_from_overlay ? overlay_width + m_line_height * 5 : 0); | ||||
| 
 | ||||
| 	if (m_line_height != ImGui::CalcTextSize("A").y) | ||||
| 		init(); | ||||
|  | @ -263,12 +258,9 @@ void NotificationManager::PopNotification::init() | |||
| } | ||||
| void NotificationManager::PopNotification::set_next_window_size(ImGuiWrapper& imgui) | ||||
| {  | ||||
| 	if (m_multiline) { | ||||
| 		m_window_height = m_lines_count * m_line_height; | ||||
| 	}else | ||||
| 	{ | ||||
| 		m_window_height = 2 * m_line_height; | ||||
| 	} | ||||
| 	m_window_height = m_multiline ? | ||||
| 		m_lines_count * m_line_height : | ||||
| 		2 * m_line_height; | ||||
| 	m_window_height += 1 * m_line_height; // top and bottom
 | ||||
| } | ||||
| 
 | ||||
|  | @ -622,14 +614,13 @@ void NotificationManager::SlicingCompleteLargeNotification::render_text(ImGuiWra | |||
| 		imgui.text(m_text1.c_str()); | ||||
| 
 | ||||
| 		render_hypertext(imgui, x_offset + text1_size.x + 4, cursor_y, m_hypertext); | ||||
| 		 | ||||
| 	} | ||||
| } | ||||
| void NotificationManager::SlicingCompleteLargeNotification::set_print_info(const std::string &info) | ||||
| { | ||||
| 	m_print_info = info; | ||||
| 	m_has_print_info = true; | ||||
| 	if(m_is_large) | ||||
| 	if (m_is_large) | ||||
| 		m_lines_count = 2; | ||||
| } | ||||
| void NotificationManager::SlicingCompleteLargeNotification::set_large(bool l) | ||||
|  | @ -813,17 +804,17 @@ bool NotificationManager::push_notification_data(std::unique_ptr<NotificationMan | |||
| 			return false; | ||||
| 		} | ||||
| 	} | ||||
| 	if (!this->find_older(notification.get())) { | ||||
| 			m_pop_notifications.emplace_back(std::move(notification)); | ||||
| 		canvas.request_extra_frame(); | ||||
| 		return true; | ||||
| 	} else { | ||||
| 	if (this->activate_existing(notification.get())) { | ||||
| 		m_pop_notifications.back()->update(notification->get_data()); | ||||
| 		canvas.request_extra_frame(); | ||||
| 		return false; | ||||
| 	} else { | ||||
| 		m_pop_notifications.emplace_back(std::move(notification)); | ||||
| 		canvas.request_extra_frame(); | ||||
| 		return true; | ||||
| 	} | ||||
| } | ||||
| void NotificationManager::render_notifications(GLCanvas3D& canvas, float overlay_width, float slope_width) | ||||
| void NotificationManager::render_notifications(GLCanvas3D& canvas, float overlay_width) | ||||
| { | ||||
| 	float    last_x = 0.0f; | ||||
| 	float    current_height = 0.0f; | ||||
|  | @ -837,7 +828,7 @@ void NotificationManager::render_notifications(GLCanvas3D& canvas, float overlay | |||
| 			it = m_pop_notifications.erase(it); | ||||
| 		} else { | ||||
| 			(*it)->set_paused(m_hovered); | ||||
| 			PopNotification::RenderResult res = (*it)->render(canvas, last_x, m_move_from_overlay, overlay_width, m_move_from_slope, slope_width); | ||||
| 			PopNotification::RenderResult res = (*it)->render(canvas, last_x, m_move_from_overlay, overlay_width); | ||||
| 			if (res != PopNotification::RenderResult::Finished) { | ||||
| 				last_x = (*it)->get_top() + GAP_WIDTH; | ||||
| 				current_height = std::max(current_height, (*it)->get_current_top()); | ||||
|  | @ -889,20 +880,20 @@ void NotificationManager::sort_notifications() | |||
| 		}); | ||||
| } | ||||
| 
 | ||||
| bool NotificationManager::find_older(NotificationManager::PopNotification* notification) | ||||
| bool NotificationManager::activate_existing(const NotificationManager::PopNotification* notification) | ||||
| { | ||||
| 	NotificationType type = notification->get_type(); | ||||
| 	std::string text = notification->get_data().text1; | ||||
| 	NotificationType   new_type = notification->get_type(); | ||||
| 	const std::string &new_text = notification->get_data().text1; | ||||
| 	for (auto it = m_pop_notifications.begin(); it != m_pop_notifications.end(); ++it) { | ||||
| 		if((*it)->get_type() == type && !(*it)->get_finished()) { | ||||
| 			if (type == NotificationType::CustomNotification || type == NotificationType::PlaterWarning) { | ||||
| 				if (!(*it)->compare_text(text)) | ||||
| 		if ((*it)->get_type() == new_type && !(*it)->get_finished()) { | ||||
| 			if (new_type == NotificationType::CustomNotification || new_type == NotificationType::PlaterWarning) { | ||||
| 				if (!(*it)->compare_text(new_text)) | ||||
| 					continue; | ||||
| 			}else if (type == NotificationType::SlicingWarning) { | ||||
| 			} else if (new_type == NotificationType::SlicingWarning) { | ||||
| 				auto w1 = dynamic_cast<SlicingWarningNotification*>(notification); | ||||
| 				auto w2 = dynamic_cast<SlicingWarningNotification*>(it->get()); | ||||
| 				if (w1 != nullptr && w2 != nullptr) { | ||||
| 					if (!(*it)->compare_text(text) || w1->object_id != w2->object_id) { | ||||
| 					if (!(*it)->compare_text(new_text) || w1->object_id != w2->object_id) { | ||||
| 						continue; | ||||
| 					} | ||||
| 				} else { | ||||
|  | @ -918,7 +909,7 @@ bool NotificationManager::find_older(NotificationManager::PopNotification* notif | |||
| 	return false; | ||||
| } | ||||
| 
 | ||||
| void NotificationManager::set_in_preview(bool preview)  | ||||
| void NotificationManager::set_in_preview(bool preview) | ||||
| {  | ||||
|     m_in_preview = preview; | ||||
|     for (std::unique_ptr<PopNotification> ¬ification : m_pop_notifications) { | ||||
|  | @ -926,6 +917,7 @@ void NotificationManager::set_in_preview(bool preview) | |||
|             notification->hide(preview);      | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| bool NotificationManager::has_slicing_error_notification() | ||||
| { | ||||
| 	return std::any_of(m_pop_notifications.begin(), m_pop_notifications.end(), [](auto &n) { | ||||
|  |  | |||
|  | @ -107,7 +107,7 @@ public: | |||
| 	// the "slicing info" normally shown at the side bar.
 | ||||
| 	void set_slicing_complete_large(bool large); | ||||
| 	// renders notifications in queue and deletes expired ones
 | ||||
| 	void render_notifications(GLCanvas3D& canvas, float overlay_width, float slope_width); | ||||
| 	void render_notifications(GLCanvas3D& canvas, float overlay_width); | ||||
| 	// finds and closes all notifications of given type
 | ||||
| 	void close_notification_of_type(const NotificationType type); | ||||
| 	// Which view is active? Plater or G-code preview? Hide warnings in G-code preview.
 | ||||
|  | @ -154,7 +154,7 @@ private: | |||
| 		}; | ||||
| 		PopNotification(const NotificationData &n, NotificationIDProvider &id_provider, wxEvtHandler* evt_handler); | ||||
| 		virtual ~PopNotification() { if (m_id) m_id_provider.release_id(m_id); } | ||||
| 		RenderResult           render(GLCanvas3D& canvas, const float& initial_y, bool move_from_overlay, float overlay_width, bool move_from_slope, float slope_width); | ||||
| 		RenderResult           render(GLCanvas3D& canvas, const float& initial_y, bool move_from_overlay, float overlay_width); | ||||
| 		// close will dissapear notification on next render
 | ||||
| 		void                   close() { m_close_pending = true; } | ||||
| 		// data from newer notification of same type
 | ||||
|  | @ -279,7 +279,7 @@ private: | |||
| 	bool push_notification_data(const NotificationData& notification_data, GLCanvas3D& canvas, int timestamp); | ||||
| 	bool push_notification_data(std::unique_ptr<NotificationManager::PopNotification> notification, GLCanvas3D& canvas, int timestamp); | ||||
| 	//finds older notification of same type and moves it to the end of queue. returns true if found
 | ||||
| 	bool find_older(NotificationManager::PopNotification* notification); | ||||
| 	bool activate_existing(const NotificationManager::PopNotification* notification); | ||||
| 	// Put the more important notifications to the bottom of the list.
 | ||||
| 	void sort_notifications(); | ||||
| 	// If there is some error notification active, then the "Export G-code" notification after the slicing is finished is suppressed.
 | ||||
|  | @ -292,11 +292,10 @@ private: | |||
| 	std::deque<std::unique_ptr<PopNotification>> m_pop_notifications; | ||||
| 	long                         m_last_time { 0 }; | ||||
| 	bool                         m_hovered { false }; | ||||
| 	//timestamps used for slining finished - notification could be gone so it needs to be stored here
 | ||||
| 	//timestamps used for slicing finished - notification could be gone so it needs to be stored here
 | ||||
| 	std::unordered_set<int>      m_used_timestamps; | ||||
| 	bool                         m_in_preview { false }; | ||||
| 	bool                         m_move_from_overlay { false }; | ||||
| 	bool                         m_move_from_slope { false }; | ||||
| 
 | ||||
| 	//prepared (basic) notifications
 | ||||
| 	const std::vector<NotificationData> basic_notifications = { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vojtech Bubnik
						Vojtech Bubnik