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

📄 output.cc

📁 模糊聚类分析的源程序!
💻 CC
📖 第 1 页 / 共 5 页
字号:
//**************************************************************//*   filename: output.cc                                      *//*                                                            *//**************************************************************//* programmed by: Thomas Wagner                               *//* last change:  (XXX: not updated)                           *//**************************************************************#include <stdio.h>#include <stdlib.h>#include <string.h>#include <X11/Xlib.h>#include <X11/Xatom.h>#include "output.h"#include "connect.h"#include "regel.h"#include "onofficon.h"#include "init.h"#include "quicksort.h"#include "include_bmps/makerules.bmp"#include "include_bmps/ghost.bmp"#include "include_bmps/load.bmp"#include "include_bmps/save.bmp"#include "include_bmps/go.bmp"#include "include_bmps/classify.bmp"#include "include_bmps/reset.bmp"#include "include_bmps/d2.bmp"#include "include_bmps/d3.bmp"#include "include_bmps/singlemembership.bmp"#include "include_bmps/pointtyppoint.bmp"#include "include_bmps/pointtypcross.bmp"#include "include_bmps/roll.bmp"#include "include_bmps/move.bmp"#include "include_bmps/fitscale.bmp"#include "include_bmps/movepoint.bmp"#include "include_bmps/selectpoint.bmp"#include "include_bmps/deletepoint.bmp"#include "include_bmps/createpoint.bmp"#include "include_bmps/drawonlyoriginal.bmp"#include "include_bmps/drawonlyresult.bmp"#include "include_bmps/drawboth.bmp"#include "include_bmps/d2cluster.bmp"#include "include_bmps/d3cluster.bmp"#include "include_bmps/d2membertyp1.bmp"#include "include_bmps/d3membertyp1.bmp"#include "include_bmps/d2membertyp2.bmp"#include "include_bmps/d3membertyp2.bmp"#include "include_bmps/d2guete.bmp"#include "include_bmps/clustertypellipsis.bmp"#include "include_bmps/clustertypsymbol.bmp"#include "include_bmps/clustertypstar.bmp"#include "include_bmps/clustertypcolor.bmp"#include "include_bmps/createcluster.bmp"#include "include_bmps/movecluster.bmp"#include "include_bmps/deletecluster.bmp"#include "include_bmps/selectcluster.bmp"//including from Olli:#include "verfahren.h"#include "matrix.h"#include "regel.h"extern unsigned long buttonpix, blackpix, whitepix, shadowpix;extern unsigned long lightpix, redpix;extern Cursor moveconnectcursor, moveaxescursor, delconnectcursor, maincursor;extern Cursor waitcursor, movepointcursor, createpointcursor, rotatecursor;/* * dump the given pixmap to a data-file (xbm-format) */static voiddump_bitmap (Display *display, Pixmap pixmap, int width, int height){  char *fname = "dump.xbm";  fprintf (stderr, "dumping bitmap to ``%s'' ... ", fname);  fflush (stderr);  if (BitmapSuccess != XWriteBitmapFile(display, fname, pixmap,					width, height, -1, -1)) {    fprintf (stderr, "error - not done.\n");  } else {    fprintf (stderr, "done.\n");  }}voidOutput::DumpBitmap (){  dump_bitmap (display, pixmap, width, height);}int Getvektorindex (DVektor * vector, DVektorArray * array){  short counter, foundindex = 0;  for (counter = 0; counter < array->Lese_Groesse (); counter++)    if (&(array->Lese_Vektor (counter)) == vector) {      foundindex = counter;      break;			// for(...)    }  return foundindex;}RuleResultInfo::RuleResultInfo (Datensatz * Dataset){  dataset = Dataset;  result = new DVektorArray (Dataset->Lese_Daten ().Lese_Dim (),			     Dataset->Lese_Daten ().Lese_Groesse (),			     NULL);}RuleResultInfo::~RuleResultInfo (){  delete result;}void RuleResultInfo::operator= (RuleResultInfo & source){  result = source.result;  dataset = source.dataset;}Output::Output (Display * initdisplay,	GC initgc,	MoveableIcon * initOutputicon,	XFontStruct * fontstruct,	int initx, int inity,	int initwidth, int initheight,	char *text):BigWindow (initdisplay,	   initgc,	   DefaultRootWindow (initdisplay),	   fontstruct,	   initx, inity,	   initwidth, initheight,	   text,	   DEFAULT_BDWIDTH){  unsigned int depth;  Dataset = NULL;  myicon = initOutputicon;  depth = DefaultDepth (display, DefaultScreen (display));  pixmap = XCreatePixmap (display, window, width, height, depth);  XSetForeground (display, gc, whitepix);  XFillRectangle (display, pixmap, gc, 0, 0, width, height);  ghost = new ActionIcon (display,			  gc,			  this,			  fontstruct,			  0, 0, 16, 16,			  "", ghost_bits,			  ghost_width, ghost_height,			  OUTPUT_GHOST,			  ICON_SELECTABLE);  ghost->MapMe ();  SetMinSize (width, height);}Output::~Output (){  XFreePixmap (display, pixmap);  delete ghost;}void Output::ClearPixmap (){  if (pixmap != 0) {    XSetForeground (display, gc, whitepix);    XFillRectangle (display, pixmap, gc, 0, 0, width, height);  }}void Output::MapMe (){  XMapWindow (display, window);  RaiseMe ();}void Output::DrawSymbol (short xpos,		    short ypos,		    Drawable drawable,		    int symbolindex){  if (symbolindex < MAXINT) {    switch (symbolindex % (SYMBOLNUMBER - 1)) {    case 0:      {//   |	// --|--	//   |	XSegment lines[2];	lines[0].x1 = lines[0].x2 = xpos;	lines[0].y1 = ypos - SYMBOLHALFWIDTH;	lines[0].y2 = ypos + SYMBOLHALFWIDTH;	lines[1].x1 = xpos - SYMBOLHALFWIDTH;	lines[1].x2 = xpos + SYMBOLHALFWIDTH;	lines[1].y1 = lines[1].y2 = ypos;	XDrawSegments (display, drawable, gc, lines, 2);      }      break;    case 1:      {//   /\	//  /  \	//  ----	XPoint points[4];	points[3].x = points[0].x = xpos;	points[3].y = points[0].y = ypos - SYMBOLHALFWIDTH;	points[2].y = points[1].y = ypos + SYMBOLHALFWIDTH;	points[1].x = xpos + SYMBOLHALFWIDTH;	points[2].x = xpos - SYMBOLHALFWIDTH;	XDrawLines (display, drawable, gc, points, 4, CoordModeOrigin);      }      break;    case 2:      {//   ___	//  |   |	//  |   |	//   ---	XDrawRectangle (display,			drawable,			gc,			xpos - SYMBOLHALFWIDTH, ypos - SYMBOLHALFWIDTH,			2 * SYMBOLHALFWIDTH, 2 * SYMBOLHALFWIDTH);      }      break;    case 3:      {//    ___	//   /   \	//  |     |	//   \___/	XDrawArc (display,		  drawable,		  gc,		  xpos - SYMBOLHALFWIDTH, ypos - SYMBOLHALFWIDTH,		  SYMBOLHALFWIDTH * 2, SYMBOLHALFWIDTH * 2,		  0, 23040);      }      break;    case 4:      {//   /\	//  /xx\	//  ----	XPoint points[3];	points[0].x = xpos;	points[0].y = ypos - SYMBOLHALFWIDTH;	points[2].y = points[1].y = ypos + SYMBOLHALFWIDTH;	points[1].x = xpos + SYMBOLHALFWIDTH;	points[2].x = xpos - SYMBOLHALFWIDTH;	XFillPolygon (display, drawable, gc, points, 3, Convex, CoordModeOrigin);      }      break;    case 5:      {//   ___	//  |xxx|	//  |xxx|	//   ---	XFillRectangle (display,			drawable,			gc,			xpos - SYMBOLHALFWIDTH, ypos - SYMBOLHALFWIDTH,			2 * SYMBOLHALFWIDTH, 2 * SYMBOLHALFWIDTH);      }      break;    case 6:      {//    ___	//   /xxx\	//  |xxxxx|	//   \___/	XFillArc (display,		  drawable,		  gc,		  xpos - SYMBOLHALFWIDTH, ypos - SYMBOLHALFWIDTH,		  SYMBOLHALFWIDTH * 2, SYMBOLHALFWIDTH * 2,		  0, 23040);      }      break;    case 7:      {//  ----	//  \  /	//   \/	XPoint points[4];	points[3].x = points[0].x = xpos;	points[3].y = points[0].y = ypos + SYMBOLHALFWIDTH;	points[2].y = points[1].y = ypos - SYMBOLHALFWIDTH;	points[1].x = xpos + SYMBOLHALFWIDTH;	points[2].x = xpos - SYMBOLHALFWIDTH;	XDrawLines (display, drawable, gc, points, 4, CoordModeOrigin);      }      break;    case 8:      {//   /\	//  /  \	//  \  /	//   \/	XPoint points[5];	points[4].x = points[0].x = points[2].x = xpos;	points[1].y = points[3].y = ypos;	points[4].y = points[0].y = ypos - SYMBOLHALFWIDTH;	points[2].y = ypos + SYMBOLHALFWIDTH;	points[1].x = xpos + SYMBOLHALFWIDTH;	points[3].x = xpos - SYMBOLHALFWIDTH;	XDrawLines (display, drawable, gc, points, 5, CoordModeOrigin);      }      break;    case 9:      {//  ----	//  \**/	//   \/	XPoint points[3];	points[0].x = xpos;	points[0].y = ypos + SYMBOLHALFWIDTH;	points[2].y = points[1].y = ypos - SYMBOLHALFWIDTH;	points[1].x = xpos + SYMBOLHALFWIDTH;	points[2].x = xpos - SYMBOLHALFWIDTH;	XFillPolygon (display, drawable, gc, points, 3, Convex, CoordModeOrigin);      }      break;    case 10:      {//   /\	//  /**\	//  \**/	//   \/	XPoint points[4];	points[0].x = points[2].x = xpos;	points[1].y = points[3].y = ypos;	points[0].y = ypos - SYMBOLHALFWIDTH;	points[2].y = ypos + SYMBOLHALFWIDTH;	points[1].x = xpos + SYMBOLHALFWIDTH;	points[3].x = xpos - SYMBOLHALFWIDTH;	XFillPolygon (display, drawable, gc, points, 4, Convex, CoordModeOrigin);      }      break;    }  } else {//  \  /    //   \/    //   /\    //  /  \#if 1#endif    XSegment lines[2];    lines[0].x1 = lines[1].x2 = xpos - SYMBOLHALFWIDTH;    lines[0].x2 = lines[1].x1 = xpos + SYMBOLHALFWIDTH;    lines[0].y1 = lines[1].y1 = ypos - SYMBOLHALFWIDTH;    lines[0].y2 = lines[1].y2 = ypos + SYMBOLHALFWIDTH;    XDrawSegments (display, drawable, gc, lines, 2);  }}void Output::DrawColorbox (short xpos,		      short ypos,		      Drawable drawable,		      int symbolindex){  if (symbolindex < MAXINT)    XSetForeground (display, gc, indexcolor[symbolindex % (SYMBOLNUMBER - 1)]);  else    XSetForeground (display, gc, buttonpix);  XFillRectangle (display,		  drawable,		  gc,		  xpos - SYMBOLHALFWIDTH, ypos - SYMBOLHALFWIDTH,		  2 * SYMBOLHALFWIDTH, 2 * SYMBOLHALFWIDTH);}void Output::UnDrawBox (short xpos,		   short ypos,		   Drawable drawable){  XSetForeground (display, gc, whitepix);  XFillRectangle (display,		  drawable,		  gc,		  xpos - SYMBOLHALFWIDTH, ypos - SYMBOLHALFWIDTH,		  2 * SYMBOLHALFWIDTH, 2 * SYMBOLHALFWIDTH);}void Output::DrawBox (short xpos,		 short ypos,		 Drawable drawable){  XSetForeground (display, gc, blackpix);  XDrawRectangle (display,		  drawable,		  gc,		  xpos - SYMBOLHALFWIDTH, ypos - SYMBOLHALFWIDTH,		  2 * SYMBOLHALFWIDTH, 2 * SYMBOLHALFWIDTH);}void Output::UpdateOutput (){  XCopyArea (display, pixmap, window, gc, 0, 0, width, height, 0, 0);}void Output::Resized (int newwidth, int newheight){  int depth;  width = newwidth;  height = newheight;  XFreePixmap (display, pixmap);  depth = DefaultDepth (display, DefaultScreen (display));  pixmap = XCreatePixmap (display, window, width, height, depth);  XResizeWindow (display, window, width, height);}Output2d_3d::Output2d_3d (Display * initdisplay,	     GC initgc,	     MoveableIcon * initOutputicon,	     XFontStruct * fontstruct,	     int initx, int inity, int initwidth, int initheight,	     char *text):

⌨️ 快捷键说明

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