# HG changeset patch # User Hasan Yavuz ÖZDERYA # Date 2016-05-22 08:07:08 # Node ID 3a0d0d3df434d00d644c9432a0764a6c77202c1d # Parent 300a8da1b0c9b443330227fe78dec72b4c8abcda adding number format selection and endianness selection as separate widgets tested but not yet used in code diff --git a/src/endiannessbox.cpp b/src/endiannessbox.cpp new file mode 100644 --- /dev/null +++ b/src/endiannessbox.cpp @@ -0,0 +1,50 @@ +/* + Copyright © 2016 Hasan Yavuz Özderya + + This file is part of serialplot. + + serialplot is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + serialplot is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with serialplot. If not, see . +*/ + +#include "endiannessbox.h" +#include "ui_endiannessbox.h" + +EndiannessBox::EndiannessBox(QWidget *parent) : + QGroupBox(parent), + ui(new Ui::EndiannessBox) +{ + ui->setupUi(this); + + connect(ui->rbLittleE, &QRadioButton::toggled, [this](bool checked) + { + emit selectionChanged(currentSelection()); + }); +} + +EndiannessBox::~EndiannessBox() +{ + delete ui; +} + +Endianness EndiannessBox::currentSelection() +{ + if (ui->rbLittleE->isChecked()) + { + return LittleEndian; + } + else + { + return BigEndian; + } +} diff --git a/src/endiannessbox.h b/src/endiannessbox.h new file mode 100644 --- /dev/null +++ b/src/endiannessbox.h @@ -0,0 +1,53 @@ +/* + Copyright © 2016 Hasan Yavuz Özderya + + This file is part of serialplot. + + serialplot is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + serialplot is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with serialplot. If not, see . +*/ + +#ifndef ENDIANNESSBOX_H +#define ENDIANNESSBOX_H + +#include + +namespace Ui { +class EndiannessBox; +} + +enum Endianness +{ + LittleEndian, + BigEndian +}; + +class EndiannessBox : public QGroupBox +{ + Q_OBJECT + +public: + explicit EndiannessBox(QWidget *parent = 0); + ~EndiannessBox(); + + Endianness currentSelection(); ///< currently selected endianness + +signals: + /// Signaled when endianness selection is changed + void selectionChanged(Endianness endianness); + +private: + Ui::EndiannessBox *ui; +}; + +#endif // ENDIANNESSBOX_H diff --git a/src/endiannessbox.ui b/src/endiannessbox.ui new file mode 100644 --- /dev/null +++ b/src/endiannessbox.ui @@ -0,0 +1,47 @@ + + + EndiannessBox + + + + 0 + 0 + 131 + 86 + + + + GroupBox + + + Byte Order: + + + + + + least significant byte first + + + Little Endian + + + true + + + + + + + most significant byte first + + + Big Endian + + + + + + + + diff --git a/src/numberformatbox.cpp b/src/numberformatbox.cpp new file mode 100644 --- /dev/null +++ b/src/numberformatbox.cpp @@ -0,0 +1,56 @@ +/* + Copyright © 2016 Hasan Yavuz Özderya + + This file is part of serialplot. + + serialplot is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + serialplot is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with serialplot. If not, see . +*/ + +#include "numberformatbox.h" +#include "ui_numberformatbox.h" + +NumberFormatBox::NumberFormatBox(QWidget *parent) : + QGroupBox(parent), + ui(new Ui::NumberFormatBox) +{ + ui->setupUi(this); + + // setup buttons + buttonGroup.addButton(ui->rbUint8, NumberFormat_uint8); + buttonGroup.addButton(ui->rbUint16, NumberFormat_uint16); + buttonGroup.addButton(ui->rbUint32, NumberFormat_uint32); + buttonGroup.addButton(ui->rbInt8, NumberFormat_int8); + buttonGroup.addButton(ui->rbInt16, NumberFormat_int16); + buttonGroup.addButton(ui->rbInt32, NumberFormat_int32); + buttonGroup.addButton(ui->rbFloat, NumberFormat_float); + + QObject::connect( + &buttonGroup, SIGNAL(buttonToggled(int, bool)), + this, SLOT(onButtonToggled(int, bool))); +} + +NumberFormatBox::~NumberFormatBox() +{ + delete ui; +} + +void NumberFormatBox::onButtonToggled(int numberFormatId, bool checked) +{ + if (checked) emit selectionChanged((NumberFormat) numberFormatId); +} + +NumberFormat NumberFormatBox::currentSelection() +{ + return (NumberFormat) buttonGroup.checkedId(); +} diff --git a/src/numberformatbox.h b/src/numberformatbox.h new file mode 100644 --- /dev/null +++ b/src/numberformatbox.h @@ -0,0 +1,63 @@ +/* + Copyright © 2016 Hasan Yavuz Özderya + + This file is part of serialplot. + + serialplot is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + serialplot is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with serialplot. If not, see . +*/ + +#ifndef NUMBERFORMATBOX_H +#define NUMBERFORMATBOX_H + +#include +#include + +namespace Ui { +class NumberFormatBox; +} + +enum NumberFormat +{ + NumberFormat_uint8, + NumberFormat_uint16, + NumberFormat_uint32, + NumberFormat_int8, + NumberFormat_int16, + NumberFormat_int32, + NumberFormat_float, +}; + +class NumberFormatBox : public QGroupBox +{ + Q_OBJECT + +public: + explicit NumberFormatBox(QWidget *parent = 0); + ~NumberFormatBox(); + + NumberFormat currentSelection(); ///< returns the currently selected number format + +signals: + /// Signaled when number format selection is changed + void selectionChanged(NumberFormat numberFormat); + +private: + Ui::NumberFormatBox *ui; + QButtonGroup buttonGroup; + +private slots: + void onButtonToggled(int numberFormatId, bool checked); +}; + +#endif // NUMBERFORMATBOX_H diff --git a/src/numberformatbox.ui b/src/numberformatbox.ui new file mode 100644 --- /dev/null +++ b/src/numberformatbox.ui @@ -0,0 +1,97 @@ + + + NumberFormatBox + + + + 0 + 0 + 158 + 142 + + + + GroupBox + + + Number Format: + + + + + + unsigned 1 byte integer + + + uint8 + + + true + + + + + + + signed 1 byte integer + + + int8 + + + + + + + unsigned 2 bytes integer + + + uint16 + + + + + + + signed 2 bytes integer + + + int16 + + + + + + + unsigned 4 bytes integer + + + uint32 + + + + + + + signed 4 bytes integer + + + int32 + + + + + + + 4 bytes floating point number + + + float + + + + + + + +