Files
lmms/plugins/Vectorscope/VecControls.h
Michael Gregorius 501011e573 Vectorscope render fix (#7652)
* Fix rendering for Vectorscope

The rendering of the Vectorscope is broken on Wayland if the size of the
Vectorscope is increased. This is caused by using a `QImage` to render
the scope traces which is then scaled up.

Introduce a new way to paint the vector scope (goniometer) which simply
paints lines or points that progressively get dimmer and which does not
make use of a QImage anymore.

It supports the following features:
* Log mode
* Zooming
* Rendering the drawing performance
* Selecting a different color for the traces

It does not support:
* HQ Mode: The new implementation provides a performance that's
  equivalent to Non-HQ mode and look similar or better than the HQ mode.
* Blurring of old data
* Persistence: Might be implemented by using a factor for the dimming

Rendering of the samples/trances uses the composition mode "Plus" so
that overlapping elements will appear like adding brightness. Painting
the grid and lines is done using the normal composition mode "Source
Over" so that it simply replaces existing pixels.

Painting of the lines/points and the grids and lines is done in a
"signal space", i.e. a transform where elements in the interval of
[-1, 1] feel "natural". The text is painted in "widget space".

* Remove old implementation

Remove HQ mode and persistence. Also remove the legacy option again.
This removes the models, loading, saving and the GUI controls.

Remove all unnecessary members from `VectorView`, adjust the
constructor. Move the implementation of `paintLinesMode` into
`paintEvent`. Remove methods `paintLegacyMode` and `paintLinesMode`.

* Move colors into VectorView

Move the colors out of `VecControls` into `VectorView` as they are
related to presentation.

* Remove friend relationship to VectorView

Remove a friend relationship to `VectorView` from `VecControls` by
introducing  const getters for the models.

* Remove VectorView::m_visible

Remove the unnecessary member `m_visible` from `VectorView`. It was not
initialized and only written to but never read.

* Make Vectorscope themeable

Make the Vectorscope themeable by introducing Qt properties for the
relevant colors.

The default theme gets the values from the code whereas the classic
theme gets a trace with amber color.

* Rename m_colorFG

Rename `m_colorFG` to `m_colorTrace`. Adjust the Qt property
accordingly.

Remove local variable `traceColor` from paint method and use member
`m_colorTrace` directly.

* Remove m_colorOutline

Remove unused member `m_colorOutline`.

* Fix horizontal lines on silence

Fix the horizontal lines that are rendered on silence. They seem to be
produced when rendering lines that start and end at the same point.

Therefore we only draw a point if the current and last point are the
same.

* Add some margin to the VectorView

Add some margin to the rendering of the `VectorView` so that the circle
does not touch the bounary of the widget.

* Clean up the layout of the Vectorscope

Clean up the layout of the Vectorscope. The checkboxes are not put on
top of the vector view anymore but are organized in a horizontal layout
beneath it. This gives a much tidier look.
2025-01-22 22:40:17 +01:00

76 lines
1.9 KiB
C++

/*
* VecControls.h - declaration of VecControls class.
*
* Copyright (c) 2019 Martin Pavelek <he29/dot/HS/at/gmail/dot/com>
*
* This file is part of LMMS - https://lmms.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#ifndef VECCONTROLS_H
#define VECCONTROLS_H
#include <QColor>
#include "EffectControls.h"
namespace lmms
{
class Vectorscope;
namespace gui
{
class VecControlsDialog;
class VectorView;
}
// Holds all the configuration values
class VecControls : public EffectControls
{
Q_OBJECT
public:
explicit VecControls(Vectorscope *effect);
~VecControls() override = default;
gui::EffectControlDialog* createView() override;
void saveSettings (QDomDocument &document, QDomElement &element) override;
void loadSettings (const QDomElement &element) override;
QString nodeName() const override {return "Vectorscope";}
int controlCount() override {return 3;}
const BoolModel& getLogarithmicModel() const { return m_logarithmicModel; }
const BoolModel& getLinesModel() const { return m_linesModeModel; }
private:
Vectorscope *m_effect;
BoolModel m_logarithmicModel;
BoolModel m_linesModeModel;
friend class gui::VecControlsDialog;
};
} // namespace lmms
#endif // VECCONTROLS_H