22
22
#include < iomanip>
23
23
#include < sstream>
24
24
25
+ #include " helpers.h"
25
26
26
- template <class C >
27
- void print_help (C cli)
28
- {
29
- std::cout << make_man_page (cli, " bubble_chamber" ) << " \n " ;
30
- }
31
- // ______________________________________________________________________________
32
-
33
- template <typename T>
34
- void print_usage (T cli, const char * argv0 )
35
- {
36
- // used default formatting
37
- std::cout << " Usage:\n " << usage_lines (cli, argv0)
38
- << " \n Options:\n " << documentation (cli) << ' \n ' ;
39
- }
40
- // ______________________________________________________________________________
41
-
42
- bool fexists (const std::string& filename) {
43
- std::ifstream ifile (filename.c_str ());
44
- if ( ifile ) return true ;
45
- return false ;
46
- }
47
- // ______________________________________________________________________________
48
-
49
- std::string exec (const char * cmd) {
50
- std::shared_ptr<FILE> pipe (popen (cmd, " r" ), pclose);
51
- if (!pipe) return " ERROR" ;
52
- char buffer[128 ];
53
- std::string result = " " ;
54
- while (!feof (pipe.get ())) {
55
- if (fgets (buffer, 128 , pipe.get ()) != NULL )
56
- result += buffer;
57
- }
58
- return result;
59
- }
60
- // ______________________________________________________________________________
61
-
62
- void copy_files (const std::vector<std::string>& files)
63
- {
64
- for (const auto & f: files) {
65
- std::string cmd = std::string (" cp " ) + f + " ." ;
66
- if ( fexists (f) ) {
67
- std::cout << " copying " << f << std::endl;
68
- exec (cmd.c_str ());
69
- }
70
- }
71
- }
72
- // ______________________________________________________________________________
73
-
74
- template <typename T>
75
- void print_man_page (T cli, const char * argv0 ){
76
- // all formatting options (with their default values)
77
- auto fmt = clipp::doc_formatting{}
78
- .start_column (8 ) // column where usage lines and documentation starts
79
- .doc_column (30 ) // parameter docstring start col
80
- .indent_size (4 ) // indent of documentation lines for children of a documented group
81
- .line_spacing (0 ) // number of empty lines after single documentation lines
82
- .paragraph_spacing (1 ) // number of empty lines before and after paragraphs
83
- .flag_separator (" , " ) // between flags of the same parameter
84
- .param_separator (" " ) // between parameters
85
- .group_separator (" " ) // between groups (in usage)
86
- .alternative_param_separator (" |" ) // between alternative flags
87
- .alternative_group_separator (" | " ) // between alternative groups
88
- .surround_group (" (" , " )" ) // surround groups with these
89
- .surround_alternatives (" (" , " )" ) // surround group of alternatives with these
90
- .surround_alternative_flags (" " , " " ) // surround alternative flags with these
91
- .surround_joinable (" (" , " )" ) // surround group of joinable flags with these
92
- .surround_optional (" [" , " ]" ) // surround optional parameters with these
93
- .surround_repeat (" " , " ..." ); // surround repeatable parameters with these
94
- // .surround_value("<", ">") //surround values with these
95
- // .empty_label("") //used if parameter has no flags and no label
96
- // .max_alternative_flags_in_usage(1) //max. # of flags per parameter in usage
97
- // .max_alternative_flags_in_doc(2) //max. # of flags per parameter in detailed documentation
98
- // .split_alternatives(true) //split usage into several lines for large alternatives
99
- // .alternatives_min_split_size(3) //min. # of parameters for separate usage line
100
- // .merge_alternative_flags_with_common_prefix(false) //-ab(cdxy|xy) instead of -abcdxy|-abxy
101
- // .merge_joinable_flags_with_common_prefix(true); //-abc instead of -a -b -c
102
- auto mp = make_man_page (cli, argv0, fmt);
103
- mp.prepend_section (" DESCRIPTION" , " Bubble chamber simulation" );
104
- mp.append_section (" EXAMPLES" , " $ bubble_chamber -h " );
105
- std::cout << mp << " \n " ;
106
- }
107
- // ______________________________________________________________________________
108
27
109
28
static void error_callback (int error, const char * description)
110
29
{
111
30
fprintf (stderr, " Error %d: %s\n " , error, description);
112
31
}
113
32
// ______________________________________________________________________________
114
33
115
-
116
34
int main (int argc, char ** argv)
117
35
{
118
36
using namespace clipp ;
119
37
using std::cout;
120
38
using CopyMode = ImGuiDM::Settings::CopyMode;
121
39
using Mode = ImGuiDM::Settings::Mode;
122
40
123
- ImGuiDM::ImGuiDMApplication app;
41
+ ImGuiDM::Application app;
124
42
auto & menu = app.menu ;
125
43
auto & S = app.settings ;
126
44
auto & gps_conf = app.gps_conf ;
@@ -144,7 +62,6 @@ int main(int argc, char** argv)
144
62
};
145
63
146
64
cout << " args -> parameter mapping:\n " ;
147
- ;
148
65
for (const auto & m0 : result) {
149
66
std::cout << " #" << m0.index () << " " << m0.arg () << " -> " ;
150
67
auto p = m0.param ();
@@ -257,29 +174,15 @@ int main(int argc, char** argv)
257
174
// ---------------------------------------------------------------------------
258
175
// Setup window
259
176
// ---------------------------------------------------------------------------
260
- glfwSetErrorCallback (error_callback);
261
- if (!glfwInit ())
262
- return 1 ;
263
- glfwWindowHint (GLFW_CONTEXT_VERSION_MAJOR, 3 );
264
- glfwWindowHint (GLFW_CONTEXT_VERSION_MINOR, 2 );
265
- glfwWindowHint (GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
266
- #if __APPLE__
267
- glfwWindowHint (GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
268
- #endif
269
- int w = 1280 ;
270
- int h = 720 ;
271
- GLFWwindow* window = glfwCreateWindow (1280 , 720 , " ImGui OpenGL3 example" , NULL , NULL );
272
- glfwMakeContextCurrent (window);
273
- glfwSwapInterval (1 ); // Enable vsync
274
- gl3wInit ();
275
-
276
- // // Setup ImGui binding
277
- // ImGui::CreateContext();
278
- // ImGuiIO& io = ImGui::GetIO();
279
- // //(void)io;
280
- // ImGui_ImplGlfwGL3_Init(window, true);
281
- // //io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
282
- // //io.NavFlags |= ImGuiNavFlags_EnableGamepad; // Enable Gamepad Controls
177
+ GLFWwindow* window = app.CreateWindow (1280 , 720 );
178
+
179
+ // //// Setup ImGui binding
180
+ // //ImGui::CreateContext();
181
+ // //ImGuiIO& io = ImGui::GetIO();
182
+ // ////(void)io;
183
+ // //ImGui_ImplGlfwGL3_Init(window, true);
184
+ // ////io.NavFlags |= ImGuiNavFlags_EnableKeyboard; // Enable Keyboard Controls
185
+ // ////io.NavFlags |= ImGuiNavFlags_EnableGamepad; // Enable Gamepad Controls
283
186
284
187
app.Init (window);
285
188
// // Setup style
0 commit comments