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

📄 barmanager.cpp

📁 openmosix viewer图形界面工具。o penmosix viewer图形界面工具。o penmosix viewer图形界面工具。o penmosix viewer图形界面工具。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
#include "barmanager.h"GLuint base;            // base display list for the font set.int maxnumber=0;int loadingdata=0;// to store the selected node valuesnodevalues sel;void BarManager::BuildFont() {    Display *dpy;    XFontStruct *fontInfo;  // storage for our font.    base = glGenLists(96);                      // storage for 96 characters.        // load the font.  what fonts any of you have is going    // to be system dependent, but on my system they are    // in /usr/X11R6/lib/X11/fonts/*, with fonts.alias and    // fonts.dir explaining what fonts the .pcf.gz files    // are.  in any case, one of these 2 fonts should be    // on your system...or you won't see any text.        // get the current display.  This opens a second    // connection to the display in the DISPLAY environment    // value, and will be around only long enough to load     // the font.     dpy = XOpenDisplay(NULL); // default to DISPLAY env.       fontInfo = XLoadQueryFont(dpy, "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1");//    fontInfo = XLoadQueryFont(dpy, "-adobe-helvetica-medium-r-normal--10-*-*-*-p-*-iso8859-1");	if (fontInfo == NULL) {	    printf("no X font available?\n");	    exit(-1);	}        // start at character 32 (space), get 96 characters (a few characters past z), and    // store them starting at base.// un-comment this line to get the text displayed. It is disabled// here because it causes crashes on some libglut versions//    glXUseXFont(fontInfo->fid, 32, 96, base);	    // free that font's info now that we've got the     // display lists.    XFreeFont(dpy, fontInfo);    // close down the 2nd display connection.    XCloseDisplay(dpy);}void BarManager::KillFont()                         // delete the font.{    glDeleteLists(base, 96);                    // delete all 96 characters.}void BarManager::glPrint(char *text)                      // custom gl print routine.{    if (text == NULL) {                         // if there's no text, do nothing.	return;    }        glPushAttrib(GL_LIST_BIT);                  // alert that we're about to offset the display lists with glListBase    glListBase(base - 32);                      // sets the base character to 32.    glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // draws the display list text.    glPopAttrib();                              // undoes the glPushAttrib(GL_LIST_BIT);}void BarManager::nodeinfo()                      // draws the node ids{ char updatestring[50];char nodestring[10];bar_record tmpbar;int thisnode=0;int gotcha=0;glPushMatrix();// if the selected node is too highif (selectednode>maxnumber) {  selectednode=1;}// if the selected node is too lowif (selectednode<=0) {  selectednode=maxnumber;}maxnumber=0;//  printf("nodesid1 = %d\n", read_data.real_node_number);//  printf("nodesid2 = %d\n", read_data.mosix_number);for (BarIter = BarList.begin(); BarIter != BarList.end(); BarIter++) {    //	if(BarIter->mosix_number==read_data.real_node_number) { 		tmpbar=*BarIter;    thisnode=read_data.real_node_number;    // printf("node %d\n", thisnode);    // search the selected node    if(thisnode==selectednode) {      // debugging      // printf("nodesid2 = %d\n", read_data.mosix_number);  	  // printf("selected node %d\n", selectednode);      // printf("realnodenumber = %d\n", read_data.real_node_number);     	// printf("found node %d\n\n", BarIter->mosix_number);    	// printf("X %d\n\n", GetXsquares());      if(BarIter->mosix_number==read_data.real_node_number) {         // load the material         tmpbar.bar->loadMaterials(yellowMaterials);         }  else {         if (DISPLAYMODE == LOAD) {           tmpbar.bar->loadMaterials(greenMaterials);         }         if (DISPLAYMODE == MEM) {           tmpbar.bar->loadMaterials(blueMaterials);         }         if (DISPLAYMODE == UTIL) {           tmpbar.bar->loadMaterials(redMaterials);         }       }      // load the values      sel.number=read_data.mosix_number;      sel.load=read_data.mosix_info.load;      sel.speed=read_data.mosix_info.speed;      sel.availmem=read_data.mosix_info.tmem/1048576;      sel.usemem=(read_data.mosix_info.tmem/1048576)-(read_data.mosix_info.rmem/1048576);      sel.cpus=read_data.mosix_info.ncpus;      sel.stat=read_data.mosix_info.status;      sel.mosversion=read_data.openmosix;    }    // here we count the nodes to get the max nodenumber    maxnumber++; }	// here we update the nodes information	glEnable(GL_COLOR_MATERIAL);  	// write the view information  	if (DISPLAYMODE == LOAD) {  		glColor3f(0,1,0);  		glRasterPos2f(5, +19);  		glPrint("load view");  	}  // first we check if were are in "loading-data"  if (loadingdata<=maxnumber) {    loadingdata++;		glColor3f(1,1,0);		glRasterPos2f(4, +10);		glPrint("loading univers...");    } else {  	if (DISPLAYMODE == MEM) {  		glColor3f(0,0,1);  		glRasterPos2f(5, +19);  			glPrint("memory view");  	}  	if (DISPLAYMODE == UTIL) {  		glColor3f(1,0,0);  		glRasterPos2f(5, +19);  		glPrint("utilization view");  	}    // when there is data available for the node    if (sel.number>0) {  		glColor3f(1,1,0);  		// write the headline  		glRasterPos2f(-24, +19);  		glPrint("node informations");  		// here we write the bar number  		sprintf(nodestring, "%d", selectednode);  		strcpy(updatestring, "selected node : ");  		strcat(updatestring, nodestring);  		glRasterPos2f(-24, +16);  		glPrint(updatestring);  		// here we write the node id text  		sprintf(nodestring, "%d", sel.number);  		strcpy(updatestring, "node ID : ");  		strcat(updatestring, nodestring);  		glRasterPos2f(-24, +14);  		glPrint(updatestring);  		// here we write the nodes load  		sprintf(nodestring, "%d", sel.load);  		strcpy(updatestring, "load : ");  		strcat(updatestring, nodestring);  		glRasterPos2f(-24, +12);  		glPrint(updatestring);  		// here we write the nodes speed  		sprintf(nodestring, "%d", sel.speed);  		strcpy(updatestring, "speed : ");  		strcat(updatestring, nodestring);  		glRasterPos2f(-24, +10);  		glPrint(updatestring);  		// here we write the nodes available memory  		sprintf(nodestring, "%d", sel.availmem);  		strcpy(updatestring, "avail. mem : ");  		strcat(updatestring, nodestring);  		strcat(updatestring, " MB");  		glRasterPos2f(-24, +8);  		glPrint(updatestring);  		// here we write the nodes used memory  		sprintf(nodestring, "%d", sel.usemem);  		strcpy(updatestring, "used mem : ");  		strcat(updatestring, nodestring);  		strcat(updatestring, " MB");  		glRasterPos2f(-24, +6);  		glPrint(updatestring);  		// here we write the nodes cpus  		sprintf(nodestring, "%d", sel.cpus);  		strcpy(updatestring, "cpu's : ");  		strcat(updatestring, nodestring);  		glRasterPos2f(-24, +4);  		glPrint(updatestring);  		// here we write the nodes status  		strcpy(updatestring, "status : ");  		if (sel.stat>=2) {  			strcat(updatestring, "up");  			} else {  			strcat(updatestring, "down");  		}  		glRasterPos2f(-24, +2);  		glPrint(updatestring);  		glColor3f(1,1,0);  		// write the right headline  		glRasterPos2f(+30, +19);  		glPrint("cluster informations");  		// howmany we are  		sprintf(nodestring, "%d", maxnumber);  		strcpy(updatestring, "total nodes : ");  		strcat(updatestring, nodestring);  		glRasterPos2f(+30, +16);  		glPrint(updatestring);  		// who we are ;)      if (sel.mosversion) {    		strcpy(updatestring, "running openMosix");        } else {    		strcpy(updatestring, "running Mosix");      }  		glRasterPos2f(+30, +14);  		glPrint(updatestring);    }  }  glDisable(GL_COLOR_MATERIAL);  glPopMatrix();}// #########################################################################################BarManager :: BarManager(){       	NumBars = 0;	size = sizeof(struct node_info);  selectednode=1;}int BarManager :: init(char *server, char *port){    ConnectToServer(server, port);    ReadNumNodes();    return 0;}int BarManager::GenerateGrid(){		TwoDRect *tile;		for (int x = 0; x <GetXsquares(); x++)	    for (int z = 0; z < GetZsquares(); z++)	    {   

⌨️ 快捷键说明

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