-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSharedWavesManager.ipf
executable file
·1633 lines (1548 loc) · 71.9 KB
/
SharedWavesManager.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 rtGlobals=1 // Use modern global access method.
#pragma IgorVersion = 5.05
#include "CustomFolderLoad"
#include "ListObjects"
#include "killDisplayedWave"
//Last modified Oct 03 2012 by Jamie Boyd
//SharedWavesManager provides a simple interface to load, edit, and save waves that are shared with files on disk.
//This provides an easy way to accumulate summary data from different experiments.
//The left side of the SharedWavesManager control panel includes a listbox showing Igor Binary Waves in a chosen directory on the disk
// and controls to choose the directory and to load (as shared waves) Igor binary waves selected in the list box.
// The left side of the control panel has a list box for Igor waves in the chosen datafolder in the open Igor Experiment
// and controls to choose the datafolder and to save to the selected disk directory (as shared Igor Binary Waves) waves from this dataFolder
//The center of the control panel contains an embedded table showing the loaded waves, and buttons to make new shared waves and to
// save and unload from the experiment the shared waves selected in the embedded table.
menu "Macros"
"Manage Shared Waves",/Q, SharedWaves_MenuStart ()
end
//*****************************************************************************************************
// when starting from menu, prompt for instance name, and don't wait for user to set datafolder and directory
Function SharedWaves_MenuStart ()
string instanceName=""
prompt instanceName, "Name for this Shared Waves Manager :"
doPrompt "Shared Waves Manager", instanceName
if (V_FLag)
return 1
else
SharedWaves_Init (instanceName,"","",0)
endif
end
//*****************************************************************************************************
//Make some global values in a packages folder and make the sharedwavesmanager control panel
// a new folder will be made for each instance of shared waves manager. Each instance must have a unique name
// Last Modified Nov 16 2011 by Jamie Boyd
Function SharedWaves_Init (instanceName, inDirPathStr, inFldrStr, setDirAndFldr)
string instanceName
string inDirPathStr
string inFldrStr
variable setDirAndFldr // if non-zero, set up pauseForUser until directory and datafolder are both valid
string instanceClean =cleanupname (instanceName, 0)
// initialize sharedwaves folder with list of instances, or add this instance to the list
if (!(datafolderexists ("root:packages:")))
newdatafolder root:packages
endif
if (!(datafolderexists ("root:packages:SharedWaves")))
newdatafolder root:packages:sharedwaves
endif
// make dataFolder for this instance, if needed, and reference globals
if (!(dataFolderExists ("root:packages:sharedWaves:" + instanceClean)))
newDataFolder $"root:packages:sharedWaves:" + instanceClean
//waves for the list box showing files in the selected directory
make/t/n = 0 $"root:packages:sharedwaves:" + instanceClean + ":DirListWave"
make/n = 0 $"root:packages:sharedwaves:" + instanceClean + ":DirListSelWave"
//and in the selected data folder
make/t/n = 0 $"root:packages:sharedwaves:" + instanceClean + ":FldrListWave"
make/n = 0 $"root:packages:sharedwaves:" + instanceClean + ":FldrListSelWave"
// the description of the path to the directory, written out in full for display on the control panel
String/G $"root:packages:sharedWaves:" + instanceClean + ":dirPathDescStr" = ""
// the name of the datafolder in the current Igor Experiment where shared waves will be loaded
String/G $"root:packages:sharedWaves:" + instanceClean + ":fldrStr" = ""
endif
WAVE/T DirListWave = $"root:packages:sharedwaves:" + instanceClean + ":DirListWave"
WAVE DirListSelWave = $"root:packages:sharedwaves:" + instanceClean + ":DirListSelWave"
WAVE/T fldrListWave = $"root:packages:sharedwaves:" + instanceClean + ":FldrListWave"
WAVE fldrListSelWave = $"root:packages:sharedwaves:" + instanceClean + ":FldrListSelWave"
redimension/n = 0 DirListWave, DirListSelWave, fldrListWave, fldrListSelWave
SVAR dirPathDescStr = $"root:packages:sharedWaves:" + instanceClean + ":dirPathDescStr"
SVAR fldrStr = $"root:packages:sharedWaves:" + instanceClean + ":fldrStr"
// Symbolic path - either passed as a an Igor Path or as a path description
string dirPath =instanceClean + "_Path"
if (cmpStr (inDirPathStr, "") != 0) // we were passed a string
// check if inDirPath is the name of an existing Igor path and if so, use it.
PathInfo/S $inDirPathStr
if (V_flag ==1) // inDirPathStr is an existing Igor Path. Copy it to the path for this instance
NewPath/O/Z $dirPath, S_path
dirPathDescStr = S_path
else // check if inDirPathStr is a description of a path to a directory
GetFileFolderInfo/D/Q/Z=1 inDirPathStr
if (V_Flag ==0) // inDirPathStr is a valid path
NewPath/O/Z $dirPath, S_path
dirPathDescStr = S_path
else // inDirPathStr is not valid. Set it to ""
inDirPathStr = ""
endif
endif
endif
if (cmpStr (inDirPathStr, "") == 0) // we were passed an empty string or a bad path...
if (cmpStr (dirPathDescStr, "") != 0) // BUT we have existing path
GetFileFolderInfo/D/Q/Z=1 dirPathDescStr
if (V_Flag ==0) // dirPathDescStr is a valid path
NewPath/O/Z $dirPath, S_path
else
dirPathDescStr = "" // user will have to set it
endif
else
dirPathDescStr = "" // user will have to set it
endif
endif
// datafolder String
if (cmpstr (inFldrStr, "") !=0)
if (DataFolderExists (inFldrStr))
fldrStr = inFldrStr
else
inFldrStr = ""
endif
endif
if (cmpStr (inFldrStr, "") == 0) // passed empty string or a bad datafolder spec
if (cmpStr (fldrStr, "") != 0) // but we have existing datafolder spec
if (!(DataFolderExists (fldrStr)))
fldrStr = ""
endif
endif
endif
// make control panel for this instance, if needed
string panelName = instanceClean + "_SW"
doWindow/F $panelName
if (!(V_Flag ))
NewPanel /K=1 /W=(2,44,971,521) as instanceName + " Shared Waves"
DoWindow/C $panelName
// Set/show directory on disk
GroupBox SetDirGrp win=$panelName , pos={2,0},size={100,43},title="Set Me First",fSize=9,frame=0
GroupBox SetDirGrp win=$panelName, fColor=(65535,0,0)
Button SetPathButton win=$panelName ,pos={6,17},size={90,21},proc=SharedWaves_SetPathProc,title="Set Directory"
Button SetPathButton win=$panelName,help={"Allows you to select the Shared Waves directory - where .ibw files for shared waves are located."}
TitleBox SharedWavesPathTitle win=$panelName,pos={107,18}, size={394,16}
TitleBox SharedWavesPathTitle win=$panelName, help={"Shows the path to the selected Shared Waves directory - where .ibw files for shared waves are locaed"}
TitleBox SharedWavesPathTitle win=$panelName,fSize=12,frame=0
TitleBox SharedWavesPathTitle win=$panelName,variable= dirPathDescStr
// List box for files in directory
ListBox SharedWavesList win=$panelName,pos={4,54},size={151,418}
ListBox SharedWavesList win=$panelName,help={"Select waves to be be loaded from this list of all the .ibw files in the Shared Waves directory."}
ListBox SharedWavesList win=$panelName,listWave=DirListWave
ListBox SharedWavesList win=$panelName,selWave=DirListSelWave
ListBox SharedWavesList win=$panelName,mode= 4
// buttons managing directory list box
Button UpdateDirButton win=$panelName,pos={159,58},size={84,22},proc=SharedWaves_UpdatePathListProc,title="Update Dir"
Button UpdateDirButton win=$panelName,help={"Updates the list of .ibw files in the Shared Waves directory"}
Button SelectAllDirButton win=$panelName,pos={160,88},size={84,22},proc=SharedWaves_SelectAllProc,title="Select All"
Button SelectAllDirButton win=$panelName,help={"Selects all the files in the list of .ibw files in the Shared Waves directory"}
Button LoadSelectedButton win=$panelName,pos={159,118},size={84,22},proc=SharedWaves_LoadSelectedProc,title="Share-->"
Button LoadSelectedButton win=$panelName,help={"Loads shared waves from .ibw files selected from the list of files in the Shared Waves directory."}
// Set/Show Igor data folder
GroupBox SetFldrGrp win=$panelName, pos={502,1},size={123,43}, title="Set Me First",fSize=9,frame=0
GroupBox SetFldrGrp win=$panelName,fColor=(65535,0,0)
PopupMenu DataFolderPopUp win=$panelName,pos={507,16},size={114,20},proc=SharedWaves_setDFProc,title="Set DataFolder"
PopupMenu DataFolderPopUp win=$panelName,fSize=12
PopupMenu DataFolderPopUp win=$panelName,mode=0,value= #"\"Current Folder-\" + getdatafolder(1)+ \";New Folder;\\\\M1-;\" + \"root:;\" + ListObjectsRecursive(\"root:\", 4, \"*\") "
PopupMenu DataFolderPopUp win=$panelName,help = {"Sets the Shared Waves data folder - from where waves to be shared will be selected, and to where waves loaded from .ibw files will be stored."}
TitleBox DataFolderTitle win=$panelName,pos={629,18},size={338,16}, fSize=12,frame=0, variable= fldrStr
TitleBox DataFolderTitle win=$panelName, help = {"Shows the Shared Waves data folder."}
// List box for waves in data folder
ListBox DataFolderWavesList win=$panelName,pos={814,54},size={151,418}
ListBox DataFolderWavesList win=$panelName,help={"Select waves to be be saved to disk from this list of all the waves in the Shared Waves datafolder"}
ListBox DataFolderWavesList win=$panelName,listWave=fldrListWave
ListBox DataFolderWavesList win=$panelName,selWave=fldrListSelWave
ListBox DataFolderWavesList win=$panelName,mode= 4
// buttons for managing waves in data folder
Button UpdateFldrButton win=$panelName,pos={725,58},size={84,22},proc=SharedWaves_UpdateFldrProc,title="Update Fldr"
Button UpdateFldrButton win=$panelName, help = {"Updates the list of waves in the Shared Waves datafolder"}
Button SelectAllFldrButton win=$panelName,pos={725,88},size={84,22},proc=SharedWaves_SelectAllProc,title="Select All"
Button SelectAllFldrButton win=$panelName,help={"Selects all the waves in the list of waves from the Shared Waves datafolder"}
Button ShareWavesButton win=$panelName,pos={725,118},size={84,22},proc=SharedWaves_ShareDFProc,title="<--Share"
Button ShareWavesButton win=$panelName, help = {"Saves selected waves as shared .ibw files in the Shared Waves directory"}
//a table allowing editing and selecting of all the shared waves we are are managing
Edit/W=(248,53,718,438)/HOST=#
RenameWindow #,SWT
SetActiveSubwindow ##
// Buttons for managing waves that are currently shared
Button NewWaveButton win=$panelName,pos={192,446},size={122,22},proc=SharedWaves_NewWaveProc,title="New Shared Wave"
Button NewWaveButton win=$panelName,help={"Makes a new Shared Wave in Shared Waves datafolder, shared with an .ibw file in the Shared Waves directory"}
Button UnShareButton win=$panelName,pos={318,446},size={121,22},proc=SharedWaves_UnShareProc,title="Unshare Selected"
Button UnShareButton win=$panelName,help={"adopts selected waves (or all shared waves, if shift key pressed) into the Experiment, breaking link with .ibw files in Shared Waves directory."}
Button UpdateButton win=$panelName,pos={443,446},size={93,22},proc=SharedWaves_UpdateToDiskProc,title="Save Selected"
Button UpdateButton win=$panelName,help={"Saves selected waves (or all shared waves if shift key pressed) to their shared .ibw files without having to save the entire Experiment"}
Button KillButton win=$panelName,pos={541,446},size={86,22},proc=SharedWaves_KillSelectedProc,title="Kill Selected"
Button KillButton win=$panelName,help={"Kills selected waves (or all shared waves if shift key pressed) including the shared .ibw files."}
Button SortButton win=$panelName,pos={632,446},size={44,22},proc=SharedWaves_SortButtonProc,title="Sort"
Button SortButton win=$panelName,help={"Sorts selected waves (or all shared waves if shift key pressed) by a key wave chosen from a menu"}
Button SaveAsTextButton win=$panelName,pos={683,446},size={86,22},proc=SharedWaves_WriteDelimTextProc,title="Save as Text"
Button SaveAsTextButton win=$panelName,help={"Saves selected waves (or all shared waves if shift key pressed) as a single tab-delimitted (or comma-delimitted if command/control key pressed) text file"}
// fixed size option for title boxes not compatible with Igor 5
if (NumberByKey("IGORVERS", IgorInfo(0), ":", ";") >= 6)
Execute/Q "TitleBox SharedWavesPathTitle win=" + panelName + ", fixedSize =1"
Execute/Q "TitleBox DataFolderTitle win=" + panelName + ", fixedSize =1"
endif
// set resizing hook
setWindow $panelName hook(ReSizeHook )=SharedWaves_ResizeHook
endif
// check that symbolic path and Igor dataFolder are valid and return this info, bitwise bit 0 for directory and bit 1 for dataFolder
variable returnVal = 0
if (cmpstr (dirPathDescStr, "") !=0)
returnVal +=1
groupbox SetDirGrp win=$panelName, disable =1
STRUCT WMButtonAction ba
ba.eventCode = 2
ba.win = InstanceClean + "_SW"
SharedWaves_UpdatePathListProc(ba)
endif
if ((dataFolderExists (fldrStr)) && (cmpstr (fldrStr, "") != 0)) // the data foler "" always exists; you're in it right now! (relative path to current datafolder)
returnVal +=2 // datafolder found
groupbox SetFldrGrp win=$panelName, disable =1
SharedWaves_UpdateFldr (instanceClean)
endif
// if both are valid, look for already shared waves
if (returnVal == 3)
SharedWaves_UpdateShared (instanceClean)
else // ensure dhared waves table is blank
SharedWaves_CleanShared (instanceClean)
endif
// if requested, make sure both directory and data folder are valid
if ((setDirAndFldr ==1) && (returnVal < 3))
newpanel/N=swmSetWarn/W=(150,50,462,154) as instanceName + " Shared Waves Warning"
TitleBox WarningTitle,pos={42,8},size={218,38},title="Please set a Valid Disk Directory and\rIgor Pro DataFolder then click \"O.K.\"."
TitleBox WarningTitle,fSize=14,frame=0
Button okButton,pos={112,58},size={50,20},proc=SharedWaves_ValidButtonProc,title="O.K."
string/G root:packages:sharedWaves:WarnInstance = instanceClean
pauseForUser swmSetWarn, $panelName
endif
return returnVal
end
//*****************************************************************************************************
// hook function that does control resizing/moving upon a resize event
// Last Modified Dec 01 2011 by Jamie Boyd
function SharedWaves_ResizeHook(s)
STRUCT WMWinHookStruct &s
if (s.eventCode ==6)
// test for minimum width, height
variable doMove=0
if (s.winRect.right < 580)
s.winRect.right = 580
doMove += 1
endif
if (s.winRect.bottom < 220)
s.winRect.bottom = 220
doMove +=2
endif
if (doMove > 0)
GetWindow $s.winName wsize
variable winFudge=(72/ScreenResolution)
switch (doMove)
case 1: // adjust length only
movewindow /w=$s.winName ( winFudge * V_left), (winFudge * V_Top), (winFudge * (V_left + 580)), (winFudge* (V_bottom))
break
case 2: // adjust height only
movewindow /w=$s.winName ( winFudge * V_left), (winFudge * V_Top), (winFudge * (V_Right)), (winFudge* (V_Top + 220))
break
case 3: // adjust both length and height
movewindow /w=$s.winName ( winFudge * V_left), (winFudge * V_Top), (winFudge * (V_left + 580)), (winFudge* (V_Top + 220))
break
endswitch
endif
// adjust position of datafolder popup and title
variable leftPos = s.winRect.right/2
PopupMenu DataFolderPopUp win= $s.winName, pos={leftPos,16}
TitleBox DataFolderTitle win= $s.winName, pos={(leftPos + 120),17}, size = {(s.winRect.right - (leftPos + 120)), 16}
// adjust length of pathTitle
TitleBox SharedWavesPathTitle win= $s.winName, size={(leftPos - 112),16}
// adjust "editing" buttons at bottom of panel
variable bottomPos = s.winRect.bottom-24
variable buttonLeft = (s.winRect.right - 575)/2
Button NewWaveButton win= $s.winName, pos={(buttonLeft),(bottomPos)}
buttonLeft += 126
Button UnShareButton win= $s.winName, pos={buttonLeft,(bottomPos)}
buttonLeft += 125
Button UpdateButton win= $s.winName, pos={buttonLeft,(bottomPos)}
buttonLeft += 98
Button KillButton win= $s.winName, pos={buttonLeft,(bottomPos)}
buttonLeft += 90
Button SortButton win= $s.winName, pos={buttonLeft,(bottomPos)}
buttonLeft += 49
Button SaveAsTextButton win= $s.winName, pos={buttonLeft,(bottomPos)}
// adjust height of list boxes and position of datafolder list box
variable listboxsize= s.winRect.bottom - 56
if (((s.winRect.right - 575)/2) < 157)
listboxsize -= 26
endif
leftPos = s.winRect.right - 153
ListBox SharedWavesList win= $s.winName, size={151,listboxsize}
ListBox DataFolderWavesList win= $s.winName, pos={leftPos,54}, size={151,listboxsize}
// adjust positions of folder buttons
leftPos -= 88
Button UpdateFldrButton win= $s.winName, pos={leftPos,58}
Button SelectAllFldrButton win= $s.winName, pos={leftPos,88}
Button ShareWavesButton win= $s.winName, pos={leftPos,118}
// resize table subwindow
MoveSubwindow /W=$s.winName + "#SWT" fnum=(248, 53, (leftPos -2), (bottomPos -2))
return 1
endif
return 0 // 0 if nothing done, else 1
End
//*****************************************************************************************************
// Makes sure that directory and datafolder are valid. If so, kill the window to exit pause for user.
// Last Modified Nov 2 2011 by Jamie Boyd
Function SharedWaves_ValidButtonProc(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
variable Valid = 0
SVAR warnInstance = root:packages:sharedWaves:WarnInstance
string instanceClean = cleanupname (warnInstance, 0)
string panelName = instanceClean + "_SW"
string dirPath = instanceClean + "_Path"
SVAR dirPathDescStr = $"root:packages:sharedWaves:" + instanceClean + ":dirPathDescStr"
GetFileFolderInfo/D/Q/Z=1 dirPathDescStr
if (V_Flag ==0) // directory was found
Valid +=1
endif
SVAR folderStr = $"root:packages:sharedWaves:" + instanceClean + ":fldrStr"
if ((dataFolderExists (folderStr)) && (cmpstr (folderStr, "") != 0))
Valid +=2
endif
if (Valid ==3)
doWindow/K swmSetWarn
endif
break
case -1: // control being killed
break
endswitch
return 0
End
//*****************************************************************************************************
// Looks if waves are already shared between the Shared Waves directory on disk and the Shared Waves Datafolder, and adds them to the Shared Waves Table
// Make sure the list boxes are updated before calling this function, or you may have waves in the table that don't appear in the lists of available waves
// Last modified Jan 13 2012 by Jamie Boyd
Function SharedWaves_UpdateShared (instanceClean)
string instanceClean
SharedWaves_CleanShared (instanceClean)
SVAR fldrStr = $"root:packages:sharedWaves:" + instanceClean + ":fldrStr"
string importPathStr = InstanceClean + "_Path"
string fldrwaves = ListObjects(fldrStr, 1, "*", 0, "")
variable iWave, nWaves = itemsinlist (fldrwaves, ";")
string tableName = instanceClean + "_SW#SWT"
string wavePath
for (iWave =0;iWave < nWaves; iWave +=1)
WAVE aWave = $fldrStr + stringfromlist (iWave, fldrwaves, ";")
wavePath = stringBYkey ("PATH", waveinfo (aWave, 0), ":", ";")
if (cmpStr (wavePath, ImportPathStr) == 0) // the wave is loaded from the shared waves directory and has same name, it's probably the same wave, so add to the table
AppendToTable /W=$tableName aWave
if (cmpstr (waveUnits(aWave, -1), "dat") ==0)
ModifyTable/W=$tableName format(aWave)=8
elseif (wavetype (aWave) == 4)
ModifyTable /W= $tableName sigDigits(aWave)=16
else
ModifyTable /W= $tableName sigDigits(aWave)=8
endif
endif
endfor
end
//*****************************************************************************************************
// Removes all the waves from the shared waves table
// Last modified Nov 16 2011 by Jamie Boyd
Function SharedWaves_CleanShared (instanceClean)
string instanceClean
string info = TableInfo (instanceClean + "_SW#SWT", -2)
variable iCol, lastCol =NumberByKey("COLUMNS", info , ":", ";") -2
string colWaveStr
for (iCol =lastCol; iCol >= 0; iCol -=1)
colWaveStr = stringbykey ("WAVE", TableInfo (instanceClean + "_SW#SWT", iCol), ":", ";")
WAVE colwave = $colWaveStr
RemoveFromTable/W= $instanceClean + "_SW#SWT" $colWaveStr
endfor
end
//*****************************************************************************************************
//set the path to the directory on disk
// Last modified Nov 16 2011 by Jamie Boyd
Function SharedWaves_SetPathProc(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
string instanceClean = stringfromlist (0, ba.win, "_")
WAVE/T DirListWave = $"root:packages:sharedwaves:" + instanceClean + ":DirListWave"
WAVE DirListSelWave = $"root:packages:sharedwaves:" + instanceClean + ":DirListSelWave"
SVAR pathDescStr = $"root:packages:sharedWaves:" + instanceClean + ":dirPathDescStr"
string newPathDesc = CFL_SetImPathProc(instanceClean + "_Path", "Igor binary waves and saving them")
if (cmpStr (newPathDesc, "") != 0)
groupbox SetDirGrp win=$ba.win, disable =1
pathDescStr =newPathDesc
CFL_ShowFilesinFolder (DirListWave, DirListSelWave, ".ibw", "", "", instanceClean + "_Path")
// if we have a folder, update shared waves
SVAR fldrStr = $"root:packages:sharedwaves:" + instanceClean + ":fldrStr"
if ((cmpStr (fldrStr, "") != 0) && (dataFolderExists (fldrStr)))
SharedWaves_UpdateShared (instanceClean)
else
SharedWaves_CleanShared (instanceClean)
endif
endif
break
case -1: // control being killed
break
endswitch
return 0
End
//*****************************************************************************************************
//Updates the listing of the contents of the disk directory pointed to by SharedWavesPath by calling SharedWaves_UpdatePathList
// Last modified Nov 18 2011 by Jamie Boyd
Function SharedWaves_UpdatePathListProc(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
string instanceClean = stringfromlist (0, ba.win, "_")
SharedWaves_UpdatePathList (instanceClean)
break
case -1: // control being killed
break
endswitch
return 0
End
//*****************************************************************************************************
//Updates the listing of the contents of the disk directory pointed to by SharedWavesPath
// Last modified Nov 18 2011 by Jamie Boyd
Function SharedWaves_UpdatePathList (instanceClean)
string instanceClean
WAVE/T DirListWave = $"root:packages:sharedwaves:" + instanceClean + ":DirListWave"
WAVE DirListSelWave = $"root:packages:sharedwaves:" + instanceClean + ":DirListSelWave"
CFL_ShowFilesinFolder (DirListWave, DirListSelWave, ".ibw", "", "", instanceClean + "_Path")
end
//*****************************************************************************************************
//Select all the files in the list of Igor Binary waves in the chosen directory, or all the waves in the chosen data folder
// Last modified Oct 21 2011 by Jamie Boyd
Function SharedWaves_SelectAllProc(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
string instanceClean = stringfromlist (0, ba.win, "_")
if (cmpStr (ba.ctrlName, "SelectAllDirButton") ==0)
WAVE ListSelWave = $"root:packages:sharedwaves:" + instanceClean + ":DirListSelWave"
else
WAVE ListSelWave = $"root:packages:sharedwaves:" + instanceClean + ":FldrListSelWave"
endif
CFL_SelectAllProc(ListSelWave)
case -1: // control being killed
break
endswitch
return 0
End
//*****************************************************************************************************
// load (into the chosen folder) as shared waves the files selected from the listbox showing files in the directoy
// Gives user option to rename or overwrite previously existing waves in the chosen folder with the same name
// Last modified Nov 2 2011 by Jamie Boyd
Function SharedWaves_LoadSelectedProc(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch(ba.eventCode)
case 2: // mouse up
string instanceClean = stringfromlist (0, ba.win, "_")
STRUCT CFL_loadStruct s
s.importPathStr = instanceClean + "_Path"
SVAR TargetFolderStr = $"root:packages:sharedWaves:" + instanceClean + ":fldrStr"
WAVE/T s.FolderListWave = $"root:packages:sharedwaves:" + instanceClean + ":DirListWave"
WAVE s.FolderListSelWave = $"root:packages:sharedwaves:" + instanceClean + ":DirListSelWave"
s.TargetFolderStr=TargetFolderStr
funcref CFL_LoadProtoFunc s.LoadFunc = SharedWaves_LoadFunc
funcref CFL_ProcessProtoFunc s.ProcessFunc = SharedWaves_ProcessFunc
s.loadOptionStr =instanceClean
s.processOptionStr = instanceClean
s.overWrite = 2
s.WaveRename =2
CFL_CustomFolderLoad (s)
SharedWaves_UpdateFldr (instanceClean)
break
case -1: // control being killed
break
endswitch
return 0
End
//*****************************************************************************************************
// loads an individual .ibw as a shared wave, and tries to harmonize with waves already in dataFolder
// last modified Jan 13 2012 by Jamie Boyd
function SharedWaves_LoadFunc(ImportPathStr, FileNameStr, instanceClean)
string ImportPathStr // string containing the name of an Igor path to the folder on disk from which to import files (ImportPath)
string FileNameStr // string containing the name of the selected file
string instanceClean // option string used to pass name of instance of shared waves manager
// does a wave with the same name as the .ibw file already exist in the dataFolder?
SVAR fldrStr = $"root:packages:sharedWaves:" + instanceClean + ":fldrStr"
String newWaveName = removeEnding (filenameStr, ".ibw")
WAVE/Z alreadyLoadedWave = $fldrStr + newWaveName
SVAR pathDescStr = $"root:packages:sharedWaves:" + instanceClean + ":dirPathDescStr"
string tableName = instanceClean + "_SW#SWT"
if (WaveExists (alreadyLoadedWave))
string wavePath = stringBYkey ("PATH", waveinfo (alreadyLoadedWave, 0), ":", ";")
PathInfo $wavePath
if ((V_Flag ==1) && (cmpStr (S_Path, pathDescStr) ==0))
AppendToTable/W=$tableName alreadyLoadedWave
if (cmpstr (waveUnits(alreadyLoadedWave, -1), "dat") ==0)
ModifyTable/W=$tableName format(alreadyLoadedWave)=8
elseif (wavetype (alreadyLoadedWave) == 4)
ModifyTable /W= $tableName sigDigits(alreadyLoadedWave)=16
else
ModifyTable /W= $tableName sigDigits(alreadyLoadedWave)=8
endif
else // alert the user to the conflict
doAlert 2, "A Wave named \"" + newWaveName + "\" already exists in the \"" + instanceClean +"\" datafolder. Press \"Yes\" to replace the existing wave. Press \"No\" to replace the .ibw file. Press \"Cancel\" to leave both file and wave unchanged"
if (V_Flag == 1) // yes to overwriting existing wave,
// Load the wave - into the CFL "SandBox" folder
LoadWave/O/P=$ImportPathStr FileNameStr
// there is very slight possibility that wave name and .ibw file name may be out of synch
if (cmpStr (newWaveName , stringfromlist (0, S_waveNames, ";")) != 0)
doAlert 0, "FYI: the name of the wave loaded from the file did not match the file name. Shared Waves Manager frowns on this behaviour."
endif
elseif (V_Flag == 2) // no to overwriting wave, but go the other way, overwriting .ibw file with wave
Save/O/P= $ImportPathStr alreadyLoadedWave as LowerStr(FileNameStr )
AppendToTable /W=$tableName alreadyLoadedWave
if (cmpstr (waveUnits(alreadyLoadedWave, -1), "dat") ==0)
ModifyTable/W=$tableName format(alreadyLoadedWave)=8
elseif (wavetype (alreadyLoadedWave) == 4)
ModifyTable /W= $tableName sigDigits(alreadyLoadedWave)=16
else
ModifyTable /W= $tableName sigDigits(alreadyLoadedWave)=8
endif
endif
endif
else // no conflicts, just load the file
LoadWave/O/P=$ImportPathStr FileNameStr
endif
End
//*****************************************************************************************************
// adds a loaded individual wave to the table for this instance of shared waves manager, after being moved by CFL into the dataFolder
// last modified Jan 13 2011 by Jamie Boyd
Function SharedWaves_ProcessFunc(LoadedWave, ImportPathStr, FileNameStr, instanceClean)
Wave LoadedWave // A reference to the loaded wave
string ImportPathStr // string containing the name of an Igor path to the folder on disk from which to import files (ImportPath)
string FileNameStr // string containing the name of the file on disk from where the wave was loaded
string instanceClean // option string used to pass name of instance of shared waves manager
string tableName = instanceClean + "_SW#SWT"
AppendToTable /W=$tableName loadedWave
if (cmpstr (waveUnits(LoadedWave, -1), "dat") ==0)
ModifyTable/W=$tableName format(loadedWave)=8
elseif (wavetype (loadedWave) == 4)
ModifyTable /W= $tableName sigDigits(loadedWave)=16
else
ModifyTable /W= $tableName sigDigits(loadedWave)=8
endif
End
//*****************************************************************************************************
//Selects datafolder to put shared waves in and to get shared waves from. Appends waves in datafolder to DataFolderWavesList
// Last modified Oct 21 2011 by Jamie Boyd
Function SharedWaves_setDFProc(pa) : PopupMenuControl
STRUCT WMPopupAction &pa
switch( pa.eventCode )
case 2: // mouse up
string instanceClean = stringfromlist (0, pa.win, "_")
SVAR DataFolderStr = $"root:packages:sharedwaves:" + instanceClean +":fldrStr"
switch (pa.popnum)
case 1: // current folder
DataFolderStr = getdatafolder (1)
break
case 2: //new folder
string folderHere = DataFolderStr
string folderName = "New"
Prompt FolderHere, "Make New DataFolder Here:" , popup, "root:;" + ListObjectsRecursive("root:", 4, "*")
Prompt folderName, "Name for new DataFolder:"
DoPrompt "Make a new DataFolder", FolderHere, FolderName
if (V_flag==1)
DatafolderStr = getdatafolder (1)
else
foldername = cleanupname (foldername, 1)
newdatafolder/o $folderhere + foldername
DataFolderStr = folderhere + foldername + ":"
endif
break
default:
DatafolderStr = pa.popStr
break
endswitch
groupbox SetFldrGrp win=$pa.win, disable =1
// update list box for waves in datafolder
SharedWaves_UpdateFldr (instanceClean)
// if we have a path, update the table
PathInfo $instanceClean + "_Path"
if (V_Flag ==1)
SharedWaves_UpdateShared (instanceClean)
else
SharedWaves_CleanShared (instanceClean)
endif
break
case -1: // control being killed
break
endswitch
return 0
End
//*****************************************************************************************************
// Button function to update the listbox that shows the contents of the dataFolder slected for sharing waves
// last modified Nov 2 2011 by Jamie Boyd
Function SharedWaves_UpdateFldrProc(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
string instanceClean = StringFromList(0, ba.win , "_")
SharedWaves_UpdateFldr (instanceClean)
break
case -1: // control being killed
break
endswitch
return 0
End
//*****************************************************************************************************
// Updates the listbox that shows the contents of the dataFolder slected for sharing waves
// last modified Oct 21 2011 by Jamie Boyd
function SharedWaves_UpdateFldr (instanceClean)
string instanceClean // cleaned up name of this instance of shared waves manager
SVAR DataFolderStr = $"root:packages:sharedwaves:" + instanceClean +":fldrStr"
WAVE/T ListWave = $"root:packages:sharedwaves:" + instanceClean + ":FldrListWave"
WAVE SelWave =$"root:packages:sharedwaves:" + instanceClean + ":FldrListSelWave"
string waves = ListObjects(DataFolderStr, 1, "*", 0, "")
variable ii, nWaves = itemsinlist (waves, ";")
Redimension/N=(nWaves) ListWave, SelWave
for (ii = 0; ii < nWaves; ii += 1)
ListWave [ii] = stringfromlist (ii, waves, ";")
endfor
selWave =0 // make sure nothing is selected in the listbox
end
//*****************************************************************************************************
// Shares Selected waves by saving them to selected directory, trying to harmonize with existing .ibw files
// Last modified Nov 18 2011 by Jamie Boyd
Function SharedWaves_ShareDFProc(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
string instanceClean = stringFromList (0, ba.win, "_")
string sharedWavesPath = instanceClean + "_Path"
SVAR dfStr = $"root:packages:SharedWaves:" + instanceClean +":fldrStr"
SVAR dirPathDescStr = $"root:packages:SharedWaves:" + instanceClean +":dirPathDescStr"
WAVE/T dfList = $"root:packages:SharedWaves:" + instanceClean +":fldrListWave"
WAVE dfSelList = $"root:packages:SharedWaves:" + instanceClean +":fldrListSelWave"
variable iPos, nPos = numpnts (dfList)
string wavePath, savedFolder
string tableName = instanceClean + "_SW#SWT"
for (iPos= 0; iPos < nPos ;iPos +=1)
if ((dfSelList [iPos] & 1))
WAVE theWave = $dfStr + dfList [iPos]
// does a file with the same name already exists in the directory?
GetFileFolderInfo/Q/Z=1 dirPathDescStr + dfList [iPos] + ".ibw"
if (V_Flag == 0) //such a file exists
wavePath = stringBYkey ("PATH", waveinfo (theWave, 0), ":", ";")
pathinfo $wavePath
if ((V_Flag ==1) && (cmpStr (S_Path, dirPathDescStr)==0)) // it's the same wave, already shares
AppendToTable /W=$tableName theWave
else // it's not the same wave
doAlert 2, "A file named \"" + dfList [iPos] + ".ibw\" already exists in the \"" + instanceClean +"\" directory. Press \"Yes\" to replace the existing .ibw file. Press \"No\" to replace the wave. Press \"Cancel\" to leave both wave and .ibw file unchanged"
if (V_Flag == 3) // Cancel
continue
elseif (V_Flag ==2) // overwrite the wave with the .ibw replacement
// Load the wave
savedFolder = getdatafolder (1)
setdatafolder $dfStr
LoadWave/O/P=$sharedWavesPath dfList [iPos] + ".ibw"
AppendToTable /W=$tableName theWave
setdatafolder $savedFolder
elseif (V_Flag ==1) // overwrite .ibw with wave
Save/O/P= $SharedWavesPath theWave as LowerStr(dfList [iPos]) + ".ibw"
AppendToTable /W=$tableName theWave
endif
endif
else // no matching .ibw file exists
Save/O/P= $SharedWavesPath theWave as LowerStr(dfList [iPos]) + ".ibw"
AppendToTable /W=$tableName theWave
endif
endif
if (cmpstr (waveUnits(theWave, -1), "dat") ==0)
ModifyTable/W=$tableName format(theWave)=8
elseif (wavetype (theWave) == 4)
ModifyTable /W= $tableName sigDigits(theWave)=16
else
ModifyTable /W= $tableName sigDigits(theWave)=8
endif
endfor
SharedWaves_UpdatePathListProc(ba)
break
case -1: // control being killed
break
endswitch
return 0
End
//*****************************************************************************************************
//Makes a new Igor Binary wave and saves it as a shared wave in the chosen directory and dataFolder.
// Overwrites files with same name that may be in the chosen directory or dataFolder
// Last modified Jan 13 2012 by Jamie Boyd
Function SharedWaves_NewWaveProc(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
string instanceClean = stringfromlist (0, ba.win, "_")
SVAR DataFolderStr = $"root:packages:sharedwaves:" + instanceClean +":fldrStr"
string pathStr = instanceClean + "_Path"
// prompt for new wave name and dataType
string newWavename
variable dType, isUnsigned
Prompt newWavename, "Name for new wave:"
Prompt dtype, "Data type of new wave:", popup, "32-bit float;64-bit float;8-bit int;16-bit int;32-bit int;text"
Prompt isUnsigned, "Integer types are:", popup "signed;unsigned"
DoPrompt "Make a new shared wave", newWaveName, dtYpe, isUnsigned
if (V_flag==1)
return 1
endif
// check for wave and .ibw file
variable newFileExists = 0
SVAR dirPathDescStr = $"root:packages:sharedwaves:" + instanceClean +":dirPathDescStr"
GetFileFolderInfo/Q/Z=1 dirPathDescStr +newwavename + ".ibw"
if (V_Flag ==0) // file was found
newFileExists = 1
endif
newWaveName = cleanupname (newWaveName, 0)
string newwavenameAndPath = DataFolderStr + newwavename
variable newWaveExists = 0
if (waveExists ($newwavenameAndPath))
newWaveExists = 1 // file was found
WAVE oldWave = $newwavenameAndPath
// NOTE: overwriting will fail if overwriting a text wave with a numeric wave
if ((dtype == 6) && (wavetype (oldWave) != 0))
doalert 0, "A numeric wave with the name \"" + newWaveName + "\" already exists and, sadly, you can't overwrite a numeric wave with a text wave."
return 1
elseif ((dtype != 6) && (wavetype (oldWave) == 0))
doalert 0, "A text wave with the name \"" + newWaveName + "\" already exists and, sadly, you can't overwrite a text wave with a numeric wave."
return 1
endif
endif
if ((newWaveExists) || (newFileExists))
if((newWaveExists) && (newFileExists))
doalert 1, "Both a wave and an .ibw file with the name \"" + newWaveName + "\" already exist. Overwrite them?"
elseif (newWaveExists)
doalert 1, "A wave with the name \"" + newWaveName + "\" already exists. Overwrite it?"
elseif (newFileExists)
doalert 1, "An .ibw file with the name \"" + newWaveName + "\" already exists. Overwrite it?"
endif
endif
if (V_Flag == 2)
return 1
endif
// array of dataTypes (WM format)
//Type Bit #
//complex 0 =1 // not allowed for shared waves manager
//32-bit float 1 =2
//64-bit float 2 =4
//8-bit integer 3 =8
//16-bit integer 4 =16
//32-bit integer 5 =32
//unsigned 6 =64
variable bitWiseType
if (dtype == 6)
bitWiseType =0
else
bitWiseType =2^dtype + (isUnsigned-1)*2^6
endif
make/o/Y=(bitWiseType)/n=0 $newwavenameAndPath
WAVE newWave = $newwavenameAndPath
Save/o/P= $pathStr newWave as LowerStr (newWaveName) + ".ibw"
string tableName = instanceClean + "_SW#SWT"
AppendToTable /W=$tableName newWave
if (cmpstr (waveUnits(newWave, -1), "dat") ==0)
ModifyTable/W=$tableName format(newWave)=8
elseif (wavetype (newWave) == 4)
ModifyTable /W= $tableName sigDigits(newWave)=16
else
ModifyTable /W= $tableName sigDigits(newWave)=8
endif
doUpdate
WAVE/T FolderListWave = $"root:packages:sharedwaves:" + instanceClean + ":dirListWave"
WAVE FolderListSelWave = $"root:packages:sharedwaves:" + instanceClean + ":dirListSelWave"
CFL_ShowFilesinFolder (FolderListWave, FolderListSelWave, ".ibw", "????", "*", pathStr)
SharedWaves_UpdateFldr (instanceClean)
break
case -1: // control being killed
break
endswitch
return 0
End
//*****************************************************************************************************
// Unshares Selected waves by saving with/H option, breaking the link between files on disk and waves in datafolder
// If shift key pressed, unshares all waves
// Last modified Jan 24 2012 by Jamie Boyd
Function SharedWaves_UnShareProc(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
string instanceClean = stringFromList (0, ba.win, "_")
variable isValid
string sharedWavesPath = SharedWaves_GetDirPath (instanceCLean, isValid)
if(!(isValid))
return 1
endif
string sharedWavesdf =SharedWaves_GetDataFolder(instanceCLean, isValid)
if(!(isValid))
return 1
endif
if (NumberByKey("IGORVERS", IgorInfo(0), ":", ";") < 6)
string savedFolder = getdatafolder (1)
setdatafolder (sharedWavesdf)
endif
string info = TableInfo (instanceClean + "_SW#SWT", -2)
variable firstCol, lastCol
if (ba.eventMod &2) // do All
firstCol = 0
lastCol = NumberByKey("COLUMNS", info , ":", ";") -2
else
string Selected = stringByKey ("SELECTION", info, ":", ";") //firstRow , firstCol , lastRow , lastCol
firstCol = str2num (stringfromlist (1, Selected, ","))
lastCol = str2num (stringfromlist (3, Selected, ","))
endif
variable iCol
string colWaveStr
for (iCol =lastCol; iCol >= firstCol; iCol -=1)
colWaveStr = stringfromlist (0, stringbykey ("COLUMNNAME", TableInfo (instanceClean + "_SW#SWT", iCol), ":", ";"), ".")
if (NumberByKey("IGORVERS", IgorInfo(0), ":", ";") < 6)
LoadWave/Q/H/O/P=$sharedWavesPath colWaveStr + ".ibw"
else
execute/Q "Save/H " + sharedWavesdf + colWaveStr
endif
RemoveFromTable/W= $instanceClean + "_SW#SWT" $sharedWavesdf + colWaveStr
endfor
if (NumberByKey("IGORVERS", IgorInfo(0), ":", ";") < 6)
setdatafolder (savedFolder)
endif
break
case -1: // control being killed
break
endswitch
return 0
End
//*****************************************************************************************************
// Updates the directory copy of selected waves
// if shift key pressed, updates all waves
// Last modified Nov 29 2011 by Jamie Boyd
Function SharedWaves_UpdateToDiskProc(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
string instanceClean = stringFromList (0, ba.win, "_")
string sharedWavesPath = instanceClean + "_Path"
string info = TableInfo (instanceClean + "_SW#SWT", -2)
variable firstCol, lastCol
if (ba.eventMod &2) // do All
firstCol = 0
lastCol = NumberByKey("COLUMNS", info , ":", ";") -2
else // do selected
string Selected = stringByKey ("SELECTION", info, ":", ";") //firstRow , firstCol , lastRow , lastCol
firstCol = str2num (stringfromlist (1, Selected, ","))
lastCol = str2num (stringfromlist (3, Selected, ","))
endif
variable iCol
string colWaveStr, colType
for (iCol =lastCol; iCol >= firstCol; iCol -=1)
colWaveStr = stringbykey ("WAVE", TableInfo (instanceClean + "_SW#SWT", iCol), ":", ";")
WAVE colwave = $colWaveStr
Save/o/P= $SharedWavesPath colwave as LowerStr(nameofWave (colWave)) + ".ibw"
endfor
break
case -1: // control being killed
break
endswitch
return 0
End
//*****************************************************************************************************
// Kills selected shared waves, and deletes the .ibw file in the directory
// if shift key pressed, kills all shared waves
// Last modified Nov 15 2011 by Jamie Boyd
Function SharedWaves_KillSelectedProc(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
string instanceClean = stringFromList (0, ba.win, "_")
string sharedWavesPath = instanceClean + "_Path"
string info = TableInfo (instanceClean + "_SW#SWT", -2)
variable firstCol, lastCol
if (ba.eventMod &2) // do All
doAlert 1, "This action will delete all waves in the Shared Waves table. Are you sure?"
if (V_Flag == 2)
return 1
endif
firstCol = 0
lastCol = NumberByKey("COLUMNS", info , ":", ";") -2
else // do selected
string Selected = stringByKey ("SELECTION", info, ":", ";") //firstRow , firstCol , lastRow , lastCol
firstCol = str2num (stringfromlist (1, Selected, ","))
lastCol = str2num (stringfromlist (3, Selected, ","))
endif
variable iCol
string colWaveStr, colNameStr
for (iCol =lastCol; iCol >= firstCol; iCol -=1)
colWaveStr = stringbykey ("WAVE", TableInfo (instanceClean + "_SW#SWT", iCol), ":", ";")
colNameStr = stringbykey ("COLUMNNAME", TableInfo (instanceClean + "_SW#SWT", iCol), ":", ";")
colNameStr = removeEnding (colNameStr, ".d")
WAVE colwave = $colWaveStr
RemoveFromTable/W= $instanceClean + "_SW#SWT" colwave
killDisplayedWave (colwave)
DeleteFile/Z=1/P=$sharedWavesPath colNameStr + ".ibw"
endfor
WAVE/T FolderListWave = $"root:packages:sharedwaves:" + instanceClean + ":DirListWave"
WAVE FolderListSelWave = $"root:packages:sharedwaves:" + instanceClean + ":DirListSelWave"
CFL_ShowFilesinFolder (FolderListWave, FolderListSelWave, ".ibw", "????", "*", sharedWavesPath)
SharedWaves_UpdateFldr (instanceClean)
break
case -1: // control being killed
break
endswitch
return 0
End
//*****************************************************************************************************
// writes a file containing tab- or comma- delimitted (if command/ctrl key pressed) text of selected waves.
// The default file extension will be .txt for tab-sprated and .csv for comma-separated
// if shift key pressed, writes out all waves
// Last modified Jan 23 2012 by Jamie Boyd
Function SharedWaves_WriteDelimTextProc(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
string instanceClean = stringFromList (0, ba.win, "_")
variable isValid
string sharedWavesPath = SharedWaves_GetDirPath (instanceClean, isValid)
if (!(isValid))
doAlert 0, "First set a path to a directory on disk this Shared Waves Manager."
return 1
endif
string sharedWavesFolder = SharedWaves_GetDataFolder (instanceClean, isValid)
if (!(isValid))
doAlert 0, "First set a datafolder for this Shared Waves Manager."
return 1
endif
string savedFolder = GetDataFolder (1)
setDataFolder $sharedWavesFolder
string info = TableInfo (instanceClean + "_SW#SWT", -2)
variable firstCol, lastCol
if (ba.eventMod &2) // do All
firstCol = 0
lastCol = NumberByKey("COLUMNS", info , ":", ";") -2
else // do selected
string Selected = stringByKey ("SELECTION", info, ":", ";") //firstRow , firstCol , lastRow , lastCol
firstCol = str2num (stringfromlist (1, Selected, ","))
lastCol = str2num (stringfromlist (3, Selected, ","))
endif
variable iCol
string SaveList = ""
for (iCol =lastCol; iCol >= firstCol; iCol -=1)
SaveList += StringFromList (0, stringbykey ("COLUMNNAME", TableInfo (instanceClean + "_SW#SWT", iCol), ":", ";"), ".") + ";"
endfor
if (ba.eventMod &8) // command key to do csv
edit/N=SaveCsvTable as "Save csv Table"
string tableName = S_name
variable nCOls = itemsInList (saveList, ";")
for (iCol = 0; iCol < nCols; iCol +=1)
wave aWave = $StringFromList (iCol, SaveList, ";")
appendToTable/W=$tableName aWave
if (cmpstr (waveUnits(aWave, -1), "dat") ==0)
ModifyTable/W=$tableName format(aWave)=8
elseif (wavetype (aWave) == 4)
ModifyTable /W= $tableName sigDigits(aWave)=16
else