DSQSS  1.1
graphic.cc
説明を見る。
00001 // the following fuctions are for graphical display
00002 //                 (active with the compile option -D GRAPHIC)
00003 //======================================================================
00004 
00005 void Simulation::g_init() {
00006   int g_xorigin = 600;
00007   int g_yorigin = 10;
00008   int g_winwidth = 400;
00009   int g_winheight = 300;
00010   float g_winxmin = 0;
00011   float g_winxmax = 2.0;//(float)(L+1);
00012   float g_winymin = (float)(-0.1 * BETA);
00013   float g_winymax = (float)( 1.1 * BETA);
00014   if (D != 1) {
00015     printf(">>> Only 1D is supported for graphics.\n");
00016     exit(0);
00017   }
00018   if (L > 16) {
00019     printf(">>> L must not exceed 16 for graphics.\n");
00020     exit(0);
00021   }
00022   if (ALG.NX != 2) {
00023     printf(">>> Only 2-state model is supported for graphics.\n");
00024     exit(0);
00025   }
00026   printf(" %f %f %f %f\n",g_winxmin, g_winymin, g_winxmax, g_winymax);
00027   gsetinitialparsegeometry("%+d%+d",g_xorigin, g_yorigin);
00028   g_win = gopen(g_winwidth, g_winheight);
00029   winname(g_win, "test");
00030   window(g_win, g_winxmin, g_winymin, g_winxmax, g_winymax);
00031 };  
00032 
00033 //======================================================================
00034 
00035 void Simulation::g_draw() {
00036   char* color[2] = {"blue", "red"};
00037   gclr(g_win);
00038   float x, x0, x1, y, y0, y1;
00039   for (int i=0; i<LAT.NSite; i++) { 
00040     ppS is = LAT.S[i]->Seg.begin();
00041     while(is != LAT.S[i]->Seg.end()) {
00042       x = (float)(LAT.S[i]->ID);
00043       y0 = (*((*is)->bottom))->tau;
00044       y1 = (*((*is)->top))->tau;
00045       if (y0 == BETA) y0 = 0.0;
00046       newcolor(g_win, color[(*is)->X]);
00047       line(g_win, x, y0, PSET);
00048       line(g_win, x, y1, PENDOWN);
00049       is++;
00050     }
00051   }
00052   newcolor(g_win, "white");
00053   for (int i=0; i<LAT.NBond; i++) {
00054     int is = LAT.B[i]->siteA;
00055     int js = LAT.B[i]->siteB;
00056     ppV iv = LAT.B[i]->Ver.begin();
00057     while(iv != LAT.B[i]->Ver.end()) {
00058       y = (*iv)->tau;
00059       if (is == 0 && js == L-1) {
00060         line(g_win,          0.5, y, PSET);
00061         line(g_win,          1.0, y, PENDOWN);
00062         line(g_win, (float)L    , y, PSET);
00063         line(g_win, (float)L+0.5, y, PENDOWN);
00064       } else {
00065         x0 = (float)(is+1);
00066         x1 = (float)(js+1);
00067         line(g_win, x0, y, PSET);
00068         line(g_win, x1, y, PENDOWN);
00069       }
00070       iv++;
00071     }
00072   }
00073   //  getchar();
00074 };
00075 
00076 //======================================================================
00077 void Simulation::g_clear() {
00078   getchar();
00079   gclose(g_win);
00080 };  
 全て クラス ネームスペース ファイル 関数 変数 型定義 列挙型の値 フレンド マクロ定義