-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwinRFDataHub_exported.m
3316 lines (2786 loc) · 163 KB
/
winRFDataHub_exported.m
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
classdef winRFDataHub_exported < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
GridLayout matlab.ui.container.GridLayout
toolGrid matlab.ui.container.GridLayout
tool_tableNRowsIcon matlab.ui.control.Image
tool_tableNRows matlab.ui.control.Label
jsBackDoor matlab.ui.control.HTML
tool_ExportButton matlab.ui.control.Image
tool_Separator matlab.ui.control.Image
tool_PDFButton matlab.ui.control.Image
tool_RFLinkButton matlab.ui.control.Image
tool_TableVisibility matlab.ui.control.Image
tool_ControlPanelVisibility matlab.ui.control.Image
UITable matlab.ui.control.Table
chReportUndock matlab.ui.control.Image
chReportHotDownload matlab.ui.control.Image
chReportDownloadTime matlab.ui.control.Label
chReportHTML matlab.ui.control.HTML
axesToolbarGrid matlab.ui.container.GridLayout
axesTool_RegionZoom matlab.ui.control.Image
axesTool_RestoreView matlab.ui.control.Image
plotPanel matlab.ui.container.Panel
ControlTabGrid matlab.ui.container.GridLayout
menu_MainGrid matlab.ui.container.GridLayout
menu_Button3Grid matlab.ui.container.GridLayout
menu_Button3Icon matlab.ui.control.Image
menu_Button3Label matlab.ui.control.Label
menu_Button2Grid matlab.ui.container.GridLayout
menu_Button2Icon matlab.ui.control.Image
menu_Button2Label matlab.ui.control.Label
menu_Button1Grid matlab.ui.container.GridLayout
menu_Button1Icon matlab.ui.control.Image
menu_Button1Label matlab.ui.control.Label
menuUnderline matlab.ui.control.Image
ControlTabGroup matlab.ui.container.TabGroup
Tab_1 matlab.ui.container.Tab
Tab1_Grid matlab.ui.container.GridLayout
stationInfoPanel matlab.ui.container.Panel
stationInfoGrid matlab.ui.container.GridLayout
AntennaPatternPanelPlot matlab.ui.container.Panel
stationInfo matlab.ui.control.HTML
referenceTX_Panel matlab.ui.container.Panel
referenceTX_Grid matlab.ui.container.GridLayout
referenceTX_Height matlab.ui.control.NumericEditField
referenceTX_HeightLabel matlab.ui.control.Label
referenceTX_Longitude matlab.ui.control.NumericEditField
referenceTX_LongitudeLabel matlab.ui.control.Label
referenceTX_Latitude matlab.ui.control.NumericEditField
referenceTX_LatitudeLabel matlab.ui.control.Label
referenceTX_EditionCancel matlab.ui.control.Image
referenceTX_EditionConfirm matlab.ui.control.Image
referenceTX_EditionMode matlab.ui.control.Image
referenceTX_Refresh matlab.ui.control.Image
referenceTX_Label matlab.ui.control.Label
referenceTX_Icon matlab.ui.control.Image
Tab_2 matlab.ui.container.Tab
Tab2_Grid matlab.ui.container.GridLayout
filter_Tree matlab.ui.container.CheckBoxTree
filter_AddImage matlab.ui.control.Image
filter_SecondaryValuePanel matlab.ui.container.ButtonGroup
filter_SecondaryValueSubpanel matlab.ui.container.Panel
filter_SecondaryValueGrid matlab.ui.container.GridLayout
filter_SecondaryLogicalOperator matlab.ui.control.DropDown
filter_SecondaryLogicalOperatorLabel matlab.ui.control.Label
filter_SecondaryReferenceFilter matlab.ui.control.DropDown
filter_SecondaryReferenceFilterLabel matlab.ui.control.Label
filter_SecondaryTextList matlab.ui.control.DropDown
filter_SecondaryTextFree matlab.ui.control.EditField
filter_SecondaryNumValue2 matlab.ui.control.NumericEditField
filter_SecondaryNumSeparator matlab.ui.control.Label
filter_SecondaryNumValue1 matlab.ui.control.NumericEditField
filter_SecondaryOperation10 matlab.ui.control.ToggleButton
filter_SecondaryOperation9 matlab.ui.control.ToggleButton
filter_SecondaryOperation8 matlab.ui.control.ToggleButton
filter_SecondaryOperation7 matlab.ui.control.ToggleButton
filter_SecondaryOperation6 matlab.ui.control.ToggleButton
filter_SecondaryOperation5 matlab.ui.control.ToggleButton
filter_SecondaryOperation4 matlab.ui.control.ToggleButton
filter_SecondaryOperation3 matlab.ui.control.ToggleButton
filter_SecondaryOperation2 matlab.ui.control.ToggleButton
filter_SecondaryOperation1 matlab.ui.control.ToggleButton
filter_SecondaryTypePanel matlab.ui.container.ButtonGroup
filter_SecondaryType13 matlab.ui.control.RadioButton
filter_SecondaryType12 matlab.ui.control.RadioButton
filter_SecondaryType11 matlab.ui.control.RadioButton
filter_SecondaryType10 matlab.ui.control.RadioButton
filter_SecondaryType9 matlab.ui.control.RadioButton
filter_SecondaryType8 matlab.ui.control.RadioButton
filter_SecondaryType7 matlab.ui.control.RadioButton
filter_SecondaryType6 matlab.ui.control.RadioButton
filter_SecondaryType5 matlab.ui.control.RadioButton
filter_SecondaryType4 matlab.ui.control.RadioButton
filter_SecondaryType3 matlab.ui.control.RadioButton
filter_SecondaryType2 matlab.ui.control.RadioButton
filter_SecondaryType1 matlab.ui.control.RadioButton
filter_SecondaryLabel matlab.ui.control.Label
referenceRX_Panel matlab.ui.container.Panel
referenceRX_Grid matlab.ui.container.GridLayout
referenceRX_Height matlab.ui.control.NumericEditField
referenceRX_HeightLabel matlab.ui.control.Label
referenceRX_Longitude matlab.ui.control.NumericEditField
referenceRX_LongitudeLabel matlab.ui.control.Label
referenceRX_Latitude matlab.ui.control.NumericEditField
referenceRX_LatitudeLabel matlab.ui.control.Label
referenceRX_EditionCancel matlab.ui.control.Image
referenceRX_EditionConfirm matlab.ui.control.Image
referenceRX_EditionMode matlab.ui.control.Image
referenceRX_Refresh matlab.ui.control.Image
referenceRX_Label matlab.ui.control.Label
referenceRX_Icon matlab.ui.control.Image
Tab_3 matlab.ui.container.Tab
Tab3_Grid matlab.ui.container.GridLayout
misc_ElevationSourcePanel matlab.ui.container.Panel
misc_ElevationSourceGrid matlab.ui.container.GridLayout
misc_ElevationForceSearch matlab.ui.control.CheckBox
misc_ElevationNPoints matlab.ui.control.DropDown
misc_ElevationNPointsLabel matlab.ui.control.Label
misc_ElevationAPISource matlab.ui.control.DropDown
misc_ElevationAPISourceLabel matlab.ui.control.Label
ELEVAOLabel matlab.ui.control.Label
config_geoAxesPanel matlab.ui.container.Panel
config_geoAxesGrid matlab.ui.container.GridLayout
config_TX_DataTipVisibility matlab.ui.control.DropDown
config_Station_Size matlab.ui.control.Slider
config_Station_Color matlab.ui.control.ColorPicker
config_Station_Label matlab.ui.control.Label
config_RX_Size matlab.ui.control.Slider
config_RX_Color matlab.ui.control.ColorPicker
config_RX_Label matlab.ui.control.Label
config_TX_Size matlab.ui.control.Slider
config_TX_Color matlab.ui.control.ColorPicker
config_TX_Label matlab.ui.control.Label
config_geoAxesSubPanel matlab.ui.container.Panel
config_geoAxesSubGrid matlab.ui.container.GridLayout
config_Colormap matlab.ui.control.DropDown
config_ColormapLabel matlab.ui.control.Label
config_Basemap matlab.ui.control.DropDown
config_BasemapLabel matlab.ui.control.Label
config_geoAxesSublabel matlab.ui.control.Label
config_Refresh matlab.ui.control.Image
config_geoAxesLabel matlab.ui.control.Label
filter_ContextMenu matlab.ui.container.ContextMenu
filter_delButton matlab.ui.container.Menu
filter_delAllButton matlab.ui.container.Menu
end
properties (Access = public)
%-----------------------------------------------------------------%
Container
isDocked = false
CallingApp
General
rootFolder
% Essa propriedade registra o tipo de execução da aplicação, podendo
% ser: 'built-in', 'desktopApp' ou 'webApp'.
executionMode
% Essa propriedade registra se o RFDataHub está em modo "standalone"
% (true) ou como módulo do appAnalise (false).
standaloneFlag
% A função do timer é executada uma única vez após a renderização
% da figura, lendo arquivos de configuração, iniciando modo de operação
% paralelo etc. A ideia é deixar o MATLAB focar apenas na criação dos
% componentes essenciais da GUI (especificados em "createComponents"),
% mostrando a GUI para o usuário o mais rápido possível.
timerObj
% O MATLAB não renderiza alguns dos componentes de abas (do TabGroup)
% não visíveis. E a customização de componentes, usando a lib ccTools,
% somente é possível após a sua renderização. Controla-se a aplicação
% da customizaçao por meio dessa propriedade jsBackDoorFlag.
jsBackDoorFlag = {true, ...
true, ...
true};
% Janela de progresso já criada no DOM. Dessa forma, controla-se
% apenas a sua visibilidade - e tornando desnecessário criá-la a
% cada chamada (usando uiprogressdlg, por exemplo).
progressDialog
% Propriedades do app.
specData = class.specData.empty
%-----------------------------------------------------------------%
% ESPECIFICIDADES AUXAPP.WINDRIVETEST
%-----------------------------------------------------------------%
rfDataHub
rfDataHubLOG
rfDataHubSummary
rfDataHubAnnotation = table(string.empty, int32([]), struct('Latitude', {}, 'Longitude', {}, 'AntennaHeight', {}), 'VariableNames', {'ID', 'Station', 'TXSite'})
UIAxes1
UIAxes2
UIAxes3
restoreView = struct('ID', {}, 'xLim', {}, 'yLim', {}, 'cLim', {})
elevationObj = RF.Elevation
ChannelReportObj
filterTable = table('Size', [0, 9], ...
'VariableTypes', {'cell', 'int8', 'int8', 'cell', 'cell', 'int8', 'cell', 'logical', 'cell'}, ...
'VariableNames', {'Order', 'ID', 'RelatedID', 'Type', 'Operation', 'Column', 'Value', 'Enable', 'uuid'})
end
methods (Access = private)
%-----------------------------------------------------------------%
% INICIALIZAÇÃO
%-----------------------------------------------------------------%
function jsBackDoor_Initialization(app)
app.jsBackDoor.HTMLSource = ccTools.fcn.jsBackDoorHTMLSource();
app.jsBackDoor.HTMLEventReceivedFcn = @(~, evt)jsBackDoor_Listener(app, evt);
end
%-----------------------------------------------------------------%
function jsBackDoor_Listener(app, event)
switch event.HTMLEventName
case 'app.filter_Tree'
filter_delFilter(app, struct('Source', app.filter_delButton))
otherwise
% ...
end
drawnow
end
%-------------------------------------------------------------------------%
function jsBackDoor_Customizations(app, tabIndex)
% O menu gráfico controla, programaticamente, qual das abas de
% app.ControlTabGroup estará visível.
% Lembrando que o MATLAB renderiza em tela apenas as abas visíveis.
% Por isso as customizações de abas e suas subabas somente é possível
% após a renderização da aba.
switch tabIndex
case 0 % STARTUP
if app.isDocked && ~isempty(app.CallingApp) && isprop(app.CallingApp, 'progressDialog')
app.progressDialog = app.CallingApp.progressDialog;
else
app.progressDialog = ccTools.ProgressDialog(app.jsBackDoor);
end
sendEventToHTMLSource(app.jsBackDoor, 'htmlClassCustomization', struct('className', '.mw-theme-light', ...
'classAttributes', ['--mw-backgroundColor-dataWidget-selected: rgb(180 222 255 / 45%); ' ...
'--mw-backgroundColor-selected: rgb(180 222 255 / 45%); ' ...
'--mw-backgroundColor-selectedFocus: rgb(180 222 255 / 45%);']));
sendEventToHTMLSource(app.jsBackDoor, 'htmlClassCustomization', struct('className', '.mw-default-header-cell', ...
'classAttributes', 'font-size: 10px; white-space: pre-wrap; margin-bottom: 5px;'));
% uialert, uiprogressdialog, uiconfirm
% sendEventToHTMLSource(app.jsBackDoor, 'htmlClassCustomization', struct('className', '.mwDialog', ...
% 'classAttributes', 'background-color: white;'));
%
% sendEventToHTMLSource(app.jsBackDoor, 'htmlClassCustomization', struct('className', '.mwDialog .mwDialogTitleBar', ...
% 'classAttributes', 'background-color: #f0f0f0;'));
%
% sendEventToHTMLSource(app.jsBackDoor, 'htmlClassCustomization', struct('className', '.mwDialog .mwDialogTitleBar .mwCloseNode', ...
% 'classAttributes', 'background-color: #f0f0f0;'));
otherwise
if any(app.jsBackDoorFlag{tabIndex})
app.jsBackDoorFlag{tabIndex} = false;
switch tabIndex
case 1 % RFDATAHUB
ccTools.compCustomizationV2(app.jsBackDoor, app.ControlTabGroup, 'transparentHeader', 'transparent')
ccTools.compCustomizationV2(app.jsBackDoor, app.axesToolbarGrid, 'borderBottomLeftRadius', '5px', 'borderBottomRightRadius', '5px')
case 2 % FILTRAGEM
ccTools.compCustomizationV2(app.jsBackDoor, app.ControlTabGroup, 'transparentHeader', 'transparent')
app.filter_Tree.UserData = struct(app.filter_Tree).Controller.ViewModel.Id;
sendEventToHTMLSource(app.jsBackDoor, 'addKeyDownListener', struct('componentName', 'app.filter_Tree', 'componentDataTag', app.filter_Tree.UserData, 'keyEvents', "Delete"))
case 3 % CONFIGURAÇÕES GERAIS
% ...
end
end
end
end
%-----------------------------------------------------------------%
function startup_timerCreation(app)
% A criação desse timer tem como objetivo garantir uma renderização
% mais rápida dos componentes principais da GUI, possibilitando a
% visualização da sua tela inicialpelo usuário. Trata-se de aspecto
% essencial quando o app é compilado como webapp.
app.timerObj = timer("ExecutionMode", "fixedSpacing", ...
"StartDelay", 1.5, ...
"Period", .1, ...
"TimerFcn", @(~,~)app.startup_timerFcn);
start(app.timerObj)
end
%-----------------------------------------------------------------%
function startup_timerFcn(app)
if ccTools.fcn.UIFigureRenderStatus(app.UIFigure)
stop(app.timerObj)
delete(app.timerObj)
startup_Controller(app)
end
end
%-----------------------------------------------------------------%
function startup_Controller(app)
% Drawnow antes das customizações, garantindo que elas terão
% efeito.
drawnow
% Customiza as aspectos estéticos de alguns dos componentes da GUI
% (diretamente em JS).
jsBackDoor_Customizations(app, 0)
app.progressDialog.Visible = 'visible';
if app.standaloneFlag
% PATH SEARCH
appName = class.Constants.appName;
MFilePath = fileparts(mfilename('fullpath'));
app.rootFolder = appUtil.RootFolder(appName, MFilePath);
app.executionMode = appUtil.ExecutionMode(app.UIFigure);
% "GeneralSettings.json"
startup_Files2Read(app)
% userPath
if ~strcmp(app.executionMode, 'webApp')
userPaths = appUtil.UserPaths(app.General.fileFolder.userPath);
app.General.fileFolder.userPath = userPaths{end};
end
end
switch app.executionMode
case 'webApp'
% ...
otherwise
% Define tamanho mínimo do app (não aplicável à versão webapp).
if ~app.isDocked
appUtil.winMinSize(app.UIFigure, class.Constants.windowMinSize)
end
end
startup_AppProperties(app)
startup_AxesCreation(app)
startup_GUIComponents(app)
filter_TableFiltering(app)
app.progressDialog.Visible = 'hidden';
% Customiza aspectos estéticos de componentes da GUI relacionados
% à aba selecionada.
jsBackDoor_Customizations(app, 1)
end
%-----------------------------------------------------------------%
function startup_Files2Read(app)
% "GeneralSettings.json"
[app.General, msgWarning] = appUtil.generalSettingsLoad(class.Constants.appName, app.rootFolder);
if ~isempty(msgWarning)
appUtil.modalWindow(app.UIFigure, 'error', msgWarning);
end
app.General.AppVersion = fcn.envVersion(app.rootFolder, 'full');
end
%-----------------------------------------------------------------%
function startup_AppProperties(app)
% refRX: armazena o valor inicial da estação receptora de referência
% para fins de análise da edição.
rxSite = referenceRX_InitialValue(app);
app.referenceRX_Refresh.UserData.InitialValue = rxSite;
referenceRX_UpdatePanel(app, rxSite)
% app.rfDataHub
global RFDataHub
global RFDataHubLog
app.rfDataHub = RFDataHub;
app.rfDataHubLOG = RFDataHubLog;
% Contorna erro da função inROI, que retorna como se todos os
% pontos estivessem internos ao ROI, quando as coordenadas
% estão em float32. No float64 isso não acontece... aberto BUG
% na Mathworks, que indicou estar ciente.
app.rfDataHub.Latitude = double(app.rfDataHub.Latitude);
app.rfDataHub.Longitude = double(app.rfDataHub.Longitude);
app.rfDataHub.ID = "#" + string((1:height(RFDataHub))');
app.rfDataHub.Description = "[" + string(RFDataHub.Source) + "] " + string(RFDataHub.Status) + ", " + string(RFDataHub.StationClass) + ", " + string(RFDataHub.Name) + ", " + string(RFDataHub.Location) + "/" + string(RFDataHub.State) + " (M=" + string(RFDataHub.MergeCount) + ")";
referenceRX_CalculateDistance(app, rxSite)
% app.rfDataHubSummary
app.rfDataHubSummary = summary(RFDataHub);
% A coluna "Source" possui agrupamentos da fonte dos dados,
% decorrente da mesclagem de estações.
tempSourceList = cellfun(@(x) strsplit(x, ' | '), app.rfDataHubSummary.Source.Categories, 'UniformOutput', false);
app.rfDataHubSummary.Source.RawCategories = unique(horzcat(tempSourceList{:}))';
% A coluna "Location" não está sendo corretamente ordenada por
% conta dos caracteres especiais.
tempLocationList = textAnalysis.preProcessedData(app.rfDataHubSummary.Location.Categories);
[app.rfDataHubSummary.Location.CacheCategories, idxSort] = sort(tempLocationList);
app.rfDataHubSummary.Location.Categories = app.rfDataHubSummary.Location.Categories(idxSort);
% lastPrimarySearch
filter_getReferenceSearch(app)
end
%-----------------------------------------------------------------%
function startup_AxesCreation(app)
hParent = tiledlayout(app.plotPanel, 2, 2, "Padding", "none", "TileSpacing", "none");
% Eixo geográfico: MAPA
app.UIAxes1 = plot.axes.Creation(hParent, 'Geographic', {'Basemap', app.config_Basemap.Value, ...
'UserData', struct('CLimMode', 'auto', 'Colormap', '')});
app.UIAxes1.Layout.Tile = 1;
app.UIAxes1.Layout.TileSpan = [2, 2];
set(app.UIAxes1.LatitudeAxis, 'TickLabels', {}, 'Color', 'none')
set(app.UIAxes1.LongitudeAxis, 'TickLabels', {}, 'Color', 'none')
geolimits(app.UIAxes1, 'auto')
plot.axes.Colormap(app.UIAxes1, app.config_Colormap.Value)
% Eixo cartesiano: PERFIL DE RELEVO
app.UIAxes2 = plot.axes.Creation(hParent, 'Cartesian', {'XGrid', 'off', 'XMinorGrid', 'off', 'XTick', [], 'XColor', [.8,.8,.8], 'XLimitMethod', 'padded', ...
'YGrid', 'off', 'YMinorGrid', 'off', 'YTick', [], 'YColor', 'none', ...
'Color', 'none', 'Clipping', 'off', 'LineWidth', 2, 'Layer', 'top', 'Visible', 'off'});
app.UIAxes2.Layout.Tile = 3;
app.UIAxes2.Layout.TileSpan = [1 2];
app.UIAxes2.XAxis.TickLabelFormat = '%.1f';
% Eixo cartesiano: DIAGRAMA DE RADIAÇÃO DA ANTENA
app.AntennaPatternPanelPlot.AutoResizeChildren = 'off';
app.UIAxes3 = polaraxes(app.AntennaPatternPanelPlot, 'Units', 'normalized', ...
'Position', [.05,.05,.9,.9], ...
'ThetaZeroLocation', 'top', ...
'Toolbar', [], ...
'FontSize', 8, ...
'Color', 'none', ...
'ThetaTick', 0, ...
'ThetaDir', 'clockwise', ...
'RTickLabel', {});
hold(app.UIAxes3, 'on')
% Legenda
legend(app.UIAxes1, 'Location', 'southwest', 'Color', [.94,.94,.94], 'EdgeColor', [.9,.9,.9], 'NumColumns', 4, 'LineWidth', .5, 'FontSize', 7.5)
% Axes interactions:
plot.axes.Interactivity.DefaultCreation(app.UIAxes1, [dataTipInteraction, zoomInteraction, panInteraction])
plot.axes.Interactivity.DefaultCreation(app.UIAxes2, dataTipInteraction)
end
%-----------------------------------------------------------------%
function startup_GUIComponents(app)
% Controles de funcionalidades:
app.referenceTX_EditionMode.UserData = false;
app.referenceRX_EditionMode.UserData = false;
app.tool_TableVisibility.UserData = true;
app.tool_RFLinkButton.UserData = false;
app.tool_PDFButton.UserData = false;
% Elevação:
app.misc_ElevationAPISource.Value = app.General.Elevation.Server;
app.misc_ElevationNPoints.Value = num2str(app.General.Elevation.Points);
app.misc_ElevationForceSearch.Value = app.General.Elevation.ForceSearch;
end
end
methods (Access = private)
%-----------------------------------------------------------------%
function [idxRFDataHub, idxSelectedRow] = getRFDataHubIndex(app)
if isempty(app.UITable.Selection)
idxRFDataHub = [];
idxSelectedRow = 0;
else
idxSelectedRow = app.UITable.Selection(1);
idxVirtual = app.UITable.Data.ID(idxSelectedRow);
idxRFDataHub = str2double(extractAfter(idxVirtual, '#'));
end
end
%-----------------------------------------------------------------%
function varargout = RFLinkObjects(app, siteType, varargin)
arguments
app
siteType char {mustBeMember(siteType, {'TX', 'RX', 'TX-RX'})} = 'TX-RX'
end
arguments (Repeating)
varargin
end
% txSite e rxSite estão como struct, mas basta mudar para "txsite" e
% "rxsite" que eles poderão ser usados em predições, uma vez que os
% campos da estrutura são idênticos às propriedades dos objetos.
varargout = {};
if contains(siteType, 'TX')
idxRFDataHub = varargin{1};
% TX
txSite = struct('Name', 'TX', ...
'TransmitterFrequency', double(app.rfDataHub.Frequency(idxRFDataHub)) * 1e+6, ...
'Latitude', app.referenceTX_Latitude.Value, ...
'Longitude', app.referenceTX_Longitude.Value, ...
'AntennaHeight', app.referenceTX_Height.Value, ...
'ID', app.rfDataHub.ID(idxRFDataHub), ...
'Station', app.rfDataHub.Station(idxRFDataHub));
varargout{end+1} = txSite;
end
if contains(siteType, 'RX')
% RX
rxSite = struct('Name', 'RX', ...
'Latitude', app.referenceRX_Latitude.Value, ...
'Longitude', app.referenceRX_Longitude.Value, ...
'AntennaHeight', app.referenceRX_Height.Value);
varargout{end+1} = rxSite;
end
end
%-----------------------------------------------------------------%
% TAB: 1
% PAINEL: ESTAÇÃO TRANSMISSORA - TX
%-----------------------------------------------------------------%
function referenceTX_UpdatePanel(app, idxRFDataHub)
idxAnnotation = referenceTX_AddOrDelTXSiteTempList(app, 'Search', app.rfDataHub.ID(idxRFDataHub));
% A ideia aqui é destacar as informações que foram editadas...
txLatitudeFontColor = [0,0,0];
txLongitudeFontColor = [0,0,0];
txHeightFontColor = [0,0,0];
txLatitudeBackground = [1,1,1];
txLongitudeBackground = [1,1,1];
txHeightBackground = [1,1,1];
if idxAnnotation
app.referenceTX_Refresh.Visible = 1;
% Latitude
if app.rfDataHubAnnotation.TXSite(idxAnnotation).Latitude.Status
txLatitude = app.rfDataHubAnnotation.TXSite(idxAnnotation).Latitude.EditedValue;
txLatitudeFontColor = [1,1,1];
txLatitudeBackground = [1,0,0];
else
txLatitude = app.rfDataHubAnnotation.TXSite(idxAnnotation).Latitude.RawValue;
end
% Longitude
if app.rfDataHubAnnotation.TXSite(idxAnnotation).Longitude.Status
txLongitude = app.rfDataHubAnnotation.TXSite(idxAnnotation).Longitude.EditedValue;
txLongitudeFontColor = [1,1,1];
txLongitudeBackground = [1,0,0];
else
txLongitude = app.rfDataHubAnnotation.TXSite(idxAnnotation).Longitude.RawValue;
end
% Height
if app.rfDataHubAnnotation.TXSite(idxAnnotation).AntennaHeight.Status
txHeight = app.rfDataHubAnnotation.TXSite(idxAnnotation).AntennaHeight.EditedValue;
txHeightFontColor = [1,1,1];
txHeightBackground = [1,0,0];
else
txHeight = app.rfDataHubAnnotation.TXSite(idxAnnotation).AntennaHeight.RawValue;
end
else
app.referenceTX_Refresh.Visible = 0;
[txLatitude, ...
txLongitude, ...
txHeight] = referenceTX_getRawData(app);
end
set(app.referenceTX_Latitude, 'Value', txLatitude, 'FontColor', txLatitudeFontColor, 'BackgroundColor', txLatitudeBackground)
set(app.referenceTX_Longitude, 'Value', txLongitude, 'FontColor', txLongitudeFontColor, 'BackgroundColor', txLongitudeBackground)
set(app.referenceTX_Height, 'Value', txHeight, 'FontColor', txHeightFontColor, 'BackgroundColor', txHeightBackground)
end
%-----------------------------------------------------------------%
function referenceTX_EditionPanelLayout(app, editionStatus)
arguments
app
editionStatus char {mustBeMember(editionStatus, {'on', 'off'})}
end
idxRFDataHub = getRFDataHubIndex(app);
hEditFields = findobj(app.referenceTX_Grid.Children, '-not', 'Type', 'uilabel');
switch editionStatus
case 'on'
set(app.referenceTX_EditionMode, 'ImageSource', 'Edit_32Filled.png', 'UserData', true)
set(hEditFields, 'Editable', true)
app.Tab1_Grid.ColumnWidth(5:6) = {16,16};
app.referenceTX_EditionConfirm.Enable = 1;
app.referenceTX_EditionCancel.Enable = 1;
case 'off'
referenceTX_UpdatePanel(app, idxRFDataHub)
set(app.referenceTX_EditionMode, 'ImageSource', 'Edit_32.png', 'UserData', false)
set(hEditFields, 'Editable', false)
app.Tab1_Grid.ColumnWidth(5:6) = {0,0};
app.referenceTX_EditionConfirm.Enable = 0;
app.referenceTX_EditionCancel.Enable = 0;
end
end
%-----------------------------------------------------------------%
function varargout = referenceTX_AddOrDelTXSiteTempList(app, operationType, varargin)
arguments
app
operationType char {mustBeMember(operationType, {'Search', 'Add', 'Del'})}
end
arguments (Repeating)
varargin
end
switch operationType
case 'Search'
ID = varargin{1};
[~, idxAnnotation] = ismember(ID, app.rfDataHubAnnotation.ID);
varargout = {idxAnnotation};
case 'Add'
[txObj, ID, Station, idxAnnotation] = referenceTX_checkTXSiteTempList(app);
[txLatitude, ...
txLongitude, ...
txHeight] = referenceTX_getRawData(app);
% Confirma que ocorreu alteração em algum dos parâmetros
% do registro.
txSiteDiff = struct('Latitude', struct('Status', false, 'RawValue', txLatitude, 'EditedValue', []), ...
'Longitude', struct('Status', false, 'RawValue', txLongitude, 'EditedValue', []), ...
'AntennaHeight', struct('Status', false, 'RawValue', txHeight, 'EditedValue', []));
txSiteDiffFlag = false;
% Cria estrutura que possibilita identificar quais dos
% parâmetros foram editados manualmente...
% Latitude
if ~isequal(txObj.Latitude, txLatitude)
txSiteDiffFlag = true;
txSiteDiff.Latitude.Status = true;
txSiteDiff.Latitude.EditedValue = txObj.Latitude;
end
% Longitude
if ~isequal(txObj.Longitude, txLongitude)
txSiteDiffFlag = true;
txSiteDiff.Longitude.Status = true;
txSiteDiff.Longitude.EditedValue = txObj.Longitude;
end
% Height
if ~isequal(txObj.AntennaHeight, txHeight)
txSiteDiffFlag = true;
txSiteDiff.AntennaHeight.Status = true;
txSiteDiff.AntennaHeight.EditedValue = txObj.AntennaHeight;
end
if txSiteDiffFlag
% Evidenciada alteração no registro. Cria-se nova linha
% ou edita-se a existente.
if idxAnnotation
if isequal(app.rfDataHubAnnotation.TXSite(idxAnnotation), txSiteDiff)
return
end
else
idxAnnotation = height(app.rfDataHubAnnotation) + 1;
end
app.rfDataHubAnnotation(idxAnnotation, :) = {ID, Station, txSiteDiff};
layout_AddNewTableStyle(app, 'EditedRows')
% Força a atualização do painel HTML e dos plots...
app.stationInfo.UserData = [];
UITableSelectionChanged(app)
else
% Não evidenciada alteração no registro. Apaga-se linha,
% caso existente. O usuário, aqui, desfez alteração
% manualmente (sem pressionar no Refresh).
if idxAnnotation
app.rfDataHubAnnotation(idxAnnotation, :) = [];
layout_AddNewTableStyle(app, 'EditedRows')
app.stationInfo.UserData = [];
UITableSelectionChanged(app)
end
end
case 'Del'
[~, ~, ~, idxAnnotation] = referenceTX_checkTXSiteTempList(app);
if idxAnnotation
app.rfDataHubAnnotation(idxAnnotation, :) = [];
layout_AddNewTableStyle(app, 'EditedRows')
app.stationInfo.UserData = [];
UITableSelectionChanged(app)
end
end
end
%-----------------------------------------------------------------%
function [txObj, ID, Station, idxAnnotation] = referenceTX_checkTXSiteTempList(app)
idxRFDataHub = getRFDataHubIndex(app);
% Objeto.
txObj = RFLinkObjects(app, 'TX', idxRFDataHub);
ID = txObj.ID;
Station = txObj.Station;
% Consulta se esse objeto está na lista temporária de estações
% editadas do RFDataHub.
[~, idxAnnotation] = ismember(ID, app.rfDataHubAnnotation.ID);
end
%-----------------------------------------------------------------%
function [txLatitude, txLongitude, txHeight] = referenceTX_getRawData(app)
idxRFDataHub = getRFDataHubIndex(app);
txLatitude = round(double(app.rfDataHub.Latitude(idxRFDataHub)), 6);
txLongitude = round(double(app.rfDataHub.Longitude(idxRFDataHub)), 6);
txHeight = round(str2double(char(app.rfDataHub.AntennaHeight(idxRFDataHub))), 1);
if txHeight < 0
txHeight = app.General.RFDataHub.DefaultTX.Height;
end
end
%-----------------------------------------------------------------%
% TAB: 2
% PAINEL: ESTAÇÃO RECEPTORA - RX
%-----------------------------------------------------------------%
function rxSite = referenceRX_InitialValue(app)
refRXFlag = false;
for ii = 1:numel(app.specData)
if app.specData(ii).GPS.Status
rxLatitude = app.specData(ii).GPS.Latitude;
rxLongitude = app.specData(ii).GPS.Longitude;
% Salvo engano, o campo de altura só existe nos arquivos
% gerados pelo appColeta, no formato "10m", por exemplo.
rxHeight = [];
if isfield(app.specData(ii).MetaData.Antenna, 'Height')
rxHeight = str2double(extractBefore(app.specData(ii).MetaData.Antenna.Height, 'm'));
end
if isempty(rxHeight) || isnan(rxHeight) || (rxHeight <= 0) || isinf(rxHeight)
rxHeight = app.General.RFDataHub.DefaultRX.Height;
end
refRXFlag = true;
break
end
end
if ~refRXFlag
if ~isempty(app.General.RFDataHub.lastSearch)
rxLatitude = app.General.RFDataHub.lastSearch.RX.Latitude;
rxLongitude = app.General.RFDataHub.lastSearch.RX.Longitude;
rxHeight = app.General.RFDataHub.lastSearch.RX.Height;
else
rxLatitude = app.General.RFDataHub.DefaultRX.Latitude;
rxLongitude = app.General.RFDataHub.DefaultRX.Longitude;
rxHeight = app.General.RFDataHub.DefaultRX.Height;
end
end
rxSite = struct('Name', 'RX', ...
'Latitude', rxLatitude, ...
'Longitude', rxLongitude, ...
'AntennaHeight', rxHeight);
end
%-----------------------------------------------------------------%
function referenceRX_UpdatePanel(app, rxSite)
app.referenceRX_Latitude.Value = rxSite.Latitude;
app.referenceRX_Longitude.Value = rxSite.Longitude;
app.referenceRX_Height.Value = rxSite.AntennaHeight;
end
%-----------------------------------------------------------------%
function referenceRX_CalculateDistance(app, rxSite)
app.rfDataHub.Distance = round(single(deg2km(distance(app.rfDataHub.Latitude, ...
app.rfDataHub.Longitude, ...
rxSite.Latitude, ...
rxSite.Longitude))), 1);
app.referenceRX_Refresh.UserData.DistanceColumnSource = rxSite;
end
%-----------------------------------------------------------------%
function referenceRX_EditOrRefreshReferenceRX(app, operationType)
arguments
app
operationType char {mustBeMember(operationType, {'Refresh', 'Edit'})}
end
refInitialValue = app.referenceRX_Refresh.UserData.InitialValue;
refDistanceColumnSource = app.referenceRX_Refresh.UserData.DistanceColumnSource;
switch operationType
case 'Refresh'
rxSite = refInitialValue;
referenceRX_UpdatePanel(app, rxSite)
case 'Edit'
rxSite = RFLinkObjects(app, 'RX');
end
if ~isequal(rxSite, refInitialValue)
app.referenceRX_Refresh.Visible = 1;
else
app.referenceRX_Refresh.Visible = 0;
end
% Recalcula a coluna "Distance" caso a alteração tenha
% ocorrido em "Latitude" ou "Longitude".
if ~isequal(rmfield(refDistanceColumnSource, 'AntennaHeight'), rmfield(rxSite, 'AntennaHeight'))
referenceRX_RefreshTableAndPlots(app, rxSite)
elseif ~isequal(refDistanceColumnSource.AntennaHeight, rxSite.AntennaHeight)
app.referenceRX_Refresh.UserData.DistanceColumnSource.AntennaHeight = rxSite.AntennaHeight;
app.stationInfo.UserData = [];
UITableSelectionChanged(app)
end
end
%-----------------------------------------------------------------%
function referenceRX_EditionPanelLayout(app, editionStatus)
arguments
app
editionStatus char {mustBeMember(editionStatus, {'on', 'off'})}
end
hEditFields = findobj(app.referenceRX_Grid.Children, '-not', 'Type', 'uilabel');
switch editionStatus
case 'on'
set(app.referenceRX_EditionMode, 'ImageSource', 'Edit_32Filled.png', 'UserData', true)
set(hEditFields, 'Editable', true)
app.Tab2_Grid.ColumnWidth(5:6) = {16,16};
app.referenceRX_EditionConfirm.Enable = 1;
app.referenceRX_EditionCancel.Enable = 1;
case 'off'
set(app.referenceRX_EditionMode, 'ImageSource', 'Edit_32.png', 'UserData', false)
set(hEditFields, 'Editable', false)
app.Tab2_Grid.ColumnWidth(5:6) = {0,0};
app.referenceRX_EditionConfirm.Enable = 0;
app.referenceRX_EditionCancel.Enable = 0;
end
end
%-----------------------------------------------------------------%
function referenceRX_RefreshTableAndPlots(app, rxSite)
referenceRX_CalculateDistance(app, rxSite)
filter_TableFiltering(app)
end
%-----------------------------------------------------------------%
% FILTRAGEM
%-----------------------------------------------------------------%
function filter_getReferenceSearch(app)
if isempty(app.filterTable)
if ~isempty(app.General.RFDataHub.lastSearch)
filterType = app.General.RFDataHub.lastSearch.Filter.ColumnLabel;
filterValue = app.General.RFDataHub.lastSearch.Filter.Value;
filterOperation = app.General.RFDataHub.lastSearch.Filter.Operation;
else
filterType = app.General.RFDataHub.DefaultFilter.ColumnLabel;
filterValue = app.General.RFDataHub.DefaultFilter.Value;
filterOperation = app.General.RFDataHub.DefaultFilter.Operation;
end
hFilterNames = findobj(app.filter_SecondaryTypePanel.Children, 'Type', 'uiradiobutton');
hFilterOperations = findobj(app.filter_SecondaryValuePanel.Children, 'Type', 'uitogglebutton');
hFilterValues = [app.filter_SecondaryNumValue1, ...
app.filter_SecondaryNumValue2, ...
app.filter_SecondaryTextFree, ...
app.filter_SecondaryTextList];
listOfFilterNames = {hFilterNames.Text};
listOfOperations = {hFilterOperations.Text};
[~, idxFilter] = ismember(filterType, listOfFilterNames);
[~, idxOperation] = ismember(filterOperation, listOfOperations);
if ~isempty(idxFilter) && ~isempty(idxOperation)
hFilterNames(idxFilter).Value = true;
filter_typePanelSelectionChanged(app)
hFilterOperations(idxOperation).Value = true;
filter_SecondaryValuePanelSelectionChanged(app)
hFilterValues = hFilterValues(arrayfun(@(x) x.Visible, hFilterValues));
for ii = 1:numel(hFilterValues)
hFilterValues(ii).Value = filterValue(ii);
end
end
columnName = filter_FilterType2ColumnNames(app, filterType);
[~, columnIndex] = ismember(columnName, app.rfDataHub.Properties.VariableNames);
newFilter = {'Node', 1, -3, filterType, filterOperation, columnIndex, filterValue, true, char(matlab.lang.internal.uuid())};
filter_AddNewFilter(app, newFilter)
end
filter_TreeBuilding(app)
end
%-----------------------------------------------------------------%
function filter_AddNewFilter(app, newFilter)
app.filterTable(end+1,[1:6,8:9]) = newFilter([1:6,8:9]);
app.filterTable.Value{end} = newFilter{7};
end
%-----------------------------------------------------------------%
function columnName = filter_FilterType2ColumnNames(app, filterType)
filterTypes = ["Fonte", "Frequência", "Largura banda", "Classe emissão", "Entidade", "Fistel", "Serviço", "Estação", "UF", "Município", "Distância"];
columnNames = ["Source", "Frequency", "BW", "EmissionClass", "Name", "Fistel", "Service", "Station", "State", "Location", "Distance"];
d = dictionary(filterTypes, columnNames);
columnName = d(filterType);
end
%-----------------------------------------------------------------%
function filter_TreeBuilding(app)
if ~isempty(app.filter_Tree.Children)
delete(app.filter_Tree.Children)
end
idx1 = find(strcmp(app.filterTable.Order, 'Node'))';
if ~isempty(idx1)
checkedNodes = {};
for ii = idx1
idx2 = find(app.filterTable.RelatedID == app.filterTable.ID(ii))';
if isempty(idx2)
parentNode = uitreenode(app.filter_Tree, 'Text', sprintf('#%d: RFDataHub.("%s") %s %s', app.filterTable.ID(ii), ...
app.filterTable.Type{ii}, ...
app.filterTable.Operation{ii}, ...
filter_Value(app, app.filterTable.Value{ii})), ...
'NodeData', ii, 'ContextMenu', app.filter_ContextMenu);
if app.filterTable.Enable(ii)
checkedNodes = [checkedNodes, parentNode];
end
else
parentNode = uitreenode(app.filter_Tree, 'Text', '*.*', ...
'NodeData', [ii, idx2], 'ContextMenu', app.filter_ContextMenu);
for jj = [ii, idx2]
childNode = uitreenode(parentNode, 'Text', sprintf('#%d: RFDataHub.("%s") %s %s', app.filterTable.ID(jj), ...
app.filterTable.Type{jj}, ...
app.filterTable.Operation{jj}, ...
filter_Value(app, app.filterTable.Value{jj})), ...
'NodeData', jj, 'ContextMenu', app.filter_ContextMenu);
if app.filterTable.Enable(jj)
checkedNodes = [checkedNodes, childNode];
end
end
end
end
app.filter_Tree.CheckedNodes = checkedNodes;
expand(app.filter_Tree, 'all')
end
app.filter_SecondaryReferenceFilter.Items = [{''}, cellstr("#" + string((idx1)))];
end
%-----------------------------------------------------------------%
function filter_TableFiltering(app)
app.progressDialog.Visible = 'visible';
% Identifica registro inicialmente selecionado da tabela.
initialSelectedRowID = '';
if ~isempty(app.UITable.Selection)
initialSelectedRowID = app.UITable.Data.ID{app.UITable.Selection(1)};
end