source: sans/SANSReduction/branches/kline_29MAR07/Put in User Procedures/SANS_Reduction_v5.00/Initialize.ipf @ 72

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

Initial file shuffling, partially done.
Created 3 new files:
SANS_Utilities
NCNR_Utils
NCNR_DataReadWrite

(SANS_Utilites may eventually become NCNR-specific, but I'm not sure)

File size: 5.0 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        InitFacilityGlobals()
36        DoWindow/F Main_Panel
37        If(V_flag == 0)
38                //draw panel
39                Main_Panel()
40        Endif
41        ResizeCmdWindow()
42End
43
44//creates all the necessary data folders in the root folder
45//does not overwrite any existing folders of the same name
46//it leaves data in them untouched
47Function InitFolders()
48       
49        NewDataFolder/O root:myGlobals
50        NewDataFolder/O root:myGlobals:CatVSHeaderInfo
51        NewDataFolder/O root:RAW
52        NewDataFolder/O root:SAM
53        NewDataFolder/O root:EMP
54        NewDataFolder/O root:BGD
55        NewDataFolder/O root:COR
56        NewDataFolder/O root:DIV
57        NewDataFolder/O root:MSK
58        NewDataFolder/O root:ABS
59        NewDataFolder/O root:CAL
60        NewDataFolder/O root:STO
61        NewDataFolder/O root:SUB
62        NewDataFolder/O root:DRK
63       
64        Return(0)
65End
66
67//Global folder already exists...
68//adds appropriate globals to the newly created myGlobals folder
69//return data folder to root: before leaving
70//
71// global parameters used for detector constants are facility specific
72// and have been moved
73//
74Function InitGlobals()
75       
76        Variable/G root:myGlobals:gIsLogScale = 0
77        String/G root:myGlobals:gDataDisplayType = "RAW"
78       
79        //check platform, so Angstrom can be drawn correctly
80       
81        if(cmpstr("Macintosh",IgorInfo(2)) == 0)
82                String/G root:myGlobals:gAngstStr = num2char(-127)
83                Variable/G root:myGlobals:gIsMac = 1
84        else
85                //either Windows or Windows NT
86                String/G root:myGlobals:gAngstStr = num2char(-59)
87                Variable/G root:myGlobals:gIsMac = 0
88                //SetIgorOption to keep some PC's (graphics cards?) from smoothing the 2D image
89                Execute "SetIgorOption WinDraw,forceCOLORONCOLOR=1"
90        endif
91       
92        //global to set log scale as the default for display of RAW data
93        //these can be set using the Misc->Preferences panel
94        Variable/G root:myGlobals:gLogScalingAsDefault=1
95        Variable/G root:myGlobals:gAllowDRK=0                   //don't show DRK as default
96        Variable/G root:myGlobals:gDoTransCheck=1
97        Variable/G root:myGlobals:gBinWidth=1
98        Variable/G root:myGlobals:gNPhiSteps=72
99
100        //set flag if Demo Version is detected
101        Variable/G root:myGlobals:isDemoVersion = isDemo()
102       
103        Return(0)
104End
105
106//creates the "base" protocols that should be available, after creating the data folder
107//
108//all protocols are kept in the root:myGlobals:Protocols folder, created here
109//
110Function InitFakeProtocols()
111       
112        //*****as of 0901, protocols are 8 points long, [6] is used for work.drk, [7] is unused
113        NewDataFolder/O root:myGlobals:Protocols
114        Make/O/T $"root:myGlobals:Protocols:Base"={"none","none","ask","ask","none","AVTYPE=Circular;SAVE=Yes;NAME=Manual;PLOT=Yes","DRK=none,DRKMODE=0,",""}
115        Make/O/T $"root:myGlobals:Protocols:DoAll"={"ask","ask","ask","ask","ask","AVTYPE=Circular;SAVE=Yes;NAME=Manual;PLOT=Yes","DRK=none,DRKMODE=0,",""}
116        Make/O/T/N=8 $"root:myGlobals:Protocols:CreateNew"                      //null wave
117        //Initialize waves to store values in
118       
119        String/G root:myGlobals:Protocols:gProtoStr=""
120        String/G root:myGlobals:Protocols:gNewStr=""
121        String/G root:myGlobals:Protocols:gAvgInfoStr = "AVTYPE=Circular;SAVE=Yes;NAME=Auto;PLOT=Yes;"
122       
123        Return(0)
124End
125
126//simple function to resize the comand window to a nice size, no matter what the resolution
127//need to test out on several different monitors and both platforms
128//
129// could easily be incorporated into the initialization routines to ensure that the
130// command window is always visible at startup of the macros. No need for a hook function
131//
132Function ResizeCmdWindow()
133
134        String str=IgorInfo(0),rect="",platform=igorinfo(2)
135        Variable depth,left,top,right,bottom,factor
136       
137        if(cmpstr(platform,"Macintosh")==0)
138                factor=1
139        else
140                factor = 0.6            //fudge factor to get command window on-screen on Windows
141        endif
142        rect = StringByKey("SCREEN1", str  ,":",";")   
143        sscanf rect,"DEPTH=%d,RECT=%d,%d,%d,%d",depth, left,top,right,bottom
144        MoveWindow/C  (left+3)*factor,(bottom-150)*factor,(right-50)*factor,(bottom-10)*factor
145End
146
147
148//returns 1 if demo version, 0 if full version
149Function IsDemo()
150
151        // create small offscreen graph
152        Display/W=(3000,3000,3010,3010)
153        DoWindow/C IsDemoGraph
154
155        // try to save a PICT or bitmap of it to the clipboard
156        SavePICT/Z  as "Clipboard"
157        Variable isDemo= V_Flag != 0    // if error: must be demo
158        DoWindow/K IsDemoGraph
159        return isDemo
160End
Note: See TracBrowser for help on using the repository browser.