[a9d5684] | 1 | """ |
---|
| 2 | """ |
---|
| 3 | import wx |
---|
| 4 | |
---|
| 5 | class Properties(wx.Dialog): |
---|
| 6 | """ |
---|
| 7 | """ |
---|
| 8 | def __init__(self, parent, id=-1, title="Select the scale of the graph"): |
---|
| 9 | wx.Dialog.__init__(self, parent, id, title) |
---|
| 10 | self.parent = parent |
---|
| 11 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
[3477478] | 12 | sizer = wx.GridBagSizer(5, 5) |
---|
[a9d5684] | 13 | |
---|
| 14 | x_size = 70 |
---|
| 15 | |
---|
| 16 | ix = 1 |
---|
| 17 | iy = 1 |
---|
| 18 | sizer.Add(wx.StaticText(self, -1, 'X'), (iy, ix)) |
---|
| 19 | ix += 2 |
---|
| 20 | sizer.Add(wx.StaticText(self, -1, 'Y'), (iy, ix)) |
---|
| 21 | ix += 2 |
---|
| 22 | sizer.Add(wx.StaticText(self, -1, 'View'), (iy, ix)) |
---|
| 23 | iy += 1 |
---|
| 24 | ix = 1 |
---|
| 25 | self.xvalue = wx.ComboBox(self, -1) |
---|
| 26 | x_size += self.xvalue.GetSize()[0] |
---|
[3477478] | 27 | sizer.Add(self.xvalue, (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) |
---|
| 28 | |
---|
[a9d5684] | 29 | ix += 2 |
---|
| 30 | self.yvalue = wx.ComboBox(self, -1) |
---|
| 31 | x_size += self.yvalue.GetSize()[0] |
---|
[3477478] | 32 | sizer.Add(self.yvalue, (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0) |
---|
| 33 | |
---|
[a9d5684] | 34 | ix += 2 |
---|
| 35 | self.view = wx.ComboBox(self, -1) |
---|
| 36 | x_size += self.view.GetSize()[0] |
---|
| 37 | self.view.SetMinSize((160, 30)) |
---|
[3477478] | 38 | sizer.Add(self.view, (iy, ix), (1, 1), |
---|
| 39 | wx.EXPAND | wx.RIGHT | wx.ADJUST_MINSIZE, 10) |
---|
[a9d5684] | 40 | self.SetMinSize((x_size, 50)) |
---|
[3477478] | 41 | vbox.Add(sizer, 0, wx.EXPAND | wx.ADJUST_MINSIZE, 0) |
---|
| 42 | |
---|
| 43 | cancel_button = wx.Button(self, wx.ID_CANCEL, 'Cancel') |
---|
| 44 | ok_button = wx.Button(self, wx.ID_OK, "OK") |
---|
[a9d5684] | 45 | sizer_button = wx.BoxSizer(wx.HORIZONTAL) |
---|
[3477478] | 46 | sizer_button.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0) |
---|
| 47 | sizer_button.Add(ok_button, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) |
---|
| 48 | sizer_button.Add(cancel_button, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) |
---|
[a9d5684] | 49 | vbox.Add(sizer_button, 0, |
---|
[3477478] | 50 | wx.EXPAND | wx.TOP | wx.BOTTOM | wx.ADJUST_MINSIZE, 10) |
---|
[a9d5684] | 51 | # scale value for x |
---|
| 52 | self.xvalue.SetValue("ln(x)") |
---|
| 53 | self.xvalue.Insert("x", 0) |
---|
| 54 | self.xvalue.Insert("x^(2)", 1) |
---|
| 55 | self.xvalue.Insert("x^(4)", 2) |
---|
| 56 | self.xvalue.Insert("ln(x)", 3) |
---|
| 57 | self.xvalue.Insert("log10(x)", 4) |
---|
| 58 | self.xvalue.Insert("log10(x^(4))", 5) |
---|
[3477478] | 59 | |
---|
[a9d5684] | 60 | # scale value for y |
---|
| 61 | self.yvalue.SetValue("ln(y)") |
---|
| 62 | self.yvalue.Insert("y", 0) |
---|
| 63 | self.yvalue.Insert("1/y", 1) |
---|
| 64 | self.yvalue.Insert("ln(y)", 2) |
---|
| 65 | self.yvalue.Insert("y^(2)", 3) |
---|
| 66 | self.yvalue.Insert("y*x^(4)", 4) |
---|
| 67 | self.yvalue.Insert("1/sqrt(y)", 5) |
---|
| 68 | self.yvalue.Insert("log10(y)", 6) |
---|
| 69 | self.yvalue.Insert("ln(y*x)", 7) |
---|
| 70 | self.yvalue.Insert("ln(y*x^(2))", 8) |
---|
| 71 | self.yvalue.Insert("ln(y*x^(4))", 9) |
---|
| 72 | self.yvalue.Insert("log10(y*x^(4))", 10) |
---|
| 73 | # type of view or model used |
---|
| 74 | self.view.SetValue("--") |
---|
| 75 | self.view.Insert("--", 0) |
---|
| 76 | self.view.Insert("Linear y vs x", 1) |
---|
| 77 | self.view.Insert("Guinier lny vs x^(2)", 2) |
---|
| 78 | self.view.Insert("XS Guinier ln(y*x) vs x^(2)", 3) |
---|
| 79 | self.view.Insert("Porod y*x^(4) vs x^(4)", 4) |
---|
[3409a90] | 80 | # This did not work in 3.1.2 and does not work now. |
---|
| 81 | # prefer to fix (should not be too hard) but for the moment |
---|
| 82 | # am removing as an option the user sees so they don't get |
---|
| 83 | # disappointed. PDB 7/10/2016 |
---|
| 84 | # self.view.Insert("Kratky y*x^(2) vs x", 5) |
---|
[a9d5684] | 85 | self.SetSizer(vbox) |
---|
| 86 | self.Fit() |
---|
| 87 | self.Centre() |
---|
[3477478] | 88 | |
---|
[a9d5684] | 89 | def setValues(self, x, y, view): |
---|
| 90 | """ |
---|
| 91 | """ |
---|
[3477478] | 92 | return self.xvalue.SetValue(x), self.yvalue.SetValue(y), \ |
---|
[a9d5684] | 93 | self.view.SetValue(view) |
---|
[3477478] | 94 | |
---|
[a9d5684] | 95 | def getValues(self): |
---|
| 96 | """ |
---|
| 97 | """ |
---|
[3477478] | 98 | return self.xvalue.GetValue(), self.yvalue.GetValue(), \ |
---|
[a9d5684] | 99 | self.view.GetValue() |
---|