Minsky
minsky::PhillipsFlow Class Reference

#include <phillipsDiagram.h>

Inheritance diagram for minsky::PhillipsFlow:
Inheritance graph
Collaboration diagram for minsky::PhillipsFlow:
Collaboration graph

Public Member Functions

 PhillipsFlow ()=default
 
 PhillipsFlow (const std::weak_ptr< Port > &from, const std::weak_ptr< Port > &to)
 
Units units () const
 
void addTerm (double coef, const std::string &name)
 
double value () const
 
void draw (cairo_t *)
 
- Public Member Functions inherited from minsky::Wire
 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< Portfrom () const
 
std::shared_ptr< Portto () 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...
 
- Public Member Functions inherited from minsky::NoteBase
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
 
- Public Member Functions inherited from minsky::WireAccessor
 WireAccessor ()
 

Public Attributes

classdesc::Exclude< std::vector< std::pair< double, FlowVar > > > terms
 
- Public Attributes inherited from minsky::NoteBase
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...
 

Static Public Attributes

static std::map< Units, double > maxFlow
 

Private Member Functions

 CLASSDESC_ACCESS (PhillipsFlow)
 

Detailed Description

Definition at line 35 of file phillipsDiagram.h.

Constructor & Destructor Documentation

◆ PhillipsFlow() [1/2]

minsky::PhillipsFlow::PhillipsFlow ( )
default

◆ PhillipsFlow() [2/2]

minsky::PhillipsFlow::PhillipsFlow ( const std::weak_ptr< Port > &  from,
const std::weak_ptr< Port > &  to 
)
inline

Definition at line 40 of file phillipsDiagram.h.

40  :
41  Wire(from,to) {}
std::shared_ptr< Port > from() const
Definition: wire.h:63
std::shared_ptr< Port > to() const
Definition: wire.h:64
Wire()
Definition: wire.h:58

Member Function Documentation

◆ addTerm()

void minsky::PhillipsFlow::addTerm ( double  coef,
const std::string &  name 
)
inline

Definition at line 49 of file phillipsDiagram.h.

References terms.

49 {terms.emplace_back(coef, name);}
classdesc::Exclude< std::vector< std::pair< double, FlowVar > > > terms

◆ CLASSDESC_ACCESS()

minsky::PhillipsFlow::CLASSDESC_ACCESS ( PhillipsFlow  )
private

◆ draw()

void minsky::PhillipsFlow::draw ( cairo_t *  cairo)

Definition at line 33 of file phillipsDiagram.cc.

References minsky::Wire::draw(), maxFlow, units(), and value().

34  {
35  const CairoSave cs(cairo);
36  const double value=this->value();
37  double& maxV=maxFlow[units()];
38  if (abs(value)>maxV) maxV=abs(value);
39  double lineWidth=1;
40  if (maxV>0)
41  {
42  const double lw=5*abs(value)/maxV;
43  lineWidth=std::max(1.0, lw);
44  static const double dashLength=3;
45  if (lw<1)
46  cairo_set_dash(cairo,&dashLength,1,0);
47  }
48  cairo_set_line_width(cairo, lineWidth);
49  Wire::draw(cairo,value>=0);
50  }
static std::map< Units, double > maxFlow
double value() const
void draw(cairo_t *cairo, bool reverseArrow=false) const
draw this item into a cairo context
Definition: wire.cc:374
Here is the call graph for this function:

◆ units()

Units minsky::PhillipsFlow::units ( ) const
inline

Definition at line 45 of file phillipsDiagram.h.

References terms.

Referenced by draw().

45  {
46  if (terms.empty()) return {};
47  return terms.front().second.units();
48  }
classdesc::Exclude< std::vector< std::pair< double, FlowVar > > > terms
Here is the caller graph for this function:

◆ value()

double minsky::PhillipsFlow::value ( ) const
inline

Definition at line 50 of file phillipsDiagram.h.

References terms.

Referenced by draw().

50  {
51  double r=0;
52  for (auto& i: terms)
53  r+=i.first*i.second.value();
54  return r;
55  }
classdesc::Exclude< std::vector< std::pair< double, FlowVar > > > terms
Here is the caller graph for this function:

Member Data Documentation

◆ maxFlow

std::map< Units, double > minsky::PhillipsFlow::maxFlow
static

Definition at line 42 of file phillipsDiagram.h.

Referenced by draw().

◆ terms

classdesc::Exclude<std::vector<std::pair<double, FlowVar> > > minsky::PhillipsFlow::terms

Definition at line 43 of file phillipsDiagram.h.

Referenced by addTerm(), units(), and value().


The documentation for this class was generated from the following files: