OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
anonymous_namespace{EmbossJob.cpp}::CreateObjectJob Class Reference

Create new TextObject on the platter Should not be stopped. More...

Inheritance diagram for anonymous_namespace{EmbossJob.cpp}::CreateObjectJob:
Collaboration diagram for anonymous_namespace{EmbossJob.cpp}::CreateObjectJob:

Public Types

enum  JobPrepareState { PREPARE_STATE_DEFAULT = 0 , PREPARE_STATE_MENU = 1 }

Public Member Functions

 CreateObjectJob (DataCreateObject &&input)
 Create Object.
void process (Ctl &ctl) override
void finalize (bool canceled, std::exception_ptr &eptr) override

Private Attributes

DataCreateObject m_input
TriangleMesh m_result
Transform3d m_transformation

Detailed Description

Create new TextObject on the platter Should not be stopped.

Member Enumeration Documentation

◆ JobPrepareState

Enumerator
PREPARE_STATE_DEFAULT 
PREPARE_STATE_MENU 
22 {
25 };
@ PREPARE_STATE_MENU
Definition Job.hpp:24
@ PREPARE_STATE_DEFAULT
Definition Job.hpp:23

Constructor & Destructor Documentation

◆ CreateObjectJob()

CreateObjectJob::CreateObjectJob ( DataCreateObject && input)
explicit

Create Object.

328: m_input(std::move(input)){ assert(check(m_input)); }
DataCreateObject m_input
Definition EmbossJob.cpp:144
bool check(const DataBase &input, bool check_fontfile=true, bool use_surface=false)
Assert check of inputs data.
Definition EmbossJob.cpp:719

References anonymous_namespace{EmbossJob.cpp}::check(), and m_input.

Here is the call graph for this function:

Member Function Documentation

◆ finalize()

void CreateObjectJob::finalize ( bool canceled,
std::exception_ptr & eptr )
overridevirtual

Reimplemented from Slic3r::GUI::Job.

373{
374 if (!::finalize(canceled, eptr, *m_input.base))
375 return;
376
377 // only for sure
378 if (m_result.empty())
379 return create_message(_u8L("Can't create empty object."));
380
381 GUI_App &app = wxGetApp();
382 Plater *plater = app.plater();
383 plater->take_snapshot(_u8L("Add Emboss text object"));
384
385 Model& model = plater->model();
386#ifdef _DEBUG
388#endif /* _DEBUG */
389 {
390 // INFO: inspiration for create object is from ObjectList::load_mesh_object()
391 ModelObject *new_object = model.add_object();
392 new_object->name = m_input.base->volume_name;
393 new_object->add_instance(); // each object should have at list one instance
394 new_object->config.set_key_value("extruder", new ConfigOptionInt(1));
395 ModelVolume *new_volume = new_object->add_volume(std::move(m_result));
396 // set a default extruder value, since user can't add it manually
397 new_volume->config.set_key_value("extruder", new ConfigOptionInt(1));
398 // write emboss data into volume
399 m_input.base->write(*new_volume);
400
401 // set transformation
402 Slic3r::Geometry::Transformation tr(m_transformation);
403 new_object->instances.front()->set_transformation(tr);
404 new_object->ensure_on_bed();
405
406 // Actualize right panel and set inside of selection
407 app.obj_list()->paste_objects_into_list({model.objects.size() - 1});
408 }
409#ifdef _DEBUG
411#endif /* _DEBUG */
412
413 // When add new object selection is empty.
414 // When cursor move and no one object is selected than
415 // Manager::reset_all() So Gizmo could be closed before end of creation object
416 GLCanvas3D *canvas = plater->get_view3D_canvas3D();
417 GLGizmosManager &manager = canvas->get_gizmos_manager();
418 if (manager.get_current_type() != m_input.gizmo)
419 manager.open_gizmo(m_input.gizmo);
420
421 // redraw scene
422 canvas->reload_scene(true);
423}
void reload_scene(bool refresh_immediately, bool force_full_scene_refresh=false)
Definition GLCanvas3D.cpp:3162
const GLGizmosManager & get_gizmos_manager() const
Definition GLCanvas3D.hpp:1031
bool open_gizmo(EType type)
Definition GLGizmosManager.cpp:458
EType get_current_type() const
Definition GLGizmosManager.hpp:299
ObjectList * obj_list()
Definition GUI_App.cpp:9699
Plater * plater()
Definition GUI_App.cpp:9709
void paste_objects_into_list(const std::vector< size_t > &object_idxs)
Definition GUI_ObjectList.cpp:1484
const Model & model() const
Definition Plater.cpp:16047
void take_snapshot(const std::string &snapshot_name)
Definition Plater.cpp:21281
GLCanvas3D * get_view3D_canvas3D()
Definition Plater.cpp:22082
bool set_key_value(const std::string &opt_key, ConfigOption *opt)
Definition PrintConfig.hpp:2635
void ensure_on_bed(bool allow_negative_z=false)
Definition Model.cpp:1896
ModelConfigObject config
Definition Model.hpp:395
std::string name
Definition Model.hpp:384
ModelInstancePtrs instances
Definition Model.hpp:390
ModelVolume * add_volume(const TriangleMesh &mesh, bool modify_to_center_geometry=true)
Definition Model.cpp:1389
ModelInstance * add_instance()
Definition Model.cpp:1554
ModelConfigObject config
Definition Model.hpp:904
ModelObjectPtrs objects
Definition Model.hpp:1702
ModelObject * add_object()
Definition Model.cpp:607
void finalize(bool canceled, std::exception_ptr &eptr) override
Definition EmbossJob.cpp:372
Transform3d m_transformation
Definition EmbossJob.cpp:146
TriangleMesh m_result
Definition EmbossJob.cpp:145
static Plater * plater()
Definition GUI_Factories.cpp:400
@ Plater
Definition Shortcuts.hpp:21
void check_model_ids_validity(const Model &model)
Definition Model.cpp:4375
void create_message(const std::string &message)
Definition EmbossJob.cpp:1613
#define _u8L(s)
Definition I18N.hpp:11

References _u8L, Slic3r::ModelObject::add_instance(), Slic3r::Model::add_object(), Slic3r::ModelObject::add_volume(), Slic3r::check_model_ids_validity(), Slic3r::ModelObject::config, Slic3r::ModelVolume::config, anonymous_namespace{EmbossJob.cpp}::create_message(), Slic3r::ModelObject::ensure_on_bed(), finalize(), Slic3r::GUI::GLGizmosManager::get_current_type(), Slic3r::GUI::GLCanvas3D::get_gizmos_manager(), Slic3r::ModelObject::instances, m_input, m_result, m_transformation, Slic3r::ModelObject::name, Slic3r::GUI::GUI_App::obj_list(), Slic3r::Model::objects, Slic3r::GUI::GLGizmosManager::open_gizmo(), Slic3r::GUI::ObjectList::paste_objects_into_list(), Slic3r::GUI::GUI_App::plater(), Slic3r::GUI::plater(), Slic3r::GUI::GLCanvas3D::reload_scene(), and Slic3r::ModelConfig::set_key_value().

Referenced by finalize().

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

◆ process()

void CreateObjectJob::process ( Ctl & ctl)
overridevirtual

Implements Slic3r::GUI::Job.

331{
332 if (!check(m_input))
333 throw JobException(_u8L("Bad input data for EmbossCreateObjectJob."));
334
335 // can't create new object with using surface
336 if (m_input.base->shape.projection.use_surface)
337 m_input.base->shape.projection.use_surface = false;
338
339 auto was_canceled = ::was_canceled(ctl, *m_input.base);
341 if (was_canceled()) return;
342
343 // Create new object
344 // calculate X,Y offset position for lay on platter in place of
345 // mouse click
347 m_input.camera, m_input.screen_coor);
348
349 // check point is on build plate:
350 Points bed_shape_;
351 bed_shape_.reserve(m_input.bed_shape.size());
352 for (const Vec2d &p : m_input.bed_shape)
353 bed_shape_.emplace_back(p.cast<coord_t>());
354 Slic3r::Polygon bed(bed_shape_);
355 if (!bed.contains(bed_coor.cast<coord_t>()))
356 // mouse pose is out of build plate so create object in center of plate
357 bed_coor = bed.centroid().cast<double>();
358
359 double z = m_input.base->shape.projection.depth / 2;
360 Vec3d offset(bed_coor.x(), bed_coor.y(), z);
361 offset -= m_result.center();
362 Transform3d::TranslationType tt(offset.x(), offset.y(), offset.z());
364
365 // rotate around Z by style settings
366 if (m_input.angle.has_value()) {
367 std::optional<float> distance; // new object ignore surface distance from style settings
369 }
370}
static Vec2d get_z0_position(const Camera &camera, const Vec2d &coor)
Unproject mouse coordinate to get position in space where z coor is zero Platter surface should be in...
Definition CameraUtils.cpp:129
int64_t coord_t
Definition libslic3r.h:48
void apply_transformation(const std::optional< float > &angle, const std::optional< float > &distance, Transform3d &transformation)
Use data from font property to modify transformation.
Definition Emboss.cpp:1480
float distance(SpiralVase::SpiralPoint a, SpiralVase::SpiralPoint b)
Definition SpiralVase.cpp:19
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68
Eigen::Transform< double, 3, Eigen::Affine, Eigen::DontAlign > Transform3d
Definition Point.hpp:96
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582
std::vector< Point, PointsAllocator< Point > > Points
Definition Point.hpp:73
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67
auto was_canceled(const Job::Ctl &ctl, const DataBase &base)
Definition EmbossJob.cpp:292
TriangleMesh create_mesh(DataBase &input, const Fnc &was_canceled, Job::Ctl &ctl)
Definition EmbossJob.cpp:984

References _u8L, Slic3r::Emboss::apply_transformation(), Slic3r::Polygon::centroid(), anonymous_namespace{EmbossJob.cpp}::check(), Slic3r::Polygon::contains(), anonymous_namespace{EmbossJob.cpp}::create_mesh(), Slic3r::GUI::CameraUtils::get_z0_position(), m_input, m_result, m_transformation, Slic3r::offset(), and anonymous_namespace{EmbossJob.cpp}::was_canceled().

Here is the call graph for this function:

Member Data Documentation

◆ m_input

DataCreateObject anonymous_namespace{EmbossJob.cpp}::CreateObjectJob::m_input
private

Referenced by CreateObjectJob(), finalize(), and process().

◆ m_result

TriangleMesh anonymous_namespace{EmbossJob.cpp}::CreateObjectJob::m_result
private

Referenced by finalize(), and process().

◆ m_transformation

Transform3d anonymous_namespace{EmbossJob.cpp}::CreateObjectJob::m_transformation
private

Referenced by finalize(), and process().


The documentation for this class was generated from the following file:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/Jobs/EmbossJob.cpp