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

Rework the Statistics Item #612

Draft
wants to merge 39 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
437da37
Modify classes that use the new statistics type
ChristianFeldmann Jan 10, 2025
4ed687c
Don't check rendering of grid. What does this have to do with anything?
ChristianFeldmann Jan 11, 2025
bf3c146
Use StatsTypeBuilder instead of intransparent constructors
ChristianFeldmann Jan 11, 2025
9976e7a
Compile fix for ubuntu
ChristianFeldmann Jan 11, 2025
eb59d59
Merge branch 'feature/reworkStatisticsType' of github.com:IENT/YUView…
ChristianFeldmann Jan 11, 2025
f1a4c26
Fix compilation GCC
ChristianFeldmann Jan 11, 2025
2defa85
Fix tests
ChristianFeldmann Jan 11, 2025
cf7650b
Try c++ 20
ChristianFeldmann Jan 11, 2025
c2b3392
Merge branch 'feature/reworkStatisticsType' of github.com:IENT/YUView…
ChristianFeldmann Jan 11, 2025
e76e96d
Add support for c++ 20 also with gcc 9
ChristianFeldmann Jan 14, 2025
da5bb18
Add missing widget lib
ChristianFeldmann Jan 15, 2025
ef5f4a4
Merge branch 'feature/reworkStatisticsType' of github.com:IENT/YUView…
ChristianFeldmann Jan 15, 2025
a75c0c9
Typo in widgets
ChristianFeldmann Jan 15, 2025
1de46fb
Add test fur StatisticsTypeBuilder
ChristianFeldmann Jan 16, 2025
96cfeef
Constructor
ChristianFeldmann Jan 17, 2025
c377ba6
Construction of struct 2
ChristianFeldmann Jan 17, 2025
dc4599c
Add saving/loading back
ChristianFeldmann Jan 17, 2025
abcff36
Merge branch 'feature/reworkStatisticsType' of github.com:IENT/YUView…
ChristianFeldmann Jan 17, 2025
7d937fa
Add missing operators. Emplace on optional does not want to work in GCC.
ChristianFeldmann Jan 20, 2025
ab862ea
Make types only creatable through builder.
ChristianFeldmann Jan 21, 2025
5b2136a
Name optional function separately. This is problematic on older clang.
ChristianFeldmann Jan 22, 2025
e70a09b
Move storage and loading of statis items to separate class for testing.
ChristianFeldmann Jan 26, 2025
e707f4f
Add modofied type container
ChristianFeldmann Jan 29, 2025
d3d5e60
Add scale by percent function
ChristianFeldmann Jan 29, 2025
8bcdf28
Add explicit conversion
ChristianFeldmann Jan 29, 2025
4ca565e
Make render and alpha values use the modified struct
ChristianFeldmann Jan 29, 2025
f9abca4
Missing header for GCC
ChristianFeldmann Jan 29, 2025
2bf16ea
Store initial value so that return to initial value is also detected …
ChristianFeldmann Jan 29, 2025
14fccec
Add arrow operator
ChristianFeldmann Jan 29, 2025
f3d9cf9
Add modified to the value data
ChristianFeldmann Jan 29, 2025
9a45e53
Missing optional check
ChristianFeldmann Jan 29, 2025
f22aa24
Reformat wasModified function for valueDataOptions
ChristianFeldmann Jan 29, 2025
9315f47
Make vectorDataOptions use modified tool
ChristianFeldmann Jan 29, 2025
ec89168
Move grid options to modified handler
ChristianFeldmann Feb 2, 2025
12d617e
Add tests for comparison operators
ChristianFeldmann Feb 3, 2025
f24da72
Add test for grid options
ChristianFeldmann Feb 3, 2025
d815715
Remove set function. That is the task of the builder.
ChristianFeldmann Feb 3, 2025
40c9174
Clean up comparison functions
ChristianFeldmann Feb 4, 2025
2b05f96
Fix C++ 20 lambda warnings
ChristianFeldmann Feb 4, 2025
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
7 changes: 6 additions & 1 deletion YUViewApp/YUViewApp.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ QT += core gui widgets opengl xml concurrent network

TARGET = YUView
TEMPLATE = app
CONFIG += c++17
CONFIG -= debug_and_release

CONFIG += c++20
gcc {
# For gcc 9, setting 20 does not work. Must set c++2a.
equals(QMAKE_GCC_MAJOR_VERSION, 9): QMAKE_CXXFLAGS += -std=c++2a
}

SOURCES += $$files(src/*.cpp, false)
HEADERS += $$files(src/*.h, false)

Expand Down
7 changes: 6 additions & 1 deletion YUViewLib/YUViewLib.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ QT += core gui widgets opengl xml concurrent network

TEMPLATE = lib
CONFIG += staticlib
CONFIG += c++17
CONFIG -= debug_and_release
CONFIG += object_parallel_to_source

CONFIG += c++20
gcc {
# For gcc 9, setting 20 does not work. Must set c++2a.
equals(QMAKE_GCC_MAJOR_VERSION, 9): QMAKE_CXXFLAGS += -std=c++2a
}

SOURCES += $$files(src/*.cpp, true)
HEADERS += $$files(src/*.h, true)

Expand Down
12 changes: 12 additions & 0 deletions YUViewLib/src/common/Functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include <common/Typedef.h>

#include <cmath>
#include <istream>
#include <optional>

Expand Down Expand Up @@ -101,4 +102,15 @@ template <typename T, typename R> inline T clip(T val, Range<R> range)
std::optional<unsigned> toUnsigned(const std::string_view text);
std::optional<int> toInt(const std::string_view text);

template <typename T, typename P> inline T scaleValueByPercent(T value, P percent)
{
static_assert(std::is_integral<T>::value, "Type T must be an integral type.");
static_assert(std::is_integral<P>::value || std::is_floating_point<P>::value,
"Type P must be an integral or floating point type type.");

const auto factor = static_cast<double>(percent) / 100.0;
const auto scaledValue = static_cast<double>(value) * factor;
return static_cast<T>(std::round(scaledValue));
}

} // namespace functions
58 changes: 58 additions & 0 deletions YUViewLib/src/common/Modified.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* This file is part of YUView - The YUV player with advanced analytics toolset
* <https://github.com/IENT/YUView>
* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY
*
* 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 3 of the License, or
* (at your option) any later version.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*
* You must obey the GNU General Public License in all respects for all
* of the code used other than OpenSSL. If you modify file(s) with this
* exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do
* so, delete this exception statement from your version. If you delete
* this exception statement from all source files in the program, then
* also delete it here.
*
* 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. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

template <typename T> class modified
{
public:
modified() = default;
modified(const T &value) : internalValue(value), initialValue(value) {}

T operator*() const { return this->internalValue; }
T value() const { return this->internalValue; }
const T *operator->() const { return &this->internalValue; }
T *operator->() { return &this->internalValue; }
operator T() const { return this->internalValue; }

void operator=(const T &newValue) { this->internalValue = newValue; }

bool operator==(const T &other) const { return this->internalValue == other; }
bool operator==(const modified<T> &other) const { return this->internalValue == other.value(); }

[[nodiscard]] bool wasModified() const { return !(this->internalValue == this->initialValue); }
void setUnmodified() { this->initialValue = this->internalValue; }

private:
T internalValue{};
T initialValue{};
};
4 changes: 2 additions & 2 deletions YUViewLib/src/common/Typedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ template <typename T> struct Range
T min{};
T max{};

bool operator!=(const Range &other) const
bool operator==(const Range &other) const
{
return this->min != other.min || this->max != other.max;
return this->min == other.min && this->max == other.max;
}
};

Expand Down
Loading
Loading