36 #include <polyPackBase.h> 39 #include <cairo/cairo.h> 97 classdesc::Exclude<std::shared_ptr<ecolab::Plot>>
miniPlot;
107 virtual std::size_t
numPorts()
const=0;
130 virtual std::string
name()
const;
131 virtual std::string
name(
const std::string& nm);
139 bool ioVar()
const override;
145 virtual std::string
valueId()
const;
150 std::shared_ptr<VariableValue>
vValue()
const;
152 std::vector<unsigned>
dims()
const;
154 std::vector<std::string>
dimLabels()
const;
157 std::pair<std::string,std::string>
setDimLabelsPicked(
const std::string& dimLabel1,
const std::string& dimLabel2) {
163 std::string
init()
const;
164 std::string
init(
const std::string&);
168 virtual double value(
const double&);
169 virtual double value()
const override;
173 const std::string&
detailedText(
const std::string&
x)
override;
174 const std::string&
tooltip()
const override;
175 const std::string&
tooltip(
const std::string&
x)
override;
183 void setUnits(
const std::string&)
const;
186 bool onKeyPress(
int,
const std::string&,
int)
override;
201 void draw(cairo_t*)
const override;
221 void exportAsCSV(
const std::string& filename,
bool tabular)
const;
223 void importFromCSV(
const std::vector<std::string>& filenames,
254 template <minsky::VariableType::Type T>
256 public classdesc::PolyPack<Variable<T> >
261 std::size_t
numPorts()
const override;
281 v->controller.reset();
283 assert(dynamic_cast<Variable*>(v));
293 std::string
valueId()
const override {
return "constant:"+
str(
id);}
299 std::string
classType()
const override {
return "VarConstant";}
303 public classdesc::shared_ptr<VariableBase>
305 typedef classdesc::shared_ptr<VariableBase>
PtrBase;
307 virtual int id()
const {
return -1;}
309 const std::string& name=
""):
316 assert(!
var || *
this);
331 template <>
struct is_smart_ptr<
minsky::VariablePtr>:
public true_type {};
334 #include "variable.cd" 335 #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
void reloadCSV()
reload CSV file if previously imported
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
void adjustSliderBounds() const
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.
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
represents the units (in sense of dimensional analysis) of a variable.
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