Minsky
|
#include <wire.h>
Public Member Functions | |
Wire () | |
Wire (const std::weak_ptr< Port > &from, const std::weak_ptr< Port > &to, const std::vector< float > &a_coords=std::vector< float >()) | |
~Wire () | |
std::shared_ptr< Port > | from () const |
std::shared_ptr< Port > | to () const |
void | moveToPorts (const std::shared_ptr< Port > &from, const std::shared_ptr< Port > &to) |
switch ports this wire links to More... | |
void | storeCairoCoords (cairo_t *cairo) const |
stash all the internal cairo coordinates along a wire More... | |
void | draw (cairo_t *cairo, bool reverseArrow=false) const |
draw this item into a cairo context More... | |
std::vector< float > | coords () const |
display coordinates More... | |
std::vector< float > | coords (const std::vector< float > &coords) |
bool | near (float x, float y) const |
returns true if coordinates are near this wire More... | |
unsigned | nearestHandle (float x, float y) |
returns the index into the coordinate list if x,y is close to it. Otherwise inserts midpoints and returns that. Wire endpoints are not returned More... | |
void | insertHandle (unsigned position, float x, float y) |
void | deleteHandle (float x, float y) |
void | editHandle (unsigned position, float x, float y) |
void | straighten () |
bool | visible () const |
whether this wire is visible or not More... | |
void | moveIntoGroup (Group &dest) |
move this from its group into dest More... | |
void | split () |
splits wires crossing group boundaries More... | |
Units | units (bool) const |
units (dimensional analysis) of data flowing across wire More... | |
![]() | |
virtual std::string const & | detailedText () const |
virtual std::string const & | detailedText (const std::string &x) |
virtual std::string const & | tooltip () const |
virtual std::string const & | tooltip (const std::string &x) |
virtual void | adjustBookmark () const |
adjust bookmark list to reflect current configuration More... | |
virtual void | updateBoundingBox () |
virtual | ~NoteBase ()=default |
![]() | |
WireAccessor () | |
Private Member Functions | |
CLASSDESC_ACCESS (Wire) | |
Private Attributes | |
std::vector< float > | m_coords |
std::weak_ptr< Port > | m_from |
ports this wire connects More... | |
std::weak_ptr< Port > | m_to |
int | unitsCtr =0 |
for detecting wiring loops in units() More... | |
std::vector< std::pair< float, float > > | cairoCoords |
contains all the internal cairo coordinates used to draw a wire More... | |
Static Private Attributes | |
static constexpr float | handleRadius =3 |
Friends | |
struct | SchemaHelper |
Additional Inherited Members | |
![]() | |
bool | mouseFocus =false |
true if target of a mouseover More... | |
bool | selected =false |
true if selected for cut, copy or group operation More... | |
bool | bookmark =false |
Is this item also a bookmark? More... | |
|
inline |
minsky::Wire::Wire | ( | const std::weak_ptr< Port > & | from, |
const std::weak_ptr< Port > & | to, | ||
const std::vector< float > & | a_coords = std::vector<float>() |
||
) |
minsky::Wire::~Wire | ( | ) |
|
private |
vector< float > minsky::Wire::coords | ( | ) | const |
display coordinates
Definition at line 45 of file wire.cc.
References f, from(), m_coords, minsky::sqr(), MathDAG::sqrt(), and to().
Referenced by coords(), deleteHandle(), draw(), editHandle(), insertHandle(), near(), nearestHandle(), schema3::populateWire(), and Wire().
vector< float > minsky::Wire::coords | ( | const std::vector< float > & | coords | ) |
Definition at line 69 of file wire.cc.
References coords(), m_coords, minsky::sqr(), and MathDAG::sqrt().
void minsky::Wire::deleteHandle | ( | float | x, |
float | y | ||
) |
Definition at line 655 of file wire.cc.
References coords(), and minsky::anonymous_namespace{wire.cc}::d2().
void minsky::Wire::draw | ( | cairo_t * | cairo, |
bool | reverseArrow = false |
||
) | const |
draw this item into a cairo context
Two control points are inserted between two adjacent handles (knots) of the curved wires on the canvas. The first and second derivatives of the cubic Bezier curves, representing curved segments of wires, and spanning adjacent knots, are matched at the common knots. The second derivatives are set to zero at the ends to absorb the extra degrees of freedom, thus leading to a matrix equation relating control points \(c_i\) to the knots \(k_i\):
\[ \left(\begin{array}{c} b_1 & a_1 & 0 \\ d_1 & b_2 & a_2 \\ 0 & d_2 & b_3 \end{array}\right) \left(\begin{array}{c} c_1 \\ c_2 \\ c_3 \end{array}\right) = \left(\begin{array}{c} k_1 \\ k_2 \\ k_3 \end{array}\right) \]
Definition at line 374 of file wire.cc.
References cairoCoords, minsky::anonymous_namespace{wire.cc}::computeControlPoints(), minsky::anonymous_namespace{wire.cc}::constructTargetVector(), minsky::anonymous_namespace{wire.cc}::constructTriDiag(), coords(), handleRadius, minsky::latexToPango(), M_PI, minsky::NoteBase::mouseFocus, storeCairoCoords(), minsky::anonymous_namespace{wire.cc}::toCoordPair(), minsky::NoteBase::tooltip(), and visible().
Referenced by minsky::PhillipsFlow::draw().
void minsky::Wire::editHandle | ( | unsigned | position, |
float | x, | ||
float | y | ||
) |
Definition at line 674 of file wire.cc.
References coords().
Referenced by minsky::PhillipsDiagram::mouseMove().
|
inline |
void minsky::Wire::insertHandle | ( | unsigned | position, |
float | x, | ||
float | y | ||
) |
Definition at line 643 of file wire.cc.
References coords().
Referenced by nearestHandle().
void minsky::Wire::moveIntoGroup | ( | Group & | dest | ) |
move this from its group into dest
Definition at line 131 of file wire.cc.
References minsky::GroupItems::addWire(), minsky::Group::globalGroup(), minsky::GroupItems::recursiveDo(), and minsky::GroupItems::wires.
void minsky::Wire::moveToPorts | ( | const std::shared_ptr< Port > & | from, |
const std::shared_ptr< Port > & | to | ||
) |
bool minsky::Wire::near | ( | float | x, |
float | y | ||
) | const |
returns true if coordinates are near this wire
Definition at line 574 of file wire.cc.
References minsky::anonymous_namespace{wire.cc}::allHandleCoords(), cairoCoords, coords(), minsky::anonymous_namespace{wire.cc}::d2(), and minsky::anonymous_namespace{wire.cc}::segNear().
unsigned minsky::Wire::nearestHandle | ( | float | x, |
float | y | ||
) |
returns the index into the coordinate list if x,y is close to it. Otherwise inserts midpoints and returns that. Wire endpoints are not returned
Definition at line 603 of file wire.cc.
References coords(), minsky::anonymous_namespace{wire.cc}::d2(), and insertHandle().
void minsky::Wire::split | ( | ) |
splits wires crossing group boundaries
Definition at line 513 of file wire.cc.
References from(), moveToPorts(), to(), and Wire().
void minsky::Wire::storeCairoCoords | ( | cairo_t * | cairo | ) | const |
stash all the internal cairo coordinates along a wire
Definition at line 350 of file wire.cc.
References cairoCoords.
Referenced by draw().
|
inline |
|
inline |
Units minsky::Wire::units | ( | bool | check | ) | const |
bool minsky::Wire::visible | ( | ) | const |
|
friend |
|
mutableprivate |
contains all the internal cairo coordinates used to draw a wire
Definition at line 55 of file wire.h.
Referenced by draw(), near(), and storeCairoCoords().
|
staticprivate |
|
private |
Definition at line 49 of file wire.h.
Referenced by coords(), and straighten().
|
private |
ports this wire connects
Definition at line 51 of file wire.h.
Referenced by from(), moveToPorts(), and Wire().
|
private |
Definition at line 51 of file wire.h.
Referenced by moveToPorts(), to(), and Wire().
|
mutableprivate |