Skip to content

Commit 98b83e4

Browse files
committed
GUI
1 parent 832c840 commit 98b83e4

File tree

8 files changed

+132
-18
lines changed

8 files changed

+132
-18
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
# Solidify
1+
# Solidify
2+
Small GUI utility to Solidify (fill, push-pull) empty areas in textures.
3+
Use OpenImageIO and QT5.
4+
5+
Usage
6+
------------
7+
8+
### Run Solidify.exe and drag&drop images into open window.

Solidify.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
<SDLCheck>true</SDLCheck>
105105
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
106106
<ConformanceMode>true</ConformanceMode>
107+
<AdditionalIncludeDirectories>E:\VC\installed\x64-windows\include\qt5</AdditionalIncludeDirectories>
107108
</ClCompile>
108109
<Link>
109110
<SubSystem>Console</SubSystem>
@@ -118,6 +119,7 @@
118119
<SDLCheck>true</SDLCheck>
119120
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
120121
<ConformanceMode>true</ConformanceMode>
122+
<AdditionalIncludeDirectories>E:\VC\installed\x64-windows\include\qt5;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
121123
</ClCompile>
122124
<Link>
123125
<SubSystem>Console</SubSystem>
@@ -128,8 +130,10 @@
128130
</ItemDefinitionGroup>
129131
<ItemGroup>
130132
<ClCompile Include="src\Solidify.cpp" />
133+
<ClCompile Include="src\ui.cpp" />
131134
</ItemGroup>
132135
<ItemGroup>
136+
<ClInclude Include="src\solidify.h" />
133137
<ClInclude Include="src\Timer.h" />
134138
</ItemGroup>
135139
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

Solidify.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,16 @@
1818
<ClCompile Include="src\Solidify.cpp">
1919
<Filter>Source Files</Filter>
2020
</ClCompile>
21+
<ClCompile Include="src\ui.cpp">
22+
<Filter>Source Files</Filter>
23+
</ClCompile>
2124
</ItemGroup>
2225
<ItemGroup>
2326
<ClInclude Include="src\Timer.h">
2427
<Filter>Source Files</Filter>
2528
</ClInclude>
29+
<ClInclude Include="src\solidify.h">
30+
<Filter>Source Files</Filter>
31+
</ClInclude>
2632
</ItemGroup>
2733
</Project>

imgui.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[Window][Debug##Default]
2+
Pos=60,60
3+
Size=400,400
4+
Collapsed=0
5+
6+
[Window][Drag and Drop Files Here]
7+
Pos=180,93
8+
Size=627,472
9+
Collapsed=0
10+

src/Solidify.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,23 @@ bool progress_callback(void* opaque_data, float portion_done)
3636
return (portion_done >= 1.f);
3737
}
3838

39-
int main(int argc, char* argv[]) {
40-
if (argc != 3) {
41-
std::cerr << "Usage: " << argv[0] << " INPUT OUTPUT\n";
42-
return 1;
43-
}
39+
//int main(int argc, char* argv[]) {
40+
int solidify_main(const std::string& inputFileName, const std::string& outputFileName) {
41+
//if (argc != 3) {
42+
// std::cerr << "Usage: " << argv[0] << " INPUT OUTPUT\n";
43+
// return 1;
44+
//}
4445

4546
Timer g_timer;
4647

47-
const char* input_filename = argv[1];
48-
const char* output_filename = argv[2];
48+
//const char* input_filename = argv[0];
49+
//const char* output_filename = argv[1];
4950

5051
// Create an ImageBuf object for the input file
51-
ImageBuf input_buf(input_filename);
52+
ImageBuf input_buf(inputFileName);
5253

5354
// Read the image with a progress callback
54-
std::cout << "Reading " << input_filename << std::endl;
55+
std::cout << "Reading " << inputFileName << std::endl;
5556
bool read_ok = input_buf.read(0, 0, 0, -1, true, TypeUnknown, *progress_callback, nullptr);
5657
if (!read_ok) {
5758
std::cerr << "Error: Could not read input image\n";
@@ -75,28 +76,26 @@ int main(int argc, char* argv[]) {
7576

7677
std::cout << "Push-Pull time : " << pushpull_timer.nowText() << std::endl;
7778

78-
auto out = ImageOutput::create(output_filename);
79+
auto out = ImageOutput::create(outputFileName);
7980
if (!out) {
80-
std::cerr << "Could not create output file: " << output_filename << std::endl;
81+
std::cerr << "Could not create output file: " << outputFileName << std::endl;
8182
return 1;
8283
}
8384

8485
ImageSpec spec = result_buf.spec();
8586
spec.nchannels = 3; // Only write RGB channels
8687
spec.alpha_channel = -1; // No alpha channel
8788

88-
out->open(output_filename, spec, ImageOutput::Create);
89+
out->open(outputFileName, spec, ImageOutput::Create);
8990

90-
std::cout << "Writing " << output_filename << std::endl;
91+
std::cout << "Writing " << outputFileName << std::endl;
9192

9293
out->write_image(result_buf.spec().format, result_buf.localpixels(),
9394
result_buf.pixel_stride(), result_buf.scanline_stride(), result_buf.z_stride(),
9495
*progress_callback, nullptr);
9596
out->close();
9697

97-
std::cout << std::endl;
98-
99-
std::cout << "Total processing time : " << g_timer.nowText() << std::endl;
98+
std::cout << std::endl << "Total processing time : " << g_timer.nowText() << std::endl;
10099

101100
return 0;
102101
}

src/Timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* This file is part of the RawGL distribution (https://github.com/ssh4net/RawGL).
2+
* This file is part of the Solidify distribution.
33
* Copyright (c) 2022 Erium Vladlen.
44
*
55
* This program is free software: you can redistribute it and/or modify

src/solidify.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
3+
int solidify_main(const std::string& inputFileName, const std::string& outputFileName);

src/ui.cpp

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Solidify (Push Pull) algorithm implementation using OpenImageIO
3+
* Copyright (c) 2022 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+
18+
#include <QtWidgets/QApplication>
19+
#include <QtWidgets/QLabel>
20+
#include <QtGui/QDragEnterEvent>
21+
#include <QtGui/QDropEvent>
22+
#include <QtCore/QMimeData>
23+
#include <QtCore/QDebug>
24+
#include <QtCore/QFileInfo>
25+
26+
#include "solidify.h"
27+
28+
class DropArea : public QLabel {
29+
public:
30+
DropArea() {
31+
setAcceptDrops(true);
32+
resize(400, 400);
33+
setText("Drag-n-drop files here"); // Set text
34+
setAlignment(Qt::AlignCenter); // Set alignment to center
35+
}
36+
37+
protected:
38+
void dragEnterEvent(QDragEnterEvent* event) override {
39+
event->acceptProposedAction();
40+
}
41+
42+
void dropEvent(QDropEvent* event) override {
43+
QList<QUrl> urls = event->mimeData()->urls();
44+
if (urls.isEmpty()) {
45+
return;
46+
}
47+
48+
//QString fileName = urls.first().toLocalFile();
49+
//if (fileName.isEmpty()) {
50+
// return;
51+
//}
52+
53+
std::vector<QString> fileNames; // This will hold the names of all files
54+
55+
for (const QUrl& url : urls) {
56+
QString fileName = url.toLocalFile();
57+
if (!fileName.isEmpty()) {
58+
fileNames.push_back(fileName);
59+
}
60+
}
61+
62+
for (int i = 0; i < fileNames.size(); i++) {
63+
//qDebug() << "File name: " << fileName;
64+
QFileInfo fileInfo(fileNames[i]);
65+
QString baseName = fileInfo.baseName();
66+
QString path = fileInfo.absolutePath();
67+
QString outName = path + baseName + "_fill." + fileInfo.completeSuffix();
68+
69+
// Call the solidify_main function
70+
if (solidify_main(fileNames[i].toStdString(), outName.toStdString())) {
71+
exit(-1);
72+
};
73+
}
74+
qDebug() << "Done!";
75+
}
76+
};
77+
78+
int main(int argc, char* argv[]) {
79+
QApplication app(argc, argv);
80+
81+
DropArea dropArea;
82+
dropArea.show();
83+
84+
return app.exec();
85+
}

0 commit comments

Comments
 (0)