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

📄 moveicon.cc

📁 模糊聚类分析的源程序!
💻 CC
📖 第 1 页 / 共 4 页
字号:
	   int initx, int inity, int initwidth, int initheight,	   char *inittext):MoveableIcon (initdisplay,	      initgc,	      fontstruct,	      initMainwindow,	      initx, inity, initwidth, initheight,	      inittext){  InOutputwindow = new InOutput (display,				 gc,				 this,				 fontstruct,				 70, 10,				 OUTPUTMINSIZE, OUTPUTMINSIZE,				 text);  DrawMoveableIcon ();};InputIcon::~InputIcon (){  delete InOutputwindow;}void InputIcon::Doubleclicked (){  InOutputwindow->MapMe ();}void InputIcon::Connectin (Connection * acuteconnection){  if (In == NULL) {    switch (acuteconnection->GetStartIcon ()->GetTyp ()) {    case MOVEABLEICONTYP_RULE:      if (InOutputwindow->GetDataset ()->Lese_OutputDim () == 0) {	Mainwindow->printError ("Input-Objects dataset has no outputs!");	break;      }    case MOVEABLEICONTYP_CLASSIFY:      acuteconnection->ErasetempArrow ();      acuteconnection->SetEnd ((int) (x + width * .5), (int) (y + height * .5));      acuteconnection->DrawArrow ();      Mainwindow->SetStatus (MAINNORMALSTATUS);      acuteconnection->SetStatus (CONNECTSTATUS_VISIBLE);      if (acuteconnection->GetEndIcon () != this) {	if (acuteconnection->GetEndIcon () != NULL)	  acuteconnection->GetEndIcon ()->Action (ICON_REMOVECONNECTIN, (int) (Mainwindow->GetAcuteconnection ()));	acuteconnection->SetEndIcon (this);	In = acuteconnection;      }      ChangeConnectin (acuteconnection);      XDefineCursor (display, Mainwindow->GetWindow (), maincursor);      break;    case MOVEABLEICONTYP_INPUT:      Mainwindow->printError ("No connection from Input-Object to Input-Object!");      break;    case MOVEABLEICONTYP_CLUSTER:      Mainwindow->printError ("No connection from Cluster-Object to Input-Object!");      break;    }  } else    Mainwindow->printError ("Only one input to Input-Object!");}void InputIcon::Connectout (Connection * acuteconnection){  Mainwindow->SetStatus (MAINENDCONNECTSTATUS);  acuteconnection->SetStartIcon (this);  *Outputs += acuteconnection;  XDefineCursor (display, Mainwindow->GetWindow (), createendcursor);}void InputIcon::ChangeConnectin (Connection * acuteconnection){  InOutputwindow->Action (OUTPUT_ICONLOSTINPUTCONNECTION, 0);  switch (Mainwindow->GetAcuteconnection ()->GetStartIcon ()->GetTyp ()) {  case MOVEABLEICONTYP_RULE:    {      RuleResultInfo *tempinfo;      InOutputwindow->Action (OUTPUT_ICONREQUESTFORRULERESULTINFO, (int) &tempinfo);      In->SendActiontoStart (ICON_REQUESTFORRULERESULTS, (int) tempinfo);      InOutputwindow->Action (OUTPUT_REDRAW, 0);      InOutputwindow->UpdateOutput ();    }    break;  case MOVEABLEICONTYP_CLASSIFY:    In->SendActiontoStart (ICON_REQUESTFORCLASSIFYRESULTS, (int) InOutputwindow->GetDataset ());    InOutputwindow->Action (OUTPUT_REDRAW, 0);    InOutputwindow->UpdateOutput ();    break;  default:    break;  }}void InputIcon::ChangeConnectout (Connection * acuteconnection){  if (acuteconnection->GetEndIcon ()->GetTyp () != MOVEABLEICONTYP_INPUT) {    char bothdimsequal = TRUE;    if (acuteconnection->GetEndIcon ()->GetTyp () == MOVEABLEICONTYP_CLUSTER) {      Clustering *targetclustering;      Datensatz *Dataset = InOutputwindow->GetDataset ();      acuteconnection->SendActiontoEnd (ICON_REQUESTFORCLUSTERING, (int) (&targetclustering));      if (targetclustering->Lese_Clusteranzahl () > 0)	if (targetclustering->Lese_Clusterdimension () != Dataset->Lese_Daten ().Lese_Dim ())	  bothdimsequal = FALSE;    }    if (bothdimsequal) {      acuteconnection->GetStartIcon ()->Action (ICON_REMOVECONNECTOUT, (int) (Mainwindow->GetAcuteconnection ()));      acuteconnection->ErasetempArrow ();      acuteconnection->SetStart ((int) (x + width * .5), (int) (y + height * .5));      acuteconnection->DrawArrow ();      Mainwindow->SetStatus (MAINNORMALSTATUS);      acuteconnection->SetStartIcon (this);      acuteconnection->SetStatus (CONNECTSTATUS_VISIBLE);      *Outputs += acuteconnection;      Outputs->SendActiontoallEnds (ICON_SENDINGDATASET,				    (int) (InOutputwindow->GetDataset ()));      Outputs->SendActiontoallEnds (ICON_SENDINGDVECTOR,			   (int) InOutputwindow->GetSelectedinputvector ());      short counter = 1;      char *newtext = (char *) malloc (sizeof (char) * 3);	// 3 has to be enough      Connectlist *temp = Outputs;      Connection *connection = temp->GetConnection ();      while (connection != NULL) {	sprintf (newtext, "%d", counter);	connection->SendActiontoEnd (ICON_SENDINGINDEX, (int) newtext);	temp = temp->GetNext ();	if (temp != NULL)	  connection = temp->GetConnection ();	else	  connection = NULL;	counter++;      }      XDefineCursor (display, Mainwindow->GetWindow (), maincursor);    } else      Mainwindow->printError ("Cluster dimension not equal to data dimension!");  } else    Mainwindow->printError ("No connection from Input-Object to Input-Object!");}void InputIcon::DrawMoveableIcon (){  short textx, texty, depth;  width = XTextWidth (fontstruct, text, strlen (text)) + 4;  width = MAX (width, MOVEABLEICON_WIDTH);  height = width;  SizeMe (width, height);  textx = (int) ((width - XTextWidth (fontstruct, text, strlen (text))) * .5);  texty = (int) ((height + fontstruct->max_bounds.ascent +     fontstruct->max_bounds.descent) * .5 - fontstruct->max_bounds.descent);  if (pixmap_up != 0)    XFreePixmap (display, pixmap_up);  if (pixmap_down != 0)    XFreePixmap (display, pixmap_down);  depth = DefaultDepth (display, DefaultScreen (display));  pixmap_up = XCreatePixmap (display, window, width, height, depth);  pixmap_down = XCreatePixmap (display, window, width, height, depth);  XSetForeground (display, gc, yellowbuttonpix);  XSetBackground (display, gc, yellowbuttonpix);  XFillRectangle (display, pixmap_up, gc, 0, 0, width, height);  XFillRectangle (display, pixmap_down, gc, 0, 0, width, height);  XSegment linesrightlow[4] =  {    {width - 1, 1, width - 1, height - 1},    {width - 2, 2, width - 2, height - 1},    {1, height - 1, width - 1, height - 1},    {2, height - 2, width - 1, height - 2},  }, lineslefthigh[6] =  {    {0, 0, width - 2, 0},    {0, 1, width - 3, 1},    {0, 0, 0, (height / 4) - 1},    {1, 0, 1, (height / 4) - 2},    {0, (3 * height / 4), 0, height - 2},    {1, (3 * height / 4), 1, height - 3}  }, shadowarrowlines[7] =  {    {1, (height / 4), (width / 2), (height / 4)},    {2, (height / 4) - 1, (width / 2) + 1, (height / 4) - 1},    {(width / 2), (height / 4), (width / 2), 2},    {(width / 2) + 1, (height / 4), (width / 2) + 1, 2},    {(width / 2), 2, width - 3, (height / 2) - 1},    {(width / 2), (3 * height / 4), (width / 2), height - 3},    {(width / 2) + 1, (3 * height / 4), (width / 2) + 1, height - 3}  }, lightarrowlines[4] =  {    {1, (3 * height / 4), (width / 2) + 1, (3 * height / 4)},    {2, (3 * height / 4) + 1, (width / 2), (3 * height / 4) + 1},    {(width / 2) + 2, height - 4, width - 3, (height / 2)},    {(width / 2) + 2, height - 5, width - 4, (height / 2)}  };  XSetForeground (display, gc, yellowshadowpix);  XDrawSegments (display, pixmap_up, gc, linesrightlow, 4);  XDrawSegments (display, pixmap_down, gc, lineslefthigh, 6);  XDrawSegments (display, pixmap_up, gc, shadowarrowlines, 7);  XDrawSegments (display, pixmap_down, gc, lightarrowlines, 4);  XSetForeground (display, gc, yellowlightpix);  XDrawSegments (display, pixmap_up, gc, lineslefthigh, 6);  XDrawSegments (display, pixmap_down, gc, linesrightlow, 4);  XDrawSegments (display, pixmap_down, gc, shadowarrowlines, 7);  XDrawSegments (display, pixmap_up, gc, lightarrowlines, 4);  XSetForeground (display, gc, blackpix);  XDrawString (display, pixmap_up, gc, textx, texty, text, strlen (text));  XDrawString (display, pixmap_down, gc, textx, texty, text, strlen (text));}void InputIcon::Action (int actiontyp, int value){  switch (actiontyp) {  case ICON_DATASETCLASSIFIED:    InOutputwindow->Action (OUTPUT_CLASSIFIED, value);    break;  case ICON_RULERESULTSCHANGED:  case ICON_CLASSIFYRESULTSCHANGED:    InOutputwindow->Action (OUTPUT_REDRAW, 0);    InOutputwindow->UpdateOutput ();    break;  case ICON_REMOVECONNECTOUT:    *Outputs -= (Connection *) (value);    break;  case ICON_REMOVECONNECTIN:    In = NULL;    InOutputwindow->Action (OUTPUT_ICONLOSTINPUTCONNECTION, 0);    break;  case ICON_DATASETMODIFIED:    Outputs->SendActiontoallEnds (ICON_DATASETMODIFIED, 0);    if (In != NULL) {      switch (In->GetStartIcon ()->GetTyp ()) {      case MOVEABLEICONTYP_RULE:	In->SendActiontoStart (ICON_REQUESTFORRULERESULTS, value);	break;      case MOVEABLEICONTYP_CLASSIFY:	In->SendActiontoStart (ICON_REQUESTFORCLASSIFYRESULTS, (int) InOutputwindow->GetDataset ());//                InOutputwindow->Action(OUTPUT_CLASSIFIED,0);	break;      default:	break;      }    }    break;  case ICON_REQUESTFORDVECTOR:    *((DVektor **) value) = InOutputwindow->GetSelectedinputvector ();    break;  case ICON_SENDINGDVECTOR:    Outputs->SendActiontoallEnds (ICON_SENDINGDVECTOR, value);    break;  case ICON_REQUESTFORDATASET:    *((Datensatz **) value) = InOutputwindow->GetDataset ();    break;  case ICON_REQUESTFORINDEX:    {      short counter = 1;      char *newtext = (char *) malloc (sizeof (char) * 3);      Connectlist *temp = Outputs;      Connection *connection = temp->GetConnection ();      while ((connection == NULL) || (connection != (Connection *) value)) {	counter++;	temp = temp->GetNext ();	if (temp != NULL)	  connection = temp->GetConnection ();	else	  temp = NULL;      }      sprintf (newtext, "%d", counter);      if (connection != NULL)	connection->SendActiontoEnd (ICON_SENDINGINDEX, (int) newtext);    }    break;  }}ClusterIcon::ClusterIcon (Display * initdisplay,	     GC initgc,	     XFontStruct * fontstruct,	     MainWindow * initMainwindow,	     int initx, int inity,	     int initwidth, int initheight,	     char *text,	     ClusterInfo * values)://                         Clustering *theclustering):MoveableIcon (initdisplay,	      initgc,	      fontstruct,	      initMainwindow,	      initx, inity, initwidth, initheight,	      text){  pixmap_up = 0;  pixmap_down = 0;  indextext = "";  ClusterOutputwindow = new ClusterOutput (display,					   gc,					   this,					   fontstruct,					   70, 10,					   OUTPUTMINSIZE, OUTPUTMINSIZE,					   text);  if (values != NULL)    ClusterOutputwindow->SetClustertyp (values);  else {    ClusterInfo defaultvalues;    defaultvalues.clusternumber = MAXINT;    defaultvalues.repeatnumber = MAXINT;    defaultvalues.clustertyp = FCM;    defaultvalues.validitytyp = NONE;    ClusterOutputwindow->SetClustertyp (&defaultvalues);//  if(theclustering!=NULL)    //    ClusterOutputwindow->Action(OUTPUT_LOADOK, (int) theclustering);  }};ClusterIcon::~ClusterIcon (){  delete ClusterOutputwindow;}void ClusterIcon::Doubleclicked (){  ClusterOutputwindow->MapMe ();}void ClusterIcon::Pressedbutton3 (){  ClusterOutputwindow->Action (OUTPUT_DISPLAYCLUSTEROPTIONS_ACTION, 0);}void ClusterIcon::Connectin (Connection * acuteconnection){  if (acuteconnection->GetStartIcon ()->GetTyp () != MOVEABLEICONTYP_RULE) {    if (acuteconnection->GetStartIcon ()->GetTyp () != MOVEABLEICONTYP_CLASSIFY) {      if (In == NULL) {	if (acuteconnection->GetStartIcon () != this) {	  char bothdimsequal = TRUE;	  Datensatz *tempdataset;	  Clustering *clustering = ClusterOutputwindow->Getclustering ();	  acuteconnection->SendActiontoStart (ICON_REQUESTFORDATASET, (int) &tempdataset);	  if (tempdataset != NULL)	    if ((clustering->Lese_Clusteranzahl () > 0) &&		(tempdataset->Lese_Daten ().Lese_Dim ()) != clustering->Lese_Clusterdimension ())	      bothdimsequal = FALSE;	  if (bothdimsequal) {	    acuteconnection->GetStartIcon ()->AddStatus (ICON_CHECKED);	    status |= ICON_CHECKED;	    char circlefound = FALSE;	    Outputs->SendActiontoallEnds (ICON_SEARCHFORCIRCLE, (int) &circlefound);	    status &= ~ICON_CHECKED;	    acuteconnection->GetStartIcon ()->DelStatus (ICON_CHECKED);	    if (!circlefound) {	      acuteconnection->ErasetempArrow ();	      acuteconnection->SetEnd ((int) (x + width * .5), (int) (y + height * .5));	      acuteconnection->DrawArrow ();	      Mainwindow->SetStatus (MAINNORMALSTATUS);	      acuteconnection->SetStatus (CONNECTSTATUS_VISIBLE);	      if (acuteconnection->GetEndIcon () != this) {		if (acuteconnection->GetEndIcon () != NULL)		  acuteconnection->GetEndIcon ()->Action (ICON_REMOVECONNECTIN, (int) acuteconnection);		acuteconnection->SetEndIcon (this);		In = acuteconnection;		Datensatz *tempdataset;		In->SendActiontoStart (ICON_REQUESTFORDATASET, (int) &tempdataset);		ClusterOutputwindow->SetDataset (tempdataset);		Outputs->SendActiontoallEnds (ICON_SENDINGDATASET, (int) tempdataset);		DVektor *tempinput;		In->SendActiontoStart (ICON_REQUESTFORDVECTOR, (int) &tempinput);		ClusterOutputwindow->SetSelectedinputvector (tempinput);		Outputs->SendActiontoallEnds (ICON_SENDINGDVECTOR, (int) tempinput);		In->SendActiontoStart (ICON_REQUESTFORINDEX, (int) In);	      }	      XDefineCursor (display, Mainwindow->GetWindow (), maincursor);	    } else	      Mainwindow->printError ("Circle not allowed!");	  } else	    Mainwindow->printError ("Cluster dimension not equal to data dimension!");	} else	  Mainwindow->printError ("Cluster-Object cannot be connected to itself!");      } else	Mainwindow->printError ("Only one input to Cluster-Object!");    } else      Mainwindow->printError ("No connection from Classify-Object to Cluster-Object!");  } else    Mainwindow->printError ("No connection from Rule-Object to Cluster-Object!");}void ClusterIcon::Connectout (Connection * acuteconnection){  Mainwindow->SetStatus (MAINENDCONNECTSTATUS);  acuteconnection->SetStartIcon (this);  *Outputs += acuteconnection;  XDefineCursor (display, Mainwindow->GetWindow (), createendcursor);}void ClusterIcon::ChangeConnectin (Connection * acuteconnection){}void ClusterIcon::ChangeConnectout (Connection * acuteconnection)

⌨️ 快捷键说明

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