97#define APP_EXTENSION ".exe"
118gchar *
bs_styles[] = {
"ball&stick",
"balls&sticks",
"balls&stick",
"ball&sticks",
119 "ball_&_stick",
"balls_&_sticks",
"balls_&_stick",
"ball_&_sticks",
120 "ball_and_sticks",
"balls_and_sticks",
"balls_and_stick",
"ball_and_stick",
121 "ballsandsticks",
"ballsandstick",
"ballanddsticks",
"ballandstick",
122 "b&s",
"b_and_s",
"bs",
"b", NULL};
123gchar *
wi_styles[] = {
"wireframe",
"wireframes",
"wires",
"wire",
"wi",
"w", NULL};
124gchar *
co_styles[] = {
"covalent_radius",
"covalent",
"cov_rad",
"cov",
"co",
"cr", NULL};
125gchar *
io_styles[] = {
"ionic_radius",
"ionic_rad",
"ionic",
"ion",
"ir", NULL};
126gchar *
vw_styles[] = {
"vdw_radius",
"van_der_waals_radius",
"van_der_waals",
"vdw_radius",
"vdw_rad",
"vdw",
"vr", NULL};
127gchar *
cr_styles[] = {
"crystal",
"crystal_radius",
"in_crystal",
"in_crystal_radius",
"cryst",
"crystal_rad",
"cr", NULL};
128gchar *
sp_styles[] = {
"sphere",
"spheres",
"sph",
"sp",
"S", NULL};
129gchar *
cy_styles[] = {
"cylinder",
"cylinders",
"cyl",
"cy",
"c", NULL};
142 printf (_(
"\nUsage: atomes [OPTION]\n"
144 " atomes [OPTION] [FILE]\n"
145 " atomes [FILE1] [FILE2] ...\n"
146 " atomes [OPTION1] [FILE1] [OPTION2] [FILE2] ...\n\n"
147 "3D atomic-scale models analysis, creation/edition and post-processing tool\n\n"
149 " -v, --version version information\n"
150 " -h, --help display this help message\n\n"
151 "files, any number, in any order, in the following formats:\n\n"
152 " atomes workspace file : .awf\n"
153 " atomes project file : .apf\n"
154 " XYZ coordinates file : .xyz\n"
155 " Chem3D coordinates file : .c3d\n"
156 " CPMD trajectory : .trj\n"
157 " VASP trajectory : .xdatcar\n"
158 " PDB coordinates : .pdb, .ent\n"
159 " Crystallographic Information File : .cif\n"
160 " DL-POLY history file : .hist\n"
161 " atomes chemical library file (XML) : .sml\n"
162 " ISAACS project file : .ipf\n\n"
163 " alternatively specify the file format using:\n\n"
170 " -pdb [FILE], or, -ent [FILE]\n"
176 " atomes -pdb this.f file.awf -cif that.f *.xyz\n\n"
177 "Image rendering from the command line:\n\n"
178 "Usage: atomes [IMAGE_OPTIONS]\n"
179 " -p, --png, --render-png render image in PNG format\n"
180 " -j, --jpg, --render-jpg render image in JPEG format\n"
181 " -o, --output=[FILE] image file name\n"
182 " -W, --width=[XSIZE] image width\n"
183 " -H, --height=[YSIZE] image height\n"
184 " -s, --style=[STYLE] rendering style\n"
185 " -r, --rep=[REP] representation type\n"
186 " -b, --box=[STYLE] box style\n"
187 " -a, --axis=[STYLE] axis style\n"
188 " -e, --acolor=[MAP] atoms and bonds color map\n"
189 " -t, --pcolor=[MAP] ployhedra color map\n"
190 " -C, --box_color=[COLOR] box color\n"
191 " -G, --back_grad=[GRAD] background gradient type\n"
192 " -B, --back_color=[COLOR] background color\n"
193 " -D, --back_dir=[DIR] background gradient direction\n"
194 " -P, --back_pos=[POS] colors mixed position\n"
195 " -U, --grad_col_a=[COL] gradient initial color\n"
196 " -V, --grad_col_b=[COL] gradient final color\n\n"
198 " atomes --render-png --width=1920 -H 1024 --output=project.png project.apf -s ball_and_stick\n"
199 " atomes --jpg --style=vdw -r ortho -e pc -t pc file.xyz\n\n"
200 "Atomic coordinates conversion from the command line:\n\n"
201 "Usage: atomes [CONVERSION_OPTIONS]\n"
202 " -c, --convert=[FORMAT] conversion format\n\n"
204 " atomes --convert=xyz project.apf\n"
205 " atomes -c sml file.pdb\n\n"));
206 printf (
"%s", _(
"\nReport a bug to <"));
217 printf (
"%s", _(
"\n3D atomic scale model analysis, creation/edition and post-processing tool\n"));
219 printf (
"\nGTK+ version : %1d.%1d.%1d\n",
223 printf (
"Libavutil version : %2d.%2d.%3d\n",
224 LIBAVUTIL_VERSION_MAJOR,
225 LIBAVUTIL_VERSION_MINOR,
226 LIBAVUTIL_VERSION_MICRO);
227 printf (
"Libavformat version : %2d.%2d.%3d\n",
228 LIBAVFORMAT_VERSION_MAJOR,
229 LIBAVFORMAT_VERSION_MINOR,
230 LIBAVFORMAT_VERSION_MICRO);
231 printf (
"Libavcodec version : %2d.%2d.%3d\n",
232 LIBAVCODEC_VERSION_MAJOR,
233 LIBAVCODEC_VERSION_MINOR,
234 LIBAVCODEC_VERSION_MICRO);
235 printf (
"Libswscale version : %2d.%2d.%3d\n",
236 LIBSWSCALE_VERSION_MAJOR,
237 LIBSWSCALE_VERSION_MINOR,
238 LIBSWSCALE_VERSION_MICRO);
246 v_string =
"2005-05";
250 v_string =
"2008-05";
254 v_string =
"2011-07";
258 v_string =
"2013-07";
262 v_string =
"2015-11";
266 v_string =
"2018-11";
270 v_string =
"2020-11";
274 v_string =
"2021-11";
277 v_string =
"unknown";
280 printf (
"OpenMP version : %1.1f (%s)\n", v, v_string);
282 printf (
"FC Compiler : %s\n", FC);
283 printf (
"FC Compiler flags : %s\n", FCFLAGS);
284 printf (
"C Compiler : %s\n", CC);
285 printf (
"C Compiler flags : %s\n", CFLAGS);
287 printf (
"%s", _(
"\nReport a bug to <"));
302 gchar * aext = g_strdup_printf (
"%c%c%c%c", arg[len-4], arg[len-3], arg[len-2], arg[len-1]);
303 char * eext[17]={
".awf",
".apf",
".xyz",
"NULL",
".c3d",
".trj",
"NULL",
".car",
"NULL",
".pdb",
".ent",
".cif",
"NULL",
"NULL",
".hist",
".sml",
".ipf"};
304 for (i=0; i<17; i++)
if (g_strcmp0 (aext, eext[i]) == 0)
322 char * fext[17]={
"-awf",
"-apf",
" -xyz",
"NULL",
"-c3d",
"-trj",
"NULL",
"-xdatcar",
"NULL",
"-pdb",
"-ent",
"-cif",
"NULL",
"NULL",
"-hist",
"-sml",
"-ipf"};
325 gchar * str = g_ascii_strdown (arg, i);
328 if (g_strcmp0 (str, fext[j]) == 0)
351 while (* list != NULL)
353 if (g_strcmp0(* list,
string) == 0)
393 gchar * ortho_keys[] = {
"orthographic",
"ortho",
"o",
"0", NULL};
394 gchar * persp_keys[] = {
"perspective",
"persp",
"p",
"1", NULL};
438 gchar * sp_keys[] = {
"species",
"spec",
"sp",
"0", NULL};
439 gchar * pt_keys[] = {
"total_coordinations",
"total_coordination",
"total_coord",
"total",
"tc",
"t",
"1", NULL};
440 gchar * pc_keys[] = {
"partial_coordinations",
"partial_coordination",
"partial_coord",
"partial",
"pc",
"p",
"2", NULL};
441 gchar * fg_keys[] = {
"fragments",
"fragment",
"frag",
"fg",
"f",
"3", NULL};
442 gchar * mo_keys[] = {
"molecules",
"molecule",
"mol",
"mo",
"m",
"4", NULL};
461 const char *
color = color_string;
465 size_t len = strlen(
color);
466 if (len != 3 && len != 4 && len != 6 && len != 8)
472 int is_long = (len == 6 || len == 8) ? TRUE : FALSE;
473 float ratio = (is_long) ? 255.0 : 15.0;
474 int incr = (is_long) ? 2 : 1;
475 col = g_malloc0(
sizeof*
col);
481 if (is_long) buf[1] =
color[1];
482 col->red = strtol(buf, NULL, 16) / ratio;
483 buf[0] =
color[incr];
484 if (is_long) buf[1] =
color[incr+1];
485 col->green = strtol(buf, NULL, 16) / ratio;
486 buf[0] =
color[2*incr];
487 if (is_long) buf[1] =
color[2*incr+1];
488 col->blue = strtol(buf, NULL, 16) / ratio;
489 if (len == 4 || len == 8)
491 buf[0] =
color[3*incr];
492 if (is_long) buf[1] =
color[3*incr+1];
493 col->alpha = strtol(buf, NULL, 16) / ratio;
497 if (
col -> red < 0.0 || col -> red > 1.0 ||
498 col -> green < 0.0 || col -> green > 1.0 ||
499 col -> blue < 0.0 || col -> blue > 1.0 ||
500 col -> alpha < 0.0 || col -> alpha > 1.0)
517 gchar * no_keys[] = {
"none",
"no",
"n",
"0", NULL};
518 gchar * li_keys[] = {
"linear",
"lin",
"li",
"l",
"1", NULL};
519 gchar * ci_keys[] = {
"circular",
"circ",
"ci",
"c",
"2", NULL};
540 for (j=start; j<end; j++)
543 if (k > 0 && j < end-1)
559 argv[j] = argv[j+1] = g_strdup_printf (
" ");
576 setlocale (LC_ALL,
"");
577 setlocale (LC_NUMERIC,
"C");
578 bindtextdomain (
PACKAGE, PACKAGE_LOCALE);
580 bind_textdomain_codeset (
PACKAGE,
"UTF-8");
593 struct option atomes_options[] = {{
"help", no_argument, 0,
'h'},
594 {
"version", no_argument, 0,
'v'},
595 {
"libreoffice", no_argument, 0,
'l'},
596 {
"render-png", no_argument, 0,
'p'},
597 {
"png", no_argument, 0,
'p'},
598 {
"render-jpg", no_argument, 0,
'j'},
599 {
"jpg", no_argument, 0,
'j'},
600 {
"width", required_argument, 0,
'W'},
601 {
"height", required_argument, 0,
'H'},
602 {
"output", required_argument, 0,
'o'},
603 {
"style", required_argument, 0,
's'},
604 {
"atoms", required_argument, 0,
'e'},
605 {
"poly", required_argument, 0,
't'},
606 {
"axis", required_argument, 0,
'a'},
607 {
"box", required_argument, 0,
'b'},
608 {
"box_color", required_argument, 0,
'C'},
609 {
"back_color", required_argument, 0,
'B'},
610 {
"back_grad", required_argument, 0,
'G'},
611 {
"back_dir", required_argument, 0,
'D'},
612 {
"back_pos", required_argument, 0,
'P'},
613 {
"grad_col_a", required_argument, 0,
'U'},
614 {
"grad_col_b", required_argument, 0,
'V'},
615 {
"rep", required_argument, 0,
'r'},
616 {
"convert", required_argument, 0,
'c'},
623 gchar * image_x = NULL;
624 gchar * image_y = NULL;
637 while ((opt = getopt_long(argc, argv,
"hvlpjdW:H:o:s:a:b:c:r:e:t:B:C:G:D:P:U:V:", atomes_options, & index)) != -1)
656 img_opt += (index == -1) ? 1 : 0;
663 img_opt += (index == -1) ? 1 : 0;
682 img_opt += (index == -1) ? 1 : 0;
685 image_x = g_strdup_printf (
"%s", optarg);
687 img_opt += (index == -1) ? 1 : 0;
690 image_y = g_strdup_printf (
"%s", optarg);
692 img_opt += (index == -1) ? 1 : 0;
697 img_opt += (index == -1) ? 1 : 0;
702 img_opt += (index == -1) ? 1 : 0;
707 img_opt += (index == -1) ? 1 : 0;
712 img_opt += (index == -1) ? 1 : 0;
717 img_opt += (index == -1) ? 1 : 0;
722 img_opt += (index == -1) ? 1 : 0;
727 img_opt += (index == -1) ? 1 : 0;
730 if (isdigit(optarg[0]))
735 img_opt += (index == -1) ? 1 : 0;
741 img_opt += (index == -1) ? 1 : 0;
746 img_opt += (index == -1) ? 1 : 0;
751 img_opt += (index == -1) ? 1 : 0;
765 if (image_x || image_y)
787 for (i=optind; i<argc; i++)
801 ftmp -> next = g_malloc0(
sizeof*
ftmp -> next);
804 ftmp -> file_name = g_strdup_printf (
"%s", argv[i]);
805 ftmp -> file_type = -j;
825 GtkWidget * splashi = (GtkWidget*) user_data;
840G_MODULE_EXPORT gboolean splashdraw (GtkWidget * widget, cairo_t * cr, gpointer data)
842 cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
856 gtk_window_set_decorated (GTK_WINDOW (splash_window), FALSE);
860 gchar * backcol = g_strdup_printf (
"window#splash {\n"
862 " background-color: rgba(255, 255, 255, 0);}");
864 gtk_widget_set_name (splash_window,
"splash");
867 gtk_window_set_type_hint (GTK_WINDOW (splash_window), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN);
868 gtk_window_set_position (GTK_WINDOW (splash_window), GTK_WIN_POS_CENTER_ALWAYS);
869 gtk_widget_set_app_paintable (splash_window, TRUE);
870 GdkScreen * screen = gtk_widget_get_screen (splash_window);
871 GdkVisual * visual = gdk_screen_get_rgba_visual (screen);
872 gtk_widget_set_visual (splash_window, visual);
874 g_signal_connect(G_OBJECT(splash_window),
"draw", G_CALLBACK(splashdraw), NULL);
878 gtk_window_set_transient_for ((GtkWindow *)splash_window, (GtkWindow *)
atomes_main_window);
880 return splash_window;
893 FILE *
fp = fopen (this_file,
dfi[0]);
899 gchar * err = g_strdup_printf (_(
"Error while reading workspace file\n%s\n"), this_file);
941 end = g_strdup_printf (
"%c", file_name[strlen(file_name)-1]);
942 if (g_strcmp0 (file_name,
"*") == 0 || g_strcmp0 (end,
"*") == 0)
944 if (g_strcmp0 (file_name,
"*") == 0)
946 filedir = g_strdup_printf (
"./");
950 filedir = g_strdup_printf (
"%c", file_name[0]);
951 for (i=1; i<strlen(file_name)-1; i++) filedir = g_strdup_printf (
"%s%c", filedir, file_name[i]);
954 hFind = FindFirstFile (filedir, & ffd);
955 if (hFind != INVALID_HANDLE_VALUE)
957 if (ffd.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY)
959 str = g_strdup_printf (
"%s\\%s", filedir, (gchar *)ffd.cFileName);
963 while (FindNextFile(hFind, &ffd) != 0)
965 if (ffd.dwFileAttributes & ! FILE_ATTRIBUTE_DIRECTORY)
967 str = g_strdup_printf (
"%s\\%s", filedir, (gchar *)ffd.cFileName);
975 d = opendir (filedir);
978 while ((dir = readdir(d)) != NULL)
980 if (dir -> d_type == DT_REG)
982 str = g_strdup_printf (
"%s/%s", filedir, dir -> d_name);
1002 end = g_strdup_printf (
"%c", file_name[strlen(file_name)-1]);
1003 if (g_strcmp0 (file_name,
"*") == 0 || g_strcmp0 (end,
"*") == 0)
1005 if (g_strcmp0 (file_name,
"*") == 0)
1007 filedir = g_strdup_printf (
"./");
1011 filedir = g_strdup_printf (
"%c", file_name[0]);
1012 for (i=1; i<strlen(file_name)-1; i++) filedir = g_strdup_printf (
"%s%c", filedir, file_name[i]);
1015 hFind = FindFirstFile (filedir, & ffd);
1016 if (hFind != INVALID_HANDLE_VALUE)
1018 if (ffd.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY)
1021 active_project -> coordfile = g_strdup_printf (
"%s\\%s", filedir, (gchar *)ffd.cFileName);
1024 while (FindNextFile(hFind, &ffd) != 0)
1026 if (ffd.dwFileAttributes & ! FILE_ATTRIBUTE_DIRECTORY)
1029 active_project -> coordfile = g_strdup_printf (
"%s\\%s", filedir, (gchar *)ffd.cFileName);
1036 d = opendir (filedir);
1039 while ((dir = readdir(d)) != NULL)
1041 if (dir -> d_type == DT_REG)
1044 active_project -> coordfile = g_strdup_printf (
"%s/%s", filedir, dir -> d_name);
1074static gboolean handle_open_file (
Instance *
object, GDBusMethodInvocation * invocation,
const gchar * arg_file, gpointer user_data)
1076 if (arg_file && strlen (arg_file) > 0)
1078 int len = strlen (arg_file);
1103static gboolean init_dbus_server ()
1105 GError * error = NULL;
1106 GDBusConnection * connection;
1107 GDBusInterfaceSkeleton * skeleton;
1110 connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, & error);
1113 g_printerr (
"D-Bus connection error : %s\n", error -> message);
1114 g_error_free (error);
1120 skeleton = G_DBUS_INTERFACE_SKELETON (interface);
1123 g_signal_connect (interface,
"handle-open-file", G_CALLBACK (handle_open_file), NULL);
1126 if (! g_dbus_interface_skeleton_export (skeleton, connection,
"/fr/ipcms/atomes/Instance", & error))
1128 g_printerr (
"D-Bus interface export error : %s\n", error -> message);
1129 g_error_free (error);
1135 GVariant * name_result = g_dbus_connection_call_sync (connection,
1136 "org.freedesktop.DBus",
1137 "/org/freedesktop/DBus",
1138 "org.freedesktop.DBus",
1140 g_variant_new (
"(su)",
"fr.ipcms.atomes.Instance", 4u),
1141 G_VARIANT_TYPE (
"(u)"),
1142 G_DBUS_CALL_FLAGS_NONE,
1147 g_printerr (
"D-Bus name reservation error : %s\n", error -> message);
1148 g_error_free (error);
1151 else if (name_result)
1154 g_variant_get (name_result,
"(u)", & reply);
1155 g_variant_unref (name_result);
1158 g_printerr (
"Impossible d'obtenir le nom D-Bus (code: %u)\n", reply);
1172static gboolean check_existing_instance ()
1174 gboolean sent = FALSE;
1175 if (!
flist)
return sent;
1177 GError * error = NULL;
1178 GDBusConnection * connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, & error);
1181 g_printerr (
"D-Bus connection error : %s\n", error -> message);
1182 g_error_free (error);
1186 if (!
flist)
return sent;
1192 GVariant * result = g_dbus_connection_call_sync (connection,
1193 "fr.ipcms.atomes.Instance",
1194 "/fr/ipcms/atomes/Instance",
1195 "fr.ipcms.atomes.Instance",
1197 g_variant_new (
"(s)", tmp ->
file_name),
1199 G_DBUS_CALL_FLAGS_NONE,
1206 g_printerr (
"D-Bus OpenFile error: %s\n", error -> message);
1207 g_error_free (error);
1212 g_variant_unref (result);
1218 g_object_unref (connection);
1223#define ATOMES_MUTEX_NAME "fr.ipcms.atomes.mutex"
1224#define ATOMES_PIPE_NAME "\\\\.\\pipe\\fr.ipcms.atomes.pipe"
1225#define ATOMES_PIPE_BUFSIZE 4096
1227HANDLE win32_mutex = NULL;
1234typedef struct OpenFileData OpenFileData;
1252static gboolean win32_open_file_idle (gpointer user_data)
1254 OpenFileData * ofd = (OpenFileData *) user_data;
1260 g_free (ofd -> file_name);
1276static gpointer win32_pipe_server_thread (gpointer user_data)
1280 HANDLE pipe = CreateNamedPipe (ATOMES_PIPE_NAME,
1281 PIPE_ACCESS_INBOUND,
1282 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
1283 PIPE_UNLIMITED_INSTANCES,
1284 ATOMES_PIPE_BUFSIZE,
1285 ATOMES_PIPE_BUFSIZE,
1287 if (pipe == INVALID_HANDLE_VALUE)
1289 g_printerr (
"CreateNamedPipe failed: %lu\n", GetLastError ());
1293 BOOL connected = ConnectNamedPipe(pipe, NULL);
1294 if (! connected && GetLastError() != ERROR_PIPE_CONNECTED)
1296 g_printerr (
"ConnectNamedPipe failed: %lu", GetLastError());
1300 else if (connected || GetLastError () == ERROR_PIPE_CONNECTED)
1302 char buf[ATOMES_PIPE_BUFSIZE];
1303 DWORD bytes_read = 0;
1304 BOOL ok = ReadFile (pipe, buf,
sizeof (buf) - 1, & bytes_read, NULL);
1305 if (ok && bytes_read > 0)
1307 buf[bytes_read] =
'\0';
1308 int len = (int) strlen (buf);
1312 OpenFileData * ofd = g_malloc0 (
sizeof * ofd);
1313 ofd -> file_type = file_type;
1314 ofd -> file_name = g_strdup (buf);
1315 g_idle_add (win32_open_file_idle, ofd);
1320 g_printerr (
"ReadFile failed: %lu", GetLastError());
1323 DisconnectNamedPipe(pipe);
1337static gboolean init_win32_server ()
1339 win32_mutex = CreateMutex (NULL, TRUE, ATOMES_MUTEX_NAME);
1340 if (win32_mutex == NULL)
1342 g_printerr (
"CreateMutex failed: %lu\n", GetLastError ());
1346 if (GetLastError () == ERROR_ALREADY_EXISTS)
1348 CloseHandle (win32_mutex);
1353 HANDLE thread = g_thread_new (
"atomes-pipe-server", win32_pipe_server_thread, NULL);
1356 CloseHandle (win32_mutex);
1375static gboolean check_existing_win32_instance ()
1377 if (!
flist)
return FALSE;
1379 HANDLE mutex = OpenMutex (MUTEX_ALL_ACCESS, FALSE, ATOMES_MUTEX_NAME);
1380 if (mutex == NULL)
return FALSE;
1382 gboolean sent = FALSE;
1386 HANDLE pipe = CreateFile (ATOMES_PIPE_NAME,
1394 if (pipe == INVALID_HANDLE_VALUE)
1396 g_printerr (
"CreateFile PIPE FAILED: %lu\n", GetLastError());
1399 DWORD len = (DWORD) strlen (tmp ->
file_name);
1402 BOOL ok = WriteFile (pipe, tmp ->
file_name, len, & written, NULL);
1406 g_printerr (
"WriteFile FAILED: %lu\n", GetLastError());
1410 g_printerr (
"WriteFile OK: %lu/%lu bytes\n", written, len);
1411 if (written == len) sent = TRUE;
1418 CloseHandle (mutex);
1430static void process_pending_files ()
1476 setlocale (LC_NUMERIC,
"C");
1477 GtkSettings * default_settings = gtk_settings_get_default ();
1484 g_object_set (default_settings,
"gtk-button-images", TRUE, NULL);
1488 g_object_set (default_settings,
"gtk-key-theme-name",
"win32", NULL);
1497#ifdef MAC_INTEGRATION
1498 GtkosxApplication * ProgOSX;
1499 ProgOSX = g_object_new (GTKOSX_TYPE_APPLICATION, NULL);
1500 gtkosx_application_set_use_quartz_accelerators (ProgOSX, FALSE);
1501 gtkosx_application_ready (ProgOSX);
1511 if (isplash == NULL)
1513 g_warning (_(
"Impossible to load the splash screen\n"));
1521 if (
flist) process_pending_files ();
1523#ifdef MAC_INTEGRATION
1524 g_object_unref (ProgOSX);
1535static void queue_open_file (
const gchar *
path)
1537 if (
path == NULL || *
path ==
'\0')
return;
1539 gsize len = strlen(
path);
1540 if (len < 4)
return;
1547 struct file_list * node = g_malloc0(
sizeof*node);
1558 while (last ->
next != NULL)
1560 last = last ->
next;
1562 last ->
next = node;
1581G_MODULE_EXPORT
void on_atomes_open (GApplication * app, GFile ** files, gint n_files,
const gchar * hint, gpointer user_data)
1584 for (i = 0; i < n_files; i++)
1586 gchar *
path = g_file_get_path(files[i]);
1589 gchar * absolute_path = g_canonicalize_filename (
path, NULL);
1590 queue_open_file (absolute_path);
1591 g_free (absolute_path);
1597 process_pending_files ();
1608 GError * error = NULL;
1609 gchar * proc_dir = NULL;
1610 gchar * proc_path = NULL;
1611 const char * proc_name;
1613 proc_dir = g_build_filename (PACKAGE_PREFIX,
"bin", NULL);
1614 proc_name =
"atomes_startup_testing.exe";
1615 proc_path = g_build_filename (proc_dir, proc_name, NULL);
1617 proc_dir = g_build_filename (PACKAGE_LIBEXEC, NULL);
1618 proc_name =
"atomes_startup_testing";
1619 proc_path = g_build_filename (PACKAGE_LIBEXEC, proc_name, NULL);
1622 g_print (
"proc_dir= %s\n", proc_dir);
1623 g_print (
"proc_name= %s\n", proc_name);
1624 g_print (
"proc_path= %s\n", proc_path);
1628 GSubprocess * proc = g_subprocess_new (G_SUBPROCESS_FLAGS_NONE, & error, proc_path, NULL);
1631 GSubprocessLauncher * proc_launch = g_subprocess_launcher_new (G_SUBPROCESS_FLAGS_NONE);
1632 g_subprocess_launcher_set_cwd (proc_launch, proc_dir);
1633 GSubprocess * proc = g_subprocess_launcher_spawn (proc_launch, & error, proc_path, NULL);
1635 GSubprocess * proc = g_subprocess_new (G_SUBPROCESS_FLAGS_NONE, & error, proc_path, NULL);
1641 g_printerr (
"error: %s\n", error -> message);
1642 g_clear_error (& error);
1644 g_subprocess_wait (proc, NULL, & error);
1645 int res = g_subprocess_get_exit_status (proc);
1647 g_debug (
"Exit status of atomes_startup_testing = %d",
res);
1649 g_object_unref (proc);
1652 g_object_unref (proc_launch);
1657 gchar * ogl_info = NULL;
1661 ogl_info = g_strdup_printf (_(
"Fatal error on OpenGL initialization: trying to adjust environment !"));
1664 ogl_info = g_strdup_printf (_(
"Impossible to initialize the OpenGL 3D rendering !"));
1667 ogl_info = g_strdup_printf (_(
"GDK visual must be modified to initialize the OpenGL context !"));
1674 g_print (
"%s\n", ogl_info);
1691 gboolean RUNC = FALSE;
1697 PACKAGE_PREFIX = g_win32_get_package_installation_directory_of_module (NULL);
1698 PACKAGE_LOCALE = g_build_filename (PACKAGE_PREFIX,
"locale", NULL);
1702 PACKAGE_IMP = g_build_filename (PACKAGE_PREFIX,
"pixmaps/import.png", NULL);
1703 PACKAGE_IMP = g_build_filename (PACKAGE_PREFIX,
"pixmaps/import.png", NULL);
1704 PACKAGE_CON = g_build_filename (PACKAGE_PREFIX,
"pixmaps/convert.png", NULL);
1705 PACKAGE_IMG = g_build_filename (PACKAGE_PREFIX,
"pixmaps/image.png", NULL);
1706 PACKAGE_PDF = g_build_filename (PACKAGE_PREFIX,
"pixmaps/pdf.png", NULL);
1707 PACKAGE_SVG = g_build_filename (PACKAGE_PREFIX,
"pixmaps/svg.png", NULL);
1708 PACKAGE_EPS = g_build_filename (PACKAGE_PREFIX,
"pixmaps/eps.png", NULL);
1709 PACKAGE_PNG = g_build_filename (PACKAGE_PREFIX,
"pixmaps/png.png", NULL);
1710 PACKAGE_JPG = g_build_filename (PACKAGE_PREFIX,
"pixmaps/jpg.png", NULL);
1711 PACKAGE_BMP = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bmp.png", NULL);
1712 PACKAGE_TIFF = g_build_filename (PACKAGE_PREFIX,
"pixmaps/tiff.png", NULL);
1713 PACKAGE_VOID = g_build_filename (PACKAGE_PREFIX,
"pixmaps/void.png", NULL);
1714 PACKAGE_TD = g_build_filename (PACKAGE_PREFIX,
"pixmaps/td.png", NULL);
1715 PACKAGE_MOL = g_build_filename (PACKAGE_PREFIX,
"pixmaps/molecule.png", NULL);
1716 PACKAGE_OGL = g_build_filename (PACKAGE_PREFIX,
"pixmaps/opengl.png", NULL);
1717 PACKAGE_OGLM = g_build_filename (PACKAGE_PREFIX,
"pixmaps/mol.png", NULL);
1718 PACKAGE_OGLC = g_build_filename (PACKAGE_PREFIX,
"pixmaps/mol.png", NULL);
1719 PACKAGE_PRO = g_build_filename (PACKAGE_PREFIX,
"pixmaps/prop.png", NULL);
1720 PACKAGE_SET = g_build_filename (PACKAGE_PREFIX,
"pixmaps/settings.png", NULL);
1721 PACKAGE_LOGO = g_build_filename (PACKAGE_PREFIX,
"pixmaps/logo.png", NULL);
1722 PACKAGE_LAGPL = g_build_filename (PACKAGE_PREFIX,
"pixmaps/logo-agpl.png", NULL);
1723 PACKAGE_LABOUT = g_build_filename (PACKAGE_PREFIX,
"pixmaps/logo-about.png", NULL);
1724 PACKAGE_DOTA = g_build_filename (PACKAGE_PREFIX,
"pixmaps/dots/dots-a.png", NULL);
1725 PACKAGE_DOTB = g_build_filename (PACKAGE_PREFIX,
"pixmaps/dots/dots-b.png", NULL);
1726 PACKAGE_DOTC = g_build_filename (PACKAGE_PREFIX,
"pixmaps/dots/dots-c.png", NULL);
1727 PACKAGE_DOTD = g_build_filename (PACKAGE_PREFIX,
"pixmaps/dots/dots-d.png", NULL);
1728 PACKAGE_DOTE = g_build_filename (PACKAGE_PREFIX,
"pixmaps/dots/dots-e.png", NULL);
1729 PACKAGE_DOTF = g_build_filename (PACKAGE_PREFIX,
"pixmaps/dots/dots-f.png", NULL);
1730 PACKAGE_DOTG = g_build_filename (PACKAGE_PREFIX,
"pixmaps/dots/dots-g.png", NULL);
1731 PACKAGE_DOTH = g_build_filename (PACKAGE_PREFIX,
"pixmaps/dots/dots-h.png", NULL);
1732 PACKAGE_DFBD = g_build_filename (PACKAGE_PREFIX,
"pixmaps/field/bd.png", NULL);
1733 PACKAGE_DFAN = g_build_filename (PACKAGE_PREFIX,
"pixmaps/field/an.png", NULL);
1734 PACKAGE_DFDI = g_build_filename (PACKAGE_PREFIX,
"pixmaps/field/di.png", NULL);
1735 PACKAGE_DFTD = g_build_filename (PACKAGE_PREFIX,
"pixmaps/field/td.png", NULL);
1736 PACKAGE_DFIN = g_build_filename (PACKAGE_PREFIX,
"pixmaps/field/in.png", NULL);
1737 PACKAGE_SGCP = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bravais/Cubic-P.png", NULL);
1738 PACKAGE_SGCI = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bravais/Cubic-I.png", NULL);
1739 PACKAGE_SGCF = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bravais/Cubic-F.png", NULL);
1740 PACKAGE_SGHP = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bravais/Hexagonal.png", NULL);
1741 PACKAGE_SGTR = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bravais/Trigonal-R.png", NULL);
1742 PACKAGE_SGTI = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bravais/Tetragonal-I.png", NULL);
1743 PACKAGE_SGTP = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bravais/Tetragonal-P.png", NULL);
1744 PACKAGE_SGOP = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bravais/Orthorhombic-P.png", NULL);
1745 PACKAGE_SGOI = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bravais/Orthorhombic-I.png", NULL);
1746 PACKAGE_SGOC = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bravais/Orthorhombic-C.png", NULL);
1747 PACKAGE_SGOF = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bravais/Orthorhombic-F.png", NULL);
1748 PACKAGE_SGMP = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bravais/Monoclinic-P.png", NULL);
1749 PACKAGE_SGMI = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bravais/Monoclinic-I.png", NULL);
1750 PACKAGE_SGTC = g_build_filename (PACKAGE_PREFIX,
"pixmaps/bravais/Triclinic.png", NULL);
1773 g_setenv (
"GSK_RENDERER",
"gl", TRUE);
1774 g_setenv (
"GDK_DEBUG",
"gl-prefer-gl", TRUE);
1779 g_setenv (
"GDK_RENDERER",
"ngl", TRUE);
1789 g_setenv (
"GSK_RENDERER",
"gl", TRUE);
1794 PWSTR localPath = NULL;
1795 HRESULT hr = SHGetKnownFolderPath (& FOLDERID_LocalAppData, 0, NULL, & localPath);
1798 fprintf (stderr, _(
"Error impossible to obtain the AppData\\Roaming (code 0x%08lx)\n%s"), hr);
1804 char appdata[MAX_PATH];
1805 wcstombs (appdata, localPath, MAX_PATH);
1806 CoTaskMemFree (localPath);
1812 struct passwd * pw = getpwuid(getuid());
1829 if (argc > 1 && check_existing_win32_instance ())
1833 if (! init_win32_server ())
1835 g_print (
"Init Win32 pipe server failed\n");
1839 if (argc > 1 && check_existing_instance ())
1845 if (! init_dbus_server ())
1847 g_print (
"Init D-BUS failed\n");
1854#if GLIB_MINOR_VERSION < 74
1855 atomes_app = gtk_application_new (g_strdup_printf (
"fr.ipcms.atomes.prog-%d", (
int)clock()), G_APPLICATION_HANDLES_OPEN);
1857 atomes_app = gtk_application_new (g_strdup_printf (
"fr.ipcms.atomes.prog-%d", (
int)clock()), G_APPLICATION_DEFAULT_FLAGS | G_APPLICATION_HANDLES_OPEN);
1862 GError * error = NULL;
1863 if (! g_application_register (G_APPLICATION(
atomes_app), NULL, & error))
1865 g_printerr (
"Application registration failed: %s\n", error -> message);
1866 g_error_free (error);
1876 ReleaseMutex (win32_mutex);
1877 CloseHandle (win32_mutex);
Binding to the Fortran90 subroutines.
int open_save_workspace(FILE *fp, int act)
open or save the active workspace
void open_this_coordinate_file(int format, gchar *proj_name, gboolean main_reader)
open coordinate file format, if successful add to workspace
int open_save(FILE *fp, int act, int wid, int pid, int aid, gchar *pfile)
open or save project file
void open_this_isaacs_xml_file(gchar *profile, int ptoc, gboolean visible)
open an ISAACS XML file
Callback declarations for main window.
#define PACKAGE_BUGREPORT
Instance * instance_skeleton_new(void)
void instance_complete_open_file(Instance *object G_GNUC_UNUSED, GDBusMethodInvocation *invocation)
struct _Instance Instance
GtkWidget * atomes_main_window
gboolean atomes_render_image
int * allocint(int val)
allocate an int * pointer
gchar * ATOMES_CONFIG_DIR
GtkApplication * atomes_app
double string_to_double(gpointer string)
convert string to double
gboolean atomes_from_libreoffice
Global variable declarations Global convenience function declarations Global data structure defin...
GtkWidget * new_gtk_window()
create a new GtkWindow
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
void provide_gtk_css(gchar *css)
create a css provider based on the css data
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
ColRGBA * render_image_grad_color[2]
ColRGBA * render_image_box_color
ColRGBA * render_image_back_color
int * render_image_pixels
int render_image_back_grad
gboolean trigger_fragment_analysis
float render_image_back_pos
int render_image_back_dir
gchar * render_image_output
gboolean trigger_molecule_analysis
void init_project(gboolean alloc_box)
initialize a new project
void show_error(char *error, int val, GtkWidget *win)
show error message
Messaging function declarations.
int get_color_map_from_string(gchar *col_string)
retrieve color map from command line string
int get_rep_from_string(gchar *rep_string)
retrieve representation style from command line string
int main(int argc, char *argv[])
initialization of the atomes program
int check_opengl_rendering()
check the initialization parameters for an OpenGL context
int test_this_arg(gchar *arg)
test an argument from the command line
int get_box_axis_from_string(gchar *box_axis_string)
retrieve box or axis style from command line string
int get_file_format_from_string(gchar *file_format_string)
retrieve file format for convertion from command line string
G_MODULE_EXPORT void on_atomes_open(GApplication *app, GFile **files, gint n_files, const gchar *hint, gpointer user_data)
hanlde the open signal for the atomes application
GtkWidget * create_splash_window()
create splash screen window
void print_version()
print version information
ColRGBA * get_color_from_hexa_string(gchar *color_string)
convert Hexadecimal string to ColRGBA
void set_atomes_locale()
set locale
gboolean is_string_in_string_list(gchar *string, gchar **list)
check if a string is in a list of strings
int get_gradient_from_string(gchar *grad_string)
retrieve background gradient from command line string
void print_help()
print basic help
GtkWidget * create_main_window(GApplication *app)
create the main application window
gboolean destroy_func(gpointer user_data)
destroy splash screen
int parse_command_line(int argc, char *argv[])
test command line arguments
int test_this_ext(int len, gchar *arg)
test extension of an argument from the command line
void open_this_data_file(int file_type, gchar *file_name)
open data file from the command line
G_MODULE_EXPORT void on_atomes_start(GApplication *app, gpointer data)
run the program
int check_for_atomes_file_options(int start, int end, char *argv[])
retrieve the list of files to read from the command line leave out all other options
void read_this_file(int file_type, gchar *this_file)
read file from the command line
int get_style_from_string(gchar *style_string)
retrieve style from command line string
Data structure declarations for movie encoding Function declarations for movie encoding.
void set_atomes_preferences()
set software default parameters
Preference variable declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
Function declarations for workspace managment.