30 (
"description",(Getter)&
IntOp::description,(Setter)&
IntOp::description) {}
45 double coupledIntTranslation=0;
57 const cairo::CairoSave cs(cairo);
61 cairo_rotate(cairo,angle);
63 if (rv.
width()<iv.iWidth()) coupledIntTranslation=-0.5*(
intVarOffset+2*iv.iWidth()+2+
r)*z;
68 const cairo::CairoSave cs(cairo);
69 cairo_rotate(cairo, angle);
70 cairo_scale(cairo,z,z);
71 if (textFlipped) cairo_rotate(cairo,
M_PI);
73 cairo_scale(cairo,sf,sf);
74 cairo_move_to(cairo,-7,3.5);
75 cairo_show_text(cairo,
"∫dt");
82 cairo_rotate(cairo, angle);
87 cairo_move_to(cairo,
l,
h);
88 cairo_line_to(cairo,
l,-
h);
89 cairo_line_to(cairo,
r,0);
91 cairo_close_path(cairo);
93 cairo_set_source_rgb(cairo,0,0,1);
94 cairo_stroke_preserve(cairo);
99 cairo_new_path(cairo);
100 cairo_move_to(cairo,
r,0);
101 cairo_line_to(cairo,
r+ivo,0);
102 cairo_set_source_rgb(cairo,0,0,0);
108 intVarWidth=rv.
width()*z;
112 auto ivp=rot(
x()+
r+ivo+intVarWidth,
y());
113 intVar->moveTo(ivp.x(), ivp.y());
116 cairo_translate(cairo,
r+ivo+intVarWidth,0);
122 cairo_restore(cairo);
125 cairo_move_to(cairo,
l,
h);
126 cairo_line_to(cairo,
l,-
h);
127 cairo_line_to(cairo,
r,0);
128 cairo_line_to(cairo,
r+ivo,0);
132 cairo_line_to(cairo,
r+ivo,-rvh);
133 cairo_line_to(cairo,
r+ivo+2*rvw,-rvh);
134 cairo_line_to(cairo,
r+ivo+2*rvw+2*z,0);
135 cairo_line_to(cairo,
r+ivo+2*rvw,rvh);
136 cairo_line_to(cairo,
r+ivo,rvh);
137 cairo_line_to(cairo,
r+ivo,0);
138 cairo_line_to(cairo,
r,0);
139 cairo_close_path(cairo);
142 cairo::Path clipPath(cairo);
144 double x0=
r, y0=0, x1=
l, y1=
numPorts() > 2? -
h+3: 0,
147 if (textFlipped) swap(y1,y2);
154 cairo_identity_matrix(cairo);
155 cairo_translate(cairo,
x(),
y());
156 cairo_rotate(cairo, angle);
157 cairo_user_to_device(cairo, &x0, &y0);
158 cairo_user_to_device(cairo, &x1, &y1);
159 cairo_user_to_device(cairo, &x2, &y2);
160 cairo_restore(cairo);
169 cairo_translate(cairo,-coupledIntTranslation,0);
170 cairo_restore(cairo);
178 cairo_new_path(cairo);
179 clipPath.appendToCurrent(cairo);
192 intVar->iHeight(0.5*std::abs(b.
y1-b.
y0)*invZ);
204 intVar.reset(
x.intVar->clone());
223 if (desc[0]==
':') desc=desc.substr(1);
228 vector<Wire> savedWires;
232 for (
auto w:
intVar->ports(0).lock()->wires())
233 savedWires.push_back(*w);
243 if (i!=
minsky().variableValues.end())
255 if (
minsky().definingVar(vid))
259 if (desc[0]==
':') desc=desc.substr(1);
268 if (
auto g=
group.lock())
269 intVar->controller=g->findItem(*
this);
274 for (
auto& w: savedWires)
280 if (
auto g=
group.lock())
295 if (
auto g=
group.lock())
299 intVar->controller.reset();
304 if (
auto g=
group.lock())
306 for (
auto w:
intVar->ports(1).lock()->wires())
308 intVar->controller=g->findItem(*
this);
std::string newName(const std::string &name) const
generate a new valueId not otherwise in the system
#define M_PI
some useful geometry types, defined from boost::geometry
represents items that have been selected
IntOp & operator=(const IntOp &x)
void drawPorts(cairo_t *cairo) const
std::size_t numPorts() const override
virtual void displayTooltip(cairo_t *, const std::string &) const
display tooltip text, eg on mouseover
void drawPort(F f, float x, float y, float rotation) const
VariableValues variableValues
std::string description() const
name of the associated integral variable
bool onResizeHandles
set to true to indicate mouse is ovcaler resize handles
represents rectangular region of a lasso operation
std::shared_ptr< Item > ItemPtr
std::shared_ptr< Wire > WirePtr
std::pair< double, bool > rotationAsRadians() const
return the rotation as radians, and whether rotation should have additional straight angle added for ...
string valueId(const string &name)
construct a valueId from fully qualified name @ name should not be canonicalised
rotate (x,y) by rot (in degrees) around the origin (x0, y0) can be used for rotating multiple points ...
void insertControlled(Selection &selection) override
BoundingBox bb
canvas bounding box.
virtual std::string const & tooltip() const
void resize(const LassoBox &b) override
resize this item on the canvas
virtual float zoomFactor() const
void update(const Item &x)
void pack(classdesc::pack_t &x, const std::string &d) const override
static void drawSelected(cairo_t *cairo)
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky's state cha...
void drawSymbol(const char *s) const
Type type() const override
float scaleFactor() const override
factor by which item has been resized
represents the units (in sense of dimensional analysis) of a variable.
const Minsky & cminsky()
const version to help in const correctness
CLASSDESC_ACCESS_EXPLICIT_INSTANTIATION(minsky::IntOp)
VariablePtr intVar
return reference to integration variable
void removeControlledItems(minsky::GroupItems &) override
bool selected
true if selected for cut, copy or group operation
void ensureItemInserted(const ItemPtr &item)
check if item already present, and if not, inserts item delegates to ensureGroupInserted if passed a ...
void draw(cairo_t *) const override
draw this item into a cairo context
bool toggleCoupled()
toggles coupled state of integration variable. Only valid for integrate
bool mouseFocus
true if target of a mouseover
void convertVarType(const std::string &name, VariableType::Type type)
Converts variable(s) named by name into a variable of type type.
void moveTo(float x, float y)
void unpack(classdesc::unpack_t &x, const std::string &d) override
UnitsExpressionWalker timeUnit
static constexpr float intVarOffset
Minsky & minsky()
global minsky object
helper class to draw port label symbols
void drawResizeHandles(cairo_t *cairo) const override
void draw()
render the cairo image
ItemT & operator=(const ItemT &)=default
Units units(bool) const override
compute the dimensional units
float height() const
half height of unrotated image
ItemPtr removeItem(const Item &)
float width() const
half width of unrotated image