Changeset 973 for cpp/frams/canvas
- Timestamp:
- 07/03/20 00:37:13 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/canvas/neurodiagram.cpp
r838 r973 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 17Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2020 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 136 136 int *xywh = GetXYWH(el); 137 137 XY[0] = 0; 138 XY[1] = ((1 + i) *xywh[3]) / (GetInputs(el) + 1);138 XY[1] = ((1 + i) * xywh[3]) / (GetInputs(el) + 1); 139 139 return XY; 140 140 } … … 230 230 if (i >= countNeurons()) return; 231 231 NeuroProbe *probe = new NeuroProbe(getNS(i)); 232 Pixel s =getSize();233 s.x =s.y=max(probe->getSize().x,min(s.x/3,s.y/3));232 Pixel s = getSize(); 233 s.x = s.y = max(probe->getSize().x, min(s.x / 3, s.y / 3)); 234 234 probes += (void*)probe; 235 235 add(probe); … … 255 255 addNeuroDescription(tooltip, n); 256 256 label += n->getClassName(); 257 if (n->getClassParams().len ())257 if (n->getClassParams().length()) 258 258 { 259 259 tooltip += "\n"; tooltip += n->getClassParams(); … … 319 319 */ 320 320 321 // NeuroSymbol is also responsible for drawing connection lines from its inputs to other NeuroSymbols' outputs321 // NeuroSymbol is also responsible for drawing connection lines from its inputs to other NeuroSymbols' outputs 322 322 NeuroSymbol *ns2; 323 323 if (!diagram.isLive()) … … 350 350 { 351 351 y2 = pos.y - yw / 3; 352 if ((ns2->pos.y <pos.y) && (ns2->pos.y>(pos.y - ns2->size.y))) y2 -= pos.y - ns2->pos.y;352 if ((ns2->pos.y < pos.y) && (ns2->pos.y > (pos.y - ns2->size.y))) y2 -= pos.y - ns2->pos.y; 353 353 } 354 354 // note: "diagram" uses global coordinate system, so we add "pos" or "ns2->pos" to get NeuroSymbol's global positions … … 413 413 int NeuroSymbol::inputY(int i) 414 414 { 415 return (1 + i) *size.y / ((n->getInputCount()) + 1);415 return (1 + i) * size.y / ((n->getInputCount()) + 1); 416 416 } 417 417 … … 421 421 if (x < size.x / 4) 422 422 { // inputs? 423 if (n->getInputCount() > 0) 424 { 425 int i = (y*n->getInputCount()) / size.y; 426 double w; 427 Neuro* target = n->getInput(i, w); 428 if (target) 423 if (n->getInputCount() > 0) 429 424 { 430 SString t = "connected to #"; 431 t += SString::valueOf((int)target->refno); 432 t += " - "; 433 addNeuroDescription(t, target); 434 // if (w!=1.0) 425 int i = (y * n->getInputCount()) / size.y; 426 double w; 427 Neuro* target = n->getInput(i, w); 428 if (target) 435 429 { 436 t += ", weight="; 437 t += SString::valueOf(w); 430 SString t = "connected to #"; 431 t += SString::valueOf((int)target->refno); 432 t += " - "; 433 addNeuroDescription(t, target); 434 // if (w!=1.0) 435 { 436 t += ", weight="; 437 t += SString::valueOf(w); 438 } 439 return t; 438 440 } 439 return t;440 441 } 441 }442 442 } 443 443 return CanvasWindow::hint(x, y); … … 448 448 NeuroProbe::NeuroProbe(NeuroSymbol* ns) 449 449 :DCanvasWindow(DCanvasWindow::Title + DCanvasWindow::Border + DCanvasWindow::Close + DCanvasWindow::Size, 450 ns->getLabel().c_str(), &neurochart, &neurochart)450 ns->getLabel().c_str(), &neurochart, &neurochart) 451 451 { 452 452 holdismine = 0; … … 515 515 while (*dr != NeuroImpl::ENDDRAWING) 516 516 { 517 int x = ((*(dr++)) *scale) / (NeuroImpl::MAXDRAWINGXY + 1) + x0;518 int y = ((*(dr++)) *scale) / (NeuroImpl::MAXDRAWINGXY + 1) + y0;517 int x = ((*(dr++)) * scale) / (NeuroImpl::MAXDRAWINGXY + 1) + x0; 518 int y = ((*(dr++)) * scale) / (NeuroImpl::MAXDRAWINGXY + 1) + y0; 519 519 if (first) { moveTo(x, y); first = 0; } 520 520 else lineTo(x, y); … … 577 577 { 578 578 double st = neurochart.unmapData(unmapClientY(y)); 579 if (st <-1.0) st = -1.0; else if (st>1.0) st = 1.0;579 if (st < -1.0) st = -1.0; else if (st > 1.0) st = 1.0; 580 580 if (chsel == 0) 581 581 link->n->state = st; … … 602 602 int sy = size.y; 603 603 if (chsel >= 0) sy -= textHeight(); 604 return ((y <sy) && (y>(sy - textHeight())));604 return ((y < sy) && (y > (sy - textHeight()))); 605 605 } 606 606 return 0; … … 635 635 { 636 636 link->n->flags ^= Neuro::HoldState; 637 holdismine = ((link->n->flags &Neuro::HoldState) != 0);637 holdismine = ((link->n->flags & Neuro::HoldState) != 0); 638 638 requestPaint(); 639 639 return LeftButton; … … 645 645 SString NeuroProbe::hint(int x, int y) 646 646 { 647 if ((chsel >= 0) && (x <size.x - 16) && (y>size.y - 16))648 return SString((link->n->flags &Neuro::HoldState) ? "Click to release" : "Click to hold");647 if ((chsel >= 0) && (x < size.x - 16) && (y > size.y - 16)) 648 return SString((link->n->flags & Neuro::HoldState) ? "Click to release" : "Click to hold"); 649 649 else if (insideChSelector(x, y)) 650 650 return SString::sprintf("channel %d of %d (click and drag to switch channels)", chsel, chnum);
Note: See TracChangeset
for help on using the changeset viewer.