Ignore:
Timestamp:
Sep 21, 2016, 11:40:56 AM (5 years ago)
Author:
Thomas Fuhrmann
Message:

Change the GUI of MavPlanner? to match with mission planning (only GUI is working)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/mavlink/tools/Controller/Mavlink/src/GuiInterface.cpp

    r71 r77  
    2929#include <GroupBox.h>
    3030#include <ListWidget.h>
     31#include <Label.h>
     32#include <ComboBox.h>
    3133
    3234#include <string>
     
    4850  // Controls group
    4951  controlsGroupBox = new GroupBox(settingsTab->NewRow(), "Controls");
    50   btnInitialize = new PushButton(controlsGroupBox->LastRowLastCol(), "Initialize");
    5152  btnStartMission = new PushButton(controlsGroupBox->LastRowLastCol(), "Start mission");
    5253  btnStopMission = new PushButton(controlsGroupBox->LastRowLastCol(), "Stop mission");
    53   btnKill = new PushButton(controlsGroupBox->LastRowLastCol(), "Kill");
     54  btnResumeMission = new PushButton(controlsGroupBox->LastRowLastCol(), "Resume mission");
    5455
    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");
    6485
    6586  // 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");
    7389
    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");
    79101
    80102  //TODO IP & PORT from config.h file
     
    97119    Thread::SleepMS(500);
    98120    // Buttons to control GUI
    99         if (btnAddMissionWpt->Clicked()) {
    100                 listMissionWpt->AddItem(GetWptLatLon());
     121        if (btnAddMissionCmd->Clicked()) {
     122                //TODO
     123      listMissionItems->AddItem(MissionCmdGet());
    101124    }
    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();
    116127    }
    117128    // Buttons to send commands
    118         if (btnInitialize->Clicked()) {
    119                 MissionInitialize();
    120     }
    121129        if (btnStartMission->Clicked()) {
    122130                MissionStart();
     
    125133                MissionStop();
    126134    }
    127         if (btnKill->Clicked()) {
    128                 MissionKill();
     135        if (btnResumeMission->Clicked()) {
     136                MissionResume();
    129137    }
    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();
    138140    }
    139141  }
    140142}
    141143
    142 std::string GuiInterface::GetWptLatLon() {
     144std::string GuiInterface::MissionCmdGet() {
    143145  std::ostringstream stringStream;
    144   stringStream.precision(3);
     146  stringStream.precision(1);
    145147  stringStream << fixed;
    146   stringStream << latField->Value() << " - " << lonField->Value();
     148  stringStream << commandsAvailable[comboCmd->CurrentIndex()] << "|" << param1Field->Value() << "|" << param2Field->Value() << "|" << param3Field->Value();
    147149  return stringStream.str();
    148150}
    149 
Note: See TracChangeset for help on using the changeset viewer.