mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-04 11:14:21 +08:00
Add missing changes
CURA-3710
This commit is contained in:
parent
8fe6e82459
commit
54dc63a596
@ -87,6 +87,7 @@ from PyQt5.QtGui import QColor, QIcon
|
|||||||
from PyQt5.QtWidgets import QMessageBox
|
from PyQt5.QtWidgets import QMessageBox
|
||||||
from PyQt5.QtQml import qmlRegisterUncreatableType, qmlRegisterSingletonType, qmlRegisterType
|
from PyQt5.QtQml import qmlRegisterUncreatableType, qmlRegisterSingletonType, qmlRegisterType
|
||||||
|
|
||||||
|
from configparser import ConfigParser
|
||||||
import sys
|
import sys
|
||||||
import os.path
|
import os.path
|
||||||
import numpy
|
import numpy
|
||||||
@ -348,57 +349,19 @@ class CuraApplication(QtApplication):
|
|||||||
|
|
||||||
preferences.setDefault("local_file/last_used_type", "text/x-gcode")
|
preferences.setDefault("local_file/last_used_type", "text/x-gcode")
|
||||||
|
|
||||||
preferences.setDefault("general/visible_settings", """
|
setting_visibily_preset_names = self.getVisibilitySettingsPresetTypes()
|
||||||
machine_settings
|
preferences.setDefault("general/visible_settings_preset", setting_visibily_preset_names)
|
||||||
resolution
|
|
||||||
layer_height
|
visible_settings_preset_choice = Preferences.getInstance().getValue("general/visible_settings_preset_choice")
|
||||||
shell
|
|
||||||
wall_thickness
|
default_visibility_preset = "Basic"
|
||||||
top_bottom_thickness
|
if visible_settings_preset_choice == "" or visible_settings_preset_choice is None:
|
||||||
z_seam_x
|
if not visible_settings_preset_choice in setting_visibily_preset_names:
|
||||||
z_seam_y
|
visible_settings_preset_choice = default_visibility_preset
|
||||||
infill
|
|
||||||
infill_sparse_density
|
visible_settings = self.getVisibilitySettingPreset(settings_preset_name = visible_settings_preset_choice)
|
||||||
gradual_infill_steps
|
preferences.setDefault("general/visible_settings", visible_settings)
|
||||||
material
|
preferences.setDefault("general/visible_settings_preset_choice", visible_settings_preset_choice)
|
||||||
material_print_temperature
|
|
||||||
material_bed_temperature
|
|
||||||
material_diameter
|
|
||||||
material_flow
|
|
||||||
retraction_enable
|
|
||||||
speed
|
|
||||||
speed_print
|
|
||||||
speed_travel
|
|
||||||
acceleration_print
|
|
||||||
acceleration_travel
|
|
||||||
jerk_print
|
|
||||||
jerk_travel
|
|
||||||
travel
|
|
||||||
cooling
|
|
||||||
cool_fan_enabled
|
|
||||||
support
|
|
||||||
support_enable
|
|
||||||
support_extruder_nr
|
|
||||||
support_type
|
|
||||||
platform_adhesion
|
|
||||||
adhesion_type
|
|
||||||
adhesion_extruder_nr
|
|
||||||
brim_width
|
|
||||||
raft_airgap
|
|
||||||
layer_0_z_overlap
|
|
||||||
raft_surface_layers
|
|
||||||
dual
|
|
||||||
prime_tower_enable
|
|
||||||
prime_tower_size
|
|
||||||
prime_tower_position_x
|
|
||||||
prime_tower_position_y
|
|
||||||
meshfix
|
|
||||||
blackmagic
|
|
||||||
print_sequence
|
|
||||||
infill_mesh
|
|
||||||
cutting_mesh
|
|
||||||
experimental
|
|
||||||
""".replace("\n", ";").replace(" ", ""))
|
|
||||||
|
|
||||||
self.applicationShuttingDown.connect(self.saveSettings)
|
self.applicationShuttingDown.connect(self.saveSettings)
|
||||||
self.engineCreatedSignal.connect(self._onEngineCreated)
|
self.engineCreatedSignal.connect(self._onEngineCreated)
|
||||||
@ -410,6 +373,92 @@ class CuraApplication(QtApplication):
|
|||||||
|
|
||||||
self.getCuraSceneController().setActiveBuildPlate(0) # Initialize
|
self.getCuraSceneController().setActiveBuildPlate(0) # Initialize
|
||||||
|
|
||||||
|
@pyqtSlot(str, result=str)
|
||||||
|
def getVisibilitySettingPreset(self, settings_preset_name):
|
||||||
|
|
||||||
|
result = self._load_visibilyty_setting_preset(settings_preset_name)
|
||||||
|
|
||||||
|
formatted_preset_settings = self.format_visibility_setting_preset(result)
|
||||||
|
|
||||||
|
return formatted_preset_settings
|
||||||
|
|
||||||
|
def format_visibility_setting_preset(self, settings_data):
|
||||||
|
|
||||||
|
result_string = ""
|
||||||
|
|
||||||
|
for key in settings_data:
|
||||||
|
result_string += key + ";"
|
||||||
|
|
||||||
|
for value in settings_data[key]:
|
||||||
|
result_string += value + ";"
|
||||||
|
|
||||||
|
return result_string
|
||||||
|
|
||||||
|
|
||||||
|
def _load_visibilyty_setting_preset(self, visibility_preset_name):
|
||||||
|
preset_dir = Resources.getPath(Resources.VisibilitySettingsPreset)
|
||||||
|
|
||||||
|
result = {}
|
||||||
|
right_preset_found = False
|
||||||
|
|
||||||
|
for item in os.listdir(preset_dir):
|
||||||
|
file_path = os.path.join(preset_dir, item)
|
||||||
|
if not os.path.isfile(file_path):
|
||||||
|
continue
|
||||||
|
|
||||||
|
parser = ConfigParser(allow_no_value=True) # accept options without any value,
|
||||||
|
|
||||||
|
try:
|
||||||
|
parser.read([file_path])
|
||||||
|
|
||||||
|
if not parser.has_option("general", "name"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if parser["general"]["name"] == visibility_preset_name:
|
||||||
|
right_preset_found = True
|
||||||
|
for section in parser.sections():
|
||||||
|
if section == 'general':
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
section_settings = []
|
||||||
|
for option in parser[section]._options():
|
||||||
|
section_settings.append(option)
|
||||||
|
|
||||||
|
result[section] = section_settings
|
||||||
|
|
||||||
|
if right_preset_found:
|
||||||
|
break
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
Logger.log("e", "Failed to load setting visibility preset %s: %s", file_path, str(e))
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
def getVisibilitySettingsPresetTypes(self):
|
||||||
|
preset_dir = Resources.getPath(Resources.VisibilitySettingsPreset)
|
||||||
|
result = {}
|
||||||
|
|
||||||
|
for item in os.listdir(preset_dir):
|
||||||
|
file_path = os.path.join(preset_dir, item)
|
||||||
|
if not os.path.isfile(file_path):
|
||||||
|
continue
|
||||||
|
|
||||||
|
parser = ConfigParser(allow_no_value=True) # accept options without any value,
|
||||||
|
|
||||||
|
try:
|
||||||
|
parser.read([file_path])
|
||||||
|
|
||||||
|
if not parser.has_option("general", "name") and not parser.has_option("general", "weight"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
result[parser["general"]["weight"]] = parser["general"]["name"]
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
Logger.log("e", "Failed to load setting preset %s: %s", file_path, str(e))
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def _onEngineCreated(self):
|
def _onEngineCreated(self):
|
||||||
self._engine.addImageProvider("camera", CameraImageProvider.CameraImageProvider())
|
self._engine.addImageProvider("camera", CameraImageProvider.CameraImageProvider())
|
||||||
|
|
||||||
|
@ -420,6 +420,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
Logger.log("w", "Workspace did not contain visible settings. Leaving visibility unchanged")
|
Logger.log("w", "Workspace did not contain visible settings. Leaving visibility unchanged")
|
||||||
else:
|
else:
|
||||||
global_preferences.setValue("general/visible_settings", visible_settings)
|
global_preferences.setValue("general/visible_settings", visible_settings)
|
||||||
|
global_preferences.setValue("general/visible_settings_preset_choice", "Custom")
|
||||||
|
|
||||||
categories_expanded = temp_preferences.getValue("cura/categories_expanded")
|
categories_expanded = temp_preferences.getValue("cura/categories_expanded")
|
||||||
if categories_expanded is None:
|
if categories_expanded is None:
|
||||||
|
@ -24,6 +24,11 @@ UM.PreferencesPage
|
|||||||
function reset()
|
function reset()
|
||||||
{
|
{
|
||||||
UM.Preferences.resetPreference("general/visible_settings")
|
UM.Preferences.resetPreference("general/visible_settings")
|
||||||
|
|
||||||
|
// After calling this function update Setting visibility preset combobox.
|
||||||
|
// Reset should set "Basic" setting preset
|
||||||
|
visibilityPreset.setBasicPreset()
|
||||||
|
|
||||||
}
|
}
|
||||||
resetEnabled: true;
|
resetEnabled: true;
|
||||||
|
|
||||||
@ -72,6 +77,9 @@ UM.PreferencesPage
|
|||||||
{
|
{
|
||||||
definitionsModel.setAllVisible(false)
|
definitionsModel.setAllVisible(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// After change set "Custom" option
|
||||||
|
visibilityPreset.currentIndex = visibilityPreset.model.count - 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,7 +93,8 @@ UM.PreferencesPage
|
|||||||
top: parent.top
|
top: parent.top
|
||||||
left: toggleVisibleSettings.right
|
left: toggleVisibleSettings.right
|
||||||
leftMargin: UM.Theme.getSize("default_margin").width
|
leftMargin: UM.Theme.getSize("default_margin").width
|
||||||
right: parent.right
|
right: visibilityPreset.left
|
||||||
|
rightMargin: UM.Theme.getSize("default_margin").width
|
||||||
}
|
}
|
||||||
|
|
||||||
placeholderText: catalog.i18nc("@label:textbox", "Filter...")
|
placeholderText: catalog.i18nc("@label:textbox", "Filter...")
|
||||||
@ -93,6 +102,88 @@ UM.PreferencesPage
|
|||||||
onTextChanged: definitionsModel.filter = {"i18n_label": "*" + text}
|
onTextChanged: definitionsModel.filter = {"i18n_label": "*" + text}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ComboBox
|
||||||
|
{
|
||||||
|
property int customOptionValue: 100
|
||||||
|
|
||||||
|
function setBasicPreset()
|
||||||
|
{
|
||||||
|
var index = 0
|
||||||
|
for(var i = 0; i < presetNamesList.count; ++i)
|
||||||
|
{
|
||||||
|
if(model.get(i).text == "Basic")
|
||||||
|
{
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
visibilityPreset.currentIndex = index
|
||||||
|
}
|
||||||
|
|
||||||
|
id: visibilityPreset
|
||||||
|
width: 150
|
||||||
|
anchors
|
||||||
|
{
|
||||||
|
top: parent.top
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
|
||||||
|
model: ListModel
|
||||||
|
{
|
||||||
|
id: presetNamesList
|
||||||
|
Component.onCompleted:
|
||||||
|
{
|
||||||
|
// returned value is Dictionary (Ex: {1:"Basic"}, The number 1 is the weight and sort by weight)
|
||||||
|
var itemsDict = UM.Preferences.getValue("general/visible_settings_preset")
|
||||||
|
var sorted = [];
|
||||||
|
for(var key in itemsDict) {
|
||||||
|
sorted[sorted.length] = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
sorted.sort();
|
||||||
|
for(var i = 0; i < sorted.length; i++) {
|
||||||
|
presetNamesList.append({text: itemsDict[sorted[i]], value: i});
|
||||||
|
}
|
||||||
|
|
||||||
|
// By agreement lets "Custom" option will have value 100
|
||||||
|
presetNamesList.append({text: "Custom", value: visibilityPreset.customOptionValue});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
currentIndex:
|
||||||
|
{
|
||||||
|
// Load previously selected preset.
|
||||||
|
var text = UM.Preferences.getValue("general/visible_settings_preset_choice");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var index = 0;
|
||||||
|
for(var i = 0; i < presetNamesList.count; ++i)
|
||||||
|
{
|
||||||
|
if(model.get(i).text == text)
|
||||||
|
{
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
onActivated:
|
||||||
|
{
|
||||||
|
// TODO What to do if user is selected "Custom from Combobox" ?
|
||||||
|
if (model.get(index).text == "Custom")
|
||||||
|
return
|
||||||
|
|
||||||
|
console.log("SETTING VALUE : " + model.get(index).text)
|
||||||
|
|
||||||
|
var newVisibleSettings = CuraApplication.getVisibilitySettingPreset(model.get(index).text)
|
||||||
|
UM.Preferences.setValue("general/visible_settings", newVisibleSettings)
|
||||||
|
UM.Preferences.setValue("general/visible_settings_preset_choice", model.get(index).text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ScrollView
|
ScrollView
|
||||||
{
|
{
|
||||||
id: scrollView
|
id: scrollView
|
||||||
@ -162,7 +253,18 @@ UM.PreferencesPage
|
|||||||
{
|
{
|
||||||
id: settingVisibilityItem;
|
id: settingVisibilityItem;
|
||||||
|
|
||||||
UM.SettingVisibilityItem { }
|
UM.SettingVisibilityItem {
|
||||||
|
|
||||||
|
// after changing any visibility of settings, set the preset to the "Custom" option
|
||||||
|
visibilityChangeCallback : function()
|
||||||
|
{
|
||||||
|
// If already "Custom" then don't do nothing
|
||||||
|
if (visibilityPreset.currentIndex != visibilityPreset.model.count - 1)
|
||||||
|
{
|
||||||
|
visibilityPreset.currentIndex = visibilityPreset.model.count - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user