Skip to content

Commit

Permalink
Merge pull request #4 from vedranMv/dev-0.4
Browse files Browse the repository at this point in the history
Dev 0.4
  • Loading branch information
Vedran authored Dec 8, 2020
2 parents c504903 + fa78595 commit bb86377
Show file tree
Hide file tree
Showing 12 changed files with 357 additions and 57 deletions.
2 changes: 1 addition & 1 deletion helperObjects/dataMultiplexer/datamultiplexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ void DataMultiplexer::_ComputeMathChannels()
_channelData[ std::get<1>(_mChannel[i]->_component[j]) ];
else if (std::get<0>(_mChannel[i]->_component[j]) == MathOperation::Multiply)
_channelData[ _channelCount[SignalSource::SerialSignal] + i] *= \
abs(_channelData[ std::get<1>(_mChannel[i]->_component[j]) ]);
_channelData[ std::get<1>(_mChannel[i]->_component[j]) ];
else if (std::get<0>(_mChannel[i]->_component[j]) == MathOperation::Add_Abs)
_channelData[ _channelCount[SignalSource::SerialSignal] + i] += \
abs(_channelData[ std::get<1>(_mChannel[i]->_component[j]) ]);
Expand Down
52 changes: 51 additions & 1 deletion helperObjects/graphHeaderWidget/graphheaderwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,18 @@ graphHeaderWidget::graphHeaderWidget(uint8_t chnnelNum)
{
_inChLabel.push_back(new QLabel());
_inChLabel.back()->setText("Channel "+QString::number(i));
_inChLabel.back()->setToolTip( _STYLE_TOOLTIP_(\
"Select which input channel should be used as channel " \
+ QString::number(i) + " in the plot"));
_inChLabel.back()->setFixedHeight(22);

_inCh.push_back(new QComboBox());
// Set fixed height for nicer look
_inCh.back()->setFixedHeight(22);
_inChLabel.back()->setFixedHeight(22);
_inCh.back()->setToolTip( _STYLE_TOOLTIP_(\
"Select which input channel should be used as channel " \
+ QString::number(i) + " in the plot"));

// Trigger 'ComboBoxUpdated' function here whenever the combo-boxes
// get updated
QObject::connect(_inCh[i],
Expand Down Expand Up @@ -112,6 +119,49 @@ QVector<QString> graphHeaderWidget::GetChLabels()
return retVal;
}

/**
* @brief Returns an array with which channels are selected on the graph
* @return Vector containing indexes of selected channel in every drop-down
*/
QVector<uint8_t> graphHeaderWidget::GetSelectedChannels()
{
QVector<uint8_t>retVal;

for (QComboBox* X : _inCh)
retVal.push_back(X->currentIndex());

return retVal;
}

/**
* @brief Restore the selected channels in their respective drop-downs
* provided the list generated by \ref graphHeaderWidget::GetSelectedChannels()
* @param selectedCh list saying which id to select in which QComboBox
*/
void graphHeaderWidget::SetSelectedChannels(QVector<uint8_t> &selectedCh)
{
for (uint8_t i = 0; i < _inCh.size(); i++)
// Check that current index exists in the array
if (i < selectedCh.size())
// Check that the value on current index does not exceed total
// number of index on the list
if (selectedCh[i] < _inCh[i]->count())
_inCh[i]->setCurrentIndex(selectedCh[i]);
}

/**
* @brief Update tooltip of a selected channel
* @param id Channel ID to be updated
* @param toolTip String to use as tooltip
*/
void graphHeaderWidget::SetChToolTip(uint8_t id, QString toolTip)
{
// Check if Id is valid
if ((id >= _inCh.size()) || (id >= _inChLabel.size()))
return;
_inChLabel[id]->setToolTip( _STYLE_TOOLTIP_(+toolTip+));
_inCh[id]->setToolTip( _STYLE_TOOLTIP_(+toolTip+));
}
/**
* @brief Returns main header layout
* @return main header layout
Expand Down
4 changes: 4 additions & 0 deletions helperObjects/graphHeaderWidget/graphheaderwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class graphHeaderWidget : public QObject

QVector<QLabel*>& GetLabels();
QVector<QString> GetChLabels();
QVector<uint8_t> GetSelectedChannels();

void SetSelectedChannels(QVector<uint8_t> &selectedCh);
void SetChToolTip(uint8_t id, QString toolTip);

public slots:

Expand Down
51 changes: 37 additions & 14 deletions helperObjects/mathComponent/mathchannelcomponent.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "mathchannelcomponent.h"
#include <QDebug>

#define _STYLE_TOOLTIP_(X) "<html><head/><body><p>" X "</p></body></html>"


UIMathChannelComponent::~UIMathChannelComponent()
{
Expand All @@ -16,20 +18,24 @@ UIMathChannelComponent::~UIMathChannelComponent()

UIMathChannelComponent::UIMathChannelComponent(uint8_t id): _id(id)
{
labels[0] = new QLabel("Input channel");
labels[1] = new QLabel("Math channel");
labels[2] = new QLabel("Math");
QLabel *labels[4];
QSpacerItem *horSpacer;

labels[0] = new QLabel("Math channel");
labels[1] = new QLabel("+= ");
labels[2] = new QLabel("(Input channel");
labels[3] = new QLabel(")");

mathChSelector = new QComboBox();
inChSelector = new QSpinBox();

mathSelector = new QComboBox();
mathSelector->addItem("Add");
mathSelector->addItem("Subtract");
mathSelector->addItem("Multiply");
mathSelector->addItem("Add ABS");
mathSelector->addItem("Subtract ABS");
mathSelector->addItem("Multiply ABS");
mathSelector->addItem("+");
mathSelector->addItem("-");
mathSelector->addItem("*");
mathSelector->addItem("+ ABS");
mathSelector->addItem(" - ABS");
mathSelector->addItem("* ABS");

deleteButton = new QPushButton();
deleteButton->setText("X");
Expand All @@ -42,18 +48,35 @@ UIMathChannelComponent::UIMathChannelComponent(uint8_t id): _id(id)

// Construct layout with all the elements
layout->addWidget(labels[0], 0, Qt::AlignLeft);
layout->addWidget(inChSelector, 0, Qt::AlignLeft);
layout->addWidget(labels[1], 0, Qt::AlignLeft);
layout->addWidget(mathChSelector, 0, Qt::AlignLeft);
layout->addWidget(labels[2], 0, Qt::AlignLeft);
layout->addWidget(labels[1], 0, Qt::AlignLeft);
layout->addWidget(mathSelector, 0, Qt::AlignLeft);
layout->addWidget(labels[2], 0, Qt::AlignLeft);
layout->addWidget(inChSelector, 0, Qt::AlignLeft);
layout->addWidget(labels[3], 0, Qt::AlignLeft);

layout->addSpacerItem(horSpacer);
layout->addWidget(deleteButton, 0, Qt::AlignLeft);

labels[0]->setToolTip(_STYLE_TOOLTIP_("Select input channel to be used "
"in math operation"));
inChSelector->setToolTip(_STYLE_TOOLTIP_("Select input channel to be used "
"in math operation"));
labels[1]->setToolTip(_STYLE_TOOLTIP_("Select math channel that the "
"operation should be a component of"));
mathChSelector->setToolTip(_STYLE_TOOLTIP_("Select math channel that the "
"operation should be a component of"));
labels[2]->setToolTip(_STYLE_TOOLTIP_("Select arithmetic operation to be "
"performed on the input channel "));
mathSelector->setToolTip(_STYLE_TOOLTIP_("Select arithmetic operation to be "
"performed on the input channel "));
deleteButton->setToolTip(_STYLE_TOOLTIP_("Delete math component"));

for (int i = 0; i < 6; i++)
mathChSelector->addItem(QString::number(i+1));

QObject::connect(deleteButton, &QPushButton::pressed, this, &UIMathChannelComponent::deleteComponent);
QObject::connect(deleteButton, &QPushButton::pressed,
this, &UIMathChannelComponent::deleteComponent);
}

void UIMathChannelComponent::UpdateMathCh(int *mathCh, int size)
Expand Down
4 changes: 1 addition & 3 deletions helperObjects/mathComponent/mathchannelcomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <QHBoxLayout>
#include <QSpacerItem>


class UIMathChannelComponent : public QObject
{
Q_OBJECT
Expand All @@ -36,13 +35,12 @@ class UIMathChannelComponent : public QObject

QHBoxLayout* GetLayout();

QLabel *labels[3];

QComboBox *mathChSelector;
QComboBox *mathSelector;
QSpinBox *inChSelector;
QPushButton *deleteButton;
QHBoxLayout *layout;
QSpacerItem *horSpacer;

signals:
void deleteRequested(uint8_t id);
Expand Down
Loading

0 comments on commit bb86377

Please sign in to comment.