traverso-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Traverso-commit] traverso/src/sheetcanvas AudioClipView.cpp Audi...


From: Nicola Doebelin
Subject: [Traverso-commit] traverso/src/sheetcanvas AudioClipView.cpp Audi...
Date: Tue, 24 Feb 2009 21:28:57 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Nicola Doebelin <n_doebelin>    09/02/24 21:28:57

Modified files:
        src/sheetcanvas: AudioClipView.cpp AudioClipView.h 

Log message:
        * new implementation of the db-line drawing

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/AudioClipView.cpp?cvsroot=traverso&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/traverso/src/sheetcanvas/AudioClipView.h?cvsroot=traverso&r1=1.7&r2=1.8

Patches:
Index: AudioClipView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/sheetcanvas/AudioClipView.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- AudioClipView.cpp   23 Feb 2009 20:14:59 -0000      1.18
+++ AudioClipView.cpp   24 Feb 2009 21:28:57 -0000      1.19
@@ -201,6 +201,11 @@
                draw_clipinfo_area(painter, xstart, pixelcount);
        }
        
+       // Draw the db lines at 0 and -6 db
+       if (m_drawDbGrid) {
+               draw_db_lines(painter, xstart, pixelcount);
+       }
+
        // Draw the contour
        painter->setPen(themer()->get_color("AudioClip:contour"));
        int adjust = 0;
@@ -410,34 +415,6 @@
                        
p->setPen(themer()->get_color("AudioClip:wavemicroview"));
                        p->drawPolyline(m_polygon);
                
-                       // draw lines at 0 and -6 db
-                       if (m_drawDbGrid) {
-                               if (m_height >= m_mimimumheightforinfoarea) {
-                                       p->setMatrix(matrix().translate(0, 
m_infoAreaHeight), true);
-                               }
-                               p->setMatrix(matrix().translate(0, ytrans), 
true);
-
-                               float scale = scaleFactor;
-                               if (m_mergedView) {
-                                       scale = channels;
-                               }
-
-                               
p->setPen(themer()->get_color("AudioClip:db-grid"));
-                               p->setFont( 
themer()->get_font("AudioClip:fontscale:dblines") );
-
-                               p->drawLine(m_lineOffset, -0.45 * scale * 
height, xstart+pixelcount, -0.45 * scale * height);
-                               p->drawText(0.0, -0.45 * scale * height - 1 + 
m_lineVOffset, "  0 dB");
-
-                               p->drawLine(m_lineOffset, 0.45 * scale * height 
+ 1, xstart+pixelcount, 0.45 * scale * height + 1);
-                               p->drawText(0.0, 0.45 * scale * height + 
m_lineVOffset, "  0 dB");
-
-                               p->drawLine(m_lineOffset, -0.225 * scale * 
height, xstart+pixelcount, -0.225 * scale * height);
-                               p->drawText(0.0, -0.225 * scale * height - 1 + 
m_lineVOffset, " -6 dB");
-
-                               p->drawLine(m_lineOffset, 0.225 * scale * 
height + 1, xstart+pixelcount, 0.225 * scale * height + 1);
-                               p->drawText(0.0, 0.225 * scale * height + 
m_lineVOffset, " -6 dB");
-                       }
-
                // Macroview, paint waveform with painterpath
                } else {
                        if (m_fillwave) {
@@ -507,33 +484,6 @@
                                p->setPen(minINFLineColor);
                                p->drawLine(0, 0, pixelcount, 0);
 
-                               // draw lines at 0 and -6 db
-                               if (m_drawDbGrid) {
-                                       if (m_height >= 
m_mimimumheightforinfoarea) {
-                                               
p->setMatrix(matrix().translate(0, m_infoAreaHeight), true);
-                                       }
-                                       p->setMatrix(matrix().translate(0, 
ytrans), true);
-
-                                       int scale = 1;
-                                       if (m_mergedView) {
-                                               scale = channels;
-                                       }
-
-                                       
p->setPen(themer()->get_color("AudioClip:db-grid"));
-                                       p->setFont( 
themer()->get_font("AudioClip:fontscale:dblines") );
-
-                                       p->drawLine(m_lineOffset, -0.45 * scale 
* height, xstart+pixelcount, -0.45 * scale * height);
-                                       p->drawText(0.0, -0.45 * scale * height 
- 1 + m_lineVOffset, "  0 dB");
-
-                                       p->drawLine(m_lineOffset, 0.45 * scale 
* height + 1, xstart+pixelcount, 0.45 * scale * height + 1);
-                                       p->drawText(0.0, 0.45 * scale * height 
+ m_lineVOffset, "  0 dB");
-
-                                       p->drawLine(m_lineOffset, -0.225 * 
scale * height, xstart+pixelcount, -0.225 * scale * height);
-                                       p->drawText(0.0, -0.225 * scale * 
height - 1 + m_lineVOffset, " -6 dB");
-
-                                       p->drawLine(m_lineOffset, 0.225 * scale 
* height + 1, xstart+pixelcount, 0.225 * scale * height + 1);
-                                       p->drawText(0.0, 0.225 * scale * height 
+ m_lineVOffset, " -6 dB");
-                               }
                        } else {
                                scaleFactor =  (float) height * 0.95 * 
m_clip->get_gain() / Peak::MAX_DB_VALUE * curveDefaultValue;
                                ytrans = height + (chan * height);
@@ -560,42 +510,95 @@
                                
                                p->drawPath(path);
 
-                               // draw lines at 0 and -6 db
-                               if (m_drawDbGrid) {
+                       }
+               }
+               
+               p->restore();
+       }
+}
+
+void AudioClipView::draw_clipinfo_area(QPainter* p, int xstart, int pixelcount)
+{
+       // fill info area bg
+       p->fillRect(xstart, 1, pixelcount, m_infoAreaHeight, 
themer()->get_color("AudioClip:clipinfobackground:inactive"));
                                        if (m_height >= 
m_mimimumheightforinfoarea) {
-                                               
p->setMatrix(matrix().translate(0, m_infoAreaHeight), true);
+               p->drawPixmap(7, 1, m_clipInfo);
                                        }
-                                       p->setMatrix(matrix().translate(0, 
ytrans), true);
+}
+
+
+void AudioClipView::draw_db_lines(QPainter* p, qreal xstart, int pixelcount)
+{
+       p->save();
+
+       int height;
+       int channels = m_clip->get_channels();
+       bool microView = m_sheet->get_hzoom() < 64 ? 1 : 0;
 
-                                       int scale = 1;
                                        if (m_mergedView) {
-                                               scale = channels;
+               channels = 1;
+       }
+
+       // calculate the height of one channel
+       if (m_height >= m_mimimumheightforinfoarea) {
+               p->setMatrix(matrix().translate(0, m_infoAreaHeight), true);
+               height = (m_height - m_infoAreaHeight) / channels;
+       } else {
+               height = m_height / channels;
                                        }
 
                                        
p->setPen(themer()->get_color("AudioClip:db-grid"));
                                        p->setFont( 
themer()->get_font("AudioClip:fontscale:dblines") );
 
-                                       p->drawLine(m_lineOffset, -0.95 * scale 
* height, xstart+pixelcount, -0.95 * scale *  height);
-                                       p->drawText(0.0, -0.95 * scale * height 
- 1 + m_lineVOffset, "  0 dB");
+       if (m_classicView || microView) { // classicView = non-rectified
+
+               // translate the painter to set the first channel center line 
to 0
+               p->setMatrix(matrix().translate(0, height / 2), true);
+
+               // determine the distance of the db line from the center line
+               int zeroDb = 0.9 * height / 2;
+               int msixDb = 0.9 * height / 4;
+
+               // draw the lines above and below the center line, then 
translate
+               // the painter to the next channel
+               for (int i = 0; i < channels; ++i) {
+                       p->drawLine(m_lineOffset, zeroDb, xstart+pixelcount, 
zeroDb);
+                       p->drawText(0.0, zeroDb - 1 + m_lineVOffset, "  0 dB");
+
+                       p->drawLine(m_lineOffset, -zeroDb, xstart+pixelcount, 
-zeroDb);
+                       p->drawText(0.0, -zeroDb + m_lineVOffset, "  0 dB");
+
+                       p->drawLine(m_lineOffset, msixDb, xstart+pixelcount, 
msixDb);
+                       p->drawText(0.0, msixDb + m_lineVOffset, " -6 dB");
 
-                                       p->drawLine(m_lineOffset, -0.475 * 
scale * height, xstart+pixelcount, -0.475 * scale * height);
-                                       p->drawText(0.0, -0.475 * scale * 
height - 1 + m_lineVOffset, " -6 dB");
+                       p->drawLine(m_lineOffset, -msixDb + 1, 
xstart+pixelcount, -msixDb + 1);
+                       p->drawText(0.0, -msixDb + m_lineVOffset, " -6 dB");
+
+                       p->setMatrix(matrix().translate(0, height), true);
                                }
+       } else {  // rectified
+
+               // translate the painter to set the first channel base line to 0
+               p->setMatrix(matrix().translate(0, height), true);              
+
+               // determine the distance of the db line from the center line
+               int zeroDb = 0.95 * height;
+               int msixDb = 0.95 * height / 2;
+
+               // draw the lines above the center line, then translate
+               // the painter to the next channel
+               for (int i = 0; i < channels; ++i) {
+                       p->drawLine(m_lineOffset, -zeroDb, xstart+pixelcount, 
-zeroDb);
+                       p->drawText(0.0, -zeroDb + m_lineVOffset, "  0 dB");
+
+                       p->drawLine(m_lineOffset, -msixDb + 1, 
xstart+pixelcount, -msixDb + 1);
+                       p->drawText(0.0, -msixDb + m_lineVOffset, " -6 dB");
 
+                       p->setMatrix(matrix().translate(0, height), true);
                        }
                }
                
                p->restore();
-       }
-}
-
-void AudioClipView::draw_clipinfo_area(QPainter* p, int xstart, int pixelcount)
-{
-       // fill info area bg
-       p->fillRect(xstart, 1, pixelcount, m_infoAreaHeight, 
themer()->get_color("AudioClip:clipinfobackground:inactive"));
-       if (m_height >= m_mimimumheightforinfoarea) {
-               p->drawPixmap(7, 1, m_clipInfo);
-       }
 }
 
 void AudioClipView::create_brushes()

Index: AudioClipView.h
===================================================================
RCS file: /sources/traverso/traverso/src/sheetcanvas/AudioClipView.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- AudioClipView.h     22 Feb 2009 19:48:15 -0000      1.7
+++ AudioClipView.h     24 Feb 2009 21:28:57 -0000      1.8
@@ -122,6 +122,7 @@
        void create_clipinfo_string();
 
        void draw_clipinfo_area(QPainter* painter, int xstart, int pixelcount);
+       void draw_db_lines(QPainter* painter, qreal xstart, int pixelcount);
        void draw_peaks(QPainter* painter, qreal xstart, int pixelcount);
        void create_brushes();
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]