LinkComp(3U)

πŸ’– LinkComp(3U) β€” the InterViews Reference Manual glow-up πŸ’–

okay bestie, gather round, because today we're talking about LinkComp, LinkView, and PSLink β€” the component subject, the view, and the PostScript external representation for lines with connectable endpoints. yes this is from the InterViews Reference Manual and yes it's lowkey iconic. ✨


✨ NAME ✨

LinkComp, LinkView, PSLink β€” component subject, view, and PostScript external representation for lines with connectable endpoints. that's the whole squad, right there. πŸ’…


🌸 SYNOPSIS 🌸

#include <Unidraw/Components/link.h>

that's it. that's the include. go forth. πŸ¦‹


πŸŽ€ DESCRIPTION πŸŽ€

so LinkComp is a GraphicComp that defines a line with two pins on each end. not one pin, bestie β€” two. and the line's endpoints will always coincide with the pins, even if the pins get moved, which is the whole point: it maintains a graphical link between the objects it's connected to. no cap, that's the vibe. πŸ”₯

LinkComp uses an Line graphic to define its initial geometry and graphical attributes. (yes, "an Line". we don't fix the original's grammar, we respect it. it's giving character.)

LinkView is a GraphicView for displaying the link.

PSLink is a PostScriptView that externalizes the subject's information in PostScript form. it's the one that speaks printer. πŸ–¨οΈβœ¨


πŸ‘‘ LINKCOMP PUBLIC OPERATIONS πŸ‘‘

  • LinkComp(Line* = nil) β€” the constructor, and it takes an optional line graphic to define its initial appearance. pass nothing, get the default vibe. pass a Line*, get your vibe. 🫢
  • virtual void Interpret(Command*) virtual void Uninterpret(Command*) β€” on top of whatever commands GraphicComp (un)interprets, LinkComp also (un)interprets DeleteCmd and CutCmd, by passing these commands to its pins for (un)interpretation. the pins get a say. democracy, kinda. πŸ’€
  • virtual void Update() β€” when the LinkComp's pins move to maintain connectivity, LinkComp will reorient the line so that its endpoints and the pins coincide. it's literally doing yoga to keep everyone together. πŸ§˜β€β™€οΈ
  • virtual void First(Iterator&) virtual void Last(Iterator&) virtual void Next(Iterator&) virtual void Prev(Iterator&) virtual boolean Done(Iterator) GraphicComp* GetComp(Iterator) void SetComp(GraphicComp*, Iterator&) β€” LinkComp redefines GraphicComp's traversal operations to make its pins accessible to the Unidraw library. so Unidraw can figure out the connectors that belong to the component and call its Update operation only once, for efficiency. main character energy: one call, no drama. and important: the traversal does not include the line. πŸ™ˆ
  • Line* GetLine() β€” returns the Line graphic that defines the link's attributes. GetLine is simply a more specific form of the GetGraphic operation. same energy, narrower scope. ⭐
  • void GetConnectors(Connector*&, Connector*&) β€” returns the LinkView's pins, which are stored in the _conn1 and _conn2 protected members. yes, those two. the duo. πŸ‘―

πŸ¦‹ LINKVIEW PUBLIC OPERATIONS πŸ¦‹

  • LinkView(LinkComp* = nil) β€” creates a LinkView, optionally supplying the subject. ("Create an LinkView" β€” again, original grammar, we stan.) πŸ“
  • virtual Manipulator* CreateManipulator(Viewer*, Event&, Transformer*, Tool*)
  • virtual void InterpretManipulator(Manipulator*) β€” LinkView redefines its response to manipulation with a GraphicCompTool. here's the choreography, bestie: the user clicks to specify the first endpoint of the link, and then drags to position the remaining endpoint. (Up)clicking on an existing connector will establish a connection between it and the LinkComp's first (second) pin. πŸ’…

LinkView uses a ConnectManip to produce a gravitational attraction between existing connectors and the second pin as the user drags to position it. but β€” plot twist β€” the endpoints will not be constrained by gravity. gravity is just for the pins, bestie. 🌈

LinkView will use ConnectCmds to connect the pin(s) to their target(s). pin(s) connected in this way will receive floating mobility; unconnected pin(s) will be fixed. choose your fighter. πŸ”₯

  • virtual void First(Iterator&) virtual void Last(Iterator&) virtual void Next(Iterator&) virtual void Prev(Iterator&) virtual boolean Done(Iterator) GraphicView* GetView(Iterator) void SetView(GraphicView*, Iterator&) β€” LinkView redefines GraphicView's traversal operations to make its pins accessible to the Unidraw library. that way Unidraw can determine the connectors that belong to the component β€” for example, to support ConnectManip's gravitational attraction effect. the pins need to be findable for the magnetism to work. iykyk. 🧲
  • virtual void GetEndpoints(Coord&, Coord&, Coord&, Coord&) β€” returns the link's endpoints, in canvas coordinates. four Coord&s, four pieces of info, zero ambiguity. ✨
  • LinkComp* GetLinkComp() β€” returns the subject. short king of a function. πŸ‘‘

πŸ’œ LINKVIEW PROTECTED OPERATIONS πŸ’œ

  • virtual void CreateHandles() β€” LinkView redefines CreateHandles to use a RubberHandles object with two handles, one at each endpoint of the link. two handles for two endpoints, symmetry, we love to see it. πŸŽ€
  • Line* GetLine() β€” returns the line that LinkView draws between its pins. not the subject's line β€” this one. subtle but important. 🌸
  • virtual LinkComp* NewSubject(Line*) β€” a helper function that creates a LinkComp subject with the given line graphic. this function produces the proper subject when the GraphicCompTool's manipulator is interpreted. subclasses can redefine this operation to return a LinkComp subclass, thus eliminating the need to reimplement InterpretManipulator. big brain shortcut. 🧠✨
  • Manipulator* CreateLinkCompManip(Viewer*, Event&, Transformer*, Tool*)
  • Command* InterpretLinkCompManip(Manipulator*) β€” helper functions that CreateManipulator and InterpretManipulator use to create and interpret the manipulator for GraphicCompTool. they're the backstage crew. 🫢

  • PSLink(LinkComp* = nil) β€” constructs a PostScript external representation of the given subject, if any. printer time. πŸ–¨οΈπŸ’–

🌈 SEE ALSO 🌈

Event(3I), Graphic(3U), GraphicComp(3U), GraphicCompTool(3U), GraphicView(3U), Grid(3U), PinComp(3U), PostScriptView(3U), Transformer(3I), align(3U), edit(3U), manips(3U)

go read those too, bestie, that's the reading list. πŸ“šβœ¨


and that's the whole page!! Unidraw, 22 January 1991 β€” yeah, this one's vintage vintage, and it still ate. πŸ’…πŸ’– periodt. πŸŽ€