📄 moveicon.cc
字号:
{ switch (acuteconnection->GetEndIcon ()->GetTyp ()) { case MOVEABLEICONTYP_CLUSTER: if (acuteconnection->GetEndIcon () != this) { char bothdimsequal = TRUE; Clustering *targetclustering, *clustering = ClusterOutputwindow->Getclustering (); Datensatz *Dataset = ClusterOutputwindow->GetDataset (); acuteconnection->SendActiontoEnd (ICON_REQUESTFORCLUSTERING, (int) (&targetclustering)); if (targetclustering->Lese_Clusteranzahl () > 0) { if (Dataset != NULL) if (Dataset->Lese_Daten ().Lese_Dim () != targetclustering->Lese_Clusterdimension ()) { Mainwindow->printError ("Cluster dimension not equal to data dimension!"); bothdimsequal = FALSE; } if ((clustering->Lese_Clusteranzahl () > 0) && (clustering->Lese_Clusterdimension () != targetclustering->Lese_Clusterdimension ())) { Mainwindow->printError ("Cluster dimensions of both objects have to be equal!"); bothdimsequal = FALSE; } } if (bothdimsequal) { status |= ICON_CHECKED; char circlefound = FALSE; acuteconnection->SendActiontoEnd (ICON_SEARCHFORCIRCLE, (int) &circlefound); status &= ~ICON_CHECKED; if (!circlefound) { acuteconnection->ErasetempArrow (); acuteconnection->SetStart ((int) (x + width * .5), (int) (y + height * .5)); acuteconnection->DrawArrow (); acuteconnection->GetStartIcon ()->Action (ICON_REMOVECONNECTOUT, (int) (Mainwindow->GetAcuteconnection ())); acuteconnection->SetStartIcon (this); acuteconnection->SetStatus (CONNECTSTATUS_VISIBLE); *Outputs += acuteconnection; Outputs->SendActiontoallEnds (ICON_SENDINGDATASET, (int) (ClusterOutputwindow->GetDataset ())); Outputs->SendActiontoallEnds (ICON_SENDINGDVECTOR, (int) GetOutput ()->GetSelectedinputvector ()); short counter = 1; char *newtext = (char *) malloc (sizeof (char) * (strlen (indextext) + 4)); // has to Connectlist *temp = Outputs; Connection *connection = temp->GetConnection (); while (temp != NULL) { sprintf (newtext, "%s-%d", indextext, counter); if (connection != NULL) connection->SendActiontoEnd (ICON_SENDINGINDEX, (int) newtext); temp = temp->GetNext (); if (temp != NULL) connection = temp->GetConnection (); else connection = NULL; counter++; } Mainwindow->SetStatus (MAINNORMALSTATUS); XDefineCursor (display, Mainwindow->GetWindow (), maincursor); } else Mainwindow->printError ("Circle not allowed!"); } } else Mainwindow->printError ("Cluster-Object cannot be connected to itself!"); break; case MOVEABLEICONTYP_INPUT: Mainwindow->printError ("No connection from Cluster-Object to Input-Object!"); break; case MOVEABLEICONTYP_CLASSIFY: Mainwindow->printError ("No connection from Cluster-Object to Classify-Object!"); break; case MOVEABLEICONTYP_RULE: Mainwindow->printError ("No connection from Cluster-Object to Rule-Object!"); break; }}void ClusterIcon::SetIconname (char *newtext){ short length = strlen (newtext), counter, textstart = 0; for (counter = length - 1; counter >= 0; counter--) if (newtext[counter] == '/') // found last "/" { textstart = counter + 1; break; }//text+=textstart; text = newtext + textstart; DrawMoveableIcon ();}void ClusterIcon::DrawMoveableIcon (){ char *clustertext = ClusterOutputwindow->Getclustering ()->Lese_Name (); short clustertextwidth = XTextWidth (fontstruct, clustertext, strlen (clustertext)); short indextextwidth = XTextWidth (fontstruct, indextext, strlen (indextext)); short textwidth = XTextWidth (fontstruct, text, strlen (text)); short textheight = fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent; width = MAX (clustertextwidth, textwidth); width = MAX (width, indextextwidth); height = 5 * textheight; width += 4; if (pixmap_up != 0) { char *space = " "; char *windowtext = (char *) malloc (sizeof (char) * (4 + strlen (text) + strlen (indextext) + strlen (clustertext))); strcpy (windowtext, ""); strcat (windowtext, text); strcat (windowtext, space); strcat (windowtext, indextext); strcat (windowtext, space); strcat (windowtext, clustertext); ClusterOutputwindow->SetWindowName (windowtext); ClusterOutputwindow->Getmemberoutput ()->SetWindowName (windowtext); XFreePixmap (display, pixmap_up); XFreePixmap (display, pixmap_down); } short depth; width = height = MAX (width, height); SizeMe (width, height); depth = DefaultDepth (display, DefaultScreen (display)); pixmap_up = XCreatePixmap (display, window, width, height, depth); pixmap_down = XCreatePixmap (display, window, width, height, depth); XSetForeground (display, gc, greenbuttonpix); XSetBackground (display, gc, greenbuttonpix); XFillRectangle (display, pixmap_up, gc, 0, 0, width, height); XFillRectangle (display, pixmap_down, gc, 0, 0, width, height); XSegment linesrightlow[4] = { {width - 1, height / 4, width - 1, height / 2}, {width - 2, height / 4 + 1, width - 2, height / 2}, {1, height - 1, width / 2, height - 1}, {2, height - 2, width / 2 - 1, height - 2}, }, lineslefthigh[6] = { {0, 0, width / 2, 0}, {0, 1, width / 2 - 1, 1}, {0, 0, 0, height / 2 - 1}, {1, 0, 1, height / 2 - 4}, {0, 3 * height / 4, 0, height}, {1, 3 * height / 4, 1, height - 1} }, shadowobjectlines[4] = { {width / 2, 0, width / 2, height / 4}, {1 + width / 2, 0, 1 + width / 2, 1 + height / 4}, {0, height / 2, width / 8, height / 4}, {0, height / 2 - 1, width / 8, height / 4 - 1} }, lightobjectlines[5] = { {1, 3 * height / 4, 3 * width / 8 + 1, 3 * height / 4}, {2, 1 + 3 * height / 4, 3 * width / 8, 3 * height / 4 + 1}, {1 + width / 2, height / 4, width - 1, height / 4}, {width / 2, 1 + height / 4, width - 2, 1 + height / 4}, {width / 8, height / 4 - 1, 3 * width / 8, 3 * height / 4} }; XSetForeground (display, gc, greenshadowpix); XDrawArc (display, pixmap_up, gc, width / 2, height / 2, width, height, 90 * 64, 90 * 64); XDrawArc (display, pixmap_up, gc, width / 2, 1 + height / 2, width, height, 90 * 64, 90 * 64); XDrawArc (display, pixmap_up, gc, 1 + width / 2, height / 2, width, height, 90 * 64, 90 * 64); XSetForeground (display, gc, greenlightpix); XDrawArc (display, pixmap_down, gc, width / 2, height / 2, width, height, 90 * 64, 90 * 64); XDrawArc (display, pixmap_down, gc, width / 2, 1 + height / 2, width, height, 90 * 64, 90 * 64); XDrawArc (display, pixmap_down, gc, 1 + width / 2, height / 2, width, height, 90 * 64, 90 * 64); XDrawSegments (display, pixmap_up, gc, lineslefthigh, 6); XDrawSegments (display, pixmap_down, gc, linesrightlow, 4); XDrawSegments (display, pixmap_down, gc, shadowobjectlines, 4); XDrawSegments (display, pixmap_up, gc, lightobjectlines, 5); XSetForeground (display, gc, greenshadowpix); XDrawSegments (display, pixmap_up, gc, linesrightlow, 4); XDrawSegments (display, pixmap_down, gc, lineslefthigh, 6); XDrawSegments (display, pixmap_up, gc, shadowobjectlines, 4); XDrawSegments (display, pixmap_down, gc, lightobjectlines, 5); short textx, texty; XSetForeground (display, gc, blackpix); 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); XDrawString (display, pixmap_up, gc, textx, texty - textheight, text, strlen (text)); XDrawString (display, pixmap_down, gc, textx, texty - textheight, text, strlen (text)); textx = (int) ((width - XTextWidth (fontstruct, clustertext, strlen (clustertext))) * .5); XDrawString (display, pixmap_up, gc, textx, texty + textheight, clustertext, strlen (clustertext)); XDrawString (display, pixmap_down, gc, textx, texty + textheight, clustertext, strlen (clustertext)); textx = (int) ((width - XTextWidth (fontstruct, indextext, strlen (indextext))) * .5); XDrawString (display, pixmap_up, gc, textx, texty, indextext, strlen (indextext)); XDrawString (display, pixmap_down, gc, textx, texty, indextext, strlen (indextext)); DrawIcon (~ICON_SELECTED); CenterConnections ();}void ClusterIcon::Action (int actiontyp, int value){ switch (actiontyp) { case ICON_SEARCHFORCIRCLE: if (status & ICON_CHECKED) { *((char *) value) = TRUE; break; } status |= ICON_CHECKED; Outputs->SendActiontoallEnds (ICON_SEARCHFORCIRCLE, value); status &= ~ICON_CHECKED; break; case ICON_SENDINGDVECTOR: GetOutput ()->SetSelectedinputvector ((DVektor *) value); Outputs->SendActiontoallEnds (ICON_SENDINGDVECTOR, value); break; case ICON_REQUESTFORDVECTOR: *((DVektor **) value) = ClusterOutputwindow->GetSelectedinputvector (); break; case ICON_REMOVECONNECTIN: In = NULL; ClusterOutputwindow->SetDataset ((Datensatz *) NULL); text = "unplugged"; indextext = " "; DrawMoveableIcon (); if (Outputs != NULL) { Outputs->SendActiontoallEnds (ICON_SENDINGDVECTOR, (int) NULL); Outputs->SendActiontoallEnds (ICON_SENDINGDATASET, (int) NULL); } break; case ICON_REMOVECONNECTOUT: *Outputs -= (Connection *) (value); break; case ICON_DATASETMODIFIED:// ClusterOutputwindow->Action(OUTPUT_REDRAW,0); // ClusterOutputwindow->UpdateOutput(); ClusterOutputwindow->Action (OUTPUT_DATASETMODIFIED, 0); Outputs->SendActiontoallEnds (ICON_DATASETMODIFIED, 0); break; case ICON_SENDINGDATASET: if ((Datensatz *) value != ClusterOutputwindow->GetDataset ()) { if ((Datensatz *) value == NULL) { text = "unplugged"; indextext = " "; DrawMoveableIcon (); } ClusterOutputwindow->SetDataset ((Datensatz *) value); Outputs->SendActiontoallEnds (ICON_SENDINGDATASET, value); } break; case ICON_REQUESTFORDATASET: *((Datensatz **) value) = ClusterOutputwindow->GetDataset (); break; case ICON_REQUESTFORCLUSTERING: *((Clustering **) value) = ClusterOutputwindow->Getclustering (); break; case ICON_SENDINGDATASETNAME: text = (char *) value; DrawMoveableIcon (); break; case ICON_REQUESTFORINDEX: { short counter = 1; char *newtext = (char *) malloc (sizeof (char) * (4 + strlen (indextext))); char *temptext = (char *) malloc (sizeof (char) * 4); Connectlist *temp = Outputs; while ((temp != NULL) && (temp->GetConnection () != (Connection *) value)) { counter++; temp = temp->GetNext (); } sprintf (temptext, "-%d", counter); strcpy (newtext, indextext); strcat (newtext, temptext); Connection *connection = temp->GetConnection (); if ((connection != NULL) && strcmp (indextext, "")) connection->SendActiontoEnd (ICON_SENDINGINDEX, (int) newtext); } break; case ICON_SENDINGINDEX: indextext = (char *) value; DrawMoveableIcon (); { Connectlist *temp = Outputs; while (temp != NULL) { Action (ICON_REQUESTFORINDEX, (int) temp->GetConnection ()); temp = temp->GetNext (); } } break; }}RuleIcon::RuleIcon (Display * initdisplay, GC initgc, XFontStruct * fontstruct, MainWindow * initMainwindow, int initx, int inity, int initwidth, int initheight, char *inittext, RuleInfo * ruleinfo):MoveableIcon (initdisplay, initgc, fontstruct, initMainwindow, initx, inity, initwidth, initheight, inittext){ index = 0; pixmap_up = 0; RuleOutputwindow = new RuleOutput (display, gc, this, fontstruct, 70, 10, OUTPUTMINSIZE, OUTPUTMINSIZE, text, ruleinfo); DrawMoveableIcon ();};RuleIcon::~RuleIcon (){ delete RuleOutputwindow;}void RuleIcon::Doubleclicked (){ RuleOutputwindow->MapMe ();}void RuleIcon::Connectin (Connection * acuteconnection){ switch (acuteconnection->GetStartIcon ()->GetTyp ()) { case MOVEABLEICONTYP_INPUT: if (In == NULL) { if (Outputs->GetConnection () == NULL) { 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); RuleOutputwindow->SetDataset (tempdataset); } XDefineCursor (display, Mainwindow->GetWindow (), maincursor); } else Mainwindow->printError ("Only input if no output exists!"); } else Mainwindow->printError ("Only one input to Rule-Object!"); break; case MOVEABLEICONTYP_CLUSTER: Mainwindow->printError ("No connection from Cluster-Object to Rule-Object!"); break; case MOVEABLEICONTYP_RULE: Mainwindow->printError ("No connection from Rule-Object to Rule-Object!"); break; case MOVEABLEICONTYP_CLASSIFY: Mainwindow->printError ("No connection from Classify-Object to Rule-Object!"); break; default: break; }}void RuleIcon::Connectout (Connection * acuteconnection){ if (In == NULL) { Mainwindow->SetStatus (MAINENDCONNECTSTATUS); acuteconnection->SetStartIcon (this); *Outputs += acuteconnection; XDefineCursor (display, Mainwindow->GetWindow (), createendcursor); } else Mainwindow->printError ("Only output, if no input exists!");}void RuleIcon::ChangeConnectin (Connection * acuteconnection){}void RuleIcon::ChangeConnectout (Connection * acuteconnection){ if (Outputs->GetConnection () == NULL) { if (In == NULL) { switch (acuteconnection->GetEndIcon ()->GetTyp ()) { case MOVEABLEICONTYP_INPUT: acuteconnection->GetStartIcon ()->Action (ICON_REMOVECONNECTOUT, (int) (Mainwindow->GetAcuteconnection ())); acuteconnection->ErasetempArrow (); acuteconnection->SetStart ((int) (x + width * .5), (int) (y + height * .5)); acuteconnection->DrawArrow (); acuteconnection->GetStartIcon ()->Action (ICON_REMOVECONNECTOUT, (int) (Mainwindow->GetAcuteconnection ())); acuteconnection->SetStartIcon (this); acuteconnection->SetStatus (CONNECTSTATUS_VISIBLE); Mainwindow->SetStatus (MAINNORMALSTATUS); *Outputs += Mainwindow->GetAcuteconnection (); XDefineCursor (display, Mainwindow->GetWindow (), maincursor); acuteconnection->GetEndIcon ()->ChangeConnectin (acuteconnection); break; case MOVEABLEICONTYP_CLASSIFY: Mainwindow->printError ("No connection from Rule-Object to Classify-Object!"); break; case MOVEABLEICONTYP_CLUSTER:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -