mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-23 00:31:11 -06:00
Merge remote-tracking branch 'origin/master' into new_main_page_ui
This commit is contained in:
commit
e78a885247
39 changed files with 7971 additions and 817 deletions
|
@ -1287,6 +1287,10 @@ void GCode::process_layer(
|
|||
m_wipe_tower->tool_change(*this, extruder_id, extruder_id == layer_tools.extruders.back()) :
|
||||
this->set_extruder(extruder_id);
|
||||
|
||||
// let analyzer tag generator aware of a role type change
|
||||
if (m_enable_analyzer && layer_tools.has_wipe_tower && m_wipe_tower)
|
||||
m_last_analyzer_extrusion_role = erWipeTower;
|
||||
|
||||
if (extrude_skirt) {
|
||||
auto loops_it = skirt_loops_per_extruder.find(extruder_id);
|
||||
if (loops_it != skirt_loops_per_extruder.end()) {
|
||||
|
@ -2170,7 +2174,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||
double F = speed * 60; // convert mm/sec to mm/min
|
||||
|
||||
// extrude arc or line
|
||||
if (m_enable_extrusion_role_markers || m_enable_analyzer)
|
||||
if (m_enable_extrusion_role_markers)
|
||||
{
|
||||
if (path.role() != m_last_extrusion_role)
|
||||
{
|
||||
|
@ -2181,18 +2185,20 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||
sprintf(buf, ";_EXTRUSION_ROLE:%d\n", int(m_last_extrusion_role));
|
||||
gcode += buf;
|
||||
}
|
||||
if (m_enable_analyzer)
|
||||
{
|
||||
char buf[32];
|
||||
sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), int(m_last_extrusion_role));
|
||||
gcode += buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// adds analyzer tags and updates analyzer's tracking data
|
||||
if (m_enable_analyzer)
|
||||
{
|
||||
if (path.role() != m_last_analyzer_extrusion_role)
|
||||
{
|
||||
m_last_analyzer_extrusion_role = path.role();
|
||||
char buf[32];
|
||||
sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), int(m_last_analyzer_extrusion_role));
|
||||
gcode += buf;
|
||||
}
|
||||
|
||||
if (m_last_mm3_per_mm != path.mm3_per_mm)
|
||||
{
|
||||
m_last_mm3_per_mm = path.mm3_per_mm;
|
||||
|
@ -2230,6 +2236,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
|||
if (path.role() == erExternalPerimeter)
|
||||
comment += ";_EXTERNAL_PERIMETER";
|
||||
}
|
||||
|
||||
// F is mm per minute.
|
||||
gcode += m_writer.set_speed(F, "", comment);
|
||||
double path_length = 0.;
|
||||
|
|
|
@ -121,6 +121,7 @@ public:
|
|||
m_enable_cooling_markers(false),
|
||||
m_enable_extrusion_role_markers(false),
|
||||
m_enable_analyzer(false),
|
||||
m_last_analyzer_extrusion_role(erNone),
|
||||
m_layer_count(0),
|
||||
m_layer_index(-1),
|
||||
m_layer(nullptr),
|
||||
|
@ -253,6 +254,7 @@ protected:
|
|||
// Extended markers will be added during G-code generation.
|
||||
// The G-code Analyzer will remove these comments from the final G-code.
|
||||
bool m_enable_analyzer;
|
||||
ExtrusionRole m_last_analyzer_extrusion_role;
|
||||
// How many times will change_layer() be called?
|
||||
// change_layer() will update the progress bar.
|
||||
unsigned int m_layer_count;
|
||||
|
|
|
@ -536,7 +536,7 @@ float CoolingBuffer::calculate_layer_slowdown(std::vector<PerExtruderAdjustments
|
|||
adj.time_total = adj.elapsed_time_total();
|
||||
// Maximum time for this extruder, when all extrusion moves are slowed down to min_extrusion_speed.
|
||||
adj.time_maximum = adj.maximum_time_after_slowdown(true);
|
||||
if (adj.cooling_slow_down_enabled) {
|
||||
if (adj.cooling_slow_down_enabled && adj.lines.size() > 0) {
|
||||
by_slowdown_time.emplace_back(&adj);
|
||||
if (! m_cooling_logic_proportional)
|
||||
// sorts the lines, also sets adj.time_non_adjustable
|
||||
|
|
|
@ -275,7 +275,7 @@ bool GCodePreviewData::empty() const
|
|||
return extrusion.layers.empty() && travel.polylines.empty() && retraction.positions.empty() && unretraction.positions.empty();
|
||||
}
|
||||
|
||||
const GCodePreviewData::Color& GCodePreviewData::get_extrusion_role_color(ExtrusionRole role) const
|
||||
GCodePreviewData::Color GCodePreviewData::get_extrusion_role_color(ExtrusionRole role) const
|
||||
{
|
||||
return extrusion.role_colors[role];
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ public:
|
|||
void reset();
|
||||
bool empty() const;
|
||||
|
||||
const Color& get_extrusion_role_color(ExtrusionRole role) const;
|
||||
Color get_extrusion_role_color(ExtrusionRole role) const;
|
||||
Color get_height_color(float height) const;
|
||||
Color get_width_color(float width) const;
|
||||
Color get_feedrate_color(float feedrate) const;
|
||||
|
|
|
@ -126,6 +126,11 @@ public:
|
|||
m_extrusions.emplace_back(WipeTower::Extrusion(WipeTower::xy(rot.x, rot.y), width, m_current_tool));
|
||||
}
|
||||
|
||||
// adds tag for analyzer
|
||||
char buf[64];
|
||||
sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower);
|
||||
m_gcode += buf;
|
||||
|
||||
m_gcode += "G1";
|
||||
if (rot.x != rotated_current_pos.x) {
|
||||
m_gcode += set_format_X(rot.x); // Transform current position back to wipe tower coordinates (was updated by set_format_X)
|
||||
|
@ -488,11 +493,6 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime(
|
|||
.travel(cleaning_box.ld, 7200)
|
||||
.set_extruder_trimpot(750); // Increase the extruder driver current to allow fast ramming.
|
||||
|
||||
// adds tag for analyzer
|
||||
char buf[32];
|
||||
sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower);
|
||||
writer.append(buf);
|
||||
|
||||
for (size_t idx_tool = 0; idx_tool < tools.size(); ++ idx_tool) {
|
||||
unsigned int tool = tools[idx_tool];
|
||||
m_left_to_right = true;
|
||||
|
@ -585,12 +585,6 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo
|
|||
xy initial_position = cleaning_box.ld + WipeTower::xy(0.f,m_depth_traversed);
|
||||
writer.set_initial_position(initial_position);
|
||||
|
||||
|
||||
// adds tag for analyzer
|
||||
char buf[32];
|
||||
sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower);
|
||||
writer.append(buf);
|
||||
|
||||
// Increase the extruder driver current to allow fast ramming.
|
||||
writer.set_extruder_trimpot(750);
|
||||
|
||||
|
@ -658,12 +652,8 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(bool sideOnly, flo
|
|||
xy initial_position = wipeTower_box.lu - xy(m_perimeter_width * 6.f, 0);
|
||||
writer.set_initial_position(initial_position);
|
||||
|
||||
// adds tag for analyzer
|
||||
char buf[32];
|
||||
sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower);
|
||||
writer.append(buf)
|
||||
.extrude_explicit(wipeTower_box.ld - xy(m_perimeter_width * 6.f, 0), // Prime the extruder left of the wipe tower.
|
||||
1.5f * m_extrusion_flow * (wipeTower_box.lu.y - wipeTower_box.ld.y), 2400);
|
||||
writer.extrude_explicit(wipeTower_box.ld - xy(m_perimeter_width * 6.f, 0), // Prime the extruder left of the wipe tower.
|
||||
1.5f * m_extrusion_flow * (wipeTower_box.lu.y - wipeTower_box.ld.y), 2400);
|
||||
|
||||
// The tool is supposed to be active and primed at the time when the wipe tower brim is extruded.
|
||||
// Extrude 4 rounds of a brim around the future wipe tower.
|
||||
|
|
|
@ -404,7 +404,7 @@ bool Model::looks_like_multipart_object() const
|
|||
return false;
|
||||
}
|
||||
|
||||
void Model::convert_multipart_object()
|
||||
void Model::convert_multipart_object(unsigned int max_extruders)
|
||||
{
|
||||
if (this->objects.empty())
|
||||
return;
|
||||
|
@ -421,7 +421,7 @@ void Model::convert_multipart_object()
|
|||
if (new_v != nullptr)
|
||||
{
|
||||
new_v->name = o->name;
|
||||
new_v->config.set_deserialize("extruder", get_auto_extruder_id_as_string());
|
||||
new_v->config.set_deserialize("extruder", get_auto_extruder_id_as_string(max_extruders));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -481,20 +481,20 @@ bool Model::fits_print_volume(const FullPrintConfig &config) const
|
|||
return print_volume.contains(transformed_bounding_box());
|
||||
}
|
||||
|
||||
unsigned int Model::get_auto_extruder_id()
|
||||
unsigned int Model::get_auto_extruder_id(unsigned int max_extruders)
|
||||
{
|
||||
unsigned int id = s_auto_extruder_id;
|
||||
|
||||
if (++s_auto_extruder_id > 4)
|
||||
if (++s_auto_extruder_id > max_extruders)
|
||||
reset_auto_extruder_id();
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
std::string Model::get_auto_extruder_id_as_string()
|
||||
std::string Model::get_auto_extruder_id_as_string(unsigned int max_extruders)
|
||||
{
|
||||
char str_extruder[64];
|
||||
sprintf(str_extruder, "%ud", get_auto_extruder_id());
|
||||
sprintf(str_extruder, "%ud", get_auto_extruder_id(max_extruders));
|
||||
return str_extruder;
|
||||
}
|
||||
|
||||
|
@ -996,7 +996,7 @@ ModelMaterial* ModelVolume::assign_unique_material()
|
|||
// Split this volume, append the result to the object owning this volume.
|
||||
// Return the number of volumes created from this one.
|
||||
// This is useful to assign different materials to different volumes of an object.
|
||||
size_t ModelVolume::split()
|
||||
size_t ModelVolume::split(unsigned int max_extruders)
|
||||
{
|
||||
TriangleMeshPtrs meshptrs = this->mesh.split();
|
||||
if (meshptrs.size() <= 1) {
|
||||
|
@ -1019,7 +1019,7 @@ size_t ModelVolume::split()
|
|||
char str_idx[64];
|
||||
sprintf(str_idx, "_%d", idx + 1);
|
||||
this->object->volumes[ivolume]->name = name + str_idx;
|
||||
this->object->volumes[ivolume]->config.set_deserialize("extruder", Model::get_auto_extruder_id_as_string());
|
||||
this->object->volumes[ivolume]->config.set_deserialize("extruder", Model::get_auto_extruder_id_as_string(max_extruders));
|
||||
delete mesh;
|
||||
++ idx;
|
||||
}
|
||||
|
|
|
@ -173,8 +173,8 @@ public:
|
|||
// Split this volume, append the result to the object owning this volume.
|
||||
// Return the number of volumes created from this one.
|
||||
// This is useful to assign different materials to different volumes of an object.
|
||||
size_t split();
|
||||
|
||||
size_t split(unsigned int max_extruders);
|
||||
|
||||
ModelMaterial* assign_unique_material();
|
||||
|
||||
private:
|
||||
|
@ -280,7 +280,7 @@ public:
|
|||
void duplicate_objects_grid(size_t x, size_t y, coordf_t dist);
|
||||
|
||||
bool looks_like_multipart_object() const;
|
||||
void convert_multipart_object();
|
||||
void convert_multipart_object(unsigned int max_extruders);
|
||||
|
||||
// Ensures that the min z of the model is not negative
|
||||
void adjust_min_z();
|
||||
|
@ -291,8 +291,8 @@ public:
|
|||
|
||||
void print_info() const { for (const ModelObject *o : this->objects) o->print_info(); }
|
||||
|
||||
static unsigned int get_auto_extruder_id();
|
||||
static std::string get_auto_extruder_id_as_string();
|
||||
static unsigned int get_auto_extruder_id(unsigned int max_extruders);
|
||||
static std::string get_auto_extruder_id_as_string(unsigned int max_extruders);
|
||||
static void reset_auto_extruder_id();
|
||||
};
|
||||
|
||||
|
|
|
@ -111,7 +111,8 @@ PrintConfigDef::PrintConfigDef()
|
|||
"with cooling (use a fan) before tweaking this.");
|
||||
def->cli = "bridge-flow-ratio=f";
|
||||
def->min = 0;
|
||||
def->default_value = new ConfigOptionFloat(1);
|
||||
def->max = 2;
|
||||
def->default_value = new ConfigOptionFloat(1);
|
||||
|
||||
def = this->add("bridge_speed", coFloat);
|
||||
def->label = L("Bridges");
|
||||
|
|
|
@ -51,9 +51,6 @@ TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Point3>& fa
|
|||
|
||||
for (int i = 0; i < stl.stats.number_of_facets; i++) {
|
||||
stl_facet facet;
|
||||
facet.normal.x = 0;
|
||||
facet.normal.y = 0;
|
||||
facet.normal.z = 0;
|
||||
|
||||
const Pointf3& ref_f1 = points[facets[i].x];
|
||||
facet.vertex[0].x = ref_f1.x;
|
||||
|
@ -73,6 +70,13 @@ TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Point3>& fa
|
|||
facet.extra[0] = 0;
|
||||
facet.extra[1] = 0;
|
||||
|
||||
float normal[3];
|
||||
stl_calculate_normal(normal, &facet);
|
||||
stl_normalize_vector(normal);
|
||||
facet.normal.x = normal[0];
|
||||
facet.normal.y = normal[1];
|
||||
facet.normal.z = normal[2];
|
||||
|
||||
stl.facet_start[i] = facet;
|
||||
}
|
||||
stl_get_size(&stl);
|
||||
|
|
|
@ -84,6 +84,21 @@ inline T next_highest_power_of_2(T v)
|
|||
return ++ v;
|
||||
}
|
||||
|
||||
class PerlCallback {
|
||||
public:
|
||||
PerlCallback(void *sv) : m_callback(nullptr) { this->register_callback(sv); }
|
||||
PerlCallback() : m_callback(nullptr) {}
|
||||
~PerlCallback() { this->deregister_callback(); }
|
||||
void register_callback(void *sv);
|
||||
void deregister_callback();
|
||||
void call();
|
||||
void call(int i);
|
||||
void call(int i, int j);
|
||||
// void call(const std::vector<int> &ints);
|
||||
private:
|
||||
void *m_callback;
|
||||
};
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_Utils_hpp_
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <boost/thread.hpp>
|
||||
|
||||
#define SLIC3R_FORK_NAME "Slic3r Prusa Edition"
|
||||
#define SLIC3R_VERSION "1.40.0"
|
||||
#define SLIC3R_VERSION "1.40.0-alpha"
|
||||
#define SLIC3R_BUILD "UNKNOWN"
|
||||
|
||||
typedef int32_t coord_t;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include "Utils.hpp"
|
||||
|
||||
#include <locale>
|
||||
#include <ctime>
|
||||
|
||||
|
@ -135,44 +137,6 @@ const std::string& data_dir()
|
|||
|
||||
} // namespace Slic3r
|
||||
|
||||
#ifdef SLIC3R_HAS_BROKEN_CROAK
|
||||
|
||||
// Some Strawberry Perl builds (mainly the latest 64bit builds) have a broken mechanism
|
||||
// for emiting Perl exception after handling a C++ exception. Perl interpreter
|
||||
// simply hangs. Better to show a message box in that case and stop the application.
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
void confess_at(const char *file, int line, const char *func, const char *format, ...)
|
||||
{
|
||||
char dest[1024*8];
|
||||
va_list argptr;
|
||||
va_start(argptr, format);
|
||||
vsprintf(dest, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
char filelinefunc[1024*8];
|
||||
sprintf(filelinefunc, "\r\nin function: %s\r\nfile: %s\r\nline: %d\r\n", func, file, line);
|
||||
strcat(dest, filelinefunc);
|
||||
strcat(dest, "\r\n Closing the application.\r\n");
|
||||
#ifdef WIN32
|
||||
::MessageBoxA(NULL, dest, "Slic3r Prusa Edition", MB_OK | MB_ICONERROR);
|
||||
#endif
|
||||
|
||||
// Give up.
|
||||
printf(dest);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <xsinit.h>
|
||||
|
||||
void
|
||||
|
@ -202,7 +166,88 @@ confess_at(const char *file, int line, const char *func,
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
void PerlCallback::register_callback(void *sv)
|
||||
{
|
||||
if (! SvROK((SV*)sv) || SvTYPE(SvRV((SV*)sv)) != SVt_PVCV)
|
||||
croak("Not a Callback %_ for PerlFunction", (SV*)sv);
|
||||
if (m_callback)
|
||||
SvSetSV((SV*)m_callback, (SV*)sv);
|
||||
else
|
||||
m_callback = newSVsv((SV*)sv);
|
||||
}
|
||||
|
||||
void PerlCallback::deregister_callback()
|
||||
{
|
||||
if (m_callback) {
|
||||
sv_2mortal((SV*)m_callback);
|
||||
m_callback = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void PerlCallback::call()
|
||||
{
|
||||
if (! m_callback)
|
||||
return;
|
||||
dSP;
|
||||
ENTER;
|
||||
SAVETMPS;
|
||||
PUSHMARK(SP);
|
||||
PUTBACK;
|
||||
perl_call_sv(SvRV((SV*)m_callback), G_DISCARD);
|
||||
FREETMPS;
|
||||
LEAVE;
|
||||
}
|
||||
|
||||
void PerlCallback::call(int i)
|
||||
{
|
||||
if (! m_callback)
|
||||
return;
|
||||
dSP;
|
||||
ENTER;
|
||||
SAVETMPS;
|
||||
PUSHMARK(SP);
|
||||
XPUSHs(sv_2mortal(newSViv(i)));
|
||||
PUTBACK;
|
||||
perl_call_sv(SvRV((SV*)m_callback), G_DISCARD);
|
||||
FREETMPS;
|
||||
LEAVE;
|
||||
}
|
||||
|
||||
void PerlCallback::call(int i, int j)
|
||||
{
|
||||
if (! m_callback)
|
||||
return;
|
||||
dSP;
|
||||
ENTER;
|
||||
SAVETMPS;
|
||||
PUSHMARK(SP);
|
||||
XPUSHs(sv_2mortal(newSViv(i)));
|
||||
XPUSHs(sv_2mortal(newSViv(j)));
|
||||
PUTBACK;
|
||||
perl_call_sv(SvRV((SV*)m_callback), G_DISCARD);
|
||||
FREETMPS;
|
||||
LEAVE;
|
||||
}
|
||||
|
||||
/*
|
||||
void PerlCallback::call(const std::vector<int> &ints)
|
||||
{
|
||||
if (! m_callback)
|
||||
return;
|
||||
dSP;
|
||||
ENTER;
|
||||
SAVETMPS;
|
||||
PUSHMARK(SP);
|
||||
AV* av = newAV();
|
||||
for (int i : ints)
|
||||
av_push(av, newSViv(i));
|
||||
XPUSHs(av);
|
||||
PUTBACK;
|
||||
perl_call_sv(SvRV((SV*)m_callback), G_DISCARD);
|
||||
FREETMPS;
|
||||
LEAVE;
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef NOMINMAX
|
||||
|
|
|
@ -443,13 +443,16 @@ std::vector<int> GLVolumeCollection::load_object(
|
|||
int GLVolumeCollection::load_wipe_tower_preview(
|
||||
int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool use_VBOs)
|
||||
{
|
||||
float color[4] = { 1.0f, 1.0f, 0.0f, 0.5f };
|
||||
float color[4] = { 0.5f, 0.5f, 0.0f, 0.5f };
|
||||
this->volumes.emplace_back(new GLVolume(color));
|
||||
GLVolume &v = *this->volumes.back();
|
||||
|
||||
auto mesh = make_cube(width, depth, height);
|
||||
mesh.translate(-width/2.f,-depth/2.f,0.f);
|
||||
Point origin_of_rotation(0.f,0.f);
|
||||
if (height == 0.0f)
|
||||
height = 0.1f;
|
||||
|
||||
auto mesh = make_cube(width, depth, height);
|
||||
mesh.translate(-width / 2.f, -depth / 2.f, 0.f);
|
||||
Point origin_of_rotation(0.f, 0.f);
|
||||
mesh.rotate(rotation_angle,&origin_of_rotation);
|
||||
|
||||
if (use_VBOs)
|
||||
|
@ -2201,7 +2204,7 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data,
|
|||
return 0.0f;
|
||||
}
|
||||
|
||||
static const GCodePreviewData::Color& path_color(const GCodePreviewData& data, const std::vector<float>& tool_colors, float value)
|
||||
static GCodePreviewData::Color path_color(const GCodePreviewData& data, const std::vector<float>& tool_colors, float value)
|
||||
{
|
||||
switch (data.extrusion.view_type)
|
||||
{
|
||||
|
@ -2217,7 +2220,7 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data,
|
|||
return data.get_volumetric_rate_color(value);
|
||||
case GCodePreviewData::Extrusion::Tool:
|
||||
{
|
||||
static GCodePreviewData::Color color;
|
||||
GCodePreviewData::Color color;
|
||||
::memcpy((void*)color.rgba, (const void*)(tool_colors.data() + (unsigned int)value * 4), 4 * sizeof(float));
|
||||
return color;
|
||||
}
|
||||
|
@ -2254,7 +2257,6 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data,
|
|||
};
|
||||
|
||||
typedef std::vector<Filter> FiltersList;
|
||||
|
||||
size_t initial_volumes_count = volumes.volumes.size();
|
||||
|
||||
// detects filters
|
||||
|
@ -2278,7 +2280,6 @@ void _3DScene::_load_gcode_extrusion_paths(const GCodePreviewData& preview_data,
|
|||
for (Filter& filter : filters)
|
||||
{
|
||||
s_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Extrusion, (unsigned int)filter.role, (unsigned int)volumes.volumes.size());
|
||||
|
||||
GLVolume* volume = new GLVolume(Helper::path_color(preview_data, tool_colors, filter.value).rgba);
|
||||
if (volume != nullptr)
|
||||
{
|
||||
|
|
|
@ -82,10 +82,8 @@ namespace Slic3r { namespace GUI {
|
|||
return std::regex_match(string, regex_pattern);
|
||||
}
|
||||
|
||||
// boost::any Field::get_value_by_opt_type(wxString& str)
|
||||
void Field::get_value_by_opt_type(wxString& str)
|
||||
{
|
||||
// boost::any m_value;
|
||||
switch (m_opt.type){
|
||||
case coInt:
|
||||
m_value = wxAtoi(str);
|
||||
|
@ -96,8 +94,25 @@ namespace Slic3r { namespace GUI {
|
|||
case coFloat:{
|
||||
if (m_opt.type == coPercent && str.Last() == '%')
|
||||
str.RemoveLast();
|
||||
else if (str.Last() == '%') {
|
||||
wxString label = m_Label->GetLabel();
|
||||
if (label.Last() == '\n') label.RemoveLast();
|
||||
while (label.Last() == ' ') label.RemoveLast();
|
||||
if (label.Last() == ':') label.RemoveLast();
|
||||
show_error(m_parent, wxString::Format(_(L("%s doesn't support percentage")), label));
|
||||
set_value(double_to_string(m_opt.min), true);
|
||||
m_value = double(m_opt.min);
|
||||
break;
|
||||
}
|
||||
double val;
|
||||
str.ToCDouble(&val);
|
||||
if (m_opt.min > val && val > m_opt.max)
|
||||
{
|
||||
show_error(m_parent, _(L("Input value is out of range")));
|
||||
if (m_opt.min > val) val = m_opt.min;
|
||||
if (val > m_opt.max) val = m_opt.max;
|
||||
set_value(double_to_string(val), true);
|
||||
}
|
||||
m_value = val;
|
||||
break; }
|
||||
case coString:
|
||||
|
@ -108,8 +123,6 @@ namespace Slic3r { namespace GUI {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// return m_value;
|
||||
}
|
||||
|
||||
void TextCtrl::BUILD() {
|
||||
|
@ -170,17 +183,32 @@ namespace Slic3r { namespace GUI {
|
|||
//! to allow the default handling
|
||||
event.Skip();
|
||||
//! eliminating the g-code pop up text description
|
||||
temp->GetToolTip()->Enable(false);
|
||||
bool flag = false;
|
||||
#ifdef __WXGTK__
|
||||
// I have no idea why, but on GTK flag works in other way
|
||||
flag = true;
|
||||
#endif // __WXGTK__
|
||||
temp->GetToolTip()->Enable(flag);
|
||||
}), temp->GetId());
|
||||
|
||||
#if !defined(__WXGTK__)
|
||||
temp->Bind(wxEVT_KILL_FOCUS, ([this, temp](wxEvent& e)
|
||||
{
|
||||
e.Skip();// on_kill_focus(e);
|
||||
temp->GetToolTip()->Enable(true);
|
||||
}), temp->GetId());
|
||||
#endif // __WXGTK__
|
||||
|
||||
temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent) { on_change_field(); }), temp->GetId());
|
||||
|
||||
// select all text using Ctrl+A
|
||||
temp->Bind(wxEVT_CHAR, ([temp](wxKeyEvent& event)
|
||||
{
|
||||
if (wxGetKeyState(wxKeyCode('A')) && wxGetKeyState(WXK_CONTROL))
|
||||
temp->SetSelection(-1, -1); //select all
|
||||
event.Skip();
|
||||
}));
|
||||
|
||||
// recast as a wxWindow to fit the calling convention
|
||||
window = dynamic_cast<wxWindow*>(temp);
|
||||
}
|
||||
|
@ -188,9 +216,9 @@ namespace Slic3r { namespace GUI {
|
|||
boost::any& TextCtrl::get_value()
|
||||
{
|
||||
wxString ret_str = static_cast<wxTextCtrl*>(window)->GetValue();
|
||||
/*boost::any ret_val*/get_value_by_opt_type(ret_str);
|
||||
get_value_by_opt_type(ret_str);
|
||||
|
||||
return m_value;//ret_val;
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void TextCtrl::enable() { dynamic_cast<wxTextCtrl*>(window)->Enable(); dynamic_cast<wxTextCtrl*>(window)->SetEditable(true); }
|
||||
|
|
|
@ -124,7 +124,6 @@ public:
|
|||
virtual wxWindow* getWindow() { return nullptr; }
|
||||
|
||||
bool is_matched(const std::string& string, const std::string& pattern);
|
||||
// boost::any get_value_by_opt_type(wxString& str);
|
||||
void get_value_by_opt_type(wxString& str);
|
||||
|
||||
/// Factory method for generating new derived classes.
|
||||
|
|
|
@ -118,21 +118,34 @@ void OptionsGroup::append_line(const Line& line, wxStaticText** colored_Label/*
|
|||
if (option_set.size() == 1 && label_width == 0 && option_set.front().opt.full_width &&
|
||||
option_set.front().opt.sidetext.size() == 0 && option_set.front().side_widget == nullptr &&
|
||||
line.get_extra_widgets().size() == 0) {
|
||||
wxSizer* tmp_sizer;
|
||||
#ifdef __WXGTK__
|
||||
tmp_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
m_panel->SetSizer(tmp_sizer);
|
||||
m_panel->Layout();
|
||||
#else
|
||||
tmp_sizer = sizer;
|
||||
#endif /* __WXGTK__ */
|
||||
|
||||
const auto& option = option_set.front();
|
||||
const auto& field = build_field(option);
|
||||
|
||||
auto btn_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
btn_sizer->Add(field->m_Undo_to_sys_btn);
|
||||
btn_sizer->Add(field->m_Undo_btn);
|
||||
sizer->Add(btn_sizer, 0, wxEXPAND | wxALL, 0);
|
||||
tmp_sizer->Add(btn_sizer, 0, wxEXPAND | wxALL, 0);
|
||||
if (is_window_field(field))
|
||||
sizer->Add(field->getWindow(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5);
|
||||
tmp_sizer->Add(field->getWindow(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5);
|
||||
if (is_sizer_field(field))
|
||||
sizer->Add(field->getSizer(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5);
|
||||
tmp_sizer->Add(field->getSizer(), 0, wxEXPAND | wxALL, wxOSX ? 0 : 5);
|
||||
return;
|
||||
}
|
||||
|
||||
auto grid_sizer = m_grid_sizer;
|
||||
#ifdef __WXGTK__
|
||||
m_panel->SetSizer(m_grid_sizer);
|
||||
m_panel->Layout();
|
||||
#endif /* __WXGTK__ */
|
||||
|
||||
// Build a label if we have it
|
||||
wxStaticText* label=nullptr;
|
||||
|
|
|
@ -138,8 +138,6 @@ public:
|
|||
static_cast<wxFlexGridSizer*>(m_grid_sizer)->AddGrowableCol(label_width != 0);
|
||||
#ifdef __WXGTK__
|
||||
m_panel = new wxPanel( _parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
m_panel->SetSizer(m_grid_sizer);
|
||||
m_panel->Layout();
|
||||
sizer->Fit(m_panel);
|
||||
sizer->Add(m_panel, 0, wxEXPAND | wxALL, wxOSX||!staticbox ? 0: 5);
|
||||
#else
|
||||
|
|
|
@ -2125,7 +2125,7 @@ void Tab::save_preset(std::string name /*= ""*/)
|
|||
return;
|
||||
}
|
||||
if (existing && (existing->is_external)) {
|
||||
show_error(this, _(L("Cannot overwrite an external.")));
|
||||
show_error(this, _(L("Cannot overwrite an external profile.")));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,15 +195,6 @@ SV* to_SV(TriangleMesh* THIS);
|
|||
|
||||
}
|
||||
|
||||
#ifdef SLIC3R_HAS_BROKEN_CROAK
|
||||
#undef croak
|
||||
#ifdef _MSC_VER
|
||||
#define croak(...) confess_at(__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
|
||||
#else
|
||||
#define croak(...) confess_at(__FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Defined in wxPerlIface.cpp
|
||||
// Return a pointer to the associated wxWidgets object instance given by classname.
|
||||
extern void* wxPli_sv_2_object( pTHX_ SV* scalar, const char* classname );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue