# Path: importerUtils.py
# def logInfo(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkLogging", False)): _log("logInfo",    Console.PrintMessage, msg, args)
# 
# def getIconPath(fileName):
# 	return os.path.join(os.path.dirname(__file__), "Resources", "icons", fileName)
# 
# def getTableValue(table, col, row):
# 	try:
# 		return table.get(getCellRef(col, row))
# 	except:
# 		return None
# 
# def setTableValue(table, col, row, val):
# 	if (type(val) == str):
# 		table.set(getCellRef(col, row), val)
# 	else:
# 		if ((sys.version_info.major <= 2) and (type(val) == unicode)):
# 			table.set(getCellRef(col, row), "%s" %(val.encode("utf8")))
# 		else:
# 			table.set(getCellRef(col, row), str(val))
# 
# def logInfo(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkLogging", False)): _log("logInfo",    Console.PrintMessage, msg, args)
# 
# def logWarning(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkWarning", False)): _log("logWarning", Console.PrintWarning, msg, args)
# 
# def logError(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkError", True)):    _log("logError",   Console.PrintError,   msg, args)
# 
# def getCellRef(col, row):
# 	if (isString(col)):
# 		return u"%s%d" %(col, row)
# 	return u"%s%d" %(int2col(col), row)
# 
# def setTableValue(table, col, row, val):
# 	if (type(val) == str):
# 		table.set(getCellRef(col, row), val)
# 	else:
# 		if ((sys.version_info.major <= 2) and (type(val) == unicode)):
# 			table.set(getCellRef(col, row), "%s" %(val.encode("utf8")))
# 		else:
# 			table.set(getCellRef(col, row), str(val))
# 
# def calcAliasname(name):
# 	alias = name.replace(':', '_')
# 	if (IS_CELL_REF.search(name)):
# 		return '%s_' %(alias)
# 	# 45, 48..57, 65..90, 97..122
# 	result = ''
# 	for c in alias:
# 		i = ord(c)
# 		if (i == 45) or (i > 47 and i < 58) or (i > 64 and i < 91) or (i > 96 and i < 123):
# 			result += c
# 		else:
# 			result += '_'
# 	if (result[0] == '_'):
# 		return 'd' + result
# 	return result
# 
# Path: importerClasses.py
# class ParameterTableModel(TableModel):
# 	def __init__(self, parent, mylist, *args):
# 		TableModel.__init__(self, parent, mylist, ['Variant', 'Source', 'Property', 'Parameter', 'Value', 'Units'], *args)
# 	def flags(self, index):
# 		if (index.column() == 0):
# 			return Qt.ItemIsEnabled | Qt.ItemIsEditable | Qt.ItemIsUserCheckable
# 		if (index.column() in [1, 2, 5]): # make object's name and property and unit column read only!
# 			return Qt.ItemIsEnabled
# 		return Qt.ItemIsEnabled |Qt.ItemIsEditable
# 
# class VariantTableModel(TableModel):
# 	def __init__(self, parent, values, *args):
# 		TableModel.__init__(self, parent, values[1:], values[0], *args)
# 	def flags(self, index):
# 		return Qt.ItemIsEnabled | Qt.ItemIsEditable
# 
# Path: importerConstants.py
# DIR_X  = VEC(1, 0, 0)
# 
# DIR_Y  = VEC(0, 1, 0)
# 
# DIR_Z  = VEC(0, 0, 1)


import os, re, sys, Part, FreeCAD, FreeCADGui
from importerUtils   import logInfo, getIconPath, getTableValue, setTableValue, logInfo, logWarning, logError, getCellRef, setTableValue, calcAliasname
from FreeCAD         import Vector as VEC
from importerClasses import ParameterTableModel, VariantTableModel
from math            import degrees, radians, pi, sqrt, cos, sin, atan
from PySide.QtCore   import *
from PySide.QtGui    import *
from importerConstants import DIR_X, DIR_Y, DIR_Z
		return []

	def getIcon(self):
		return getIconPath("Sketch3D.xpm")

def makeSketch3D(name = u"Sketch3D"):
	fp = createPartFeature("Part::FeaturePython", name)
	sketch3D = _Sketch3D(fp)
	if (FreeCAD.GuiUp):
		_ViewProviderSketch3D(fp.ViewObject)
	FreeCAD.ActiveDocument.recompute()
	return fp

class _PartVariants(_ObjectProxy):
	def __init__(self, fp):
		super(_PartVariants, self).__init__(fp)
		fp.addProperty("App::PropertyPythonObject", "Values")
		fp.addProperty("App::PropertyPythonObject", "Rows").Rows = {}
		fp.addProperty("App::PropertyPythonObject", "Mapping").Mapping = {}
		fp.addProperty("App::PropertyPythonObject", "Proxy").Proxy = self
		fp.addProperty("App::PropertyLink"        , "Parameters")
		fp.addProperty("App::PropertyEnumeration" , "Variant", "iPart")

	def _getHeadersByRow_(self, table):
		headers = {}
		row = 2 # Skip header row
		header = getTableValue(table, 'A', row)
		while (header):
			headers[header] = row
			row += 1

# Path: importerUtils.py
# def logInfo(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkLogging", False)): _log("logInfo",    Console.PrintMessage, msg, args)
# 
# def getIconPath(fileName):
# 	return os.path.join(os.path.dirname(__file__), "Resources", "icons", fileName)
# 
# def getTableValue(table, col, row):
# 	try:
# 		return table.get(getCellRef(col, row))
# 	except:
# 		return None
# 
# def setTableValue(table, col, row, val):
# 	if (type(val) == str):
# 		table.set(getCellRef(col, row), val)
# 	else:
# 		if ((sys.version_info.major <= 2) and (type(val) == unicode)):
# 			table.set(getCellRef(col, row), "%s" %(val.encode("utf8")))
# 		else:
# 			table.set(getCellRef(col, row), str(val))
# 
# def logInfo(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkLogging", False)): _log("logInfo",    Console.PrintMessage, msg, args)
# 
# def logWarning(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkWarning", False)): _log("logWarning", Console.PrintWarning, msg, args)
# 
# def logError(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkError", True)):    _log("logError",   Console.PrintError,   msg, args)
# 
# def getCellRef(col, row):
# 	if (isString(col)):
# 		return u"%s%d" %(col, row)
# 	return u"%s%d" %(int2col(col), row)
# 
# def setTableValue(table, col, row, val):
# 	if (type(val) == str):
# 		table.set(getCellRef(col, row), val)
# 	else:
# 		if ((sys.version_info.major <= 2) and (type(val) == unicode)):
# 			table.set(getCellRef(col, row), "%s" %(val.encode("utf8")))
# 		else:
# 			table.set(getCellRef(col, row), str(val))
# 
# def calcAliasname(name):
# 	alias = name.replace(':', '_')
# 	if (IS_CELL_REF.search(name)):
# 		return '%s_' %(alias)
# 	# 45, 48..57, 65..90, 97..122
# 	result = ''
# 	for c in alias:
# 		i = ord(c)
# 		if (i == 45) or (i > 47 and i < 58) or (i > 64 and i < 91) or (i > 96 and i < 123):
# 			result += c
# 		else:
# 			result += '_'
# 	if (result[0] == '_'):
# 		return 'd' + result
# 	return result
# 
# Path: importerClasses.py
# class ParameterTableModel(TableModel):
# 	def __init__(self, parent, mylist, *args):
# 		TableModel.__init__(self, parent, mylist, ['Variant', 'Source', 'Property', 'Parameter', 'Value', 'Units'], *args)
# 	def flags(self, index):
# 		if (index.column() == 0):
# 			return Qt.ItemIsEnabled | Qt.ItemIsEditable | Qt.ItemIsUserCheckable
# 		if (index.column() in [1, 2, 5]): # make object's name and property and unit column read only!
# 			return Qt.ItemIsEnabled
# 		return Qt.ItemIsEnabled |Qt.ItemIsEditable
# 
# class VariantTableModel(TableModel):
# 	def __init__(self, parent, values, *args):
# 		TableModel.__init__(self, parent, values[1:], values[0], *args)
# 	def flags(self, index):
# 		return Qt.ItemIsEnabled | Qt.ItemIsEditable
# 
# Path: importerConstants.py
# DIR_X  = VEC(1, 0, 0)
# 
# DIR_Y  = VEC(0, 1, 0)
# 
# DIR_Z  = VEC(0, 0, 1)


# Path: InventorViewProviders.py
import os, re, sys, Part, FreeCAD, FreeCADGui
from importerUtils   import logInfo, getIconPath, getTableValue, setTableValue, logInfo, logWarning, logError, getCellRef, setTableValue, calcAliasname
from FreeCAD         import Vector as VEC
from importerClasses import ParameterTableModel, VariantTableModel
from math            import degrees, radians, pi, sqrt, cos, sin, atan
from PySide.QtCore   import *
from PySide.QtGui    import *
from importerConstants import DIR_X, DIR_Y, DIR_Z

		return []

	def getIcon(self):
		return getIconPath("Sketch3D.xpm")

def makeSketch3D(name = u"Sketch3D"):
	fp = createPartFeature("Part::FeaturePython", name)
	sketch3D = _Sketch3D(fp)
	if (FreeCAD.GuiUp):
		_ViewProviderSketch3D(fp.ViewObject)
	FreeCAD.ActiveDocument.recompute()
	return fp

class _PartVariants(_ObjectProxy):
	def __init__(self, fp):
		super(_PartVariants, self).__init__(fp)
		fp.addProperty("App::PropertyPythonObject", "Values")
		fp.addProperty("App::PropertyPythonObject", "Rows").Rows = {}
		fp.addProperty("App::PropertyPythonObject", "Mapping").Mapping = {}
		fp.addProperty("App::PropertyPythonObject", "Proxy").Proxy = self
		fp.addProperty("App::PropertyLink"        , "Parameters")
		fp.addProperty("App::PropertyEnumeration" , "Variant", "iPart")

	def _getHeadersByRow_(self, table):
		headers = {}
		row = 2 # Skip header row
		header = getTableValue(table, 'A', row)
		while (header):
			headers[header] = row
			row += 1

			header = getTableValue(table, 'A', row)