Changeset - c901d5cbc093
[Not reviewed]
barplot
0 3 0
Hasan Yavuz Ă–ZDERYA - 8 years ago 2017-10-05 08:52:44
hy@ozderya.net
slight code reduction
3 files changed with 6 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/barplot.cpp
Show inline comments
 
@@ -31,13 +31,11 @@ BarPlot::BarPlot(ChannelManager* channel
 
    update();
 
    connect(_channelMan, &ChannelManager::dataAdded, this, &BarPlot::update);
 
    connect(_channelMan, &ChannelManager::numOfChannelsChanged, this, &BarPlot::update);
 
    connect(_channelMan, &ChannelManager::channelNameChanged, this, &BarPlot::update);
 
}
 

	
 
void BarPlot::update()
 
{
 
    setAxisScale(QwtPlot::xBottom, 0, _channelMan->numOfChannels(), 1);
 
    static_cast<BarScaleDraw*>(axisScaleDraw(QwtPlot::xBottom))->updateLabels();
 
    barChart.resample();
 
    replot();
 
}
src/barscaledraw.cpp
Show inline comments
 
@@ -27,6 +27,12 @@ BarScaleDraw::BarScaleDraw(ChannelManage
 
    enableComponent(Backbone, false);
 
    setLabelRotation(-90);
 
    setLabelAlignment(Qt::AlignLeft | Qt::AlignVCenter);
 

	
 
    QObject::connect(_channelMan, &ChannelManager::channelNameChanged,
 
            [this]()
 
            {
 
                invalidateCache();
 
            });
 
}
 

	
 
QwtText BarScaleDraw::label(double value) const
 
@@ -34,8 +40,6 @@ QwtText BarScaleDraw::label(double value
 
    int index = value;
 
    unsigned numChannels = _channelMan->numOfChannels();
 

	
 
    qDebug() << index;
 

	
 
    if (index >=0 && index < (int) numChannels)
 
    {
 
        return _channelMan->channelName(index);
 
@@ -45,8 +49,3 @@ QwtText BarScaleDraw::label(double value
 
        return QString("");
 
    }
 
}
 

	
 
void BarScaleDraw::updateLabels()
 
{
 
    invalidateCache();
 
}
src/barscaledraw.h
Show inline comments
 
@@ -32,9 +32,6 @@ public:
 
    explicit BarScaleDraw(ChannelManager* channelMan);
 
    QwtText label(double value) const;
 

	
 
public slots:
 
    void updateLabels();
 

	
 
private:
 
    ChannelManager* _channelMan;
 
};
0 comments (0 inline, 0 general)