19 #ifndef OPERATIONBASE_H 20 #define OPERATIONBASE_H 23 #include <xml_pack_base.h> 24 #include <xml_unpack_base.h> 33 #include <cairo/cairo.h> 38 #include "polyPackBase.h" 39 #include <pack_base.h> 42 namespace ecolab {
class Pango;}
54 mutable classdesc::Exclude<std::shared_ptr<ecolab::Pango>>
cachedPango;
56 void setCachedText(cairo_t*,
const std::string&,
double)
const;
58 static constexpr
float l=-8,
h=12,
r=12;
61 virtual std::size_t
numPorts()
const=0;
70 virtual void iconDraw(cairo_t *)
const=0;
83 void draw(cairo_t*)
const override;
88 double value()
const override;
117 typedef std::shared_ptr<OperationBase>
PtrBase;
123 std::size_t
use_count()
const {
return classdesc::shared_ptr<OperationBase>::use_count();}
132 inline std::ostream& operator<<(std::ostream& x, const std::vector<int>& y)
134 for (std::size_t i=0; i<y.size(); ++i)
135 x<<(i==0?
"":
" ")<<y[i];
140 inline void pack(classdesc::pack_t&,
const classdesc::string&,classdesc::ref<ecolab::urand>&) {}
141 inline void unpack(classdesc::pack_t&,
const classdesc::string&,classdesc::ref<ecolab::urand>&) {}
142 inline void xml_pack(classdesc::xml_pack_t&,
const classdesc::string&,classdesc::ref<ecolab::urand>&) {}
143 inline void xml_unpack(classdesc::xml_unpack_t&,
const classdesc::string&,classdesc::ref<ecolab::urand>&) {}
147 #include "operationBase.cd" 148 #include "operationBase.xcd" void setCachedText(cairo_t *, const std::string &, double) const
check if cachedPango is up to date, and if not recreate
OperationBase * operationCast() override
OperationPtr(OperationType::Type type=OperationType::numOps)
classdesc::Exclude< std::shared_ptr< ecolab::Pango > > cachedPango
void draw(cairo_t *) const override
draw this item into a cairo context
void xml_unpack(classdesc::xml_unpack_t &, const classdesc::string &, classdesc::ref< ecolab::urand > &)
std::shared_ptr< OperationBase > PtrBase
void pack(classdesc::pack_t &, const classdesc::string &, classdesc::ref< ecolab::urand > &)
const OperationBase * operationCast() const override
std::vector< std::string > dimensions() const
return dimension names of tensor object attached to input if binary op, then the union of dimension n...
double arg
operation argument. For example, the offset used in a difference operator, or binsize in a binning op...
OperationPtr clone() const
void unpack(classdesc::pack_t &, const classdesc::string &, classdesc::ref< ecolab::urand > &)
void xml_pack(classdesc::xml_pack_t &, const classdesc::string &, classdesc::ref< ecolab::urand > &)
shared_ptr class for polymorphic operation objects. Note, you may assume that this pointer is always ...
OperationPtr & operator=(const PtrBase &x)
represents rectangular region of a lasso operation
void drawUserFunction(cairo_t *cairo) const
std::string portValues() const
returns a list of values the ports currently have
std::shared_ptr< Item > ItemPtr
OperationPtr(const PtrBase &x)
Units units(bool check=false) const override
compute the dimensional units
virtual std::size_t numPorts() const =0
OperationPtr(OperationBase *op)
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky's state cha...
std::size_t use_count() const
float scaleFactor() const override
factor by which item has been resized
represents the units (in sense of dimensional analysis) of a variable.
static OperationBase * create(Type type)
factory method.
void resize(const LassoBox &b) override
resize this item on the canvas
OperationPtr(const ItemPtr &x)
std::string axis
axis selector in tensor operations
virtual Type type() const =0
Units unitsBinOpCase(bool check) const
virtual void iconDraw(cairo_t *) const =0
visual representation of operation on the canvas
double value() const override
current value of output port
CLASSDESC_ACCESS(OperationBase)