Changeset - f102fddaeb9f
[Not reviewed]
Hasan Yavuz Ă–ZDERYA - 8 years ago 2017-08-16 12:19:45
hy@ozderya.net
added plot width option
9 files changed with 104 insertions and 10 deletions:
0 comments (0 inline, 0 general)
src/mainwindow.cpp
Show inline comments
 
@@ -147,6 +147,9 @@ MainWindow::MainWindow(QWidget *parent) 
 
    connect(&plotControlPanel, &PlotControlPanel::xScaleChanged,
 
            plotMan, &PlotManager::setXAxis);
 

	
 
    connect(&plotControlPanel, &PlotControlPanel::plotWidthChanged,
 
            plotMan, &PlotManager::setPlotWidth);
 

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

	
 
@@ -222,6 +225,7 @@ MainWindow::MainWindow(QWidget *parent) 
 
    plotMan->setXAxis(plotControlPanel.xAxisAsIndex(),
 
                      plotControlPanel.xMin(), plotControlPanel.xMax());
 
    plotMan->setNumOfSamples(numOfSamples);
 
    plotMan->setPlotWidth(plotControlPanel.plotWidth());
 

	
 
    // Init sps (sample per second) counter
 
    spsLabel.setText("0sps");
src/plot.cpp
Show inline comments
 
@@ -348,3 +348,8 @@ void Plot::setNumOfSamples(unsigned valu
 
    numOfSamples = value;
 
    onXScaleChanged();
 
}
 

	
 
void Plot::setPlotWidth(double width)
 
{
 
    zoomer.setHViewSize(width);
 
}
src/plot.h
Show inline comments
 
@@ -73,6 +73,8 @@ public slots:
 

	
 
    void setNumOfSamples(unsigned value);
 

	
 
    void setPlotWidth(double width);
 

	
 
protected:
 
    /// update the display of symbols depending on `symbolSize`
 
    void updateSymbols();
src/plotcontrolpanel.cpp
Show inline comments
 
@@ -89,6 +89,9 @@ PlotControlPanel::PlotControlPanel(QWidg
 
    connect(ui->spXmin, SIGNAL(valueChanged(double)),
 
            this, SLOT(onXScaleChanged()));
 

	
 
    connect(ui->spPlotWidth, SIGNAL(valueChanged(int)),
 
            this, SLOT(onPlotWidthChanged()));
 

	
 
    // init scale range preset list
 
    for (int nbits = 8; nbits <= 24; nbits++) // signed binary formats
 
    {
 
@@ -275,6 +278,7 @@ void PlotControlPanel::onIndexChecked(bo
 

	
 
        emit xScaleChanged(false, ui->spXmin->value(), ui->spXmax->value());
 
    }
 
    emit plotWidthChanged(plotWidth());
 
}
 

	
 
void PlotControlPanel::onXScaleChanged()
 
@@ -282,9 +286,29 @@ void PlotControlPanel::onXScaleChanged()
 
    if (!xAxisAsIndex())
 
    {
 
        emit xScaleChanged(false, ui->spXmin->value(), ui->spXmax->value());
 
        emit plotWidthChanged(plotWidth());
 
    }
 
}
 

	
 
double PlotControlPanel::plotWidth() const
 
{
 
    double value = ui->spPlotWidth->value();
 
    if (!xAxisAsIndex())
 
    {
 
        // scale by xmin and xmax
 
        auto xmax = ui->spXmax->value();
 
        auto xmin = ui->spXmin->value();
 
        double scale = (xmax - xmin) / _numOfSamples;
 
        value *= scale;
 
    }
 
    return value;
 
}
 

	
 
void PlotControlPanel::onPlotWidthChanged()
 
{
 
    emit plotWidthChanged(plotWidth());
 
}
 

	
 
void PlotControlPanel::setChannelInfoModel(ChannelInfoModel* model)
 
{
 
    ui->tvChannelInfo->setModel(model);
src/plotcontrolpanel.h
Show inline comments
 
@@ -46,6 +46,7 @@ public:
 
    bool   xAxisAsIndex() const;
 
    double xMax() const;
 
    double xMin() const;
 
    double plotWidth() const;
 

	
 
    void setChannelInfoModel(ChannelInfoModel* model);
 

	
 
@@ -58,6 +59,7 @@ signals:
 
    void numOfSamplesChanged(int value);
 
    void yScaleChanged(bool autoScaled, double yMin = 0, double yMax = 1);
 
    void xScaleChanged(bool asIndex, double xMin = 0, double xMax = 1);
 
    void plotWidthChanged(double width);
 

	
 
private:
 
    Ui::PlotControlPanel *ui;
 
@@ -80,6 +82,7 @@ private slots:
 
    void onRangeSelected();
 
    void onIndexChecked(bool checked);
 
    void onXScaleChanged();
 
    void onPlotWidthChanged();
 
};
 

	
 
#endif // PLOTCONTROLPANEL_H
src/plotcontrolpanel.ui
Show inline comments
 
@@ -7,7 +7,7 @@
 
    <x>0</x>
 
    <y>0</y>
 
    <width>706</width>
 
    <height>187</height>
 
    <height>195</height>
 
   </rect>
 
  </property>
 
  <property name="windowTitle">
 
@@ -132,15 +132,24 @@
 
     </property>
 
     <item row="0" column="0">
 
      <widget class="QLabel" name="label_3">
 
       <property name="toolTip">
 
        <string/>
 
       </property>
 
       <property name="text">
 
        <string>Number Of Samples:</string>
 
        <string>Buffer Size:</string>
 
       </property>
 
      </widget>
 
     </item>
 
     <item row="0" column="1">
 
      <widget class="QSpinBox" name="spNumOfSamples">
 
       <property name="minimumSize">
 
        <size>
 
         <width>80</width>
 
         <height>0</height>
 
        </size>
 
       </property>
 
       <property name="toolTip">
 
        <string>length of X axis</string>
 
        <string>Length of acquisition as number of samples</string>
 
       </property>
 
       <property name="keyboardTracking">
 
        <bool>false</bool>
 
@@ -156,7 +165,7 @@
 
       </property>
 
      </widget>
 
     </item>
 
     <item row="1" column="0">
 
     <item row="2" column="0">
 
      <widget class="QCheckBox" name="cbIndex">
 
       <property name="text">
 
        <string>Index as X AXis</string>
 
@@ -166,7 +175,7 @@
 
       </property>
 
      </widget>
 
     </item>
 
     <item row="1" column="1">
 
     <item row="2" column="1">
 
      <layout class="QHBoxLayout" name="horizontalLayout_4">
 
       <item>
 
        <widget class="QLabel" name="lXmin">
 
@@ -237,7 +246,7 @@
 
       </item>
 
      </layout>
 
     </item>
 
     <item row="2" column="0">
 
     <item row="3" column="0">
 
      <widget class="QCheckBox" name="cbAutoScale">
 
       <property name="text">
 
        <string>Auto Scale Y Axis</string>
 
@@ -247,7 +256,7 @@
 
       </property>
 
      </widget>
 
     </item>
 
     <item row="2" column="1">
 
     <item row="3" column="1">
 
      <layout class="QHBoxLayout" name="horizontalLayout_3">
 
       <item>
 
        <widget class="QLabel" name="lYmin">
 
@@ -318,16 +327,51 @@
 
       </item>
 
      </layout>
 
     </item>
 
     <item row="5" column="0">
 
     <item row="6" column="0">
 
      <widget class="QLabel" name="label">
 
       <property name="text">
 
        <string>Select Range Preset:</string>
 
       </property>
 
      </widget>
 
     </item>
 
     <item row="5" column="1">
 
     <item row="6" column="1">
 
      <widget class="QComboBox" name="cbRangePresets"/>
 
     </item>
 
     <item row="1" column="0">
 
      <widget class="QLabel" name="label_4">
 
       <property name="toolTip">
 
        <string/>
 
       </property>
 
       <property name="text">
 
        <string>Plot Width:</string>
 
       </property>
 
      </widget>
 
     </item>
 
     <item row="1" column="1">
 
      <widget class="QSpinBox" name="spPlotWidth">
 
       <property name="minimumSize">
 
        <size>
 
         <width>80</width>
 
         <height>0</height>
 
        </size>
 
       </property>
 
       <property name="toolTip">
 
        <string>Width of X axis as maximum number of samples that are shown in plot</string>
 
       </property>
 
       <property name="keyboardTracking">
 
        <bool>false</bool>
 
       </property>
 
       <property name="minimum">
 
        <number>2</number>
 
       </property>
 
       <property name="maximum">
 
        <number>100000</number>
 
       </property>
 
       <property name="value">
 
        <number>1000</number>
 
       </property>
 
      </widget>
 
     </item>
 
    </layout>
 
   </item>
 
   <item>
src/plotmanager.cpp
Show inline comments
 
@@ -542,6 +542,15 @@ void PlotManager::setNumOfSamples(unsign
 
    }
 
}
 

	
 
void PlotManager::setPlotWidth(double width)
 
{
 
    _plotWidth = width;
 
    for (auto plot : plotWidgets)
 
    {
 
        plot->setPlotWidth(width);
 
    }
 
}
 

	
 
PlotViewSettings PlotManager::viewSettings() const
 
{
 
    return PlotViewSettings(
src/plotmanager.h
Show inline comments
 
@@ -88,6 +88,8 @@ public slots:
 
    void flashSnapshotOverlay();
 
    /// Should be called to update zoom base
 
    void setNumOfSamples(unsigned value);
 
    /// Maximum width of X axis (limit of hscroll)
 
    void setPlotWidth(double width);
 

	
 
private:
 
    bool isMulti;
 
@@ -106,6 +108,7 @@ private:
 
    double _xMin;
 
    double _xMax;
 
    unsigned _numOfSamples;
 
    double _plotWidth;
 
    Plot::ShowSymbols showSymbols;
 

	
 
    // menu actions
src/scrollzoomer.cpp
Show inline comments
 
@@ -70,12 +70,12 @@ void ScrollZoomer::setXLimits(double min
 
    xMin = min;
 
    xMax = max;
 
    setZoomBase();
 
    // TODO: should we update zoom base here?
 
}
 

	
 
void ScrollZoomer::setHViewSize(double size)
 
{
 
    hViewSize = size;
 
    setZoomBase();
 
}
 

	
 
void ScrollZoomer::setZoomBase(bool doReplot)
0 comments (0 inline, 0 general)