Skip to content

Commit 18e9fba

Browse files
committed
[processing] remember min/max value in number params in modeler
1 parent da5766c commit 18e9fba

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

python/plugins/processing/modeler/ModelerParameterDefinitionDialog.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
***************************************************************************
1818
"""
1919

20+
2021
__author__ = 'Victor Olaya'
2122
__date__ = 'August 2012'
2223
__copyright__ = '(C) 2012, Victor Olaya'
@@ -25,6 +26,8 @@
2526

2627
__revision__ = '$Format:%H$'
2728

29+
import math
30+
2831
from PyQt4.QtCore import *
2932
from PyQt4.QtGui import *
3033

@@ -203,14 +206,20 @@ def setupUi(self):
203206
self.horizontalLayout2.addWidget(QLabel(self.tr('Min/Max values')))
204207
self.minTextBox = QLineEdit()
205208
self.maxTextBox = QLineEdit()
209+
if self.param is not None:
210+
self.minTextBox.setText(str(self.param.min))
211+
self.maxTextBox.setText(str(self.param.max))
206212
self.horizontalLayout2.addWidget(self.minTextBox)
207213
self.horizontalLayout2.addWidget(self.maxTextBox)
208214
self.verticalLayout.addLayout(self.horizontalLayout2)
209215
self.horizontalLayout3.addWidget(QLabel(self.tr('Default value')))
210216
self.defaultTextBox = QLineEdit()
211217
self.defaultTextBox.setText(self.tr('0'))
212218
if self.param is not None:
213-
self.defaultTextBox.setText(str(self.param.default))
219+
default = self.param.default
220+
if self.param.isInteger:
221+
default = int(math.floor(default))
222+
self.defaultTextBox.setText(str(default))
214223
self.horizontalLayout3.addWidget(self.defaultTextBox)
215224
self.verticalLayout.addLayout(self.horizontalLayout3)
216225
elif self.paramType \
@@ -312,7 +321,7 @@ def okPressed(self):
312321
else:
313322
vmax = float(vmax)
314323
self.param = ParameterNumber(name, description, vmin, vmax,
315-
float(str(self.defaultTextBox.text())))
324+
str(self.defaultTextBox.text()))
316325
except:
317326
QMessageBox.warning(self, self.tr('Unable to define parameter'),
318327
self.tr('Wrong or missing parameter values'))

0 commit comments

Comments
 (0)