Skip to content

Commit 6db5d6e

Browse files
committed
0.0.5 (#21)
* modifications to allow both UltimakerFormatPackage and this plugin to play nice together * Updated configuration section of readme about the need to restart PrusaSlicer once the ini file has been updated * add state panel thumbnail for selected file if available
1 parent 1d85d21 commit 6db5d6e

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ Since PrusaSlicer only enables thumbnails by default for the Prusa Mini you may
2626

2727
**Note:** If you don't see your printer's ini file in the printers sub-folder; you are probably using one of the bundled Prusa Printer profiles (ie MK3S). If so you may need to create a copy of this printer profile to be able to have an ini file to edit. To do this in PrusaSlicer go to the Printer Settings tab and Click the save button next to the printer list and give it a new name. Alternatively, push Prusa Research to update their bundled profiles to match the Mini by commenting in the issue posted on their repository [here](https://github.com/prusa3d/PrusaSlicer/issues/3488).
2828

29-
Open your desired printer profile in your favorite text editor and find the `thumbnails =` section and add the resolution that you would like to include in your sliced files, and therefore visible by this plugin. For example `thumbnails = 16x16,220x124` will be the equivalent of the Prusa Mini as described above.
29+
Open your desired printer profile in your favorite text editor and find the `thumbnails =` section and add the resolution that you would like to include in your sliced files, and therefore visible by this plugin. For example `thumbnails = 16x16,220x124` will be the equivalent of the Prusa Mini as described above.
30+
31+
**Note:** Once you've made your changes you will need to restart PrusaSlicer in order for the changes to be used and embed the thumbnails in the exported gcode files.
3032

3133
**Warning**: the higher the resolution of the thumbnail you enter in this setting the larger your gcode file will be when sliced.
3234

octoprint_prusaslicerthumbnails/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def get_settings_defaults(self):
3030
scale_inline_thumbnail=False,
3131
inline_thumbnail_scale_value="50",
3232
align_inline_thumbnail=False,
33-
inline_thumbnail_align_value="left"
33+
inline_thumbnail_align_value="left",
34+
state_panel_thumbnail=True
3435
)
3536

3637
##~~ AssetPlugin mixin
@@ -78,6 +79,7 @@ def on_event(self, event, payload):
7879
if os.path.exists(thumbnail_filename):
7980
thumbnail_url = "plugin/prusaslicerthumbnails/thumbnail/" + payload["path"].replace(".gcode", ".png") + "?" + "{:%Y%m%d%H%M%S}".format(datetime.datetime.now())
8081
self._file_manager.set_additional_metadata("local", payload["path"], "thumbnail", thumbnail_url, overwrite=True)
82+
self._file_manager.set_additional_metadata("local", payload["path"], "thumbnail_src", self._identifier, overwrite=True)
8183

8284
##~~ Routes hook
8385
def route_hook(self, server_routes, *args, **kwargs):

octoprint_prusaslicerthumbnails/static/js/prusaslicerthumbnails.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ $(function() {
1010

1111
self.settingsViewModel = parameters[0];
1212
self.filesViewModel = parameters[1];
13+
self.printerStateViewModel = parameters[2];
1314

1415
self.thumbnail_url = ko.observable('/static/img/tentacle-20x20.png');
1516
self.thumbnail_title = ko.observable('');
@@ -26,11 +27,6 @@ $(function() {
2627
}
2728
}
2829

29-
/* self.filesViewModel.inline_thumbnail_url = function(data) {
30-
// return '/plugin/prusaslicerthumbnails/thumbnail/' + data.path.replace('.gcode','.png');
31-
return data.thumbnail;
32-
} */
33-
3430
self.DEFAULT_THUMBNAIL_SCALE = "100%"
3531
self.filesViewModel.thumbnailScaleValue = ko.observable(self.DEFAULT_THUMBNAIL_SCALE)
3632

@@ -71,18 +67,25 @@ $(function() {
7167
self.settingsViewModel.settings.plugins.prusaslicerthumbnails.inline_thumbnail_align_value.subscribe(function(newValue){
7268
self.filesViewModel.thumbnailAlignValue(newValue);
7369
});
70+
71+
self.filesViewModel.listHelper.selectedItem.subscribe(function(data){
72+
// remove the state panel thumbnail in case it's already there
73+
$('#prusalicer_state_thumbnail').remove();
74+
if(self.settingsViewModel.settings.plugins.prusaslicerthumbnails.state_panel_thumbnail() && data.thumbnail && data.thumbnail_src == 'prusaslicerthumbnails'){
75+
$('#state > div > hr:nth-child(4)').after('<div id="prusalicer_state_thumbnail" class="row-fluid"><img src="'+data.thumbnail+'" width="100%"/>\n<hr/></div>');
76+
}
77+
});
7478
}
7579

7680

7781
$(document).ready(function(){
7882
let regex = /<div class="btn-group action-buttons">([\s\S]*)<.div>/mi;
79-
let template = '<div class="btn btn-mini" data-bind="click: function() { if ($root.loginState.isUser()) { $root.open_thumbnail($data) } else { return; } }, visible: ($data.thumbnail && $root.settingsViewModel.settings.plugins.prusaslicerthumbnails.inline_thumbnail() == false)" title="Show Thumbnail" style="display: none;"><i class="fa fa-image"></i></div>';
83+
let template = '<div class="btn btn-mini" data-bind="click: function() { if ($root.loginState.isUser()) { $root.open_thumbnail($data) } else { return; } }, visible: ($data.thumbnail_src == \'prusaslicerthumbnails\' && $root.settingsViewModel.settings.plugins.prusaslicerthumbnails.inline_thumbnail() == false)" title="Show Thumbnail" style="display: none;"><i class="fa fa-image"></i></div>';
8084
let inline_thumbnail_template = '<div class="row-fluid inline_prusa_thumbnail" ' +
81-
'data-bind="if: ($data.thumbnail && $root.settingsViewModel.settings.plugins.prusaslicerthumbnails.inline_thumbnail() == true), style: {\'text-align\': $root.thumbnailAlignValue}">' +
85+
'data-bind="if: ($data.thumbnail_src == \'prusaslicerthumbnails\' && $root.settingsViewModel.settings.plugins.prusaslicerthumbnails.inline_thumbnail() == true), style: {\'text-align\': $root.thumbnailAlignValue}">' +
8286
'<img data-bind="attr: {src: $data.thumbnail, width: $root.thumbnailScaleValue}, ' +
83-
'visible: ($data.thumbnail.length > 0 && $root.settingsViewModel.settings.plugins.prusaslicerthumbnails.inline_thumbnail() == true), ' +
87+
'visible: ($data.thumbnail_src == \'prusaslicerthumbnails\' && $root.settingsViewModel.settings.plugins.prusaslicerthumbnails.inline_thumbnail() == true), ' +
8488
'click: function() { if ($root.loginState.isUser()) { $root.open_thumbnail($data) } else { return; } }" ' +
85-
// 'width="100%" ' +
8689
'style="display: none;"/></div>'
8790

8891
$("#files_template_machinecode").text(function () {
@@ -95,7 +98,7 @@ $(function() {
9598

9699
OCTOPRINT_VIEWMODELS.push({
97100
construct: PrusaslicerthumbnailsViewModel,
98-
dependencies: ['settingsViewModel', 'filesViewModel'],
101+
dependencies: ['settingsViewModel', 'filesViewModel', 'printerStateViewModel'],
99102
elements: ['div#prusa_thumbnail_viewer']
100103
});
101104
});

octoprint_prusaslicerthumbnails/templates/prusaslicerthumbnails_settings.jinja2

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<h3>{{ _('PrusaSlicer Thumbnails') }}</h3>
22
<div class="control-group">
3+
<div class="controls">
4+
<label class="checkbox">
5+
<input type="checkbox" data-bind="checked: settings.plugins.prusaslicerthumbnails.state_panel_thumbnail"> Show thumbnail in state panel.
6+
</label>
7+
</div>
38
<div class="controls">
49
<label class="checkbox">
510
<input type="checkbox" data-bind="checked: settings.plugins.prusaslicerthumbnails.inline_thumbnail"> Use inline thumbnails.

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
plugin_name = "PrusaSlicer Thumbnails"
1515

1616
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
17-
plugin_version = "0.0.4"
17+
plugin_version = "0.0.5"
1818

1919
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
2020
# module

0 commit comments

Comments
 (0)