Browse Source

Dateien hochladen nach „src/TactileVisualization“

master
Tobias Baumann 2 years ago
parent
commit
c6d41a2377

+ 12
- 57
src/TactileVisualization/TactileMenu.cpp View File

@@ -12,84 +12,39 @@
//includes
#include "TactileMenu.h"
#include <string>
namespace OpenViBE {
namespace Plugins {
namespace Tactilebci {
//TactileMenu Memberfunctions
TactileMenu::TactileMenu(char* label0, char* label1, char* label2, char* label3, char* label4, char* label5)
TactileMenu::TactileMenu(int n_Tactilos)
{
m_LabelText[0] = label0;
m_LabelText[1] = label1;
m_LabelText[2] = label2;
m_LabelText[3] = label3;
m_LabelText[4] = label4;
m_LabelText[5] = label5;
m_MainInterface = nullptr;
for(int i = 0; i < 6; i++)
{
m_SubMenu[i] = this;
m_SubRoutine[i] = nullptr;
m_Label[i] = nullptr;
}
}
void TactileMenu::call_SubRoutine(int i)
{
if(m_SubRoutine[i] != nullptr)
for(int i = 1; i <= n_Tactilos; i++)
{
(*m_SubRoutine[i])();
m_LabelText.push_back("Tactilo" + std::to_string(i));
m_SubMenu.push_back(this);
}
}
char* TactileMenu::get_LabelText(int i)
{
return(m_LabelText[i]);
}
TactileMenu* TactileMenu::get_SubMenu(int i)
{
return(m_SubMenu[i]);
}
void TactileMenu::set_SubRoutine(int i, void(*subroutine)(void))
void TactileMenu::set_LabelText(int i, std::string Text)
{
m_SubRoutine[i] = subroutine;
m_LabelText[i] = Text;
}
void TactileMenu::set_SubMenu(int i, TactileMenu* submenu)
void TactileMenu::set_SubMenu(int i, TactileMenu* Menu)
{
m_SubMenu[i] = submenu;
m_SubMenu[i] = Menu;
}
void TactileMenu::reloadui(void)
std::string TactileMenu::get_LabelText(int i)
{
for(int i = 0; i < 6; i++)
{
gtk_label_set_text(m_Label[i], m_LabelText[i]);
}
return(m_LabelText[i]);
}
void TactileMenu::init_Labels(GtkBuilder* maininterface)
TactileMenu* TactileMenu::get_SubMenu(int i)
{
m_MainInterface = maininterface;
m_Label[0] = GTK_LABEL(gtk_builder_get_object(maininterface, "label-1"));
m_Label[1] = GTK_LABEL(gtk_builder_get_object(maininterface, "label-2"));
m_Label[2] = GTK_LABEL(gtk_builder_get_object(maininterface, "label-3"));
m_Label[3] = GTK_LABEL(gtk_builder_get_object(maininterface, "label-4"));
m_Label[4] = GTK_LABEL(gtk_builder_get_object(maininterface, "label-5"));
m_Label[5] = GTK_LABEL(gtk_builder_get_object(maininterface, "label-6"));
}
//Subroutine Functions
void dummysubroutine(void)
{
return(m_SubMenu[i]);
}
} // namespace Tactilebci

+ 10
- 18
src/TactileVisualization/TactileMenu.h View File

@@ -8,7 +8,6 @@
/// \copyright <a href="https://choosealicense.com/licenses/agpl-3.0/">GNU Affero General Public License v3.0</a>.
///
///-------------------------------------------------------------------------------------------------
//includes
#pragma once
@@ -18,6 +17,9 @@
#include <openvibe/ov_all.h>
#include <toolkit/ovtk_all.h>
#include <vector>
#include <string>
namespace OpenViBE {
namespace Plugins {
namespace Tactilebci {
@@ -26,29 +28,19 @@ namespace Tactilebci {
class TactileMenu
{
private:
char* m_LabelText[6];
TactileMenu* m_SubMenu[6];
void (*m_SubRoutine[6])(void);
GtkLabel* m_Label[6];
GtkBuilder* m_MainInterface;
std::vector<std::string> m_LabelText;
std::vector<TactileMenu*> m_SubMenu;
public:
TactileMenu(char* label0, char* label1, char* label2, char* label3, char* label4, char* label5);
void call_SubRoutine(int i);
char* get_LabelText(int i);
TactileMenu* get_SubMenu(int i);
TactileMenu(int n_Tactilos);
void set_SubRoutine(int i, void(*subroutine)(void));
void set_SubMenu(int i, TactileMenu* submenu);
std::string get_LabelText(int i);
TactileMenu* get_SubMenu(int i);
void init_Labels(GtkBuilder* maininterface);
void reloadui(void);
void set_LabelText(int i, std::string Text);
void set_SubMenu(int i, TactileMenu* Menu);
};
//Subroutine declarations
void dummysubroutine(void);
} // namespace Tactilebci
} // namespace Plugins
} // namespace OpenViBE

+ 68
- 45
src/TactileVisualization/ovpCBoxAlgorithmP300TactileVisualization.cpp View File

@@ -66,6 +66,8 @@ bool CBoxAlgorithmP300TactileVisualization::initialize()
m_selectedBgColor = CGdkcolorAutoCast(boxContext, this->getConfigurationManager(), 12);
m_selectedFgColor = CGdkcolorAutoCast(boxContext, this->getConfigurationManager(), 13);
m_selectedFontSize = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 14);
m_nTactilos = FSettingValueAutoCast(*this->getBoxAlgorithmContext(), 15);
// ----------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -129,39 +131,65 @@ bool CBoxAlgorithmP300TactileVisualization::initialize()
m_result = GTK_LABEL(gtk_builder_get_object(m_mainWidgetInterface, "label-result"));
m_target = GTK_LABEL(gtk_builder_get_object(m_mainWidgetInterface, "label-target"));
//Begin TactileMenu Initialization -------------------------------------------------------------------------------------
//Create Menus
m_MainMenu = new TactileMenu("Ja", "Nein", "Pflege", "Hilfe", "Geräte", "Funktionen");
m_CareMenu = new TactileMenu("Ja", "Nein", "Hunger", "Lage", "Müdigkeit", "Hauptmenü");
m_HelpMenu = new TactileMenu("Ja", "Nein", "Schmerzen", "Atemnot", "Anderes", "Hauptmenü");
m_DevicesMenu = new TactileMenu("Ja", "Nein", "Atemgerät", "Rollstuhl", "Computer", "Hauptmenü");
m_FunctionsMenu = new TactileMenu("Ja", "Nein", "befehl1", "befehl2", "befehl3", "Hauptmenü");
//Initialize MainMenu
m_MainMenu->init_Labels(m_mainWidgetInterface);
m_MainMenu->set_SubMenu(2, m_CareMenu);
m_MainMenu->set_SubMenu(3, m_HelpMenu);
m_MainMenu->set_SubMenu(4, m_DevicesMenu);
m_MainMenu->set_SubMenu(5, m_FunctionsMenu);
//Initialize CareMenu
m_CareMenu->init_Labels(m_mainWidgetInterface);
m_CareMenu->set_SubMenu(5, m_MainMenu);
//Initialize HelpMenu
m_HelpMenu->init_Labels(m_mainWidgetInterface);
m_HelpMenu->set_SubMenu(5, m_MainMenu);
//Initialize DevicesMenu
m_DevicesMenu->init_Labels(m_mainWidgetInterface);
m_DevicesMenu->set_SubMenu(5, m_MainMenu);
//Initialize FunctionsMenu
m_FunctionsMenu->init_Labels(m_mainWidgetInterface);
m_FunctionsMenu->set_SubMenu(5, m_MainMenu);
//Set Pointer to active Menu
//Load MenuLabels
m_CurrentMenu = m_MainMenu;
m_CurrentMenu->reloadui();
//Begin Menu Initialization -------------------------------------------------------------------------------------
if(m_nTactilos == 6) //Create Menus for m_nTactilos = 6
{
m_Menu.push_back(TactileMenu(6));
m_Menu[0].set_LabelText(0, "Ja");
m_Menu[0].set_LabelText(1, "Nein");
m_Menu[0].set_LabelText(2, "Pflege");
m_Menu[0].set_LabelText(3, "Hilfe");
m_Menu[0].set_LabelText(4, "Geräte");
m_Menu[0].set_LabelText(5, "Funktionen");
m_Menu[0].set_SubMenu(2, &m_Menu[1]);
m_Menu[0].set_SubMenu(3, &m_Menu[2]);
m_Menu[0].set_SubMenu(4, &m_Menu[3]);
m_Menu.push_back(TactileMenu(6));
m_Menu[1].set_LabelText(0, "Ja");
m_Menu[1].set_LabelText(1, "Nein");
m_Menu[1].set_LabelText(2, "Hunger");
m_Menu[1].set_LabelText(3, "Lage");
m_Menu[1].set_LabelText(4, "Müdigkeit");
m_Menu[1].set_LabelText(5, "Hauptmenü");
m_Menu[0].set_SubMenu(5, &m_Menu[0]);
//End TactileMenu Initialization ---------------------------------------------------------------------------------------
m_Menu.push_back(TactileMenu(6));
m_Menu[2].set_LabelText(0, "Ja");
m_Menu[2].set_LabelText(1, "Nein");
m_Menu[2].set_LabelText(2, "Schmerzen");
m_Menu[2].set_LabelText(3, "Atemnot");
m_Menu[2].set_LabelText(4, "Anderes");
m_Menu[2].set_LabelText(5, "Hauptmenü");
m_Menu[0].set_SubMenu(5, &m_Menu[0]);
m_Menu.push_back(TactileMenu(6));
m_Menu[3].set_LabelText(0, "Ja");
m_Menu[3].set_LabelText(1, "Nein");
m_Menu[3].set_LabelText(2, "Atemgerät");
m_Menu[3].set_LabelText(3, "Rollstuhl");
m_Menu[3].set_LabelText(4, "Computer");
m_Menu[3].set_LabelText(5, "Hauptmenü");
m_Menu[0].set_SubMenu(5, &m_Menu[0]);
//Set Pointer to Mainmenu
m_currMenu = &m_Menu[0];
//Init Gtk Labels
for(int i = 0; i < 6; i++)
{
std::string label_id = "label-" + std::to_string(i+1);
std::string label_text = m_currMenu->get_LabelText(i);
m_Label.push_back(GTK_LABEL(gtk_builder_get_object(m_mainWidgetInterface, label_id.c_str())));
gtk_label_set_text(m_Label[i], label_text.c_str());
}
}
else
{
}
//End Menu Initialization ---------------------------------------------------------------------------------------
gtk_builder_connect_signals(m_mainWidgetInterface, nullptr);
gtk_builder_connect_signals(m_toolbarWidgetInterface, nullptr);
@@ -231,15 +259,7 @@ bool CBoxAlgorithmP300TactileVisualization::initialize()
}
bool CBoxAlgorithmP300TactileVisualization::uninitialize()
{
//Begin Uninitialize TactileMenu -----------------------------------------------------------------------
delete m_MainMenu;
delete m_CareMenu;
delete m_HelpMenu;
delete m_DevicesMenu;
delete m_FunctionsMenu;
//End Uninitialize TactileMenu -------------------------------------------------------------------------
{
if (m_idleFuncTag)
{
m_stimuliQueue.clear();
@@ -634,10 +654,13 @@ bool CBoxAlgorithmP300TactileVisualization::process()
this->getLogManager() << Kernel::LogLevel_Warning << "Did not find a unique widget at row : " << size_t(m_selectedRow) <<
" column : " << size_t(m_selectedCol) << "\n";
}
//Toggle Menu
m_CurrentMenu->call_SubRoutine(m_selectedRow);
m_CurrentMenu = m_CurrentMenu->get_SubMenu(m_selectedRow);
m_CurrentMenu->reloadui();
//Switch Menu
m_currMenu = m_currMenu->get_SubMenu(m_selectedRow);
for(int i = 0; i < 6; i++)
{
std::string label_text = m_currMenu->get_LabelText(i);
gtk_label_set_text(m_Label[i], label_text.c_str());
}
}
else
{

+ 10
- 9
src/TactileVisualization/ovpCBoxAlgorithmP300TactileVisualization.h View File

@@ -8,7 +8,6 @@
/// \copyright <a href="https://choosealicense.com/licenses/agpl-3.0/">GNU Affero General Public License v3.0</a>.
///
///-------------------------------------------------------------------------------------------------
//includes
#pragma once
@@ -21,6 +20,7 @@
#include <gtk/gtk.h>
#include <list>
#include <map>
#include <vector>
#include "../utils.h"
namespace TCPTagging {
@@ -71,16 +71,13 @@ private:
GtkLabel* m_target = nullptr;
//Deklaration TactileMenu Variablen
TactileMenu* m_MainMenu = nullptr;
TactileMenu* m_CareMenu = nullptr;
TactileMenu* m_HelpMenu = nullptr;
TactileMenu* m_DevicesMenu = nullptr;
TactileMenu* m_FunctionsMenu = nullptr;
std::vector<TactileMenu> m_Menu;
std::vector<GtkLabel*> m_Label;
TactileMenu* m_currMenu;
TactileMenu* m_CurrentMenu = nullptr;
uint64_t m_nRow = 0;
uint64_t m_nCol = 0;
uint64_t m_nRow = 0;
uint64_t m_nCol = 0;
int m_lastTargetRow = 0;
int m_lastTargetCol = 0;
@@ -145,6 +142,8 @@ protected:
GdkColor m_selectedFgColor = InitGDKColor(0, 19661, 6554, 6554);
uint64_t m_selectedFontSize = 100;
PangoFontDescription* m_selectedFontDesc = nullptr;
uint64_t m_nTactilos = 0;
};
class CBoxAlgorithmP300TactileVisualizationDesc final : public IBoxAlgorithmDesc
@@ -195,6 +194,8 @@ public:
prototype.addSetting("Selected background color", OV_TypeId_Color, "70,20,20");
prototype.addSetting("Selected foreground color", OV_TypeId_Color, "30,10,10");
prototype.addSetting("Selected font size", OV_TypeId_Integer, "100");
prototype.addSetting("Number of Tactilos",OV_TypeId_Integer,"6");
return true;
}

Loading…
Cancel
Save