Skip to content
Snippets Groups Projects
Commit a9d566fc authored by Paul Beuchat's avatar Paul Beuchat
Browse files

Added vertical banner to all GUI tabs indicating whether that controller is...

Added vertical banner to all GUI tabs indicating whether that controller is active not. Tested in simulation (there is a small chance this causes the GUI to occassionaly crash becuase of simultaneous setting of the properties of the banners). Tested in Simulation. Also fixed small mistake in the coordinator launch file
parent e49badc0
No related branches found
No related tags found
No related merge requests found
......@@ -142,6 +142,9 @@ private:
QColor m_tab_text_colour_normal;
QColor m_tab_text_colour_highlight;
// Mutex for the highlighting of the active controller
QMutex m_change_highlighted_controller_mutex;
// Sound effect for when the controller changes while flying
//QSoundEffect m_soundEffect_controllerChanged;
......@@ -183,9 +186,15 @@ private:
void setControllerEnabled(int new_controller);
void setTextColourOfTabLabel(QColor color , QWidget * tab_widget);
void setAllTabLabelsToNormalColouring();
void setTextColourOfTabLabel(QColor color , QWidget * tab_widget);
void setAllFramesToControllerIsOffColouring();
void setAllFramesToControllerCoordinatorColouring();
};
......
......@@ -46,7 +46,10 @@ ControllerTabs::ControllerTabs(QWidget *parent) :
// Specify the color for normal and highlighted tabs
m_tab_text_colour_normal = Qt::black;
m_tab_text_colour_highlight = QColor(0,200,0);
m_tab_text_colour_highlight = QColor(40,120,40);
// Set all the frame to be the inactive colouring
setAllFramesToControllerIsOffColouring();
// Initialise the sound effect for when the controller changes while flying
//QSoundEffect m_soundEffect_controllerChanged;
......@@ -437,8 +440,16 @@ void ControllerTabs::controllerUsedChangedCallback(const std_msgs::Int32& msg)
void ControllerTabs::setControllerEnabled(int new_controller)
{
// Define the on string and style sheet setting locally
const static QString style_sheet_string_for_on = "background-color:rgb(40,120,40);";
const static QString text_for_controller_isOn = "A\nC\nT\nI\nV\nE";
// First set everything back to normal colouring
setAllTabLabelsToNormalColouring();
setAllFramesToControllerIsOffColouring();
// Lock the mutex
m_change_highlighted_controller_mutex.lock();
// Now switch to highlight the tab corresponding to
// the enable controller
......@@ -447,6 +458,8 @@ void ControllerTabs::setControllerEnabled(int new_controller)
case DEFAULT_CONTROLLER:
{
setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->default_tab );
ui->frame_isCurrentController_default->setStyleSheet(style_sheet_string_for_on);
ui->label_isCurrentController_default->setText(text_for_controller_isOn);
break;
}
case DEMO_CONTROLLER:
......@@ -457,6 +470,8 @@ void ControllerTabs::setControllerEnabled(int new_controller)
case STUDENT_CONTROLLER:
{
setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->student_tab );
ui->frame_isCurrentController_student->setStyleSheet(style_sheet_string_for_on);
ui->label_isCurrentController_student->setText(text_for_controller_isOn);
break;
}
case MPC_CONTROLLER:
......@@ -467,26 +482,36 @@ void ControllerTabs::setControllerEnabled(int new_controller)
case REMOTE_CONTROLLER:
{
setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->remote_tab );
ui->frame_isCurrentController_remote->setStyleSheet(style_sheet_string_for_on);
ui->label_isCurrentController_remote->setText(text_for_controller_isOn);
break;
}
case TUNING_CONTROLLER:
{
setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->tuning_tab );
ui->frame_isCurrentController_tuning->setStyleSheet(style_sheet_string_for_on);
ui->label_isCurrentController_tuning->setText(text_for_controller_isOn);
break;
}
case PICKER_CONTROLLER:
{
setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->picker_tab );
ui->frame_isCurrentController_picker->setStyleSheet(style_sheet_string_for_on);
ui->label_isCurrentController_picker->setText(text_for_controller_isOn);
break;
}
case TEMPLATE_CONTROLLER:
{
setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->template_tab );
ui->frame_isCurrentController_template->setStyleSheet(style_sheet_string_for_on);
ui->label_isCurrentController_template->setText(text_for_controller_isOn);
break;
}
case CSONE_CONTROLLER:
{
setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->csone_tab );
ui->frame_isCurrentController_csone->setStyleSheet(style_sheet_string_for_on);
ui->label_isCurrentController_csone->setText(text_for_controller_isOn);
break;
}
default:
......@@ -495,11 +520,30 @@ void ControllerTabs::setControllerEnabled(int new_controller)
break;
}
}
// Unlock the mutex
m_change_highlighted_controller_mutex.unlock();
}
void ControllerTabs::setTextColourOfTabLabel(QColor color , QWidget * tab_widget)
{
// Get the current index of the tab
int current_index_of_tab = ui->controller_tabs_widget->indexOf(tab_widget);
// Only apply the colour if the tab is found
if (current_index_of_tab >= 0)
{
ui->controller_tabs_widget->tabBar()->setTabTextColor(current_index_of_tab, color);
}
}
void ControllerTabs::setAllTabLabelsToNormalColouring()
{
// Lock the mutex
m_change_highlighted_controller_mutex.lock();
// Set all the colours to normal
setTextColourOfTabLabel( m_tab_text_colour_normal , ui->default_tab );
setTextColourOfTabLabel( m_tab_text_colour_normal , ui->student_tab );
setTextColourOfTabLabel( m_tab_text_colour_normal , ui->picker_tab );
......@@ -507,21 +551,79 @@ void ControllerTabs::setAllTabLabelsToNormalColouring()
setTextColourOfTabLabel( m_tab_text_colour_normal , ui->remote_tab );
setTextColourOfTabLabel( m_tab_text_colour_normal , ui->template_tab );
setTextColourOfTabLabel( m_tab_text_colour_normal , ui->csone_tab );
// Unlock the mutex
m_change_highlighted_controller_mutex.unlock();
}
void ControllerTabs::setTextColourOfTabLabel(QColor color , QWidget * tab_widget)
void ControllerTabs::setAllFramesToControllerIsOffColouring()
{
// Get the current index of the tab
int current_index_of_tab = ui->controller_tabs_widget->indexOf(tab_widget);
// Only apply the colour if the tab is found
if (current_index_of_tab >= 0)
{
ui->controller_tabs_widget->tabBar()->setTabTextColor(current_index_of_tab, color);
}
// Define the off string and style sheet setting locally
const static QString text_for_controller_isOff = "O\nF\nF";
const static QString style_sheet_string_for_off = "background-color:rgb(160,40,40);";
// Lock the mutex
m_change_highlighted_controller_mutex.lock();
// Set all the frames to the off colour
ui->frame_isCurrentController_default ->setStyleSheet(style_sheet_string_for_off);
ui->frame_isCurrentController_student ->setStyleSheet(style_sheet_string_for_off);
ui->frame_isCurrentController_picker ->setStyleSheet(style_sheet_string_for_off);
ui->frame_isCurrentController_tuning ->setStyleSheet(style_sheet_string_for_off);
ui->frame_isCurrentController_remote ->setStyleSheet(style_sheet_string_for_off);
ui->frame_isCurrentController_template->setStyleSheet(style_sheet_string_for_off);
ui->frame_isCurrentController_csone ->setStyleSheet(style_sheet_string_for_off);
// Set all the texts to the off string
ui->label_isCurrentController_default ->setText(text_for_controller_isOff);
ui->label_isCurrentController_student ->setText(text_for_controller_isOff);
ui->label_isCurrentController_picker ->setText(text_for_controller_isOff);
ui->label_isCurrentController_tuning ->setText(text_for_controller_isOff);
ui->label_isCurrentController_remote ->setText(text_for_controller_isOff);
ui->label_isCurrentController_template->setText(text_for_controller_isOff);
ui->label_isCurrentController_csone ->setText(text_for_controller_isOff);
// Unlock the mutex
m_change_highlighted_controller_mutex.unlock();
}
void ControllerTabs::setAllFramesToControllerCoordinatorColouring()
{
// Define the off string locally
const static QString text_for_coordinatorMode = "C\nO\nO\nR\nD";
const static QString style_sheet_string_for_coordinatorMode = "background-color:rgb(150,150,150);";
// Lock the mutex
m_change_highlighted_controller_mutex.lock();
// Set all the frames to the off colour
ui->frame_isCurrentController_default ->setStyleSheet(style_sheet_string_for_coordinatorMode);
ui->frame_isCurrentController_student ->setStyleSheet(style_sheet_string_for_coordinatorMode);
ui->frame_isCurrentController_picker ->setStyleSheet(style_sheet_string_for_coordinatorMode);
ui->frame_isCurrentController_tuning ->setStyleSheet(style_sheet_string_for_coordinatorMode);
ui->frame_isCurrentController_remote ->setStyleSheet(style_sheet_string_for_coordinatorMode);
ui->frame_isCurrentController_template->setStyleSheet(style_sheet_string_for_coordinatorMode);
ui->frame_isCurrentController_csone ->setStyleSheet(style_sheet_string_for_coordinatorMode);
// Set all the texts to the off string
ui->label_isCurrentController_default ->setText(text_for_coordinatorMode);
ui->label_isCurrentController_student ->setText(text_for_coordinatorMode);
ui->label_isCurrentController_picker ->setText(text_for_coordinatorMode);
ui->label_isCurrentController_tuning ->setText(text_for_coordinatorMode);
ui->label_isCurrentController_remote ->setText(text_for_coordinatorMode);
ui->label_isCurrentController_template->setText(text_for_coordinatorMode);
ui->label_isCurrentController_csone ->setText(text_for_coordinatorMode);
// Unlock the mutex
m_change_highlighted_controller_mutex.unlock();
}
// ----------------------------------------------------------------------------------
// A GGGG EEEEE N N TTTTT III DDDD SSSS
// A A G E NN N T I D D S
......@@ -592,6 +694,8 @@ void ControllerTabs::setAgentIDsToCoordinate(QVector<int> agentIDs , bool should
// Set all tabs to be normal colours
setAllTabLabelsToNormalColouring();
// Set all current controller frames to be in "coordinator mode"
setAllFramesToControllerCoordinatorColouring();
}
#endif
......
......@@ -12,7 +12,7 @@
<!-- Example of how to specify the coordID from command line -->
<!-- roslaunch dfall_pkg coordID:=001 -->
<group ns="$(eval 'agent' + str(coordID).zfill(3))">
<group ns="$(eval 'coord' + str(coordID).zfill(3))">
<!-- COORDINATOR GUI -->
<group if="$(arg withGUI)">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment