Minsky
minsky::VarConstant Struct Reference

#include <variable.h>

Inheritance diagram for minsky::VarConstant:
Inheritance graph
Collaboration diagram for minsky::VarConstant:
Collaboration graph

Public Member Functions

 VarConstant ()
 
std::string valueId () const override
 string used to link to the VariableValue associated with this More...
 
std::string name () const override
 variable displayed name More...
 
std::string name (const std::string &nm) override
 variable displayed name More...
 
double value (const double &x) override
 < set the initial value for this variable More...
 
VarConstantclone () const override
 
std::string classType () const override
 
void TCL_obj (classdesc::TCL_obj_t &t, const classdesc::string &d) override
 
virtual double value (const double &)
 < set the initial value for this variable More...
 
virtual double value () const override
 
- Public Member Functions inherited from minsky::Variable< VariableType::constant >
Type type () const override
 
std::size_t numPorts () const override
 
size_t numPorts () const
 
size_t numPorts () const
 
size_t numPorts () const
 
size_t numPorts () const
 
size_t numPorts () const
 
size_t numPorts () const
 
size_t numPorts () const
 
 Variable (const Variable &x)
 
 Variable (Variable &&x)
 
 Variable (const std::string &name="")
 
Variableoperator= (const Variable &x)
 
Variableoperator= (Variable &&x)
 
std::string classType () const override
 
Variableclone () const override
 
- Public Member Functions inherited from minsky::ItemT< Variable< T >, VariableBase >
void TCL_obj (classdesc::TCL_obj_t &t, const std::string &d) override
 
void RESTProcess (classdesc::RESTProcess_t &rp, const std::string &d) override
 dummy template definition for use with gui executable More...
 
void RESTProcess (classdesc::RESTProcess_t &rp, const std::string &d) const override
 
void json_pack (classdesc::json_pack_t &j) const override
 
 ItemT ()=default
 
 ItemT (const ItemT &)=default
 
 ItemT (ItemT &&)=delete
 
ItemToperator= (const ItemT &)=default
 
ItemToperator= (ItemT &&)=delete
 
- Public Member Functions inherited from minsky::VariableBase
void retype (VariableType::Type type)
 attempt to replace this variable with variable of type. More...
 
bool visible () const override
 whether this item is visible on the canvas. More...
 
const VariableBasevariableCast () const override
 
VariableBasevariableCast () override
 
float zoomFactor () const override
 
bool local () const
 
void toggleLocal ()
 toggle local status More...
 
const std::string & rawName () const
 accessor for the name member (may differ from name() with top level variables) More...
 
bool ioVar () const override
 indicates this is a group I/O variable More...
 
void ensureValueExists (VariableValue *vv, const std::string &name) const
 ensure an associated variableValue exists More...
 
std::string valueIdInCurrentScope (const std::string &nm) const
 returns valueId for nm. If nm is not qualified, this variable's scope is used More...
 
std::shared_ptr< VariableValuevValue () const
 variableValue associated with this. nullptr if not associated with a variableValue More...
 
std::vector< unsigned > dims () const
 variable's tensor shape More...
 
std::vector< std::string > dimLabels () const
 labels along each axis More...
 
std::pair< std::string, std::string > getDimLabelsPicked () const
 
std::pair< std::string, std::string > setDimLabelsPicked (const std::string &dimLabel1, const std::string &dimLabel2)
 
const std::string & detailedText () const override
 
const std::string & detailedText (const std::string &x) override
 
const std::string & tooltip () const override
 
const std::string & tooltip (const std::string &x) override
 
bool sliderVisible () const
 returns true if slider is to be drawn More...
 
Units units (bool check) const override
 sets/gets the units associated with this type More...
 
Units units () const
 
void setUnits (const std::string &) const
 
std::string unitsStr () const
 
bool onKeyPress (int, const std::string &, int) override
 respond to key press events More...
 
bool lhs () const
 variable is on left hand side of flow calculation More...
 
bool temp () const
 variable is temporary More...
 
bool isStock () const
 
std::string definition () const
 formula defining this variable More...
 
void draw (cairo_t *) const override
 
void resize (const LassoBox &b) override
 resize this item on the canvas More...
 
ClickType::Type clickType (float x, float y) const override
 returns the clicktype given a mouse click at x, y. More...
 
bool defined () const
 
bool inputWired () const
 
std::vector< std::string > accessibleVars () const
 return a list of existing variables this could be connected to More...
 
EngNotation engExp () const
 return formatted mantissa and exponent in engineering format More...
 
std::string mantissa (const EngNotation &e, int digits=3) const
 
void exportAsCSV (const std::string &filename, bool tabular) const
 export this variable as a CSV file More...
 
void importFromCSV (const std::vector< std::string > &filenames, const DataSpecSchema &spec) const
 import CSV files, using spec More...
 
void destroyFrame () override
 clean up popup window structures on window close More...
 
bool miniPlotEnabled () const
 
bool miniPlotEnabled (bool)
 
void resetMiniPlot ()
 
bool onMouseMotion (float x, float y) override
 respond to mouse motion events with button pressed More...
 
void adjustSliderBounds ()
 
const std::string & canonicalName () const
 variable displayed name More...
 
std::string init () const
 the initial value of this variable More...
 
std::string init (const std::string &)
 < return initial value for this variable More...
 
virtual double value () const override
 < set the initial value for this variable More...
 
double sliderMin () const
 slider parameters More...
 
double sliderMin (double) const
 slider parameters More...
 
double sliderMax () const
 slider parameters More...
 
double sliderMax (double) const
 slider parameters More...
 
double sliderStep () const
 slider parameters More...
 
double sliderStep (double) const
 slider parameters More...
 
bool sliderStepRel () const
 slider parameters More...
 
bool sliderStepRel (bool) const
 slider parameters More...
 
bool enableSlider () const
 slider parameters More...
 
bool enableSlider (bool)
 slider parameters More...
 
- Public Member Functions inherited from minsky::BottomRightResizerItem
bool onResizeHandle (float x, float y) const override
 
void drawResizeHandles (cairo_t *cairo) const override
 
virtual Point resizeHandleCoords () const
 returns coordinates of the resizer handle More...
 
- Public Member Functions inherited from minsky::Item
 Item ()
 
virtual std::weak_ptr< Portports (std::size_t i) const
 callback to be run when item deleted from group More...
 
std::size_t portsSize () const
 number of ports More...
 
float portX (std::size_t i)
 
float portY (std::size_t i)
 
virtual bool contains (float xx, float yy) const
 
bool contains (const Point &p) const
 
void updateBoundingBox () override
 
void throw_error (const std::string &) const
 mark item on canvas, then throw More...
 
double rotation () const
 
double rotation (const double &r)
 
std::pair< double, bool > rotationAsRadians () const
 return the rotation as radians, and whether rotation should have additional straight angle added for text that stays upright. More...
 
float iWidth () const
 
float iWidth (const float &w)
 
float iHeight () const
 
float iHeight (const float &h)
 
virtual void flip ()
 rotate icon though 180∘ More...
 
std::string id () const
 return an id uniquely identifying this item More...
 
virtual float x () const
 
virtual float y () const
 
void ensureBBValid () const
 
float width () const
 
float height () const
 
virtual std::vector< Pointcorners () const
 
float left () const
 
float right () const
 
float top () const
 
float bottom () const
 
std::string bookmarkId () const
 Id of bookmark associated with this. More...
 
void adjustBookmark () const override
 adjust bookmark list to reflect current configuration More...
 
float resizeHandleSize () const
 resize handles should be at least a percentage if the icon size (#1025) More...
 
virtual bool inItem (float x, float y) const
 
virtual bool onItem (float x, float y) const
 returns true if (x,y) is on the icon More...
 
virtual void onMouseDown (float x, float y)
 respond to mouse down events More...
 
virtual void onMouseUp (float x, float y)
 respond to mouse up events More...
 
virtual bool onMouseOver (float x, float y)
 respond to mouse motion events (hover) without button pressed More...
 
virtual void onMouseLeave ()
 respond to mouse leave events (when mouse leaves item) More...
 
virtual void deleteAttachedWires ()
 delete all attached wires More...
 
void moveTo (float x, float y)
 
virtual float scaleFactor () const
 factor by which item has been resized More...
 
virtual float scaleFactor (const float &sf)
 
void dummyDraw () const
 draw into a dummy cairo context, for purposes of calculating port positions More...
 
virtual void displayTooltip (cairo_t *, const std::string &) const
 display tooltip text, eg on mouseover More...
 
virtual void updateIcon (double t)
 update display after a step() More...
 
 Item (const Item &)=default
 
Itemoperator= (const Item &)=default
 
virtual ~Item ()
 
void drawPorts (cairo_t *cairo) const
 
virtual std::shared_ptr< PortclosestOutPort (float x, float y) const
 returns closest output port to x,y More...
 
virtual std::shared_ptr< PortclosestInPort (float x, float y) const
 
virtual std::shared_ptr< Itemselect (float x, float y) const
 returns the variable if point (x,y) is within a visible variable icon, null otherwise. More...
 
void RESTProcess (classdesc::RESTProcess_t &rp, const std::string &d) override
 runs the RESTProcess descriptor suitable for this type More...
 
void RESTProcess (classdesc::RESTProcess_t &rp, const std::string &d) const override
 
virtual void displayDelayedTooltip (float x, float y)
 enable extended tooltip help message appropriate for mouse at (x,y) More...
 
virtual void disableDelayedTooltip ()
 
virtual bool editorMode () const
 some items have an editor mode attribute More...
 
virtual void toggleEditorMode ()
 
Units checkUnits () const
 perform units consistency checks More...
 
ItemPtr itemPtrFromThis () const
 return a shared_ptr to this More...
 
- Public Member Functions inherited from minsky::NoteBase
virtual ~NoteBase ()=default
 
- Public Member Functions inherited from minsky::VarAccessors::NameAccessor
 NameAccessor ()
 
- Public Member Functions inherited from minsky::VarAccessors::InitAccessor
 InitAccessor ()
 
- Public Member Functions inherited from minsky::VarAccessors::ValueAccessor
 ValueAccessor ()
 
- Public Member Functions inherited from minsky::VariableCaches
 VariableCaches ()=default
 
 VariableCaches (const VariableCaches &)
 
VariableCachesoperator= (const VariableCaches &)
 

Public Attributes

int id
 
- Public Attributes inherited from minsky::VariableBase
classdesc::Exclude< std::weak_ptr< Item > > controller
 reference to a controlling item - eg GodleyIcon, IntOp or a Group if an IOVar. More...
 
- Public Attributes inherited from minsky::Item
float m_x =0
 
float m_y =0
 position in canvas, or within group More...
 
float m_sf =1
 scale factor of item on canvas, or within group More...
 
bool onResizeHandles =false
 set to true to indicate mouse is ovcaler resize handles More...
 
bool onBorder =false
 true to indicate mouse hovering over border More...
 
std::string deleteCallback
 
BoundingBox bb
 canvas bounding box. More...
 
- 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 int nextId =0
 
- Static Public Attributes inherited from minsky::VariableBase
static int varsPassed =0
 for caching units calculation factory method More...
 

Additional Inherited Members

- Public Types inherited from minsky::Variable< VariableType::constant >
typedef VariableBase::Type Type
 
- Public Types inherited from minsky::VariableBase
typedef VariableType::Type Type
 
- Public Types inherited from minsky::VariableType
enum  Type {
  undefined, constant, parameter, flow,
  integral, stock, tempFlow, numVarTypes
}
 
- Static Public Member Functions inherited from minsky::VariableBase
static VariableBasecreate (Type type)
 
- Static Public Member Functions inherited from minsky::Item
static void drawSelected (cairo_t *cairo)
 
- Static Public Member Functions inherited from minsky::VariableType
static std::string typeName (int t)
 
- Protected Member Functions inherited from minsky::VariableBase
void addPorts ()
 
- Static Protected Member Functions inherited from minsky::Item
static void drawResizeHandle (cairo_t *cairo, double x, double y, double sf, double angle)
 
- Protected Attributes inherited from minsky::Item
double m_width =10
 
double m_height =10
 
ItemPortVector m_ports
 
minsky::Item::MemoisedRotator memoisedRotator
 
- Protected Attributes inherited from minsky::VariableCaches
classdesc::Exclude< std::shared_ptr< RenderVariable > > cachedNameRender
 cached Pango objects More...
 
classdesc::Exclude< std::shared_ptr< ecolab::Pango > > cachedMantissa
 
classdesc::Exclude< std::shared_ptr< ecolab::Pango > > cachedExponent
 
double cachedValue
 
double cachedTime
 

Detailed Description

Definition at line 298 of file variable.h.

Constructor & Destructor Documentation

◆ VarConstant()

minsky::VarConstant::VarConstant ( )
inline

Definition at line 302 of file variable.h.

References minsky::VariableBase::ensureValueExists().

Referenced by clone().

302 : id(nextId++) {ensureValueExists(nullptr,"");}
void ensureValueExists(VariableValue *vv, const std::string &name) const
ensure an associated variableValue exists
Definition: variable.cc:262
std::string id() const
return an id uniquely identifying this item
Definition: item.h:236
static int nextId
Definition: variable.h:301
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ classType()

std::string minsky::VarConstant::classType ( ) const
inlineoverridevirtual

Reimplemented from minsky::Item.

Definition at line 309 of file variable.h.

309 {return "VarConstant";}

◆ clone()

VarConstant* minsky::VarConstant::clone ( ) const
inlineoverridevirtual

Implements minsky::VariableBase.

Definition at line 308 of file variable.h.

References VarConstant().

308 {auto r=new VarConstant(*this); r->group.reset(); return r;}
Here is the call graph for this function:

◆ name() [1/2]

std::string minsky::VarConstant::name ( ) const
inlineoverridevirtual

variable displayed name

Reimplemented from minsky::VariableBase.

Definition at line 304 of file variable.h.

References minsky::VariableBase::init().

304 {return init();}
std::string init() const
the initial value of this variable
Definition: variable.cc:285
Here is the call graph for this function:

◆ name() [2/2]

std::string minsky::VarConstant::name ( const std::string &  nm)
inlineoverridevirtual

variable displayed name

Reimplemented from minsky::VariableBase.

Definition at line 305 of file variable.h.

References minsky::VariableBase::ensureValueExists(), and name().

Referenced by name().

305 {ensureValueExists(nullptr,""); return name();}
std::string name() const override
variable displayed name
Definition: variable.h:304
void ensureValueExists(VariableValue *vv, const std::string &name) const
ensure an associated variableValue exists
Definition: variable.cc:262
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TCL_obj()

void minsky::VarConstant::TCL_obj ( classdesc::TCL_obj_t &  t,
const classdesc::string &  d 
)
inlineoverride

Definition at line 310 of file variable.h.

311  {::TCL_obj(t,d,*this);}
void TCL_obj(classdesc::TCL_obj_t &t, const classdesc::string &d) override
Definition: variable.h:310

◆ value() [1/3]

double VariableBase::value

< set the initial value for this variable

current value associated with this variable

Definition at line 340 of file variable.cc.

341 {
342  if (!m_name.empty() && isValueId(valueId()))
343  {
344  (*minsky().variableValues[valueId()])[0]=x;
345  if (type()==constant)
346  cachedNameRender.reset();
347  }
348  return x;
349 }
virtual float x() const
Definition: item.cc:107
VariableValues variableValues
Definition: minsky.h:200
std::string valueId() const override
string used to link to the VariableValue associated with this
Definition: variable.h:303
bool isValueId(const string &name)
check that name is a valid valueId (useful for assertions)
Definition: valueId.cc:33
std::string m_name
Definition: variable.h:101
classdesc::Exclude< std::shared_ptr< RenderVariable > > cachedNameRender
cached Pango objects
Definition: variable.h:77
Minsky & minsky()
global minsky object
Definition: minskyTCL.cc:51

◆ value() [2/3]

double VariableBase::value
override

Definition at line 332 of file variable.cc.

333 {
334  auto& vvs=minsky::cminsky().variableValues;
335  auto v=vvs.find(valueId());
336  if (v==vvs.end() || !v->second) return 0;
337  return v->second->value();
338 }
VariableValues variableValues
Definition: minsky.h:200
std::string valueId() const override
string used to link to the VariableValue associated with this
Definition: variable.h:303
const Minsky & cminsky()
const version to help in const correctness
Definition: minsky.h:549

◆ value() [3/3]

double minsky::VarConstant::value ( const double &  x)
inlineoverridevirtual

< set the initial value for this variable

current value associated with this variable

Reimplemented from minsky::VariableBase.

Definition at line 307 of file variable.h.

References minsky::VariableBase::init(), minsky::str(), and minsky::Item::x().

307 {init(str(x)); return x;}
virtual float x() const
Definition: item.cc:107
std::string str(T x)
utility function to create a string representation of a numeric type
Definition: str.h:33
std::string init() const
the initial value of this variable
Definition: variable.cc:285
Here is the call graph for this function:

◆ valueId()

std::string minsky::VarConstant::valueId ( ) const
inlineoverridevirtual

string used to link to the VariableValue associated with this

Reimplemented from minsky::VariableBase.

Definition at line 303 of file variable.h.

References minsky::str().

303 {return "constant:"+str(id);}
std::string str(T x)
utility function to create a string representation of a numeric type
Definition: str.h:33
Here is the call graph for this function:

Member Data Documentation

◆ id

int minsky::VarConstant::id

Definition at line 300 of file variable.h.

◆ nextId

int VarConstant::nextId =0
static

Definition at line 301 of file variable.h.


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