mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Analyzer tags for the wipe tower also generate layer height and line width (so the priming lines+brim are visible and ramming lines are correct width)
This commit is contained in:
		
							parent
							
								
									c72ecb382d
								
							
						
					
					
						commit
						549351bbb4
					
				
					 1 changed files with 31 additions and 24 deletions
				
			
		|  | @ -42,14 +42,31 @@ namespace PrusaMultiMaterial { | ||||||
| class Writer | class Writer | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	Writer() :  | 	Writer(float layer_height, float line_width) : | ||||||
| 		m_current_pos(std::numeric_limits<float>::max(), std::numeric_limits<float>::max()), | 		m_current_pos(std::numeric_limits<float>::max(), std::numeric_limits<float>::max()), | ||||||
| 		m_current_z(0.f), | 		m_current_z(0.f), | ||||||
| 		m_current_feedrate(0.f), | 		m_current_feedrate(0.f), | ||||||
| 		m_layer_height(0.f), | 		m_layer_height(layer_height), | ||||||
| 		m_extrusion_flow(0.f), | 		m_extrusion_flow(0.f), | ||||||
| 		m_preview_suppressed(false), | 		m_preview_suppressed(false), | ||||||
| 		m_elapsed_time(0.f) {} | 		m_elapsed_time(0.f), | ||||||
|  |         m_default_analyzer_line_width(line_width) | ||||||
|  |         { | ||||||
|  |             // adds tag for analyzer:
 | ||||||
|  |             char buf[64]; | ||||||
|  |             sprintf(buf, ";%s%f\n", GCodeAnalyzer::Height_Tag.c_str(), m_layer_height); // don't rely on GCodeAnalyzer knowing the layer height - it knows nothing at priming
 | ||||||
|  |             m_gcode += buf; | ||||||
|  |             sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower); | ||||||
|  |             m_gcode += buf; | ||||||
|  |             change_analyzer_line_width(line_width); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |     Writer&              change_analyzer_line_width(float line_width) { | ||||||
|  |             // adds tag for analyzer:
 | ||||||
|  |             char buf[64]; | ||||||
|  |             sprintf(buf, ";%s%f\n", GCodeAnalyzer::Width_Tag.c_str(), line_width); | ||||||
|  |             m_gcode += buf; | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
| 	Writer& 			 set_initial_position(const WipeTower::xy &pos) {  | 	Writer& 			 set_initial_position(const WipeTower::xy &pos) {  | ||||||
| 		m_start_pos = WipeTower::xy(pos,0.f,m_y_shift).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg); | 		m_start_pos = WipeTower::xy(pos,0.f,m_y_shift).rotate(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_angle_deg); | ||||||
|  | @ -62,9 +79,6 @@ public: | ||||||
| 	Writer&				 set_z(float z)  | 	Writer&				 set_z(float z)  | ||||||
| 		{ m_current_z = z; return *this; } | 		{ m_current_z = z; return *this; } | ||||||
| 
 | 
 | ||||||
| 	Writer&				 set_layer_height(float layer_height) |  | ||||||
| 		{ m_layer_height = layer_height; return *this; } |  | ||||||
| 
 |  | ||||||
| 	Writer& 			 set_extrusion_flow(float flow) | 	Writer& 			 set_extrusion_flow(float flow) | ||||||
| 		{ m_extrusion_flow = flow; return *this; } | 		{ m_extrusion_flow = flow; return *this; } | ||||||
| 		 | 		 | ||||||
|  | @ -80,8 +94,8 @@ public: | ||||||
| 	// Suppress / resume G-code preview in Slic3r. Slic3r will have difficulty to differentiate the various
 | 	// Suppress / resume G-code preview in Slic3r. Slic3r will have difficulty to differentiate the various
 | ||||||
| 	// filament loading and cooling moves from normal extrusion moves. Therefore the writer
 | 	// filament loading and cooling moves from normal extrusion moves. Therefore the writer
 | ||||||
| 	// is asked to suppres output of some lines, which look like extrusions.
 | 	// is asked to suppres output of some lines, which look like extrusions.
 | ||||||
| 	Writer& 			 suppress_preview() { m_preview_suppressed = true; return *this; } | 	Writer& 			 suppress_preview() { change_analyzer_line_width(0.f); m_preview_suppressed = true; return *this; } | ||||||
| 	Writer& 			 resume_preview() { m_preview_suppressed = false; return *this; } | 	Writer& 			 resume_preview()   { change_analyzer_line_width(m_default_analyzer_line_width); m_preview_suppressed = false; return *this; } | ||||||
| 
 | 
 | ||||||
| 	Writer& 			 feedrate(float f) | 	Writer& 			 feedrate(float f) | ||||||
| 	{ | 	{ | ||||||
|  | @ -126,11 +140,6 @@ public: | ||||||
| 			m_extrusions.emplace_back(WipeTower::Extrusion(WipeTower::xy(rot.x, rot.y), width, m_current_tool));			 | 			m_extrusions.emplace_back(WipeTower::Extrusion(WipeTower::xy(rot.x, rot.y), width, m_current_tool));			 | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|         // adds tag for analyzer
 |  | ||||||
|         char buf[64]; |  | ||||||
|         sprintf(buf, ";%s%d\n", GCodeAnalyzer::Extrusion_Role_Tag.c_str(), erWipeTower); |  | ||||||
|         m_gcode += buf; |  | ||||||
| 
 |  | ||||||
| 		m_gcode += "G1"; | 		m_gcode += "G1"; | ||||||
| 		if (rot.x != rotated_current_pos.x) { | 		if (rot.x != rotated_current_pos.x) { | ||||||
| 			m_gcode += set_format_X(rot.x);     // Transform current position back to wipe tower coordinates (was updated by set_format_X)
 | 			m_gcode += set_format_X(rot.x);     // Transform current position back to wipe tower coordinates (was updated by set_format_X)
 | ||||||
|  | @ -397,6 +406,7 @@ private: | ||||||
| 	float 		  m_wipe_tower_width = 0.f; | 	float 		  m_wipe_tower_width = 0.f; | ||||||
| 	float		  m_wipe_tower_depth = 0.f; | 	float		  m_wipe_tower_depth = 0.f; | ||||||
| 	float		  m_last_fan_speed = 0.f; | 	float		  m_last_fan_speed = 0.f; | ||||||
|  |     const float   m_default_analyzer_line_width; | ||||||
| 
 | 
 | ||||||
| 	std::string   set_format_X(float x) | 	std::string   set_format_X(float x) | ||||||
| 	{ | 	{ | ||||||
|  | @ -485,10 +495,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime( | ||||||
| 	const float prime_section_width = std::min(240.f / tools.size(), 60.f); | 	const float prime_section_width = std::min(240.f / tools.size(), 60.f); | ||||||
| 	box_coordinates cleaning_box(xy(5.f, 0.f), prime_section_width, 100.f); | 	box_coordinates cleaning_box(xy(5.f, 0.f), prime_section_width, 100.f); | ||||||
| 
 | 
 | ||||||
| 	PrusaMultiMaterial::Writer writer; | 	PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width); | ||||||
| 	writer.set_extrusion_flow(m_extrusion_flow) | 	writer.set_extrusion_flow(m_extrusion_flow) | ||||||
| 		  .set_z(m_z_pos) | 		  .set_z(m_z_pos) | ||||||
| 		  .set_layer_height(m_layer_height) |  | ||||||
| 		  .set_initial_tool(m_current_tool) | 		  .set_initial_tool(m_current_tool) | ||||||
| 		  .append(";--------------------\n" | 		  .append(";--------------------\n" | ||||||
| 			 	  "; CP PRIMING START\n") | 			 	  "; CP PRIMING START\n") | ||||||
|  | @ -574,10 +583,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo | ||||||
| 		(tool != (unsigned int)(-1) ? /*m_layer_info->depth*/wipe_area+m_depth_traversed-0.5*m_perimeter_width | 		(tool != (unsigned int)(-1) ? /*m_layer_info->depth*/wipe_area+m_depth_traversed-0.5*m_perimeter_width | ||||||
|                                     : m_wipe_tower_depth-m_perimeter_width)); |                                     : m_wipe_tower_depth-m_perimeter_width)); | ||||||
| 
 | 
 | ||||||
| 	PrusaMultiMaterial::Writer writer; | 	PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width); | ||||||
| 	writer.set_extrusion_flow(m_extrusion_flow) | 	writer.set_extrusion_flow(m_extrusion_flow) | ||||||
| 		.set_z(m_z_pos) | 		.set_z(m_z_pos) | ||||||
| 		.set_layer_height(m_layer_height) |  | ||||||
| 		.set_initial_tool(m_current_tool) | 		.set_initial_tool(m_current_tool) | ||||||
| 		.set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) | 		.set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) | ||||||
| 		.set_y_shift(m_y_shift + (tool!=(unsigned int)(-1) && (m_current_shape == SHAPE_REVERSED && !m_peters_wipe_tower) ? m_layer_info->depth - m_layer_info->toolchanges_depth(): 0.f)) | 		.set_y_shift(m_y_shift + (tool!=(unsigned int)(-1) && (m_current_shape == SHAPE_REVERSED && !m_peters_wipe_tower) ? m_layer_info->depth - m_layer_info->toolchanges_depth(): 0.f)) | ||||||
|  | @ -646,10 +654,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(bool sideOnly, flo | ||||||
| 		m_wipe_tower_width, | 		m_wipe_tower_width, | ||||||
| 		m_wipe_tower_depth); | 		m_wipe_tower_depth); | ||||||
| 
 | 
 | ||||||
| 	PrusaMultiMaterial::Writer writer; | 	PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width); | ||||||
| 	writer.set_extrusion_flow(m_extrusion_flow * 1.1f) | 	writer.set_extrusion_flow(m_extrusion_flow * 1.1f) | ||||||
| 		  .set_z(m_z_pos) // Let the writer know the current Z position as a base for Z-hop.
 | 		  .set_z(m_z_pos) // Let the writer know the current Z position as a base for Z-hop.
 | ||||||
| 		  .set_layer_height(m_layer_height) |  | ||||||
| 		  .set_initial_tool(m_current_tool) | 		  .set_initial_tool(m_current_tool) | ||||||
|   		  .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) |   		  .set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) | ||||||
| 		  .append(";-------------------------------------\n" | 		  .append(";-------------------------------------\n" | ||||||
|  | @ -703,11 +710,12 @@ void WipeTowerPrusaMM::toolchange_Unload( | ||||||
| 	float xl = cleaning_box.ld.x + 1.f * m_perimeter_width; | 	float xl = cleaning_box.ld.x + 1.f * m_perimeter_width; | ||||||
| 	float xr = cleaning_box.rd.x - 1.f * m_perimeter_width; | 	float xr = cleaning_box.rd.x - 1.f * m_perimeter_width; | ||||||
| 	 | 	 | ||||||
| 	writer.append("; CP TOOLCHANGE UNLOAD\n"); |  | ||||||
| 	 |  | ||||||
| 	const float line_width = m_perimeter_width * m_filpar[m_current_tool].ramming_line_width_multiplicator;       // desired ramming line thickness
 | 	const float line_width = m_perimeter_width * m_filpar[m_current_tool].ramming_line_width_multiplicator;       // desired ramming line thickness
 | ||||||
| 	const float y_step = line_width * m_filpar[m_current_tool].ramming_step_multiplicator * m_extra_spacing; // spacing between lines in mm
 | 	const float y_step = line_width * m_filpar[m_current_tool].ramming_step_multiplicator * m_extra_spacing; // spacing between lines in mm
 | ||||||
| 
 | 
 | ||||||
|  |     writer.append("; CP TOOLCHANGE UNLOAD\n") | ||||||
|  |           .change_analyzer_line_width(line_width); | ||||||
|  | 
 | ||||||
| 	unsigned i = 0;										// iterates through ramming_speed
 | 	unsigned i = 0;										// iterates through ramming_speed
 | ||||||
| 	m_left_to_right = true;								// current direction of ramming
 | 	m_left_to_right = true;								// current direction of ramming
 | ||||||
| 	float remaining = xr - xl ;							// keeps track of distance to the next turnaround
 | 	float remaining = xr - xl ;							// keeps track of distance to the next turnaround
 | ||||||
|  | @ -781,7 +789,7 @@ void WipeTowerPrusaMM::toolchange_Unload( | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	WipeTower::xy end_of_ramming(writer.x(),writer.y()); | 	WipeTower::xy end_of_ramming(writer.x(),writer.y()); | ||||||
| 
 |     writer.change_analyzer_line_width(m_perimeter_width);   // so the next lines are not affected by ramming_line_width_multiplier
 | ||||||
| 
 | 
 | ||||||
|     // Retraction:
 |     // Retraction:
 | ||||||
|     float old_x = writer.x(); |     float old_x = writer.x(); | ||||||
|  | @ -960,10 +968,9 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer() | ||||||
| 	// Otherwise the caller would likely travel to the wipe tower in vain.
 | 	// Otherwise the caller would likely travel to the wipe tower in vain.
 | ||||||
| 	assert(! this->layer_finished()); | 	assert(! this->layer_finished()); | ||||||
| 
 | 
 | ||||||
| 	PrusaMultiMaterial::Writer writer; | 	PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width); | ||||||
| 	writer.set_extrusion_flow(m_extrusion_flow) | 	writer.set_extrusion_flow(m_extrusion_flow) | ||||||
| 		.set_z(m_z_pos) | 		.set_z(m_z_pos) | ||||||
| 		.set_layer_height(m_layer_height) |  | ||||||
| 		.set_initial_tool(m_current_tool) | 		.set_initial_tool(m_current_tool) | ||||||
| 		.set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) | 		.set_rotation(m_wipe_tower_pos, m_wipe_tower_width, m_wipe_tower_depth, m_wipe_tower_rotation_angle) | ||||||
| 		.set_y_shift(m_y_shift - (m_current_shape == SHAPE_REVERSED && !m_peters_wipe_tower ? m_layer_info->toolchanges_depth() : 0.f)) | 		.set_y_shift(m_y_shift - (m_current_shape == SHAPE_REVERSED && !m_peters_wipe_tower ? m_layer_info->toolchanges_depth() : 0.f)) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lukas Matena
						Lukas Matena