Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move WOverview::drawNextPixmapPart() into new class WOverviewLMH (Low Mid High), also add new HSV waveform overview and interface, to select woverview type #17

Merged
merged 13 commits into from
Jun 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@ def sources(self, build):
"widget/wslider.cpp",
"widget/wstatuslight.cpp",
"widget/woverview.cpp",
"widget/woverviewlmh.cpp",
"widget/woverviewhsv.cpp",
"widget/wspinny.cpp",
"widget/wskincolor.cpp",
"widget/wabstractcontrol.cpp",
Expand Down
14 changes: 14 additions & 0 deletions src/dlgprefcontrols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,11 @@ void DlgPrefControls::slotSetWaveformType(int index) {
}
}

void DlgPrefControls::slotSetWaveformOverviewType(int index) {
m_pConfig->set(ConfigKey("[Waveform]","WaveformOverviewType"), ConfigValue(index));
m_mixxx->rebootMixxxView();
}

void DlgPrefControls::slotSetDefaultZoom(int index) {
WaveformWidgetFactory::instance()->setDefaultZoom( index + 1);
}
Expand Down Expand Up @@ -664,6 +669,15 @@ void DlgPrefControls::initWaveformControl()
connect(normalizeOverviewCheckBox,SIGNAL(toggled(bool)),
this,SLOT(slotSetNormalizeOverview(bool)));

// Waveform overview init
waveformOverviewComboBox->addItem( tr("Filtered") ); // "0"
waveformOverviewComboBox->addItem( tr("HSV") ); // "1"

// By default we set filtered woverview = "0"
waveformOverviewComboBox->setCurrentIndex(
m_pConfig->getValueString(ConfigKey("[Waveform]","WaveformOverviewType"), "0").toInt());
connect(waveformOverviewComboBox,SIGNAL(currentIndexChanged(int)),
this,SLOT(slotSetWaveformOverviewType(int)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add commends to clarify what "0" is and to clarify the relation between config options and ComboBox items/index.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add commends to clarify what "0" is

I wrote "By default we set filtered woverview", I must write something more?

and to clarify the relation between config options and ComboBox items/index.

Hmm... I don't understand, can you give an example?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Waveform overview init
waveformOverviewComboBox->addItem( tr("Filtered") ); // "0"
waveformOverviewComboBox->addItem( tr("HSV") ); // "1"

// By default we set "Filtered" woverview = "0"
waveformOverviewComboBox->setCurrentIndex(
m_pConfig->getValueString(ConfigKey("[Waveform]","WaveformOverviewType"), "0").toInt());

}

//Returns TRUE if skin fits to screen resolution, FALSE otherwise
Expand Down
1 change: 1 addition & 0 deletions src/dlgprefcontrols.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public slots:

void slotSetFrameRate(int frameRate);
void slotSetWaveformType(int index);
void slotSetWaveformOverviewType(int index);
void slotSetDefaultZoom(int index);
void slotSetZoomSynchronization(bool checked);
void slotSetVisualGainAll(double gain);
Expand Down
90 changes: 50 additions & 40 deletions src/dlgprefcontrolsdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>519</width>
<height>728</height>
<height>729</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -598,29 +598,20 @@
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<widget class="QLabel" name="waveformTypeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="6" column="2" colspan="4">
<widget class="QLabel" name="openGlStatusIcon">
<property name="toolTip">
<string>Displays which OpenGL version is supported by the current platform.</string>
</property>
<property name="text">
<string>Display type</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>waveformTypeComboBox</cstring>
<string/>
</property>
</widget>
</item>
<item row="0" column="2" colspan="4">
<widget class="QComboBox" name="waveformTypeComboBox"/>
</item>
<item row="1" column="2" colspan="2">
<item row="2" column="2" colspan="2">
<widget class="QSlider" name="frameRateSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
Expand Down Expand Up @@ -648,7 +639,7 @@
</property>
</widget>
</item>
<item row="1" column="4">
<item row="2" column="4">
<widget class="QSpinBox" name="frameRateSpinBox">
<property name="toolTip">
<string/>
Expand All @@ -664,7 +655,7 @@
</property>
</widget>
</item>
<item row="2" column="5">
<item row="3" column="5">
<widget class="QDoubleSpinBox" name="highVisualGain">
<property name="toolTip">
<string>Visual gain of the high frequencies</string>
Expand All @@ -683,7 +674,7 @@
</property>
</widget>
</item>
<item row="2" column="4">
<item row="3" column="4">
<widget class="QDoubleSpinBox" name="midVisualGain">
<property name="toolTip">
<string>Visual gain of the middle frequencies</string>
Expand All @@ -702,7 +693,7 @@
</property>
</widget>
</item>
<item row="2" column="3">
<item row="3" column="3">
<widget class="QDoubleSpinBox" name="lowVisualGain">
<property name="toolTip">
<string>Visual gain of the low frequencies</string>
Expand All @@ -721,7 +712,7 @@
</property>
</widget>
</item>
<item row="2" column="2">
<item row="3" column="2">
<widget class="QDoubleSpinBox" name="allVisualGain">
<property name="toolTip">
<string>Global visual gain</string>
Expand All @@ -740,7 +731,7 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="visualGainLabel">
<property name="text">
<string>Visual gain</string>
Expand All @@ -753,7 +744,7 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="frameRateLabel">
<property name="text">
<string>Frame rate</string>
Expand All @@ -766,10 +757,10 @@
</property>
</widget>
</item>
<item row="4" column="2" colspan="2">
<item row="5" column="2" colspan="2">
<widget class="QComboBox" name="defaultZoomComboBox"/>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="defaultZoomLabel">
<property name="text">
<string>Default zoom</string>
Expand All @@ -782,7 +773,7 @@
</property>
</widget>
</item>
<item row="4" column="4" colspan="2">
<item row="5" column="4" colspan="2">
<widget class="QCheckBox" name="synchronizeZoomCheckBox">
<property name="toolTip">
<string>Synchronize zoom level across all waveform displays.</string>
Expand All @@ -792,7 +783,7 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="openGlStatusLabel">
<property name="toolTip">
<string/>
Expand All @@ -805,17 +796,7 @@
</property>
</widget>
</item>
<item row="5" column="2" colspan="4">
<widget class="QLabel" name="openGlStatusIcon">
<property name="toolTip">
<string>Displays which OpenGL version is supported by the current platform.</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="5">
<item row="2" column="5">
<widget class="QLabel" name="frameRateAverage">
<property name="toolTip">
<string>Displays the actual frame rate.</string>
Expand All @@ -825,20 +806,49 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QLabel" name="dummySpacerLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="2" colspan="4">
<item row="4" column="2" colspan="4">
<widget class="QCheckBox" name="normalizeOverviewCheckBox">
<property name="text">
<string>Normalize Overview</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="waveformTypeLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Display type</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>waveformTypeComboBox</cstring>
</property>
</widget>
</item>
<item row="1" column="2" colspan="4">
<widget class="QComboBox" name="waveformOverviewComboBox"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="waveformOverviewLabel">
<property name="text">
<string>Preview type</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
13 changes: 11 additions & 2 deletions src/skin/legacyskinparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
#include "widget/wnumber.h"
#include "widget/wnumberpos.h"
#include "widget/wnumberrate.h"
#include "widget/woverview.h"
#include "widget/woverviewlmh.h"
#include "widget/woverviewhsv.h"
#include "widget/wspinny.h"
#include "widget/wwaveformviewer.h"
#include "waveform/waveformwidgetfactory.h"
Expand Down Expand Up @@ -595,7 +596,15 @@ QWidget* LegacySkinParser::parseOverview(QDomElement node) {
if (pPlayer == NULL)
return NULL;

WOverview* overviewWidget = new WOverview(pSafeChannelStr, m_pConfig, m_pParent);
WOverview* overviewWidget = NULL;

// HSV = "1" or "Filtered" = "0" (LMH) waveform overview type
if (m_pConfig->getValueString(ConfigKey("[Waveform]","WaveformOverviewType"),
"0").toInt() == 0) {
overviewWidget = new WOverviewLMH(pSafeChannelStr, m_pConfig, m_pParent);
} else {
overviewWidget = new WOverviewHSV(pSafeChannelStr, m_pConfig, m_pParent);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please brake the line at a reasonable point near column 80. Btw: I love braces in this case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this:

    if( m_pConfig->getValueString(ConfigKey("[Waveform]","WaveformOverviewType"),
            "0").toInt() == 0 ) {
        overviewWidget = new WOverviewLMH(pSafeChannelStr, m_pConfig, m_pParent);
    }
    else
        overviewWidget = new WOverviewHSV(pSafeChannelStr, m_pConfig, m_pParent);

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More like this:

    if (m_pConfig->getValueString(ConfigKey("[Waveform]", "WaveformOverviewType"),
            "0").toInt() == 0) {
        overviewWidget = new WOverviewLMH(pSafeChannelStr, m_pConfig, m_pParent);
    } else {
        overviewWidget = new WOverviewHSV(pSafeChannelStr, m_pConfig, m_pParent);
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

second line should be:

    if (m_pConfig->getValueString(ConfigKey("[Waveform]","WaveformOverviewType"),
                                  "0").toInt() == 0) {

or

    if (m_pConfig->getValueString(ConfigKey("[Waveform]","WaveformOverviewType"),
            "0").toInt() == 0) {

?

I mean ident

}

connect(overviewWidget, SIGNAL(trackDropped(QString, QString)),
m_pPlayerManager, SLOT(slotLoadToPlayer(QString, QString)));
Expand Down
103 changes: 0 additions & 103 deletions src/widget/woverview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,109 +248,6 @@ void WOverview::onMarkRangeChange(double /*v*/) {
update();
}

bool WOverview::drawNextPixmapPart() {
ScopedTimer t("WOverview::drawNextPixmapPart");

//qDebug() << "WOverview::drawNextPixmapPart() - m_waveform" << m_waveform;

int currentCompletion;

if (!m_pWaveform) {
return false;
}

const int dataSize = m_pWaveform->getDataSize();
if (dataSize == 0 ) {
return false;
}

if (!m_pWaveformSourceImage) {
//waveform pixmap twice the height of the viewport to be scalable by total_gain
//we keep full range waveform data to scale it on paint
m_pWaveformSourceImage = new QImage(dataSize / 2, 2 * 255, QImage::Format_ARGB32_Premultiplied);
m_pWaveformSourceImage->fill(QColor(0,0,0,0).value());
}

const int waveformCompletion = m_pWaveform->getCompletion(); // always multiple of 2
// test if there is some new to draw (at least of pixel width)
const int completionIncrement = waveformCompletion - m_actualCompletion;

int visiblePixelIncrement = completionIncrement * width() / dataSize;
if (completionIncrement < 2 || visiblePixelIncrement == 0) {
return false;
}

if (!m_pWaveform->getMutex()->tryLock()) {
return false;
}

const int nextCompletion = m_actualCompletion + completionIncrement;

//qDebug() << "WOverview::drawNextPixmapPart() - nextCompletion:" << nextCompletion
// << "m_actualCompletion:" << m_actualCompletion
// << "waveformCompletion:" << waveformCompletion
// << "completionIncrement:" << completionIncrement;


QPainter painter(m_pWaveformSourceImage);
painter.translate(0.0,(double)m_pWaveformSourceImage->height()/2.0);

QColor lowColor = m_signalColors.getLowColor();
QPen lowColorPen(QBrush(lowColor), 1);

QColor midColor = m_signalColors.getMidColor();
QPen midColorPen(QBrush(midColor), 1);

QColor highColor = m_signalColors.getHighColor();
QPen highColorPen(QBrush(highColor), 1);

for (currentCompletion = m_actualCompletion;
currentCompletion < nextCompletion; currentCompletion += 2) {
unsigned char lowNeg = m_pWaveform->getLow(currentCompletion);
unsigned char lowPos = m_pWaveform->getLow(currentCompletion+1);
if (lowPos || lowNeg) {
painter.setPen(lowColorPen);
painter.drawLine(QPoint(currentCompletion / 2, -lowNeg),
QPoint(currentCompletion / 2, lowPos));
}
}

for (currentCompletion = m_actualCompletion;
currentCompletion < nextCompletion; currentCompletion += 2) {
painter.setPen(midColorPen);
painter.drawLine(QPoint(currentCompletion / 2, - m_pWaveform->getMid(currentCompletion)),
QPoint(currentCompletion / 2, m_pWaveform->getMid(currentCompletion+1)));
}

for (currentCompletion = m_actualCompletion;
currentCompletion < nextCompletion; currentCompletion += 2) {
painter.setPen(highColorPen);
painter.drawLine(QPoint(currentCompletion / 2, - m_pWaveform->getHigh(currentCompletion)),
QPoint(currentCompletion / 2, m_pWaveform->getHigh(currentCompletion+1)));
}

//evaluate waveform ratio peak

for (currentCompletion = m_actualCompletion;
currentCompletion < nextCompletion; currentCompletion += 2) {
m_waveformPeak = math_max(m_waveformPeak, (float)m_pWaveform->getAll(currentCompletion));
m_waveformPeak = math_max(m_waveformPeak, (float)m_pWaveform->getAll(currentCompletion+1));
}

m_actualCompletion = nextCompletion;
m_waveformImageScaled = QImage();
m_diffGain = 0;

//test if the complete waveform is done
if (m_actualCompletion >= dataSize - 2) {
m_pixmapDone = true;
//qDebug() << "m_waveformPeakRatio" << m_waveformPeak;
}

m_pWaveform->getMutex()->unlock();
return true;
}

void WOverview::mouseMoveEvent(QMouseEvent* e) {
m_iPos = e->x();
m_iPos = math_max(0, math_min(m_iPos,width() - 1));
Expand Down
Loading