mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
ENH: enable gcode window and support viewing added custom gcode
Change-Id: I2def8c32c17b6f2edfd2e6d0776123127560f167
This commit is contained in:
parent
e2f96590cf
commit
d776c7595e
12 changed files with 195 additions and 107 deletions
4
resources/images/im_gcode_custom.svg
Normal file
4
resources/images/im_gcode_custom.svg
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M13.5 7C13.5 10.5899 10.5899 13.5 7 13.5C3.41015 13.5 0.5 10.5899 0.5 7C0.5 3.41015 3.41015 0.5 7 0.5C10.5899 0.5 13.5 3.41015 13.5 7Z" fill="#909090" stroke="#909090"/>
|
||||||
|
<path d="M7 11.5C6.44684 11.5 5.96085 11.396 5.54203 11.188C5.13111 10.972 4.81106 10.672 4.5819 10.288C4.36063 9.896 4.25 9.436 4.25 8.908V5.092C4.25 4.556 4.36063 4.096 4.5819 3.712C4.81106 3.328 5.13111 3.032 5.54203 2.824C5.96085 2.608 6.44684 2.5 7 2.5C7.56106 2.5 8.0431 2.608 8.44612 2.824C8.85704 3.032 9.17708 3.328 9.40625 3.712C9.63542 4.096 9.75 4.556 9.75 5.092H8.25647C8.25647 4.676 8.14583 4.36 7.92457 4.144C7.71121 3.928 7.40302 3.82 7 3.82C6.59698 3.82 6.28484 3.928 6.06358 4.144C5.84231 4.36 5.73168 4.672 5.73168 5.08V8.908C5.73168 9.316 5.84231 9.632 6.06358 9.856C6.28484 10.08 6.59698 10.192 7 10.192C7.40302 10.192 7.71121 10.08 7.92457 9.856C8.14583 9.632 8.25647 9.316 8.25647 8.908V8.02H6.78664V6.724H9.75V8.908C9.75 9.436 9.63542 9.896 9.40625 10.288C9.17708 10.672 8.85704 10.972 8.44612 11.188C8.0431 11.396 7.56106 11.5 7 11.5Z" fill="white"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
|
@ -131,7 +131,7 @@
|
||||||
"change_filament_gcode": "",
|
"change_filament_gcode": "",
|
||||||
"before_layer_change_gcode": ";BEFORE_LAYER_CHANGE\n;[layer_z]\nG92 E0\n",
|
"before_layer_change_gcode": ";BEFORE_LAYER_CHANGE\n;[layer_z]\nG92 E0\n",
|
||||||
"layer_change_gcode": ";AFTER_LAYER_CHANGE\n;[layer_z]",
|
"layer_change_gcode": ";AFTER_LAYER_CHANGE\n;[layer_z]",
|
||||||
"machine_pause_gcode": "M400 U1\n",
|
"machine_pause_gcode": "M400 U1",
|
||||||
"wipe": [
|
"wipe": [
|
||||||
"1"
|
"1"
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "Bambulab",
|
"name": "Bambulab",
|
||||||
"url": "http://www.bambulab.com/Parameters/vendor/BBL.json",
|
"url": "http://www.bambulab.com/Parameters/vendor/BBL.json",
|
||||||
"version": "01.05.00.22",
|
"version": "01.05.00.23",
|
||||||
"force_update": "0",
|
"force_update": "0",
|
||||||
"description": "the initial version of BBL configurations",
|
"description": "the initial version of BBL configurations",
|
||||||
"machine_model_list": [
|
"machine_model_list": [
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -160,7 +160,7 @@
|
||||||
"change_filament_gcode": "M620 S[next_extruder]A\nM204 S9000\n{if toolchange_count > 1 && (z_hop_types[current_extruder] == 0 || z_hop_types[current_extruder] == 3)}\nG17\nG2 Z{z_after_toolchange + 0.4} I0.86 J0.86 P1 F10000 ; spiral lift a little from second lift\n{endif}\nG1 Z{max_layer_z + 3.0} F1200\n\nG1 X70 F21000\nG1 Y245\nG1 Y265 F3000\nM400\nM106 P1 S0\nM106 P2 S0\n{if old_filament_temp > 142 && next_extruder < 255}M104 S[old_filament_temp]{endif}\nG1 X90 F3000\nG1 Y255 F4000\nG1 X100 F5000\nG1 X120 F15000\n\nG1 X20 Y50 F21000\nG1 Y-3\n{if toolchange_count == 2}\n; get travel path for change filament\nM620.1 X[travel_point_1_x] Y[travel_point_1_y] F21000 P0\nM620.1 X[travel_point_2_x] Y[travel_point_2_y] F21000 P1\nM620.1 X[travel_point_3_x] Y[travel_point_3_y] F21000 P2\n{endif}\nM620.1 E F[old_filament_e_feedrate] T{nozzle_temperature_range_high[previous_extruder]}\nT[next_extruder]\nM620.1 E F[new_filament_e_feedrate] T{nozzle_temperature_range_high[next_extruder]}\n\n{if next_extruder < 255}\nM400\n\nG92 E0\n{if flush_length_1 > 1}\n; FLUSH_START\n; always use highest temperature to flush\nM400\nM109 S[nozzle_temperature_range_high]\n{if flush_length_1 > 23.7}\nG1 E23.7 F{old_filament_e_feedrate} ; do not need pulsatile flushing for start part\nG1 E{(flush_length_1 - 23.7) * 0.02} F50\nG1 E{(flush_length_1 - 23.7) * 0.23} F{old_filament_e_feedrate}\nG1 E{(flush_length_1 - 23.7) * 0.02} F50\nG1 E{(flush_length_1 - 23.7) * 0.23} F{new_filament_e_feedrate}\nG1 E{(flush_length_1 - 23.7) * 0.02} F50\nG1 E{(flush_length_1 - 23.7) * 0.23} F{new_filament_e_feedrate}\nG1 E{(flush_length_1 - 23.7) * 0.02} F50\nG1 E{(flush_length_1 - 23.7) * 0.23} F{new_filament_e_feedrate}\n{else}\nG1 E{flush_length_1} F{old_filament_e_feedrate}\n{endif}\n; FLUSH_END\nG1 E-[old_retract_length_toolchange] F1800\nG1 E[old_retract_length_toolchange] F300\n{endif}\n\n{if flush_length_2 > 1}\n; FLUSH_START\nG1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_2 * 0.02} F50\nG1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_2 * 0.02} F50\nG1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_2 * 0.02} F50\nG1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_2 * 0.02} F50\nG1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_2 * 0.02} F50\n; FLUSH_END\nG1 E-[new_retract_length_toolchange] F1800\nG1 E[new_retract_length_toolchange] F300\n{endif}\n\n{if flush_length_3 > 1}\n; FLUSH_START\nG1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_3 * 0.02} F50\nG1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_3 * 0.02} F50\nG1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_3 * 0.02} F50\nG1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_3 * 0.02} F50\nG1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_3 * 0.02} F50\n; FLUSH_END\nG1 E-[new_retract_length_toolchange] F1800\nG1 E[new_retract_length_toolchange] F300\n{endif}\n\n{if flush_length_4 > 1}\n; FLUSH_START\nG1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_4 * 0.02} F50\nG1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_4 * 0.02} F50\nG1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_4 * 0.02} F50\nG1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_4 * 0.02} F50\nG1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_4 * 0.02} F50\n; FLUSH_END\n{endif}\n; FLUSH_START\nM400\nM109 S[new_filament_temp]\nG1 E2 F{new_filament_e_feedrate} ;Compensate for filament spillage during waiting temperature\n; FLUSH_END\nM400\nG92 E0\nG1 E-[new_retract_length_toolchange] F1800\nM106 P1 S255\nM400 S3\nG1 X80 F15000\nG1 X60 F15000\nG1 X80 F15000\nG1 X60 F15000; shake to put down garbage\n\nG1 X70 F5000\nG1 X90 F3000\nG1 Y255 F4000\nG1 X100 F5000\nG1 Y265 F5000\nG1 X70 F10000\nG1 X100 F5000\nG1 X70 F10000\nG1 X100 F5000\nG1 X165 F15000; wipe and shake\nG1 Y256 ; move Y to aside, prevent collision\nM400\nG1 Z{max_layer_z + 3.0} F3000\n{if layer_z <= (initial_layer_print_height + 0.001)}\nM204 S[initial_layer_acceleration]\n{else}\nM204 S[default_acceleration]\n{endif}\n{else}\nG1 X[x_after_toolchange] Y[y_after_toolchange] Z[z_after_toolchange] F12000\n{endif}\nM621 S[next_extruder]A",
|
"change_filament_gcode": "M620 S[next_extruder]A\nM204 S9000\n{if toolchange_count > 1 && (z_hop_types[current_extruder] == 0 || z_hop_types[current_extruder] == 3)}\nG17\nG2 Z{z_after_toolchange + 0.4} I0.86 J0.86 P1 F10000 ; spiral lift a little from second lift\n{endif}\nG1 Z{max_layer_z + 3.0} F1200\n\nG1 X70 F21000\nG1 Y245\nG1 Y265 F3000\nM400\nM106 P1 S0\nM106 P2 S0\n{if old_filament_temp > 142 && next_extruder < 255}M104 S[old_filament_temp]{endif}\nG1 X90 F3000\nG1 Y255 F4000\nG1 X100 F5000\nG1 X120 F15000\n\nG1 X20 Y50 F21000\nG1 Y-3\n{if toolchange_count == 2}\n; get travel path for change filament\nM620.1 X[travel_point_1_x] Y[travel_point_1_y] F21000 P0\nM620.1 X[travel_point_2_x] Y[travel_point_2_y] F21000 P1\nM620.1 X[travel_point_3_x] Y[travel_point_3_y] F21000 P2\n{endif}\nM620.1 E F[old_filament_e_feedrate] T{nozzle_temperature_range_high[previous_extruder]}\nT[next_extruder]\nM620.1 E F[new_filament_e_feedrate] T{nozzle_temperature_range_high[next_extruder]}\n\n{if next_extruder < 255}\nM400\n\nG92 E0\n{if flush_length_1 > 1}\n; FLUSH_START\n; always use highest temperature to flush\nM400\nM109 S[nozzle_temperature_range_high]\n{if flush_length_1 > 23.7}\nG1 E23.7 F{old_filament_e_feedrate} ; do not need pulsatile flushing for start part\nG1 E{(flush_length_1 - 23.7) * 0.02} F50\nG1 E{(flush_length_1 - 23.7) * 0.23} F{old_filament_e_feedrate}\nG1 E{(flush_length_1 - 23.7) * 0.02} F50\nG1 E{(flush_length_1 - 23.7) * 0.23} F{new_filament_e_feedrate}\nG1 E{(flush_length_1 - 23.7) * 0.02} F50\nG1 E{(flush_length_1 - 23.7) * 0.23} F{new_filament_e_feedrate}\nG1 E{(flush_length_1 - 23.7) * 0.02} F50\nG1 E{(flush_length_1 - 23.7) * 0.23} F{new_filament_e_feedrate}\n{else}\nG1 E{flush_length_1} F{old_filament_e_feedrate}\n{endif}\n; FLUSH_END\nG1 E-[old_retract_length_toolchange] F1800\nG1 E[old_retract_length_toolchange] F300\n{endif}\n\n{if flush_length_2 > 1}\n; FLUSH_START\nG1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_2 * 0.02} F50\nG1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_2 * 0.02} F50\nG1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_2 * 0.02} F50\nG1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_2 * 0.02} F50\nG1 E{flush_length_2 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_2 * 0.02} F50\n; FLUSH_END\nG1 E-[new_retract_length_toolchange] F1800\nG1 E[new_retract_length_toolchange] F300\n{endif}\n\n{if flush_length_3 > 1}\n; FLUSH_START\nG1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_3 * 0.02} F50\nG1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_3 * 0.02} F50\nG1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_3 * 0.02} F50\nG1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_3 * 0.02} F50\nG1 E{flush_length_3 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_3 * 0.02} F50\n; FLUSH_END\nG1 E-[new_retract_length_toolchange] F1800\nG1 E[new_retract_length_toolchange] F300\n{endif}\n\n{if flush_length_4 > 1}\n; FLUSH_START\nG1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_4 * 0.02} F50\nG1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_4 * 0.02} F50\nG1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_4 * 0.02} F50\nG1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_4 * 0.02} F50\nG1 E{flush_length_4 * 0.18} F{new_filament_e_feedrate}\nG1 E{flush_length_4 * 0.02} F50\n; FLUSH_END\n{endif}\n; FLUSH_START\nM400\nM109 S[new_filament_temp]\nG1 E2 F{new_filament_e_feedrate} ;Compensate for filament spillage during waiting temperature\n; FLUSH_END\nM400\nG92 E0\nG1 E-[new_retract_length_toolchange] F1800\nM106 P1 S255\nM400 S3\nG1 X80 F15000\nG1 X60 F15000\nG1 X80 F15000\nG1 X60 F15000; shake to put down garbage\n\nG1 X70 F5000\nG1 X90 F3000\nG1 Y255 F4000\nG1 X100 F5000\nG1 Y265 F5000\nG1 X70 F10000\nG1 X100 F5000\nG1 X70 F10000\nG1 X100 F5000\nG1 X165 F15000; wipe and shake\nG1 Y256 ; move Y to aside, prevent collision\nM400\nG1 Z{max_layer_z + 3.0} F3000\n{if layer_z <= (initial_layer_print_height + 0.001)}\nM204 S[initial_layer_acceleration]\n{else}\nM204 S[default_acceleration]\n{endif}\n{else}\nG1 X[x_after_toolchange] Y[y_after_toolchange] Z[z_after_toolchange] F12000\n{endif}\nM621 S[next_extruder]A",
|
||||||
"layer_change_gcode": "; layer num/total_layer_count: {layer_num+1}/[total_layer_count]\nM622.1 S1 ; for prev firware, default turned on\nM1002 judge_flag timelapse_record_flag\nM622 J1\n{if timelapse_type == 0} ; timelapse without wipe tower\nM971 S11 C10 O0\n{elsif timelapse_type == 1} ; timelapse with wipe tower\nG92 E0\nG1 E-[retraction_length] F1800\nG17\nG2 Z{layer_z + 0.4} I0.86 J0.86 P1 F20000 ; spiral lift a little\nG1 X65 Y245 F20000 ; move to safe pos\nG17\nG2 Z{layer_z} I0.86 J0.86 P1 F20000\nG1 Y265 F3000\nM400 P300\nM971 S11 C10 O0\nG92 E0\nG1 E[retraction_length] F300\nG1 X100 F5000\nG1 Y255 F20000\n{endif}\nM623\n; update layer progress\nM73 L{layer_num+1}\nM991 S0 P{layer_num} ;notify layer change",
|
"layer_change_gcode": "; layer num/total_layer_count: {layer_num+1}/[total_layer_count]\nM622.1 S1 ; for prev firware, default turned on\nM1002 judge_flag timelapse_record_flag\nM622 J1\n{if timelapse_type == 0} ; timelapse without wipe tower\nM971 S11 C10 O0\n{elsif timelapse_type == 1} ; timelapse with wipe tower\nG92 E0\nG1 E-[retraction_length] F1800\nG17\nG2 Z{layer_z + 0.4} I0.86 J0.86 P1 F20000 ; spiral lift a little\nG1 X65 Y245 F20000 ; move to safe pos\nG17\nG2 Z{layer_z} I0.86 J0.86 P1 F20000\nG1 Y265 F3000\nM400 P300\nM971 S11 C10 O0\nG92 E0\nG1 E[retraction_length] F300\nG1 X100 F5000\nG1 Y255 F20000\n{endif}\nM623\n; update layer progress\nM73 L{layer_num+1}\nM991 S0 P{layer_num} ;notify layer change",
|
||||||
"machine_end_gcode": ";===== date: 20230118 =====================\nM400 ; wait for buffer to clear\nG92 E0 ; zero the extruder\nG1 E-0.8 F1800 ; retract\nG1 Z{max_layer_z + 0.5} F900 ; lower z a little\nG1 X65 Y245 F12000 ; move to safe pos \nG1 Y265 F3000\nM991 S0 P-1 ;end smooth timelapse at safe pos\nM400 S2 ;wait for last picture to be taken\n\nG1 X65 Y245 F12000\nG1 Y265 F3000\nM140 S0 ; turn off bed\nM106 S0 ; turn off fan\nM106 P2 S0 ; turn off remote part cooling fan\nM106 P3 S0 ; turn off chamber cooling fan\n\nG1 X100 F12000 ; wipe\n; pull back filament to AMS\nM620 S255\nG1 X20 Y50 F12000\nG1 Y-3\nT255\nG1 X65 F12000\nG1 Y265\nG1 X100 F12000 ; wipe\nM621 S255\nM104 S0 ; turn off hotend\n\nM400 ; wait all motion done\nM17 S\nM17 Z0.4 ; lower z motor current to reduce impact if there is something in the bottom\n{if (max_layer_z + 100.0) < 250}\n G1 Z{max_layer_z + 100.0} F600\n G1 Z{max_layer_z +98.0}\n{else}\n G1 Z250 F600\n G1 Z248\n{endif}\nM400 P100\nM17 R ; restore z current\n\nG90\nG1 X128 Y250 F3600\n\nM220 S100 ; Reset feedrate magnitude\nM201.2 K1.0 ; Reset acc magnitude\nM73.2 R1.0 ;Reset left time magnitude\nM1002 set_gcode_claim_speed_level : 0\n\nM17 X0.8 Y0.8 Z0.5 ; lower motor current to 45% power\n\n",
|
"machine_end_gcode": ";===== date: 20230118 =====================\nM400 ; wait for buffer to clear\nG92 E0 ; zero the extruder\nG1 E-0.8 F1800 ; retract\nG1 Z{max_layer_z + 0.5} F900 ; lower z a little\nG1 X65 Y245 F12000 ; move to safe pos \nG1 Y265 F3000\nM991 S0 P-1 ;end smooth timelapse at safe pos\nM400 S2 ;wait for last picture to be taken\n\nG1 X65 Y245 F12000\nG1 Y265 F3000\nM140 S0 ; turn off bed\nM106 S0 ; turn off fan\nM106 P2 S0 ; turn off remote part cooling fan\nM106 P3 S0 ; turn off chamber cooling fan\n\nG1 X100 F12000 ; wipe\n; pull back filament to AMS\nM620 S255\nG1 X20 Y50 F12000\nG1 Y-3\nT255\nG1 X65 F12000\nG1 Y265\nG1 X100 F12000 ; wipe\nM621 S255\nM104 S0 ; turn off hotend\n\nM400 ; wait all motion done\nM17 S\nM17 Z0.4 ; lower z motor current to reduce impact if there is something in the bottom\n{if (max_layer_z + 100.0) < 250}\n G1 Z{max_layer_z + 100.0} F600\n G1 Z{max_layer_z +98.0}\n{else}\n G1 Z250 F600\n G1 Z248\n{endif}\nM400 P100\nM17 R ; restore z current\n\nG90\nG1 X128 Y250 F3600\n\nM220 S100 ; Reset feedrate magnitude\nM201.2 K1.0 ; Reset acc magnitude\nM73.2 R1.0 ;Reset left time magnitude\nM1002 set_gcode_claim_speed_level : 0\n\nM17 X0.8 Y0.8 Z0.5 ; lower motor current to 45% power\n\n",
|
||||||
"machine_pause_gcode": "M400 U1\n",
|
"machine_pause_gcode": "M400 U1",
|
||||||
"wipe": [
|
"wipe": [
|
||||||
"1"
|
"1"
|
||||||
]
|
]
|
||||||
|
|
|
@ -119,7 +119,7 @@
|
||||||
"silent_mode": "0",
|
"silent_mode": "0",
|
||||||
"single_extruder_multi_material": "1",
|
"single_extruder_multi_material": "1",
|
||||||
"change_filament_gcode": "",
|
"change_filament_gcode": "",
|
||||||
"machine_pause_gcode": "PAUSE\n",
|
"machine_pause_gcode": "PAUSE",
|
||||||
"wipe": [
|
"wipe": [
|
||||||
"1"
|
"1"
|
||||||
],
|
],
|
||||||
|
|
|
@ -498,14 +498,14 @@ void GCodeViewer::SequentialView::Marker::render(int canvas_width, int canvas_he
|
||||||
imgui.pop_toolbar_style();
|
imgui.pop_toolbar_style();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeViewer::SequentialView::GCodeWindow::load_gcode(const std::string& filename, std::vector<size_t> &&lines_ends)
|
void GCodeViewer::SequentialView::GCodeWindow::load_gcode(const std::string& filename, const std::vector<size_t> &lines_ends)
|
||||||
{
|
{
|
||||||
assert(! m_file.is_open());
|
assert(! m_file.is_open());
|
||||||
if (m_file.is_open())
|
if (m_file.is_open())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_filename = filename;
|
m_filename = filename;
|
||||||
m_lines_ends = std::move(lines_ends);
|
m_lines_ends = lines_ends;
|
||||||
|
|
||||||
m_selected_line_id = 0;
|
m_selected_line_id = 0;
|
||||||
m_last_lines_size = 0;
|
m_last_lines_size = 0;
|
||||||
|
@ -561,11 +561,11 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, f
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const ImVec4 LINE_NUMBER_COLOR = ImGuiWrapper::COL_ORANGE_LIGHT;
|
static const ImVec4 LINE_NUMBER_COLOR = { 0, 174.0f / 255.0f, 66.0f / 255.0f, 1.0f };
|
||||||
static const ImVec4 SELECTION_RECT_COLOR = ImGuiWrapper::COL_ORANGE_DARK;
|
static const ImVec4 SELECTION_RECT_COLOR = { 0, 174.0f / 255.0f, 66.0f / 255.0f, 1.0f };
|
||||||
static const ImVec4 COMMAND_COLOR = { 0.8f, 0.8f, 0.0f, 1.0f };
|
static const ImVec4 COMMAND_COLOR = m_is_dark ? ImVec4( 240.0f / 255.0f, 240.0f / 255.0f, 240.0f / 255.0f, 1.0f ) : ImVec4( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||||
static const ImVec4 PARAMETERS_COLOR = { 1.0f, 1.0f, 1.0f, 1.0f };
|
static const ImVec4 PARAMETERS_COLOR = m_is_dark ? ImVec4( 179.0f / 255.0f, 179.0f / 255.0f, 179.0f / 255.0f, 1.0f ) : ImVec4( 206.0f / 255.0f, 206.0f / 255.0f, 206.0f / 255.0f, 1.0f );
|
||||||
static const ImVec4 COMMENT_COLOR = { 0.7f, 0.7f, 0.7f, 1.0f };
|
static const ImVec4 COMMENT_COLOR = m_is_dark ? ImVec4(129.0f / 255.0f, 129.0f / 255.0f, 129.0f / 255.0f, 1.0f) : ImVec4( 172.0f / 255.0f, 172.0f / 255.0f, 172.0f / 255.0f, 1.0f );
|
||||||
|
|
||||||
if (!m_visible || m_filename.empty() || m_lines_ends.empty() || curr_line_id == 0)
|
if (!m_visible || m_filename.empty() || m_lines_ends.empty() || curr_line_id == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -615,7 +615,7 @@ void GCodeViewer::SequentialView::GCodeWindow::render(float top, float bottom, f
|
||||||
imgui.set_next_window_pos(right, top, ImGuiCond_Always, 1.0f, 0.0f);
|
imgui.set_next_window_pos(right, top, ImGuiCond_Always, 1.0f, 0.0f);
|
||||||
imgui.set_next_window_size(0.0f, wnd_height, ImGuiCond_Always);
|
imgui.set_next_window_size(0.0f, wnd_height, ImGuiCond_Always);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||||
ImGui::SetNextWindowBgAlpha(0.6f);
|
ImGui::SetNextWindowBgAlpha(0.8f);
|
||||||
imgui.begin(std::string("G-code"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove);
|
imgui.begin(std::string("G-code"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoMove);
|
||||||
|
|
||||||
// center the text in the window by pushing down the first line
|
// center the text in the window by pushing down the first line
|
||||||
|
@ -691,7 +691,7 @@ void GCodeViewer::SequentialView::GCodeWindow::stop_mapping_file()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//BBS: GUI refactor: move to the right
|
//BBS: GUI refactor: move to the right
|
||||||
void GCodeViewer::SequentialView::render(float legend_height, int canvas_width, int canvas_height, const EViewType& view_type) const
|
void GCodeViewer::SequentialView::render(float legend_height, int canvas_width, int canvas_height, int right_margin, const EViewType& view_type) const
|
||||||
{
|
{
|
||||||
marker.render(canvas_width, canvas_height, view_type);
|
marker.render(canvas_width, canvas_height, view_type);
|
||||||
|
|
||||||
|
@ -702,9 +702,7 @@ void GCodeViewer::SequentialView::render(float legend_height, int canvas_width,
|
||||||
bottom -= wxGetApp().plater()->get_view_toolbar().get_height();
|
bottom -= wxGetApp().plater()->get_view_toolbar().get_height();
|
||||||
#endif
|
#endif
|
||||||
//gcode_window.render(legend_height, bottom, static_cast<uint64_t>(gcode_ids[current.last]));
|
//gcode_window.render(legend_height, bottom, static_cast<uint64_t>(gcode_ids[current.last]));
|
||||||
if (wxGetApp().get_mode() == ConfigOptionMode::comDevelop) {
|
gcode_window.render(legend_height, (float)canvas_height, (float)canvas_width - (float)right_margin, static_cast<uint64_t>(gcode_ids[current.last]));
|
||||||
gcode_window.render(legend_height, (float)canvas_height, (float)canvas_width, static_cast<uint64_t>(gcode_ids[current.last]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<GCodeViewer::Color> GCodeViewer::Extrusion_Role_Colors {{
|
const std::vector<GCodeViewer::Color> GCodeViewer::Extrusion_Role_Colors {{
|
||||||
|
@ -898,6 +896,7 @@ void GCodeViewer::init(ConfigOptionMode mode, PresetBundle* preset_bundle)
|
||||||
void GCodeViewer::on_change_color_mode(bool is_dark) {
|
void GCodeViewer::on_change_color_mode(bool is_dark) {
|
||||||
m_is_dark = is_dark;
|
m_is_dark = is_dark;
|
||||||
m_sequential_view.marker.on_change_color_mode(m_is_dark);
|
m_sequential_view.marker.on_change_color_mode(m_is_dark);
|
||||||
|
m_sequential_view.gcode_window.on_change_color_mode(m_is_dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeViewer::set_scale(float scale)
|
void GCodeViewer::set_scale(float scale)
|
||||||
|
@ -984,11 +983,7 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
|
||||||
m_gcode_result = &gcode_result;
|
m_gcode_result = &gcode_result;
|
||||||
m_only_gcode_in_preview = only_gcode;
|
m_only_gcode_in_preview = only_gcode;
|
||||||
|
|
||||||
if (mode == ConfigOptionMode::comDevelop) {
|
m_sequential_view.gcode_window.load_gcode(gcode_result.filename, gcode_result.lines_ends);
|
||||||
m_sequential_view.gcode_window.load_gcode(gcode_result.filename,
|
|
||||||
// Stealing out lines_ends should be safe because this gcode_result is processed only once (see the 1st if in this function).
|
|
||||||
std::move(const_cast<std::vector<size_t>&>(gcode_result.lines_ends)));
|
|
||||||
}
|
|
||||||
|
|
||||||
//BBS: add only gcode mode
|
//BBS: add only gcode mode
|
||||||
//if (wxGetApp().is_gcode_viewer())
|
//if (wxGetApp().is_gcode_viewer())
|
||||||
|
@ -1092,7 +1087,6 @@ void GCodeViewer::load(const GCodeProcessorResult& gcode_result, const Print& pr
|
||||||
bool current_has_print_instances = current_plate->has_printable_instances();
|
bool current_has_print_instances = current_plate->has_printable_instances();
|
||||||
if (current_plate->is_slice_result_valid() && wxGetApp().model().objects.empty() && !current_has_print_instances)
|
if (current_plate->is_slice_result_valid() && wxGetApp().model().objects.empty() && !current_has_print_instances)
|
||||||
only_gcode_3mf = true;
|
only_gcode_3mf = true;
|
||||||
|
|
||||||
m_layers_slider->set_menu_enable(!(only_gcode || only_gcode_3mf));
|
m_layers_slider->set_menu_enable(!(only_gcode || only_gcode_3mf));
|
||||||
m_layers_slider->set_as_dirty();
|
m_layers_slider->set_as_dirty();
|
||||||
m_moves_slider->set_as_dirty();
|
m_moves_slider->set_as_dirty();
|
||||||
|
@ -1287,7 +1281,7 @@ void GCodeViewer::render(int canvas_width, int canvas_height, int right_margin)
|
||||||
m_sequential_view.marker.set_world_position(m_sequential_view.current_position);
|
m_sequential_view.marker.set_world_position(m_sequential_view.current_position);
|
||||||
m_sequential_view.marker.set_world_offset(m_sequential_view.current_offset);
|
m_sequential_view.marker.set_world_offset(m_sequential_view.current_offset);
|
||||||
//BBS fixed buttom margin. m_moves_slider.pos_y
|
//BBS fixed buttom margin. m_moves_slider.pos_y
|
||||||
m_sequential_view.render(legend_height, canvas_width, canvas_height - bottom_margin * m_scale, m_view_type);
|
m_sequential_view.render(legend_height, canvas_width, canvas_height - bottom_margin * m_scale, right_margin * m_scale, m_view_type);
|
||||||
}
|
}
|
||||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
render_statistics();
|
render_statistics();
|
||||||
|
@ -4345,7 +4339,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
||||||
ImGui::PushStyleColor(ImGuiCol_ScrollbarGrab, ImVec4(0.42f, 0.42f, 0.42f, 1.00f));
|
ImGui::PushStyleColor(ImGuiCol_ScrollbarGrab, ImVec4(0.42f, 0.42f, 0.42f, 1.00f));
|
||||||
ImGui::PushStyleColor(ImGuiCol_ScrollbarGrabHovered, ImVec4(0.93f, 0.93f, 0.93f, 1.00f));
|
ImGui::PushStyleColor(ImGuiCol_ScrollbarGrabHovered, ImVec4(0.93f, 0.93f, 0.93f, 1.00f));
|
||||||
ImGui::PushStyleColor(ImGuiCol_ScrollbarGrabActive, ImVec4(0.93f, 0.93f, 0.93f, 1.00f));
|
ImGui::PushStyleColor(ImGuiCol_ScrollbarGrabActive, ImVec4(0.93f, 0.93f, 0.93f, 1.00f));
|
||||||
ImGui::SetNextWindowBgAlpha(0.6f);
|
ImGui::SetNextWindowBgAlpha(0.8f);
|
||||||
const float max_height = 0.75f * static_cast<float>(cnv_size.get_height());
|
const float max_height = 0.75f * static_cast<float>(cnv_size.get_height());
|
||||||
const float child_height = 0.3333f * max_height;
|
const float child_height = 0.3333f * max_height;
|
||||||
ImGui::SetNextWindowSizeConstraints({ 0.0f, 0.0f }, { -1.0f, max_height });
|
ImGui::SetNextWindowSizeConstraints({ 0.0f, 0.0f }, { -1.0f, max_height });
|
||||||
|
|
|
@ -648,6 +648,7 @@ public:
|
||||||
std::string parameters;
|
std::string parameters;
|
||||||
std::string comment;
|
std::string comment;
|
||||||
};
|
};
|
||||||
|
bool m_is_dark = false;
|
||||||
bool m_visible{ true };
|
bool m_visible{ true };
|
||||||
uint64_t m_selected_line_id{ 0 };
|
uint64_t m_selected_line_id{ 0 };
|
||||||
size_t m_last_lines_size{ 0 };
|
size_t m_last_lines_size{ 0 };
|
||||||
|
@ -661,7 +662,7 @@ public:
|
||||||
public:
|
public:
|
||||||
GCodeWindow() = default;
|
GCodeWindow() = default;
|
||||||
~GCodeWindow() { stop_mapping_file(); }
|
~GCodeWindow() { stop_mapping_file(); }
|
||||||
void load_gcode(const std::string& filename, std::vector<size_t> &&lines_ends);
|
void load_gcode(const std::string& filename, const std::vector<size_t> &lines_ends);
|
||||||
void reset() {
|
void reset() {
|
||||||
stop_mapping_file();
|
stop_mapping_file();
|
||||||
m_lines_ends.clear();
|
m_lines_ends.clear();
|
||||||
|
@ -674,6 +675,7 @@ public:
|
||||||
//BBS: GUI refactor: add canvas size
|
//BBS: GUI refactor: add canvas size
|
||||||
//void render(float top, float bottom, uint64_t curr_line_id) const;
|
//void render(float top, float bottom, uint64_t curr_line_id) const;
|
||||||
void render(float top, float bottom, float right, uint64_t curr_line_id) const;
|
void render(float top, float bottom, float right, uint64_t curr_line_id) const;
|
||||||
|
void on_change_color_mode(bool is_dark) { m_is_dark = is_dark; }
|
||||||
|
|
||||||
void stop_mapping_file();
|
void stop_mapping_file();
|
||||||
};
|
};
|
||||||
|
@ -697,7 +699,7 @@ public:
|
||||||
float m_scale = 1.0;
|
float m_scale = 1.0;
|
||||||
|
|
||||||
//BBS: GUI refactor: add canvas size
|
//BBS: GUI refactor: add canvas size
|
||||||
void render(float legend_height, int canvas_width, int canvas_height, const EViewType& view_type) const;
|
void render(float legend_height, int canvas_width, int canvas_height, int right_margin, const EViewType& view_type) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ETools
|
struct ETools
|
||||||
|
|
|
@ -67,6 +67,8 @@ static std::string gcode(Type type)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
//BBS
|
//BBS
|
||||||
case Template: return config.opt_string("template_custom_gcode");
|
case Template: return config.opt_string("template_custom_gcode");
|
||||||
|
case PausePrint: return config.opt_string("machine_pause_gcode");
|
||||||
|
|
||||||
default: return "";
|
default: return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,6 +152,7 @@ bool IMSlider::init_texture()
|
||||||
result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off_dark.svg", 28, 28, m_one_layer_off_dark_id);
|
result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off_dark.svg", 28, 28, m_one_layer_off_dark_id);
|
||||||
result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off_hover_dark.svg", 28, 28, m_one_layer_off_hover_dark_id);
|
result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/one_layer_off_hover_dark.svg", 28, 28, m_one_layer_off_hover_dark_id);
|
||||||
result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/im_gcode_pause.svg", 14, 14, m_pause_icon_id);
|
result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/im_gcode_pause.svg", 14, 14, m_pause_icon_id);
|
||||||
|
result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/im_gcode_custom.svg", 14, 14, m_custom_icon_id);
|
||||||
result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/im_slider_delete.svg", 14, 14, m_delete_icon_id);
|
result &= IMTexture::load_from_svg_file(Slic3r::resources_dir() + "/images/im_slider_delete.svg", 14, 14, m_delete_icon_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,18 +295,12 @@ void IMSlider::SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model,
|
||||||
|
|
||||||
UseDefaultColors(m_mode == SingleExtruder);
|
UseDefaultColors(m_mode == SingleExtruder);
|
||||||
|
|
||||||
auto curr_plate = wxGetApp().plater()->get_partplate_list().get_curr_plate();
|
m_is_wipe_tower = m_mode != SingleExtruder;
|
||||||
auto curr_print_seq = curr_plate->get_real_print_seq();
|
|
||||||
|
|
||||||
if (curr_print_seq == PrintSequence::ByObject)
|
|
||||||
m_is_wipe_tower = false;
|
|
||||||
else
|
|
||||||
m_is_wipe_tower = m_mode != SingleExtruder;
|
|
||||||
|
|
||||||
auto config = wxGetApp().preset_bundle->full_config();
|
auto config = wxGetApp().preset_bundle->full_config();
|
||||||
m_is_spiral_vase = config.option<ConfigOptionBool>("spiral_mode")->value;
|
m_is_spiral_vase = config.option<ConfigOptionBool>("spiral_mode")->value;
|
||||||
|
|
||||||
m_can_change_color = can_change_color;
|
m_can_change_color = can_change_color && !m_is_spiral_vase;
|
||||||
|
|
||||||
// close opened menu window after reslice
|
// close opened menu window after reslice
|
||||||
m_show_menu = false;
|
m_show_menu = false;
|
||||||
|
@ -376,6 +373,11 @@ void IMSlider::add_code_as_tick(Type type, int selected_extruder)
|
||||||
post_ticks_changed_event(type);
|
post_ticks_changed_event(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IMSlider::delete_tick(const TickCode& tick) {
|
||||||
|
m_ticks.ticks.erase(tick);
|
||||||
|
post_ticks_changed_event(tick.type);
|
||||||
|
}
|
||||||
|
|
||||||
bool IMSlider::check_ticks_changed_event(Type type)
|
bool IMSlider::check_ticks_changed_event(Type type)
|
||||||
{
|
{
|
||||||
//BBL only support MultiExtruder
|
//BBL only support MultiExtruder
|
||||||
|
@ -623,12 +625,16 @@ void IMSlider::draw_ticks(const ImRect& slideable_region) {
|
||||||
if (ImGui::IsMouseHoveringRect(tick_hover_box.Min, tick_hover_box.Max))
|
if (ImGui::IsMouseHoveringRect(tick_hover_box.Min, tick_hover_box.Max))
|
||||||
{
|
{
|
||||||
// render left tick box
|
// render left tick box
|
||||||
ImGui::RenderFrame(tick_hover_box.Min, { slideable_region.Min.x, tick_hover_box.Max.y }, tick_hover_box_clr, false);
|
ImRect left_hover_box = ImRect(tick_hover_box.Min, { slideable_region.Min.x, tick_hover_box.Max.y });
|
||||||
|
ImGui::RenderFrame(left_hover_box.Min, left_hover_box.Max, tick_hover_box_clr, false);
|
||||||
// render right tick box
|
// render right tick box
|
||||||
ImGui::RenderFrame({ slideable_region.Max.x, tick_hover_box.Min.y }, tick_hover_box.Max, tick_hover_box_clr, false);
|
ImRect right_hover_box = ImRect({ slideable_region.Max.x, tick_hover_box.Min.y }, tick_hover_box.Max);
|
||||||
|
ImGui::RenderFrame(right_hover_box.Min, right_hover_box.Max, tick_hover_box_clr, false);
|
||||||
|
|
||||||
|
show_tooltip(*tick_it);
|
||||||
if (context.IO.MouseClicked[0]) {
|
if (context.IO.MouseClicked[0]) {
|
||||||
m_tick_value = tick_it->tick;
|
m_tick_value = tick_it->tick;
|
||||||
m_tick_rect = ImVec4(tick_hover_box.Min.x, tick_hover_box.Min.y, tick_hover_box.Max.x, tick_hover_box.Max.y);
|
m_tick_rect = ImVec4(tick_hover_box.Min.x, tick_hover_box.Min.y, tick_hover_box.Max.x, tick_hover_box.Max.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++tick_it;
|
++tick_it;
|
||||||
|
@ -651,6 +657,11 @@ void IMSlider::draw_ticks(const ImRect& slideable_region) {
|
||||||
ImVec2 icon_pos = ImVec2(slideable_region.GetCenter().x + icon_offset.x, tick_pos - icon_offset.y);
|
ImVec2 icon_pos = ImVec2(slideable_region.GetCenter().x + icon_offset.x, tick_pos - icon_offset.y);
|
||||||
button_with_pos(pause_icon_id, icon_size, icon_pos);
|
button_with_pos(pause_icon_id, icon_size, icon_pos);
|
||||||
}
|
}
|
||||||
|
if (tick_it->type == Custom || tick_it->type == Template) {
|
||||||
|
ImTextureID custom_icon_id = m_custom_icon_id;
|
||||||
|
ImVec2 icon_pos = ImVec2(slideable_region.GetCenter().x + icon_offset.x, tick_pos - icon_offset.y);
|
||||||
|
button_with_pos(custom_icon_id, icon_size, icon_pos);
|
||||||
|
}
|
||||||
++tick_it;
|
++tick_it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,13 +675,41 @@ void IMSlider::draw_ticks(const ImRect& slideable_region) {
|
||||||
if (ImGui::IsMouseHoveringRect(icon_pos, icon_pos + icon_size)) {
|
if (ImGui::IsMouseHoveringRect(icon_pos, icon_pos + icon_size)) {
|
||||||
if (context.IO.MouseClicked[0]) {
|
if (context.IO.MouseClicked[0]) {
|
||||||
// delete tick
|
// delete tick
|
||||||
Type type = tick_it->type;
|
delete_tick(*tick_it);
|
||||||
m_ticks.ticks.erase(tick_it);
|
|
||||||
post_ticks_changed_event(type);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMSlider::show_tooltip(const TickCode& tick){
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, { 6 * m_scale, 3 * m_scale });
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, { 3 * m_scale });
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_PopupBg, ImGuiWrapper::COL_WINDOW_BACKGROUND);
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Border, { 0,0,0,0 });
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.00f, 1.00f, 1.00f, 1.00f));
|
||||||
|
ImGui::BeginTooltip();
|
||||||
|
switch (tick.type)
|
||||||
|
{
|
||||||
|
case CustomGCode::ColorChange:
|
||||||
|
break;
|
||||||
|
case CustomGCode::PausePrint:
|
||||||
|
ImGui::TextUnformatted((_u8L("Pause:") + " \"" + gcode(PausePrint) + "\"").c_str());
|
||||||
|
break;
|
||||||
|
case CustomGCode::ToolChange:
|
||||||
|
ImGui::TextUnformatted(_u8L("Change Filament").c_str());
|
||||||
|
break;
|
||||||
|
case CustomGCode::Template:
|
||||||
|
ImGui::TextUnformatted((_u8L("Custom Template:") + " \"" + gcode(Template) + "\"").c_str());
|
||||||
|
break;
|
||||||
|
case CustomGCode::Custom:
|
||||||
|
ImGui::TextUnformatted((_u8L("Custom G-code:") + " \"" + tick.extra + "\"").c_str());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ImGui::EndTooltip();
|
||||||
|
ImGui::PopStyleColor(3);
|
||||||
|
ImGui::PopStyleVar(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IMSlider::vertical_slider(const char* str_id, int* higher_value, int* lower_value, std::string& higher_label, std::string& lower_label,int v_min, int v_max, const ImVec2& size, SelectedSlider& selection, bool one_layer_flag, float scale)
|
bool IMSlider::vertical_slider(const char* str_id, int* higher_value, int* lower_value, std::string& higher_label, std::string& lower_label,int v_min, int v_max, const ImVec2& size, SelectedSlider& selection, bool one_layer_flag, float scale)
|
||||||
|
@ -790,12 +829,10 @@ bool IMSlider::vertical_slider(const char* str_id, int* higher_value, int* lower
|
||||||
context.IO.MouseClicked[0])
|
context.IO.MouseClicked[0])
|
||||||
m_show_menu = false;
|
m_show_menu = false;
|
||||||
|
|
||||||
if (!m_ticks.empty()) {
|
// draw ticks
|
||||||
// draw ticks
|
draw_ticks(h_selected ? higher_slideable_region : lower_slideable_region);
|
||||||
draw_ticks(h_selected ? higher_slideable_region : lower_slideable_region);
|
// draw colored band
|
||||||
// draw colored band
|
draw_colored_band(groove, h_selected ? higher_slideable_region : lower_slideable_region);
|
||||||
draw_colored_band(groove, h_selected ? higher_slideable_region : lower_slideable_region);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_ticks.has_tick_with_code(ToolChange)) {
|
if (!m_ticks.has_tick_with_code(ToolChange)) {
|
||||||
// draw scroll line
|
// draw scroll line
|
||||||
|
@ -862,12 +899,10 @@ bool IMSlider::vertical_slider(const char* str_id, int* higher_value, int* lower
|
||||||
|
|
||||||
ImVec2 bar_center = higher_handle.GetCenter();
|
ImVec2 bar_center = higher_handle.GetCenter();
|
||||||
|
|
||||||
if (!m_ticks.empty()) {
|
// draw ticks
|
||||||
// draw ticks
|
draw_ticks(one_slideable_region);
|
||||||
draw_ticks(one_slideable_region);
|
// draw colored band
|
||||||
// draw colored band
|
draw_colored_band(groove, one_slideable_region);
|
||||||
draw_colored_band(groove, one_slideable_region);
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw handle
|
// draw handle
|
||||||
window->DrawList->AddLine(ImVec2(mid_x - 0.5 * bar_width, handle_center.y), ImVec2(mid_x + 0.5 * bar_width, handle_center.y), handle_clr, 2 * line_width);
|
window->DrawList->AddLine(ImVec2(mid_x - 0.5 * bar_width, handle_center.y), ImVec2(mid_x + 0.5 * bar_width, handle_center.y), handle_clr, 2 * line_width);
|
||||||
|
@ -963,7 +998,7 @@ bool IMSlider::render(int canvas_width, int canvas_height)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMSlider::render_input_custom_gcode()
|
void IMSlider::render_input_custom_gcode(std::string custom_gcode)
|
||||||
{
|
{
|
||||||
if (m_show_custom_gcode_window)
|
if (m_show_custom_gcode_window)
|
||||||
ImGui::OpenPopup((_u8L("Custom G-code")).c_str());
|
ImGui::OpenPopup((_u8L("Custom G-code")).c_str());
|
||||||
|
@ -995,9 +1030,13 @@ void IMSlider::render_input_custom_gcode()
|
||||||
if (set_focus && !ImGui::IsAnyItemActive() && !ImGui::IsMouseClicked(0)) {
|
if (set_focus && !ImGui::IsAnyItemActive() && !ImGui::IsMouseClicked(0)) {
|
||||||
wxGetApp().plater()->get_current_canvas3D()->force_set_focus();
|
wxGetApp().plater()->get_current_canvas3D()->force_set_focus();
|
||||||
ImGui::SetKeyboardFocusHere(0);
|
ImGui::SetKeyboardFocusHere(0);
|
||||||
|
strcpy(m_custom_gcode, custom_gcode.c_str());
|
||||||
}
|
}
|
||||||
const int text_height = 6;
|
const int text_height = 6;
|
||||||
ImGui::InputTextMultiline("##text", m_custom_gcode, sizeof(m_custom_gcode), ImVec2(-1, ImGui::GetTextLineHeight() * text_height));
|
|
||||||
|
ImGui::InputTextMultiline("##text", m_custom_gcode, sizeof(m_custom_gcode), ImVec2(-1, ImGui::GetTextLineHeight() * text_height), ImGuiInputTextFlags_CallbackAlways, [](ImGuiInputTextCallbackData* data) {
|
||||||
|
return data->CursorPos = data->BufTextLen;
|
||||||
|
});
|
||||||
|
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
ImGui::SameLine(ImGui::GetStyle().WindowPadding.x * 14);
|
ImGui::SameLine(ImGui::GetStyle().WindowPadding.x * 14);
|
||||||
|
@ -1046,7 +1085,7 @@ void IMSlider::do_go_to_layer(size_t layer_number) {
|
||||||
void IMSlider::render_go_to_layer_dialog()
|
void IMSlider::render_go_to_layer_dialog()
|
||||||
{
|
{
|
||||||
if (m_show_go_to_layer_dialog)
|
if (m_show_go_to_layer_dialog)
|
||||||
ImGui::OpenPopup((_u8L("Jump to layer")).c_str());
|
ImGui::OpenPopup((_u8L("Jump to Layer")).c_str());
|
||||||
|
|
||||||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||||
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
|
ImVec2 center = ImGui::GetMainViewport()->GetCenter();
|
||||||
|
@ -1123,28 +1162,41 @@ void IMSlider::render_go_to_layer_dialog()
|
||||||
imgui.pop_menu_style();
|
imgui.pop_menu_style();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMSlider::render_menu()
|
void IMSlider::render_menu() {
|
||||||
{
|
|
||||||
if (!m_menu_enable)
|
if (!m_menu_enable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGuiWrapper::push_menu_style(m_scale);
|
ImGuiWrapper::push_menu_style(m_scale);
|
||||||
int extruder_num = m_extruder_colors.size();
|
ImGui::PushStyleVar(ImGuiStyleVar_::ImGuiStyleVar_ChildRounding, 4.0f * m_scale);
|
||||||
|
|
||||||
if (m_show_menu) {
|
auto tick_it = GetSelection() == ssHigher ? m_ticks.ticks.find(TickCode{ GetHigherValue() }) :
|
||||||
ImGui::OpenPopup("slider_menu_popup");
|
GetSelection() == ssLower ? m_ticks.ticks.find(TickCode{ GetLowerValue() }) :
|
||||||
|
m_ticks.ticks.end();
|
||||||
|
std::string custom_code;
|
||||||
|
if (tick_it != m_ticks.ticks.end()) {
|
||||||
|
render_edit_menu(*tick_it);
|
||||||
|
if (tick_it->type == CustomGCode::Custom)
|
||||||
|
custom_code = tick_it->extra;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
render_add_menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_::ImGuiStyleVar_ChildRounding, 4.0f * m_scale);
|
ImGui::PopStyleVar(1);
|
||||||
if (ImGui::BeginPopup("slider_menu_popup")) {
|
ImGuiWrapper::pop_menu_style();
|
||||||
|
|
||||||
|
render_input_custom_gcode(custom_code);
|
||||||
|
render_go_to_layer_dialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IMSlider::render_add_menu()
|
||||||
|
{
|
||||||
|
int extruder_num = m_extruder_colors.size();
|
||||||
|
|
||||||
|
if (m_show_menu)
|
||||||
|
ImGui::OpenPopup("slider_add_menu_popup");
|
||||||
|
if (ImGui::BeginPopup("slider_add_menu_popup")) {
|
||||||
bool menu_item_enable = m_draw_mode != dmSequentialFffPrint;
|
bool menu_item_enable = m_draw_mode != dmSequentialFffPrint;
|
||||||
//if ((m_selection == ssLower && GetLowerValueD() == m_zero_layer_height) || (m_selection == ssHigher && GetHigherValueD() == m_zero_layer_height))
|
|
||||||
//{
|
|
||||||
// if (menu_item_with_icon(_u8L("Jump to Layer").c_str(), "")) {
|
|
||||||
// m_show_go_to_layer_dialog = true;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
{
|
{
|
||||||
if (menu_item_with_icon(_u8L("Add Pause").c_str(), "", ImVec2(0, 0), 0, false, menu_item_enable)) {
|
if (menu_item_with_icon(_u8L("Add Pause").c_str(), "", ImVec2(0, 0), 0, false, menu_item_enable)) {
|
||||||
add_code_as_tick(PausePrint);
|
add_code_as_tick(PausePrint);
|
||||||
|
@ -1164,7 +1216,7 @@ void IMSlider::render_menu()
|
||||||
|
|
||||||
//BBS render this menu item only when extruder_num > 1
|
//BBS render this menu item only when extruder_num > 1
|
||||||
if (extruder_num > 1) {
|
if (extruder_num > 1) {
|
||||||
if (!m_can_change_color || m_draw_mode == dmSequentialFffPrint || m_is_spiral_vase) {
|
if (!m_can_change_color || m_draw_mode == dmSequentialFffPrint) {
|
||||||
begin_menu(_u8L("Change Filament").c_str(), false);
|
begin_menu(_u8L("Change Filament").c_str(), false);
|
||||||
}
|
}
|
||||||
else if (begin_menu(_u8L("Change Filament").c_str())) {
|
else if (begin_menu(_u8L("Change Filament").c_str())) {
|
||||||
|
@ -1178,12 +1230,62 @@ void IMSlider::render_menu()
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
ImGui::PopStyleVar(1);
|
}
|
||||||
|
|
||||||
ImGuiWrapper::pop_menu_style();
|
void IMSlider::render_edit_menu(const TickCode& tick)
|
||||||
|
{
|
||||||
render_input_custom_gcode();
|
if (m_show_menu)
|
||||||
render_go_to_layer_dialog();
|
ImGui::OpenPopup("slider_edit_menu_popup");
|
||||||
|
if (ImGui::BeginPopup("slider_edit_menu_popup")) {
|
||||||
|
switch (tick.type)
|
||||||
|
{
|
||||||
|
case CustomGCode::PausePrint:
|
||||||
|
if (menu_item_with_icon(_u8L("Delete Pause").c_str(), "")) {
|
||||||
|
delete_tick(tick);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CustomGCode::Template:
|
||||||
|
if (!gcode(Template).empty()) {
|
||||||
|
if (menu_item_with_icon(_u8L("Delete Custom Template").c_str(), "")) {
|
||||||
|
delete_tick(tick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CustomGCode::Custom:
|
||||||
|
if (menu_item_with_icon(_u8L("Edit Custom G-code").c_str(), "")) {
|
||||||
|
m_show_custom_gcode_window = true;
|
||||||
|
}
|
||||||
|
if (menu_item_with_icon(_u8L("Delete Custom G-code").c_str(), "")) {
|
||||||
|
delete_tick(tick);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CustomGCode::ToolChange: {
|
||||||
|
int extruder_num = m_extruder_colors.size();
|
||||||
|
if (extruder_num > 1) {
|
||||||
|
if (!m_can_change_color || m_draw_mode == dmSequentialFffPrint) {
|
||||||
|
begin_menu(_u8L("Change Filament").c_str(), false);
|
||||||
|
}
|
||||||
|
else if (begin_menu(_u8L("Change Filament").c_str())) {
|
||||||
|
for (int i = 0; i < extruder_num; i++) {
|
||||||
|
std::array<float, 4> rgba = decode_color_to_float_array(m_extruder_colors[i]);
|
||||||
|
ImU32 icon_clr = IM_COL32(rgba[0] * 255.0f, rgba[1] * 255.0f, rgba[2] * 255.0f, rgba[3] * 255.0f);
|
||||||
|
if (menu_item_with_icon((_u8L("Filament ") + std::to_string(i + 1)).c_str(), "", ImVec2(14, 14) * m_scale, icon_clr)) add_code_as_tick(ToolChange, i + 1);
|
||||||
|
}
|
||||||
|
end_menu();
|
||||||
|
}
|
||||||
|
if (menu_item_with_icon(_u8L("Delete Filament Change").c_str(), "")) {
|
||||||
|
delete_tick(tick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CustomGCode::ColorChange:
|
||||||
|
case CustomGCode::Unknown:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IMSlider::on_change_color_mode(bool is_dark) {
|
void IMSlider::on_change_color_mode(bool is_dark) {
|
||||||
|
@ -1317,16 +1419,8 @@ std::string IMSlider::get_label(int tick, LabelType label_type)
|
||||||
if (label_type == ltHeightWithLayer) {
|
if (label_type == ltHeightWithLayer) {
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
size_t layer_number;
|
size_t layer_number;
|
||||||
if (m_values[GetMinValueD()] == m_zero_layer_height) {
|
layer_number = m_draw_mode == dmSequentialFffPrint ? (m_values.empty() ? value : value + 1) : m_is_wipe_tower ? get_layer_number(value, label_type) + 1 : (m_values.empty() ? value : value + 1);
|
||||||
layer_number = m_is_wipe_tower ? get_layer_number(value, label_type): (m_values.empty() ? value : value);
|
::sprintf(buffer, "%5s\n%5s", std::to_string(layer_number).c_str(), layer_height);
|
||||||
m_values[value] == m_zero_layer_height ?
|
|
||||||
::sprintf(buffer, "%5s\n%5s", _u8L("Start").c_str(), _u8L("G-code").c_str()) :
|
|
||||||
::sprintf(buffer, "%5s\n%5s", std::to_string(layer_number).c_str(), layer_height);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
layer_number = m_is_wipe_tower ? get_layer_number(value, label_type) + 1 : (m_values.empty() ? value : value + 1);
|
|
||||||
::sprintf(buffer, "%5s\n%5s", std::to_string(layer_number).c_str(), layer_height);
|
|
||||||
}
|
|
||||||
return std::string(buffer);
|
return std::string(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,6 @@ enum LabelType
|
||||||
ltEstimatedTime,
|
ltEstimatedTime,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class IMSlider
|
class IMSlider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -134,16 +133,20 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void add_custom_gcode(std::string custom_gcode);
|
void add_custom_gcode(std::string custom_gcode);
|
||||||
void add_code_as_tick(Type type, int selected_extruder = -1);
|
void add_code_as_tick(Type type, int selected_extruder = -1);
|
||||||
void do_go_to_layer(size_t layer_number);
|
void delete_tick(const TickCode& tick);
|
||||||
|
void do_go_to_layer(size_t layer_number); //menu
|
||||||
void correct_lower_value();
|
void correct_lower_value();
|
||||||
void correct_higher_value();
|
void correct_higher_value();
|
||||||
bool horizontal_slider(const char* str_id, int* v, int v_min, int v_max, const ImVec2& size, float scale = 1.0);
|
bool horizontal_slider(const char* str_id, int* v, int v_min, int v_max, const ImVec2& size, float scale = 1.0);
|
||||||
void render_go_to_layer_dialog();
|
void render_go_to_layer_dialog(); //menu
|
||||||
void render_input_custom_gcode();
|
void render_input_custom_gcode(std::string custom_gcode = ""); //menu
|
||||||
void render_menu();
|
void render_menu();
|
||||||
|
void render_add_menu(); //menu
|
||||||
|
void render_edit_menu(const TickCode& tick); //menu
|
||||||
void draw_background_and_groove(const ImRect& bg_rect, const ImRect& groove);
|
void draw_background_and_groove(const ImRect& bg_rect, const ImRect& groove);
|
||||||
void draw_colored_band(const ImRect& groove, const ImRect& slideable_region);
|
void draw_colored_band(const ImRect& groove, const ImRect& slideable_region);
|
||||||
void draw_ticks(const ImRect& slideable_region);
|
void draw_ticks(const ImRect& slideable_region);
|
||||||
|
void show_tooltip(const TickCode& tick); //menu
|
||||||
bool vertical_slider(const char* str_id, int* higher_value, int* lower_value,
|
bool vertical_slider(const char* str_id, int* higher_value, int* lower_value,
|
||||||
std::string& higher_label, std::string& lower_label,
|
std::string& higher_label, std::string& lower_label,
|
||||||
int v_min, int v_max, const ImVec2& size,
|
int v_min, int v_max, const ImVec2& size,
|
||||||
|
@ -176,22 +179,14 @@ private:
|
||||||
bool m_render_as_disabled{ false };
|
bool m_render_as_disabled{ false };
|
||||||
|
|
||||||
SelectedSlider m_selection;
|
SelectedSlider m_selection;
|
||||||
bool m_is_left_down = false;
|
|
||||||
bool m_is_right_down = false;
|
|
||||||
bool m_is_one_layer = false;
|
bool m_is_one_layer = false;
|
||||||
bool m_is_focused = false;
|
bool m_menu_enable = true; //menu
|
||||||
bool m_show_menu = false;
|
bool m_show_menu = false; //menu
|
||||||
bool m_menu_enable = true;
|
bool m_show_custom_gcode_window = false; //menu
|
||||||
bool m_show_custom_gcode_window = false;
|
bool m_show_go_to_layer_dialog = false; //menu
|
||||||
bool m_show_go_to_layer_dialog = false;
|
|
||||||
bool m_force_mode_apply = true;
|
bool m_force_mode_apply = true;
|
||||||
bool m_enable_action_icon = true;
|
|
||||||
bool m_enable_cog_icon = false;
|
|
||||||
bool m_is_wipe_tower = false; // This flag indicates that there is multiple extruder print with wipe tower
|
bool m_is_wipe_tower = false; // This flag indicates that there is multiple extruder print with wipe tower
|
||||||
bool m_is_spiral_vase = false;
|
bool m_is_spiral_vase = false;
|
||||||
bool m_display_lower = true;
|
|
||||||
bool m_display_higher = true;
|
|
||||||
int m_selected_tick_value = -1;
|
|
||||||
|
|
||||||
/* BBS slider images */
|
/* BBS slider images */
|
||||||
void *m_one_layer_on_id;
|
void *m_one_layer_on_id;
|
||||||
|
@ -207,6 +202,7 @@ private:
|
||||||
void* m_one_layer_off_dark_id;
|
void* m_one_layer_off_dark_id;
|
||||||
void* m_one_layer_off_hover_dark_id;
|
void* m_one_layer_off_hover_dark_id;
|
||||||
void *m_pause_icon_id;
|
void *m_pause_icon_id;
|
||||||
|
void *m_custom_icon_id;
|
||||||
void *m_delete_icon_id;
|
void *m_delete_icon_id;
|
||||||
|
|
||||||
DrawMode m_draw_mode = dmRegular;
|
DrawMode m_draw_mode = dmRegular;
|
||||||
|
@ -230,8 +226,8 @@ private:
|
||||||
|
|
||||||
std::vector<double> m_alternate_values;
|
std::vector<double> m_alternate_values;
|
||||||
|
|
||||||
char m_custom_gcode[1024] = { 0 };
|
char m_custom_gcode[1024] = { 0 }; //menu
|
||||||
char m_layer_number[64] = { 0 };
|
char m_layer_number[64] = { 0 }; //menu
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,7 +124,7 @@ const ImVec4 ImGuiWrapper::COL_GREY_DARK = { 0.333f, 0.333f, 0.333f, 1.0
|
||||||
const ImVec4 ImGuiWrapper::COL_GREY_LIGHT = { 0.4f, 0.4f, 0.4f, 1.0f };
|
const ImVec4 ImGuiWrapper::COL_GREY_LIGHT = { 0.4f, 0.4f, 0.4f, 1.0f };
|
||||||
const ImVec4 ImGuiWrapper::COL_ORANGE_DARK = { 0.757f, 0.404f, 0.216f, 1.0f };
|
const ImVec4 ImGuiWrapper::COL_ORANGE_DARK = { 0.757f, 0.404f, 0.216f, 1.0f };
|
||||||
const ImVec4 ImGuiWrapper::COL_ORANGE_LIGHT = { 1.0f, 0.49f, 0.216f, 1.0f };
|
const ImVec4 ImGuiWrapper::COL_ORANGE_LIGHT = { 1.0f, 0.49f, 0.216f, 1.0f };
|
||||||
const ImVec4 ImGuiWrapper::COL_WINDOW_BACKGROUND = { 0.133f, 0.133f, 0.133f, 0.8f };
|
const ImVec4 ImGuiWrapper::COL_WINDOW_BACKGROUND = { 0.1f, 0.1f, 0.1f, 0.8f };
|
||||||
const ImVec4 ImGuiWrapper::COL_BUTTON_BACKGROUND = COL_ORANGE_DARK;
|
const ImVec4 ImGuiWrapper::COL_BUTTON_BACKGROUND = COL_ORANGE_DARK;
|
||||||
const ImVec4 ImGuiWrapper::COL_BUTTON_HOVERED = COL_ORANGE_LIGHT;
|
const ImVec4 ImGuiWrapper::COL_BUTTON_HOVERED = COL_ORANGE_LIGHT;
|
||||||
const ImVec4 ImGuiWrapper::COL_BUTTON_ACTIVE = ImGuiWrapper::COL_BUTTON_HOVERED;
|
const ImVec4 ImGuiWrapper::COL_BUTTON_ACTIVE = ImGuiWrapper::COL_BUTTON_HOVERED;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue