2012-02-19 23:30:49 +00:00
"""
Settings is a collection of utilities to display , read & write the settings and position widgets .
"""
from __future__ import absolute_import
2012-04-10 14:45:53 +00:00
from __future__ import division
2012-02-19 23:30:49 +00:00
#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
import __init__
2012-02-21 14:27:03 +00:00
import os , sys
2012-02-24 18:25:55 +00:00
import types , math
2012-02-19 23:30:49 +00:00
2012-03-28 12:26:40 +00:00
from util import profile
2012-02-21 22:05:30 +00:00
from fabmetheus_utilities import archive
2012-02-27 13:51:52 +00:00
def DEFSET ( setting ) :
2012-02-23 21:47:42 +00:00
return setting . value
def storedSetting ( name ) :
2012-03-17 11:03:38 +00:00
return lambda setting : profile . getProfileSetting ( name )
2012-04-10 14:45:53 +00:00
def storedSettingFloat ( name ) :
return lambda setting : profile . getProfileSettingFloat ( name )
def storedSettingInt ( name ) :
return lambda setting : int ( profile . getProfileSettingFloat ( name ) )
2012-03-20 15:09:25 +00:00
def storedPreference ( name ) :
return lambda setting : profile . getPreference ( name )
2012-09-12 15:02:42 +00:00
def storedPreferenceFloat ( name ) :
return lambda setting : profile . getPreferenceFloat ( name )
2012-06-21 16:44:30 +00:00
def storedSettingInvertBoolean ( name ) :
return lambda setting : profile . getProfileSetting ( name ) == " False "
2012-02-23 21:47:42 +00:00
2012-02-26 13:30:34 +00:00
def ifSettingAboveZero ( name ) :
2012-04-10 14:45:53 +00:00
return lambda setting : profile . getProfileSettingFloat ( name ) > 0
2012-02-26 13:30:34 +00:00
2012-03-17 11:03:38 +00:00
def ifSettingIs ( name , value ) :
return lambda setting : profile . getProfileSetting ( name ) == value
2012-02-27 15:40:33 +00:00
2012-03-18 22:00:33 +00:00
def raftLayerCount ( setting ) :
if profile . getProfileSetting ( ' enable_raft ' ) == " True " :
return ' 1 '
return ' 0 '
2012-02-24 16:07:03 +00:00
def storedPercentSetting ( name ) :
2012-04-10 14:45:53 +00:00
return lambda setting : profile . getProfileSettingFloat ( name ) / 100
2012-02-24 16:07:03 +00:00
2012-02-24 18:19:00 +00:00
def calculateEdgeWidth ( setting ) :
2012-03-26 13:03:26 +00:00
return profile . calculateEdgeWidth ( )
2012-02-24 18:19:00 +00:00
def calculateShells ( setting ) :
2012-03-26 13:03:26 +00:00
return profile . calculateLineCount ( ) - 1
2012-02-27 15:40:33 +00:00
def calculateShellsBase ( setting ) :
2012-03-26 13:03:26 +00:00
edgeWidth = profile . calculateEdgeWidth ( )
2012-04-10 14:45:53 +00:00
extraWall = profile . getProfileSettingFloat ( ' extra_base_wall_thickness ' )
2012-02-24 18:19:00 +00:00
2012-03-26 13:03:26 +00:00
return profile . calculateLineCount ( ) - 1 + int ( extraWall / edgeWidth + 0.0001 )
2012-02-24 18:19:00 +00:00
def calculateSolidLayerCount ( setting ) :
2012-03-26 13:03:26 +00:00
return profile . calculateSolidLayerCount ( )
2012-02-24 18:19:00 +00:00
2012-02-27 13:51:52 +00:00
def firstLayerSpeedRatio ( setting ) :
2012-04-10 14:45:53 +00:00
bottomSpeed = profile . getProfileSettingFloat ( ' bottom_layer_speed ' )
speed = profile . getProfileSettingFloat ( ' print_speed ' )
2012-02-27 13:51:52 +00:00
return bottomSpeed / speed
2012-03-16 10:51:44 +00:00
def calcSupportDistanceRatio ( setting ) :
edgeWidth = calculateEdgeWidth ( setting )
2012-04-10 14:45:53 +00:00
distance = profile . getProfileSettingFloat ( ' support_distance ' )
2012-03-16 10:51:44 +00:00
return distance / edgeWidth
2012-03-21 12:20:30 +00:00
def calculateMultiplyDistance ( setting ) :
edgeWidth = calculateEdgeWidth ( setting )
return 10.0 / edgeWidth
2012-04-05 14:50:59 +00:00
def calcBottomLayerFlowRateRatio ( setting ) :
2012-04-10 14:45:53 +00:00
bottomThickness = profile . getProfileSettingFloat ( ' bottom_thickness ' )
layerThickness = profile . getProfileSettingFloat ( ' layer_height ' )
2012-04-05 14:50:59 +00:00
if bottomThickness < layerThickness :
return 1.0
return bottomThickness / layerThickness
def calcExtraBottomThickness ( setting ) :
2012-04-10 14:45:53 +00:00
bottomThickness = profile . getProfileSettingFloat ( ' bottom_thickness ' )
layerThickness = profile . getProfileSettingFloat ( ' layer_height ' )
2012-04-05 14:50:59 +00:00
if bottomThickness < layerThickness :
return 0.0
return bottomThickness - layerThickness
def calcLayerSkip ( setting ) :
2012-04-10 14:45:53 +00:00
bottomThickness = profile . getProfileSettingFloat ( ' bottom_thickness ' )
layerThickness = profile . getProfileSettingFloat ( ' layer_height ' )
2012-04-05 14:50:59 +00:00
if bottomThickness < layerThickness :
return 0
return int ( math . ceil ( ( bottomThickness - layerThickness ) / layerThickness + 0.0001 ) - 1 )
2012-03-24 09:51:52 +00:00
def getProfileInformation ( ) :
2012-02-20 17:55:54 +00:00
return {
' carve ' : {
2012-02-27 13:51:52 +00:00
' Add_Layer_Template_to_SVG ' : DEFSET ,
2012-02-24 18:19:00 +00:00
' Edge_Width_mm ' : calculateEdgeWidth ,
2012-02-27 13:51:52 +00:00
' Extra_Decimal_Places_float ' : DEFSET ,
' Import_Coarseness_ratio ' : DEFSET ,
2012-04-10 14:45:53 +00:00
' Layer_Height_mm ' : storedSettingFloat ( " layer_height " ) ,
2012-04-05 14:50:59 +00:00
' Layers_From_index ' : calcLayerSkip ,
2012-02-27 13:51:52 +00:00
' Layers_To_index ' : DEFSET ,
' Correct_Mesh ' : DEFSET ,
' Unproven_Mesh ' : DEFSET ,
' SVG_Viewer ' : DEFSET ,
2012-03-07 15:58:04 +00:00
' FlipX ' : storedSetting ( " flip_x " ) ,
' FlipY ' : storedSetting ( " flip_y " ) ,
' FlipZ ' : storedSetting ( " flip_z " ) ,
2012-04-05 20:35:52 +00:00
' SwapXZ ' : storedSetting ( " swap_xz " ) ,
' SwapYZ ' : storedSetting ( " swap_yz " ) ,
2012-04-10 14:45:53 +00:00
' Scale ' : storedSettingFloat ( " model_scale " ) ,
' Rotate ' : storedSettingFloat ( " model_rotate_base " ) ,
2012-04-29 12:22:20 +00:00
' CenterX ' : storedSettingFloat ( " machine_center_x " ) ,
' CenterY ' : storedSettingFloat ( " machine_center_y " ) ,
' AlternativeCenterFile ' : storedSetting ( " alternative_center " ) ,
2012-02-20 17:55:54 +00:00
} , ' scale ' : {
2012-02-24 18:19:00 +00:00
' Activate_Scale ' : " False " ,
2012-02-27 13:51:52 +00:00
' XY_Plane_Scale_ratio ' : DEFSET ,
' Z_Axis_Scale_ratio ' : DEFSET ,
' SVG_Viewer ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' bottom ' : {
2012-02-27 13:51:52 +00:00
' Activate_Bottom ' : DEFSET ,
' Additional_Height_over_Layer_Thickness_ratio ' : DEFSET ,
2012-04-05 14:50:59 +00:00
' Altitude_mm ' : calcExtraBottomThickness ,
2012-02-27 13:51:52 +00:00
' SVG_Viewer ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' preface ' : {
2012-02-27 13:51:52 +00:00
' Meta ' : DEFSET ,
2012-04-25 11:34:25 +00:00
' Set_Positioning_to_Absolute ' : " False " ,
' Set_Units_to_Millimeters ' : " False " ,
2012-02-27 13:51:52 +00:00
' Start_at_Home ' : DEFSET ,
' Turn_Extruder_Off_at_Shut_Down ' : DEFSET ,
' Turn_Extruder_Off_at_Start_Up ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' widen ' : {
2012-02-27 13:51:52 +00:00
' Activate_Widen ' : DEFSET ,
2012-03-22 12:46:55 +00:00
' Widen_Width_over_Edge_Width_ratio ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' inset ' : {
2012-03-30 07:50:13 +00:00
' Add_Custom_Code_for_Temperature_Reading ' : " False " ,
2012-05-07 16:12:26 +00:00
' Infill_in_Direction_of_Bridge ' : ifSettingAboveZero ( ' fill_density ' ) ,
2012-04-10 14:45:53 +00:00
' Infill_Width ' : storedSettingFloat ( " nozzle_size " ) ,
2012-02-27 13:51:52 +00:00
' Loop_Order_Choice ' : DEFSET ,
' Overlap_Removal_Width_over_Perimeter_Width_ratio ' : DEFSET ,
2012-04-17 17:12:40 +00:00
' Turn_Extruder_Heater_Off_at_Shut_Down ' : " False " ,
2012-02-27 13:51:52 +00:00
' Volume_Fraction_ratio ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' fill ' : {
2012-02-26 13:30:34 +00:00
' Activate_Fill ' : " True " ,
2012-02-27 15:40:33 +00:00
' Solid_Surface_Top ' : storedSetting ( " solid_top " ) ,
' Override_First_Layer_Sequence ' : storedSetting ( " force_first_layer_sequence " ) ,
2012-02-27 13:51:52 +00:00
' Diaphragm_Period_layers ' : DEFSET ,
' Diaphragm_Thickness_layers ' : DEFSET ,
2012-02-24 18:19:00 +00:00
' Extra_Shells_on_Alternating_Solid_Layer_layers ' : calculateShells ,
2012-02-27 15:40:33 +00:00
' Extra_Shells_on_Base_layers ' : calculateShellsBase ,
2012-02-24 18:19:00 +00:00
' Extra_Shells_on_Sparse_Layer_layers ' : calculateShells ,
2012-02-27 13:51:52 +00:00
' Grid_Circle_Separation_over_Perimeter_Width_ratio ' : DEFSET ,
' Grid_Extra_Overlap_ratio ' : DEFSET ,
' Grid_Junction_Separation_Band_Height_layers ' : DEFSET ,
' Grid_Junction_Separation_over_Octogon_Radius_At_End_ratio ' : DEFSET ,
' Grid_Junction_Separation_over_Octogon_Radius_At_Middle_ratio ' : DEFSET ,
' Infill_Begin_Rotation_degrees ' : DEFSET ,
' Infill_Begin_Rotation_Repeat_layers ' : DEFSET ,
' Infill_Odd_Layer_Extra_Rotation_degrees ' : DEFSET ,
2012-03-17 11:03:38 +00:00
' Grid_Circular ' : ifSettingIs ( ' infill_type ' , ' Grid Circular ' ) ,
' Grid_Hexagonal ' : ifSettingIs ( ' infill_type ' , ' Grid Hexagonal ' ) ,
' Grid_Rectangular ' : ifSettingIs ( ' infill_type ' , ' Grid Rectangular ' ) ,
' Line ' : ifSettingIs ( ' infill_type ' , ' Line ' ) ,
2012-03-14 15:01:06 +00:00
' Infill_Perimeter_Overlap_ratio ' : storedPercentSetting ( ' fill_overlap ' ) ,
2012-02-24 16:07:03 +00:00
' Infill_Solidity_ratio ' : storedPercentSetting ( ' fill_density ' ) ,
2012-04-10 14:45:53 +00:00
' Infill_Width ' : storedSettingFloat ( " nozzle_size " ) ,
2012-03-22 12:46:55 +00:00
' Sharpest_Angle_degrees ' : DEFSET ,
2012-02-24 18:19:00 +00:00
' Solid_Surface_Thickness_layers ' : calculateSolidLayerCount ,
2012-02-27 13:51:52 +00:00
' Start_From_Choice ' : DEFSET ,
' Surrounding_Angle_degrees ' : DEFSET ,
2012-02-27 16:21:50 +00:00
' Thread_Sequence_Choice ' : storedSetting ( ' sequence ' ) ,
2012-02-20 17:55:54 +00:00
} , ' multiply ' : {
2012-04-29 12:22:20 +00:00
' Activate_Multiply ' : " False " ,
2012-04-10 14:45:53 +00:00
' Center_X_mm ' : storedSettingFloat ( " machine_center_x " ) ,
' Center_Y_mm ' : storedSettingFloat ( " machine_center_y " ) ,
2012-03-16 12:27:04 +00:00
' Number_of_Columns_integer ' : storedSetting ( ' model_multiply_x ' ) ,
' Number_of_Rows_integer ' : storedSetting ( ' model_multiply_y ' ) ,
2012-02-27 13:51:52 +00:00
' Reverse_Sequence_every_Odd_Layer ' : DEFSET ,
2012-03-21 12:20:30 +00:00
' Separation_over_Perimeter_Width_ratio ' : calculateMultiplyDistance ,
2012-02-20 17:55:54 +00:00
} , ' speed ' : {
2012-02-23 21:47:42 +00:00
' Activate_Speed ' : " True " ,
' Add_Flow_Rate ' : " True " ,
2012-03-20 10:01:47 +00:00
' Bridge_Feed_Rate_Multiplier_ratio ' : storedPercentSetting ( ' bridge_speed ' ) ,
2012-06-03 06:54:32 +00:00
' Bridge_Flow_Rate_Multiplier_ratio ' : storedPercentSetting ( ' bridge_speed ' ) ,
2012-02-27 13:51:52 +00:00
' Duty_Cyle_at_Beginning_portion ' : DEFSET ,
' Duty_Cyle_at_Ending_portion ' : DEFSET ,
2012-04-10 14:45:53 +00:00
' Feed_Rate_mm/s ' : storedSettingFloat ( " print_speed " ) ,
' Flow_Rate_Setting_float ' : storedSettingFloat ( " print_speed " ) ,
2012-02-27 13:51:52 +00:00
' Object_First_Layer_Feed_Rate_Infill_Multiplier_ratio ' : firstLayerSpeedRatio ,
' Object_First_Layer_Feed_Rate_Perimeter_Multiplier_ratio ' : firstLayerSpeedRatio ,
' Object_First_Layer_Feed_Rate_Travel_Multiplier_ratio ' : firstLayerSpeedRatio ,
' Object_First_Layer_Flow_Rate_Infill_Multiplier_ratio ' : firstLayerSpeedRatio ,
' Object_First_Layer_Flow_Rate_Perimeter_Multiplier_ratio ' : firstLayerSpeedRatio ,
' Object_First_Layers_Amount_Of_Layers_For_Speed_Change ' : DEFSET ,
' Orbital_Feed_Rate_over_Operating_Feed_Rate_ratio ' : DEFSET ,
' Maximum_Z_Feed_Rate_mm/s ' : DEFSET ,
' Perimeter_Feed_Rate_Multiplier_ratio ' : DEFSET ,
' Perimeter_Flow_Rate_Multiplier_ratio ' : DEFSET ,
2012-04-10 14:45:53 +00:00
' Travel_Feed_Rate_mm/s ' : storedSettingFloat ( " travel_speed " ) ,
2012-04-05 14:50:59 +00:00
' Bottom_layer_flow_rate_ratio ' : calcBottomLayerFlowRateRatio ,
2012-02-20 17:55:54 +00:00
} , ' temperature ' : {
2012-02-27 13:51:52 +00:00
' Activate_Temperature ' : DEFSET , #ifSettingAboveZero('print_temperature'),
' Cooling_Rate_Celcius/second ' : DEFSET ,
' Heating_Rate_Celcius/second ' : DEFSET ,
2012-04-10 14:45:53 +00:00
' Base_Temperature_Celcius ' : DEFSET , #storedSettingFloat("print_temperature"),
' Interface_Temperature_Celcius ' : DEFSET , #storedSettingFloat("print_temperature"),
' Object_First_Layer_Infill_Temperature_Celcius ' : DEFSET , #storedSettingFloat("print_temperature"),
' Object_First_Layer_Perimeter_Temperature_Celcius ' : DEFSET , #storedSettingFloat("print_temperature"),
' Object_Next_Layers_Temperature_Celcius ' : DEFSET , #storedSettingFloat("print_temperature"),
' Support_Layers_Temperature_Celcius ' : DEFSET , #storedSettingFloat("print_temperature"),
' Supported_Layers_Temperature_Celcius ' : DEFSET , #storedSettingFloat("print_temperature"),
2012-02-20 17:55:54 +00:00
} , ' raft ' : {
2012-02-26 13:30:34 +00:00
' Activate_Raft ' : " True " ,
2012-02-27 13:51:52 +00:00
' Add_Raft,_Elevate_Nozzle,_Orbit ' : DEFSET ,
' Base_Feed_Rate_Multiplier_ratio ' : DEFSET ,
2012-03-20 14:59:31 +00:00
' Base_Flow_Rate_Multiplier_ratio ' : storedPercentSetting ( ' raft_base_material_amount ' ) ,
2012-02-27 13:51:52 +00:00
' Base_Infill_Density_ratio ' : DEFSET ,
' Base_Layer_Thickness_over_Layer_Thickness ' : DEFSET ,
2012-03-18 22:00:33 +00:00
' Base_Layers_integer ' : raftLayerCount ,
2012-02-27 13:51:52 +00:00
' Base_Nozzle_Lift_over_Base_Layer_Thickness_ratio ' : DEFSET ,
' Initial_Circling ' : DEFSET ,
' Infill_Overhang_over_Extrusion_Width_ratio ' : DEFSET ,
' Interface_Feed_Rate_Multiplier_ratio ' : DEFSET ,
2012-03-20 14:59:31 +00:00
' Interface_Flow_Rate_Multiplier_ratio ' : storedPercentSetting ( ' raft_interface_material_amount ' ) ,
2012-02-27 13:51:52 +00:00
' Interface_Infill_Density_ratio ' : DEFSET ,
' Interface_Layer_Thickness_over_Layer_Thickness ' : DEFSET ,
2012-03-18 22:00:33 +00:00
' Interface_Layers_integer ' : raftLayerCount ,
2012-02-27 13:51:52 +00:00
' Interface_Nozzle_Lift_over_Interface_Layer_Thickness_ratio ' : DEFSET ,
' Name_of_Support_End_File ' : DEFSET ,
' Name_of_Support_Start_File ' : DEFSET ,
' Operating_Nozzle_Lift_over_Layer_Thickness_ratio ' : DEFSET ,
' Raft_Additional_Margin_over_Length_ % ' : DEFSET ,
2012-04-10 14:45:53 +00:00
' Raft_Margin_mm ' : storedSettingFloat ( ' raft_margin ' ) ,
2012-02-26 13:30:34 +00:00
' Support_Cross_Hatch ' : ' False ' ,
2012-03-16 10:51:44 +00:00
' Support_Flow_Rate_over_Operating_Flow_Rate_ratio ' : storedPercentSetting ( ' support_rate ' ) ,
' Support_Gap_over_Perimeter_Extrusion_Width_ratio ' : calcSupportDistanceRatio ,
2012-03-20 14:59:31 +00:00
' Support_Material_Choice_ ' : storedSetting ( ' support ' ) ,
2012-02-27 13:51:52 +00:00
' Support_Minimum_Angle_degrees ' : DEFSET ,
2012-05-18 07:52:12 +00:00
' Support_Margin_mm ' : ' 3.0 ' ,
2012-09-12 15:02:42 +00:00
' Support_Offset_X_mm ' : lambda setting : - profile . getPreferenceFloat ( ' extruder_offset_x1 ' ) if profile . getProfileSetting ( ' support_dual_extrusion ' ) == ' True ' and int ( profile . getPreference ( ' extruder_amount ' ) ) > 1 else ' 0 ' ,
' Support_Offset_Y_mm ' : lambda setting : - profile . getPreferenceFloat ( ' extruder_offset_y1 ' ) if profile . getProfileSetting ( ' support_dual_extrusion ' ) == ' True ' and int ( profile . getPreference ( ' extruder_amount ' ) ) > 1 else ' 0 ' ,
2012-02-20 17:55:54 +00:00
} , ' skirt ' : {
2012-02-23 21:47:42 +00:00
' Skirt_line_count ' : storedSetting ( " skirt_line_count " ) ,
' Convex ' : " True " ,
' Gap_Width_mm ' : storedSetting ( " skirt_gap " ) ,
' Layers_To_index ' : " 1 " ,
2012-02-27 16:21:50 +00:00
} , ' joris ' : {
' Activate_Joris ' : storedSetting ( " joris " ) ,
' Layers_From_index ' : calculateSolidLayerCount ,
2012-02-20 17:55:54 +00:00
} , ' chamber ' : {
2012-02-24 16:07:03 +00:00
' Activate_Chamber ' : " False " ,
2012-02-27 13:51:52 +00:00
' Bed_Temperature_Celcius ' : DEFSET ,
' Bed_Temperature_Begin_Change_Height_mm ' : DEFSET ,
' Bed_Temperature_End_Change_Height_mm ' : DEFSET ,
' Bed_Temperature_End_Celcius ' : DEFSET ,
' Chamber_Temperature_Celcius ' : DEFSET ,
' Holding_Force_bar ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' tower ' : {
2012-02-24 16:07:03 +00:00
' Activate_Tower ' : " False " ,
2012-02-27 13:51:52 +00:00
' Extruder_Possible_Collision_Cone_Angle_degrees ' : DEFSET ,
' Maximum_Tower_Height_layers ' : DEFSET ,
' Tower_Start_Layer_integer ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' jitter ' : {
2012-02-24 21:37:53 +00:00
' Activate_Jitter ' : " False " ,
2012-02-27 13:51:52 +00:00
' Jitter_Over_Perimeter_Width_ratio ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' clip ' : {
2012-02-24 21:37:53 +00:00
' Activate_Clip ' : " False " ,
2012-02-27 13:51:52 +00:00
' Clip_Over_Perimeter_Width_ratio ' : DEFSET ,
' Maximum_Connection_Distance_Over_Perimeter_Width_ratio ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' smooth ' : {
2012-02-24 21:37:53 +00:00
' Activate_Smooth ' : " False " ,
2012-02-27 13:51:52 +00:00
' Layers_From_index ' : DEFSET ,
' Maximum_Shortening_over_Width_float ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' stretch ' : {
2012-02-24 21:37:53 +00:00
' Activate_Stretch ' : " False " ,
2012-02-27 13:51:52 +00:00
' Cross_Limit_Distance_Over_Perimeter_Width_ratio ' : DEFSET ,
' Loop_Stretch_Over_Perimeter_Width_ratio ' : DEFSET ,
' Path_Stretch_Over_Perimeter_Width_ratio ' : DEFSET ,
' Perimeter_Inside_Stretch_Over_Perimeter_Width_ratio ' : DEFSET ,
' Perimeter_Outside_Stretch_Over_Perimeter_Width_ratio ' : DEFSET ,
' Stretch_From_Distance_Over_Perimeter_Width_ratio ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' skin ' : {
2012-04-06 15:08:49 +00:00
' Activate_Skin ' : storedSetting ( " enable_skin " ) ,
' Horizontal_Infill_Divisions_integer ' : " 1 " ,
' Horizontal_Perimeter_Divisions_integer ' : " 1 " ,
' Vertical_Divisions_integer ' : " 2 " ,
' Hop_When_Extruding_Infill ' : " False " ,
' Layers_From_index ' : " 1 " ,
2012-02-20 17:55:54 +00:00
} , ' comb ' : {
2012-02-24 21:37:53 +00:00
' Activate_Comb ' : " True " ,
2012-02-27 13:51:52 +00:00
' Running_Jump_Space_mm ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' cool ' : {
2012-02-24 21:37:53 +00:00
' Activate_Cool ' : " True " ,
2012-02-27 13:51:52 +00:00
' Bridge_Cool_Celcius ' : DEFSET ,
' Cool_Type ' : DEFSET ,
' Maximum_Cool_Celcius ' : DEFSET ,
2012-04-10 14:45:53 +00:00
' Minimum_Layer_Time_seconds ' : storedSettingFloat ( " cool_min_layer_time " ) ,
2012-02-27 13:51:52 +00:00
' Minimum_Orbital_Radius_millimeters ' : DEFSET ,
' Name_of_Cool_End_File ' : DEFSET ,
' Name_of_Cool_Start_File ' : DEFSET ,
' Orbital_Outset_millimeters ' : DEFSET ,
2012-04-02 14:09:56 +00:00
' Turn_Fan_On_at_Beginning ' : storedSetting ( " fan_enabled " ) ,
2012-04-12 12:43:51 +00:00
' Turn_Fan_Off_at_Ending ' : storedSetting ( " fan_enabled " ) ,
2012-04-10 14:45:53 +00:00
' Minimum_feed_rate_mm/s ' : storedSettingFloat ( " cool_min_feedrate " ) ,
' Fan_on_at_layer ' : storedSettingInt ( ' fan_layer ' ) ,
2012-07-03 15:45:18 +00:00
' Fan_speed_min_ % ' : storedSettingInt ( ' fan_speed ' ) ,
' Fan_speed_max_ % ' : storedSettingInt ( ' fan_speed_max ' ) ,
2012-02-20 17:55:54 +00:00
} , ' hop ' : {
2012-02-24 18:19:00 +00:00
' Activate_Hop ' : " False " ,
2012-02-27 13:51:52 +00:00
' Hop_Over_Layer_Thickness_ratio ' : DEFSET ,
' Minimum_Hop_Angle_degrees ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' wipe ' : {
2012-02-24 18:19:00 +00:00
' Activate_Wipe ' : " False " ,
2012-02-27 13:51:52 +00:00
' Arrival_X_mm ' : DEFSET ,
' Arrival_Y_mm ' : DEFSET ,
' Arrival_Z_mm ' : DEFSET ,
' Departure_X_mm ' : DEFSET ,
' Departure_Y_mm ' : DEFSET ,
' Departure_Z_mm ' : DEFSET ,
' Wipe_X_mm ' : DEFSET ,
' Wipe_Y_mm ' : DEFSET ,
' Wipe_Z_mm ' : DEFSET ,
' Wipe_Period_layers ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' oozebane ' : {
2012-02-24 18:19:00 +00:00
' Activate_Oozebane ' : " False " ,
2012-02-27 13:51:52 +00:00
' After_Startup_Distance_millimeters ' : DEFSET ,
' Early_Shutdown_Distance_millimeters ' : DEFSET ,
' Early_Startup_Distance_Constant_millimeters ' : DEFSET ,
' Early_Startup_Maximum_Distance_millimeters ' : DEFSET ,
' First_Early_Startup_Distance_millimeters ' : DEFSET ,
' Minimum_Distance_for_Early_Startup_millimeters ' : DEFSET ,
' Minimum_Distance_for_Early_Shutdown_millimeters ' : DEFSET ,
' Slowdown_Startup_Steps_positive_integer ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' dwindle ' : {
2012-09-26 13:12:14 +00:00
' Activate_Dwindle ' : " False " ,
2012-05-14 14:01:55 +00:00
' End_Rate_Multiplier_ratio ' : ' 0.5 ' ,
2012-09-26 13:12:14 +00:00
' Pent_Up_Volume_cubic_millimeters ' : " 0.4 " ,
2012-05-14 14:01:55 +00:00
' Slowdown_Steps_positive_integer ' : ' 5 ' ,
2012-09-26 13:12:14 +00:00
' Slowdown_Volume_cubic_millimeters ' : " 5.0 " ,
2012-02-20 17:55:54 +00:00
} , ' splodge ' : {
2012-02-24 18:19:00 +00:00
' Activate_Splodge ' : " False " ,
2012-02-27 13:51:52 +00:00
' Initial_Lift_over_Extra_Thickness_ratio ' : DEFSET ,
' Initial_Splodge_Feed_Rate_mm/s ' : DEFSET ,
' Operating_Splodge_Feed_Rate_mm/s ' : DEFSET ,
' Operating_Splodge_Quantity_Length_millimeters ' : DEFSET ,
' Initial_Splodge_Quantity_Length_millimeters ' : DEFSET ,
' Operating_Lift_over_Extra_Thickness_ratio ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' home ' : {
2012-02-24 18:19:00 +00:00
' Activate_Home ' : " False " ,
2012-02-27 13:51:52 +00:00
' Name_of_Home_File ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' lash ' : {
2012-02-24 18:19:00 +00:00
' Activate_Lash ' : " False " ,
2012-02-27 13:51:52 +00:00
' X_Backlash_mm ' : DEFSET ,
' Y_Backlash_mm ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' fillet ' : {
2012-02-24 21:37:53 +00:00
' Activate_Fillet ' : " False " ,
2012-02-27 13:51:52 +00:00
' Arc_Point ' : DEFSET ,
' Arc_Radius ' : DEFSET ,
' Arc_Segment ' : DEFSET ,
' Bevel ' : DEFSET ,
' Corner_Feed_Rate_Multiplier_ratio ' : DEFSET ,
' Fillet_Radius_over_Perimeter_Width_ratio ' : DEFSET ,
' Reversal_Slowdown_Distance_over_Perimeter_Width_ratio ' : DEFSET ,
' Use_Intermediate_Feed_Rate_in_Corners ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' limit ' : {
2012-02-24 21:37:53 +00:00
' Activate_Limit ' : " False " ,
2012-02-27 13:51:52 +00:00
' Maximum_Initial_Feed_Rate_mm/s ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' unpause ' : {
2012-02-24 21:37:53 +00:00
' Activate_Unpause ' : " False " ,
2012-02-27 13:51:52 +00:00
' Delay_milliseconds ' : DEFSET ,
' Maximum_Speed_ratio ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' dimension ' : {
2012-02-24 18:19:00 +00:00
' Activate_Dimension ' : " True " ,
' Absolute_Extrusion_Distance ' : " True " ,
' Relative_Extrusion_Distance ' : " False " ,
2012-04-10 14:45:53 +00:00
' Extruder_Retraction_Speed_mm/s ' : storedSettingFloat ( ' retraction_speed ' ) ,
' Filament_Diameter_mm ' : storedSettingFloat ( " filament_diameter " ) ,
' Filament_Packing_Density_ratio ' : storedSettingFloat ( " filament_density " ) ,
2012-02-27 13:51:52 +00:00
' Maximum_E_Value_before_Reset_float ' : DEFSET ,
2012-04-10 14:45:53 +00:00
' Minimum_Travel_for_Retraction_millimeters ' : storedSettingFloat ( " retraction_min_travel " ) ,
2012-06-21 16:44:30 +00:00
' Retract_Within_Island ' : storedSettingInvertBoolean ( " retract_on_jumps_only " ) ,
2012-04-10 14:45:53 +00:00
' Retraction_Distance_millimeters ' : storedSettingFloat ( ' retraction_amount ' ) ,
' Restart_Extra_Distance_millimeters ' : storedSettingFloat ( ' retraction_extra ' ) ,
2012-02-20 17:55:54 +00:00
} , ' alteration ' : {
2012-04-17 17:12:40 +00:00
' Activate_Alteration ' : storedSetting ( ' add_start_end_gcode ' ) ,
2012-02-24 21:37:53 +00:00
' Name_of_End_File ' : " end.gcode " ,
' Name_of_Start_File ' : " start.gcode " ,
2012-02-24 18:19:00 +00:00
' Remove_Redundant_Mcode ' : " True " ,
2012-02-27 13:51:52 +00:00
' Replace_Variable_with_Setting ' : DEFSET ,
2012-02-20 17:55:54 +00:00
} , ' export ' : {
2012-02-24 18:19:00 +00:00
' Activate_Export ' : " True " ,
2012-02-27 13:51:52 +00:00
' Add_Descriptive_Extension ' : DEFSET ,
' Add_Export_Suffix ' : DEFSET ,
' Add_Profile_Extension ' : DEFSET ,
' Add_Timestamp_Extension ' : DEFSET ,
' Also_Send_Output_To ' : DEFSET ,
' Analyze_Gcode ' : DEFSET ,
' Comment_Choice ' : DEFSET ,
' Do_Not_Change_Output ' : DEFSET ,
' binary_16_byte ' : DEFSET ,
' gcode_step ' : DEFSET ,
' gcode_time_segment ' : DEFSET ,
' gcode_small ' : DEFSET ,
2012-04-17 17:12:40 +00:00
' File_Extension ' : storedSetting ( ' gcode_extension ' ) ,
2012-02-27 13:51:52 +00:00
' Name_of_Replace_File ' : DEFSET ,
2012-02-26 13:30:34 +00:00
' Save_Penultimate_Gcode ' : " False " ,
2012-02-20 17:55:54 +00:00
}
}
2012-02-19 23:30:49 +00:00
def safeConfigName ( name ) :
return name . replace ( " = " , " " ) . replace ( " : " , " " ) . replace ( " " , " _ " ) . replace ( " ( " , " " ) . replace ( " ) " , " " )
def getReadRepository ( repository ) :
" Read the configuration for this ' repository ' "
2012-03-24 09:51:52 +00:00
info = getProfileInformation ( )
2012-02-20 17:55:54 +00:00
if not info . has_key ( repository . name ) :
2012-06-21 17:53:18 +00:00
print ( " Warning: Plugin: " + repository . name + " missing from Cura info " )
2012-02-20 17:55:54 +00:00
return repository
info = info [ repository . name ]
2012-02-20 15:44:43 +00:00
#print('getReadRepository:', repository.name)
2012-02-19 23:30:49 +00:00
for p in repository . preferences :
2012-02-20 17:55:54 +00:00
name = safeConfigName ( p . name )
if not info . has_key ( name ) :
2012-06-21 17:53:18 +00:00
print ( " Setting: " + repository . name + " : " + name + " missing from Cura info " )
2012-02-20 17:55:54 +00:00
continue
2012-02-23 21:47:42 +00:00
if isinstance ( info [ name ] , types . FunctionType ) :
p . setValueToString ( str ( info [ name ] ( p ) ) )
else :
p . setValueToString ( str ( info [ name ] ) )
2012-02-20 22:27:34 +00:00
return repository
2012-02-19 23:30:49 +00:00
def printProgress ( layerIndex , procedureName ) :
2012-06-21 17:53:18 +00:00
print ( " Progress[ " + procedureName + " : " + str ( layerIndex + 1 ) + " ] " )
2012-02-21 14:27:03 +00:00
sys . stdout . flush ( )
2012-02-19 23:30:49 +00:00
def printProgressByNumber ( layerIndex , numberOfLayers , procedureName ) :
2012-06-21 17:53:18 +00:00
print ( " Progress[ " + procedureName + " : " + str ( layerIndex + 1 ) + " : " + str ( numberOfLayers ) + " ] " )
2012-02-21 14:27:03 +00:00
sys . stdout . flush ( )
2012-02-19 23:30:49 +00:00
def getAlterationFileLines ( fileName ) :
' Get the alteration file line and the text lines from the fileName in the alterations directories. '
2012-02-21 22:05:30 +00:00
return getAlterationLines ( fileName )
2012-02-20 17:55:54 +00:00
2012-02-19 23:30:49 +00:00
def getAlterationLines ( fileName ) :
2012-02-21 22:05:30 +00:00
return archive . getTextLines ( getAlterationFile ( fileName ) )
2012-03-27 11:48:40 +00:00
def getAlterationFile ( fileName ) :
2012-04-25 11:34:25 +00:00
return profile . getAlterationFileContents ( fileName )
2012-02-19 23:30:49 +00:00
####################################
## Configuration settings classes ##
####################################
class GeneralSetting :
" Just a basic setting subclass "
def getFromValue ( self , name , repository , value ) :
#print('GeneralSetting:', name, repository, value )
self . name = name
self . value = value
repository . preferences . append ( self )
return self
class StringSetting ( GeneralSetting ) :
" A class to display, read & write a string. "
def setValueToString ( self , value ) :
self . value = value
class BooleanSetting ( GeneralSetting ) :
" A class to display, read & write a boolean. "
def setValueToString ( self , value ) :
2012-02-21 16:33:02 +00:00
self . value = str ( value ) == " True "
2012-02-19 23:30:49 +00:00
class LatentStringVar :
" This is actually used as ' group ' object for Radio buttons. (Did I mention the code is a mess?) "
" This class doesn ' t have a name, and isn ' t really used for anything. It doesn ' t even know which repository it belongs to "
class Radio ( BooleanSetting ) :
" A class to display, read & write a boolean with associated radio button. "
def getFromRadio ( self , latentStringVar , name , repository , value ) :
" Initialize. "
#print('Radio->getFromRadio:', latentStringVar, name, repository, value )
self . name = name
self . value = value
repository . preferences . append ( self )
return self
class RadioCapitalized ( Radio ) :
" A class to display, read & write a boolean with associated radio button. "
class RadioCapitalizedButton ( Radio ) :
" A class to display, read & write a boolean with associated radio button. With an added configuration dialog button "
" Only used for the extra export options, which we are not using, so ignore the path for now "
def getFromPath ( self , latentStringVar , name , path , repository , value ) :
" Initialize. "
2012-02-20 15:44:43 +00:00
#print('RadioCapitalizedButton->getFromPath:', latentStringVar, name, path, repository, value )
2012-02-19 23:30:49 +00:00
self . name = name
self . value = value
repository . preferences . append ( self )
return self
class FileNameInput ( StringSetting ) :
" A class to display, read & write a fileName. "
def getFromFileName ( self , fileTypes , name , repository , value ) :
#print('FileNameInput:getFromFileName:', self, fileTypes, name, repository, value )
self . name = name
self . value = value
return self
class HelpPage :
" A class to open a help page. "
def getOpenFromAbsolute ( self , hypertextAddress ) :
return self
class MenuButtonDisplay :
" A class to add a combo box selection. "
def getFromName ( self , name , repository ) :
#print('MenuButtonDisplay->getFromName:', name, repository )
self . name = name
self . value = " ERROR "
self . radioList = [ ]
repository . preferences . append ( self )
return self
def addRadio ( self , radio , default ) :
if default :
self . value = radio . name
self . radioList . append ( radio )
def setValueToString ( self , value ) :
valueFound = False
for radio in self . radioList :
if radio . name == value :
valueFound = True ;
if valueFound :
self . value = value
for radio in self . radioList :
radio . value = ( radio . name == value )
class MenuRadio ( BooleanSetting ) :
" A class to display, read & write a boolean with associated combo box selection. "
def getFromMenuButtonDisplay ( self , menuButtonDisplay , name , repository , value ) :
" Initialize. "
2012-02-20 15:44:43 +00:00
#print('MenuRadio->getFromMenuButtonDisplay:', menuButtonDisplay, name, repository, value )
2012-02-19 23:30:49 +00:00
self . name = name
self . value = value
menuButtonDisplay . addRadio ( self , value )
return self
class LabelDisplay :
" A class to add a label. "
def getFromName ( self , name , repository ) :
" Initialize. "
return self
class FloatSetting ( GeneralSetting ) :
" A class to display, read & write a float. "
def setValueToString ( self , value ) :
self . value = float ( value )
class FloatSpin ( FloatSetting ) :
" A class to display, read & write an float in a spin box. "
def getFromValue ( self , from_ , name , repository , to , value ) :
" Initialize. "
self . name = name
self . value = value
2012-02-20 22:27:34 +00:00
if repository != None :
repository . preferences . append ( self )
2012-02-19 23:30:49 +00:00
return self
class LabelSeparator :
" A class to add a label and menu separator. "
def getFromRepository ( self , repository ) :
" Initialize. "
return self
class IntSpin ( FloatSpin ) :
" A class to display, read & write an int in a spin box. "
def getSingleIncrementFromValue ( self , from_ , name , repository , to , value ) :
" Initialize. "
self . name = name
self . value = value
repository . preferences . append ( self )
return self
def setValueToString ( self , value ) :
self . value = int ( value )
##########################
# Helper classes
##########################
class LayerCount :
' A class to handle the layerIndex. '
def __init__ ( self ) :
' Initialize. '
self . layerIndex = - 1
def __repr__ ( self ) :
' Get the string representation of this LayerCount. '
return str ( self . layerIndex )
def printProgressIncrement ( self , procedureName ) :
' Print progress then increment layerIndex. '
self . layerIndex + = 1
printProgress ( self . layerIndex , procedureName )