28 #include "polyRESTProcessBase.h" 30 #include <json_pack_base.h> 34 #include <cairo_base.h> 39 #include <RESTProcess_base.h> 56 typedef std::shared_ptr<Item>
ItemPtr;
89 return m_left-portRadius<=x && m_right+portRadius>=x &&
m_top-portRadius<=y && m_bottom+portRadius>=y;
104 classdesc::Exclude<std::weak_ptr<Group>>
group;
147 public classdesc::PolyRESTProcessBase,
148 public classdesc::Exclude<ItemExclude>
165 static void drawResizeHandle(cairo_t* cairo,
double x,
double y,
double sf,
double angle);
177 virtual std::weak_ptr<Port>
ports(std::size_t i)
const {
183 if (
auto p=
ports(i).lock())
return p->x();
188 if (
auto p=
ports(i).lock())
return p->y();
195 return left()-hz<=xx && right()+hz>=xx &&
top()-hz<=yy && bottom()+hz>=yy;
201 [[noreturn]]
void throw_error(
const std::string&)
const;
204 virtual bool ioVar()
const {
return false;}
206 virtual double value()
const {
return 0;}
209 double rotation(
const double& r) {
return m_rotation=r;}
233 std::string
id()
const {
return str(
size_t(
this));}
235 virtual float x()
const;
236 virtual float y()
const;
241 virtual std::vector<Point>
corners()
const;
256 virtual bool inItem(
float x,
float y)
const {
return false;}
258 virtual bool onItem(
float x,
float y)
const;
273 virtual bool onKeyPress(
int keySym,
const std::string& utf8,
int state)
280 auto r=
new Item(*
this);
291 virtual void draw(cairo_t* cairo)
const;
325 virtual std::shared_ptr<Item>
select(
float x,
float y)
const {
return {};}
327 void RESTProcess(classdesc::RESTProcess_t& rp,
const std::string& d)
override 329 void RESTProcess(classdesc::RESTProcess_t& rp,
const std::string& d)
const override 375 #pragma omit pack minsky::Item 376 #pragma omit unpack minsky::Item 379 #pragma omit pack minsky::ItemExclude 380 #pragma omit unpack minsky::ItemExclude 381 #pragma omit json_pack minsky::ItemExclude 382 #pragma omit json_unpack minsky::ItemExclude 383 #pragma omit xml_pack minsky::ItemExclude 384 #pragma omit xml_unpack minsky::ItemExclude 385 #pragma omit TCL_obj minsky::ItemExclude 386 #pragma omit RESTProcess minsky::ItemExclude 392 public classdesc::NullDescriptor<classdesc::pack_t> {};
394 public classdesc::NullDescriptor<classdesc::unpack_t> {};
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)
virtual void json_pack(classdesc::json_pack_t &j) const
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 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)
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 std::weak_ptr< Port > ports(std::size_t i) const
callback to be run when item deleted from group
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 &&)