⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mfb.0

📁 spice中支持多层次元件模型仿真的可单独运行的插件源码
💻 0
📖 第 1 页 / 共 5 页
字号:
     #ifndef vms         /* graphics device ttyb struct */         MFBSAVETTYB graphTtyb;         /* keyboard ttyb struct if graphics device does not have a kybrd */         MFBSAVETTYB kybrdTtyb;         /* tty status ints */         MFBSAVESTAT oldstat;     #endif         /*          * CHARACTERS          */         char deviceType;                /* TTY=tty, HCOPY=hard copy */         char strBuf[BUFSIZE];           /* storage for format strings */         char ttyBuffer[TTYBUFSIZE];     /* tty output buffer */         };     typedef struct mfb MFB;226/21/83                                                    MFB(3)EXAMPLE     The following C program is a simple example that uses     several _M_F_B routines.  The terminal type is assumed to be     the first command line argument.  This program will display     several triangles in different line styles, display at four     angles of rotation the text that is returned from _M_F_B_K_e_y_-     _b_o_a_r_d, draw a solid line between two points, and draw an arc     clipped to a rectangle.          #include <cad/mfb.h>          main(argc, argv)              int argc;              char *argv[];              {              int i, j, k, m;              int X1, X2, Y1, Y2;              int numcolors;              int numlinestyles;              int button;              int error;              MFB *mfb, *MFBOpen();              MFBPATH *pp;              char key;              char *TypeIn;              /* open graphics device */              mfb = MFBOpen(argv[1], NULL, &error);              /* exit on any error */              if(error < 0) {                  fprintf(stderr, "error:  %s\n", MFBError(error));                  exit(0);                  }              /* get device information */              X1 = MFBInfo(MAXX)/2;              X2 = X1/2;              Y1 = MFBInfo(MAXY)/30;              numcolors = MFBInfo(MAXCOLORS);              numlinestyles = MFBInfo(MAXLINESTYLES);              if(numcolors > 7)                  numcolors = 7;              if(numlinestyles > 7)                  numlinestyles = 7;                                                               23MFB(3)                                                    6/21/83              /* draw pyramid of lines in different line styles */              for(j=0; j<28; ++j) {                  /* set color (increment by one to prevent 'invisible' lines) */                  k = j % (numcolors - 1);                  MFBSetColor(k + 1);                  /* define and set line style */                  m = j % numlinestyles;                  MFBDefineLineStyle(m, j * 6);                  MFBSetLineStyle(m);                  /* draw pyramid */                  MFBLine(0, 0, X2, Y1*j + 2*j);                  MFBLine(X1, 0, X2, Y1*j + 2*j);                  }              /* flush output */              MFBUpdate();              /* test of MFBKeyboard */              MFBText("Test of MFBKeyboard.", X2, Y1*28, 0);              TypeIn = MFBKeyboard(X1, 5, 0, 1);              MFBText(TypeIn, X1, 70, 0);              MFBText(TypeIn, X1, 70, 90);              MFBText(TypeIn, X1, 70, 180);              MFBText(TypeIn, X1, 70, 270);              MFBUpdate();              sleep(3);              /* test of MFBPoint */              MFBSetColor(1);              MFBFlood();              MFBSetColor(0);              MFBText("Test of MFBPoint.", X2, Y1*28, 0);              MFBPoint(&X1, &Y1, &key, &button);              MFBPoint(&X2, &Y2, &key, &button);              MFBSetLineStyle(0);              MFBLine(X1, Y1, X2, Y2);              /* draw outline of box to contain arc */              MFBLine(100, 100, 100, 350);              MFBLine(100, 100, 370, 100);              MFBLine(370, 100, 370, 350);              MFBLine(100, 350, 370, 350);              /* test of MFBArcPath and MFBClipArc */              i = 0;              pp = MFBClipArc(MFBArcPath(70, 70, 200, 0, 0, 30), 100, 100, 370, 350);              while(pp[i].nvertices != 0 && i < 4) {                  MFBDrawPath(&pp[i]);                  i++;                  }246/21/83                                                    MFB(3)              /* flush output and wait */              MFBUpdate();              sleep(6);              MFBClose();              }DEBOUNCING THE POINTING DEVICE     The following C program is another example of using _M_F_B rou-     tines that demonstrates several methods of debouncing the     pointing device.  Several graphics terminals can return     bogus pointing reports that can be serious and annoying in     some applications.  Identifying these bogus reports is very     terminal dependent (e.g. the AED 512 returns bad button     masks, the Metheus 400 returns negative coordinates, etc.),     and it is therefore necessary to use all possible tests.          #include <cad/mfb.h>          #ifdef vms          #include <timeb.h>          #else          #include <sys/timeb.h>          #endif          /*           * This is the minimum time in milliseconds           * between accepted pointing events.           */          #define DEBOUNCETIME 100          /*           * we keep track of the time between pointing           * events to debounce the cursor           */          static long LastPointTime = 0;          /*           * routine to read and debounce pointing device.           */          point(pointX,pointY,Key,Mask)              int *pointX,*pointY,*Mask;              char *Key;              {              struct timeb now;              long newtime;              int X,Y,Buttons;              char KeyTyped;                                                               25MFB(3)                                                    6/21/83              SetDebounceTime();              /* Loop until DEBOUNCETIME has passed */              while(True) {                  /* Loop until valid report is received */                  while(True) {                      /* Get pointing event */                      MFBPoint(&X,&Y,&KeyTyped,&Buttons);                      /* Was a character typed? */                      if(Key != 0)                          break;                      /* Does the pointing device have buttons? */                      if(MFBInfo(POINTINGBUTTONS)){                          /*                           * Test button masks and vicinity of coordinate.                           * Assume a four button mouse.                           */                          if((Buttons == MFBInfo(BUTTON1) ||                              Buttons == MFBInfo(BUTTON2) ||                              Buttons == MFBInfo(BUTTON3) ||                              Buttons == MFBInfo(BUTTON4)) &&                              (X < MFBInfo(MAXX) && X > 0 &&                              Y < MFBInfo(MAXY) && Y > 0))                              break;                          }                      }                  ftime(&now);                  newtime = 1000 * now.time + now.millitm;                  if((newtime - LastPointTime) < DEBOUNCETIME) continue;                  SetDebounceTime();                  }              *pointX = X;              *pointY = Y;              *Key = KeyTyped;              *Mask = Buttons;              }          SetDebounceTime(){              struct timeb now;              ftime(&now);              LastPointTime = 1000 * now.time + now.millitm;              }266/21/83                                                    MFB(3)NOTES     On some systems, _M_F_B is contained in /usr rather than ~cad.     _M_F_B will also compile to run under _V_M_S (a trademark of Digi-     tal Equipment Corp.) or any other operating system.  How-     ever, special I/O routines such as those in     ~cad/src/mfb/vmsio.c must be provided for _M_F_B to function     properly.     _M_F_B was written to be utmost UNIX compatible and consistent     with the style of the C programming language.  For example,     a control sequence always begins with a call to an (_M_F_B)_O_p_e_n     routine and is terminated by a call to a (_M_F_B)_C_l_o_s_e routine.     Another example is the provision of the _M_F_B_H_a_l_t routine that     is intended primarily for the handling of the SIGTSTP sig-     nal.  One possible exception to the style of C is the use of     a global output descriptor that is set by a call to the     _S_e_t_C_u_r_r_e_n_t_M_F_B routine, as opposed to passing the output     descriptor as an argument to ever active function call.     _M_F_B was initially aimed toward the modeling of lower perfor-     mance graphics terminals (e.g., there is currently no sup-     port of segments or definable windows and viewports at the     device level).  As a result, programs that use _M_F_B are     likely to work on the low performance (least expensive)     graphics terminals as well as on the more expensive devices.BUGS     Raster (hard copy) output is not yet implemented.FUTURE ENHANCEMENTS     Future modifications to _M_F_B may include the following:          Extension to hard copy graphics devices.          Definable vector and raster character fonts.          Improved cursor support including a definable cursor          font, cursor tracking by the host, cursor-on/cursor-off          capability, and cursor report without event.          Window/viewport geometry clipping by the terminal if          the device possesses that capability.          Bit block transfer (BitBlt).FILES     ~cad/lib/mfbcap     ~cad/include/mfb.h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -