Changes in / [c1694f8:7d32aaf] in sasview


Ignore:
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • build_tools/conda/pyopencl/meta.yaml

    r20b238df r0037131  
    3838  run: 
    3939    - python 
     40    - setuptools 
    4041    - numpy 
    4142    - pytools >=2014.2 
  • src/sas/guiframe/media/data_explorer_help.rst

    rc147870 r2bf5e3b  
    3939Hide by clicking *Show/Hide Data Explorer*. 
    4040 
    41 NOTE! When *Data Explorer* is hidden, all data loaded will be sent directly  
    42 to the current active application, if possible. When *Data Explorer* is  
    43 shown, data go first to the *Data Explorer*. 
     41*NOTE! When* Data Explorer *is hidden, all data loaded will be sent directly  
     42to the current active application, if possible. When* Data Explorer *is  
     43shown, data go first to the* Data Explorer. 
    4444 
    4545.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    5252To load data, click the button *Load Data*, then select one or more (by holding  
    5353the Ctrl key) files to load into the application. The name of each selected  
    54 file will be listed. Clicking the *+*  symbol will display any available  
    55 metadata. 
     54file will be listed. 
     55 
     56Clicking the *+*  symbol will display any available metadata. 
    5657 
    5758.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    6364 
    6465Right-clicking on a loaded dataset (or model calculation, what SasView calls a  
    65 theory) brings up a *Handy Menu* from which it is possible to access Data Info,  
     66theory) brings up a *Handy Menu* from which it is possible to access Datainfo,  
    6667Save the data/theory, or Plot the data/theory. 
    6768 
     
    9091----------- 
    9192 
    92 WARNING! *Remove Data* will stop any data operations currently using the  
    93 selected data sets. 
    94  
     93*WARNING!* Remove Data *will stop any data operations currently using the  
     94selected data sets.* 
    9595 
    9696*Remove Data* removes all reference to selected data from the application. 
     
    103103-------------------- 
    104104 
     105This operation can only be performed on 1D data and plot panels currently  
     106containing 1D data. 
     107 
    105108Click on the button *Append To* to add selected data to a plot panel. Next to  
    106109the button is a combo box containing the names of available plot panels.  
     
    110113disabled. 
    111114 
    112 2D Data cannot be appended to any plot panels. This operation can  
    113 only be performed on 1D data and plot panels currently containing 1D data. 
     1152D Data cannot be appended to any plot panels. 
    114116 
    115117.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    132134The *Freeze Theory* button generates data from the selected theory. 
    133135 
    134 NOTE! This operation can only be performed when theory labels are selected. 
     136*NOTE! This operation can only be performed when theory labels are selected.* 
    135137 
    136138.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    150152fitted at the same time, use *Simultaneous* fitting under the *Fitting*  
    151153option on the menu bar. 
     154 
     155.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     156 
     157.. note::  This help document was last changed by Steve King, 18Feb2015 
  • src/sas/guiframe/media/data_formats_help.rst

    r6f10243 r3fd3d5a4  
    2929SasView recognises the following file extensions: 
    3030 
    31     .TXT 
    32      
    33     .ASC 
    34      
    35     .DAT 
    36      
    37     .XML (in canSAS format v1.0 and 1.1) 
     31*  .TXT 
     32*  .ASC 
     33*  .DAT 
     34*  .XML (in canSAS format v1.0 and 1.1) 
    3835 
    3936If using CSV output from, for example, a spreadsheet, ensure that it is not  
    4037using commas as delimiters for thousands. 
    4138 
     39For a description of the CanSAS/SASXML format see: 
     40http://www.cansas.org/formats/canSAS1d/1.1/doc/ 
     41 
    4242For a description of the NIST 1D format see: 
    43  
    4443http://danse.chem.utk.edu/trac/wiki/NCNROutput1D_IQ 
    4544 
    4645For a description of the ISIS 1D format see: 
    47  
    4846http://www.isis.stfc.ac.uk/instruments/loq/software/colette-ascii-file-format-descriptions9808.pdf 
    4947 
    50 NB: SasView does not at present load data where the Q and I(Q) data are in  
    51 separate files. 
     48*NOTE! SasView does not at present load data where the Q and I(Q) data are in  
     49separate files.* 
    5250 
    5351.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    6563 
    6664For a description of the NIST 2D format see: 
    67  
    6865http://danse.chem.utk.edu/trac/wiki/NCNROutput1D_2DQxQy  
    6966 
    7067.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     68 
     69.. note::  This help document was last changed by Steve King, 18Feb2015 
  • src/sas/guiframe/media/graph_help.rst

    r98b30b4 r1394952  
    44.. by S King, ISIS, during SasView CodeCamp-III in Feb 2015. 
    55 
     6.. |delta| unicode:: U+03B4 
     7.. |phi| unicode:: U+03C6 
     8 
     9 
    610Plotting Data/Models 
    711==================== 
    812 
    9 Graph_Menu_ 
     13Graph_Window_Options_ 
     14 
     15Dataset_Menu_Options_ 
    1016 
    11172D_Data_Averaging_ 
    1218 
    13 Key_Sequences_ 
    14  
    1519.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    1620 
    17 .. _Graph_Menu: 
    18  
    19 Graph Menu 
     21.. _Graph_Window_Options: 
     22 
     23Graph Window Options 
     24-------------------- 
     25 
     26Invoking_the_Graph_Menu_ 
     27 
     28Hide_Show_Delete_Graph_ 
     29 
     30Drag_Plot_ 
     31 
     32Zoom_In_Out_ 
     33 
     34Save_Plot_Image_ 
     35 
     36Print_Plot_ 
     37 
     38Reset_Graph_ 
     39 
     40Graph_Modifications_ 
     41 
     42Change_Scale_ 
     43 
     44Toggle_Scale_ 
     45 
     462D_Color_Map_ 
     47 
     48Data_Coordinates_ 
     49 
     50.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     51 
     52.. _Dataset_Menu_Options: 
     53 
     54Dataset Menu Options 
     55-------------------- 
     56 
     57Invoking_the_Dataset_Menu_ 
     58 
     59Data_Info_ 
     60 
     61Save_Data_ 
     62 
     63Linear_Fit_ 
     64 
     65Remove_Data_from_Plot_ 
     66 
     67Show_Hide_Error_Bars_ 
     68 
     69Modify_Plot_Property_ 
     70 
     712D Averaging 
     72------------ 
     73 
     742D_Data_Averaging_ 
     75 
     76.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     77 
     78.. _Invoking_the_Graph_Menu: 
     79 
     80Invoking the Graph Menu 
     81----------------------- 
     82 
     83To invoke the *Graph Menu* simply right-click on a data/theory plot, or click  
     84the *Graph Menu* (bullet list) icon in the toolbar at the bottom of the plot.  
     85Then select a menu item. 
     86 
     87.. _Hide_Show_Delete_Graph: 
     88 
     89Hide/Show/Delete Graph 
     90---------------------- 
     91 
     92To expand a plot window, click the *Maximise* (square) icon in the top-right  
     93corner. 
     94 
     95To shrink a plot window, click the *Restore down* (square-on-square) icon in  
     96the top-right corner. 
     97 
     98To hide a plot, click the *Minimise* (-) icon in the top-right corner of the  
     99plot window. 
     100 
     101To show a hidden plot, select the *Restore up* (square-on-square) icon on the  
     102minimised window. 
     103 
     104To delete a plot, click the *Close* (x) icon in the top-right corner of the  
     105plot window. 
     106 
     107*NOTE! If a residuals graph (when fitting data) is hidden, it will not show up  
     108after computation.* 
     109 
     110.. _Drag_Plot: 
     111 
     112Drag Plot 
     113--------- 
     114 
     115Select the *Pan* (crossed arrows) icon in the toolbar at the bottom of the plot  
     116to activate this option. Move the mouse pointer to the plot. It will change to  
     117a hand. Then left-click and drag the plot around. The axis values will adjust  
     118accordingly. 
     119  
     120To disable dragging mode, unselect the *crossed arrows* icon on the toolbar. 
     121 
     122.. _Zoom_In_Out: 
     123 
     124Zoom In/Out 
     125----------- 
     126 
     127Select the *Zoom* (magnifying glass) button in the toolbar at the bottom of  
     128the plot to activate this option. Move the mouse pointer to the plot. It will  
     129change to a cross-hair. Then left-click and drag the pointer around to generate  
     130a region of interest. Release the mouse button to generate the new view. 
     131 
     132To disable zoom mode, unselect the *Zoom* button on the toolbar. 
     133 
     134After zooming in on a a region, the *left arrow* or *right arrow* buttons on  
     135the toolbar will switch between recent views. 
     136 
     137*NOTE! If a wheel mouse is available scrolling the wheel will zoom in/out  
     138on the current plot (changing both axes). Alternatively, point at the numbers  
     139on one axis and scroll the wheel to zoom in/out on just that axis.* 
     140 
     141To return to the original view of the data, click the the *Reset* (home) icon  
     142in the toolbar at the bottom of the plot (see Reset_Graph_ for further details). 
     143 
     144.. _Save_Plot_Image: 
     145 
     146Save Plot Image 
     147--------------- 
     148 
     149To save the current plot as an image file, right click on the plot to bring up  
     150the *Graph Menu* (see Invoking_the_Graph_Menu_) and select *Save Image*.  
     151Alternatively, click on the *Save* (floppy disk) icon in the toolbar at the  
     152bottom of the plot. 
     153  
     154A dialog window will open. Select a folder, enter a filename, choose an output  
     155image type, and click *Save*. 
     156 
     157The currently supported image types are: 
     158 
     159*  EPS (encapsulated postscript) 
     160*  EMF (enhanced metafile) 
     161*  JPG/JPEG (joint photographics experts group) 
     162*  PDF (portable documant format) 
     163*  PNG (portable network graphics) 
     164*  PS (postscript) 
     165*  RAW/RGBA (bitmap) 
     166*  SVG/SVGA (scalable vector graphics) 
     167*  TIF/TIFF (tagged iamge file) 
     168 
     169.. _Print_Plot: 
     170 
     171Print Plot 
    20172---------- 
    21173 
    22 Invoking_the_Graph_Menu_ 
    23  
    24 Reset_Graph_ 
    25  
    26 Hide_Show_Delete_Graph_ 
    27  
    28 Data_Info_ 
    29  
    30 Save_Plot_Image_ 
    31  
    32 Save_Data_ 
    33  
    34 Drag_Plot_ 
    35  
    36 Zoom_In_Out_ 
    37  
    38 Remove_Data_from_Plot_ 
    39  
    40 Change_Scale_ 
    41  
    42 Linear_Fit_ 
    43  
    44 Other_Graph_Modifications_ 
    45  
    46 .. _Invoking_the_Graph_Menu: 
    47  
    48 Introduction 
    49 ------------ 
    50  
    51 Locating the pointer and right-clicking on a data/theory plot will bring a  
    52 context menu. On the menu, select a menu item. 
     174To send the current plot to a printer, click on the *Print* (printer) icon in  
     175the toolbar at the bottom of the plot. 
    53176 
    54177.. _Reset_Graph: 
     
    57180----------- 
    58181 
    59 To reset the graph's axis range, right click on the plot and the context menu  
    60 pops-up. Select *Reset Graph*  and the plot will take its initial range. Also  
    61 the 'home' icon in tool bar will do the same. 
    62  
    63 .. _Hide_Show_Delete_Graph: 
    64  
    65 Hide/Show/Delete Graph 
    66 ---------------------- 
    67  
    68 To Hide, click the Hide (bar) button in the tool bar.To Show, select the the  
    69 'Show' menu item in the 'Graph' menu in the menu bar.To Delete, click the 'x'  
    70 button in the title bar. 
    71  
    72 Note: If a residuals graph (in Fitting) is hidden, it will not show up after  
    73 computation. 
     182To reset the axis range of a graph to its initial values select *Reset Graph  
     183Range* on the *Graph Menu* (see Invoking_the_Graph_Menu_). Alternatively, use  
     184the *Reset* (home) icon in the toolbar at the bottom of the plot. 
     185 
     186.. _Graph_Modifications: 
     187 
     188Graph Modifications 
     189------------------- 
     190 
     191From the *Graph Menu* (see Invoking_the_Graph_Menu_) it is also possible to  
     192make some custom modifications to plots, including: 
     193 
     194*  changing the plot window title 
     195*  changing the axis legend locations 
     196*  changing the axis legend label text 
     197*  changing the axis legend label units 
     198*  changing the axis legend label font & font colour 
     199*  adding/removing a text string 
     200*  adding a grid overlay 
     201 
     202.. _Change_Scale: 
     203 
     204Change Scale 
     205------------ 
     206 
     207This menu option is only available with 1D data. 
     208 
     209From the *Graph Menu* (see Invoking_the_Graph_Menu_) select *Change Scale*. A  
     210dialog window will appear in which it is possible to choose different  
     211transformations of the x (usually Q) or y (usually I(Q)) axes, including: 
     212 
     213*  x, x^2, x^4, ln(x), log10(x), log10(x^4) 
     214*  y, 1/y, ln(y), y^2, y.(x^4), 1/sqrt(y), 
     215*  log10(y), ln(y.x), ln(y.x^2), ln(y.x^4), log10(y.x^4) 
     216  
     217A *View* option includes short-cuts to common SAS transformations, such as: 
     218 
     219*  linear 
     220*  Guinier 
     221*  X-sectional Guinier 
     222*  Porod 
     223*  Kratky 
     224 
     225For properly corrected and scaled data, these SAS transformations can be used  
     226to estimate, for example, Rg, rod diameter, or SANS incoherent background  
     227levels, via a linear fit (see Linear_Fit_). 
     228 
     229.. _Toggle_Scale: 
     230 
     231Toggle Scale 
     232------------ 
     233 
     234This menu option is only available with 2D data. 
     235 
     236From the *Graph Menu* (see Invoking_the_Graph_Menu_) select *Toggle Linear/Log  
     237Scale* to switch between a linear to log intensity scale. The type of scale  
     238selected is written alongside the colour scale. 
     239 
     240.. _2D_Color_Map: 
     241 
     2422D Color Map 
     243------------ 
     244 
     245This menu option is only available with 2D data. 
     246 
     247From the *Graph Menu* (see Invoking_the_Graph_Menu_) select *2D Color Map* to  
     248choose a different color scale for the image and/or change the maximum or  
     249minimum limits of the scale. 
     250 
     251.. _Data_Coordinates: 
     252 
     253Data Coordinates 
     254---------------- 
     255 
     256Clicking anywhere in the plot window will cause the current coordinates to be  
     257displayed in the status bar at the very bottom-left of the SasView window. 
     258  
     259.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     260 
     261.. _Invoking_the_Dataset_Menu: 
     262 
     263Invoking_the_Dataset_Menu 
     264------------------------- 
     265 
     266From the *Graph Menu* (see Invoking_the_Graph_Menu_) highlight a plotted  
     267dataset. 
    74268 
    75269.. _Data_Info: 
     
    78272--------- 
    79273 
    80 From the context menu, select 'Data Info' to see the data information dialog 
    81 panel. 
    82  
    83 .. _Save_Plot_Image: 
    84  
    85 Save Plot Image 
    86 --------------- 
    87  
    88 Right click on plot. Context menu will pop-up select save image [file name]. 
    89 A dialog window opens and write a the name of the file to save and click on  
    90 *Save Image.* 
     274In the *Dataset Menu* (see Invoking_the_Dataset_Menu_), highlight a data set  
     275and select *DataInfo* to bring up a data information dialog panel for that  
     276data set. 
    91277 
    92278.. _Save_Data: 
     
    95281--------- 
    96282 
    97 From the context menu, select 'Save points as a file' for 1D, or 'Save as a  
    98 file(DAT)' for 2D. Note that two formats, txt and xml, are available in 1D  
    99 saving. 
    100  
    101 .. _Drag_Plot: 
    102  
    103 Drag Plot 
    104 --------- 
    105  
    106 Select the *crossed arrows*  button on the plot panel *toolbar*  to drag the  
    107 plot. To disable dragging mode, unselect the same button on the toolbar. 
    108  
    109 .. _Zoom_In_Out: 
    110  
    111 Zoom In/Out 
    112 ----------- 
    113  
    114 Select the *rectangle*  button on the plot panel *toolbar*  to zoom in a 
    115 region of the plot. 
    116  
    117 To disable zoom mode, unselect the same button on the toolbar. After zoom in 
    118 a region, select *left arrow*  or *right arrow*  button on the toolbar to set 
    119 the graph the the previous size. If a mouse wheel button is available, 
    120 *zoom in/out*  by scrolling the mouse wheel (see Key_Sequences_ help for 
    121 details). 
     283In the *Dataset Menu* (see Invoking_the_Dataset_Menu_), select *Save Points as  
     284a File* (if 1D data) or *Save as a file(DAT)* (if 2D data). A save dialog will  
     285appear. 
     286 
     2871D data can be saved in either ASCII text (.TXT) or CanSAS/SASXML (.XML)  
     288formats (see :ref:`1D_Formats`). 
     289 
     2902D data can only be saved in the NIST 2D format (.DAT) (see :ref:`2D_Formats`). 
     291 
     292.. _Linear_Fit: 
     293 
     294Linear Fit 
     295---------- 
     296 
     297Linear fit performs a simple ( y(x)=ax+b ) linear fit within the plot window. 
     298 
     299In the *Dataset Menu* (see Invoking_the_Dataset_Menu_), select *Linear Fit*. A  
     300fitting dialog will appear. Set some initial parameters and data limits and  
     301click *Fit*. The fitted parameter values are displayed and the resulting line  
     302calculated from them is added to the plot.  
     303 
     304This option is most useful for performing simple Guinier, XS Guinier, and 
     305Porod type analyses, for example, to estimate Rg, a rod diameter, or incoherent  
     306background level, respectively. 
     307 
     308The following figure shows an example of a Guinier analysis using this option 
     309 
     310.. image:: guinier_fit.png 
    122311 
    123312.. _Remove_Data_from_Plot: 
     
    126315--------------------- 
    127316 
    128 Highlight the plot and the context menu appears.Select *remove [file name]*. 
    129 The plot selected will disappear. 
    130  
    131 .. _Change_Scale: 
    132  
    133 Change Scale 
    134 ------------ 
    135  
    136 If the loaded data is a 1-D data changing scale or data representation will  
    137 work as follows. *Right click* on the plot window. A context menu pops-up and  
    138 select *Change Scale* . A dialog window titled *select the scale of the graph*  
    139 will pop-up then change the *x* , the *y*  and the *view*  values as wish. 
    140  
    141 The 'view' option includes the axis scale short-cuts such as Linear, Guinier,  
    142 Cross-sectional (XC) Guinier, and Porod plot scale. For a proper data set,  
    143 these axis scales can be used to estimate Rg, Rod diameter, or Background of  
    144 neutron scattering data respectively (via 'Linear Fit'; see below). For a 2D  
    145 image, *Right click*  on the image to pop-up the context menu. Select to  
    146 switch from linear to log scale. The scale selected is printed on the status  
    147 bar. 
    148  
    149 If the loaded data is an image. *Right click*  on the image to pop-up the 
    150 context menu. Select to switch from linear to log scale. The scale selected is 
    151 printed on the status bar. 
    152  
    153 .. _Linear_Fit: 
    154  
    155 Linear Fit 
    156 ---------- 
    157  
    158 Linear fit is to perform a line model fitting keeping the scale of the plot. 
    159 Highlight data to fit. From the context menu select *Linear Fit* . A dialog 
    160 window appears. Change model initial parameters, data limits and hit *fit* 
    161 button. New parameters values are displayed and the line with the new 
    162 parameters is added to the plot. Especially for Guinier, XC Guinier, and 
    163 Porod plot scale, this 'Linear Fit' will provides Rg, Rod diameter, and 
    164 background, respectively. The following figure shows an example for the 
    165 Guinier scale. 
    166  
    167 .. image:: guinier_fit.png 
    168  
    169 .. _Other_Graph_Modifications: 
    170  
    171 Other Graph Modifications 
    172 ------------------------- 
    173  
    174 Some custom modifications of the symbols, text, axis, etc of the graph are  
    175 provided. 
     317In the *Dataset Menu* (see Invoking_the_Dataset_Menu_), select *Remove*. The  
     318selected data will be removed from the plot. 
     319 
     320*NOTE! This action cannot be undone.* 
     321 
     322.. _Show_Hide_Error_Bars: 
     323 
     324Show/Hide Error Bars 
     325-------------------- 
     326 
     327In the *Dataset Menu* (see Invoking_the_Dataset_Menu_), select *Show Error Bar*  
     328or *Hide Error Bar* to switch between showing/hiding the errors associated  
     329with the chosen dataset.  
     330 
     331.. _Modify_Plot_Property: 
     332 
     333Modify Plot Property 
     334-------------------- 
     335 
     336In the *Dataset Menu* (see Invoking_the_Dataset_Menu_), select *Modify Plot  
     337Property* to change the size, color, or shape of the displayed marker for the  
     338chosen dataset, or to change the dataset label that appears on the plot. 
    176339 
    177340.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    182345----------------- 
    183346 
    184 Principle_ 
     347Purpose_ 
    185348 
    186349How_to_Average_ 
     
    204367.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    205368 
    206 .. Principle:  
    207  
    208 Principle 
    209 --------- 
    210  
    211 This feature allows you to perform different types of averages on your data,  
    212 and allows you to see what regions of the detector will contribute to the  
    213 average. The region to be averaged will be drown and can be modified by  
    214 dragging the lines around. 
     369.. Purpose:  
     370 
     371Purpose 
     372------- 
     373 
     374This feature is only available with 2D data. 
     375 
     3762D data averaging allows you to perform different types of averages on your  
     377data. The region to be averaged is displayed in the plot window and its limits  
     378can be modified by dragging the boundaries around. 
    215379 
    216380.. _How_to_Average: 
     
    219383-------------- 
    220384 
    221 Right click on 2D data for the context menu to appear. Select one type of  
    222 averages among *"sector [Q view]", "Annulus [Phi view]", "Box sum", "Box  
    223 averaging in Qx ", "box averaging on Qy","Perform circular Average".* 
    224  
    225 A slicer will appear except for *"Perform circular Average"*  that you can  
    226 drag by clicking on a slicer 's marker. When the marker is highlighted in red,  
    227 it means that the slicer can change size.You can also move some of the slicer  
    228 by simply drag its side when highlighted in red. the slicer size will be reset  
    229 to its previous size if the user try to select a region greater than the size  
    230 of the data. 
    231  
    232 The user can also select a region to average when a slicer has been selected  
    233 already by *right clicking*  on the context menu and selecting *Edit Slicer  
    234 Parameters* . The dialog window will appears and the user can enter values to  
    235 selected a region or selected numbers of points to plot *nbins* . 
    236  
    237 For *Box sum* , when the user selects this option, a new panel is created  
    238 containing the result of average of the sum of every pixels contains on that  
    239 data.The user can also enter values to select a region. 
     385In the *Dataset Menu* (see Invoking_the_Dataset_Menu_), select one of the  
     386following averages 
     387 
     388*  Perform Circular Average 
     389*  Sector [Q view] 
     390*  Annulus [Phi view] 
     391*  Box sum 
     392*  Box averaging in Qx 
     393*  Box averaging on Qy 
     394 
     395A 'slicer' will appear (except for *Perform Circular Average*) in the plot that  
     396you can drag by clicking on a slicer's handle. When the handle is highlighted  
     397in red, it means that the slicer can move/change size. 
     398 
     399*NOTE! The slicer size will reset if you try to select a region greater than  
     400the size of the data.* 
     401 
     402Alternatively, once a 'slicer' is active you can also select the region to  
     403average by bringing back the *Dataset Menu* and selecting *Edit Slicer  
     404Parameters*. A dialog window will appear in which you can enter values to  
     405define a region or select the number of points to plot (*nbins*). 
     406 
     407A separate plot window will also have appeared, displaying the requested  
     408average. 
     409 
     410*NOTE! The displayed average only updates when input focus is moved back to  
     411that window; ie, when the mouse pointer is moved onto that plot.* 
     412 
     413Selecting *Box Sum* automatically brings up the 'Slicer Parameters' dialog in  
     414order to display the average numerically, rather than graphically. 
     415 
     416To remove a 'slicer', bring back the *Dataset menu* and select *Clear Slicer*. 
    240417 
    241418.. _Available_Averagings: 
     
    244421-------------------- 
    245422 
    246 Some different types of averaging are provided for. 
     423The available averages are 
    247424 
    248425.. _Unmasked_Circular_Average: 
     
    251428------------------------- 
    252429 
    253 This operation will perform and average in constant q-rings around the (x,y) pixel 
    254 location of the beam center. 
     430This operation will perform an average in constant Q-rings around the (x,y)  
     431pixel location of the beam center. 
    255432 
    256433.. _Masked_Circular_Average: 
     
    259436----------------------- 
    260437 
    261 This operation is same as 'Masked Circular Average' except that the masked 
    262 region is excluded if masked. 
     438This operation is the same as 'Unmasked Circular Average' except that any  
     439masked region is excluded. 
    263440 
    264441.. _Sector_Average: 
     
    267444----------------------- 
    268445 
    269 This operation averages in constant q-arcs. The width of the sector is specified in 
    270 degrees (+/- delta phi) each side of the central angle (phi). 
     446This operation averages in constant Q-arcs. 
     447 
     448The width of the sector is specified in degrees (+/- |delta|\|phi|\) each side  
     449of the central angle (|phi|\). 
    271450 
    272451.. _Annular_Average: 
    273452 
    274 Annular Average [Phi View] 
    275 -------------------------- 
    276  
    277 It performs an average between two q-values centered in (0,0), and averaged  
    278 over a width of a specified number of pixels. The data is returned as a  
    279 function of angle (phi) in degrees. Moving one circle of this slicer to  
    280 radius of zero corresponding to a circular averaging on radius qmax , the  
    281 outer circle. The angle zero starts from the positive x-axis direction. 
     453Annular Average [|phi| View] 
     454---------------------------- 
     455 
     456This operation performs an average between two Q-values centered on (0,0),  
     457and averaged over a specified number of pixels. 
     458 
     459The data is returned as a function of angle (|phi|\) in degrees with zero  
     460degrees at the 3 O'clock position. 
    282461 
    283462.. _Box_Sum: 
     
    286465------- 
    287466 
    288 Perform the sum of counts in a 2D region of interest.When editing the slicer,  
    289 the user can enter the length and the width the rectangle slicer and the  
    290 coordinates of the center of this rectangle. 
     467This operation performs a sum of counts in a 2D region of interest. 
     468 
     469When editing the slicer parameters, the user can enter the length and the width  
     470the rectangular slicer and the coordinates of the center of the rectangle. 
    291471 
    292472.. _Box_Averaging_in_Qx: 
     
    295475------------------- 
    296476 
    297 Computes average I(Qx) for a region of interest. When editing the slicer, the  
    298 user can control the length and the width the rectangle slicer. The averaged  
    299 output is calculated from the constant bins with rectangular shape. The  
    300 resultant q values are nominal values, i.e., the central values of each bins  
    301 on the x-axis. 
     477This operation computes an average I(Qx) for the region of interest. 
     478 
     479When editing the slicer parameters, the user can control the length and the  
     480width the rectangular slicer. The averaged output is calculated from constant  
     481bins with rectangular shape. The resultant Q values are nominal values, that  
     482is, the central value of each bin on the x-axis. 
    302483 
    303484.. _Box_Averaging_in_Qy: 
     
    306487------------------- 
    307488 
    308 Computes average I(Qy) for a region of interest.When editing the slicer, the  
    309 user can control the length and the width the rectangle slicer. The averaged  
    310 output is calculated from the constant bins with rectangular shape. The  
    311 resultant q values are nominal values, i.e., the central values of each bins  
    312 on the y-axis. 
    313  
    314 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    315  
    316 .. _Key_Sequences: 
    317  
    318 Key Sequences 
    319 ------------- 
    320  
    321 Floating_Panel_ 
    322  
    323 Context_Menu_ 
    324  
    325 Zoom_ 
    326  
    327 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    328  
    329 .. _Floating_Panel: 
    330  
    331 Floating Panel 
    332 -------------- 
    333  
    334 For a graph panel to float on the top of the SV window: 
    335  
    336 Press the *Ctrl(Cmd on MAC) key*  on dragging and placing a panel. Or if you  
    337 want to make all plot panels float, select 'Float' from Graph/Preperences in  
    338 the menu bar. Otherwise choose 'Dock'. 
    339  
    340 .. _Context_Menu: 
    341  
    342 Graph Context Menu 
    343 ------------------ 
    344  
    345 To get the graph context menu to print, copy, save data, (2D)average, etc,  
    346 *locate the mouse point on the plot to highlight and *(Mouse) Right Click*  
    347 to bring up the full menu. 
    348  
    349 .. _Zoom: 
    350  
    351 Zoom In/Out 
    352 ----------- 
    353  
    354 To Zoom in or out the full plot, *locate the mouse point inside the graph  
    355 which will be the center of the zooming, then *rotate MouseWheel*. 
    356  
    357 *To Zoom in or out the plot in x or y direction, *locate (and click) the  
    358 mouse point near x (or y) axis just outside of the graph and then *rotate  
    359 MouseWheel* .* Note that this works only on the 1D plots. 
     489 
     490This operation computes an average I(Qy) for the region of interest. 
     491 
     492When editing the slicer parameters, the user can control the length and the  
     493width the rectangular slicer. The averaged output is calculated from constant  
     494bins with rectangular shape. The resultant Q values are nominal values, that  
     495is, the central value of each bin on the x-axis. 
     496 
     497.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     498 
     499.. note::  This help document was last changed by Steve King, 18Feb2015 
  • src/sas/models/media/model_functions.rst

    rcd06a5f r7072ce6  
    1010 
    1111.. To do: 
    12 .. Remove the 'This is xi' & 'This is zeta' lines before release! 
    1312.. Add example parameters/plots for the CoreShellEllipsoidXTModel 
    1413.. Add example parameters/plots for the RectangularPrism models 
     
    2019.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
    2120 
     21 
     22.. note::  The contents of this document are awaiting proof reading. Feb2015 
    2223 
    2324 
     
    169170- RaspBerryModel_ 
    170171- CoreShellModel_ (including magnetic 2D version) 
     172- MicelleSphCoreModel_ 
    171173- CoreMultiShellModel_ (including magnetic 2D version) 
    172174- Core2ndMomentModel_ 
     
    24442446 
    24452447where |delta|\ T = tail length (or *t_length*), |delta|\ H = head thickness (or *h_thickness*), 
    2446 |drho|\ H = SLD(headgroup) - SLD(solvent), and |drho|\ T = SLD(tail) - SLD(solvent). 
     2448|drho|\ H = SLD(headgroup) - SLD(solvent), and |drho|\ T = SLD(tail) - SLD(solvent). The total thickness is 2(H+T). 
    24472449 
    24482450The 2D scattering intensity is calculated in the same way as 1D, where the *q* vector is defined as 
     
    33723374 
    33733375 
     3376.. _MicelleSphCoreModel: 
     3377 
     3378**2.1.42. MicelleSphCoreModel** 
     3379 
     3380This model provides the form factor, *P(q)*, for a micelle with a spherical core  
     3381and Gaussian polymer chains attached to the surface. 
     3382 
     3383*2.1.42.1. Definition* 
     3384 
     3385The 1D scattering intensity for this model is calculated according to the equations given by Pedersen 
     3386(Pedersen, 2000). 
     3387 
     3388*2.1.42.2. Validation of the MicelleSphCoreModel* 
     3389 
     3390This model has not yet been validated. Feb2015 
     3391 
     3392REFERENCES 
     3393 
     3394J Pedersen, *J. Appl. Cryst.*, 33 (2000) 637-640 
     3395 
     3396 
     3397 
    337433982.2 Shape-independent Functions 
    33753399------------------------------- 
  • src/sas/perspectives/calculator/image_viewer.py

    r7a04dbb reec63a8  
    5959                plot_frame = ImageFrame(parent, -1, basename, img) 
    6060                plot_frame.Show(False) 
    61                 #plot_frame.im_show(img) 
    6261                ax = plot_frame.plotpanel 
    6362                if not is_png: 
     
    7372            except: 
    7473                print "parent", parent 
    75                 raise 
    7674                err_msg += "Failed to load '%s'.\n"% basename 
    7775        if err_msg: 
     
    8078            else: 
    8179                print err_msg 
    82  
    8380         
    8481    def choose_data_file(self, location=None): 
     
    8683        Open a file dialog to allow loading a file 
    8784        """ 
    88         parent = self.parent 
    8985        path = None 
    9086        if location == None: 
    9187            location = os.getcwd() 
    92         wlist = '' 
    93         elist = ["All images (*.png, *.bmp, *.gif, *.jpg, *.tif, *.tiff) | \ 
    94                 *.png; *.bmp; *.gif; *.jpg; *.tif; *.tiff",  
    95                 "PNG files (*.PNG, *.png) | *.png",  
    96                 "BMP files (*.BMP, *.bmp) | *.bmp",  
    97                 "GIF files (*.GIF, *.gif) | *.gif", 
    98                 "JPG files (*.JPG, *.jpg) | *.jpg", 
    99                 "TIF files (*.TIF, *.tif) | *.tif", 
    100                 "TIFF files (*.TIFF, *.tiff) | *.tiff"] 
    101         if not IS_WIN: 
    102             del elist[0] 
    103         elist.append("All files (*.*) | *.*") 
    104         wlist = '|'.join(elist)         
    105         style = wx.OPEN|wx.FD_MULTIPLE 
    106         dlg = wx.FileDialog(parent, "Image Viewer: Choose a image file",  
    107                             location, "", wlist, style=style) 
     88        dlg = wx.FileDialog(self.parent, "Image Viewer: Choose a image file",  
     89                            location, "", "", style=wx.FD_OPEN|wx.FD_MULTIPLE) 
    10890        if dlg.ShowModal() == wx.ID_OK: 
    10991            path = dlg.GetPaths() 
  • src/sas/perspectives/calculator/media/data_operator_help.rst

    r98b30b4 r684fade  
    99Description 
    1010----------- 
    11 This dialog panel provides arithmetic operations between two data sets (the  
    12 last data set could be a number). 
    1311 
    14 When data1 and data2 are selected, their x (or qx and qy for 2D) value(s) 
    15 must match with each other. 
     12This tool permits arithmetic operations between two data sets. Alternatively,  
     13the last data set can be a number. 
     14 
     15*NOTE! When* Data1 *and* Data2 *are both data, their Q (or Qx and Qy for 2D)  
     16value(s) must match with each other UNLESS using the 'append' operator.* 
    1617 
    1718.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     
    1920How To 
    2021------ 
    21 1. Type the data name resulted from an operation. 
    2222 
    23 2) Select a data/theory in the drop down menus. When data2 is set to number,  
    24    type a number in the text control box. 
     231) Enure you have loaded data into the *Data Explorer* (see :ref:`Load_Data`). 
    2524 
    26 3) Select an arithmetic operator symbol; + (for addition), - (for subtraction),  
    27    * (for multiplication), / (for division), and | (for combination of two data 
    28    sets). 
     252) Select *Data Operation* from the *Tool* menu on the SasView toolbar. 
    2926 
    30    If two data sets do not match, the operation will fail and the background color 
    31    of the combo box items will turn to red (WIN only). 
     273) Select a dataset/theory in the drop-down menu *Data1*. A mini-plot of the 
     28   data will appear underneath. 
    3229 
    33 4) If the operation is successful, hit the Apply button to make the new data. 
    34    Then the data name will be shown up in the data box in the data explorer. 
     304) Select a dataset/theory in the drop-down menu *Data2* or select *Number*  
     31   and enter a number in the box that appears alongside. 
    3532 
    36 Note: Any errors and warnings will be displayed at the bottom of the SasView 
    37 window. 
     335) Select an arithmetic operator symbol from the *Operator* drop-down. The  
     34   available operators are: 
     35    
     36*  + (for addition) 
     37*  - (for subtraction),  
     38*  * (for multiplication) 
     39*  / (for division) 
     40*  | (for combination of two data sets) 
     41 
     42   If two data sets do not match, the operation will fail and the background  
     43   color of the combo box items will turn to red (WIN only). 
     44 
     456) If the operation is successful, hit the Apply button to make the new dataset. 
     46   The new dataset will appear in the *Data Explorer*. 
     47 
     48*NOTE! Any errors and warnings will be displayed at the bottom of the SasView 
     49window.* 
    3850 
    3951.. image:: data_oper_pic.png 
     52 
     53.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     54 
     55.. note::  This help document was last changed by Steve King, 18Feb2015  
  • src/sas/perspectives/calculator/media/density_calculator_help.rst

    rec392464 r054a3ad  
    1010----------- 
    1111 
    12 This tool is to calculate the mass density from the molar volume or vice  
     12This tool calculates the mass density from the molar volume or vice  
    1313versa. To calculate the mass density, the chemical formula and molar volume  
    1414should be provided. 
     
    1919------ 
    2020 
    21 1. Molecular Formula: The chemical formula of ONE molecule or ONE atom. For  
    22 mixtures, the ratio of the each molecules should be used; for example,  
    23 (H2O)0.5(D2O)0.5. 
     211) Enter the empirical formula of a molecule. For mixtures, the ratio of each  
     22   of the molecules should be used, for example, (H2O)0.5(D2O)0.5. 
    2423 
    25 2. Select input (molar volume or mass density) from combobox. Then type in the  
    26 input value. 
     242) Use the input combo box to choose between molar volume or mass density and  
     25   then type in an input value. 
    2726 
    28 3. Click the 'Calculate' button to perform the calculation. 
    29  
    30 4. Outputs also include the molar mass (weight) that depends only on the  
    31 chemical formula 
     273) Click the 'Calculate' button to perform the calculation. 
    3228 
    3329.. image:: density_tutor.gif 
     30 
     31.. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 
     32 
     33.. note::  This help document was last changed by Steve King, 18Feb2015 
  • src/sas/perspectives/fitting/batchfitpage.py

    r79492222 rfa09d62  
    1717from sas.models.qsmearing import smear_selection 
    1818from sas.perspectives.fitting.fitpage import FitPage 
     19from sas.perspectives.fitting.fitpage import check_data_validity 
    1920 
    2021class BatchFitPage(FitPage): 
     
    3031        """ 
    3132        FitPage.__init__(self, parent, color=color) 
    32         self.window_name = "BatchFit" 
    33         self.window_caption  = "BatchFit" 
    34         self._set_save_flag(False) 
    35         self._set_bookmark_flag(False) 
    36          
    37     def _fill_range_sizer(self): 
     33         
     34        ## draw sizer 
     35         
     36    def _fill_data_sizer(self): 
    3837        """ 
    39         Fill the sizer containing the plotting range 
    40         add  access to npts 
     38        fill sizer 0 with data info 
    4139        """ 
    42         is_2Ddata = False 
    43          
    44         # Check if data is 2D 
    45         if self.data.__class__.__name__ ==  "Data2D" or \ 
    46                         self.enable2D: 
    47             is_2Ddata = True 
    48              
    49         title = "Fitting"      
    50         self._get_smear_info() 
    51          
    52         #Sizers 
    53         box_description_range = wx.StaticBox(self, -1, str(title)) 
    54         boxsizer_range = wx.StaticBoxSizer(box_description_range, wx.VERTICAL)       
    55         self.sizer_set_smearer = wx.BoxSizer(wx.VERTICAL) 
    56         #sizer_smearer = wx.BoxSizer(wx.HORIZONTAL) 
    57         self.sizer_new_smear = wx.BoxSizer(wx.HORIZONTAL) 
    58         self.sizer_set_masking = wx.BoxSizer(wx.HORIZONTAL) 
    59         sizer_chi2 = wx.BoxSizer(wx.VERTICAL) 
    60  
    61         sizer_fit = wx.GridSizer(2, 4, 2, 6) 
    62         #Fit button 
    63         self.btFit = wx.Button(self, wx.NewId(), 'Fit', size=(88, 25)) 
    64         self.default_bt_colour =  self.btFit.GetDefaultAttributes() 
    65         self.btFit.Bind(wx.EVT_BUTTON, self._onFit, id= self.btFit.GetId()) 
    66         self.btFit.SetToolTipString("Start fitting.") 
    67  
    68         # Update and Draw button 
    69         self.draw_button = wx.Button(self, wx.NewId(), 'Compute', size=(88, 24)) 
    70         self.draw_button.Bind(wx.EVT_BUTTON, \ 
    71                               self._onDraw,id=self.draw_button.GetId()) 
    72         self.draw_button.SetToolTipString("Compute and Draw.")   
    73         sizer_fit.Add(self.draw_button, 0, 0) 
    74         sizer_fit.Add(self.btFit, 0, 0)  
    75         sizer_chi2.Add((-1, 5)) 
    76         # get smear_selection 
    77         self.current_smearer = smear_selection( self.data, self.model ) 
    78         boxsizer_range.Add(self.sizer_set_masking) 
    79          #2D data? default 
    80         is_2Ddata = False 
    81          
    82         #check if it is 2D data 
    83         if self.data.__class__.__name__ ==  "Data2D" or \ 
    84                         self.enable2D: 
    85             is_2Ddata = True 
    86              
    87         self.sizer5.Clear(True) 
    88       
    89         self.qmin  = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),  
    90                                           style=wx.TE_PROCESS_ENTER,  
    91                                     text_enter_callback = self._onQrangeEnter) 
    92         self.qmin.SetValue(str(self.qmin_x)) 
    93         self.qmin.SetToolTipString("Minimun value of Q in linear scale.") 
    94       
    95         self.qmax  = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),  
    96                                           style=wx.TE_PROCESS_ENTER,  
    97                                         text_enter_callback=self._onQrangeEnter) 
    98         self.qmax.SetValue(str(self.qmax_x)) 
    99         self.qmax.SetToolTipString("Maximum value of Q in linear scale.") 
    100          
    101         id = wx.NewId() 
    102         self.reset_qrange =wx.Button(self, id, 'Reset', size=(77, 20)) 
    103        
    104         self.reset_qrange.Bind(wx.EVT_BUTTON, self.on_reset_clicked, id=id) 
    105         self.reset_qrange.SetToolTipString(\ 
    106                                     "Reset Q range to the default values") 
    107       
    108         sizer_horizontal = wx.BoxSizer(wx.HORIZONTAL) 
    109         sizer = wx.GridSizer(2, 4, 2, 6) 
    110  
    111         self.btEditMask = wx.Button(self, wx.NewId(),'Editor', size=(88, 23)) 
    112         self.btEditMask.Bind(wx.EVT_BUTTON,  
    113                              self._onMask,id=self.btEditMask.GetId()) 
    114         self.btEditMask.SetToolTipString("Edit Mask.") 
    115         self.EditMask_title = wx.StaticText(self, -1, ' Masking(2D)') 
    116  
    117         sizer.Add(wx.StaticText(self, -1, 'Q range'))      
    118         sizer.Add(wx.StaticText(self, -1, ' Min[1/A]')) 
    119         sizer.Add(wx.StaticText(self, -1, ' Max[1/A]')) 
    120         sizer.Add(self.EditMask_title) 
    121   
    122         sizer.Add(self.reset_qrange)    
    123         sizer.Add(self.qmin) 
    124         sizer.Add(self.qmax) 
    125  
    126         sizer.Add(self.btEditMask) 
    127         boxsizer_range.Add(sizer_chi2)  
    128         boxsizer_range.Add((10, 10)) 
    129         boxsizer_range.Add(sizer) 
    130          
    131         boxsizer_range.Add((10, 15)) 
    132         boxsizer_range.Add(sizer_fit) 
    133         if is_2Ddata: 
    134             self.btEditMask.Enable()   
    135             self.EditMask_title.Enable()  
     40        self.data_box_description = wx.StaticBox(self, -1, 'I(q) Data Source') 
     41        if check_data_validity(self.data): 
     42            dname_color = wx.BLUE 
    13643        else: 
    137             self.btEditMask.Disable()   
    138             self.EditMask_title.Disable() 
    139  
    140         ## save state 
    141         #self.save_current_state() 
    142  
    143         self.sizer5.Add(boxsizer_range, 0, wx.EXPAND | wx.ALL, 10) 
    144         self.sizer5.Layout() 
    145         
    146     def _on_select_model(self, event=None):  
    147         """ 
    148         call back for model selection 
    149         """   
    150          
    151         self.Show(False)     
    152         self._on_select_model_helper()  
    153         self.set_model_param_sizer(self.model)                    
    154         if self.model is None: 
    155             self._set_bookmark_flag(False) 
    156             self._keep.Enable(False) 
    157             self._set_save_flag(False) 
    158         self.enable_disp.SetValue(False) 
    159         self.disable_disp.SetValue(True) 
    160         try: 
    161             self.set_dispers_sizer() 
    162         except: 
    163             pass 
    164         self.state.structurecombobox = self.structurebox.GetCurrentSelection() 
    165         self.state.formfactorcombobox = self.formfactorbox.GetCurrentSelection() 
    166        
    167         if self.model != None: 
    168             self._set_copy_flag(True) 
    169             self._set_paste_flag(True) 
    170             if self.data != None: 
    171                 self._set_bookmark_flag(False) 
    172                 self._keep.Enable(False) 
    173                  
    174             temp_smear = None 
    175             ## event to post model to fit to fitting plugins 
    176             (ModelEventbox, _) = wx.lib.newevent.NewEvent() 
    177           
    178             ## set smearing value whether or not  
    179             #    the data contain the smearing info 
    180             evt = ModelEventbox(model=self.model,  
    181                                         smearer=temp_smear,  
    182                                         qmin=float(self.qmin_x), 
    183                                         uid=self.uid, 
    184                                      qmax=float(self.qmax_x))  
    185     
    186             self._manager._on_model_panel(evt=evt) 
    187             self.mbox_description.SetLabel("Model [%s]" % str(self.model.name)) 
    188             self.state.model = self.model.clone() 
    189             self.state.model.name = self.model.name 
    190  
    191              
    192         if event != None: 
    193             ## post state to fit panel 
    194             new_event = PageInfoEvent(page = self) 
    195             wx.PostEvent(self.parent, new_event)  
    196             #update list of plugins if new plugin is available 
    197             if self.plugin_rbutton.GetValue(): 
    198                 temp = self.parent.update_model_list() 
    199                 if temp: 
    200                     self.model_list_box = temp 
    201                     current_val = self.formfactorbox.GetValue() 
    202                     pos = self.formfactorbox.GetSelection() 
    203                     self._show_combox_helper() 
    204                     self.formfactorbox.SetSelection(pos) 
    205                     self.formfactorbox.SetValue(current_val) 
    206             self._onDraw(event=None) 
    207         else: 
    208             self._draw_model() 
    209         self.SetupScrolling() 
    210         self.Show(True)    
    211          
    212     def _update_paramv_on_fit(self): 
    213         """ 
    214         make sure that update param values just before the fitting 
    215         """ 
    216         #flag for qmin qmax check values 
    217         flag = True 
    218         self.fitrange = True 
    219         is_modified = False 
    220  
    221         if self.model != None:            
    222             ##Check the values 
    223             self._check_value_enter( self.fittable_param, is_modified) 
    224             self._check_value_enter( self.fixed_param, is_modified) 
    225             self._check_value_enter( self.parameters, is_modified) 
    226  
    227             # If qmin and qmax have been modified, update qmin and qmax and  
    228              # Here we should check whether the boundaries have been modified. 
    229             # If qmin and qmax have been modified, update qmin and qmax and  
    230             # set the is_modified flag to True 
    231             self.fitrange = self._validate_qrange(self.qmin, self.qmax) 
    232             if self.fitrange: 
    233                 tempmin = float(self.qmin.GetValue()) 
    234                 if tempmin != self.qmin_x: 
    235                     self.qmin_x = tempmin 
    236                 tempmax = float(self.qmax.GetValue()) 
    237                 if tempmax != self.qmax_x: 
    238                     self.qmax_x = tempmax 
    239                 if tempmax == tempmin: 
    240                     flag = False     
    241                 #temp_smearer = None 
    242                 if self._is_2D(): 
    243                     # only 2D case set mask   
    244                     flag = self._validate_Npts() 
    245                     if not flag: 
    246                         return flag 
    247             else: flag = False 
    248         else:  
    249             flag = False 
    250  
    251         #For invalid q range, disable the mask editor and fit button, vs.     
    252         if not self.fitrange: 
    253             #self.btFit.Disable() 
    254             if self._is_2D(): 
    255                 self.btEditMask.Disable() 
    256         else: 
    257             #self.btFit.Enable(True) 
    258             if self._is_2D() and  self.data != None: 
    259                 self.btEditMask.Enable(True) 
    260  
    261         if not flag: 
    262             msg = "Cannot Plot or Fit :Must select a " 
    263             msg += " model or Fitting range is not valid!!!  " 
    264             wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 
    265          
    266         self.save_current_state() 
    267     
    268         return flag   
    269     def save_current_state(self): 
    270         """ 
    271         Currently no save option implemented for batch page 
    272         """ 
    273         pass  
    274     def save_current_state_fit(self): 
    275         """ 
    276         Currently no save option implemented for batch page 
    277         """ 
    278         pass 
    279     def set_data(self, data): 
    280         """ 
    281         reset the current data  
    282         """ 
    283         #id = None 
    284         group_id = None 
    285         flag = False 
    286         if self.data is None and data is not None: 
    287             flag = True 
    288         if data is not None: 
    289             #id = data.id 
    290             group_id = data.group_id 
    291             if self.data is not None: 
    292                 flag = (data.id != self.data.id) 
    293         self.data = data 
    294         if self.data is None: 
    295             data_min = "" 
    296             data_max = "" 
    297             data_name = "" 
    298             self._set_bookmark_flag(False) 
    299             self._keep.Enable(False) 
    300             self._set_save_flag(False) 
    301         else: 
    302             if self.model != None: 
    303                 self._set_bookmark_flag(False) 
    304                 self._keep.Enable(False) 
    305             self._set_save_flag(False) 
    306             self._set_preview_flag(True) 
    307    
    308             self.formfactorbox.Enable() 
    309             self.structurebox.Enable() 
    310             data_name = self.data.name 
    311             #set maximum range for x in linear scale 
    312             if not hasattr(self.data,"data"): #Display only for 1D data fit 
    313                 # Minimum value of data    
    314                 data_min = min(self.data.x) 
    315                 # Maximum value of data   
    316                 data_max = max(self.data.x) 
    317                 self.btEditMask.Disable()   
    318                 self.EditMask_title.Disable() 
    319             else: 
    320                  
    321                 ## Minimum value of data  
    322                 data_min = 0 
    323                 x = max(math.fabs(self.data.xmin), math.fabs(self.data.xmax))  
    324                 y = max(math.fabs(self.data.ymin), math.fabs(self.data.ymax)) 
    325                 ## Maximum value of data   
    326                 data_max = math.sqrt(x*x + y*y) 
    327                 self.btEditMask.Enable()   
    328                 self.EditMask_title.Enable()  
    329  
    330         self.dataSource.SetValue(data_name) 
    331         self.qmin_x = data_min 
    332         self.qmax_x = data_max 
    333         #self.minimum_q.SetValue(str(data_min)) 
    334         #self.maximum_q.SetValue(str(data_max)) 
    335         self.qmin.SetValue(str(data_min)) 
    336         self.qmax.SetValue(str(data_max)) 
    337         self.qmin.SetBackgroundColour("white") 
    338         self.qmax.SetBackgroundColour("white") 
    339         self.state.data = data 
    340         self.state.qmin = self.qmin_x 
    341         self.state.qmax = self.qmax_x 
    342          
    343         #update model plot with new data information 
    344         if flag: 
    345             #set model view button 
    346             if self.data.__class__.__name__ == "Data2D": 
    347                 self.enable2D = True 
    348                 self.model_view.SetLabel("2D Mode") 
    349             else: 
    350                 self.enable2D = False 
    351                 self.model_view.SetLabel("1D Mode") 
    352                  
    353             self.model_view.Disable() 
    354              
    355             wx.PostEvent(self._manager.parent,  
    356                              NewPlotEvent(group_id=group_id, 
    357                                                action="delete")) 
    358             #plot the current selected data 
    359             wx.PostEvent(self._manager.parent, NewPlotEvent(plot=self.data,  
    360                                                     title=str(self.data.title))) 
    361             self._manager.store_data(uid=self.uid, data=data, 
    362                                      data_list=self.data_list, 
    363                                       caption=self.window_name) 
    364             self._draw_model() 
     44            dname_color = wx.RED 
     45        self.data_box_description.SetForegroundColour(dname_color) 
     46        boxsizer1 = wx.StaticBoxSizer(self.data_box_description, wx.VERTICAL) 
     47        #---------------------------------------------------------- 
     48        sizer_data = wx.BoxSizer(wx.VERTICAL) 
     49        text1 = wx.StaticText(self, -1, ' - Choose a file to set initial fit parameters -') 
     50        text1.SetForegroundColour(wx.RED) 
     51        sizer_data.Add(text1) 
     52        text2 = wx.StaticText(self, -1, ' - This panel is not designed to view individual fits. - ') 
     53        text2.SetForegroundColour(wx.RED) 
     54        sizer_data.Add(text2) 
     55         
     56        combo = wx.BoxSizer(wx.HORIZONTAL) 
     57        self.dataSource = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
     58        wx.EVT_COMBOBOX(self.dataSource, -1, self.on_select_data) 
     59        self.dataSource.SetMinSize((_DATA_BOX_WIDTH, -1)) 
     60         
     61        combo.Add(wx.StaticText(self, -1, 'Name : ')) 
     62        combo.Add((0,5)) 
     63        combo.Add(self.dataSource) 
     64         
     65        sizer_data.Add(combo, 0, wx.ALL, 10) 
     66        boxsizer1.Add(sizer_data, 0, wx.ALL, 0) 
     67        self.sizer0.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 
     68        self.sizer0.Layout() 
     69 
     70#    COMMENTED OUT TO USE METHODS INHERITED FROM fitpage.py 
     71         
     72#     def _fill_range_sizer(self): 
     73#         """ 
     74#         Fill the sizer containing the plotting range 
     75#         add  access to npts 
     76#         """ 
     77#         is_2Ddata = False 
     78#          
     79#         # Check if data is 2D 
     80#         if self.data.__class__.__name__ ==  "Data2D" or \ 
     81#                         self.enable2D: 
     82#             is_2Ddata = True 
     83#              
     84#         title = "Fitting"      
     85#         self._get_smear_info() 
     86#          
     87#         #Sizers 
     88#         box_description_range = wx.StaticBox(self, -1, str(title)) 
     89#         boxsizer_range = wx.StaticBoxSizer(box_description_range, wx.VERTICAL)       
     90#         self.sizer_set_smearer = wx.BoxSizer(wx.VERTICAL) 
     91#         #sizer_smearer = wx.BoxSizer(wx.HORIZONTAL) 
     92#         self.sizer_new_smear = wx.BoxSizer(wx.HORIZONTAL) 
     93#         self.sizer_set_masking = wx.BoxSizer(wx.HORIZONTAL) 
     94#         sizer_chi2 = wx.BoxSizer(wx.VERTICAL) 
     95#  
     96#         sizer_fit = wx.GridSizer(2, 4, 2, 6) 
     97#         #Fit button 
     98#         self.btFit = wx.Button(self, wx.NewId(), 'Fit', size=(88, 25)) 
     99#         self.default_bt_colour =  self.btFit.GetDefaultAttributes() 
     100#         self.btFit.Bind(wx.EVT_BUTTON, self._onFit, id= self.btFit.GetId()) 
     101#         self.btFit.SetToolTipString("Start fitting.") 
     102#  
     103#         # Update and Draw button 
     104#         self.draw_button = wx.Button(self, wx.NewId(), 'Compute', size=(88, 24)) 
     105#         self.draw_button.Bind(wx.EVT_BUTTON, \ 
     106#                               self._onDraw,id=self.draw_button.GetId()) 
     107#         self.draw_button.SetToolTipString("Compute and Draw.")   
     108#         sizer_fit.Add(self.draw_button, 0, 0) 
     109#         sizer_fit.Add(self.btFit, 0, 0)  
     110#         sizer_chi2.Add((-1, 5)) 
     111#         # get smear_selection 
     112#         self.current_smearer = smear_selection( self.data, self.model ) 
     113#         boxsizer_range.Add(self.sizer_set_masking) 
     114#          #2D data? default 
     115#         is_2Ddata = False 
     116#          
     117#         #check if it is 2D data 
     118#         if self.data.__class__.__name__ ==  "Data2D" or \ 
     119#                         self.enable2D: 
     120#             is_2Ddata = True 
     121#              
     122#         self.sizer5.Clear(True) 
     123#       
     124#         self.qmin  = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),  
     125#                                           style=wx.TE_PROCESS_ENTER,  
     126#                                     text_enter_callback = self._onQrangeEnter) 
     127#         self.qmin.SetValue(str(self.qmin_x)) 
     128#         self.qmin.SetToolTipString("Minimun value of Q in linear scale.") 
     129#       
     130#         self.qmax  = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),  
     131#                                           style=wx.TE_PROCESS_ENTER,  
     132#                                         text_enter_callback=self._onQrangeEnter) 
     133#         self.qmax.SetValue(str(self.qmax_x)) 
     134#         self.qmax.SetToolTipString("Maximum value of Q in linear scale.") 
     135#          
     136#         id = wx.NewId() 
     137#         self.reset_qrange =wx.Button(self, id, 'Reset', size=(77, 20)) 
     138#        
     139#         self.reset_qrange.Bind(wx.EVT_BUTTON, self.on_reset_clicked, id=id) 
     140#         self.reset_qrange.SetToolTipString(\ 
     141#                                     "Reset Q range to the default values") 
     142#       
     143#         sizer_horizontal = wx.BoxSizer(wx.HORIZONTAL) 
     144#         sizer = wx.GridSizer(2, 4, 2, 6) 
     145#  
     146#         self.btEditMask = wx.Button(self, wx.NewId(),'Editor', size=(88, 23)) 
     147#         self.btEditMask.Bind(wx.EVT_BUTTON,  
     148#                              self._onMask,id=self.btEditMask.GetId()) 
     149#         self.btEditMask.SetToolTipString("Edit Mask.") 
     150#         self.EditMask_title = wx.StaticText(self, -1, ' Masking(2D)') 
     151#  
     152#         sizer.Add(wx.StaticText(self, -1, 'Q range'))      
     153#         sizer.Add(wx.StaticText(self, -1, ' Min[1/A]')) 
     154#         sizer.Add(wx.StaticText(self, -1, ' Max[1/A]')) 
     155#         sizer.Add(self.EditMask_title) 
     156 
     157#         sizer.Add(self.reset_qrange)    
     158#         sizer.Add(self.qmin) 
     159#         sizer.Add(self.qmax) 
     160#  
     161#         sizer.Add(self.btEditMask) 
     162#         boxsizer_range.Add(sizer_chi2)  
     163#         boxsizer_range.Add((10, 10)) 
     164#         boxsizer_range.Add(sizer) 
     165#          
     166#         boxsizer_range.Add((10, 15)) 
     167#         boxsizer_range.Add(sizer_fit) 
     168#         if is_2Ddata: 
     169#             self.btEditMask.Enable()   
     170#             self.EditMask_title.Enable()  
     171#         else: 
     172#             self.btEditMask.Disable()   
     173#             self.EditMask_title.Disable() 
     174#  
     175#         ## save state 
     176#         #self.save_current_state() 
     177#  
     178#         self.sizer5.Add(boxsizer_range, 0, wx.EXPAND | wx.ALL, 10) 
     179#         self.sizer5.Layout() 
     180#         
     181#     def _on_select_model(self, event=None):  
     182#         """ 
     183#         call back for model selection 
     184#         """   
     185#          
     186#         self.Show(False)     
     187#         self._on_select_model_helper()  
     188#         self.set_model_param_sizer(self.model)                    
     189#         if self.model is None: 
     190#             self._set_bookmark_flag(False) 
     191#             self._keep.Enable(False) 
     192#             self._set_save_flag(False) 
     193#         self.enable_disp.SetValue(False) 
     194#         self.disable_disp.SetValue(True) 
     195#         try: 
     196#             self.set_dispers_sizer() 
     197#         except: 
     198#             pass 
     199#         self.state.structurecombobox = self.structurebox.GetCurrentSelection() 
     200#         self.state.formfactorcombobox = self.formfactorbox.GetCurrentSelection() 
     201#        
     202#         if self.model != None: 
     203#             self._set_copy_flag(True) 
     204#             self._set_paste_flag(True) 
     205#             if self.data != None: 
     206#                 self._set_bookmark_flag(False) 
     207#                 self._keep.Enable(False) 
     208#                  
     209#             temp_smear = None 
     210#             ## event to post model to fit to fitting plugins 
     211#             (ModelEventbox, _) = wx.lib.newevent.NewEvent() 
     212#           
     213#             ## set smearing value whether or not  
     214#             #    the data contain the smearing info 
     215#             evt = ModelEventbox(model=self.model,  
     216#                                         smearer=temp_smear,  
     217#                                         qmin=float(self.qmin_x), 
     218#                                         uid=self.uid, 
     219#                                      qmax=float(self.qmax_x))  
     220#     
     221#             self._manager._on_model_panel(evt=evt) 
     222#             self.mbox_description.SetLabel("Model [%s]" % str(self.model.name)) 
     223#             self.state.model = self.model.clone() 
     224#             self.state.model.name = self.model.name 
     225#  
     226#              
     227#         if event != None: 
     228#             ## post state to fit panel 
     229#             new_event = PageInfoEvent(page = self) 
     230#             wx.PostEvent(self.parent, new_event)  
     231#             #update list of plugins if new plugin is available 
     232#             if self.plugin_rbutton.GetValue(): 
     233#                 temp = self.parent.update_model_list() 
     234#                 if temp: 
     235#                     self.model_list_box = temp 
     236#                     current_val = self.formfactorbox.GetValue() 
     237#                     pos = self.formfactorbox.GetSelection() 
     238#                     self._show_combox_helper() 
     239#                     self.formfactorbox.SetSelection(pos) 
     240#                     self.formfactorbox.SetValue(current_val) 
     241#             self._onDraw(event=None) 
     242#         else: 
     243#             self._draw_model() 
     244#         self.SetupScrolling() 
     245#         self.Show(True)    
     246#          
     247#     def _update_paramv_on_fit(self): 
     248#         """ 
     249#         make sure that update param values just before the fitting 
     250#         """ 
     251#         #flag for qmin qmax check values 
     252#         flag = True 
     253#         self.fitrange = True 
     254#         is_modified = False 
     255#  
     256#         if self.model != None:            
     257#             ##Check the values 
     258#             self._check_value_enter( self.fittable_param, is_modified) 
     259#             self._check_value_enter( self.fixed_param, is_modified) 
     260#             self._check_value_enter( self.parameters, is_modified) 
     261#  
     262#             # If qmin and qmax have been modified, update qmin and qmax and  
     263#              # Here we should check whether the boundaries have been modified. 
     264#             # If qmin and qmax have been modified, update qmin and qmax and  
     265#             # set the is_modified flag to True 
     266#             self.fitrange = self._validate_qrange(self.qmin, self.qmax) 
     267#             if self.fitrange: 
     268#                 tempmin = float(self.qmin.GetValue()) 
     269#                 if tempmin != self.qmin_x: 
     270#                     self.qmin_x = tempmin 
     271#                 tempmax = float(self.qmax.GetValue()) 
     272#                 if tempmax != self.qmax_x: 
     273#                     self.qmax_x = tempmax 
     274#                 if tempmax == tempmin: 
     275#                     flag = False     
     276#                 #temp_smearer = None 
     277#                 if self._is_2D(): 
     278#                     # only 2D case set mask   
     279#                     flag = self._validate_Npts() 
     280#                     if not flag: 
     281#                         return flag 
     282#             else: flag = False 
     283#         else:  
     284#             flag = False 
     285#  
     286#         #For invalid q range, disable the mask editor and fit button, vs.     
     287#         if not self.fitrange: 
     288#             #self.btFit.Disable() 
     289#             if self._is_2D(): 
     290#                 self.btEditMask.Disable() 
     291#         else: 
     292#             #self.btFit.Enable(True) 
     293#             if self._is_2D() and  self.data != None: 
     294#                 self.btEditMask.Enable(True) 
     295#  
     296#         if not flag: 
     297#             msg = "Cannot Plot or Fit :Must select a " 
     298#             msg += " model or Fitting range is not valid!!!  " 
     299#             wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 
     300#          
     301#         self.save_current_state() 
     302#     
     303#         return flag   
     304#     def save_current_state(self): 
     305#         """ 
     306#         Currently no save option implemented for batch page 
     307#         """ 
     308#         pass  
     309#     def save_current_state_fit(self): 
     310#         """ 
     311#         Currently no save option implemented for batch page 
     312#         """ 
     313#         pass 
     314#     def set_data(self, data): 
     315#         """ 
     316#         reset the current data  
     317#         """ 
     318#         #id = None 
     319#         group_id = None 
     320#         flag = False 
     321#         if self.data is None and data is not None: 
     322#             flag = True 
     323#         if data is not None: 
     324#             #id = data.id 
     325#             group_id = data.group_id 
     326#             if self.data is not None: 
     327#                 flag = (data.id != self.data.id) 
     328#         self.data = data 
     329#         if self.data is None: 
     330#             data_min = "" 
     331#             data_max = "" 
     332#             data_name = "" 
     333#             self._set_bookmark_flag(False) 
     334#             self._keep.Enable(False) 
     335#             self._set_save_flag(False) 
     336#         else: 
     337#             if self.model != None: 
     338#                 self._set_bookmark_flag(False) 
     339#                 self._keep.Enable(False) 
     340#             self._set_save_flag(False) 
     341#             self._set_preview_flag(True) 
     342#    
     343#             self.formfactorbox.Enable() 
     344#             self.structurebox.Enable() 
     345#             data_name = self.data.name 
     346#             #set maximum range for x in linear scale 
     347#             if not hasattr(self.data,"data"): #Display only for 1D data fit 
     348#                 # Minimum value of data    
     349#                 data_min = min(self.data.x) 
     350#                 # Maximum value of data   
     351#                 data_max = max(self.data.x) 
     352#                 self.btEditMask.Disable()   
     353#                 self.EditMask_title.Disable() 
     354#             else: 
     355#                  
     356#                 ## Minimum value of data  
     357#                 data_min = 0 
     358#                 x = max(math.fabs(self.data.xmin), math.fabs(self.data.xmax))  
     359#                 y = max(math.fabs(self.data.ymin), math.fabs(self.data.ymax)) 
     360#                 ## Maximum value of data   
     361#                 data_max = math.sqrt(x*x + y*y) 
     362#                 self.btEditMask.Enable()   
     363#                 self.EditMask_title.Enable()  
     364#  
     365#         self.dataSource.SetValue(data_name) 
     366#         self.qmin_x = data_min 
     367#         self.qmax_x = data_max 
     368#         #self.minimum_q.SetValue(str(data_min)) 
     369#         #self.maximum_q.SetValue(str(data_max)) 
     370#         self.qmin.SetValue(str(data_min)) 
     371#         self.qmax.SetValue(str(data_max)) 
     372#         self.qmin.SetBackgroundColour("white") 
     373#         self.qmax.SetBackgroundColour("white") 
     374#         self.state.data = data 
     375#         self.state.qmin = self.qmin_x 
     376#         self.state.qmax = self.qmax_x 
     377#          
     378#         #update model plot with new data information 
     379#         if flag: 
     380#             #set model view button 
     381#             if self.data.__class__.__name__ == "Data2D": 
     382#                 self.enable2D = True 
     383#                 self.model_view.SetLabel("2D Mode") 
     384#             else: 
     385#                 self.enable2D = False 
     386#                 self.model_view.SetLabel("1D Mode") 
     387#                  
     388#             self.model_view.Disable() 
     389#              
     390#             wx.PostEvent(self._manager.parent,  
     391#                              NewPlotEvent(group_id=group_id, 
     392#                                                action="delete")) 
     393#             #plot the current selected data 
     394#             wx.PostEvent(self._manager.parent, NewPlotEvent(plot=self.data,  
     395#                                                     title=str(self.data.title))) 
     396#             self._manager.store_data(uid=self.uid, data=data, 
     397#                                      data_list=self.data_list, 
     398#                                       caption=self.window_name) 
     399#             self._draw_model() 
    365400     
    366401 
  • src/sas/perspectives/fitting/fitpanel.py

    r79492222 rfa09d62  
    371371        """ 
    372372        from fitpage import FitPage 
    373         panel = FitPage(parent=self) 
     373        from batchfitpage import BatchFitPage 
    374374        if self.batch_on: 
     375            panel = BatchFitPage(parent=self) 
    375376            self.batch_page_index += 1 
    376377            caption = "BatchPage" + str(self.batch_page_index) 
     
    378379        else: 
    379380            #Increment index of fit page 
     381            panel = FitPage(parent=self) 
    380382            self.fit_page_index += 1 
    381383            caption = "FitPage" + str(self.fit_page_index) 
     
    467469        if data_1d_list and data_2d_list: 
    468470            # need to warning the user that this batch is a special case 
    469             from sas import BatchDataDialog 
     471            from sas.perspectives.fitting.fitting_widgets import BatchDataDialog 
    470472            dlg = BatchDataDialog(self) 
    471473            if dlg.ShowModal() == wx.ID_OK: 
  • src/sas/perspectives/fitting/report_dialog.py

    r4ec242e re8bb5b6  
    1414 
    1515import wx 
    16 import sys 
    1716import os 
    1817import wx.html as html 
    19 import logging 
    2018 
    21 _STATICBOX_WIDTH = 480 
    22 PANEL_WIDTH = 530 
    23 PANEL_HEIGHT = 700 
    24 FONT_VARIANT = 1 
    25 ISMAC = False 
    26 ISPDF = False 
    27 if sys.platform == "win32": 
    28     _STATICBOX_WIDTH = 450 
    29     PANEL_WIDTH = 500 
    30     PANEL_HEIGHT = 700 
    31     FONT_VARIANT = 0 
    32     ISMAC = False 
    33     ISPDF = True 
    34 elif sys.platform == "darwin": 
    35     ISMAC = True 
    36     ISPDF = True 
     19from sas.guiframe.report_dialog import BaseReportDialog 
    3720 
    38          
    39 class ReportDialog(wx.Dialog): 
     21class ReportDialog(BaseReportDialog): 
    4022    """ 
    4123    The report dialog box. 
    4224    """ 
    4325     
    44     def __init__(self, list, *args, **kwds): 
     26    def __init__(self, report_list, *args, **kwds): 
    4527        """ 
    4628        Initialization. The parameters added to Dialog are: 
    4729         
    48         :param list: report_list (list of html_str, text_str, image) 
     30        :param report_list: list of html_str, text_str, image 
    4931        from invariant_state 
    5032        """ 
    51         kwds["style"] = wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE 
    52         wx.Dialog.__init__(self, *args, **kwds) 
    53         kwds["image"] = 'Dynamic Image' 
     33        super(ReportDialog, self).__init__(report_list, *args, **kwds) 
     34 
    5435        # title 
    5536        self.SetTitle("Report: Fitting") 
    56         # size 
    57         self.SetSize((720, 650)) 
    58         # font size 
    59         self.SetWindowVariant(variant=FONT_VARIANT) 
    60         # check if tit is MAC 
    61         self.is_pdf = ISPDF 
    62         # report string 
    63         self.report_list = list 
     37 
    6438        # number of images of plot 
    65         self.nimages = len(list[2]) 
     39        self.nimages = len(self.report_list[2]) 
    6640         
    67         if list[2] != None: 
     41        if self.report_list[2] != None: 
    6842            # put image path in the report string 
    69             if len(list[2]) == 1: 
     43            if len(self.report_list[2]) == 1: 
    7044                self.report_html = self.report_list[0] % \ 
    7145                                    "memory:img_fit0.png" 
    72             elif len(list[2]) == 2: 
     46            elif len(self.report_list) == 2: 
    7347                self.report_html = self.report_list[0] % \ 
    7448                                    ("memory:img_fit0.png", 
     
    8559        self._setup_layout() 
    8660         
    87     def _setup_layout(self): 
    88         """ 
    89         Set up layout 
    90         """ 
    91         hbox = wx.BoxSizer(wx.HORIZONTAL) 
    92          
    93         # buttons 
    94         id = wx.ID_OK 
    95         button_close = wx.Button(self, id, "Close") 
    96         button_close.SetToolTipString("Close this report window.") 
    97         #hbox.Add((5,10), 1 , wx.EXPAND|wx.ADJUST_MINSIZE,0) 
    98         hbox.Add(button_close) 
    99         button_close.SetFocus() 
    100  
    101         id = wx.NewId() 
    102         button_preview = wx.Button(self, id, "Preview") 
    103         button_preview.SetToolTipString("Print preview this report.") 
    104         button_preview.Bind(wx.EVT_BUTTON, self.onPreview, 
    105                             id=button_preview.GetId())  
    106         hbox.Add(button_preview) 
    107  
    108         id = wx.NewId() 
    109         button_print = wx.Button(self, id, "Print") 
    110         button_print.SetToolTipString("Print this report.") 
    111         button_print.Bind(wx.EVT_BUTTON, self.onPrint, 
    112                           id=button_print.GetId()) 
    113         hbox.Add(button_print) 
    114          
    115         id = wx.NewId() 
    116         button_save = wx.Button(self, id, "Save") 
    117         button_save.SetToolTipString("Save this report.") 
    118         button_save.Bind(wx.EVT_BUTTON, self.onSave, id=button_save.GetId()) 
    119         hbox.Add(button_save) 
    120          
    121         # panel for report page 
    122         #panel = wx.Panel(self, -1) 
    123         vbox = wx.BoxSizer(wx.VERTICAL) 
    124         # html window 
    125         self.hwindow = html.HtmlWindow(self, style=wx.BORDER) 
    126         # set the html page with the report string 
    127         self.hwindow.SetPage(self.report_html) 
    128          
    129         # add panels to boxsizers 
    130         vbox.Add(hbox) 
    131         vbox.Add(self.hwindow, 1, wx.EXPAND|wx.ALL,0) 
    132  
    133         self.SetSizer(vbox) 
    134         self.Centre() 
    135         self.Show(True) 
    136  
    13761    def onSave(self, event=None): 
    13862        """ 
    13963        Save 
    14064        """ 
    141         # pdf supporting only on MAC, not on exe 
    142         if self.is_pdf: 
    143             wild_card = ' PDF files (*.pdf)|*.pdf|' 
    144             ind_cor = 0 
    145         else: 
    146             wild_card = '' 
    147             ind_cor = 1 
    148         wild_card += 'HTML files (*.html)|*.html|' 
    149         wild_card += 'Text files (*.txt)|*.txt' 
    150  
    15165        #todo: complete saving fig file and as a txt file 
    15266        dlg = wx.FileDialog(self, "Choose a file", 
    153                             wildcard=wild_card, 
     67                            wildcard=self.wild_card, 
    15468                            style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR) 
    15569        dlg.SetFilterIndex(0)  # Set .html files to be default 
     
    16680        pic_fname = [] 
    16781        #PDF 
    168         if ext_num == (0 + 2 * ind_cor): 
     82        if ext_num == (0 + 2 * self.index_offset): 
    16983            # TODO: Sort this case out 
    17084            ext = '.pdf' 
     
    216130            return 
    217131        #HTML + png(graph) 
    218         elif ext_num == (1 - ind_cor): 
     132        elif ext_num == (1 - self.index_offset): 
    219133            ext = '.html' 
    220134            for num in range(self.nimages): 
     
    222136            report_frame = self.report_list[0] 
    223137        #TEXT + pdf(graph) 
    224         elif ext_num == (2 - ind_cor): 
     138        elif ext_num == (2 - self.index_offset): 
    225139            ext = '.txt' 
    226140            # changing the image extension actually changes the image 
     
    241155            pic_fname.append(pic_name) 
    242156        #put the image path in html string 
    243         if ext_num == (1 - ind_cor): 
     157        if ext_num == (1 - self.index_offset): 
    244158            if self.nimages == 1: 
    245159                report = report_frame % os.path.basename(pic_fname[0]) 
     
    259173            self.report_list[2][num].savefig(pic_fname[num]) 
    260174         
    261     def onPreview(self, event=None): 
    262         """ 
    263         Preview 
    264          
    265         : event: Preview button event 
    266         """ 
    267         previewh = html.HtmlEasyPrinting(name="Printing", parentWindow=self) 
    268         previewh.PreviewText(self.report_html) 
    269         if event is not None: 
    270             event.Skip() 
    271         self.Update() 
    272      
    273     def onPrint(self, event=None): 
    274         """ 
    275         Print 
    276          
    277         : event: Print button event 
    278         """ 
    279         printh = html.HtmlEasyPrinting(name="Printing", parentWindow=self) 
    280         printh.PrintText(self.report_html) 
    281         if event is not None: 
    282             event.Skip() 
    283         self.Update() 
    284          
    285     def OnClose(self, event=None): 
    286         """ 
    287         Close the Dialog 
    288          
    289         : event: Close button event 
    290         """ 
    291         self.Close() 
    292         # Reset memory 
    293         #wx.MemoryFSHandler() 
    294         if event is not None: 
    295             event.Skip() 
    296      
    297     def HTML2PDF(self, data, filename): 
    298         """ 
    299         Create a PDF file from html source string. 
    300         Returns True is the file creation was successful.  
    301          
    302         : data: html string 
    303         : filename: name of file to be saved 
    304         """ 
    305         try: 
    306             from xhtml2pdf import pisa 
    307             # open output file for writing (truncated binary) 
    308             resultFile = open(filename, "w+b") 
    309             # convert HTML to PDF 
    310             pisaStatus = pisa.CreatePDF(data, dest=resultFile) 
    311             # close output file 
    312             resultFile.close() 
    313             self.Update() 
    314             return pisaStatus.err 
    315         except: 
    316             logging.error("Error creating pdf: %s" % sys.exc_value) 
    317         return False 
  • src/sas/perspectives/invariant/report_dialog.py

    r4ec242e re8bb5b6  
    1515""" 
    1616import wx 
    17 import sys 
    1817import os 
    1918import wx.html as html 
    20 import logging 
    21 ISPDF = False 
    22 if sys.platform == "win32": 
    23     _STATICBOX_WIDTH = 450 
    24     PANEL_WIDTH = 500  
    25     PANEL_HEIGHT = 700 
    26     FONT_VARIANT = 0 
    27     ISMAC = False 
    28     ISPDF = True 
    29 elif sys.platform == "darwin": 
    30     _STATICBOX_WIDTH = 480 
    31     PANEL_WIDTH = 530 
    32     PANEL_HEIGHT = 700 
    33     FONT_VARIANT = 1 
    34     ISMAC = True 
    35     ISPDF = True 
    36    
    37 class ReportDialog(wx.Dialog): 
     19  
     20from sas.guiframe.report_dialog import BaseReportDialog 
     21 
     22class ReportDialog(BaseReportDialog): 
    3823    """ 
    3924    The report dialog box.  
    4025    """ 
    4126     
    42     def __init__(self,  list, *args, **kwds): 
     27    def __init__(self,  report_list, *args, **kwds): 
    4328        """ 
    4429        Initialization. The parameters added to Dialog are: 
    4530         
    46         :param list: report_list (list of html_str, text_str, image) 
     31        :param report_list: list of html_str, text_str, image 
    4732        from invariant_state 
    4833        """ 
    49         kwds["style"] = wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE 
    50         wx.Dialog.__init__(self, *args, **kwds) 
    51         kwds["image"] = 'Dynamic Image' 
     34        super(ReportDialog, self).__init__(report_list, *args, **kwds) 
     35 
    5236        # title 
    5337        self.SetTitle("Report: Invariant computaion") 
    54         # size 
    55         self.SetSize((720, 650)) 
    56         # font size  
    57         self.SetWindowVariant(variant=FONT_VARIANT) 
    5838 
    59         # check if tit is MAC 
    60         self.is_pdf = ISPDF 
    61          
    62         # report string 
    63         self.report_list = list 
    6439        # put image path in the report string 
    6540        self.report_html = self.report_list[0] % "memory:img_inv.png" 
    6641        # layout 
    6742        self._setup_layout() 
    68         # wild card 
    69         # pdf supporting only on MAC 
    70         if self.is_pdf: 
    71                 self.wild_card = ' PDF files (*.pdf)|*.pdf|' 
    72         else: 
    73                 self.wild_card = '' 
    74         self.wild_card += 'HTML files (*.html)|*.html|' 
    75         self.wild_card += 'Text files (*.txt)|*.txt' 
    76    
    77          
    78          
    79     def _setup_layout(self): 
    80         """ 
    81         Set up layout 
    82         """ 
    83         hbox = wx.BoxSizer(wx.HORIZONTAL) 
    84          
    85         # buttons 
    86         id = wx.ID_OK 
    87         button_close = wx.Button(self, id, "Close") 
    88         button_close.SetToolTipString("Close this report window.")  
    89         #hbox.Add((5,10), 1 , wx.EXPAND|wx.ADJUST_MINSIZE,0) 
    90         hbox.Add(button_close) 
    91         button_close.SetFocus() 
    92  
    93         id = wx.NewId() 
    94         button_preview = wx.Button(self, id, "Preview") 
    95         button_preview.SetToolTipString("Print preview this report.") 
    96         button_preview.Bind(wx.EVT_BUTTON, self.onPreview, 
    97                             id=button_preview.GetId())  
    98         hbox.Add(button_preview) 
    99  
    100         id = wx.NewId() 
    101         button_print = wx.Button(self, id, "Print") 
    102         button_print.SetToolTipString("Print this report.") 
    103         button_print.Bind(wx.EVT_BUTTON, self.onPrint, 
    104                           id=button_print.GetId())  
    105         hbox.Add(button_print) 
    106          
    107         id = wx.NewId() 
    108         button_save = wx.Button(self, id, "Save" ) 
    109         button_save.SetToolTipString("Save this report.") 
    110         button_save.Bind(wx.EVT_BUTTON, self.onSave, id = button_save.GetId())  
    111         hbox.Add(button_save)      
    112          
    113         # panel for report page 
    114         #panel = wx.Panel(self, -1) 
    115         vbox = wx.BoxSizer(wx.VERTICAL) 
    116         # html window 
    117         self.hwindow = html.HtmlWindow(self,style=wx.BORDER) 
    118         # set the html page with the report string 
    119         self.hwindow.SetPage(self.report_html) 
    120          
    121         # add panels to boxsizers 
    122         vbox.Add(hbox) 
    123         vbox.Add(self.hwindow, 1, wx.EXPAND|wx.ALL,0) 
    124  
    125         self.SetSizer(vbox) 
    126         self.Centre() 
    127         self.Show(True) 
    128                  
    12943 
    13044    def onSave(self, event=None): 
     
    14458        fName = dlg.GetPath() 
    14559        ext_num = dlg.GetFilterIndex()   
    146         # index correction  
    147         if not self.is_pdf: 
    148                 ind_cor = 1  
    149         else: 
    150                 ind_cor = 0  
    15160        #set file extensions   
    152         if ext_num == (0 + 2 * ind_cor): 
    153                         # TODO: Sort this case out 
     61        if ext_num == (0 + 2 * self.index_offset): 
     62            # TODO: Sort this case out 
    15463            ext = '.pdf' 
    15564            img_ext = '_img.png' 
     
    18695            os.remove(pic_fname) 
    18796            return 
    188         elif ext_num == (1 - ind_cor): 
     97        elif ext_num == (1 - self.index_offset): 
    18998            ext = '.html' 
    19099            img_ext = '_img4html.png' 
    191100            report_frame = self.report_list[0] 
    192         elif ext_num == (2 - ind_cor): 
     101        elif ext_num == (2 - self.index_offset): 
    193102            ext = '.txt'    
    194103            # changing the image extension actually changes the image 
     
    205114        pic_fname = os.path.splitext(fName)[0] + img_ext 
    206115        #put the image path in html string 
    207         if ext_num == (1 - ind_cor): 
     116        if ext_num == (1 - self.index_offset): 
    208117            report = report_frame % os.path.basename(pic_fname) 
    209118 
     
    214123        self.report_list[2].savefig(pic_fname) 
    215124         
    216              
    217     def onPreview(self, event=None): 
    218         """ 
    219         Preview 
    220          
    221         : event: Preview button event 
    222         """ 
    223         previewh = html.HtmlEasyPrinting(name="Printing", parentWindow=self) 
    224         previewh.PreviewText(self.report_html) 
    225         if event is not None: 
    226             event.Skip() 
    227      
    228     def onPrint(self, event=None): 
    229         """ 
    230         Print 
    231          
    232         : event: Print button event 
    233         """ 
    234         printh = html.HtmlEasyPrinting(name="Printing", parentWindow=self) 
    235         printh.PrintText(self.report_html) 
    236         if event is not None: 
    237             event.Skip() 
    238  
    239     def OnClose(self,event=None): 
    240         """ 
    241         Close the Dialog 
    242          
    243         : event: Close button event 
    244         """ 
    245         self.Close() 
    246      
    247     def HTML2PDF(self, data, filename): 
    248         """ 
    249         Create a PDF file from html source string. 
    250         Returns True is the file creation was successful.  
    251          
    252         : data: html string 
    253         : filename: name of file to be saved 
    254         """ 
    255         try: 
    256             from xhtml2pdf import pisa 
    257             # open output file for writing (truncated binary) 
    258             resultFile = open(filename, "w+b") 
    259             # convert HTML to PDF 
    260             pisaStatus = pisa.CreatePDF(data, dest=resultFile) 
    261             # close output file 
    262             resultFile.close() 
    263             self.Update() 
    264             return pisaStatus.err 
    265         except: 
    266             logging.error("Error creating pdf: %s" % sys.exc_value) 
    267         return False 
Note: See TracChangeset for help on using the changeset viewer.