Beispiel #1
0
/*-------------------------------------------------------------------------*/
void qmonSetCE_Type(
Widget w,
lList *lp,
int full 
) {
   lListElem *ep;
   int row;
   int max_rows;
   const char *ce_entry[CE_MAX];
   int i;
   
   DENTER(GUI_LAYER, "qmonSetCE_Type");
   
   XtVaGetValues(w, XmNrows, &max_rows, NULL);
   
   /* clear the area */
   XtVaSetValues(w, XmNcells, NULL, NULL);
   
   for (ep = lFirst(lp), row = 0; ep; ep = lNext(ep), row++) {
      if (row == max_rows) {
         XbaeMatrixAddRows(w, 
                           max_rows, 
                           NULL,       /* empty rows  */
                           NULL,       /* no lables   */
                           NULL,       /* no different colors */
                           1);         /* we add 1 row */
         max_rows++;
      }
      if (getCE_TypeValues(ep, ce_entry)) {
         if (full) {
            for (i=0; i<CE_MAX; i++) {
               /* FIX_CONST_GUI */
               XbaeMatrixSetCell(w, row, i, 
                  ce_entry[i] ? (String)ce_entry[i] : "");
            }
         }
         else {
            /* FIX_CONST_GUI */
            XbaeMatrixSetCell(w, row, 0, 
               ce_entry[CE_NAME] ? (String)ce_entry[CE_NAME] : "");
            /* FIX_CONST_GUI */
            XbaeMatrixSetCell(w, row, 1, 
               ce_entry[CE_TYPE] ? (String)ce_entry[CE_TYPE] : "");
            /* FIX_CONST_GUI */
            XbaeMatrixSetCell(w, row, 2, 
               ce_entry[CE_RELOP] ? (String)ce_entry[CE_RELOP] : "");
         }
      }
      else
         DPRINTF(("qmonSetCE_Type failure\n"));
   }
       
   DEXIT;
}
Beispiel #2
0
void matrix_row(int *ievt, struct dsc$descriptor_s *row_dsc)
{
   char *row = row_dsc->dsc$a_pointer;
#else
void matrix_row(int *ievt, char *row)
{
#endif
   int      i;
   char   **rows, **evt, *s, lab[MAXLAB+1];
   static int cur_event;

   if (!matrix) return;

   /* when scan command finished it calls this routine with *ievt = -1 */
   if (*ievt == -1) {
      if (nrows == 0)
         km_inform_user(matrix, "No events satisfied the imposed cuts.", "");
      if (reverse_order) {
         s = XtCalloc(MAX_STRING, 1);
         sprintf(s, "%d", cur_event);
         XmTextSetString(firstScText, s);
         if (cur_event == 1)
            XtSetSensitive(previousScButton, False);
         XtFree(s);
      }
      return;
   }

   if (nrows >= max_rows) {
      *ievt = -1;
      return;
   }

   s  = row;

   rows = (char **) XtMalloc(ncols * sizeof(char *));
   evt  = (char **) XtMalloc(1 * sizeof(char *));

   for (i = 0; i < ncols; i++) {
      strncpy(lab, s, MAXLAB); lab[MAXLAB] = '\0';
      rows[i] = km_strip(lab);
      s      += MAXLAB;
   }

   cur_event = *ievt;
   evt[0] = XtMalloc(10);
   sprintf(evt[0], "%d", *ievt);

   if (!nrows) {

      for (i = 0; i < ncols; i++)
         XbaeMatrixSetCell(matrix, 0, i, rows[i]);

      XtVaSetValues(matrix, XmNrowLabels, evt, NULL);
      last_event = *ievt;

   } else {

      if (reverse_order)
         /* Scan the events in reverse order and add matrix element */
         /* from bottom to top */
         XbaeMatrixAddRows(matrix, 0, rows, evt, NULL, 1);
      else {
         /* Scan the events in normal order and add matrix element */
         /* from top to bottom */
         XbaeMatrixAddRows(matrix, nrows, rows, evt, NULL, 1);
         last_event = *ievt;
      }

   }

   nrows++;

   for (i = 0; i < ncols; i++)
      XtFree(rows[i]);
   XtFree(evt[0]);

   XtFree((char *) rows);
   XtFree((char *) evt);
}
Beispiel #3
0
void matrix_label(struct dsc$descriptor_s *label_dsc, int *nlab)
{
   char *label = label_dsc->dsc$a_pointer;
#else
void matrix_label(char *label, int *nlab)
{
#endif
   Widget   clip;
   int      i, old_nrows;
   char   **labels, **rlab, *s, lab[MAXLAB+1];
   unsigned char *ca;
   short   *cw;

   if (ntuple_id == 0) return;

   ncols     = *nlab;
   old_nrows = nrows;
   nrows     = 0;
   s         = label;

   labels = (char **) XtMalloc(ncols * sizeof(char *));
   rlab   = (char **) XtMalloc(1 * sizeof(char *));
   cw     = (short *) XtMalloc(ncols * sizeof(short));
   ca     = (unsigned char *) XtMalloc(ncols * sizeof(unsigned char));

   for (i = 0; i < ncols; i++) {
      strncpy(lab, s, MAXLAB); lab[MAXLAB] = '\0';
      labels[i] = km_strip(lab);
      cw[i]     = 15;
      ca[i]     = XmALIGNMENT_CENTER;
      s        += MAXLAB;
   }

   /* empty row label */
   rlab[0] = XtMalloc(2);
   strcpy(rlab[0], " ");

   if (!matrix) {
      /*
       * Create a Matrix widget
       */
      matrix = XtVaCreateManagedWidget("matrix",
                                xbaeMatrixWidgetClass,    ntupleScan,
                                XmNleftOffset,            5,
                                XmNleftAttachment,        XmATTACH_FORM,
                                XmNrightOffset,           5,
                                XmNrightAttachment,       XmATTACH_FORM,
                                XmNtopWidget,             separatorGadget5,
                                XmNtopOffset,             5,
                                XmNtopAttachment,         XmATTACH_WIDGET,
                                XmNbottomWidget,          separatorGadget4,
                                XmNbottomOffset,          5,
                                XmNbottomAttachment,      XmATTACH_WIDGET,
                                XmNcolumnLabels,          labels,
                                XmNcolumnWidths,          cw,
                                XmNcolumnLabelAlignments, ca,
                                XmNcolumns,               ncols,
                                XmNrowLabels,             rlab,
                                XmNrowLabelWidth,         (short) 6,
                                XmNrows,                  1,
                                NULL);

      /* overridebtranslation table, also for clip widget */
      XtOverrideTranslations(matrix,
                             XtParseTranslationTable(translation_table));
      clip = XtNameToWidget(matrix, "clip");
      if (clip)
         XtOverrideTranslations(clip,
                                XtParseTranslationTable(translation_table));

      /* install some callbacks */
      XtAddCallback(matrix, XmNenterCellCallback,
                 (XtCallbackProc)matrix_enter_cb, NULL);
      XtAddCallback(matrix, XmNselectCellCallback,
                 (XtCallbackProc)matrix_select_cb, NULL);
   } else {

      XbaeMatrixDeleteRows(matrix, 1, old_nrows-1);
      for (i = 0; i < ncols; i++)
         XbaeMatrixSetCell(matrix, 0, i, " ");

      XtVaSetValues(matrix, XmNrowLabels, rlab, NULL);

   }

   for (i = 0; i < ncols; i++)
      XtFree(labels[i]);
   XtFree(rlab[0]);

   XtFree((char *) labels);
   XtFree((char *) rlab);
   XtFree((char *) cw);
   XtFree((char *) ca);
}
Beispiel #4
0
/*-------------------------------------------------------------------------*/
void qmonSet2xN(
Widget w,
lList *lp,
int field1,
int field2 
) {
   lListElem *ep;
   int row;
   int max_rows;
   const char *col1 = NULL, *col2 = NULL;
   int val;
   double dval;
   char buf[128];
   
   DENTER(GUI_LAYER, "qmonSet2xN");
   
   /* clear the area */
   XtVaSetValues(w, XmNcells, NULL, NULL);
   
   if (!lp) {
      DEXIT;
      return;
   }
      
   XtVaGetValues(w, XmNrows, &max_rows, NULL);

   for (ep = lFirst(lp), row = 0; ep; ep = lNext(ep), row++) {
      if (row == max_rows) {
         XbaeMatrixAddRows(w, 
                           max_rows, 
                           NULL,       /* empty rows  */
                           NULL,       /* no lables   */
                           NULL,       /* no different colors */
                           1);         /* we add 1 rows      */
         max_rows++;
      }
      /*
      ** the first column of the matrix can be string or host type
      **
      */
      switch (lGetType(lGetListDescr(lp), field1)) {
         case lStringT:
            col1 = (StringConst)lGetString(ep, field1);
            break;
         case lHostT:
            col1 = (StringConst)lGetHost(ep,field1);
            break;
      }
      /*
      ** the second column can be of different type
      */
      switch (lGetType(lGetListDescr(lp), field2)) {
         case lStringT:
            col2 = (StringConst)lGetString(ep, field2);
            break;
         case lHostT:
            col2 = (StringConst)lGetHost(ep,field2);
            break;
         case lUlongT:
            val = (int)lGetUlong(ep, field2);
            if (val) {
               sprintf(buf, "%d", val);
               col2 = buf;
            }
            else
               col2 = NULL;
            break;
         case lDoubleT:
            dval = lGetDouble(ep, field2);
            sprintf(buf, "%.2f", dval);
            col2 = buf;
            break;
      }

      if (col1) {
         /* FIX_CONST_GUI */
         XbaeMatrixSetCell(w, row, 0 , col1 ? (String)col1 : "");
         /* FIX_CONST_GUI */
         XbaeMatrixSetCell(w, row, 1 , col2 ? (String)col2 : "");
      }
   }
       
   DEXIT;
}
Beispiel #5
0
/*-------------------------------------------------------------------------*/
void qmonSetNxN(Widget w, lList *lp, int num_fields, ...)
{
   lListElem *ep;
   int i, row;
   int max_rows;
   int val;
   double dval;
   char buf[128];
   int *field;
   const char **col;
   va_list ap;
   
   DENTER(GUI_LAYER, "qmonSetNxN");
   
   /* clear the area */
   XtVaSetValues(w, XmNcells, NULL, NULL);
   
   if (!lp)
   {
      DEXIT;
      return;
   }

   field = malloc(num_fields*sizeof(int));
   col   = malloc(num_fields*sizeof(char *));
   if (field == NULL || col == NULL)
      abort();

   va_start(ap, num_fields);
   for(i=0; i<num_fields; i++)
      field[i] = va_arg(ap, int);

   XtVaGetValues(w, XmNrows, &max_rows, NULL);

   for (ep = lFirst(lp), row = 0; ep; ep = lNext(ep), row++)
   {
      if (row == max_rows)
      {
         XbaeMatrixAddRows(w, 
                           max_rows, 
                           NULL,       /* empty rows  */
                           NULL,       /* no lables   */
                           NULL,       /* no different colors */
                           1);         /* we add 1 rows      */
         max_rows++;
      }

      memset(col, 0, num_fields*sizeof(char *));

      /*
       * get column values
       */

      for(i=0; i<num_fields; i++)
      {
         switch (lGetType(lGetListDescr(lp), field[i]))
         {
            case lStringT:
               col[i] = (StringConst)lGetString(ep, field[i]);
               break;
            case lHostT:
               col[i] = (StringConst)lGetHost(ep,field[i]);
               break;
            case lUlongT:
               val = (int)lGetUlong(ep, field[i]);
#if 0
               if (val) {
                  sprintf(buf, "%d", val);
                  col[i] = buf;
               }
               else
                  col[i] = NULL;
#else
               sprintf(buf, "%d", val);
               col[i] = buf;
#endif
               break;
            case lDoubleT:
               dval = lGetDouble(ep, field[i]);
               sprintf(buf, "%.2f", dval);
               col[i] = buf;
               break;
         }
      }

      if (col[0])
      {
         /* FIX_CONST_GUI */
         for(i=0; i<num_fields; i++)
            XbaeMatrixSetCell(w, row, i, col[i] ? (String)col[i] : "");
      }
   }

   va_end(ap);
   free(field);
   free(col);
       
   DEXIT;
}