Changeset d0cc0bbc in sasview
- Timestamp:
- Apr 5, 2010 2:57:26 PM (15 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 46dda00
- Parents:
- c7c5ef8
- Location:
- invariantview/perspectives/invariant
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
invariantview/perspectives/invariant/invariant_details.py
r277fad8 rd0cc0bbc 9 9 RECTANGLE_WIDTH = 400.0 10 10 RECTANGLE_HEIGHT = 20 11 RECTANGLE_SCALE = 0.000112 DEFAULT_QSTAR = 1.013 11 #Invariant panel size 14 12 _BOX_WIDTH = 76 15 _BOX_PERCENT_WIDTH = 100 13 14 #scale to use for a bar of value zero 15 RECTANGLE_SCALE = 0.0001 16 DEFAULT_QSTAR = 1.0 16 17 17 18 if sys.platform.count("win32")>0: 18 19 _STATICBOX_WIDTH = 450 19 20 PANEL_WIDTH = 500 20 PANEL_HEIGHT = 70021 PANEL_HEIGHT = 430 21 22 FONT_VARIANT = 0 22 23 else: 23 24 _STATICBOX_WIDTH = 480 24 25 PANEL_WIDTH = 530 25 PANEL_HEIGHT = 70026 PANEL_HEIGHT = 430 26 27 FONT_VARIANT = 1 27 28 29 28 30 31 class InvariantContainer(wx.Object): 32 def __init__(self): 33 #invariant at low range 34 self.qstar_low = 0.0 35 #invariant at low range error 36 self.qstar_low_err = 0.0 37 #invariant 38 self.qstar = 0.0 39 #invariant error 40 self.qstar_err = 0.0 41 #invariant at high range 42 self.qstar_high = 0.0 43 #invariant at high range error 44 self.qstar_high_err = 0.0 45 #invariant total 46 self.qstar_total = None 47 #invariant error 48 self.qstar_total_err = None 49 #scale 50 self.qstar_low_percent = 0.0 51 self.qstar_high_percent = 0.0 52 self.qstar_percent = 0.0 53 # warning message 54 self.existing_warning = False 55 self.warning_msg = "No Details on calculations available...\n" 56 57 def compute_percentage(self): 58 """ 59 Compute percentage of each invariant 60 """ 61 if self.qstar_total is not None and self.qstar_total != 0: 62 #compute invariant percentage 63 if self.qstar is None: 64 self.qstar = 0.0 65 self.qstar_percent = self.qstar/self.qstar_total 66 #compute low q invariant percentage 67 if self.qstar_low is None: 68 self.qstar_low = 0.0 69 self.qstar_low_percent = self.qstar_low/self.qstar_total 70 #compute high q invariant percentage 71 if self.qstar_high is None: 72 self.qstar_high = 0.0 73 self.qstar_high_percent = self.qstar_high/self.qstar_total 74 self.check_values() 75 76 def check_values(self): 77 """ 78 check the validity if invariant 79 """ 80 #warning to the user when the extrapolated invariant is greater than %5 81 if self.qstar_low_percent >= 0.05: 82 self.existing_warning = True 83 self.warning_msg += "Extrapolated contribution at Low Q is higher " 84 self.warning_msg += "than 5% of the invariant.\n" 85 if self.qstar_high_percent >= 0.05: 86 self.existing_warning = True 87 self.warning_msg += "Extrapolated contribution at High Q is higher " 88 self.warning_msg += "than 5% of the invariant.\n" 89 if self.qstar_low_percent + self.qstar_high_percent >= 0.05: 90 self.existing_warning = True 91 self.warning_msg += "The sum of all extrapolated contributions is higher " 92 self.warning_msg += "than 5% of the invariant.\n" 93 94 if self.existing_warning: 95 self.warning_msg += "The calculations are likely to be unreliable!\n" 96 else: 97 self.warning_msg = "No Details on calculations available...\n" 98 29 99 class InvariantDetailsPanel(wx.Dialog): 30 100 """ … … 32 102 """ 33 103 def __init__(self, parent=None, id=-1, qstar_container=None, title="", 34 size=(PANEL_WIDTH, 450)):104 size=(PANEL_WIDTH, PANEL_HEIGHT)): 35 105 wx.Dialog.__init__(self, parent, id=id, title=title, size=size) 36 106 37 107 #Font size 38 108 self.SetWindowVariant(variant=FONT_VARIANT) … … 40 110 #self.qstar_container 41 111 self.qstar_container = qstar_container 42 self.compute_scale()43 112 #warning message 44 self.warning_msg = "" 113 self.warning_msg = self.qstar_container.warning_msg 114 45 115 #Define scale of each bar 46 low_inv_scale = self.qstar_container.qstar_low_scale 47 self.low_scale = self.check_scale(scale=low_inv_scale, scale_name="Low") 48 inv_scale = self.qstar_container.qstar_scale 49 self.inv_scale = self.check_scale(scale=inv_scale, scale_name="Inv") 50 high_inv_scale = self.qstar_container.qstar_high_scale 51 self.high_scale = self.check_scale(scale=high_inv_scale, scale_name="High") 116 self.low_inv_percent = self.qstar_container.qstar_low_percent 117 self.low_scale = self.get_scale(percentage=self.low_inv_percent, 118 scale_name="Extrapolated at Low Q") 119 self.inv_percent = self.qstar_container.qstar_percent 120 self.inv_scale = self.get_scale(percentage=self.inv_percent, 121 scale_name="Inv in Q range") 122 self.high_inv_percent = self.qstar_container.qstar_high_percent 123 self.high_scale = self.get_scale(percentage=self.high_inv_percent, 124 scale_name="Extrapolated at High Q") 125 52 126 #Default color the extrapolation bar is grey 53 127 self.extrapolation_color_low = wx.Colour(169, 169, 168, 128) … … 58 132 self._do_layout() 59 133 self.set_values() 60 134 61 135 def _define_structure(self): 62 136 """ … … 68 142 chart_box = wx.StaticBox(self, -1, "Invariant Chart") 69 143 self.chart_sizer = wx.StaticBoxSizer(chart_box, wx.VERTICAL) 70 self.chart_sizer.SetMinSize((PANEL_WIDTH - 50, -1))144 self.chart_sizer.SetMinSize((PANEL_WIDTH - 50,100)) 71 145 #Sizer related to invariant values 72 146 self.invariant_sizer = wx.GridBagSizer(4, 4) 147 invariant_box = wx.StaticBox(self, -1, "Numerical Values") 148 self.invariant_box_sizer = wx.StaticBoxSizer(invariant_box, 149 wx.HORIZONTAL) 150 151 self.invariant_box_sizer.SetMinSize((PANEL_WIDTH - 50,-1)) 73 152 #Sizer related to warning message 74 153 warning_box = wx.StaticBox(self, -1, "Warning") … … 91 170 """ 92 171 uncertainty = "+/-" 93 unit_invariant = '[1/ cm 1/A]'172 unit_invariant = '[1/(cm * A)]' 94 173 95 174 invariant_txt = wx.StaticText(self, -1, 'Invariant') … … 115 194 116 195 #Invariant low 117 iy = 1196 iy = 0 118 197 ix = 0 119 198 self.invariant_sizer.Add(invariant_low_txt, (iy, ix), (1,1), … … 164 243 ix += 1 165 244 self.invariant_sizer.Add(invariant_high_units_txt 166 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 245 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 246 self.invariant_box_sizer.Add(self.invariant_sizer, 0, wx.TOP|wx.BOTTOM, 10) 167 247 168 248 def _layout_warning(self): … … 172 252 #Warning [string] 173 253 self.warning_msg_txt = wx.StaticText(self, -1,self.warning_msg) 174 self.warning_msg_txt.SetForegroundColour('red') 254 if self.qstar_container.existing_warning: 255 self.warning_msg_txt.SetForegroundColour('red') 175 256 self.warning_sizer.AddMany([(self.warning_msg_txt, 0, 176 257 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10)]) … … 196 277 self._layout_warning() 197 278 self._layout_button() 198 self.main_sizer.AddMany([(self.chart_sizer, 1, wx.ALL, 10),199 ( self.invariant_sizer, 0, wx.ALL, 10),279 self.main_sizer.AddMany([(self.chart_sizer, 0, wx.ALL, 10), 280 ( self.invariant_box_sizer, 0, wx.ALL, 10), 200 281 (self.warning_sizer, 0, wx.ALL, 10), 201 282 (self.button_sizer, 0, wx.ALL, 10)]) … … 213 294 self.invariant_high_tcl.SetValue(format_number(self.qstar_container.qstar_high)) 214 295 self.invariant_high_err_tcl.SetValue(format_number(self.qstar_container.qstar_high_err)) 215 216 def compute_scale(self): 217 """ 218 Compute scale 219 """ 220 qstar_total = self.qstar_container.qstar_total 221 if qstar_total is None: 222 qstar_total = DEFAULT_QSTAR 223 #compute the percentage of invariant 224 inv = self.qstar_container.qstar 225 if inv is None: 226 inv = 0.0 227 inv_scale = inv/qstar_total 228 self.qstar_container.qstar_scale = inv_scale 229 #compute the percentage of low q invariant 230 inv_low = self.qstar_container.qstar_low 231 if inv_low is None: 232 inv_low = 0.0 233 inv_scale = inv_low/qstar_total 234 self.qstar_container.qstar_low_scale = inv_scale 235 #compute the percentage of high q invariant 236 inv_high = self.qstar_container.qstar_high 237 if inv_high is None: 238 inv_high = 0.0 239 inv_scale = inv_high/qstar_total 240 self.qstar_container.qstar_high_scale = inv_scale 241 242 def check_scale(self, scale, scale_name='scale'): 243 """ 244 Check scale receive in this panel. i 296 297 def get_scale(self, percentage, scale_name='scale'): 298 """ 299 Check scale receive in this panel. 245 300 """ 246 301 try: 247 if scale is None: 248 scale = 0.0 249 scale = float(scale) 250 if scale == 0.0: 251 scale = RECTANGLE_SCALE 302 if percentage is None or percentage == 0.0: 303 percentage = RECTANGLE_SCALE 304 percentage = float(percentage) 252 305 except: 253 scale = RECTANGLE_SCALE306 percentage = RECTANGLE_SCALE 254 307 self.warning_msg += "Receive an invalid scale for %s\n" 255 self.warning_msg += "check this value : %s\n"%(str(scale_name),str( scale))256 return scale308 self.warning_msg += "check this value : %s\n"%(str(scale_name),str(percentage)) 309 return percentage 257 310 258 311 def set_color_bar(self): … … 263 316 if self.low_scale >= 0.05: 264 317 self.extrapolation_color_low = wx.Colour(255, 0, 0, 128) 265 self.warning_msg += "The value of invariant extrapolated at \n"266 self.warning_msg += "low q range is %s percent \n"%(str(self.low_scale*100))267 318 if self.high_scale >= 0.05: 268 319 self.extrapolation_color_high = wx.Colour(255, 0, 0, 128) 269 self.warning_msg += "The value of invariant extrapolated at \n" 270 self.warning_msg += "high q range is %s percent \n"%(str(self.high_scale*100)) 271 320 272 321 def on_close(self, event): 273 322 """ … … 295 344 path.AddRectangle(-RECTANGLE_WIDTH/2,-RECTANGLE_HEIGHT/2, 296 345 RECTANGLE_WIDTH/2,RECTANGLE_HEIGHT/2) 297 x_origine = 50346 x_origine = 20 298 347 y_origine = 15 299 348 #Draw low rectangle 300 349 gc.PushState() 301 label = " Low"350 label = "Q* At Low-Q" 302 351 PathFunc = gc.DrawPath 303 352 w, h = gc.GetTextExtent(label) … … 309 358 gc.SetPen(wx.Pen("black", 1)) 310 359 gc.SetBrush(wx.Brush(self.extrapolation_color_low)) 360 low_percent = format_number(self.low_inv_percent*100)+ '%' 361 x_center = 20 362 y_center = -h 363 gc.DrawText(low_percent, x_center, y_center) 311 364 # Increase width by self.low_scale 312 365 gc.Scale(self.low_scale, 1.0) … … 316 369 gc.PushState() # save it again 317 370 y_origine += 20 318 gc.DrawText(" Inv", x_origine, y_origine)371 gc.DrawText("Q* In range", x_origine, y_origine) 319 372 # offset to the lower part of the window 320 373 x_center = x_origine + RECTANGLE_WIDTH * self.inv_scale/2 + w + 10 … … 324 377 gc.SetBrush(wx.Brush(wx.Colour(67, 208, 128, 128))) 325 378 # Increase width by self.inv_scale 379 inv_percent = format_number(self.inv_percent*100)+ '%' 380 x_center = 20 381 y_center = -h 382 gc.DrawText(inv_percent, x_center, y_center) 326 383 gc.Scale(self.inv_scale, 1.0) 327 384 gc.DrawPath(path) … … 331 388 gc.PushState() 332 389 y_origine += 20 333 gc.DrawText(" High", x_origine, y_origine)390 gc.DrawText("Q* At High-Q", x_origine, y_origine) 334 391 #define the position of the new rectangle 335 392 x_center = x_origine + RECTANGLE_WIDTH * self.high_scale/2 + w + 10 … … 338 395 gc.SetBrush(wx.Brush(self.extrapolation_color_high)) 339 396 # increase scale by self.high_scale 397 high_percent = format_number(self.high_inv_percent*100)+ '%' 398 x_center = 20 399 y_center = -h 400 gc.DrawText(high_percent, x_center, y_center) 401 340 402 gc.Scale(self.high_scale, 1.0) 341 403 gc.DrawPath(path) … … 348 410 self.container = qstar_container 349 411 if self.container is None: 350 from invariant_panel import InvariantContainer351 412 self.container = InvariantContainer() 352 self.container.qstar_total = 1 413 self.container.qstar_total = 1.0 353 414 self.container.qstar = 0.75 354 415 self.container.qstar_low = 0.60 … … 362 423 class InvariantDetailsTest(wx.Frame): 363 424 def __init__(self, parent, qstar_container=None, *args, **kwds): 364 kwds["size"]= (PANEL_WIDTH , 450)425 kwds["size"]= (PANEL_WIDTH , PANEL_HEIGHT) 365 426 wx.Frame.__init__(self, parent, *args, **kwds) 366 427 self.container = qstar_container 367 428 if self.container is None: 368 from invariant_panel import InvariantContainer369 429 self.container = InvariantContainer() 370 self.container.qstar_total = 1 430 self.container.qstar_total = 1.0 371 431 self.container.qstar = 0.75 372 432 self.container.qstar_low = 0.60 … … 381 441 if __name__ =="__main__": 382 442 app = wx.App() 383 from invariant_panel import InvariantContainer 443 384 444 container = InvariantContainer() 385 container.qstar_total = 1 386 container.qstar = 0.75 387 container.qstar_low = 0.60 388 container.qstar_high = 0.0049 445 container.qstar_total = 100.0 446 container.qstar = 15.0 447 container.qstar_low = 0.001 448 container.qstar_high = 100.0 449 container.compute_percentage() 450 389 451 window = InvariantDetailsTest(parent=None, id=-1,qstar_container=container, 390 title=" Source Editor")452 title="Invariant Details") 391 453 window.Show() 392 454 app.MainLoop() -
invariantview/perspectives/invariant/invariant_panel.py
rf338d3b rd0cc0bbc 10 10 from sans.guiframe.utils import format_number, check_float 11 11 from sans.guicomm.events import NewPlotEvent, StatusEvent 12 from invariant_details import InvariantDetailsPanel 12 from invariant_details import InvariantDetailsPanel, InvariantContainer 13 13 from invariant_widgets import OutputTextCtrl, InvTextCtrl 14 14 # The minimum q-value to be used when extrapolating … … 26 26 #default value of the contrast 27 27 CONTRAST = 1.0 28 #default value of the power used for power law 29 POWER = 4.0 28 30 #Invariant panel size 29 31 _BOX_WIDTH = 76 30 #scale to use for a bar of value zero31 RECTANGLE_SCALE = 0.000132 32 33 33 if sys.platform.count("win32")>0: … … 41 41 PANEL_HEIGHT = 700 42 42 FONT_VARIANT = 1 43 44 class InvariantContainer(wx.Object): 45 def __init__(self): 46 #invariant at low range 47 self.qstar_low = None 48 #invariant at low range error 49 self.qstar_low_err = None 50 #invariant 51 self.qstar = None 52 #invariant error 53 self.qstar_err = None 54 #invariant at high range 55 self.qstar_high = None 56 #invariant at high range error 57 self.qstar_high_err = None 58 #invariant total 59 self.qstar_total = None 60 #invariant error 61 self.qstar_total_err = None 62 #scale 63 self.qstar_low_scale = RECTANGLE_SCALE 64 self.qstar_scale = RECTANGLE_SCALE 65 self.qstar_high_scale = RECTANGLE_SCALE 66 43 44 67 45 class InvariantPanel(wx.ScrolledWindow): 68 46 """ … … 83 61 #plug-in using this panel 84 62 self._manager = manager 85 #Default power value86 self.power_law_exponant = 487 63 #Data uses for computation 88 64 self._data = data … … 91 67 #Draw the panel 92 68 self._do_layout() 69 self.reset_panel() 93 70 if self.parent is not None: 94 71 msg = "" … … 123 100 self.data_max_tcl.SetLabel(str(data_qmax)) 124 101 self.hint_msg_txt.SetLabel('') 125 102 self.reset_panel() 103 self.compute_invariant(event=None) 104 105 def set_message(self): 106 """ 107 Display warning message if available 108 """ 109 if self.inv_container is not None: 110 if self.inv_container.existing_warning: 111 msg = "Warning! Computations on invariant require your " 112 msg += "attention.\n Please click on Details button." 113 self.hint_msg_txt.SetForegroundColour("red") 114 else: 115 msg = "For more information, click on Details button." 116 self.hint_msg_txt.SetForegroundColour("black") 117 self.hint_msg_txt.SetLabel(msg) 118 wx.PostEvent(self.parent, StatusEvent(status=msg)) 119 self.data_name_boxsizer.Layout() 120 126 121 def set_manager(self, manager): 127 122 """ … … 239 234 power_low = inv.get_extrapolation_power(range='low') 240 235 if self.power_law_low.GetValue(): 241 self.power_low_tcl.SetValue( str(power_low))236 self.power_low_tcl.SetValue(format_number(power_low)) 242 237 self._manager.plot_theory(data=extrapolated_data, 243 238 name="Low-Q extrapolation") … … 257 252 self.inv_container.qstar_high_err = qstar_high_err 258 253 power_high = inv.get_extrapolation_power(range='high') 259 self.power_high_tcl.SetValue( str(power_high))254 self.power_high_tcl.SetValue(format_number(power_high)) 260 255 high_out_data = inv.get_extra_data_high(q_end=Q_MAXIMUM_PLOT) 261 256 self._manager.plot_theory(data=high_out_data, … … 346 341 open another panel for more details on invariant calculation 347 342 """ 348 #panel = InvariantDetailsWindow(parent=self.parent,349 # qstar_container=self.inv_container)350 343 panel = InvariantDetailsPanel(parent=self, 351 344 qstar_container=self.inv_container) 352 345 panel.ShowModal() 353 346 panel.Destroy() 354 355 def compute_invariant(self, event): 347 self.button_calculate.SetFocus() 348 349 def compute_invariant(self, event=None): 356 350 """ 357 351 compute invariant … … 418 412 msg= "Error occurred computing invariant: %s"%sys.exc_value 419 413 wx.PostEvent(self.parent, StatusEvent(status= msg)) 420 414 415 #compute percentage of each invariant 416 self.inv_container.compute_percentage() 417 #display a message 418 self.set_message() 421 419 #enable the button_ok for more details 422 self.button_ok.Enable() 420 self.button_details.Enable() 421 self.button_details.SetFocus() 423 422 424 423 def reset_panel(self): … … 426 425 set the panel at its initial state. 427 426 """ 427 self.background_tcl.SetValue(str(BACKGROUND)) 428 self.scale_tcl.SetValue(str(SCALE)) 429 self.contrast_tcl.SetValue(str(CONTRAST)) 430 self.npts_low_tcl.SetValue(str(NPTS)) 431 self.enable_low_cbox.SetValue(False) 432 self.fix_enable_low.SetValue(True) 433 self.power_low_tcl.SetValue(str(POWER)) 434 self.guinier.SetValue(True) 435 self.power_low_tcl.Disable() 436 self.enable_high_cbox.SetValue(False) 437 self.fix_enable_high.SetValue(True) 438 self.power_high_tcl.SetValue(str(POWER)) 439 self.npts_high_tcl.SetValue(str(NPTS)) 440 self.button_details.Disable() 441 #Change the state of txtcrtl to enable/disable 442 self._enable_low_q_section() 443 #Change the state of txtcrtl to enable/disable 444 self._enable_high_q_section() 445 self._reset_output() 446 self.button_calculate.SetFocus() 428 447 429 448 def _reset_output(self): … … 457 476 self.data_name_sizer = wx.BoxSizer(wx.HORIZONTAL) 458 477 self.data_range_sizer = wx.BoxSizer(wx.HORIZONTAL) 459 #Sizer related to background 460 self.b ackground_sizer = wx.BoxSizer(wx.HORIZONTAL)461 #Sizer related to scale462 self. scale_sizer = wx.BoxSizer(wx.HORIZONTAL)463 #Sizer related to contrast464 self.contrast_sizer = wx.BoxSizer(wx.HORIZONTAL)465 #Sizer related to Porod Constant466 self.porod_constant_sizer = wx.BoxSizer(wx.HORIZONTAL)478 #Sizer related to background and scale 479 self.bkg_scale_sizer = wx.BoxSizer(wx.HORIZONTAL) 480 #Sizer related to contrast and porod constant 481 self.contrast_porod_sizer = wx.BoxSizer(wx.HORIZONTAL) 482 #Sizer related to inputs 483 inputs_box = wx.StaticBox(self, -1, "Customized Inputs") 484 self.inputs_sizer = wx.StaticBoxSizer(inputs_box, wx.VERTICAL) 485 #Sizer related to extrapolation 467 486 extrapolation_box = wx.StaticBox(self, -1, "Extrapolation") 468 487 self.extrapolation_sizer = wx.StaticBoxSizer(extrapolation_box, 469 488 wx.VERTICAL) 470 489 self.extrapolation_sizer.SetMinSize((PANEL_WIDTH,-1)) 471 self.extrapolation_hint_sizer = wx.BoxSizer(wx.HORIZONTAL)472 490 self.extrapolation_range_sizer = wx.BoxSizer(wx.HORIZONTAL) 473 491 self.extrapolation_low_high_sizer = wx.BoxSizer(wx.HORIZONTAL) … … 520 538 (self.data_range_sizer, 0 , wx.ALL, 10)]) 521 539 522 def _layout_b ackground(self):523 """ 524 Draw widgets related to background 540 def _layout_bkg_scale(self): 541 """ 542 Draw widgets related to background and scale 525 543 """ 526 544 background_txt = wx.StaticText(self, -1, 'Background : ') 527 545 self.background_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 528 self.background_tcl.SetValue(str(BACKGROUND))529 546 background_hint_txt = "background" 530 547 self.background_tcl.SetToolTipString(background_hint_txt) 531 548 background_unit_txt = wx.StaticText(self, -1, '[1/cm]') 532 self.background_sizer.AddMany([(background_txt, 0, wx.LEFT, 10),533 (self.background_tcl, 0, wx.LEFT, 15),534 (background_unit_txt, 0, wx.LEFT, 10)])535 def _layout_scale(self):536 """537 Draw widgets related to scale538 """539 549 scale_txt = wx.StaticText(self, -1, 'Scale : ') 540 550 self.scale_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 541 551 scale_hint_txt = "Scale" 542 552 self.scale_tcl.SetToolTipString(scale_hint_txt) 543 self.scale_tcl.SetValue(str(SCALE)) 544 self.scale_sizer.AddMany([(scale_txt, 0, wx.LEFT|wx.RIGHT, 10), 545 (self.scale_tcl, 0, wx.LEFT, 35)]) 546 547 def _layout_contrast(self): 548 """ 549 Draw widgets related to contrast 553 self.bkg_scale_sizer.AddMany([(background_txt, 0, wx.LEFT, 10), 554 (self.background_tcl, 0, wx.LEFT, 5), 555 (background_unit_txt, 0, wx.LEFT, 10), 556 (scale_txt, 0, wx.LEFT, 70), 557 (self.scale_tcl, 0, wx.LEFT, 40)]) 558 559 def _layout_contrast_porod(self): 560 """ 561 Draw widgets related to porod constant and contrast 550 562 """ 551 563 contrast_txt = wx.StaticText(self, -1, 'Contrast : ') 552 564 self.contrast_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0) 553 self.contrast_tcl.SetValue(str(CONTRAST))554 565 contrast_hint_txt = "Contrast" 555 566 self.contrast_tcl.SetToolTipString(contrast_hint_txt) 556 567 contrast_unit_txt = wx.StaticText(self, -1, '[1/A^(2)]') 557 self.contrast_sizer.AddMany([(contrast_txt, 0, wx.LEFT|wx.RIGHT, 10),558 (self.contrast_tcl, 0, wx.LEFT, 18),559 (contrast_unit_txt, 0, wx.LEFT, 10)])560 561 def _layout_porod_constant(self):562 """563 Draw widgets related to porod constant564 """565 568 porod_const_txt = wx.StaticText(self, -1, 'Porod Constant:') 566 569 self.porod_constant_tcl = InvTextCtrl(self, -1, … … 569 572 self.porod_constant_tcl.SetToolTipString(porod_const_hint_txt) 570 573 optional_txt = wx.StaticText(self, -1, '(Optional)') 571 self.porod_constant_sizer.AddMany([(porod_const_txt, 0, wx.LEFT, 10), 574 self.contrast_porod_sizer.AddMany([(contrast_txt, 0, wx.LEFT, 10), 575 (self.contrast_tcl, 0, wx.LEFT, 20), 576 (contrast_unit_txt, 0, wx.LEFT, 10), 577 (porod_const_txt, 0, wx.LEFT, 50), 572 578 (self.porod_constant_tcl, 0, wx.LEFT, 0), 573 579 (optional_txt, 0, wx.LEFT, 10)]) … … 602 608 self._enable_power_law_low() 603 609 self._enable_fit_power_law_low() 610 self.button_calculate.SetFocus() 604 611 605 612 def _enable_power_law_low(self, event=None): … … 622 629 """ 623 630 self.enable_low_cbox = wx.CheckBox(self, -1, "Enable Extrapolate Low Q") 624 self.enable_low_cbox.SetValue(False)625 631 wx.EVT_CHECKBOX(self, self.enable_low_cbox.GetId(), 626 632 self._enable_low_q_section) 627 633 self.fix_enable_low = wx.RadioButton(self, -1, 'Fix', 628 634 (10, 10),style=wx.RB_GROUP) 629 self.fix_enable_low.SetValue(True)630 635 self.fit_enable_low = wx.RadioButton(self, -1, 'Fit', (10, 10)) 631 636 self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_low, … … 635 640 self.guinier = wx.RadioButton(self, -1, 'Guinier', 636 641 (10, 10),style=wx.RB_GROUP) 637 self.guinier.SetValue(True)638 642 self.power_law_low = wx.RadioButton(self, -1, 'Power Law', (10, 10)) 639 643 self.Bind(wx.EVT_RADIOBUTTON, self._enable_power_law_low, … … 644 648 npts_low_txt = wx.StaticText(self, -1, 'Npts') 645 649 self.npts_low_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH*2/3, -1)) 646 self.npts_low_tcl.SetValue(str(NPTS))647 650 msg_hint = "Number of Q points to consider" 648 651 msg_hint +="while extrapolating the low-Q region" … … 650 653 power_txt = wx.StaticText(self, -1, 'Power') 651 654 self.power_low_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH*2/3, -1)) 652 self.power_low_tcl.SetValue(str(self.power_law_exponant)) 653 self.power_low_tcl.Disable() 655 654 656 power_hint_txt = "Exponent to apply to the Power_law function." 655 657 self.power_low_tcl.SetToolTipString(power_hint_txt) … … 689 691 self.low_q_sizer.Add(self.power_low_tcl, (iy, ix), (1,1), 690 692 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 691 #Change the state of txtcrtl to enable/disable692 self._enable_low_q_section()693 693 self.low_extrapolation_sizer.AddMany([(self.low_q_sizer, 0, 694 wx.BOTTOM|wx.RIGHT, 10)]) 694 wx.BOTTOM|wx.RIGHT, 15)]) 695 695 696 def _enable_fit_power_law_high(self, event=None): 696 697 """ … … 720 721 self.fit_enable_high.Disable() 721 722 self._enable_fit_power_law_high() 723 self.button_calculate.SetFocus() 722 724 723 725 def _layout_extrapolation_high(self): … … 726 728 """ 727 729 self.enable_high_cbox = wx.CheckBox(self, -1, "Enable Extrapolate high-Q") 728 self.enable_high_cbox.SetValue(False)729 730 wx.EVT_CHECKBOX(self, self.enable_high_cbox.GetId(), 730 731 self._enable_high_q_section) … … 732 733 self.fix_enable_high = wx.RadioButton(self, -1, 'Fix', 733 734 (10, 10),style=wx.RB_GROUP) 734 self.fix_enable_high.SetValue(True)735 735 self.fit_enable_high = wx.RadioButton(self, -1, 'Fit', (10, 10)) 736 736 self.Bind(wx.EVT_RADIOBUTTON, self._enable_fit_power_law_high, … … 740 740 741 741 self.power_law_high = wx.StaticText(self, -1, 'Power Law') 742 #msg_hint ="Check to extrapolate data at high-Q"743 #self.power_law_high.SetToolTipString(msg_hint)742 msg_hint ="Check to extrapolate data at high-Q" 743 self.power_law_high.SetToolTipString(msg_hint) 744 744 npts_high_txt = wx.StaticText(self, -1, 'Npts') 745 745 self.npts_high_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH*2/3, -1)) … … 747 747 msg_hint += "while extrapolating the high-Q region" 748 748 self.npts_high_tcl.SetToolTipString(msg_hint) 749 self.npts_high_tcl.SetValue(str(NPTS))750 749 power_txt = wx.StaticText(self, -1, 'Power') 751 750 self.power_high_tcl = InvTextCtrl(self, -1, size=(_BOX_WIDTH*2/3, -1)) 752 self.power_high_tcl.SetValue(str(self.power_law_exponant))753 751 power_hint_txt = "Exponent to apply to the Power_law function." 754 752 self.power_high_tcl.SetToolTipString(power_hint_txt) … … 784 782 self.high_q_sizer.Add(self.power_high_tcl, (iy, ix), (1,1), 785 783 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 786 #Change the state of txtcrtl to enable/disable 787 self._enable_high_q_section() 788 self.high_extrapolation_sizer.AddMany([(self.high_q_sizer, 0, wx.RIGHT, 10)]) 784 self.high_extrapolation_sizer.AddMany([(self.high_q_sizer, 0, 785 wx.BOTTOM|wx.RIGHT, 10)]) 789 786 790 787 def _layout_extrapolation(self): … … 813 810 0, wx.LEFT, 10), 814 811 ]) 815 extra_enable_hint = "Hint: Check any box to enable a specific extrapolation !"816 extra_enable_hint_txt = wx.StaticText(self, -1, extra_enable_hint )817 self.extrapolation_hint_sizer.AddMany([(extra_enable_hint_txt, 0, wx.LEFT, 0)818 ])819 812 self._layout_extrapolation_low() 820 813 self._layout_extrapolation_high() … … 825 818 self.extrapolation_sizer.AddMany([(self.extrapolation_range_sizer, 0, 826 819 wx.RIGHT, 10), 827 (self.extrapolation_hint_sizer, 0,828 wx.ALL, 10),829 820 (self.extrapolation_low_high_sizer, 0, 830 821 wx.ALL, 10)]) … … 915 906 wx.EXPAND|wx.ADJUST_MINSIZE, 10) 916 907 908 def _layout_inputs_sizer(self): 909 """ 910 Draw widgets related to inputs 911 """ 912 self._layout_bkg_scale() 913 self._layout_contrast_porod() 914 self.inputs_sizer.AddMany([(self.bkg_scale_sizer, 0, wx.ALL, 5), 915 (self.contrast_porod_sizer, 0, wx.ALL, 5)]) 916 917 917 def _layout_outputs_sizer(self): 918 918 """ … … 931 931 #compute button 932 932 id = wx.NewId() 933 button_calculate = wx.Button(self, id, "Compute")934 button_calculate.SetToolTipString("Compute invariant")933 self.button_calculate = wx.Button(self, id, "Compute") 934 self.button_calculate.SetToolTipString("Compute invariant") 935 935 self.Bind(wx.EVT_BUTTON, self.compute_invariant, id=id) 936 936 #detail button 937 937 id = wx.NewId() 938 self.button_ ok= wx.Button(self, id, "Details?")939 self.button_ ok.SetToolTipString("Give Details on Computation")938 self.button_details = wx.Button(self, id, "Details?") 939 self.button_details.SetToolTipString("Give Details on Computation") 940 940 self.Bind(wx.EVT_BUTTON, self.display_details, id=id) 941 self.button_ok.Disable()942 941 details = "Details on Invariant Total Calculations" 943 942 details_txt = wx.StaticText(self, -1, details) 944 self.button_sizer.AddMany([((20,20), 0 , wx.LEFT, 100), 945 (details_txt, 0 , wx.ALL, 10), 946 (self.button_ok, 0 , wx.ALL, 10), 947 (button_calculate, 0 , wx.RIGHT|wx.TOP|wx.BOTTOM, 10)]) 943 self.button_sizer.AddMany([((10,10), 0 , wx.LEFT,0), 944 (details_txt, 0 , 945 wx.RIGHT|wx.BOTTOM|wx.TOP, 10), 946 (self.button_details, 0 , wx.ALL, 10), 947 (self.button_calculate, 0 , wx.RIGHT|wx.TOP|wx.BOTTOM, 10)]) 948 948 949 949 def _do_layout(self): … … 953 953 self._define_structure() 954 954 self._layout_data_name() 955 self._layout_background()956 self._layout_scale()957 self._layout_contrast()958 self._layout_porod_constant()959 955 self._layout_extrapolation() 956 self._layout_inputs_sizer() 960 957 self._layout_outputs_sizer() 961 958 self._layout_button() 962 self.main_sizer.AddMany([(self.data_name_boxsizer, 0, wx.ALL, 10), 963 (self.background_sizer, 0, 964 wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), 965 (self.scale_sizer, 0, 966 wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), 967 (self.contrast_sizer, 0, 968 wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), 969 (self.porod_constant_sizer, 0, 970 wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), 971 (self.extrapolation_sizer, 0, 972 wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), 959 self.main_sizer.AddMany([(self.data_name_boxsizer, 1, wx.ALL, 10), 973 960 (self.outputs_sizer, 0, 974 961 wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), 975 962 (self.button_sizer, 0, 963 wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), 964 (self.inputs_sizer, 0, 965 wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), 966 (self.extrapolation_sizer, 0, 976 967 wx.LEFT|wx.RIGHT|wx.BOTTOM, 10)]) 977 968 self.SetSizer(self.main_sizer)
Note: See TracChangeset
for help on using the changeset viewer.