From f5ba8ad63ed94ef751655ae62138f098be8c4051 Mon Sep 17 00:00:00 2001 From: eddyem Date: Thu, 18 Aug 2016 12:26:48 +0300 Subject: [PATCH] fix bug with relative coordinates shown in preview window --- CMakeLists.txt | 3 ++- bta_print.c | 4 +++- defhdrs.c | 2 ++ image_view_module/CMakeLists.txt | 5 +++-- image_view_module/events.c | 5 ++++- takepic.c | 9 +++++---- usage.c | 2 +- 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc32c57..99e9f39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,7 +78,8 @@ if(NOT DEFINED NOIMAGEVIEW) endif() if(IMAGEVIEW_FOUND) message("Found OpenGL. Will use ${IMLIB} to show data") - target_link_libraries(${PROJ} ${${PROJ}_LIBRARIES} -lm ${IMLIB}) + find_package(X11 REQUIRED) + target_link_libraries(${PROJ} ${X11_LIBRARIES} ${${PROJ}_LIBRARIES} -lm ${IMLIB}) add_definitions(-DIMAGEVIEW) else() message("Will compile without image view module") diff --git a/bta_print.c b/bta_print.c index fa1be60..9999842 100644 --- a/bta_print.c +++ b/bta_print.c @@ -93,12 +93,14 @@ static char buf[1024]; char *time_asc(double t){ int h, m; double s; + char *str = ""; h = (int)(t/3600.); + if(t < 0.){ t = -t; str = "-";} m = (int)((t - (double)h*3600.)/60.); s = t - (double)h*3600. - (double)m*60.; h %= 24; if(s>59) s=59; - sprintf(buf, "%dh:%02dm:%04.1fs", h,m,s); + sprintf(buf, "%s%dh:%02dm:%04.1fs", str, h,m,s); return buf; } diff --git a/defhdrs.c b/defhdrs.c index 025b068..9551ab2 100644 --- a/defhdrs.c +++ b/defhdrs.c @@ -440,6 +440,8 @@ void calc_coords(float x, float y, double *alpha, double *delta){ if(!wcs_rdy){*alpha = 5e6; *delta = 5e6; return; } ra = crval1 + dx * CD[0][0] + dy * CD[0][1]; dec = crval2 + dx * CD[1][0] + dy * CD[1][1]; + DBG("ra=%g, dec=%g", ra,dec); if(alpha) *alpha = ra * 3600.; // hrsec if(delta) *delta = dec * 3600.; // arcsec + DBG("ra=%g, dec=%g", *alpha, *delta); } diff --git a/image_view_module/CMakeLists.txt b/image_view_module/CMakeLists.txt index c3975df..bc8ed00 100644 --- a/image_view_module/CMakeLists.txt +++ b/image_view_module/CMakeLists.txt @@ -29,8 +29,9 @@ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} IMSOURCES) find_package(PkgConfig REQUIRED) find_package(OpenGL) find_package(GLUT) +find_package(X11) -if(NOT GLUT_FOUND OR NOT OPENGL_FOUND) +if(NOT GLUT_FOUND OR NOT OPENGL_FOUND OR NOT X11_FOUND) message("GLUT library not found, image view won't be available") else() # exe file @@ -145,6 +146,6 @@ endif(NOT DEFINED STANDALONE) target_link_libraries(${IMLIB} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} -lm -lpthread) include_directories(${${IMLIB}_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR} ..) link_directories(${${IMLIB}_LIBRARY_DIRS}) -endif(NOT GLUT_FOUND OR NOT OPENGL_FOUND) +endif(NOT GLUT_FOUND OR NOT OPENGL_FOUND OR NOT X11_FOUND) diff --git a/image_view_module/events.c b/image_view_module/events.c index 038500a..1e050df 100644 --- a/image_view_module/events.c +++ b/image_view_module/events.c @@ -94,7 +94,10 @@ void mousePressed(_U_ int key, _U_ int state, _U_ int x, _U_ int y){ if(RA > 4e6){ printf("\n"); WARNX(_("Give WCS parameters, at least ROT0, CRPIX1 and CRPIX2")); - }else printf(", ra = %s, dec=%s\n", angle_asc(RA), time_asc(D)); + }else{ + printf(", ra = %s", angle_asc(RA)); + printf(", dec=%s\n", time_asc(D)); + } if(key == GLUT_MIDDLE_BUTTON) movingwin = 1; if(key == 3){ // wheel UP if(mod == 0) win->y += 10.*win->zoom; // nothing pressed - scroll up diff --git a/takepic.c b/takepic.c index e85adc7..d1aeadd 100644 --- a/takepic.c +++ b/takepic.c @@ -196,7 +196,7 @@ void check4running(){ file = open(path, O_RDONLY); if(file == -1) return 0; do{ - read(file, &byte, 1); + if(read(file, &byte, 1) != 1) break; if (byte != '/') *pp++ = byte; else pp = name; } @@ -218,13 +218,14 @@ void check4running(){ self = getpid(); // self PID if(stat(pidfilename, &s_buf) == 0){ // PID file exists pidfile = fopen(pidfilename, "r"); - fscanf(pidfile, "%d", &run); // get PID of (possibly) running process - fclose(pidfile); - if(readname(name, run) && strncmp(name, myname, 255) == 0){ + if(1 == fscanf(pidfile, "%d", &run)){ // get PID of (possibly) running process + if(readname(name, run) && strncmp(name, myname, 255) == 0){ // "Обнаружен работающий процесс (pid=%d), выход.\n" ERR(_("\nFound running process (pid=%d), exit.\n"), run); exit(7); + } } + fclose(pidfile); } // there's no PID file or it's old readname(myname, self); // self name diff --git a/usage.c b/usage.c index 693bc28..fecf276 100644 --- a/usage.c +++ b/usage.c @@ -248,7 +248,7 @@ void usage(char *fmt, ...){ // "выбрать диапазон для считывания" _("select clip region")); // ONLY LONG - printf("\t\t--fakeimg\t\t\t%s\n", + printf("\t\t--fakeimg\t\t%s\n", // "Тест окна OpenGL без получения изображения" _("Test OpenGL window (without image exposure)")); printf("\t\t--flipX\t\t\t%s\n",