[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 |
---|
[5129686] | 25 | self.xvalue = wx.ComboBox(self, -1, style=wx.CB_READONLY) |
---|
[a9d5684] | 26 | x_size += self.xvalue.GetSize()[0] |
---|
[5129686] | 27 | sizer.Add(self.xvalue, (iy, ix), (1, 1), wx.ADJUST_MINSIZE, 0) |
---|
[3477478] | 28 | |
---|
[a9d5684] | 29 | ix += 2 |
---|
[5129686] | 30 | self.yvalue = wx.ComboBox(self, -1, style=wx.CB_READONLY) |
---|
[a9d5684] | 31 | x_size += self.yvalue.GetSize()[0] |
---|
[5129686] | 32 | sizer.Add(self.yvalue, (iy, ix), (1, 1), wx.ADJUST_MINSIZE, 0) |
---|
[3477478] | 33 | |
---|
[a9d5684] | 34 | ix += 2 |
---|
[5129686] | 35 | self.view = wx.ComboBox(self, -1, style=wx.CB_READONLY) |
---|
| 36 | self.view.Bind(wx.EVT_COMBOBOX, self.viewChanged) |
---|
[a9d5684] | 37 | x_size += self.view.GetSize()[0] |
---|
| 38 | self.view.SetMinSize((160, 30)) |
---|
[3477478] | 39 | sizer.Add(self.view, (iy, ix), (1, 1), |
---|
| 40 | wx.EXPAND | wx.RIGHT | wx.ADJUST_MINSIZE, 10) |
---|
[a9d5684] | 41 | self.SetMinSize((x_size, 50)) |
---|
[3477478] | 42 | vbox.Add(sizer, 0, wx.EXPAND | wx.ADJUST_MINSIZE, 0) |
---|
| 43 | |
---|
| 44 | cancel_button = wx.Button(self, wx.ID_CANCEL, 'Cancel') |
---|
| 45 | ok_button = wx.Button(self, wx.ID_OK, "OK") |
---|
[a9d5684] | 46 | sizer_button = wx.BoxSizer(wx.HORIZONTAL) |
---|
[3477478] | 47 | sizer_button.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0) |
---|
| 48 | sizer_button.Add(ok_button, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) |
---|
| 49 | sizer_button.Add(cancel_button, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) |
---|
[a9d5684] | 50 | vbox.Add(sizer_button, 0, |
---|
[3477478] | 51 | wx.EXPAND | wx.TOP | wx.BOTTOM | wx.ADJUST_MINSIZE, 10) |
---|
[a9d5684] | 52 | # scale value for x |
---|
| 53 | self.xvalue.SetValue("ln(x)") |
---|
| 54 | self.xvalue.Insert("x", 0) |
---|
| 55 | self.xvalue.Insert("x^(2)", 1) |
---|
| 56 | self.xvalue.Insert("x^(4)", 2) |
---|
| 57 | self.xvalue.Insert("ln(x)", 3) |
---|
| 58 | self.xvalue.Insert("log10(x)", 4) |
---|
| 59 | self.xvalue.Insert("log10(x^(4))", 5) |
---|
[3477478] | 60 | |
---|
[a9d5684] | 61 | # scale value for y |
---|
| 62 | self.yvalue.SetValue("ln(y)") |
---|
| 63 | self.yvalue.Insert("y", 0) |
---|
| 64 | self.yvalue.Insert("1/y", 1) |
---|
| 65 | self.yvalue.Insert("ln(y)", 2) |
---|
| 66 | self.yvalue.Insert("y^(2)", 3) |
---|
[09d6719] | 67 | self.yvalue.Insert("y*x^(2)", 4) |
---|
| 68 | self.yvalue.Insert("y*x^(4)", 5) |
---|
| 69 | self.yvalue.Insert("1/sqrt(y)", 6) |
---|
| 70 | self.yvalue.Insert("log10(y)", 7) |
---|
| 71 | self.yvalue.Insert("ln(y*x)", 8) |
---|
| 72 | self.yvalue.Insert("ln(y*x^(2))", 9) |
---|
| 73 | self.yvalue.Insert("ln(y*x^(4))", 10) |
---|
| 74 | self.yvalue.Insert("log10(y*x^(4))", 11) |
---|
[a9d5684] | 75 | # type of view or model used |
---|
| 76 | self.view.SetValue("--") |
---|
| 77 | self.view.Insert("--", 0) |
---|
| 78 | self.view.Insert("Linear y vs x", 1) |
---|
| 79 | self.view.Insert("Guinier lny vs x^(2)", 2) |
---|
| 80 | self.view.Insert("XS Guinier ln(y*x) vs x^(2)", 3) |
---|
| 81 | self.view.Insert("Porod y*x^(4) vs x^(4)", 4) |
---|
[09d6719] | 82 | self.view.Insert("Kratky y*x^(2) vs x", 5) |
---|
[a9d5684] | 83 | self.SetSizer(vbox) |
---|
| 84 | self.Fit() |
---|
| 85 | self.Centre() |
---|
[3477478] | 86 | |
---|
[5129686] | 87 | def viewChanged(self, event): |
---|
| 88 | event.Skip() |
---|
| 89 | view = self.view.GetValue() |
---|
| 90 | if view == "Linear y vs x": |
---|
| 91 | self.xvalue.SetValue("x") |
---|
| 92 | self.yvalue.SetValue("y") |
---|
| 93 | elif view == "Guinier lny vs x^(2)": |
---|
| 94 | self.xvalue.SetValue("x^(2)") |
---|
| 95 | self.yvalue.SetValue("ln(y)") |
---|
| 96 | elif view == "XS Guinier ln(y*x) vs x^(2)": |
---|
| 97 | self.xvalue.SetValue("x^(2)") |
---|
| 98 | self.yvalue.SetValue("ln(y*x)") |
---|
| 99 | elif view == "Porod y*x^(4) vs x^(4)": |
---|
| 100 | self.xvalue.SetValue("x^(4)") |
---|
| 101 | self.yvalue.SetValue("y*x^(4)") |
---|
| 102 | elif view == "Kratky y*x^(2) vs x": |
---|
| 103 | self.xvalue.SetValue("x") |
---|
| 104 | self.yvalue.SetValue("y*x^(2)") |
---|
| 105 | |
---|
[a9d5684] | 106 | def setValues(self, x, y, view): |
---|
| 107 | """ |
---|
| 108 | """ |
---|
[3477478] | 109 | return self.xvalue.SetValue(x), self.yvalue.SetValue(y), \ |
---|
[a9d5684] | 110 | self.view.SetValue(view) |
---|
[3477478] | 111 | |
---|
[a9d5684] | 112 | def getValues(self): |
---|
| 113 | """ |
---|
| 114 | """ |
---|
[3477478] | 115 | return self.xvalue.GetValue(), self.yvalue.GetValue(), \ |
---|
[a9d5684] | 116 | self.view.GetValue() |
---|