示例#1
0
 def templateAttrs(self, obj):
     attrs = {}
     attrs['version'] = 2  # Path.Tool is version 1
     attrs['name'] = obj.Label
     if PathPreferences.toolsStoreAbsolutePaths():
         attrs['shape'] = obj.BitShape
     else:
         attrs['shape'] = findRelativePathShape(obj.BitShape)
     params = {}
     for name in obj.BitPropertyNames:
         params[name] = PathUtil.getPropertyValueString(obj, name)
     attrs['parameter'] = params
     params = {}
     attrs['attribute'] = params
     return attrs
示例#2
0
    def librarySave(self):
        library = {}
        tools = []
        library['version'] = 1
        library['tools'] = tools
        for row in range(self.model.rowCount()):
            toolNr = self.model.data(self.model.index(row, 0), PySide.QtCore.Qt.EditRole)
            toolPath = self.model.data(self.model.index(row, 0), _PathRole)
            if PathPreferences.toolsStoreAbsolutePaths():
                tools.append({'nr': toolNr, 'path': toolPath})
            else:
                tools.append({'nr': toolNr, 'path': PathToolBit.findRelativePathTool(toolPath)})

        with open(self.path, 'w') as fp:
            json.dump(library, fp, sort_keys=True, indent=2)
示例#3
0
 def templateAttrs(self, obj):
     attrs = {}
     attrs['version'] = 2  # Path.Tool is version 1
     attrs['name'] = obj.Label
     if PathPreferences.toolsStoreAbsolutePaths():
         attrs['shape'] = obj.BitShape
     else:
         # attrs['shape'] = findRelativePathShape(obj.BitShape)
         # Extract the name of the shape file
         __, filShp = os.path.split(
             obj.BitShape
         )  #  __ is an ignored placeholder acknowledged by LGTM
         attrs['shape'] = str(filShp)
     params = {}
     for name in obj.BitPropertyNames:
         params[name] = PathUtil.getPropertyValueString(obj, name)
     attrs['parameter'] = params
     params = {}
     attrs['attribute'] = params
     return attrs
    def librarySave(self):
        library = {}
        tools = []
        library['version'] = 1
        library['tools'] = tools
        for row in range(self.toolModel.rowCount()):
            toolNr = self.toolModel.data(self.toolModel.index(row, 0), PySide.QtCore.Qt.EditRole)
            toolPath = self.toolModel.data(self.toolModel.index(row, 0), _PathRole)
            if PathPreferences.toolsStoreAbsolutePaths():
                bitPath = toolPath
            else:
                # bitPath = PathToolBit.findRelativePathTool(toolPath)
                # Extract the name of the shape file
                __, filShp = os.path.split(toolPath)  #  __ is an ignored placeholder acknowledged by LGTM
                bitPath = str(filShp)
            tools.append({'nr': toolNr, 'path': bitPath})

        if self.path is not None:
            with open(self.path, 'w') as fp:
                json.dump(library, fp, sort_keys=True, indent=2)
示例#5
0
 def shapeAttrs(self, obj):
     attrs = {}
     attrs['version'] = 2  # Path.Tool is version 1
     attrs['name'] = obj.Label
     if PathPreferences.toolsStoreAbsolutePaths():
         attrs['shape'] = obj.BitShape
     else:
         attrs['shape'] = findRelativePathShape(obj.BitShape)
     params = {}
     for name in self.propertyNamesBit(obj):
         params[name] = PathUtil.getPropertyValueString(obj, name)
     attrs['parameter'] = params
     params = {}
     for name in self.propertyNamesAttribute(obj):
         #print(f"shapeattr {name}")
         if name == "UserAttributes":
             for key, value in obj.UserAttributes.items():
                 params[key] = value
         else:
             params[name] = PathUtil.getPropertyValueString(obj, name)
     attrs['attribute'] = params
     return attrs
示例#6
0
 def loadToolSettings(self):
     self.form.toolsUseLegacy.setChecked(
         PathPreferences.toolsUseLegacyTools())
     self.form.toolsAbsolutePaths.setChecked(
         PathPreferences.toolsStoreAbsolutePaths())