Information from DoubleSlider is saved to Model

GCode creating can work with that values.
This commit is contained in:
YuSanka 2019-10-10 16:03:58 +02:00
parent 6ac53aa4f3
commit 70ef0f25ef
10 changed files with 193 additions and 43 deletions

View file

@ -870,8 +870,11 @@ void GCode::_do_export(Print &print, FILE *file)
this->apply_print_config(print.config());
this->set_extruders(print.extruders());
// Initialize colorprint.
// #ys_FIXME_COLOR // Initialize colorprint.
m_colorprint_heights = cast<float>(print.config().colorprint_heights.values);
// Initialize custom gcode
Model* model = print.get_object(0)->model_object()->get_model();
m_custom_g_code_heights = model->custom_gcode_per_height;
// Initialize autospeed.
{
@ -1676,8 +1679,15 @@ void GCode::process_layer(
// In case there are more toolchange requests that weren't done yet and should happen simultaneously, erase them all.
// (Layers can be close to each other, model could have been resliced with bigger layer height, ...).
bool colorprint_change = false;
while (!m_colorprint_heights.empty() && m_colorprint_heights.front()-EPSILON < layer.print_z) {
m_colorprint_heights.erase(m_colorprint_heights.begin());
// #ys_FIXME_COLOR
// while (!m_colorprint_heights.empty() && m_colorprint_heights.front()-EPSILON < layer.print_z) {
// m_colorprint_heights.erase(m_colorprint_heights.begin());
// colorprint_change = true;
// }
std::string custom_code = "";
while (!m_custom_g_code_heights.empty() && m_custom_g_code_heights.front().height-EPSILON < layer.print_z) {
custom_code = m_custom_g_code_heights.front().gcode;
m_custom_g_code_heights.erase(m_custom_g_code_heights.begin());
colorprint_change = true;
}
@ -1688,7 +1698,9 @@ void GCode::process_layer(
gcode += "; " + GCodeAnalyzer::Color_Change_Tag + "\n";
// add tag for time estimator
gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n";
gcode += "M600\n";
// #ys_FIXME_COLOR
// gcode += "M600\n";
gcode += custom_code + "\n";
}

View file

@ -353,6 +353,8 @@ protected:
// Layer heights for colorprint - updated before the export and erased during the process
// so no toolchange occurs twice.
std::vector<float> m_colorprint_heights;
// extensions for colorprint - now it's not a just color_print, there can be some custom gcode
std::vector<Model::CustomGCode> m_custom_g_code_heights;
// Time estimators
GCodeTimeEstimator m_normal_time_estimator;

View file

@ -745,6 +745,32 @@ public:
ModelObjectPtrs objects;
// Wipe tower object.
ModelWipeTower wipe_tower;
// Extensions for
struct CustomGCode
{
CustomGCode(double height, const std::string& code, int extruder) :
height(height), gcode(code), extruder(extruder) {}
bool operator<(const CustomGCode& other) const { return other.height > this->height; }
bool operator==(const CustomGCode& other) const
{
return (other.height == this->height) &&
(other.gcode == this->gcode) &&
(other.extruder == this->extruder );
}
bool operator!=(const CustomGCode& other) const
{
return (other.height != this->height) ||
(other.gcode != this->gcode) ||
(other.extruder != this->extruder );
}
double height;
std::string gcode;
int extruder;
};
std::vector<CustomGCode> custom_gcode_per_height;
// Default constructor assigns a new ID to the model.
Model() { assert(this->id().valid()); }

View file

@ -749,6 +749,11 @@ Print::ApplyStatus Print::apply(const Model &model, DynamicPrintConfig new_full_
delete model_object;
}
}
if (model.custom_gcode_per_height != m_model.custom_gcode_per_height)
{
update_apply_status(this->invalidate_step(psGCodeExport));
m_model.custom_gcode_per_height = model.custom_gcode_per_height;
}
}
// 2) Map print objects including their transformation matrices.