Easy3D 2.5.3
dialog.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
27#ifndef EASY3D_UTIL_DIALOG_H
28#define EASY3D_UTIL_DIALOG_H
29
30#include <string>
31#include <vector>
32
33
34namespace easy3d
35{
36
37 namespace dialog {
38
52 std::vector<std::string> open(
53 const std::string& title,
54 const std::string& default_directory,
55 const std::vector<std::string>& filters,
56 bool multiple
57 );
58
73 std::string open(
74 const std::string& title = "Please choose a file to open",
75 const std::string& default_directory = "",
76 const std::vector<std::string>& filters = { "All Files (*.*)", "*" }
77 );
78
79 // -----------------------------------------------------------------------------
80
95 std::string save(
96 const std::string& title = "Please choose a file name",
97 const std::string& default_file_name = "",
98 const std::vector<std::string>& filters = { "All Files (*.*)", "*" },
99 bool confirm_overwrite = true
100 );
101
102 // -----------------------------------------------------------------------------
103
110 std::string open_folder(
111 const std::string& title = "Please choose a folder",
112 const std::string& default_directory = ""
113 );
114
115 // -----------------------------------------------------------------------------
116
117 enum class Type {
118 info = 0,
119 warning,
120 error,
121 question
122 };
123
124 enum class Response {
125 cancel = -1,
126 ok,
127 yes,
128 no,
129 abort,
130 retry,
131 ignore,
132 };
133
134 enum class Choice {
135 ok = 0,
136 ok_cancel,
137 yes_no,
138 yes_no_cancel,
139 retry_cancel,
140 abort_retry_ignore,
141 };
142
150 void notify(
151 const std::string& title,
152 const std::string& message,
153 Type type = Type::info
154 );
155
156 // -----------------------------------------------------------------------------
157
166 Response message(
167 const std::string& title,
168 const std::string& message,
169 Choice choice = Choice::ok_cancel,
170 Type type = Type::info
171 );
172
173
174#ifdef HAS_OSDIALOG
175 // usage
176 // const std::string filters =
177 // "Source:off,obj,ply;"
178 // "Header:xyz,ply";
179 // const std::string& file_name = FileDialog::open("", filters);
180 static std::string open(const std::string& file_name, const std::string& filters) ;
181#endif
182
183#ifdef HAS_TINY_FILE_DIALOG
184
190 static std::string open(
191 const std::vector<std::string> & filetypes,
192 const std::string& default_path = ""
193 );
194
202 static std::vector<std::string> open(
203 const std::vector<std::string>& filetypes,
204 bool multiple,
205 const std::string& default_path = ""
206 );
207
208
213 static std::string save(
214 const std::vector<std::string>& filetypes,
215 const std::string& default_file_name = ""
216 );
217#endif
218
219 }
220
221#ifdef HAS_TINY_FILE_DIALOG
222
223 class ColorDialog {
224 public:
225 // c is the current color
226 static vec3 pick(const vec3& c);
227 };
228
229#endif
230
231}
232
233#endif // EASY3D_UTIL_DIALOG_H
234
Definition: collider.cpp:182
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition: types.h:45