-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGo2Alpha.s
More file actions
131 lines (107 loc) · 4.32 KB
/
Copy pathGo2Alpha.s
File metadata and controls
131 lines (107 loc) · 4.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
Go2Alpha
BLW @NMRC
This script creates a UI in DigitalMicrograph that helps tilting the stage for setting eucentric height.
Two angles can be defined, "Alpha 1" and "Alpha 2" in degrees. Pressing the correspinding button will move the
microscope stage to the defined angle. The "Tilt Neutral" button will set the stage angle to 0.
Care should be taken by the user that tilting to the defined angle will not cause a stage touch. If in doubt, check the maximum tilt range of your
stage before using this script.
Alpha refers to the tilt-x axis in a JEOL microscope. This script does not control the Beta tilt axis in double-tilt holders.
If you found this script useful, consider citing: http://arxiv.org/abs/2507.10247
*/
//Variables
number target_alpha
class Go2AlphaThread:Thread
{
number linkedDLG_ID
Go2AlphaThread( object self )
{
// result( self.ScriptObjectGetID() + " created.\n" )
}
~Go2AlphaThread( object self )
{
// result( self.ScriptObjectGetID() + " destroyed.\n" )
}
void SetLinkedDialogID( object self, number ID ) { linkedDLG_ID = ID; }
}
//Declare UI elements
class myDialog : UIframe
{
object callThread
myDialog( object self )
{
// result( self.ScriptObjectGetID() + " created.\n" )
}
~myDialog( object self )
{
// result( self.ScriptObjectGetID() + " destroyed.\n")
}
//Button functions
void GoToAlpha1( object self )
{
{
self.DLGGetValue( "alpha_1_field", target_alpha )
}
EMSetStageAlpha( target_alpha )
}
void GoToAlpha2( object self )
{
{
self.DLGGetValue( "alpha_2_field", target_alpha )
}
EMSetStageAlpha( target_alpha )
}
void TiltNeutral( object self )
{
EMSetStageAlpha( 0 )
}
TagGroup CreateDLG( object self )//copied from GiveMeED
{
number label_width = 10
number entry_width = 10
number button_width = 50
TagGroup label
TagGroup Dialog_UI = DLGCreateDialog( "Go2Alpha" )
// Angles: alpha is tilt-x on a JEOL microscope
TagGroup alpha_box_items
TagGroup alpha_box = DLGCreateBox( "Stage Alpha", alpha_box_items ).DLGFill( "XY" )
TagGroup alpha_1_field//start angle for tilt
label = DLGCreateLabel( "Alpha1 (deg):" ).DLGWidth( label_width )
alpha_1_field = DLGCreateStringField( "0" ).DLGIdentifier( "alpha_1_field" ).DLGWidth( entry_width )
TagGroup alpha_1_group = DLGGroupItems( label, alpha_1_field ).DLGTableLayout( 2, 1, 0 ).DLGAnchor( "West" )
TagGroup alpha_2_field//end angle for tilt
label = DLGCreateLabel( "Alpha2 (deg):" ).DLGWidth( label_width )
alpha_2_field = DLGCreateStringField( "0" ).DLGIdentifier( "alpha_2_field" ).DLGWidth( entry_width )
TagGroup alpha_2_group = DLGGroupItems( label, alpha_2_field ).DLGTableLayout( 2, 1, 0 ).DLGAnchor( "West" )
//Alpha buttons - add a function for go to start angle of alpha
TagGroup GoToAlpha1 = DLGCreatePushButton( "Go to A1", "GoToAlpha1" ).DLGWidth(button_width)
TagGroup GoToAlpha2 = DLGCreatePushButton( "Go to A2", "GoToAlpha2" ).DLGWidth(button_width)
TagGroup TiltNeutral = DLGCreatePushButton( "Tilt Neutral", "TiltNeutral" ).DLGWidth(button_width)
TagGroup alpha_buttons = DLGGroupItems( GoToAlpha1, GoToAlpha2, TiltNeutral ).DLGTableLayout( 2, 2, 0 ).DLGAnchor( "East" )
TagGroup alpha_group = DLGGroupItems( alpha_1_group, alpha_2_group, alpha_buttons ).DLGTableLayout( 1, 4, 0 )
alpha_box_items.DLGAddElement( alpha_group )
Dialog_UI.DLGAddElement( alpha_box )
TagGroup footer = DLGCreateLabel("GMED: Go2Alpha")
Dialog_UI.DLGAddElement(footer)
return Dialog_UI
}
object Init(object self, number callThreadID )
{
// Assign thread-object via weak-reference
callThread = GetScriptObjectFromID( callThreadID )
if ( !callThread.ScriptObjectIsvalid() )
Throw( "Invalid thread object passed in! Object of given ID not found." )
// Pass weak-reference to thread object
callThread.SetLinkedDialogID( self.ScriptObjectGetID() )
return self.super.init( self.CreateDLG() )
}
}
// launches threads
void Invoke( )
{
object threadObject = alloc( Go2AlphaThread )
object dlgObject = alloc( myDialog ).Init( threadObject.ScriptObjectGetID() )
dlgObject.display( "Go2Alpha" ) //title of UI
}
// Script starts here
Invoke()