fix bug with relative coordinates shown in preview window

This commit is contained in:
eddyem 2016-08-18 12:26:48 +03:00
parent c601c6ac10
commit f5ba8ad63e
7 changed files with 20 additions and 10 deletions

View File

@ -78,7 +78,8 @@ if(NOT DEFINED NOIMAGEVIEW)
endif() endif()
if(IMAGEVIEW_FOUND) if(IMAGEVIEW_FOUND)
message("Found OpenGL. Will use ${IMLIB} to show data") 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) add_definitions(-DIMAGEVIEW)
else() else()
message("Will compile without image view module") message("Will compile without image view module")

View File

@ -93,12 +93,14 @@ static char buf[1024];
char *time_asc(double t){ char *time_asc(double t){
int h, m; int h, m;
double s; double s;
char *str = "";
h = (int)(t/3600.); h = (int)(t/3600.);
if(t < 0.){ t = -t; str = "-";}
m = (int)((t - (double)h*3600.)/60.); m = (int)((t - (double)h*3600.)/60.);
s = t - (double)h*3600. - (double)m*60.; s = t - (double)h*3600. - (double)m*60.;
h %= 24; h %= 24;
if(s>59) s=59; 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; return buf;
} }

View File

@ -440,6 +440,8 @@ void calc_coords(float x, float y, double *alpha, double *delta){
if(!wcs_rdy){*alpha = 5e6; *delta = 5e6; return; } if(!wcs_rdy){*alpha = 5e6; *delta = 5e6; return; }
ra = crval1 + dx * CD[0][0] + dy * CD[0][1]; ra = crval1 + dx * CD[0][0] + dy * CD[0][1];
dec = crval2 + dx * CD[1][0] + dy * CD[1][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(alpha) *alpha = ra * 3600.; // hrsec
if(delta) *delta = dec * 3600.; // arcsec if(delta) *delta = dec * 3600.; // arcsec
DBG("ra=%g, dec=%g", *alpha, *delta);
} }

View File

@ -29,8 +29,9 @@ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} IMSOURCES)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
find_package(OpenGL) find_package(OpenGL)
find_package(GLUT) 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") message("GLUT library not found, image view won't be available")
else() else()
# exe file # exe file
@ -145,6 +146,6 @@ endif(NOT DEFINED STANDALONE)
target_link_libraries(${IMLIB} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} -lm -lpthread) target_link_libraries(${IMLIB} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} -lm -lpthread)
include_directories(${${IMLIB}_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR} ..) include_directories(${${IMLIB}_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR} ..)
link_directories(${${IMLIB}_LIBRARY_DIRS}) 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)

View File

@ -94,7 +94,10 @@ void mousePressed(_U_ int key, _U_ int state, _U_ int x, _U_ int y){
if(RA > 4e6){ if(RA > 4e6){
printf("\n"); printf("\n");
WARNX(_("Give WCS parameters, at least ROT0, CRPIX1 and CRPIX2")); 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 == GLUT_MIDDLE_BUTTON) movingwin = 1;
if(key == 3){ // wheel UP if(key == 3){ // wheel UP
if(mod == 0) win->y += 10.*win->zoom; // nothing pressed - scroll up if(mod == 0) win->y += 10.*win->zoom; // nothing pressed - scroll up

View File

@ -196,7 +196,7 @@ void check4running(){
file = open(path, O_RDONLY); file = open(path, O_RDONLY);
if(file == -1) return 0; if(file == -1) return 0;
do{ do{
read(file, &byte, 1); if(read(file, &byte, 1) != 1) break;
if (byte != '/') *pp++ = byte; if (byte != '/') *pp++ = byte;
else pp = name; else pp = name;
} }
@ -218,13 +218,14 @@ void check4running(){
self = getpid(); // self PID self = getpid(); // self PID
if(stat(pidfilename, &s_buf) == 0){ // PID file exists if(stat(pidfilename, &s_buf) == 0){ // PID file exists
pidfile = fopen(pidfilename, "r"); pidfile = fopen(pidfilename, "r");
fscanf(pidfile, "%d", &run); // get PID of (possibly) running process if(1 == fscanf(pidfile, "%d", &run)){ // get PID of (possibly) running process
fclose(pidfile); if(readname(name, run) && strncmp(name, myname, 255) == 0){
if(readname(name, run) && strncmp(name, myname, 255) == 0){
// "ïÂÎÁÒÕÖÅÎ ÒÁÂÏÔÁÀÝÉÊ ÐÒÏÃÅÓÓ (pid=%d), ×ÙÈÏÄ.\n" // "ïÂÎÁÒÕÖÅÎ ÒÁÂÏÔÁÀÝÉÊ ÐÒÏÃÅÓÓ (pid=%d), ×ÙÈÏÄ.\n"
ERR(_("\nFound running process (pid=%d), exit.\n"), run); ERR(_("\nFound running process (pid=%d), exit.\n"), run);
exit(7); exit(7);
}
} }
fclose(pidfile);
} }
// there's no PID file or it's old // there's no PID file or it's old
readname(myname, self); // self name readname(myname, self); // self name

View File

@ -248,7 +248,7 @@ void usage(char *fmt, ...){
// "выбрать диапазон для считывания" // "выбрать диапазон для считывания"
_("select clip region")); _("select clip region"));
// ONLY LONG // ONLY LONG
printf("\t\t--fakeimg\t\t\t%s\n", printf("\t\t--fakeimg\t\t%s\n",
// "Тест окна OpenGL без получения изображения" // "Тест окна OpenGL без получения изображения"
_("Test OpenGL window (without image exposure)")); _("Test OpenGL window (without image exposure)"));
printf("\t\t--flipX\t\t\t%s\n", printf("\t\t--flipX\t\t\t%s\n",