|
|
|
|
import FreeCAD
|
|
|
|
|
import FreeCAD as App
|
|
|
|
|
import numpy as np
|
|
|
|
|
import math
|
|
|
|
|
import time
|
|
|
|
|
import Part
|
|
|
|
|
import Draft
|
|
|
|
|
from pivy import coin
|
|
|
|
|
|
|
|
|
|
class LaserProgram:
|
|
|
|
|
def __init__(self, obj):
|
|
|
|
|
obj.addProperty("App::PropertyVector", "base_reference", "Reference", "Reference Point (teached)")
|
|
|
|
|
obj.base_reference = App.Vector(0,0,0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
obj.addProperty("App::PropertyFloat", "laser_power", "Laser Parameter", "Laser Power output (0.4 means 4 Volts)")
|
|
|
|
|
obj.laser_power = 0.4
|
|
|
|
|
|
|
|
|
|
obj.addProperty("App::PropertyInteger", "laser_pilot_out", "Laser Parameter", "Pilot Laser output")
|
|
|
|
|
obj.laser_pilot_out = 4
|
|
|
|
|
|
|
|
|
|
obj.addProperty("App::PropertyInteger", "laser_real_out", "Laser Parameter", "Laser output")
|
|
|
|
|
obj.laser_real_out = 3
|
|
|
|
|
|
|
|
|
|
obj.addProperty("App::PropertyInteger", "laser_gas_out", "Laser Parameter", "Laser inert gas")
|
|
|
|
|
obj.laser_gas_out = 9
|
|
|
|
|
|
|
|
|
|
obj.addProperty("App::PropertyInteger", "laser_powder_out", "Laser Parameter", "Laser Powder Bucket")
|
|
|
|
|
obj.laser_powder_out = 7
|
|
|
|
|
|
|
|
|
|
obj.addProperty("App::PropertyFloat", "laser_feedrate", "Laser Parameter", "Process Velocity (Feedrate m/s)")
|
|
|
|
|
obj.laser_feedrate = 0.022500
|
|
|
|
|
|
|
|
|
|
obj.addProperty("App::PropertyFloat", "laser_speed", "Laser Parameter", "Velocity reaching (m/s)")
|
|
|
|
|
obj.laser_speed = 0.15
|
|
|
|
|
|
|
|
|
|
obj.addProperty("App::PropertyInteger", "rob_tool", "Roboter Parameter", "Tool")
|
|
|
|
|
obj.rob_tool = 6
|
|
|
|
|
|
|
|
|
|
obj.addProperty("App::PropertyInteger", "rob_base", "Roboter Parameter", "Base")
|
|
|
|
|
obj.rob_base = 6
|
|
|
|
|
|
|
|
|
|
obj.addProperty("App::PropertyBool", "simulation", "Roboter Parameter", "Use Simulation")
|
|
|
|
|
obj.simulation = True
|
|
|
|
|
|
|
|
|
|
obj.addProperty("App::PropertyPath", "progpath", "Export Parameters", "Where to store the Program")
|
|
|
|
|
obj.progpath = "/home/jk/"
|
|
|
|
|
|
|
|
|
|
obj.addProperty("App::PropertyString", "article", "Export Parameters", "Article Number")
|
|
|
|
|
obj.article = "0000000"
|
|
|
|
|
|
|
|
|
|
obj.addProperty("App::PropertyString", "templatename", "Export Parameters", "Template Filename")
|
|
|
|
|
obj.templatename = "lasercladding"
|
|
|
|
|
|
|
|
|
|
obj.addExtension("App::GroupExtensionPython")
|
|
|
|
|
obj.Proxy = self
|
|
|
|
|
|
|
|
|
|
def onChanged(self, fp, prop):
|
|
|
|
|
'''Do something when a property has changed'''
|
|
|
|
|
#App.Console.PrintMessage("Change property: " + str(prop) + "\n")
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def execute(self, fp):
|
|
|
|
|
'''Do something when doing a recomputation, this method is mandatory'''
|
|
|
|
|
App.Console.PrintMessage("Recompute LaserPad\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ViewProviderLaserProgram:
|
|
|
|
|
def __init__(self, obj):
|
|
|
|
|
'''Set this object to the proxy object of the actual view provider'''
|
|
|
|
|
obj.addProperty("App::PropertyColor","Color","Box","Color of the box").Color=(1.0,0.0,0.0)
|
|
|
|
|
obj.addExtension("Gui::ViewProviderGroupExtensionPython")
|
|
|
|
|
obj.Proxy = self
|
|
|
|
|
|
|
|
|
|
def attach(self, vobj):
|
|
|
|
|
self.Object = vobj.Object
|
|
|
|
|
self.ViewObject = vobj
|
|
|
|
|
self.standard = coin.SoGroup()
|
|
|
|
|
vobj.addDisplayMode(self.standard,"Standard");
|
|
|
|
|
|
|
|
|
|
def getDisplayModes(self,obj):
|
|
|
|
|
"'''Return a list of display modes.'''"
|
|
|
|
|
return ["Standard"]
|
|
|
|
|
|
|
|
|
|
def getDefaultDisplayMode(self):
|
|
|
|
|
"'''Return the name of the default display mode. It must be defined in getDisplayModes.'''"
|
|
|
|
|
return "Standard"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def updateData(self, fp, prop):
|
|
|
|
|
'''If a property of the handled feature has changed we have the chance to handle this here'''
|
|
|
|
|
# fp is the handled feature, prop is the name of the property that has changed
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def setDisplayMode(self,mode):
|
|
|
|
|
'''Map the display mode defined in attach with those defined in getDisplayModes.\
|
|
|
|
|
Since they have the same names nothing needs to be done. This method is optional'''
|
|
|
|
|
return mode
|
|
|
|
|
|
|
|
|
|
def onChanged(self, vp, prop):
|
|
|
|
|
'''Here we can do something when a single property got changed'''
|
|
|
|
|
# App.Console.PrintMessage("Change property: " + str(prop) + "\n")
|
|
|
|
|
#if prop == "Color":
|
|
|
|
|
# c = vp.getPropertyByName("Color")
|
|
|
|
|
# self.color.rgb.setValue(c[0],c[1],c[2])
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def getIcon(self):
|
|
|
|
|
'''Return the icon in XPM format which will appear in the tree view. This method is\
|
|
|
|
|
optional and if not defined a default icon is shown.'''
|
|
|
|
|
return """
|
|
|
|
|
/* XPM */
|
|
|
|
|
static const char * ViewProviderBox_xpm[] = {
|
|
|
|
|
"16 16 6 1",
|
|
|
|
|
" c None",
|
|
|
|
|
". c #141010",
|
|
|
|
|
"+ c #615BD2",
|
|
|
|
|
"@ c #C39D55",
|
|
|
|
|
"# c #000000",
|
|
|
|
|
"$ c #57C355",
|
|
|
|
|
" ........",
|
|
|
|
|
" ......++..+..",
|
|
|
|
|
" .@@@@.++..++.",
|
|
|
|
|
" .@@@@.++..++.",
|
|
|
|
|
" .@@ .++++++.",
|
|
|
|
|
" ..@@ .++..++.",
|
|
|
|
|
"###@@@@ .++..++.",
|
|
|
|
|
"##$.@@$#.++++++.",
|
|
|
|
|
"#$#$.$$$........",
|
|
|
|
|
"#$$####### ",
|
|
|
|
|
"#$$#$$$$$# ",
|
|
|
|
|
"#$$#$$$$$# ",
|
|
|
|
|
"#$$#$$$$$# ",
|
|
|
|
|
" #$#$$$$$# ",
|
|
|
|
|
" ##$$$$$# ",
|
|
|
|
|
" ####### "};
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def __getstate__(self):
|
|
|
|
|
'''When saving the document this object gets stored using Python's json module.\
|
|
|
|
|
Since we have some un-serializable parts here -- the Coin stuff -- we must define this method\
|
|
|
|
|
to return a tuple of all serializable objects or None.'''
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def __setstate__(self,state):
|
|
|
|
|
'''When restoring the serialized object from document we have the chance to set some internals here.\
|
|
|
|
|
Since no data were serialized nothing needs to be done here.'''
|
|
|
|
|
return None
|