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

📄 output.cc

📁 模糊聚类的算法实现程序
💻 CC
📖 第 1 页 / 共 5 页
字号:
{  WorldtoPixel3d (xpos, ypos, zpos,		  &Point->x, &Point->y);}void Output2d_3d::FillLines (XSegment * lines,			double xpos,			double ypos,			double zpos,			short *xpixel, short *ypixel){  WorldtoPixel3d (xpos, ypos, zpos,		  xpixel, ypixel);  lines[0].y1 = lines[0].y2 = *ypixel;  lines[0].x1 = (short) (*xpixel - CROSSWIDTH);  lines[0].x2 = (short) (*xpixel + CROSSWIDTH);  lines[1].x1 = lines[1].x2 = *xpixel;  lines[1].y1 = (short) (*ypixel - CROSSWIDTH);  lines[1].y2 = (short) (*ypixel + CROSSWIDTH);}Output2d::Output2d (Display * initdisplay,	  GC initgc,	  MoveableIcon * initOutputicon,	  XFontStruct * fontstruct,	  int initx, int inity, int initwidth, int initheight,	  char *text):Output (initdisplay,	initgc,	initOutputicon,	fontstruct,	initx, inity, initwidth, initheight,	text){}void Output2d::DrawGraph (Parameter * parameter,		     int xpos, int ypos, int drawwidth, int drawheight,		     double range, double minxvalue){  int counter;  XSegment Lines[2];  XPoint *points;  XPoint arrow[4];  if ((points = (XPoint *) malloc (sizeof (XPoint) * parameter->Lese_Parameter_Anzahl ())) == NULL) {    printf ("Out of memory!\n");    exit (1);  }//first draw axes  Lines[0].x1 = xpos;  Lines[0].y1 = ypos;  Lines[0].x2 = xpos + drawwidth;  Lines[0].y2 = ypos;  Lines[1].x2 = Lines[1].x1 = xpos + (int) (drawwidth * (-minxvalue / range));  Lines[1].y1 = ypos;  Lines[1].y2 = ypos - drawheight;  XDrawSegments (display, pixmap, gc, Lines, 2);//and arrows on x-axis >   arrow[0].x = xpos + 1 + drawwidth - (int) (drawwidth * RULE_ARROWLENGTHMULT);  arrow[0].y = ypos - (int) (drawheight * RULE_ARROWWIDTHMULT);  arrow[1].x = xpos + 1 + drawwidth;  arrow[1].y = ypos;  arrow[2].x = xpos + 1 + drawwidth - (int) (drawwidth * RULE_ARROWLENGTHMULT);  arrow[2].y = ypos + (int) (drawheight * RULE_ARROWWIDTHMULT);// +1 looks nicer !  XFillPolygon (display, pixmap, gc, arrow, 3, Convex, CoordModeOrigin);//and arrows on y-axis /\#if 0/* guess - Guess - GUESS -- ARGHHHHHHHHHHH */#endif  arrow[0].x = Lines[1].x1 - (int) (drawwidth * RULE_ARROWWIDTHMULT);  arrow[0].y = ypos - drawheight - 1 + (int) (drawheight * RULE_ARROWLENGTHMULT);  arrow[1].x = Lines[1].x1;  arrow[1].y = ypos - drawheight - 1;  arrow[2].x = Lines[1].x1 + (int) (drawwidth * RULE_ARROWWIDTHMULT);  arrow[2].y = ypos - drawheight - 1 + (int) (drawheight * RULE_ARROWLENGTHMULT);  XFillPolygon (display, pixmap, gc, arrow, 3, Convex, CoordModeOrigin);  for (counter = 0; counter < parameter->Lese_Parameter_Anzahl (); counter++) {    points[counter].x = xpos + (int) (drawwidth * ((parameter->Lese_xParameter (counter) - minxvalue) / range));    points[counter].y = ypos - (short) (drawheight * parameter->Lese_yParameter (counter));  }  XDrawLines (display, pixmap, gc, points, parameter->Lese_Parameter_Anzahl (), CoordModeOrigin);// now draw values  {    char leftvalue[RULE_VALUELENGTH], rightvalue[RULE_VALUELENGTH];    short lefttextwidth, righttextwidth, overlap;    // first lower values    sprintf (leftvalue, "%2.3f", parameter->Lese_xParameter (0));    sprintf (rightvalue, "%2.3f", parameter->Lese_xParameter (parameter->Lese_Parameter_Anzahl () - 1));    lefttextwidth = XTextWidth (fontstruct, leftvalue, strlen (leftvalue));    righttextwidth = XTextWidth (fontstruct, rightvalue, strlen (rightvalue));    points[parameter->Lese_Parameter_Anzahl () - 1].y = ypos;    points[0].y = points[parameter->Lese_Parameter_Anzahl () - 1].y += fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent,      points[0].x -= lefttextwidth / 2;    points[parameter->Lese_Parameter_Anzahl () - 1].x -= righttextwidth / 2;    overlap = MAX (0, 5 + points[0].x + lefttextwidth - points[parameter->Lese_Parameter_Anzahl () - 1].x);    points[0].x -= overlap / 2;    points[parameter->Lese_Parameter_Anzahl () - 1].x += overlap / 2;    XDrawString (display, pixmap, gc,		 points[0].x, points[0].y,		 leftvalue, strlen (leftvalue));    XDrawString (display, pixmap, gc,		 points[parameter->Lese_Parameter_Anzahl () - 1].x, points[parameter->Lese_Parameter_Anzahl () - 1].y,		 rightvalue, strlen (rightvalue));  }  free (points);}InOutput::InOutput (Display * initdisplay,	  GC initgc,	  InputIcon * initOutputicon,	  XFontStruct * fontstruct,	  int initx, int inity, int initwidth, int initheight,	  char *text):Output2d_3d (initdisplay,	     initgc,	     initOutputicon,	     fontstruct,	     initx, inity, initwidth, initheight,	     text){  ruleresultinfo = NULL;  selectedinput = NULL;  viewicons = NULL;  resultdisplaytyp = NULL;  xindex = DEFAULTXINDEX;  yindex = DEFAULTYINDEX;  zindex = DEFAULTZINDEX;  axismenu = NULL;  float_to_pixel = 1.0;  XDefineCursor (display, window, maincursor);  viewicons = new SelectIconlist ();  *viewicons += new SelectIcon (display, gc, this, fontstruct,			 width - 2 * VIEWICON_SIZE - 3 * DEFAULT_BDWIDTH, 0,				VIEWICON_SIZE, VIEWICON_SIZE,		     "", d2_bits, d2_width, d2_height, OUTPUT_VIEW2D_SELECT,				ICON_SELECTED);  *viewicons += new SelectIcon (display, gc, this, fontstruct,			     width - VIEWICON_SIZE - 2 * DEFAULT_BDWIDTH, 0,				VIEWICON_SIZE, VIEWICON_SIZE,		     "", d3_bits, d3_width, d3_height, OUTPUT_VIEW3D_SELECT,				0);  *viewicons += new SelectIcon (display, gc, this, fontstruct,			    width - 2 * VIEWICON_SIZE - 3 * DEFAULT_BDWIDTH,				VIEWICON_SIZE + 1 * DEFAULT_BDWIDTH,				VIEWICON_SIZE, VIEWICON_SIZE,				"", d2membertyp1_bits, d2membertyp1_width, d2membertyp1_height, OUTPUT_VIEW2DCLASSMEMBERSHIP_SELECT,				0);  *viewicons += new SelectIcon (display, gc, this, fontstruct,				width - VIEWICON_SIZE - 2 * DEFAULT_BDWIDTH,				VIEWICON_SIZE + 1 * DEFAULT_BDWIDTH,				VIEWICON_SIZE, VIEWICON_SIZE,				"", d3membertyp1_bits, d3membertyp1_width, d3membertyp1_height, OUTPUT_VIEW3DCLASSMEMBERSHIP_SELECT,				0);  pointtypicons = new SelectIconlist ();  *pointtypicons += new SelectIcon (display, gc, this, fontstruct,			    width - 2 * VIEWICON_SIZE - 3 * DEFAULT_BDWIDTH,				    2 * VIEWICON_SIZE + 3 * DEFAULT_BDWIDTH,				    VIEWICON_SIZE, VIEWICON_SIZE,	  "", pointtyppoint_bits, pointtyppoint_width, pointtyppoint_height,				    OUTPUT_POINTTYPPOINT,				    ICON_SELECTABLE);  *pointtypicons += new SelectIcon (display, gc, this, fontstruct,				width - VIEWICON_SIZE - 2 * DEFAULT_BDWIDTH,				    2 * VIEWICON_SIZE + 3 * DEFAULT_BDWIDTH,				    VIEWICON_SIZE, VIEWICON_SIZE,	  "", pointtypcross_bits, pointtypcross_width, pointtypcross_height,				    OUTPUT_POINTTYPCROSS,				    ICON_SELECTED | ICON_SELECTABLE);  *pointtypicons += new SelectIcon (display, gc, this, fontstruct,			    width - 2 * VIEWICON_SIZE - 3 * DEFAULT_BDWIDTH,				    3 * VIEWICON_SIZE + 4 * DEFAULT_BDWIDTH,				    VIEWICON_SIZE, VIEWICON_SIZE,  "", clustertypsymbol_bits, clustertypsymbol_width, clustertypsymbol_height,				    OUTPUT_POINTTYPCLASSES,				    ICON_SELECTABLE);  *pointtypicons += new SelectIcon (display, gc, this, fontstruct,				width - VIEWICON_SIZE - 2 * DEFAULT_BDWIDTH,				    3 * VIEWICON_SIZE + 4 * DEFAULT_BDWIDTH,				    VIEWICON_SIZE, VIEWICON_SIZE,    "", clustertypcolor_bits, clustertypcolor_width, clustertypcolor_height,				    OUTPUT_POINTTYPCOLOR,				    ICON_SELECTABLE);  actionselecticons = new SelectIconlist ();  *actionselecticons += new SelectIcon (display, gc, this, fontstruct,				width - VIEWICON_SIZE - 2 * DEFAULT_BDWIDTH,				    4 * VIEWICON_SIZE + 6 * DEFAULT_BDWIDTH,					VIEWICON_SIZE, VIEWICON_SIZE,				     "", move_bits, move_width, move_height,					OUTPUTSTATUS_MOVE,					ICON_SELECTABLE);  *actionselecticons += new SelectIcon (display, gc, this, fontstruct,			    width - 2 * VIEWICON_SIZE - 3 * DEFAULT_BDWIDTH,				    4 * VIEWICON_SIZE + 6 * DEFAULT_BDWIDTH,					VIEWICON_SIZE, VIEWICON_SIZE,				     "", roll_bits, roll_width, roll_height,					OUTPUTSTATUS_ROLL,					ICON_SELECTED | ICON_SELECTABLE);  *actionselecticons += new SelectIcon (display, gc, this, fontstruct,				width - VIEWICON_SIZE - 2 * DEFAULT_BDWIDTH,				    5 * VIEWICON_SIZE + 7 * DEFAULT_BDWIDTH,					VIEWICON_SIZE, VIEWICON_SIZE,		      "", movepoint_bits, movepoint_width, movepoint_height,					OUTPUTSTATUS_MOVEPOINT,					ICON_SELECTABLE);  *actionselecticons += new SelectIcon (display, gc, this, fontstruct,			    width - 2 * VIEWICON_SIZE - 3 * DEFAULT_BDWIDTH,				    5 * VIEWICON_SIZE + 7 * DEFAULT_BDWIDTH,					VIEWICON_SIZE, VIEWICON_SIZE,		"", selectpoint_bits, selectpoint_width, selectpoint_height,					OUTPUTSTATUS_SELECTPOINT,					ICON_SELECTABLE);  *actionselecticons += new SelectIcon (display, gc, this, fontstruct,				width - VIEWICON_SIZE - 2 * DEFAULT_BDWIDTH,				    6 * VIEWICON_SIZE + 8 * DEFAULT_BDWIDTH,					VIEWICON_SIZE, VIEWICON_SIZE,		"", createpoint_bits, createpoint_width, createpoint_height,					OUTPUTSTATUS_CREATEPOINT,					ICON_SELECTABLE);  *actionselecticons += new SelectIcon (display, gc, this, fontstruct,			    width - 2 * VIEWICON_SIZE - 3 * DEFAULT_BDWIDTH,				    6 * VIEWICON_SIZE + 8 * DEFAULT_BDWIDTH,					VIEWICON_SIZE, VIEWICON_SIZE,		"", deletepoint_bits, deletepoint_width, deletepoint_height,					OUTPUTSTATUS_DELETEPOINT,					ICON_SELECTABLE);  resultdisplaytyp = new SelectIconlist ();  *resultdisplaytyp += new SelectIcon (display, gc, this, fontstruct,				width - VIEWICON_SIZE - 2 * DEFAULT_BDWIDTH,				   7 * VIEWICON_SIZE + 10 * DEFAULT_BDWIDTH,				       VIEWICON_SIZE, VIEWICON_SIZE,  "", drawonlyoriginal_bits, drawonlyoriginal_width, drawonlyoriginal_height,				       OUTPUT_DRAWONLYORIGINAL_SELECT,				       0);  *resultdisplaytyp += new SelectIcon (display, gc, this, fontstruct,			    width - 2 * VIEWICON_SIZE - 3 * DEFAULT_BDWIDTH,				   7 * VIEWICON_SIZE + 10 * DEFAULT_BDWIDTH,				       VIEWICON_SIZE, VIEWICON_SIZE,       "", drawonlyresult_bits, drawonlyresult_width, drawonlyresult_height,				       OUTPUT_DRAWONLYRESULT_SELECT,				       0);  *resultdisplaytyp += new SelectIcon (display, gc, this, fontstruct,				width - VIEWICON_SIZE - 2 * DEFAULT_BDWIDTH,				   8 * VIEWICON_SIZE + 11 * DEFAULT_BDWIDTH,				       VIEWICON_SIZE, VIEWICON_SIZE,			 "", drawboth_bits, drawboth_width, drawboth_height,				       OUTPUT_DRAWBOTH_SELECT,				       ICON_SELECTED);  Scroll = new ScrollWindow (display, gc, this, fontstruct,			     width - 26, 170,			     24, 120,			     0, 1,			 SCROLL_BORDER_OPTION | SCROLL_COUNTERWINDOW_OPTION,			     OUTPUT_CHANCECLASSINDEX_ACTION);  fitscaleicon = new OnOffIcon (display,				gc,				this,				fontstruct,				0, 18, 16, 16,				"", fitscale_bits,				fitscale_width, fitscale_height,				OUTPUT_FITSCALE, ICON_SELECTABLE);  fitscaleicon->MapMe ();  SetSelectedInput (ExposureMask		    | StructureNotifyMask		    | PointerMotionMask		    | ButtonPressMask		    | ButtonReleaseMask		    | KeyPressMask);}InOutput::~InOutput (){  if (axismenu != NULL)    delete axismenu;  delete viewicons;  delete actionselecticons;  delete resultdisplaytyp;  delete pointtypicons;  delete Scroll;  if (ruleresultinfo != NULL)    delete ruleresultinfo;}void InOutput::Unmapmyicons (){  Scroll->UnmapMe ();  axismenu->UnmapMe ();  ghost->UnmapMe ();  actionselecticons->UnmapMe ();  viewicons->UnmapMe ();  pointtypicons->UnmapMe ();  resultdisplaytyp->UnmapMe ();  fitscaleicon->UnmapMe ();}void InOutput::Mapmyicons (){  if ((viewicons->GetSelectedvalue () == OUTPUT_VIEW2DCLASSMEMBERSHIP_SELECT) ||    (viewicons->GetSelectedvalue () == OUTPUT_VIEW3DCLASSMEMBERSHIP_SELECT))    Scroll->MapMe ();  axismenu->MapMe ();  ghost->MapMe ();  actionselecticons->MapMe ();  viewicons->MapMe ();  pointtypicons->MapMe ();  resultdisplaytyp->MapMe ();  fitscaleicon->MapMe ();}void InOutput::SetDataset (Datensatz * newinputDataset){  int counter;  inputDataset = *newinputDataset;  Dataset = &inputDataset;  DVektorArray *inputData = &(Dataset->Lese_Daten ());  if (Dataset->Lese_Daten_Typ () == Klassifiziert) {    int number = inputData->Lese_Groesse (), maxclass = 0;    for (counter = 0; counter < number; counter++)      if (inputData->Lese_Vektor (counter).Lese_Nummer () < MAXINT)	maxclass = MAX (maxclass, inputData->Lese_Vektor (counter).Lese_Nummer ());    Scroll->SetMinMax (0, maxclass);  }  deepvalues.DVektor (inputData->Lese_Groesse (),		      0,		      NULL);  deepindex.IVektor (inputData->Lese_Groesse (),		     NULL);//for(counter=0;counter<inputData->Lese_Groesse();counter++)  for (counter = inputData->Lese_Groesse () - 1; counter > 0; counter--)    deepindex[counter] = counter;  selectedinput = &(Dataset->Lese_Daten ().Lese_Vektor (0));  InitOutput (&(Dataset->Lese_Daten ()));  Mapmyicons ();}void InOutput::DrawInputData (int options){  Drawable drawable;  if (options & DRAWINWINDOW)    drawable = window;  else    drawable = pixmap;// erase old drawing   if ((options & ERASEOLDDRAWING) || (Dataset == 0)) {    XSetForeground (display, gc, whitepix);    XFillRectangle (display, drawable, gc, 0, 0, width, height);  }  switch (viewicons->GetSelectedvalue ()) {  case OUTPUT_VIEW2D_SELECT:    if (Dataset->Lese_Daten ().Lese_Dim () > 1)      DrawInputData2d (options);    else      DrawInputData1d (options);    break;  case OUTPUT_VIEW3D_SELECT:    DrawInputData3d (options);    break;  case OUTPUT_VIEW2DCLASSMEMBERSHIP_SELECT:    DrawClassMember2d (options);    break;  case OUTPUT_VIEW3DCLASSMEMBERSHIP_SELECT:    DrawClassMember3d (options);    break;  }};void InOutput::DrawDifference2d (int options,			    DVektorArray * originaldata,			    DVektorArray * calculateddata){  int counter, number = originaldata->Lese_Groesse ();  Drawable drawable;  if (options & DRAWINWINDOW)    drawable = window;  else    drawable = pixmap;//switch(typ)  switch (pointtypicons->GetSelectedvalue ()) {  case OUTPUT_POINTTYPPOINT:    {      XSegment *difflines = 0;      XPoint *originalpoints = 0;      XPoint *calculatedpoints = 0;      if (((originalpoints = (XPoint *) malloc (sizeof (XPoint) * number)) == NULL) ||	  ((calculatedpoints = (XPoint *) malloc (sizeof (XPoint) * number)) == NULL) ||	  ((difflines = (XSegment *) malloc (sizeof (XSegment) * number)) == NULL)) {	printf ("Out of memory!\n");	exit (1);      }      for (counter = 0; counter < number; counter++) {	FillPoint (&(originalpoints[counter]),		   originaldata->Lese_Vektor (counter, xindex),		   originaldata->Lese_Vektor (counter, yindex));	FillPoint (&(calculatedpoints[counter]),		   calculateddata->Lese_Vektor (counter, xindex),		   calculateddata->Lese_Vektor (counter, yindex));	difflines[counter].x1 = originalpoints[counter].x;	difflines[counter].y1 = originalpoints[counter].y;	difflines[counter].x2 = calculatedpoints[counter].x;	difflines[counter].y2 = calculatedpoints[counter].y;      }      XSetForeground (display, gc, redpix);      XDrawSegments (display, drawable, gc, difflines, number);      XSetForeground (display, gc, shadowpix);      XDrawPoints (display, drawable, gc, calculatedpoints, number, CoordModeOrigin);      XSetForeground (display, gc, blackpix);      XDrawPoints (display, drawable, gc, originalpoints, number, CoordModeOrigin);      free (difflines);      free (originalpoints);      free (calculatedpoints);    }    break;			// OUTPUT_POINTTYPPOINT  case OUTPUT_POINTTYPCROSS:    

⌨️ 快捷键说明

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