OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::anonymous_namespace{Plater.cpp} Namespace Reference

Classes

class  SvgArchivePathsRestorer
struct  MixedGradientSlot

Typedefs

using SvgFile = EmbossShape::SvgFile
using SvgFiles = std::vector<SvgFile*>

Functions

bool emboss_svg (Plater &plater, const wxString &svg_file, const Vec2d &mouse_drop_position)
std::string imex_placement_error (PartPlate *plate)
std::string get_file_name (const std::string &file_path)
std::string create_unique_3mf_filepath (const std::string &file, const SvgFiles svgs)
bool set_by_local_path (SvgFile &svg, const SvgFiles &svgs)
void publish (Model &model, SaveStrategy strategy)
 Function to secure private data before store to 3mf.
std::vector< MixedGradientSlot > parse_mixed_gradient_slots (const Slic3r::DynamicPrintConfig &config, size_t slot_count)

Class Documentation

◆ Slic3r::GUI::anonymous_namespace{Plater.cpp}::MixedGradientSlot

struct Slic3r::GUI::anonymous_namespace{Plater.cpp}::MixedGradientSlot
Collaboration diagram for Slic3r::GUI::anonymous_namespace{Plater.cpp}::MixedGradientSlot:
Class Members
string color_from
string color_to
bool is_gradient = false

Typedef Documentation

◆ SvgFile

using Slic3r::GUI::anonymous_namespace{Plater.cpp}::SvgFile = EmbossShape::SvgFile

◆ SvgFiles

using Slic3r::GUI::anonymous_namespace{Plater.cpp}::SvgFiles = std::vector<SvgFile*>

Function Documentation

◆ create_unique_3mf_filepath()

std::string Slic3r::GUI::anonymous_namespace{Plater.cpp}::create_unique_3mf_filepath ( const std::string & file,
const SvgFiles svgs )
20330{
20331 // const std::string MODEL_FOLDER = "3D/"; // copy from file 3mf.cpp
20332 std::string path_in_3mf = "3D/" + file + ".svg";
20333 size_t suffix_number = 0;
20334 bool is_unique = false;
20335 do{
20336 is_unique = true;
20337 path_in_3mf = "3D/" + file + ((suffix_number++)? ("_" + std::to_string(suffix_number)) : "") + ".svg";
20338 for (SvgFile *svgfile : svgs) {
20339 if (svgfile->path_in_3mf.empty())
20340 continue;
20341 if (svgfile->path_in_3mf.compare(path_in_3mf) == 0) {
20342 is_unique = false;
20343 break;
20344 }
20345 }
20346 } while (!is_unique);
20347 return path_in_3mf;
20348}
EmbossShape::SvgFile SvgFile
Definition Plater.cpp:20327

References create_unique_3mf_filepath().

Referenced by create_unique_3mf_filepath(), and publish().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emboss_svg()

bool Slic3r::GUI::anonymous_namespace{Plater.cpp}::emboss_svg ( Plater & plater,
const wxString & svg_file,
const Vec2d & mouse_drop_position )
7142{
7143 std::string svg_file_str = into_u8(svg_file);
7144 GLCanvas3D* canvas = plater.canvas3D();
7145 if (canvas == nullptr)
7146 return false;
7147 auto base_svg = canvas->get_gizmos_manager().get_gizmo(GLGizmosManager::Svg);
7148 if (base_svg == nullptr)
7149 return false;
7150 GLGizmoSVG* svg = dynamic_cast<GLGizmoSVG *>(base_svg);
7151 if (svg == nullptr)
7152 return false;
7153
7154 // Refresh hover state to find surface point under mouse
7155 wxMouseEvent evt(wxEVT_MOTION);
7156 evt.SetPosition(wxPoint(mouse_drop_position.x(), mouse_drop_position.y()));
7157 canvas->on_mouse(evt); // call render where is call GLCanvas3D::_picking_pass()
7158
7159 return svg->create_volume(svg_file_str, mouse_drop_position, ModelVolumeType::MODEL_PART);
7160}
Definition GLCanvas3D.hpp:239
void on_mouse(wxMouseEvent &evt)
Definition GLCanvas3D.cpp:4731
const GLGizmosManager & get_gizmos_manager() const
Definition GLCanvas3D.hpp:1031
Definition GLGizmoSVG.hpp:44
bool create_volume(ModelVolumeType volume_type, const Vec2d &mouse_pos)
Create new embossed text volume by type on position of mouse.
Definition GLGizmoSVG.cpp:234
@ Svg
Definition GLGizmosManager.hpp:100
GLGizmoBase * get_gizmo(GLGizmosManager::EType type) const
Definition GLGizmosManager.cpp:1393
wxMouseEvent
Definition CameraPopup.cpp:47
static Plater * plater()
Definition GUI_Factories.cpp:400
std::string into_u8(const wxString &str)
Definition GUI.cpp:549
@ MODEL_PART
Definition Model.hpp:357

References Slic3r::GUI::GLGizmoSVG::create_volume(), emboss_svg(), Slic3r::GUI::GLGizmosManager::get_gizmo(), Slic3r::GUI::GLCanvas3D::get_gizmos_manager(), Slic3r::GUI::into_u8(), Slic3r::MODEL_PART, Slic3r::GUI::GLCanvas3D::on_mouse(), Slic3r::GUI::plater(), Slic3r::GUI::GLGizmosManager::Svg, and Slic3r::GUI::wxMouseEvent.

Referenced by emboss_svg().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_file_name()

std::string Slic3r::GUI::anonymous_namespace{Plater.cpp}::get_file_name ( const std::string & file_path)
20320{
20321 size_t pos_last_delimiter = file_path.find_last_of("/\\");
20322 size_t pos_point = file_path.find_last_of('.');
20323 size_t offset = pos_last_delimiter + 1;
20324 size_t count = pos_point - pos_last_delimiter - 1;
20325 return file_path.substr(offset, count);
20326}
static unsigned int count
Definition AuxiliaryDataViewModel.cpp:246
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582

References count, get_file_name(), and Slic3r::offset().

Referenced by get_file_name(), and publish().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ imex_placement_error()

std::string Slic3r::GUI::anonymous_namespace{Plater.cpp}::imex_placement_error ( PartPlate * plate)
11378{
11379 if (!plate)
11380 return {};
11381 switch (plate->imex_placement_violation()) {
11383 return _u8L("Cannot slice: an object overlaps an area reserved for IDEX/IQEX parallel printing "
11384 "(a secondary zone, or a carriage clearance strip inside the primary zone).");
11386 return _u8L("Cannot slice: the prime tower overlaps an area reserved for IDEX/IQEX parallel printing "
11387 "(a secondary zone, or a carriage clearance strip inside the primary zone).");
11389 break;
11390 }
11391 return {};
11392}
ImexPlacementViolation imex_placement_violation()
Definition PartPlate.cpp:1250
@ PrimeTower
Definition PartPlate.hpp:625
@ Object
Definition PartPlate.hpp:625
#define _u8L(s)
Definition I18N.hpp:11

References _u8L, imex_placement_error(), Slic3r::GUI::PartPlate::imex_placement_violation(), Slic3r::GUI::PartPlate::None, Slic3r::GUI::PartPlate::Object, and Slic3r::GUI::PartPlate::PrimeTower.

Referenced by imex_placement_error().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_mixed_gradient_slots()

std::vector< MixedGradientSlot > Slic3r::GUI::anonymous_namespace{Plater.cpp}::parse_mixed_gradient_slots ( const Slic3r::DynamicPrintConfig & config,
size_t slot_count )
21824{
21825 std::vector<MixedGradientSlot> result(slot_count);
21826 const auto* is_mixed = config.option<ConfigOptionBools>("filament_is_mixed");
21827 const auto* mixed_grad = config.option<ConfigOptionBools>("filament_mixed_gradient");
21828 const auto* mixed_comp = config.option<ConfigOptionStrings>("filament_mixed_components");
21829 const auto* grad_range = config.option<ConfigOptionStrings>("filament_mixed_gradient_range");
21830 const auto* fil_colour = config.option<ConfigOptionStrings>("filament_colour");
21831 if (!is_mixed || !mixed_grad || !mixed_comp || !fil_colour) return result;
21832
21833 for (size_t i = 0; i < slot_count && i < is_mixed->values.size(); ++i) {
21834 if (!is_mixed->values[i]) continue;
21835 if (i >= mixed_grad->values.size() || !mixed_grad->values[i]) continue;
21836 if (i >= mixed_comp->values.size()) continue;
21837
21838 std::vector<unsigned int> comp_ids;
21839 std::istringstream iss(mixed_comp->values[i]);
21840 std::string tok;
21841 while (std::getline(iss, tok, ',')) {
21842 unsigned int v = 0;
21843 if (std::sscanf(tok.c_str(), "%u", &v) == 1)
21844 comp_ids.push_back(v);
21845 }
21846 if (comp_ids.size() != 2) continue;
21847
21848 int direction = 0;
21849 if (grad_range && i < grad_range->values.size()) {
21850 CNumericLocalesSetter c_locale_setter;
21851 float v0 = 0, v1 = 0;
21852 if (std::sscanf(grad_range->values[i].c_str(), "%f,%f", &v0, &v1) == 2)
21853 direction = (v0 > v1) ? 0 : 1;
21854 }
21855
21856 unsigned int from_id = (direction == 0) ? comp_ids[0] : comp_ids[1];
21857 unsigned int to_id = (direction == 0) ? comp_ids[1] : comp_ids[0];
21858 result[i].is_gradient = true;
21859 result[i].color_from = (from_id >= 1 && from_id <= fil_colour->values.size())
21860 ? fil_colour->values[from_id - 1] : "#D9D9D9";
21861 result[i].color_to = (to_id >= 1 && to_id <= fil_colour->values.size())
21862 ? fil_colour->values[to_id - 1] : "#D9D9D9";
21863 }
21864 return result;
21865}
Definition LocalesUtils.hpp:19
ConfigOption * option(const t_config_option_key &opt_key, bool create=false)
Definition Config.hpp:2768
Definition Config.hpp:1190
std::vector< unsigned char > values
Definition Config.hpp:418
ConfigOptionBoolsTempl< false > ConfigOptionBools
Definition Config.hpp:2066

References Slic3r::ConfigBase::option(), parse_mixed_gradient_slots(), Slic3r::ConfigOptionVector< T >::size(), Slic3r::ConfigOptionVector< T >::values, and Slic3r::ConfigOptionVector< unsigned char >::values.

Referenced by parse_mixed_gradient_slots().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publish()

void Slic3r::GUI::anonymous_namespace{Plater.cpp}::publish ( Model & model,
SaveStrategy strategy )

Function to secure private data before store to 3mf.

Parameters
modelData(also private) to clean before publishing
20368 {
20369
20370 // SVG file publishing
20371 bool exist_new = false;
20372 SvgFiles svgfiles;
20373 for (ModelObject *object: model.objects){
20374 for (ModelVolume *volume : object->volumes) {
20375 if (!volume->emboss_shape.has_value())
20376 continue;
20377 if (volume->text_configuration.has_value())
20378 continue; // text dosen't have svg path
20379
20380 assert(volume->emboss_shape->svg_file.has_value());
20381 if (!volume->emboss_shape->svg_file.has_value())
20382 continue;
20383
20384 SvgFile* svg = &(*volume->emboss_shape->svg_file);
20385 if (svg->path_in_3mf.empty())
20386 exist_new = true;
20387 svgfiles.push_back(svg);
20388 }
20389 }
20390
20391 for (SvgFile *svgfile : svgfiles) {
20392 if (!svgfile->path_in_3mf.empty())
20393 continue; // already suggested path (previous save)
20394
20395 // create unique name for svgs, when local path differ
20396 std::string filename = "unknown";
20397 if (!svgfile->path.empty()) {
20398 if (set_by_local_path(*svgfile, svgfiles))
20399 continue;
20400 // check whether original filename is already in:
20401 filename = get_file_name(svgfile->path);
20402 }
20403 svgfile->path_in_3mf = create_unique_3mf_filepath(filename, svgfiles);
20404 }
20405}
Definition Model.hpp:382
ModelVolumePtrs volumes
Definition Model.hpp:393
Definition Model.hpp:832
std::optional< EmbossShape > emboss_shape
Definition Model.hpp:1019
std::optional< TextConfiguration > text_configuration
Definition Model.hpp:1015
ModelObjectPtrs objects
Definition Model.hpp:1702
std::vector< SvgFile * > SvgFiles
Definition Plater.cpp:20328
std::string get_file_name(const std::string &file_path)
Definition Plater.cpp:20319
bool set_by_local_path(SvgFile &svg, const SvgFiles &svgs)
Definition Plater.cpp:20350
std::string create_unique_3mf_filepath(const std::string &file, const SvgFiles svgs)
Definition Plater.cpp:20329
std::string path_in_3mf
Definition EmbossShape.hpp:97

References create_unique_3mf_filepath(), Slic3r::ModelVolume::emboss_shape, get_file_name(), Slic3r::Model::objects, Slic3r::EmbossShape::SvgFile::path_in_3mf, publish(), set_by_local_path(), Slic3r::ModelVolume::text_configuration, and Slic3r::ModelObject::volumes.

Referenced by publish().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_by_local_path()

bool Slic3r::GUI::anonymous_namespace{Plater.cpp}::set_by_local_path ( SvgFile & svg,
const SvgFiles & svgs )
20351{
20352 // Try to find already used svg file
20353 for (SvgFile *svg_ : svgs) {
20354 if (svg_->path_in_3mf.empty())
20355 continue;
20356 if (svg.path.compare(svg_->path) == 0) {
20357 svg.path_in_3mf = svg_->path_in_3mf;
20358 return true;
20359 }
20360 }
20361 return false;
20362}
std::string path
Definition EmbossShape.hpp:92

References Slic3r::EmbossShape::SvgFile::path, Slic3r::EmbossShape::SvgFile::path_in_3mf, and set_by_local_path().

Referenced by publish(), and set_by_local_path().

Here is the call graph for this function:
Here is the caller graph for this function: