Merge remote-tracking branch 'origin/master' into ys_update_settings

This commit is contained in:
YuSanka 2019-08-22 13:19:44 +02:00
commit a966a46896
8 changed files with 134 additions and 46 deletions

View File

@ -1522,7 +1522,13 @@ void GCode::process_layer(
// we should add or not colorprint_change in respect to nozzle_diameter count instead of really used extruders count
if (colorprint_change && print./*extruders()*/config().nozzle_diameter.size()==1)
{
// add tag for analyzer
gcode += "; " + GCodeAnalyzer::Color_Change_Tag + "\n";
// add tag for time estimator
gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n";
gcode += "M600\n";
}
// Extrude skirt at the print_z of the raft layers and normal object layers

View File

@ -25,6 +25,7 @@ const std::string GCodeAnalyzer::Extrusion_Role_Tag = "_ANALYZER_EXTR_ROLE:";
const std::string GCodeAnalyzer::Mm3_Per_Mm_Tag = "_ANALYZER_MM3_PER_MM:";
const std::string GCodeAnalyzer::Width_Tag = "_ANALYZER_WIDTH:";
const std::string GCodeAnalyzer::Height_Tag = "_ANALYZER_HEIGHT:";
const std::string GCodeAnalyzer::Color_Change_Tag = "_ANALYZER_COLOR_CHANGE";
const double GCodeAnalyzer::Default_mm3_per_mm = 0.0;
const float GCodeAnalyzer::Default_Width = 0.0f;
@ -240,11 +241,6 @@ void GCodeAnalyzer::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLi
{
switch (::atoi(&cmd[1]))
{
case 600: // Set color change
{
_processM600(line);
break;
}
case 82: // Set extruder to absolute mode
{
_processM82(line);
@ -517,12 +513,6 @@ void GCodeAnalyzer::_reset_cached_position()
}
}
void GCodeAnalyzer::_processM600(const GCodeReader::GCodeLine& line)
{
m_state.cur_cp_color_id++;
_set_cp_color_id(m_state.cur_cp_color_id);
}
void GCodeAnalyzer::_processT(const std::string& cmd)
{
if (cmd.length() > 1)
@ -579,6 +569,14 @@ bool GCodeAnalyzer::_process_tags(const GCodeReader::GCodeLine& line)
return true;
}
// color change tag
pos = comment.find(Color_Change_Tag);
if (pos != comment.npos)
{
_process_color_change_tag();
return true;
}
return false;
}
@ -608,6 +606,12 @@ void GCodeAnalyzer::_process_height_tag(const std::string& comment, size_t pos)
_set_height((float)::strtod(comment.substr(pos + Height_Tag.length()).c_str(), nullptr));
}
void GCodeAnalyzer::_process_color_change_tag()
{
m_state.cur_cp_color_id++;
_set_cp_color_id(m_state.cur_cp_color_id);
}
void GCodeAnalyzer::_set_units(GCodeAnalyzer::EUnits units)
{
m_state.units = units;
@ -945,12 +949,12 @@ void GCodeAnalyzer::_calc_gcode_preview_travel(GCodePreviewData& preview_data, s
polyline = Polyline3();
// add both vertices of the move
polyline.append(Vec3crd(scale_(move.start_position.x()), scale_(move.start_position.y()), scale_(move.start_position.z())));
polyline.append(Vec3crd(scale_(move.end_position.x()), scale_(move.end_position.y()), scale_(move.end_position.z())));
polyline.append(Vec3crd((int)scale_(move.start_position.x()), (int)scale_(move.start_position.y()), (int)scale_(move.start_position.z())));
polyline.append(Vec3crd((int)scale_(move.end_position.x()), (int)scale_(move.end_position.y()), (int)scale_(move.end_position.z())));
}
else
// append end vertex of the move to current polyline
polyline.append(Vec3crd(scale_(move.end_position.x()), scale_(move.end_position.y()), scale_(move.end_position.z())));
polyline.append(Vec3crd((int)scale_(move.end_position.x()), (int)scale_(move.end_position.y()), (int)scale_(move.end_position.z())));
// update current values
position = move.end_position;
@ -994,7 +998,7 @@ void GCodeAnalyzer::_calc_gcode_preview_retractions(GCodePreviewData& preview_da
cancel_callback();
// store position
Vec3crd position(scale_(move.start_position.x()), scale_(move.start_position.y()), scale_(move.start_position.z()));
Vec3crd position((int)scale_(move.start_position.x()), (int)scale_(move.start_position.y()), (int)scale_(move.start_position.z()));
preview_data.retraction.positions.emplace_back(position, move.data.width, move.data.height);
}
@ -1021,7 +1025,7 @@ void GCodeAnalyzer::_calc_gcode_preview_unretractions(GCodePreviewData& preview_
cancel_callback();
// store position
Vec3crd position(scale_(move.start_position.x()), scale_(move.start_position.y()), scale_(move.start_position.z()));
Vec3crd position((int)scale_(move.start_position.x()), (int)scale_(move.start_position.y()), (int)scale_(move.start_position.z()));
preview_data.unretraction.positions.emplace_back(position, move.data.width, move.data.height);
}

View File

@ -19,6 +19,7 @@ public:
static const std::string Mm3_Per_Mm_Tag;
static const std::string Width_Tag;
static const std::string Height_Tag;
static const std::string Color_Change_Tag;
static const double Default_mm3_per_mm;
static const float Default_Width;
@ -177,9 +178,6 @@ private:
// Repetier: Go to stored position
void _processM402(const GCodeReader::GCodeLine& line);
// Set color change
void _processM600(const GCodeReader::GCodeLine& line);
// Processes T line (Select Tool)
void _processT(const std::string& command);
void _processT(const GCodeReader::GCodeLine& line);
@ -200,6 +198,9 @@ private:
// Processes height tag
void _process_height_tag(const std::string& comment, size_t pos);
// Processes color change tag
void _process_color_change_tag();
void _set_units(EUnits units);
EUnits _get_units() const;

View File

@ -168,10 +168,14 @@ namespace Slic3r {
}
#endif // ENABLE_MOVE_STATS
const std::string GCodeTimeEstimator::Normal_First_M73_Output_Placeholder_Tag = "; NORMAL_FIRST_M73_OUTPUT_PLACEHOLDER";
const std::string GCodeTimeEstimator::Silent_First_M73_Output_Placeholder_Tag = "; SILENT_FIRST_M73_OUTPUT_PLACEHOLDER";
const std::string GCodeTimeEstimator::Normal_Last_M73_Output_Placeholder_Tag = "; NORMAL_LAST_M73_OUTPUT_PLACEHOLDER";
const std::string GCodeTimeEstimator::Silent_Last_M73_Output_Placeholder_Tag = "; SILENT_LAST_M73_OUTPUT_PLACEHOLDER";
const std::string GCodeTimeEstimator::Normal_First_M73_Output_Placeholder_Tag = "; _TE_NORMAL_FIRST_M73_OUTPUT_PLACEHOLDER";
const std::string GCodeTimeEstimator::Silent_First_M73_Output_Placeholder_Tag = "; _TE_SILENT_FIRST_M73_OUTPUT_PLACEHOLDER";
const std::string GCodeTimeEstimator::Normal_Last_M73_Output_Placeholder_Tag = "; _TE_NORMAL_LAST_M73_OUTPUT_PLACEHOLDER";
const std::string GCodeTimeEstimator::Silent_Last_M73_Output_Placeholder_Tag = "; _TE_SILENT_LAST_M73_OUTPUT_PLACEHOLDER";
// temporary human readable form to use until not removed from gcode by the new post-process method
const std::string GCodeTimeEstimator::Color_Change_Tag = "PRINT_COLOR_CHANGE";
// const std::string GCodeTimeEstimator::Color_Change_Tag = "_TE_COLOR_CHANGE";
GCodeTimeEstimator::GCodeTimeEstimator(EMode mode)
: m_mode(mode)
@ -814,6 +818,11 @@ namespace Slic3r {
void GCodeTimeEstimator::_process_gcode_line(GCodeReader&, const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
// processes 'special' comments contained in line
if (_process_tags(line))
return;
std::string cmd = line.cmd();
if (cmd.length() > 1)
{
@ -921,11 +930,6 @@ namespace Slic3r {
_processM566(line);
break;
}
case 600: // Set color change
{
_processM600(line);
break;
}
case 702: // MK3 MMU2: Process the final filament unload.
{
_processM702(line);
@ -1396,18 +1400,6 @@ namespace Slic3r {
set_axis_max_jerk(E, line.e() * MMMIN_TO_MMSEC);
}
void GCodeTimeEstimator::_processM600(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
m_needs_color_times = true;
_calculate_time();
if (m_color_time_cache != 0.0f)
{
m_color_times.push_back(m_color_time_cache);
m_color_time_cache = 0.0f;
}
}
void GCodeTimeEstimator::_processM702(const GCodeReader::GCodeLine& line)
{
PROFILE_FUNC();
@ -1439,6 +1431,33 @@ namespace Slic3r {
}
}
bool GCodeTimeEstimator::_process_tags(const GCodeReader::GCodeLine& line)
{
std::string comment = line.comment();
// color change tag
size_t pos = comment.find(Color_Change_Tag);
if (pos != comment.npos)
{
_process_color_change_tag();
return true;
}
return false;
}
void GCodeTimeEstimator::_process_color_change_tag()
{
PROFILE_FUNC();
m_needs_color_times = true;
_calculate_time();
if (m_color_time_cache != 0.0f)
{
m_color_times.push_back(m_color_time_cache);
m_color_time_cache = 0.0f;
}
}
void GCodeTimeEstimator::_simulate_st_synchronize()
{
PROFILE_FUNC();

View File

@ -22,6 +22,8 @@ namespace Slic3r {
static const std::string Normal_Last_M73_Output_Placeholder_Tag;
static const std::string Silent_Last_M73_Output_Placeholder_Tag;
static const std::string Color_Change_Tag;
enum EMode : unsigned char
{
Normal,
@ -425,15 +427,19 @@ namespace Slic3r {
// Set allowable instantaneous speed change
void _processM566(const GCodeReader::GCodeLine& line);
// Set color change
void _processM600(const GCodeReader::GCodeLine& line);
// Unload the current filament into the MK3 MMU2 unit at the end of print.
void _processM702(const GCodeReader::GCodeLine& line);
// Processes T line (Select Tool)
void _processT(const GCodeReader::GCodeLine& line);
// Processes the tags
// Returns true if any tag has been processed
bool _process_tags(const GCodeReader::GCodeLine& line);
// Processes color change tag
void _process_color_change_tag();
// Simulates firmware st_synchronize() call
void _simulate_st_synchronize();

View File

@ -7,6 +7,7 @@
#include "Line.hpp"
#include "MultiPoint.hpp"
#include "Polyline.hpp"
#include "Polygon.hpp"
namespace Slic3r {

View File

@ -17,6 +17,10 @@
#include <boost/algorithm/string.hpp>
#include "slic3r/Utils/FixModelByWin10.hpp"
#ifdef __WXMSW__
#include "wx/uiaction.h"
#endif /* __WXMSW__ */
namespace Slic3r
{
namespace GUI
@ -119,6 +123,10 @@ ObjectList::ObjectList(wxWindow* parent) :
* instead of real last clicked item.
* So, let check last selected item in such strange way
*/
#ifdef __WXMSW__
// Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected.
int new_selected_column = -1;
#endif __WXMSW__
if (wxGetKeyState(WXK_SHIFT))
{
wxDataViewItemArray sels;
@ -128,8 +136,25 @@ ObjectList::ObjectList(wxWindow* parent) :
else
m_last_selected_item = event.GetItem();
}
else
m_last_selected_item = event.GetItem();
else {
wxDataViewItem new_selected_item = event.GetItem();
#ifdef __WXMSW__
// Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected.
wxDataViewItem item;
wxDataViewColumn *col;
this->HitTest(get_mouse_position_in_control(), item, col);
new_selected_column = (col == nullptr) ? -1 : (int)col->GetModelColumn();
if (new_selected_item == m_last_selected_item && m_last_selected_column != -1 && m_last_selected_column != new_selected_column) {
// Mouse clicked on another column of the active row. Simulate keyboard enter to enter the editing mode of the current column.
wxUIActionSimulator sim;
sim.Char(WXK_RETURN);
}
#endif __WXMSW__
m_last_selected_item = new_selected_item;
}
#ifdef __WXMSW__
m_last_selected_column = new_selected_column;
#endif __WXMSW__
selection_changed();
#ifndef __WXMSW__
@ -184,7 +209,10 @@ ObjectList::ObjectList(wxWindow* parent) :
Bind(wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, &ObjectList::OnDropPossible, this);
Bind(wxEVT_DATAVIEW_ITEM_DROP, &ObjectList::OnDrop, this);
Bind(wxEVT_DATAVIEW_ITEM_EDITING_DONE, &ObjectList::OnEditingDone, this);
#ifdef __WXMSW__
Bind(wxEVT_DATAVIEW_ITEM_EDITING_STARTED, &ObjectList::OnEditingStarted, this);
#endif /* __WXMSW__ */
Bind(wxEVT_DATAVIEW_ITEM_EDITING_DONE, &ObjectList::OnEditingDone, this);
Bind(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, &ObjectList::ItemValueChanged, this);
@ -3541,6 +3569,15 @@ void ObjectList::ItemValueChanged(wxDataViewEvent &event)
update_extruder_in_config(event.GetItem());
}
#ifdef __WXMSW__
// Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected.
// Here the last active column is forgotten, so when leaving the editing mode, the next mouse click will not enter the editing mode of the newly selected column.
void ObjectList::OnEditingStarted(wxDataViewEvent &event)
{
m_last_selected_column = -1;
}
#endif __WXMSW__
void ObjectList::OnEditingDone(wxDataViewEvent &event)
{
if (event.GetColumn() != colName)
@ -3553,6 +3590,12 @@ void ObjectList::OnEditingDone(wxDataViewEvent &event)
show_error(this, _(L("The supplied name is not valid;")) + "\n" +
_(L("the following characters are not allowed:")) + " <>:/\\|?*\"");
});
#ifdef __WXMSW__
// Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected.
// Here the last active column is forgotten, so when leaving the editing mode, the next mouse click will not enter the editing mode of the newly selected column.
m_last_selected_column = -1;
#endif __WXMSW__
}
void ObjectList::show_multi_selection_menu()

View File

@ -157,6 +157,10 @@ private:
int m_selected_row = 0;
wxDataViewItem m_last_selected_item {nullptr};
#ifdef __WXMSW__
// Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected.
int m_last_selected_column = -1;
#endif /* __MSW__ */
#if 0
SettingsBundle m_freq_settings_fff;
@ -366,6 +370,10 @@ private:
bool can_drop(const wxDataViewItem& item) const ;
void ItemValueChanged(wxDataViewEvent &event);
#ifdef __WXMSW__
// Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected.
void OnEditingStarted(wxDataViewEvent &event);
#endif /* __WXMSW__ */
void OnEditingDone(wxDataViewEvent &event);
void show_multi_selection_menu();