5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #include "modeledit.h"
23 #include "ui_modeledit.h"
26 #include "flightmodes.h"
31 #include "verticalscrollarea.h"
32 #include "logicalswitches.h"
33 #include "customfunctions.h"
34 #include "telemetry.h"
37 ModelEdit::ModelEdit(QWidget
* parent
, RadioData
& radioData
, int modelId
, Firmware
* firmware
) :
39 ui(new Ui::ModelEdit
),
44 Stopwatch
s1("ModelEdit");
45 gStopwatch
.report("ModelEdit start constructor");
48 setWindowIcon(CompanionIcon("edit.png"));
49 restoreGeometry(g
.modelEditGeo());
50 ui
->pushButton
->setIcon(CompanionIcon("simulate.png"));
51 SetupPanel
* setupPanel
= new SetupPanel(this, radioData
.models
[modelId
], radioData
.generalSettings
, firmware
);
52 addTab(setupPanel
, tr("Setup"));
53 if (firmware
->getCapability(Heli
))
54 addTab(new HeliPanel(this, radioData
.models
[modelId
], radioData
.generalSettings
, firmware
), tr("Heli"));
55 addTab(new FlightModesPanel(this, radioData
.models
[modelId
], radioData
.generalSettings
, firmware
), tr("Flight Modes"));
56 addTab(new InputsPanel(this, radioData
.models
[modelId
], radioData
.generalSettings
, firmware
), tr("Inputs"));
58 addTab(new MixesPanel(this, radioData
.models
[modelId
], radioData
.generalSettings
, firmware
), tr("Mixes"));
60 Channels
* chnPanel
= new Channels(this, radioData
.models
[modelId
], radioData
.generalSettings
, firmware
);
61 addTab(chnPanel
, tr("Outputs"));
63 addTab(new Curves(this, radioData
.models
[modelId
], radioData
.generalSettings
, firmware
), tr("Curves"));
64 addTab(new LogicalSwitchesPanel(this, radioData
.models
[modelId
], radioData
.generalSettings
, firmware
), tr("Logical Switches"));
66 addTab(new CustomFunctionsPanel(this, &radioData
.models
[modelId
], radioData
.generalSettings
, firmware
), tr("Special Functions"));
68 if (firmware
->getCapability(Telemetry
) & TM_HASTELEMETRY
)
69 addTab(new TelemetryPanel(this, radioData
.models
[modelId
], radioData
.generalSettings
, firmware
), tr("Telemetry"));
71 onTabIndexChanged(ui
->tabWidget
->currentIndex()); // make sure to trigger update on default tab panel
73 connect(setupPanel
, &SetupPanel::extendedLimitsToggled
, chnPanel
, &Channels::refreshExtendedLimits
);
74 connect(ui
->tabWidget
, &QTabWidget::currentChanged
, this, &ModelEdit::onTabIndexChanged
);
75 connect(ui
->pushButton
, &QPushButton::clicked
, this, &ModelEdit::launchSimulation
);
78 gStopwatch
.report("ModelEdit end constructor");
81 ModelEdit::~ModelEdit()
86 void ModelEdit::closeEvent(QCloseEvent
*event
)
88 g
.modelEditGeo( saveGeometry() );
91 void ModelEdit::addTab(GenericPanel
*panel
, QString text
)
94 QWidget
* widget
= new QWidget(ui
->tabWidget
);
95 QVBoxLayout
*baseLayout
= new QVBoxLayout(widget
);
96 VerticalScrollArea
* area
= new VerticalScrollArea(widget
, panel
);
97 baseLayout
->addWidget(area
);
98 ui
->tabWidget
->addTab(widget
, text
);
99 connect(panel
, &GenericPanel::modified
, this, &ModelEdit::modified
);
102 void ModelEdit::onTabIndexChanged(int index
)
104 if (index
< panels
.size())
105 panels
.at(index
)->update();
108 void ModelEdit::launchSimulation()
110 startSimulation(this, radioData
, modelId
);