mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	FIX: cannot change filament if has support filament(STUDIO-2737)
Change-Id: Ie5f7d33e0a3a40357cd443ff114187c742208fe9
This commit is contained in:
		
							parent
							
								
									fdd7d11b14
								
							
						
					
					
						commit
						537ec8da26
					
				
					 3 changed files with 61 additions and 15 deletions
				
			
		|  | @ -477,7 +477,7 @@ void Preview::update_layers_slider_mode() | ||||||
|     // BBS
 |     // BBS
 | ||||||
|     if (wxGetApp().filaments_cnt() > 1) { |     if (wxGetApp().filaments_cnt() > 1) { | ||||||
|         //const ModelObjectPtrs& objects = wxGetApp().plater()->model().objects;
 |         //const ModelObjectPtrs& objects = wxGetApp().plater()->model().objects;
 | ||||||
|         auto plate_extruders = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_extruders(); |         auto plate_extruders = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_extruders_without_support(); | ||||||
|         for (auto extruder : plate_extruders) { |         for (auto extruder : plate_extruders) { | ||||||
|             if (extruder != plate_extruders[0]) |             if (extruder != plate_extruders[0]) | ||||||
|                 can_change_color = false; |                 can_change_color = false; | ||||||
|  | @ -486,23 +486,23 @@ void Preview::update_layers_slider_mode() | ||||||
|         if (!plate_extruders.empty()) { |         if (!plate_extruders.empty()) { | ||||||
|             //const int extruder = objects[0]->config.has("extruder") ? objects[0]->config.option("extruder")->getInt() : 0;
 |             //const int extruder = objects[0]->config.has("extruder") ? objects[0]->config.option("extruder")->getInt() : 0;
 | ||||||
|             only_extruder = plate_extruders[0]; |             only_extruder = plate_extruders[0]; | ||||||
|         //    auto is_one_extruder_printed_model = [objects, extruder]() {
 |             //    auto is_one_extruder_printed_model = [objects, extruder]() {
 | ||||||
|         //        for (ModelObject *object : objects) {
 |             //        for (ModelObject *object : objects) {
 | ||||||
|         //            if (object->config.has("extruder") && object->config.option("extruder")->getInt() != extruder) /*return false*/;
 |             //            if (object->config.has("extruder") && object->config.option("extruder")->getInt() != extruder) /*return false*/;
 | ||||||
| 
 | 
 | ||||||
|         //            for (ModelVolume *volume : object->volumes)
 |             //            for (ModelVolume *volume : object->volumes)
 | ||||||
|         //                if ((volume->config.has("extruder") && volume->config.option("extruder")->getInt() != extruder) || !volume->mmu_segmentation_facets.empty()) return false;
 |             //                if ((volume->config.has("extruder") && volume->config.option("extruder")->getInt() != extruder) || !volume->mmu_segmentation_facets.empty()) return false;
 | ||||||
| 
 | 
 | ||||||
|         //            for (const auto &range : object->layer_config_ranges)
 |             //            for (const auto &range : object->layer_config_ranges)
 | ||||||
|         //                if (range.second.has("extruder") && range.second.option("extruder")->getInt() != extruder) return false;
 |             //                if (range.second.has("extruder") && range.second.option("extruder")->getInt() != extruder) return false;
 | ||||||
|         //        }
 |             //        }
 | ||||||
|         //        return true;
 |             //        return true;
 | ||||||
|         //    };
 |             //    };
 | ||||||
| 
 | 
 | ||||||
|         //    if (is_one_extruder_printed_model())
 |             //    if (is_one_extruder_printed_model())
 | ||||||
|         //        only_extruder = extruder;
 |             //        only_extruder = extruder;
 | ||||||
|         //    else
 |             //    else
 | ||||||
|         //        one_extruder_printed_model = false;
 |             //        one_extruder_printed_model = false;
 | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1335,6 +1335,51 @@ std::vector<int> PartPlate::get_extruders(bool conside_custom_gcode) const | ||||||
| 	return plate_extruders; | 	return plate_extruders; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | std::vector<int> PartPlate::get_extruders_without_support(bool conside_custom_gcode) const | ||||||
|  | { | ||||||
|  | 	std::vector<int> plate_extruders; | ||||||
|  | 	// if gcode.3mf file
 | ||||||
|  | 	if (m_model->objects.empty()) { | ||||||
|  | 		for (int i = 0; i < slice_filaments_info.size(); i++) { | ||||||
|  | 			plate_extruders.push_back(slice_filaments_info[i].id + 1); | ||||||
|  | 		} | ||||||
|  | 		return plate_extruders; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	// if 3mf file
 | ||||||
|  | 	const DynamicPrintConfig& glb_config = wxGetApp().preset_bundle->prints.get_edited_preset().config; | ||||||
|  | 
 | ||||||
|  | 	for (int obj_idx = 0; obj_idx < m_model->objects.size(); obj_idx++) { | ||||||
|  | 		if (!contain_instance_totally(obj_idx, 0)) | ||||||
|  | 			continue; | ||||||
|  | 
 | ||||||
|  | 		ModelObject* mo = m_model->objects[obj_idx]; | ||||||
|  | 		for (ModelVolume* mv : mo->volumes) { | ||||||
|  | 			std::vector<int> volume_extruders = mv->get_extruders(); | ||||||
|  | 			plate_extruders.insert(plate_extruders.end(), volume_extruders.begin(), volume_extruders.end()); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if (conside_custom_gcode) { | ||||||
|  | 		//BBS
 | ||||||
|  | 		int nums_extruders = 0; | ||||||
|  | 		if (const ConfigOptionStrings* color_option = dynamic_cast<const ConfigOptionStrings*>(wxGetApp().preset_bundle->project_config.option("filament_colour"))) { | ||||||
|  | 			nums_extruders = color_option->values.size(); | ||||||
|  | 			if (m_model->plates_custom_gcodes.find(m_plate_index) != m_model->plates_custom_gcodes.end()) { | ||||||
|  | 				for (auto item : m_model->plates_custom_gcodes.at(m_plate_index).gcodes) { | ||||||
|  | 					if (item.type == CustomGCode::Type::ToolChange && item.extruder <= nums_extruders) | ||||||
|  | 						plate_extruders.push_back(item.extruder); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	std::sort(plate_extruders.begin(), plate_extruders.end()); | ||||||
|  | 	auto it_end = std::unique(plate_extruders.begin(), plate_extruders.end()); | ||||||
|  | 	plate_extruders.resize(std::distance(plate_extruders.begin(), it_end)); | ||||||
|  | 	return plate_extruders; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| std::vector<int> PartPlate::get_used_extruders() | std::vector<int> PartPlate::get_used_extruders() | ||||||
| { | { | ||||||
| 	std::vector<int> used_extruders; | 	std::vector<int> used_extruders; | ||||||
|  |  | ||||||
|  | @ -285,6 +285,7 @@ public: | ||||||
|     Vec3d get_origin() { return m_origin; } |     Vec3d get_origin() { return m_origin; } | ||||||
|     Vec3d estimate_wipe_tower_size(const double w, const double wipe_volume) const; |     Vec3d estimate_wipe_tower_size(const double w, const double wipe_volume) const; | ||||||
|     std::vector<int> get_extruders(bool conside_custom_gcode = false) const; |     std::vector<int> get_extruders(bool conside_custom_gcode = false) const; | ||||||
|  |     std::vector<int> get_extruders_without_support(bool conside_custom_gcode = false) const; | ||||||
|     std::vector<int> get_used_extruders(); |     std::vector<int> get_used_extruders(); | ||||||
| 
 | 
 | ||||||
|     /* instance related operations*/ |     /* instance related operations*/ | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 liz.li
						liz.li