📄 moveicon.cc
字号:
Mainwindow->printError ("No connection from Rule-Object to Cluster-Object!"); break; case MOVEABLEICONTYP_RULE: Mainwindow->printError ("No connection from Rule-Object to Rule-Object!"); break; } } else Mainwindow->printError ("Only output, if no input exists!"); } else Mainwindow->printError ("Only output, if no output exists!");}void RuleIcon::DrawMoveableIcon (){ short textx, texty, depth; char *indextext = (char *) malloc (sizeof (char) * 5); // has to be enough sprintf (indextext, "%d", index); short textheight = fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent; width = MAX (XTextWidth (fontstruct, text, strlen (indextext)), XTextWidth (fontstruct, text, strlen (text))); width += 4; height = 5 * textheight; width = height = (((width) > (height)) ? (width) : (height)); SizeMe (width, height); if (pixmap_up != 0) { XFreePixmap (display, pixmap_up); XFreePixmap (display, pixmap_down); char *space = " "; char *windowtext = (char *) malloc (sizeof (char) * (4 + strlen (text) + strlen (indextext))); strcpy (windowtext, ""); strcat (windowtext, text); strcat (windowtext, space); strcat (windowtext, indextext); RuleOutputwindow->SetWindowName (windowtext); } depth = DefaultDepth (display, DefaultScreen (display)); pixmap_up = XCreatePixmap (display, window, width, height, depth); pixmap_down = XCreatePixmap (display, window, width, height, depth); XSetForeground (display, gc, redbuttonpix); XFillRectangle (display, pixmap_up, gc, 0, 0, width, height); XFillRectangle (display, pixmap_down, gc, 0, 0, width, height); XSegment shadowlines[12] = { {1, height - 1, width - 1, height - 1}, {2, height - 2, width - 1, height - 2}, {width - 1, 1, width - 1, height - 1}, {width - 2, 1, width - 2, height - 2}, {width / 8, 3 * height / 8, 3 * width / 8, height / 8}, {1 + width / 8, 3 * height / 8, 3 * width / 8, 1 + height / 8}, {width / 8, 1 + 3 * height / 8, 5 * width / 8, 5 * height / 8}, {1 + width / 8, 1 + 3 * height / 8, 5 * width / 8 - 1, 5 * height / 8 - 1}, {3 * width / 4, 5 * height / 8, 5 * width / 8, 3 * height / 4}, {3 * width / 4, 5 * height / 8 + 1, 5 * width / 8 + 1, 3 * height / 4}, {3 * width / 4, 7 * height / 8, 5 * width / 8, 3 * height / 4}, {3 * width / 4, 7 * height / 8 - 1, 5 * width / 8 + 1, 3 * height / 4} }; XSegment lightlines[10] = { {0, 0, 0, height - 2}, {1, 0, 1, height - 3}, {0, 0, width - 2, 0}, {0, 1, width - 3, 1}, {1 + 3 * width / 8, height / 8, 5 * width / 8, 5 * height / 8}, {1 + 3 * width / 8, 1 + height / 8, 5 * width / 8 - 1, 5 * height / 8 - 1}, {3 * width / 4, 5 * height / 8, 7 * width / 8, 3 * height / 4}, {3 * width / 4, 5 * height / 8 + 1, 7 * width / 8 - 1, 3 * height / 4}, {3 * width / 4, 7 * height / 8, 7 * width / 8, 3 * height / 4}, {3 * width / 4, 7 * height / 8 - 1, 7 * width / 8 - 1, 3 * height / 4} }; XSetForeground (display, gc, redshadowpix); XDrawSegments (display, pixmap_up, gc, shadowlines, 12); XDrawSegments (display, pixmap_down, gc, lightlines, 10); XSetForeground (display, gc, redlightpix); XDrawSegments (display, pixmap_down, gc, shadowlines, 12); XDrawSegments (display, pixmap_up, gc, lightlines, 10); XSetForeground (display, gc, blackpix); texty = (int) ((height + fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent) * .5 - fontstruct->max_bounds.descent) - textheight; textx = (int) ((width - XTextWidth (fontstruct, text, strlen (text))) * .5);//texty=2*textheight; XDrawString (display, pixmap_up, gc, textx, texty, text, strlen (text)); XDrawString (display, pixmap_down, gc, textx, texty, text, strlen (text)); textx = (int) ((width - XTextWidth (fontstruct, indextext, strlen (indextext))) * .5); texty += 2 * textheight; XDrawString (display, pixmap_up, gc, textx, texty, indextext, strlen (indextext)); XDrawString (display, pixmap_down, gc, textx, texty, indextext, strlen (indextext));}void RuleIcon::Action (int actiontyp, int value){ switch (actiontyp) { case ICON_REQUESTFORRULERESULTS: RuleOutputwindow->CalculateResults ((RuleResultInfo *) value); break; case ICON_RULERESULTSCHANGED: Outputs->SendActiontoallEnds (ICON_RULERESULTSCHANGED, 0); break; case ICON_REMOVECONNECTIN: RuleOutputwindow->SetDataset ((Datensatz *) NULL); In = NULL; break; case ICON_REMOVECONNECTOUT: *Outputs -= (Connection *) (value); RuleOutputwindow->SetDataset ((Datensatz *) NULL); break; case ICON_SENDINGDATASET: RuleOutputwindow->SetDataset ((Datensatz *) value); break; case ICON_REQUESTFORDVECTOR: if (In != NULL) In->SendActiontoStart (ICON_REQUESTFORDVECTOR, value); break; case ICON_SENDINGDVECTOR: RuleOutputwindow->SetSelectedinputvector ((DVektor *) value); break; }}ClassifyIcon::ClassifyIcon (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; ClassifyOutputwindow = new ClassifyOutput (display, gc, this, fontstruct, 70, 10, OUTPUTMINSIZE, OUTPUTMINSIZE, text, ruleinfo); DrawMoveableIcon ();};ClassifyIcon::~ClassifyIcon (){ delete ClassifyOutputwindow;}void ClassifyIcon::Doubleclicked (){ ClassifyOutputwindow->MapMe ();}void ClassifyIcon::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); ClassifyOutputwindow->SetDataset (tempdataset); } XDefineCursor (display, Mainwindow->GetWindow (), maincursor); } else Mainwindow->printError ("Only input if no output exists!"); } else Mainwindow->printError ("Only one input to Classify-Object!"); break; case MOVEABLEICONTYP_CLUSTER: Mainwindow->printError ("No connection from Cluster-Object to Classify-Object!"); break; case MOVEABLEICONTYP_RULE: Mainwindow->printError ("No connection from Rule-Object to Classify-Object!"); break; case MOVEABLEICONTYP_CLASSIFY: Mainwindow->printError ("No connection from Classify-Object to Classify-Object!"); break; }}void ClassifyIcon::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 ClassifyIcon::ChangeConnectin (Connection * acuteconnection){}void ClassifyIcon::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 Classify-Object to Classify-Object!"); break; case MOVEABLEICONTYP_CLUSTER: Mainwindow->printError ("No connection from Classify-Object to Cluster-Object!"); break; case MOVEABLEICONTYP_RULE: Mainwindow->printError ("No connection from Classify-Object to Rule-Object!"); break; } } else Mainwindow->printError ("Only output, if no input exists!"); } else Mainwindow->printError ("Only output, if no output exists!");}void ClassifyIcon::DrawMoveableIcon (){ short textx, texty, depth; char *indextext = (char *) malloc (sizeof (char) * 5); // has to be enough sprintf (indextext, "%d", index); short textheight = fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent; width = MAX (XTextWidth (fontstruct, text, strlen (indextext)), XTextWidth (fontstruct, text, strlen (text))); width += 4; height = 5 * textheight; width = height = (((width) > (height)) ? (width) : (height)); SizeMe (width, height); if (pixmap_up != 0) { XFreePixmap (display, pixmap_up); XFreePixmap (display, pixmap_down); char *space = " "; char *windowtext = (char *) malloc (sizeof (char) * (4 + strlen (text) + strlen (indextext))); strcpy (windowtext, ""); strcat (windowtext, text); strcat (windowtext, space); strcat (windowtext, indextext); ClassifyOutputwindow->SetWindowName (windowtext); } depth = DefaultDepth (display, DefaultScreen (display)); pixmap_up = XCreatePixmap (display, window, width, height, depth); pixmap_down = XCreatePixmap (display, window, width, height, depth); XSetForeground (display, gc, bluebuttonpix); XFillRectangle (display, pixmap_up, gc, 0, 0, width, height); XFillRectangle (display, pixmap_down, gc, 0, 0, width, height); XSegment shadowlines[28] = { {1, height - 1, width / 2, height - 1}, {2, height - 2, width / 2, height - 2}, {5 * width / 8, height - 1, width - 1, height - 1}, {5 * width / 8 + 1, height - 2, width - 1, height - 2}, {width - 1, 1, width - 1, height / 4}, {width - 2, 1, width - 2, height / 4 - 1}, {3 * width / 4, 3 * height / 8, 3 * width / 4, height / 2}, {3 * width / 4 + 1, 3 * height / 8 - 1, 3 * width / 4 + 1, height / 2 - 1}, {7 * width / 8, height / 4, width - 2, height / 4}, {7 * width / 8 + 1, height / 4 - 1, width - 1, height / 4 - 1}, {3 * width / 4 + 1, height / 8, 7 * width / 8, height / 8}, {3 * width / 4, height / 8 - 1, 7 * width / 8 + 1, height / 8 - 1}, {3 * width / 4, height / 8, 3 * width / 4, height / 4 - 1}, {3 * width / 4 + 1, height / 8 - 1, 3 * width / 4 + 1, height / 4}, {5 * width / 8, height / 4, 3 * width / 4 + 1, height / 4}, {5 * width / 8 + 1, height / 4 - 1, 3 * width / 4, height / 4 - 1}, {width / 2, height / 4, width / 2, 3 * height / 8}, {width / 2 + 1, height / 4, width / 2 + 1, 3 * height / 8 - 1}, {width - 1, 3 * height / 8, width - 1, height - 1}, {width - 2, 3 * height / 8 + 1, width - 2, height - 2}, {width / 4, 5 * height / 8, width / 4, 3 * height / 4}, {width / 4 + 1, 5 * height / 8 + 1, width / 4 + 1, 3 * height / 4 - 1}, {width / 4, 5 * height / 8, 3 * width / 4, 5 * height / 8}, {width / 4 + 1, 5 * height / 8 + 1, 3 * width / 4 - 1, 5 * height / 8 + 1}, {5 * width / 8, 0, width / 2, height / 4}, {5 * width / 8 + 1, 0, width / 2 + 1, height / 4}, {5 * width / 8, 3 * height / 4, width / 2, height - 1}, {5 * width / 8 + 1, 3 * height / 4 - 1, width / 2 + 1, height - 1} }; XSegment lightlines[26] = { {0, 0, 0, 3 * height / 8}, {1, 0, 1, 3 * height / 8 - 1}, {0, height / 2 + 2, 0, height - 2}, {1, height / 2 + 2, 1, height - 3}, {0, 0, 5 * width / 8, 0}, {0, 1, 5 * width / 8 - 1, 1}, {3 * height / 4, 0, width - 2, 0}, {3 * height / 4, 1, width - 3, 1}, {7 * width / 8, 3 * height / 8, width - 1, 3 * height / 8}, {7 * width / 8 + 1, 3 * height / 8 + 1, width - 2, 3 * height / 8 + 1}, {5 * width / 8, height - 2, 3 * width / 4, 3 * height / 4}, {5 * width / 8 - 1, height - 1, 3 * width / 4 - 1, 3 * height / 4 - 1}, {width / 2, 3 * height / 8, 3 * width / 4, 3 * height / 8}, {width / 2 + 1, 3 * height / 8 - 1, 3 * width / 4 + 1, 3 * height / 8 - 1}, {7 * width / 8, height / 8, 7 * width / 8, height / 4}, {7 * width / 8 + 1, height / 8 - 1, 7 * width / 8 + 1, height / 4 - 1}, {3 * width / 4, 5 * height / 8, 3 * width / 4, 3 * height / 4}, {3 * width / 4 - 1, 5 * height / 8 + 1, 3 * width / 4 - 1, 3 * height / 4 - 1}, {3 * width / 4, height / 2, 7 * width / 8, height / 2}, {3 * width / 4 + 1, height / 2 - 1, 7 * width / 8 + 1, height / 2 - 1}, {7 * width / 8, height / 2 - 1, 7 * width / 8, 3 * height / 8}, {7 * width / 8 + 1, height / 2, 7 * width / 8 + 1, 3 * height / 8 + 1}, {5 * width / 8, height / 4, 3 * width / 4 - 1, 0}, {5 * width / 8 + 1, height / 4 - 1, 3 * width / 4, 1}, {width / 4, 3 * height / 4, 5 * width / 8, 3 * height / 4}, {width / 4 + 1, 3 * height / 4 - 1, 5 * width / 8 + 1, 3 * height / 4 - 1} }; XSetForeground (display, gc, blueshadowpix); XDrawArc (display, pixmap_up, gc, -width / 8, -3 * height / 8, width / 4, 3 * height / 4, 270 * 64, 360 * 64); XDrawArc (display, pixmap_up, gc, -width / 8, -3 * height / 8 + 1, width / 4, 3 * height / 4, 270 * 64, 360 * 64); XDrawArc (display, pixmap_up, gc, -width / 8 + 1, -3 * height / 8, width / 4, 3 * height / 4, 270 * 64, 360 * 64); XDrawArc (display, pixmap_down, gc, -width / 4, -height / 2, width / 2, height, 270 * 64, 360 * 64); XDrawArc (display, pixmap_down, gc, -width / 4, -height / 2 + 1, width / 2, height, 270 * 64, 360 * 64); XDrawArc (display, pixmap_down, gc, -width / 4 + 1, -height / 2, width / 2, height, 270 * 64, 360 * 64); XSetForeground (display, gc, bluelightpix); XDrawArc (display, pixmap_up, gc, -width / 4, -height / 2, width / 2, height, 270 * 64, 360 * 64); XDrawArc (display, pixmap_up, gc, -width / 4, -height / 2 + 1, width / 2, height, 270 * 64, 360 * 64); XDrawArc (display, pixmap_up, gc, -width / 4 + 1, -height / 2, width / 2, height, 270 * 64, 360 * 64); XDrawArc (display, pixmap_down, gc, -width / 8, -3 * height / 8, width / 4, 3 * height / 4, 270 * 64, 360 * 64); XDrawArc (display, pixmap_down, gc, -width / 8, -3 * height / 8 + 1, width / 4, 3 * height / 4, 270 * 64, 360 * 64); XDrawArc (display, pixmap_down, gc, -width / 8 + 1, -3 * height / 8, width / 4, 3 * height / 4, 270 * 64, 360 * 64); XSetForeground (display, gc, blueshadowpix); XDrawSegments (display, pixmap_up, gc, shadowlines, 28); XDrawSegments (display, pixmap_down, gc, lightlines, 26); XSetForeground (display, gc, bluelightpix); XDrawSegments (display, pixmap_down, gc, shadowlines, 28); XDrawSegments (display, pixmap_up, gc, lightlines, 26); XSetForeground (display, gc, blackpix); texty = (int) ((height + fontstruct->max_bounds.ascent + fontstruct->max_bounds.descent) * .5 - fontstruct->max_bounds.descent) - textheight; textx = (int) ((width - XTextWidth (fontstruct, text, strlen (text))) * .5); XDrawString (display, pixmap_up, gc, textx, texty, text, strlen (text)); XDrawString (display, pixmap_down, gc, textx, texty, text, strlen (text)); textx = (int) ((width - XTextWidth (fontstruct, indextext, strlen (indextext))) * .5); texty += 2 * textheight; XDrawString (display, pixmap_up, gc, textx, texty, indextext, strlen (indextext)); XDrawString (display, pixmap_down, gc, textx, texty, indextext, strlen (indextext));}void ClassifyIcon::Action (int actiontyp, int value){ switch (actiontyp) { case ICON_REQUESTFORCLASSIFYRESULTS: ClassifyOutputwindow->CalculateResults ((Datensatz *) value); break; case ICON_CLASSIFYRESULTSCHANGED: Outputs->SendActiontoallEnds (ICON_CLASSIFYRESULTSCHANGED, 0); break; case ICON_REMOVECONNECTIN: ClassifyOutputwindow->SetDataset ((Datensatz *) NULL); In = NULL; break; case ICON_REMOVECONNECTOUT: *Outputs -= (Connection *) (value); ClassifyOutputwindow->SetDataset ((Datensatz *) NULL); break; case ICON_REQUESTFORDVECTOR: if (In != NULL) In->SendActiontoStart (ICON_REQUESTFORDVECTOR, value); break; case ICON_SENDINGDVECTOR: ClassifyOutputwindow->SetSelectedinputvector ((DVektor *) value); break; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -