1- classdef AircraftAttitudeView < FlightDashboardComponent
2- % AIRCRAFTATTITUDEVIEW Provide a view of the aircraft's attitude.
3-
4- properties ( Access = private )
5- % Aircraft chart.
6- Chart (: , 1 ) AircraftChart {mustBeScalarOrEmpty }
7- % Dropdown menu for the exaggeration factor.
8- ExaggerationDropdown (: , 1 ) matlab.ui.control.DropDown ...
9- {mustBeScalarOrEmpty }
10- end % properties ( Access = private )
11-
12- methods
13-
14- function obj = AircraftAttitudeView( model , namedArgs )
15- % AIRCRAFTATTITUDEVIEW Construct an AircraftAttitudeView, given
16- % the model and optional name-value arguments.
17-
18- arguments ( Input )
19- model (1 , 1 ) FlightDashboardModel
20- namedArgs.?AircraftAttitudeView
21- end % arguments ( Input )
22-
23- % Call the superclass constructor.
24- obj@FlightDashboardComponent( model )
25-
26- % Refresh the component.
27- obj .onFlightDataChanged()
28-
29- % Set any user-defined properties.
30- set( obj , namedArgs )
31-
32- end % constructor
33-
34- end % methods
35-
36- methods ( Access = protected )
37-
38- function setup( obj )
39- % SETUP Initialize the component.
40-
41- % Create the chart.
42- mainGrid = uigridlayout( obj , [2 , 2 ], ...
43- " RowHeight" , [" fit" , " 1x" ], ...
44- " ColumnWidth" , [" 1x" , " fit" ] );
45- uilabel( " Parent" , mainGrid , ...
46- " Text" , " Exaggeration" , ...
47- " HorizontalAlignment" , " right" , ...
48- " FontSize" , FlightDashboardTheme .LabelFontSize , ...
49- " FontName" , FlightDashboardTheme .FontName );
50- obj.ExaggerationDropdown = uidropdown( " Parent" , mainGrid , ...
51- " Items" , (1 : 3 ) + " x" , ...
52- " ItemsData" , 1 : 3 , ...
53- " Value" , 1 , ...
54- " Tooltip" , " Select the exaggeration factor" , ...
55- " FontName" , FlightDashboardTheme .FontName , ...
56- " FontSize" , FlightDashboardTheme .LabelFontSize );
57- obj.Chart = AircraftChart( " Parent" , mainGrid ) ;
58- title( obj .Chart , " Attitude" , ...
59- " FontName" , FlightDashboardTheme .FontName , ...
60- " FontSize" , FlightDashboardTheme .TitleFontSize )
61- obj.Chart.Layout.Column = [1 , 2 ];
62- title( obj .Chart , " Aircraft Attitude" , ...
63- " FontSize" , FlightDashboardTheme .TitleFontSize , ...
64- " FontName" , FlightDashboardTheme .FontName )
65-
66- end % setup
67-
68- function update( ~ )
69- % UPDATE Update the component.
70-
71- end % update
72-
73- function onFlightDataChanged( obj , ~, ~ )
74- % ONFLIGHTDATACHANGED Respond to the model event
75- % "FlightDataChanged".
76-
77- obj .Chart .reset()
78- obj .onCurrentTimeChanged()
79-
80- end % onFlightDataChanged
81-
82- function onCurrentTimeChanged( obj , ~, ~ )
83- % ONCURRENTTIMECHANGED Respond to the model event
84- % "CurrentTimeChanged".
85-
86- t = obj .Model .CurrentTime ;
87- rollPitchYaw = obj.Model.FlightData{t , ...
88- [" Roll" , " Pitch" , " Yaw" ]};
89- dropdown = obj .ExaggerationDropdown ;
90- exaggeration = dropdown .ItemsData(dropdown .ValueIndex );
91-
92- if ~isempty( rollPitchYaw )
93- obj .Chart .setAttitude( rollPitchYaw(1 ), ...
94- rollPitchYaw(2 ), rollPitchYaw(3 ), exaggeration )
95- end % if
96-
97- end % onCurrentTimeChanged
98-
99- end % methods ( Access = protected )
100-
1+ classdef AircraftAttitudeView < FlightDashboardComponent
2+ % AIRCRAFTATTITUDEVIEW Provide a view of the aircraft's attitude.
3+
4+ properties ( Access = private )
5+ % Aircraft chart.
6+ Chart (: , 1 ) AircraftChart {mustBeScalarOrEmpty }
7+ % Dropdown menu for the exaggeration factor.
8+ ExaggerationDropdown (: , 1 ) matlab.ui.control.DropDown ...
9+ {mustBeScalarOrEmpty }
10+ end % properties ( Access = private )
11+
12+ methods
13+
14+ function obj = AircraftAttitudeView( model , namedArgs )
15+ % AIRCRAFTATTITUDEVIEW Construct an AircraftAttitudeView, given
16+ % the model and optional name-value arguments.
17+
18+ arguments ( Input )
19+ model (1 , 1 ) FlightDashboardModel
20+ namedArgs.?AircraftAttitudeView
21+ end % arguments ( Input )
22+
23+ % Call the superclass constructor.
24+ obj@FlightDashboardComponent( model )
25+
26+ % Refresh the component.
27+ obj .onFlightDataChanged()
28+
29+ % Set any user-defined properties.
30+ set( obj , namedArgs )
31+
32+ end % constructor
33+
34+ end % methods
35+
36+ methods ( Access = protected )
37+
38+ function setup( obj )
39+ % SETUP Initialize the component.
40+
41+ % Create the chart.
42+ mainGrid = uigridlayout( obj , [2 , 2 ], ...
43+ " RowHeight" , [" fit" , " 1x" ], ...
44+ " ColumnWidth" , [" 1x" , " fit" ] );
45+ uilabel( " Parent" , mainGrid , ...
46+ " Text" , " Exaggeration" , ...
47+ " HorizontalAlignment" , " right" , ...
48+ " FontSize" , FlightDashboardTheme .LabelFontSize , ...
49+ " FontName" , FlightDashboardTheme .FontName );
50+ obj.ExaggerationDropdown = uidropdown( " Parent" , mainGrid , ...
51+ " Items" , (1 : 3 ) + " x" , ...
52+ " ItemsData" , 1 : 3 , ...
53+ " Value" , 1 , ...
54+ " Tooltip" , " Select the exaggeration factor" , ...
55+ " FontName" , FlightDashboardTheme .FontName , ...
56+ " FontSize" , FlightDashboardTheme .LabelFontSize );
57+ obj.Chart = AircraftChart( " Parent" , mainGrid ) ;
58+ title( obj .Chart , " Attitude" , ...
59+ " FontName" , FlightDashboardTheme .FontName , ...
60+ " FontSize" , FlightDashboardTheme .TitleFontSize )
61+ obj.Chart.Layout.Column = [1 , 2 ];
62+ title( obj .Chart , " Aircraft Attitude" , ...
63+ " FontSize" , FlightDashboardTheme .TitleFontSize , ...
64+ " FontName" , FlightDashboardTheme .FontName )
65+
66+ end % setup
67+
68+ function update( ~ )
69+ % UPDATE Update the component.
70+
71+ end % update
72+
73+ function onFlightDataChanged( obj , ~, ~ )
74+ % ONFLIGHTDATACHANGED Respond to the model event
75+ % "FlightDataChanged".
76+
77+ obj .Chart .reset()
78+ obj .onCurrentTimeChanged()
79+
80+ end % onFlightDataChanged
81+
82+ function onCurrentTimeChanged( obj , ~, ~ )
83+ % ONCURRENTTIMECHANGED Respond to the model event
84+ % "CurrentTimeChanged".
85+
86+ t = obj .Model .CurrentTime ;
87+ rollPitchYaw = obj.Model.FlightData{t , ...
88+ [" Roll" , " Pitch" , " Yaw" ]};
89+ dropdown = obj .ExaggerationDropdown ;
90+ exaggeration = dropdown .ItemsData(dropdown .ValueIndex );
91+
92+ if ~isempty( rollPitchYaw )
93+ obj .Chart .setAttitude( rollPitchYaw(1 ), ...
94+ rollPitchYaw(2 ), rollPitchYaw(3 ), exaggeration )
95+ end % if
96+
97+ end % onCurrentTimeChanged
98+
99+ end % methods ( Access = protected )
100+
101101end % classdef
0 commit comments