mirror of
https://github.com/QIDITECH/QIDIStudio.git
synced 2026-02-02 01:48:42 +03:00
update slic3r
This commit is contained in:
@@ -374,7 +374,11 @@ void CreateObjectJob::process(Ctl &ctl)
|
||||
if (m_input.base->shape.projection.use_surface) m_input.base->shape.projection.use_surface = false;
|
||||
|
||||
// auto was_canceled = ::was_canceled(ctl, *m_input.base);
|
||||
m_result = create_mesh(*m_input.base);
|
||||
if (m_input.base->merge_shape || !m_input.base->text_lines.empty()) { // || m_input.base->shape.shapes_with_ids.size() > 20
|
||||
m_result = create_mesh(*m_input.base);
|
||||
} else {
|
||||
m_results = create_meshs(*m_input.base);
|
||||
}
|
||||
|
||||
// Create new object
|
||||
// calculate X,Y offset position for lay on platter in place of
|
||||
@@ -407,7 +411,7 @@ void CreateObjectJob::finalize(bool canceled, std::exception_ptr &eptr)
|
||||
{
|
||||
if (!_finalize(canceled, eptr, *m_input.base)) return;
|
||||
// only for sure
|
||||
if (m_result.empty()) {
|
||||
if (m_result.empty() && m_results.empty()) {
|
||||
create_message("Can't create empty object.");
|
||||
return;
|
||||
}
|
||||
@@ -425,13 +429,28 @@ void CreateObjectJob::finalize(bool canceled, std::exception_ptr &eptr)
|
||||
new_object->name = m_input.base->volume_name;
|
||||
new_object->add_instance(); // each object should have at list one instance
|
||||
|
||||
ModelVolume *new_volume = new_object->add_volume(std::move(m_result));
|
||||
// set a default extruder value, since user can't add it manually
|
||||
new_volume->config.set_key_value("extruder", new ConfigOptionInt(0));
|
||||
|
||||
// write emboss data into volume
|
||||
m_input.base->write(*new_volume);
|
||||
if (!m_result.empty()) {
|
||||
ModelVolume *new_volume = new_object->add_volume(std::move(m_result));
|
||||
// set a default extruder value, since user can't add it manually
|
||||
new_volume->config.set_key_value("extruder", new ConfigOptionInt(0));
|
||||
// write emboss data into volume
|
||||
m_input.base->write(*new_volume);
|
||||
} else if (!m_results.empty()) {
|
||||
int index = 0;
|
||||
for (auto shape : m_input.base->shape.shapes_with_ids) {
|
||||
if (shape.expoly.empty())
|
||||
continue;
|
||||
ModelVolume *new_volume = new_object->add_volume(std::move(m_results[index]));
|
||||
// set a default extruder value, since user can't add it manually
|
||||
new_volume->config.set_key_value("extruder", new ConfigOptionInt(0));
|
||||
//donot write emboss data into volume
|
||||
new_volume->name = new_object->name + "_" + std::to_string(index);
|
||||
index++;
|
||||
}
|
||||
|
||||
} else {
|
||||
create_message("CreateObjectJob:unknown error.");
|
||||
}
|
||||
// set transformation
|
||||
Slic3r::Geometry::Transformation tr(m_transformation);
|
||||
new_object->instances.front()->set_transformation(tr);
|
||||
@@ -632,6 +651,26 @@ TriangleMesh create_mesh(DataBase &input)
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<TriangleMesh> create_meshs(DataBase &input)
|
||||
{
|
||||
std::vector<TriangleMesh> meshs;
|
||||
|
||||
// NOTE: SHAPE_SCALE is applied in ProjectZ
|
||||
double scale = input.shape.scale;
|
||||
double depth = input.shape.projection.depth / scale;
|
||||
auto projectZ = std::make_unique<ProjectZ>(depth);
|
||||
float offset = input.is_outside ? -SAFE_SURFACE_OFFSET : (SAFE_SURFACE_OFFSET - input.shape.projection.depth);
|
||||
if (input.from_surface.has_value()) offset += *input.from_surface;
|
||||
Transform3d tr = Eigen::Translation<double, 3>(0., 0., static_cast<double>(offset)) * Eigen::Scaling(scale);
|
||||
ProjectTransform project(std::move(projectZ), tr);
|
||||
|
||||
for (auto shape : input.shape.shapes_with_ids) {
|
||||
if (shape.expoly.empty()) continue;
|
||||
meshs.emplace_back(TriangleMesh(polygons2model(shape.expoly, project)));
|
||||
}
|
||||
return meshs;
|
||||
}
|
||||
|
||||
void create_volume(
|
||||
TriangleMesh &&mesh, const ObjectID &object_id, const ModelVolumeType type, const std::optional<Transform3d> &trmat, const DataBase &data, unsigned char gizmo_type)
|
||||
{
|
||||
@@ -967,9 +1006,13 @@ bool start_update_volume(DataUpdate &&data, const ModelVolume &volume, const Sel
|
||||
return execute_job(std::move(job));
|
||||
#endif // EXECUTE_UPDATE_ON_MAIN_THREAD
|
||||
}
|
||||
bool is_merge_shape_before_create_object() {
|
||||
return GUI::wxGetApp().app_config->get_bool("import_single_svg_and_split") ? false : true;
|
||||
}
|
||||
|
||||
bool start_create_object_job(const CreateVolumeParams &input, DataBasePtr emboss_data, const Vec2d &coor)
|
||||
{
|
||||
emboss_data->merge_shape = input.merge_shape;
|
||||
const Pointfs & bed_shape = input.build_volume.printable_area();
|
||||
DataCreateObject m_input{std::move(emboss_data), coor, input.camera, bed_shape, input.gizmo_type, input.angle};
|
||||
|
||||
@@ -1025,17 +1068,20 @@ bool start_create_volume_without_position(CreateVolumeParams &input, DataBasePtr
|
||||
const ModelObjectPtrs &objects = selection.get_model()->objects;
|
||||
|
||||
// No selected object so create new object
|
||||
if (selection.is_empty() || object_idx < 0 || static_cast<size_t>(object_idx) >= objects.size())
|
||||
if (selection.is_empty() || object_idx < 0 || static_cast<size_t>(object_idx) >= objects.size()){
|
||||
// create Object on center of screen
|
||||
// when ray throw center of screen not hit bed it create object on center of bed
|
||||
input.merge_shape = is_merge_shape_before_create_object();
|
||||
return start_create_object_job(input, std::move(data), screen_center);
|
||||
|
||||
}
|
||||
// create volume inside of selected object
|
||||
Vec2d coor;
|
||||
const Camera &camera = wxGetApp().plater()->get_camera();
|
||||
input.gl_volume = find_closest(selection, screen_center, camera, objects, &coor);
|
||||
if (input.gl_volume == nullptr)
|
||||
if (input.gl_volume == nullptr) {
|
||||
input.merge_shape = is_merge_shape_before_create_object();
|
||||
return start_create_object_job(input, std::move(data), screen_center);
|
||||
}
|
||||
else {
|
||||
return start_create_volume_on_surface_job(input, std::move(data), coor);
|
||||
}
|
||||
@@ -1097,6 +1143,7 @@ bool start_create_volume_on_surface_job(CreateVolumeParams &input, DataBasePtr d
|
||||
// object. After right click, object is selected and object_idx is set
|
||||
// also hit must exist. But there is options to add text by object list
|
||||
if (!hit.has_value()) { // modify by qds
|
||||
input.merge_shape = is_merge_shape_before_create_object();
|
||||
return start_create_object_job(input, std::move(data), mouse_pos); // return on_bad_state(std::move(data), object);
|
||||
}
|
||||
|
||||
@@ -1114,9 +1161,11 @@ bool start_create_volume(CreateVolumeParams &input, DataBasePtr data, const Vec2
|
||||
if (data == nullptr) return false;
|
||||
if (!check(input)) return false;
|
||||
|
||||
if (input.gl_volume == nullptr || !input.gl_volume->selected)
|
||||
if (input.gl_volume == nullptr || !input.gl_volume->selected) {
|
||||
input.merge_shape = is_merge_shape_before_create_object();
|
||||
// object is not under mouse position soo create object on plater
|
||||
return start_create_object_job(input, std::move(data), mouse_pos);
|
||||
}
|
||||
else { // modify by qds
|
||||
return start_create_volume_on_surface_job(input, std::move(data), mouse_pos);
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public:
|
||||
std::shared_ptr<std::atomic<bool>> cancel;
|
||||
// shape to emboss
|
||||
EmbossShape shape;
|
||||
bool merge_shape{true};
|
||||
};
|
||||
|
||||
struct DataCreateVolumeUtil : public DataBase // modfiy bu qds //struct DataCreateVolume : public DataBase
|
||||
@@ -124,6 +125,7 @@ struct DataUpdate
|
||||
std::optional<float> distance = {};
|
||||
// Wanted additionl rotation around Z of new created volume
|
||||
std::optional<float> angle = {};
|
||||
bool merge_shape{true};
|
||||
};
|
||||
struct DataCreateObject
|
||||
{
|
||||
@@ -251,6 +253,7 @@ class CreateObjectJob : public JobNew
|
||||
{
|
||||
DataCreateObject m_input;
|
||||
TriangleMesh m_result;
|
||||
std::vector<TriangleMesh> m_results;
|
||||
Transform3d m_transformation;
|
||||
|
||||
public:
|
||||
@@ -318,6 +321,7 @@ static ExPolygons create_shape(DataBase &input);
|
||||
static TriangleMesh create_mesh_per_glyph(DataBase &input);
|
||||
static TriangleMesh try_create_mesh(DataBase &input);
|
||||
static TriangleMesh create_mesh(DataBase &input);
|
||||
static std::vector<TriangleMesh> create_meshs(DataBase &input);
|
||||
static indexed_triangle_set cut_surface_to_its(const ExPolygons &shapes, const Transform3d &tr, const SurfaceVolumeData::ModelSources &sources, DataBase &input);
|
||||
static TriangleMesh cut_per_glyph_surface(DataBase &input1, const SurfaceVolumeData &input2);
|
||||
static TriangleMesh cut_surface(DataBase &input1, const SurfaceVolumeData &input2);
|
||||
|
||||
@@ -21,6 +21,7 @@ static wxString file_over_size_str = _L("The print file exceeds the max
|
||||
static wxString print_canceled_str = _L("Task canceled.");
|
||||
static wxString send_print_failed_str = _L("Failed to send the print job. Please try again.");
|
||||
static wxString upload_ftp_failed_str = _L("Failed to upload file to ftp. Please try again.");
|
||||
static wxString print_signed_str = _L("Your software is not signed, and some printing functions have been restricted. Please use the officially signed software version.");
|
||||
|
||||
static wxString desc_network_error = _L("Check the current status of the qidi server by clicking on the link above.");
|
||||
static wxString desc_file_too_large = _L("The size of the print file is too large. Please adjust the file size and try again.");
|
||||
@@ -593,8 +594,10 @@ void PrintJob::process()
|
||||
|
||||
if (result < 0) {
|
||||
curr_percent = -1;
|
||||
|
||||
if (result == QIDI_NETWORK_ERR_PRINT_WR_FILE_NOT_EXIST || result == QIDI_NETWORK_ERR_PRINT_SP_FILE_NOT_EXIST) {
|
||||
if (result == QIDI_NETOWRK_ERR_PRINT_SP_ENC_FLAG_NOT_READY) {
|
||||
msg_text = _L("Retrieving printer information, please try again later.");
|
||||
}
|
||||
else if (result == QIDI_NETWORK_ERR_PRINT_WR_FILE_NOT_EXIST || result == QIDI_NETWORK_ERR_PRINT_SP_FILE_NOT_EXIST) {
|
||||
msg_text = file_is_not_exists_str;
|
||||
} else if (result == QIDI_NETWORK_ERR_PRINT_SP_FILE_OVER_SIZE || result == QIDI_NETWORK_ERR_PRINT_WR_FILE_OVER_SIZE) {
|
||||
msg_text = file_over_size_str;
|
||||
@@ -607,6 +610,8 @@ void PrintJob::process()
|
||||
} else if (result == QIDI_NETWORK_ERR_CANCELED) {
|
||||
msg_text = print_canceled_str;
|
||||
this->update_status(0, msg_text);
|
||||
} else if (result == QIDI_NETWORK_SIGNED_ERROR) {
|
||||
msg_text = print_signed_str;
|
||||
} else {
|
||||
msg_text = send_print_failed_str;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user