Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

Jog.hh

Go to the documentation of this file.
00001 #ifndef __JOG__H__
00002 #define __JOG__H__
00003 
00004 #include <Xm/Xm.h>
00005 #include <Xm/Frame.h>
00006 #include <Xm/Form.h>
00007 #include <Xm/PushB.h>
00008 #include <Xm/PushBP.h>
00009 #include <Xm/Separator.h>
00010 #include <X11/xpm.h>
00011 
00012 #ifdef DEBUG                    /* Allow cout */
00013 #include <iostream.h>
00014 #endif
00015 
00016 
00017 #ifdef JOG
00018 #include "GuiStrings.hh"
00019 #include "r_arrow.xpm"
00020 #include "r_arrow_in.xpm"
00021 #include "l_arrow.xpm"
00022 #include "l_arrow_in.xpm"
00023 #include "right_arrows.xpm"
00024 #include "right_arrows_in.xpm"
00025 #include "left_arrows.xpm"
00026 #include "left_arrows_in.xpm"
00027 
00028 static Widget arrowFrame = NULL;
00029 static Widget arrowForm = NULL;
00030 static Widget arrowB1[6] = { NULL };
00031 static Widget arrowB2[6] = { NULL };
00032 static Widget label[6] = { NULL };
00033 static Widget arrowB3[6] = { NULL };
00034 static Widget arrowB4[6] = { NULL };
00035 static Widget doneB = NULL;
00036 static Widget jogLabel = NULL;
00037 static Widget separator = NULL;
00038 
00039 static Pixmap r_pixmap;
00040 static Pixmap r_pixmap_in;
00041 static Pixmap l_pixmap;
00042 static Pixmap l_pixmap_in;
00043 
00044 static Pixmap rr_pixmap;
00045 static Pixmap rr_pixmap_in;
00046 static Pixmap ll_pixmap;
00047 static Pixmap ll_pixmap_in;
00048 
00049 const char *axesLabel[6] = {
00050   AXIS0_STR,
00051   AXIS1_STR,
00052   AXIS2_STR,
00053   AXIS3_STR,
00054   AXIS4_STR,
00055   AXIS5_STR,
00056 };
00057 
00058 static void buttonCB (Widget mw, XtPointer cd, XtPointer cb);
00059 static void unbuttonCB (Widget mw, XtPointer cd, XtPointer cb);
00060 static int whichAxis (Widget w, int type);
00061 static void do_jog (int theAxis, int type);
00062 static void stop_jog (int theAxis, int type);
00063 
00064 enum
00065 {
00066   ARROW_LEFT_FAST,
00067   ARROW_LEFT,
00068   ARROW_RIGHT,
00069   ARROW_RIGHT_FAST,
00070   DONE,
00071 };
00072 
00073 // Code sniplets
00074 
00075 #define CREATE_PIXMAP(xpm_name, pixmap_name) \
00076   do { \
00077   XpmCreatePixmapFromData (XtDisplay (arrowFrame), \
00078                            DefaultRootWindow (XtDisplay (arrowFrame)), \
00079                            xpm_name, &pixmap_name, 0, 0); \
00080   } while (0)
00081 
00082 #define SEPARATOR() \
00083   do { \
00084     separator = \
00085       XtVaCreateManagedWidget ("separator", xmSeparatorWidgetClass, arrowForm, \
00086                                XmNtopAttachment, XmATTACH_WIDGET, \
00087                                XmNtopWidget, arrowB1[i - 1], \
00088                                XmNtopOffset, 5, \
00089                                XmNbottomAttachment, XmATTACH_NONE, \
00090                                XmNleftAttachment, XmATTACH_FORM, \
00091                                XmNrightAttachment, XmATTACH_FORM, \
00092                                XmNmarginWidth, 5, XmNmarginHeight, 5, NULL); \
00093   } while (0)
00094 
00095 #define JOG_AXIS(arrow_widget, top_attach_type, left_attach_type, left_attach_widget, \
00096     arrow_pixmap, arrow_type) \
00097   do { \
00098    arrow_widget = \
00099     XtVaCreateManagedWidget ("arrowB", xmPushButtonWidgetClass, \
00100                              arrowForm, XmNtopAttachment, top_attach_type, \
00101                              XmNtopWidget, separator, XmNtopOffset, 5, \
00102                              XmNbottomAttachment, XmATTACH_NONE, \
00103                              XmNleftAttachment, left_attach_type, \
00104                              XmNleftWidget, left_attach_widget, XmNrightAttachment, \
00105                              XmATTACH_NONE, XmNwidth, 50, XmNheight, 50, \
00106                              XmNlabelPixmap, arrow_pixmap, XmNlabelType, \
00107                              XmPIXMAP, XmNmarginWidth, 0, XmNmarginHeight, \
00108                                  0, XmNshadowThickness, 0, NULL); \
00109       XtAddCallback (arrow_widget, XmNarmCallback, buttonCB, \
00110                      (XtPointer) arrow_type); \
00111       XtAddCallback (arrow_widget, XmNdisarmCallback, unbuttonCB, \
00112                      (XtPointer) arrow_type); \
00113   } while (0)
00114 
00115 #define LABEL_AXIS(k, top_attach_type) \
00116   do { \
00117       XmStringCharSet cs = (char *) XmSTRING_DEFAULT_CHARSET; \
00118       XFontStruct *newfont = NULL; \
00119       XmFontList fontlist = NULL; \
00120       if ((newfont = XLoadQueryFont (XtDisplay (arrowFrame), \
00121                                      "-adobe-courier-bold-r-normal--64-*-*-*-*-*-*-1")) \
00122           == NULL) \
00123         { \
00124           newfont = XLoadQueryFont (XtDisplay (arrowFrame), "fixed"); \
00125         } \
00126       fontlist = XmFontListCreate (newfont, cs); \
00127       XmString axisLabel = \
00128         XmStringCreateLtoR ((char *) axesLabel[k], XmSTRING_DEFAULT_CHARSET); \
00129       label[k] = \
00130         XtVaCreateManagedWidget ("label", xmLabelWidgetClass, arrowForm, \
00131                                  XmNtopAttachment, top_attach_type, \
00132                                  XmNtopWidget, separator, \
00133                                  XmNtopOffset, 5, \
00134                                  XmNbottomAttachment, XmATTACH_NONE, \
00135                                  XmNleftAttachment, XmATTACH_WIDGET, \
00136                                  XmNleftWidget, arrowB2[k], \
00137                                  XmNrightAttachment, XmATTACH_NONE, \
00138                                  XmNwidth, 50, \
00139                                  XmNheight, 50, \
00140                                  XmNfontList, fontlist, \
00141                                  XmNlabelString, axisLabel, NULL); \
00142       XmFontListFree (fontlist); \
00143       XUnloadFont (XtDisplay (arrowFrame), newfont->fid); \
00144       /* XFreeFont (XtDisplay (arrowFrame), newfont);  This produces BadFont error */ \
00145       XmStringFree (axisLabel); \
00146   } while (0)
00147 
00148 
00149 #endif
00150 
00151 extern void showRunMode (void);
00152 extern void hideRunMode (void);
00153 
00154 extern void jogDone (void);
00155 extern Widget
00156 JogControl (Dimension x0, Dimension x1, Dimension y1, Dimension y2,
00157             Dimension boxMarginWidth, Dimension boxMarginHeight,
00158             Widget parent, int numAxes);
00159 
00160 #endif //  __JOG__H__

Generated on Sun Dec 2 15:27:41 2001 for EMC by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001