meaningful gcode names
This commit is contained in:
parent
aab27fa181
commit
a49f2b721f
4 changed files with 43 additions and 10 deletions
|
|
@ -1,8 +1,9 @@
|
|||
function VectorConversionViewModel(loginStateViewModel, settingsViewModel) {
|
||||
function VectorConversionViewModel(loginStateViewModel, settingsViewModel, workingAreaViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.loginState = loginStateViewModel;
|
||||
self.settings = settingsViewModel;
|
||||
self.workingArea = workingAreaViewModel;
|
||||
|
||||
self.target = undefined;
|
||||
self.file = undefined;
|
||||
|
|
@ -39,11 +40,42 @@ function VectorConversionViewModel(loginStateViewModel, settingsViewModel) {
|
|||
self.svg = s.outerSVG();
|
||||
// TODO: js svg conversion
|
||||
self.title(gettext("Converting"));
|
||||
var gcodeFile = "tmp"+Date.now()+".gco"; // TODO: user should not deal with gcode anymore. go and laser it.
|
||||
var gcodeFile = self.create_gcode_filename(self.workingArea.placedDesigns());
|
||||
self.gcodeFilename(gcodeFile);
|
||||
$("#dialog_vector_graphics_conversion").modal("show");
|
||||
};
|
||||
|
||||
self.create_gcode_filename = function(placedDesigns){
|
||||
if(placedDesigns.length > 0){
|
||||
var filemap = {};
|
||||
for(var idx in placedDesigns){
|
||||
var design = placedDesigns[idx];
|
||||
var start = design.url.lastIndexOf('/')+1;
|
||||
var end = design.url.lastIndexOf('.');
|
||||
var name = design.url.substring(start, end);
|
||||
if(filemap[name] !== undefined) filemap[name] += 1;
|
||||
else filemap[name] = 1;
|
||||
}
|
||||
var mostPlaced;
|
||||
var placed = 0;
|
||||
for(var name in filemap){
|
||||
if(filemap[name] > placed){
|
||||
mostPlaced = name;
|
||||
placed = filemap[name];
|
||||
}
|
||||
}
|
||||
var uniqueDesigns = Object.keys(filemap).length;
|
||||
var gcode_name = mostPlaced;
|
||||
if(placed > 1) gcode_name += "." + placed + "x";
|
||||
if(uniqueDesigns > 1){
|
||||
gcode_name += "_"+(uniqueDesigns-1)+"more";
|
||||
}
|
||||
return gcode_name + ".gco";
|
||||
} else {
|
||||
return "tmp"+Date.now()+".gco"; // TODO: user should not deal with gcode anymore. go and laser it.
|
||||
}
|
||||
};
|
||||
|
||||
self.slicer.subscribe(function(newValue) {
|
||||
self.profilesForSlicer(newValue);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
function WorkingAreaViewModel(loginStateViewModel, settingsViewModel, printerStateViewModel) {
|
||||
function WorkingAreaViewModel(loginStateViewModel, settingsViewModel) {
|
||||
var self = this;
|
||||
|
||||
self.loginState = loginStateViewModel;
|
||||
self.settings = settingsViewModel;
|
||||
self.state = printerStateViewModel;
|
||||
self.state = undefined;
|
||||
|
||||
self.log = [];
|
||||
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ var UI_API_KEY = "{{ uiApiKey }}";
|
|||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableRemove($data)) { $root.removeFile($data); } else { return; } }, css: {disabled: !$root.enableRemove($data)}"><i class="icon-trash" title="{{ _('Remove') }}"></i></div>
|
||||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, false); } else { return; } }, css: {disabled: !$root.enableSelect($data)}"><i class="icon-folder-open" title="{{ _('Load') }}"></i></div>
|
||||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableSelect($data)) { $root.loadFile($data, true); } else { return; } }, css: {disabled: !$root.enableSelect($data)}"><i class="icon-fire" title="{{ _('Load and Laser') }}"></i></div>
|
||||
<div class="btn btn-mini" data-bind="click: function() { $root.showFile($data); }"><i class="icon-arrow-right" title="{{ _('Preview') }}"></i></div>
|
||||
<!--<div class="btn btn-mini" data-bind="click: function() { $root.showFile($data); }"><i class="icon-arrow-right" title="{{ _('Preview') }}"></i></div>-->
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
|
@ -307,7 +307,7 @@ var UI_API_KEY = "{{ uiApiKey }}";
|
|||
<div class="size">{{ _('Size') }}: <span data-bind="text: formatSize(size)"></span></div>
|
||||
<div class="btn-group action-buttons">
|
||||
<div class="btn btn-mini" data-bind="click: function() { if ($root.enableRemove($data)) { $root.removeFile($data); } else { return; } }, css: {disabled: !$root.enableRemove($data)}"><i class="icon-trash" title="{{ _('Remove') }}"></i></div>
|
||||
<div class="btn btn-mini" data-bind="click: function() { $root.convertSVG($data); }, css: {disabled: !$root.enableSVGConversion($data)}"><i class="icon-play" title="{{ _('Convert to Laserpath') }}"></i></div>
|
||||
<!--<div class="btn btn-mini" data-bind="click: function() { $root.convertSVG($data); }, css: {disabled: !$root.enableSVGConversion($data)}"><i class="icon-play" title="{{ _('Convert to Laserpath') }}"></i></div>-->
|
||||
<div class="btn btn-mini" data-bind="click: function() { $root.placeSVG($data); }, css: {disabled: !$root.enableSVGConversion($data)}"><i class="icon-arrow-right" title="{{ _('Use') }}"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -62,15 +62,16 @@ $(function() {
|
|||
var settingsViewModel = new SettingsViewModel(loginStateViewModel, usersViewModel);
|
||||
var connectionViewModel = new ConnectionViewModel(loginStateViewModel, settingsViewModel);
|
||||
var timelapseViewModel = new TimelapseViewModel(loginStateViewModel);
|
||||
var vectorConversionViewModel = new VectorConversionViewModel(loginStateViewModel, settingsViewModel);
|
||||
var printerStateViewModel = new PrinterStateViewModel(loginStateViewModel, vectorConversionViewModel);
|
||||
var appearanceViewModel = new AppearanceViewModel(settingsViewModel);
|
||||
var temperatureViewModel = new TemperatureViewModel(loginStateViewModel, settingsViewModel);
|
||||
var controlViewModel = new ControlViewModel(loginStateViewModel, settingsViewModel, printerStateViewModel);
|
||||
var terminalViewModel = new TerminalViewModel(loginStateViewModel, settingsViewModel);
|
||||
var slicingViewModel = new SlicingViewModel(loginStateViewModel);
|
||||
var workingAreaViewModel = new WorkingAreaViewModel(loginStateViewModel, settingsViewModel, printerStateViewModel);
|
||||
var workingAreaViewModel = new WorkingAreaViewModel(loginStateViewModel, settingsViewModel);
|
||||
var vectorConversionViewModel = new VectorConversionViewModel(loginStateViewModel, settingsViewModel, workingAreaViewModel);
|
||||
var printerStateViewModel = new PrinterStateViewModel(loginStateViewModel, vectorConversionViewModel);
|
||||
workingAreaViewModel.state = printerStateViewModel; // resolving circular dependency ugly
|
||||
var gcodeFilesViewModel = new GcodeFilesViewModel(printerStateViewModel, loginStateViewModel, slicingViewModel, vectorConversionViewModel, workingAreaViewModel);
|
||||
var controlViewModel = new ControlViewModel(loginStateViewModel, settingsViewModel, printerStateViewModel);
|
||||
var gcodeViewModel = new GcodeViewModel(loginStateViewModel, settingsViewModel);
|
||||
var navigationViewModel = new NavigationViewModel(loginStateViewModel, appearanceViewModel, settingsViewModel, usersViewModel);
|
||||
var logViewModel = new LogViewModel(loginStateViewModel);
|
||||
|
|
|
|||
Loading…
Reference in a new issue