X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fanalogsignal.cpp;h=3291c1615f4fb253048ae36468fc191a04c3840a;hp=8ccad390eb4730ee8436d34007f133833579d329;hb=efdec55aec1a137460fa362a381ed1904182bfed;hpb=bf0edd2b0cbb5f4bd5d69b0f00bcea7d037e2287 diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 8ccad39..3291c16 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -14,8 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * along with this program; if not, see . */ #include @@ -48,7 +47,8 @@ using std::shared_ptr; using std::deque; namespace pv { -namespace view { +namespace views { +namespace TraceView { const QColor AnalogSignal::SignalColours[4] = { QColor(0xC4, 0xA0, 0x00), // Yellow @@ -71,28 +71,38 @@ const int AnalogSignal::InfoTextMarginBottom = 5; AnalogSignal::AnalogSignal( pv::Session &session, - shared_ptr channel, - shared_ptr data) : - Signal(session, channel), - data_(data), + shared_ptr base) : + Signal(session, base), scale_index_(4), // 20 per div scale_index_drag_offset_(0), div_height_(3 * QFontMetrics(QApplication::font()).height()), vdivs_(1), resolution_(0) { - channel_->set_colour(SignalColours[channel_->index() % countof(SignalColours)]); + base_->set_colour(SignalColours[base_->index() % countof(SignalColours)]); update_scale(); } shared_ptr AnalogSignal::data() const { - return data_; + return base_->analog_data(); } -shared_ptr AnalogSignal::analog_data() const +void AnalogSignal::save_settings(QSettings &settings) const { - return data_; + settings.setValue("vdivs", vdivs_); + settings.setValue("scale_index", scale_index_); +} + +void AnalogSignal::restore_settings(QSettings &settings) +{ + if (settings.contains("vdivs")) + vdivs_ = settings.value("vdivs").toInt(); + + if (settings.contains("scale_index")) { + scale_index_ = settings.value("scale_index").toInt(); + update_scale(); + } } std::pair AnalogSignal::v_extents() const @@ -127,7 +137,7 @@ void AnalogSignal::scale_handle_drag_release() void AnalogSignal::paint_back(QPainter &p, const ViewItemPaintParams &pp) { - if (channel_->enabled()) { + if (base_->enabled()) { Trace::paint_back(p, pp); paint_axis(p, pp, get_visual_y()); } @@ -135,18 +145,18 @@ void AnalogSignal::paint_back(QPainter &p, const ViewItemPaintParams &pp) void AnalogSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp) { - assert(data_); + assert(base_->analog_data()); assert(owner_); const int y = get_visual_y(); - if (!channel_->enabled()) + if (!base_->enabled()) return; paint_grid(p, y, pp.left(), pp.right()); const deque< shared_ptr > &segments = - data_->analog_segments(); + base_->analog_data()->analog_segments(); if (segments.empty()) return; @@ -186,7 +196,7 @@ void AnalogSignal::paint_fore(QPainter &p, const ViewItemPaintParams &pp) // Show the info section on the right side of the trace const QString infotext = QString("%1 V/div").arg(resolution_); - p.setPen(channel_->colour()); + p.setPen(base_->colour()); p.setFont(QApplication::font()); const QRectF bounding_rect = QRectF(pp.left(), @@ -235,7 +245,7 @@ void AnalogSignal::paint_trace(QPainter &p, const float *const samples = segment->get_samples(start, end); assert(samples); - p.setPen(channel_->colour()); + p.setPen(base_->colour()); QPointF *points = new QPointF[sample_count]; QPointF *point = points; @@ -267,7 +277,7 @@ void AnalogSignal::paint_envelope(QPainter &p, return; p.setPen(QPen(Qt::NoPen)); - p.setBrush(channel_->colour()); + p.setBrush(base_->colour()); QRectF *const rects = new QRectF[e.length]; QRectF *rect = rects; @@ -375,5 +385,6 @@ void AnalogSignal::on_resolution_changed(int index) owner_->row_item_appearance_changed(false, true); } -} // namespace view +} // namespace TraceView +} // namespace views } // namespace pv