Minsky
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 ()
 
void macOSXRedraw ()
 
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.

Referenced by minsky::MinskyTCL::addGodley().

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
Here is the caller graph for this function:

◆ addGroup()

void minsky::Canvas::addGroup ( )
inline

item or wire obtained by get*At() calls

Definition at line 201 of file canvas.h.

Referenced by minsky::MinskyTCL::addGroup().

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
Here is the caller graph for this function:

◆ addLock()

void minsky::Canvas::addLock ( )
inline

item or wire obtained by get*At() calls

Definition at line 204 of file canvas.h.

Referenced by minsky::MinskyTCL::addLock().

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
Here is the caller graph for this function:

◆ 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.

Referenced by minsky::MinskyTCL::addNote().

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
Here is the caller graph for this function:

◆ 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.

Referenced by minsky::MinskyTCL::addOperation().

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:
Here is the caller 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().

Referenced by minsky::MinskyTCL::addPlot().

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:
Here is the caller 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.

Referenced by minsky::MinskyTCL::addRavel().

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
Here is the caller graph for this function:

◆ addSheet()

void minsky::Canvas::addSheet ( )
inline

item or wire obtained by get*At() calls

Definition at line 205 of file canvas.h.

Referenced by minsky::MinskyTCL::addSheet().

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
Here is the caller graph for this function:

◆ addSwitch()

void minsky::Canvas::addSwitch ( )
inline

item or wire obtained by get*At() calls

Definition at line 202 of file canvas.h.

Referenced by minsky::MinskyTCL::addSwitch().

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
Here is the caller graph for this function:

◆ 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::MinskyTCL::addVariable(), and 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 958 of file canvas.cc.

958  {
959  if (auto p=item->plotWidgetCast()) {
960  // stash titles to restore later
961  const string title(p->title), xlabel(p->xlabel()),
962  ylabel(p->ylabel()), y1label(p->y1label());
964  p->title=title, p->xlabel(xlabel),
965  p->ylabel(ylabel), p->y1label(y1label);
966  }
967  }
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 118 of file canvas.cc.

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

119  {
120  shared_ptr<Port> closestPort;
121  auto minD=numeric_limits<float>::max();
122  model->recursiveDo(&GroupItems::items,
123  [&](const Items&, Items::const_iterator i)
124  {
125  if ((*i)->group.lock()->displayContents())
126  for (size_t pi=0; pi<(*i)->portsSize(); ++pi)
127  {
128  auto p=(*i)->ports(pi).lock();
129  const float d=sqr(p->x()-x)+sqr(p->y()-y);
130  if (d<minD)
131  {
132  minD=d;
133  closestPort=p;
134  }
135  }
136  return false;
137  });
138  return closestPort;
139  }
Model model
Definition: canvas.h:103
std::vector< ItemPtr > Items
Definition: item.h:366
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 40 of file canvas.cc.

41  {
42  mouseDownCommon(x,y);
43  if (itemFocus && itemFocus->group.lock() == model)
45  }
Model model
Definition: canvas.h:103
void mouseDownCommon(float x, float y)
Definition: canvas.cc:55
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:711
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:711
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 615 of file canvas.cc.

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

616  {
617  if (item)
618  {
619  ItemPtr newItem;
620  // cannot duplicate an integral, just its variable
621  if (auto intop=dynamic_cast<IntOp*>(item.get()))
622  newItem.reset(intop->intVar->clone());
623  else if (auto group=dynamic_cast<Group*>(item.get()))
624  newItem=group->copy();
625  else
626  {
627  if (item->ioVar())
628  if (auto v=item->variableCast())
629  if (v->rawName()[0]!=':')
630  try
631  {
632  minsky().pushHistory(); // save current state in case of failure
633  // attempt to make variable outer scoped. For #1100
634  minsky().canvas.renameAllInstances(":"+v->rawName());
635  }
636  catch (...)
637  {
638  minsky().undo(); // back out of change
639  throw;
640  }
641 
642  newItem.reset(item->clone());
643  // if copied from a Godley table or I/O var, set orientation to default
644  if (auto v=item->variableCast())
645  if (v->controller.lock())
646  newItem->rotation(defaultRotation);
647 
648  }
649  setItemFocus(model->addItem(newItem));
650  model->normaliseGroupRefs(model);
651  }
652  }
bool pushHistory()
push current model state onto history if it differs from previous
Definition: minsky.cc:1265
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:57
Model model
Definition: canvas.h:103
void renameAllInstances(const std::string &newName)
rename all instances of variable as item to newName
Definition: canvas.cc:555
long undo(int changes=1)
restore model to state changes ago
Definition: minsky.cc:1401
Canvas canvas
Definition: minsky.h:256
Definition: group.tcl:84
Minsky & minsky()
global minsky object
Definition: minskyTCL.cc:51
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 711 of file canvas.cc.

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

712  {
713  float maxWidth=0, totalHeight=0;
714  vector<float> widths, heights;
715  // Throw error if no stock/flow vars on Godley icon. For ticket 1039
716  if (!v.empty()) {
717  selection.clear();
718  for (auto& i: v)
719  {
720  const RenderVariable rv(*i);
721  widths.push_back(rv.width());
722  heights.push_back(rv.height());
723  maxWidth=max(maxWidth, widths.back());
724  totalHeight+=heights.back();
725  }
726  float y=v[0]->y() - totalHeight;
727  for (size_t i=0; i<v.size(); ++i)
728  {
729  // Stock and flow variables on Godley icons should not be copied as groups. For ticket 1039
730  const ItemPtr ni(v[i]->clone());
731  (ni->variableCast())->rotation(0);
732  ni->moveTo(v[0]->x()+maxWidth-v[i]->zoomFactor()*widths[i],
733  y+heights[i]);
734  // variables need to refer to outer scope
735  if ((ni->variableCast())->name()[0]!=':')
736  (ni->variableCast())->name(':'+(ni->variableCast())->name());
737  y+=2*v[i]->zoomFactor()*heights[i];
738  selection.insertItem(model->addItem(ni));
739  }
740  // Item focus put on one of the copied vars that are still in selection. For ticket 1039
742  else setItemFocus(nullptr);
743  } else throw error("no flow or stock variables to copy");
744  }
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:57
Model model
Definition: canvas.h:103
bool empty() const
Definition: group.h:102
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 485 of file canvas.cc.

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

486  {
487  if (item)
488  {
489  model->deleteItem(*item);
490  minsky().requestReset();
491  }
492  }
void requestReset()
Definition: minsky.cc:467
Model model
Definition: canvas.h:103
Minsky & minsky()
global minsky object
Definition: minskyTCL.cc:51
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 494 of file canvas.cc.

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

495  {
496  if (wire)
497  {
498  model->removeWire(*wire);
499  wire.reset();
500  minsky().requestReset();
501  }
502  }
WirePtr wire
item or wire obtained by get*At() calls
Definition: canvas.h:176
void requestReset()
Definition: minsky.cc:467
Model model
Definition: canvas.h:103
Minsky & minsky()
global minsky object
Definition: minskyTCL.cc:51
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 505 of file canvas.cc.

506  {
507  wireFocus=model->findAny(&Group::wires,
508  [&](const WirePtr& i){return i->near(x,y);});
509  if (wireFocus)
510  {
511  wireFocus->deleteHandle(x,y);
512  wireFocus.reset(); // prevent accidental moves of handle
513  }
514  requestRedraw();
515  }
std::shared_ptr< Wire > WirePtr
Definition: wire.h:102
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 368 of file canvas.cc.

369  {
370  if (auto item=itemAt(x,y))
371  {
372  item->displayDelayedTooltip(x,y);
373  requestRedraw();
374  }
375  }
ItemPtr itemAt(float x, float y)
item or wire obtained by get*At() calls
Definition: canvas.cc:409
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 768 of file canvas.cc.

Referenced by minsky::MinskyTCL::findVariableDefinition().

769  {
770  if (auto iv=item->variableCast())
771  {
772  if (iv->type()==VariableType::constant ||
773  iv->type()==VariableType::parameter || iv->inputWired())
774  return (itemIndicator=item).get();
775 
776  itemIndicator=model->findAny
777  (&GroupItems::items, [&](const ItemPtr& i) {
778  if (auto v=i->variableCast())
779  return v->inputWired() && v->valueId()==iv->valueId();
780  if (auto g=dynamic_cast<GodleyIcon*>(i.get()))
781  for (auto& v: g->stockVars())
782  {
783  if (v->valueId()==iv->valueId())
784  return true;
785  }
786  else if (auto o=dynamic_cast<IntOp*>(i.get()))
787  return o->intVar->valueId()==iv->valueId();
788  return false;
789  });
790  return itemIndicator.get();
791  }
792  return false;
793  }
std::shared_ptr< Item > ItemPtr
Definition: item.h:57
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
Here is the caller graph for this function:

◆ 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.

Referenced by minsky::MinskyTCL::getItemAt().

178 {return (item=itemAt(x,y)).get();}
ItemPtr itemAt(float x, float y)
item or wire obtained by get*At() calls
Definition: canvas.cc:409
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175
Here is the caller graph for this function:

◆ 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 432 of file canvas.cc.

References minsky::wire.

Referenced by minsky::MinskyTCL::getWireAt().

433  {
434  wire=model->findAny(&Group::wires,
435  [&](const WirePtr& i){return i->near(x,y);});
436  return wire.get();
437  }
WirePtr wire
item or wire obtained by get*At() calls
Definition: canvas.h:176
std::shared_ptr< Wire > WirePtr
Definition: wire.h:102
Model model
Definition: canvas.h:103
Here is the caller graph for this function:

◆ groupSelection()

void minsky::Canvas::groupSelection ( )

create a group from items found in the current selection

Definition at line 439 of file canvas.cc.

Referenced by minsky::MinskyTCL::createGroup().

440  {
441  const GroupPtr r=model->addGroup(new Group);
442  for (auto& i: selection.items)
443  r->addItem(i);
444  for (auto& i: selection.groups)
445  r->addItem(i);
446  r->splitBoundaryCrossingWires();
447  r->resizeOnContents();
448  }
Model model
Definition: canvas.h:103
Groups groups
Definition: group.h:79
Selection selection
Definition: canvas.h:105
std::shared_ptr< Group > GroupPtr
Definition: port.h:32
Here is the caller graph for this function:

◆ 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 409 of file canvas.cc.

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

410  {
411  // Fix for library dependency problem with items during Travis build
412  ItemPtr item;
413  auto minD=numeric_limits<float>::max();
414  model->recursiveDo(&GroupItems::items,
415  [&](const Items&, Items::const_iterator i)
416  {
417  const float d=sqr((*i)->x()-x)+sqr((*i)->y()-y);
418  if (d<minD && (*i)->visible() && (*i)->contains(x,y))
419  {
420  minD=d;
421  item=*i;
422  }
423  return false;
424  });
425  if (!item)
426  item=model->findAny
427  (&Group::groups, [&](const GroupPtr& i)
428  {return i->visible() && i->clickType(x,y)!=ClickType::outside;});
429  return item;
430  }
std::shared_ptr< Item > ItemPtr
Definition: item.h:57
Model model
Definition: canvas.h:103
std::vector< ItemPtr > Items
Definition: item.h:366
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:79
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 355 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.

356  {
357  if (auto item=itemAt(args.x,args.y))
358  if (item->onKeyPress(args.keySym, args.utf8, args.state))
359  {
360  minsky().markEdited(); // keyPresses don't set the dirty flag by default
361  requestRedraw();
362  return true;
363  }
364  return false;
365  }
ItemPtr itemAt(float x, float y)
item or wire obtained by get*At() calls
Definition: canvas.cc:409
void markEdited()
indicate model has been changed since last saved
Definition: minsky.h:173
void requestRedraw()
request a redraw on the screen
Definition: canvas.h:292
Minsky & minsky()
global minsky object
Definition: minskyTCL.cc:51
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 450 of file canvas.cc.

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

48  {
49  mouseDownCommon(x,y);
51  selection.clear(); // clicking outside a selection clears it
52  }
void mouseDownCommon(float x, float y)
Definition: canvas.cc:55
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 55 of file canvas.cc.

56  {
57  wireFocus.reset();
58  // firstly, see if the user is selecting an item
59  if ((itemFocus=itemAt(x,y)))
60  {
61  clickType=itemFocus->clickType(x,y);
62  switch (clickType)
63  {
64  case ClickType::onPort:
65  // items all have their output port first, if they have an output port at all.
66  if ((fromPort=itemFocus->closestOutPort(x,y)))
67  {
68  termX=x;
69  termY=y;
70  itemFocus.reset();
71  }
72  break;
73  case ClickType::onItem:
74  moveOffsX=x-itemFocus->x();
75  moveOffsY=y-itemFocus->y();
76  break;
77  case ClickType::outside:
78  itemFocus.reset();
81  break;
82  case ClickType::inItem:
83  itemFocus->onMouseDown(x,y);
84  break;
87  // set x0,y0 to the opposite corner of (x,y)
88  lasso.x0 = x>itemFocus->x()? itemFocus->left(): itemFocus->right();
89  lasso.y0 = y>itemFocus->y()? itemFocus->top(): itemFocus->bottom();
90  lasso.x1=x;
91  lasso.y1=y;
93  break;
95  if (auto p=itemFocus->plotWidgetCast())
96  p->mouseDown(x,y);
97  break;
98  }
99  }
100  else
101  {
102  wireFocus=model->findAny(&Group::wires,
103  [&](const WirePtr& i){return i->near(x,y);});
104  if (wireFocus)
105  handleSelected=wireFocus->nearestHandle(x,y);
106  else
109  }
110 
112  {
113  lasso.x0=x;
114  lasso.y0=y;
115  }
116  }
ItemPtr itemAt(float x, float y)
item or wire obtained by get*At() calls
Definition: canvas.cc:409
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:102
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 239 of file canvas.cc.

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

241  {
242  if (rotatingItem && item)
243  {
244  item->rotate(Point{x,y},rotateOrigin);
245  requestRedraw();
246  return;
247  }
248 
249  if (itemFocus)
250  {
251  switch (clickType)
252  {
253  case ClickType::onItem:
254  mouseMoveOnItem(x,y);
255  return;
256  case ClickType::inItem:
257  if (itemFocus->onMouseMotion(x,y))
258  requestRedraw();
259  return;
261  if (auto p=itemFocus->plotWidgetCast())
262  {
263  p->mouseMove(x,y);
264  requestRedraw();
265  }
266  return;
267  case ClickType::onResize:
268  lasso.x1=x;
269  lasso.y1=y;
270  requestRedraw();
271  break;
272  default:
273  break;
274  }
275  }
276  else if (fromPort.get())
277  {
278  termX=x;
279  termY=y;
280  requestRedraw();
281  }
282  else if (wireFocus)
283  {
284  wireFocus->editHandle(handleSelected,x,y);
285  requestRedraw();
286  }
288  {
289  lasso.x1=x;
290  lasso.y1=y;
291  requestRedraw();
292  }
293  else
294  {
295  auto setFlagAndRequestRedraw=[&](bool& flag, bool cond) {
296  if (flag==cond) return;
297  flag=cond;
298  requestRedraw();
299  };
300  // set mouse focus to display ports etc.
301  bool mouseFocusSet=false; // ensure only one item is focused by mouse.
302  model->recursiveDo(&Group::items, [&](Items&,Items::iterator& i)
303  {
304  (*i)->disableDelayedTooltip();
305  // with coupled integration variables, we
306  // do not want to set mousefocus, as this
307  // draws unnecessary port circles on the
308  // variable
309  if (!(*i)->visible() &&
310  dynamic_cast<Variable<VariableBase::integral>*>(i->get()))
311  (*i)->mouseFocus=false;
312  else
313  {
314  auto ct=(*i)->clickType(x,y);
315  setFlagAndRequestRedraw((*i)->mouseFocus, !mouseFocusSet && ct!=ClickType::outside);
316  if ((*i)->mouseFocus) mouseFocusSet=true;
317  setFlagAndRequestRedraw((*i)->onResizeHandles, ct==ClickType::onResize);
318  setFlagAndRequestRedraw((*i)->onBorder, ct==ClickType::onItem);
319  if (ct==ClickType::outside)
320  (*i)->onMouseLeave();
321  else if ((*i)->onMouseOver(x,y))
322  requestRedraw();
323  }
324  return false;
325  });
326  model->recursiveDo(&Group::groups, [&](Groups&,Groups::iterator& i)
327  {
328  auto ct=(*i)->clickType(x,y);
329  setFlagAndRequestRedraw((*i)->mouseFocus, !mouseFocusSet && ct!=ClickType::outside);
330  if ((*i)->mouseFocus) mouseFocusSet=true;
331  const bool onResize = ct==ClickType::onResize;
332  if (onResize!=(*i)->onResizeHandles)
333  {
334  (*i)->onResizeHandles=onResize;
335  requestRedraw();
336  }
337  return false;
338  });
339  model->recursiveDo(&Group::wires, [&](Wires&,Wires::iterator& i)
340  {
341  const bool mf=(*i)->near(x,y);
342  if (mf!=(*i)->mouseFocus)
343  {
344  (*i)->mouseFocus=mf;
345  requestRedraw();
346  }
347  return false;
348  });
349  }
350  if (minsky().reset_flag())
351  minsky().resetAt=std::chrono::system_clock::now()+std::chrono::milliseconds(1500); // postpone reset whilst mousing
352  }
353  catch (...) {/* absorb any exceptions, as they're not useful here */}
std::vector< WirePtr > Wires
Definition: wire.h:103
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:171
std::vector< ItemPtr > Items
Definition: item.h:366
std::vector< GroupPtr > Groups
Definition: group.h:54
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:79
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:193
Minsky & minsky()
global minsky object
Definition: minskyTCL.cc:51
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 193 of file canvas.cc.

194  {
195  updateRegion=LassoBox(itemFocus->x(),itemFocus->y(),x,y);
196  // move item relatively to avoid accidental moves on double click
198  itemFocus->moveTo(x-moveOffsX, y-moveOffsY);
199  else
200  {
201  // move the whole selection
202  auto deltaX=x-moveOffsX-itemFocus->x(), deltaY=y-moveOffsY-itemFocus->y();
203  for (auto& i: selection.items)
204  i->moveTo(i->x()+deltaX, i->y()+deltaY);
205  for (auto& i: selection.groups)
206  i->moveTo(i->x()+deltaX, i->y()+deltaY);
207  }
208  requestRedraw();
209  // check if the move has moved outside or into a group
210  if (auto g=itemFocus->group.lock())
211  if (g==model || !g->contains(itemFocus->x(),itemFocus->y()))
212  {
213  if (auto toGroup=model->minimalEnclosingGroup
214  (itemFocus->x(),itemFocus->y(),itemFocus->x(),itemFocus->y(),itemFocus.get()))
215  {
216  if (g.get()==toGroup) return;
217  // prevent moving a group inside itself
218  if (auto g=dynamic_cast<Group*>(itemFocus.get()))
219  if (g->higher(*toGroup))
220  return;
221  selection.clear(); // prevent old wires from being held onto
222  toGroup->addItem(itemFocus);
223  toGroup->splitBoundaryCrossingWires();
224  g->splitBoundaryCrossingWires();
225  }
226  else if (g!=model)
227  {
228  selection.clear(); // prevent old wires from being held onto
229  model->addItem(itemFocus);
230  model->splitBoundaryCrossingWires();
231  g->splitBoundaryCrossingWires();
232  }
233  }
234  if (auto g=itemFocus->group.lock())
235  if (g!=model)
236  g->checkAddIORegion(itemFocus);
237  }
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:102
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:79
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 141 of file canvas.cc.

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

142  {
143  mouseMove(x,y);
144 
146  {
147  itemFocus->onMouseUp(x,y);
148  itemFocus.reset(); // prevent spurious mousemove events being processed
149  minsky().requestReset();
150  }
151  if (fromPort.get())
152  {
153  if (auto to=closestInPort(x,y)) {
154  model->addWire(static_cast<shared_ptr<Port>&>(fromPort),to);
155 
156  // populate the destination tooltip if a Ravel
157  if (to->item().tooltip().empty() && to->item().ravelCast())
158  if (auto v=fromPort->item().variableCast())
159  to->item().tooltip(v->name());
160 
161  minsky().requestReset();
162  }
163  fromPort.reset();
164  }
165 
166  if (wireFocus)
167  wireFocus->editHandle(handleSelected,x,y);
168 
169  switch (lassoMode)
170  {
171  case LassoMode::lasso:
172  select({lasso.x0,lasso.y0,x,y});
173  requestRedraw();
174  break;
176  if (item)
177  {
178  item->resize(lasso);
179  requestRedraw();
180  }
181  break;
182  default: break;
183  }
185 
186 
187  itemIndicator.reset();
188  rotatingItem=false;
189  itemFocus.reset();
190  wireFocus.reset();
191  }
void requestReset()
Definition: minsky.cc:467
void mouseMove(float x, float y) override
Definition: canvas.cc:239
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:377
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:118
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: minskyTCL.cc:51
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 692 of file canvas.cc.

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

Referenced by minsky::MinskyTCL::openGroupInCanvas(), and minsky::MinskyTCL::openModelInCanvas().

693  {
694  if (auto g=dynamic_pointer_cast<Group>(item))
695  {
696  if (auto parent=model->group.lock())
697  model->setZoom(parent->zoomFactor());
698  model=g;
699  zoomToFit();
700 
702  this->item.reset();
703  itemFocus.reset();
704  wire.reset();
705  selection.clear();
706  fromPort.reset();
707  requestRedraw();
708  }
709  }
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:654
virtual void bookmarkRefresh()
refresh the bookmark menu after changes
Definition: minsky.h:450
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: minskyTCL.cc:51
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:

◆ 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 397 of file canvas.cc.

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

◆ recentre()

void minsky::Canvas::recentre ( )

adjust canvas so that -ve coordinates appear on canvas

Definition at line 927 of file canvas.cc.

928  {
929  const SurfacePtr tmp(surface());
930  surface().reset(new Surface(cairo_recording_surface_create(CAIRO_CONTENT_COLOR,nullptr)));
931  redraw();
932  model->moveTo(model->x()-surface()->left(), model->y()-surface()->top());
933  surface()=tmp;
934  requestRedraw();
935  }
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:821

◆ redraw() [1/2]

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

Definition at line 795 of file canvas.cc.

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

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

◆ 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 827 of file canvas.cc.

References M_PI.

828  {
829  bool didDrawSomething = false;
830  if (!surface().get()) {
831  return didDrawSomething;
832  }
833  m_redrawRequested=false;
834  auto cairo=surface()->cairo();
835  const CairoSave cs(cairo);
837  cairo_clip(cairo);
838  cairo_set_line_width(cairo, 1);
839  // items
840  model->recursiveDo
841  (&GroupItems::items, [&](const Items&, Items::const_iterator i)
842  {
843  auto& it=**i;
844  if (it.visible() && updateRegion.intersects(it))
845  {
846  didDrawSomething = true;
847  const CairoSave cs(cairo);
848  cairo_identity_matrix(cairo);
849  cairo_translate(cairo,it.x(), it.y());
850  try
851  {
852  it.draw(cairo);
853  }
854  catch (const std::exception& ex)
855  {
856  cerr << ex.what() << endl;
857  }
858  }
859  return false;
860  });
861 
862  // groups
863  model->recursiveDo
864  (&GroupItems::groups, [&](const Groups&, Groups::const_iterator i)
865  {
866  auto& it=**i;
867  if (it.visible() && updateRegion.intersects(it))
868  {
869  didDrawSomething = true;
870  const CairoSave cs(cairo);
871  cairo_identity_matrix(cairo);
872  cairo_translate(cairo,it.x(), it.y());
873  it.draw(cairo);
874  }
875  return false;
876  });
877 
878  // draw all wires - wires will go over the top of any icons. TODO
879  // introduce an ordering concept if needed
880  model->recursiveDo
881  (&GroupItems::wires, [&](const Wires&, Wires::const_iterator i)
882  {
883  const Wire& w=**i;
884  if (w.visible()) {
885  w.draw(cairo);
886  }
887  return false;
888  });
889 
890  if (fromPort.get()) // we're in process of creating a wire
891  {
892  didDrawSomething = true;
893  cairo_move_to(cairo,fromPort->x(),fromPort->y());
894  cairo_line_to(cairo,termX,termY);
895  cairo_stroke(cairo);
896  // draw arrow
897  const CairoSave cs(cairo);
898  cairo_translate(cairo, termX,termY);
899  cairo_rotate(cairo,atan2(termY-fromPort->y(), termX-fromPort->x()));
900  cairo_move_to(cairo,0,0);
901  cairo_line_to(cairo,-5,-3);
902  cairo_line_to(cairo,-3,0);
903  cairo_line_to(cairo,-5,3);
904  cairo_close_path(cairo);
905  cairo_fill(cairo);
906  }
907 
909  {
910  didDrawSomething = true;
911  cairo_rectangle(cairo,lasso.x0,lasso.y0,lasso.x1-lasso.x0,lasso.y1-lasso.y0);
912  cairo_stroke(cairo);
913  }
914 
915  if (itemIndicator) // draw a red circle to indicate an error or other marker
916  {
917  const CairoSave cs(surface()->cairo());
918  cairo_set_source_rgb(surface()->cairo(),1,0,0);
919  cairo_arc(surface()->cairo(),itemIndicator->x(),itemIndicator->y(),15,0,2*M_PI);
920  cairo_stroke(surface()->cairo());
921  }
922 
923  surface()->blit();
924  return didDrawSomething;
925  }
#define M_PI
some useful geometry types, defined from boost::geometry
Definition: geometry.h:29
std::vector< WirePtr > Wires
Definition: wire.h:103
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:366
ecolab::cairo::SurfacePtr & surface()
Definition: canvas.h:148
std::vector< GroupPtr > Groups
Definition: group.h:54
double termX
Definition: canvas.h:110
Groups groups
Definition: group.h:79
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 517 of file canvas.cc.

518  {
519  if (item)
520  if (auto g=item->group.lock())
521  {
522  if (auto parent=g->group.lock())
523  {
524  itemFocus=parent->addItem(item);
525  if (auto v=itemFocus->variableCast())
526  v->controller.reset();
527  g->splitBoundaryCrossingWires();
528  }
529  // else item already at toplevel
530  }
531  }
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 555 of file canvas.cc.

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

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

556  {
557  auto var=item->variableCast();
558  if (!var)
559  if (auto i=dynamic_cast<IntOp*>(item.get()))
560  var=i->intVar.get();
561  if (var)
562  {
563  // cache name and valueId for later use as var gets invalidated in the recursiveDo
564  auto valueId=var->valueId();
565  model->renameAllInstances(valueId, newName);
566  }
567  }
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 603 of file canvas.cc.

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

604  {
605  if (!item) return;
606  if (auto var=item->variableCast())
607  {
608  var->name(newName);
609  // check stock variables are defined, convert to flow if not
610  if (var->isStock() && !cminsky().definingVar(var->valueId()))
611  var->retype(VariableType::flow);
612  }
613  }
VariablePtr definingVar(const std::string &valueId) const
returns reference to variable defining (ie input wired) for valueId
Definition: minsky.cc:205
const Minsky & cminsky()
const version to help in const correctness
Definition: minsky.h:549
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 943 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.

944  {
945  model->zoom(model->x(),model->y(),z.zoom);
946  model->moveTo(model->x()-z.left,model->y()-z.top);
947  cairo::SurfacePtr tmp(new cairo::Surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32,z.width,z.height)));
948  tmp.swap(surface());
949  redraw(0,0,z.width,z.height);
950  tmp.swap(surface());
951  cairo_surface_write_to_png(tmp->surface(),filename.c_str());
952  model->moveTo(model->x()+z.left,model->y()+z.top);
953  model->zoom(model->x(),model->y(),1/z.zoom);
954  }
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:821

◆ reportDrawTime()

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

Definition at line 937 of file canvas.cc.

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

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

◆ 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 377 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.

378  {
379  selection.clear();
380 
381  auto topLevel = model->minimalEnclosingGroup(lasso.x0,lasso.y0,lasso.x1,lasso.y1);
382 
383  if (!topLevel) topLevel=&*model;
384 
385  for (auto& i: topLevel->items)
386  if (i->visible() && lasso.intersects(*i))
388 
389  for (auto& i: topLevel->groups)
390  if (i->visible() && lasso.intersects(*i))
392 
393  // X11 behaviour, selecting automatically copies.
394  minsky().copy();
395  }
void copy() const
copy items in current selection into clipboard
Definition: minsky.cc:191
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: minskyTCL.cc:51
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 533 of file canvas.cc.

References minsky::var.

534  {
535  selection.clear();
536  auto var=item->variableCast();
537  if (!var)
538  if (auto i=dynamic_cast<IntOp*>(item.get()))
539  var=i->intVar.get();
540  if (var)
541  {
542  model->recursiveDo
543  (&GroupItems::items, [&](const Items&,Items::const_iterator i)
544  {
545  if (auto v=(*i)->variableCast())
546  if (v->valueId()==var->valueId())
547  {
549  }
550  return false;
551  });
552  }
553  }
Model model
Definition: canvas.h:103
std::vector< ItemPtr > Items
Definition: item.h:366
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 755 of file canvas.cc.

Referenced by minsky::MinskyTCL::selectVar().

756  {
757  if (item)
758  {
759  if (auto v=item->select(x,y))
760  {
761  item=v;
762  return true;
763  }
764  }
765  return false;
766  }
ItemPtr item
item or wire obtained by get*At() calls
Definition: canvas.h:175
Here is the caller graph for this function:

◆ 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 969 of file canvas.cc.

970  {
971  item = itemFocus;
972  }
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 569 of file canvas.cc.

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

479  {
480  for (auto& i: selection.items)
481  if (auto r=dynamic_cast<Ravel*>(i.get()))
482  r->leaveLockGroup();
483  }
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 746 of file canvas.cc.

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

747  {
748  if (auto g=dynamic_cast<Group*>(item.get()))
749  {
750  model->zoom(g->x(),g->y(),1.1/(g->relZoom*g->zoomFactor()));
751  minsky().resetScroll();
752  }
753  }
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:453
Minsky & minsky()
global minsky object
Definition: minskyTCL.cc:51
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 654 of file canvas.cc.

References minsky::flipped().

655  {
656  if (frameArgs().parentWindowId.empty()) return; // no window to fit to, so do nothing
657  // recompute all bounding boxes - why is this needed?
658  for (auto& i: model->items) i->updateBoundingBox();
659 
660  double x0,x1,y0,y1;
661  model->contentBounds(x0,y0,x1,y1);
662  float inOffset=0, outOffset=0;
663  const bool notFlipped=!flipped(model->rotation());
664  const float flip=notFlipped? 1: -1;
665 
666  // we need to move the io variables
667  for (auto& v: model->inVariables)
668  inOffset=std::max(inOffset, v->width());
669  for (auto& v: model->outVariables)
670  outOffset=std::max(outOffset, v->width());
671 
672  const float zoomFactor=std::min(frameArgs().childWidth/(x1-x0+inOffset+outOffset),
673  frameArgs().childHeight/(y1-y0));
674 
675  model->zoom(model->x(),model->y(),zoomFactor);
676 
677 
678  model->contentBounds(x0,y0,x1,y1);
679  float ioOffset=notFlipped? x0: x1;
680 
681  // we need to move the io variables
682  for (auto& v: model->inVariables)
683  v->moveTo(ioOffset-flip*v->width(),v->y());
684  ioOffset=notFlipped? x1: x0;
685  for (auto& v: model->outVariables)
686  v->moveTo(ioOffset+flip*v->width(),v->y());
687 
688  recentre();
689  requestRedraw();
690  }
const RenderFrameArgs & frameArgs() const
void recentre()
adjust canvas so that -ve coordinates appear on canvas
Definition: canvas.cc:927
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

◆ itemFocus

◆ 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

◆ 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.

Referenced by minsky::MinskyTCL::getWireAt().

◆ 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: