From e1d3a756ccc197ab443358a9de33c2e013c85052 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Mon, 22 Mar 2021 11:05:19 -0400 Subject: [PATCH] 2021-03-22 Fred Gleason * Implemented movable reference lines for 'Cut Gain' adjustments in 'RDMarkerDialog'. Signed-off-by: Fred Gleason --- ChangeLog | 3 +++ lib/rdmarkerview.cpp | 33 +++++++++++++++++++++++++++++++-- lib/rdmarkerview.h | 2 ++ lib/rdwavefactory.cpp | 6 ++++-- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6537e6a5..e760d38e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21327,3 +21327,6 @@ 2021-03-21 Fred Gleason * Fixed a bug in 'RDMarkerPlayer' that would cause the play cursor position to fail to be properly initialized when opening a new cut. +2021-03-22 Fred Gleason + * Implemented movable reference lines for 'Cut Gain' adjustments + in 'RDMarkerDialog'. diff --git a/lib/rdmarkerview.cpp b/lib/rdmarkerview.cpp index 91c64e1e..71327551 100644 --- a/lib/rdmarkerview.cpp +++ b/lib/rdmarkerview.cpp @@ -569,8 +569,11 @@ void RDMarkerView::setNoSegueFade(bool state) void RDMarkerView::setPlayGain(int db) { - d_has_unsaved_changes=db!=d_play_gain; - d_play_gain=db; + if(db!=d_play_gain) { + d_play_gain=db; + d_has_unsaved_changes=true; + SetReferenceLines(); + } } @@ -1100,6 +1103,18 @@ void RDMarkerView::WriteWave() d_scene->addRect(LEFT_MARGIN+wavemap.width(),0,d_pad_size,d_height-20,QPen(Qt::gray),QBrush(Qt::gray)); d_right_margin=LEFT_MARGIN+wavemap.width(); + // + // Reference Level Lines + // + for(unsigned i=0;isetPen(QPen(Qt::red)); + d_scene->addItem(d_reference_line_items[i][j]); + } + } + SetReferenceLines(); + // // Markers // @@ -1174,3 +1189,17 @@ void RDMarkerView::RemoveMarker(RDMarkerHandle::PointerRole role) emit pointerValueChanged(role,-1); } + + +void RDMarkerView::SetReferenceLines() +{ + int sh=d_scene->height(); + double ratio=exp10((double)(d_audio_gain-100*d_play_gain)/2000.0); + int ref_line=exp10((double)(-REFERENCE_LEVEL)/2000.00)*sh*ratio/ + ((double)d_channels*2.0); + for(unsigned i=0;isetPos(0,zero_line+ref_line); + d_reference_line_items[i][1]->setPos(0,zero_line-ref_line); + } +} diff --git a/lib/rdmarkerview.h b/lib/rdmarkerview.h index 17339d2e..d845f9ba 100644 --- a/lib/rdmarkerview.h +++ b/lib/rdmarkerview.h @@ -145,6 +145,7 @@ class RDMarkerView : public QWidget void DrawMarker(RDMarkerHandle::PointerType type, RDMarkerHandle::PointerRole role,int handle_pos); void RemoveMarker(RDMarkerHandle::PointerRole role); + void SetReferenceLines(); QGraphicsView *d_view; QGraphicsScene *d_scene; unsigned d_cart_number; @@ -180,6 +181,7 @@ class RDMarkerView : public QWidget bool d_marker_menu_used; RDMarkerHandle::PointerRole d_selected_markers[2]; int d_wheel_angle; + QGraphicsLineItem *d_reference_line_items[2][2]; }; diff --git a/lib/rdwavefactory.cpp b/lib/rdwavefactory.cpp index fcbd2cd4..05a2fd6e 100644 --- a/lib/rdwavefactory.cpp +++ b/lib/rdwavefactory.cpp @@ -96,12 +96,13 @@ QPixmap RDWaveFactory::generate(int height,int x_shrink,int gain, // Waveform // p->setPen(Qt::black); - int ref_line=exp10((double)(-REFERENCE_LEVEL)/2000.00)*height*ratio/ - ((double)d_energy_channels*2.0); + // int ref_line=exp10((double)(-REFERENCE_LEVEL)/2000.00)*height*ratio/ + // ((double)d_energy_channels*2.0); int clip_line=height/(2*d_energy_channels); for(unsigned i=0;isetPen(Qt::red); p->drawLine(0,zero_line+ref_line, @@ -110,6 +111,7 @@ QPixmap RDWaveFactory::generate(int height,int x_shrink,int gain, d_energy.size()/x_shrink,zero_line-ref_line); p->setPen(Qt::black); } + */ } p->drawLine(0,zero_line,d_energy.size()/x_shrink,zero_line); for(int j=i;j