Changeset - e65811fa0522
[Not reviewed]
default
0 3 0
Hasan Yavuz Ă–ZDERYA - 10 years ago 2015-04-19 06:57:00
hy@ozderya.net
added number of channels selection
3 files changed with 74 insertions and 2 deletions:
0 comments (0 inline, 0 general)
mainwindow.cpp
Show inline comments
 
@@ -69,12 +69,17 @@ MainWindow::MainWindow(QWidget *parent) 
 
    QObject::connect(ui->spYmax, SIGNAL(valueChanged(double)),
 
                     this, SLOT(onYScaleChanged()));
 

	
 
    QObject::connect(ui->actionClear, SIGNAL(triggered(bool)),
 
                     this, SLOT(clearPlot()));
 

	
 
    // setup number of channels spinbox
 
    QObject::connect(ui->spNumOfChannels,
 
                     SELECT<int>::OVERLOAD_OF(&QSpinBox::valueChanged),
 
                     this, &MainWindow::onNumOfChannelsChanged);
 

	
 
    // setup number format buttons
 
    numberFormatButtons.addButton(ui->rbUint8,  NumberFormat_uint8);
 
    numberFormatButtons.addButton(ui->rbUint16, NumberFormat_uint16);
 
    numberFormatButtons.addButton(ui->rbUint32, NumberFormat_uint32);
 
    numberFormatButtons.addButton(ui->rbInt8,   NumberFormat_int8);
 
    numberFormatButtons.addButton(ui->rbInt16,  NumberFormat_int16);
 
@@ -496,12 +501,41 @@ void MainWindow::onNumOfSamplesChanged(i
 
                channelsData[ci].prepend(0);
 
            }
 
        }
 
    }
 
}
 

	
 
void MainWindow::onNumOfChannelsChanged(int value)
 
{
 
    unsigned int oldNum = this->numOfChannels;
 
    this->numOfChannels = value;
 

	
 
    if (numOfChannels > oldNum)
 
    {
 
        // add new channels
 
        for (int i = 0; i < numOfChannels - oldNum; i++)
 
        {
 
            channelsData.append(DataArray(numOfSamples, 0.0));
 
            curves.append(new QwtPlotCurve());
 
            curves.last()->setSamples(dataX, channelsData.last());
 
            curves.last()->attach(ui->plot);
 
        }
 
    }
 
    else if(numOfChannels < oldNum)
 
    {
 
        // remove channels
 
        for (int i = 0; i < oldNum - numOfChannels; i++)
 
        {
 
            channelsData.removeLast();
 
            auto curve = curves.takeLast();
 
            curve->detach();
 
            delete curve;
 
        }
 
    }
 
}
 

	
 
void MainWindow::onAutoScaleChecked(bool checked)
 
{
 
    if (checked)
 
    {
 
        ui->plot->setAxisAutoScale(QwtPlot::yLeft);
 
        ui->lYmin->setEnabled(false);
mainwindow.h
Show inline comments
 
@@ -104,12 +104,13 @@ private slots:
 
    void skipByte();
 

	
 
    void onNumOfSamplesChanged(int value);
 
    void onAutoScaleChecked(bool checked);
 
    void onYScaleChanged();
 

	
 
    void onNumOfChannelsChanged(int value);
 
    void onNumberFormatButtonToggled(int numberFormatId, bool checked);
 
    void selectNumberFormat(NumberFormat numberFormatId);
 

	
 
    void clearPlot();
 

	
 
signals:
mainwindow.ui
Show inline comments
 
@@ -341,12 +341,46 @@
 
      <widget class="QWidget" name="tabDataFormat">
 
       <attribute name="title">
 
        <string>Data Format</string>
 
       </attribute>
 
       <layout class="QHBoxLayout" name="horizontalLayout_5">
 
        <item>
 
         <layout class="QFormLayout" name="formLayout_3">
 
          <item row="0" column="0">
 
           <widget class="QLabel" name="label_4">
 
            <property name="text">
 
             <string>Number Of Channels:</string>
 
            </property>
 
           </widget>
 
          </item>
 
          <item row="0" column="1">
 
           <widget class="QSpinBox" name="spNumOfChannels">
 
            <property name="minimumSize">
 
             <size>
 
              <width>60</width>
 
              <height>0</height>
 
             </size>
 
            </property>
 
            <property name="minimum">
 
             <number>1</number>
 
            </property>
 
            <property name="maximum">
 
             <number>32</number>
 
            </property>
 
           </widget>
 
          </item>
 
         </layout>
 
        </item>
 
        <item>
 
         <widget class="Line" name="line_2">
 
          <property name="orientation">
 
           <enum>Qt::Vertical</enum>
 
          </property>
 
         </widget>
 
        </item>
 
        <item>
 
         <widget class="QGroupBox" name="groupBox">
 
          <property name="title">
 
           <string>Number Format:</string>
 
          </property>
 
          <layout class="QGridLayout" name="gridLayout_2">
 
           <item row="0" column="0">
 
@@ -412,15 +446,18 @@
 
        </item>
 
        <item>
 
         <spacer name="horizontalSpacer_3">
 
          <property name="orientation">
 
           <enum>Qt::Horizontal</enum>
 
          </property>
 
          <property name="sizeType">
 
           <enum>QSizePolicy::MinimumExpanding</enum>
 
          </property>
 
          <property name="sizeHint" stdset="0">
 
           <size>
 
            <width>445</width>
 
            <width>20</width>
 
            <height>20</height>
 
           </size>
 
          </property>
 
         </spacer>
 
        </item>
 
       </layout>
 
@@ -554,13 +591,13 @@
 
  <widget class="QMenuBar" name="menuBar">
 
   <property name="geometry">
 
    <rect>
 
     <x>0</x>
 
     <y>0</y>
 
     <width>653</width>
 
     <height>20</height>
 
     <height>23</height>
 
    </rect>
 
   </property>
 
   <widget class="QMenu" name="menuFile">
 
    <property name="title">
 
     <string>File</string>
 
    </property>
0 comments (0 inline, 0 general)