Changeset 77 in flair-src for branches/mavlink/tools/Controller/Mavlink/src/GuiInterface.cpp
- Timestamp:
- 09/21/16 11:40:56 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/mavlink/tools/Controller/Mavlink/src/GuiInterface.cpp
r71 r77 29 29 #include <GroupBox.h> 30 30 #include <ListWidget.h> 31 #include <Label.h> 32 #include <ComboBox.h> 31 33 32 34 #include <string> … … 48 50 // Controls group 49 51 controlsGroupBox = new GroupBox(settingsTab->NewRow(), "Controls"); 50 btnInitialize = new PushButton(controlsGroupBox->LastRowLastCol(), "Initialize");51 52 btnStartMission = new PushButton(controlsGroupBox->LastRowLastCol(), "Start mission"); 52 53 btnStopMission = new PushButton(controlsGroupBox->LastRowLastCol(), "Stop mission"); 53 btn Kill = new PushButton(controlsGroupBox->LastRowLastCol(), "Kill");54 btnResumeMission = new PushButton(controlsGroupBox->LastRowLastCol(), "Resume mission"); 54 55 55 // Add wpt group 56 addWptGroupBox = new GroupBox(settingsTab->NewRow(), "Add waypoint"); 57 latField = new DoubleSpinBox(addWptGroupBox->NewRow(), "Latitude", 58 -90, 90, 0.001, 3, 3); 59 lonField = new DoubleSpinBox(addWptGroupBox->LastRowLastCol(), "Longitude", 60 -180, 180, 0.001, 3, 3); 61 btnAddMissionWpt = new PushButton(addWptGroupBox->NewRow(), "Add mission wpt"); 62 btnAddEntranceWpt = new PushButton(addWptGroupBox->LastRowLastCol(), "Add entrance wpt"); 63 btnAddExitWpt = new PushButton(addWptGroupBox->LastRowLastCol(), "Add exit wpt"); 56 // Add cmd group 57 addCmdGroupBox = new GroupBox(settingsTab->NewRow(), "Add mission command"); 58 // commandLabel = new Label(addCmdGroupBox->NewRow(), "Command label"); 59 // commandLabel->SetText("Command"); 60 // param1Label = new Label(addCmdGroupBox->LastRowLastCol(), "Param1 label"); 61 // commandLabel->SetText("Param1"); 62 // param2Label = new Label(addCmdGroupBox->LastRowLastCol(), "Param2 label"); 63 // commandLabel->SetText("Param2"); 64 // param3Label = new Label(addCmdGroupBox->LastRowLastCol(), "Param3 label"); 65 // commandLabel->SetText("Param3"); 66 comboCmd = new ComboBox(addCmdGroupBox->NewRow(), "Select command"); 67 // Fill the ComboBox 68 for (auto &command : commandsAvailable) { 69 comboCmd->AddItem(command); 70 } 71 // comboCmd->AddItem("WAYPOINT"); 72 // comboCmd->AddItem("TAKEOFF"); 73 // comboCmd->AddItem("LAND"); 74 // comboCmd->AddItem("RETURN"); 75 // comboCmd->AddItem("JUMP"); 76 param1Field = new DoubleSpinBox(addCmdGroupBox->NewRow(), "Param1", 77 -90, 90, 0.5, 1, 3); 78 param2Field = new DoubleSpinBox(addCmdGroupBox->NewRow(), "Param2", 79 -90, 90, 0.5, 1, 3); 80 param3Field = new DoubleSpinBox(addCmdGroupBox->NewRow(), "Param3", 81 -90, 90, 0.5, 1, 3); 82 btnAddMissionCmd = new PushButton(addCmdGroupBox->NewRow(), "Add mission cmd"); 83 btnDelMissionCmd = new PushButton(addCmdGroupBox->LastRowLastCol(), "Del mission cmd"); 84 btnSendMission = new PushButton(addCmdGroupBox->LastRowLastCol(), "Send mission"); 64 85 65 86 // Show wpt group 66 showWptGroupBox = new GroupBox(settingsTab->NewRow(), "Show waypoints"); 67 listMissionWpt = new ListWidget(showWptGroupBox->NewRow(), "Mission wpt"); 68 listEntranceWpt = new ListWidget(showWptGroupBox->LastRowLastCol(), "Entrance wpt"); 69 listExitWpt = new ListWidget(showWptGroupBox->LastRowLastCol(), "Exit wpt"); 70 btnRemoveMissionWpt = new PushButton(showWptGroupBox->NewRow(), "Remove mission wpt"); 71 btnRemoveEntranceWpt = new PushButton(showWptGroupBox->LastRowLastCol(), "Remove entrance wpt"); 72 btnRemoveExitWpt = new PushButton(showWptGroupBox->LastRowLastCol(), "Remove exit wpt"); 87 showItemsGroupBox = new GroupBox(settingsTab->NewRow(), "Show mission items"); 88 listMissionItems = new ListWidget(showItemsGroupBox->NewRow(), "Mission cmd list"); 73 89 74 // Action wpt group 75 actionWptGroupBox = new GroupBox(settingsTab->NewRow(), "Action"); 76 btnSendWpt = new PushButton(actionWptGroupBox->NewRow(), "Send wpt"); 77 btnClearWpt = new PushButton(actionWptGroupBox->LastRowLastCol(), "Clear wpt"); 78 btnLoop = new PushButton(actionWptGroupBox->LastRowLastCol(), "Loop"); 90 // listEntranceWpt = new ListWidget(showWptGroupBox->LastRowLastCol(), "Entrance wpt"); 91 // listExitWpt = new ListWidget(showWptGroupBox->LastRowLastCol(), "Exit wpt"); 92 // btnRemoveMissionWpt = new PushButton(showWptGroupBox->NewRow(), "Remove mission wpt"); 93 // btnRemoveEntranceWpt = new PushButton(showWptGroupBox->LastRowLastCol(), "Remove entrance wpt"); 94 // btnRemoveExitWpt = new PushButton(showWptGroupBox->LastRowLastCol(), "Remove exit wpt"); 95 96 // // Action wpt group 97 // actionWptGroupBox = new GroupBox(settingsTab->NewRow(), "Action"); 98 // btnSendWpt = new PushButton(actionWptGroupBox->NewRow(), "Send wpt"); 99 // btnClearWpt = new PushButton(actionWptGroupBox->LastRowLastCol(), "Clear wpt"); 100 // btnLoop = new PushButton(actionWptGroupBox->LastRowLastCol(), "Loop"); 79 101 80 102 //TODO IP & PORT from config.h file … … 97 119 Thread::SleepMS(500); 98 120 // Buttons to control GUI 99 if (btnAddMissionWpt->Clicked()) { 100 listMissionWpt->AddItem(GetWptLatLon()); 121 if (btnAddMissionCmd->Clicked()) { 122 //TODO 123 listMissionItems->AddItem(MissionCmdGet()); 101 124 } 102 if (btnAddEntranceWpt->Clicked()) { 103 listEntranceWpt->AddItem(GetWptLatLon()); 104 } 105 if (btnAddExitWpt->Clicked()) { 106 listExitWpt->AddItem(GetWptLatLon()); 107 } 108 if (btnRemoveMissionWpt->Clicked()) { 109 listMissionWpt->RemoveItem(); 110 } 111 if (btnRemoveEntranceWpt->Clicked()) { 112 listEntranceWpt->RemoveItem(); 113 } 114 if (btnRemoveExitWpt->Clicked()) { 115 listExitWpt->RemoveItem(); 125 if (btnDelMissionCmd->Clicked()) { 126 listMissionItems->RemoveItem(); 116 127 } 117 128 // Buttons to send commands 118 if (btnInitialize->Clicked()) {119 MissionInitialize();120 }121 129 if (btnStartMission->Clicked()) { 122 130 MissionStart(); … … 125 133 MissionStop(); 126 134 } 127 if (btn Kill->Clicked()) {128 Mission Kill();135 if (btnResumeMission->Clicked()) { 136 MissionResume(); 129 137 } 130 if (btnSendWpt->Clicked()) { 131 WptSend(); 132 } 133 if (btnClearWpt->Clicked()) { 134 WptClear(); 135 } 136 if (btnLoop->Clicked()) { 137 WptLoopSend(); 138 if (btnSendMission->Clicked()) { 139 MissionSend(); 138 140 } 139 141 } 140 142 } 141 143 142 std::string GuiInterface:: GetWptLatLon() {144 std::string GuiInterface::MissionCmdGet() { 143 145 std::ostringstream stringStream; 144 stringStream.precision( 3);146 stringStream.precision(1); 145 147 stringStream << fixed; 146 stringStream << latField->Value() << " - " << lonField->Value();148 stringStream << commandsAvailable[comboCmd->CurrentIndex()] << "|" << param1Field->Value() << "|" << param2Field->Value() << "|" << param3Field->Value(); 147 149 return stringStream.str(); 148 150 } 149
Note:
See TracChangeset
for help on using the changeset viewer.