37 #include <polyPackBase.h> 41 #include <cairo/cairo.h> 63 namespace VarAccessors
110 classdesc::Exclude<std::shared_ptr<ecolab::Plot>>
miniPlot;
120 virtual std::size_t
numPorts()
const=0;
143 virtual std::string
name()
const;
144 virtual std::string
name(
const std::string& nm);
152 bool ioVar()
const override;
158 virtual std::string
valueId()
const;
163 std::shared_ptr<VariableValue>
vValue()
const;
165 std::vector<unsigned>
dims()
const;
167 std::vector<std::string>
dimLabels()
const;
170 std::pair<std::string,std::string>
setDimLabelsPicked(
const std::string& dimLabel1,
const std::string& dimLabel2) {
176 std::string
init()
const;
177 std::string
init(
const std::string&);
181 virtual double value(
const double&);
182 virtual double value()
const override;
186 const std::string&
detailedText(
const std::string&
x)
override;
187 const std::string&
tooltip()
const override;
188 const std::string&
tooltip(
const std::string&
x)
override;
196 void setUnits(
const std::string&)
const;
199 bool onKeyPress(
int,
const std::string&,
int)
override;
214 void draw(cairo_t*)
const override;
234 void exportAsCSV(
const std::string& filename,
bool tabular)
const;
236 void importFromCSV(
const std::vector<std::string>& filenames,
264 template <minsky::VariableType::Type T>
266 public classdesc::PolyPack<Variable<T> >
271 std::size_t
numPorts()
const override;
291 v->controller.reset();
293 assert(dynamic_cast<Variable*>(v));
303 std::string
valueId()
const override {
return "constant:"+
str(
id);}
309 std::string
classType()
const override {
return "VarConstant";}
310 void TCL_obj(classdesc::TCL_obj_t& t,
const classdesc::string& d)
override 315 public classdesc::shared_ptr<VariableBase>
317 typedef classdesc::shared_ptr<VariableBase>
PtrBase;
319 virtual int id()
const {
return -1;}
321 const std::string& name=
""):
328 assert(!
var || *
this);
343 template <>
struct is_smart_ptr<
minsky::VariablePtr>:
public true_type {};
346 #include "variable.cd" 347 #include "variable.xcd"
represents items that have been selected
Variable(const Variable &x)
bool onKeyPress(int, const std::string &, int) override
respond to key press events
bool miniPlotEnabled() const
const std::string & rawName() const
accessor for the name member (may differ from name() with top level variables)
classdesc::Exclude< std::shared_ptr< ecolab::Pango > > cachedExponent
EngNotation engExp(double value)
return formatted mantissa and exponent in engineering format
std::pair< std::string, std::string > m_dimLabelsPicked
virtual std::size_t numPorts() const =0
std::pair< std::string, std::string > getDimLabelsPicked() const
void destroyFrame() override
clean up popup window structures on window close
std::string valueIdInCurrentScope(const std::string &nm) const
returns valueId for nm. If nm is not qualified, this variable's scope is used
static int stockVarsPassed
for detecting reentrancy in units()
void makeConsistentWithValue()
make variable's type consistent with the type of the valueId
exception-safe increment/decrement of a counter in a block
represents rectangular region of a lasso operation
Type type() const override
VarConstant * clone() const override
virtual double value() const override
< set the initial value for this variable
std::vector< std::string > accessibleVars() const
return a list of existing variables this could be connected to
void retype(VariableBase::Type type)
changes type of variable to type
std::string name() const override
variable displayed name
std::shared_ptr< Item > ItemPtr
std::string name(const std::string &nm) override
variable displayed name
std::size_t numPorts() const override
std::string unitsStr() const
double sliderMax() const
slider parameters
const std::string & tooltip() const override
VariablePtr(const VariableBase &x)
VariablePtr(VariableBase::Type type=VariableBase::undefined, const std::string &name="")
virtual Type type() const =0
void exportAsCSV(const std::string &filename, bool tabular) const
export this variable as a CSV file
void resize(const LassoBox &b) override
resize this item on the canvas
virtual VariableBase * clone() const override=0
static VariableBase * create(Type type)
int unitsCtr
for detecting reentrancy in units()
bool sliderVisible() const
returns true if slider is to be drawn
float zoomFactor() const override
bool visible() const override
whether this item is visible on the canvas.
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky's state cha...
classdesc::Exclude< std::weak_ptr< Item > > controller
reference to a controlling item - eg GodleyIcon, IntOp or a Group if an IOVar.
VariableCaches & operator=(const VariableCaches &)
void insertControlled(Selection &selection) override
bool ioVar() const override
indicates this is a group I/O variable
std::pair< std::string, std::string > setDimLabelsPicked(const std::string &dimLabel1, const std::string &dimLabel2)
static int varsPassed
for caching units calculation factory method
Variable & operator=(const Variable &x)
Variable(const std::string &name="")
std::vector< unsigned > dims() const
variable's tensor shape
std::vector< std::string > dimLabels() const
labels along each axis
virtual std::string valueId() const
string used to link to the VariableValue associated with this
const VariableBase * variableCast() const override
void TCL_obj(classdesc::TCL_obj_t &t, const classdesc::string &d) override
represents the units (in sense of dimensional analysis) of a variable.
void adjustSliderBounds()
void ensureValueExists(VariableValue *vv, const std::string &name) const
ensure an associated variableValue exists
double value(const double &x) override
< set the initial value for this variable
std::string valueId() const override
string used to link to the VariableValue associated with this
static std::string typeName(int t)
std::string str(T x)
utility function to create a string representation of a numeric type
std::string m_canonicalName
latex processed and active stripped version of name
std::string definition() const
formula defining this variable
std::string mantissa(double value, const EngNotation &, int digits=3)
EngNotation engExp() const
return formatted mantissa and exponent in engineering format
const std::string & detailedText() const override
Variable & operator=(Variable &&x)
void toggleLocal()
toggle local status
void importFromCSV(const std::vector< std::string > &filenames, const DataSpecSchema &spec) const
import CSV files, using spec
CLASSDESC_ACCESS(VariableCaches)
IncrDecrCounter(int &ctr)
std::string init() const
the initial value of this variable
ClickType::Type clickType(float x, float y) const override
returns the clicktype given a mouse click at x, y.
virtual std::string name() const
variable displayed name
bool enableSlider() const
slider parameters
std::string mantissa(const EngNotation &e, int digits=3) const
bool sliderStepRel() const
slider parameters
classdesc::Exclude< std::shared_ptr< ecolab::Pango > > cachedMantissa
classdesc::Exclude< std::shared_ptr< RenderVariable > > cachedNameRender
cached Pango objects
caches need copy operations to be nobbled, because they hold a reference to the derived variable ...
CLASSDESC_ACCESS(VariableBase)
VariablePtr(const ItemPtr &x)
double sliderStep() const
slider parameters
void draw(cairo_t *) const override
std::string classType() const override
bool temp() const
variable is temporary
bool lhs() const
variable is on left hand side of flow calculation
std::shared_ptr< VariableValue > vValue() const
variableValue associated with this. nullptr if not associated with a variableValue ...
classdesc::shared_ptr< VariableBase > PtrBase
classdesc::Exclude< std::shared_ptr< ecolab::Plot > > miniPlot
miniature plot feature
std::string id() const
return an id uniquely identifying this item
VariablePtr(const classdesc::shared_ptr< VariableBase > &x)
double sliderMin() const
slider parameters
void retype(VariableType::Type type)
attempt to replace this variable with variable of type.
VariableCaches(const VariableCaches &)
void setUnits(const std::string &) const
std::string classType() const override
const std::string & canonicalName() const
variable displayed name
Variable * clone() const override
VariableBase * variableCast() override
bool onMouseMotion(float x, float y) override
respond to mouse motion events with button pressed