button show after write

This commit is contained in:
David Kocik 2019-12-12 14:56:30 +01:00
parent 0cb9a4c542
commit 95ccc2c4df
3 changed files with 10 additions and 37 deletions

View file

@ -3171,6 +3171,7 @@ void Plater::priv::update_fff_scene()
this->preview->reload_print(); this->preview->reload_print();
// In case this was MM print, wipe tower bounding box on 3D tab might need redrawing with exact depth: // In case this was MM print, wipe tower bounding box on 3D tab might need redrawing with exact depth:
view3D->reload_scene(true); view3D->reload_scene(true);
show_action_buttons(false);
} }
void Plater::priv::update_sla_scene() void Plater::priv::update_sla_scene()
@ -4052,7 +4053,7 @@ void Plater::priv::show_action_buttons(const bool is_ready_to_slice) const
if (sidebar->show_reslice(false) | if (sidebar->show_reslice(false) |
sidebar->show_export(true) | sidebar->show_export(true) |
sidebar->show_send(send_gcode_shown) | sidebar->show_send(send_gcode_shown) |
sidebar->show_disconnect(false/*disconnect_shown*/)) sidebar->show_disconnect(disconnect_shown))
sidebar->Layout(); sidebar->Layout();
} }
else else
@ -4606,9 +4607,10 @@ void Plater::export_gcode()
} }
if (! output_path.empty()) if (! output_path.empty())
{ {
RemovableDriveManager::get_instance().update(0, true); std::string path = output_path.string();
RemovableDriveManager::get_instance().set_last_save_path(output_path.string());
p->export_gcode(std::move(output_path), PrintHostJob()); p->export_gcode(std::move(output_path), PrintHostJob());
RemovableDriveManager::get_instance().update(0, true);
RemovableDriveManager::get_instance().set_last_save_path(path);
} }
} }

View file

@ -24,9 +24,6 @@ GUID WceusbshGUID = { 0x25dbce51, 0x6c8f, 0x4a72,
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
//std::vector<DriveData> RemovableDriveManager::m_current_drives;
//std::vector<std::function<void()>> RemovableDriveManager::m_callbacks;
#if _WIN32 #if _WIN32
INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
@ -42,7 +39,6 @@ void RemovableDriveManager::search_for_drives()
std::string path (1,(char)('A' + i)); std::string path (1,(char)('A' + i));
path+=":"; path+=":";
UINT drive_type = GetDriveTypeA(path.c_str()); UINT drive_type = GetDriveTypeA(path.c_str());
//std::cout << "found drive" << (char)('A' + i) << ": type:" <<driveType << "\n";
if (drive_type == DRIVE_REMOVABLE) if (drive_type == DRIVE_REMOVABLE)
{ {
// get name of drive // get name of drive
@ -63,7 +59,6 @@ void RemovableDriveManager::search_for_drives()
{ {
ULARGE_INTEGER free_space; ULARGE_INTEGER free_space;
GetDiskFreeSpaceExA(path.c_str(), &free_space, NULL, NULL); GetDiskFreeSpaceExA(path.c_str(), &free_space, NULL, NULL);
//std::cout << std::string(volumeName.begin(), volumeName.end()) << " " << std::string(fileSystemName.begin(), fileSystemName.end()) << " " << freeSpace.QuadPart << "\n";
if (free_space.QuadPart > 0) if (free_space.QuadPart > 0)
{ {
path += "\\"; path += "\\";
@ -74,12 +69,9 @@ void RemovableDriveManager::search_for_drives()
} }
} }
} }
//std::cout << "found drives:" << m_current_drives.size() << "\n";
} }
void RemovableDriveManager::eject_drive(const std::string &path) void RemovableDriveManager::eject_drive(const std::string &path)
{ {
//if (!update() || !is_drive_mounted(path))
if(m_current_drives.empty()) if(m_current_drives.empty())
return; return;
for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it) for (auto it = m_current_drives.begin(); it != m_current_drives.end(); ++it)
@ -88,7 +80,6 @@ void RemovableDriveManager::eject_drive(const std::string &path)
{ {
std::string mpath = "\\\\.\\" + path; std::string mpath = "\\\\.\\" + path;
mpath = mpath.substr(0, mpath.size() - 1); mpath = mpath.substr(0, mpath.size() - 1);
//std::cout << "Ejecting " << mpath << "\n";
HANDLE handle = CreateFileA(mpath.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr); HANDLE handle = CreateFileA(mpath.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
if (handle == INVALID_HANDLE_VALUE) if (handle == INVALID_HANDLE_VALUE)
{ {
@ -138,7 +129,7 @@ std::string RemovableDriveManager::get_drive_from_path(const std::string& path)
} }
void RemovableDriveManager::register_window() void RemovableDriveManager::register_window()
{ {
std::cout << "Registering for device notification\n"; //creates new unvisible window that is recieving callbacks from system
WNDCLASSEX wndClass; WNDCLASSEX wndClass;
wndClass.cbSize = sizeof(WNDCLASSEX); wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; wndClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
@ -181,9 +172,6 @@ INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
LRESULT lRet = 1; LRESULT lRet = 1;
static HDEVNOTIFY hDeviceNotify; static HDEVNOTIFY hDeviceNotify;
static HWND hEditWnd;
static ULONGLONG msgCount = 0;
switch (message) switch (message)
{ {
case WM_CREATE: case WM_CREATE:
@ -194,11 +182,7 @@ INT_PTR WINAPI WinProcCallback(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
NotificationFilter.dbcc_classguid = WceusbshGUID; NotificationFilter.dbcc_classguid = WceusbshGUID;
hDeviceNotify = RegisterDeviceNotification( hDeviceNotify = RegisterDeviceNotification(hWnd, &NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE);
hWnd, // events recipient
&NotificationFilter, // type of device
DEVICE_NOTIFY_WINDOW_HANDLE // type of recipient handle
);
break; break;
case WM_DEVICECHANGE: case WM_DEVICECHANGE:
@ -280,7 +264,6 @@ void RemovableDriveManager::search_for_drives()
} }
//std::cout << "found drives:" <<m_current_drives.size() << "\n";
#endif #endif
} }
void RemovableDriveManager::search_path(const std::string &path,const std::string &parent_path) void RemovableDriveManager::search_path(const std::string &path,const std::string &parent_path)
@ -416,7 +399,7 @@ void RemovableDriveManager::init()
#endif #endif
update(); update();
} }
bool RemovableDriveManager::update(const long time, bool check) bool RemovableDriveManager::update(const long time,const bool check)
{ {
if(time != 0) //time = 0 is forced update if(time != 0) //time = 0 is forced update
{ {
@ -467,11 +450,8 @@ std::vector<DriveData> RemovableDriveManager::get_all_drives()
} }
void RemovableDriveManager::check_and_notify() void RemovableDriveManager::check_and_notify()
{ {
//std::cout<<"drives count: "<<m_drives_count;
if(m_drives_count != m_current_drives.size()) if(m_drives_count != m_current_drives.size())
{ {
//m_rdmmm->log("drives count not same");
//std::cout<<" vs "<< m_current_drives.size();
if(m_callbacks.size() != 0 && m_drives_count > m_current_drives.size() && m_last_save_path != "" && !is_drive_mounted(m_last_save_path)) if(m_callbacks.size() != 0 && m_drives_count > m_current_drives.size() && m_last_save_path != "" && !is_drive_mounted(m_last_save_path))
{ {
for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it) for (auto it = m_callbacks.begin(); it != m_callbacks.end(); ++it)
@ -481,7 +461,6 @@ void RemovableDriveManager::check_and_notify()
} }
m_drives_count = m_current_drives.size(); m_drives_count = m_current_drives.size();
} }
//std::cout<<"\n";
} }
void RemovableDriveManager::add_callback(std::function<void()> callback) void RemovableDriveManager::add_callback(std::function<void()> callback)
{ {
@ -522,10 +501,4 @@ void RemovableDriveManager::reset_last_save_path()
{ {
m_last_save_path = ""; m_last_save_path = "";
} }
}}//namespace Slicer::Gui
void RemovableDriveManager::print()
{
//std::cout << "Removed Device: "<<(int)is_last_drive_removed()<<"\n";
std::cout << "notified\n";
}
}}//namespace Slicer::Gui::

View file

@ -32,7 +32,7 @@ public:
//update() searches for removable devices, returns false if empty. //update() searches for removable devices, returns false if empty.
void init(); void init();
bool update(const long time = 0, bool check = false); //time = 0 is forced update, time expects wxGetLocalTime() bool update(const long time = 0,const bool check = false); //time = 0 is forced update, time expects wxGetLocalTime()
bool is_drive_mounted(const std::string &path); bool is_drive_mounted(const std::string &path);
void eject_drive(const std::string &path); void eject_drive(const std::string &path);
std::string get_last_save_path(); std::string get_last_save_path();
@ -44,8 +44,6 @@ public:
void set_last_save_path(const std::string &path); void set_last_save_path(const std::string &path);
bool is_last_drive_removed(); bool is_last_drive_removed();
bool is_last_drive_removed_with_update(const long time = 0); // param as update() bool is_last_drive_removed_with_update(const long time = 0); // param as update()
void print();
private: private:
RemovableDriveManager(); RemovableDriveManager();
void search_for_drives(); void search_for_drives();