mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	Merge branch 'master' of https://github.com/prusa3d/Slic3r
This commit is contained in:
		
						commit
						3a1923e4f1
					
				
					 4 changed files with 74 additions and 19 deletions
				
			
		|  | @ -5088,11 +5088,42 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) | ||||||
| #endif // ENABLE_MOVE_MIN_THRESHOLD
 | #endif // ENABLE_MOVE_MIN_THRESHOLD
 | ||||||
|             m_mouse.dragging = true; |             m_mouse.dragging = true; | ||||||
| 
 | 
 | ||||||
|             // Get new position at the same Z of the initial click point.
 |             Vec3d cur_pos = m_mouse.drag.start_position_3D; | ||||||
|             float z0 = 0.0f; |  | ||||||
|             float z1 = 1.0f; |  | ||||||
|             // we do not want to translate objects if the user just clicked on an object while pressing shift to remove it from the selection and then drag
 |             // we do not want to translate objects if the user just clicked on an object while pressing shift to remove it from the selection and then drag
 | ||||||
|             Vec3d cur_pos = m_selection.contains_volume(m_hover_volume_id) ? Linef3(_mouse_to_3d(pos, &z0), _mouse_to_3d(pos, &z1)).intersect_plane(m_mouse.drag.start_position_3D(2)) : m_mouse.drag.start_position_3D; |             if (m_selection.contains_volume(m_hover_volume_id)) | ||||||
|  |             { | ||||||
|  |                 if (m_camera.get_theta() == 90.0f) | ||||||
|  |                 { | ||||||
|  |                     // side view -> move selected volumes orthogonally to camera view direction
 | ||||||
|  |                     Linef3 ray = mouse_ray(pos); | ||||||
|  |                     Vec3d dir = ray.unit_vector(); | ||||||
|  |                     // finds the intersection of the mouse ray with the plane parallel to the camera viewport and passing throught the starting position
 | ||||||
|  |                     // use ray-plane intersection see i.e. https://en.wikipedia.org/wiki/Line%E2%80%93plane_intersection algebric form
 | ||||||
|  |                     // in our case plane normal and ray direction are the same (orthogonal view)
 | ||||||
|  |                     // when moving to perspective camera the negative z unit axis of the camera needs to be transformed in world space and used as plane normal
 | ||||||
|  |                     Vec3d inters = ray.a + (m_mouse.drag.start_position_3D - ray.a).dot(dir) / dir.squaredNorm() * dir; | ||||||
|  |                     // vector from the starting position to the found intersection
 | ||||||
|  |                     Vec3d inters_vec = inters - m_mouse.drag.start_position_3D; | ||||||
|  | 
 | ||||||
|  |                     // get the view matrix back from opengl
 | ||||||
|  |                     GLfloat matrix[16]; | ||||||
|  |                     ::glGetFloatv(GL_MODELVIEW_MATRIX, matrix); | ||||||
|  |                     Vec3d camera_right((double)matrix[0], (double)matrix[4], (double)matrix[8]); | ||||||
|  | 
 | ||||||
|  |                     // finds projection of the vector along the camera right axis
 | ||||||
|  |                     double projection = inters_vec.dot(camera_right); | ||||||
|  | 
 | ||||||
|  |                     cur_pos = m_mouse.drag.start_position_3D + projection * camera_right; | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                 { | ||||||
|  |                     // Generic view
 | ||||||
|  |                     // Get new position at the same Z of the initial click point.
 | ||||||
|  |                     float z0 = 0.0f; | ||||||
|  |                     float z1 = 1.0f; | ||||||
|  |                     cur_pos = Linef3(_mouse_to_3d(pos, &z0), _mouse_to_3d(pos, &z1)).intersect_plane(m_mouse.drag.start_position_3D(2)); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
| 
 | 
 | ||||||
|             m_regenerate_volumes = false; |             m_regenerate_volumes = false; | ||||||
|             m_selection.translate(cur_pos - m_mouse.drag.start_position_3D); |             m_selection.translate(cur_pos - m_mouse.drag.start_position_3D); | ||||||
|  |  | ||||||
|  | @ -637,12 +637,25 @@ void Preview::update_double_slider(const std::vector<double>& layers_z, bool for | ||||||
| 
 | 
 | ||||||
|     const auto& config = wxGetApp().preset_bundle->project_config; |     const auto& config = wxGetApp().preset_bundle->project_config; | ||||||
|     const std::vector<double> &ticks_from_config = (config.option<ConfigOptionFloats>("colorprint_heights"))->values; |     const std::vector<double> &ticks_from_config = (config.option<ConfigOptionFloats>("colorprint_heights"))->values; | ||||||
|  | 
 | ||||||
|  |     // Switch to the "Feature type" from the very beginning of a new object slicing after deleting of the old one
 | ||||||
|  |     if (ticks_from_config.empty()) | ||||||
|  |     { | ||||||
|  |         const int& type = m_choice_view_type->FindString(_(L("Feature type"))); | ||||||
|  |         if (m_choice_view_type->GetSelection() != type) { | ||||||
|  |             m_choice_view_type->SetSelection(type); | ||||||
|  |             if (0 <= type && type < int(GCodePreviewData::Extrusion::Num_View_Types)) | ||||||
|  |                 m_gcode_preview_data->extrusion.view_type = GCodePreviewData::Extrusion::EViewType(type); | ||||||
|  |             m_preferred_color_mode = "feature"; | ||||||
|  |             reload_print(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|     m_slider->SetTicksValues(ticks_from_config); |     m_slider->SetTicksValues(ticks_from_config); | ||||||
| 
 | 
 | ||||||
|     bool color_print_enable = (wxGetApp().plater()->printer_technology() == ptFFF); |     bool color_print_enable = (wxGetApp().plater()->printer_technology() == ptFFF); | ||||||
|     if (color_print_enable) { |     if (color_print_enable) { | ||||||
|         const auto& config = wxGetApp().preset_bundle->full_config(); |         const auto& cfg = wxGetApp().preset_bundle->full_config(); | ||||||
|         if (config.opt<ConfigOptionFloats>("nozzle_diameter")->values.size() > 1)  |         if (cfg.opt<ConfigOptionFloats>("nozzle_diameter")->values.size() > 1)  | ||||||
|             color_print_enable = false; |             color_print_enable = false; | ||||||
|     } |     } | ||||||
|     m_slider->EnableTickManipulation(color_print_enable); |     m_slider->EnableTickManipulation(color_print_enable); | ||||||
|  |  | ||||||
|  | @ -1432,9 +1432,11 @@ PrusaDoubleSlider::PrusaDoubleSlider(wxWindow *parent, | ||||||
|     m_min_value(minValue), m_max_value(maxValue), |     m_min_value(minValue), m_max_value(maxValue), | ||||||
|     m_style(style == wxSL_HORIZONTAL || style == wxSL_VERTICAL ? style: wxSL_HORIZONTAL) |     m_style(style == wxSL_HORIZONTAL || style == wxSL_VERTICAL ? style: wxSL_HORIZONTAL) | ||||||
| { | { | ||||||
| #ifndef __WXOSX__ // SetDoubleBuffered exists on Win and Linux/GTK, but is missing on OSX
 | #ifdef __WXOSX__  | ||||||
|     SetDoubleBuffered(true); |     is_osx = true; | ||||||
| #endif //__WXOSX__
 | #endif //__WXOSX__
 | ||||||
|  |     if (!is_osx) | ||||||
|  |         SetDoubleBuffered(true);// SetDoubleBuffered exists on Win and Linux/GTK, but is missing on OSX
 | ||||||
| 
 | 
 | ||||||
|     m_bmp_thumb_higher = wxBitmap(create_scaled_bitmap(style == wxSL_HORIZONTAL ? "right_half_circle.png"   : "up_half_circle.png")); |     m_bmp_thumb_higher = wxBitmap(create_scaled_bitmap(style == wxSL_HORIZONTAL ? "right_half_circle.png"   : "up_half_circle.png")); | ||||||
|     m_bmp_thumb_lower  = wxBitmap(create_scaled_bitmap(style == wxSL_HORIZONTAL ? "left_half_circle.png"    : "down_half_circle.png")); |     m_bmp_thumb_lower  = wxBitmap(create_scaled_bitmap(style == wxSL_HORIZONTAL ? "left_half_circle.png"    : "down_half_circle.png")); | ||||||
|  | @ -1480,6 +1482,10 @@ PrusaDoubleSlider::PrusaDoubleSlider(wxWindow *parent, | ||||||
| 
 | 
 | ||||||
|     line_pens = { &DARK_GREY_PEN, &GREY_PEN, &LIGHT_GREY_PEN }; |     line_pens = { &DARK_GREY_PEN, &GREY_PEN, &LIGHT_GREY_PEN }; | ||||||
|     segm_pens = { &DARK_ORANGE_PEN, &ORANGE_PEN, &LIGHT_ORANGE_PEN }; |     segm_pens = { &DARK_ORANGE_PEN, &ORANGE_PEN, &LIGHT_ORANGE_PEN }; | ||||||
|  | 
 | ||||||
|  |     wxPaintDC dc(this); | ||||||
|  |     const wxFont& font = dc.GetFont(); | ||||||
|  |     m_font = is_osx ? font.Smaller().Smaller() : font.Smaller(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int PrusaDoubleSlider::GetActiveValue() const | int PrusaDoubleSlider::GetActiveValue() const | ||||||
|  | @ -1494,7 +1500,9 @@ wxSize PrusaDoubleSlider::DoGetBestSize() const | ||||||
|     const wxSize size = wxControl::DoGetBestSize(); |     const wxSize size = wxControl::DoGetBestSize(); | ||||||
|     if (size.x > 1 && size.y > 1) |     if (size.x > 1 && size.y > 1) | ||||||
|         return size; |         return size; | ||||||
|     const int new_size = is_horizontal() ? 6 * Slic3r::GUI::wxGetApp().em_unit() : 8 * Slic3r::GUI::wxGetApp().em_unit(); |     const int new_size = is_horizontal() ?  | ||||||
|  |                          (is_osx ? 8 : 6) * Slic3r::GUI::wxGetApp().em_unit() : | ||||||
|  |                          (is_osx ? 10 : 8) * Slic3r::GUI::wxGetApp().em_unit(); | ||||||
|     return wxSize(new_size, new_size); |     return wxSize(new_size, new_size); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -1558,7 +1566,7 @@ void PrusaDoubleSlider::draw_scroll_line(wxDC& dc, const int lower_pos, const in | ||||||
|     wxCoord line_end_y = is_horizontal() ? height*0.5 - 1 : height - SLIDER_MARGIN + 1; |     wxCoord line_end_y = is_horizontal() ? height*0.5 - 1 : height - SLIDER_MARGIN + 1; | ||||||
| 
 | 
 | ||||||
|     wxCoord segm_beg_x = is_horizontal() ? lower_pos : width*0.5 - 1; |     wxCoord segm_beg_x = is_horizontal() ? lower_pos : width*0.5 - 1; | ||||||
|     wxCoord segm_beg_y = is_horizontal() ? height*0.5 - 1 : lower_pos-1; |     wxCoord segm_beg_y = is_horizontal() ? height*0.5 - 1 : lower_pos/*-1*/; | ||||||
|     wxCoord segm_end_x = is_horizontal() ? higher_pos : width*0.5 - 1; |     wxCoord segm_end_x = is_horizontal() ? higher_pos : width*0.5 - 1; | ||||||
|     wxCoord segm_end_y = is_horizontal() ? height*0.5 - 1 : higher_pos-1; |     wxCoord segm_end_y = is_horizontal() ? height*0.5 - 1 : higher_pos-1; | ||||||
| 
 | 
 | ||||||
|  | @ -1619,8 +1627,11 @@ std::vector<double> PrusaDoubleSlider::GetTicksValues() const | ||||||
|     std::vector<double> values; |     std::vector<double> values; | ||||||
| 
 | 
 | ||||||
|     if (!m_values.empty()) |     if (!m_values.empty()) | ||||||
|         for (auto tick : m_ticks) |         for (auto tick : m_ticks) { | ||||||
|  |             if (tick > m_values.size()) | ||||||
|  |                 break; | ||||||
|             values.push_back(m_values[tick].second); |             values.push_back(m_values[tick].second); | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|     return values; |     return values; | ||||||
| } | } | ||||||
|  | @ -1673,9 +1684,7 @@ void PrusaDoubleSlider::render() | ||||||
|     draw_focus_rect(); |     draw_focus_rect(); | ||||||
| 
 | 
 | ||||||
|     wxPaintDC dc(this); |     wxPaintDC dc(this); | ||||||
|     wxFont font = dc.GetFont(); |     dc.SetFont(m_font); | ||||||
|     const wxFont smaller_font = font.Smaller(); |  | ||||||
|     dc.SetFont(smaller_font); |  | ||||||
| 
 | 
 | ||||||
|     const wxCoord lower_pos = get_position_from_value(m_lower_value); |     const wxCoord lower_pos = get_position_from_value(m_lower_value); | ||||||
|     const wxCoord higher_pos = get_position_from_value(m_higher_value); |     const wxCoord higher_pos = get_position_from_value(m_higher_value); | ||||||
|  | @ -1727,8 +1736,8 @@ void PrusaDoubleSlider::draw_info_line_with_icon(wxDC& dc, const wxPoint& pos, c | ||||||
|     if (m_selection == selection) { |     if (m_selection == selection) { | ||||||
|         //draw info line
 |         //draw info line
 | ||||||
|         dc.SetPen(DARK_ORANGE_PEN); |         dc.SetPen(DARK_ORANGE_PEN); | ||||||
|         const wxPoint pt_beg = is_horizontal() ? wxPoint(pos.x, pos.y - m_thumb_size.y) : wxPoint(pos.x - m_thumb_size.x, pos.y - 1); |         const wxPoint pt_beg = is_horizontal() ? wxPoint(pos.x, pos.y - m_thumb_size.y) : wxPoint(pos.x - m_thumb_size.x, pos.y/* - 1*/); | ||||||
|         const wxPoint pt_end = is_horizontal() ? wxPoint(pos.x, pos.y + m_thumb_size.y) : wxPoint(pos.x + m_thumb_size.x, pos.y - 1); |         const wxPoint pt_end = is_horizontal() ? wxPoint(pos.x, pos.y + m_thumb_size.y) : wxPoint(pos.x + m_thumb_size.x, pos.y/* - 1*/); | ||||||
|         dc.DrawLine(pt_beg, pt_end); |         dc.DrawLine(pt_beg, pt_end); | ||||||
| 
 | 
 | ||||||
|         //draw action icon
 |         //draw action icon
 | ||||||
|  | @ -1779,7 +1788,7 @@ void PrusaDoubleSlider::draw_thumb_item(wxDC& dc, const wxPoint& pos, const Sele | ||||||
|         } |         } | ||||||
|         else { |         else { | ||||||
|             x_draw = pos.x - int(0.5*m_thumb_size.x); |             x_draw = pos.x - int(0.5*m_thumb_size.x); | ||||||
|             y_draw = pos.y; |             y_draw = pos.y+1; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     else{ |     else{ | ||||||
|  | @ -1850,9 +1859,9 @@ void PrusaDoubleSlider::draw_ticks(wxDC& dc) | ||||||
|         const wxCoord pos = get_position_from_value(tick); |         const wxCoord pos = get_position_from_value(tick); | ||||||
| 
 | 
 | ||||||
|         is_horizontal() ?   dc.DrawLine(pos, mid-14, pos, mid-9) : |         is_horizontal() ?   dc.DrawLine(pos, mid-14, pos, mid-9) : | ||||||
|                             dc.DrawLine(mid - 14, pos - 1, mid - 9, pos - 1); |                             dc.DrawLine(mid - 14, pos/* - 1*/, mid - 9, pos/* - 1*/); | ||||||
|         is_horizontal() ?   dc.DrawLine(pos, mid+14, pos, mid+9) : |         is_horizontal() ?   dc.DrawLine(pos, mid+14, pos, mid+9) : | ||||||
|                             dc.DrawLine(mid + 14, pos - 1, mid + 9, pos - 1); |                             dc.DrawLine(mid + 14, pos/* - 1*/, mid + 9, pos/* - 1*/); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -791,6 +791,8 @@ protected: | ||||||
|     double      get_double_value(const SelectedSlider& selection); |     double      get_double_value(const SelectedSlider& selection); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|  |     bool        is_osx { false }; | ||||||
|  |     wxFont      m_font; | ||||||
|     int         m_min_value; |     int         m_min_value; | ||||||
|     int         m_max_value; |     int         m_max_value; | ||||||
|     int         m_lower_value; |     int         m_lower_value; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 bubnikv
						bubnikv