IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 12, 2025, 5:00:47 PM (8 months ago)
Author:
eugene
Message:

fixes to cgrid for inverted regions; add features tdhistogram and region; free memory on exit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/section.c

    r31160 r42942  
    11# include "data.h"
    22
    3 enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL, BG, IMAGE};
     3enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL, BG, IMAGE, IMCENTER};
    44
    55int section (int argc, char **argv) {
     
    1717  }
    1818  if ((N = get_argument (argc, argv, "-up"))) {
     19    if (action != NONE) goto escape;
    1920    action = UP;
    2021    remove_argument (N, &argc, argv);
    2122  }
    2223  if ((N = get_argument (argc, argv, "-down"))) {
     24    if (action != NONE) goto escape;
    2325    action = DOWN;
    2426    remove_argument (N, &argc, argv);
    2527  }
    2628  if ((N = get_argument (argc, argv, "-top"))) {
     29    if (action != NONE) goto escape;
    2730    action = TOP;
    2831    remove_argument (N, &argc, argv);
    2932  }
    3033  if ((N = get_argument (argc, argv, "-bottom"))) {
     34    if (action != NONE) goto escape;
    3135    action = BOTTOM;
    3236    remove_argument (N, &argc, argv);
    3337  }
    3438  if ((N = get_argument (argc, argv, "-imtool"))) {
     39    if (action != NONE) goto escape;
    3540    action = TOOL;
    3641    remove_argument (N, &argc, argv);
     
    4146  background = -1; // invisible
    4247  if ((N = get_argument (argc, argv, "-bg"))) {
     48    if (action != NONE) goto escape;
    4349    remove_argument (N, &argc, argv);
    4450    if (!strcasecmp (argv[N], "NONE")) {
     
    5258
    5359  if ((N = get_argument (argc, argv, "-image"))) {
     60    if (action != NONE) goto escape;
    5461    remove_argument (N, &argc, argv);
    5562    action = IMAGE;
     63  }
     64
     65  if ((N = get_argument (argc, argv, "-imcenter"))) {
     66    if (action != NONE) goto escape;
     67    remove_argument (N, &argc, argv);
     68    action = IMCENTER;
    5669  }
    5770
     
    6578  FREE (name);
    6679
    67   /* list sections */
    68   if ((argc == 1) && (action == NONE)) {
    69     KapaGetSection (kapa, "*");
    70     gprint (GP_ERR, "USAGE: section name [x y dx dy] or [options]\n");
    71     gprint (GP_ERR, "OPTIONS: -list   : show properties of all sections\n");
    72     gprint (GP_ERR, "         -up     : move section up in display stack\n");
    73     gprint (GP_ERR, "         -down   : move section down in display stack\n");
    74     gprint (GP_ERR, "         -top    : move section to top of display stack\n");
    75     gprint (GP_ERR, "         -bottom : move section to bottom of display stack\n");
    76     gprint (GP_ERR, "         -imtool (position) : set location of image zoom / status box\n");
    77     gprint (GP_ERR, "                 (position may be: -x, +x, -y, +y, none)\n");
    78     gprint (GP_ERR, "         -image  : define section upper-right corner so image fills the section\n");
    79     gprint (GP_ERR, "         -bg (color) : set background color (see style -c help for color choices)\n");
    80    
    81     return (TRUE);
    82   }
    83  
    84   if ((argc != 2) && (action != NONE)) {
    85       gprint (GP_ERR, "can only use dash options without numbers\n");
     80  // deal with these cases first
     81  if (action == NONE) {
     82    if (argc == 1) { // command: section
     83      gprint (GP_ERR, "USAGE: section name x y dx dy\n");
     84      gprint (GP_ERR, "       section name -image x y\n");
     85      gprint (GP_ERR, "       section name [options]\n");
     86      gprint (GP_ERR, "OPTIONS: -list   : show properties of all sections\n");
     87      gprint (GP_ERR, "         -up     : move section up in display stack\n");
     88      gprint (GP_ERR, "         -down   : move section down in display stack\n");
     89      gprint (GP_ERR, "         -top    : move section to top of display stack\n");
     90      gprint (GP_ERR, "         -bottom : move section to bottom of display stack\n");
     91      gprint (GP_ERR, "         -imtool (position) : set location of image zoom / status box\n");
     92      gprint (GP_ERR, "                 (position may be: -x, +x, -y, +y, none)\n");
     93      gprint (GP_ERR, "         -image  : define section upper-right corner so image fills the section\n");
     94      gprint (GP_ERR, "         -bg (color) : set background color (see style -c help for color choices or use NONE)\n");
     95      return (TRUE);
     96    }
     97    if (argc == 2) { // command: section name
     98      KapaSelectSection (kapa, argv[1]);
     99      return TRUE;
     100    }
     101    if (argc == 6) { // command: section name x y dx dy
     102      /* set section */
     103      section.name = argv[1];
     104      section.x = atof (argv[2]);
     105      section.y = atof (argv[3]);
     106      section.dx = atof (argv[4]);
     107      section.dy = atof (argv[5]);
     108      section.bg = -2; // bg must be set on its own
     109      KapaSetSection (kapa, &section);
     110      return (TRUE);
     111    }
     112    goto escape;
     113  }
     114
     115  // list properties of the specified section, or all sections
     116  if (action == LIST) {
     117    if (argc == 1) {
     118      KapaGetSection (kapa, "*");
     119      return TRUE;
     120    }
     121    if (argc == 2) {
     122      KapaGetSection (kapa, argv[1]);
     123      KapaSelectSection (kapa, argv[1]);
     124      return TRUE;
     125    }
     126    goto escape;
     127  }
     128
     129  if ((action == IMAGE) || (action == IMCENTER)) {
     130    if (argc != 4) goto escape;
     131  } else {
     132    if (argc != 2) goto escape;
     133  }
     134
     135  /* select / show section */
     136  switch (action) {
     137    case UP:
     138      KapaMoveSection (kapa, argv[1], "up");
     139      break;
     140    case DOWN:
     141      KapaMoveSection (kapa, argv[1], "down");
     142      break;
     143    case TOP:
     144      KapaMoveSection (kapa, argv[1], "top");
     145      break;
     146    case BOTTOM:
     147      KapaMoveSection (kapa, argv[1], "bottom");
     148      break;
     149
     150    case BG:
     151      KapaSectionBG (kapa, argv[1], background);
     152      break;
     153
     154    case TOOL:
     155      KapaSelectSection (kapa, argv[1]);
     156      if (!strcmp(location, "-x")) {
     157        KapaSetToolbox (kapa, 1);
     158        break;
     159      }
     160      if (!strcmp(location, "+x")) {
     161        KapaSetToolbox (kapa, 3);
     162        break;
     163      }
     164      if (!strcmp(location, "-y")) {
     165        KapaSetToolbox (kapa, 2);
     166        break;
     167      }
     168      if (!strcmp(location, "+y")) {
     169        KapaSetToolbox (kapa, 4);
     170        break;
     171      }
     172      if (!strcmp(location, "none")) {
     173        KapaSetToolbox (kapa, 0);
     174        break;
     175      }
     176      gprint (GP_ERR, "unknown toolbox location %s\n", location);
     177      gprint (GP_ERR, "valid values: -x, +x, -y, +y, none\n");
    86178      return (FALSE);
    87   }
    88 
    89   if (argc == 2) {
    90     /* select / show section */
    91     switch (action) {
    92       case NONE:
    93         KapaSelectSection (kapa, argv[1]);
    94         break;
    95 
    96       case UP:
    97         KapaMoveSection (kapa, argv[1], "up");
    98         break;
    99       case DOWN:
    100         KapaMoveSection (kapa, argv[1], "down");
    101         break;
    102       case TOP:
    103         KapaMoveSection (kapa, argv[1], "top");
    104         break;
    105       case BOTTOM:
    106         KapaMoveSection (kapa, argv[1], "bottom");
    107         break;
    108 
    109       case BG:
    110         KapaSectionBG (kapa, argv[1], background);
    111         break;
    112 
    113       case TOOL:
    114         if (!strcmp(location, "-x")) {
    115           KapaSetToolbox (kapa, 1);
    116           break;
    117         }
    118         if (!strcmp(location, "+x")) {
    119           KapaSetToolbox (kapa, 3);
    120           break;
    121         }
    122         if (!strcmp(location, "-y")) {
    123           KapaSetToolbox (kapa, 2);
    124           break;
    125         }
    126         if (!strcmp(location, "+y")) {
    127           KapaSetToolbox (kapa, 4);
    128           break;
    129         }
    130         if (!strcmp(location, "none")) {
    131           KapaSetToolbox (kapa, 0);
    132           break;
    133         }
    134         gprint (GP_ERR, "unknown toolbox location %s\n", location);
    135         gprint (GP_ERR, "valid values: -x, +x, -y, +y, none\n");
    136         return (FALSE);
    137 
    138       case LIST:
    139         KapaGetSection (kapa, argv[1]);
    140         break;
    141     }
    142     return (TRUE);
    143   }
    144  
    145   if (argc == 4) {
    146     /* set section */
    147     section.name = argv[1];
    148     section.x = atof (argv[2]);
    149     section.y = atof (argv[3]);
    150     section.bg = background;
    151     KapaSetSectionByImage (kapa, &section);
    152     return (TRUE);
    153   }
    154 
    155   if (argc == 6) {
    156     /* set section */
    157     section.name = argv[1];
    158     section.x = atof (argv[2]);
    159     section.y = atof (argv[3]);
    160     section.dx = atof (argv[4]);
    161     section.dy = atof (argv[5]);
    162     section.bg = background;
    163     KapaSetSection (kapa, &section);
    164     return (TRUE);
    165   }
    166   gprint (GP_ERR, "USAGE: section name [x y dx dy]\n");
    167   gprint (GP_ERR, "USAGE: section name [-image x y] : width based on current image\n");
    168   gprint (GP_ERR, "USAGE: section name [-list] [-up] [-down] [-top] [-bottom]\n");
     179
     180    case IMAGE:
     181      /* set section */
     182      section.name = argv[1];
     183      section.x = atof (argv[2]);
     184      section.y = atof (argv[3]);
     185      section.bg = -2;
     186      KapaSetSectionByImage (kapa, &section);
     187      return (TRUE);
     188
     189    case IMCENTER:
     190      /* set section */
     191      section.name = argv[1];
     192      section.x = atof (argv[2]);
     193      section.y = atof (argv[3]);
     194      KapaSetSectionCenterByImage (kapa, &section);
     195      return (TRUE);
     196
     197    case NONE:
     198    case LIST:
     199    default:
     200      gprint (GP_ERR, "oops, programming error in section.c:171\n");
     201      break;
     202  }
     203  return (TRUE);
     204
     205escape:
     206  gprint (GP_ERR, "USAGE: section name : select the section\n");
     207  gprint (GP_ERR, "USAGE: section name x y dx dy : define section location\n");
     208  gprint (GP_ERR, "USAGE: section name -image x y : width based on current image\n");
     209  gprint (GP_ERR, "USAGE: section name -imtool (position) : width based on current image\n");
     210  gprint (GP_ERR, "USAGE: section name [-list] [-up] [-down] [-top] [-bottom] [-bg color]\n");
     211  gprint (GP_ERR, "  only one -OPTION at a time\n");
    169212  return (FALSE);
    170213}
Note: See TracChangeset for help on using the changeset viewer.