source: sans/SANSReduction/trunk/Put in User Procedures/SANS_Reduction_v5.00/Initialize.ipf @ 40

Last change on this file since 40 was 40, checked in by srkline, 16 years ago

Initial checkin of V5.00 SANSReduction files

File size: 5.9 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma version=5.0
3#pragma IgorVersion=4.0
4
5//***********************
6// 091901 Vers 1.2
7//
8// Initialization procedures that must be run before any analysis is started
9// this is accomplished by placing:
10//
11// Initialize()
12// #include "includes"
13//
14// in the built-in procedure window of the .pxt (template) experiment
15// IGOR recognizes this, and executes Initialize() immediately after
16// compiling all of the included procedures. This is all done as the blank
17// template is opened
18//
19// Choosing initialize from the SANS menu will do the same, and no harm is done
20// to the experiment by re- initializing. no data or folders are overwritten
21//
22//************************
23
24//this is the main initualization procedure that must be the first thing
25//done when opening a new Data reduction experiment
26//
27//sets up data folders, globals, protocols, and draws the main panel
28Proc Initialize()
29
30        Variable/G root:SANS_RED_VERSION=5.00
31       
32        InitFolders()
33        InitFakeProtocols()
34        InitGlobals()   
35        DoWindow/F Main_Panel
36        If(V_flag == 0)
37                //draw panel
38                Main_Panel()
39        Endif
40        ResizeCmdWindow()
41End
42
43//creates all the necessary data folders in the root folder
44//does not overwrite any existing folders of the same name
45//it leaves data in them untouched
46Function InitFolders()
47       
48        NewDataFolder/O root:myGlobals
49        NewDataFolder/O root:myGlobals:CatVSHeaderInfo
50        NewDataFolder/O root:RAW
51        NewDataFolder/O root:SAM
52        NewDataFolder/O root:EMP
53        NewDataFolder/O root:BGD
54        NewDataFolder/O root:COR
55        NewDataFolder/O root:DIV
56        NewDataFolder/O root:MSK
57        NewDataFolder/O root:ABS
58        NewDataFolder/O root:CAL
59        NewDataFolder/O root:STO
60        NewDataFolder/O root:SUB
61        NewDataFolder/O root:DRK
62       
63        Return(0)
64End
65
66//Global folder already exists...
67//adds appropriate globals to the newly created myGlobals folder
68//return data folder to root: before leaving
69//
70//now contains global parameters used for detector constants
71//
72Function InitGlobals()
73       
74        Variable/G root:myGlobals:gIsLogScale = 0
75        String/G root:myGlobals:gDataDisplayType = "RAW"
76       
77        //check platform, so Angstrom can be drawn correctly
78       
79        if(cmpstr("Macintosh",IgorInfo(2)) == 0)
80                String/G root:myGlobals:gAngstStr = num2char(-127)
81                Variable/G root:myGlobals:gIsMac = 1
82        else
83                //either Windows or Windows NT
84                String/G root:myGlobals:gAngstStr = num2char(-59)
85                Variable/G root:myGlobals:gIsMac = 0
86                //SetIgorOption to keep some PC's (graphics cards?) from smoothing the 2D image
87                Execute "SetIgorOption WinDraw,forceCOLORONCOLOR=1"
88        endif
89       
90        //global to set log scale as the default for display of RAW data
91        //these can be set using the Misc->Preferences panel
92        Variable/G root:myGlobals:gLogScalingAsDefault=1
93        Variable/G root:myGlobals:gAllowDRK=0                   //don't show DRK as default
94        Variable/G root:myGlobals:gDoTransCheck=1
95        Variable/G root:myGlobals:gBinWidth=1
96        Variable/G root:myGlobals:gNPhiSteps=72
97        Variable/G root:myGlobals:gNPixelsX=128
98        Variable/G root:myGlobals:gNPixelsY=128
99       
100        //Detector -specific globals
101        Variable/G root:myGlobals:PixelResNG3_ILL = 1.0         //pixel resolution in cm
102        Variable/G root:myGlobals:PixelResNG5_ILL = 1.0
103        Variable/G root:myGlobals:PixelResNG7_ILL = 1.0
104        Variable/G root:myGlobals:PixelResNG3_ORNL = 0.5
105        Variable/G root:myGlobals:PixelResNG5_ORNL = 0.5
106        Variable/G root:myGlobals:PixelResNG7_ORNL = 0.5
107        Variable/G root:myGlobals:PixelResDefault = 0.5
108       
109        Variable/G root:myGlobals:DeadtimeNG3_ILL = 3.0e-6              //deadtime in seconds
110        Variable/G root:myGlobals:DeadtimeNG5_ILL = 3.0e-6
111        Variable/G root:myGlobals:DeadtimeNG7_ILL = 3.0e-6
112        Variable/G root:myGlobals:DeadtimeNG3_ORNL = 3.4e-6
113        Variable/G root:myGlobals:DeadtimeNG5_ORNL = 0.6e-6             //as of 9 MAY 2002
114        Variable/G root:myGlobals:DeadtimeNG7_ORNL = 3.4e-6
115        Variable/G root:myGlobals:DeadtimeDefault = 3.4e-6
116       
117        //set flag if Demo Version is detected
118        Variable/G root:myGlobals:isDemoVersion = isDemo()
119       
120        Return(0)
121End
122
123//creates the "base" protocols that should be available, after creating the data folder
124//
125//all protocols are kept in the root:myGlobals:Protocols folder, created here
126//
127Function InitFakeProtocols()
128       
129        //*****as of 0901, protocols are 8 points long, [6] is used for work.drk, [7] is unused
130        NewDataFolder/O root:myGlobals:Protocols
131        Make/O/T $"root:myGlobals:Protocols:Base"={"none","none","ask","ask","none","AVTYPE=Circular;SAVE=Yes;NAME=Manual;PLOT=Yes","DRK=none,DRKMODE=0,",""}
132        Make/O/T $"root:myGlobals:Protocols:DoAll"={"ask","ask","ask","ask","ask","AVTYPE=Circular;SAVE=Yes;NAME=Manual;PLOT=Yes","DRK=none,DRKMODE=0,",""}
133        Make/O/T/N=8 $"root:myGlobals:Protocols:CreateNew"                      //null wave
134        //Initialize waves to store values in
135       
136        String/G root:myGlobals:Protocols:gProtoStr=""
137        String/G root:myGlobals:Protocols:gNewStr=""
138        String/G root:myGlobals:Protocols:gAvgInfoStr = "AVTYPE=Circular;SAVE=Yes;NAME=Auto;PLOT=Yes;"
139       
140        Return(0)
141End
142
143//simple function to resize the comand window to a nice size, no matter what the resolution
144//need to test out on several different monitors and both platforms
145//
146// could easily be incorporated into the initialization routines to ensure that the
147// command window is always visible at startup of the macros. No need for a hook function
148//
149Function ResizeCmdWindow()
150
151        String str=IgorInfo(0),rect="",platform=igorinfo(2)
152        Variable depth,left,top,right,bottom,factor
153       
154        if(cmpstr(platform,"Macintosh")==0)
155                factor=1
156        else
157                factor = 0.6            //fudge factor to get command window on-screen on Windows
158        endif
159        rect = StringByKey("SCREEN1", str  ,":",";")   
160        sscanf rect,"DEPTH=%d,RECT=%d,%d,%d,%d",depth, left,top,right,bottom
161        MoveWindow/C  (left+3)*factor,(bottom-150)*factor,(right-50)*factor,(bottom-10)*factor
162End
163
164
165//returns 1 if demo version, 0 if full version
166Function IsDemo()
167
168        // create small offscreen graph
169        Display/W=(3000,3000,3010,3010)
170        DoWindow/C IsDemoGraph
171
172        // try to save a PICT or bitmap of it to the clipboard
173        SavePICT/Z  as "Clipboard"
174        Variable isDemo= V_Flag != 0    // if error: must be demo
175        DoWindow/K IsDemoGraph
176        return isDemo
177End
Note: See TracBrowser for help on using the repository browser.