IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25757


Ignore:
Timestamp:
Oct 2, 2009, 3:15:42 PM (17 years ago)
Author:
eugene
Message:

various dvo and other improvements from gene@dev branch

Location:
trunk/Ohana/src
Files:
5 deleted
93 edited
16 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/src/ConfigInit.c

    r24973 r25757  
    180180  /* XXX this does not yet write out the master photcode table */
    181181  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    182   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     182  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    183183    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    184184    exit (1);
  • trunk/Ohana/src/addstar/src/ConfigInit_skycells.c

    r16061 r25757  
    5555  /* XXX this does not yet write out the master photcode table */
    5656  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    57   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     57  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    5858    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    5959    exit (1);
  • trunk/Ohana/src/addstar/src/addstar.c

    r21508 r25757  
    2525  options = args (argc, argv, options);
    2626
    27   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     27  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    2828  if (sky == NULL) {
    2929      fprintf (stderr, "ERROR: unable to load sky table data\n");
  • trunk/Ohana/src/addstar/src/addstard.c

    r6236 r25757  
    1212
    1313  /* store the sky table in a global for internal use */
    14   ServerSky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     14  ServerSky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1515  SkyTableSetFilenames (ServerSky, CATDIR, "cpt");
    1616
  • trunk/Ohana/src/addstar/src/addstart.c

    r10939 r25757  
    1212
    1313  /* store the sky table in a global for internal use */
    14   ServerSky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     14  ServerSky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1515  SkyTableSetFilenames (ServerSky, CATDIR, "cpt");
    1616
  • trunk/Ohana/src/addstar/src/load2mass.c

    r24977 r25757  
    1616
    1717  // load the full sky description table:
    18   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     18  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1919  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2020 
  • trunk/Ohana/src/addstar/src/sedstar.c

    r15743 r25757  
    1515  options = args_sedstar (argc, argv, options);
    1616
    17   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     17  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1818  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1919 
  • trunk/Ohana/src/delstar/src/ConfigInit.c

    r12332 r25757  
    4545  /* XXX this does not yet write out the master photcode table */
    4646  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    47   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     47  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    4848    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    4949    exit (1);
  • trunk/Ohana/src/delstar/src/delete_imagefile.c

    r15743 r25757  
    1212
    1313  /* load sky from correct table */
    14   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     14  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1515  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1616
  • trunk/Ohana/src/delstar/src/delete_imagename.c

    r17245 r25757  
    1515
    1616  /* load sky from correct table */
    17   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     17  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1818  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1919
  • trunk/Ohana/src/delstar/src/delete_times.c

    r15743 r25757  
    1515
    1616  /* load sky from correct table */
    17   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     17  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1818  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1919
  • trunk/Ohana/src/dvomerge/src/dvomerge.c

    r24750 r25757  
    2424  // the first input define the photcode table & db layout
    2525  sprintf (filename, "%s/Photcodes.dat", input1);
    26   if (!LoadPhotcodes (filename, NULL)) {
     26  if (!LoadPhotcodes (filename, NULL, FALSE)) {
    2727    fprintf (stderr, "error loading photcode table %s\n", filename);
    2828    exit (1);
     
    3030  // save the photcodes in the output catdir
    3131  sprintf (filename, "%s/Photcodes.dat", output);
    32   if (!check_file_access (filename, TRUE, TRUE)) {
     32  if (!check_file_access (filename, TRUE, TRUE, TRUE)) {
    3333    fprintf (stderr, "error creating output catdir %s\n", output);
    3434    exit (1);
     
    4040
    4141  // load the sky table for the existing database
    42   insky1 = SkyTableLoadOptimal (input1, NULL, NULL, SKY_DEPTH_HST, VERBOSE);
     42  insky1 = SkyTableLoadOptimal (input1, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE);
    4343  SkyTableSetFilenames (insky1, input1, "cpt");
    4444
    45   insky2 = SkyTableLoadOptimal (input2, NULL, NULL, SKY_DEPTH_HST, VERBOSE);
     45  insky2 = SkyTableLoadOptimal (input2, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE);
    4646  SkyTableSetFilenames (insky2, input2, "cpt");
    4747
    4848  // generate an output table populated at the desired depth
    49   outsky = SkyTableLoadOptimal (output, NULL, GSCFILE, SKY_DEPTH, VERBOSE);
     49  outsky = SkyTableLoadOptimal (output, NULL, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    5050  SkyTableSetFilenames (outsky, output, "cpt");
    5151
     
    117117  // save the output sky table copy
    118118  sprintf (filename, "%s/SkyTable.fits", output);
    119   check_file_access (filename, TRUE, VERBOSE);
     119  check_file_access (filename, TRUE, TRUE, VERBOSE);
    120120  if (!SkyTableSave (outsky, filename)) {
    121121    fprintf (stderr, "ERROR: failed to save sky table for %s\n", output);
  • trunk/Ohana/src/dvosplit/src/ConfigInit.c

    r24753 r25757  
    3333  /* XXX this does not yet write out the master photcode table */
    3434  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    35   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     35  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    3636    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    3737    exit (1);
  • trunk/Ohana/src/dvosplit/src/dvosplit.c

    r15746 r25757  
    1818
    1919  // load the sky table for the existing database
    20   sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, SKY_DEPTH_HST, VERBOSE);
     20  sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, SKY_DEPTH_HST, VERBOSE);
    2121  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2222
     
    7979  // save sky table copy
    8080  sprintf (filename, "%s/SkyTable.fits", CATDIR);
    81   check_file_access (filename, TRUE, VERBOSE);
     81  check_file_access (filename, TRUE, TRUE, VERBOSE);
    8282  if (!SkyTableSave (sky, filename)) {
    8383    fprintf (stderr, "ERROR: failed to save sky table for %s\n", CATDIR);
  • trunk/Ohana/src/gastro/src/getptolemy.c

    r16810 r25757  
    1919
    2020  /* load regions from GSC table, restrict to patch */
    21   sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, SKY_DEPTH_HST, VERBOSE);
     21  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, FALSE, SKY_DEPTH_HST, VERBOSE);
    2222  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2323  skylist = SkyListByPatch (sky, -1, &patch);
  • trunk/Ohana/src/gastro2/src/getptolemy.c

    r16810 r25757  
    2121
    2222  /* load regions from GSC table, restrict to patch */
    23   sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, SKY_DEPTH_HST, VERBOSE);
     23  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, FALSE, SKY_DEPTH_HST, VERBOSE);
    2424  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2525  skylist = SkyListByPatch (sky, -1, &patch);
  • trunk/Ohana/src/getstar/src/ConfigInit.c

    r15543 r25757  
    3434  /* XXX this does not yet write out the master photcode table */
    3535  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    36   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     36  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    3737    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    3838    exit (1);
  • trunk/Ohana/src/getstar/src/ConfigInit_coords.c

    r24914 r25757  
    3535  /* XXX this does not yet write out the master photcode table */
    3636  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    37   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     37  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    3838    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    3939    exit (1);
  • trunk/Ohana/src/getstar/src/ConfigInit_extract.c

    r12840 r25757  
    3535  /* XXX this does not yet write out the master photcode table */
    3636  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    37   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     37  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    3838    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    3939    exit (1);
  • trunk/Ohana/src/getstar/src/ConfigInit_overlaps.c

    r12774 r25757  
    3535  /* XXX this does not yet write out the master photcode table */
    3636  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    37   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     37  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, FALSE)) {
    3838    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    3939    exit (1);
  • trunk/Ohana/src/getstar/src/getstar.c

    r20984 r25757  
    1313  set_db (&db);
    1414
    15   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     15  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1616  if (!sky) exit (1);
    1717   
  • trunk/Ohana/src/imregister/base/ConfigInit.c

    r12332 r25757  
    105105  /* XXX this does not yet write out the master photcode table */
    106106  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", catdir);
    107   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     107  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    108108    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    109109    exit (1);
  • trunk/Ohana/src/imregister/imphot/ConfigInit.c

    r12332 r25757  
    101101  /* XXX this does not yet write out the master photcode table */
    102102  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    103   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     103  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    104104    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    105105    exit (1);
  • trunk/Ohana/src/kapa2/Makefile

    r16270 r25757  
    4848$(SRC)/Layout.$(ARCH).o                   $(SRC)/Sections.$(ARCH).o           \
    4949$(SRC)/Graphs.$(ARCH).o                   $(SRC)/SetGraphSize.$(ARCH).o       \
    50 $(SRC)/Resize.$(ARCH).o                   $(SRC)/ErasePlots.$(ARCH).o         \
    51 $(SRC)/EraseImage.$(ARCH).o               $(SRC)/SetToolbox.$(ARCH).o         \
     50$(SRC)/Resize.$(ARCH).o                   $(SRC)/Relocate.$(ARCH).o           \
     51$(SRC)/ErasePlots.$(ARCH).o               $(SRC)/EraseImage.$(ARCH).o         \
    5252$(SRC)/EraseCurrentPlot.$(ARCH).o         $(SRC)/EraseSections.$(ARCH).o      \
     53$(SRC)/SetToolbox.$(ARCH).o                                                   \
    5354$(SRC)/SetSection.$(ARCH).o               $(SRC)/DefineSection.$(ARCH).o      \
    5455$(SRC)/SetLimits.$(ARCH).o                $(SRC)/SetFont.$(ARCH).o            \
     
    7980$(SRC)/ColorHistogram.$(ARCH).o           $(SRC)/CreateWide.$(ARCH).o
    8081
    81 #$(SRC)/CreateZoom8.$(ARCH).o              $(SRC)/CreateZoom16.$(ARCH).o       \
    82 #$(SRC)/CreateZoom24.$(ARCH).o             $(SRC)/CreateZoom32.$(ARCH).o       \
    83 
    8482OBJ  =  $(KAPA)
    8583
  • trunk/Ohana/src/kapa2/include/constants.h

    r16011 r25757  
    1111
    1212# define NCHANNELS 3
    13 # define NPIXELS_DYNAMIC 128
     13# define NPIXELS_DYNAMIC 4600
    1414
    1515// XXX for the moment, this is set to match the values in SetColorScale3D_CC
  • trunk/Ohana/src/kapa2/include/prototypes.h

    r21153 r25757  
    5555int           LoadTextlines       PROTO((int sock));
    5656int           Resize              PROTO((int sock));
     57int           Relocate            PROTO((int sock));
    5758int           GetLimits           PROTO((int sock));
    5859int           SetLimits           PROTO((int sock));
     
    178179void          Image_to_Picture    PROTO((double *x1, double *y1, double x2, double y2, Picture *picture));
    179180void          Image_to_Screen     PROTO((double *x1, double *y1, double x2, double y2, Picture *picture));
    180 void          Picture_Lower       PROTO((int *i_start, int *j_start, Matrix *matrix, Picture *picture));
    181 void          Picture_Upper       PROTO((int *i_end, int *j_end, Matrix *matrix, Picture *picture));
     181void          Picture_Lower       PROTO((int *i_start, int *j_start, int *I_start, int *J_start, Matrix *matrix, Picture *picture));
     182void          Picture_Upper       PROTO((int *i_end, int *j_end, int i_start, int j_start, Matrix *matrix, Picture *picture));
    182183
    183184void          DragColorbar        PROTO((Graphic *graphic, KapaImageWidget *image, XButtonEvent *mouse_event));
  • trunk/Ohana/src/kapa2/include/structures.h

    r21153 r25757  
    2121  Window         window;
    2222  Visual        *visual;
    23   int            visualclass; // is visual dynamic? (XXX change name?)
     23  int            dynamicColors; // is visual dynamic?
    2424  int            Nbits;       // pixel depth in bits (8, 16, 24, 32)
    2525  GC             gc;
     
    9494  int      DX, DY;            // size of displayed picture (must be updated with new images...)
    9595  int      expand;            // zoomscale
    96   double   X,  Y;             // center of image in picture
     96  double   Xc,  Yc;           // center of image in picture
    9797  char     flipx, flipy;      // parity (0 = +; 1 = -)
    9898  XImage  *pix;
  • trunk/Ohana/src/kapa2/src/ButtonFunctions.c

    r21153 r25757  
    4444int Recenter (Graphic *graphic, KapaImageWidget *image) {
    4545
    46   image[0].picture.X = 0.5*image[0].image[0].matrix.Naxis[0];
    47   image[0].picture.Y = 0.5*image[0].image[0].matrix.Naxis[1];
     46  image[0].picture.Xc = 0.5*image[0].image[0].matrix.Naxis[0];
     47  image[0].picture.Yc = 0.5*image[0].image[0].matrix.Naxis[1];
    4848 
    4949  Remap (graphic, image);
     
    5656
    5757  image[0].picture.expand = 1;
     58  image[0].zoom.expand = 5;
    5859  Remap (graphic, image);
    5960  Refresh ();
     
    6465int RecenterRescale (Graphic *graphic, KapaImageWidget *image) {
    6566
    66   image[0].picture.X = 0.5*image[0].image[0].matrix.Naxis[0];
    67   image[0].picture.Y = 0.5*image[0].image[0].matrix.Naxis[1];
     67  image[0].picture.Xc = 0.5*image[0].image[0].matrix.Naxis[0];
     68  image[0].picture.Yc = 0.5*image[0].image[0].matrix.Naxis[1];
    6869  image[0].picture.expand = 1;
     70  image[0].zoom.expand = 5;
    6971 
    7072  Remap (graphic, image);
  • trunk/Ohana/src/kapa2/src/Center.c

    r21060 r25757  
    1616  if (image == NULL) return (TRUE);
    1717
    18   image[0].picture.X = X;
    19   image[0].picture.Y = Y;
     18  // enforce integer center here?
     19  image[0].picture.Xc = X;
     20  image[0].picture.Yc = Y;
    2021  if ((zoom != 0) && (zoom != -1)) {
    2122    image[0].picture.expand = zoom;
     23    image[0].zoom.expand = MIN(image[0].zoom.dx / 5.5, MAX(5, 2*zoom));
    2224  }
    2325
  • trunk/Ohana/src/kapa2/src/CheckPipe.c

    r21060 r25757  
    131131  }
    132132
     133  if (!strcmp (word, "MOVE")) {
     134    status = Relocate (sock);
     135    KiiSendCommand (sock, 4, "DONE");
     136    FINISHED (status);
     137  }
     138
    133139  if (!strcmp (word, "GLIM")) {
    134140    GetLimits (sock);
  • trunk/Ohana/src/kapa2/src/CheckVisual.c

    r21153 r25757  
    1010
    1111  int i, Nfound, N;
    12   int isColor, isDefault, isDynamic;
     12  int isColor, isDefault;
    1313  XVisualInfo *visual_list, visual_temp;
    1414  unsigned long planes[3];
     
    3434  }
    3535 
    36 // skip the default and the PseudoColor visuals, go for TrueColor first
    37 # if (0)
    38   /* check default visual first */
    39   for (i = 0; (i < Nfound) && (graphic[0].visual != visual_list[i].visual); i++);
    40   if (i == Nfound) {
    41     fprintf (stderr, "default visual not found??\n");
    42     exit (0);
    43   }
    44 # endif
    45 
    4636  // set these based on selected visual
    47   isColor = isDefault = isDynamic = FALSE;
    48 
    49 # if (0)
    50   // attempt to select the most desirable type of visual: Default as PseudoColor (XXX is it still true?)
    51   if (DEBUG) fprintf (stderr, "default visual class is %d\n", visual_list[i].class);
    52   if (visual_list[i].class == PseudoColor) {
    53     isColor = isDefault = isDynamic = TRUE;
    54     graphic[0].visual = visual_list[i].visual;
    55     graphic[0].visualclass = TRUE;
    56     goto test_pixels;
    57   }
    58 # endif
    59 
    60   // attempt to select the most desirable type of visual: TrueColor (XXX is it still true?)
     37  isColor = isDefault = FALSE;
     38
     39  // attempt to select the most desirable type of visual: TrueColor
    6140  for (i = 0; (i < Nfound) && (visual_list[i].class != TrueColor); i++);
    6241  if (i != Nfound) {
     
    6544    isDefault = (graphic[0].visual == visual_list[i].visual);
    6645    graphic[0].visual = visual_list[i].visual;
    67     graphic[0].visualclass = FALSE;
     46    graphic[0].dynamicColors = FALSE;
     47    if (DEBUG) fprintf (stderr, "got TrueColor visual\n");
     48    goto test_pixels;
     49  }
     50
     51  // attempt to select the most desirable type of visual: DirectColor
     52  for (i = 0; (i < Nfound) && (visual_list[i].class != DirectColor); i++);
     53  if (i != Nfound) {
     54    isColor = TRUE;
     55    if (DEBUG) fprintf (stderr, "visual class is %d\n", visual_list[i].class);
     56    isDefault = (graphic[0].visual == visual_list[i].visual);
     57    graphic[0].visual = visual_list[i].visual;
     58    graphic[0].dynamicColors = TRUE;
     59    if (DEBUG) fprintf (stderr, "got DirectColor visual\n");
    6860    goto test_pixels;
    6961  }
     
    7264  for (i = 0; (i < Nfound) && (visual_list[i].class != PseudoColor); i++);
    7365  if (i != Nfound) {
    74     isColor = isDynamic = TRUE;
     66    isColor = TRUE;
    7567    if (DEBUG) fprintf (stderr, "selected visual class is %d\n", visual_list[i].class);
    7668    isDefault = (graphic[0].visual == visual_list[i].visual);
    7769    graphic[0].visual = visual_list[i].visual;
    78     graphic[0].visualclass = TRUE;
     70    graphic[0].dynamicColors = TRUE;
     71    if (DEBUG) fprintf (stderr, "got PseudoColor visual\n");
    7972    goto test_pixels;
    8073  }
     
    8376  for (i = 0; (i < Nfound) && (visual_list[i].class != GrayScale); i++);
    8477  if (i != Nfound) {
    85     isDynamic = TRUE;
    8678    if (DEBUG) fprintf (stderr, "selected visual class is %d\n", visual_list[i].class);
    8779    isDefault = (graphic[0].visual == visual_list[i].visual);
    8880    graphic[0].visual = visual_list[i].visual;
    89     graphic[0].visualclass = TRUE;
     81    graphic[0].dynamicColors = TRUE;
     82    if (DEBUG) fprintf (stderr, "got GrayScale visual\n");
    9083    goto test_pixels;
    9184  }
     
    9790    isDefault = (graphic[0].visual == visual_list[i].visual);
    9891    graphic[0].visual = visual_list[i].visual;
    99     graphic[0].visualclass = FALSE;
     92    graphic[0].dynamicColors = FALSE;
     93    if (DEBUG) fprintf (stderr, "got StaticColor visual\n");
    10094    goto test_pixels;
    10195  }
     
    107101    isDefault = (graphic[0].visual == visual_list[i].visual);
    108102    graphic[0].visual = visual_list[i].visual;
    109     graphic[0].visualclass = FALSE;
     103    graphic[0].dynamicColors = FALSE;
     104    if (DEBUG) fprintf (stderr, "got StaticGray visual\n");
    110105    goto test_pixels;
    111106  }
     
    115110  /* need to make a colormap if
    116111     1) the selected visual is not the default
     112        XXX not sure if I need to / am allowed to alloc a colormap if I've grabbed the default.
    117113     2) there are not enough colors available */
    118114
     
    125121  }
    126122
    127   // allocate a private colormap, if needed
     123  // dynamic visual classes can accept AllocAll and can use XAllocColorCells while AllocNone must use XAllocColor
     124  // int allocMode = graphic[0].dynamicColors ? AllocAll : AllocNone;
     125  int allocMode = AllocNone;
     126
     127  // allocate a private colormap, if desired or needed
    128128  if (!isDefault) {
    129129    if (DEBUG) fprintf (stderr, "allocated private colormap\n");
    130     graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, AllocNone);
    131   }
    132 
    133   if (isDynamic) {
     130    graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, allocMode);
     131  }
     132
     133  if (graphic[0].dynamicColors) {
    134134    Npixels = NPIXELS_DYNAMIC;
    135135    if ((N = get_argument (*argc, argv, "-ncolors"))) {
     
    144144    for (graphic[0].Npixels = Npixels; graphic[0].Npixels >= 16; graphic[0].Npixels -= 4) {
    145145      if (DEBUG) fprintf (stderr, "trying %d colors\n", (int) graphic[0].Npixels);
    146       if (XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 1, graphic[0].pixels, graphic[0].Npixels)) {
     146      if (XAllocColorCells (graphic[0].display, graphic[0].colormap, FALSE, planes, 0, graphic[0].pixels, graphic[0].Npixels)) {
    147147        break;
     148      }
     149      for (i = 0; i < graphic[0].Npixels; i++) {
     150        graphic[0].cmap[i].pixel = graphic[0].pixels[i];
    148151      }
    149152    }
     
    152155    if (graphic[0].Npixels < 16) {
    153156      if (!isDefault) {
     157        // We've already tried to allocate a colormap above...
    154158        fprintf (stderr, "can't allocate enough cells in private colormap\n");
    155159        exit (0);
    156160      }
    157161      if (DEBUG) fprintf (stderr, "can't allocate enough cells, using private colormap\n");
    158       graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, AllocNone);
     162      graphic[0].colormap = XCreateColormap (graphic[0].display, RootWindow (graphic[0].display, graphic[0].screen), graphic[0].visual, allocMode);
    159163
    160164      for (graphic[0].Npixels = NPIXELS_DYNAMIC; graphic[0].Npixels >= 16; graphic[0].Npixels -= 4) {
     
    163167          break;
    164168        }
    165       }
    166 
     169        for (i = 0; i < graphic[0].Npixels; i++) {
     170          graphic[0].cmap[i].pixel = graphic[0].pixels[i];
     171        }
     172      }
    167173      if ((N = get_argument (*argc, argv, "-colorcount"))) {
    168174        fprintf (stderr, "kapa can grab %d colors\n", graphic[0].Npixels);
  • trunk/Ohana/src/kapa2/src/CursorOps.c

    r16270 r25757  
    22
    33// input coordinates are relative to the picture bounding box
     4// XXX pre-calculate fexpand, Xc, Yc when expand is set?
    45void Picture_to_Image (double *x1, double *y1, double x2, double y2, Picture *picture) {
    56
     
    1415 
    1516  // pixel coordinates in picture frame
    16   dx = expand*(x2 - 0.5*picture[0].dx);
    17   dy = expand*(y2 - 0.5*picture[0].dy);
     17  dx = expand*(x2 - (int)(0.5*picture[0].dx));
     18  dy = expand*(y2 - (int)(0.5*picture[0].dy));
     19
     20  // set the true center (image and screen pixel boundaries must be aligned)
     21  // Xc = (int)(picture[0].Xc / expand) * expand;
     22  // Yc = (int)(picture[0].Yc / expand) * expand;
    1823
    1924  // picture[0].X,Y is the image coordinate in the center of the picture
    20   *x1 = picture[0].flipx ? picture[0].X - dx : picture[0].X + dx;
    21   *y1 = picture[0].flipy ? picture[0].Y - dy : picture[0].Y + dy;
     25  *x1 = picture[0].flipx ? picture[0].Xc - dx : picture[0].Xc + dx;
     26  *y1 = picture[0].flipy ? picture[0].Yc - dy : picture[0].Yc + dy;
    2227}
    2328
     
    4651  }
    4752 
     53  // set the true center (image and screen pixel boundaries must be aligned)
     54  // Xc = ((int)(picture[0].Xc * expand)) / expand;
     55  // Yc = ((int)(picture[0].Yc * expand)) / expand;
     56
    4857  // pixel coordinates in picture frame
    49   dx = picture[0].flipx ? picture[0].X - x2 : x2 - picture[0].X;
    50   dy = picture[0].flipy ? picture[0].Y - y2 : y2 - picture[0].Y;
     58  dx = picture[0].flipx ? picture[0].Xc - x2 : x2 - picture[0].Xc;
     59  dy = picture[0].flipy ? picture[0].Yc - y2 : y2 - picture[0].Yc;
    5160   
    52   *x1 = expand*dx + 0.5*picture[0].dx;
    53   *y1 = expand*dy + 0.5*picture[0].dy;
     61  *x1 = expand*dx + (int)(0.5*picture[0].dx);
     62  *y1 = expand*dy + (int)(0.5*picture[0].dy);
    5463}
    5564
     
    6675
    6776// input coordinates are relative to the picture bounding box
    68 void Picture_Lower (int *i_start, int *j_start, Matrix *matrix, Picture *picture) {
     77void Picture_Lower (int *i_start, int *j_start, int *I_start, int *J_start, Matrix *matrix, Picture *picture) {
    6978
    7079  double Ix, Iy, Sx, Sy;
     
    7281  // Ix, Iy are the image coordinates of the specified screen pixel
    7382  Picture_to_Image (&Ix, &Iy, 0.0, 0.0, picture);
    74 
    75   // Ix, Iy are now limited to valid image coordinates
    76   Ix = MIN (MAX (Ix, 0), matrix[0].Naxis[0]);
    77   Iy = MIN (MAX (Iy, 0), matrix[0].Naxis[1]);
    7883
    7984  // round up (down) to nearest pixel boundary
     
    8489    Iy = picture[0].flipy ? (int)(Iy) : (int)(Iy) + 1;
    8590  }
     91
     92  // Ix, Iy are now limited to valid image coordinates
     93  Ix = MIN (MAX (Ix, 0), matrix[0].Naxis[0]);
     94  Iy = MIN (MAX (Iy, 0), matrix[0].Naxis[1]);
     95
     96  // I_start, J_start are the first displayed image pixel
     97  *I_start = Ix;
     98  *J_start = Iy;
    8699
    87100  // Sx, Sy are the screen coordinates of the Ix,Iy pixel
     
    94107 
    95108// input coordinates are relative to the picture bounding box
    96 void Picture_Upper (int *i_end, int *j_end, Matrix *matrix, Picture *picture) {
     109void Picture_Upper (int *i_end, int *j_end, int i_start, int j_start, Matrix *matrix, Picture *picture) {
    97110
     111  int nExtra;
    98112  double Ix, Iy, Sx, Sy;
    99113
     
    101115  Picture_to_Image (&Ix, &Iy, picture[0].dx, picture[0].dy, picture);
    102116
     117  // round down (up) to nearest pixel boundary
     118  if (Ix > (int)(Ix)) {
     119    Ix = picture[0].flipx ? (int)(Ix) + 1: (int)(Ix);
     120  }
     121  if (Iy > (int)(Iy)) {
     122    Iy = picture[0].flipy ? (int)(Iy) + 1: (int)(Iy);
     123  }
     124
    103125  // Ix, Iy are now limited to valid image coordinates
    104126  Ix = MIN (MAX (Ix, 0), matrix[0].Naxis[0]);
    105127  Iy = MIN (MAX (Iy, 0), matrix[0].Naxis[1]);
    106128
    107   // round down (up) to nearest pixel boundary
    108   if (Ix > (int)(Ix)) {
    109     Ix = picture[0].flipx ? (int)(Ix) + 1 : (int)(Ix);
    110   }
    111   if (Iy > (int)(Iy)) {
    112     Iy = picture[0].flipy ? (int)(Iy) + 1: (int)(Iy);
    113   }
     129  // I_end, J_end are the last displayed image pixel
     130  // *I_end = Ix;
     131  // *J_end = Iy;
    114132
    115133  // Sx, Sy are the screen coordinates of the Ix,Iy pixel
     
    119137  *i_end = MIN (MAX (Sx, 0), picture[0].dx);
    120138  *j_end = MIN (MAX (Sy, 0), picture[0].dy);
     139
     140  // round off error can leave us with a small number of extra pixels here.
     141  if (picture[0].expand > 1) {
     142    nExtra = (*i_end - i_start) % picture[0].expand;
     143    *i_end -= nExtra;
     144    nExtra = (*j_end - j_start) % picture[0].expand;
     145    *j_end -= nExtra;
     146  }
    121147}
  • trunk/Ohana/src/kapa2/src/DragColorbar.c

    r16011 r25757  
    1010  int             xstatus, Npix, center;
    1111
    12   if (!graphic[0].visualclass) return;
     12  if (!graphic[0].dynamicColors) return;
    1313
    1414  X = mouse_event[0].x;
     
    7979  XColor cmap[256];
    8080
    81   if (!graphic[0].visualclass) return;
     81  if (!graphic[0].dynamicColors) return;
    8282
    8383  for (i = 0; i < graphic[0].Npixels; i++) {
     
    8888      cmap[i].blue = graphic[0].cmap[0].blue;
    8989      cmap[i].green = graphic[0].cmap[0].green;
     90      cmap[i].flags = DoRed | DoGreen | DoBlue;
    9091    }
    9192    else {
     
    9495        cmap[i].blue = graphic[0].cmap[graphic[0].Npixels-1].blue;
    9596        cmap[i].green = graphic[0].cmap[graphic[0].Npixels-1].green;
     97        cmap[i].flags = DoRed | DoGreen | DoBlue;
    9698      }
    9799      else {
     
    99101        cmap[i].blue = graphic[0].cmap[j].blue;
    100102        cmap[i].green = graphic[0].cmap[j].green;
     103        cmap[i].flags = DoRed | DoGreen | DoBlue;
    101104      }
    102105    }
  • trunk/Ohana/src/kapa2/src/Image.c

    r21153 r25757  
    4848
    4949  // set the center and expansion for the pictures:
    50   image[0].picture.X      = 0.0;
    51   image[0].picture.Y      = 0.0;
     50  image[0].picture.Xc     = 0.0;
     51  image[0].picture.Yc     = 0.0;
    5252  image[0].picture.expand = 1;
    5353  image[0].picture.flipx  = FALSE;
    5454  image[0].picture.flipy  = FALSE;
    5555
    56   image[0].zoom.X         = 0.0;
    57   image[0].zoom.Y         = 0.0;
    58   image[0].zoom.expand    = +5;
     56  image[0].zoom.Xc        = 0.0;
     57  image[0].zoom.Yc        = 0.0;
     58  image[0].zoom.expand    = 5;
    5959  image[0].zoom.flipx     = FALSE;
    6060  image[0].zoom.flipy     = FALSE;
    6161
    62   image[0].wide.X         = 0.0;
    63   image[0].wide.Y         = 0.0;
     62  image[0].wide.Xc        = 0.0;
     63  image[0].wide.Yc        = 0.0;
    6464  image[0].wide.expand    = -5;
    6565  image[0].wide.flipx     = FALSE;
     
    144144                  image[0].picture.dx+1, image[0].picture.dy+1);
    145145 
    146   XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,
    147              image[0].picture.pix, 0, 0,
    148              image[0].picture.x + 1, image[0].picture.y + 1,
    149              image[0].picture.dx, image[0].picture.dy);
     146  if (image[0].picture.pix) {
     147    XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,
     148               image[0].picture.pix, 0, 0,
     149               image[0].picture.x + 1, image[0].picture.y + 1,
     150               image[0].picture.dx, image[0].picture.dy);
     151  }
    150152
    151153  for (i = 0; i < NOVERLAYS; i++) {
     
    156158
    157159  if (image[0].location) {
    158     XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,
    159                image[0].cmapbar.pix, 0, 0,
    160                image[0].cmapbar.x, image[0].cmapbar.y,
    161                image[0].cmapbar.dx, image[0].cmapbar.dy);
    162 
    163     XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,
    164                image[0].wide.pix, 0, 0,
    165                image[0].wide.x, image[0].wide.y,
    166                image[0].wide.dx, image[0].wide.dy);
     160    if (image[0].cmapbar.pix) {
     161      XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,
     162                 image[0].cmapbar.pix, 0, 0,
     163                 image[0].cmapbar.x, image[0].cmapbar.y,
     164                 image[0].cmapbar.dx, image[0].cmapbar.dy);
     165    }
     166    if (image[0].wide.pix) {
     167        XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,
     168                   image[0].wide.pix, 0, 0,
     169                   image[0].wide.x, image[0].wide.y,
     170                   image[0].wide.dx, image[0].wide.dy);
     171    }
    167172
    168173    CrossHairs (graphic, &image[0].zoom);
  • trunk/Ohana/src/kapa2/src/InterpretKeys.c

    r18411 r25757  
    9393      SetColorScale (graphic, image);
    9494      Remap (graphic, image);
    95       Reorient (graphic, image, image[0].picture.X, image[0].picture.Y, 0);
     95      Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0);
    9696      break;
    9797
     
    100100      SetColorScale (graphic, image);
    101101      Remap (graphic, image);
    102       Reorient (graphic, image, image[0].picture.X, image[0].picture.Y, 0);
     102      Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0);
    103103      break;
    104104
     
    107107      SetColorScale (graphic, image);
    108108      Remap (graphic, image);
    109       Reorient (graphic, image, image[0].picture.X, image[0].picture.Y, 0);
     109      Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0);
    110110      break;
    111111
     
    113113    case XK_Home:
    114114      image[0].picture.expand = 1;
    115       Reorient (graphic, image, image[0].picture.X, image[0].picture.Y, 0);
     115      image[0].zoom.expand = 5;
     116      Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0);
    116117      break;
    117118    case XK_KP_End:
    118119    case XK_End:
    119120      image[0].picture.expand = 1;
     121      image[0].zoom.expand = 5;
    120122      Reorient (graphic, image, 0.5*image[0].image[0].matrix.Naxis[0], 0.5*image[0].image[0].matrix.Naxis[1], 0);
    121123      break;
     
    128130    case XK_Prior:
    129131    case XK_KP_Prior:
    130       Reorient (graphic, image, image[0].picture.X, image[0].picture.Y, +1);
     132      Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, +1);
    131133      break;
    132134    case XK_Next:
    133135    case XK_KP_Next:
    134       Reorient (graphic, image, image[0].picture.X, image[0].picture.Y, -1);
     136      Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, -1);
    135137      break;
    136138    case XK_Up:
    137139    case XK_KP_Up:
    138       Reorient (graphic, image, image[0].picture.X, image[0].picture.Y + offset, 0);
     140      Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc + offset, 0);
    139141      break;
    140142    case XK_Down:
    141143    case XK_KP_Down:
    142       Reorient (graphic, image, image[0].picture.X, image[0].picture.Y - offset, 0);
     144      Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc - offset, 0);
    143145      break;
    144146    case XK_Left:
    145147    case XK_KP_Left:
    146       Reorient (graphic, image, image[0].picture.X + offset, image[0].picture.Y, 0);
     148      Reorient (graphic, image, image[0].picture.Xc + offset, image[0].picture.Yc, 0);
    147149      break;
    148150    case XK_Right:
    149151    case XK_KP_Right:
    150       Reorient (graphic, image, image[0].picture.X - offset, image[0].picture.Y, 0);
     152      Reorient (graphic, image, image[0].picture.Xc - offset, image[0].picture.Yc, 0);
    151153      break;
    152154
     
    160162      SetColorScale (graphic, image);
    161163      Remap (graphic, image);
    162       Reorient (graphic, image, image[0].picture.X, image[0].picture.Y, 0);
     164      Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0);
    163165      break;
    164166    case XK_KP_Subtract:
     
    171173      SetColorScale (graphic, image);
    172174      Remap (graphic, image);
    173       Reorient (graphic, image, image[0].picture.X, image[0].picture.Y, 0);
     175      Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0);
    174176      break;
    175177
  • trunk/Ohana/src/kapa2/src/JPEGit24.c

    r19833 r25757  
    2222  int ii, i, j;
    2323  int i_start, i_end, j_start, j_end;
     24  int I_start, J_start;
    2425  int dropback;  /* this is a bit of a kludge... */
    2526  int dx, dy, DX, DY, inDX, inDY;
     
    9596  DY = image[0].image[0].matrix.Naxis[1];
    9697
    97   // x, y are the closest lit screen pixel to 0,0
    98   Picture_Lower (&i_start, &j_start, &image[0].image[0].matrix, &image[0].picture);
    99 
    100   // x, y are the closest lit screen pixel to dx, dy
    101   Picture_Upper (&i_end, &j_end, &image[0].image[0].matrix, &image[0].picture);
    102 
    103   if (i_end < i_start) MY_SWAP_INT (i_start, i_end);
    104   if (j_end < j_start) MY_SWAP_INT (j_start, j_end);
    105 
    106   // Ix,Iy are the first displayed image pixel
    107   Picture_to_Image (&Ix, &Iy, i_start, j_start, &image[0].picture);
    108   Ix = MIN (MAX (0, Ix), DX - 1);
    109   Iy = MIN (MAX (0, Iy), DY - 1);
     98  // i_start, j_start are the closest lit screen pixel to 0,0
     99  // I_start, J_start are the image pixel corresponding to i_start, j_start
     100  Picture_Lower (&i_start, &j_start, &I_start, &J_start, &image[0].image[0].matrix, &image[0].picture);
     101
     102  // i_end, j_end are the closest lit screen pixel to dx, dy
     103  // I_end, J_end are the image pixel corresponding to i_end, j_end
     104  Picture_Upper (&i_end, &j_end, i_start, j_start, &image[0].image[0].matrix, &image[0].picture);
     105
     106  assert (i_start <= i_end);
     107  assert (j_start <= j_end);
     108
     109  Ix = image[0].picture.flipx ? I_start - 1 : I_start;
     110  Iy = image[0].picture.flipy ? J_start - 1 : J_start;
    110111
    111112  inDX = image[0].picture.flipx ? -1 : +1;
  • trunk/Ohana/src/kapa2/src/LoadPicture.c

    r21060 r25757  
    2525  Yoffset = 0.0;
    2626  if (image[0].image[0].matrix.size) {
    27     Xoffset = image[0].picture.X - 0.5*image[0].image[0].matrix.Naxis[0];
    28     Yoffset = image[0].picture.Y - 0.5*image[0].image[0].matrix.Naxis[1];
     27    // XXX enforce int center here?
     28    Xoffset = image[0].picture.Xc - 0.5*image[0].image[0].matrix.Naxis[0];
     29    Yoffset = image[0].picture.Yc - 0.5*image[0].image[0].matrix.Naxis[1];
    2930  }
    3031
     
    4950
    5051  // reference point for image is the center pixel
    51   image[0].picture.X = 0.5*header.Naxis[0] + Xoffset;
    52   image[0].picture.Y = 0.5*header.Naxis[1] + Yoffset;
     52  image[0].picture.Xc = 0.5*header.Naxis[0] + Xoffset;
     53  image[0].picture.Yc = 0.5*header.Naxis[1] + Yoffset;
    5354
    5455  // choose expand for wide to guarantee we fit:
     
    5960    image[0].wide.expand = 1.0 / wx;
    6061  }   
    61   image[0].wide.X = 0.5*header.Naxis[0];
    62   image[0].wide.Y = 0.5*header.Naxis[1];
     62  image[0].wide.Xc = 0.5*header.Naxis[0];
     63  image[0].wide.Yc = 0.5*header.Naxis[1];
    6364
    6465  fcntl (sock, F_SETFL, O_NONBLOCK); 
  • trunk/Ohana/src/kapa2/src/MakeColormap.c

    r16011 r25757  
    22
    33static char default_cmap[] = "grayscale";
     4// static char default_cmap[] = "heat";
    45
    56void MakeColormap (int argc, char **argv) {
  • trunk/Ohana/src/kapa2/src/PSOverlay.c

    r19835 r25757  
    8080          double sn = sin(angle);
    8181          x0 = X + pX*dX*cs;
    82           y0 = Y + pY*dX*sn;
     82          y0 = Y - pY*dX*sn;
    8383          // XXX dt should be based on the size of the ellipse...
    8484          // 0.10 -> 60 segments on the ellipse
    8585          # define DT 0.1
    8686          for (t = DT; t < 2*M_PI + DT; t+=DT) {
    87             x1 = X + pX*dX*cos(t)*cs - pX*dY*sin(t)*sn;
    88             y1 = Y + pY*dX*cos(t)*sn + pY*dY*sin(t)*cs;
     87            x1 = X + pX*dX*cos(t)*cs + pX*dY*sin(t)*sn;
     88            y1 = Y - pY*dX*cos(t)*sn + pY*dY*sin(t)*cs;
    8989            fprintf (f, " %6.1f %6.1f %6.1f %6.1f L\n", x0 + extra, y0 + extra, x1 + extra, y1 + extra);
    9090            x0 = x1;
  • trunk/Ohana/src/kapa2/src/PaintOverlay.c

    r20936 r25757  
    99 
    1010  XSetForeground (graphic[0].display, graphic[0].gc, image[0].overlay[N].color);
    11   XSetLineAttributes (graphic->display, graphic->gc, 2, LineSolid, CapNotLast, JoinMiter);
     11  XSetLineAttributes (graphic->display, graphic->gc, 1, LineSolid, CapNotLast, JoinMiter);
    1212 
    1313  expand = 1.0;
     
    7272          double sn = sin(angle);
    7373          x0 = X + pX*dx*cs;
    74           y0 = Y - pY*dx*sn;
     74          y0 = Y + pY*dx*sn;
    7575          // XXX dt should be based on the size of the ellipse...
    7676          // 0.10 -> 60 segments on the ellipse
    7777          # define DT 0.1
    7878          for (t = DT; t < 2*M_PI + DT; t+=DT) {
    79             x1 = X + pX*dx*cos(t)*cs + pX*dy*sin(t)*sn;
    80             y1 = Y - pY*dx*cos(t)*sn + pY*dy*sin(t)*cs;
     79            x1 = X + pX*dx*cos(t)*cs - pX*dy*sin(t)*sn;
     80            y1 = Y + pY*dx*cos(t)*sn + pY*dy*sin(t)*cs;
    8181            XDrawLine (graphic[0].display, graphic[0].window, graphic[0].gc, x0, y0, x1, y1);
    8282            x0 = x1;
  • trunk/Ohana/src/kapa2/src/Remap16.c

    r18324 r25757  
    11# include "Ximage.h"
     2# define OUT_TYPE unsigned short
    23
    34# define MY_SWAP_BYTE(W) { \
     
    1011  int i, j, ii, jj;
    1112  int i_start, i_end, j_start, j_end;
    12   int dropback;
     13  int I_start, J_start;
     14  int dropback, inDX, inDY;
    1315  int dx, dy, DX, DY;
    1416  double expand, Ix, Iy;
    1517  int expand_in, expand_out;
    16   unsigned short *out_pix, *out_pix2, *data;
     18  OUT_TYPE *out_pix, *out_pix2, *data;
    1719  unsigned short *in_pix, *in_pix2;
    18   unsigned short *pixel, pixvalue;
    19   unsigned short back;
     20  OUT_TYPE *pixel, pixvalue;
     21  OUT_TYPE back;
    2022  int swap_client, swap_server, swap_bytes;
    2123
    22   ALLOCATE (pixel, unsigned short, graphic[0].Npixels);
     24  // just skip if there is no data
     25  if (matrix[0].Naxes == 0) return;
     26  if (matrix[0].Naxis[0] == 0) return;
     27  if (matrix[0].Naxis[1] == 0) return;
     28
     29  ALLOCATE (pixel, OUT_TYPE, graphic[0].Npixels);
    2330
    2431# ifdef BYTE_SWAP
     
    3845  back = 0xffff & graphic[0].back;
    3946  if (swap_bytes) MY_SWAP_BYTE (back);
    40   // XXX not certain this is the correct solution...
    4147
    4248  // set up expansions
     
    6066  DY = matrix[0].Naxis[1];
    6167
    62   // x, y are the closest lit screen pixel to 0,0
    63   Picture_Lower (&i_start, &j_start, matrix, picture);
     68  // i_start, j_start are the closest lit screen pixel to 0,0
     69  // I_start, J_start are the image pixel corresponding to i_start, j_start
     70  Picture_Lower (&i_start, &j_start, &I_start, &J_start, matrix, picture);
    6471
    65   // x, y are the closest lit screen pixel to dx, dy
    66   Picture_Upper (&i_end, &j_end, matrix, picture);
     72  // i_end, j_end are the closest lit screen pixel to dx, dy
     73  // I_end, J_end are the image pixel corresponding to i_end, j_end
     74  Picture_Upper (&i_end, &j_end, i_start, j_start, matrix, picture);
    6775
    68   // Ix,Iy are the first displayed image pixel
    69   Picture_to_Image (&Ix, &Iy, i_start, j_start, picture);
     76  assert (i_start <= i_end);
     77  assert (j_start <= j_end);
     78
     79  Ix = picture[0].flipx ? I_start - 1 : I_start;
     80  Iy = picture[0].flipy ? J_start - 1 : J_start;
     81
     82  inDX = picture[0].flipx ? -1 : +1;
     83  inDY = picture[0].flipy ? -1 : +1;
    7084
    7185  dropback = expand_out - (i_end - i_start) % expand_out;
    7286  if ((i_end - i_start) % expand_out == 0) dropback = 0;
    7387
    74   data = out_pix = (unsigned short *) picture[0].data;
     88  out_pix = data = (OUT_TYPE *) picture[0].data;
    7589  in_pix  = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)];
    7690
     
    8296  }
    8397 
    84   for (j = j_start; j < j_end; j+= expand_out, in_pix += expand_in*DX) {
     98  for (j = j_start; j < j_end; j+= expand_out, in_pix += inDY*expand_in*DX) {
    8599    out_pix = &data[j*dx];
    86100
     
    97111    in_pix2 = in_pix;
    98112    if (expand_out == 1) {
    99       for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) {
     113      for (i = i_start; i < i_end; i++, in_pix2 += inDX*expand_in, out_pix++) {
    100114        *out_pix = pixel[*in_pix2];
    101115      }
    102116    } else {
    103       for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) {
     117      for (i = i_start; i < i_end; i+= expand_out, in_pix2 += inDX, out_pix+= expand_out) {
    104118        pixvalue = pixel[*in_pix2];
    105119        out_pix2 = out_pix;
     
    124138  /**** fill in top area ****/
    125139  out_pix = &data[j_end*dx];
    126   for (j = 0; j < (dy - j_end); j++) {
     140  for (j = 0; j < dy - j_end; j++) {
    127141    for (i = 0; i < dx; i++, out_pix++) {
    128142      *out_pix = back;
  • trunk/Ohana/src/kapa2/src/Remap24.c

    r18324 r25757  
    55  int i, j, ii, jj;
    66  int i_start, i_end, j_start, j_end;
    7   int dropback, extra;
     7  int I_start, J_start;
     8  int dropback, extra, inDX, inDY;
    89  int dx, dy, DX, DY;
    910  double expand, Ix, Iy;
     
    5354  extra = 4 - (dx * 3) % 4;
    5455
    55   // x, y are the closest lit screen pixel to 0,0
    56   Picture_Lower (&i_start, &j_start, matrix, picture);
     56  // i_start, j_start are the closest lit screen pixel to 0,0
     57  // I_start, J_start are the image pixel corresponding to i_start, j_start
     58  Picture_Lower (&i_start, &j_start, &I_start, &J_start, matrix, picture);
    5759
    58   // x, y are the closest lit screen pixel to dx, dy
    59   Picture_Upper (&i_end, &j_end, matrix, picture);
     60  // i_end, j_end are the closest lit screen pixel to dx, dy
     61  // I_end, J_end are the image pixel corresponding to i_end, j_end
     62  Picture_Upper (&i_end, &j_end, i_start, j_start, matrix, picture);
    6063
    61   // Ix,Iy are the first displayed image pixel
    62   Picture_to_Image (&Ix, &Iy, i_start, j_start, picture);
     64  assert (i_start <= i_end);
     65  assert (j_start <= j_end);
     66
     67  Ix = picture[0].flipx ? I_start - 1 : I_start;
     68  Iy = picture[0].flipy ? J_start - 1 : J_start;
     69
     70  inDX = picture[0].flipx ? -1 : +1;
     71  inDY = picture[0].flipy ? -1 : +1;
    6372
    6473  dropback = expand_out - (i_end - i_start) % expand_out;
     
    8089  }
    8190 
    82   for (j = j_start; j < j_end; j+= expand_out, in_pix += expand_in*DX) {
     91  for (j = j_start; j < j_end; j+= expand_out, in_pix += inDY*expand_in*DX) {
    8392    out_pix = &data[j*(3*dx+extra)];
    8493
     
    97106    in_pix2 = in_pix;
    98107    if (expand_out == 1) {
    99       for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix+=3) {
     108      for (i = i_start; i < i_end; i++, in_pix2+= inDX*expand_in, out_pix+=3) {
    100109        out_pix[0] = pixel1[*in_pix2];
    101110        out_pix[1] = pixel2[*in_pix2];
     
    103112      }
    104113    } else {
    105       for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= 3*expand_out) {
     114      for (i = i_start; i < i_end; i+= expand_out, in_pix2 += inDX, out_pix+= 3*expand_out) {
    106115        pixvalue1 = pixel1[*in_pix2];
    107116        pixvalue2 = pixel2[*in_pix2];
     
    121130    /**** fill in area to the right of the picture ****/
    122131    for (jj = 0; (jj < expand_out) && (j + jj < dy); jj++) {
    123       //    for (jj = 0; jj < expand_out; jj++) {
    124132      out_pix2 = out_pix + jj*(3*dx+extra);
    125133      for (i = i_end; i < dx; i++, out_pix2+=3) {
  • trunk/Ohana/src/kapa2/src/Remap32.c

    r18324 r25757  
    11# include "Ximage.h"
     2# define OUT_TYPE unsigned int
    23
    34# define MY_SWAP_INT(A,B) { int tmp; tmp = A; A = B; B = tmp; }
    45
    5 # define MY_SWAP_WORD(W) { \
    6   char tmp, *X; \
    7   X = (char *) &W; \
    8   tmp = X[0]; X[0] = X[3]; X[3] = tmp; \
    9   tmp = X[1]; X[1] = X[2]; X[2] = tmp; }
     6# define MY_SWAP_WORD(W) {                      \
     7    char tmp, *X;                               \
     8    X = (char *) &W;                            \
     9    tmp = X[0]; X[0] = X[3]; X[3] = tmp;        \
     10    tmp = X[1]; X[1] = X[2]; X[2] = tmp; }
    1011
    1112void Remap32 (Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix) {
     
    1314  int i, j, ii, jj;
    1415  int i_start, i_end, j_start, j_end;
     16  int I_start, J_start;
    1517  int dropback, inDX, inDY;
    1618  int dx, dy, DX, DY;
    1719  double expand, Ix, Iy;
    1820  int expand_in, expand_out;
    19   unsigned int *out_pix, *out_pix2;
     21  OUT_TYPE *out_pix, *out_pix2, *data;
    2022  unsigned short *in_pix, *in_pix2;
    21   unsigned long *pixel, pixvalue;
    22   unsigned long back;
     23  OUT_TYPE *pixel, pixvalue;
     24  OUT_TYPE back;
    2325  int swap_client, swap_server, swap_bytes;
    2426
    25   ALLOCATE (pixel, unsigned long, graphic[0].Npixels);
     27  // just skip if there is no data
     28  if (matrix[0].Naxes == 0) return;
     29  if (matrix[0].Naxis[0] == 0) return;
     30  if (matrix[0].Naxis[1] == 0) return;
     31
     32  ALLOCATE (pixel, OUT_TYPE, graphic[0].Npixels);
    2633
    2734# ifdef BYTE_SWAP
     
    4350
    4451  // set up expansions
    45   assert ((picture[0].expand >= 1) || (picture[0].expand <= -1));
     52  assert ((picture[0].expand >= 1) || (picture[0].expand <= -2));
    4653  expand = expand_in = expand_out = 1.0;
    4754  if (picture[0].expand > 0) {
     
    6269  DY = matrix[0].Naxis[1];
    6370
    64   // x, y are the closest lit screen pixel to 0,0
    65   Picture_Lower (&i_start, &j_start, matrix, picture);
     71  // i_start, j_start are the closest lit screen pixel to 0,0
     72  // I_start, J_start are the image pixel corresponding to i_start, j_start
     73  Picture_Lower (&i_start, &j_start, &I_start, &J_start, matrix, picture);
    6674
    67   // x, y are the closest lit screen pixel to dx, dy
    68   Picture_Upper (&i_end, &j_end, matrix, picture);
     75  // i_end, j_end are the closest lit screen pixel to dx, dy
     76  // I_end, J_end are the image pixel corresponding to i_end, j_end
     77  Picture_Upper (&i_end, &j_end, i_start, j_start, matrix, picture);
    6978
    70   if (i_end < i_start) MY_SWAP_INT (i_start, i_end);
    71   if (j_end < j_start) MY_SWAP_INT (j_start, j_end);
     79  assert (i_start <= i_end);
     80  assert (j_start <= j_end);
    7281
    73   // Ix,Iy are the first displayed image pixel
    74   Picture_to_Image (&Ix, &Iy, i_start, j_start, picture);
    75   Ix = MIN (MAX (0, Ix), DX - 1);
    76   Iy = MIN (MAX (0, Iy), DY - 1);
    77   // XXX not completely consistent with the i_start, i_end range...
    78 
    79   // we need to offset because i_start points to the bottom edge of Ix
    80   // if (picture[0].flipx) Ix -= 1.0;
    81   // if (picture[0].flipy) Iy -= 1.0;
     82  Ix = picture[0].flipx ? I_start - 1 : I_start;
     83  Iy = picture[0].flipy ? J_start - 1 : J_start;
    8284
    8385  inDX = picture[0].flipx ? -1 : +1;
     
    8789  if ((i_end - i_start) % expand_out == 0) dropback = 0;
    8890
    89   out_pix = (unsigned int *) picture[0].data;
     91  out_pix = data = (OUT_TYPE *) picture[0].data;
    9092  in_pix  = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)];
    9193
     
    9799  }
    98100 
    99   for (j = j_start; j < j_end; j+= expand_out, out_pix+=(expand_out-1)*dx, in_pix += inDY*expand_in*DX) {
     101  for (j = j_start; j < j_end; j+= expand_out, in_pix += inDY*expand_in*DX) {
     102    out_pix = &data[j*dx];
    100103
    101104    /**** fill in area to the left of the picture ****/
     
    126129    }
    127130    out_pix -= dropback;
    128    
    129     // assert (in_pix2 - image[0].pixmap <= DX*DY);
    130     // assert (in_pix2 - image[0].pixmap >= 0);
    131     // assert (in_pix - image[0].pixmap <= DX*DY);
    132     // assert (in_pix - image[0].pixmap >= 0);
    133131
    134132    /**** fill in area to the right of the picture ****/
     
    139137      }
    140138    }
    141     out_pix += (dx - i_end);
    142     // assert (out_pix - (unsigned int *)picture[0].data <= dx*dy);
    143     // assert (out_pix - (unsigned int *)picture[0].data >= 0);
    144139  }
    145  
    146   if ((j_end - j_start) % expand_out > 0)
    147     out_pix -= expand_out - (j_end - j_start) % expand_out;
    148  
    149   // assert (out_pix - (unsigned int *)picture[0].data <= dx*dy);
    150   // assert (out_pix - (unsigned int *)picture[0].data >= 0);
    151140
    152141  /**** fill in top area ****/
    153   for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned int *)picture[0].data < dx*dy); j++, out_pix++) {
    154     *out_pix = back;
     142  out_pix = &data[j_end*dx];
     143  for (j = 0; j < dy - j_end; j++) {
     144    for (i = 0; i < dx; i++, out_pix ++) {
     145      *out_pix = back;
     146    }
    155147  }
    156148
    157149  picture[0].pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0,
    158                                         picture[0].data, picture[0].dx, picture[0].dy, 32, 0);
     150                                 picture[0].data, picture[0].dx, picture[0].dy, 32, 0);
    159151
    160152  free (pixel);
  • trunk/Ohana/src/kapa2/src/Remap8.c

    r18324 r25757  
    11# include "Ximage.h"
     2# define OUT_TYPE unsigned char
    23
    34void Remap8 (Graphic *graphic, KapaImageWidget *image, Picture *picture, Matrix *matrix) {
     
    56  int i, j, ii, jj;
    67  int i_start, i_end, j_start, j_end;
    7   int dropback;
     8  int I_start, J_start;
     9  int dropback, inDX, inDY;
    810  int dx, dy, DX, DY;
    911  double expand, Ix, Iy;
    1012  int expand_in, expand_out;
    11   unsigned char *out_pix, *out_pix2;
    12   unsigned short *in_pix,  *in_pix2;
    13   unsigned char *pixel, pixvalue;
    14   unsigned char back;
     13  OUT_TYPE *out_pix, *out_pix2, *data;
     14  unsigned short *in_pix, *in_pix2;
     15  OUT_TYPE *pixel, pixvalue;
     16  OUT_TYPE back;
    1517
    16   ALLOCATE (pixel, unsigned char, graphic[0].Npixels);
     18  // just skip if there is no data
     19  if (matrix[0].Naxes == 0) return;
     20  if (matrix[0].Naxis[0] == 0) return;
     21  if (matrix[0].Naxis[1] == 0) return;
     22
     23  ALLOCATE (pixel, OUT_TYPE, graphic[0].Npixels);
    1724
    1825  // local array for pixel values
     
    4451  DY = matrix[0].Naxis[1];
    4552
    46   // x, y are the closest lit screen pixel to 0,0
    47   Picture_Lower (&i_start, &j_start, matrix, picture);
     53  // i_start, j_start are the closest lit screen pixel to 0,0
     54  // I_start, J_start are the image pixel corresponding to i_start, j_start
     55  Picture_Lower (&i_start, &j_start, &I_start, &J_start, matrix, picture);
    4856
    49   // x, y are the closest lit screen pixel to dx, dy
    50   Picture_Upper (&i_end, &j_end, matrix, picture);
     57  // i_end, j_end are the closest lit screen pixel to dx, dy
     58  // I_end, J_end are the image pixel corresponding to i_end, j_end
     59  Picture_Upper (&i_end, &j_end, i_start, j_start, matrix, picture);
    5160
    52   // Ix,Iy are the first displayed image pixel
    53   Picture_to_Image (&Ix, &Iy, i_start, j_start, picture);
     61  assert (i_start <= i_end);
     62  assert (j_start <= j_end);
     63
     64  Ix = picture[0].flipx ? I_start - 1 : I_start;
     65  Iy = picture[0].flipy ? J_start - 1 : J_start;
     66
     67  inDX = picture[0].flipx ? -1 : +1;
     68  inDY = picture[0].flipy ? -1 : +1;
    5469
    5570  dropback = expand_out - (i_end - i_start) % expand_out;
    5671  if ((i_end - i_start) % expand_out == 0) dropback = 0;
    5772
    58   out_pix = (unsigned char *) picture[0].data;
     73  out_pix = data = (OUT_TYPE *) picture[0].data;
    5974  in_pix  = &image[0].pixmap[DX*(int)MAX(Iy,0) + (int)MAX(Ix,0)];
    6075
     
    6681  }
    6782 
    68   for (j = j_start; j < j_end; j+= expand_out, out_pix+=(expand_out-1)*dx, in_pix += expand_in*DX) {
     83  for (j = j_start; j < j_end; j+= expand_out, in_pix += inDY*expand_in*DX) {
     84    out_pix = &data[j*dx];
    6985
    7086    /**** fill in area to the left of the picture ****/
     
    8096    in_pix2 = in_pix;
    8197    if (expand_out == 1) {
    82       for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) {
     98      for (i = i_start; i < i_end; i++, in_pix2 += inDX*expand_in, out_pix++) {
    8399        *out_pix = pixel[*in_pix2];
    84100      }
    85101    } else {
    86       for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) {
     102      for (i = i_start; i < i_end; i+= expand_out, in_pix2 += inDX, out_pix+= expand_out) {
    87103        pixvalue = pixel[*in_pix2];
    88104        out_pix2 = out_pix;
    89         for (jj = 0; (jj < expand_out) & (j + jj < dy); jj++, out_pix2+=(dx-expand_out)) {
     105        for (jj = 0; (jj < expand_out) && (j + jj < dy); jj++, out_pix2+=(dx-expand_out)) {
    90106          for (ii = 0; ii < expand_out; ii++, out_pix2++) {
    91107            *out_pix2 = pixvalue;
     
    103119      }
    104120    }
    105     out_pix += (dx - i_end);
    106    
    107121  }
    108122 
    109   if ((j_end - j_start) % expand_out > 0)
    110     out_pix -= expand_out - (j_end - j_start) % expand_out;
    111  
    112123  /**** fill in top area ****/
    113   for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned char *)picture[0].data < dx*dy); j++, out_pix++) {
    114     *out_pix = back;
     124  out_pix = &data[j_end*dx];
     125  for (j = 0; j < dy - j_end; j++) {
     126    for (i = 0; i < dx; i++, out_pix++) {
     127      *out_pix = back;
     128    }
    115129  }
    116130  picture[0].pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0,
  • trunk/Ohana/src/kapa2/src/Reorient.c

    r16228 r25757  
    77  picture = &image[0].picture;
    88
    9   if (picture[0].expand == 0) picture[0].expand = 1;
     9  if (picture[0].expand == 0) {
     10      picture[0].expand = 1;
     11      image[0].zoom.expand = 5;
     12  }
    1013
    11   if ((picture[0].X == X) && (picture[0].Y == Y) && (mode == 0)) {
     14  if ((picture[0].Xc == X) && (picture[0].Yc == Y) && (mode == 0)) {
    1215    Refresh ();
    1316    XFlush (graphic[0].display);
     
    1720  switch (mode) {
    1821  case 0:
    19     if ((picture[0].X != X) || (picture[0].Y != Y)) {
    20       picture[0].X = X;
    21       picture[0].Y = Y;
     22    if ((picture[0].Xc != X) || (picture[0].Yc != Y)) {
     23      picture[0].Xc = X;
     24      picture[0].Yc = Y;
    2225    }
    2326    break;
     
    2528    picture[0].expand--;
    2629    if ((picture[0].expand == 0) || (picture[0].expand == -1)) picture[0].expand = -2;
    27     picture[0].X = X;
    28     picture[0].Y = Y;
     30    picture[0].Xc = X;
     31    picture[0].Yc = Y;
    2932    break;
    3033  case +1:
    3134    picture[0].expand++;
    3235    if ((picture[0].expand == 0) || (picture[0].expand == -1)) picture[0].expand = 1;
    33     picture[0].X = X;
    34     picture[0].Y = Y;
     36    picture[0].Xc = X;
     37    picture[0].Yc = Y;
    3538    break;
    3639  }
     40  image[0].zoom.expand = MIN(image[0].zoom.dx / 5.5, MAX(5, 2*picture[0].expand));
    3741
    3842  Remap (graphic, image);
  • trunk/Ohana/src/kapa2/src/SetColorScale.c

    r16061 r25757  
    218218  // store the colors
    219219  if (USE_XWINDOW) {
    220     if (graphic[0].visualclass) {
     220    if (graphic[0].dynamicColors) {
    221221      XStoreColors(graphic[0].display, graphic[0].colormap, graphic[0].cmap, Npixels);
    222222    } else {
  • trunk/Ohana/src/kapa2/src/SetColormap.c

    r16039 r25757  
    146146 store_colors:
    147147  if (!USE_XWINDOW) return (TRUE);
    148   if (graphic[0].visualclass) {
    149     XStoreColors(graphic[0].display, graphic[0].colormap, graphic[0].cmap, graphic[0].Npixels);
     148  if (graphic[0].dynamicColors) {
     149    if (!XStoreColors(graphic[0].display, graphic[0].colormap, graphic[0].cmap, graphic[0].Npixels)) {
     150        fprintf (stderr, "error storing colors\n");
     151    }
    150152  } else {
    151153    for (i = 0; i < graphic[0].Npixels; i++) {
    152       if (XAllocColor (graphic[0].display, graphic[0].colormap, &graphic[0].cmap[i]) == 0) {
     154      if (!XAllocColor (graphic[0].display, graphic[0].colormap, &graphic[0].cmap[i])) {
    153155        fprintf (stderr, "error on %d\n", i);
    154156      }
  • trunk/Ohana/src/kapa2/src/SetUpGraphic.c

    r21153 r25757  
    6060  graphic->color = KapaX11colors (graphic->display, graphic->colormap, graphic->fore, &Ncolors);
    6161  if (MAP_WINDOW) MapWindow (graphic);
     62
    6263  return;
    6364}
  • trunk/Ohana/src/kapa2/src/StatusBox.c

    r16256 r25757  
    1111    y = 0.5*image[0].image[0].matrix.Naxis[1];
    1212    // z = -1;
    13     image[0].zoom.X = x;
    14     image[0].zoom.Y = y;
     13    image[0].zoom.Xc = x;
     14    image[0].zoom.Yc = y;
    1515    // image[0].z = z;
    1616  } else {
    17     x = image[0].zoom.X;
    18     y = image[0].zoom.Y;
     17    x = image[0].zoom.Xc;
     18    y = image[0].zoom.Yc;
    1919    // z = image[0].z;
    2020  }
  • trunk/Ohana/src/kapa2/src/UpdatePointer.c

    r16256 r25757  
    2929
    3030  skip:
    31     image[0].zoom.X = x;
    32     image[0].zoom.Y = y;
     31    image[0].zoom.Xc = x;
     32    image[0].zoom.Yc = y;
    3333   
    3434    UpdateStatusBox (graphic, image, x, y, z, 0);
     
    3636     
    3737    CreateZoom (graphic, image); 
    38     XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,
    39                image[0].zoom.pix, 0, 0,
    40                image[0].zoom.x, image[0].zoom.y,
    41                image[0].zoom.dx, image[0].zoom.dy);
     38    if (image[0].zoom.pix) {
     39        XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,
     40                   image[0].zoom.pix, 0, 0,
     41                   image[0].zoom.x, image[0].zoom.y,
     42                   image[0].zoom.dx, image[0].zoom.dy);
     43    }
    4244    CrossHairs (graphic, &image[0].zoom);
    4345    XFlush (graphic[0].display);
  • trunk/Ohana/src/kapa2/src/UpdateStatusBox.c

    r16255 r25757  
    4848 
    4949  bzero (line, 100);
    50   sprintf (line, "%10.1f %10.1f", x, y);
     50  sprintf (line, "%10.2f %10.2f", x, y);
    5151  XDrawString (graphic[0].display, graphic[0].window, graphic[0].gc,
    5252               image[0].text_x + PAD1, image[0].text_y + 2*textpad + 2*PAD1, line, strlen(line));
  • trunk/Ohana/src/kapa2/src/bDrawOverlay.c

    r19838 r25757  
    8181          double sn = sin(angle);
    8282          x0 = X + pX*dx*cs;
    83           y0 = Y - pY*dx*sn;
     83          y0 = Y + pY*dx*sn;
    8484          // XXX dt should be based on the size of the ellipse...
    8585          // 0.10 -> 60 segments on the ellipse
    8686          # define DT 0.1
    8787          for (t = DT; t < 2*M_PI + DT; t+=DT) {
    88             x1 = X + pX*dx*cos(t)*cs + pX*dy*sin(t)*sn;
    89             y1 = Y - pY*dx*cos(t)*sn + pY*dy*sin(t)*cs;
     88            x1 = X + pX*dx*cos(t)*cs - pX*dy*sin(t)*sn;
     89            y1 = Y + pY*dx*cos(t)*sn + pY*dy*sin(t)*cs;
    9090            bDrawLine (x0, y0, x1, y1);
    9191            x0 = x1;
  • trunk/Ohana/src/libdvo/include/dvo.h

    r24976 r25757  
    325325PhotCodeData *GetPhotcodeTable (void);
    326326
    327 int LoadPhotcodes (char *catdir_file, char *master_file);
     327int LoadPhotcodes (char *catdir_file, char *master_file, int readwrite);
    328328int LoadPhotcodesText (char *filename);
    329329int LoadPhotcodesFITS (char *filename);
     
    432432SkyTable  *SkyTableLoad            PROTO((char *filename, int VERBOSE));
    433433SkyTable  *SkyTableFromGSC         PROTO((char *filename, int depth, int VERBOSE));
    434 SkyTable  *SkyTableLoadOptimal     PROTO((char *catdir, char *SKYFILE, char *GSCFILE, int depth, int VERBOSE));
     434SkyTable  *SkyTableLoadOptimal     PROTO((char *catdir, char *SKYFILE, char *GSCFILE, int readwrite, int depth, int VERBOSE));
    435435int        SkyTableSetDepth        PROTO((SkyTable *sky, int depth));
    436436SkyList   *SkyRegionByPoint        PROTO((SkyTable *table, int depth, double ra, double dec));
  • trunk/Ohana/src/libdvo/src/LoadPhotcodes.c

    r12332 r25757  
    11# include <dvo.h>
    22
    3 int LoadPhotcodes (char *catdir_file, char *master_file) {
     3int LoadPhotcodes (char *catdir_file, char *master_file, int readwrite) {
    44
    55  /* first try to load the photcodes from the specified CATDIR location */
    66  if (LoadPhotcodesFITS (catdir_file)) return TRUE;
    77 
     8  if (!readwrite) {
     9    fprintf (stderr, "db is missing a photcode table & access is read-only -- create one with photcode-table -import\n");
     10    return FALSE;
     11  }
     12
    813  /* next try to load the photcodes from the master text photcode file */
    914  /* automatically (or on demand?) save the text file to the FITS version */
    1015  if (LoadPhotcodesText (master_file)) {
    11       if (!check_file_access (catdir_file, TRUE, TRUE)) return TRUE;
    12       SavePhotcodesFITS (catdir_file);
    13       return TRUE;
     16    if (!check_file_access (catdir_file, TRUE, TRUE, TRUE)) return TRUE;
     17    SavePhotcodesFITS (catdir_file);
     18    return TRUE;
    1419  }
    1520
  • trunk/Ohana/src/libdvo/src/coordops.c

    r19823 r25757  
    163163        return (FALSE);
    164164    }
     165    if (fabs(alpha) >= 180.0) return (FALSE);
    165166    *ra  = alpha + coords[0].crval1;
    166167    *dec = delta + coords[0].crval2;
  • trunk/Ohana/src/libdvo/src/dvo_catalog.c

    r24748 r25757  
    180180
    181181  int Nsecfilt, mode;
     182  int BACKUP, READWRITE;
    182183
    183184  mode = DVO_OPEN_NONE;
     
    192193  dvo_catalog_init (catalog, FALSE);
    193194
     195  // default access control options:
    194196  catalog[0].lockmode  = LCK_XCLD;
    195   if (mode == DVO_OPEN_READ) catalog[0].lockmode  = LCK_SOFT;
     197  BACKUP = TRUE;
     198  READWRITE = TRUE;
     199
     200  // in read-only mode, do not backup or require write access
     201  if (mode == DVO_OPEN_READ) {
     202    catalog[0].lockmode  = LCK_SOFT;
     203    BACKUP = FALSE;
     204    READWRITE = FALSE;
     205  }
    196206 
    197   // XXX make a backup?  always?
    198   if (!check_file_access (catalog[0].filename, TRUE, VERBOSE)) {
     207  if (!check_file_access (catalog[0].filename, BACKUP, READWRITE, VERBOSE)) {
    199208    if (VERBOSE) fprintf (stderr, "no permission to access %s\n", catalog[0].filename);
    200209    return (FALSE);
  • trunk/Ohana/src/libdvo/src/dvo_image.c

    r24748 r25757  
    44int dvo_image_lock (FITS_DB *db, char *filename, double timeout, int lockstate) {
    55
    6   /* lock the image catalog */
    7   if (!check_file_access (filename, FALSE, TRUE)) return (FALSE);
     6  int READWRITE;
     7
     8  // default access control options:
     9  READWRITE = TRUE;
     10
     11  // in read-only mode, do not backup or require write access
     12  if (lockstate == LCK_SOFT) {
     13    READWRITE = FALSE;
     14  }
     15
     16  // do not perform a backup here
     17  if (!check_file_access (filename, FALSE, READWRITE, TRUE)) return (FALSE);
    818
    919  db[0].lockstate = lockstate;
  • trunk/Ohana/src/libdvo/src/skyregion_io.c

    r17000 r25757  
    8484}
    8585
    86 SkyTable *SkyTableLoadOptimal (char *catdir, char *skyfile, char *gscfile, int depth, int verbose) {
     86SkyTable *SkyTableLoadOptimal (char *catdir, char *skyfile, char *gscfile, int readwrite, int depth, int verbose) {
    8787
    8888  char filename[256];
     
    9393  sprintf (filename, "%s/SkyTable.fits", catdir);
    9494  if (stat (filename, &filestat)) goto SKYFILE;
    95   if (!check_file_access (filename, FALSE, verbose)) goto SKYFILE;
     95  if (!check_file_access (filename, FALSE, readwrite, verbose)) goto SKYFILE;
    9696  sky = SkyTableLoad (filename, verbose);
    9797  if (sky == NULL) {
     
    106106  if (skyfile[0] != 0) goto GSCFILE;
    107107  if (stat (skyfile, &filestat)) goto GSCFILE;
    108   if (!check_file_access (skyfile, FALSE, verbose)) goto GSCFILE;
     108  if (!check_file_access (skyfile, FALSE, readwrite, verbose)) goto GSCFILE;
    109109  sky = SkyTableLoad (skyfile, verbose);
    110110  if (sky == NULL) {
     
    117117  /* create CATDIR copy */
    118118  sprintf (filename, "%s/SkyTable.fits", catdir);
    119   check_file_access (filename, FALSE, verbose);
     119  check_file_access (filename, FALSE, readwrite, verbose);
    120120  if (!SkyTableSave (sky, filename)) return NULL;
    121121
     
    134134  /* create CATDIR copy */
    135135  sprintf (filename, "%s/SkyTable.fits", catdir);
    136   check_file_access (filename, FALSE, verbose);
     136  check_file_access (filename, FALSE, readwrite, verbose);
    137137  if (!SkyTableSave (sky, filename)) return NULL;
    138138
  • trunk/Ohana/src/libkapa/include/kapa.h

    r21153 r25757  
    154154/* KapaWindow.c */
    155155int KiiResize (int fd, int Nx, int Ny);
     156int KiiRelocate (int fd, int x, int y);
    156157int KiiCenter (int fd, double x, double y, int zoom);
    157158int KiiParity (int fd, int xflip, int yflip);
  • trunk/Ohana/src/libkapa/src/KapaWindow.c

    r21060 r25757  
    2323  KiiSendCommand (fd, 4, "RSIZ");
    2424  KiiSendMessage (fd, "%d %d", Nx, Ny);
     25  KiiWaitAnswer (fd, "DONE");
     26  return (TRUE);
     27}
     28
     29int KiiRelocate (int fd, int x, int y) {
     30
     31  KiiSendCommand (fd, 4, "MOVE");
     32  KiiSendMessage (fd, "%d %d", x, y);
    2533  KiiWaitAnswer (fd, "DONE");
    2634  return (TRUE);
  • trunk/Ohana/src/libohana/include/ohana.h

    r21508 r25757  
    166166int     mkdirhier              PROTO((char *path, int mode));
    167167void    make_backup            PROTO((char *filename));
    168 int     check_file_access      PROTO((char *basefile, int backup, int verbose));
     168int     check_file_access      PROTO((char *basefile, int backup, int readwrite, int verbose));
    169169int     check_dir_access       PROTO((char *path, int verbose));
    170170int     check_file_exec        PROTO((char *filename));
  • trunk/Ohana/src/libohana/src/findexec.c

    r18051 r25757  
    6767   - file backup permission OK (optional)
    6868*/
    69 int check_file_access (char *basefile, int BACKUP, int VERBOSE) {
     69int check_file_access (char *basefile, int BACKUP, int READWRITE, int VERBOSE) {
    7070 
    7171  char *path, *filename;
     
    7474  gid_t gid;
    7575  int status;
     76  int valid;
    7677
    7778  uid = getuid();
    7879  gid = getgid();
     80
     81  // XXX this function needs to call 'getgroups' to get the full list of the user's
     82  // groups.  we would then need to loop over all groups in the gid test below
     83  // to see if any match the file.  test to see how slow this is.
    7984
    8085  /* check permission to write to directory */
     
    8792  status = stat (basefile, &filestat);
    8893  if (status == 0) { /* file exists, are permissions OK? */
    89     if (((uid == filestat.st_uid) && (filestat.st_mode & S_IRUSR) && (filestat.st_mode & S_IWUSR)) ||
    90         ((gid == filestat.st_gid) && (filestat.st_mode & S_IRGRP) && (filestat.st_mode & S_IWGRP)) ||
    91         ((filestat.st_mode & S_IROTH) && (filestat.st_mode & S_IWOTH))) {
    92     } else {
     94    valid = FALSE;
     95    if (!valid && (uid == filestat.st_uid)) {
     96      valid = (filestat.st_mode & S_IRUSR) != 0;
     97      valid &= !READWRITE || (filestat.st_mode & S_IWUSR);
     98    }
     99    if (!valid && (gid == filestat.st_gid)) {
     100      valid = (filestat.st_mode & S_IRGRP) != 0;
     101      valid &= !READWRITE || (filestat.st_mode & S_IWGRP);
     102    }
     103    if (!valid) {
     104      valid = (filestat.st_mode & S_IROTH) != 0;
     105      valid &= !READWRITE || (filestat.st_mode & S_IWOTH);
     106    }
     107    if (!valid) {
    93108      if (VERBOSE) fprintf (stderr, "can't write to %s\n", basefile);
    94109      return (FALSE);
     
    102117    status = stat (filename, &filestat);
    103118    if (status == 0) { /* file exists, are permissions OK? */
    104       if (((uid == filestat.st_uid) && (filestat.st_mode & S_IRUSR) && (filestat.st_mode & S_IWUSR)) ||
    105           ((gid == filestat.st_gid) && (filestat.st_mode & S_IRGRP) && (filestat.st_mode & S_IWGRP)) ||
    106           ((filestat.st_mode & S_IROTH) && (filestat.st_mode & S_IWOTH))) {
    107       } else {
     119      valid = FALSE;
     120      if (!valid && (uid == filestat.st_uid)) {
     121        valid = (filestat.st_mode & S_IRUSR) != 0;
     122        valid &= !READWRITE || (filestat.st_mode & S_IWUSR);
     123      }
     124      if (!valid && (gid == filestat.st_gid)) {
     125        valid = (filestat.st_mode & S_IRGRP) != 0;
     126        valid &= !READWRITE || (filestat.st_mode & S_IWGRP);
     127      }
     128      if (!valid) {
     129        valid = (filestat.st_mode & S_IROTH) != 0;
     130        valid &= !READWRITE || (filestat.st_mode & S_IWOTH);
     131      }
     132      if (!valid) {
    108133        if (VERBOSE) fprintf (stderr, "can't write to %s\n", filename);
    109134        return (FALSE);
  • trunk/Ohana/src/markrock/src/ConfigInit.c

    r12332 r25757  
    4444  /* XXX this does not yet write out the master photcode table */
    4545  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    46   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     46  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    4747    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    4848    exit (1);
  • trunk/Ohana/src/markrock/src/markrock.c

    r15743 r25757  
    3333
    3434  /* if lockfile exists, program will complain and quit */
    35   if (!check_file_access (argv[1], TRUE, TRUE)) exit (1);
    36   if (!check_file_access (RockCat, TRUE, TRUE)) exit (1);
     35  if (!check_file_access (argv[1], TRUE, TRUE, TRUE)) exit (1);
     36  if (!check_file_access (RockCat, TRUE, TRUE, TRUE)) exit (1);
    3737
    3838  catalog.filename = argv[1];
  • trunk/Ohana/src/markstar/src/ConfigInit.c

    r12332 r25757  
    5454  /* XXX this does not yet write out the master photcode table */
    5555  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    56   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     56  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    5757    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    5858    exit (1);
  • trunk/Ohana/src/mosastro/src/getptolemy.c

    r16810 r25757  
    1919
    2020  /* load regions from GSC table, restrict to patch */
    21   sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, SKY_DEPTH_HST, VERBOSE);
     21  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, FALSE, SKY_DEPTH_HST, VERBOSE);
    2222  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2323  skylist = SkyListByPatch (sky, -1, &patch);
  • trunk/Ohana/src/opihi/cmd.astro/Makefile

    r21061 r25757  
    2121$(SRC)/cgrid.$(ARCH).o             \
    2222$(SRC)/coords.$(ARCH).o    \
     23$(SRC)/cdot.$(ARCH).o              \
    2324$(SRC)/cplot.$(ARCH).o             \
    2425$(SRC)/csystem.$(ARCH).o           \
     
    3637$(SRC)/medianmap.$(ARCH).o         \
    3738$(SRC)/mkgauss.$(ARCH).o           \
     39$(SRC)/mksersic.$(ARCH).o          \
     40$(SRC)/galradius.$(ARCH).o         \
     41$(SRC)/galradbins.$(ARCH).o        \
     42$(SRC)/galsectors.$(ARCH).o        \
     43$(SRC)/galprofiles.$(ARCH).o       \
     44$(SRC)/elliprofile.$(ARCH).o       \
     45$(SRC)/petrosian.$(ARCH).o         \
    3846$(SRC)/multifit.$(ARCH).o          \
    3947$(SRC)/objload.$(ARCH).o           \
  • trunk/Ohana/src/opihi/cmd.astro/cgrid.c

    r20936 r25757  
    3737  /* set spacings for RA */
    3838  minorRA = minorDEC = 0.1;
    39   range = MIN (fabs(graphmode.xmax-graphmode.xmin), fabs(graphmode.ymax-graphmode.ymin));
     39  range = MIN (fabs(graphmode.coords.cdelt1*(graphmode.xmax-graphmode.xmin)), fabs(graphmode.coords.cdelt2*(graphmode.ymax-graphmode.ymin)));
    4040  if (NorthPole || SouthPole) range = 360;
    4141  lrange = log10(MAX(fabs(range), 1e-30));
     
    5858  }
    5959  dR = range / 100.0;
     60
    6061  /* set spacings for DEC */
    61   range = MIN (fabs(graphmode.xmax-graphmode.xmin), fabs(graphmode.ymax-graphmode.ymin));
     62  range = MIN (fabs(graphmode.coords.cdelt1*(graphmode.xmax-graphmode.xmin)), fabs(graphmode.coords.cdelt2*(graphmode.ymax-graphmode.ymin)));
    6263  lrange = log10(MAX(fabs(range), 1e-30));
    6364  factor = (int) (lrange);
  • trunk/Ohana/src/opihi/cmd.astro/init.c

    r21061 r25757  
    55int cgrid                   PROTO((int, char **));
    66int coords                  PROTO((int, char **));
     7int cdot                    PROTO((int, char **));
    78int cplot                   PROTO((int, char **));
    89int csystem                 PROTO((int, char **));
     
    2223int imsub                   PROTO((int, char **));
    2324int medianmap               PROTO((int, char **));
     25int galsectors              PROTO((int, char **));
     26int galprofiles             PROTO((int, char **));
     27int galradius               PROTO((int, char **));
     28int galradbins              PROTO((int, char **));
     29int elliprofile             PROTO((int, char **));
     30int petrosian               PROTO((int, char **));
    2431int mkgauss                 PROTO((int, char **));
     32int mksersic                PROTO((int, char **));
    2533int multifit                PROTO((int, char **));
    2634int objload                 PROTO((int, char **));
     
    4452  {1, "cgrid",       cgrid,        "plot sky coordinate grid"},
    4553  {1, "coords",      coords,       "load coordinates for buffer from file"},
     54  {1, "cdot",        cdot,         "plot point in sky coordinates"},
    4655  {1, "cplot",       cplot,        "plot vectors in sky coordinates"},
    4756  {1, "csystem",     csystem,      "convert between coordinate systems"},
     
    6170  {1, "medianmap",   medianmap,    "small median image"},
    6271  {1, "mkgauss",     mkgauss,      "generate a 2-D gaussian centered in image"},
     72  {1, "mksersic",    mksersic,     "generate a 2-D sersic profile"},
     73  {1, "galsectors",  galsectors,   "generate radial vectors for sectors of width dtheta"},
     74  {1, "galprofiles", galprofiles,  "generate radial vectors with interpolation along paths"},
     75  {1, "galradius",   galradius,    "generate radial vectors with interpolation along paths"},
     76  {1, "galradbins",  galradbins,   "generate radial vectors with interpolation along paths"},
     77  {1, "elliprofile", elliprofile,  "generate radial vectors with interpolation along paths"},
     78  {1, "petrosian",   petrosian,    "petrosian parameters given radial bins"},
    6379  {1, "multifit",    multifit,     "fit multi-order spectrum"},
    6480  {1, "objload",     objload,      "plot obj data on Ximage "},
  • trunk/Ohana/src/opihi/cmd.astro/region.c

    r14590 r25757  
    66  double Ra, Dec, Radius;
    77  float dx, dy;
    8   int N, kapa;
     8  int N, kapa, NoClear;
    99  char *name;
    1010  Graphdata graphmode;
     
    4646    remove_argument (N, &argc, argv);
    4747    graphmode.flipnorth = FALSE;
     48  }
     49
     50  NoClear = FALSE;
     51  if ((N = get_argument (argc, argv, "-no-clear"))) {
     52    remove_argument (N, &argc, argv);
     53    NoClear = TRUE;
    4854  }
    4955
     
    122128  graphmode.coords.cdelt1 = graphmode.coords.cdelt2 = 1.0;
    123129
    124   KapaClearSections (kapa);
     130  if (!NoClear) KapaClearSections (kapa);
    125131  KapaSetLimits (kapa, &graphmode);
    126132
    127133  /* drop this? */
    128   sprintf (string, "%8.4f %8.4f (%f)", Ra, Dec, Radius);
    129   KapaSendLabel (kapa, string, 2);
     134  // sprintf (string, "%8.4f %8.4f (%f)", Ra, Dec, Radius);
     135  // KapaSendLabel (kapa, string, 2);
    130136
    131137  // XXX is this the right thing to be doing?
  • trunk/Ohana/src/opihi/cmd.basic/substr.c

    r18705 r25757  
    1616  // add a range check here
    1717  if ((N1 < 0) || (N1 >=  strlen(argv[1]))) {
    18       gprint (GP_ERR, "ERROR: N1 out of range\n");
     18      gprint (GP_ERR, "ERROR: start value out of range in substr command\n");
    1919      return (FALSE);
    2020  }
    2121  if ((N2 < 0) || ((N2+N1) >  strlen(argv[1]))) {
    22       gprint (GP_ERR, "ERROR: N2 out of range\n");
     22      gprint (GP_ERR, "ERROR: end value out of range in substr command\n");
    2323      return (FALSE);
    2424  }
  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r21508 r25757  
    9797$(SRC)/rebin.$(ARCH).o          \
    9898$(SRC)/resize.$(ARCH).o \
     99$(SRC)/relocate.$(ARCH).o       \
    99100$(SRC)/roll.$(ARCH).o           \
    100101$(SRC)/rotate.$(ARCH).o \
     
    110111$(SRC)/style.$(ARCH).o             \
    111112$(SRC)/subraster.$(ARCH).o         \
    112 $(SRC)/subset.$(ARCH).o    \
     113$(SRC)/subset.$(ARCH).o            \
    113114$(SRC)/svd.$(ARCH).o               \
    114115$(SRC)/swapbytes.$(ARCH).o         \
     
    118119$(SRC)/tvcolors.$(ARCH).o          \
    119120$(SRC)/tvcontour.$(ARCH).o         \
    120 $(SRC)/tvgrid.$(ARCH).o    \
     121$(SRC)/tvgrid.$(ARCH).o            \
    121122$(SRC)/uniq.$(ARCH).o              \
    122 $(SRC)/unsign.$(ARCH).o    \
     123$(SRC)/unsign.$(ARCH).o            \
    123124$(SRC)/vbin.$(ARCH).o              \
     125$(SRC)/vgroup.$(ARCH).o            \
    124126$(SRC)/vclip.$(ARCH).o             \
    125 $(SRC)/vgauss.$(ARCH).o           \
    126 $(SRC)/vmaxwell.$(ARCH).o           \
     127$(SRC)/vgauss.$(ARCH).o            \
     128$(SRC)/vellipse.$(ARCH).o          \
     129$(SRC)/vmaxwell.$(ARCH).o          \
    127130$(SRC)/vgrid.$(ARCH).o             \
    128131$(SRC)/vload.$(ARCH).o             \
     
    130133$(SRC)/vpop.$(ARCH).o              \
    131134$(SRC)/vroll.$(ARCH).o             \
    132 $(SRC)/vsmooth.$(ARCH).o        \
     135$(SRC)/vsmooth.$(ARCH).o           \
    133136$(SRC)/vstats.$(ARCH).o            \
    134137$(SRC)/wd.$(ARCH).o                \
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r24219 r25757  
    8585int rebin            PROTO((int, char **));
    8686int resize           PROTO((int, char **));
     87int relocate         PROTO((int, char **));
    8788int roll             PROTO((int, char **));
    8889int rotate           PROTO((int, char **));
     
    110111int unsign           PROTO((int, char **));
    111112int vbin             PROTO((int, char **));
     113int vgroup           PROTO((int, char **));
    112114int vclip            PROTO((int, char **));
    113115int vect_select      PROTO((int, char **));
    114116int vgrid            PROTO((int, char **));
    115117int vgauss           PROTO((int, char **));
     118int vellipse         PROTO((int, char **));
    116119int vmaxwell         PROTO((int, char **));
    117120int vload            PROTO((int, char **));
     
    218221  {1, "rebin",        rebin,            "rebin image data by factor of N"},
    219222  {1, "resize",       resize,           "set graphics/image window size"},
     223  {1, "relocate",     relocate,         "set graphics/image window position"},
    220224  {1, "roll",         roll,             "roll image to new start point"},
    221225  {1, "rotate",       rotate,           "rotate image"},
     
    243247  {1, "uniq",         uniq,             "create a uniq vector subset from a vector"},
    244248  {1, "unsign",       unsign,           "toggle the UNSIGN status"},
    245   {1, "vbin",         vbin,             "rebin vector data by a fector of N"},
     249  {1, "vbin",         vbin,             "rebin vector data by a factor of N"},
     250  {1, "vgroup",       vgroup,           "group y vector into bins defined by x vector values"},
    246251  {1, "vclip",        vclip,            "clip values in a vector to be within a range"},
    247252  {1, "vectors",      list_vectors,     "list vectors"},
    248253  {1, "vgauss",       vgauss,           "fit a Gaussian to a vector"},
     254  {1, "vellipse",     vellipse,         "fit a Ellipse to a vector pair"},
    249255  {1, "vgrid",        vgrid,            "generate an image from a triplet of vectors"},
    250256  {1, "vhistogram",   histogram,        "generate histogram from vector"},
  • trunk/Ohana/src/opihi/cmd.data/subset.c

    r20936 r25757  
    66 
    77  char *out;
    8   int  i, Npts, size;
     8  int  i, Npts, size, valid;
    99  Vector *ivec, *ovec, *tvec;
    1010
     
    1212  ivec = ovec = tvec = NULL;
    1313
    14   if ((argc < 6) || strcmp(argv[2], "=") || strcmp (argv[4], "if")) {
    15     gprint (GP_ERR, "SYNTAX: subset vec = vec if (logic expression)\n");
     14  valid = TRUE;
     15  valid &= (argc >= 6);
     16  valid &= !strcmp(argv[2], "=");
     17  valid &= !strcmp(argv[4], "if") || !strcmp (argv[4], "where");
     18  if (!valid) {
     19    gprint (GP_ERR, "SYNTAX: subset vec = vec [if/where] (logic expression)\n");
    1620    return (FALSE);
    1721  }
     
    7680  return (TRUE);
    7781
    78  error:
     82error:
    7983  DeleteVector (tvec);
    8084  DeleteVector (ovec);
  • trunk/Ohana/src/opihi/cmd.data/tvcolors.c

    r16059 r25757  
    1919  if (argc != 2) {
    2020    gprint (GP_ERR, "USAGE: tvcolors (colormap)\n");
     21    gprint (GP_ERR, " colormap options : greyscale, -greyscale, rainbow, heat, fullcolor, ruffcolor (also grayscale, -grayscale)\n");
    2122    return (FALSE);
    2223  }
  • trunk/Ohana/src/opihi/dvo/Makefile

    r20936 r25757  
    7373$(SRC)/imrough.$(ARCH).o                \
    7474$(SRC)/imsearch.$(ARCH).o               \
    75 $(SRC)/imstats.$(ARCH).o                \
    7675$(SRC)/lcat.$(ARCH).o                   \
    7776$(SRC)/lcurve.$(ARCH).o         \
  • trunk/Ohana/src/opihi/dvo/gimages.c

    r21508 r25757  
    124124      }
    125125
     126      // find coordinates of image center
    126127      XY_to_RD (&Ro, &Do, Xo, Yo, &image[i].coords);
     128      if (fabs(Ro - Ra) > 120.0) continue;
    127129
    128130      local.crval1 = Ro;
     
    138140        Xs = -0.5*image[i].NX;
    139141        Ys = -0.5*image[i].NY;
    140         Xe = +0.5*image[i].NX;
    141         Ye = +0.5*image[i].NY;
    142142      } else {
    143143        Xs = 0.0;
    144144        Ys = 0.0;
    145         Xe = image[i].NX;
    146         Ye = image[i].NY;
    147145      }
    148146     
     147      // find coordinates of an image corner
    149148      XY_to_RD (&Ro, &Do, Xs, Ys, &image[i].coords);
    150       RD_to_XY (&Xo, &Xo, Ro, Do, &local);
     149
     150      // find radius of image in arcsec
     151      RD_to_XY (&Xo, &Yo, Ro, Do, &local);
    151152      Radius = hypot (Xo, Yo);
    152153      // fprintf (stderr, "%s: %f %f    %f ", image[i].name, local.crval1, local.crval2, Radius);
    153154
    154       XY_to_RD (&Ro, &Do, Xs, Ye, &image[i].coords);
    155       RD_to_XY (&Xo, &Xo, Ro, Do, &local);
    156       Radius = MAX (Radius, hypot (Xo, Yo));
    157       // fprintf (stderr, "%f ", Radius);
    158 
    159       XY_to_RD (&Ro, &Do, Xe, Ys, &image[i].coords);
    160       RD_to_XY (&Xo, &Xo, Ro, Do, &local);
    161       Radius = MAX (Radius, hypot (Xo, Yo));
    162       // fprintf (stderr, "%f ", Radius);
    163 
    164       XY_to_RD (&Ro, &Do, Xe, Ye, &image[i].coords);
    165       RD_to_XY (&Xo, &Xo, Ro, Do, &local);
    166       Radius = MAX (Radius, hypot (Xo, Yo));
    167       // fprintf (stderr, "%f ", Radius);
    168 
     155      // check for distances to coordinates in arcsec
    169156      RD_to_XY (&Xo, &Yo, Ra, Dec, &local);
    170157      // fprintf (stderr, " : %f\n", hypot(Xo,Yo));
     158
     159      // skip images with center too far from coordinaes
    171160      if (hypot(Xo,Yo) > 1.5*Radius) continue;
    172161      // fprintf (stderr, " ** try me **\n");
  • trunk/Ohana/src/opihi/dvo/imbox.c

    r21065 r25757  
    33int imbox (int argc, char **argv) {
    44 
    5   int j, kapa, Nskip, status, InPic, flipped, N, haveNx, haveNy, Nx, Ny, SOLO_PHU;
     5  int j, kapa, Nskip, status, InPic, flipped, N, haveNx, haveNy, Nx, Ny, SOLO_PHU, Npts, NPTS;
    66  Vector Xvec, Yvec;
    77  double r, d, x[4], y[4], Rmin, Rmax, Rmid;
     
    3636 
    3737  /* project this image to screen display coords */
    38   SetVector (&Xvec, OPIHI_FLT, 8);
    39   SetVector (&Yvec, OPIHI_FLT, 8);
     38  Npts = 0;
     39  NPTS = 200;
     40  SetVector (&Xvec, OPIHI_FLT, NPTS);
     41  SetVector (&Yvec, OPIHI_FLT, NPTS);
    4042
    4143  while (gfits_fread_header (f, &header)) {
     
    8284        while (r > Rmid) r-= 360.0;
    8385      }
    84       status |= RD_to_XY (&Xvec.elements.Flt[2*j], &Yvec.elements.Flt[2*j], r, d, &graphmode.coords);
     86      status |= RD_to_XY (&Xvec.elements.Flt[Npts + 2*j], &Yvec.elements.Flt[Npts + 2*j], r, d, &graphmode.coords);
    8587      if (j > 0) {
    86         Xvec.elements.Flt[2*j - 1] = Xvec.elements.Flt[2*j];
    87         Yvec.elements.Flt[2*j - 1] = Yvec.elements.Flt[2*j];
     88        Xvec.elements.Flt[Npts + 2*j - 1] = Xvec.elements.Flt[Npts + 2*j];
     89        Yvec.elements.Flt[Npts + 2*j - 1] = Yvec.elements.Flt[Npts + 2*j];
    8890      }
    8991    }
    90     Xvec.elements.Flt[7] = Xvec.elements.Flt[0];
    91     Yvec.elements.Flt[7] = Yvec.elements.Flt[0];
     92    Xvec.elements.Flt[Npts + 7] = Xvec.elements.Flt[Npts + 0];
     93    Yvec.elements.Flt[Npts + 7] = Yvec.elements.Flt[Npts + 0];
     94
    9295    InPic = FALSE;
    9396    for (j = 0; j < 8; j+=2) {
    94       if ((Xvec.elements.Flt[j] >= graphmode.xmin) &&
    95           (Xvec.elements.Flt[j] <= graphmode.xmax) &&
    96           (Yvec.elements.Flt[j] >= graphmode.ymin) &&
    97           (Yvec.elements.Flt[j] <= graphmode.ymax))
    98         InPic = TRUE;
     97      if ((Xvec.elements.Flt[Npts + j] >= graphmode.xmin) &&
     98          (Xvec.elements.Flt[Npts + j] <= graphmode.xmax) &&
     99          (Yvec.elements.Flt[Npts + j] >= graphmode.ymin) &&
     100          (Yvec.elements.Flt[Npts + j] <= graphmode.ymax))
     101        InPic = TRUE;
     102    }
     103    if (!InPic) continue;
     104
     105    Npts += 8;
     106    if (Npts + 8 >= NPTS) {  /* need to leave room for 4 point image */
     107      NPTS += 200;
     108      REALLOCATE (Xvec.elements.Flt, opihi_flt, NPTS);
     109      REALLOCATE (Yvec.elements.Flt, opihi_flt, NPTS);
    99110    }
    100111
    101     Xvec.Nelements = Yvec.Nelements = 8;
    102     if (InPic) {
    103       graphmode.style = 2; /* points */
    104       graphmode.ptype = 100; /* connect pairs of points */
    105       graphmode.etype = 0;
    106       PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
    107     }
    108112  skip:
    109113    Nskip = gfits_data_size (&header);
     
    111115    gfits_free_header (&header);
    112116  }
     117
     118  Xvec.Nelements = Yvec.Nelements = Npts;
     119  if (Npts > 0) {
     120    graphmode.style = 2; /* points */
     121    graphmode.ptype = 100; /* connect pairs of points */
     122    graphmode.etype = 0;
     123    PlotVectorPair (kapa, &Xvec, &Yvec, &graphmode);
     124  }
     125
    113126  fclose (f);
    114127  free (Xvec.elements.Flt);
  • trunk/Ohana/src/opihi/dvo/init.c

    r21541 r25757  
    102102  {1, "subpix",      subpix,       "get subpixel positions"},
    103103  {1, "version",     version,      "show version information"},
    104 //{1, "imstats",     imstats,      "plot image statistics"},
    105104//{1, "addxtra",     addxtra,      "add extra data to object"},
    106105//{1, "getxtra",     getxtra,      "get extra data from object"},
  • trunk/Ohana/src/opihi/dvo/photometry.c

    r21508 r25757  
    325325    return (FALSE);
    326326  }
    327   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     327
     328  // XXX now that DVO does not allow write access, we can drop the MasterPhotcodeFile
     329  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, FALSE)) {
    328330    gprint (GP_ERR, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    329331    return (FALSE);
  • trunk/Ohana/src/opihi/dvo/region_list.c

    r15753 r25757  
    4242
    4343  if (sky != NULL) SkyTableFree (sky);
    44   sky = SkyTableLoadOptimal (CATDIR, skyfile, gscfile, skydepth, verbose);
     44  sky = SkyTableLoadOptimal (CATDIR, skyfile, gscfile, FALSE, skydepth, verbose);
    4545  if (sky == NULL) return FALSE;
    4646
  • trunk/Ohana/src/opihi/dvo/skycoverage.c

    r21153 r25757  
    1616  Coords coords;
    1717  int typehash;
     18  int PhotcodeSelect;
     19  PhotCode *PhotcodeValue;
    1820
    1921  WITH_MOSAIC = FALSE;
     
    4345    remove_argument (N, &argc, argv);
    4446    ByName = TRUE;
     47  }
     48
     49  PhotcodeValue = NULL;
     50  PhotcodeSelect = FALSE;
     51  if ((N = get_argument (argc, argv, "-photcode"))) {
     52    if (!InitPhotcodes ()) return (FALSE);
     53    PhotcodeSelect = TRUE;
     54    remove_argument (N, &argc, argv);
     55    PhotcodeValue = GetPhotcodebyName (argv[N]);
     56    if (PhotcodeValue == NULL) {
     57      gprint (GP_ERR, "photcode not found in photcode table\n");
     58      return (FALSE);
     59    }
     60    remove_argument (N, &argc, argv);
    4561  }
    4662
     
    85101 
    86102  if (argc != 4) {
    87     gprint (GP_ERR, "USAGE: skycoverage (buffer) (pixscale) (Npts) [-time start range] [-name name]\n");
     103    gprint (GP_ERR, "USAGE: skycoverage (buffer) (pixscale) (Npts)\n");
     104    gprint (GP_ERR, "  options: [-time start range] [-trange start stop] [-name name] [-photcode name] [+mosaic] [-mosaic] [-ra-center RA]\n");
    88105    gprint (GP_ERR, "       (buffer) saves bitmapped AIT plot\n");
    89106    gprint (GP_ERR, "       (pixscale) specifies the pixel size in degrees\n");
     
    128145    for (xs = 0; xs < Nx; xs++) {
    129146      status = XY_to_RD (&r, &d, (double)(xs), (double)(ys), &coords);
    130       status &= (r > 0);
    131       status &= (r < 360);
     147      status &= (r >= 0);
     148      status &= (r <= 360);
    132149      if (status) {
    133150        V[ys*Nx + xs] = 2;
     
    141158    if (ByName && strcmp (name, image[i].name)) continue;
    142159    if (TimeSelect && ((image[i].tzero < tzero) || (image[i].tzero+image[i].trate*image[i].NY > tzero + trange))) continue;
     160
     161    if (PhotcodeSelect) {
     162      if (PhotcodeValue[0].type == PHOT_DEP) {
     163        if (PhotcodeValue[0].code != image[i].photcode) continue;
     164      } else {
     165        if (PhotcodeValue[0].code != GetPhotcodeEquivCodebyCode (image[i].photcode)) continue;
     166      }
     167    }
     168
    143169    if (!FindMosaicForImage (image, Nimage, i)) continue;
    144170
     
    167193        XY_to_RD (&r, &d, Xi, Yi, &image[i].coords);
    168194        r = ohana_normalize_angle (r);
     195        if (r - RaCenter > +180.0) r -= 360.0;
     196        if (r - RaCenter < -180.0) r += 360.0;
    169197        status = RD_to_XY (&Xs, &Ys, r, d, &coords);
    170198        if (Xs < 0) continue;
  • trunk/Ohana/src/opihi/lib.data/mrqmin.c

    r20936 r25757  
    1717
    1818  int k, j, i;
    19   opihi_flt ydiff, wt, chisq;
     19  opihi_flt ymodel, ydiff, wt, chisq;
    2020
    2121  for (j = 0; j < Npar; j++) {
     
    2727  for (i = 0; i < Npts; i++) {
    2828
    29     ydiff = funcs (x[i], par, Npar, dyda) - y[i];
     29    ymodel = funcs (x[i], par, Npar, dyda);
     30    ydiff = ymodel - y[i];
    3031    chisq += SQ(ydiff) * dy[i];
     32
     33    // fprintf (stderr, "%f %f - %f : %f -> %f\n", x[i], y[i], ymodel, dy[i], chisq);
    3134
    3235    for (j = 0; j < Npar; j++) {
     
    8588
    8689  /* if good, save temp values */
    87   if (rho > 0) {
     90  if ((chisq > 1e-3) && (rho > -1e-6)) {
    8891    lambda *= 0.1;
    8992    ochisq = chisq;
  • trunk/Ohana/src/photdbc/src/ConfigInit.c

    r17284 r25757  
    6464  /* XXX this does not yet write out the master photcode table */
    6565  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    66   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     66  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    6767    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    6868    exit (1);
  • trunk/Ohana/src/photdbc/src/photdbc.c

    r17284 r25757  
    1717
    1818  // the output catalog needs to inherit the SKY_DEPTH of the input catalog
    19   sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, SKY_DEPTH_HST, VERBOSE);
     19  sky = SkyTableLoadOptimal (CATDIR, NULL, GSCFILE, TRUE, SKY_DEPTH_HST, VERBOSE);
    2020  SkyTableSetFilenames (sky, CATDIR, "cpt");
    2121  skylist = SkyListByPatch (sky, -1, &REGION);
  • trunk/Ohana/src/relastro/src/ConfigInit.c

    r24308 r25757  
    6060  /* update master photcode table if not defined */
    6161  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    62   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     62  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    6363    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    6464    exit (1);
  • trunk/Ohana/src/relastro/src/load_images.c

    r12332 r25757  
    1111
    1212  // load the current sky table (layout of all SkyRegions)
    13   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     13  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1414  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1515 
  • trunk/Ohana/src/relastro/src/relastro_objects.c

    r24308 r25757  
    1111
    1212  // load the current sky table (layout of all SkyRegions)
    13   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     13  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1414  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1515 
  • trunk/Ohana/src/relphot/src/ConfigInit.c

    r20323 r25757  
    5858  /* XXX this does not yet write out the master photcode table */
    5959  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    60   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     60  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    6161    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    6262    exit (1);
  • trunk/Ohana/src/relphot/src/load_images.c

    r10506 r25757  
    1111
    1212  // load the current sky table (layout of all SkyRegions)
    13   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     13  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1414  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1515 
  • trunk/Ohana/src/relphot/src/relphot_objects.c

    r25733 r25757  
    1111
    1212  // load the current sky table (layout of all SkyRegions)
    13   sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, SKY_DEPTH, VERBOSE);
     13  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    1414  SkyTableSetFilenames (sky, CATDIR, "cpt");
    1515 
  • trunk/Ohana/src/tools/src/mktemp.c

    r12333 r25757  
    11# include <stdio.h>
    22# include <stdlib.h>
     3# include <string.h>
     4
     5# define FALSE 0
     6# define TRUE 1
    37
    48int main (int argc, char **argv) {
    59
    6   if (argc != 2) {
    7     fprintf (stderr, "USAGE: %s (template)\n", argv[0]);
    8     exit (1);
     10  int i, j, Ntotal;
     11  char *tmpdir, *template, deftemplate[32], *prefix, defprefix[32], *filename;
     12  int make_directory, fail_silently, unsafe_mode, full_path;
     13
     14  tmpdir = NULL;
     15  prefix = NULL;
     16  template = NULL;
     17  filename = NULL;
     18
     19  make_directory = FALSE;
     20  fail_silently = FALSE;
     21  unsafe_mode = FALSE;
     22  full_path = TRUE;
     23
     24  for (i = 1; i < argc; i++) {
     25    // -options must be first
     26    if (argv[i][0] == '-') {
     27      if (!strcmp(argv[i], "-V")) {
     28        fprintf (stdout, "mktemp version Ohana $Revision: $\n");
     29        exit (0);
     30      }
     31      if (!strcmp(argv[i], "-p")) {
     32        if (argc <= i + 1) usage();
     33        i++;
     34        prefix = argv[i];
     35        full_path = FALSE;
     36        continue;
     37      }
     38      for (j = 1; j < strlen(argv[i]); j++) {
     39        if (argv[i][j] == 'q') {
     40          fail_silently = TRUE;
     41          continue;
     42        }
     43        if (argv[i][j] == 't') {
     44          full_path = FALSE;
     45          continue;
     46        }
     47        if (argv[i][j] == 'd') {
     48          // make directory
     49          make_directory = TRUE;
     50          continue;
     51        }
     52        if (argv[i][j] == 'u') {
     53          unsafe_mode = TRUE;
     54          continue;
     55        }
     56        // unknown option
     57        usage();
     58      }
     59      continue;
     60    }
     61    // report an error if too many arguments are given
     62    if (template) usage();
     63    template = argv[i];
    964  }
    1065
    11   if (mkstemp (argv[1]) == -1) exit (1);
     66  if (!full_path) {
     67    // prefix = TMPDIR ? TMPDIR : (prefix ? prefix : /tmp)
     68    tmpdir = getenv("TMPDIR");
     69    if (tmpdir) {
     70      prefix = tmpdir;
     71    }
     72    if (!prefix) {
     73      strcpy (defprefix, "/tmp");
     74      prefix = defprefix;
     75    }
     76    if (template && strchr(template, '/')) usage();
     77  }
    1278
    13   fprintf (stdout, "%s\n", argv[1]);
     79  if (!template) {
     80    if (full_path) {
     81      strcpy (deftemplate, "/tmp/tmp.XXXXXXXXXX");
     82    } else {
     83      strcpy (deftemplate, "tmp.XXXXXXXXXX");
     84    }
     85    template = deftemplate;
     86  }
     87
     88  // filename = full_path ? prefix/template : template;
     89  if (!full_path) {
     90    Ntotal = strlen(prefix) + strlen(template) + 2;
     91    filename = (char *) malloc (Ntotal);
     92    snprintf (filename, Ntotal, "%s/%s", prefix, template);
     93    template = filename;
     94  }
     95
     96  if (make_directory) {
     97    if (mkdtemp (template) == -1) {
     98      if (!fail_silently) fprintf (stderr, "failed to make temp file from %s\n", template);
     99      exit (1);
     100    }
     101  } else {
     102    if (mkstemp (template) == -1) {
     103      if (!fail_silently) fprintf (stderr, "failed to make temp file from %s\n", template);
     104      exit (1);
     105    }
     106  }
     107
     108  fprintf (stdout, "%s\n", template);
    14109
    15110  exit (0);
    16111}
    17112 
     113usage() {
     114  fprintf (stderr, "Usage: mktemp [-V] | [-dqtu] [-p prefix] [template]\n");
     115  exit (1);
     116}
  • trunk/Ohana/src/uniphot/src/ConfigInit.c

    r12332 r25757  
    3636  /* XXX this does not yet write out the master photcode table */
    3737  sprintf (CatdirPhotcodeFile, "%s/Photcodes.dat", CATDIR);
    38   if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile)) {
     38  if (!LoadPhotcodes (CatdirPhotcodeFile, MasterPhotcodeFile, TRUE)) {
    3939    fprintf (stderr, "error loading photcode table %s or master file %s\n", CatdirPhotcodeFile, MasterPhotcodeFile);
    4040    exit (1);
Note: See TracChangeset for help on using the changeset viewer.