2020-08-03 13:36:55 +00:00
# ifndef slic3r_GUI_NotificationManager_hpp_
# define slic3r_GUI_NotificationManager_hpp_
# include "Event.hpp"
# include "I18N.hpp"
2020-10-14 14:48:56 +00:00
# include <libslic3r/ObjectID.hpp>
2020-12-04 23:02:23 +00:00
# include <libslic3r/Technologies.hpp>
# include <wx/time.h>
2020-10-14 14:48:56 +00:00
2020-08-03 13:36:55 +00:00
# include <string>
# include <vector>
# include <deque>
# include <unordered_set>
namespace Slic3r {
namespace GUI {
using EjectDriveNotificationClickedEvent = SimpleEvent ;
wxDECLARE_EVENT ( EVT_EJECT_DRIVE_NOTIFICAION_CLICKED , EjectDriveNotificationClickedEvent ) ;
using ExportGcodeNotificationClickedEvent = SimpleEvent ;
wxDECLARE_EVENT ( EVT_EXPORT_GCODE_NOTIFICAION_CLICKED , ExportGcodeNotificationClickedEvent ) ;
2020-10-14 10:57:40 +00:00
using PresetUpdateAvailableClickedEvent = SimpleEvent ;
wxDECLARE_EVENT ( EVT_PRESET_UPDATE_AVAILABLE_CLICKED , PresetUpdateAvailableClickedEvent ) ;
2020-08-03 13:36:55 +00:00
class GLCanvas3D ;
class ImGuiWrapper ;
enum class NotificationType
{
CustomNotification ,
2020-10-14 10:57:40 +00:00
// Notification on end of slicing and G-code processing (the full G-code preview is available).
// Contains a hyperlink to export the G-code to a removable media.
2020-08-03 13:36:55 +00:00
SlicingComplete ,
2020-10-14 12:18:04 +00:00
// SlicingNotPossible,
2020-10-14 10:57:40 +00:00
// Notification on end of export to a removable media, with hyperling to eject the external media.
2020-11-04 08:23:47 +00:00
// Obsolete by ExportFinished
// ExportToRemovableFinished,
// Notification on end of export, with hyperling to see folder and eject if export was to external media.
// Own subclass.
ExportFinished ,
2020-10-14 10:57:40 +00:00
// Works on OSX only.
//FIXME Do we want to have it on Linux and Windows? Is it possible to get the Disconnect event on Windows?
2020-08-03 13:36:55 +00:00
Mouse3dDisconnected ,
2020-10-14 12:18:04 +00:00
// Mouse3dConnected,
// NewPresetsAviable,
2020-10-14 10:57:40 +00:00
// Notification on the start of PrusaSlicer, when a new PrusaSlicer version is published.
// Contains a hyperlink to open a web browser pointing to the PrusaSlicer download location.
2020-10-15 07:56:33 +00:00
NewAppAvailable ,
2020-10-14 10:57:40 +00:00
// Notification on the start of PrusaSlicer, when updates of system profiles are detected.
// Contains a hyperlink to execute installation of the new system profiles.
PresetUpdateAvailable ,
2020-10-14 12:18:04 +00:00
// LoadingFailed,
2020-10-14 10:57:40 +00:00
// Not used - instead Slicing error is used for both slicing and validate errors.
2020-10-14 12:18:04 +00:00
// ValidateError,
2020-10-14 10:57:40 +00:00
// Slicing error produced by BackgroundSlicingProcess::validate() or by the BackgroundSlicingProcess background
// thread thowing a SlicingError exception.
2020-08-03 13:36:55 +00:00
SlicingError ,
2020-10-14 10:57:40 +00:00
// Slicing warnings, issued by the slicing process.
2020-10-14 12:18:04 +00:00
// Slicing warnings are registered for a particular Print milestone or a PrintObject and its milestone.
2020-08-03 13:36:55 +00:00
SlicingWarning ,
2020-10-14 12:18:04 +00:00
// Object partially outside the print volume. Cannot slice.
2020-08-03 13:36:55 +00:00
PlaterError ,
2020-10-14 12:18:04 +00:00
// Object fully outside the print volume, or extrusion outside the print volume. Slicing is not disabled.
2020-11-10 08:20:39 +00:00
PlaterWarning ,
// Progress bar instead of text.
2020-12-09 10:36:25 +00:00
ProgressBar ,
// Notification, when Color Change G-code is empty and user try to add color change on DoubleSlider.
2020-12-14 13:23:05 +00:00
EmptyColorChangeCode ,
// Notification that custom supports/seams were deleted after mesh repair.
2021-02-23 17:46:05 +00:00
CustomSupportsAndSeamRemovedAfterRepair ,
// Notification that auto adding of color changes is impossible
EmptyAutoColorChange
2020-08-03 13:36:55 +00:00
} ;
2020-10-13 13:32:41 +00:00
2020-08-03 13:36:55 +00:00
class NotificationManager
{
public :
enum class NotificationLevel : int
{
2020-10-15 07:56:33 +00:00
// The notifications will be presented in the order of importance, thus these enum values
// are sorted by the importance.
// "Good to know" notification, usually but not always with a quick fade-out.
RegularNotification = 1 ,
// Information notification without a fade-out or with a longer fade-out.
ImportantNotification ,
2020-11-10 08:20:39 +00:00
// Important notification with progress bar, no fade-out, might appear again after closing.
ProgressBarNotification ,
2020-10-15 07:56:33 +00:00
// Warning, no fade-out.
WarningNotification ,
// Error, no fade-out.
ErrorNotification ,
2020-08-03 13:36:55 +00:00
} ;
2020-10-13 13:32:41 +00:00
NotificationManager ( wxEvtHandler * evt_handler ) ;
2020-10-15 07:20:05 +00:00
// Push a prefabricated notification from basic_notifications (see the table at the end of this file).
2020-11-30 12:45:17 +00:00
void push_notification ( const NotificationType type , int timestamp = 0 ) ;
2020-10-15 07:20:05 +00:00
// Push a NotificationType::CustomNotification with NotificationLevel::RegularNotification and 10s fade out interval.
2020-11-30 12:45:17 +00:00
void push_notification ( const std : : string & text , int timestamp = 0 ) ;
2020-10-15 07:20:05 +00:00
// Push a NotificationType::CustomNotification with provided notification level and 10s for RegularNotification.
// ErrorNotification and ImportantNotification are never faded out.
2020-12-14 13:23:05 +00:00
void push_notification ( NotificationType type , NotificationLevel level , const std : : string & text , const std : : string & hypertext = " " ,
std : : function < bool ( wxEvtHandler * ) > callback = std : : function < bool ( wxEvtHandler * ) > ( ) , int timestamp = 0 ) ;
2020-10-15 07:20:05 +00:00
// Creates Slicing Error notification with a custom text and no fade out.
2020-11-30 12:45:17 +00:00
void push_slicing_error_notification ( const std : : string & text ) ;
2020-10-15 07:20:05 +00:00
// Creates Slicing Warning notification with a custom text and no fade out.
2020-11-30 12:45:17 +00:00
void push_slicing_warning_notification ( const std : : string & text , bool gray , ObjectID oid , int warning_step ) ;
2020-10-13 13:32:41 +00:00
// marks slicing errors as gray
void set_all_slicing_errors_gray ( bool g ) ;
// marks slicing warings as gray
void set_all_slicing_warnings_gray ( bool g ) ;
2020-10-14 14:48:56 +00:00
// void set_slicing_warning_gray(const std::string& text, bool g);
// immediately stops showing slicing errors
2020-10-13 13:32:41 +00:00
void close_slicing_errors_and_warnings ( ) ;
2020-10-14 14:48:56 +00:00
// Release those slicing warnings, which refer to an ObjectID, which is not in the list.
// living_oids is expected to be sorted.
void remove_slicing_warnings_of_released_objects ( const std : : vector < ObjectID > & living_oids ) ;
2020-10-15 07:20:05 +00:00
// Object partially outside of the printer working space, cannot print. No fade out.
2020-11-30 12:45:17 +00:00
void push_plater_error_notification ( const std : : string & text ) ;
2020-10-15 07:20:05 +00:00
// Object fully out of the printer working space and such. No fade out.
2020-11-30 12:45:17 +00:00
void push_plater_warning_notification ( const std : : string & text ) ;
2020-10-14 14:48:56 +00:00
// Closes error or warning of the same text
2020-10-13 13:32:41 +00:00
void close_plater_error_notification ( const std : : string & text ) ;
void close_plater_warning_notification ( const std : : string & text ) ;
2020-10-15 07:20:05 +00:00
// Creates special notification slicing complete.
// If large = true (Plater side bar is closed), then printing time and export button is shown
// at the notification and fade-out is disabled. Otherwise the fade out time is set to 10s.
2020-11-30 12:45:17 +00:00
void push_slicing_complete_notification ( int timestamp , bool large ) ;
2020-10-14 14:48:56 +00:00
// Add a print time estimate to an existing SlicingComplete notification.
void set_slicing_complete_print_time ( const std : : string & info ) ;
// Called when the side bar changes its visibility, as the "slicing complete" notification supplements
// the "slicing info" normally shown at the side bar.
2020-10-13 13:32:41 +00:00
void set_slicing_complete_large ( bool large ) ;
2020-11-04 08:23:47 +00:00
// Exporting finished, show this information with path, button to open containing folder and if ejectable - eject button
2020-11-30 12:45:17 +00:00
void push_exporting_finished_notification ( const std : : string & path , const std : : string & dir_path , bool on_removable ) ;
2020-11-10 08:20:39 +00:00
// notification with progress bar
2020-11-30 12:45:17 +00:00
void push_progress_bar_notification ( const std : : string & text , float percentage = 0 ) ;
void set_progress_bar_percentage ( const std : : string & text , float percentage ) ;
2020-11-10 08:20:39 +00:00
// Close old notification ExportFinished.
2020-11-04 08:23:47 +00:00
void new_export_began ( bool on_removable ) ;
// finds ExportFinished notification and closes it if it was to removable device
void device_ejected ( ) ;
2020-10-13 13:32:41 +00:00
// renders notifications in queue and deletes expired ones
2020-11-30 12:45:17 +00:00
void render_notifications ( float overlay_width ) ;
2020-10-13 13:32:41 +00:00
// finds and closes all notifications of given type
void close_notification_of_type ( const NotificationType type ) ;
2020-10-14 14:48:56 +00:00
// Which view is active? Plater or G-code preview? Hide warnings in G-code preview.
2020-10-13 13:32:41 +00:00
void set_in_preview ( bool preview ) ;
2020-11-04 08:23:47 +00:00
// Move to left to avoid colision with variable layer height gizmo.
2020-10-13 13:32:41 +00:00
void set_move_from_overlay ( bool move ) { m_move_from_overlay = move ; }
2021-02-19 11:18:09 +00:00
2020-10-13 13:32:41 +00:00
private :
2020-08-03 13:36:55 +00:00
// duration 0 means not disapearing
struct NotificationData {
2020-11-10 08:20:39 +00:00
NotificationType type ;
NotificationLevel level ;
2020-10-15 07:20:05 +00:00
// Fade out time
2020-11-10 08:20:39 +00:00
const int duration ;
const std : : string text1 ;
const std : : string hypertext ;
2020-11-23 15:42:03 +00:00
// Callback for hypertext - returns true if notification should close after triggering
// Usually sends event to UI thread thru wxEvtHandler.
// Examples in basic_notifications.
2020-11-10 08:20:39 +00:00
std : : function < bool ( wxEvtHandler * ) > callback { nullptr } ;
const std : : string text2 ;
2020-08-03 13:36:55 +00:00
} ;
2020-10-14 12:18:04 +00:00
// Cache of IDs to identify and reuse ImGUI windows.
class NotificationIDProvider
{
public :
int allocate_id ( ) ;
void release_id ( int id ) ;
private :
// Next ID used for naming the ImGUI windows.
int m_next_id { 1 } ;
// IDs of ImGUI windows, which were released and they are ready for reuse.
std : : vector < int > m_released_ids ;
} ;
2020-08-03 13:36:55 +00:00
//Pop notification - shows only once to user.
class PopNotification
{
public :
2020-12-16 16:42:50 +00:00
2020-12-03 14:12:32 +00:00
enum class EState
{
Unknown ,
2020-12-06 13:53:13 +00:00
Hidden ,
FadingOutRender , // Requesting Render
FadingOutStatic ,
ClosePending , // Requesting Render
Finished , // Requesting Render
2020-12-03 14:12:32 +00:00
} ;
2020-12-16 16:42:50 +00:00
2020-10-14 12:18:04 +00:00
PopNotification ( const NotificationData & n , NotificationIDProvider & id_provider , wxEvtHandler * evt_handler ) ;
virtual ~ PopNotification ( ) { if ( m_id ) m_id_provider . release_id ( m_id ) ; }
2020-12-03 14:12:32 +00:00
void render ( GLCanvas3D & canvas , float initial_y , bool move_from_overlay , float overlay_width ) ;
2020-08-03 13:36:55 +00:00
// close will dissapear notification on next render
void close ( ) { m_close_pending = true ; }
// data from newer notification of same type
void update ( const NotificationData & n ) ;
2020-12-03 14:12:32 +00:00
bool is_finished ( ) const { return m_finished | | m_close_pending ; }
bool is_hovered ( ) const { return m_hovered ; }
2020-08-03 13:36:55 +00:00
// returns top after movement
float get_top ( ) const { return m_top_y ; }
//returns top in actual frame
float get_current_top ( ) const { return m_top_y ; }
const NotificationType get_type ( ) const { return m_data . type ; }
2020-12-03 14:12:32 +00:00
const NotificationData get_data ( ) const { return m_data ; }
const bool is_gray ( ) const { return m_is_gray ; }
2020-08-03 13:36:55 +00:00
// Call equals one second down
2020-12-16 12:59:16 +00:00
void substract_remaining_time ( int seconds ) { m_remaining_time - = seconds ; }
2020-08-03 13:36:55 +00:00
void set_gray ( bool g ) { m_is_gray = g ; }
void set_paused ( bool p ) { m_paused = p ; }
bool compare_text ( const std : : string & text ) ;
2020-08-25 07:55:29 +00:00
void hide ( bool h ) { m_hidden = h ; }
2020-12-16 16:42:50 +00:00
// sets m_next_render with time of next mandatory rendering
2020-12-03 14:12:32 +00:00
void update_state ( ) ;
2020-12-16 16:42:50 +00:00
int64_t next_render ( ) const { return m_next_render ; }
/*
2020-12-06 13:53:13 +00:00
bool requires_render ( ) const { return m_state = = EState : : FadingOutRender | | m_state = = EState : : ClosePending | | m_state = = EState : : Finished ; }
bool requires_update ( ) const { return m_state ! = EState : : Hidden ; }
2020-12-16 16:42:50 +00:00
*/
2020-12-03 14:12:32 +00:00
EState get_state ( ) const { return m_state ; }
2020-08-03 13:36:55 +00:00
protected :
// Call after every size change
void init ( ) ;
2020-11-04 08:23:47 +00:00
// Part of init()
virtual void count_spaces ( ) ;
2020-08-03 13:36:55 +00:00
// Calculetes correct size but not se it in imgui!
virtual void set_next_window_size ( ImGuiWrapper & imgui ) ;
virtual void render_text ( ImGuiWrapper & imgui ,
const float win_size_x , const float win_size_y ,
const float win_pos_x , const float win_pos_y ) ;
2020-11-04 08:23:47 +00:00
virtual void render_close_button ( ImGuiWrapper & imgui ,
2020-08-03 13:36:55 +00:00
const float win_size_x , const float win_size_y ,
const float win_pos_x , const float win_pos_y ) ;
2020-11-04 08:23:47 +00:00
virtual void render_hypertext ( ImGuiWrapper & imgui ,
2020-08-03 13:36:55 +00:00
const float text_x , const float text_y ,
const std : : string text ,
bool more = false ) ;
2020-11-04 08:23:47 +00:00
// Left sign could be error or warning sign
2020-08-03 13:36:55 +00:00
void render_left_sign ( ImGuiWrapper & imgui ) ;
2020-11-04 08:23:47 +00:00
virtual void render_minimize_button ( ImGuiWrapper & imgui ,
2020-08-03 13:36:55 +00:00
const float win_pos_x , const float win_pos_y ) ;
2020-11-23 15:42:03 +00:00
// Hypertext action, returns true if notification should close.
// Action is stored in NotificationData::callback as std::function<bool(wxEvtHandler*)>
2020-11-04 08:23:47 +00:00
virtual bool on_text_click ( ) ;
2020-08-03 13:36:55 +00:00
const NotificationData m_data ;
2020-10-14 14:48:56 +00:00
// For reusing ImGUI windows.
2020-10-14 12:18:04 +00:00
NotificationIDProvider & m_id_provider ;
2020-12-16 16:42:50 +00:00
2020-12-03 14:12:32 +00:00
EState m_state { EState : : Unknown } ;
2020-12-16 16:42:50 +00:00
2020-12-03 14:12:32 +00:00
int m_id { 0 } ;
2020-08-26 08:49:42 +00:00
bool m_initialized { false } ;
2020-08-03 13:36:55 +00:00
// Main text
std : : string m_text1 ;
// Clickable text
std : : string m_hypertext ;
// Aditional text after hypertext - currently not used
std : : string m_text2 ;
// Countdown variables
long m_remaining_time ;
bool m_counting_down ;
long m_last_remaining_time ;
2020-08-26 08:49:42 +00:00
bool m_paused { false } ;
int m_countdown_frame { 0 } ;
bool m_fading_out { false } ;
2020-12-16 15:15:58 +00:00
int64_t m_fading_start { 0LL } ;
2020-12-15 15:03:20 +00:00
// time of last done render when fading
2020-12-16 15:15:58 +00:00
int64_t m_last_render_fading { 0LL } ;
2020-12-15 15:03:20 +00:00
// first appereance of notification or last hover;
2020-12-16 16:42:50 +00:00
int64_t m_notification_start ;
2020-12-15 15:03:20 +00:00
// time to next must-do render
2020-12-16 15:15:58 +00:00
int64_t m_next_render { std : : numeric_limits < int64_t > : : max ( ) } ;
2020-12-03 14:12:32 +00:00
float m_current_fade_opacity { 1.0f } ;
2020-08-03 13:36:55 +00:00
// If hidden the notif is alive but not visible to user
bool m_hidden { false } ;
// m_finished = true - does not render, marked to delete
bool m_finished { false } ;
// Will go to m_finished next render
2021-02-19 11:18:09 +00:00
bool m_close_pending { false } ;
2020-12-03 14:12:32 +00:00
bool m_hovered { false } ;
2020-08-03 13:36:55 +00:00
// variables to count positions correctly
2020-11-04 08:23:47 +00:00
// all space without text
2020-08-03 13:36:55 +00:00
float m_window_width_offset ;
2020-11-04 08:23:47 +00:00
// Space on left side without text
2020-08-03 13:36:55 +00:00
float m_left_indentation ;
// Total size of notification window - varies based on monitor
float m_window_height { 56.0f } ;
float m_window_width { 450.0f } ;
//Distance from bottom of notifications to top of this notification
float m_top_y { 0.0f } ;
// Height of text
// Used as basic scaling unit!
float m_line_height ;
2021-01-14 12:00:03 +00:00
std : : vector < size_t > m_endlines ;
2020-08-03 13:36:55 +00:00
// Gray are f.e. eorrors when its uknown if they are still valid
bool m_is_gray { false } ;
//if multiline = true, notification is showing all lines(>2)
bool m_multiline { false } ;
2020-11-04 08:23:47 +00:00
// True if minimized button is rendered, helps to decide where is area for invisible close button
bool m_minimize_b_visible { false } ;
2021-01-14 12:00:03 +00:00
size_t m_lines_count { 1 } ;
2020-10-14 14:48:56 +00:00
// Target for wxWidgets events sent by clicking on the hyperlink available at some notifications.
2020-08-03 13:36:55 +00:00
wxEvtHandler * m_evt_handler ;
} ;
class SlicingCompleteLargeNotification : public PopNotification
{
public :
2020-10-14 12:18:04 +00:00
SlicingCompleteLargeNotification ( const NotificationData & n , NotificationIDProvider & id_provider , wxEvtHandler * evt_handler , bool largeds ) ;
2020-08-03 13:36:55 +00:00
void set_large ( bool l ) ;
bool get_large ( ) { return m_is_large ; }
2020-10-14 14:48:56 +00:00
void set_print_info ( const std : : string & info ) ;
2020-08-03 13:36:55 +00:00
protected :
virtual void render_text ( ImGuiWrapper & imgui ,
const float win_size_x , const float win_size_y ,
const float win_pos_x , const float win_pos_y )
override ;
bool m_is_large ;
bool m_has_print_info { false } ;
2021-01-14 12:00:03 +00:00
std : : string m_print_info ;
2020-08-03 13:36:55 +00:00
} ;
class SlicingWarningNotification : public PopNotification
{
public :
2020-10-14 12:18:04 +00:00
SlicingWarningNotification ( const NotificationData & n , NotificationIDProvider & id_provider , wxEvtHandler * evt_handler ) : PopNotification ( n , id_provider , evt_handler ) { }
2020-10-14 14:48:56 +00:00
ObjectID object_id ;
int warning_step ;
2020-08-03 13:36:55 +00:00
} ;
2020-11-10 08:20:39 +00:00
class ProgressBarNotification : public PopNotification
{
public :
ProgressBarNotification ( const NotificationData & n , NotificationIDProvider & id_provider , wxEvtHandler * evt_handler , float percentage ) : PopNotification ( n , id_provider , evt_handler ) { set_percentage ( percentage ) ; }
void set_percentage ( float percent ) { m_percentage = percent ; if ( percent > = 1.0f ) m_progress_complete = true ; else m_progress_complete = false ; }
protected :
virtual void init ( ) ;
virtual void render_text ( ImGuiWrapper & imgui ,
const float win_size_x , const float win_size_y ,
const float win_pos_x , const float win_pos_y ) ;
void render_bar ( ImGuiWrapper & imgui ,
const float win_size_x , const float win_size_y ,
const float win_pos_x , const float win_pos_y ) ;
bool m_progress_complete { false } ;
float m_percentage ;
} ;
2020-11-04 08:23:47 +00:00
class ExportFinishedNotification : public PopNotification
{
public :
ExportFinishedNotification ( const NotificationData & n , NotificationIDProvider & id_provider , wxEvtHandler * evt_handler , bool to_removable , const std : : string & export_path , const std : : string & export_dir_path )
: PopNotification ( n , id_provider , evt_handler )
, m_to_removable ( to_removable )
, m_export_path ( export_path )
, m_export_dir_path ( export_dir_path )
{
m_multiline = true ;
}
bool m_to_removable ;
std : : string m_export_path ;
std : : string m_export_dir_path ;
protected :
// Reserves space on right for more buttons
virtual void count_spaces ( ) override ;
virtual void render_text ( ImGuiWrapper & imgui ,
const float win_size_x , const float win_size_y ,
const float win_pos_x , const float win_pos_y ) override ;
// Renders also button to open directory with exported path and eject removable media
virtual void render_close_button ( ImGuiWrapper & imgui ,
const float win_size_x , const float win_size_y ,
const float win_pos_x , const float win_pos_y ) override ;
void render_eject_button ( ImGuiWrapper & imgui ,
const float win_size_x , const float win_size_y ,
const float win_pos_x , const float win_pos_y ) ;
virtual void render_minimize_button ( ImGuiWrapper & imgui , const float win_pos_x , const float win_pos_y ) override
{ m_minimize_b_visible = false ; }
virtual bool on_text_click ( ) override ;
// local time of last hover for showing tooltip
long m_hover_time { 0 } ;
} ;
2020-08-03 13:36:55 +00:00
//pushes notification into the queue of notifications that are rendered
//can be used to create custom notification
2020-11-30 12:45:17 +00:00
bool push_notification_data ( const NotificationData & notification_data , int timestamp ) ;
bool push_notification_data ( std : : unique_ptr < NotificationManager : : PopNotification > notification , int timestamp ) ;
2020-08-03 13:36:55 +00:00
//finds older notification of same type and moves it to the end of queue. returns true if found
2020-10-14 15:17:14 +00:00
bool activate_existing ( const NotificationManager : : PopNotification * notification ) ;
2020-10-14 14:48:56 +00:00
// Put the more important notifications to the bottom of the list.
2020-08-03 13:36:55 +00:00
void sort_notifications ( ) ;
2020-10-14 14:48:56 +00:00
// If there is some error notification active, then the "Export G-code" notification after the slicing is finished is suppressed.
bool has_slicing_error_notification ( ) ;
2020-12-16 16:42:50 +00:00
// perform update_state on each notification and ask for more frames if needed
void update_notifications ( ) ;
2021-02-19 11:18:09 +00:00
2020-12-16 16:42:50 +00:00
// Target for wxWidgets events sent by clicking on the hyperlink available at some notifications.
2020-08-03 13:36:55 +00:00
wxEvtHandler * m_evt_handler ;
2020-10-14 12:18:04 +00:00
// Cache of IDs to identify and reuse ImGUI windows.
NotificationIDProvider m_id_provider ;
2020-10-13 14:08:08 +00:00
std : : deque < std : : unique_ptr < PopNotification > > m_pop_notifications ;
2020-10-15 07:56:33 +00:00
// Last render time in seconds for fade out control.
2020-08-03 13:36:55 +00:00
long m_last_time { 0 } ;
2020-10-15 07:56:33 +00:00
// When mouse hovers over some notification, the fade-out of all notifications is suppressed.
2020-08-03 13:36:55 +00:00
bool m_hovered { false } ;
2020-10-14 15:17:14 +00:00
//timestamps used for slicing finished - notification could be gone so it needs to be stored here
2020-08-03 13:36:55 +00:00
std : : unordered_set < int > m_used_timestamps ;
2020-10-15 07:20:05 +00:00
// True if G-code preview is active. False if the Plater is active.
2020-09-21 11:47:18 +00:00
bool m_in_preview { false } ;
2020-10-15 07:20:05 +00:00
// True if the layer editing is enabled in Plater, so that the notifications are shifted left of it.
2020-10-02 08:26:11 +00:00
bool m_move_from_overlay { false } ;
2021-02-19 11:18:09 +00:00
2020-08-03 13:36:55 +00:00
//prepared (basic) notifications
const std : : vector < NotificationData > basic_notifications = {
2020-10-14 12:18:04 +00:00
// {NotificationType::SlicingNotPossible, NotificationLevel::RegularNotification, 10, _u8L("Slicing is not possible.")},
2020-11-04 08:23:47 +00:00
// {NotificationType::ExportToRemovableFinished, NotificationLevel::ImportantNotification, 0, _u8L("Exporting finished."), _u8L("Eject drive.") },
2020-08-03 13:36:55 +00:00
{ NotificationType : : Mouse3dDisconnected , NotificationLevel : : RegularNotification , 10 , _u8L ( " 3D Mouse disconnected. " ) } ,
2020-10-14 12:18:04 +00:00
// {NotificationType::Mouse3dConnected, NotificationLevel::RegularNotification, 5, _u8L("3D Mouse connected.") },
// {NotificationType::NewPresetsAviable, NotificationLevel::ImportantNotification, 20, _u8L("New Presets are available."), _u8L("See here.") },
2021-01-14 12:00:03 +00:00
{ NotificationType : : PresetUpdateAvailable , NotificationLevel : : ImportantNotification , 20 , _u8L ( " Configuration update is available. " ) , _u8L ( " See more. " ) ,
[ ] ( wxEvtHandler * evnthndlr ) {
if ( evnthndlr ! = nullptr )
wxPostEvent ( evnthndlr , PresetUpdateAvailableClickedEvent ( EVT_PRESET_UPDATE_AVAILABLE_CLICKED ) ) ;
return true ;
}
} ,
2020-11-10 08:20:39 +00:00
{ NotificationType : : NewAppAvailable , NotificationLevel : : ImportantNotification , 20 , _u8L ( " New version is available. " ) , _u8L ( " See Releases page. " ) , [ ] ( wxEvtHandler * evnthndlr ) {
wxLaunchDefaultBrowser ( " https://github.com/prusa3d/PrusaSlicer/releases " ) ; return true ; } } ,
2020-12-09 10:36:25 +00:00
{ NotificationType : : EmptyColorChangeCode , NotificationLevel : : RegularNotification , 10 ,
_u8L ( " You have just added a G-code for color change, but its value is empty. \n "
" To export the G-code correctly, check the \" Color Change G-code \" in \" Printer Settings > Custom G-code \" " ) } ,
2021-02-23 17:46:05 +00:00
{ NotificationType : : EmptyAutoColorChange , NotificationLevel : : RegularNotification , 10 ,
_u8L ( " This model doesn't allow to automatically add the color changes " ) } ,
2020-10-15 07:56:33 +00:00
//{NotificationType::NewAppAvailable, NotificationLevel::ImportantNotification, 20, _u8L("New vesion of PrusaSlicer is available.", _u8L("Download page.") },
2020-08-03 13:36:55 +00:00
//{NotificationType::LoadingFailed, NotificationLevel::RegularNotification, 20, _u8L("Loading of model has Failed") },
//{NotificationType::DeviceEjected, NotificationLevel::RegularNotification, 10, _u8L("Removable device has been safely ejected")} // if we want changeble text (like here name of device), we need to do it as CustomNotification
} ;
} ;
} //namespace GUI
} //namespace Slic3r
2020-12-04 23:02:23 +00:00
# endif //slic3r_GUI_NotificationManager_hpp_