def saveSettings(self): sceneRoot = sceneUtils.getSceneRootNode() newSettings = dict() currentPresetIndex = self.comboOptionPreset.currentIndex() for widget in self.widgetToProperty.keys(): prop = self.widgetToProperty[widget] if (isinstance(widget, QCheckBox)): state = True if widget.checkState() == Qt.Checked else False elif (isinstance(widget, QGroupBox)): state = widget.isChecked() elif (isinstance(widget, QComboBox)): state = widget.currentIndex() elif (isinstance(widget, QLineEdit)): state = widget.text() if currentPresetIndex == 0: userprop.setUserProp(sceneRoot, prop, str(state)) newSettings[prop] = state for special in self.specialWidgetToProperty.keys(): prop = self.specialWidgetToProperty[special] if (isinstance(special, QComboBox)): state = special.currentText() if (isinstance(special, QLineEdit)): state = special.text() if currentPresetIndex == 0: userprop.setUserProp(sceneRoot, prop, state) newSettings[prop] = state self.comboOptionPreset.updatePreset(currentPresetIndex, newSettings) self.btnSave.setText(APPLY_UPTODATE) self.madeChanges = False self.onModifiedData.emit()
def _load(self): sceneRoot = sceneUtils.getSceneRootNode() propList = userprop.getUserPropList(sceneRoot, self.listStorage) if propList is not None: if self.identifier in propList: preset = userprop.getUserProp(sceneRoot, self.identifier) self.name = preset
def delete(self): self._load() sceneRoot = sceneUtils.getSceneRootNode() propList = userprop.getUserPropList(sceneRoot, self.listStorage) if self.identifier in propList: propList.remove(self.identifier) userprop.removeUserProp(sceneRoot, self.identifier) userprop.setUserPropList(sceneRoot, self.listStorage, propList)
def _gatherGroups(self): rootNode = sceneUtils.getSceneRootNode() groupList = userprop.getUserPropList(rootNode, self.groupStorageId) groups = [] if groupList is not None: for groupID in groupList: g = GroupObject(groupID) groups.append(g) return groups
def _gatherSceneObjects(self): rootNode = sceneUtils.getSceneRootNode() presetList = userprop.getUserPropList(rootNode, self.presetStorageId) presets = [] if presetList is not None: for presetID in presetList: p = PresetObject(presetID) presets.append(p) return presets
def _load(self): sceneRoot = sceneUtils.getSceneRootNode() propList = userprop.getUserPropList(sceneRoot, self.listStorage) if propList is not None: if self.identifier in propList: preset = userprop.getUserPropList(sceneRoot, self.identifier) self.name = preset[0] self.optionPreset = None if len(preset) < 2 else preset[1]
def initializeWidgets(self, dictObj=None): """ Initialize each widgets in the option menu by doing this: - Get corresponding UserProperty of a widget in the self.widgetToProperty dictionary - Using this userProperty get the value in the input dictObj. - if it isn't in the dictObj look in the root node - if it isn't stored in the root then get the default value from BabylonPYMXS - if it isn't in BabylonPYMXS default values use the type default (False, 0, 0.0, "") - finally set this value in the widget \nin: dictObj=dict[str] var """ sceneRoot = sceneUtils.getSceneRootNode() for widget in self.widgetToProperty.keys(): prop = self.widgetToProperty[widget] state = None if dictObj is not None: if dictObj.has_key(prop): state = dictObj[prop] if state is None: state = userprop.getUserProp(sceneRoot, prop) #INITIALIZE if (state == None): state = getPropertyDefaultValue(prop) if (isinstance(widget, QCheckBox)): widget.setCheckState(Qt.Checked if state else Qt.Unchecked) elif (isinstance(widget, QGroupBox)): if (state is None): state = False widget.setChecked(state) elif (isinstance(widget, QComboBox)): if state is None: state = 0 widget.setCurrentIndex(state) elif (isinstance(widget, QLineEdit)): widget.setText(str(state)) for special in self.specialWidgetToProperty.keys(): prop = self.specialWidgetToProperty[special] state = userprop.getUserProp(sceneRoot, prop) #INITIALIZE if dictObj is not None: if dictObj.has_key(prop): state = dictObj[prop] if (state is None): state = getPropertyDefaultValue(prop) if isinstance(special, QComboBox): if state is None: state = special.itemText(0) special.setCurrentText(state) if isinstance(special, QLineEdit): if state is None: state = special.text() special.setText(state) self.appliedOption()
def _gatherGroups(self): rootNode = sceneUtils.getSceneRootNode() groupList = userprop.getUserPropList(rootNode, constants.PROP_PRESET_GROUP_LIST) groups = [] if groupList is not None: for groupID in groupList: g = presetUtils.GroupObject(groupID) groups.append(g) return groups
def _load(self): sceneRoot = sceneUtils.getSceneRootNode() propList = userprop.getUserPropList(sceneRoot, self.listStorage) if propList is not None: if self.identifier in propList: groupTuple = userprop.getUserPropHeadedDict( sceneRoot, self.identifier) if (isinstance(groupTuple, tuple)): self.name = groupTuple[0] self.dictionary = groupTuple[1]
def _gatherScenePresets(self): rootNode = sceneUtils.getSceneRootNode() presetList = userprop.getUserPropList(rootNode, constants.PROP_PRESET_LIST) presets = [] if presetList is not None: for presetID in presetList: p = presetUtils.PresetObject(presetID) presets.append(p) return presets
def _load(self): sceneRoot = sceneUtils.getSceneRootNode() propList = userprop.getUserPropList(sceneRoot, self.listStorage) if propList is not None: if self.identifier in propList: preset = userprop.getUserPropList(sceneRoot, self.identifier) self.name = preset[const.PROP_PRESET_PARAM_NAME_ID] self.group = preset[const.PROP_PRESET_PARAM_GROUP_ID] self.path = preset[const.PROP_PRESET_PARAM_PATH_ID] self.layerNames = preset[const. PROP_PRESET_PARAM_OFFSET:len(preset)]
def getCurrentSettingsAsDict(): """ Returns the current babylon parameters saved in the root node as a dict \nout: dictionary key: pymxs user property string value: var """ sceneRoot = sceneUtils.getSceneRootNode() newDict = dict() for val in babylonParameters: newDict[val] = userprop.getUserProp(sceneRoot, val) return newDict
def _write(self): sceneRoot = sceneUtils.getSceneRootNode() propList = userprop.getUserPropList(sceneRoot, self.listStorage) if (propList is None): presetList = list() else: presetList = propList if self.name is None: newPreset = self.defaultName else: newPreset = self.name if self.identifier not in presetList: presetList.append(self.identifier) userprop.setUserProp(sceneRoot, self.identifier, newPreset) userprop.setUserPropList(sceneRoot, self.listStorage, presetList)
def _write(self): sceneRoot = sceneUtils.getSceneRootNode() propList = userprop.getUserPropList(sceneRoot, self.listStorage) if (propList is None): presetList = list() else: presetList = propList if self.name is None: self.name = self.defaultName newGroup = (self.name, self.dictionary) if self.identifier not in presetList: presetList.append(self.identifier) userprop.setUserPropHeadedDict(sceneRoot, self.identifier, newGroup) userprop.setUserPropList(sceneRoot, self.listStorage, presetList)
def createTree(self): self.clearSelection() self._rootDict.clear() self.clear() self._groupDict.clear() roots = self._gatherSceneObjects() groups = self._gatherGroups() sceneRoot = sceneUtils.getSceneRootNode() if (isinstance(groups, list) and groups is not None): for g in groups: qTreeWidget = QTreeWidgetItem() qTreeWidget.setFlags(Qt.ItemIsDropEnabled | Qt.ItemIsEditable | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) qTreeWidget.setCheckState(0, Qt.CheckState.Unchecked) qTreeWidget.setText(0, str(g.name)) if g.optionPreset is not None: option = OptionPresetObject(g.optionPreset) else: option = getDefaultExportPresetOptions() optionName = option.name qTreeWidget.setText(1, "Export with : '{0}'".format(optionName)) # store the group id in the fourth column qTreeWidget.setData(0, Qt.UserRole, g) qTreeWidget.setData(1, Qt.UserRole, option) qTreeWidget.setText(4, g.identifier) self._groupDict[g] = qTreeWidget self.addTopLevelItem(qTreeWidget) if (isinstance(roots, list) and roots is not None): for r in roots: qTreeWidgetPreset = self._createRootWidget(obj=r, offset=0) self._rootDict[qTreeWidgetPreset] = r group = None for k in self._groupDict.keys(): if k.identifier == r.group: group = k break if (group != None): self._groupDict[group].addChild(qTreeWidgetPreset) else: self.addTopLevelItem(qTreeWidgetPreset)
def _write(self): sceneRoot = sceneUtils.getSceneRootNode() propList = userprop.getUserPropList(sceneRoot, self.listStorage) if (propList is None): presetList = list() else: presetList = propList newPreset = [] newPreset.insert( const.PROP_PRESET_PARAM_NAME_ID, str(self.defaultName) if self.name is None else str(self.name)) newPreset.insert(const.PROP_PRESET_PARAM_GROUP_ID, "-" if self.group is None else self.group) newPreset.insert(const.PROP_PRESET_PARAM_PATH_ID, ".\\" if self.path is None else self.path) for layer in self.layerNames: newPreset.append(layer) if self.identifier not in presetList: presetList.append(self.identifier) userprop.setUserPropList(sceneRoot, self.identifier, newPreset) userprop.setUserPropList(sceneRoot, self.listStorage, presetList)
def _intializeContent(self): self.clear() self.presetObjectList = [] optionPresetList = userprop.getUserPropList( sceneUtils.getSceneRootNode(), const.PROP_OPTIONS_LIST) if optionPresetList is None: optionPresetList = list() if len(optionPresetList) > 0: defaultPresetId = optionPresetList[0] else: defaultPresetId = const.PROP_OPTIONS_ENTRY_PREFIX.format( uuid.uuid4()) defaultPreset = presetUtils.OptionPresetObject( defaultPresetId, listStorage=const.PROP_OPTIONS_LIST) defaultPreset.create("default", getCurrentSettingsAsDict()) self.presetObjectList.append(defaultPreset) for i in range(1, len(optionPresetList)): option = optionPresetList[i] preset = presetUtils.OptionPresetObject(option, const.PROP_OPTIONS_LIST) self.presetObjectList.append(preset) for item in self.presetObjectList: self.addItem(item.name, item)
def getExportPath(presetID): rootNode = sceneUtils.getSceneRootNode() presetParam = userprop.getUserPropList(rootNode, presetID) return presetParam[const.PROP_PRESET_PARAM_PATH_ID]
def getDefaultExportPresetOptions(): sceneRoot = sceneUtils.getSceneRootNode() optionPresetList = userprop.getUserPropList(sceneRoot, const.PROP_OPTIONS_LIST) option = OptionPresetObject(optionPresetList[0]) return option