IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13404


Ignore:
Timestamp:
May 16, 2007, 4:00:06 PM (19 years ago)
Author:
eugene
Message:

asserting libkapa API, adding section and erase commands

Location:
branches/kapa-mods-2007-05/Ohana/src
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • branches/kapa-mods-2007-05/Ohana/src/addstar/src/SEDops.c

    r8361 r13404  
    111111  graphdata.style = 2;
    112112  graphdata.ptype = 2;
    113   KapaClear (Xgraph, TRUE);
     113  KapaClearSections (Xgraph);
    114114  magSection.name = strcreate ("mag");
    115115  magSection.x  = 0;
     
    156156  SWAP (graphdata.ymin, graphdata.ymax);
    157157
    158   KapaClear (Xgraph, TRUE);
     158  KapaClearSections (Xgraph);
    159159  KapaSetSection (Xgraph, &magSection);
    160160  KapaSetLimits (Xgraph, &graphdata);
  • branches/kapa-mods-2007-05/Ohana/src/gastro/src/plotstuff.c

    r13402 r13404  
    3636void PrepPlotting (int Npts, Graphdata *graphmode, int N) {
    3737
     38  if (Xgraph[N] == 0) return;
     39
    3840  active = N;
    3941  if (Npts < 1) return;
     
    6365 
    6466  if (Xgraph[N] < 1) if (!open_graph(N)) return;
    65   KapaClear (Xgraph[N], TRUE);
     67  KapaClearSections (Xgraph[N]);
    6668}
    6769
  • branches/kapa-mods-2007-05/Ohana/src/gastro2/src/plotstuff.c

    r13402 r13404  
    2828
    2929void DonePlotting (Graphdata *graphmode, int N) {
    30   char buffer[65], buffer2[65];
    3130
     31  if (Xgraph[N] == 0) return;
    3232  KapaBox (Xgraph[N], graphmode);
     33  return;
    3334}
    3435
    3536void PrepPlotting (int Npts, Graphdata *graphmode, int N) {
    3637
    37   int i, status;
    38   char buffer[128], buffer2[128];
     38  if (Xgraph[N] == 0) return;
    3939
    4040  active = N;
     
    6565 
    6666  if (Xgraph[N] < 1) if (!open_graph(N)) return;
    67   KapaClear (Xgraph[N], TRUE);
     67  KapaClearSections (Xgraph[N]);
    6868}
    6969
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/include/prototypes.h

    r13402 r13404  
    5656int           SetSection          PROTO((int sock));
    5757int           ListSection         PROTO((int sock));
     58int           MoveSection         PROTO((int sock));
    5859int           DefineSection       PROTO((int sock));
    5960int           SetFont             PROTO((int sock));
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/src/CheckPipe.c

    r13402 r13404  
    142142  }
    143143 
     144  if (!strcmp (word, "MSEC")) {
     145    status = MoveSection (sock);
     146    KiiSendCommand (sock, 4, "DONE");
     147    return (TRUE);
     148  }
     149 
    144150  if (!strcmp (word, "FONT")) {
    145151    status = SetFont (sock);
  • branches/kapa-mods-2007-05/Ohana/src/kapa2/src/Sections.c

    r13401 r13404  
    154154    return;
    155155}
     156
     157// return TRUE even for nonsense cases to avoid quitting kapa
     158int MoveSection (int sock) {
     159
     160  char name[128];
     161  char direction[16];
     162  Section *tmpSection = NULL;
     163
     164  KiiScanMessage (sock, "%s %s", name, direction);
     165 
     166  N = GetSectionByName (name);
     167  if (N < 0) {
     168    fprintf (stderr, "section %s not found\n", name);
     169    return (TRUE);
     170  }
     171
     172  if (!strcasecmp (direction, "up")) {
     173      if (N < 0) return (TRUE);
     174      if (N > Nsections - 2) return (TRUE);
     175      tmpSection = sections[N];
     176      sections[N] = sections[N+1];
     177      sections[N] = tmpSection;
     178      Refresh (1);
     179      return (TRUE);
     180  }
     181
     182  if (!strcasecmp (direction, "down")) {
     183      if (N < 1) return (TRUE);
     184      if (N > Nsections - 1) return (TRUE);
     185      tmpSection = sections[N];
     186      sections[N] = sections[N-1];
     187      sections[N] = tmpSection;
     188      Refresh (1);
     189      return (TRUE);
     190  }
     191
     192  if (!strcasecmp (direction, "top")) {
     193      if (N < 0) return (TRUE);
     194      if (N > Nsections - 2) return (TRUE);
     195      tmpSection = sections[N];
     196      for (i = N; i < Nsections - 1; i++) {
     197        sections[i] = sections[i+1];
     198      }
     199      sections[i] = tmpSection;
     200      Refresh (1);
     201      return (TRUE);
     202  }
     203
     204  if (!strcasecmp (direction, "bottom")) {
     205      if (N < 1) return (TRUE);
     206      if (N > Nsections - 1) return (TRUE);
     207      tmpSection = sections[N];
     208      for (i = N; i >= 1; i--) {
     209        sections[i] = sections[i-1];
     210      }
     211      sections[i] = tmpSection;
     212      Refresh (1);
     213      return (TRUE);
     214  }
     215  fprintf (stderr, "unknown direction %s for MoveSection\n", direction);
     216  return (TRUE);
     217}
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/doc/api.txt

    r13402 r13404  
    1717SLIM | SetLimits        | KapaWindow.c  | KapaSetLimits
    1818DSEC | DefineSection    | KapaWindow.c  | KapaSetSection
     19MSEC | MoveSection      | KapaWindow.c  | KapaMoveSection
    1920CENT | Center           | KapaWindow.c  | KiiCenter
    2021QUIT | Quit             | KiiOpen.c     | KiiClose
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/include/kapa.h

    r13402 r13404  
    154154int KapaSelectSection (int fd, char *name);
    155155int KapaGetSection (int fd, char *name);
     156int KapaMoveSection (int fd, KapaSection *section, char *direction);
    156157
    157158/* KapaColors */
  • branches/kapa-mods-2007-05/Ohana/src/libkapa/src/KapaWindow.c

    r13402 r13404  
    240240}
    241241
     242int KapaMoveSection (int fd, char *name, char *direction) {
     243
     244  if (!strcasecmp(direction, "up")) goto valid;
     245  if (!strcasecmp(direction, "down")) goto valid;
     246  if (!strcasecmp(direction, "top")) goto valid;
     247  if (!strcasecmp(direction, "bottom")) goto valid;
     248 
     249  fprintf (stderr, "unexpected direction %s\n", direction);
     250  return (FALSE);
     251
     252valid:
     253  KiiSendCommand (fd, 4, "MSEC");
     254  KiiSendMessage (fd, "%s %s", name, direction);
     255  KiiScanCommand (fd, 4, "%s", word);
     256  if (strcmp (word, "DONE")) {
     257      fprintf (stderr, "unexpected response %s\n", word);
     258      return (FALSE);
     259  }
     260 
     261  return (TRUE);
     262}
     263
    242264int KapaSelectSection (int fd, char *name) {
    243265
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.astro/region.c

    r13402 r13404  
    107107  graphmode.coords.cdelt1 = graphmode.coords.cdelt2 = 1.0;
    108108
    109   KapaClear (kapa, TRUE);
     109  KapaClearSections (kapa);
    110110  KapaSetLimits (kapa, &graphmode);
    111111
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/clear.c

    r13391 r13404  
    11# include "data.h"
    22
     3// default is to clear all plots, but not the sections or the images
    34int clear (int argc, char **argv) {
    45 
    5   int N, ClearSection;
     6  int N;
    67  int kapa;
    78  char *name;
     
    1617  FREE (name);
    1718
    18   /* XXX need to distinguish between Plot, AllPlots, Image, AllSections */
    19   ClearSection = FALSE;
    20   if ((N = get_argument (argc, argv, "-s"))) {
    21     remove_argument (N, &argc, argv);
    22     ClearSection = TRUE;
     19  // clear all sections
     20  if ((N = get_argument (argc, argv, "-s")) ||
     21      (N = get_argument (argc, argv, "-section"))) {
     22      KapaClearSections (kapa);
     23      return (TRUE);
     24  }
     25
     26  // clear all sections
     27  if ((N = get_argument (argc, argv, "-graph"))) {
     28      KapaClearCurrentPlot (kapa);
     29      return (TRUE);
     30  }
     31
     32  // clear image
     33  if ((N = get_argument (argc, argv, "-image"))) {
     34      KapaClearImage (kapa);
     35      return (TRUE);
    2336  }
    2437
    2538  if (argc != 1) {
    26     gprint (GP_ERR, "USAGE: clear [-n Xgraph]\n");
     39    gprint (GP_ERR, "USAGE: clear [-n Xgraph] [-s|-section] [-image] [-graph]\n");
     40    gprint (GP_ERR, "       [-s|-section] : clear all sections\n");
     41    gprint (GP_ERR, "       [-graph]      : clear current graph\n");
     42    gprint (GP_ERR, "       [-image]      : clear current image\n");
    2743    return (FALSE);
    2844  }
    2945
    30   KapaClear (kapa, ClearSection);
     46  KapaClearPlots (kapa);
    3147  return (TRUE);
    3248}
  • branches/kapa-mods-2007-05/Ohana/src/opihi/cmd.data/section.c

    r13391 r13404  
    11# include "data.h"
     2
     3enum {NONE, LIST, UP, DOWN, TOP, BOTTOM};
    24
    35int section (int argc, char **argv) {
    46 
    5   int N, List;
     7  int N, action;
    68  int kapa;
    79  char *name;
     
    911  KapaSection section;
    1012
    11   List = FALSE;
     13  action = NONE;
    1214  if ((N = get_argument (argc, argv, "-list"))) {
    1315    remove_argument (N, &argc, argv);
    14     List = TRUE;
     16    action = LIST;
     17  }
     18  if ((N = get_argument (argc, argv, "-up"))) {
     19    remove_argument (N, &argc, argv);
     20    action = UP;
     21  }
     22  if ((N = get_argument (argc, argv, "-down"))) {
     23    remove_argument (N, &argc, argv);
     24    action = DOWN;
     25  }
     26  if ((N = get_argument (argc, argv, "-top"))) {
     27    remove_argument (N, &argc, argv);
     28    action = TOP;
     29  }
     30  if ((N = get_argument (argc, argv, "-bottom"))) {
     31    remove_argument (N, &argc, argv);
     32    action = BOTTOM;
    1533  }
    1634
     
    2846    KapaGetSection (kapa, "*");
    2947    gprint (GP_ERR, "USAGE: section name [x y dx dy]\n");
     48    gprint (GP_ERR, "USAGE: section name [-list] [-up] [-down] [-top] [-bottom]\n");
    3049    return (TRUE);
    3150  }
     
    3352  if (argc == 2) {
    3453    /* select / show section */
    35     if (List) {
    36       KapaGetSection (kapa, argv[1]);
    37     } else {
    38       KapaSelectSection (kapa, argv[1]);
     54    switch (action) {
     55      case NONE:
     56        KapaSelectSection (kapa, argv[1]);
     57        break;
     58
     59      case UP:
     60        KapaMoveSection (kapa, argv[1], "up");
     61        break;
     62      case DOWN:
     63        KapaMoveSection (kapa, argv[1], "down");
     64        break;
     65      case TOP:
     66        KapaMoveSection (kapa, argv[1], "top");
     67        break;
     68      case BOTTOM:
     69        KapaMoveSection (kapa, argv[1], "bottom");
     70        break;
     71
     72      case LIST:
     73        KapaGetSection (kapa, argv[1]);
     74        break;
    3975    }
    4076    return (TRUE);
     
    5288  }
    5389  gprint (GP_ERR, "USAGE: section name [x y dx dy]\n");
     90  gprint (GP_ERR, "USAGE: section name [-list] [-up] [-down] [-top] [-bottom]\n");
    5491  return (FALSE);
    5592}
  • branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/fitcolors.c

    r13391 r13404  
    9595    graphdata.style = 2;
    9696    graphdata.ptype = 2;
    97     KapaClear (kapa, TRUE);
     97    KapaClearSections (kapa);
    9898    KapaSetFont (kapa, "helvetica", 14);
    9999
     
    337337            sprintf (filename, "%s.%02d.png", plotname, Nplot);
    338338            KapaPNG (kapa, filename);
    339             KapaClear (kapa, TRUE);
     339            KapaClearSections (kapa);
    340340            Nplot++;
    341341          }
  • branches/kapa-mods-2007-05/Ohana/src/opihi/dvo/fitsed.c

    r13391 r13404  
    161161    graphdata.style = 2;
    162162    graphdata.ptype = 2;
    163     KapaClear (kapa, TRUE);
     163    KapaClearSections (kapa);
    164164    magSection.name = strcreate ("mag");
    165165    magSection.x  = 0;
     
    261261        SWAP (graphdata.ymin, graphdata.ymax);
    262262
    263         KapaClear (kapa, TRUE);
     263        KapaClearSections (kapa);
    264264        KapaSetSection (kapa, &magSection);
    265265        KapaSetLimits (kapa, &graphdata);
  • branches/kapa-mods-2007-05/Ohana/src/relastro/src/plotstuff.c

    r13402 r13404  
    6363  if (Xgraph[N] < 1) if (!open_graph(N)) return;
    6464
    65   KapaClear (Xgraph[N], TRUE);
     65  KapaClearSections (Xgraph[N]);
    6666
    6767  KapaPrepPlot (Xgraph[N], Npts, graphmode);
  • branches/kapa-mods-2007-05/Ohana/src/relphot/src/plotstuff.c

    r13402 r13404  
    6363  if (Xgraph[N] < 1) if (!open_graph(N)) return;
    6464
    65   KapaClear (Xgraph[N], TRUE);
     65  KapaClearSections (Xgraph[N]);
    6666
    6767  KapaPrepPlot (Xgraph[N], Npts, graphmode);
  • branches/kapa-mods-2007-05/Ohana/src/uniphot/src/plotstuff.c

    r13402 r13404  
    7272 
    7373  if (Xgraph[N] < 1) if (!open_graph(N)) return;
    74   KapaClear (Xgraph[N], TRUE);
     74  KapaClearSections (Xgraph[N]);
    7575}
    7676
Note: See TracChangeset for help on using the changeset viewer.