-
Notifications
You must be signed in to change notification settings - Fork 0
/
NTP_Controls.ipf
executable file
·2177 lines (1787 loc) · 57 KB
/
NTP_Controls.ipf
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#pragma TextEncoding = "UTF-8"
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
//This file handles all of the control activation code (i.e. Buttons, setVariables, ListBoxes, etc.)
//There is a single function for all controls of the same type
//LIST BOXES------------------------------------------------------------
Function ntListBoxProc(lba) : ListBoxControl
STRUCT WMListboxAction &lba
Variable row = lba.row
Variable col = lba.col
WAVE/T/Z listWave = lba.listWave
WAVE/Z selWave = lba.selWave
Variable errorCode = 0
DFREF NPD = $DSF
DFREF NPC = $CW
NVAR dragging = NPC:dragging
SVAR listFocus = NPC:listFocus
Variable hookResult = 0
switch( lba.eventCode )
case -1: // control being killed
break
case 1: // mouse down
//set a potential drag variable
If(!cmpstr(lba.ctrlName,"waveListBox"))
dragging = 1
//freeze selection
EndIf
break
case 2: // mouse up
//display the full path to the wave in a text box
//reset the drag and drop variable on a mouse up
dragging = 0
// If(row > DimSize(selWave,0) - 1 || row == -1)
// break
// EndIf
//
// strswitch(lba.ctrlName)
// case "MatchListBox":
// case "DataSetWavesListBox":
// DrawAction/W=NTP getGroup=fullPathText,delete
// SetDrawEnv/W=NTP fname=$LIGHT,fstyle=2,fsize=10,xcoord=abs,ycoord=abs, textxjust= 0,gname=fullPathText,gstart
// DrawText/W=NTP 14,464,listWave[row][0][1]
// SetDrawEnv/W=NTP gstop
// break
// endswitch
//change focus for the list box selection
strswitch(lba.ctrlName)
case "matchListBox": //wave matches
AppendToViewer(listWave,selWave)
//out of range selection
If(row > DimSize(listWave,0) - 1)
//change the list box focus still
changeFocus("WaveMatch",1)
//Delete full path wave text
DrawAction/W=NTP getGroup=fullPathText,delete
return 0
EndIf
//change the list box focus
If(!cmpstr(listFocus,"DataSet"))
changeFocus("WaveMatch",1)
EndIf
break
case "dataSetWavesListBox": //data set waves
//out of range selection
AppendToViewer(listWave,selWave)
If(row > DimSize(listWave,0) - 1)
//change the list box focus still
changeFocus("DataSet",1)
//Delete full path wave text
DrawAction/W=NTP getGroup=fullPathText,delete
return 0
EndIf
//change the list box focus
If(!cmpstr(listFocus,"WaveMatch"))
changeFocus("DataSet",1)
EndIf
drawFullPathText()
break
endswitch
break
case 4: // cell selection
case 5: // cell selection plus shift key
If(HandleLBSelection(lba.ctrlName,listWave,row,lba.mouseLoc.h,lba.mouseLoc.v,lba.eventMod))
print "SELECTION CHANGE ERROR"
EndIf
//Only selection updates for keyboard triggered selections
If(lba.eventMod == 0)
If(!cmpstr(lba.ctrlName,"MatchListBox") || !cmpstr(lba.ctrlName,"DataSetWavesListBox"))
DrawAction/W=NTP getGroup=fullPathText,delete
SetDrawEnv/W=NTP fname=$LIGHT,fstyle=2,fsize=10,xcoord=abs,ycoord=abs,textxjust= 0,gname=fullPathText,gstart
DrawText/W=NTP 14,464,listWave[row][0][1]
SetDrawEnv/W=NTP gstop
EndIf
AppendToViewer(listWave,selWave)
EndIf
break
case 6: // begin edit
break
case 7: // finish edit
break
case 12: //keyboard
If(!cmpstr(lba.ctrlName,"DataSetNamesListBox"))
hookResult = 1
return hookResult
EndIf
//Detect ASCII for 'w' or 'q'
//'q' jumps to previous waveset
//'w' jumpts to next waveset
Variable i
If(row == 113 || row == 81)
//JUMP TO PREVIOUS WAVE SET
//Find the first row that is selected, and find the first wave set before or after that
If(sum(lba.selWave) > 0)
For(i=0; i < DimSize(lba.selWave,0); i+= 1)
If(lba.selWave[i] > 0)
If(row == 119 || row == 87) //w
Variable index = i + 1
ElseIf(row == 113|| row == 81) //q
index = i - 1
EndIf
break
EndIf
EndFor
Else
index = 0
EndIf
If(row == 113) // no shift, erase other selection
lba.selWave = 0
EndIf
//Find the surrounding wave set
For(i=index;i>-1;i-=1)
If(stringmatch(lba.listWave[i][0][0],"*WAVE SET*"))
lba.selWave[i] = 1
break
EndIf
EndFor
ElseIf(row == 119 || row == 87)
//JUMP TO NEXT WAVE SET
//Find the last row that is selected, and find the first wave set after that
If(sum(lba.selWave) > 0)
For(i=DimSize(lba.selWave,0) - 1; i > - 1; i-= 1)
If(lba.selWave[i] > 0)
If(row == 119 || row == 87) //w
index = i + 1
EndIf
break
EndIf
EndFor
Else
index = 0
EndIf
If(row == 119) // no shift
lba.selWave = 0
EndIf
//Find the surrounding wave set
For(i=index;i<DimSize(lba.selWave,0);i+=1)
If(stringmatch(lba.listWave[i][0][0],"*WAVE SET*"))
lba.selWave[i] = 1
break
EndIf
EndFor
EndIf
ListBox $lba.ctrlName win=NTP#Data,row=i
If(HandleLBSelection(lba.ctrlName,listWave,i,lba.mouseLoc.h,lba.mouseLoc.v,lba.eventMod))
print "SELECTION CHANGE ERROR"
EndIf
break
case 13: // checkbox clicked (Igor 6.2 or later)
break
endswitch
return 1
End
//Handles list box selections
Function HandleLBSelection(ctrlName,listWave,row,mouseHor,mouseVert,eventMod)
String ctrlName
Wave/T listWave
Variable row,mouseHor,mouseVert,eventMod
Variable errorCode = 0
DFREF NPC = $CW
DFREF NPD = $DSF
SVAR listFocus = NPC:listFocus
strswitch(ctrlName)
case "matchListBox": //wave matches
Wave/T MatchLB_ListWave = NPC:MatchLB_ListWave
Wave MatchLB_SelWave = NPC:MatchLB_SelWave
//out of range selection
If(row > DimSize(listWave,0) - 1)
//change the list box focus still
changeFocus("WaveMatch",1)
//Delete full path wave text
DrawAction/W=NTP getGroup=fullPathText,delete
return 0
EndIf
If(eventMod == 16 || eventMod == 17)
//GOTO selected wave contextual menu
PopupContextualMenu/C=(mouseHor, mouseVert) "GoTo;Edit;Delete;Display;"
If(V_flag)
HandleRightClick("matchListBox",V_flag,row=row)
EndIf
EndIf
//change the list box focus
If(!cmpstr(listFocus,"DataSet"))
changeFocus("WaveMatch",1)
EndIf
// NVAR viewerOpen = NPC:viewerOpen
// If(viewerOpen)
If(eventMod == 0)
AppendToViewer(MatchLB_ListWave,MatchLB_SelWave)
EndIf
break
case "dataSetWavesListBox": //data set waves
//out of range selection
If(row > DimSize(listWave,0) - 1)
//change the list box focus still
changeFocus("DataSet",1)
//Delete full path wave text
DrawAction/W=NTP getGroup=fullPathText,delete
return 0
EndIf
If(eventMod == 16 || eventMod == 17)
//GOTO selected wave contextual menu
PopupContextualMenu/C=(mouseHor, mouseVert) "GoTo;Edit;Delete;Display;"
If(V_flag)
HandleRightClick("dataSetWavesListBox",V_flag,row=row)
EndIf
EndIf
//change the list box focus
If(!cmpstr(listFocus,"WaveMatch"))
changeFocus("DataSet",1)
EndIf
//display the full path to the wave in a text box
Wave/T DataSetLB_ListWave = NPD:DataSetLB_ListWave
Wave DataSetLB_SelWave = NPD:DataSetLB_SelWave
// NVAR viewerOpen = NPC:viewerOpen
If(eventMod == 0)
AppendToViewer(DataSetLB_ListWave,DataSetLB_SelWave)
EndIf
break
case "dataSetNamesListBox": //data set names
If(eventMod == 16 || eventMod == 17)
//If the right click happens on a non-previously selected data set,
//first loads those data set setttings into the GUI controls
If(row > DimSize(listWave,0) - 1)
return 0
EndIf
changeDataSet(listWave[row][0][0])
//GOTO selected wave contextual menu
PopupContextualMenu/C=(mouseHor,mouseVert) "Send To WaveMatch;"
If(V_flag)
HandleRightClick("dataSetNamesListBox",V_flag,row=row)
EndIf
Else
//change the list box focus
If(!cmpstr(listFocus,"WaveMatch"))
changeFocus("DataSet",1)
EndIf
//correct row if we selected outside of the listbox limits
If(row > DimSize(listWave,0) - 1 && DimSize(listWave,0) > 0)
row = DimSize(listWave,0) - 1
EndIf
changeDataSet(listWave[row][0][0])
EndIf
break
case "folderListBox": //folder navigation
//out of range selection
If(row > DimSize(listWave,0) - 1)
return 0
EndIf
If(eventMod == 16 || eventMod == 17)
//GOTO selected wave contextual menu
PopupContextualMenu/C=(mouseHor, mouseVert) "GoTo;"
If(V_flag)
HandleRightClick("folderListBox",V_flag,row=row)
EndIf
EndIf
break
case "waveListBox": //waves navigation
Wave/T WavesLB_ListWave = NPC:WavesLB_ListWave
Wave WavesLB_SelWave = NPC:WavesLB_SelWave
//out of range selection
If(row > DimSize(listWave,0) - 1)
return 0
EndIf
If(eventMod == 16 || eventMod == 17)
//GOTO selected wave contextual menu
PopupContextualMenu/C=(mouseHor, mouseVert) "GoTo;Edit;Delete;Display;"
If(V_flag)
HandleRightClick("waveListBox",V_flag,row=row)
EndIf
EndIf
// NVAR viewerOpen = NPC:viewerOpen
// If(viewerOpen)
// AppendToViewer(WavesLB_ListWave,WavesLB_SelWave)
// EndIf
break
case "fileListBox":
//browse files on disk for wavesurfer or pclamp loading
Variable fileID
SVAR wsFilePath = NPC:wsFilePath
SVAR wsFileName = NPC:wsFileName
If(row > DimSize(listWave,0) -1)
return 0
EndIf
wsFileName = listWave[row]
String fullPath = wsFilePath + wsFileName
//What file type are we opening?
ControlInfo/W=NTP fileType
String fileType = S_Value
strswitch(fileType)
case "WaveSurfer":
HDF5OpenFile/R fileID as fullPath
If(V_flag == -1) //cancelled
break
EndIf
//Save the path and filename
wsFilePath = S_path
wsFileName = S_fileName
UpdateWaveSurferLists(fileID,wsFilePath,wsFileName)
GetStimulusData(fileID)
HDF5CloseFile/A fileID
break
case "PClamp":
// Variable refnum
// fullPath = RemoveEnding(fullPath,".abf") + ".abf"
// Open/R/Z=2 refnum as fullPath
//
// fSetPos refnum,12
//
// Variable numSweeps = 0
// FBInRead/B=3/F=3/U refnum,numSweeps
//
// Wave/T wsSweepListWave = NPC:wsSweepListWave
// Redimension/N=(numSweeps) wsSweepListWave
//
// Variable i
// For(i=0;i<numSweeps;i+=1)
// wsSweepListWave[i] = "Sweep " + num2str(i + 1)
// EndFor
//
// Close refnum
break
case "Presentinator":
break
endswitch
break
endswitch
return errorCode
End
//Handles list box right clicks
Function HandleRightClick(controlName,command,[row])
String controlName
Variable command,row
DFREF NPC = $CW
DFREF NPD = $DSF
STRUCT filters filters
SVAR listFocus = NPC:listFocus
Variable errorCode = 0
strswitch(controlName)
case "dataSetWavesListBox": //data set waves
//Get the full path list wave for the selected data set
String dsName = GetDSName()
Wave/T listWave = GetDataSetWave(dsName,"ORG")
//out of range selection
If(row > DimSize(listWave,0) - 1)
return 0
EndIf
//Selected wave in the data set waves list box
String list = listWave[row][0][1]
//If a wave set was selected
If(stringmatch(list,"*WAVE SET*"))
Variable wsn = str2num(StringByKey("WAVE SET",list," ","-"))
Wave/T ws = GetWaveSet(listWave,wsn)
DeletePoints/M=2 0,1,ws
list = TextWaveToStringList(ws,";")
EndIf
doRightClickAction(command,list)
break
case "dataSetNamesListBox": //data set names
//Right click sends the selected data set's filters, groups, and
//original wave match settings to the WaveMatch list
Wave/T DSNamesLB_ListWave = NPD:DSNamesLB_ListWave
Variable index = GetDSIndex()
If(index != -1)
//Save the current filters/grouping settings
If(!cmpstr(listFocus,"DataSet"))
saveFilterSettings("DataSet")
EndIf
//Puts the saved filter settings into the GUI controls
recallFilterSettings("DataSet")
//Change focus to the WaveMatch list, without doing a save/retrieve
changeFocus("WaveMatch",0)
//Select the old folders
SelectFolder(DSNamesLB_ListWave[index][0][2])
//Put the original filter settings into the control panel
RecallOriginalFilters(DSNamesLB_ListWave[index][0][1])
//With focus on the WaveMatch list, re-run the match/filter/group
getWaveMatchList()
EndIf
break
case "matchListBox":
case "waveListBox": //waves navigation
//Get a list of the selected waves
If(!cmpstr(controlName,"matchListBox"))
Wave/T listWave = NPC:MatchLB_ListWave
If(row > DimSize(listWave,0)-1)
return 0
EndIf
list = listWave[row][0][1] + ";"
//If a wave set was selected
If(stringmatch(list,"*WAVE SET*"))
wsn = str2num(StringByKey("WAVE SET",list," ","-"))
Wave/T ws = GetWaveSet(listWave,wsn)
DeletePoints/M=2 0,1,ws
list = TextWaveToStringList(ws,";")
EndIf
ElseIf(!cmpstr(controlName,"waveListBox"))
Wave/T listWave = NPC:WavesLB_ListWave
If(row > DimSize(listWave,0)-1)
return 0
EndIf
String theFolder = GetDataFolder(1)
list = theFolder + listWave[row][0][1] + ";"
EndIf
//Perform selected right click action
doRightClickAction(command,list)
endswitch
return errorCode
End
//Performs one of the actions in the contextual right click menu
Function doRightClickAction(command,list)
Variable command
String list
//which option was clicked?
switch(command)
case 1: //GoTo
Variable i = 0
//Browse to the selected wave
ModifyBrowser collapseAll//close all folders first
CreateBrowser //activates the data browser focus
ModifyBrowser clearSelection,selectList=list //selects waves
break
case 2: //Edit
GetWindow NTP#Data wsize
Wave theWave = $StringFromList(0,list,";")
If(!WaveExists(theWave))
return 0
EndIf
If(!strlen(GetDimLabel(theWave,0,0)))
Edit/K=1/W=(V_right,V_top,V_right + 200,V_top + 200) theWave
Else
Edit/K=1/W=(V_right,V_top,V_right + 200,V_top + 200) theWave.ld
EndIf
break
case 3: //Delete
Wave theWave = $StringFromList(0,list,";")
DoAlert/T="Delete Wave" 1,"Are you sure you want to delete the wave: " + StringFromList(0,list,";") + "?"
If(V_flag == 1)
ReallyKillWaves(theWave)
EndIf
CheckDataSetWaves()
GetFolders()
GetFolderWaves()
break
case 4: //Display
GetWindow NTP#Data wsize
Wave theWave = $StringFromList(0,list,";")
If(!WaveExists(theWave))
return 0
EndIf
If(WaveType(theWave,1) != 1)
break
ElseIf(WaveDims(theWave) == 1) //1D
Display/W=(V_right,V_top,V_right + 390,V_top + 205)
For(i=0;i<ItemsInList(list,";");i+=1)
AppendToGraph $StringFromList(i,list,";")
EndFor
Else //2D
NewImage/N=$NameOfWave(theWave) theWave
EndIf
break
endswitch
return 0
End
//Handles list box double clicks
Function HandleLBDoubleClick(lba)
STRUCT WMListboxAction &lba
Variable errorCode = 0
DFREF NPC = $CW
strswitch(lba.ctrlName)
case "matchListBox": //wave matches
break
case "dataSetWavesListBox": //data set waves
break
case "dataSetNamesListBox": //data set names
break
case "folderListBox": //folder navigation
Wave/T FolderLB_ListWave = NPC:FolderLB_ListWave
If(lba.row < DimSize(FolderLB_ListWave,0))
switchFolders(FolderLB_ListWave[lba.row])
EndIf
break
case "waveListBox": //waves navigation
break
endswitch
return errorCode
End
//BUTTONS------------------------------------------------------------
Function ntButtonProc(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
//Immediately open the data set name input upon mouse down
If(!cmpstr(ba.ctrlName,"addDataSet"))
//animate a text box opening under the button
SetVariable dsNameInput win=NT,disable=0,activate,value=_STR:"NewDS"
GroupBox dsNameGroupBox win=NT,disable=0
EndIf
If(HandleButtonClick(ba))
print "BUTTON ERROR"
EndIf
break
case -1: // control being killed
break
endswitch
return 0
End
//Handles button clicks
Function HandleButtonClick(ba)
STRUCT WMButtonAction &ba
DFREF NPC = $CW
DFREF NPD = $DSF
SVAR selectedCmd = NPC:selectedCmd
Wave/T param = NPC:ExtFunc_Parameters
Variable errorCode = 0
strswitch(ba.ctrlName)
case "WaveListSelector":
NVAR foldStatus = NPC:foldStatus
//Prevents weird bug where the Wave Selector menu opens even though parameter panel is closed
If(!foldStatus)
break
EndIf
PopUpContextualMenu/C=(507,95)/N "WaveListSelectorMenu"
String popStr = S_Selection
Variable popNum = V_flag
If(V_flag == 0 || V_flag == -1)
break
EndIf
//Switches the menu text, center aligned
switchWaveListSelectorMenu(popStr)
//auto loads the selected data set into the Data Set waves list box
strswitch(popStr)
case "Wave Match":
case "Navigator":
case "Image Browser":
break
default:
Wave/T DSNamesLB_ListWave = NPD:DSNamesLB_ListWave
ListBox DataSetNamesListBox win=NTP#Data,selRow=tableMatch(popStr,DSNamesLB_ListWave)
changeDataSet(popStr)
endswitch
break
case "refreshMenu":
Wave/T param = NPC:ExtFunc_Parameters
GetExternalFunctionData(param)
BuildMenu "FunctionMenu"
BuildExtFuncControls(CurrentExtFunc())
break
case "functionPopUp":
//external functions drop down menu selection
Wave/T param = NPC:ExtFunc_Parameters
// GetExternalFunctionData(param)
BuildMenu "FunctionMenu"
SVAR selectedCmd = NPC:selectedCmd
PopUpContextualMenu/C=(40,62)/W=NTP#Func/N "FunctionMenu"
popStr = S_Selection
popNum = V_flag
If(V_flag == 0 || V_flag == -1)
break
EndIf
SwitchExternalFunction(popStr)
String func = GetFunctionFromTitle(popStr)
selectedCmd = func
SVAR currentFunc = NPC:currentFunc
currentFunc = selectedCmd
break
case "gotoFunc": //opens the procedure window of the current external function
func = CurrentExtFunc()
DisplayProcedure/W=NTP_ExternalFunctions func
break
case "funcNotes":
func = CurrentExtFunc()
String functionStr = ProcedureText(func,0)
String funcNote = GetFunctionNote(functionStr)
DisplayFunctionNote(func,funcNote)
break
case "measureType": //pop up menu for the Measure function
PopUpContextualMenu/C=(487,125)/N "MeasureTypeMenu"
popStr = S_Selection
popNum = V_flag
If(V_flag == 0 || V_flag == -1)
break
EndIf
//Calculates spacer to ensure centered text on the drop down menu
String spacer = ""
Variable cmdLen = strlen(popStr)
cmdLen = 15 - cmdLen
Do
spacer += " "
cmdLen -= 1
While(cmdLen > 0)
//switch the text on the button/drop down menu
Button measureType win=NT,title="\\JL▼ " + spacer + popStr
setupMeasureControls(popStr)
break
case "runFunc":
//Starts the series of wrapper functions that will run the specified user function.
RunCmd(selectedCmd)
break
case "scaleFactorUpdate":
NVAR scaleFactor = root:Packages:NT:Settings:scaleFactor
DoWindow/F/W=NTP NT
Variable dpi = ScreenResolution
dpi = round(dpi * scaleFactor)
String cmdStr = "SetIgorOption PanelResolution = 72"
Execute cmdStr
case "Reload":
GetWindow NTP wsize
KillWindow/Z NTP
LoadNeuroPlus()
DoWindow SI
If(V_flag)
KillWindow/Z SI
LoadScanImagePackage()
EndIf
break
case "Back":
folderBack()
break
case "hideNTP":
//hide the GUI
SetWindow NTP,hide=1
break
case "NT_Settings":
// openSettingsPanel()
break
case "addDataSet":
//adds a new data set with the contents of the WaveMatch list box
SVAR dsNameInput = NPD:dsNameInput
dsNameInput = ""
//Hide the update and delete data set controls
Button delDataSet win=NT,disable=1
Button updateDataSet win=NT,disable=1
//Wait for user to enter the data set name on mouse up
Do
PauseForUser/C NT
While(!strlen(dsNameInput))
If(addDataSet(dsNameInput))
print "ADD DATA SET ERROR"
EndIf
//close the text box
SetVariable dsNameInput win=NT,disable=1
GroupBox dsNameGroupBox win=NT,disable=1
//Show the update and delete data set controls
Button delDataSet win=NT,disable=0
Button updateDataSet win=NT,disable=0
break
case "delDataSet":
//Deletes a data set
Wave/T DSNamesLB_ListWave = NPD:DSNamesLB_ListWave
//No data sets exist to be deleted
If(DimSize(DSNamesLB_ListWave,0) == 0)
return 0
EndIf
String dsName = GetDSName()
If(deleteDataSet(dsName))
print "DELETE DATA SET ERROR"
EndIf
break
case "updateDataSet":
//Updates the selected data set with the contents of the WaveMatch list box
Wave/T DSNamesLB_ListWave = NPD:DSNamesLB_ListWave
//No data sets exist to be deleted
If(DimSize(DSNamesLB_ListWave,0) == 0)
return 0
EndIf
dsName = GetDSName()
//Nothing selected
If(!strlen(dsName))
return 0
EndIf
If(updateDataSet(dsName))
print "UPDATE DATA SET ERROR"
EndIf
break
case "clearFilters":
clearFilterControls()
break
case "appendCommand":
appendCommandLineEntry()
break
case "clearCommand":
clearCommandLineEntry()
break
// case "ntViewerButton":
// break
case "ntViewerAutoScaleButton":
SetAxis/W=NTP#Nav#Viewer/A
break
// case "ntViewerSeparateVertButton":
// SeparateTraces("vert")
// break
// case "ntViewerSeparateHorizButton":
// SeparateTraces("horiz")
// break
case "ntViewerDisplayTracesButton":
String theTraces = TraceNameList("NTP#Nav#Viewer",";",1)
GetWindow/Z NT wsize
//Duplicates the Viewer graph outside of the viewer
String winRec = WinRecreation("NTP#Nav#Viewer",0)
Variable pos1 = strsearch(winRec,"/W",0)
Variable pos2 = strsearch(winRec,"/FG",0) - 1
String matchStr = winRec[pos1,pos2]
winRec = ReplaceString(matchStr,winRec,"/W=(" + num2str(V_right+10) + "," + num2str(V_top) + "," + num2str(V_right+360) + "," + num2str(V_top+200) + ")")
winRec = ReplaceString("/FG=(FL,VT,FR,VB)/HOST=#",winRec,"")
Execute/Q/Z winRec
break
case "ntViewerClearTracesButton":
clearTraces()
NVAR areHorizSeparated = NPC:areHorizSeparated
NVAR areVertSeparated = NPC:areVertSeparated
areHorizSeparated = 0
areVertSeparated = 0
break
case "BrowseFiles":
//browse files on disk for wavesurfer loading
Variable fileID
SVAR wsFilePath = NPC:wsFilePath
SVAR wsFileName = NPC:wsFileName
//What file type are we opening?
ControlInfo/W=NTP fileType
String fileType = S_Value
BrowseEphys(fileType)
break
case "copyToClipboard":
Wave/T savedNameTable = NPC:savedNameTable
ControlInfo/W=NTP savedNames
Variable index = tablematch(S_Value,savedNameTable)
If(index == -1)
String str = ""
Else
str = savedNameTable[index][1]
EndIf
//Copy the string to the clipboard
PutScrapText str
break
case "editSaveNames":
Wave/T savedNameTable = NPC:savedNameTable
If(!WaveExists(savedNameTable))
Make/N=(0,2)/T/O NPC:savedNameTable /Wave = savedNameTable
EndIf
Edit savedNameTable
break
case "deleteSuffix":
RunCmd("delSuffix")
break
endswitch
return errorCode
End
//SET VARIABLES------------------------------------------------------------
Function ntSetVarProc(sva) : SetVariableControl
STRUCT WMSetVariableAction &sva
STRUCT filters filters
DFREF NPC = $CW
DFREF NPD = $DSF
SVAR listFocus = NPC:listFocus
switch( sva.eventCode )
case 1: // mouse up
case 2: // Enter key
Variable dval = sva.dval
String sval = sva.sval
strswitch(sva.ctrlName)
case "waveMatch":
case "waveNotMatch":
case "relativeFolderMatch":
//Save the current filters/grouping settings before changing focus
If(!cmpstr(listFocus,"DataSet"))
saveFilterSettings("DataSet")
EndIf
//Don't recall previous settings, bc we just changed it.
changeFocus("WaveMatch",0)
case "waveGrouping":
case "prefixGroup":
case "groupGroup":
case "seriesGroup":
case "sweepGroup":
case "traceGroup":
case "pos6Group":
case "pos7Group":
//Builds the match list according to all search terms, groupings, and filters
getWaveMatchList()
//display the full path to the wave in a text box
drawFullPathText()
break
case "dsNameInput":
SVAR dsNameInput = NPD:dsNameInput
dsNameInput = sval
break
case "cmdLineStr":
SVAR masterCmdLineStr = NPC:masterCmdLineStr
NVAR editingMasterCmdLineStr = NPC:editingMasterCmdLineStr