Orbiter 2022
Combinatorial Objects
interface_toolkit.cpp
Go to the documentation of this file.
1/*
2 * interface_toolkit.cpp
3 *
4 * Created on: Nov 29, 2020
5 * Author: betten
6 */
7
8
9
10
11
12
13#include "orbiter.h"
14
15using namespace std;
16
17namespace orbiter {
18namespace layer5_applications {
19namespace user_interface {
20
21
22
23
25{
26 f_create_files = FALSE;
27 Create_file_description = NULL;
28
29
30 f_csv_file_select_rows = FALSE;
31 //std::string csv_file_select_rows_fname;
32 //std::string csv_file_select_rows_text;
33
34 f_csv_file_split_rows_modulo = FALSE;
35 //std::string csv_file_split_rows_modulo_fname;
36 csv_file_split_rows_modulo_n = 0;
37
38 f_csv_file_select_cols = FALSE;
39 //std::string csv_file_select_cols_fname;
40 //std::string csv_file_select_cols_text;
41
42 f_csv_file_select_rows_and_cols = FALSE;
43 //csv_file_select_rows_and_cols_fname;
44 //std::string csv_file_select_rows_and_cols_R_text;
45 //std::string csv_file_select_rows_and_cols_C_text;
46
47 f_csv_file_sort_each_row = FALSE;
48 //std::string csv_file_sort_each_row_fname;
49
50 f_csv_file_join = FALSE;
51 //csv_file_join_fname
52 //csv_file_join_identifier
53
54
55 f_csv_file_concatenate = FALSE;
56 //std::string csv_file_concatenate_fname_out;
57 //std::vector<std::string> csv_file_concatenate_fname_in;
58
59 f_csv_file_extract_column_to_txt = FALSE;
60 //std::string csv_file_extract_column_to_txt_fname;
61 //std::string csv_file_extract_column_to_txt_col_label;
62
63 f_csv_file_latex = FALSE;
64 f_produce_latex_header = FALSE;
65 //std::vector<std::string> csv_file_latex_fname;
66
67 f_draw_matrix = FALSE;
68 Draw_bitmap_control = NULL;
69
70
71 f_reformat = FALSE;
72 //std::string reformat_fname_in;
73 //std::string reformat_fname_out;
74 reformat_nb_cols = 0;
75
76 f_split_by_values = FALSE;
77 //std::string split_by_values_fname_in;
78
79 f_store_as_csv_file = FALSE;
80 //std::string> store_as_csv_file_fname;
81 store_as_csv_file_m = 0;
82 store_as_csv_file_n = 0;
83 //std::string store_as_csv_file_data;
84
85 f_mv = FALSE;
86 //std::string mv_a;
87 //std::string mv_b;
88
89 f_loop = FALSE;
90 loop_start_idx = 0;
91 loop_end_idx = 0;
92 //std::string loop_variable;
93 loop_from = 0;
94 loop_to = 0;
95 loop_step = 0;
96 loop_argv = NULL;
97
98 f_plot_function = FALSE;
99 //std::string plot_function_fname;
100
101 f_draw_projective_curve = FALSE;
102 Draw_projective_curve_description = NULL;
103
104 f_tree_draw = FALSE;
105 Tree_draw_options = NULL;
106}
107
108
110 std::string *argv, int i, int verbose_level)
111{
113
114 if (ST.stringcmp(argv[i], "-create_files") == 0) {
115 cout << "-create_files <description>" << endl;
116 }
117 else if (ST.stringcmp(argv[i], "-csv_file_select_rows") == 0) {
118 cout << "-cvs_file_select_rows <string : csv_file_name> <string : list of rows>" << endl;
119 }
120 else if (ST.stringcmp(argv[i], "-csv_file_split_rows_modulo") == 0) {
121 cout << "-csv_file_split_rows_modulo <string : csv_file_name> <int : n>" << endl;
122 }
123 else if (ST.stringcmp(argv[i], "-csv_file_select_cols") == 0) {
124 cout << "-cvs_file_select_cols <string : csv_file_name> <string : list of cols>" << endl;
125 }
126 else if (ST.stringcmp(argv[i], "-csv_file_select_rows_and_cols") == 0) {
127 cout << "-csv_file_select_rows_and_cols <string : csv_file_name> <string : list of rows> <string : list of cols>" << endl;
128 }
129 else if (ST.stringcmp(argv[i], "-csv_file_sort_each_row") == 0) {
130 cout << "-csv_file_sort_each_row <string : input file>" << endl;
131 }
132 else if (ST.stringcmp(argv[i], "-csv_file_join") == 0) {
133 cout << "-cvs_file_join <int : number of files> <string : input file1> <string : column label1> ..." << endl;
134 }
135 else if (ST.stringcmp(argv[i], "-csv_file_concatenate") == 0) {
136 cout << "-csv_file_concatenate <string : fname_out> <int : number of input files> <string : inout file1> ..." << endl;
137 }
138 else if (ST.stringcmp(argv[i], "-csv_file_extract_column_to_txt") == 0) {
139 cout << "-csv_file_extract_column_to_txt <string : csv_fname> <string : col_label>" << endl;
140 }
141 else if (ST.stringcmp(argv[i], "-csv_file_latex") == 0) {
142 cout << "-cvs_file_latex <int : f_produce_header> <string : file_name>" << endl;
143 }
144 else if (ST.stringcmp(argv[i], "-draw_matrix") == 0) {
145 cout << "-draw_matrix options -end" << endl;
146 }
147 else if (ST.stringcmp(argv[i], "-reformat") == 0) {
148 cout << "-reformat <string : fname_in> <string : fname_out> <int : new_width>" << endl;
149 }
150 else if (ST.stringcmp(argv[i], "-split_by_values") == 0) {
151 cout << "-split_by_values <string : fname_in>" << endl;
152 }
153 else if (ST.stringcmp(argv[i], "-store_as_csv_file") == 0) {
154 cout << "-store_as_csv_file <string : fname> <int : m> "
155 "<int : n> <string : data> " << endl;
156 }
157 else if (ST.stringcmp(argv[i], "-mv") == 0) {
158 cout << "-mv <string : from> <string : to> " << endl;
159 }
160 else if (ST.stringcmp(argv[i], "-loop") == 0) {
161 cout << "-loop <string : variable> <string : logfile_mask> <int : from> <int : to> <int : step> <arguments> -loop_end" << endl;
162 }
163 else if (ST.stringcmp(argv[i], "-plot_function") == 0) {
164 cout << "-plot_function <string : fname_csv>" << endl;
165 }
166 else if (ST.stringcmp(argv[i], "-draw_projective_curve") == 0) {
167 cout << "-draw_projective_curve ..." << endl;
168 }
169 else if (ST.stringcmp(argv[i], "-tree_draw") == 0) {
170 cout << "-tree_draw <options> -end" << endl;
171 }
172}
173
175 std::string *argv, int i, int verbose_level)
176{
178
179 if (i >= argc) {
180 return false;
181 }
182 if (ST.stringcmp(argv[i], "-create_files") == 0) {
183 return true;
184 }
185 else if (ST.stringcmp(argv[i], "-csv_file_select_rows") == 0) {
186 return true;
187 }
188 else if (ST.stringcmp(argv[i], "-csv_file_split_rows_modulo") == 0) {
189 return true;
190 }
191 else if (ST.stringcmp(argv[i], "-csv_file_select_cols") == 0) {
192 return true;
193 }
194 else if (ST.stringcmp(argv[i], "-csv_file_select_rows_and_cols") == 0) {
195 return true;
196 }
197 else if (ST.stringcmp(argv[i], "-csv_file_sort_each_row") == 0) {
198 return true;
199 }
200 else if (ST.stringcmp(argv[i], "-csv_file_join") == 0) {
201 return true;
202 }
203 else if (ST.stringcmp(argv[i], "-csv_file_concatenate") == 0) {
204 return true;
205 }
206 else if (ST.stringcmp(argv[i], "-csv_file_extract_column_to_txt") == 0) {
207 return true;
208 }
209 else if (ST.stringcmp(argv[i], "-csv_file_latex") == 0) {
210 return true;
211 }
212 else if (ST.stringcmp(argv[i], "-draw_matrix") == 0) {
213 return true;
214 }
215 else if (ST.stringcmp(argv[i], "-reformat") == 0) {
216 return true;
217 }
218 else if (ST.stringcmp(argv[i], "-split_by_values") == 0) {
219 return true;
220 }
221 else if (ST.stringcmp(argv[i], "-store_as_csv_file") == 0) {
222 return true;
223 }
224 else if (ST.stringcmp(argv[i], "-mv") == 0) {
225 return true;
226 }
227 else if (ST.stringcmp(argv[i], "-loop") == 0) {
228 return true;
229 }
230 else if (ST.stringcmp(argv[i], "-plot_function") == 0) {
231 return true;
232 }
233 else if (ST.stringcmp(argv[i], "-draw_projective_curve") == 0) {
234 return true;
235 }
236 else if (ST.stringcmp(argv[i], "-tree_draw") == 0) {
237 return true;
238 }
239 return false;
240}
241
243 std::string *argv, int &i, int verbose_level)
244{
245 int f_v = (verbose_level >= 1);
247
248 if (f_v) {
249 cout << "interface_toolkit::read_arguments" << endl;
250 }
251
252 if (f_v) {
253 cout << "interface_toolkit::read_arguments the next argument is " << argv[i] << endl;
254 }
255 if (ST.stringcmp(argv[i], "-create_files") == 0) {
256 f_create_files = TRUE;
257
258 if (f_v) {
259 cout << "-create_files " << endl;
260 }
261
263 i += Create_file_description->read_arguments(argc - i - 1,
264 argv + i + 1, verbose_level);
265 if (f_v) {
266 cout << "interface_combinatorics::read_arguments finished "
267 "reading -create_files" << endl;
268 cout << "i = " << i << endl;
269 cout << "argc = " << argc << endl;
270 if (i < argc) {
271 cout << "next argument is " << argv[i] << endl;
272 }
273
274 cout << "-create_files " <<endl;
275 }
276 }
277 else if (ST.stringcmp(argv[i], "-csv_file_select_rows") == 0) {
278 f_csv_file_select_rows = TRUE;
279 csv_file_select_rows_fname.assign(argv[++i]);
280 csv_file_select_rows_text.assign(argv[++i]);
281 if (f_v) {
282 cout << "-csv_file_select_rows " << csv_file_select_rows_fname
283 << " " << csv_file_select_rows_text << endl;
284 }
285 }
286 else if (ST.stringcmp(argv[i], "-csv_file_split_rows_modulo") == 0) {
287 f_csv_file_split_rows_modulo = TRUE;
288 csv_file_split_rows_modulo_fname.assign(argv[++i]);
289 csv_file_split_rows_modulo_n = ST.strtoi(argv[++i]);
290 if (f_v) {
291 cout << "-csv_file_split_rows_modulo " << csv_file_split_rows_modulo_fname
292 << " " << csv_file_split_rows_modulo_n << endl;
293 }
294 }
295 else if (ST.stringcmp(argv[i], "-csv_file_select_cols") == 0) {
296 f_csv_file_select_cols = TRUE;
297 csv_file_select_cols_fname.assign(argv[++i]);
298 csv_file_select_cols_text.assign(argv[++i]);
299 if (f_v) {
300 cout << "-csv_file_select_cols " << csv_file_select_cols_fname
301 << " " << csv_file_select_cols_text << endl;
302 }
303 }
304 else if (ST.stringcmp(argv[i], "-csv_file_select_rows_and_cols") == 0) {
305 f_csv_file_select_rows_and_cols = TRUE;
306 csv_file_select_rows_and_cols_fname.assign(argv[++i]);
307 csv_file_select_rows_and_cols_R_text.assign(argv[++i]);
308 csv_file_select_rows_and_cols_C_text.assign(argv[++i]);
309 if (f_v) {
310 cout << "-csv_file_select_rows_and_cols "
311 << csv_file_select_rows_and_cols_fname
312 << " " << csv_file_select_rows_and_cols_R_text
313 << " " << csv_file_select_rows_and_cols_C_text
314 << endl;
315 }
316 }
317 else if (ST.stringcmp(argv[i], "-csv_file_sort_each_row") == 0) {
318 f_csv_file_sort_each_row = TRUE;
319 csv_file_sort_each_row_fname.assign(argv[++i]);
320 if (f_v) {
321 cout << "-csv_file_sort_each_row "
322 << csv_file_sort_each_row_fname
323 << endl;
324 }
325 }
326 else if (ST.stringcmp(argv[i], "-csv_file_join") == 0) {
327 string s;
328 int nb, j;
329
330 f_csv_file_join = TRUE;
331 nb = ST.strtoi(argv[++i]);
332 for (j = 0; j < nb; j++) {
333 s.assign(argv[++i]);
334 csv_file_join_fname.push_back(s);
335 s.assign(argv[++i]);
336 csv_file_join_identifier.push_back(s);
337 }
338 if (f_v) {
339 cout << "-csv_file_join " << endl;
340 for (j = 0; j < nb; j++) {
341 cout << j << " : " << csv_file_join_fname[j]
342 << " : " << csv_file_join_identifier[j] << endl;
343 }
344 }
345 }
346 else if (ST.stringcmp(argv[i], "-csv_file_concatenate") == 0) {
347 string s;
348 int nb, j;
349
350 f_csv_file_concatenate = TRUE;
351 csv_file_concatenate_fname_out.assign(argv[++i]);
352 nb = ST.strtoi(argv[++i]);
353 for (j = 0; j < nb; j++) {
354 s.assign(argv[++i]);
355 csv_file_concatenate_fname_in.push_back(s);
356 }
357 if (f_v) {
358 cout << "-csv_file_concatenate " << csv_file_concatenate_fname_out << endl;
359 for (j = 0; j < nb; j++) {
360 cout << j << " : " << csv_file_concatenate_fname_in[j] << endl;
361 }
362 }
363 }
364 else if (ST.stringcmp(argv[i], "-csv_file_extract_column_to_txt") == 0) {
365 f_csv_file_extract_column_to_txt = TRUE;
366 csv_file_extract_column_to_txt_fname.assign(argv[++i]);
367 csv_file_extract_column_to_txt_col_label.assign(argv[++i]);
368 if (f_v) {
369 cout << "-csv_file_extract_column_to_txt " << csv_file_extract_column_to_txt_fname << " " << csv_file_extract_column_to_txt_col_label << endl;
370 }
371 }
372
373 else if (ST.stringcmp(argv[i], "-csv_file_latex") == 0) {
374 f_csv_file_latex = TRUE;
375 f_produce_latex_header = ST.strtoi(argv[++i]);
376 csv_file_latex_fname.assign(argv[++i]);
377 if (f_v) {
378 cout << "-csv_file_latex " << f_produce_latex_header << " " << csv_file_latex_fname << endl;
379 }
380 }
381 else if (ST.stringcmp(argv[i], "-draw_matrix") == 0) {
382 f_draw_matrix = TRUE;
383 Draw_bitmap_control = NEW_OBJECT(graphics::draw_bitmap_control);
384 if (f_v) {
385 cout << "reading -draw_matrix" << endl;
386 }
387 i += Draw_bitmap_control->read_arguments(argc - (i + 1),
388 argv + i + 1, verbose_level);
389 if (f_v) {
390 cout << "i = " << i << endl;
391 cout << "argc = " << argc << endl;
392 if (i < argc) {
393 cout << "next argument is " << argv[i] << endl;
394 }
395 cout << "-draw_matrix " << endl;
396 Draw_bitmap_control->print();
397 }
398 }
399 else if (ST.stringcmp(argv[i], "-reformat") == 0) {
400 f_reformat = TRUE;
401 reformat_fname_in.assign(argv[++i]);
402 reformat_fname_out.assign(argv[++i]);
403 reformat_nb_cols = ST.strtoi(argv[++i]);
404 if (f_v) {
405 cout << "-reformat " << reformat_fname_in
406 << " " << reformat_fname_out
407 << " " << reformat_nb_cols << endl;
408 }
409 }
410 else if (ST.stringcmp(argv[i], "-split_by_values") == 0) {
411 f_split_by_values = TRUE;
412 split_by_values_fname_in.assign(argv[++i]);
413 if (f_v) {
414 cout << "-split_by_values " << split_by_values_fname_in << endl;
415 }
416 }
417 else if (ST.stringcmp(argv[i], "-store_as_csv_file") == 0) {
418 f_store_as_csv_file = TRUE;
419 store_as_csv_file_fname.assign(argv[++i]);
420 store_as_csv_file_m = ST.strtoi(argv[++i]);
421 store_as_csv_file_n = ST.strtoi(argv[++i]);
422 store_as_csv_file_data.assign(argv[++i]);
423 if (f_v) {
424 cout << "-store_as_csv_file " << store_as_csv_file_fname
425 << " " << store_as_csv_file_m
426 << " " << store_as_csv_file_n
427 << " " << store_as_csv_file_data << endl;
428 }
429 }
430 else if (ST.stringcmp(argv[i], "-mv") == 0) {
431 f_mv = TRUE;
432 mv_a.assign(argv[++i]);
433 mv_b.assign(argv[++i]);
434 if (f_v) {
435 cout << "-mv " << mv_a
436 << " " << mv_b << endl;
437 }
438 }
439 else if (ST.stringcmp(argv[i], "-loop") == 0) {
440 f_loop = TRUE;
441 loop_start_idx = i + 5;
442 loop_variable.assign(argv[++i]);
443 loop_from = ST.strtoi(argv[++i]);
444 loop_to = ST.strtoi(argv[++i]);
445 loop_step = ST.strtoi(argv[++i]);
446 loop_argv = argv;
447
448 for (++i; i < argc; i++) {
449 if (ST.stringcmp(argv[i], "-end_loop") == 0) {
450 loop_end_idx = i;
451 break;
452 }
453 }
454 if (i == argc) {
455 cout << "-loop cannot find -end_loop" << endl;
456 exit(1);
457 }
458 if (f_v) {
459 cout << "-loop " << loop_variable
460 << " " << loop_from
461 << " " << loop_to
462 << " " << loop_step
463 << " " << loop_start_idx
464 << " " << loop_end_idx;
465
466 for (int j = loop_start_idx; j < loop_end_idx; j++) {
467 cout << " " << argv[j];
468 }
469 cout << endl;
470 }
471 }
472 else if (ST.stringcmp(argv[i], "-plot_function") == 0) {
473 f_plot_function = TRUE;
474 plot_function_fname.assign(argv[++i]);
475 if (f_v) {
476 cout << "-plot_function " << plot_function_fname << endl;
477 }
478 }
479 else if (ST.stringcmp(argv[i], "-draw_projective_curve") == 0) {
480 f_draw_projective_curve = TRUE;
481 Draw_projective_curve_description = NEW_OBJECT(graphics::draw_projective_curve_description);
482 if (f_v) {
483 cout << "reading -draw_projective_curve" << endl;
484 }
485 i += Draw_projective_curve_description->read_arguments(argc - (i + 1),
486 argv + i + 1, verbose_level);
487 if (f_v) {
488 cout << "i = " << i << endl;
489 cout << "argc = " << argc << endl;
490 if (i < argc) {
491 cout << "next argument is " << argv[i] << endl;
492 }
493 cout << "-draw_projective_curve " << endl;
494 Draw_projective_curve_description->print();
495 }
496 }
497 else if (ST.stringcmp(argv[i], "-tree_draw") == 0) {
498 f_tree_draw = TRUE;
499 Tree_draw_options = NEW_OBJECT(graphics::tree_draw_options);
500 if (f_v) {
501 cout << "reading -tree_draw" << endl;
502 }
503 i += Tree_draw_options->read_arguments(argc - (i + 1),
504 argv + i + 1, verbose_level);
505 if (f_v) {
506 cout << "i = " << i << endl;
507 cout << "argc = " << argc << endl;
508 if (i < argc) {
509 cout << "next argument is " << argv[i] << endl;
510 }
511 cout << "-tree_draw " << endl;
512 Tree_draw_options->print();
513 }
514 }
515
516
517
518 if (f_v) {
519 cout << "interface_toolkit::read_arguments done" << endl;
520 }
521}
522
524{
525 int j;
526
527 if (f_create_files) {
528 cout << "-create_files " << endl;
529 Create_file_description->print();
530 }
531 if (f_csv_file_select_rows) {
532 cout << "-csv_file_select_rows " << csv_file_select_rows_fname
533 << " " << csv_file_select_rows_text << endl;
534 }
535 if (f_csv_file_split_rows_modulo) {
536 cout << "-csv_file_split_rows_modulo " << csv_file_split_rows_modulo_fname
537 << " " << csv_file_split_rows_modulo_n << endl;
538 }
539 if (f_csv_file_select_cols) {
540 cout << "-csv_file_select_cols " << csv_file_select_cols_fname
541 << " " << csv_file_select_cols_text << endl;
542 }
543 if (f_csv_file_select_rows_and_cols) {
544 cout << "-csv_file_select_rows_and_cols "
545 << csv_file_select_rows_and_cols_fname
546 << " " << csv_file_select_rows_and_cols_R_text
547 << " " << csv_file_select_rows_and_cols_C_text
548 << endl;
549 }
550 if (f_csv_file_sort_each_row) {
551 cout << "-csv_file_sort_each_row "
552 << csv_file_sort_each_row_fname
553 << endl;
554 }
555 if (f_csv_file_join) {
556 cout << "-csv_file_join " << endl;
557 for (j = 0; j < csv_file_join_fname.size(); j++) {
558 cout << j << " : " << csv_file_join_fname[j] << " : " << csv_file_join_identifier[j] << endl;
559 }
560 }
561 if (f_csv_file_concatenate) {
562 cout << "-csv_file_concatenate " << csv_file_concatenate_fname_out << endl;
563 for (j = 0; j < csv_file_concatenate_fname_in.size(); j++) {
564 cout << j << " : " << csv_file_concatenate_fname_in[j] << endl;
565 }
566 }
567 if (f_csv_file_extract_column_to_txt) {
568 cout << "-csv_file_extract_column_to_txt " << csv_file_extract_column_to_txt_fname << " " << csv_file_extract_column_to_txt_col_label << endl;
569 }
570 if (f_csv_file_latex) {
571 cout << "-csv_file_latex " << csv_file_latex_fname << endl;
572 }
573 if (f_draw_matrix) {
574 cout << "-draw_matrix " << endl;
575 Draw_bitmap_control->print();
576 }
577 if (f_reformat) {
578 cout << "-reformat " << reformat_fname_in
579 << " " << reformat_fname_out
580 << " " << reformat_nb_cols << endl;
581 }
582 if (f_split_by_values) {
583 cout << "-split_by_values " << split_by_values_fname_in << endl;
584 }
585 if (f_store_as_csv_file) {
586 cout << "-store_as_csv_file " << store_as_csv_file_fname
587 << " " << store_as_csv_file_m
588 << " " << store_as_csv_file_n
589 << " " << store_as_csv_file_data << endl;
590 }
591 if (f_mv) {
592 cout << "-mv " << mv_a
593 << " " << mv_b << endl;
594 }
595 if (f_loop) {
596 cout << "-loop " << loop_variable
597 << " " << loop_from
598 << " " << loop_to
599 << " " << loop_step
600 << " " << loop_start_idx
601 << " " << loop_end_idx;
602
603 cout << endl;
604
605 }
606 if (f_plot_function) {
607 cout << "-plot_function " << plot_function_fname << endl;
608 }
609 if (f_draw_projective_curve) {
610 cout << "-draw_projective_curve " << endl;
611 Draw_projective_curve_description->print();
612 }
613 if (f_tree_draw) {
614 cout << "-tree_draw " << endl;
615 Tree_draw_options->print();
616 }
617}
618
619void interface_toolkit::worker(int verbose_level)
620{
621 int f_v = (verbose_level >= 1);
622
623 if (f_v) {
624 cout << "interface_toolkit::worker" << endl;
625 }
626
627 if (f_create_files) {
629
630 Fio.create_file(Create_file_description, verbose_level);
631 }
632 else if (f_csv_file_select_rows) {
633
635
636 Fio.do_csv_file_select_rows(csv_file_select_rows_fname,
637 csv_file_select_rows_text, verbose_level);
638 }
639 else if (f_csv_file_split_rows_modulo) {
640
642
643 Fio.do_csv_file_split_rows_modulo(csv_file_split_rows_modulo_fname,
644 csv_file_split_rows_modulo_n, verbose_level);
645 }
646 else if (f_csv_file_select_cols) {
647
649
650 Fio.do_csv_file_select_cols(csv_file_select_cols_fname,
651 csv_file_select_cols_text, verbose_level);
652 }
653 else if (f_csv_file_select_rows_and_cols) {
654
656
658 csv_file_select_rows_and_cols_fname,
659 csv_file_select_rows_and_cols_R_text, csv_file_select_rows_and_cols_C_text,
660 verbose_level);
661 }
662 else if (f_csv_file_sort_each_row) {
664
665 Fio.do_csv_file_sort_each_row(csv_file_sort_each_row_fname, verbose_level);
666
667 }
668 else if (f_csv_file_join) {
669
671
672 Fio.do_csv_file_join(csv_file_join_fname,
673 csv_file_join_identifier, verbose_level);
674 }
675 else if (f_csv_file_concatenate) {
676
678
679 Fio.do_csv_file_concatenate(csv_file_concatenate_fname_in,
680 csv_file_concatenate_fname_out, verbose_level);
681 }
682 else if (f_csv_file_extract_column_to_txt) {
683
685
686 Fio.do_csv_file_extract_column_to_txt(csv_file_extract_column_to_txt_fname, csv_file_extract_column_to_txt_col_label, verbose_level);
687
688 }
689 else if (f_csv_file_latex) {
690
692 int nb_lines_per_table = 25;
693
694 Fio.do_csv_file_latex(csv_file_latex_fname,
695 f_produce_latex_header,
696 nb_lines_per_table,
697 verbose_level);
698 }
699 else if (f_draw_matrix) {
701
702 GO.draw_bitmap(Draw_bitmap_control, verbose_level);
703
704 FREE_int(Draw_bitmap_control->M);
705 }
706 else if (f_reformat) {
708 int *M;
709 int *M2;
710 int m, n;
711 int len;
712 int m2;
713
714 Fio.int_matrix_read_csv(reformat_fname_in, M, m, n, verbose_level);
715 len = m * n;
716 m2 = (len + reformat_nb_cols - 1) / reformat_nb_cols;
717 M2 = NEW_int(m2 * reformat_nb_cols);
718 Int_vec_zero(M2, m2 * reformat_nb_cols);
719 Int_vec_copy(M, M2, len);
720 Fio.int_matrix_write_csv(reformat_fname_out, M2, m2, reformat_nb_cols);
721 cout << "Written file " << reformat_fname_out << " of size " << Fio.file_size(reformat_fname_out) << endl;
722 }
723 else if (f_split_by_values) {
725 int *M;
726 int *M2;
727 int m, n, len, t, h, a;
728
729 Fio.int_matrix_read_csv(split_by_values_fname_in, M, m, n, verbose_level);
730 len = m * n;
732
733 T.init(M, m * n, FALSE, 0);
734 cout << "values in the file : ";
735 T.print(FALSE);
736 cout << endl;
737
738 M2 = NEW_int(len);
739 for (t = 0; t < T.nb_types; t++) {
740 Int_vec_zero(M2, len);
741 a = T.data_sorted[T.type_first[t]];
742 string fname;
743 char str[1000];
745
746 fname.assign(split_by_values_fname_in);
747 ST.chop_off_extension(fname);
748 sprintf(str, "_value%d.csv", a);
749 fname.append(str);
750 for (h = 0; h < len; h++) {
751 if (M[h] == a) {
752 M2[h] = 1;
753 }
754 }
755 Fio.int_matrix_write_csv(fname, M2, m, n);
756 cout << "Written file " << fname << " of size " << Fio.file_size(fname) << endl;
757 }
758 FREE_int(M2);
759 }
760 else if (f_store_as_csv_file) {
761 long int *D;
762 int sz;
763
764 cout << "f_store_as_csv_file" << endl;
765 cout << "data=" << store_as_csv_file_data << endl;
766
767 Lint_vec_scan(store_as_csv_file_data, D, sz);
768 if (sz != store_as_csv_file_m * store_as_csv_file_n) {
769 cout << "sz != store_as_csv_file_m * store_as_csv_file_n" << endl;
770 cout << "sz = " << sz << endl;
771 cout << "store_as_csv_file_m = " << store_as_csv_file_m << endl;
772 cout << "store_as_csv_file_n = " << store_as_csv_file_n << endl;
773 exit(1);
774 }
776
777 Fio.lint_matrix_write_csv(store_as_csv_file_fname, D, store_as_csv_file_m, store_as_csv_file_n);
778 cout << "Written file " << store_as_csv_file_fname << " of size " << Fio.file_size(store_as_csv_file_fname) << endl;
779 }
780 else if (f_mv) {
781 string cmd;
782
783 cmd.assign("mv ");
784 cmd.append(mv_a);
785 cmd.append(" ");
786 cmd.append(mv_b);
787 cout << "executing " << cmd << endl;
788 system(cmd.c_str());
789 }
790 else if (f_loop) {
791 std::string *argv2;
792 int argc2;
793 int j;
794
795 argc2 = loop_end_idx - loop_start_idx;
796 int h, s;
797
798 for (h = loop_from; h < loop_to; h += loop_step) {
799 cout << "loop h=" << h << ":" << endl;
800 argv2 = new string[argc2];
801 for (j = loop_start_idx, s = 0; j < loop_end_idx; j++, s++) {
802
803 char str[1000];
804 string arg;
805 string value_h;
806 string variable;
807
808 arg.assign(loop_argv[j]);
809 sprintf(str, "%d", h);
810 value_h.assign(str);
811 variable.assign("%");
812 variable.append(loop_variable);
813
814 while (arg.find(variable) != std::string::npos) {
815 arg.replace(arg.find(variable), variable.length(), value_h);
816 }
817 argv2[s].assign(arg);
818 }
819 cout << "loop iteration " << h << ", executing sequence of length " << argc2 << " : ";
820 for (s = 0; s < argc2; s++) {
821 cout << " " << argv2[s];
822 }
823 cout << endl;
824
825
826 The_Orbiter_top_level_session->parse_and_execute(argc2 - 1, argv2, 0, verbose_level);
827
828 cout << "loop iteration " << h << "done" << endl;
829
830 delete [] argv2;
831 }
832
833 }
834 else if (f_plot_function) {
837 int *T;
838 int *M;
839 int m1, n1, n, x, y;
840
841 Fio.int_matrix_read_csv(plot_function_fname, T, m1, n1, verbose_level);
842
843
844 n = m1 * n1;
845
846 M = NEW_int(n * n);
847 Int_vec_zero(M, n * n);
848
849
850 for (x = 0; x < n; x++) {
851
852 y = T[x];
853 M[(n - 1 - y) * n + x] = 1;
854 }
855 string fname;
856
857 fname.assign(plot_function_fname);
858 ST.chop_off_extension(fname);
859 fname.append("_graph.csv");
860 Fio.int_matrix_write_csv(fname, M, n, n);
861 cout << "Written file " << fname << " of size " << Fio.file_size(fname) << endl;
862
863 }
864 else if (f_draw_projective_curve) {
866
867 GO.draw_projective_curve(Draw_projective_curve_description,
868 orbiter_kernel_system::Orbiter->draw_options, verbose_level);
869
870 }
871 else if (f_tree_draw) {
873
874 GO.tree_draw(Tree_draw_options, verbose_level);
875
876 }
877
878
879 if (f_v) {
880 cout << "interface_toolkit::worker done" << endl;
881 }
882}
883
884
885}}}
886
functions related to strings and character arrays
a statistical analysis of data consisting of single integers
void init(int *data, int data_length, int f_second, int verbose_level)
Definition: tally.cpp:72
int read_arguments(int argc, std::string *argv, int verbose_level)
a catch-all class for things related to 2D graphics
Definition: graphics.h:411
void draw_bitmap(draw_bitmap_control *C, int verbose_level)
void draw_projective_curve(draw_projective_curve_description *Descr, layered_graph_draw_options *Opt, int verbose_level)
void tree_draw(tree_draw_options *Tree_draw_options, int verbose_level)
int read_arguments(int argc, std::string *argv, int verbose_level)
void int_matrix_write_csv(std::string &fname, int *M, int m, int n)
Definition: file_io.cpp:1300
void do_csv_file_select_rows(std::string &fname, std::string &rows_text, int verbose_level)
Definition: file_io.cpp:3832
void do_csv_file_sort_each_row(std::string &csv_fname, int verbose_level)
Definition: file_io.cpp:4129
void lint_matrix_write_csv(std::string &fname, long int *M, int m, int n)
Definition: file_io.cpp:1323
void do_csv_file_select_cols(std::string &fname, std::string &cols_text, int verbose_level)
Definition: file_io.cpp:3932
void int_matrix_read_csv(std::string &fname, int *&M, int &m, int &n, int verbose_level)
Definition: file_io.cpp:1477
void do_csv_file_split_rows_modulo(std::string &fname, int split_modulo, int verbose_level)
Definition: file_io.cpp:3881
void do_csv_file_latex(std::string &fname, int f_produce_latex_header, int nb_lines_per_table, int verbose_level)
Definition: file_io.cpp:4318
void do_csv_file_concatenate(std::vector< std::string > &fname, std::string &fname_out, int verbose_level)
Definition: file_io.cpp:4263
void do_csv_file_join(std::vector< std::string > &csv_file_join_fname, std::vector< std::string > &csv_file_join_identifier, int verbose_level)
Definition: file_io.cpp:4162
void do_csv_file_select_rows_and_cols(std::string &fname, std::string &rows_text, std::string &cols_text, int verbose_level)
Definition: file_io.cpp:4005
void create_file(create_file_description *Descr, int verbose_level)
Definition: file_io.cpp:3417
void do_csv_file_extract_column_to_txt(std::string &csv_fname, std::string &col_label, int verbose_level)
Definition: file_io.cpp:4066
void read_arguments(int argc, std::string *argv, int &i, int verbose_level)
int recognize_keyword(int argc, std::string *argv, int i, int verbose_level)
void print_help(int argc, std::string *argv, int i, int verbose_level)
void parse_and_execute(int argc, std::string *Argv, int i, int verbose_level)
#define FREE_int(p)
Definition: foundations.h:640
#define Int_vec_zero(A, B)
Definition: foundations.h:713
#define Lint_vec_scan(A, B, C)
Definition: foundations.h:717
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define NEW_int(n)
Definition: foundations.h:625
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define Int_vec_copy(A, B, C)
Definition: foundations.h:693
orbiter_kernel_system::orbiter_session * Orbiter
global Orbiter session
user_interface::orbiter_top_level_session * The_Orbiter_top_level_session
the orbiter library for the classification of combinatorial objects