]> sigrok.org Git - pulseview.git/commitdiff
Use getter for the conversion type instead of a local copy
authorSoeren Apel <redacted>
Tue, 25 Jul 2017 14:09:08 +0000 (16:09 +0200)
committerSoeren Apel <redacted>
Tue, 25 Jul 2017 14:09:08 +0000 (16:09 +0200)
Don't ask me why I used a local copy in the first place,
even I can't figure it out :)

pv/data/signalbase.cpp
pv/data/signalbase.hpp
pv/views/trace/analogsignal.cpp
pv/views/trace/analogsignal.hpp

index b43e5bb07f4db8e92c9c797aeb6daa1efc16ce55..0e887b4c8bcd5c38ad2d10a09e3db8a2441cab2e 100644 (file)
@@ -174,6 +174,11 @@ shared_ptr<data::Logic> SignalBase::logic_data() const
        return result;
 }
 
+SignalBase::ConversionType SignalBase::get_conversion_type() const
+{
+       return conversion_type_;
+}
+
 void SignalBase::set_conversion_type(ConversionType t)
 {
        if (conversion_type_ != NoConversion) {
index 635db6604bc0e314730375cda8456e2fdfb5b245..a2d23244f0e1d007aad79543f909fce796c8ab0c 100644 (file)
@@ -157,6 +157,11 @@ public:
         */
        shared_ptr<pv::data::Logic> logic_data() const;
 
+       /**
+        * Queries the kind of conversion performed on this channel.
+        */
+       ConversionType get_conversion_type() const;
+
        /**
         * Changes the kind of conversion performed on this channel.
         */
@@ -209,7 +214,7 @@ protected:
        ChannelType channel_type_;
        shared_ptr<pv::data::SignalData> data_;
        shared_ptr<pv::data::SignalData> converted_data_;
-       int conversion_type_;
+       ConversionType conversion_type_;
 
        std::thread conversion_thread_;
        atomic<bool> conversion_interrupt_;
index e26b203a2d197aa1161c3d63752ebf0ea3dcdfc9..c346fd5bce4c8d2bc52f5ae3e0981905f6fa3d13 100644 (file)
@@ -92,7 +92,6 @@ AnalogSignal::AnalogSignal(
        pos_vdivs_(1),
        neg_vdivs_(1),
        resolution_(0),
-       conversion_type_(data::SignalBase::NoConversion),
        display_type_(DisplayBoth),
        autoranging_(true)
 {
@@ -119,7 +118,6 @@ void AnalogSignal::save_settings(QSettings &settings) const
        settings.setValue("pos_vdivs", pos_vdivs_);
        settings.setValue("neg_vdivs", neg_vdivs_);
        settings.setValue("scale_index", scale_index_);
-       settings.setValue("conversion_type", conversion_type_);
        settings.setValue("display_type", display_type_);
        settings.setValue("autoranging", autoranging_);
        settings.setValue("div_height", div_height_);
@@ -138,11 +136,6 @@ void AnalogSignal::restore_settings(QSettings &settings)
                update_scale();
        }
 
-       if (settings.contains("conversion_type")) {
-               conversion_type_ = (data::SignalBase::ConversionType)(settings.value("conversion_type").toInt());
-               update_conversion_type();
-       }
-
        if (settings.contains("display_type"))
                display_type_ = (DisplayType)(settings.value("display_type").toInt());
 
@@ -243,8 +236,11 @@ void AnalogSignal::paint_mid(QPainter &p, ViewItemPaintParams &pp)
        }
 
        if ((display_type_ == DisplayConverted) || (display_type_ == DisplayBoth)) {
-               if (((conversion_type_ == data::SignalBase::A2LConversionByTreshold) ||
-                       (conversion_type_ == data::SignalBase::A2LConversionBySchmittTrigger))) {
+               const data::SignalBase::ConversionType conv_type =
+                       base_->get_conversion_type();
+
+               if (((conv_type == data::SignalBase::A2LConversionByTreshold) ||
+                       (conv_type == data::SignalBase::A2LConversionBySchmittTrigger))) {
 
                        paint_logic_mid(p, pp);
                }
@@ -594,14 +590,6 @@ void AnalogSignal::update_scale()
        scale_ = div_height_ / resolution_;
 }
 
-void AnalogSignal::update_conversion_type()
-{
-       base_->set_conversion_type(conversion_type_);
-
-       if (owner_)
-               owner_->row_item_appearance_changed(false, true);
-}
-
 void AnalogSignal::perform_autoranging(bool keep_divs, bool force_update)
 {
        const deque< shared_ptr<pv::data::AnalogSegment> > &segments =
@@ -740,7 +728,7 @@ void AnalogSignal::populate_popup_form(QWidget *parent, QFormLayout *form)
        conversion_cb_->addItem("to logic via threshold", data::SignalBase::A2LConversionByTreshold);
        conversion_cb_->addItem("to logic via schmitt-trigger", data::SignalBase::A2LConversionBySchmittTrigger);
 
-       cur_idx = conversion_cb_->findData(QVariant(conversion_type_));
+       cur_idx = conversion_cb_->findData(QVariant(base_->get_conversion_type()));
        conversion_cb_->setCurrentIndex(cur_idx);
 
        layout->addRow(tr("Conversion"), conversion_cb_);
@@ -870,13 +858,17 @@ void AnalogSignal::on_autoranging_changed(int state)
 
 void AnalogSignal::on_conversion_changed(int index)
 {
-       data::SignalBase::ConversionType old_conv_type = conversion_type_;
+       data::SignalBase::ConversionType old_conv_type =
+               base_->get_conversion_type();
 
-       conversion_type_ = (data::SignalBase::ConversionType)(conversion_cb_->itemData(index).toInt());
+       data::SignalBase::ConversionType conv_type =
+               (data::SignalBase::ConversionType)(conversion_cb_->itemData(index).toInt());
 
-       if (conversion_type_ != old_conv_type) {
-               base_->set_conversion_type(conversion_type_);
-               update_conversion_type();
+       if (conv_type != old_conv_type) {
+               base_->set_conversion_type(conv_type);
+
+               if (owner_)
+                       owner_->row_item_appearance_changed(false, true);
        }
 }
 
index a67c4ff37185d1ee63bebf8c6b8c32516a1f9a3c..07b667119b6a7e78a9633971aa2afaa1da9a9075 100644 (file)
@@ -144,8 +144,6 @@ private:
 
        void update_scale();
 
-       void update_conversion_type();
-
        void perform_autoranging(bool keep_divs, bool force_update);
 
 protected:
@@ -178,7 +176,6 @@ private:
        int pos_vdivs_, neg_vdivs_;  // divs per positive/negative side
        float resolution_; // e.g. 10 for 10 V/div
 
-       data::SignalBase::ConversionType conversion_type_;
        DisplayType display_type_;
        bool autoranging_;
 };