Skip to content

Commit 365ec86

Browse files
committed
Refactor to use precompiled headers and spdlog
Migrated to precompiled headers by introducing pch.h/pch.cpp and updating all source files to include pch.h. Replaced custom LOG macros with spdlog for logging throughout the codebase. Updated project files to remove references to LOG and QtDir, and switched build configuration to use DEV paths and static libraries. Cleaned up unused includes and improved project structure in .vcxproj and .filters files.
1 parent e13f180 commit 365ec86

File tree

15 files changed

+279
-348
lines changed

15 files changed

+279
-348
lines changed

Solidify/Solidify.vcxproj

Lines changed: 23 additions & 202 deletions
Large diffs are not rendered by default.

Solidify/Solidify.vcxproj.filters

Lines changed: 38 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
1818
<Extensions>qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
1919
</Filter>
20-
</ItemGroup>
21-
<ItemGroup>
22-
<None Include="src\gui.qrc">
23-
<Filter>Resource Files</Filter>
24-
</None>
20+
<Filter Include="src\headers">
21+
<UniqueIdentifier>{e78d3757-0dbf-4002-8b44-7435a1caa1e9}</UniqueIdentifier>
22+
</Filter>
23+
<Filter Include="src\_QT">
24+
<UniqueIdentifier>{1c9ccf6c-d6a6-444b-a7b1-9f0f91e1dfd6}</UniqueIdentifier>
25+
</Filter>
2526
</ItemGroup>
2627
<ItemGroup>
2728
<ClCompile Include="src\ui.cpp">
@@ -36,69 +37,51 @@
3637
<ClCompile Include="src\solidify.cpp">
3738
<Filter>src</Filter>
3839
</ClCompile>
39-
<ClCompile Include="src\stdafx.cpp">
40-
<Filter>src</Filter>
41-
</ClCompile>
4240
<ClCompile Include="src\imageio.cpp">
4341
<Filter>src</Filter>
4442
</ClCompile>
4543
<ClCompile Include="src\settings.cpp">
4644
<Filter>src</Filter>
4745
</ClCompile>
48-
<ClCompile Include="src\Log.cpp">
46+
<ClCompile Include="src\qrc_gui.cpp">
47+
<Filter>src\_QT</Filter>
48+
</ClCompile>
49+
<ClCompile Include="src\moc_ui.cpp">
50+
<Filter>src\_QT</Filter>
51+
</ClCompile>
52+
<ClCompile Include="src\pch.cpp">
4953
<Filter>src</Filter>
5054
</ClCompile>
5155
</ItemGroup>
5256
<ItemGroup>
53-
<None Include="src\gui.ui">
54-
<Filter>Form Files</Filter>
55-
</None>
56-
</ItemGroup>
57-
<ItemGroup>
58-
<ClInclude Include="src\processing.h">
59-
<Filter>src</Filter>
60-
</ClInclude>
61-
<ClInclude Include="src\solidify.h">
62-
<Filter>src</Filter>
63-
</ClInclude>
64-
<ClInclude Include="src\Timer.h">
65-
<Filter>src</Filter>
57+
<ClInclude Include="resource.h">
58+
<Filter>Resource Files</Filter>
6659
</ClInclude>
67-
<ClInclude Include="src\stdafx.h">
68-
<Filter>src</Filter>
60+
<ClInclude Include="src\Common.h">
61+
<Filter>src\headers</Filter>
6962
</ClInclude>
7063
<ClInclude Include="src\imageio.h">
71-
<Filter>src</Filter>
64+
<Filter>src\headers</Filter>
7265
</ClInclude>
73-
<ClInclude Include="src\settings.h">
74-
<Filter>src</Filter>
66+
<ClInclude Include="src\processing.h">
67+
<Filter>src\headers</Filter>
7568
</ClInclude>
76-
<ClInclude Include="src\threadpool.h">
77-
<Filter>src</Filter>
69+
<ClInclude Include="src\settings.h">
70+
<Filter>src\headers</Filter>
7871
</ClInclude>
79-
<ClInclude Include="src\LOG.H">
80-
<Filter>src</Filter>
72+
<ClInclude Include="src\solidify.h">
73+
<Filter>src\headers</Filter>
8174
</ClInclude>
82-
<ClInclude Include="src\Common.h">
83-
<Filter>src</Filter>
75+
<ClInclude Include="src\Timer.h">
76+
<Filter>src\headers</Filter>
8477
</ClInclude>
85-
<ClInclude Include="resource.h">
86-
<Filter>Resource Files</Filter>
78+
<ClInclude Include="src\pch.h">
79+
<Filter>src\headers</Filter>
8780
</ClInclude>
88-
</ItemGroup>
89-
<ItemGroup>
90-
<ClInclude Include="src\ui.h">
91-
<Filter>src</Filter>
81+
<ClInclude Include="src\threadpool.h">
82+
<Filter>src\headers</Filter>
9283
</ClInclude>
9384
</ItemGroup>
94-
<ItemGroup>
95-
<ClCompile Include="src\moc_ui.cpp">
96-
<Filter>src</Filter>
97-
</ClCompile>
98-
<ClCompile Include="src\qrc_gui.cpp">
99-
<Filter>src</Filter>
100-
</ClCompile>
101-
</ItemGroup>
10285
<ItemGroup>
10386
<CopyFileToFolders Include="src\sldf_config.toml">
10487
<Filter>Resource Files</Filter>
@@ -109,4 +92,12 @@
10992
<Filter>Resource Files</Filter>
11093
</ResourceCompile>
11194
</ItemGroup>
95+
<ItemGroup>
96+
<CustomBuild Include="src\gui.qrc">
97+
<Filter>Resource Files</Filter>
98+
</CustomBuild>
99+
<CustomBuild Include="src\ui.h">
100+
<Filter>src\headers</Filter>
101+
</CustomBuild>
102+
</ItemGroup>
112103
</Project>

Solidify/src/IMAGEIO.CPP

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
*/
1717
#pragma once
1818

19+
#include "pch.h"
1920
#include "imageio.h"
2021
#include "settings.h"
21-
#include "Log.h"
22+
//#include "Log.h"
2223

2324
int hue = 186;
2425
//void pbar_color_rand(QProgressBar* progressBar) {
@@ -132,31 +133,31 @@ std::string formatText(TypeDesc format) {
132133

133134
void formatFromBuff(ImageBuf& buf) {
134135
std::string format = buf.file_format_name();
135-
LOG(info) << "Format: " << format << std::endl;
136+
spdlog::info("Format: {}", format);
136137
}
137138

138139
void debugImageBufWrite(const ImageBuf& buf, const std::string& filename) {
139140
bool write_ok = buf.write(filename);
140141
if (!write_ok) {
141-
LOG(error) << "Error: Could not write to " << filename << std::endl;
142-
LOG(error) << "Error: " << buf.geterror() << std::endl;
142+
spdlog::error("Error: Could not write to {}", filename);
143+
spdlog::error("Error: {}", buf.geterror());
143144
}
144145
}
145146

146147
std::pair<ImageBuf, ImageBuf> mask_load(const std::string& mask_file, MainWindow* mainWindow) {
147148
ImageBuf alpha_buf(mask_file);
148-
LOG(info) << "Reading " << mask_file << std::endl;
149+
spdlog::info("Reading {}", mask_file);
149150
bool read_ok = alpha_buf.read(0, 0, 0, 1, true, TypeDesc::FLOAT, nullptr, nullptr);
150151
if (!read_ok) {
151-
LOG(error) << "Error: Could not read mask image\n";
152+
spdlog::error("Error: Could not read mask image\n");
152153
mainWindow->emitUpdateTextSignal("Error! Check console for details");
153154
system("pause");
154155
exit(-1);
155156
}
156157

157158
int width = alpha_buf.spec().width;
158159
int height = alpha_buf.spec().height;
159-
LOG(info) << "Mask size: " << width << "x" << height << std::endl;
160+
spdlog::info("Mask size: {}x{}", width, height);
160161

161162
// rename channel to alpha and set it as an alpha channel
162163
alpha_buf.specmod().channelnames[0] = "A";
@@ -169,7 +170,7 @@ std::pair<ImageBuf, ImageBuf> mask_load(const std::string& mask_file, MainWindow
169170
rgb_alpha = ImageBufAlgo::channels(alpha_buf, 3, channelorder, channelvalues);
170171

171172
if (rgb_alpha.has_error()) {
172-
LOG(error) << "Error: Could not append channels\n";
173+
spdlog::error("Error: Could not append channels\n");
173174
mainWindow->emitUpdateTextSignal("Error! Check console for details");
174175
system("pause");
175176
exit(-1);
@@ -229,7 +230,7 @@ bool img_load(ImageBuf& outBuf, const std::string& inputFileName, bool external_
229230

230231
bool read_ok = outBuf.read(0, 0, 0, last_channel, true, o_format, m_progress_callback, progressBar);
231232
if (!read_ok) {
232-
LOG(error) << "Error: Could not read input image\n";
233+
spdlog::error("Error: Could not read input image\n");
233234
mainWindow->emitUpdateTextSignal("Error! Check console for details");
234235
return false;
235236
}
@@ -249,7 +250,7 @@ bool img_load(ImageBuf& outBuf, const std::string& inputFileName, bool external_
249250
}
250251
read_ok = ImageBufAlgo::mul(outBuf, outBuf, alphs_rgba);
251252
if (!read_ok) {
252-
LOG(error) << "Error: Could not multiply alpha\n";
253+
spdlog::error("Error: Could not multiply alpha\n");
253254
mainWindow->emitUpdateTextSignal("Error! Check console for details");
254255
return false;
255256
}
File renamed without changes.

Solidify/src/UI.CPP

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
#define WIN32_LEAN_AND_MEAN
19-
#define NOMINMAX
20-
#include <windows.h>
21-
#include <tlhelp32.h>
22-
#include <process.h>
18+
#include "pch.h"
2319

2420
#include "ui.h"
2521

Solidify/src/main.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,36 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18+
#include "pch.h"
1819
#include "settings.h"
1920
#include <Windows.h>
2021
#include <QtCore/QResource>
2122

23+
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
24+
2225
int main(int argc, char* argv[]) {
2326
// Allocate console and redirect std output
2427
AllocConsole();
2528
freopen("CONOUT$", "w", stdout);
2629
freopen("CONOUT$", "w", stderr);
2730

28-
Log_Init();
31+
spdlog::set_level(spdlog::level::info);
32+
spdlog::set_pattern("%^[%l]%$<%t> %v");
33+
34+
time_t timestamp;
35+
time(&timestamp);
36+
std::cout << std::fixed << std::setprecision(8);
37+
38+
spdlog::info("Solidify {}.{}.{}", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
39+
spdlog::info("Build from: {} {}", __DATE__, __TIME__);
40+
spdlog::info("Log started at: {}", ctime(&timestamp), "%Y-%m-%d %H:%M:%S");
2941

3042
if (!loadSettings(settings, "sldf_config.toml")) {
31-
LOG(error) << "Can not load [app_config.toml] Using default settings." << std::endl;
43+
spdlog::error("Can not load [app_config.toml] Using default settings.");
3244
settings.reSettings();
3345
}
3446

3547
ShowWindow(GetConsoleWindow(), (settings.conEnable) ? SW_SHOW : SW_HIDE);
36-
qDebug() << qPrintable(QString("Solidify %1.%2").arg(VERSION_MAJOR).arg(VERSION_MINOR)) << "Debug output:";
3748
printSettings(settings);
3849

3950

Solidify/src/pch.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* UnRAWer - camera raw batch processor on top of OpenImageIO
3+
* Copyright (c) 2024 Erium Vladlen.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published
7+
* by the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
#include "pch.h"

Solidify/src/pch.h

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Solidify (Push Pull) algorithm implementation using OpenImageIO
3+
* Copyright (c) 2023 Erium Vladlen.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, version 3.
8+
*
9+
* This program is distributed in the hope that it will be useful, but
10+
* WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
* General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
#pragma once
18+
19+
#include <thread>
20+
#include <algorithm>
21+
#include <array>
22+
#include <atomic>
23+
#include <cassert>
24+
#include <cctype>
25+
#include <ctime>
26+
#include <condition_variable>
27+
#include <exception>
28+
#include <filesystem>
29+
#include <fstream>
30+
#include <functional>
31+
#include <future>
32+
#include <iomanip>
33+
#include <iostream>
34+
#include <iterator>
35+
#include <map>
36+
#include <memory>
37+
#include <mutex>
38+
#include <optional>
39+
#include <queue>
40+
#include <ranges>
41+
#include <sstream>
42+
#include <stdexcept>
43+
#include <string>
44+
#include <vector>
45+
46+
#define WIN32_LEAN_AND_MEAN
47+
#define NOMINMAX
48+
#include <windows.h>
49+
#include <tlhelp32.h>
50+
#include <process.h>
51+
52+
#include <QtConcurrent/QtConcurrentRun>
53+
#include <QtCore/QDebug>
54+
#include <QtCore/QDir>
55+
#include <QtCore/QFileInfo>
56+
#include <QtCore/QFutureWatcher>
57+
#include <QtCore/QList>
58+
#include <QtCore/QMimeData>
59+
#include <QtCore/QProcess>
60+
#include <QtCore/QRandomGenerator>
61+
#include <QtCore/QRegularExpression>
62+
#include <QtCore/QUrl>
63+
#include <QtCore/QtPlugin>
64+
#include <QtGui/QDragEnterEvent>
65+
#include <QtGui/QDropEvent>
66+
#include <QtWidgets/QApplication>
67+
#include <QtWidgets/QLabel>
68+
#include <QtWidgets/QMainWindow>
69+
#include <QtWidgets/QMenu>
70+
#include <QtWidgets/QMenuBar>
71+
#include <QtWidgets/QProgressBar>
72+
#include <QtWidgets/QStatusBar>
73+
#include <QtWidgets/QtWidgets>
74+
#include <QtWidgets/QVBoxLayout>
75+
76+
#include <OpenImageIO/color.h>
77+
#include <OpenImageIO/imagebuf.h>
78+
#include <OpenImageIO/imagebufalgo.h>
79+
#include <OpenImageIO/imageio.h>
80+
#include <OpenImageIO/span.h>
81+
#include <OpenImageIO/strutil.h>
82+
#include <OpenImageIO/sysutil.h>
83+
84+
//#define SPDLOG_USE_STD_FORMAT
85+
#include <spdlog/spdlog.h>
86+
#include <spdlog/sinks/stdout_color_sinks.h>
87+
#include <spdlog/sinks/basic_file_sink.h>
88+
#include <spdlog/fmt/ostr.h>
89+
90+
//#include <libraw/libraw.h>
91+
92+
#include <toml.hpp>

0 commit comments

Comments
 (0)