Browse Source

Fixed legacy profile reader

Updated some settings that were changed from 2.1 to 2.2. Also fixed some
architecture changes that were not changed correctly (or at all)

CURA-1493 and CURA-1779
Jaime van Kessel 8 years ago
parent
commit
e3d4a33954

+ 1 - 0
cura/Settings/CuraContainerRegistry.py

@@ -170,6 +170,7 @@ class CuraContainerRegistry(ContainerRegistry):
                 profile.addMetaDataEntry("material", self._activeMaterialId())
         else:
             profile.setDefinition(ContainerRegistry.getInstance().findDefinitionContainers(id="fdmprinter")[0])
+
         ContainerRegistry.getInstance().addContainer(profile)
 
     ##  Gets a list of profile writer plugins

+ 4 - 4
plugins/LegacyProfileReader/DictionaryOfDoom.json

@@ -1,6 +1,6 @@
 {
     "source_version": "15.04",
-    "target_version": 1,
+    "target_version": 2,
 
     "translation": {
         "machine_nozzle_size": "nozzle_size",
@@ -21,7 +21,7 @@
         "retraction_amount": "retraction_amount",
         "retraction_speed": "retraction_speed",
         "retraction_min_travel": "retraction_min_travel",
-        "retraction_hop": "retraction_hop",
+        "retraction_hop_enabled": "retraction_hop != 0",
         "speed_print": "print_speed",
         "speed_infill": "infill_speed if (float(infill_speed) != 0) else print_speed",
         "speed_wall_0": "inset0_speed if (float(inset0_speed) != 0) else print_speed",
@@ -29,7 +29,7 @@
         "speed_topbottom": "solidarea_speed if (float(solidarea_speed) != 0) else print_speed",
         "speed_travel": "travel_speed if (float(travel_speed) != 0) else travel_speed",
         "speed_layer_0": "bottom_layer_speed",
-        "retraction_combing": "True if (retraction_combing == \"All\" or retraction_combing == \"No Skin\") else False",
+        "retraction_combing": "\"all\" if retraction_combing == \"All\" else \"noskin\" if retraction_combing == \"No Skin\" else \"off\"",
         "cool_fan_enabled": "fan_enabled",
         "cool_fan_speed_min": "fan_speed",
         "cool_fan_speed_max": "fan_speed_max",
@@ -66,7 +66,7 @@
         "meshfix_union_all_remove_holes": "fix_horrible_union_all_type_b",
         "meshfix_extensive_stitching": "fix_horrible_extensive_stitching",
         "meshfix_keep_open_polygons": "fix_horrible_use_open_bits",
-        "magic_mesh_surface_mode": "simple_mode",
+        "magic_mesh_surface_mode": "\"surface\" if simple_mode else \"normal\"",
         "magic_spiralize": "spiralize",
         "prime_tower_enable": "wipe_tower",
         "prime_tower_size": "math.sqrt(float(wipe_tower_volume) / float(layer_height))",

+ 8 - 4
plugins/LegacyProfileReader/LegacyProfileReader.py

@@ -111,7 +111,8 @@ class LegacyProfileReader(ProfileReader):
         if "translation" not in dict_of_doom:
             Logger.log("e", "Dictionary of Doom has no translation. Is it the correct JSON file?")
             return None
-        current_printer = Application.getInstance().getGlobalContainerStack().findContainer({ }, DefinitionContainer)
+        current_printer_definition = Application.getInstance().getGlobalContainerStack().getBottom()
+        profile.setDefinition(current_printer_definition)
         for new_setting in dict_of_doom["translation"]: #Evaluate all new settings that would get a value from the translations.
             old_setting_expression = dict_of_doom["translation"][new_setting]
             compiled = compile(old_setting_expression, new_setting, "eval")
@@ -121,10 +122,13 @@ class LegacyProfileReader(ProfileReader):
             except Exception: #Probably some setting name that was missing or something else that went wrong in the ini file.
                 Logger.log("w", "Setting " + new_setting + " could not be set because the evaluation failed. Something is probably missing from the imported legacy profile.")
                 continue
-            if new_value != value_using_defaults and current_printer.findDefinitions(key = new_setting).default_value != new_value: #Not equal to the default in the new Cura OR the default in the legacy Cura.
-                profile.setSettingValue(new_setting, new_value) #Store the setting in the profile!
+            definitions = current_printer_definition.findDefinitions(key = new_setting)
+            if definitions:
+                if new_value != value_using_defaults and definitions[0].default_value != new_value:  # Not equal to the default in the new Cura OR the default in the legacy Cura.
+                    profile.setProperty(new_setting, "value", new_value)  # Store the setting in the profile!
 
-        if len(profile.getChangedSettings()) == 0:
+        if len(profile.getAllKeys()) == 0:
             Logger.log("i", "A legacy profile was imported but everything evaluates to the defaults, creating an empty profile.")
         profile.setDirty(True)
+        profile.addMetaDataEntry("type", "quality")
         return profile