mirror of
https://github.com/QIDITECH/QIDIStudio.git
synced 2026-01-30 16:38:41 +03:00
fix some bug
This commit is contained in:
@@ -858,6 +858,16 @@ inline std::string filter_characters(const std::string& str, const std::string&
|
||||
return filteredStr;
|
||||
}
|
||||
|
||||
//y71
|
||||
inline std::string get_pure_file_name(const std::string &file_path)
|
||||
{
|
||||
size_t pos_last_delimiter = file_path.find_last_of("/\\");
|
||||
size_t pos_point = file_path.find_last_of('.');
|
||||
size_t offset = pos_last_delimiter + 1;
|
||||
size_t count = pos_point - pos_last_delimiter - 1;
|
||||
return file_path.substr(offset, count);
|
||||
}
|
||||
|
||||
void save_string_file(const boost::filesystem::path& p, const std::string& str);
|
||||
void load_string_file(const boost::filesystem::path& p, std::string& str);
|
||||
|
||||
|
||||
@@ -329,7 +329,7 @@ void AuFile::on_input_enter(wxCommandEvent &evt)
|
||||
auto m_valid_type = Valid;
|
||||
wxString info_line;
|
||||
|
||||
const char *unusable_symbols = " #;\'<>:/\\|?*\"";
|
||||
const char *unusable_symbols = "#\'<>:\\|?*\"";
|
||||
|
||||
const std::string unusable_suffix = PresetCollection::get_suffix_modified(); //"(modified)";
|
||||
for (size_t i = 0; i < std::strlen(unusable_symbols); i++) {
|
||||
|
||||
@@ -296,7 +296,7 @@ void PrintJob::process()
|
||||
try {
|
||||
std::string mall_model_name = model_name->second;
|
||||
std::replace(mall_model_name.begin(), mall_model_name.end(), ' ', '_');
|
||||
const char *unusable_symbols = " #;\'<>:/\\|?*\"";
|
||||
const char *unusable_symbols = "#\'<>:\\|?*\"";
|
||||
for (const char *symbol = unusable_symbols; *symbol != '\0'; ++symbol) { std::replace(mall_model_name.begin(), mall_model_name.end(), *symbol, '_'); }
|
||||
|
||||
std::regex pattern("_+");
|
||||
|
||||
@@ -341,7 +341,7 @@ void PhysicalPrinterDialog::update_preset_input() {
|
||||
m_valid_type = Valid;
|
||||
wxString info_line;
|
||||
|
||||
const char *unusable_symbols = " #;\'<>:/\\|?*\"";
|
||||
const char *unusable_symbols = "#\'<>:\\|?*\"";
|
||||
|
||||
const std::string unusable_suffix = PresetCollection::get_suffix_modified(); //"(modified)";
|
||||
for (size_t i = 0; i < std::strlen(unusable_symbols); i++) {
|
||||
|
||||
@@ -233,7 +233,7 @@ bool Plater::has_illegal_filename_characters(const wxString& wxs_name)
|
||||
|
||||
bool Plater::has_illegal_filename_characters(const std::string& name)
|
||||
{
|
||||
const char* illegal_characters = " #;\'<>:/\\|?*\"";
|
||||
const char* illegal_characters = "#\'<>:\\|?*\"";
|
||||
for (size_t i = 0; i < std::strlen(illegal_characters); i++)
|
||||
if (name.find_first_of(illegal_characters[i]) != std::string::npos)
|
||||
return true;
|
||||
@@ -248,7 +248,7 @@ bool Plater::has_illegal_filename_characters(const std::string& name)
|
||||
|
||||
void Plater::show_illegal_characters_warning(wxWindow* parent)
|
||||
{
|
||||
show_error(parent, _L("Invalid name, the following characters are not allowed:") + " #;\'<>:/\\|?*\"" +_L("(Including its escape characters)"));
|
||||
show_error(parent, _L("Invalid name, the following characters are not allowed:") + "#\'<>:\\|?*\"" +_L("(Including its escape characters)"));
|
||||
}
|
||||
|
||||
void Plater::mark_plate_toolbar_image_dirty()
|
||||
@@ -10655,8 +10655,8 @@ wxString Plater::priv::get_export_gcode_filename(const wxString& extension, bool
|
||||
std::string plate_name = partplate_list.get_curr_plate()->get_plate_name();
|
||||
|
||||
// remove unsupported characters in filename
|
||||
curr_project_name = from_u8(filter_characters(curr_project_name.ToUTF8().data(), " #;\'<>:/\\|?*\""));
|
||||
plate_name = filter_characters(plate_name, " #;\'<>:/\\|?*\"");
|
||||
curr_project_name = from_u8(filter_characters(curr_project_name.ToUTF8().data(), "#\'<>:\\|?*\""));
|
||||
plate_name = filter_characters(plate_name, "#\'<>:\\|?*\"");
|
||||
|
||||
if (!plate_name.empty())
|
||||
plate_index_str = (boost::format("_%1%") % plate_name).str();
|
||||
@@ -15423,11 +15423,30 @@ void Plater::export_gcode(bool prefer_removable)
|
||||
unsigned int state = this->p->update_restart_background_process(false, false);
|
||||
if (state & priv::UPDATE_BACKGROUND_PROCESS_INVALID)
|
||||
return;
|
||||
// //y56
|
||||
// if (wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_string("filename_format") == "{input_filename_base}.gcode")
|
||||
// default_output_file = fs::path(into_u8(p->get_export_gcode_filename("", true, p->partplate_list.get_curr_plate_index() == PLATE_ALL_IDX ? true : false)));
|
||||
// else
|
||||
default_output_file = fs::path(this->p->background_process.output_filepath_for_project(""));
|
||||
//y56 y71
|
||||
if (wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_string("filename_format") == "{input_filename_base}.gcode")
|
||||
default_output_file = fs::path(into_u8(p->get_export_gcode_filename("", true, p->partplate_list.get_curr_plate_index() == PLATE_ALL_IDX ? true : false)));
|
||||
else
|
||||
default_output_file = fs::path(this->p->background_process.output_filepath_for_project(""));
|
||||
wxString file_name = default_output_file.wstring();
|
||||
if (file_name.find(_L("Untitled")) != wxString::npos) {
|
||||
PartPlate* part_plate = get_partplate_list().get_plate(p->partplate_list.get_curr_plate_index());
|
||||
if (part_plate) {
|
||||
if (std::vector<ModelObject*> objects = part_plate->get_objects_on_this_plate(); objects.size() > 0) {
|
||||
file_name = from_u8(objects[0]->name);
|
||||
}
|
||||
file_name = from_u8(get_pure_file_name(into_u8(file_name)));
|
||||
if (file_name.size() > 80) {
|
||||
file_name = file_name.substr(0, 80) + "...";
|
||||
}
|
||||
if (p->partplate_list.get_plate_count() > 1) {
|
||||
std::string plate_index_str = (boost::format("_plate_%1%") % std::to_string(p->partplate_list.get_curr_plate_index() + 1)).str();
|
||||
file_name += wxString::FromUTF8(plate_index_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
default_output_file = boost::filesystem::path(file_name);
|
||||
|
||||
|
||||
} catch (const Slic3r::PlaceholderParserError &ex) {
|
||||
// Show the error with monospaced font.
|
||||
@@ -15463,7 +15482,7 @@ void Plater::export_gcode(bool prefer_removable)
|
||||
output_path = into_path(dlg.GetPath());
|
||||
while (has_illegal_filename_characters(output_path.filename().string())) {
|
||||
show_error(this, _L("The provided file name is not valid.") + "\n" +
|
||||
_L("The following characters are not allowed by a FAT file system:") + " #;\'<>:/\\|?*\"");
|
||||
_L("The following characters are not allowed by a FAT file system:") + "#\'<>:\\|?*\"");
|
||||
dlg.SetFilename(from_path(output_path.filename()));
|
||||
if (dlg.ShowModal() == wxID_OK)
|
||||
output_path = into_path(dlg.GetPath());
|
||||
@@ -15529,9 +15548,36 @@ void Plater::export_gcode_3mf(bool export_all)
|
||||
default_output_file = into_path(get_export_gcode_filename(".gcode.3mf", false, export_all));
|
||||
if (default_output_file.empty()) {
|
||||
try {
|
||||
|
||||
//y71
|
||||
wxString filename = "";
|
||||
if (wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_string("filename_format") == "{input_filename_base}.gcode") {
|
||||
filename = get_export_gcode_filename("", true, export_all ? true : false);
|
||||
}
|
||||
else {
|
||||
filename = get_output_filename();
|
||||
}
|
||||
if (filename.find(_L("Untitled")) != wxString::npos && !export_all) {
|
||||
PartPlate* part_plate = get_partplate_list().get_plate(p->partplate_list.get_curr_plate_index());
|
||||
if (part_plate) {
|
||||
if (std::vector<ModelObject*> objects = part_plate->get_objects_on_this_plate(); objects.size() > 0) {
|
||||
filename = from_u8(objects[0]->name);
|
||||
}
|
||||
}
|
||||
filename = from_u8(get_pure_file_name(into_u8(filename)));
|
||||
if (filename.size() > 80) {
|
||||
filename = filename.substr(0, 80) + "...";
|
||||
}
|
||||
if (p->partplate_list.get_plate_count() > 1) {
|
||||
std::string plate_index_str = (boost::format("_plate_%1%") % std::to_string(p->partplate_list.get_curr_plate_index() + 1)).str();
|
||||
filename += wxString::FromUTF8(plate_index_str);
|
||||
}
|
||||
}
|
||||
start_dir = appconfig.get_last_output_dir("", false);
|
||||
wxString filename = get_export_gcode_filename(".gcode.3mf", true, export_all);
|
||||
|
||||
if (has_illegal_filename_characters(filename)) {
|
||||
filename = from_u8(filter_characters(filename.ToUTF8().data(), "#\'<>:\\|?*\""));
|
||||
}
|
||||
|
||||
std::string full_filename = start_dir + "/" + filename.utf8_string();
|
||||
default_output_file = boost::filesystem::path(full_filename);
|
||||
} catch(...) {
|
||||
|
||||
@@ -185,7 +185,7 @@ void SavePresetDialog::Item::update()
|
||||
|
||||
m_valid_type = Valid;
|
||||
wxString info_line;
|
||||
const char *unusable_symbols = " #;\'<>:/\\|?*\"";
|
||||
const char *unusable_symbols = "#\'<>:\\|?*\"";
|
||||
|
||||
const std::string unusable_suffix = PresetCollection::get_suffix_modified(); //"(modified)";
|
||||
for (size_t i = 0; i < std::strlen(unusable_symbols); i++) {
|
||||
|
||||
@@ -4482,25 +4482,24 @@ void SelectMachineDialog::set_default()
|
||||
}
|
||||
|
||||
fs::path filename_path(filename.c_str());
|
||||
//y52
|
||||
//y52 y71
|
||||
wxString file_name = from_u8(filename_path.filename().string());
|
||||
if (file_name.find(_L("Untitled")) != wxString::npos) {
|
||||
PartPlate* part_plate = m_plater->get_partplate_list().get_plate(m_print_plate_idx);
|
||||
if (part_plate) {
|
||||
if (std::vector<ModelObject*> objects = part_plate->get_objects_on_this_plate(); objects.size() > 0) {
|
||||
file_name = from_u8(objects[0]->name);
|
||||
for (int i = 1; i < objects.size(); i++) {
|
||||
file_name += " + " + from_u8(objects[i]->name);
|
||||
}
|
||||
}
|
||||
//if (file_name.size() > 100) {
|
||||
//file_name = file_name.substr(0, 97) + "...";
|
||||
//}
|
||||
file_name = from_u8(get_pure_file_name(into_u8(file_name)));
|
||||
if (file_name.size() > 80) {
|
||||
file_name = file_name.substr(0, 80) + "...";
|
||||
}
|
||||
if (m_plater->get_partplate_list().get_plate_count() > 1) {
|
||||
std::string plate_index_str = (boost::format("_plate_%1%") % std::to_string(m_print_plate_idx + 1)).str();
|
||||
file_name += wxString::FromUTF8(plate_index_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (file_name.size() > 80) {
|
||||
file_name = file_name.substr(0, 80) + "...";
|
||||
}
|
||||
|
||||
m_current_project_name = file_name;
|
||||
|
||||
@@ -4508,7 +4507,7 @@ void SelectMachineDialog::set_default()
|
||||
m_current_project_name = m_current_project_name.substr(0, m_current_project_name.size() - 6);
|
||||
|
||||
//unsupported character filter
|
||||
m_current_project_name = from_u8(filter_characters(m_current_project_name.ToUTF8().data(), " #;\'<>:\\|?*\""));
|
||||
m_current_project_name = from_u8(filter_characters(m_current_project_name.ToUTF8().data(), "#\'<>:\\|?*\""));
|
||||
|
||||
m_rename_text->SetLabelText(m_current_project_name);
|
||||
m_rename_normal_panel->Layout();
|
||||
|
||||
@@ -930,7 +930,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
|
||||
wxString info_line;
|
||||
auto new_dev_name = m_textCtr->GetTextCtrl()->GetValue();
|
||||
|
||||
const char * unusable_symbols = " #;\'<>:/\\|?*\"";
|
||||
const char * unusable_symbols = " #\'<>:\\|?*\"";
|
||||
const std::string unusable_suffix = PresetCollection::get_suffix_modified();
|
||||
|
||||
for (size_t i = 0; i < std::strlen(unusable_symbols); i++) {
|
||||
|
||||
@@ -1686,22 +1686,24 @@ void SendMultiMachinePage::set_default()
|
||||
}
|
||||
|
||||
fs::path filename_path(filename.c_str());
|
||||
//y52
|
||||
//y52 y71
|
||||
wxString file_name = from_u8(filename_path.filename().string());
|
||||
if (file_name.find(_L("Untitled")) != wxString::npos) {
|
||||
PartPlate* part_plate = m_plater->get_partplate_list().get_plate(m_print_plate_idx);
|
||||
if (part_plate) {
|
||||
if (std::vector<ModelObject*> objects = part_plate->get_objects_on_this_plate(); objects.size() > 0) {
|
||||
file_name = from_u8(objects[0]->name);
|
||||
for (int i = 1; i < objects.size(); i++) {
|
||||
file_name += " + " + from_u8(objects[i]->name);
|
||||
}
|
||||
}
|
||||
file_name = from_u8(get_pure_file_name(into_u8(file_name)));
|
||||
if (file_name.size() > 80) {
|
||||
file_name = file_name.substr(0, 80) + "...";
|
||||
}
|
||||
if (m_plater->get_partplate_list().get_plate_count() > 1) {
|
||||
std::string plate_index_str = (boost::format("_plate_%1%") % std::to_string(m_print_plate_idx + 1)).str();
|
||||
file_name += wxString::FromUTF8(plate_index_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (file_name.size() > 80) {
|
||||
file_name = file_name.substr(0, 80) + "...";
|
||||
}
|
||||
|
||||
m_current_project_name = file_name;
|
||||
|
||||
|
||||
@@ -2128,22 +2128,24 @@ void SendToPrinterDialog::set_default()
|
||||
}
|
||||
|
||||
fs::path filename_path(filename.c_str());
|
||||
//y52
|
||||
//y52 y71
|
||||
wxString file_name = from_u8(filename_path.filename().string());
|
||||
if (file_name.find(_L("Untitled")) != wxString::npos) {
|
||||
PartPlate* part_plate = m_plater->get_partplate_list().get_plate(m_print_plate_idx);
|
||||
if (part_plate) {
|
||||
if (std::vector<ModelObject*> objects = part_plate->get_objects_on_this_plate(); objects.size() > 0) {
|
||||
file_name = from_u8(objects[0]->name);
|
||||
for (int i = 1; i < objects.size(); i++) {
|
||||
file_name += " + " + from_u8(objects[i]->name);
|
||||
}
|
||||
}
|
||||
file_name = from_u8(get_pure_file_name(into_u8(file_name)));
|
||||
if (file_name.size() > 80) {
|
||||
file_name = file_name.substr(0, 80) + "...";
|
||||
}
|
||||
if (m_plater->get_partplate_list().get_plate_count() > 1) {
|
||||
std::string plate_index_str = (boost::format("_plate_%1%") % std::to_string(m_print_plate_idx + 1)).str();
|
||||
file_name += wxString::FromUTF8(plate_index_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (file_name.size() > 80) {
|
||||
file_name = file_name.substr(0, 80) + "...";
|
||||
}
|
||||
|
||||
m_current_project_name = file_name;
|
||||
if(m_current_project_name.find(".gcode") != wxString::npos)
|
||||
|
||||
@@ -2562,7 +2562,7 @@ void SyncAmsInfoDialog::set_default(bool hide_some)
|
||||
m_current_project_name = wxString::FromUTF8(file_name);
|
||||
|
||||
// unsupported character filter
|
||||
m_current_project_name = from_u8(filter_characters(m_current_project_name.ToUTF8().data(), " #;\'<>:/\\|?*\""));
|
||||
m_current_project_name = from_u8(filter_characters(m_current_project_name.ToUTF8().data(), "#\'<>:\\|?*\""));
|
||||
|
||||
// clear combobox
|
||||
m_list.clear();
|
||||
|
||||
@@ -2523,7 +2523,7 @@ void SyncBoxInfoDialog::set_default(bool hide_some)
|
||||
m_current_project_name = wxString::FromUTF8(file_name);
|
||||
|
||||
// unsupported character filter
|
||||
m_current_project_name = from_u8(filter_characters(m_current_project_name.ToUTF8().data(), " #;\'<>:/\\|?*\""));
|
||||
m_current_project_name = from_u8(filter_characters(m_current_project_name.ToUTF8().data(), "#\'<>:\\|?*\""));
|
||||
|
||||
// clear combobox
|
||||
m_list.clear();
|
||||
|
||||
Reference in New Issue
Block a user