28 #include "polyRESTProcessBase.h" 31 #include <TCL_obj_base.h> 32 #include <json_pack_base.h> 36 #include <cairo_base.h> 41 #include <RESTProcess_base.h> 58 typedef std::shared_ptr<Item>
ItemPtr;
91 return m_left-portRadius<=x && m_right+portRadius>=x &&
m_top-portRadius<=y && m_bottom+portRadius>=y;
106 classdesc::Exclude<std::weak_ptr<Group>>
group;
149 public classdesc::PolyRESTProcessBase,
150 public classdesc::Exclude<ItemExclude>
167 static void drawResizeHandle(cairo_t* cairo,
double x,
double y,
double sf,
double angle);
180 virtual std::weak_ptr<Port>
ports(std::size_t i)
const {
186 if (
auto p=
ports(i).lock())
return p->x();
191 if (
auto p=
ports(i).lock())
return p->y();
198 return left()-hz<=xx && right()+hz>=xx &&
top()-hz<=yy && bottom()+hz>=yy;
204 [[noreturn]]
void throw_error(
const std::string&)
const;
207 virtual bool ioVar()
const {
return false;}
209 virtual double value()
const {
return 0;}
212 double rotation(
const double& r) {
return m_rotation=r;}
236 std::string
id()
const {
return str(
size_t(
this));}
238 virtual float x()
const;
239 virtual float y()
const;
244 virtual std::vector<Point>
corners()
const;
259 virtual bool inItem(
float x,
float y)
const {
return false;}
261 virtual bool onItem(
float x,
float y)
const;
276 virtual bool onKeyPress(
int keySym,
const std::string& utf8,
int state)
283 auto r=
new Item(*
this);
294 virtual void draw(cairo_t* cairo)
const;
328 virtual std::shared_ptr<Item>
select(
float x,
float y)
const {
return {};}
330 virtual void TCL_obj(classdesc::TCL_obj_t& t,
const std::string& d)
333 void RESTProcess(classdesc::RESTProcess_t& rp,
const std::string& d)
override 335 void RESTProcess(classdesc::RESTProcess_t& rp,
const std::string& d)
const override 381 #pragma omit pack minsky::Item 382 #pragma omit unpack minsky::Item 385 #pragma omit pack minsky::ItemExclude 386 #pragma omit unpack minsky::ItemExclude 387 #pragma omit json_pack minsky::ItemExclude 388 #pragma omit json_unpack minsky::ItemExclude 389 #pragma omit xml_pack minsky::ItemExclude 390 #pragma omit xml_unpack minsky::ItemExclude 391 #pragma omit TCL_obj minsky::ItemExclude 392 #pragma omit RESTProcess minsky::ItemExclude 398 public classdesc::NullDescriptor<classdesc::pack_t> {};
400 public classdesc::NullDescriptor<classdesc::unpack_t> {};
409 if (a) a->TCL_obj(t,d);
virtual bool ioVar() const
indicates this is a group I/O variable
virtual Units units(bool check=false) const
compute the dimensional units
represents items that have been selected
float portY(std::size_t i)
virtual std::shared_ptr< Port > closestOutPort(float x, float y) const
returns closest output port to x,y
virtual bool onMouseOver(float x, float y)
respond to mouse motion events (hover) without button pressed
void drawPorts(cairo_t *cairo) const
void adjustBookmark() const override
adjust bookmark list to reflect current configuration
virtual void updateIcon(double t)
update display after a step()
represents whether a mouse click is on the item, on an output port (for wiring, or is actually outsid...
std::size_t portsSize() const
number of ports
virtual Point resizeHandleCoords() const
returns coordinates of the resizer handle
bool initialisedFrom(float rot, float x, float y) const
virtual void displayTooltip(cairo_t *, const std::string &) const
display tooltip text, eg on mouseover
virtual double value() const
current value of output port
bool contains(const Point &p) const
virtual void removeControlledItems(GroupItems &)
remove all controlled items from a group
virtual void onMouseLeave()
respond to mouse leave events (when mouse leaves item)
virtual bool visible() const
whether this item is visible on the canvas.
virtual const PlotWidget * plotWidgetCast() const
a more efficient replacement for dynamic_cast<PlotWidget*>(this)
void dummyDraw() const
draw into a dummy cairo context, for purposes of calculating port positions
bool onResizeHandles
set to true to indicate mouse is ovcaler resize handles
bool onResizeHandle(float x, float y) const override
represents rectangular region of a lasso operation
float m_sf
scale factor of item on canvas, or within group
virtual const SwitchIcon * switchIconCast() const
a more efficient replacement for dynamic_cast<SwitchIcon*>(this)
float y(float x, float y) const
virtual bool editorMode() const
some items have an editor mode attribute
std::shared_ptr< Item > ItemPtr
Item members excluded from reflection.
virtual PlotWidget * plotWidgetCast()
a more efficient replacement for dynamic_cast<PlotWidget*>(this)
std::pair< double, bool > rotationAsRadians() const
return the rotation as radians, and whether rotation should have additional straight angle added for ...
void RESTProcess(classdesc::RESTProcess_t &rp, const std::string &d) override
runs the RESTProcess descriptor suitable for this type
Rotate(float rot, float x0, float y0)
rotate (x,y) by rot (in degrees) around the origin (x0, y0) can be used for rotating multiple points ...
BoundingBox bb
canvas bounding box.
virtual std::string const & tooltip() const
virtual Ravel * ravelCast()
a more efficient replacement for dynamic_cast<Ravel*>(this)
virtual float zoomFactor() const
static void drawResizeHandle(cairo_t *cairo, double x, double y, double sf, double angle)
minsky::Item::MemoisedRotator memoisedRotator
virtual const GodleyIcon * godleyIconCast() const
a more efficient replacement for dynamic_cast<GodleyIcon*>(this)
void update(const Item &x)
void operator()(cd::TCL_obj_t &t, const cd::string &d, U &a)
void ensureBBValid() const
virtual SwitchIcon * switchIconCast()
a more efficient replacement for dynamic_cast<SwitchIcon*>(this)
virtual bool onResizeHandle(float x, float y) const
Units checkUnits() const
perform units consistency checks
virtual void draw(cairo_t *cairo) const
draw this item into a cairo context
float iHeight(const float &h)
virtual VariableBase * variableCast()
a more efficient replacement for dynamic_cast<VariableBase*>(this)
virtual ClickType::Type clickType(float x, float y) const
returns the clicktype given a mouse click at x, y.
virtual bool onMouseMotion(float x, float y)
respond to mouse motion events with button pressed
virtual void insertControlled(Selection &selection)
insert this items controlled or controller items are inserted correctly into selection.
static void drawSelected(cairo_t *cairo)
float iWidth(const float &w)
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky's state cha...
std::vector< ItemPtr > Items
double rotation(const double &r)
virtual const OperationBase * operationCast() const
a more efficient replacement for dynamic_cast<OperationBase*>(this)
virtual void onMouseUp(float x, float y)
respond to mouse up events
represents the units (in sense of dimensional analysis) of a variable.
ItemPtr itemPtrFromThis() const
return a shared_ptr to this
bool onBorder
true to indicate mouse hovering over border
void rotate(const Point &mouse, const Point &orig)
boost::geometry::model::d2::point_xy< float > Point
std::string str(T x)
utility function to create a string representation of a numeric type
virtual void drawResizeHandles(cairo_t *cairo) const
virtual bool contains(float xx, float yy) const
virtual void toggleEditorMode()
void throw_error(const std::string &) const
mark item on canvas, then throw
virtual GodleyIcon * godleyIconCast()
a more efficient replacement for dynamic_cast<GodleyIcon*>(this)
float resizeHandleSize() const
resize handles should be at least a percentage if the icon size (#1025)
virtual float scaleFactor() const
factor by which item has been resized
virtual void resize(const LassoBox &b)
resize this item on the canvas
ItemPortVector(const ItemPortVector &)
classdesc::Exclude< std::weak_ptr< Group > > group
owning group of this item.
virtual std::vector< Point > corners() const
virtual void disableDelayedTooltip()
float portX(std::size_t i)
virtual std::string classType() const
void removeControlledItems()
remove all controlled items from their owning group
virtual Item * clone() const
bounding box information (at zoom=1 scale)
std::string bookmarkId() const
Id of bookmark associated with this.
double m_rotation
rotation of icon, in degrees rotate item based on vector from orig to mouse
virtual bool inItem(float x, float y) const
virtual OperationBase * operationCast()
a more efficient replacement for dynamic_cast<OperationBase*>(this)
constexpr float portRadiusMult
virtual const Ravel * ravelCast() const
a more efficient replacement for dynamic_cast<Ravel*>(this)
virtual void deleteAttachedWires()
delete all attached wires
Item & operator=(const Item &)=default
void moveTo(float x, float y)
void updateBoundingBox() override
ItemPortVector & operator=(const ItemPortVector &)
bool contains(float x, float y) const
virtual void TCL_obj(classdesc::TCL_obj_t &t, const std::string &d)
runs the TCL_obj descriptor suitable for this type
virtual std::weak_ptr< Port > ports(std::size_t i) const
callback to be run when item deleted from group
virtual void json_pack(classdesc::json_pack_t &j) const
string to_string(CONST84 char *x)
virtual bool onKeyPress(int keySym, const std::string &utf8, int state)
respond to key press events
void RESTProcess(classdesc::RESTProcess_t &rp, const std::string &d) const override
float m_y
position in canvas, or within group
virtual void destroyFrame()
destroy any popup windows associated with this
constexpr float portRadius
radius of circle marking ports at zoom=1
virtual void displayDelayedTooltip(float x, float y)
enable extended tooltip help message appropriate for mouse at (x,y)
float x(float x, float y) const
void update(float a, float x, float y)
virtual void onMouseDown(float x, float y)
respond to mouse down events
virtual bool onItem(float x, float y) const
returns true if (x,y) is on the icon
std::string id() const
return an id uniquely identifying this item
void drawResizeHandles(cairo_t *cairo) const override
ItemPortVector(ItemPortVector &&)
virtual std::shared_ptr< Port > closestInPort(float x, float y) const
virtual void flip()
rotate icon though 180∘
std::string deleteCallback
virtual const VariableBase * variableCast() const
a more efficient replacement for dynamic_cast<VariableBase*>(this)
virtual std::shared_ptr< Item > select(float x, float y) const
returns the variable if point (x,y) is within a visible variable icon, null otherwise.
ItemPortVector & operator=(ItemPortVector &&)