From 58e46c31b8657ddef8c7dee59d2360cd3c140c3e Mon Sep 17 00:00:00 2001 From: Ksenia <briling@mail.ru> Date: Tue, 23 Nov 2021 11:52:18 +0100 Subject: [PATCH 1/6] Add secret cli option `gui:0` --- src/v.c | 6 ++++++ src/v/cli.c | 3 ++- src/v/v.h | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/v.c b/src/v.c index 5927c5f..2be66be 100644 --- a/src/v.c +++ b/src/v.c @@ -69,6 +69,7 @@ static void version(FILE * f){ static drawpars dp_init(void){ drawpars dp; dp.task = UNKNOWN; + dp.gui = 1; dp.dt = DEFAULT_TIMEOUT; memset(dp.fontname, 0, STRLEN); dp.n = 0; @@ -144,6 +145,11 @@ int main (int argc, char * argv[]) { canv = px; #endif + if(!dp.gui){ + kp_print_xyz(ent, &dp); + kp_exit(ent, &dp); + } + /*= Main loop ==============================================================*/ main_loop(ent, &dp, kp); diff --git a/src/v/cli.c b/src/v/cli.c index 16f3f60..1d8001b 100644 --- a/src/v/cli.c +++ b/src/v/cli.c @@ -84,11 +84,12 @@ int cli_parse(char * arg, drawpars * dp){ int a3 = sscanf (arg, "bonds:%d", &bonds); int a4 = sscanf (arg, "z:%d,%d,%d,%d,%d", dp->z, dp->z+1, dp->z+2, dp->z+3, dp->z+4); int a5 = sscanf (arg, "font:%255s", dp->fontname); + int a6 = sscanf (arg, "gui:%d", &(dp->gui)); int rot_count = sscan_rot (arg, rot); int cell_count = sscan_cell (arg, cell); int shell_count = sscan_shell(arg, shell); - int cli = a0||a1||a2||a3||a4||a5 || rot_count||cell_count||shell_count; + int cli = a0||a1||a2||a3||a4||a5||a6 || rot_count||cell_count||shell_count; if(vib==0){ dp->task = AT3COORDS; diff --git a/src/v/v.h b/src/v/v.h index ac8a249..1c81516 100644 --- a/src/v/v.h +++ b/src/v/v.h @@ -57,6 +57,7 @@ typedef struct { task_t task; // data type unsigned int dt; // animation timeout char fontname[STRLEN];// font + int gui; // double xy0[2]; // translation vector double ac3rmx[9]; // rotational matrix From 11105d6e5403c9eff52c6f322d0bb1d79b85e119 Mon Sep 17 00:00:00 2001 From: Ksenia <briling@mail.ru> Date: Tue, 23 Nov 2021 12:04:26 +0100 Subject: [PATCH 2/6] fixup 58e46c3 --- src/v.c | 11 ++++++----- src/v/evr.c | 12 +----------- src/v/tools.c | 15 +++++++++++++++ src/v/v.h | 1 + 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/v.c b/src/v.c index 2be66be..b16e14e 100644 --- a/src/v.c +++ b/src/v.c @@ -129,6 +129,12 @@ int main (int argc, char * argv[]) { exit(1); } + if(!dp.gui){ + kp_print_xyz(ent, &dp); + ent_free(ent, &dp); + exit(0); + } + /*= X11 init ===============================================================*/ ptf kp[NKP]; init_x(dp.fname); @@ -145,11 +151,6 @@ int main (int argc, char * argv[]) { canv = px; #endif - if(!dp.gui){ - kp_print_xyz(ent, &dp); - kp_exit(ent, &dp); - } - /*= Main loop ==============================================================*/ main_loop(ent, &dp, kp); diff --git a/src/v/evr.c b/src/v/evr.c index d0f4927..38ea354 100644 --- a/src/v/evr.c +++ b/src/v/evr.c @@ -352,17 +352,7 @@ void kp_move_d(void * ent, drawpars * dp){ } void kp_exit(void * ent, drawpars * dp){ - if (dp->task == VIBRO){ - free(((vibrstr *)ent)->ac); - free(((vibrstr *)ent)->modes); - free(ent); - } - else if (dp->task == AT3COORDS){ - if(dp->f){ - fclose(dp->f); - } - acs_free(ent); - } + ent_free(ent, dp); close_x(); exit(0); } diff --git a/src/v/tools.c b/src/v/tools.c index 9bd6799..69d2b35 100644 --- a/src/v/tools.c +++ b/src/v/tools.c @@ -1,6 +1,21 @@ #include "v.h" #include "sym.h" +void ent_free(void * ent, drawpars * dp){ + if (dp->task == VIBRO){ + free(((vibrstr *)ent)->ac); + free(((vibrstr *)ent)->modes); + free(ent); + } + else if (dp->task == AT3COORDS){ + if(dp->f){ + fclose(dp->f); + } + acs_free(ent); + } + return; +} + void acs_free(atcoords * acs){ for(int i=0; i<acs->n; i++){ free(acs->m[i]); diff --git a/src/v/v.h b/src/v/v.h index 1c81516..3dcc497 100644 --- a/src/v/v.h +++ b/src/v/v.h @@ -141,6 +141,7 @@ void drawshell (double rmin, double rmax, double scale, double * xy0); int savepic (char * s); // tools.c +void ent_free(void * ent, drawpars * dp); void acs_free(atcoords * acs); void newmol_prep(atcoords * acs, drawpars * dp); void ac3_text(atcoord * ac, drawpars * dp); From 3076e221cb8b752732e14424d1a8d22e57b6a8f0 Mon Sep 17 00:00:00 2001 From: Ksenia <briling@mail.ru> Date: Wed, 13 Apr 2022 22:35:50 +0200 Subject: [PATCH 3/6] print connectivity --- src/v.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/v.c b/src/v.c index b16e14e..6274879 100644 --- a/src/v.c +++ b/src/v.c @@ -130,7 +130,13 @@ int main (int argc, char * argv[]) { } if(!dp.gui){ - kp_print_xyz(ent, &dp); + + atcoord * ac = ((atcoords *)ent)->m[dp.n]; + if(dp.b>0 && !ac->bond_flag){ + bonds_fill(dp.rl, ac); + } + + kp_print(ent, &dp); ent_free(ent, &dp); exit(0); } From e234efd74992501dd781d0408758e5bf519e1bab Mon Sep 17 00:00:00 2001 From: Ksenia <briling@mail.ru> Date: Wed, 13 Apr 2022 22:40:09 +0200 Subject: [PATCH 4/6] fixup 3076e22 --- src/v.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v.c b/src/v.c index 6274879..1e393d7 100644 --- a/src/v.c +++ b/src/v.c @@ -136,7 +136,7 @@ int main (int argc, char * argv[]) { bonds_fill(dp.rl, ac); } - kp_print(ent, &dp); + kp_print2fig(ent, &dp); ent_free(ent, &dp); exit(0); } From 0f305a7bf9928833550d4a4e566f4dbd893c7ce3 Mon Sep 17 00:00:00 2001 From: Ksenia <briling@mail.ru> Date: Tue, 16 May 2023 20:16:06 +0200 Subject: [PATCH 5/6] Extend headless functionality --- README.md | 14 ++++++++++++-- src/v.c | 18 +++++++++++++++++- src/v/man.c | 1 + 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d1d8118..785d120 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ Show the reference: | `cell:%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf` | cell parameters in Å | | `shell:b%lf,%lf` | spheres radii in a.u. | | `shell:%lf,%lf` | spheres radii in Å | +| `gui:%d` | normal (default `1`) / headless (`0`) mode | </details> @@ -99,8 +100,17 @@ Show the reference: </details> -<details open><summary><strong>Mouse</strong></summary> -One can also use the mouse to rotate the molecule and zoom in/out (in development). +<details open><summary><strong>Mouse (in development)</strong></summary> +One can also use the mouse to rotate the molecule and zoom in/out. +</details> + +<details open><summary><strong>Headless mode (in development)</strong></summary> +If run in the headless mode with `gui:0`, `v` processes the symbols from stdio as if they were pressed in the normal mode. +Right now, only `p`, `x`, `z`, and `.` are available. For example, +``` +> echo . | ./v mol/mol0001.xyz gui:0 +D*h +``` </details> ## Examples [↑](#contents) diff --git a/src/v.c b/src/v.c index 1e393d7..aec6f50 100644 --- a/src/v.c +++ b/src/v.c @@ -136,7 +136,23 @@ int main (int argc, char * argv[]) { bonds_fill(dp.rl, ac); } - kp_print2fig(ent, &dp); + int c; + while((c = getc(stdin))!=EOF){ + switch(c){ + case('p'): + kp_print2fig(ent, &dp); break; + case('z'): + kp_print_xyz(ent, &dp); break; + case('x'): + kp_print(ent, &dp); break; + case('.'): + { + styp sym; + pg(ac, sym, dp.symtol); + printf("%s\n", sym); + }; break; + } + } ent_free(ent, &dp); exit(0); } diff --git a/src/v/man.c b/src/v/man.c index f0e401e..5da445a 100644 --- a/src/v/man.c +++ b/src/v/man.c @@ -25,6 +25,7 @@ printf("\ cell:%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf,%%lf cell parameters in Å \n\ shell:b%%lf,%%lf spheres radii in a.u. \n\ shell:%%lf,%%lf spheres radii in Å \n\ + gui:%%d` normal (1) / headless (0) mode\n\ \n\ KEYBOARD REFERENCE:\n\ \n\ From 55ba42f9ba56a3c37feb7f9651d0940b48239159 Mon Sep 17 00:00:00 2001 From: Ksenia Briling <30023616+briling@users.noreply.github.com> Date: Tue, 16 May 2023 20:19:21 +0200 Subject: [PATCH 6/6] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 785d120..819d25f 100644 --- a/README.md +++ b/README.md @@ -105,12 +105,15 @@ One can also use the mouse to rotate the molecule and zoom in/out. </details> <details open><summary><strong>Headless mode (in development)</strong></summary> -If run in the headless mode with `gui:0`, `v` processes the symbols from stdio as if they were pressed in the normal mode. + +If run in the headless mode with `gui:0`, the symbols from stdio are processed +as if the corresponding keys were pressed in the normal mode. Right now, only `p`, `x`, `z`, and `.` are available. For example, ``` > echo . | ./v mol/mol0001.xyz gui:0 D*h ``` + </details> ## Examples [↑](#contents)