42 double coupledIntTranslation=0;
54 const cairo::CairoSave cs(cairo);
58 cairo_rotate(cairo,angle);
60 if (rv.
width()<iv.iWidth()) coupledIntTranslation=-0.5*(
intVarOffset+2*iv.iWidth()+2+
r)*z;
65 const cairo::CairoSave cs(cairo);
66 cairo_rotate(cairo, angle);
67 cairo_scale(cairo,z,z);
68 if (textFlipped) cairo_rotate(cairo,
M_PI);
70 cairo_scale(cairo,sf,sf);
71 cairo_move_to(cairo,-7,3.5);
72 cairo_show_text(cairo,
"∫dt");
79 cairo_rotate(cairo, angle);
84 cairo_move_to(cairo,
l,
h);
85 cairo_line_to(cairo,
l,-
h);
86 cairo_line_to(cairo,
r,0);
88 cairo_close_path(cairo);
90 cairo_set_source_rgb(cairo,0,0,1);
91 cairo_stroke_preserve(cairo);
96 cairo_new_path(cairo);
97 cairo_move_to(cairo,
r,0);
98 cairo_line_to(cairo,
r+ivo,0);
99 cairo_set_source_rgb(cairo,0,0,0);
105 intVarWidth=rv.
width()*z;
109 auto ivp=rot(
x()+
r+ivo+intVarWidth,
y());
110 intVar->moveTo(ivp.x(), ivp.y());
113 cairo_translate(cairo,
r+ivo+intVarWidth,0);
119 cairo_restore(cairo);
122 cairo_move_to(cairo,
l,
h);
123 cairo_line_to(cairo,
l,-
h);
124 cairo_line_to(cairo,
r,0);
125 cairo_line_to(cairo,
r+ivo,0);
129 cairo_line_to(cairo,
r+ivo,-rvh);
130 cairo_line_to(cairo,
r+ivo+2*rvw,-rvh);
131 cairo_line_to(cairo,
r+ivo+2*rvw+2*z,0);
132 cairo_line_to(cairo,
r+ivo+2*rvw,rvh);
133 cairo_line_to(cairo,
r+ivo,rvh);
134 cairo_line_to(cairo,
r+ivo,0);
135 cairo_line_to(cairo,
r,0);
136 cairo_close_path(cairo);
139 cairo::Path clipPath(cairo);
141 double x0=
r, y0=0, x1=
l, y1=
numPorts() > 2? -
h+3: 0,
144 if (textFlipped) swap(y1,y2);
151 cairo_identity_matrix(cairo);
152 cairo_translate(cairo,
x(),
y());
153 cairo_rotate(cairo, angle);
154 cairo_user_to_device(cairo, &x0, &y0);
155 cairo_user_to_device(cairo, &x1, &y1);
156 cairo_user_to_device(cairo, &x2, &y2);
157 cairo_restore(cairo);
166 cairo_translate(cairo,-coupledIntTranslation,0);
167 cairo_restore(cairo);
175 cairo_new_path(cairo);
176 clipPath.appendToCurrent(cairo);
189 intVar->iHeight(0.5*std::abs(b.
y1-b.
y0)*invZ);
201 intVar.reset(
x.intVar->clone());
220 if (desc[0]==
':') desc=desc.substr(1);
225 vector<Wire> savedWires;
229 for (
auto w:
intVar->ports(0).lock()->wires())
230 savedWires.push_back(*w);
240 if (i!=
minsky().variableValues.end())
252 if (
minsky().definingVar(vid))
256 if (desc[0]==
':') desc=desc.substr(1);
265 if (
auto g=
group.lock())
266 intVar->controller=g->findItem(*
this);
271 for (
auto& w: savedWires)
277 if (
auto g=
group.lock())
292 if (
auto g=
group.lock())
296 intVar->controller.reset();
301 if (
auto g=
group.lock())
303 for (
auto w:
intVar->ports(1).lock()->wires())
305 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)
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