OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::GUI::GCodeViewer::SequentialView::Marker Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/slic3r/GUI/GCodeViewer.hpp>

Collaboration diagram for Slic3r::GUI::GCodeViewer::SequentialView::Marker:

Public Member Functions

void init (std::string filename)
const BoundingBoxf3 & get_bounding_box () const
void set_world_position (const Vec3f &position)
void set_world_offset (const Vec3f &offset)
void set_z_offset (float z_offset)
void set_high_precision_gcode (bool high_precision)
bool is_visible () const
void set_visible (bool visible)
void set_color (const ColorRGBA &color)
void render (int canvas_width, int canvas_height, const libvgcode::EViewType &view_type)
void render_position_window (const libvgcode::Viewer *viewer, int canvas_width, int canvas_height, const libvgcode::EViewType &view_type)
void on_change_color_mode (bool is_dark)

Static Public Member Functions

static ColorRGBA default_color ()

Public Attributes

float m_scale = 1.0f

Private Attributes

GLModel m_model
Vec3f m_world_position
Vec3f m_world_offset
float m_z_offset { 0.0f }
float m_model_z_offset { 0.5f }
bool m_visible { true }
bool m_is_dark = false
bool m_high_precision_gcode { false }
float m_scale_factor { 1.0f }

Detailed Description

Member Function Documentation

◆ default_color()

ColorRGBA Slic3r::GUI::GCodeViewer::SequentialView::Marker::default_color ( )
inlinestatic
124{ return { 1.0f, 1.0f, 1.0f, 0.5f }; }

Referenced by init(), and Slic3r::GUI::GCodeViewer::render_markers().

Here is the caller graph for this function:

◆ get_bounding_box()

const BoundingBoxf3 & Slic3r::GUI::GCodeViewer::SequentialView::Marker::get_bounding_box ( ) const
inline
102{ return m_model.get_bounding_box(); }
GLModel m_model
Definition GCodeViewer.hpp:79

References m_model.

◆ init()

void Slic3r::GUI::GCodeViewer::SequentialView::Marker::init ( std::string filename)
334{
335 if (filename.empty()) {
336 m_model.init_from(stilized_arrow(16, 1.5f, 3.0f, 0.8f, 3.0f));
337 } else {
338 m_model.init_from_file(filename);
339 }
340 m_model.set_color(default_color());
341}
static ColorRGBA default_color()
Definition GCodeViewer.hpp:124
GLModel::Geometry stilized_arrow(unsigned int resolution, float tip_radius, float tip_height, float stem_radius, float stem_height)
Definition GLModel.cpp:913

References default_color(), m_model, and Slic3r::GUI::stilized_arrow().

Here is the call graph for this function:

◆ is_visible()

bool Slic3r::GUI::GCodeViewer::SequentialView::Marker::is_visible ( ) const
inline
121{ return m_visible; }
bool m_visible
Definition GCodeViewer.hpp:88

References m_visible.

◆ on_change_color_mode()

void Slic3r::GUI::GCodeViewer::SequentialView::Marker::on_change_color_mode ( bool is_dark)
inline
129{ m_is_dark = is_dark; }
static bool is_dark()
Definition TextureImportDialog.cpp:85
bool m_is_dark
Definition GCodeViewer.hpp:89

References is_dark(), and m_is_dark.

Here is the call graph for this function:

◆ render()

void Slic3r::GUI::GCodeViewer::SequentialView::Marker::render ( int canvas_width,
int canvas_height,
const libvgcode::EViewType & view_type )
345{
346 if (!m_visible)
347 return;
348
349 GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
350 if (shader == nullptr)
351 return;
352
355
356 shader->start_using();
357 shader->set_uniform("emission_factor", 0.0f);
358
359 const Camera& camera = wxGetApp().plater()->get_camera();
360 const Transform3d& view_matrix = camera.get_view_matrix();
361 float scale_factor = m_scale_factor;
363 Geometry::translation_transform(scale_factor * m_model.get_bounding_box().size().z() * Vec3d::UnitZ()) * Geometry::rotation_transform({ M_PI, 0.0, 0.0 })) *
364 Geometry::scale_transform(scale_factor);
365 shader->set_uniform("view_model_matrix", view_matrix * model_matrix);
366 shader->set_uniform("projection_matrix", camera.get_projection_matrix());
367 const Matrix3d view_normal_matrix = view_matrix.matrix().block(0, 0, 3, 3) * model_matrix.matrix().block(0, 0, 3, 3).inverse().transpose();
368 shader->set_uniform("view_normal_matrix", view_normal_matrix);
369
370 m_model.render();
371
372 shader->stop_using();
373
375}
#define M_PI
Definition ExtrusionSimulator.cpp:31
#define glsafe(cmd)
Definition OpenGLUtils.hpp:25
float m_model_z_offset
Definition GCodeViewer.hpp:87
float m_scale_factor
Definition GCodeViewer.hpp:92
Vec3f m_world_position
Definition GCodeViewer.hpp:80
#define glEnable
Definition gl.h:3667
#define GL_SRC_ALPHA
Definition gl.h:1621
#define GL_BLEND
Definition gl.h:275
#define GL_ONE_MINUS_SRC_ALPHA
Definition gl.h:1239
#define glDisable
Definition gl.h:3607
#define glBlendFunc
Definition gl.h:3325
@ Camera
Definition Shortcuts.hpp:72
void translation_transform(Transform3d &transform, const Vec3d &translation)
Definition Geometry.cpp:346
void rotation_transform(Transform3d &transform, const Vec3d &rotation)
Definition Geometry.cpp:359
void scale_transform(Transform3d &transform, double scale)
Definition Geometry.cpp:372
Eigen::Transform< double, 3, Eigen::Affine, Eigen::DontAlign > Transform3d
Definition Point.hpp:96
auto cast(const BoundingBoxBase< Tin > &b)
Definition BoundingBox.hpp:299
Eigen::Matrix< double, 3, 3, Eigen::DontAlign > Matrix3d
Definition Point.hpp:86

References Slic3r::cast(), Slic3r::GUI::Camera::get_projection_matrix(), Slic3r::GUI::Camera::get_view_matrix(), GL_BLEND, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, glBlendFunc, glDisable, glEnable, glsafe, m_model, m_model_z_offset, M_PI, m_scale_factor, m_visible, m_world_position, Slic3r::Geometry::rotation_transform(), Slic3r::Geometry::scale_transform(), Slic3r::GLShaderProgram::set_uniform(), Slic3r::GLShaderProgram::start_using(), Slic3r::GLShaderProgram::stop_using(), and Slic3r::Geometry::translation_transform().

Here is the call graph for this function:

◆ render_position_window()

void Slic3r::GUI::GCodeViewer::SequentialView::Marker::render_position_window ( const libvgcode::Viewer * viewer,
int canvas_width,
int canvas_height,
const libvgcode::EViewType & view_type )
426{
427 static bool properties_shown = false;
428
429 const std::string NA_TXT = _u8L("N/A");
430 const char* NA_CSTR = NA_TXT.c_str();
431
432 if (viewer != nullptr) {
433 ImGuiWrapper& imgui = *wxGetApp().imgui();
434 // const Size cnv_size = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size();
435 imgui.set_next_window_pos(0.5f * static_cast<float>(canvas_width), static_cast<float>(canvas_height), ImGuiCond_Always, 0.5f, 1.0f);
436 ImGui::PushStyleColor(ImGuiCol_Button, ImGuiWrapper::COL_BUTTON_BACKGROUND);
437 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImGuiWrapper::COL_BUTTON_ACTIVE);
438 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGuiWrapper::COL_BUTTON_HOVERED);
439 ImGui::PushStyleColor(ImGuiCol_Border , ImVec4(.0f,.0f,.0f,.0f));
440 ImGui::PushStyleColor(ImGuiCol_Separator, ImVec4(1.f,1.f,1.f,.6f));
441 ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 8.0f * m_scale);
442 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding , ImVec2(10.f, 10.f) * m_scale);
443 ImGui::SetNextWindowBgAlpha(0.8f);
444
445 libvgcode::PathVertex vertex = viewer->get_current_vertex();
446 size_t vertex_id = viewer->get_current_vertex_id();
447 // Seam moves may contain non-deterministic vertex data, so use the
448 // last visible non-seam vertex instead (except in FeatureType view)
450 const libvgcode::Interval& visible_range = viewer->get_view_visible_range();
451 if (visible_range[1] > 0) {
452 vertex_id = static_cast<size_t>(visible_range[1]) - 1;
453 vertex = viewer->get_vertex_at(vertex_id);
454 }
455 }
456 const bool is_extrusion = vertex.is_extrusion();
457
458 const ImGuiStyle& style = ImGui::GetStyle();
459
460 char detail_buf[1024];
461 switch (view_type) {
463 if (is_extrusion)
464 strcpy(detail_buf, to_string(vertex.role).c_str());
465 else if (vertex.type != libvgcode::EMoveType::Noop)
466 strcpy(detail_buf, to_string(vertex.type).c_str());
467 else
468 strcpy(detail_buf, NA_CSTR); // Noop moves are not shown in the "Line type" view, so show N/A for them.
469 break;
471 if (is_extrusion)
472 sprintf(detail_buf, "%s%.2f", _u8L("Height: ").c_str(), vertex.height);
473 else
474 sprintf(detail_buf, "%s%s", _u8L("Height: ").c_str(), NA_CSTR);
475 break;
477 if (is_extrusion)
478 sprintf(detail_buf, "%s%.2f", _u8L("Width: ").c_str(), vertex.width);
479 else
480 sprintf(detail_buf, "%s%s", _u8L("Width: ").c_str(), NA_CSTR);
481 break;
483 if (is_extrusion)
484 sprintf(detail_buf, "%s%.2f", _u8L("Flow: ").c_str(), vertex.volumetric_rate());
485 else
486 sprintf(detail_buf, "%s%s", _u8L("Flow: ").c_str(), NA_CSTR);
487 break;
489 sprintf(detail_buf, "%s%.0f", _u8L("Fan: ").c_str(), vertex.fan_speed);
490 break;
492 sprintf(detail_buf, "%s%.0f", _u8L("Temperature: ").c_str(), vertex.temperature);
493 break;
496 sprintf(detail_buf, "%s%.1f", _u8L("Layer Time: ").c_str(), vertex.layer_duration);
497 break;
499 sprintf(detail_buf, "%s%d", _u8L("Tool: ").c_str(), vertex.extruder_id + 1);
500 break;
502 sprintf(detail_buf, "%s%d", _u8L("Color: ").c_str(), vertex.color_id + 1);
503 break;
505 sprintf(detail_buf, "%s%.0f", _u8L("Acceleration: ").c_str(), vertex.acceleration);
506 break;
508 sprintf(detail_buf, "%s%.1f", _u8L("Jerk: ").c_str(), vertex.jerk);
509 break;
511 sprintf(detail_buf, "%s%.4f", _u8L("PA: ").c_str(), vertex.pressure_advance);
512 break;
513 default:
514 detail_buf[0] = '\0';
515 break;
516 }
517
518 std::vector<std::pair<std::string, std::string>> properties_rows;
519 float table_content_w = 0.0f;
520 if (properties_shown) {
521 float label_w = 0.0f;
522 float value_w = 0.0f;
523 properties_rows.reserve(14);
524 auto add_row = [&properties_rows, &label_w, &value_w](std::string label, std::string value) {
525 label_w = std::max(label_w, ImGui::CalcTextSize(label.c_str()).x);
526 value_w = std::max(value_w, ImGui::CalcTextSize(value.c_str()).x);
527 properties_rows.emplace_back(std::move(label), std::move(value));
528 };
529 char buff[1024];
530 add_row(_u8L("Type"), _u8L(to_string(vertex.type)));
531 add_row(_u8L("Line Type"), is_extrusion ? _u8L(to_string(vertex.role)) : NA_TXT);
532 if (is_extrusion) sprintf(buff, ("%.3f " + _u8L("mm")).c_str(), vertex.width); else strcpy(buff, NA_CSTR);
533 add_row(_u8L("Width"), buff);
534 if (is_extrusion) sprintf(buff, ("%.3f " + _u8L("mm")).c_str(), vertex.height); else strcpy(buff, NA_CSTR);
535 add_row(_u8L("Height"), buff);
536 // ORCA: Length of the move ending at the current vertex. Arc moves (G2/G3) are discretized
537 // into several vertices sharing the same gcode line id, so accumulate the whole run to report
538 // the arc length instead of the length of a single chord.
539 if (vertex_id > 0 && (is_extrusion || vertex.is_travel() || vertex.is_wipe())) {
540 const size_t vertices_count = viewer->get_vertices_count();
541 size_t first_id = vertex_id;
542 while (first_id > 0 && viewer->get_vertex_at(first_id - 1).gcode_id == vertex.gcode_id)
543 --first_id;
544 size_t last_id = vertex_id;
545 while (last_id + 1 < vertices_count && viewer->get_vertex_at(last_id + 1).gcode_id == vertex.gcode_id)
546 ++last_id;
547 float length = 0.0f;
548 for (size_t i = std::max<size_t>(first_id, 1); i <= last_id; ++i) {
550 libvgcode::convert(viewer->get_vertex_at(i - 1).position)).norm();
551 }
552 sprintf(buff, ("%.3f " + _u8L("mm")).c_str(), length);
553 }
554 else
555 strcpy(buff, NA_CSTR);
556 add_row(_u8L("Length"), buff);
557 sprintf(buff, "%d", vertex.layer_id + 1);
558 add_row(_u8L("Layer"), buff);
559 sprintf(buff, ("%.1f " + _u8L("mm/s")).c_str(), vertex.feedrate);
560 add_row(_u8L("Speed"), buff);
561 sprintf(buff, ("%.0f " + _u8L("mm/s²")).c_str(), vertex.acceleration);
562 add_row(_u8L("Acceleration"), buff);
563 sprintf(buff, ("%.1f " + _u8L("mm/s")).c_str(), vertex.jerk);
564 add_row(_u8L("Jerk"), buff);
565 if (is_extrusion) sprintf(buff, ("%.3f " + _u8L("mm³/s")).c_str(), vertex.volumetric_rate()); else strcpy(buff, NA_CSTR);
566 add_row(_u8L("Flow rate"), buff);
567 sprintf(buff, "%.0f %%", vertex.fan_speed);
568 add_row(_u8L("Fan speed"), buff);
569 sprintf(buff, ("%.0f " + _u8L("\u2103" /* °C */)).c_str(), vertex.temperature);
570 add_row(_u8L("Temperature"), buff);
571 sprintf(buff, "%.4f", vertex.pressure_advance);
572 add_row(_u8L("Pressure Advance"), buff);
573 const float estimated_time = viewer->get_estimated_time_at(vertex_id);
574 sprintf(buff, "%s (%.3fs)", get_time_dhms(estimated_time).c_str(), vertex.times[static_cast<size_t>(viewer->get_time_mode())]);
575 add_row(_u8L("Time"), buff);
576
577 table_content_w = 2 * std::max(label_w, value_w) + style.ItemInnerSpacing.x;
578 }
579
580 // "ToolPosition" layout width calculation
581 const float axes_spacing_x = ImGui::CalcTextSize("sp").x; // Spacing between axes labels
582 const char* axes_sample = m_high_precision_gcode ? "X 999.9999" : "X 999.999"; // The longest possible axis label, see the precision of the position below
583 const float axes_width = ImGui::CalcTextSize(axes_sample).x; // Width of the longest possible axis label
584 const float axes_content_w = 3.0f * axes_width + 2.0f * axes_spacing_x; // Three axes
585 const float speed_width = ImGui::CalcTextSize((_u8L("Speed: ") + "9999 ").c_str()).x; // Width of the longest possible speed label
586 const float detail_width = ImGui::CalcTextSize(detail_buf).x; // Width of the detail text
587 const float info_content_w = speed_width + detail_width; // Speed + detail
588 const float info_group_w = std::max(axes_content_w, info_content_w); // The width of the group containing position and detail info, whichever is wider
589 const float fold_button_w = 24.0f * m_scale; // Width of the fold/unfold button
590 const float bottom_row_w = fold_button_w + style.ItemSpacing.x + info_group_w; // The width of the bottom row containing the fold button and the info group
591 float speed_profile_row_w = 0.0f;
592#if ENABLE_ACTUAL_SPEED_DEBUG
593 const float table_btn_width = std::max(ImGui::CalcTextSize(_u8L("Hide").c_str()).x, ImGui::CalcTextSize(_u8L("Show").c_str()).x);
594 const float btn_padding_x = 8.0f * m_scale;
595
596 if (properties_shown) {
597 // The width of the row containing the button to show/hide the actual speed profile table and its label
598 speed_profile_row_w = table_btn_width + btn_padding_x * 2.0f + style.ItemSpacing.x + ImGui::CalcTextSize(_u8L("Actual speed profile").c_str()).x;
599 }
600#endif // ENABLE_ACTUAL_SPEED_DEBUG
601 const float properties_w = std::max(table_content_w, speed_profile_row_w); // The width of the properties section, whichever is wider between the properties table and the speed profile row
602 const float content_w = std::max(bottom_row_w, properties_w); // The width of the window content, whichever is wider between the bottom row and the properties table
603 const float window_w = std::ceil(content_w + 2.0f * style.WindowPadding.x); // Final window width with padding, rounded up for better look
604
605 // "ToolPosition" layout height calculation
606 const float text_h = ImGui::GetTextLineHeight();
607 const float item_spacing_y = style.ItemSpacing.y;
608 const float cell_pad_y = style.CellPadding.y;
609 const float window_pad_h = 2.0f * style.WindowPadding.y;
610 const float show_button_h = text_h + 2.0f * 3.0f * m_scale; // ImGuiStyleVar_FramePadding.y is set to 3.f * m_scale
611 const float main_row_h = 2.0f * text_h + item_spacing_y; // Two lines of text (position and detail) + spacing between them
612 const float properties_h = static_cast<float>(properties_rows.size()) * (text_h + 2.0f * cell_pad_y) + 2.0f * cell_pad_y + 1.0f + item_spacing_y // table rows
613 + item_spacing_y + show_button_h // Spacing() + Show/Hide button row
614 + item_spacing_y + 1.0f + style.WindowPadding.y; // Spacing() + Separator() + Dummy()
615 const float folded_window_h = std::ceil(window_pad_h + main_row_h); // Height of the window when properties are hidden, with padding, rounded up for better look
616 const float unfolded_window_h = std::ceil(folded_window_h + properties_h); // Height of the window when properties are shown, with padding, rounded up for better look
617 const float window_h = properties_shown ? unfolded_window_h : folded_window_h; // Final window height depending on whether properties are shown or not
618
619 ImGui::SetNextWindowSize(ImVec2(window_w, window_h), ImGuiCond_Always);
620
621 imgui.begin(std::string("ToolPosition"), ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize);
622 ImGui::AlignTextToFramePadding();
623
624 if (properties_shown) {
625 auto append_table_row = [](const std::string& label, const std::string& value) {
626 ImGui::TableNextRow();
627 ImGui::TableSetColumnIndex(0);
629 ImGui::TableSetColumnIndex(1);
630 ImGuiWrapper::text(value);
631 };
632
633 if (ImGui::BeginTable("Properties", 2)) {
634 for (const auto& row : properties_rows)
635 append_table_row(row.first, row.second);
636
637 ImGui::EndTable();
638 }
639
640#if ENABLE_ACTUAL_SPEED_DEBUG
641 bool actual_speed_exist = vertex.is_extrusion() || vertex.is_travel() || vertex.is_wipe();
642 static float cached_table_wnd_width = 0.0f; // ORCA: Cache the calculated window width to avoid recalculation on every frame
643 static float cached_table_wnd_scale = 0.0f; // ORCA: Cache the calculated window scale to avoid recalculation on every frame
644 ImGui::Spacing();
645
646 static bool table_shown = false;
647 imgui.push_confirm_button_style();
648 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding , 3.f * m_scale);
649 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding , ImVec2(btn_padding_x, 3.f * m_scale));
650 ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(.5f, .5f));
651 if (imgui.button((table_shown ? _L("Hide") : _L("Show")).c_str(), ImVec2(table_btn_width + btn_padding_x * 2.f, 0.f), actual_speed_exist))
652 table_shown = !table_shown;
653 ImGui::PopStyleVar(3);
654 imgui.pop_confirm_button_style();
655 ImGui::SameLine();
656 ImGuiWrapper::text(_u8L("Actual speed profile").c_str()); // ORCA show label and plot on external window to make main window more compact
657
658 if (actual_speed_exist && table_shown) {
659 const float plot_height = 135.f * m_scale; // 135 is the height of the plot without labels
660
661 if (cached_table_wnd_scale != m_scale) { // ORCA
662 // Catch the window width to avoid recalculation on every frame,
663 // but recalculate it when/if scale changes.
664
665 const float cell_pad_x = 9.f * m_scale; // matches ImGuiStyleVar_CellPadding.x below
666 const float wnd_pad_x = 2.0f * style.WindowPadding.x;
667 const float table_border_x = 6.0f * m_scale;
668
669 // Calculate the width needed to fully show each table column header
670 // but not clamping to a minimum because later the window width is clamped anyway.
671 const float col0_w = ImGui::CalcTextSize((_u8L("Position") + " (" + _u8L("mm") + ")").c_str()).x;
672 const float col1_w = ImGui::CalcTextSize((_u8L("Speed") + " (" + _u8L("mm/s") + ")").c_str()).x;
673
674 const float content_w = std::ceil(col0_w + col1_w + 4.0f * cell_pad_x + table_border_x + wnd_pad_x);
675 const float aspect_w = std::ceil(plot_height * (16.0f / 9.0f)); // 16:9 ratio for better look
676 // Try to obtain 16:9 ratio if possible, but keep enough width for content to make
677 // window looking good on different languages, especially with long words in table header
678 cached_table_wnd_width = std::max(content_w, aspect_w);
679 cached_table_wnd_scale = m_scale;
680 }
681
682 // ORCA: Pre-calculate the height of the table based on number of rows
683 // and clamp the final window height to keep at least the same height as ToolPosition window.
684 const float cell_pad_y = 1.f * m_scale; // ImGuiStyleVar_CellPadding.y below
685 const float row_height = ImGui::GetTextLineHeight() + 2.f * cell_pad_y;
686 const float rows = static_cast<float>(m_actual_speed_imgui_widget.data.size());
687 const float table_h = row_height * (1.0f + rows) + 2.f * m_scale; // border allowance
688 const float target_h = std::ceil(plot_height + table_h + 2.f * style.WindowPadding.y);
689 const float min_h = ImGui::GetWindowHeight(); // keep at least the same height as ToolPosition window
690 const float max_h = static_cast<float>(canvas_height) - 8.f * m_scale; // keep inside canvas with a small margin
691 const float final_h = std::clamp(target_h, min_h, max_h);
692 const bool needs_scroll = target_h > max_h;
693 const float table_view_h = std::max(1.0f, final_h - plot_height - 2.f * style.WindowPadding.y);
694
695 //const ImVec2 wnd_size = ImGui::GetWindowSize();
696 imgui.set_next_window_pos(ImGui::GetWindowPos().x - 5.f * m_scale /*+ wnd_size.x*/, static_cast<float>(canvas_height), ImGuiCond_Always, 1.0f, 1.0f);
697 ImGui::SetNextWindowSize(ImVec2(cached_table_wnd_width, final_h), ImGuiCond_Always);
698 //ImGui::SetNextWindowSizeConstraints({ 0.0f, 0.0f }, { -1.0f, wnd_size.y });
699 imgui.begin(std::string("ToolPositionTableWnd"), ImGuiWindowFlags_NoTitleBar |
700 ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove |
701 ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
702 ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(9.f, 1.f) * m_scale);
703 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.f, 0.f));
704
705 ImVec4 scroll_col = ImVec4(0.77f, 0.77f, 0.77f, m_is_dark ? .6f : 1.0f); // same color with sliced plates toolbar scrollbar
706 ImGui::PushStyleColor(ImGuiCol_ScrollbarBg, ImVec4(0.f, 0.f, 0.f, 0.f)); // ORCA using background color with opacity creates a second color. This prevents secondary color
707 ImGui::PushStyleColor(ImGuiCol_ScrollbarGrabActive, scroll_col);
708 ImGui::PushStyleColor(ImGuiCol_ScrollbarGrabHovered, scroll_col);
709 ImGui::PushStyleColor(ImGuiCol_ScrollbarGrab, scroll_col);
710 ImGui::PushStyleColor(ImGuiCol_HeaderHovered , style.Colors[ImGuiCol_TableHeaderBg]);
711
712 const int hover_id = m_actual_speed_imgui_widget.plot("##ActualSpeedProfile", { -1.f, plot_height});
713 const ImGuiTableFlags table_flags = ImGuiTableFlags_Borders | (needs_scroll ? ImGuiTableFlags_ScrollY : 0);
714 if (ImGui::BeginTable("ToolPositionTable", 2, table_flags, ImVec2(0.0f, needs_scroll ? table_view_h : 0.0f))) {
715 char buff[1024];
716 if (needs_scroll)
717 ImGui::TableSetupScrollFreeze(0, 1); // Make top row always visible
718 ImGui::TableSetupColumn((_u8L("Position") + " (" + _u8L("mm") + ")").c_str());
719 ImGui::TableSetupColumn((_u8L("Speed") + " (" + _u8L("mm/s") + ")").c_str());
720 ImGui::TableHeadersRow();
721 int counter = 0;
722 for (const ActualSpeedImguiWidget::Item& item : m_actual_speed_imgui_widget.data) {
723 const bool highlight = hover_id >= 0 && (counter == hover_id || counter == hover_id + 1);
724 ImGui::TableNextRow();
725 const ImU32 row_bg_color = ImGui::GetColorU32(item.internal ? ImVec4(0.0f, 150.f / 255.0f, 136.0f / 255.f, 0.15f) : ImVec4(0.2f, 0.2f, 0.2f, 0.25f)); // ORCA
726 ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg0, row_bg_color);
727 ImGui::TableSetColumnIndex(0);
728 sprintf(buff, "%.3f", item.pos);
730 ImGui::TableSetColumnIndex(1);
731 sprintf(buff, "%.1f", item.speed);
733 ++counter;
734 }
735
736 ImGui::EndTable();
737 }
738 ImGui::PopStyleVar(2);
739 ImGui::PopStyleColor(5);
740 imgui.end();
741 }
742
743#endif // ENABLE_ACTUAL_SPEED_DEBUG
744
745 ImGui::Spacing();
746 ImGui::Separator();
747 ImGui::Dummy({0, style.WindowPadding.y});
748 }
749
750 float draw_area_height = ImGui::GetTextLineHeight() * 2.f + style.ItemSpacing.y;
751 ImGui::Dummy({10.f, draw_area_height}); // reserve area
752
753 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding , 3.f * m_scale);
754 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding , ImVec2(2.f, 2.f) * m_scale);
755 ImGui::PushStyleColor(ImGuiCol_Button , ImVec4(0, 0, 0, 0));
756 ImGui::PushStyleColor(ImGuiCol_ButtonHovered , ImVec4(84 / 255.f, 84 / 255.f, 90 / 255.f, 1.f));
757 ImGui::PushStyleColor(ImGuiCol_ButtonActive , ImVec4(84 / 255.f, 84 / 255.f, 90 / 255.f, 1.f));
758
759 const float main_wnd_height = ImGui::GetWindowHeight();
760 const float draw_start_y = main_wnd_height - draw_area_height - style.WindowPadding.y;
761
762 ImGui::SetCursorPos(ImVec2(style.WindowPadding.x, draw_start_y));
763
764 // ORCA use glyph based button for fixing button sizes changing depends on used font size on platform
765 const wchar_t foldIcon = properties_shown ? ImGui::UnfoldButtonIcon : ImGui::FoldButtonIcon;
766 if (imgui.glyph_button(foldIcon, ImVec2(16.f, 16.f) * m_scale)) {
767 properties_shown = !properties_shown;
768 static float main_wnd_height_temp = ImGui::GetWindowHeight();
769 static float first_click = true;
770 if (first_click || main_wnd_height_temp != main_wnd_height) {
771 main_wnd_height_temp = main_wnd_height;
772 first_click = false;
773 imgui.set_requires_extra_frame();
774 }
775 }
776 ImGui::PopStyleColor(3);
777 ImGui::PopStyleVar(2);
778
779 ImGui::SetCursorPos(ImVec2(style.WindowPadding.x + style.ItemSpacing.x + 24.f * m_scale, draw_start_y - 1.f * m_scale));
780
781 ImGui::BeginGroup(); // group contents to make information area more compact
782
783 // ORCA Use colorized axis labels & reduce precision on large-scale prints,
784 // show one more decimal when the G-code was exported with high precision
785 auto pos = vertex.position;
786 int max_value = std::round(std::max(std::max(pos[0], pos[1]), pos[2]));
787 auto precision = m_high_precision_gcode ? (max_value > 9999 ? "%.2f" : max_value > 999 ? "%.3f" : "%.4f")
788 : (max_value > 9999 ? "%.1f" : max_value > 999 ? "%.2f" : "%.3f");
789
790 char xBuf[32];
791 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::X()),"X ");
792 ImGui::SameLine(0,0); // ignore item spacing
793 sprintf(xBuf, precision, pos[0]);
794 ImGui::Text("%s", xBuf);
795
796 char yBuf[32];
797 ImGui::SameLine(axes_width + axes_spacing_x);
798 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Y()),"Y ");
799 ImGui::SameLine(0,0); // ignore item spacing
800 sprintf(yBuf, precision, pos[1]);
801 ImGui::Text("%s", yBuf);
802
803 char zBuf[32];
804 ImGui::SameLine(2.0f * (axes_width + axes_spacing_x));
805 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Z()),"Z ");
806 ImGui::SameLine(0,0); // ignore item spacing
807 sprintf(zBuf, precision, pos[2]);
808 ImGui::Text("%s", zBuf);
809
810 ImGui::SameLine(3.0f * axes_width + 2.0f * axes_spacing_x);
811 ImGui::Dummy({0,0});
812
813 char spdBuf[128];
814 sprintf(spdBuf, "%s%.0f ", _u8L("Speed: ").c_str(), vertex.feedrate);
815 ImGuiWrapper::text(spdBuf); // render Speed as different item to keep next item in same place
816
817 if (detail_buf[0] != '\0') { // dont render if buffer empty
818 ImGui::SameLine(speed_width);
819 ImGuiWrapper::text(detail_buf);
820 }
821 ImGui::EndGroup();
822
823 imgui.end();
824 ImGui::PopStyleColor(5);
825 ImGui::PopStyleVar(2);
826 }
827 else {
828 ImGuiWrapper& imgui = *wxGetApp().imgui();
829 //const Size cnv_size = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size();
830 //imgui.set_next_window_pos(0.5f * static_cast<float>(cnv_size.get_width()), static_cast<float>(cnv_size.get_height()), ImGuiCond_Always, 0.5f, 1.0f);
831 imgui.set_next_window_pos(0.5f * static_cast<float>(canvas_width), static_cast<float>(canvas_height), ImGuiCond_Always, 0.5f, 1.0f);
832 ImGui::PushStyleColor(ImGuiCol_Border , ImVec4(.0f,.0f,.0f,.0f));
833 ImGui::PushStyleColor(ImGuiCol_Separator, ImVec4(1.f,1.f,1.f,.6f));
834 ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 8.0f * m_scale);
835 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding , ImVec2(10.f, 10.f) * m_scale);
836 ImGui::SetNextWindowBgAlpha(0.8f);
837 imgui.begin(std::string("ToolPosition"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove);
838
839 const Vec3f pos = m_world_position + m_world_offset + m_z_offset * Vec3f::UnitZ();
840
841 int max_value = std::round(std::max(std::max(pos.x(), pos.y()),pos.z()));
842 auto precision = max_value > 9999 ? "%.1f" : max_value > 999 ? "%.2f" : "%.3f";
843 const float axes_width = ImGui::CalcTextSize("X 999.999sp").x;
844
845 char xBuf[32];
846 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::X()),"X ");
847 ImGui::SameLine(0,0); // ignore item spacing
848 sprintf(xBuf, precision, pos.x());
849 ImGui::Text("%s", xBuf);
850
851 char yBuf[32];
852 ImGui::SameLine(axes_width);
853 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Y()),"Y ");
854 ImGui::SameLine(0,0); // ignore item spacing
855 sprintf(yBuf, precision, pos.y());
856 ImGui::Text("%s", yBuf);
857
858 char zBuf[32];
859 ImGui::SameLine(axes_width * 2);
860 ImGui::TextColored(ImGuiWrapper::to_ImVec4(ColorRGBA::Z()),"Z ");
861 ImGui::SameLine(0,0); // ignore item spacing
862 sprintf(zBuf, precision, pos.z());
863 ImGui::Text("%s", zBuf);
864
865 ImGui::SameLine(axes_width * 3);
866 ImGui::Dummy({0,0});
867
868 imgui.end();
869 ImGui::PopStyleColor(2);
870 ImGui::PopStyleVar(2);
871 }
872}
#define _L(s)
Definition OBJ.cpp:34
#define style
Definition WipeTowerDialog.cpp:101
static const ColorRGBA Y()
Definition Color.hpp:146
static const ColorRGBA X()
Definition Color.hpp:145
static const ColorRGBA Z()
Definition Color.hpp:147
static const ColorRGBA WHITE()
Definition Color.hpp:142
float m_z_offset
Definition GCodeViewer.hpp:85
bool m_high_precision_gcode
Definition GCodeViewer.hpp:91
float m_scale
Definition GCodeViewer.hpp:98
Vec3f m_world_offset
Definition GCodeViewer.hpp:84
static void text_colored(const ImVec4 &color, const char *label)
Definition ImGuiWrapper.cpp:1157
static const ImVec4 COL_ORCA
Definition ImGuiWrapper.hpp:408
static ImVec4 to_ImVec4(const ColorRGB &color)
Definition ImGuiWrapper.cpp:1053
static void text(const char *label)
Definition ImGuiWrapper.cpp:1128
static const ImVec4 COL_BUTTON_HOVERED
Definition ImGuiWrapper.hpp:390
static const ImVec4 COL_BUTTON_ACTIVE
Definition ImGuiWrapper.hpp:391
static const ImVec4 COL_BUTTON_BACKGROUND
Definition ImGuiWrapper.hpp:389
const Interval & get_view_visible_range() const
Definition Viewer.cpp:282
size_t get_vertices_count() const
Definition Viewer.cpp:337
size_t get_current_vertex_id() const
Definition Viewer.cpp:347
const PathVertex & get_current_vertex() const
Definition Viewer.cpp:342
const PathVertex & get_vertex_at(size_t id) const
Definition Viewer.cpp:352
ETimeMode get_time_mode() const
Definition Viewer.cpp:102
float get_estimated_time_at(size_t id) const
Definition Viewer.cpp:362
static std::string to_string(libvgcode::EMoveType type)
Definition GCodeViewer.cpp:377
static void highlight(wxString &str)
Definition EditGCodeDialog.cpp:470
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16
double length(const Points &pts)
Definition MultiPoint.hpp:181
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > Vec3f
Definition Point.hpp:65
std::string get_time_dhms(float time_in_secs)
Definition Utils.hpp:609
@ Noop
Definition Types.hpp:122
@ Seam
Definition Types.hpp:125
std::array< std::size_t, 2 > Interval
Definition Types.hpp:85
@ ColorPrint
Definition Types.hpp:94
@ Width
Definition Types.hpp:98
@ Acceleration
Definition Types.hpp:108
@ LayerTimeLogarithmic
Definition Types.hpp:102
@ PressureAdvance
Definition Types.hpp:106
@ Jerk
Definition Types.hpp:110
@ LayerTimeLinear
Definition Types.hpp:101
@ FeatureType
Definition Types.hpp:93
@ Tool
Definition Types.hpp:111
@ FanSpeed
Definition Types.hpp:103
@ VolumetricFlowRate
Definition Types.hpp:99
@ Temperature
Definition Types.hpp:104
@ Height
Definition Types.hpp:97
Vec3 convert(const Slic3r::Vec3f &v)
Definition LibVGCodeWrapper.cpp:45
size_t rows(const T &raster)
Definition MarchingSquares.hpp:171
#define _u8L(s)
Definition I18N.hpp:11
float temperature
Definition PathVertex.hpp:52
bool is_extrusion() const
Definition PathVertex.cpp:12
bool is_wipe() const
Definition PathVertex.cpp:22
float feedrate
Definition PathVertex.hpp:36
float acceleration
Definition PathVertex.hpp:100
uint8_t extruder_id
Definition PathVertex.hpp:78
float volumetric_rate() const
Definition PathVertex.hpp:131
uint32_t layer_id
Definition PathVertex.hpp:74
EMoveType type
Definition PathVertex.hpp:66
Vec3 position
Definition PathVertex.hpp:24
uint8_t color_id
Definition PathVertex.hpp:82
std::array< float, TIME_MODES_COUNT > times
Definition PathVertex.hpp:86
float height
Definition PathVertex.hpp:28
float pressure_advance
Definition PathVertex.hpp:95
float jerk
Definition PathVertex.hpp:105
uint32_t gcode_id
Definition PathVertex.hpp:70
float width
Definition PathVertex.hpp:32
float fan_speed
Definition PathVertex.hpp:48
EGCodeExtrusionRole role
Definition PathVertex.hpp:62
float layer_duration
Definition PathVertex.hpp:90
bool is_travel() const
Definition PathVertex.cpp:17

References _L, _u8L, libvgcode::Acceleration, libvgcode::PathVertex::acceleration, Slic3r::GUI::ImGuiWrapper::begin(), Slic3r::GUI::ImGuiWrapper::button(), Slic3r::GUI::ImGuiWrapper::COL_BUTTON_ACTIVE, Slic3r::GUI::ImGuiWrapper::COL_BUTTON_BACKGROUND, Slic3r::GUI::ImGuiWrapper::COL_BUTTON_HOVERED, Slic3r::GUI::ImGuiWrapper::COL_ORCA, libvgcode::PathVertex::color_id, libvgcode::ColorPrint, libvgcode::convert(), Slic3r::GUI::ImGuiWrapper::end(), libvgcode::PathVertex::extruder_id, libvgcode::PathVertex::fan_speed, libvgcode::FanSpeed, libvgcode::FeatureType, libvgcode::PathVertex::feedrate, libvgcode::PathVertex::gcode_id, libvgcode::Viewer::get_current_vertex(), libvgcode::Viewer::get_current_vertex_id(), libvgcode::Viewer::get_estimated_time_at(), Slic3r::get_time_dhms(), libvgcode::Viewer::get_time_mode(), libvgcode::Viewer::get_vertex_at(), libvgcode::Viewer::get_vertices_count(), libvgcode::Viewer::get_view_visible_range(), Slic3r::GUI::ImGuiWrapper::glyph_button(), libvgcode::Height, libvgcode::PathVertex::height, Slic3r::GUI::highlight(), libvgcode::PathVertex::is_extrusion(), libvgcode::PathVertex::is_travel(), libvgcode::PathVertex::is_wipe(), libvgcode::Jerk, libvgcode::PathVertex::jerk, libvgcode::PathVertex::layer_duration, libvgcode::PathVertex::layer_id, libvgcode::LayerTimeLinear, libvgcode::LayerTimeLogarithmic, Slic3r::length(), m_high_precision_gcode, m_is_dark, m_scale, m_world_offset, m_world_position, m_z_offset, libvgcode::Noop, Slic3r::GUI::ImGuiWrapper::pop_confirm_button_style(), libvgcode::PathVertex::position, libvgcode::PathVertex::pressure_advance, libvgcode::PressureAdvance, Slic3r::GUI::ImGuiWrapper::push_confirm_button_style(), libvgcode::PathVertex::role, libvgcode::Seam, Slic3r::GUI::ImGuiWrapper::set_next_window_pos(), Slic3r::GUI::ImGuiWrapper::set_requires_extra_frame(), style, libvgcode::Temperature, libvgcode::PathVertex::temperature, Slic3r::GUI::ImGuiWrapper::text(), Slic3r::GUI::ImGuiWrapper::text_colored(), libvgcode::PathVertex::times, Slic3r::GUI::ImGuiWrapper::to_ImVec4(), Slic3r::GUI::to_string(), libvgcode::Tool, libvgcode::PathVertex::type, libvgcode::PathVertex::volumetric_rate(), libvgcode::VolumetricFlowRate, Slic3r::ColorRGBA::WHITE(), libvgcode::Width, libvgcode::PathVertex::width, Slic3r::ColorRGBA::X(), Slic3r::ColorRGBA::Y(), and Slic3r::ColorRGBA::Z().

Here is the call graph for this function:

◆ set_color()

void Slic3r::GUI::GCodeViewer::SequentialView::Marker::set_color ( const ColorRGBA & color)
inline
125{ m_model.set_color(color); }

References m_model.

◆ set_high_precision_gcode()

void Slic3r::GUI::GCodeViewer::SequentialView::Marker::set_high_precision_gcode ( bool high_precision)
inline
107{ m_high_precision_gcode = high_precision; }

References m_high_precision_gcode.

◆ set_visible()

void Slic3r::GUI::GCodeViewer::SequentialView::Marker::set_visible ( bool visible)
inline
122{ m_visible = visible; }

References m_visible.

◆ set_world_offset()

void Slic3r::GUI::GCodeViewer::SequentialView::Marker::set_world_offset ( const Vec3f & offset)
inline
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582

References m_world_offset, and Slic3r::offset().

Here is the call graph for this function:

◆ set_world_position()

void Slic3r::GUI::GCodeViewer::SequentialView::Marker::set_world_position ( const Vec3f & position)
inline
104{ m_world_position = position; }

References m_world_position.

◆ set_z_offset()

void Slic3r::GUI::GCodeViewer::SequentialView::Marker::set_z_offset ( float z_offset)
inline
106{ m_z_offset = z_offset; }

References m_z_offset.

Member Data Documentation

◆ m_high_precision_gcode

bool Slic3r::GUI::GCodeViewer::SequentialView::Marker::m_high_precision_gcode { false }
private
91{ false };

Referenced by render_position_window(), and set_high_precision_gcode().

◆ m_is_dark

bool Slic3r::GUI::GCodeViewer::SequentialView::Marker::m_is_dark = false
private

◆ m_model

GLModel Slic3r::GUI::GCodeViewer::SequentialView::Marker::m_model
private

◆ m_model_z_offset

float Slic3r::GUI::GCodeViewer::SequentialView::Marker::m_model_z_offset { 0.5f }
private
87{ 0.5f };

Referenced by render().

◆ m_scale

float Slic3r::GUI::GCodeViewer::SequentialView::Marker::m_scale = 1.0f

Referenced by render_position_window().

◆ m_scale_factor

float Slic3r::GUI::GCodeViewer::SequentialView::Marker::m_scale_factor { 1.0f }
private
92{ 1.0f };

Referenced by render().

◆ m_visible

bool Slic3r::GUI::GCodeViewer::SequentialView::Marker::m_visible { true }
private
88{ true };

Referenced by is_visible(), render(), and set_visible().

◆ m_world_offset

Vec3f Slic3r::GUI::GCodeViewer::SequentialView::Marker::m_world_offset
private

◆ m_world_position

Vec3f Slic3r::GUI::GCodeViewer::SequentialView::Marker::m_world_position
private

◆ m_z_offset

float Slic3r::GUI::GCodeViewer::SequentialView::Marker::m_z_offset { 0.0f }
private
85{ 0.0f };

Referenced by render_position_window(), and set_z_offset().


The documentation for this class was generated from the following files: