def setData(self, index, value, role): if not index.isValid(): return Qt.ItemIsEnabled # Update the row in the table row = index.row() col = index.column() var = self._data[row][0] # Solver if col == 1: new_solver = from_qvariant(value, to_text_string) self._data[row][col] = new_solver self.mdl.setSolverModel(var, self.dicoV2M[new_solver]) # Precision solver elif col == 2: coeff = from_qvariant(value, float) self._data[row][col] = coeff self.mdl.setSolverPrecision(var, coeff) # Maximum iteration elif col == 3: coeff = from_qvariant(value, int) self._data[row][col] = coeff self.mdl.setMaximumIteration(var, coeff) self.dataChanged.emit(index, index) return True
def setData(self, index, value, role): if index.column() == 0: self.dataBoundariesNames[index.row()][index.column()] = \ str(from_qvariant(value, to_text_string)) vname = self.dataBoundariesNames[index.row()][0] elif index.column() == 1: labelv = str(from_qvariant(value, to_text_string)) self.dataBoundariesNames[index.row()][index.column()] = labelv name = self.dataBoundariesNames[index.row()][0] elif index.column() == 2: v = from_qvariant(value, int) if v == Qt.Unchecked: status = "off" self.dataBoundariesNames[index.row()][index.column()] = "off" else: status = "on" self.dataBoundariesNames[index.row()][index.column()] = "on" vname = self.dataBoundariesNames[index.row()][0] self.model.setComputeBoundaryStatusFromName(vname, status) vname = self.dataBoundariesNames[index.row()][1] if vname: self.model.setComputeBoundaryStatusFromName(vname, status) self.dataChanged.emit(index, index) return True
def setData(self, index, value, role): if not index.isValid(): return Qt.ItemIsEnabled # Update the row in the table row = index.row() col = index.column() var = self._data[row][0] # Scheme if col == 1: new_scheme = from_qvariant(value, to_text_string) self._data[row][col] = new_scheme self.mdl.setSchemeModel(var, self.dicoV2M[new_scheme]) self._data[row][2] = str(self.mdl.getSlopeTestStatus(var)) # Slope Test elif col == 2: state = from_qvariant(value, int) if state == Qt.Unchecked: self._data[row][col] = "off" self.mdl.setSlopeTestStatus(var,"off") else: self._data[row][col] = "on" self.mdl.setSlopeTestStatus(var,"on") self.dataChanged.emit(index, index) return True
def setData(self, index, value, role): if not index.isValid(): return Qt.ItemIsEnabled # Update the row in the table row = index.row() col = index.column() name = row + 1 # Label if col == 0: new_label = from_qvariant(value, to_text_string) self._data[row][col] = new_label self.mdl.setScalarLabel(name, new_label) # field Id elif col == 1: new_field = from_qvariant(value, to_text_string) self._data[row][col] = new_field if self._data[row][col] == "none": id = "none" else: id = self.mdl.getFieldId(self._data[row][col]) self.mdl.setScalarFieldId(name, id) self.dataChanged.emit(index, index) return True
def setData(self, index, value, role=None): row = index.row() name = self.dataSolver[row]['name'] if index.column() == 1: self.dataSolver[row]['iresol'] = self.dicoV2M[from_qvariant(value, to_text_string)] self.NPE.setSolverChoice(name, self.dataSolver[row]['iresol']) elif index.column() == 2: self.dataSolver[row]['precond'] = self.dicoV2M[from_qvariant(value, to_text_string)] self.NPE.setPreconditioningChoice(name, self.dataSolver[row]['precond']) elif index.column() == 3: self.dataSolver[row]['epsilo'] = from_qvariant(value, float) self.NPE.setSolverPrecision(name, self.dataSolver[row]['epsilo']) elif index.column() == 4: self.dataSolver[row]['verbo'] = from_qvariant(value, int) self.NPE.setVerbosity(name, self.dataSolver[row]['verbo']) elif index.column() == 5: self.dataSolver[row]['cdtvar'] = from_qvariant(value, float) self.NPE.setScalarTimeStepFactor(name, self.dataSolver[row]['cdtvar']) self.dataChanged.emit(index, index) return True
def setData(self, index, value, role): row = index.row() col = index.column() if col == 0: self.dataFaces[row]['fraction'] = str( from_qvariant(value, to_text_string)) elif col == 1: self.dataFaces[row]['plane'] = str( from_qvariant(value, to_text_string)) elif col == 2: self.dataFaces[row]['verbosity'] = str( from_qvariant(value, to_text_string)) elif col == 3: self.dataFaces[row]['visualization'] = str( from_qvariant(value, to_text_string)) elif col == 4: self.dataFaces[row]['selector'] = str( from_qvariant(value, to_text_string)) if self.tag == "face_joining": self.mdl.replaceJoinFaces(row, self.dataFaces[row]) elif self.tag == "face_periodicity": self.mdl.replacePeriodicFaces(row, self.dataFaces[row]) log.debug("setData -> dataFaces = %s" % self.dataFaces) self.dataChanged.emit(index, index) return True
def setData(self, index, value, role=None): item = index.internalPointer() if index.column() == 0: v = from_qvariant(value, to_text_string) item.item.name = v self.mdl.setVariableName(item.item.index, item.item.name) elif index.column() == 1: value = str(from_qvariant(value, float)) item.item.value = value self.mdl.setVariableValue(item.item.value, idx=item.item.index) elif index.column() == 2: value = from_qvariant(value, to_text_string) item.item.oturns = value self.mdl.setVariableOt(item.item.index, item.item.oturns) elif index.column() == 3: editable = from_qvariant(value, to_text_string) item.item.edit = editable self.mdl.setVariableEditable(item.item.index, item.item.edit) elif index.column() == 4: description = from_qvariant(value, to_text_string) item.item.descr = description self.mdl.setVariableDescription(item.item.index, item.item.descr) self.dataChanged.emit(QModelIndex(), QModelIndex()) return True
def setData(self, index, value, role): if not index.isValid(): return Qt.ItemIsEnabled # Update the row in the table row = index.row() col = index.column() # name if col == 0: old_pname = self._data[row][col] if self.mdl.getScalarType(old_pname) == 'var_model': return new_pname = str(from_qvariant(value, to_text_string)) self._data[row][col] = new_pname self.mdl.renameScalarLabel(old_pname, new_pname) # Variance (associated scalar name) elif col == 1: variance = str(from_qvariant(value, to_text_string)) self._data[row][col] = variance name = self._data[row][0] if self.mdl.getScalarType(name) == 'var_model': return self.mdl.setScalarVariance(name, variance) self.dataChanged.emit(index, index) return True
def setData(self, index, value, role): if not index.isValid(): return Qt.ItemIsEnabled # Update the row in the table row = index.row() col = index.column() # Name if col == 0: old_pname = self._data[row][col] if self.mdl.getScalarType(old_pname) == 'var_model': return new_pname = str(from_qvariant(value, to_text_string)) self._data[row][col] = new_pname self.mdl.renameScalarLabel(old_pname, new_pname) # GGDH elif col == 1: turbFlux = str(from_qvariant(value, to_text_string)) self._data[row][col] = turbFlux name = self._data[row][0] self.mdl.setTurbulentFluxModel(name, turbFlux) self.dataChanged.emit(index, index) return True
def setData(self, index, value, role): if not index.isValid(): return Qt.ItemIsEnabled # Update the row in the table row = index.row() col = index.column() name = row if col == 1: new_sup = from_qvariant(value, int) self._data[row][col] = new_sup self.mdl.setExtrudeLayer(name, new_sup) elif col == 2: new_sup = from_qvariant(value, float) self._data[row][col] = new_sup self.mdl.setExtrudeThickness(name, new_sup) elif col == 3: new_sup = from_qvariant(value, float) self._data[row][col] = new_sup self.mdl.setExtrudeReason(name, new_sup) elif col == 4: new_sup = from_qvariant(value, to_text_string) self._data[row][col] = new_sup self.mdl.setExtrudeSelector(name, new_sup) return True
def setModelData(self, editor, model, index): if editor.validator().state == QValidator.Acceptable: row = index.row() stype = index.model().getData(row, 2) if stype == 'time step': value = from_qvariant(editor.text(), int) else: value = from_qvariant(editor.text(), float) model.setData(index, value, Qt.DisplayRole)
def setData(self, index, value, role=None): item = index.internalPointer() if index.column() == 0: label = str(from_qvariant(value, to_text_string)) if label == "": label = item.label if item not in self.noderoot.values(): self.mdl.setVariableLabel(item.item.label, label) item.item.label = label elif index.column() >= 2: c_id = index.column() - 2 v = from_qvariant(value, int) if v == Qt.Checked: item.item.status[c_id] = "on" else: item.item.status[c_id] = "off" if c_id == 1: if not OutputControlModel(self.case).isVolumeWriterActive(): item.item.status[1] = "off" if item not in self.noderoot.values(): if c_id == 0: self.mdl.setPrintingStatus(item.item.name, item.item.status[0]) elif c_id == 1: self.mdl.setPostStatus(item.item.name, item.item.status[1]) elif c_id == 2: self.mdl.setMonitorStatus(item.item.name, item.item.status[2]) # count for parent item size = len(item.parentItem.childItems) active = 0 for itm in item.parentItem.childItems: if itm.item.status[c_id] == "on": active = active + 1 if active == 0: item.parentItem.item.status[c_id] = "off" elif active == size: item.parentItem.item.status[c_id] = "on" else: item.parentItem.item.status[c_id] = "onoff" else: for itm in item.childItems: if c_id == 0: self.mdl.setPrintingStatus(itm.item.name, item.item.status[0]) elif c_id == 1: self.mdl.setPostStatus(itm.item.name, item.item.status[1]) elif c_id == 2: self.mdl.setMonitorStatus(itm.item.name, item.item.status[2]) itm.item.status[c_id] = item.item.status[c_id]
def setModelData(self, editor, model, index): if editor.validator().state == QValidator.Acceptable: if index.column() == 3 or index.column() == 5: value = from_qvariant(editor.text(), float) elif (index.column() == 2 or index.column() == 4): value = from_qvariant(editor.text(), int) selectionModel = self.parent.selectionModel() for idx in selectionModel.selectedIndexes(): if idx.column() == index.column(): model.setData(idx, value)
def setData(self, index, value, role): row = index.row() col = index.column() if col == 0: new_code = from_qvariant(value, int) self._data[row][col] = new_code elif col == 1: criteria = from_qvariant(value, to_text_string) self._data[row][col] = criteria self.mdl.setPressureDropCriteria(row, criteria) self.dataChanged.emit(index, index) return True
def setData(self, index, value, role): if not index.isValid(): return Qt.ItemIsEnabled # Update the row in the table row = index.row() col = index.column() # Label (nothing to do for the species label) if col == 0: pass # Chemical formula elif col == 1: ChemicalFormula = str(from_qvariant(value, to_text_string)) self._data[row][col] = ChemicalFormula label = self._data[row][0] self.mdl.setSpeciesChemicalFormula(label, ChemicalFormula) # Fuel Composition elif col == 2: CompFuel = str(from_qvariant(value, to_text_string)) self._data[row][col] = CompFuel label = self._data[row][0] self.mdl.setCompFuel(label, CompFuel) # Oxi Composition elif col == 3: CompOxi = str(from_qvariant(value, to_text_string)) self._data[row][col] = CompOxi label = self._data[row][0] self.mdl.setCompOxi(label, CompOxi) # Product Composition elif col == 4: CompProd = str(from_qvariant(value, to_text_string)) self._data[row][col] = CompProd label = self._data[row][0] self.mdl.setCompProd(label, CompProd) # Coeff absorption elif col == 5: CoeffAbsorp = str(from_qvariant(value, to_text_string)) self._data[row][col] = CoeffAbsorp label = self._data[row][0] self.mdl.setCoeffAbsorp(label, CoeffAbsorp) self.dataChanged.emit(index, index) return True
def setData(self, index, value, role): if not index.isValid(): return Qt.ItemIsEnabled row = index.row() col = index.column() FieldId = row + 1 # turbulence model if col == 2: new_pmodel = from_qvariant(value, to_text_string) self._data[row][col] = new_pmodel self.mdl.setTurbulenceModel(FieldId, self.dicoV2M[new_pmodel]) # Security check for models which cannot have a formula on inlet! if new_pmodel in ['mixing length', 'Tchen', 'R2-R12 Tchen']: from code_saturne.model.LocalizationModel import LocalizationModel from code_saturne.model.BoundaryNeptune import Boundary blm = LocalizationModel('BoundaryZone', self.case) for zone in blm.getZones(): if "inlet" in zone.getNature(): boundary = Boundary(zone.getNature(), zone.getLabel(), self.case, FieldId) tc = boundary.getTurbulenceChoice(FieldId) if tc == "formula": boundary.setTurbulenceChoice( FieldId, "hydraulic_diameter") self.updateItem() # Turbulent thermal fluxes (for continuous phases) elif col == 3: new_pmodel = from_qvariant(value, to_text_string) self._data[row][col] = new_pmodel self.mdl.setThermalTurbulentFlux(FieldId, self.dicoV2M[new_pmodel]) self.updateItem() # two way coupling elif col == 4: new_pmodel = from_qvariant(value, to_text_string) self._data[row][col] = new_pmodel self.mdl.setTwoWayCouplingModel(FieldId, self.dicoV2M[new_pmodel]) self.updateItem() self.dataChanged.emit(index, index) return True
def slotStopCritValue(self, text): """ Input stop criterion """ if self.lineEditStop.validator().state == QValidator.Acceptable: model, c_prev = self.mdl.getStopCriterion() value = c_prev if model in ("iterations", "iterations_add"): value = from_qvariant(text, int) self.mdl.setStopCriterion(model, value) elif model in ("maximum_time", "maximum_time_add"): value = from_qvariant(text, float) self.mdl.setStopCriterion(model, value)
def setData(self, index, value, role): row = index.row() col = index.column() if col == 0: vel = from_qvariant(value, float) self._data[row][col] = vel self.mdl.setRotorVelocity(row, vel) elif col == 1: criteria = from_qvariant(value, to_text_string) self._data[row][col] = criteria self.mdl.setRotorCriteria(row, criteria) self.dataChanged.emit(index, index) return True
def setData(self, index, value, role): if not index.isValid(): return Qt.ItemIsEnabled # Update the row in the table row = index.row() col = index.column() name = self._data[row][0] new_val = from_qvariant(value, to_text_string) # Name if col == 0: self.mdl.setUsersName(name, new_val) self._data[row][col] = new_val # location elif col == 1: self.mdl.setUsersLocation(name, new_val) self._data[row][col] = new_val # dimension elif col == 2: self.mdl.setUsersDim(name, new_val) self._data[row][col] = new_val return True
def __slotDirZ(self, text): """ INPUT value into direction of inlet flow """ if self.sender().validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setDirection('direction_z', value)
def setData(self, index, value, role): if not hasattr(self, "modelBoundary"): log.debug( "ERROR in setData (StandardItemModelCoalMass): no Boundary model defined" ) return classe = index.row() coal = index.column() if not value: return False v = from_qvariant(value, float) self.ratio[coal][classe] = v log.debug("setData v = %f " % v) lst = self.modelBoundary.getCoalRatios(coal) lastValue = 0 for iclasse in range(0, self.coalClassesNumber[coal] - 1): lastValue += self.ratio[coal][iclasse] if lastValue < 100. + 1e-6: lst[classe] = self.ratio[coal][classe] lastValue = 100 - lastValue self.ratio[coal][self.coalClassesNumber[coal] - 1] = lastValue lst[self.coalClassesNumber[coal] - 1] = lastValue self.modelBoundary.setCoalRatios(coal, lst) else: self.ratio[coal][classe] = lst[classe] self.dataChanged.emit(index, index) return True
def slotNSTITS(self, text): """ Input NSTITS. """ if self.lineEditNSTITS.validator().state == QValidator.Acceptable: value = from_qvariant(text, int) self.model.set2WayCouplingStartIteration(value)
def __slotLines(self, text): """ Private slot. Manage the number of lines allowed in the display zone. """ lines = from_qvariant(text, int) if self.sender().validator().state == QValidator.Acceptable: self.lines = lines
def slotIDPT(self, text): """ Input IDPT. """ if self.lineEditIDPT.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.model.setDiameterValue(self.zone.getLabel(), self.iset, value)
def slotTimeOptionVARRDT(self, text): """ Input VARRDT. """ if self.lineEditVARRDT.validator().state == QValidator.Acceptable: time_step_var = from_qvariant(text, float) self.mdl.setOptions('time_step_var', time_step_var)
def slotTimeOptionCDTMAX(self, text): """ Input CDTMAX. """ if self.lineEditCDTMAX.validator().state == QValidator.Acceptable: time_step_max_factor = from_qvariant(text, float) self.mdl.setOptions('time_step_max_factor', time_step_max_factor)
def setData(self, index, value, role=None): if not index.isValid(): return Qt.ItemIsEnabled row = index.row() name = self._data[row]['name'] if index.column() == 1: self._data[row]['scamin'] = from_qvariant(value, float) self.NPE.setMinValue(name, self._data[row]['scamin']) elif index.column() == 2: self._data[row]['scamax'] = from_qvariant(value, float) self.NPE.setMaxValue(name, self._data[row]['scamax']) self.dataChanged.emit(index, index) return True
def __slotPressure(self, text): """ INPUT fraction value """ if self.lineEditPressure.validator().state == QValidator.Acceptable: value = from_qvariant(text, float) self.__boundary.setReferencePressure(value)
def slotTimeOptionFOUMAX(self, text): """ Input FOUMAX. """ if self.lineEditFOUMAX.validator().state == QValidator.Acceptable: fourier_max = from_qvariant(text, float) self.mdl.setOptions('max_fourier_num', fourier_max)
def slotPressureValue(self, text): """ INPUT outlet pressure """ if self.sender().validator().state == QValidator.Acceptable: t = from_qvariant(text, float) self.__boundary.setPressureValue(t)