1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

OP-935 Disables controls when no board is connected. Re-Factored the MixerCurve widget.

This commit is contained in:
Fredrik Arvidsson 2013-05-04 00:13:15 +02:00
parent 5c906802f1
commit 4c0e5a39ca
32 changed files with 641 additions and 1029 deletions

View File

@ -23,13 +23,27 @@ QSlider::add-page:horizontal {
border-radius: 4px;
}
QSlider::add-page:horizontal:disabled {
background: #ccc;
border: 1px solid #999;
width: 1px;
border-radius: 4px;
}
QSlider::sub-page:horizontal {
background: rgb(249, 117, 76);
background: rgb(78, 147, 246);
border: 1px solid #777;
height: 1px;
border-radius: 4px;
}
QSlider::sub-page:horizontal:disabled {
background: #eee;
border: 1px solid #999;
width: 1px;
border-radius: 4px;
}
QSlider::handle:horizontal {
background: rgb(196, 196, 196);
width: 18px;
@ -56,13 +70,27 @@ QSlider::sub-page:vertical {
border-radius: 4px;
}
QSlider::sub-page:vertical:disabled {
background: #eee;
border: 1px solid #999;
width: 1px;
border-radius: 4px;
}
QSlider::add-page:vertical {
background: rgb(249, 117, 76);
background: rgb(78, 147, 246);
border: 1px solid #777;
width: 1px;
border-radius: 4px;
}
QSlider::add-page:vertical:disabled {
background: #ccc;
border: 1px solid #999;
width: 1px;
border-radius: 4px;
}
QSlider::handle:vertical {
background: rgb(196, 196, 196);
width: 18px;

View File

@ -308,7 +308,9 @@ void ConfigCcpmWidget::registerWidgets(ConfigTaskWidget &parent) {
parent.addWidget(m_aircraft->SwashLvlPositionSlider);
parent.addWidget(m_aircraft->SwashLvlPositionSpinBox);
parent.addWidget(m_aircraft->ThrottleCurve->getCurveWidget());
parent.addWidget(m_aircraft->PitchCurve->getCurveWidget());
parent.addWidget(m_aircraft->PitchCurve);
parent.addWidget(m_aircraft->ThrottleCurve->getCurveWidget());
parent.addWidget(m_aircraft->PitchCurve);
parent.addWidget(m_aircraft->ccpmAdvancedSettingsTable);
}

View File

@ -68,7 +68,6 @@ ConfigCustomWidget::ConfigCustomWidget(QWidget *parent) :
for (int i = 1; i < (int) VehicleConfig::CHANNEL_NUMELEM; i++) {
m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd);
}
}
ConfigCustomWidget::~ConfigCustomWidget()
@ -84,7 +83,9 @@ void ConfigCustomWidget::setupUI(QString frameType)
void ConfigCustomWidget::registerWidgets(ConfigTaskWidget &parent) {
parent.addWidget(m_aircraft->customMixerTable);
parent.addWidget(m_aircraft->customThrottle1Curve->getCurveWidget());
parent.addWidget(m_aircraft->customThrottle1Curve);
parent.addWidget(m_aircraft->customThrottle2Curve->getCurveWidget());
parent.addWidget(m_aircraft->customThrottle2Curve);
}
void ConfigCustomWidget::resetActuators(GUIConfigDataUnion *configData)

View File

@ -87,11 +87,9 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) :
m_aircraft->fixedWingType->addItems(fixedWingTypes);
// Set default model to "Elevator aileron rudder"
m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder"));
//setupUI(m_aircraft->fixedWingType->currentText());
connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString)));
m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder"));
setupUI(m_aircraft->fixedWingType->currentText());
}
ConfigFixedWingWidget::~ConfigFixedWingWidget()
@ -109,64 +107,61 @@ void ConfigFixedWingWidget::setupUI(QString frameType)
if (frameType == "FixedWing" || frameType == "Elevator aileron rudder") {
setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevator aileron rudder"));
m_aircraft->fwRudder1ChannelBox->setEnabled(true);
m_aircraft->fwRudder1Label->setEnabled(true);
m_aircraft->fwRudder2ChannelBox->setEnabled(true);
m_aircraft->fwRudder2Label->setEnabled(true);
m_aircraft->fwElevator1ChannelBox->setEnabled(true);
m_aircraft->fwElevator1Label->setEnabled(true);
m_aircraft->fwElevator2ChannelBox->setEnabled(true);
m_aircraft->fwElevator2Label->setEnabled(true);
m_aircraft->fwAileron1ChannelBox->setEnabled(true);
m_aircraft->fwAileron1Label->setEnabled(true);
m_aircraft->fwAileron2ChannelBox->setEnabled(true);
m_aircraft->fwAileron2Label->setEnabled(true);
m_aircraft->fwAileron1Label->setText("Aileron 1");
m_aircraft->fwAileron2Label->setText("Aileron 2");
m_aircraft->fwElevator1Label->setText("Elevator 1");
m_aircraft->fwElevator2Label->setText("Elevator 2");
m_aircraft->elevonMixBox->setHidden(true);
m_aircraft->elevonSlider1->setEnabled(false);
m_aircraft->elevonSlider2->setEnabled(false);
} else if (frameType == "FixedWingElevon" || frameType == "Elevon") {
setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevon"));
m_aircraft->fwAileron1Label->setText("Elevon 1");
m_aircraft->fwAileron2Label->setText("Elevon 2");
m_aircraft->fwElevator1ChannelBox->setEnabled(false);
m_aircraft->fwElevator1Label->setEnabled(false);
m_aircraft->fwElevator2ChannelBox->setEnabled(false);
m_aircraft->fwElevator2Label->setEnabled(false);
m_aircraft->fwRudder1ChannelBox->setEnabled(true);
m_aircraft->fwRudder1Label->setEnabled(true);
m_aircraft->fwRudder2ChannelBox->setEnabled(true);
m_aircraft->fwRudder2Label->setEnabled(true);
m_aircraft->fwElevator1Label->setText("Elevator 1");
m_aircraft->fwElevator2Label->setText("Elevator 2");
m_aircraft->elevonMixBox->setHidden(false);
m_aircraft->elevonLabel1->setText("Roll");
m_aircraft->elevonLabel2->setText("Pitch");
m_aircraft->elevonSlider1->setEnabled(true);
m_aircraft->elevonSlider2->setEnabled(true);
} else if (frameType == "FixedWingVtail" || frameType == "Vtail") {
setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Vtail"));
m_aircraft->fwRudder1ChannelBox->setEnabled(false);
m_aircraft->fwRudder1Label->setEnabled(false);
m_aircraft->fwRudder2ChannelBox->setEnabled(false);
m_aircraft->fwRudder2Label->setEnabled(false);
m_aircraft->fwElevator1ChannelBox->setEnabled(true);
m_aircraft->fwElevator1Label->setEnabled(true);
m_aircraft->fwElevator1Label->setText("Vtail 1");
m_aircraft->fwElevator1ChannelBox->setEnabled(true);
m_aircraft->fwElevator2Label->setText("Vtail 2");
m_aircraft->elevonMixBox->setHidden(false);
m_aircraft->fwElevator2ChannelBox->setEnabled(true);
m_aircraft->fwElevator2Label->setEnabled(true);
m_aircraft->fwAileron1Label->setText("Aileron 1");
m_aircraft->fwAileron2Label->setText("Aileron 2");
m_aircraft->elevonLabel1->setText("Rudder");
m_aircraft->elevonLabel2->setText("Pitch");
}
m_aircraft->elevonSlider1->setEnabled(true);
m_aircraft->elevonSlider2->setEnabled(true);
}
}
void ConfigFixedWingWidget::registerWidgets(ConfigTaskWidget &parent) {
parent.addWidget(m_aircraft->fixedWingThrottle->getCurveWidget());
parent.addWidget(m_aircraft->fixedWingThrottle);
parent.addWidget(m_aircraft->fixedWingType);
parent.addWidget(m_aircraft->fwEngineChannelBox);
@ -508,6 +503,14 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
return true;
}
void ConfigFixedWingWidget::enableControls(bool enable)
{
ConfigTaskWidget::enableControls(enable);
if(enable) {
setupUI(m_aircraft->fixedWingType->currentText());
}
}
/**
This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
*/

View File

@ -64,6 +64,9 @@ private:
bool setupFrameElevon(QString airframeType);
bool setupFrameVtail(QString airframeType);
protected:
void enableControls(bool enable);
private slots:
virtual void setupUI(QString airframeType);
virtual bool throwConfigError(QString airframeType);

View File

@ -79,11 +79,9 @@ ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) :
m_aircraft->groundVehicleType->addItems(groundVehicleTypes);
// Set default model to "Turnable (car)"
m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Turnable (car)"));
//setupUI(m_aircraft->groundVehicleType->currentText());
connect(m_aircraft->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString)));
m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Turnable (car)"));
setupUI(m_aircraft->groundVehicleType->currentText());
}
ConfigGroundVehicleWidget::~ConfigGroundVehicleWidget()
@ -96,42 +94,32 @@ ConfigGroundVehicleWidget::~ConfigGroundVehicleWidget()
*/
void ConfigGroundVehicleWidget::setupUI(QString frameType)
{
m_aircraft->differentialSteeringMixBox->setHidden(true);
//STILL NEEDS WORK
// Setup the UI
m_aircraft->gvEngineChannelBox->setEnabled(false);
m_aircraft->gvEngineLabel->setEnabled(false);
m_aircraft->gvAileron1ChannelBox->setEnabled(false);
m_aircraft->gvAileron1Label->setEnabled(false);
m_aircraft->gvAileron2ChannelBox->setEnabled(false);
m_aircraft->gvAileron2Label->setEnabled(false);
m_aircraft->differentialSteeringSlider1->setEnabled(false);
m_aircraft->differentialSteeringSlider2->setEnabled(false);
if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)") {
// Tank
setComboCurrentIndex(m_aircraft->groundVehicleType,
m_aircraft->groundVehicleType->findText("Differential (tank)"));
m_aircraft->gvMotor1ChannelBox->setEnabled(true);
m_aircraft->gvMotor1Label->setEnabled(true);
m_aircraft->gvMotor2ChannelBox->setEnabled(true);
m_aircraft->gvMotor2Label->setEnabled(true);
m_aircraft->gvMotor1Label->setText("Left motor");
m_aircraft->gvMotor2Label->setText("Right motor");
m_aircraft->gvSteering1ChannelBox->setEnabled(false);
m_aircraft->gvSteering1Label->setEnabled(false);
m_aircraft->gvSteering2ChannelBox->setEnabled(false);
m_aircraft->gvSteering2Label->setEnabled(false);
m_aircraft->gvSteering2Label->setText("Rear steering");
m_aircraft->differentialSteeringMixBox->setHidden(false);
m_aircraft->differentialSteeringSlider1->setEnabled(true);
m_aircraft->differentialSteeringSlider2->setEnabled(true);
m_aircraft->gvThrottleCurve1GroupBox->setTitle("Left throttle curve");
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Right throttle curve");
@ -140,24 +128,16 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
// Motorcycle
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Motorcycle"));
m_aircraft->gvMotor1ChannelBox->setEnabled(false);
m_aircraft->gvMotor1Label->setEnabled(false);
m_aircraft->gvMotor2ChannelBox->setEnabled(true);
m_aircraft->gvMotor2Label->setEnabled(true);
m_aircraft->gvMotor1Label->setText("Front motor");
m_aircraft->gvMotor2Label->setText("Rear motor");
m_aircraft->gvSteering1ChannelBox->setEnabled(true);
m_aircraft->gvSteering1Label->setEnabled(true);
m_aircraft->gvSteering2ChannelBox->setEnabled(true);
m_aircraft->gvSteering2Label->setEnabled(true);
m_aircraft->gvSteering2Label->setText("Balancing");
m_aircraft->differentialSteeringMixBox->setHidden(true);
m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve");
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve");
} else {
@ -165,31 +145,40 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Turnable (car)"));
m_aircraft->gvMotor1ChannelBox->setEnabled(true);
m_aircraft->gvMotor1Label->setEnabled(true);
m_aircraft->gvMotor2ChannelBox->setEnabled(true);
m_aircraft->gvMotor2Label->setEnabled(true);
m_aircraft->gvMotor1Label->setText("Front motor");
m_aircraft->gvMotor2Label->setText("Rear motor");
m_aircraft->gvSteering1ChannelBox->setEnabled(true);
m_aircraft->gvSteering1Label->setEnabled(true);
m_aircraft->gvSteering2ChannelBox->setEnabled(true);
m_aircraft->gvSteering2Label->setEnabled(true);
m_aircraft->differentialSteeringMixBox->setHidden(true);
m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve");
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve");
}
}
void ConfigGroundVehicleWidget::enableControls(bool enable)
{
ConfigTaskWidget::enableControls(enable);
if(enable) {
setupUI(m_aircraft->groundVehicleType->currentText());
}
}
void ConfigGroundVehicleWidget::registerWidgets(ConfigTaskWidget &parent) {
parent.addWidget(m_aircraft->groundVehicleThrottle1->getCurveWidget());
parent.addWidget(m_aircraft->groundVehicleThrottle1);
parent.addWidget(m_aircraft->groundVehicleThrottle2->getCurveWidget());
parent.addWidget(m_aircraft->groundVehicleThrottle2);
parent.addWidget(m_aircraft->groundVehicleType);
parent.addWidget(m_aircraft->gvEngineChannelBox);
parent.addWidget(m_aircraft->gvAileron1ChannelBox);
parent.addWidget(m_aircraft->gvAileron2ChannelBox);
parent.addWidget(m_aircraft->gvMotor1ChannelBox);
parent.addWidget(m_aircraft->gvMotor2ChannelBox);
parent.addWidget(m_aircraft->gvSteering1ChannelBox);
parent.addWidget(m_aircraft->gvSteering2ChannelBox);
}
void ConfigGroundVehicleWidget::resetActuators(GUIConfigDataUnion *configData)

View File

@ -54,6 +54,9 @@ public:
virtual void refreshWidgetsValues(QString frameType);
virtual QString updateConfigObjectsFromWidgets();
protected:
void enableControls(bool enable);
private:
Ui_GroundConfigWidget *m_aircraft;

View File

@ -122,6 +122,7 @@ ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) :
// Connect the multirotor motor reverse checkbox
connect(m_aircraft->MultirotorRevMixerCheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor()));
updateEnableControls();
}
ConfigMultiRotorWidget::~ConfigMultiRotorWidget()
@ -134,6 +135,81 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
Q_ASSERT(m_aircraft);
Q_ASSERT(quad);
if (frameType == "Tri" || frameType == "Tricopter Y") {
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Tricopter Y"));
m_aircraft->mrRollMixLevel->setValue(100);
m_aircraft->mrPitchMixLevel->setValue(100);
setYawMixLevel(50);
} else if (frameType == "QuadX" || frameType == "Quad X") {
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X"));
// init mixer levels
m_aircraft->mrRollMixLevel->setValue(50);
m_aircraft->mrPitchMixLevel->setValue(50);
setYawMixLevel(50);
} else if (frameType == "QuadP" || frameType == "Quad +") {
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +"));
m_aircraft->mrRollMixLevel->setValue(100);
m_aircraft->mrPitchMixLevel->setValue(100);
setYawMixLevel(50);
} else if (frameType == "Hexa" || frameType == "Hexacopter") {
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter"));
m_aircraft->mrRollMixLevel->setValue(50);
m_aircraft->mrPitchMixLevel->setValue(33);
setYawMixLevel(33);
} else if (frameType == "HexaX" || frameType == "Hexacopter X") {
setComboCurrentIndex(m_aircraft->multirotorFrameType,
m_aircraft->multirotorFrameType->findText("Hexacopter X"));
m_aircraft->mrRollMixLevel->setValue(33);
m_aircraft->mrPitchMixLevel->setValue(50);
setYawMixLevel(33);
} else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") {
setComboCurrentIndex(m_aircraft->multirotorFrameType,
m_aircraft->multirotorFrameType->findText("Hexacopter Y6"));
m_aircraft->mrRollMixLevel->setValue(100);
m_aircraft->mrPitchMixLevel->setValue(50);
setYawMixLevel(66);
} else if (frameType == "Octo" || frameType == "Octocopter") {
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter"));
m_aircraft->mrRollMixLevel->setValue(33);
m_aircraft->mrPitchMixLevel->setValue(33);
setYawMixLevel(25);
} else if (frameType == "OctoV" || frameType == "Octocopter V") {
setComboCurrentIndex(m_aircraft->multirotorFrameType,
m_aircraft->multirotorFrameType->findText("Octocopter V"));
m_aircraft->mrRollMixLevel->setValue(25);
m_aircraft->mrPitchMixLevel->setValue(25);
setYawMixLevel(25);
} else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") {
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +"));
m_aircraft->mrRollMixLevel->setValue(100);
m_aircraft->mrPitchMixLevel->setValue(100);
setYawMixLevel(50);
} else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") {
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X"));
m_aircraft->mrRollMixLevel->setValue(50);
m_aircraft->mrPitchMixLevel->setValue(50);
setYawMixLevel(50);
}
// Enable/Disable controls
setupEnabledControls(frameType);
// Draw the appropriate airframe
updateAirframe(frameType);
}
void ConfigMultiRotorWidget::setupEnabledControls(QString frameType)
{
// disable triyaw channel
m_aircraft->triYawChannelBox->setEnabled(false);
@ -148,109 +224,32 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
}
if (frameType == "Tri" || frameType == "Tricopter Y") {
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Tricopter Y"));
// Enable all necessary motor channel boxes...
enableComboBoxes(this, CHANNELBOXNAME, 3, true);
m_aircraft->mrRollMixLevel->setValue(100);
m_aircraft->mrPitchMixLevel->setValue(100);
setYawMixLevel(50);
m_aircraft->triYawChannelBox->setEnabled(true);
} else if (frameType == "QuadX" || frameType == "Quad X") {
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X"));
// Enable all necessary motor channel boxes...
enableComboBoxes(this, CHANNELBOXNAME, 4, true);
// init mixer levels
m_aircraft->mrRollMixLevel->setValue(50);
m_aircraft->mrPitchMixLevel->setValue(50);
setYawMixLevel(50);
} else if (frameType == "QuadP" || frameType == "Quad +") {
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +"));
// Enable all necessary motor channel boxes...
enableComboBoxes(this, CHANNELBOXNAME, 4, true);
m_aircraft->mrRollMixLevel->setValue(100);
m_aircraft->mrPitchMixLevel->setValue(100);
setYawMixLevel(50);
} else if (frameType == "Hexa" || frameType == "Hexacopter") {
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter"));
// Enable all necessary motor channel boxes...
enableComboBoxes(this, CHANNELBOXNAME, 6, true);
m_aircraft->mrRollMixLevel->setValue(50);
m_aircraft->mrPitchMixLevel->setValue(33);
setYawMixLevel(33);
} else if (frameType == "HexaX" || frameType == "Hexacopter X") {
setComboCurrentIndex(m_aircraft->multirotorFrameType,
m_aircraft->multirotorFrameType->findText("Hexacopter X"));
// Enable all necessary motor channel boxes...
enableComboBoxes(this, CHANNELBOXNAME, 6, true);
m_aircraft->mrRollMixLevel->setValue(33);
m_aircraft->mrPitchMixLevel->setValue(50);
setYawMixLevel(33);
} else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") {
setComboCurrentIndex(m_aircraft->multirotorFrameType,
m_aircraft->multirotorFrameType->findText("Hexacopter Y6"));
// Enable all necessary motor channel boxes...
enableComboBoxes(this, CHANNELBOXNAME, 6, true);
m_aircraft->mrRollMixLevel->setValue(100);
m_aircraft->mrPitchMixLevel->setValue(50);
setYawMixLevel(66);
} else if (frameType == "Octo" || frameType == "Octocopter") {
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter"));
// Enable all necessary motor channel boxes
enableComboBoxes(this, CHANNELBOXNAME, 8, true);
m_aircraft->mrRollMixLevel->setValue(33);
m_aircraft->mrPitchMixLevel->setValue(33);
setYawMixLevel(25);
} else if (frameType == "OctoV" || frameType == "Octocopter V") {
setComboCurrentIndex(m_aircraft->multirotorFrameType,
m_aircraft->multirotorFrameType->findText("Octocopter V"));
// Enable all necessary motor channel boxes
enableComboBoxes(this, CHANNELBOXNAME, 8, true);
m_aircraft->mrRollMixLevel->setValue(25);
m_aircraft->mrPitchMixLevel->setValue(25);
setYawMixLevel(25);
} else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") {
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +"));
// Enable all necessary motor channel boxes
enableComboBoxes(this, CHANNELBOXNAME, 8, true);
m_aircraft->mrRollMixLevel->setValue(100);
m_aircraft->mrPitchMixLevel->setValue(100);
setYawMixLevel(50);
} else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") {
setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X"));
// Enable all necessary motor channel boxes
enableComboBoxes(this, CHANNELBOXNAME, 8, true);
m_aircraft->mrRollMixLevel->setValue(50);
m_aircraft->mrPitchMixLevel->setValue(50);
setYawMixLevel(50);
}
// Draw the appropriate airframe
updateAirframe(frameType);
}
void ConfigMultiRotorWidget::registerWidgets(ConfigTaskWidget &parent) {
parent.addWidget(m_aircraft->multiThrottleCurve->getCurveWidget());
parent.addWidget(m_aircraft->multiThrottleCurve);
parent.addWidget(m_aircraft->multirotorFrameType);
parent.addWidget(m_aircraft->multiMotorChannelBox1);
parent.addWidget(m_aircraft->multiMotorChannelBox2);
@ -264,6 +263,7 @@ void ConfigMultiRotorWidget::registerWidgets(ConfigTaskWidget &parent) {
parent.addWidget(m_aircraft->mrRollMixLevel);
parent.addWidget(m_aircraft->mrYawMixLevel);
parent.addWidget(m_aircraft->triYawChannelBox);
parent.addWidget(m_aircraft->MultirotorRevMixerCheckBox);
}
void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData)
@ -1048,3 +1048,11 @@ void ConfigMultiRotorWidget::resizeEvent(QResizeEvent *event)
Q_UNUSED(event);
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
}
void ConfigMultiRotorWidget::enableControls(bool enable)
{
ConfigTaskWidget::enableControls(enable);
if(enable) {
setupEnabledControls(m_aircraft->multirotorFrameType->currentText());
}
}

View File

@ -58,6 +58,7 @@ public:
protected:
void showEvent(QShowEvent *event);
void resizeEvent(QResizeEvent *event);
void enableControls(bool enable);
private:
Ui_MultiRotorConfigWidget *m_aircraft;
@ -77,6 +78,7 @@ private:
void setYawMixLevel(int);
void updateAirframe(QString multiRotorType);
void setupEnabledControls(QString multiRotorType);
private slots:
virtual void setupUI(QString airframeType);

View File

@ -43,24 +43,24 @@
ConfigCameraStabilizationWidget::ConfigCameraStabilizationWidget(QWidget *parent) : ConfigTaskWidget(parent)
{
m_camerastabilization = new Ui_CameraStabilizationWidget();
m_camerastabilization->setupUi(this);
ui = new Ui_CameraStabilizationWidget();
ui->setupUi(this);
addApplySaveButtons(m_camerastabilization->camerastabilizationSaveRAM,m_camerastabilization->camerastabilizationSaveSD);
addApplySaveButtons(ui->camerastabilizationSaveRAM,ui->camerastabilizationSaveSD);
ExtensionSystem::PluginManager *pm=ExtensionSystem::PluginManager::instance();
Core::Internal::GeneralSettings * settings=pm->getObject<Core::Internal::GeneralSettings>();
if(!settings->useExpertMode())
m_camerastabilization->camerastabilizationSaveRAM->setVisible(false);
ui->camerastabilizationSaveRAM->setVisible(false);
// These widgets don't have direct relation to UAVObjects
// and need special processing
QComboBox *outputs[] = {
m_camerastabilization->rollChannel,
m_camerastabilization->pitchChannel,
m_camerastabilization->yawChannel,
ui->rollChannel,
ui->pitchChannel,
ui->yawChannel,
};
const int NUM_OUTPUTS = sizeof(outputs) / sizeof(outputs[0]);
@ -78,10 +78,10 @@ ConfigCameraStabilizationWidget::ConfigCameraStabilizationWidget(QWidget *parent
autoLoadWidgets();
// Add some widgets to track their UI dirty state and handle smartsave
addWidget(m_camerastabilization->enableCameraStabilization);
addWidget(m_camerastabilization->rollChannel);
addWidget(m_camerastabilization->pitchChannel);
addWidget(m_camerastabilization->yawChannel);
addWidget(ui->enableCameraStabilization);
addWidget(ui->rollChannel);
addWidget(ui->pitchChannel);
addWidget(ui->yawChannel);
// Add some UAVObjects to monitor their changes in addition to autoloaded ones.
// Note also that we want to reload some UAVObjects by "Reload" button and have
@ -97,6 +97,7 @@ ConfigCameraStabilizationWidget::ConfigCameraStabilizationWidget(QWidget *parent
connect(this, SIGNAL(defaultRequested(int)), this, SLOT(defaultRequestedSlot(int)));
disableMouseWheelEvents();
updateEnableControls();
}
ConfigCameraStabilizationWidget::~ConfigCameraStabilizationWidget()
@ -120,7 +121,7 @@ void ConfigCameraStabilizationWidget::refreshWidgetsValues(UAVObject *obj)
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
HwSettings::DataFields hwSettingsData = hwSettings->getData();
m_camerastabilization->enableCameraStabilization->setChecked(
ui->enableCameraStabilization->setChecked(
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] == HwSettings::OPTIONALMODULES_ENABLED);
// Load mixer outputs which are mapped to camera controls
@ -144,9 +145,9 @@ void ConfigCameraStabilizationWidget::refreshWidgetsValues(UAVObject *obj)
const int NUM_MIXERS = sizeof(mixerTypes) / sizeof(mixerTypes[0]);
QComboBox *outputs[] = {
m_camerastabilization->rollChannel,
m_camerastabilization->pitchChannel,
m_camerastabilization->yawChannel
ui->rollChannel,
ui->pitchChannel,
ui->yawChannel
};
const int NUM_OUTPUTS = sizeof(outputs) / sizeof(outputs[0]);
@ -175,7 +176,7 @@ void ConfigCameraStabilizationWidget::updateObjectsFromWidgets()
// Save state of the module enable checkbox first.
// Do not use setData() member on whole object, if possible, since it triggers
// unnessesary UAVObect update.
quint8 enableModule = m_camerastabilization->enableCameraStabilization->isChecked() ?
quint8 enableModule = ui->enableCameraStabilization->isChecked() ?
HwSettings::OPTIONALMODULES_ENABLED : HwSettings::OPTIONALMODULES_DISABLED;
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
hwSettings->setOptionalModules(HwSettings::OPTIONALMODULES_CAMERASTAB, enableModule);
@ -202,13 +203,13 @@ void ConfigCameraStabilizationWidget::updateObjectsFromWidgets()
const int NUM_MIXERS = sizeof(mixerTypes) / sizeof(mixerTypes[0]);
QComboBox *outputs[] = {
m_camerastabilization->rollChannel,
m_camerastabilization->pitchChannel,
m_camerastabilization->yawChannel
ui->rollChannel,
ui->pitchChannel,
ui->yawChannel
};
const int NUM_OUTPUTS = sizeof(outputs) / sizeof(outputs[0]);
m_camerastabilization->message->setText("");
ui->message->setText("");
bool widgetUpdated;
do {
widgetUpdated = false;
@ -223,7 +224,7 @@ void ConfigCameraStabilizationWidget::updateObjectsFromWidgets()
// If the mixer channel already mapped to something, it should not be
// used for camera output, we reset it to none
outputs[i]->setCurrentIndex(0);
m_camerastabilization->message->setText("One of the channels is already assigned, reverted to none");
ui->message->setText("One of the channels is already assigned, reverted to none");
// Loop again or we may have inconsistent widget and UAVObject
widgetUpdated = true;
@ -270,9 +271,9 @@ void ConfigCameraStabilizationWidget::defaultRequestedSlot(int group)
// For outputs we set them all to none, so don't use any UAVObject to get defaults
QComboBox *outputs[] = {
m_camerastabilization->rollChannel,
m_camerastabilization->pitchChannel,
m_camerastabilization->yawChannel,
ui->rollChannel,
ui->pitchChannel,
ui->yawChannel,
};
const int NUM_OUTPUTS = sizeof(outputs) / sizeof(outputs[0]);
@ -280,8 +281,3 @@ void ConfigCameraStabilizationWidget::defaultRequestedSlot(int group)
outputs[i]->setCurrentIndex(0);
}
}
/**
@}
@}
*/

View File

@ -43,7 +43,7 @@ public:
~ConfigCameraStabilizationWidget();
private:
Ui_CameraStabilizationWidget *m_camerastabilization;
Ui_CameraStabilizationWidget *ui;
void refreshWidgetsValues(UAVObject *obj);
void updateObjectsFromWidgets();

View File

@ -216,15 +216,9 @@ void ConfigCCAttitudeWidget::setAccelFiltering(bool active)
void ConfigCCAttitudeWidget::enableControls(bool enable)
{
if(ui->zeroBias) {
ui->zeroBias->setEnabled(enable);
}
if(ui->zeroGyroBiasOnArming) {
ui->zeroGyroBiasOnArming->setEnabled(enable);
}
if(ui->accelTauSpinbox) {
ui->accelTauSpinbox->setEnabled(enable);
}
ui->zeroBias->setEnabled(enable);
ui->zeroGyroBiasOnArming->setEnabled(enable);
ui->accelTauSpinbox->setEnabled(enable);
ConfigTaskWidget::enableControls(enable);
}

View File

@ -142,8 +142,6 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
oplinkTimeout = new QTimer(this);
connect(oplinkTimeout, SIGNAL(timeout()), this, SLOT(onOPLinkDisconnect()));
oplinkConnected = false;
ftw->setWidgetsEnabled(false);
}
ConfigGadgetWidget::~ConfigGadgetWidget()
@ -165,7 +163,6 @@ void ConfigGadgetWidget::resizeEvent(QResizeEvent *event)
}
void ConfigGadgetWidget::onAutopilotDisconnect() {
ftw->setWidgetsEnabled(false);
int selectedIndex = ftw->currentIndex();
@ -238,7 +235,7 @@ void ConfigGadgetWidget::onAutopilotConnect() {
}
ftw->setCurrentIndex(selectedIndex);
}
ftw->setWidgetsEnabled(true);
emit autopilotConnected();
}

View File

@ -63,17 +63,17 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
manualSettingsObj = ManualControlSettings::GetInstance(getObjectManager());
flightStatusObj = FlightStatus::GetInstance(getObjectManager());
receiverActivityObj=ReceiverActivity::GetInstance(getObjectManager());
m_config = new Ui_InputWidget();
m_config->setupUi(this);
ui = new Ui_InputWidget();
ui->setupUi(this);
addApplySaveButtons(m_config->saveRCInputToRAM,m_config->saveRCInputToSD);
addApplySaveButtons(ui->saveRCInputToRAM,ui->saveRCInputToSD);
ExtensionSystem::PluginManager *pm=ExtensionSystem::PluginManager::instance();
Core::Internal::GeneralSettings * settings=pm->getObject<Core::Internal::GeneralSettings>();
if(!settings->useExpertMode())
m_config->saveRCInputToRAM->setVisible(false);
ui->saveRCInputToRAM->setVisible(false);
addApplySaveButtons(m_config->saveRCInputToRAM,m_config->saveRCInputToSD);
addApplySaveButtons(ui->saveRCInputToRAM,ui->saveRCInputToSD);
//Generate the rows of buttons in the input channel form GUI
unsigned int index=0;
@ -82,13 +82,16 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
{
Q_ASSERT(index < ManualControlSettings::CHANNELGROUPS_NUMELEM);
inputChannelForm * inpForm=new inputChannelForm(this,index==0);
m_config->channelSettings->layout()->addWidget(inpForm); //Add the row to the UI
ui->channelSettings->layout()->addWidget(inpForm); //Add the row to the UI
inpForm->setName(name);
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelGroups",inpForm->ui->channelGroup,index);
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelNumber",inpForm->ui->channelNumber,index);
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelMin",inpForm->ui->channelMin,index);
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelNeutral",inpForm->ui->channelNeutral,index);
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelMax",inpForm->ui->channelMax,index);
addWidget(inpForm->ui->channelNumberDropdown);
addWidget(inpForm->ui->channelRev);
addWidget(inpForm->ui->channelResponseTime);
// Input filter response time fields supported for some channels only
switch (index) {
@ -114,51 +117,53 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
++index;
}
addUAVObjectToWidgetRelation("ManualControlSettings", "Deadband", m_config->deadband, 0, 0.01f);
addUAVObjectToWidgetRelation("ManualControlSettings", "Deadband", ui->deadband, 0, 0.01f);
connect(m_config->configurationWizard,SIGNAL(clicked()),this,SLOT(goToWizard()));
connect(m_config->stackedWidget,SIGNAL(currentChanged(int)),this,SLOT(disableWizardButton(int)));
connect(m_config->runCalibration,SIGNAL(toggled(bool)),this, SLOT(simpleCalibration(bool)));
connect(ui->configurationWizard,SIGNAL(clicked()),this,SLOT(goToWizard()));
connect(ui->stackedWidget,SIGNAL(currentChanged(int)),this,SLOT(disableWizardButton(int)));
connect(ui->runCalibration,SIGNAL(toggled(bool)),this, SLOT(simpleCalibration(bool)));
connect(m_config->wzNext,SIGNAL(clicked()),this,SLOT(wzNext()));
connect(m_config->wzCancel,SIGNAL(clicked()),this,SLOT(wzCancel()));
connect(m_config->wzBack,SIGNAL(clicked()),this,SLOT(wzBack()));
connect(ui->wzNext,SIGNAL(clicked()),this,SLOT(wzNext()));
connect(ui->wzCancel,SIGNAL(clicked()),this,SLOT(wzCancel()));
connect(ui->wzBack,SIGNAL(clicked()),this,SLOT(wzBack()));
m_config->stackedWidget->setCurrentIndex(0);
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", m_config->fmsModePos1, 0, 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", m_config->fmsModePos2, 1, 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", m_config->fmsModePos3, 2, 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", m_config->fmsModePos4, 3, 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", m_config->fmsModePos5, 4, 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", m_config->fmsModePos6, 5, 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModeNumber", m_config->fmsPosNum);
ui->stackedWidget->setCurrentIndex(0);
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos1, 0, 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos2, 1, 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos3, 2, 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos4, 3, 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos5, 4, 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos6, 5, 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModeNumber", ui->fmsPosNum);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization1Settings", m_config->fmsSsPos1Roll, "Roll", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization2Settings", m_config->fmsSsPos2Roll, "Roll", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization3Settings", m_config->fmsSsPos3Roll, "Roll", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization1Settings", m_config->fmsSsPos1Pitch, "Pitch", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization2Settings", m_config->fmsSsPos2Pitch, "Pitch", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization3Settings", m_config->fmsSsPos3Pitch, "Pitch", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization1Settings", m_config->fmsSsPos1Yaw, "Yaw", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization2Settings", m_config->fmsSsPos2Yaw, "Yaw", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization3Settings", m_config->fmsSsPos3Yaw, "Yaw", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization1Settings", ui->fmsSsPos1Roll, "Roll", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization2Settings", ui->fmsSsPos2Roll, "Roll", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization3Settings", ui->fmsSsPos3Roll, "Roll", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization1Settings", ui->fmsSsPos1Pitch, "Pitch", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization2Settings", ui->fmsSsPos2Pitch, "Pitch", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization3Settings", ui->fmsSsPos3Pitch, "Pitch", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization1Settings", ui->fmsSsPos1Yaw, "Yaw", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization2Settings", ui->fmsSsPos2Yaw, "Yaw", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization3Settings", ui->fmsSsPos3Yaw, "Yaw", 1, true);
addUAVObjectToWidgetRelation("ManualControlSettings","Arming",m_config->armControl);
addUAVObjectToWidgetRelation("ManualControlSettings","ArmedTimeout",m_config->armTimeout,0,1000);
addUAVObjectToWidgetRelation("ManualControlSettings","Arming",ui->armControl);
addUAVObjectToWidgetRelation("ManualControlSettings","ArmedTimeout",ui->armTimeout,0,1000);
connect( ManualControlCommand::GetInstance(getObjectManager()),SIGNAL(objectUpdated(UAVObject*)),this,SLOT(moveFMSlider()));
connect( ManualControlSettings::GetInstance(getObjectManager()),SIGNAL(objectUpdated(UAVObject*)),this,SLOT(updatePositionSlider()));
enableControls(false);
addWidget(ui->configurationWizard);
addWidget(ui->runCalibration);
populateWidgets();
refreshWidgetsValues();
// Connect the help button
connect(m_config->inputHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
connect(ui->inputHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
m_config->graphicsView->setScene(new QGraphicsScene(this));
m_config->graphicsView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
ui->graphicsView->setScene(new QGraphicsScene(this));
ui->graphicsView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
m_renderer = new QSvgRenderer();
QGraphicsScene *l_scene = m_config->graphicsView->scene();
m_config->graphicsView->setBackgroundBrush(QBrush(Utils::StyleHelper::baseColor()));
QGraphicsScene *l_scene = ui->graphicsView->scene();
ui->graphicsView->setBackgroundBrush(QBrush(Utils::StyleHelper::baseColor()));
if (QFile::exists(":/configgadget/images/TX2.svg") && m_renderer->load(QString(":/configgadget/images/TX2.svg")) && m_renderer->isValid())
{
l_scene->clear(); // Deletes all items contained in the scene as well.
@ -271,7 +276,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
m_txAccess2Orig.translate(orig.x(),orig.y());
m_txAccess2->setTransform(m_txAccess2Orig,true);
}
m_config->graphicsView->fitInView(m_txMainBody, Qt::KeepAspectRatio );
ui->graphicsView->fitInView(m_txMainBody, Qt::KeepAspectRatio );
animate=new QTimer(this);
connect(animate,SIGNAL(timeout()),this,SLOT(moveTxControls()));
@ -293,7 +298,10 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
ManualControlSettings::CHANNELGROUPS_ACCESSORY0 <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY1 <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY2;
updateEnableControls();
}
void ConfigInputWidget::resetTxControls()
{
@ -312,10 +320,19 @@ ConfigInputWidget::~ConfigInputWidget()
}
void ConfigInputWidget::enableControls(bool enable)
{
ConfigTaskWidget::enableControls(enable);
if(enable) {
updatePositionSlider();
}
}
void ConfigInputWidget::resizeEvent(QResizeEvent *event)
{
QWidget::resizeEvent(event);
m_config->graphicsView->fitInView(m_txBackground, Qt::KeepAspectRatio );
ui->graphicsView->fitInView(m_txBackground, Qt::KeepAspectRatio );
}
void ConfigInputWidget::openHelp()
@ -335,8 +352,8 @@ void ConfigInputWidget::goToWizard()
msgBox.exec();
// Set correct tab visible before starting wizard.
if(m_config->tabWidget->currentIndex() != 0) {
m_config->tabWidget->setCurrentIndex(0);
if(ui->tabWidget->currentIndex() != 0) {
ui->tabWidget->setCurrentIndex(0);
}
// Stash current manual settings data in case the wizard is
@ -351,27 +368,27 @@ void ConfigInputWidget::goToWizard()
// start the wizard
wizardSetUpStep(wizardWelcome);
m_config->graphicsView->fitInView(m_txBackground, Qt::KeepAspectRatio);
ui->graphicsView->fitInView(m_txBackground, Qt::KeepAspectRatio);
}
void ConfigInputWidget::disableWizardButton(int value)
{
if(value!=0)
m_config->groupBox_3->setVisible(false);
ui->groupBox_3->setVisible(false);
else
m_config->groupBox_3->setVisible(true);
ui->groupBox_3->setVisible(true);
}
void ConfigInputWidget::wzCancel()
{
dimOtherControls(false);
manualCommandObj->setMetadata(manualCommandObj->getDefaultMetadata());
m_config->stackedWidget->setCurrentIndex(0);
ui->stackedWidget->setCurrentIndex(0);
if(wizardStep != wizardNone)
wizardTearDownStep(wizardStep);
wizardStep=wizardNone;
m_config->stackedWidget->setCurrentIndex(0);
ui->stackedWidget->setCurrentIndex(0);
// Load settings back from beginning of wizard
manualSettingsObj->setData(previousManualSettingsData);
@ -433,8 +450,8 @@ void ConfigInputWidget::wzNext()
}
manualSettingsObj->setData(manualSettingsData);
// move to Arming Settings tab
m_config->stackedWidget->setCurrentIndex(0);
m_config->tabWidget->setCurrentIndex(2);
ui->stackedWidget->setCurrentIndex(0);
ui->tabWidget->setCurrentIndex(2);
break;
default:
Q_ASSERT(0);
@ -481,7 +498,7 @@ void ConfigInputWidget::wzBack()
void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
{
m_config->wzText2->clear();
ui->wzText2->clear();
switch(step) {
case wizardWelcome:
@ -491,22 +508,22 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
delete wd;
}
extraWidgets.clear();
m_config->graphicsView->setVisible(false);
ui->graphicsView->setVisible(false);
setTxMovement(nothing);
m_config->wzText->setText(tr("Welcome to the inputs configuration wizard.\n\n"
ui->wzText->setText(tr("Welcome to the inputs configuration wizard.\n\n"
"Please follow the instructions on the screen and only move your controls when asked to.\n"
"Make sure you already configured your hardware settings on the proper tab and restarted your board.\n\n"
"You can press 'back' at any time to return to the previous screen or press 'Cancel' to quit the wizard.\n"));
m_config->stackedWidget->setCurrentIndex(1);
m_config->wzBack->setEnabled(false);
ui->stackedWidget->setCurrentIndex(1);
ui->wzBack->setEnabled(false);
break;
case wizardChooseType:
{
m_config->graphicsView->setVisible(true);
m_config->graphicsView->fitInView(m_txBackground, Qt::KeepAspectRatio);
ui->graphicsView->setVisible(true);
ui->graphicsView->fitInView(m_txBackground, Qt::KeepAspectRatio);
setTxMovement(nothing);
m_config->wzText->setText(tr("Please choose your transmitter type:"));
m_config->wzBack->setEnabled(true);
ui->wzText->setText(tr("Please choose your transmitter type:"));
ui->wzBack->setEnabled(true);
QRadioButton * typeAcro=new QRadioButton(tr("Acro: normal transmitter for fixed-wing or quad"),this);
QRadioButton * typeHeli=new QRadioButton(tr("Helicopter: has collective pitch and throttle input"),this);
if (transmitterType == heli) {
@ -515,20 +532,20 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
else {
typeAcro->setChecked(true);
}
m_config->wzText2->setText(tr("If selecting the Helicopter option, please engage throttle hold now."));
ui->wzText2->setText(tr("If selecting the Helicopter option, please engage throttle hold now."));
extraWidgets.clear();
extraWidgets.append(typeAcro);
extraWidgets.append(typeHeli);
m_config->radioButtonsLayout->layout()->addWidget(typeAcro);
m_config->radioButtonsLayout->layout()->addWidget(typeHeli);
ui->radioButtonsLayout->layout()->addWidget(typeAcro);
ui->radioButtonsLayout->layout()->addWidget(typeHeli);
}
break;
case wizardChooseMode:
{
m_config->wzBack->setEnabled(true);
ui->wzBack->setEnabled(true);
extraWidgets.clear();
m_config->wzText->setText(tr("Please choose your transmitter mode:"));
ui->wzText->setText(tr("Please choose your transmitter mode:"));
for (int i = 0; i <= mode4; ++i) {
QString label;
txMode mode = static_cast<txMode>(i);
@ -548,14 +565,14 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
case mode4: label = tr("Mode 4: Throttle and Ailerons on the left, Elevator and Rudder on the right"); break;
default: Q_ASSERT(0); break;
}
m_config->wzText2->setText(tr("For a Quad: Elevator is Pitch, Ailerons are Roll, and Rudder is Yaw."));
ui->wzText2->setText(tr("For a Quad: Elevator is Pitch, Ailerons are Roll, and Rudder is Yaw."));
}
QRadioButton * modeButton = new QRadioButton(label, this);
if (transmitterMode == mode) {
modeButton->setChecked(true);
}
extraWidgets.append(modeButton);
m_config->radioButtonsLayout->layout()->addWidget(modeButton);
ui->radioButtonsLayout->layout()->addWidget(modeButton);
}
}
break;
@ -565,11 +582,11 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
nextChannel();
manualSettingsData=manualSettingsObj->getData();
connect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
m_config->wzNext->setEnabled(false);
ui->wzNext->setEnabled(false);
break;
case wizardIdentifyCenter:
setTxMovement(centerAll);
m_config->wzText->setText(QString(tr("Please center all controls and trims and press Next when ready.\n\n"
ui->wzText->setText(QString(tr("Please center all controls and trims and press Next when ready.\n\n"
"If your FlightMode switch has only two positions, leave it in either position.")));
break;
case wizardIdentifyLimits:
@ -578,7 +595,7 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
accessoryDesiredObj1 = AccessoryDesired::GetInstance(getObjectManager(),1);
accessoryDesiredObj2 = AccessoryDesired::GetInstance(getObjectManager(),2);
setTxMovement(nothing);
m_config->wzText->setText(QString(tr("Please move all controls to their maximum extents on both directions.\n\nPress Next when ready.")));
ui->wzText->setText(QString(tr("Please move all controls to their maximum extents on both directions.\n\nPress Next when ready.")));
fastMdata();
manualSettingsData=manualSettingsObj->getData();
for(uint i=0;i<ManualControlSettings::CHANNELMAX_NUMELEM;++i)
@ -612,13 +629,13 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
QCheckBox * cb=new QCheckBox(name,this);
// Make sure checked status matches current one
cb->setChecked(manualSettingsData.ChannelMax[index] < manualSettingsData.ChannelMin[index]);
dynamic_cast<QGridLayout*>(m_config->checkBoxesLayout->layout())->addWidget(cb, extraWidgets.size()/4, extraWidgets.size()%4);
dynamic_cast<QGridLayout*>(ui->checkBoxesLayout->layout())->addWidget(cb, extraWidgets.size()/4, extraWidgets.size()%4);
extraWidgets.append(cb);
connect(cb,SIGNAL(toggled(bool)),this,SLOT(invertControls()));
}
}
connect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
m_config->wzText->setText(QString(tr("Please check the picture below and correct all the sticks which show an inverted movement. Press Next when ready.")));
ui->wzText->setText(QString(tr("Please check the picture below and correct all the sticks which show an inverted movement. Press Next when ready.")));
fastMdata();
break;
case wizardFinish:
@ -626,7 +643,7 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
connect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
connect(flightStatusObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
connect(accessoryDesiredObj0, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
m_config->wzText->setText(QString(tr("You have completed this wizard, please check below if the picture mimics your sticks movement.\n\n"
ui->wzText->setText(QString(tr("You have completed this wizard, please check below if the picture mimics your sticks movement.\n\n"
"IMPORTANT: These new settings have not been saved to the board yet. After pressing Next you will go to the Arming Settings "
"tab where you can set your desired arming sequence and save the configuration.")));
fastMdata();
@ -666,7 +683,7 @@ void ConfigInputWidget::wizardTearDownStep(enum wizardSteps step)
break;
case wizardIdentifySticks:
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
m_config->wzNext->setEnabled(true);
ui->wzNext->setEnabled(true);
setTxMovement(nothing);
break;
case wizardIdentifyCenter:
@ -742,21 +759,21 @@ void ConfigInputWidget::restoreMdata()
void ConfigInputWidget::setChannel(int newChan)
{
if(newChan == ManualControlSettings::CHANNELGROUPS_COLLECTIVE)
m_config->wzText->setText(QString(tr("Please enable throttle hold mode.\n\nMove the Collective Pitch stick.")));
ui->wzText->setText(QString(tr("Please enable throttle hold mode.\n\nMove the Collective Pitch stick.")));
else if (newChan == ManualControlSettings::CHANNELGROUPS_FLIGHTMODE)
m_config->wzText->setText(QString(tr("Please toggle the Flight Mode switch.\n\nFor switches you may have to repeat this rapidly.")));
ui->wzText->setText(QString(tr("Please toggle the Flight Mode switch.\n\nFor switches you may have to repeat this rapidly.")));
else if((transmitterType == heli) && (newChan == ManualControlSettings::CHANNELGROUPS_THROTTLE))
m_config->wzText->setText(QString(tr("Please disable throttle hold mode.\n\nMove the Throttle stick.")));
ui->wzText->setText(QString(tr("Please disable throttle hold mode.\n\nMove the Throttle stick.")));
else
m_config->wzText->setText(QString(tr("Please move each control one at a time according to the instructions and picture below.\n\n"
ui->wzText->setText(QString(tr("Please move each control one at a time according to the instructions and picture below.\n\n"
"Move the %1 stick.")).arg(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan)));
if(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan).contains("Accessory") ||
manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan).contains("FlightMode")) {
m_config->wzNext->setEnabled(true);
m_config->wzText->setText(m_config->wzText->text() + tr(" Alternatively, click Next to skip this channel."));
ui->wzNext->setEnabled(true);
ui->wzText->setText(ui->wzText->text() + tr(" Alternatively, click Next to skip this channel."));
} else
m_config->wzNext->setEnabled(false);
ui->wzNext->setEnabled(false);
setMoveFromCommand(newChan);
@ -1249,15 +1266,6 @@ void ConfigInputWidget::dimOtherControls(bool value)
m_txFlightMode->setOpacity(opac);
}
void ConfigInputWidget::enableControls(bool enable)
{
m_config->configurationWizard->setEnabled(enable);
m_config->runCalibration->setEnabled(enable);
ConfigTaskWidget::enableControls(enable);
}
void ConfigInputWidget::invertControls()
{
manualSettingsData=manualSettingsObj->getData();
@ -1318,7 +1326,7 @@ void ConfigInputWidget::moveFMSlider()
uint8_t pos = ((int16_t)(valueScaled * 256) + 256) * manualSettingsDataPriv.FlightModeNumber >> 9;
if (pos >= manualSettingsDataPriv.FlightModeNumber)
pos = manualSettingsDataPriv.FlightModeNumber - 1;
m_config->fmsSlider->setValue(pos);
ui->fmsSlider->setValue(pos);
}
void ConfigInputWidget::updatePositionSlider()
@ -1328,22 +1336,22 @@ void ConfigInputWidget::updatePositionSlider()
switch(manualSettingsDataPriv.FlightModeNumber) {
default:
case 6:
m_config->fmsModePos6->setEnabled(true);
ui->fmsModePos6->setEnabled(true);
// pass through
case 5:
m_config->fmsModePos5->setEnabled(true);
ui->fmsModePos5->setEnabled(true);
// pass through
case 4:
m_config->fmsModePos4->setEnabled(true);
ui->fmsModePos4->setEnabled(true);
// pass through
case 3:
m_config->fmsModePos3->setEnabled(true);
ui->fmsModePos3->setEnabled(true);
// pass through
case 2:
m_config->fmsModePos2->setEnabled(true);
ui->fmsModePos2->setEnabled(true);
// pass through
case 1:
m_config->fmsModePos1->setEnabled(true);
ui->fmsModePos1->setEnabled(true);
// pass through
case 0:
break;
@ -1351,22 +1359,22 @@ void ConfigInputWidget::updatePositionSlider()
switch(manualSettingsDataPriv.FlightModeNumber) {
case 0:
m_config->fmsModePos1->setEnabled(false);
ui->fmsModePos1->setEnabled(false);
// pass through
case 1:
m_config->fmsModePos2->setEnabled(false);
ui->fmsModePos2->setEnabled(false);
// pass through
case 2:
m_config->fmsModePos3->setEnabled(false);
ui->fmsModePos3->setEnabled(false);
// pass through
case 3:
m_config->fmsModePos4->setEnabled(false);
ui->fmsModePos4->setEnabled(false);
// pass through
case 4:
m_config->fmsModePos5->setEnabled(false);
ui->fmsModePos5->setEnabled(false);
// pass through
case 5:
m_config->fmsModePos6->setEnabled(false);
ui->fmsModePos6->setEnabled(false);
// pass through
case 6:
default:
@ -1395,7 +1403,7 @@ void ConfigInputWidget::updateCalibration()
void ConfigInputWidget::simpleCalibration(bool enable)
{
if (enable) {
m_config->configurationWizard->setEnabled(false);
ui->configurationWizard->setEnabled(false);
QMessageBox msgBox;
msgBox.setText(tr("Arming Settings are now set to 'Always Disarmed' for your safety."));
@ -1421,7 +1429,7 @@ void ConfigInputWidget::simpleCalibration(bool enable)
connect(manualCommandObj, SIGNAL(objectUnpacked(UAVObject*)), this, SLOT(updateCalibration()));
} else {
m_config->configurationWizard->setEnabled(true);
ui->configurationWizard->setEnabled(true);
manualCommandData = manualCommandObj->getData();
manualSettingsData = manualSettingsObj->getData();

View File

@ -61,6 +61,7 @@ public:
enum txMovementType{vertical,horizontal,jump,mix};
enum txType {acro, heli};
void startInputWizard() { goToWizard(); }
void enableControls(bool enable);
private:
bool growing;
@ -68,7 +69,7 @@ private:
txMovements currentMovement;
int movePos;
void setTxMovement(txMovements movement);
Ui_InputWidget *m_config;
Ui_InputWidget *ui;
wizardSteps wizardStep;
QList<QPointer<QWidget> > extraWidgets;
txMode transmitterMode;
@ -166,7 +167,6 @@ private slots:
protected:
void resizeEvent(QResizeEvent *event);
virtual void enableControls(bool enable);
};
#endif

View File

@ -51,46 +51,51 @@
ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(parent),wasItMe(false)
{
m_config = new Ui_OutputWidget();
m_config->setupUi(this);
ui = new Ui_OutputWidget();
ui->setupUi(this);
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
Core::Internal::GeneralSettings *settings = pm->getObject<Core::Internal::GeneralSettings>();
if(!settings->useExpertMode()) {
m_config->saveRCOutputToRAM->setVisible(false);
ui->saveRCOutputToRAM->setVisible(false);
}
UAVSettingsImportExportFactory *importexportplugin = pm->getObject<UAVSettingsImportExportFactory>();
connect(importexportplugin, SIGNAL(importAboutToBegin()), this, SLOT(stopTests()));
// NOTE: we have channel indices from 0 to 9, but the convention for OP is Channel 1 to Channel 10.
// Register for ActuatorSettings changes:
for (unsigned int i = 0; i < ActuatorCommand::CHANNEL_NUMELEM; i++) {
OutputChannelForm *form = new OutputChannelForm(i, this, i == 0);
connect(m_config->channelOutTest, SIGNAL(toggled(bool)), form, SLOT(enableChannelTest(bool)));
connect(form, SIGNAL(channelChanged(int,int)), this, SLOT(sendChannelTest(int,int)));
m_config->channelLayout->addWidget(form);
}
connect(m_config->channelOutTest, SIGNAL(toggled(bool)), this, SLOT(runChannelTests(bool)));
connect(ui->channelOutTest, SIGNAL(toggled(bool)), this, SLOT(runChannelTests(bool)));
// Configure the task widget
// Connect the help button
connect(m_config->outputHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
connect(ui->outputHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
addApplySaveButtons(m_config->saveRCOutputToRAM,m_config->saveRCOutputToSD);
addApplySaveButtons(ui->saveRCOutputToRAM, ui->saveRCOutputToSD);
// Track the ActuatorSettings object
addUAVObject("ActuatorSettings");
// NOTE: we have channel indices from 0 to 9, but the convention for OP is Channel 1 to Channel 10.
// Register for ActuatorSettings changes:
for (unsigned int i = 0; i < ActuatorCommand::CHANNEL_NUMELEM; i++) {
OutputChannelForm *form = new OutputChannelForm(i, this, i == 0);
connect(ui->channelOutTest, SIGNAL(toggled(bool)), form, SLOT(enableChannelTest(bool)));
connect(form, SIGNAL(channelChanged(int,int)), this, SLOT(sendChannelTest(int,int)));
ui->channelLayout->addWidget(form);
addWidget(form->ui.actuatorMin);
addWidget(form->ui.actuatorNeutral);
addWidget(form->ui.actuatorMax);
addWidget(form->ui.actuatorRev);
addWidget(form->ui.actuatorLink);
}
// Associate the buttons with their UAVO fields
addWidget(m_config->cb_outputRate6);
addWidget(m_config->cb_outputRate5);
addWidget(m_config->cb_outputRate4);
addWidget(m_config->cb_outputRate3);
addWidget(m_config->cb_outputRate2);
addWidget(m_config->cb_outputRate1);
addWidget(m_config->spinningArmed);
addWidget(ui->cb_outputRate6);
addWidget(ui->cb_outputRate5);
addWidget(ui->cb_outputRate4);
addWidget(ui->cb_outputRate3);
addWidget(ui->cb_outputRate2);
addWidget(ui->cb_outputRate1);
addWidget(ui->spinningArmed);
disconnect(this, SLOT(refreshWidgetsValues(UAVObject*)));
@ -102,15 +107,16 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren
connect(obj,SIGNAL(objectUpdated(UAVObject*)), this, SLOT(disableIfNotMe(UAVObject*)));
refreshWidgetsValues();
updateEnableControls();
}
void ConfigOutputWidget::enableControls(bool enable)
{
ConfigTaskWidget::enableControls(enable);
if(!enable) {
m_config->channelOutTest->setChecked(false);
ui->channelOutTest->setChecked(false);
}
m_config->channelOutTest->setEnabled(enable);
ui->channelOutTest->setEnabled(enable);
}
ConfigOutputWidget::~ConfigOutputWidget()
@ -136,7 +142,7 @@ void ConfigOutputWidget::runChannelTests(bool state)
// Unfortunately must cache this since callback will reoccur
accInitialData = ActuatorCommand::GetInstance(getObjectManager())->getMetadata();
m_config->channelOutTest->setChecked(false);
ui->channelOutTest->setChecked(false);
return;
}
@ -149,7 +155,7 @@ void ConfigOutputWidget::runChannelTests(bool state)
if(retval != QMessageBox::Yes) {
state = false;
qDebug() << "Cancelled";
m_config->channelOutTest->setChecked(false);
ui->channelOutTest->setChecked(false);
return;
}
}
@ -209,7 +215,7 @@ void ConfigOutputWidget::assignOutputChannel(UAVDataObject *obj, QString str)
*/
void ConfigOutputWidget::sendChannelTest(int index, int value)
{
if (!m_config->channelOutTest->isChecked()) {
if (!ui->channelOutTest->isChecked()) {
return;
}
@ -260,47 +266,47 @@ void ConfigOutputWidget::refreshWidgetsValues(UAVObject * obj)
}
// Get the SpinWhileArmed setting
m_config->spinningArmed->setChecked(actuatorSettingsData.MotorsSpinWhileArmed == ActuatorSettings::MOTORSSPINWHILEARMED_TRUE);
ui->spinningArmed->setChecked(actuatorSettingsData.MotorsSpinWhileArmed == ActuatorSettings::MOTORSSPINWHILEARMED_TRUE);
// Setup output rates for all banks
if(m_config->cb_outputRate1->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[0])) == -1) {
m_config->cb_outputRate1->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[0]));
if(ui->cb_outputRate1->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[0])) == -1) {
ui->cb_outputRate1->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[0]));
}
if(m_config->cb_outputRate2->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[1])) == -1) {
m_config->cb_outputRate2->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[1]));
if(ui->cb_outputRate2->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[1])) == -1) {
ui->cb_outputRate2->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[1]));
}
if(m_config->cb_outputRate3->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[2]) )== -1) {
m_config->cb_outputRate3->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[2]));
if(ui->cb_outputRate3->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[2]) )== -1) {
ui->cb_outputRate3->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[2]));
}
if(m_config->cb_outputRate4->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[3])) == -1) {
m_config->cb_outputRate4->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[3]));
if(ui->cb_outputRate4->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[3])) == -1) {
ui->cb_outputRate4->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[3]));
}
if(m_config->cb_outputRate5->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[4])) == -1) {
m_config->cb_outputRate5->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[4]));
if(ui->cb_outputRate5->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[4])) == -1) {
ui->cb_outputRate5->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[4]));
}
if(m_config->cb_outputRate6->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[5])) == -1) {
m_config->cb_outputRate6->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[5]));
if(ui->cb_outputRate6->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[5])) == -1) {
ui->cb_outputRate6->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[5]));
}
m_config->cb_outputRate1->setCurrentIndex(m_config->cb_outputRate1->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[0])));
m_config->cb_outputRate2->setCurrentIndex(m_config->cb_outputRate2->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[1])));
m_config->cb_outputRate3->setCurrentIndex(m_config->cb_outputRate3->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[2])));
m_config->cb_outputRate4->setCurrentIndex(m_config->cb_outputRate4->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[3])));
m_config->cb_outputRate5->setCurrentIndex(m_config->cb_outputRate5->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[4])));
m_config->cb_outputRate6->setCurrentIndex(m_config->cb_outputRate6->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[5])));
ui->cb_outputRate1->setCurrentIndex(ui->cb_outputRate1->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[0])));
ui->cb_outputRate2->setCurrentIndex(ui->cb_outputRate2->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[1])));
ui->cb_outputRate3->setCurrentIndex(ui->cb_outputRate3->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[2])));
ui->cb_outputRate4->setCurrentIndex(ui->cb_outputRate4->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[3])));
ui->cb_outputRate5->setCurrentIndex(ui->cb_outputRate5->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[4])));
ui->cb_outputRate6->setCurrentIndex(ui->cb_outputRate6->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[5])));
// Reset to all disabled
m_config->chBank1->setText("-");
m_config->chBank2->setText("-");
m_config->chBank3->setText("-");
m_config->chBank4->setText("-");
m_config->chBank5->setText("-");
m_config->chBank6->setText("-");
m_config->cb_outputRate1->setEnabled(false);
m_config->cb_outputRate2->setEnabled(false);
m_config->cb_outputRate3->setEnabled(false);
m_config->cb_outputRate4->setEnabled(false);
m_config->cb_outputRate5->setEnabled(false);
m_config->cb_outputRate6->setEnabled(false);
ui->chBank1->setText("-");
ui->chBank2->setText("-");
ui->chBank3->setText("-");
ui->chBank4->setText("-");
ui->chBank5->setText("-");
ui->chBank6->setText("-");
ui->cb_outputRate1->setEnabled(false);
ui->cb_outputRate2->setEnabled(false);
ui->cb_outputRate3->setEnabled(false);
ui->cb_outputRate4->setEnabled(false);
ui->cb_outputRate5->setEnabled(false);
ui->cb_outputRate6->setEnabled(false);
// Get connected board model
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
@ -313,29 +319,29 @@ void ConfigOutputWidget::refreshWidgetsValues(UAVObject * obj)
// Setup labels and combos for banks according to board type
if ((board & 0xff00) == 0x0400) {
// Coptercontrol family of boards 4 timer banks
m_config->chBank1->setText("1-3");
m_config->chBank2->setText("4");
m_config->chBank3->setText("5,7-8");
m_config->chBank4->setText("6,9-10");
m_config->cb_outputRate1->setEnabled(true);
m_config->cb_outputRate2->setEnabled(true);
m_config->cb_outputRate3->setEnabled(true);
m_config->cb_outputRate4->setEnabled(true);
ui->chBank1->setText("1-3");
ui->chBank2->setText("4");
ui->chBank3->setText("5,7-8");
ui->chBank4->setText("6,9-10");
ui->cb_outputRate1->setEnabled(true);
ui->cb_outputRate2->setEnabled(true);
ui->cb_outputRate3->setEnabled(true);
ui->cb_outputRate4->setEnabled(true);
}
else if((board & 0xff00) == 0x0900) {
// Revolution family of boards 6 timer banks
m_config->chBank1->setText("1-2");
m_config->chBank2->setText("3");
m_config->chBank3->setText("4");
m_config->chBank4->setText("5-6");
m_config->chBank5->setText("7-8");
m_config->chBank6->setText("9-10");
m_config->cb_outputRate1->setEnabled(true);
m_config->cb_outputRate2->setEnabled(true);
m_config->cb_outputRate3->setEnabled(true);
m_config->cb_outputRate4->setEnabled(true);
m_config->cb_outputRate5->setEnabled(true);
m_config->cb_outputRate6->setEnabled(true);
ui->chBank1->setText("1-2");
ui->chBank2->setText("3");
ui->chBank3->setText("4");
ui->chBank4->setText("5-6");
ui->chBank5->setText("7-8");
ui->chBank6->setText("9-10");
ui->cb_outputRate1->setEnabled(true);
ui->cb_outputRate2->setEnabled(true);
ui->cb_outputRate3->setEnabled(true);
ui->cb_outputRate4->setEnabled(true);
ui->cb_outputRate5->setEnabled(true);
ui->cb_outputRate6->setEnabled(true);
}
}
@ -371,14 +377,14 @@ void ConfigOutputWidget::updateObjectsFromWidgets()
}
// Set update rates
actuatorSettingsData.ChannelUpdateFreq[0] = m_config->cb_outputRate1->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[1] = m_config->cb_outputRate2->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[2] = m_config->cb_outputRate3->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[3] = m_config->cb_outputRate4->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[4] = m_config->cb_outputRate5->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[5] = m_config->cb_outputRate6->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[0] = ui->cb_outputRate1->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[1] = ui->cb_outputRate2->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[2] = ui->cb_outputRate3->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[3] = ui->cb_outputRate4->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[4] = ui->cb_outputRate5->currentText().toUInt();
actuatorSettingsData.ChannelUpdateFreq[5] = ui->cb_outputRate6->currentText().toUInt();
actuatorSettingsData.MotorsSpinWhileArmed = m_config->spinningArmed->isChecked() ?
actuatorSettingsData.MotorsSpinWhileArmed = ui->spinningArmed->isChecked() ?
ActuatorSettings::MOTORSSPINWHILEARMED_TRUE :
ActuatorSettings::MOTORSSPINWHILEARMED_FALSE;
@ -394,7 +400,7 @@ void ConfigOutputWidget::openHelp()
void ConfigOutputWidget::stopTests()
{
m_config->channelOutTest->setChecked(false);
ui->channelOutTest->setChecked(false);
}
void ConfigOutputWidget::disableIfNotMe(UAVObject* obj)

View File

@ -50,7 +50,7 @@ public:
private:
Ui_OutputWidget *m_config;
Ui_OutputWidget *ui;
QList<QSlider> sliders;

View File

@ -41,35 +41,53 @@
ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTaskWidget(parent)
{
m_stabilization = new Ui_StabilizationWidget();
m_stabilization->setupUi(this);
ui = new Ui_StabilizationWidget();
ui->setupUi(this);
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
Core::Internal::GeneralSettings* settings = pm->getObject<Core::Internal::GeneralSettings>();
if(!settings->useExpertMode()) {
m_stabilization->saveStabilizationToRAM_6->setVisible(false);
ui->saveStabilizationToRAM_6->setVisible(false);
}
autoLoadWidgets();
realtimeUpdates = new QTimer(this);
connect(m_stabilization->realTimeUpdates_6, SIGNAL(stateChanged(int)), this, SLOT(realtimeUpdatesSlot(int)));
connect(m_stabilization->realTimeUpdates_8, SIGNAL(stateChanged(int)), this, SLOT(realtimeUpdatesSlot(int)));
realtimeUpdates = new QTimer(this);
connect(realtimeUpdates, SIGNAL(timeout()), this, SLOT(apply()));
connect(m_stabilization->checkBox_7, SIGNAL(stateChanged(int)), this, SLOT(linkCheckBoxes(int)));
connect(m_stabilization->checkBox_2, SIGNAL(stateChanged(int)), this, SLOT(linkCheckBoxes(int)));
connect(m_stabilization->checkBox_8, SIGNAL(stateChanged(int)), this, SLOT(linkCheckBoxes(int)));
connect(m_stabilization->checkBox_3, SIGNAL(stateChanged(int)), this, SLOT(linkCheckBoxes(int)));
connect(ui->realTimeUpdates_6, SIGNAL(stateChanged(int)), this, SLOT(realtimeUpdatesSlot(int)));
addWidget(ui->realTimeUpdates_6);
connect(ui->realTimeUpdates_8, SIGNAL(stateChanged(int)), this, SLOT(realtimeUpdatesSlot(int)));
addWidget(ui->realTimeUpdates_8);
connect(ui->checkBox_7, SIGNAL(stateChanged(int)), this, SLOT(linkCheckBoxes(int)));
addWidget(ui->checkBox_7);
connect(ui->checkBox_2, SIGNAL(stateChanged(int)), this, SLOT(linkCheckBoxes(int)));
addWidget(ui->checkBox_2);
connect(ui->checkBox_8, SIGNAL(stateChanged(int)), this, SLOT(linkCheckBoxes(int)));
addWidget(ui->checkBox_8);
connect(ui->checkBox_3, SIGNAL(stateChanged(int)), this, SLOT(linkCheckBoxes(int)));
addWidget(ui->checkBox_3);
addWidget(ui->pushButton_2);
addWidget(ui->pushButton_3);
addWidget(ui->pushButton_4);
addWidget(ui->pushButton_5);
addWidget(ui->pushButton_6);
addWidget(ui->pushButton_9);
addWidget(ui->pushButton_20);
addWidget(ui->pushButton_22);
addWidget(ui->pushButton_23);
connect(this, SIGNAL(widgetContentsChanged(QWidget*)), this, SLOT(processLinkedWidgets(QWidget*)));
// Link by default
m_stabilization->checkBox_7->setChecked(true);
m_stabilization->checkBox_8->setChecked(true);
ui->checkBox_7->setChecked(true);
ui->checkBox_8->setChecked(true);
disableMouseWheelEvents();
updateEnableControls();
}
ConfigStabilizationWidget::~ConfigStabilizationWidget()
@ -79,8 +97,8 @@ ConfigStabilizationWidget::~ConfigStabilizationWidget()
void ConfigStabilizationWidget::realtimeUpdatesSlot(int value)
{
m_stabilization->realTimeUpdates_6->setCheckState((Qt::CheckState)value);
m_stabilization->realTimeUpdates_8->setCheckState((Qt::CheckState)value);
ui->realTimeUpdates_6->setCheckState((Qt::CheckState)value);
ui->realTimeUpdates_8->setCheckState((Qt::CheckState)value);
if(value == Qt::Checked && !realtimeUpdates->isActive()) {
realtimeUpdates->start(300);
@ -92,84 +110,85 @@ void ConfigStabilizationWidget::realtimeUpdatesSlot(int value)
void ConfigStabilizationWidget::linkCheckBoxes(int value)
{
if(sender() == m_stabilization->checkBox_7) {
m_stabilization->checkBox_3->setCheckState((Qt::CheckState)value);
if(sender() == ui->checkBox_7) {
ui->checkBox_3->setCheckState((Qt::CheckState)value);
}
else if(sender() == m_stabilization->checkBox_3) {
m_stabilization->checkBox_7->setCheckState((Qt::CheckState)value);
else if(sender() == ui->checkBox_3) {
ui->checkBox_7->setCheckState((Qt::CheckState)value);
}
else if(sender( )== m_stabilization->checkBox_8) {
m_stabilization->checkBox_2->setCheckState((Qt::CheckState)value);
else if(sender( )== ui->checkBox_8) {
ui->checkBox_2->setCheckState((Qt::CheckState)value);
}
else if(sender() == m_stabilization->checkBox_2) {
m_stabilization->checkBox_8->setCheckState((Qt::CheckState)value);
else if(sender() == ui->checkBox_2) {
ui->checkBox_8->setCheckState((Qt::CheckState)value);
}
}
void ConfigStabilizationWidget::processLinkedWidgets(QWidget * widget)
{
if(m_stabilization->checkBox_7->checkState()==Qt::Checked)
if(ui->checkBox_7->checkState()==Qt::Checked)
{
if(widget== m_stabilization->RateRollKp_2)
if(widget== ui->RateRollKp_2)
{
m_stabilization->RatePitchKp->setValue(m_stabilization->RateRollKp_2->value());
ui->RatePitchKp->setValue(ui->RateRollKp_2->value());
}
else if(widget== m_stabilization->RateRollKi_2)
else if(widget== ui->RateRollKi_2)
{
m_stabilization->RatePitchKi->setValue(m_stabilization->RateRollKi_2->value());
ui->RatePitchKi->setValue(ui->RateRollKi_2->value());
}
else if(widget== m_stabilization->RateRollILimit_2)
else if(widget== ui->RateRollILimit_2)
{
m_stabilization->RatePitchILimit->setValue(m_stabilization->RateRollILimit_2->value());
ui->RatePitchILimit->setValue(ui->RateRollILimit_2->value());
}
else if(widget== m_stabilization->RatePitchKp)
else if(widget== ui->RatePitchKp)
{
m_stabilization->RateRollKp_2->setValue(m_stabilization->RatePitchKp->value());
ui->RateRollKp_2->setValue(ui->RatePitchKp->value());
}
else if(widget== m_stabilization->RatePitchKi)
else if(widget== ui->RatePitchKi)
{
m_stabilization->RateRollKi_2->setValue(m_stabilization->RatePitchKi->value());
ui->RateRollKi_2->setValue(ui->RatePitchKi->value());
}
else if(widget== m_stabilization->RatePitchILimit)
else if(widget== ui->RatePitchILimit)
{
m_stabilization->RateRollILimit_2->setValue(m_stabilization->RatePitchILimit->value());
ui->RateRollILimit_2->setValue(ui->RatePitchILimit->value());
}
else if(widget== m_stabilization->RollRateKd)
else if(widget== ui->RollRateKd)
{
m_stabilization->PitchRateKd->setValue(m_stabilization->RollRateKd->value());
ui->PitchRateKd->setValue(ui->RollRateKd->value());
}
else if(widget== m_stabilization->PitchRateKd)
else if(widget== ui->PitchRateKd)
{
m_stabilization->RollRateKd->setValue(m_stabilization->PitchRateKd->value());
ui->RollRateKd->setValue(ui->PitchRateKd->value());
}
}
if(m_stabilization->checkBox_8->checkState()==Qt::Checked)
if(ui->checkBox_8->checkState()==Qt::Checked)
{
if(widget== m_stabilization->AttitudeRollKp)
if(widget== ui->AttitudeRollKp)
{
m_stabilization->AttitudePitchKp_2->setValue(m_stabilization->AttitudeRollKp->value());
ui->AttitudePitchKp_2->setValue(ui->AttitudeRollKp->value());
}
else if(widget== m_stabilization->AttitudeRollKi)
else if(widget== ui->AttitudeRollKi)
{
m_stabilization->AttitudePitchKi_2->setValue(m_stabilization->AttitudeRollKi->value());
ui->AttitudePitchKi_2->setValue(ui->AttitudeRollKi->value());
}
else if(widget== m_stabilization->AttitudeRollILimit)
else if(widget== ui->AttitudeRollILimit)
{
m_stabilization->AttitudePitchILimit_2->setValue(m_stabilization->AttitudeRollILimit->value());
ui->AttitudePitchILimit_2->setValue(ui->AttitudeRollILimit->value());
}
else if(widget== m_stabilization->AttitudePitchKp_2)
else if(widget== ui->AttitudePitchKp_2)
{
m_stabilization->AttitudeRollKp->setValue(m_stabilization->AttitudePitchKp_2->value());
ui->AttitudeRollKp->setValue(ui->AttitudePitchKp_2->value());
}
else if(widget== m_stabilization->AttitudePitchKi_2)
else if(widget== ui->AttitudePitchKi_2)
{
m_stabilization->AttitudeRollKi->setValue(m_stabilization->AttitudePitchKi_2->value());
ui->AttitudeRollKi->setValue(ui->AttitudePitchKi_2->value());
}
else if(widget== m_stabilization->AttitudePitchILimit_2)
else if(widget== ui->AttitudePitchILimit_2)
{
m_stabilization->AttitudeRollILimit->setValue(m_stabilization->AttitudePitchILimit_2->value());
ui->AttitudeRollILimit->setValue(ui->AttitudePitchILimit_2->value());
}
}
}

View File

@ -46,7 +46,7 @@ public:
~ConfigStabilizationWidget();
private:
Ui_StabilizationWidget *m_stabilization;
Ui_StabilizationWidget *ui;
QTimer * realtimeUpdates;
private slots:
void realtimeUpdatesSlot(int);

View File

@ -109,8 +109,29 @@ void ConfigTxPIDWidget::saveSettings()
saveObjectToSD(obj);
}
void ConfigTxPIDWidget::enableControls(bool enable)
{
/*
m_txpid->PID1->setEnabled(enable);
m_txpid->PID2->setEnabled(enable);
m_txpid->PID3->setEnabled(enable);
/**
@}
@}
*/
m_txpid->Input1->setEnabled(enable);
m_txpid->Input2->setEnabled(enable);
m_txpid->Input3->setEnabled(enable);
m_txpid->MinPID1->setEnabled(enable);
m_txpid->MinPID2->setEnabled(enable);
m_txpid->MinPID3->setEnabled(enable);
m_txpid->MaxPID1->setEnabled(enable);
m_txpid->MaxPID2->setEnabled(enable);
m_txpid->MaxPID3->setEnabled(enable);
m_txpid->ThrottleMin->setEnabled(enable);
m_txpid->ThrottleMax->setEnabled(enable);
m_txpid->UpdateMode->setEnabled(enable);
*/
ConfigTaskWidget::setEnabled(enable);
}

View File

@ -44,6 +44,7 @@ private slots:
void refreshValues();
void applySettings();
void saveSettings();
void enableControls(bool enable);
};
#endif // CONFIGTXPIDWIDGET_H

View File

@ -138,8 +138,6 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
// Connect the help pushbutton
connect(m_aircraft->airframeHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
enableControls(false);
refreshWidgetsValues();
// register widgets for dirty state management
@ -150,8 +148,12 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
addWidget(m_aircraft->accelTime);
addWidget(m_aircraft->decelTime);
addWidget(m_aircraft->maxAccelSlider);
addWidget(m_aircraft->ffTestBox1);
addWidget(m_aircraft->ffTestBox2);
addWidget(m_aircraft->ffTestBox3);
disableMouseWheelEvents();
updateEnableControls();
}
/**

View File

@ -29,11 +29,11 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Attitude / INS calibration&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;This panel will be updated to provide the relevant controls to let you calibrate your OpenPilot INS or your CopterControl unit, depending on the board which is detected once telemetry is connected and running.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:600;&quot;&gt;Attitude Calibration&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt; font-weight:600;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:11pt;&quot;&gt;This panel will be updated to provide the relevant controls to let you calibrate your OpenPilot unit, depending on the board which is detected once telemetry is connected and running.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>

View File

@ -43,10 +43,6 @@ MixerCurve::MixerCurve(QWidget *parent) :
m_mixerUI->SettingsGroup->hide();
m_curve->showCommands(false);
m_curve->showCommand("Reset", false);
m_curve->showCommand("Popup", false);
m_curve->showCommand("Commands", false);
// create our spin delegate
m_spinDelegate = new DoubleSpinDelegate();
@ -54,27 +50,19 @@ MixerCurve::MixerCurve(QWidget *parent) :
// set the default mixer type
setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
// setup and turn off advanced mode
CommandActivated();
// paint the ui
UpdateCurveUI();
// wire up our signals
connect(m_mixerUI->CurveType, SIGNAL(currentIndexChanged(int)), this, SLOT(CurveTypeChanged()));
connect(m_mixerUI->ResetCurve, SIGNAL(clicked()), this, SLOT(ResetCurve()));
connect(m_mixerUI->PopupCurve, SIGNAL(clicked()),this,SLOT(PopupCurve()));
connect(m_mixerUI->GenerateCurve, SIGNAL(clicked()), this, SLOT(GenerateCurve()));
connect(m_curve, SIGNAL(curveUpdated()), this, SLOT(UpdateSettingsTable()));
connect(m_curve, SIGNAL(commandActivated(MixerNode*)),this, SLOT(CommandActivated(MixerNode*)));
connect(m_settings, SIGNAL(cellChanged(int,int)), this, SLOT(SettingsTableChanged()));
connect(m_mixerUI->CurveMin, SIGNAL(valueChanged(double)), this, SLOT(CurveMinChanged(double)));
connect(m_mixerUI->CurveMax, SIGNAL(valueChanged(double)), this, SLOT(CurveMaxChanged(double)));
connect(m_mixerUI->CurveStep, SIGNAL(valueChanged(double)), this, SLOT(GenerateCurve()));
}
MixerCurve::~MixerCurve()
@ -103,7 +91,6 @@ void MixerCurve::setMixerType(MixerCurveType curveType)
{
m_mixerUI->SettingsGroup->setTitle("Pitch Curve");
m_curve->setRange(-1.0, 1.0);
m_curve->setPositiveColor("#0000aa", "#0000aa");
m_mixerUI->CurveMin->setMinimum(-1.0);
m_mixerUI->CurveMax->setMinimum(-1.0);
break;
@ -126,37 +113,26 @@ void MixerCurve::ResetCurve()
initLinearCurve(MixerCurveWidget::NODE_NUMELEM, getCurveMax(), getCurveMin());
m_curve->activateCommand("Linear");
UpdateSettingsTable();
}
void MixerCurve::PopupCurve()
{
if (!m_curve->isCommandActive("Popup")) {
m_mixerUI->SettingsGroup->show();
m_mixerUI->PopupCurve->hide();
m_mixerUI->SettingsGroup->show();
m_mixerUI->PopupCurve->hide();
PopupWidget* popup = new PopupWidget();
popup->popUp(this);
PopupWidget* popup = new PopupWidget();
popup->popUp(this);
m_mixerUI->SettingsGroup->hide();
m_mixerUI->PopupCurve->show();
m_curve->showCommands(false);
}
m_mixerUI->SettingsGroup->hide();
m_mixerUI->PopupCurve->show();
}
void MixerCurve::UpdateCurveUI()
{
//get the user settings
QString curveType = m_mixerUI->CurveType->currentText();
m_curve->activateCommand(curveType);
bool cmdsActive = m_curve->isCommandActive("Commands");
m_curve->showCommand("StepPlus", cmdsActive && curveType != "Linear");
m_curve->showCommand("StepMinus", cmdsActive && curveType != "Linear");
m_curve->showCommand("StepValue", cmdsActive && curveType != "Linear");
m_mixerUI->CurveStep->setMinimum(0.0);
m_mixerUI->CurveStep->setMaximum(100.0);
@ -229,8 +205,6 @@ void MixerCurve::GenerateCurve()
double value2 = getCurveMax();
double value3 = getCurveStep();
m_curve->setCommandText("StepValue", QString("%0").arg(value3));
QString CurveType = m_mixerUI->CurveType->currentText();
QList<double> points;
@ -282,10 +256,12 @@ void MixerCurve::initCurve (const QList<double>* points)
m_curve->setCurve(points);
UpdateSettingsTable();
}
QList<double> MixerCurve::getCurve()
{
return m_curve->getCurve();
}
void MixerCurve::initLinearCurve(int numPoints, double maxValue, double minValue)
{
setMin(minValue);
@ -296,39 +272,45 @@ void MixerCurve::initLinearCurve(int numPoints, double maxValue, double minValue
if (m_spinDelegate)
m_spinDelegate->setRange(minValue, maxValue);
}
void MixerCurve::setCurve(const QList<double>* points)
{
m_curve->setCurve(points);
UpdateSettingsTable();
}
void MixerCurve::setMin(double value)
{
//m_curve->setMin(value);
m_mixerUI->CurveMin->setMinimum(value);
}
double MixerCurve::getMin()
{
return m_curve->getMin();
}
void MixerCurve::setMax(double value)
{
//m_curve->setMax(value);
m_mixerUI->CurveMax->setMaximum(value);
}
double MixerCurve::getMax()
{
return m_curve->getMax();
}
double MixerCurve::setRange(double min, double max)
{
return m_curve->setRange(min, max);
}
double MixerCurve::getCurveMin()
{
return m_mixerUI->CurveMin->value();
}
double MixerCurve::getCurveMax()
{
return m_mixerUI->CurveMax->value();
@ -370,59 +352,6 @@ void MixerCurve::SettingsTableChanged()
m_curve->setCurve(&points);
}
void MixerCurve::CommandActivated(MixerNode* node)
{
QString name = (node) ? node->getName() : "Reset";
if (name == "Reset") {
ResetCurve();
m_curve->showCommands(false);
}
else if (name == "Commands") {
}
else if (name == "Popup" ) {
PopupCurve();
}
else if (name == "Linear") {
m_mixerUI->CurveType->setCurrentIndex(m_mixerUI->CurveType->findText("Linear"));
}
else if (name == "Log") {
m_mixerUI->CurveType->setCurrentIndex(m_mixerUI->CurveType->findText("Log"));
}
else if (name == "Exp") {
m_mixerUI->CurveType->setCurrentIndex(m_mixerUI->CurveType->findText("Exp"));
}
else if (name == "Flat") {
m_mixerUI->CurveType->setCurrentIndex(m_mixerUI->CurveType->findText("Flat"));
}
else if (name == "Step") {
m_mixerUI->CurveType->setCurrentIndex(m_mixerUI->CurveType->findText("Step"));
}
else if (name == "MinPlus") {
m_mixerUI->CurveMin->stepUp();
}
else if (name == "MinMinus") {
m_mixerUI->CurveMin->stepDown();
}
else if (name == "MaxPlus") {
m_mixerUI->CurveMax->stepUp();
}
else if (name == "MaxMinus"){
m_mixerUI->CurveMax->stepDown();
}
else if (name == "StepPlus") {
m_mixerUI->CurveStep->stepUp();
m_curve->setCommandText("StepValue", QString("%0").arg(getCurveStep()));
}
else if (name == "StepMinus") {
m_mixerUI->CurveStep->stepDown();
m_curve->setCommandText("StepValue", QString("%0").arg(getCurveStep()));
}
GenerateCurve();
}
void MixerCurve::CurveTypeChanged()
{
// setup the ui for this curvetype

View File

@ -84,7 +84,6 @@ public slots:
void UpdateSettingsTable();
private slots:
void CommandActivated(MixerNode* node = 0);
void SettingsTableChanged();
void CurveTypeChanged();
void CurveMinChanged(double value);

View File

@ -38,7 +38,7 @@ class OutputChannelForm : public ConfigTaskWidget
public:
explicit OutputChannelForm(const int index, QWidget *parent = NULL, const bool showLegend = false);
~OutputChannelForm();
friend class ConfigOnputWidget;
friend class ConfigOutputWidget;
void setAssignment(const QString &assignment);
int index() const;
@ -57,10 +57,10 @@ signals:
void channelChanged(int index, int value);
private:
Ui::outputChannelForm ui;
/// Channel index
int m_index;
bool m_inChannelTest;
Ui::outputChannelForm ui;
private slots:
void linkToggled(bool state);

View File

@ -429,12 +429,9 @@ void ConfigTaskWidget::addApplySaveButtons(QPushButton *update, QPushButton *sav
smartsave->addObject((UAVDataObject*)oTw->object);
}
}
TelemetryManager* telMngr = pm->getObject<TelemetryManager>();
if(telMngr->isConnected())
enableControls(true);
else
enableControls(false);
updateEnableControls();
}
/**
* SLOT function used the enable or disable the SAVE, UPLOAD and RELOAD buttons
* @param enable set to true to enable the buttons or false to disable them
@ -442,12 +439,24 @@ void ConfigTaskWidget::addApplySaveButtons(QPushButton *update, QPushButton *sav
*/
void ConfigTaskWidget::enableControls(bool enable)
{
if(smartsave)
if(smartsave) {
smartsave->enableControls(enable);
foreach (QPushButton * button, reloadButtonList) {
}
foreach (QPushButton *button, reloadButtonList) {
button->setEnabled(enable);
}
foreach(objectToWidget *ow,objOfInterest) {
if(ow->widget) {
ow->widget->setEnabled(enable);
foreach (shadow *sh, ow->shadowsList) {
sh->widget->setEnabled(enable);
}
}
}
}
/**
* SLOT function called when on of the widgets contents added to the framework changes
*/
@ -1310,6 +1319,13 @@ void ConfigTaskWidget::loadWidgetLimits(QWidget * widget,UAVObjectField * field,
}
}
void ConfigTaskWidget::updateEnableControls()
{
TelemetryManager* telMngr = pm->getObject<TelemetryManager>();
Q_ASSERT(telMngr);
enableControls(telMngr->isConnected());
}
void ConfigTaskWidget::disableMouseWheelEvents()
{
//Disable mouse wheel events

View File

@ -195,6 +195,7 @@ private:
void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double sclale);
QString outOfLimitsStyle;
QTimer * timeOut;
protected slots:
virtual void disableObjUpdates();
virtual void enableObjUpdates();
@ -207,6 +208,8 @@ protected slots:
protected:
virtual void enableControls(bool enable);
void checkWidgetsLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, QVariant value, double scale);
void updateEnableControls();
};
#endif // CONFIGTASKWIDGET_H

View File

@ -43,17 +43,15 @@ MixerNode::MixerNode(MixerCurveWidget *graphWidget)
setFlag(ItemSendsGeometryChanges);
setCacheMode(DeviceCoordinateCache);
setZValue(-1);
cmdActive = false;
vertical = false;
cmdNode = false;
cmdToggle = true;
drawNode = true;
drawText = true;
posColor0 = "#1c870b"; //greenish?
posColor1 = "#116703"; //greenish?
negColor0 = "#aa0000"; //red
negColor1 = "#aa0000"; //red
positiveColor = "#609FF2"; //blueish?
neutralColor = "#14CE24"; //greenish?
negativeColor = "#EF5F5F"; //redish?
disabledColor = "#dddddd";
disabledTextColor = "#aaaaaa";
}
void MixerNode::addEdge(Edge *edge)
@ -70,7 +68,7 @@ QList<Edge *> MixerNode::edges() const
QRectF MixerNode::boundingRect() const
{
return cmdNode ? QRectF(-4, -4, 15, 10) : QRectF(-13, -13, 26, 26);
return QRectF(-13, -13, 26, 26);
}
QPainterPath MixerNode::shape() const
@ -82,48 +80,50 @@ QPainterPath MixerNode::shape() const
void MixerNode::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
{
QString text = cmdNode ? cmdText : QString().sprintf("%.2f", value());
QString text = QString().sprintf("%.2f", value());
painter->setFont(graph->font());
if (drawNode) {
QRadialGradient gradient(-3, -3, 10);
QColor color;
if (value() < 0) {
color = negativeColor;
}
else if (value() == 0) {
color = neutralColor;
}
else {
color = positiveColor;
}
if (option->state & QStyle::State_Sunken) {
gradient.setCenter(3, 3);
gradient.setFocalPoint(3, 3);
gradient.setColorAt(1, Qt::darkBlue);
gradient.setColorAt(0, Qt::darkBlue);
QColor selColor = color.darker();
gradient.setColorAt(1, selColor.darker());
gradient.setColorAt(0, selColor);
} else {
if (cmdNode) {
gradient.setColorAt(0, cmdActive ? posColor0 : negColor0);
gradient.setColorAt(1, cmdActive ? posColor1 : negColor1);
}
else {
if (value() < 0) {
gradient.setColorAt(0, negColor0);
gradient.setColorAt(1, negColor1);
}
else {
gradient.setColorAt(0, posColor0);
gradient.setColorAt(1, posColor1);
}
}
gradient.setColorAt(0, graph->isEnabled() ? color : disabledColor);
gradient.setColorAt(1, graph->isEnabled() ? color.darker() : disabledColor);
}
painter->setBrush(gradient);
painter->setPen(QPen(Qt::black, 0));
painter->setPen(graph->isEnabled() ? QPen(Qt::black, 0) : QPen(disabledTextColor));
painter->drawEllipse(boundingRect());
if (!image.isNull())
painter->drawImage(boundingRect().adjusted(1,1,-1,-1), image);
if (!image.isNull()) {
painter->drawImage(boundingRect().adjusted(1, 1, -1, -1), image);
}
}
if (drawText) {
painter->setPen(QPen(drawNode ? Qt::white : Qt::black, 0));
if (cmdNode) {
painter->drawText(0,4,text);
}
else {
painter->drawText( (value() < 0) ? -13 : -11, 4, text);
if(graph->isEnabled()) {
painter->setPen(QPen(drawNode ? Qt::white : Qt::black, 0));
} else {
painter->setPen(QPen(disabledTextColor));
}
painter->drawText( (value() < 0) ? -10 : -8, 3, text);
}
}
@ -131,13 +131,6 @@ void MixerNode::verticalMove(bool flag){
vertical = flag;
}
void MixerNode::commandNode(bool enable){
cmdNode = enable;
}
void MixerNode::commandText(QString text){
cmdText = text;
}
double MixerNode::value() {
double h = graph->sceneRect().height();
double ratio = (h - pos().y()) / h;
@ -186,10 +179,6 @@ QVariant MixerNode::itemChange(GraphicsItemChange change, const QVariant &val)
void MixerNode::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (cmdNode) {
graph->cmdActivated(this);
//return;
}
update();
QGraphicsItem::mousePressEvent(event);
}

View File

@ -50,22 +50,10 @@ public:
enum { Type = UserType + 10 };
int type() const { return Type; }
void setName(QString name) { cmdName = name; }
const QString& getName() { return cmdName; }
void verticalMove(bool flag);
void commandNode(bool enable);
void commandText(QString text);
int getCommandIndex() { return index; }
void setCommandIndex(int idx) { index = idx; }
bool getCommandActive() { return cmdActive; }
void setCommandActive(bool enable) { cmdActive = enable; }
void setToggle(bool enable) { cmdToggle = enable; }
bool getToggle() { return cmdToggle; }
void setPositiveColor(QString color0 = "#00ff00", QString color1 = "#00ff00") { posColor0 = color0; posColor1 = color1; }
void setNegativeColor(QString color0 = "#ff0000", QString color1 = "#ff0000") { negColor0 = color0; negColor1 = color1; }
void setPositiveColor(QColor color = "#609FF2") {positiveColor = color; }
void setNegativeColor(QColor color = "#EF5F5F") {negativeColor = color; }
void setImage(QImage img) { image = img; }
void setDrawNode(bool draw) { drawNode = draw; }
void setDrawText(bool draw) { drawText = draw; }
@ -76,9 +64,6 @@ public:
double value();
signals:
void commandActivated(QString text);
protected:
QVariant itemChange(GraphicsItemChange change, const QVariant &val);
@ -89,18 +74,16 @@ private:
QList<Edge *> edgeList;
QPointF newPos;
MixerCurveWidget* graph;
QString posColor0;
QString posColor1;
QString negColor0;
QString negColor1;
QColor positiveColor;
QColor neutralColor;
QColor negativeColor;
QColor disabledColor;
QColor disabledTextColor;
QImage image;
bool vertical;
QString cmdName;
bool cmdActive;
bool cmdNode;
bool cmdToggle;
QString cmdText;
bool drawNode;
bool drawText;
int index;

View File

@ -66,286 +66,42 @@ MixerCurveWidget::MixerCurveWidget(QWidget *parent) : QGraphicsView(parent)
plot = new QGraphicsSvgItem();
renderer->load(QString(":/uavobjectwidgetutils/images/curve-bg.svg"));
plot->setSharedRenderer(renderer);
//plot->setElementId("map");
scene->addItem(plot);
plot->setZValue(-1);
scene->setSceneRect(plot->boundingRect());
setScene(scene);
posColor0 = "#1c870b"; //greenish?
posColor1 = "#116703"; //greenish?
negColor0 = "#ff0000"; //red
negColor1 = "#ff0000"; //red
// commmand nodes
// reset
MixerNode* node = getCommandNode(0);
node->setName("Reset");
node->setToolTip("Reset Curve to Defaults");
node->setToggle(false);
node->setPositiveColor("#ffffff", "#ffffff"); //white
node->setNegativeColor("#ffffff", "#ffffff");
scene->addItem(node);
// linear
node = getCommandNode(1);
node->setName("Linear");
node->setToolTip("Generate a Linear Curve");
QImage img = QImage(":/core/images/curve_linear.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("/");
scene->addItem(node);
// log
node = getCommandNode(2);
node->setName("Log");
node->setToolTip("Generate a Logarithmic Curve");
img = QImage(":/core/images/curve_log.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("(");
scene->addItem(node);
// exp
node = getCommandNode(3);
node->setName("Exp");
node->setToolTip("Generate an Exponential Curve");
img = QImage(":/core/images/curve_exp.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText(")");
scene->addItem(node);
// flat
node = getCommandNode(4);
node->setName("Flat");
node->setToolTip("Generate a Flat Curve");
img = QImage(":/core/images/curve_flat.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("--");
scene->addItem(node);
// step
node = getCommandNode(5);
node->setName("Step");
node->setToolTip("Generate a Stepped Curve");
img = QImage(":/core/images/curve_step.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("z");
scene->addItem(node);
// curve min/max nodes
node = getCommandNode(6);
node->setName("MinPlus");
node->setToolTip("Increase Curve Minimum");
img = QImage(":/core/images/curve_plus.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("+");
node->setToggle(false);
node->setPositiveColor("#00aa00", "#00aa00"); //green
node->setNegativeColor("#00aa00", "#00aa00");
scene->addItem(node);
node = getCommandNode(7);
node->setName("MinMinus");
node->setToolTip("Decrease Curve Minimum");
img = QImage(":/core/images/curve_minus.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("-");
node->setToggle(false);
node->setPositiveColor("#aa0000", "#aa0000"); //red
node->setNegativeColor("#aa0000", "#aa0000");
scene->addItem(node);
node = getCommandNode(8);
node->setName("MaxPlus");
node->setToolTip("Increase Curve Maximum");
img = QImage(":/core/images/curve_plus.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("+");
node->setToggle(false);
node->setPositiveColor("#00aa00", "#00aa00"); //green
node->setNegativeColor("#00aa00", "#00aa00");
scene->addItem(node);
node = getCommandNode(9);
node->setName("MaxMinus");
node->setToolTip("Decrease Curve Maximum");
img = QImage(":/core/images/curve_plus.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("-");
node->setToggle(false);
node->setPositiveColor("#aa0000", "#aa0000"); //red
node->setNegativeColor("#aa0000", "#aa0000");
scene->addItem(node);
node = getCommandNode(10);
node->setName("StepPlus");
node->setToolTip("Increase Step/Power Value");
img = QImage(":/core/images/curve_plus.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("+");
node->setToggle(false);
node->setPositiveColor("#00aa00", "#00aa00"); //green
node->setNegativeColor("#00aa00", "#00aa00");
scene->addItem(node);
node = getCommandNode(11);
node->setName("StepMinus");
node->setToolTip("Decrease Step/Power Value");
img = QImage(":/core/images/curve_minus.png");
if (!img.isNull())
node->setImage(img);
else
node->commandText("-");
node->setToggle(false);
node->setPositiveColor("#aa0000", "#aa0000"); //red
node->setNegativeColor("#aa0000", "#aa0000");
scene->addItem(node);
node = getCommandNode(12);
node->setName("StepValue");
node->setDrawNode(false);
node->setToolTip("Current Step/Power Value");
node->setToggle(false);
node->setPositiveColor("#0000aa", "#0000aa"); //blue
node->setNegativeColor("#0000aa", "#0000aa");
scene->addItem(node);
// commands toggle
node = getCommandNode(13);
node->setName("Commands");
node->setToolTip("Toggle Command Buttons On/Off");
node->setToggle(true);
node->setPositiveColor("#00aa00", "#00aa00"); //greenish
node->setNegativeColor("#000000", "#000000");
scene->addItem(node);
// popup
node = getCommandNode(14);
node->setName("Popup");
node->setToolTip("Advanced Mode...");
node->commandText("");
node->setToggle(false);
node->setPositiveColor("#ff0000", "#ff0000"); //red
node->setNegativeColor("#ff0000", "#ff0000");
scene->addItem(node);
resizeCommands();
initNodes(MixerCurveWidget::NODE_NUMELEM);
}
MixerCurveWidget::~MixerCurveWidget()
{
while (!nodePool.isEmpty())
delete nodePool.takeFirst();
while (!nodeList.isEmpty()) {
delete nodeList.takeFirst();
}
while (!edgePool.isEmpty())
delete edgePool.takeFirst();
while (!cmdNodePool.isEmpty())
delete cmdNodePool.takeFirst();
while (!edgeList.isEmpty()) {
delete edgeList.takeFirst();
}
}
MixerNode* MixerCurveWidget::getCommandNode(int index)
void MixerCurveWidget::setPositiveColor(QString color)
{
MixerNode* node;
if (index >= 0 && index < cmdNodePool.count())
{
node = cmdNodePool.at(index);
for (int i=0; i < nodeList.count(); i++) {
MixerNode* node = nodeList.at(i);
node->setPositiveColor(color);
}
else {
node = new MixerNode(this);
node->commandNode(true);
node->commandText("");
node->setCommandIndex(index);
node->setActive(false);
node->setPositiveColor("#aaaa00", "#aaaa00");
node->setNegativeColor("#1c870b", "#116703");
cmdNodePool.append(node);
}
return node;
}
MixerNode* MixerCurveWidget::getNode(int index)
void MixerCurveWidget::setNegativeColor(QString color)
{
MixerNode* node;
if (index >= 0 && index < nodePool.count())
{
node = nodePool.at(index);
}
else {
node = new MixerNode(this);
nodePool.append(node);
}
return node;
}
Edge* MixerCurveWidget::getEdge(int index, MixerNode* sourceNode, MixerNode* destNode)
{
Edge* edge;
if (index >= 0 && index < edgePool.count())
{
edge = edgePool.at(index);
edge->setSourceNode(sourceNode);
edge->setDestNode(destNode);
}
else {
edge = new Edge(sourceNode,destNode);
edgePool.append(edge);
}
return edge;
}
void MixerCurveWidget::setPositiveColor(QString color0, QString color1)
{
posColor0 = color0;
posColor1 = color1;
for (int i=0; i<nodePool.count(); i++) {
MixerNode* node = nodePool.at(i);
node->setPositiveColor(color0, color1);
for (int i=0; i < nodeList.count(); i++) {
MixerNode* node = nodeList.at(i);
node->setNegativeColor(color);
}
}
void MixerCurveWidget::setNegativeColor(QString color0, QString color1)
{
negColor0 = color0;
negColor1 = color1;
for (int i=0; i<nodePool.count(); i++) {
MixerNode* node = nodePool.at(i);
node->setNegativeColor(color0, color1);
}
}
/**
Init curve: create a (flat) curve with a specified number of points.
@ -370,9 +126,11 @@ void MixerCurveWidget::initNodes(int numPoints)
foreach(Edge *edge, node->edges()) {
if (edge->sourceNode() == node) {
scene()->removeItem(edge);
delete edge;
}
}
scene()->removeItem(node);
delete node;
}
nodeList.clear();
@ -380,9 +138,9 @@ void MixerCurveWidget::initNodes(int numPoints)
// Create the nodes and edges
MixerNode* prevNode = 0;
for (int i=0; i<numPoints; i++) {
for (int i=0; i < numPoints; i++) {
MixerNode *node = getNode(i);
MixerNode *node = new MixerNode(this);
nodeList.append(node);
scene()->addItem(node);
@ -390,7 +148,7 @@ void MixerCurveWidget::initNodes(int numPoints)
node->setPos(0,0);
if (prevNode) {
scene()->addItem(getEdge(i, prevNode, node));
scene()->addItem(new Edge(prevNode, node));
}
prevNode = node;
@ -469,7 +227,6 @@ void MixerCurveWidget::showEvent(QShowEvent *event)
// the result is usually a ahrsbargraph that is way too small.
QRectF rect = plot->boundingRect();
resizeCommands();
fitInView(rect.adjusted(-15,-15,15,15), Qt::KeepAspectRatio);
}
@ -478,61 +235,17 @@ void MixerCurveWidget::resizeEvent(QResizeEvent* event)
Q_UNUSED(event);
QRectF rect = plot->boundingRect();
resizeCommands();
fitInView(rect.adjusted(-15,-15,15,15), Qt::KeepAspectRatio);
}
void MixerCurveWidget::resizeCommands()
void MixerCurveWidget::changeEvent(QEvent *event)
{
QRectF rect = plot->boundingRect();
MixerNode* node;
//popup
node = getCommandNode(14);
node->setPos((rect.left() + rect.width() / 2) - 20, rect.height() + 10);
//reset
node = getCommandNode(0);
node->setPos((rect.left() + rect.width() / 2) + 20, rect.height() + 10);
//commands on/off
node = getCommandNode(13);
node->setPos(rect.right() - 15, rect.bottomRight().x() - 14);
for (int i = 1; i<6; i++) {
node = getCommandNode(i);
//bottom right of widget
node->setPos(rect.right() - 130 + (i * 18), rect.bottomRight().x() - 14);
QGraphicsView::changeEvent(event);
if(event->type() == QEvent::EnabledChange) {
foreach (MixerNode *node, nodeList) {
node->update();
}
}
//curveminplus
node = getCommandNode(6);
node->setPos(rect.bottomLeft().x() + 15, rect.bottomLeft().y() - 10);
//curveminminus
node = getCommandNode(7);
node->setPos(rect.bottomLeft().x() + 15, rect.bottomLeft().y() + 5);
//curvemaxplus
node = getCommandNode(8);
node->setPos(rect.topRight().x() - 20, rect.topRight().y() - 7);
//curvemaxminus
node = getCommandNode(9);
node->setPos(rect.topRight().x() - 20, rect.topRight().y() + 8);
//stepplus
node = getCommandNode(10);
node->setPos(rect.bottomRight().x() - 40, rect.bottomRight().y() + 5);
//stepminus
node = getCommandNode(11);
node->setPos(rect.bottomRight().x() - 40, rect.bottomRight().y() + 15);
//step
node = getCommandNode(12);
node->setPos(rect.bottomRight().x() - 22, rect.bottomRight().y() + 9);
}
void MixerCurveWidget::itemMoved(double itemValue)
@ -575,87 +288,3 @@ double MixerCurveWidget::setRange(double min, double max)
return curveMax - curveMin;
}
MixerNode* MixerCurveWidget::getCmdNode(const QString& name)
{
MixerNode* node = 0;
for (int i=0; i<cmdNodePool.count(); i++) {
MixerNode* n = cmdNodePool.at(i);
if (n->getName() == name)
node = n;
}
return node;
}
void MixerCurveWidget::setCommandText(const QString& name, const QString& text)
{
for (int i=0; i<cmdNodePool.count(); i++) {
MixerNode* n = cmdNodePool.at(i);
if (n->getName() == name) {
n->commandText(text);
n->update();
}
}
}
void MixerCurveWidget::activateCommand(const QString& name)
{
for (int i=1; i<cmdNodePool.count()-2; i++) {
MixerNode* node = cmdNodePool.at(i);
node->setCommandActive(node->getName() == name);
node->update();
}
}
void MixerCurveWidget::showCommand(const QString& name, bool show)
{
MixerNode* node = getCmdNode(name);
if (node) {
if (show)
node->show();
else
node->hide();
}
}
void MixerCurveWidget::showCommands(bool show)
{
for (int i=1; i<cmdNodePool.count()-2; i++) {
MixerNode* node = cmdNodePool.at(i);
if (show)
node->show();
else
node->hide();
node->update();
}
}
bool MixerCurveWidget::isCommandActive(const QString& name)
{
bool active = false;
MixerNode* node = getCmdNode(name);
if (node) {
active = node->getCommandActive();
}
return active;
}
void MixerCurveWidget::cmdActivated(MixerNode* node)
{
if (node->getToggle()) {
if (node->getName() == "Commands") {
node->setCommandActive(!node->getCommandActive());
showCommands(node->getCommandActive());
}
else {
for (int i=1; i<cmdNodePool.count()-2; i++) {
MixerNode* n = cmdNodePool.at(i);
n->setCommandActive(false);
n->update();
}
node->setCommandActive(true);
}
}
node->update();
emit commandActivated(node);
}

View File

@ -58,54 +58,35 @@ public:
double getMax();
double setRange(double min, double max);
void cmdActivated(MixerNode* node);
void activateCommand(const QString& name);
bool isCommandActive(const QString& name);
void showCommand(const QString& name, bool show);
void showCommands(bool show);
MixerNode* getCmdNode(const QString& name);
void setCommandText(const QString& name, const QString& text);
static const int NODE_NUMELEM = 5;
signals:
void curveUpdated();
void curveMinChanged(double value);
void curveMaxChanged(double value);
void commandActivated(MixerNode* node);
private slots:
private:
QGraphicsSvgItem *plot;
QList<MixerNode*> nodePool;
QList<MixerNode*> cmdNodePool;
QList<Edge*> edgePool;
QList<Edge*> edgeList;
QList<MixerNode*> nodeList;
double curveMin;
double curveMax;
bool curveUpdating;
QString posColor0;
QString posColor1;
QString negColor0;
QString negColor1;
void initNodes(int numPoints);
MixerNode* getNode(int index);
MixerNode* getCommandNode(int index);
Edge* getEdge(int index, MixerNode* sourceNode, MixerNode* destNode);
void setPositiveColor(QString color0 = "#00ff00", QString color1 = "#00ff00");
void setNegativeColor(QString color0 = "#ff0000", QString color1 = "#ff0000");
void setPositiveColor(QString color);
void setNegativeColor(QString color);
void resizeCommands();
protected:
void showEvent(QShowEvent *event);
void resizeEvent(QResizeEvent *event);
void changeEvent(QEvent *event);
};