Minsky: 3.17.0
minsky::Canvas Class Reference

#include <canvas.h>

Inheritance diagram for minsky::Canvas:
Inheritance graph
Collaboration diagram for minsky::Canvas:
Collaboration graph

Classes

struct  LassoMode
 lasso mode support More...
 
struct  Model
 
struct  ZoomCrop
 

Public Types

typedef std::chrono::time_point< std::chrono::high_resolution_clock > Timestamp
 

Public Member Functions

void rotateItem (float x, float y)
 
void moveTo (float x, float y) override
 move this so that (x,y) is centred More...
 
std::vector< float > position () const override
 current centre coordinates More...
 
void zoom (double x, double y, double z) override
 
double zoomFactor () const override
 
 Canvas ()
 
 Canvas (const GroupPtr &m)
 
ecolab::cairo::SurfacePtr & surface ()
 
void mouseDown (float x, float y) override
 event handling for the canvas More...
 
void controlMouseDown (float x, float y) override
 
void mouseUp (float x, float y) override
 
void mouseMove (float x, float y) override
 
bool keyPress (const EventInterface::KeyPressArgs &) override
 handle key press over current itemFocus, More...
 
void displayDelayedTooltip (float x, float y)
 
std::shared_ptr< PortclosestInPort (float x, float y) const
 return closest visible port to (x,y). nullptr is nothing suitable More...
 
void select (const LassoBox &)
 select all items in a given region More...
 
int ravelsSelected () const
 number of ravels in selection More...
 
void setItemFocus (const ItemPtr &x)
 sets itemFocus, and resets mouse offset for placement More...
 
- Public Member Functions inherited from minsky::RenderNativeWindow
const RenderFrameArgsframeArgs () const
 
 ~RenderNativeWindow () override
 
virtual void init ()
 perform any initialisation of any subclasses of this More...
 
void renderFrame (const RenderFrameArgs &args)
 
void destroyFrame ()
 
void draw ()
 
void requestRedraw ()
 
RenderNativeWindowoperator= (const RenderNativeWindow &x)
 
 RenderNativeWindow ()=default
 
 RenderNativeWindow (const RenderNativeWindow &)=default
 
- Public Member Functions inherited from minsky::EventInterface

Public Attributes

Model model
 
Selection selection
 
ItemPtr itemFocus
 item selected by clicking More...
 
WirePtr wireFocus
 wire that mouse is hovering over More...
 
int handleSelected
 selected handle for handle moves, -ve = invalid More...
 
Exclude< shared_ptr< Port > > fromPort
 from port when creating a new wire More...
 
double termX
 
double termY
 terminal of wire when extending More...
 
float moveOffsX
 
float moveOffsY
 
bool rotatingItem =false
 set true when rotating an item More...
 
Exclude< PointrotateOrigin
 starting mouse position when rotating More...
 
ClickType::Type clickType
 
ItemPtr itemIndicator
 for drawing error indicator on the canvas More...
 
LassoMode::type lassoMode =LassoMode::none
 
LassoBox lasso {0,0,0,0}
 
bool redrawAll =true
 if false, then only redraw graphs More...
 
- Public Attributes inherited from minsky::EventInterface
ItemPtr item
 item or wire obtained by get*At() calls More...
 
WirePtr wire
 item or wire obtained by get*At() calls More...
 

Private Member Functions

 CLASSDESC_ACCESS (Canvas)
 
void copyVars (const std::vector< VariablePtr > &)
 
void reportDrawTime (double) override
 
void mouseDownCommon (float x, float y)
 
bool redraw (int x0, int y0, int width, int height) override
 
void mouseMoveOnItem (float x, float y)
 

Private Attributes

bool m_redrawRequested =false
 flag indicating that a redraw is requested, but not yet redrawn More...
 
PlotOptions defaultPlotOptions
 options to apply to a new plot widget More...
 
ItemPtr item
 item or wire obtained by get*At() calls More...
 
WirePtr wire
 item or wire obtained by get*At() calls More...
 
double defaultRotation =0
 item or wire obtained by get*At() calls More...
 
LassoBox updateRegion {0,0,0,0}
 region to be updated More...
 
ItemPtr itemAt (float x, float y)
 item or wire obtained by get*At() calls More...
 
bool getItemAt (float x, float y) override
 item or wire obtained by get*At() calls More...
 
bool getWireAt (float x, float y) override
 item or wire obtained by get*At() calls More...
 
void addOperation (OperationType::Type op)
 item or wire obtained by get*At() calls More...
 
void addVariable (const std::string &name, VariableType::Type type)
 item or wire obtained by get*At() calls More...
 
void addNote (const std::string &text)
 item or wire obtained by get*At() calls More...
 
void addPlot ()
 item or wire obtained by get*At() calls More...
 
void addGodley ()
 item or wire obtained by get*At() calls More...
 
void addGroup ()
 item or wire obtained by get*At() calls More...
 
void addSwitch ()
 item or wire obtained by get*At() calls More...
 
void addRavel ()
 item or wire obtained by get*At() calls More...
 
void addLock ()
 item or wire obtained by get*At() calls More...
 
void addSheet ()
 item or wire obtained by get*At() calls More...
 
void groupSelection ()
 create a group from items found in the current selection More...
 
void lockRavelsInSelection ()
 lock all ravels in the selection together. If ravels already belong to more than one group, then a completely new group is set up. More...
 
void unlockRavelsInSelection ()
 item or wire obtained by get*At() calls More...
 
void deleteItem ()
 delete item referenced by item More...
 
void deleteWire ()
 delete wire referenced by wire More...
 
void delHandle (float x, float y)
 delete wire handle referenced by wire More...
 
void removeItemFromItsGroup ()
 remove item from its group, leaving in itemFocus for later placement More...
 
void selectAllVariables ()
 select all variables referring to same variableValue as item More...
 
void renameAllInstances (const std::string &newName)
 rename all instances of variable as item to newName More...
 
void renameItem (const std::string &newName)
 rename variable as item to newName More...
 
void ungroupItem ()
 if item is a Group, move its contents to its parent and delete the group More...
 
void copyItem ()
 create a copy of item, and leave it focused More...
 
void zoomToFit ()
 zooms canvas to fit available window More...
 
void openGroupInCanvas (const ItemPtr &item)
 reinitialises canvas to the group located in item More...
 
void copyAllFlowVars ()
 copy all flowVars of a GodleyIcon in item More...
 
void copyAllStockVars ()
 copy all stockVars of a GodleyIcon in item More...
 
void zoomToDisplay ()
 zooms canvas such that group indexed by item is displayed More...
 
bool selectVar (float x, float y)
 populates item with a variable if (x,y) is over a variable part More...
 
bool findVariableDefinition ()
 populates item with the defining variable if there is one. Leave item unchanged if it is not a variable, or variable is undefined. NB may be a Godley table or integral More...
 
bool redraw ()
 draw a red circle around item More...
 
bool redrawUpdateRegion ()
 update region given by updateRegion More...
 
void renderToPNGCropped (const std::string &filename, const ZoomCrop &)
 Render to a PNG file filename, scaling the canvas temporarily by zoom, shifts it to left, top, and crops to width, height. More...
 
void recentre ()
 adjust canvas so that -ve coordinates appear on canvas More...
 
bool redrawRequested () const
 flag indicating that a redraw is requested, but not yet redrawn More...
 
void requestRedraw ()
 request a redraw on the screen More...
 
bool hasScrollBars () const override
 item or wire obtained by get*At() calls More...
 
void setDefaultPlotOptions ()
 item or wire obtained by get*At() calls More...
 
void applyDefaultPlotOptions ()
 item or wire obtained by get*At() calls More...
 
void setItemFromItemFocus ()
 item or wire obtained by get*At() calls More...
 

Additional Inherited Members

- Static Public Member Functions inherited from minsky::RenderNativeWindow
static double scaleFactor ()
 
- Static Public Attributes inherited from minsky::RenderNativeWindow
static ecolab::cairo::Colour backgroundColour {0.8,0.8,0.8,1}
 

Detailed Description

Definition at line 52 of file canvas.h.

Member Typedef Documentation

◆ Timestamp

typedef std::chrono::time_point<std::chrono::high_resolution_clock> minsky::Canvas::Timestamp

Definition at line 68 of file canvas.h.

Constructor & Destructor Documentation

◆ Canvas() [1/2]

minsky::Canvas::Canvas ( )
inline

Definition at line 145 of file canvas.h.

145 {}

◆ Canvas() [2/2]

minsky::Canvas::Canvas ( const GroupPtr m)
inline

Definition at line 146 of file canvas.h.

146 : model(m) {}
Model model
Definition: canvas.h:103

Member Function Documentation

◆ addGodley()

void minsky::Canvas::addGodley ( )
inline

item or wire obtained by get*At() calls

Definition at line 200 of file canvas.h.

200 {setItemFocus(model->addItem(new GodleyIcon));}
void setItemFocus(const ItemPtr &x)
sets itemFocus, and resets mouse offset for placement
Definition: canvas.h:167
Model model
Definition: canvas.h:103

◆ addGroup()

void minsky::Canvas::addGroup ( )
inline

item or wire obtained by get*At() calls

Definition at line 201 of file canvas.h.

201 {setItemFocus(model->addItem(new Group));}
void setItemFocus(const ItemPtr &x)
sets itemFocus, and resets mouse offset for placement
Definition: canvas.h:167
Model model
Definition: canvas.h:103

◆ addLock()

void minsky::Canvas::addLock ( )
inline

item or wire obtained by get*At() calls

Definition at line 204 of file canvas.h.

204 {setItemFocus(model->addItem(new Lock));}
void setItemFocus(const ItemPtr &x)
sets itemFocus, and resets mouse offset for placement
Definition: canvas.h:167
Model model
Definition: canvas.h:103

◆ addNote()

void minsky::Canvas::addNote ( const std::string &  text)
inline

item or wire obtained by get*At() calls

Definition at line 192 of file canvas.h.

192  {
193  setItemFocus(model->addItem(new Item));
194  itemFocus->detailedText(text);
195  }
void setItemFocus(const ItemPtr &x)
sets itemFocus, and resets mouse offset for placement
Definition: canvas.h:167
Model model
Definition: canvas.h:103
ItemPtr itemFocus
item selected by clicking
Definition: canvas.h:106

◆ addOperation()

void minsky::Canvas::addOperation ( OperationType::Type  op)
inline

item or wire obtained by get*At() calls

Definition at line 182 of file canvas.h.

References minsky::OperationBase::create(), minsky::OperationType::numOps, and minsky::op.

182  {
183  if (op==OperationType::numOps) return;
185  itemFocus->rotation(defaultRotation);
186  }
double defaultRotation
item or wire obtained by get*At() calls
Definition: canvas.h:181
void setItemFocus(const ItemPtr &x)
sets itemFocus, and resets mouse offset for placement
Definition: canvas.h:167
Model model
Definition: canvas.h:103
static OperationBase * create(Type type)
factory method.
Definition: operation.cc:545
ItemPtr itemFocus
item selected by clicking
Definition: canvas.h:106
Here is the call graph for this function:

◆ addPlot()

void minsky::Canvas::addPlot ( )
inline

item or wire obtained by get*At() calls

Definition at line 196 of file canvas.h.

References minsky::PlotOptions< Base >::applyPlotOptions().

196  {
197  setItemFocus(model->addItem(new PlotWidget));
198  defaultPlotOptions.applyPlotOptions(*itemFocus->plotWidgetCast());
199  }
PlotOptions defaultPlotOptions
options to apply to a new plot widget
Definition: canvas.h:65
void setItemFocus(const ItemPtr &x)
sets itemFocus, and resets mouse offset for placement
Definition: canvas.h:167
Model model
Definition: canvas.h:103
void applyPlotOptions(PlotWidget &plot) const
Definition: plotOptions.h:90
ItemPtr itemFocus
item selected by clicking
Definition: canvas.h:106
Here is the call graph for this function:

◆ addRavel()

void minsky::Canvas::addRavel ( )
inline

item or wire obtained by get*At() calls

Definition at line 203 of file canvas.h.

203 {setItemFocus(model->addItem(new Ravel));}
void setItemFocus(const ItemPtr &x)
sets itemFocus, and resets mouse offset for placement
Definition: canvas.h:167
Model model
Definition: canvas.h:103

◆ addSheet()

void minsky::Canvas::addSheet ( )
inline

item or wire obtained by get*At() calls

Definition at line 205 of file canvas.h.

205 {setItemFocus(model->addItem(new Sheet));}
void setItemFocus(const ItemPtr &x)
sets itemFocus, and resets mouse offset for placement
Definition: canvas.h:167
Model model
Definition: canvas.h:103

◆ addSwitch()

void minsky::Canvas::addSwitch ( )
inline

item or wire obtained by get*At() calls

Definition at line 202 of file canvas.h.

202 {setItemFocus(model->addItem(new SwitchIcon));}
void setItemFocus(const ItemPtr &x)
sets itemFocus, and resets mouse offset for placement
Definition: canvas.h:167
Model model
Definition: canvas.h:103

◆ addVariable()

void minsky::Canvas::addVariable ( const std::string &  name,
VariableType::Type  type 
)
inline

item or wire obtained by get*At() calls

Definition at line 187 of file canvas.h.

References minsky::VariableType::numVarTypes, and minsky::VariableType::undefined.

Referenced by minsky::VariablePaneCell::emplace().

187  {
188  if (type==VariableType::undefined || type==VariableType::numVarTypes) return;
189  setItemFocus(model->addItem(VariablePtr(type,name)));
190  itemFocus->rotation(defaultRotation);
191  }
double defaultRotation
item or wire obtained by get*At() calls
Definition: canvas.h:181
void setItemFocus(const ItemPtr &x)
sets itemFocus, and resets mouse offset for placement
Definition: canvas.h:167
Model model
Definition: canvas.h:103
ItemPtr itemFocus
item selected by clicking
Definition: canvas.h:106
Here is the caller graph for this function:

◆ applyDefaultPlotOptions()

void minsky::Canvas::applyDefaultPlotOptions ( )

item or wire obtained by get*At() calls

Definition at line 960 of file canvas.cc.

960  {
961  if (auto p=item->plotWidgetCast()) {
962  // stash titles to restore later
963  const string title(p->title), xlabel(p->xlabel()),
964  ylabel(p->ylabel()), y1label(p->y1label());
966  p->title=title, p->xlabel(xlabel),
967  p->ylabel(ylabel), p->y1label(y1label);
968  }
969  }
PlotOptions defaultPlotOptions
options to apply to a new plot widget
Definition: canvas.h:65
void applyPlotOptions(PlotWidget &plot) const
Definition: plotOptions.h:90
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175

◆ CLASSDESC_ACCESS()

minsky::Canvas::CLASSDESC_ACCESS ( Canvas  )
private

◆ closestInPort()

shared_ptr< Port > minsky::Canvas::closestInPort ( float  x,
float  y 
) const

return closest visible port to (x,y). nullptr is nothing suitable

Definition at line 120 of file canvas.cc.

References minsky::anonymous_namespace{autoLayout.cc}::minD(), and minsky::sqr().

121  {
122  shared_ptr<Port> closestPort;
123  auto minD=numeric_limits<float>::max();
124  model->recursiveDo(&GroupItems::items,
125  [&](const Items&, Items::const_iterator i)
126  {
127  if ((*i)->group.lock()->displayContents())
128  for (size_t pi=0; pi<(*i)->portsSize(); ++pi)
129  {
130  auto p=(*i)->ports(pi).lock();
131  const float d=sqr(p->x()-x)+sqr(p->y()-y);
132  if (d<minD)
133  {
134  minD=d;
135  closestPort=p;
136  }
137  }
138  return false;
139  });
140  return closestPort;
141  }
Model model
Definition: canvas.h:103
std::vector< ItemPtr > Items
Definition: item.h:360
double minD(const Item &item1, const Item &item2)
Definition: autoLayout.cc:47
T sqr(T x)
Definition: geometry.h:36
Here is the call graph for this function:

◆ controlMouseDown()

void minsky::Canvas::controlMouseDown ( float  x,
float  y 
)
overridevirtual

Reimplemented from minsky::EventInterface.

Definition at line 42 of file canvas.cc.

43  {
44  mouseDownCommon(x,y);
45  if (itemFocus && itemFocus->group.lock() == model)
47  }
Model model
Definition: canvas.h:103
void mouseDownCommon(float x, float y)
Definition: canvas.cc:57
ItemPtr itemFocus
item selected by clicking
Definition: canvas.h:106
Selection selection
Definition: canvas.h:105
void toggleItemMembership(const ItemPtr &item)
add item to selection if not present, or removes it if present groups handled as well ...
Definition: selection.cc:37

◆ copyAllFlowVars()

void minsky::Canvas::copyAllFlowVars ( )
inline

copy all flowVars of a GodleyIcon in item

Definition at line 244 of file canvas.h.

244  {
245  if (auto g=dynamic_cast<GodleyIcon*>(item.get()))
246  copyVars(g->flowVars());
247  }
void copyVars(const std::vector< VariablePtr > &)
Definition: canvas.cc:713
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175

◆ copyAllStockVars()

void minsky::Canvas::copyAllStockVars ( )
inline

copy all stockVars of a GodleyIcon in item

Definition at line 249 of file canvas.h.

249  {
250  if (auto g=dynamic_cast<GodleyIcon*>(item.get()))
251  copyVars(g->stockVars());
252  }
void copyVars(const std::vector< VariablePtr > &)
Definition: canvas.cc:713
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175

◆ copyItem()

void minsky::Canvas::copyItem ( )

create a copy of item, and leave it focused

Definition at line 617 of file canvas.cc.

References minsky::Minsky::canvas, minsky::group, pyminsky::minsky, minsky::Minsky::pushHistory(), renameAllInstances(), and minsky::Minsky::undo().

618  {
619  if (item)
620  {
621  ItemPtr newItem;
622  // cannot duplicate an integral, just its variable
623  if (auto intop=dynamic_cast<IntOp*>(item.get()))
624  newItem.reset(intop->intVar->clone());
625  else if (auto group=dynamic_cast<Group*>(item.get()))
626  newItem=group->copy();
627  else
628  {
629  if (item->ioVar())
630  if (auto v=item->variableCast())
631  if (v->rawName()[0]!=':')
632  try
633  {
634  minsky().pushHistory(); // save current state in case of failure
635  // attempt to make variable outer scoped. For #1100
636  minsky().canvas.renameAllInstances(":"+v->rawName());
637  }
638  catch (...)
639  {
640  minsky().undo(); // back out of change
641  throw;
642  }
643 
644  newItem.reset(item->clone());
645  // if copied from a Godley table or I/O var, set orientation to default
646  if (auto v=item->variableCast())
647  if (v->controller.lock())
648  newItem->rotation(defaultRotation);
649 
650  }
651  setItemFocus(model->addItem(newItem));
652  model->normaliseGroupRefs(model);
653  }
654  }
bool pushHistory()
push current model state onto history if it differs from previous
Definition: minsky.cc:1264
double defaultRotation
item or wire obtained by get*At() calls
Definition: canvas.h:181
void setItemFocus(const ItemPtr &x)
sets itemFocus, and resets mouse offset for placement
Definition: canvas.h:167
std::shared_ptr< Item > ItemPtr
Definition: item.h:55
Model model
Definition: canvas.h:103
void renameAllInstances(const std::string &newName)
rename all instances of variable as item to newName
Definition: canvas.cc:557
long undo(int changes=1)
restore model to state changes ago
Definition: minsky.cc:1400
Canvas canvas
Definition: minsky.h:243
Minsky & minsky()
global minsky object
Definition: addon.cc:545
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175
Here is the call graph for this function:

◆ copyVars()

void minsky::Canvas::copyVars ( const std::vector< VariablePtr > &  v)
private

Definition at line 713 of file canvas.cc.

References minsky::RenderVariable::height(), and minsky::RenderVariable::width().

714  {
715  float maxWidth=0, totalHeight=0;
716  vector<float> widths, heights;
717  // Throw error if no stock/flow vars on Godley icon. For ticket 1039
718  if (!v.empty()) {
719  selection.clear();
720  for (auto& i: v)
721  {
722  const RenderVariable rv(*i);
723  widths.push_back(rv.width());
724  heights.push_back(rv.height());
725  maxWidth=max(maxWidth, widths.back());
726  totalHeight+=heights.back();
727  }
728  float y=v[0]->y() - totalHeight;
729  for (size_t i=0; i<v.size(); ++i)
730  {
731  // Stock and flow variables on Godley icons should not be copied as groups. For ticket 1039
732  const ItemPtr ni(v[i]->clone());
733  (ni->variableCast())->rotation(0);
734  ni->moveTo(v[0]->x()+maxWidth-v[i]->zoomFactor()*widths[i],
735  y+heights[i]);
736  // variables need to refer to outer scope
737  if ((ni->variableCast())->name()[0]!=':')
738  (ni->variableCast())->name(':'+(ni->variableCast())->name());
739  y+=2*v[i]->zoomFactor()*heights[i];
740  selection.insertItem(model->addItem(ni));
741  }
742  // Item focus put on one of the copied vars that are still in selection. For ticket 1039
744  else setItemFocus(nullptr);
745  } else throw error("no flow or stock variables to copy");
746  }
void insertItem(const ItemPtr &item)
Definition: selection.cc:81
void setItemFocus(const ItemPtr &x)
sets itemFocus, and resets mouse offset for placement
Definition: canvas.h:167
std::shared_ptr< Item > ItemPtr
Definition: item.h:55
Model model
Definition: canvas.h:103
bool empty() const
Definition: group.h:100
Selection selection
Definition: canvas.h:105
double zoomFactor() const override
Definition: canvas.h:143
Here is the call graph for this function:

◆ deleteItem()

void minsky::Canvas::deleteItem ( )

delete item referenced by item

Definition at line 487 of file canvas.cc.

References pyminsky::minsky, and minsky::Minsky::requestReset().

488  {
489  if (item)
490  {
491  model->deleteItem(*item);
492  minsky().requestReset();
493  }
494  }
void requestReset()
Definition: minsky.cc:466
Model model
Definition: canvas.h:103
Minsky & minsky()
global minsky object
Definition: addon.cc:545
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175
Here is the call graph for this function:

◆ deleteWire()

void minsky::Canvas::deleteWire ( )

delete wire referenced by wire

Definition at line 496 of file canvas.cc.

References pyminsky::minsky, minsky::Minsky::requestReset(), and minsky::wire.

497  {
498  if (wire)
499  {
500  model->removeWire(*wire);
501  wire.reset();
502  minsky().requestReset();
503  }
504  }
WirePtr wire
item or wire obtained by get*At() calls
Definition: canvas.h:176
void requestReset()
Definition: minsky.cc:466
Model model
Definition: canvas.h:103
Minsky & minsky()
global minsky object
Definition: addon.cc:545
Here is the call graph for this function:

◆ delHandle()

void minsky::Canvas::delHandle ( float  x,
float  y 
)

delete wire handle referenced by wire

Definition at line 507 of file canvas.cc.

508  {
509  wireFocus=model->findAny(&Group::wires,
510  [&](const WirePtr& i){return i->near(x,y);});
511  if (wireFocus)
512  {
513  wireFocus->deleteHandle(x,y);
514  wireFocus.reset(); // prevent accidental moves of handle
515  }
516  requestRedraw();
517  }
std::shared_ptr< Wire > WirePtr
Definition: wire.h:98
Model model
Definition: canvas.h:103
void requestRedraw()
request a redraw on the screen
Definition: canvas.h:292
WirePtr wireFocus
wire that mouse is hovering over
Definition: canvas.h:107

◆ displayDelayedTooltip()

void minsky::Canvas::displayDelayedTooltip ( float  x,
float  y 
)

Definition at line 370 of file canvas.cc.

371  {
372  if (auto item=itemAt(x,y))
373  {
374  item->displayDelayedTooltip(x,y);
375  requestRedraw();
376  }
377  }
ItemPtr itemAt(float x, float y)
item or wire obtained by get*At() calls
Definition: canvas.cc:411
void requestRedraw()
request a redraw on the screen
Definition: canvas.h:292
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175

◆ findVariableDefinition()

bool minsky::Canvas::findVariableDefinition ( )

populates item with the defining variable if there is one. Leave item unchanged if it is not a variable, or variable is undefined. NB may be a Godley table or integral

Returns
true if definition found.

Definition at line 770 of file canvas.cc.

771  {
772  if (auto iv=item->variableCast())
773  {
774  if (iv->type()==VariableType::constant ||
775  iv->type()==VariableType::parameter || iv->inputWired())
776  return (itemIndicator=item).get();
777 
778  itemIndicator=model->findAny
779  (&GroupItems::items, [&](const ItemPtr& i) {
780  if (auto v=i->variableCast())
781  return v->inputWired() && v->valueId()==iv->valueId();
782  if (auto g=dynamic_cast<GodleyIcon*>(i.get()))
783  for (auto& v: g->stockVars())
784  {
785  if (v->valueId()==iv->valueId())
786  return true;
787  }
788  else if (auto o=dynamic_cast<IntOp*>(i.get()))
789  return o->intVar->valueId()==iv->valueId();
790  return false;
791  });
792  return itemIndicator.get();
793  }
794  return false;
795  }
std::shared_ptr< Item > ItemPtr
Definition: item.h:55
Model model
Definition: canvas.h:103
ItemPtr itemIndicator
for drawing error indicator on the canvas
Definition: canvas.h:120
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175

◆ getItemAt()

bool minsky::Canvas::getItemAt ( float  x,
float  y 
)
inlineoverridevirtual

item or wire obtained by get*At() calls

Reimplemented from minsky::EventInterface.

Definition at line 178 of file canvas.h.

178 {return (item=itemAt(x,y)).get();}
ItemPtr itemAt(float x, float y)
item or wire obtained by get*At() calls
Definition: canvas.cc:411
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175

◆ getWireAt()

bool minsky::Canvas::getWireAt ( float  x,
float  y 
)
overridevirtual

item or wire obtained by get*At() calls

Reimplemented from minsky::EventInterface.

Definition at line 434 of file canvas.cc.

References minsky::wire.

435  {
436  wire=model->findAny(&Group::wires,
437  [&](const WirePtr& i){return i->near(x,y);});
438  return wire.get();
439  }
WirePtr wire
item or wire obtained by get*At() calls
Definition: canvas.h:176
std::shared_ptr< Wire > WirePtr
Definition: wire.h:98
Model model
Definition: canvas.h:103

◆ groupSelection()

void minsky::Canvas::groupSelection ( )

create a group from items found in the current selection

Definition at line 441 of file canvas.cc.

442  {
443  const GroupPtr r=model->addGroup(new Group);
444  for (auto& i: selection.items)
445  r->addItem(i);
446  for (auto& i: selection.groups)
447  r->addItem(i);
448  r->splitBoundaryCrossingWires();
449  r->resizeOnContents();
450  }
Model model
Definition: canvas.h:103
Groups groups
Definition: group.h:77
Selection selection
Definition: canvas.h:105
std::shared_ptr< Group > GroupPtr
Definition: port.h:32

◆ hasScrollBars()

bool minsky::Canvas::hasScrollBars ( ) const
inlineoverridevirtual

item or wire obtained by get*At() calls

Reimplemented from minsky::RenderNativeWindow.

Definition at line 293 of file canvas.h.

293 {return true;}

◆ itemAt()

ItemPtr minsky::Canvas::itemAt ( float  x,
float  y 
)

item or wire obtained by get*At() calls

Definition at line 411 of file canvas.cc.

References minsky::anonymous_namespace{autoLayout.cc}::minD(), and minsky::sqr().

412  {
413  // Fix for library dependency problem with items during Travis build
414  ItemPtr item;
415  auto minD=numeric_limits<float>::max();
416  model->recursiveDo(&GroupItems::items,
417  [&](const Items&, Items::const_iterator i)
418  {
419  const float d=sqr((*i)->x()-x)+sqr((*i)->y()-y);
420  if (d<minD && (*i)->visible() && (*i)->contains(x,y))
421  {
422  minD=d;
423  item=*i;
424  }
425  return false;
426  });
427  if (!item)
428  item=model->findAny
429  (&Group::groups, [&](const GroupPtr& i)
430  {return i->visible() && i->clickType(x,y)!=ClickType::outside;});
431  return item;
432  }
std::shared_ptr< Item > ItemPtr
Definition: item.h:55
Model model
Definition: canvas.h:103
std::vector< ItemPtr > Items
Definition: item.h:360
double minD(const Item &item1, const Item &item2)
Definition: autoLayout.cc:47
T sqr(T x)
Definition: geometry.h:36
Groups groups
Definition: group.h:77
std::shared_ptr< Group > GroupPtr
Definition: port.h:32
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175
Here is the call graph for this function:

◆ keyPress()

bool minsky::Canvas::keyPress ( const EventInterface::KeyPressArgs )
overridevirtual

handle key press over current itemFocus,

Parameters
keySymthe X key sym code
utf8utf8 encoded character
statemodifer state 1=shift, 2=caps lock, 4=ctrl, 8=alt
x& y contain mouse coordinates
Returns
true if event handled

Reimplemented from minsky::EventInterface.

Definition at line 357 of file canvas.cc.

References minsky::EventInterface::KeyPressArgs::keySym, minsky::Minsky::markEdited(), pyminsky::minsky, minsky::EventInterface::KeyPressArgs::state, minsky::EventInterface::KeyPressArgs::utf8, minsky::EventInterface::KeyPressArgs::x, and minsky::EventInterface::KeyPressArgs::y.

358  {
359  if (auto item=itemAt(args.x,args.y))
360  if (item->onKeyPress(args.keySym, args.utf8, args.state))
361  {
362  minsky().markEdited(); // keyPresses don't set the dirty flag by default
363  requestRedraw();
364  return true;
365  }
366  return false;
367  }
ItemPtr itemAt(float x, float y)
item or wire obtained by get*At() calls
Definition: canvas.cc:411
void markEdited()
indicate model has been changed since last saved
Definition: minsky.h:161
void requestRedraw()
request a redraw on the screen
Definition: canvas.h:292
Minsky & minsky()
global minsky object
Definition: addon.cc:545
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175
Here is the call graph for this function:

◆ lockRavelsInSelection()

void minsky::Canvas::lockRavelsInSelection ( )

lock all ravels in the selection together. If ravels already belong to more than one group, then a completely new group is set up.

Definition at line 452 of file canvas.cc.

453  {
454  vector<shared_ptr<Ravel> > ravelsToLock;
455  shared_ptr<RavelLockGroup> lockGroup;
456  bool conflictingLockGroups=false;
457  for (auto& i: selection.items)
458  if (auto r=dynamic_pointer_cast<Ravel>(i))
459  {
460  ravelsToLock.push_back(r);
461  if (!lockGroup)
462  lockGroup=r->lockGroup;
463  if (lockGroup!=r->lockGroup)
464  conflictingLockGroups=true;
465  }
466  if (ravelsToLock.size()<2)
467  return;
468  if (!lockGroup || conflictingLockGroups)
469  lockGroup.reset(new RavelLockGroup);
470  for (auto& r: ravelsToLock)
471  {
472  lockGroup->addRavel(r);
473  r->leaveLockGroup();
474  r->lockGroup=lockGroup;
475  }
476  if (lockGroup) lockGroup->initialBroadcast();
477  selection.clear();
478  }
Selection selection
Definition: canvas.h:105

◆ mouseDown()

void minsky::Canvas::mouseDown ( float  x,
float  y 
)
overridevirtual

event handling for the canvas

Reimplemented from minsky::EventInterface.

Definition at line 49 of file canvas.cc.

50  {
51  mouseDownCommon(x,y);
53  selection.clear(); // clicking outside a selection clears it
54  }
void mouseDownCommon(float x, float y)
Definition: canvas.cc:57
bool contains(const ItemPtr &item) const
return if item is contained in selection
Definition: selection.cc:102
ItemPtr itemFocus
item selected by clicking
Definition: canvas.h:106
Selection selection
Definition: canvas.h:105

◆ mouseDownCommon()

void minsky::Canvas::mouseDownCommon ( float  x,
float  y 
)
private

Definition at line 57 of file canvas.cc.

58  {
59  wireFocus.reset();
60  // firstly, see if the user is selecting an item
61  if ((itemFocus=itemAt(x,y)))
62  {
63  clickType=itemFocus->clickType(x,y);
64  switch (clickType)
65  {
66  case ClickType::onPort:
67  // items all have their output port first, if they have an output port at all.
68  if ((fromPort=itemFocus->closestOutPort(x,y)))
69  {
70  termX=x;
71  termY=y;
72  itemFocus.reset();
73  }
74  break;
75  case ClickType::onItem:
76  moveOffsX=x-itemFocus->x();
77  moveOffsY=y-itemFocus->y();
78  break;
79  case ClickType::outside:
80  itemFocus.reset();
83  break;
84  case ClickType::inItem:
85  itemFocus->onMouseDown(x,y);
86  break;
89  // set x0,y0 to the opposite corner of (x,y)
90  lasso.x0 = x>itemFocus->x()? itemFocus->left(): itemFocus->right();
91  lasso.y0 = y>itemFocus->y()? itemFocus->top(): itemFocus->bottom();
92  lasso.x1=x;
93  lasso.y1=y;
95  break;
97  if (auto p=itemFocus->plotWidgetCast())
98  p->mouseDown(x,y);
99  break;
100  }
101  }
102  else
103  {
104  wireFocus=model->findAny(&Group::wires,
105  [&](const WirePtr& i){return i->near(x,y);});
106  if (wireFocus)
107  handleSelected=wireFocus->nearestHandle(x,y);
108  else
111  }
112 
114  {
115  lasso.x0=x;
116  lasso.y0=y;
117  }
118  }
ItemPtr itemAt(float x, float y)
item or wire obtained by get*At() calls
Definition: canvas.cc:411
int handleSelected
selected handle for handle moves, -ve = invalid
Definition: canvas.h:108
ClickType::Type clickType
Definition: canvas.h:118
std::shared_ptr< Wire > WirePtr
Definition: wire.h:98
Exclude< shared_ptr< Port > > fromPort
from port when creating a new wire
Definition: canvas.h:109
LassoBox lasso
Definition: canvas.h:125
Model model
Definition: canvas.h:103
float moveOffsX
Definition: canvas.h:111
float moveOffsY
Definition: canvas.h:111
double termX
Definition: canvas.h:110
float x0
Definition: lasso.h:30
ItemPtr itemFocus
item selected by clicking
Definition: canvas.h:106
float y1
Definition: lasso.h:30
float x1
Definition: lasso.h:30
double termY
terminal of wire when extending
Definition: canvas.h:110
float y0
Definition: lasso.h:30
LassoMode::type lassoMode
Definition: canvas.h:124
WirePtr wireFocus
wire that mouse is hovering over
Definition: canvas.h:107
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175

◆ mouseMove()

void minsky::Canvas::mouseMove ( float  x,
float  y 
)
overridevirtual

Reimplemented from minsky::EventInterface.

Definition at line 241 of file canvas.cc.

References pyminsky::minsky, and minsky::Minsky::reset_flag().

243  {
244  if (rotatingItem && item)
245  {
246  item->rotate(Point{x,y},rotateOrigin);
247  requestRedraw();
248  return;
249  }
250 
251  if (itemFocus)
252  {
253  switch (clickType)
254  {
255  case ClickType::onItem:
256  mouseMoveOnItem(x,y);
257  return;
258  case ClickType::inItem:
259  if (itemFocus->onMouseMotion(x,y))
260  requestRedraw();
261  return;
263  if (auto p=itemFocus->plotWidgetCast())
264  {
265  p->mouseMove(x,y);
266  requestRedraw();
267  }
268  return;
269  case ClickType::onResize:
270  lasso.x1=x;
271  lasso.y1=y;
272  requestRedraw();
273  break;
274  default:
275  break;
276  }
277  }
278  else if (fromPort.get())
279  {
280  termX=x;
281  termY=y;
282  requestRedraw();
283  }
284  else if (wireFocus)
285  {
286  wireFocus->editHandle(handleSelected,x,y);
287  requestRedraw();
288  }
290  {
291  lasso.x1=x;
292  lasso.y1=y;
293  requestRedraw();
294  }
295  else
296  {
297  auto setFlagAndRequestRedraw=[&](bool& flag, bool cond) {
298  if (flag==cond) return;
299  flag=cond;
300  requestRedraw();
301  };
302  // set mouse focus to display ports etc.
303  bool mouseFocusSet=false; // ensure only one item is focused by mouse.
304  model->recursiveDo(&Group::items, [&](Items&,Items::iterator& i)
305  {
306  (*i)->disableDelayedTooltip();
307  // with coupled integration variables, we
308  // do not want to set mousefocus, as this
309  // draws unnecessary port circles on the
310  // variable
311  if (!(*i)->visible() &&
312  dynamic_cast<Variable<VariableBase::integral>*>(i->get()))
313  (*i)->mouseFocus=false;
314  else
315  {
316  auto ct=(*i)->clickType(x,y);
317  setFlagAndRequestRedraw((*i)->mouseFocus, !mouseFocusSet && ct!=ClickType::outside);
318  if ((*i)->mouseFocus) mouseFocusSet=true;
319  setFlagAndRequestRedraw((*i)->onResizeHandles, ct==ClickType::onResize);
320  setFlagAndRequestRedraw((*i)->onBorder, ct==ClickType::onItem);
321  if (ct==ClickType::outside)
322  (*i)->onMouseLeave();
323  else if ((*i)->onMouseOver(x,y))
324  requestRedraw();
325  }
326  return false;
327  });
328  model->recursiveDo(&Group::groups, [&](Groups&,Groups::iterator& i)
329  {
330  auto ct=(*i)->clickType(x,y);
331  setFlagAndRequestRedraw((*i)->mouseFocus, !mouseFocusSet && ct!=ClickType::outside);
332  if ((*i)->mouseFocus) mouseFocusSet=true;
333  const bool onResize = ct==ClickType::onResize;
334  if (onResize!=(*i)->onResizeHandles)
335  {
336  (*i)->onResizeHandles=onResize;
337  requestRedraw();
338  }
339  return false;
340  });
341  model->recursiveDo(&Group::wires, [&](Wires&,Wires::iterator& i)
342  {
343  const bool mf=(*i)->near(x,y);
344  if (mf!=(*i)->mouseFocus)
345  {
346  (*i)->mouseFocus=mf;
347  requestRedraw();
348  }
349  return false;
350  });
351  }
352  if (minsky().reset_flag())
353  minsky().resetAt=std::chrono::system_clock::now()+std::chrono::milliseconds(1500); // postpone reset whilst mousing
354  }
355  catch (...) {/* absorb any exceptions, as they're not useful here */}
std::vector< WirePtr > Wires
Definition: wire.h:99
bool rotatingItem
set true when rotating an item
Definition: canvas.h:112
int handleSelected
selected handle for handle moves, -ve = invalid
Definition: canvas.h:108
ClickType::Type clickType
Definition: canvas.h:118
Exclude< shared_ptr< Port > > fromPort
from port when creating a new wire
Definition: canvas.h:109
LassoBox lasso
Definition: canvas.h:125
Model model
Definition: canvas.h:103
Exclude< Point > rotateOrigin
starting mouse position when rotating
Definition: canvas.h:113
bool reset_flag() const
true if reset needs to be called prior to numerical integration
Definition: minsky.h:159
std::vector< ItemPtr > Items
Definition: item.h:360
std::vector< GroupPtr > Groups
Definition: group.h:52
boost::geometry::model::d2::point_xy< float > Point
Definition: geometry.h:34
double termX
Definition: canvas.h:110
void requestRedraw()
request a redraw on the screen
Definition: canvas.h:292
Groups groups
Definition: group.h:77
ItemPtr itemFocus
item selected by clicking
Definition: canvas.h:106
float y1
Definition: lasso.h:30
float x1
Definition: lasso.h:30
double termY
terminal of wire when extending
Definition: canvas.h:110
void mouseMoveOnItem(float x, float y)
Definition: canvas.cc:195
Minsky & minsky()
global minsky object
Definition: addon.cc:545
LassoMode::type lassoMode
Definition: canvas.h:124
WirePtr wireFocus
wire that mouse is hovering over
Definition: canvas.h:107
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175
Here is the call graph for this function:

◆ mouseMoveOnItem()

void minsky::Canvas::mouseMoveOnItem ( float  x,
float  y 
)
private

Definition at line 195 of file canvas.cc.

196  {
197  updateRegion=LassoBox(itemFocus->x(),itemFocus->y(),x,y);
198  // move item relatively to avoid accidental moves on double click
200  itemFocus->moveTo(x-moveOffsX, y-moveOffsY);
201  else
202  {
203  // move the whole selection
204  auto deltaX=x-moveOffsX-itemFocus->x(), deltaY=y-moveOffsY-itemFocus->y();
205  for (auto& i: selection.items)
206  i->moveTo(i->x()+deltaX, i->y()+deltaY);
207  for (auto& i: selection.groups)
208  i->moveTo(i->x()+deltaX, i->y()+deltaY);
209  }
210  requestRedraw();
211  // check if the move has moved outside or into a group
212  if (auto g=itemFocus->group.lock())
213  if (g==model || !g->contains(itemFocus->x(),itemFocus->y()))
214  {
215  if (auto toGroup=model->minimalEnclosingGroup
216  (itemFocus->x(),itemFocus->y(),itemFocus->x(),itemFocus->y(),itemFocus.get()))
217  {
218  if (g.get()==toGroup) return;
219  // prevent moving a group inside itself
220  if (auto g=dynamic_cast<Group*>(itemFocus.get()))
221  if (g->higher(*toGroup))
222  return;
223  selection.clear(); // prevent old wires from being held onto
224  toGroup->addItem(itemFocus);
225  toGroup->splitBoundaryCrossingWires();
226  g->splitBoundaryCrossingWires();
227  }
228  else if (g!=model)
229  {
230  selection.clear(); // prevent old wires from being held onto
231  model->addItem(itemFocus);
232  model->splitBoundaryCrossingWires();
233  g->splitBoundaryCrossingWires();
234  }
235  }
236  if (auto g=itemFocus->group.lock())
237  if (g!=model)
238  g->checkAddIORegion(itemFocus);
239  }
represents rectangular region of a lasso operation
Definition: lasso.h:28
Model model
Definition: canvas.h:103
float moveOffsX
Definition: canvas.h:111
float moveOffsY
Definition: canvas.h:111
bool empty() const
Definition: group.h:100
bool contains(const ItemPtr &item) const
return if item is contained in selection
Definition: selection.cc:102
void requestRedraw()
request a redraw on the screen
Definition: canvas.h:292
Groups groups
Definition: group.h:77
ItemPtr itemFocus
item selected by clicking
Definition: canvas.h:106
Selection selection
Definition: canvas.h:105
LassoBox updateRegion
region to be updated
Definition: canvas.h:273

◆ mouseUp()

void minsky::Canvas::mouseUp ( float  x,
float  y 
)
overridevirtual

Reimplemented from minsky::EventInterface.

Definition at line 143 of file canvas.cc.

References pyminsky::minsky, and minsky::Minsky::requestReset().

144  {
145  mouseMove(x,y);
146 
148  {
149  itemFocus->onMouseUp(x,y);
150  itemFocus.reset(); // prevent spurious mousemove events being processed
151  minsky().requestReset();
152  }
153  if (fromPort.get())
154  {
155  if (auto to=closestInPort(x,y)) {
156  model->addWire(static_cast<shared_ptr<Port>&>(fromPort),to);
157 
158  // populate the destination tooltip if a Ravel
159  if (to->item().tooltip().empty() && to->item().ravelCast())
160  if (auto v=fromPort->item().variableCast())
161  to->item().tooltip(v->name());
162 
163  minsky().requestReset();
164  }
165  fromPort.reset();
166  }
167 
168  if (wireFocus)
169  wireFocus->editHandle(handleSelected,x,y);
170 
171  switch (lassoMode)
172  {
173  case LassoMode::lasso:
174  select({lasso.x0,lasso.y0,x,y});
175  requestRedraw();
176  break;
178  if (item)
179  {
180  item->resize(lasso);
181  requestRedraw();
182  }
183  break;
184  default: break;
185  }
187 
188 
189  itemIndicator.reset();
190  rotatingItem=false;
191  itemFocus.reset();
192  wireFocus.reset();
193  }
void requestReset()
Definition: minsky.cc:466
void mouseMove(float x, float y) override
Definition: canvas.cc:241
bool rotatingItem
set true when rotating an item
Definition: canvas.h:112
int handleSelected
selected handle for handle moves, -ve = invalid
Definition: canvas.h:108
void select(const LassoBox &)
select all items in a given region
Definition: canvas.cc:379
ClickType::Type clickType
Definition: canvas.h:118
Exclude< shared_ptr< Port > > fromPort
from port when creating a new wire
Definition: canvas.h:109
LassoBox lasso
Definition: canvas.h:125
Model model
Definition: canvas.h:103
ItemPtr itemIndicator
for drawing error indicator on the canvas
Definition: canvas.h:120
std::shared_ptr< Port > closestInPort(float x, float y) const
return closest visible port to (x,y). nullptr is nothing suitable
Definition: canvas.cc:120
void requestRedraw()
request a redraw on the screen
Definition: canvas.h:292
float x0
Definition: lasso.h:30
ItemPtr itemFocus
item selected by clicking
Definition: canvas.h:106
float y0
Definition: lasso.h:30
Minsky & minsky()
global minsky object
Definition: addon.cc:545
LassoMode::type lassoMode
Definition: canvas.h:124
WirePtr wireFocus
wire that mouse is hovering over
Definition: canvas.h:107
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175
Here is the call graph for this function:

◆ moveTo()

void minsky::Canvas::moveTo ( float  x,
float  y 
)
inlineoverridevirtual

move this so that (x,y) is centred

Reimplemented from minsky::EventInterface.

Definition at line 129 of file canvas.h.

129  {
130  model->moveTo(x,y);
131  requestRedraw();
132  }
Model model
Definition: canvas.h:103
void requestRedraw()
request a redraw on the screen
Definition: canvas.h:292

◆ openGroupInCanvas()

void minsky::Canvas::openGroupInCanvas ( const ItemPtr item)

reinitialises canvas to the group located in item

Definition at line 694 of file canvas.cc.

References minsky::Minsky::bookmarkRefresh(), pyminsky::minsky, and minsky::wire.

695  {
696  if (auto g=dynamic_pointer_cast<Group>(item))
697  {
698  if (auto parent=model->group.lock())
699  model->setZoom(parent->zoomFactor());
700  model=g;
701  zoomToFit();
702 
704  this->item.reset();
705  itemFocus.reset();
706  wire.reset();
707  selection.clear();
708  fromPort.reset();
709  requestRedraw();
710  }
711  }
WirePtr wire
item or wire obtained by get*At() calls
Definition: canvas.h:176
Exclude< shared_ptr< Port > > fromPort
from port when creating a new wire
Definition: canvas.h:109
Model model
Definition: canvas.h:103
void zoomToFit()
zooms canvas to fit available window
Definition: canvas.cc:656
virtual void bookmarkRefresh()
refresh the bookmark menu after changes
Definition: minsky.h:436
void requestRedraw()
request a redraw on the screen
Definition: canvas.h:292
ItemPtr itemFocus
item selected by clicking
Definition: canvas.h:106
Selection selection
Definition: canvas.h:105
Minsky & minsky()
global minsky object
Definition: addon.cc:545
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175
Here is the call graph for this function:

◆ position()

std::vector<float> minsky::Canvas::position ( ) const
inlineoverridevirtual

current centre coordinates

Reimplemented from minsky::EventInterface.

Definition at line 134 of file canvas.h.

134  {
135  return {model->x(), model->y()};
136  }
Model model
Definition: canvas.h:103

◆ ravelsSelected()

int minsky::Canvas::ravelsSelected ( ) const

number of ravels in selection

Definition at line 399 of file canvas.cc.

400  {
401  int ravelsSelected = 0;
402  for (auto& i: selection.items) {
403  if (dynamic_pointer_cast<Ravel>(i))
404  {
405  ravelsSelected++;
406  }
407  }
408  return ravelsSelected;
409  }
int ravelsSelected() const
number of ravels in selection
Definition: canvas.cc:399
Selection selection
Definition: canvas.h:105

◆ recentre()

void minsky::Canvas::recentre ( )

adjust canvas so that -ve coordinates appear on canvas

Definition at line 929 of file canvas.cc.

930  {
931  const SurfacePtr tmp(surface());
932  surface().reset(new Surface(cairo_recording_surface_create(CAIRO_CONTENT_COLOR,nullptr)));
933  redraw();
934  model->moveTo(model->x()-surface()->left(), model->y()-surface()->top());
935  surface()=tmp;
936  requestRedraw();
937  }
Model model
Definition: canvas.h:103
ecolab::cairo::SurfacePtr & surface()
Definition: canvas.h:148
void requestRedraw()
request a redraw on the screen
Definition: canvas.h:292
bool redraw()
draw a red circle around item
Definition: canvas.cc:823

◆ redraw() [1/2]

bool minsky::Canvas::redraw ( int  x0,
int  y0,
int  width,
int  height 
)
overrideprivate

Definition at line 797 of file canvas.cc.

798  {
799  updateRegion.x0=x0;
800  updateRegion.y0=y0;
801  updateRegion.x1=x0+width;
802  updateRegion.y1=y0+height;
803  // redraw of canvas may throw if called during a reset operation
804  try
805  {
806  return redrawUpdateRegion();
807  }
808 #ifndef NDEBUG
809  catch (std::exception& ex)
810  {
811  cerr << ex.what() << endl;
812  }
813 #endif
814  catch (...)
815  {
816  // consume exception and try redrawing
817  // this leads to an endless loop...
818  //requestRedraw();
819  }
820  return false;
821  }
bool redrawUpdateRegion()
update region given by updateRegion
Definition: canvas.cc:829
float x0
Definition: lasso.h:30
float y1
Definition: lasso.h:30
float x1
Definition: lasso.h:30
float y0
Definition: lasso.h:30
LassoBox updateRegion
region to be updated
Definition: canvas.h:273

◆ redraw() [2/2]

bool minsky::Canvas::redraw ( )

draw a red circle around item

redraw whole model

Definition at line 823 of file canvas.cc.

824  {
825  // nb using maxint here doesn't seem to work
826  return redraw(-1e9,-1e9,2e9,2e9);
827  }
bool redraw()
draw a red circle around item
Definition: canvas.cc:823

◆ redrawRequested()

bool minsky::Canvas::redrawRequested ( ) const
inline

flag indicating that a redraw is requested, but not yet redrawn

Definition at line 290 of file canvas.h.

290 {return m_redrawRequested;}
bool m_redrawRequested
flag indicating that a redraw is requested, but not yet redrawn
Definition: canvas.h:62

◆ redrawUpdateRegion()

bool minsky::Canvas::redrawUpdateRegion ( )

update region given by updateRegion

Definition at line 829 of file canvas.cc.

References M_PI.

830  {
831  bool didDrawSomething = false;
832  if (!surface().get()) {
833  return didDrawSomething;
834  }
835  m_redrawRequested=false;
836  auto cairo=surface()->cairo();
837  const CairoSave cs(cairo);
839  cairo_clip(cairo);
840  cairo_set_line_width(cairo, 1);
841  // items
842  model->recursiveDo
843  (&GroupItems::items, [&](const Items&, Items::const_iterator i)
844  {
845  auto& it=**i;
846  if (it.visible() && updateRegion.intersects(it))
847  {
848  didDrawSomething = true;
849  const CairoSave cs(cairo);
850  cairo_identity_matrix(cairo);
851  cairo_translate(cairo,it.x(), it.y());
852  try
853  {
854  it.draw(cairo);
855  }
856  catch (const std::exception& ex)
857  {
858  cerr << ex.what() << endl;
859  }
860  }
861  return false;
862  });
863 
864  // groups
865  model->recursiveDo
866  (&GroupItems::groups, [&](const Groups&, Groups::const_iterator i)
867  {
868  auto& it=**i;
869  if (it.visible() && updateRegion.intersects(it))
870  {
871  didDrawSomething = true;
872  const CairoSave cs(cairo);
873  cairo_identity_matrix(cairo);
874  cairo_translate(cairo,it.x(), it.y());
875  it.draw(cairo);
876  }
877  return false;
878  });
879 
880  // draw all wires - wires will go over the top of any icons. TODO
881  // introduce an ordering concept if needed
882  model->recursiveDo
883  (&GroupItems::wires, [&](const Wires&, Wires::const_iterator i)
884  {
885  const Wire& w=**i;
886  if (w.visible()) {
887  w.draw(cairo);
888  }
889  return false;
890  });
891 
892  if (fromPort.get()) // we're in process of creating a wire
893  {
894  didDrawSomething = true;
895  cairo_move_to(cairo,fromPort->x(),fromPort->y());
896  cairo_line_to(cairo,termX,termY);
897  cairo_stroke(cairo);
898  // draw arrow
899  const CairoSave cs(cairo);
900  cairo_translate(cairo, termX,termY);
901  cairo_rotate(cairo,atan2(termY-fromPort->y(), termX-fromPort->x()));
902  cairo_move_to(cairo,0,0);
903  cairo_line_to(cairo,-5,-3);
904  cairo_line_to(cairo,-3,0);
905  cairo_line_to(cairo,-5,3);
906  cairo_close_path(cairo);
907  cairo_fill(cairo);
908  }
909 
911  {
912  didDrawSomething = true;
913  cairo_rectangle(cairo,lasso.x0,lasso.y0,lasso.x1-lasso.x0,lasso.y1-lasso.y0);
914  cairo_stroke(cairo);
915  }
916 
917  if (itemIndicator) // draw a red circle to indicate an error or other marker
918  {
919  const CairoSave cs(surface()->cairo());
920  cairo_set_source_rgb(surface()->cairo(),1,0,0);
921  cairo_arc(surface()->cairo(),itemIndicator->x(),itemIndicator->y(),15,0,2*M_PI);
922  cairo_stroke(surface()->cairo());
923  }
924 
925  surface()->blit();
926  return didDrawSomething;
927  }
#define M_PI
some useful geometry types, defined from boost::geometry
Definition: geometry.h:29
std::vector< WirePtr > Wires
Definition: wire.h:99
bool intersects(const Item &item) const
returns whether item&#39;s icon overlaps the lasso
Definition: lasso.h:36
Exclude< shared_ptr< Port > > fromPort
from port when creating a new wire
Definition: canvas.h:109
LassoBox lasso
Definition: canvas.h:125
Model model
Definition: canvas.h:103
ItemPtr itemIndicator
for drawing error indicator on the canvas
Definition: canvas.h:120
std::vector< ItemPtr > Items
Definition: item.h:360
ecolab::cairo::SurfacePtr & surface()
Definition: canvas.h:148
std::vector< GroupPtr > Groups
Definition: group.h:52
double termX
Definition: canvas.h:110
Groups groups
Definition: group.h:77
float x0
Definition: lasso.h:30
bool m_redrawRequested
flag indicating that a redraw is requested, but not yet redrawn
Definition: canvas.h:62
float y1
Definition: lasso.h:30
float x1
Definition: lasso.h:30
double termY
terminal of wire when extending
Definition: canvas.h:110
float y0
Definition: lasso.h:30
LassoBox updateRegion
region to be updated
Definition: canvas.h:273
LassoMode::type lassoMode
Definition: canvas.h:124

◆ removeItemFromItsGroup()

void minsky::Canvas::removeItemFromItsGroup ( )

remove item from its group, leaving in itemFocus for later placement

Definition at line 519 of file canvas.cc.

520  {
521  if (item)
522  if (auto g=item->group.lock())
523  {
524  if (auto parent=g->group.lock())
525  {
526  itemFocus=parent->addItem(item);
527  if (auto v=itemFocus->variableCast())
528  v->controller.reset();
529  g->splitBoundaryCrossingWires();
530  }
531  // else item already at toplevel
532  }
533  }
ItemPtr itemFocus
item selected by clicking
Definition: canvas.h:106
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175

◆ renameAllInstances()

void minsky::Canvas::renameAllInstances ( const std::string &  newName)

rename all instances of variable as item to newName

Definition at line 557 of file canvas.cc.

References minsky::valueId(), and minsky::var.

Referenced by copyItem(), and minsky::GodleyTableEditor::update().

558  {
559  auto var=item->variableCast();
560  if (!var)
561  if (auto i=dynamic_cast<IntOp*>(item.get()))
562  var=i->intVar.get();
563  if (var)
564  {
565  // cache name and valueId for later use as var gets invalidated in the recursiveDo
566  auto valueId=var->valueId();
567  model->renameAllInstances(valueId, newName);
568  }
569  }
string valueId(const string &name)
construct a valueId from fully qualified name @ name should not be canonicalised
Definition: valueId.cc:75
Model model
Definition: canvas.h:103
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175
Here is the call graph for this function:
Here is the caller graph for this function:

◆ renameItem()

void minsky::Canvas::renameItem ( const std::string &  newName)

rename variable as item to newName

Definition at line 605 of file canvas.cc.

References minsky::cminsky(), minsky::Minsky::definingVar(), and minsky::var.

606  {
607  if (!item) return;
608  if (auto var=item->variableCast())
609  {
610  var->name(newName);
611  // check stock variables are defined, convert to flow if not
612  if (var->isStock() && !cminsky().definingVar(var->valueId()))
613  var->retype(VariableType::flow);
614  }
615  }
VariablePtr definingVar(const std::string &valueId) const
returns reference to variable defining (ie input wired) for valueId
Definition: minsky.cc:204
const Minsky & cminsky()
const version to help in const correctness
Definition: minsky.h:538
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175
Here is the call graph for this function:

◆ renderToPNGCropped()

void minsky::Canvas::renderToPNGCropped ( const std::string &  filename,
const ZoomCrop z 
)

Render to a PNG file filename, scaling the canvas temporarily by zoom, shifts it to left, top, and crops to width, height.

Definition at line 945 of file canvas.cc.

References minsky::Canvas::ZoomCrop::height, minsky::Canvas::ZoomCrop::left, minsky::Canvas::ZoomCrop::top, minsky::Canvas::ZoomCrop::width, and minsky::Canvas::ZoomCrop::zoom.

946  {
947  model->zoom(model->x(),model->y(),z.zoom);
948  model->moveTo(model->x()-z.left,model->y()-z.top);
949  cairo::SurfacePtr tmp(new cairo::Surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32,z.width,z.height)));
950  tmp.swap(surface());
951  redraw(0,0,z.width,z.height);
952  tmp.swap(surface());
953  cairo_surface_write_to_png(tmp->surface(),filename.c_str());
954  model->moveTo(model->x()+z.left,model->y()+z.top);
955  model->zoom(model->x(),model->y(),1/z.zoom);
956  }
Model model
Definition: canvas.h:103
void zoom(double x, double y, double z)
Definition: canvas.h:96
ecolab::cairo::SurfacePtr & surface()
Definition: canvas.h:148
bool redraw()
draw a red circle around item
Definition: canvas.cc:823

◆ reportDrawTime()

void minsky::Canvas::reportDrawTime ( double  t)
overrideprivate

Definition at line 939 of file canvas.cc.

References minsky::Minsky::maxWaitMS, and pyminsky::minsky.

940  {
941  // ensure screen refresh time is less than a third
942  minsky().maxWaitMS=(t>0.03)? 3000*t: 100.0;
943  }
Minsky & minsky()
global minsky object
Definition: addon.cc:545
int maxWaitMS
maximum wait in millisecond between redrawing canvas during simulation
Definition: minsky.h:340

◆ requestRedraw()

void minsky::Canvas::requestRedraw ( )
inline

request a redraw on the screen

Definition at line 292 of file canvas.h.

Referenced by minsky::Group::gotoBookmark_b(), and minsky::GodleyTableEditor::update().

292 {m_redrawRequested=true; if (surface().get()) surface()->requestRedraw();}
ecolab::cairo::SurfacePtr & surface()
Definition: canvas.h:148
bool m_redrawRequested
flag indicating that a redraw is requested, but not yet redrawn
Definition: canvas.h:62
Here is the caller graph for this function:

◆ rotateItem()

void minsky::Canvas::rotateItem ( float  x,
float  y 
)
inline

Definition at line 114 of file canvas.h.

114  {
115  rotateOrigin=Point(x,y);
116  rotatingItem=true;
117  }
bool rotatingItem
set true when rotating an item
Definition: canvas.h:112
Exclude< Point > rotateOrigin
starting mouse position when rotating
Definition: canvas.h:113
boost::geometry::model::d2::point_xy< float > Point
Definition: geometry.h:34

◆ select()

void minsky::Canvas::select ( const LassoBox lasso)

select all items in a given region

Definition at line 379 of file canvas.cc.

References minsky::Minsky::copy(), minsky::LassoBox::intersects(), pyminsky::minsky, minsky::LassoBox::x0, minsky::LassoBox::x1, minsky::LassoBox::y0, and minsky::LassoBox::y1.

380  {
381  selection.clear();
382 
383  auto topLevel = model->minimalEnclosingGroup(lasso.x0,lasso.y0,lasso.x1,lasso.y1);
384 
385  if (!topLevel) topLevel=&*model;
386 
387  for (auto& i: topLevel->items)
388  if (i->visible() && lasso.intersects(*i))
390 
391  for (auto& i: topLevel->groups)
392  if (i->visible() && lasso.intersects(*i))
394 
395  // X11 behaviour, selecting automatically copies.
396  minsky().copy();
397  }
void copy() const
copy items in current selection into clipboard
Definition: minsky.cc:190
bool intersects(const Item &item) const
returns whether item&#39;s icon overlaps the lasso
Definition: lasso.h:36
LassoBox lasso
Definition: canvas.h:125
Model model
Definition: canvas.h:103
void ensureGroupInserted(const GroupPtr &item)
check if group already present, and if not, inserts it
Definition: selection.cc:73
void ensureItemInserted(const ItemPtr &item)
check if item already present, and if not, inserts item delegates to ensureGroupInserted if passed a ...
Definition: selection.cc:60
float x0
Definition: lasso.h:30
Selection selection
Definition: canvas.h:105
float y1
Definition: lasso.h:30
float x1
Definition: lasso.h:30
float y0
Definition: lasso.h:30
Minsky & minsky()
global minsky object
Definition: addon.cc:545
Here is the call graph for this function:

◆ selectAllVariables()

void minsky::Canvas::selectAllVariables ( )

select all variables referring to same variableValue as item

Definition at line 535 of file canvas.cc.

References minsky::var.

536  {
537  selection.clear();
538  auto var=item->variableCast();
539  if (!var)
540  if (auto i=dynamic_cast<IntOp*>(item.get()))
541  var=i->intVar.get();
542  if (var)
543  {
544  model->recursiveDo
545  (&GroupItems::items, [&](const Items&,Items::const_iterator i)
546  {
547  if (auto v=(*i)->variableCast())
548  if (v->valueId()==var->valueId())
549  {
551  }
552  return false;
553  });
554  }
555  }
Model model
Definition: canvas.h:103
std::vector< ItemPtr > Items
Definition: item.h:360
void ensureItemInserted(const ItemPtr &item)
check if item already present, and if not, inserts item delegates to ensureGroupInserted if passed a ...
Definition: selection.cc:60
Selection selection
Definition: canvas.h:105
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175

◆ selectVar()

bool minsky::Canvas::selectVar ( float  x,
float  y 
)

populates item with a variable if (x,y) is over a variable part

Returns
true if item is updated

Definition at line 757 of file canvas.cc.

758  {
759  if (item)
760  {
761  if (auto v=item->select(x,y))
762  {
763  item=v;
764  return true;
765  }
766  }
767  return false;
768  }
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175

◆ setDefaultPlotOptions()

void minsky::Canvas::setDefaultPlotOptions ( )
inline

item or wire obtained by get*At() calls

Definition at line 295 of file canvas.h.

295  {
296  if (auto p=item->plotWidgetCast())
298  }
PlotOptions defaultPlotOptions
options to apply to a new plot widget
Definition: canvas.h:65
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175

◆ setItemFocus()

void minsky::Canvas::setItemFocus ( const ItemPtr x)
inline

sets itemFocus, and resets mouse offset for placement

Definition at line 167 of file canvas.h.

References minsky::ClickType::onItem.

167  {
168  itemFocus=x;
171  }
ClickType::Type clickType
Definition: canvas.h:118
float moveOffsX
Definition: canvas.h:111
float moveOffsY
Definition: canvas.h:111
ItemPtr itemFocus
item selected by clicking
Definition: canvas.h:106

◆ setItemFromItemFocus()

void minsky::Canvas::setItemFromItemFocus ( )

item or wire obtained by get*At() calls

Definition at line 971 of file canvas.cc.

972  {
973  item = itemFocus;
974  }
ItemPtr itemFocus
item selected by clicking
Definition: canvas.h:106
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175

◆ surface()

ecolab::cairo::SurfacePtr& minsky::Canvas::surface ( )
inline

Definition at line 148 of file canvas.h.

148 {return ecolab::CairoSurface::surface;}

◆ ungroupItem()

void minsky::Canvas::ungroupItem ( )

if item is a Group, move its contents to its parent and delete the group

Definition at line 571 of file canvas.cc.

572  {
573  if (auto g=dynamic_cast<Group*>(item.get()))
574  {
575  if (auto p=g->group.lock())
576  {
577  if (!g->empty()) // minskly crashes if group empty and ungrouped subsequently. for ticket 1243
578  {
579  // stash values of parameters in copied group, as they are reset for some unknown reason later on. for tickets 1243/1258
580  map<string,string> existingParms;
581  for (auto& i: g->items) {
582  auto v=i->variableCast();
583  if (v && v->type()==VariableType::parameter)
584  existingParms.emplace(v->valueId(),v->init());
585  }
586 
587  // blow up containe items so they appear in same relative locationsat parent scalefactor
588  auto scaleFactor=1/g->relZoom;
589  for (auto& i: g->items)
590  i->moveTo((i->x()-g->x())*scaleFactor+g->x(), (i->y()-g->y())*scaleFactor+g->y());
591  for (auto& i: g->groups)
592  i->moveTo((i->x()-g->x())*scaleFactor+g->x(), (i->y()-g->y())*scaleFactor+g->y());
593  p->moveContents(*g);
594  deleteItem();
595 
596  existingParms.clear();
597 
598  } else deleteItem();
599  }
600 
601  // else item is toplevel which can't be ungrouped
602  }
603  }
void deleteItem()
delete item referenced by item
Definition: canvas.cc:487
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175

◆ unlockRavelsInSelection()

void minsky::Canvas::unlockRavelsInSelection ( )

item or wire obtained by get*At() calls

Definition at line 480 of file canvas.cc.

481  {
482  for (auto& i: selection.items)
483  if (auto r=dynamic_cast<Ravel*>(i.get()))
484  r->leaveLockGroup();
485  }
Selection selection
Definition: canvas.h:105

◆ zoom()

void minsky::Canvas::zoom ( double  x,
double  y,
double  z 
)
inlineoverridevirtual

Reimplemented from minsky::EventInterface.

Definition at line 138 of file canvas.h.

References minsky::Canvas::Model::zoom().

138  {
139  model->zoom(x,y,z);
140  requestRedraw();
141  }
Model model
Definition: canvas.h:103
void zoom(double x, double y, double z)
Definition: canvas.h:96
void requestRedraw()
request a redraw on the screen
Definition: canvas.h:292
Here is the call graph for this function:

◆ zoomFactor()

double minsky::Canvas::zoomFactor ( ) const
inlineoverridevirtual

Reimplemented from minsky::EventInterface.

Definition at line 143 of file canvas.h.

143 {return model->zoomFactor();}
Model model
Definition: canvas.h:103

◆ zoomToDisplay()

void minsky::Canvas::zoomToDisplay ( )

zooms canvas such that group indexed by item is displayed

Definition at line 748 of file canvas.cc.

References pyminsky::minsky, and minsky::Minsky::resetScroll().

749  {
750  if (auto g=dynamic_cast<Group*>(item.get()))
751  {
752  model->zoom(g->x(),g->y(),1.1/(g->relZoom*g->zoomFactor()));
753  minsky().resetScroll();
754  }
755  }
Model model
Definition: canvas.h:103
void zoom(double x, double y, double z)
Definition: canvas.h:96
virtual void resetScroll()
reset main window scroll bars after model has been panned
Definition: minsky.h:439
Minsky & minsky()
global minsky object
Definition: addon.cc:545
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175
Here is the call graph for this function:

◆ zoomToFit()

void minsky::Canvas::zoomToFit ( )

zooms canvas to fit available window

Definition at line 656 of file canvas.cc.

References minsky::flipped().

657  {
658  if (frameArgs().parentWindowId.empty()) return; // no window to fit to, so do nothing
659  // recompute all bounding boxes - why is this needed?
660  for (auto& i: model->items) i->updateBoundingBox();
661 
662  double x0,x1,y0,y1;
663  model->contentBounds(x0,y0,x1,y1);
664  float inOffset=0, outOffset=0;
665  const bool notFlipped=!flipped(model->rotation());
666  const float flip=notFlipped? 1: -1;
667 
668  // we need to move the io variables
669  for (auto& v: model->inVariables)
670  inOffset=std::max(inOffset, v->width());
671  for (auto& v: model->outVariables)
672  outOffset=std::max(outOffset, v->width());
673 
674  const float zoomFactor=std::min(frameArgs().childWidth/(x1-x0+inOffset+outOffset),
675  frameArgs().childHeight/(y1-y0));
676 
677  model->zoom(model->x(),model->y(),zoomFactor);
678 
679 
680  model->contentBounds(x0,y0,x1,y1);
681  float ioOffset=notFlipped? x0: x1;
682 
683  // we need to move the io variables
684  for (auto& v: model->inVariables)
685  v->moveTo(ioOffset-flip*v->width(),v->y());
686  ioOffset=notFlipped? x1: x0;
687  for (auto& v: model->outVariables)
688  v->moveTo(ioOffset+flip*v->width(),v->y());
689 
690  recentre();
691  requestRedraw();
692  }
const RenderFrameArgs & frameArgs() const
void recentre()
adjust canvas so that -ve coordinates appear on canvas
Definition: canvas.cc:929
Model model
Definition: canvas.h:103
bool flipped(double rotation)
returns if the angle (in degrees) is in the second or third quadrant
Definition: geometry.h:102
void zoom(double x, double y, double z)
Definition: canvas.h:96
void requestRedraw()
request a redraw on the screen
Definition: canvas.h:292
double zoomFactor() const override
Definition: canvas.h:143
Here is the call graph for this function:

Member Data Documentation

◆ clickType

ClickType::Type minsky::Canvas::clickType

Definition at line 118 of file canvas.h.

◆ defaultPlotOptions

PlotOptions minsky::Canvas::defaultPlotOptions
private

options to apply to a new plot widget

Definition at line 65 of file canvas.h.

◆ defaultRotation

double minsky::Canvas::defaultRotation =0

item or wire obtained by get*At() calls

Definition at line 181 of file canvas.h.

◆ fromPort

Exclude<shared_ptr<Port> > minsky::Canvas::fromPort

from port when creating a new wire

Definition at line 109 of file canvas.h.

◆ handleSelected

int minsky::Canvas::handleSelected

selected handle for handle moves, -ve = invalid

Definition at line 108 of file canvas.h.

◆ item

ItemPtr minsky::Canvas::item

item or wire obtained by get*At() calls

Definition at line 175 of file canvas.h.

Referenced by minsky::GodleyTableEditor::update().

◆ itemFocus

ItemPtr minsky::Canvas::itemFocus

item selected by clicking

Definition at line 106 of file canvas.h.

◆ itemIndicator

ItemPtr minsky::Canvas::itemIndicator

for drawing error indicator on the canvas

Definition at line 120 of file canvas.h.

Referenced by minsky::Minsky::displayErrorItem(), and MathDAG::SystemOfEquations::SystemOfEquations().

◆ lasso

LassoBox minsky::Canvas::lasso {0,0,0,0}

Definition at line 125 of file canvas.h.

◆ lassoMode

LassoMode::type minsky::Canvas::lassoMode =LassoMode::none

Definition at line 124 of file canvas.h.

◆ m_redrawRequested

bool minsky::Canvas::m_redrawRequested =false
private

flag indicating that a redraw is requested, but not yet redrawn

Definition at line 62 of file canvas.h.

◆ model

Model minsky::Canvas::model

Definition at line 103 of file canvas.h.

Referenced by minsky::VariableBase::local(), and schema3::Minsky::populateMinsky().

◆ moveOffsX

float minsky::Canvas::moveOffsX

Definition at line 111 of file canvas.h.

◆ moveOffsY

float minsky::Canvas::moveOffsY

Definition at line 111 of file canvas.h.

◆ redrawAll

bool minsky::Canvas::redrawAll =true

if false, then only redraw graphs

Definition at line 127 of file canvas.h.

◆ rotateOrigin

Exclude<Point> minsky::Canvas::rotateOrigin

starting mouse position when rotating

Definition at line 113 of file canvas.h.

◆ rotatingItem

bool minsky::Canvas::rotatingItem =false

set true when rotating an item

Definition at line 112 of file canvas.h.

◆ selection

Selection minsky::Canvas::selection

Definition at line 105 of file canvas.h.

Referenced by minsky::VariableInstanceList::gotoInstance().

◆ termX

double minsky::Canvas::termX

Definition at line 110 of file canvas.h.

◆ termY

double minsky::Canvas::termY

terminal of wire when extending

Definition at line 110 of file canvas.h.

◆ updateRegion

LassoBox minsky::Canvas::updateRegion {0,0,0,0}

region to be updated

Definition at line 273 of file canvas.h.

◆ wire

WirePtr minsky::Canvas::wire

item or wire obtained by get*At() calls

Definition at line 176 of file canvas.h.

◆ wireFocus

WirePtr minsky::Canvas::wireFocus

wire that mouse is hovering over

Definition at line 107 of file canvas.h.


The documentation for this class was generated from the following files: