Add proper line width calculation to GCode preview. Added raft settings.

master
Daid 2012-03-18 23:00:33 +01:00
parent 19fcc1186a
commit 93f8d13b0a
4 changed files with 30 additions and 24 deletions

View File

@ -25,6 +25,11 @@ def ifSettingAboveZero(name):
def ifSettingIs(name, value):
return lambda setting: profile.getProfileSetting(name) == value
def raftLayerCount(setting):
if profile.getProfileSetting('enable_raft') == "True":
return '1'
return '0'
def storedPercentSetting(name):
return lambda setting: float(profile.getProfileSetting(name)) / 100
@ -196,7 +201,7 @@ def getSkeinPyPyProfileInformation():
'Base_Flow_Rate_Multiplier_ratio': DEFSET,
'Base_Infill_Density_ratio': DEFSET,
'Base_Layer_Thickness_over_Layer_Thickness': DEFSET,
'Base_Layers_integer': '0',
'Base_Layers_integer': raftLayerCount,
'Base_Nozzle_Lift_over_Base_Layer_Thickness_ratio': DEFSET,
'Initial_Circling': DEFSET,
'Infill_Overhang_over_Extrusion_Width_ratio': DEFSET,
@ -204,7 +209,7 @@ def getSkeinPyPyProfileInformation():
'Interface_Flow_Rate_Multiplier_ratio': DEFSET,
'Interface_Infill_Density_ratio': DEFSET,
'Interface_Layer_Thickness_over_Layer_Thickness': DEFSET,
'Interface_Layers_integer': '0',
'Interface_Layers_integer': raftLayerCount,
'Interface_Nozzle_Lift_over_Interface_Layer_Thickness_ratio': DEFSET,
'Name_of_Support_End_File': DEFSET,
'Name_of_Support_Start_File': DEFSET,

View File

@ -88,7 +88,6 @@ class mainWindow(configBase.configWindowBase):
c = configBase.SettingRow(left, "Wall thickness (mm)", 'wall_thickness', '0.8', 'Thickness of the walls.\nThis is used in combination with the nozzle size to define the number\nof perimeter lines and the thickness of those perimeter lines.')
validators.validFloat(c, 0.0)
validators.wallThicknessValidator(c)
configBase.settingNotify(c, self.preview3d.updateWallLineWidth)
configBase.TitleRow(left, "Fill")
c = configBase.SettingRow(left, "Bottom/Top thickness (mm)", 'solid_layer_thickness', '0.6', 'This controls the thickness of the bottom and top layers, the amount of solid layers put down is calculated by the layer thickness and this value.\nHaving this value a multiply of the layer thickness makes sense. And keep it near your wall thickness to make an evenly strong part.')
@ -114,6 +113,7 @@ class mainWindow(configBase.configWindowBase):
configBase.TitleRow(right, "Support")
c = configBase.SettingRow(right, "Support type", 'support', ['None', 'Exterior Only', 'Everywhere', 'Empty Layers Only'], 'Type of support structure build.\nNone does not do any support.\nExterior only only creates support on the outside.\nEverywhere creates support even on the insides of the model.\nOnly on empty layers is for stacked objects.')
c = configBase.SettingRow(right, "Add raft", 'enable_raft', False, 'A raft is a few layers of lines below the bottom of the object. It prevents warping. Full raft settings can be found in the advanced settings.\nFor PLA this is usually not required. But if you print with ABS it is almost required.')
configBase.TitleRow(right, "Filament")
c = configBase.SettingRow(right, "Diameter (mm)", 'filament_diameter', '2.89', 'Diameter of your filament, as accurately as possible.\nIf you cannot measure this value you will have to callibrate it, a higher number means less extrusion, a smaller number generates more extrusion.')
@ -135,8 +135,6 @@ class mainWindow(configBase.configWindowBase):
configBase.TitleRow(left, "Machine nozzle")
c = configBase.SettingRow(left, "Nozzle size (mm)", 'nozzle_size', '0.4', 'The nozzle size is very important, this is used to calculate the line width of the infill, and used to calculate the amount of outside wall lines and thickness for the wall thickness you entered in the print settings.')
validators.validFloat(c, 0.1, 1.0)
configBase.settingNotify(c, self.preview3d.updateWallLineWidth)
configBase.settingNotify(c, self.preview3d.updateInfillLineWidth)
configBase.TitleRow(left, "Retraction")
c = configBase.SettingRow(left, "Minimal travel (mm)", 'retraction_min_travel', '5.0', 'Minimal amount of travel needed for a retraction to happen at all. To make sure you do not get a lot of retractions in a small area')

View File

@ -19,7 +19,6 @@ from newui import profile
from newui import gcodeInterpreter
from newui import util3d
from fabmetheus_utilities import settings
from fabmetheus_utilities.fabmetheus_tools import fabmetheus_interpret
from fabmetheus_utilities.vector3 import Vector3
@ -92,14 +91,6 @@ class previewPanel(wx.Panel):
self.moveModel()
self.glCanvas.Refresh()
def updateWallLineWidth(self, setting):
#TODO: this shouldn't be needed, you can calculate the line width from the E values combined with the steps_per_E and the filament diameter (reverse volumatric)
self.glCanvas.lineWidth = settings.calculateEdgeWidth(setting)
def updateInfillLineWidth(self, setting):
#TODO: this shouldn't be needed, you can calculate the line width from the E values combined with the steps_per_E and the filament diameter (reverse volumatric)
self.glCanvas.infillLineWidth = profile.getProfileSetting('nozzle_size')
def loadModelFile(self, filename):
self.modelFilename = filename
self.gcodeFilename = filename[: filename.rfind('.')] + "_export.gcode"
@ -216,8 +207,6 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
self.zoom = 150
self.offsetX = 0
self.offsetY = 0
self.lineWidth = 0.4
self.fillLineWidth = 0.4
self.view3D = True
self.modelDisplayList = None
self.gcodeDisplayList = None
@ -315,7 +304,22 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
if self.parent.gcodeDirty:
self.parent.gcodeDirty = False
glNewList(self.gcodeDisplayList, GL_COMPILE)
prevLayerZ = 0.0
curLayerZ = 0.0
layerThickness = 0.0
filamentRadius = float(profile.getProfileSetting('filament_diameter')) / 2
filamentArea = math.pi * filamentRadius * filamentRadius
lineWidth = float(profile.getProfileSetting('nozzle_size')) / 2
curLayerNum = 0
for path in self.parent.gcode.pathList:
if path['layerNr'] != curLayerNum:
prevLayerZ = curLayerZ
curLayerZ = path['list'][1].z
curLayerNum = path['layerNr']
layerThickness = curLayerZ - prevLayerZ
c = 1.0
if path['layerNr'] != self.parent.layerSpin.GetValue():
if path['layerNr'] < self.parent.layerSpin.GetValue():
@ -336,16 +340,14 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
if path['type'] == 'retract':
glColor3f(0,c,c)
if c > 0.4 and path['type'] == 'extrude':
if path['pathType'] == 'FILL':
lineWidth = self.fillLineWidth / 2
else:
lineWidth = self.lineWidth / 2
for i in xrange(0, len(path['list'])-1):
v0 = path['list'][i]
v1 = path['list'][i+1]
dist = (v0 - v1).vsize()
if dist > 0:
extrusionMMperDist = (v1.e - v0.e) / (v0 - v1).vsize() / self.parent.gcode.stepsPerE
if dist > 0 and layerThickness > 0:
extrusionMMperDist = (v1.e - v0.e) / (v0 - v1).vsize()
lineWidth = extrusionMMperDist * filamentArea / layerThickness / 2
#TODO: Calculate line width from ePerDistance (needs layer thickness, steps_per_E and filament diameter)
normal = (v0 - v1).cross(util3d.Vector3(0,0,1))
normal.normalize()
@ -394,12 +396,12 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
modelSize = self.parent.triangleMesh.getCarveCornerMaximum() - self.parent.triangleMesh.getCarveCornerMinimum()
glNewList(self.modelDisplayList, GL_COMPILE)
glPushMatrix()
glTranslate(-(modelSize.x+self.lineWidth*15)*(multiX-1)/2,-(modelSize.y+self.lineWidth*15)*(multiY-1)/2, 0)
glTranslate(-(modelSize.x+10)*(multiX-1)/2,-(modelSize.y+10)*(multiY-1)/2, 0)
for mx in xrange(0, multiX):
for my in xrange(0, multiY):
for face in self.parent.triangleMesh.faces:
glPushMatrix()
glTranslate((modelSize.x+self.lineWidth*15)*mx,(modelSize.y+self.lineWidth*15)*my, 0)
glTranslate((modelSize.x+10)*mx,(modelSize.y+10)*my, 0)
glBegin(GL_TRIANGLES)
v1 = self.parent.triangleMesh.vertexes[face.vertexIndexes[0]]
v2 = self.parent.triangleMesh.vertexes[face.vertexIndexes[1]]

View File

@ -46,6 +46,7 @@ profileDefaultSettings = {
'support_rate': '100',
'support_distance': '0.5',
'joris': 'False',
'enable_raft': 'False',
}
preferencesDefaultSettings = {
'wizardDone': 'False',