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
 
@@ -72,6 +72,11 @@ MainWindow::MainWindow(QWidget *parent) 
 
    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);
 
@@ -499,6 +504,35 @@ void MainWindow::onNumOfSamplesChanged(i
 
    }
 
}
 

	
 
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)
mainwindow.h
Show inline comments
 
@@ -107,6 +107,7 @@ private slots:
 
    void onAutoScaleChecked(bool checked);
 
    void onYScaleChanged();
 

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

	
mainwindow.ui
Show inline comments
 
@@ -344,6 +344,40 @@
 
       </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>
 
@@ -415,9 +449,12 @@
 
          <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>
 
@@ -557,7 +594,7 @@
 
     <x>0</x>
 
     <y>0</y>
 
     <width>653</width>
 
     <height>20</height>
 
     <height>23</height>
 
    </rect>
 
   </property>
 
   <widget class="QMenu" name="menuFile">
0 comments (0 inline, 0 general)