Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libslic3r/PrintConfig.cpp14
-rw-r--r--src/libslic3r/PrintConfig.hpp18
-rw-r--r--src/libslic3r/PrintExport.hpp37
-rw-r--r--src/libslic3r/SLA/SLASupportTree.cpp6
-rw-r--r--src/libslic3r/SLAPrint.cpp19
-rw-r--r--src/slic3r/GUI/OptionsGroup.cpp3
-rw-r--r--src/slic3r/GUI/Preset.cpp2
-rw-r--r--src/slic3r/GUI/Tab.cpp2
8 files changed, 75 insertions, 26 deletions
diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp
index 6b40f50bf..ab26f5d54 100644
--- a/src/libslic3r/PrintConfig.cpp
+++ b/src/libslic3r/PrintConfig.cpp
@@ -2389,12 +2389,14 @@ void PrintConfigDef::init_sla_params()
def->min = 100;
def->default_value = new ConfigOptionInt(1440);
- def = this->add("display_flip_xy", coBool);
- def->label = ("Flip X and Y axis");
- def->tooltip = L("Flip X and Y axis in the output raster");
- def->cli = "display-flip-xy=i";
- def->min = 0;
- def->default_value = new ConfigOptionBool(true);
+ def = this->add("display_orientation", coEnum);
+ def->label = L("Display orientation");
+ def->tooltip = L("Display orientation");
+ def->cli = "display-orientation=s";
+ def->enum_keys_map = &ConfigOptionEnum<SLADisplayOrientation>::get_enum_values();
+ def->enum_values.push_back("Landscape");
+ def->enum_values.push_back("Portrait");
+ def->default_value = new ConfigOptionEnum<SLADisplayOrientation>(sladoPortrait);
def = this->add("printer_correction", coFloats);
def->full_label = L("Printer scaling correction");
diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp
index c3d17c451..f639cad76 100644
--- a/src/libslic3r/PrintConfig.hpp
+++ b/src/libslic3r/PrintConfig.hpp
@@ -56,6 +56,11 @@ enum FilamentType {
ftPLA, ftABS, ftPET, ftHIPS, ftFLEX, ftSCAFF, ftEDGE, ftNGEN, ftPVA
};
+enum SLADisplayOrientation {
+ sladoLandscape,
+ sladoPortrait
+};
+
template<> inline const t_config_enum_values& ConfigOptionEnum<PrinterTechnology>::get_enum_values() {
static t_config_enum_values keys_map;
if (keys_map.empty()) {
@@ -148,6 +153,15 @@ template<> inline const t_config_enum_values& ConfigOptionEnum<FilamentType>::ge
return keys_map;
}
+template<> inline const t_config_enum_values& ConfigOptionEnum<SLADisplayOrientation>::get_enum_values() {
+ static const t_config_enum_values keys_map = {
+ { "Landscape", sladoLandscape},
+ { "Portrait", sladoPortrait}
+ };
+
+ return keys_map;
+}
+
// Defines each and every confiuration option of Slic3r, including the properties of the GUI dialogs.
// Does not store the actual values, but defines default values.
class PrintConfigDef : public ConfigDef
@@ -1035,7 +1049,7 @@ public:
ConfigOptionFloat display_height;
ConfigOptionInt display_pixels_x;
ConfigOptionInt display_pixels_y;
- ConfigOptionBool display_flip_xy;
+ ConfigOptionEnum<SLADisplayOrientation> display_orientation;
ConfigOptionFloats printer_correction;
protected:
void initialize(StaticCacheBase &cache, const char *base_ptr)
@@ -1047,7 +1061,7 @@ protected:
OPT_PTR(display_height);
OPT_PTR(display_pixels_x);
OPT_PTR(display_pixels_y);
- OPT_PTR(display_flip_xy);
+ OPT_PTR(display_orientation);
OPT_PTR(printer_correction);
}
};
diff --git a/src/libslic3r/PrintExport.hpp b/src/libslic3r/PrintExport.hpp
index 3f96cfaea..8187d7bf0 100644
--- a/src/libslic3r/PrintExport.hpp
+++ b/src/libslic3r/PrintExport.hpp
@@ -116,6 +116,7 @@ template<> class FilePrinter<FilePrinterFormat::SLA_PNGZIP>
Raster::PixelDim m_pxdim;
double m_exp_time_s = .0, m_exp_time_first_s = .0;
double m_layer_height = .0;
+ Raster::Origin m_o = Raster::Origin::TOP_LEFT;
std::string createIniContent(const std::string& projectname) {
double layer_height = m_layer_height;
@@ -145,19 +146,41 @@ template<> class FilePrinter<FilePrinterFormat::SLA_PNGZIP>
+layerh_str+"+printer=DWARF3\n";
}
- // The PNG format has its origin in the top left corner.
- static const Raster::Origin ORIGIN = Raster::Origin::TOP_LEFT;
-
public:
+
+ enum RasterOrientation {
+ RO_LANDSCAPE,
+ RO_PORTRAIT
+ };
+
+ // We will play with the raster's coordinate origin parameter. When the
+ // printer should print in landscape mode it should have the Y axis flipped
+ // because the layers should be displayed upside down. PNG has its
+ // coordinate origin in the top-left corner so normally the Raster objects
+ // should be instantiated with the TOP_LEFT flag. However, in landscape mode
+ // we do want the pictures to be upside down so we will make BOTTOM_LEFT
+ // type rasters and the PNG format will do the flipping automatically.
+
+ // In case of portrait images, we have to rotate the image by a 90 degrees
+ // and flip the y axis. To get the correct upside-down orientation of the
+ // slice images, we can flip the x and y coordinates of the input polygons
+ // and do the Y flipping of the image. This will generate the correct
+ // orientation in portrait mode.
+
inline FilePrinter(double width_mm, double height_mm,
unsigned width_px, unsigned height_px,
double layer_height,
- double exp_time, double exp_time_first):
+ double exp_time, double exp_time_first,
+ RasterOrientation ro = RO_PORTRAIT):
m_res(width_px, height_px),
m_pxdim(width_mm/width_px, height_mm/height_px),
m_exp_time_s(exp_time),
m_exp_time_first_s(exp_time_first),
- m_layer_height(layer_height)
+ m_layer_height(layer_height),
+
+ // Here is the trick with the orientation.
+ m_o(ro == RO_LANDSCAPE? Raster::Origin::BOTTOM_LEFT :
+ Raster::Origin::TOP_LEFT )
{
}
@@ -177,12 +200,12 @@ public:
inline void begin_layer(unsigned lyr) {
if(m_layers_rst.size() <= lyr) m_layers_rst.resize(lyr+1);
- m_layers_rst[lyr].first.reset(m_res, m_pxdim, ORIGIN);
+ m_layers_rst[lyr].first.reset(m_res, m_pxdim, m_o);
}
inline void begin_layer() {
m_layers_rst.emplace_back();
- m_layers_rst.front().first.reset(m_res, m_pxdim, ORIGIN);
+ m_layers_rst.front().first.reset(m_res, m_pxdim, m_o);
}
inline void finish_layer(unsigned lyr_id) {
diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp
index 3dc9451e7..8615ab91c 100644
--- a/src/libslic3r/SLA/SLASupportTree.cpp
+++ b/src/libslic3r/SLA/SLASupportTree.cpp
@@ -392,7 +392,7 @@ struct Pillar {
void add_base(double height = 3, double radius = 2) {
if(height <= 0) return;
- assert(steps > 0);
+ assert(steps >= 0);
auto last = int(steps - 1);
if(radius < r ) radius = r;
@@ -1293,7 +1293,7 @@ bool SLASupportTree::generate(const PointSet &points,
return distance(Vec2d(p1(X), p1(Y)), Vec2d(p2(X), p2(Y)));
});
- assert(lcid > 0);
+ assert(lcid >= 0);
auto cid = unsigned(lcid);
cl_centroids.push_back(unsigned(cid));
@@ -1454,7 +1454,7 @@ bool SLASupportTree::generate(const PointSet &points,
SpatIndex innerring;
for(unsigned i : newring) {
const Pillar& pill = result.head_pillar(gndidx[i]);
- assert(pill.id > 0);
+ assert(pill.id >= 0);
innerring.insert(pill.endpoint, unsigned(pill.id));
}
diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp
index 2aed15273..72043b9da 100644
--- a/src/libslic3r/SLAPrint.cpp
+++ b/src/libslic3r/SLAPrint.cpp
@@ -413,6 +413,12 @@ sla::SupportConfig make_support_cfg(const SLAPrintObjectConfig& c) {
return scfg;
}
+
+void swapXY(ExPolygon& expoly) {
+ for(auto& p : expoly.contour.points) std::swap(p(X), p(Y));
+ for(auto& h : expoly.holes) for(auto& p : h.points) std::swap(p(X), p(Y));
+}
+
}
void SLAPrint::process()
@@ -715,7 +721,9 @@ void SLAPrint::process()
std::vector<long long> keys; keys.reserve(levels.size());
for(auto& e : levels) keys.emplace_back(e.first);
- bool flpXY = m_printer_config.display_flip_xy.getBool();
+ // If the raster has vertical orientation, we will flip the coordinates
+ bool flpXY = m_printer_config.display_orientation.getInt() ==
+ SLADisplayOrientation::sladoPortrait;
{ // create a raster printer for the current print parameters
// I don't know any better
@@ -733,7 +741,9 @@ void SLAPrint::process()
if(flpXY) { std::swap(w, h); std::swap(pw, ph); }
- m_printer.reset(new SLAPrinter(w, h, pw, ph, lh, exp_t, iexp_t));
+ m_printer.reset(new SLAPrinter(w, h, pw, ph, lh, exp_t, iexp_t,
+ flpXY? SLAPrinter::RO_PORTRAIT :
+ SLAPrinter::RO_LANDSCAPE));
}
// Allocate space for all the layers
@@ -770,10 +780,7 @@ void SLAPrint::process()
// apply rotation before translation...
slice.rotate(double(cp.rotation));
slice.translate(cp.shift(X), cp.shift(Y));
- if(flpXY) {
- for(auto& p : slice.contour.points) std::swap(p(X), p(Y));
- for(auto& h : slice.holes) for(auto& p : h.points) std::swap(p(X), p(Y));
- }
+ if(flpXY) swapXY(slice);
printer.draw_polygon(slice, level_id);
}
}
diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp
index 4701ae20b..bf7b3ed58 100644
--- a/src/slic3r/GUI/OptionsGroup.cpp
+++ b/src/slic3r/GUI/OptionsGroup.cpp
@@ -554,6 +554,9 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config
else if (opt_key.compare("host_type") == 0) {
ret = static_cast<int>(config.option<ConfigOptionEnum<PrintHostType>>(opt_key)->value);
}
+ else if (opt_key.compare("display_orientation") == 0) {
+ ret = static_cast<int>(config.option<ConfigOptionEnum<SLADisplayOrientation>>(opt_key)->value);
+ }
}
break;
case coPoints:
diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp
index 4582e83ba..639f70cf7 100644
--- a/src/slic3r/GUI/Preset.cpp
+++ b/src/slic3r/GUI/Preset.cpp
@@ -453,7 +453,7 @@ const std::vector<std::string>& Preset::sla_printer_options()
"printer_technology",
"bed_shape", "max_print_height",
"display_width", "display_height", "display_pixels_x", "display_pixels_y",
- "display_flip_xy",
+ "display_orientation",
"printer_correction",
"printer_notes",
"inherits"
diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp
index 66fd0e2e8..6372f7321 100644
--- a/src/slic3r/GUI/Tab.cpp
+++ b/src/slic3r/GUI/Tab.cpp
@@ -1883,7 +1883,7 @@ void TabPrinter::build_sla()
line.append_option(option);
line.append_option(optgroup->get_option("display_pixels_y"));
optgroup->append_line(line);
- optgroup->append_single_option_line("display_flip_xy");
+ optgroup->append_single_option_line("display_orientation");
optgroup = page->new_optgroup(_(L("Corrections")));
line = Line{ m_config->def()->get("printer_correction")->full_label, "" };