Minsky
|
#include <canvas.h>
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< Port > | closestInPort (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... | |
![]() | |
const RenderFrameArgs & | frameArgs () 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 () |
RenderNativeWindow & | operator= (const RenderNativeWindow &x) |
RenderNativeWindow ()=default | |
RenderNativeWindow (const RenderNativeWindow &)=default | |
![]() |
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< Point > | rotateOrigin |
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... | |
![]() | |
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 double | scaleFactor () |
![]() | |
static ecolab::cairo::Colour | backgroundColour {0.8,0.8,0.8,1} |
typedef std::chrono::time_point<std::chrono::high_resolution_clock> minsky::Canvas::Timestamp |
|
inline |
item or wire obtained by get*At() calls
Definition at line 200 of file canvas.h.
Referenced by minsky::MinskyTCL::addGodley().
|
inline |
item or wire obtained by get*At() calls
Definition at line 201 of file canvas.h.
Referenced by minsky::MinskyTCL::addGroup().
|
inline |
item or wire obtained by get*At() calls
Definition at line 204 of file canvas.h.
Referenced by minsky::MinskyTCL::addLock().
|
inline |
item or wire obtained by get*At() calls
Definition at line 192 of file canvas.h.
Referenced by minsky::MinskyTCL::addNote().
|
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().
|
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().
|
inline |
item or wire obtained by get*At() calls
Definition at line 203 of file canvas.h.
Referenced by minsky::MinskyTCL::addRavel().
|
inline |
item or wire obtained by get*At() calls
Definition at line 205 of file canvas.h.
Referenced by minsky::MinskyTCL::addSheet().
|
inline |
item or wire obtained by get*At() calls
Definition at line 202 of file canvas.h.
Referenced by minsky::MinskyTCL::addSwitch().
|
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().
void minsky::Canvas::applyDefaultPlotOptions | ( | ) |
item or wire obtained by get*At() calls
Definition at line 958 of file canvas.cc.
|
private |
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().
|
overridevirtual |
Reimplemented from minsky::EventInterface.
Definition at line 40 of file canvas.cc.
|
inline |
|
inline |
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().
|
private |
Definition at line 711 of file canvas.cc.
References minsky::RenderVariable::height(), and minsky::RenderVariable::width().
void minsky::Canvas::deleteItem | ( | ) |
delete item referenced by item
Definition at line 485 of file canvas.cc.
References pyminsky::minsky, and minsky::Minsky::requestReset().
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.
void minsky::Canvas::delHandle | ( | float | x, |
float | y | ||
) |
delete wire handle referenced by wire
Definition at line 505 of file canvas.cc.
void minsky::Canvas::displayDelayedTooltip | ( | float | x, |
float | y | ||
) |
Definition at line 368 of file canvas.cc.
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
Definition at line 768 of file canvas.cc.
Referenced by minsky::MinskyTCL::findVariableDefinition().
|
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().
|
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().
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().
|
inlineoverridevirtual |
item or wire obtained by get*At() calls
Reimplemented from minsky::RenderNativeWindow.
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().
|
overridevirtual |
handle key press over current itemFocus,
keySym | the X key sym code |
utf8 | utf8 encoded character |
state | modifer state 1=shift, 2=caps lock, 4=ctrl, 8=alt |
x | & y contain mouse coordinates |
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.
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.
|
overridevirtual |
event handling for the canvas
Reimplemented from minsky::EventInterface.
Definition at line 47 of file canvas.cc.
|
private |
Definition at line 55 of file canvas.cc.
|
overridevirtual |
Reimplemented from minsky::EventInterface.
Definition at line 239 of file canvas.cc.
References pyminsky::minsky, and minsky::Minsky::reset_flag().
|
private |
Definition at line 193 of file canvas.cc.
|
overridevirtual |
Reimplemented from minsky::EventInterface.
Definition at line 141 of file canvas.cc.
References pyminsky::minsky, and minsky::Minsky::requestReset().
|
inlineoverridevirtual |
move this so that (x,y) is centred
Reimplemented from minsky::EventInterface.
Definition at line 129 of file canvas.h.
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().
|
inlineoverridevirtual |
current centre coordinates
Reimplemented from minsky::EventInterface.
Definition at line 134 of file canvas.h.
int minsky::Canvas::ravelsSelected | ( | ) | const |
number of ravels in selection
Definition at line 397 of file canvas.cc.
void minsky::Canvas::recentre | ( | ) |
adjust canvas so that -ve coordinates appear on canvas
Definition at line 927 of file canvas.cc.
|
overrideprivate |
Definition at line 795 of file canvas.cc.
bool minsky::Canvas::redraw | ( | ) |
|
inline |
flag indicating that a redraw is requested, but not yet redrawn
Definition at line 290 of file canvas.h.
bool minsky::Canvas::redrawUpdateRegion | ( | ) |
update region given by updateRegion
Definition at line 827 of file canvas.cc.
References M_PI.
void minsky::Canvas::removeItemFromItsGroup | ( | ) |
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().
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.
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.
|
overrideprivate |
Definition at line 937 of file canvas.cc.
References minsky::Minsky::maxWaitMS, and pyminsky::minsky.
|
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().
|
inline |
Definition at line 114 of file canvas.h.
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.
void minsky::Canvas::selectAllVariables | ( | ) |
select all variables referring to same variableValue as item
Definition at line 533 of file canvas.cc.
References minsky::var.
bool minsky::Canvas::selectVar | ( | float | x, |
float | y | ||
) |
populates item with a variable if (x,y) is over a variable part
Definition at line 755 of file canvas.cc.
Referenced by minsky::MinskyTCL::selectVar().
|
inline |
item or wire obtained by get*At() calls
Definition at line 295 of file canvas.h.
|
inline |
sets itemFocus, and resets mouse offset for placement
Definition at line 167 of file canvas.h.
References minsky::ClickType::onItem.
void minsky::Canvas::setItemFromItemFocus | ( | ) |
|
inline |
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.
void minsky::Canvas::unlockRavelsInSelection | ( | ) |
|
inlineoverridevirtual |
Reimplemented from minsky::EventInterface.
Definition at line 138 of file canvas.h.
References minsky::Canvas::Model::zoom().
|
inlineoverridevirtual |
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().
void minsky::Canvas::zoomToFit | ( | ) |
zooms canvas to fit available window
Definition at line 654 of file canvas.cc.
References minsky::flipped().
ClickType::Type minsky::Canvas::clickType |
|
private |
double minsky::Canvas::defaultRotation =0 |
Exclude<shared_ptr<Port> > minsky::Canvas::fromPort |
int minsky::Canvas::handleSelected |
ItemPtr minsky::Canvas::item |
item or wire obtained by get*At() calls
Definition at line 175 of file canvas.h.
Referenced by minsky::MinskyTCL::addIntegral(), minsky::MinskyTCL::addLock(), minsky::MinskyTCL::addRavel(), minsky::MinskyTCL::addSheet(), minsky::MinskyTCL::convertVarType(), minsky::MinskyTCL::findObject(), minsky::MinskyTCL::findVariable(), minsky::MinskyTCL::findVariableDefinition(), minsky::MinskyTCL::getItemAt(), minsky::MinskyTCL::getItemAtFocus(), minsky::MinskyTCL::groupOfItem(), minsky::MinskyTCL::itemFocusFromItem(), minsky::MinskyTCL::itemFromItemFocus(), minsky::MinskyTCL::listAllInstances(), minsky::MinskyTCL::loadVariableFromCSV(), minsky::MinskyTCL::openGodley(), minsky::MinskyTCL::openGroupInCanvas(), minsky::MinskyTCL::resetItem(), minsky::MinskyTCL::retypeItem(), minsky::MinskyTCL::selectVar(), minsky::MinskyTCL::TCLItem(), and minsky::GodleyTableEditor::update().
ItemPtr minsky::Canvas::itemFocus |
item selected by clicking
Definition at line 106 of file canvas.h.
Referenced by minsky::MinskyTCL::addGodley(), minsky::MinskyTCL::addGroup(), minsky::MinskyTCL::addNote(), minsky::MinskyTCL::addOperation(), minsky::MinskyTCL::addPlot(), minsky::MinskyTCL::addSwitch(), minsky::MinskyTCL::addVariable(), minsky::MinskyTCL::createGroup(), minsky::MinskyTCL::getItemAtFocus(), minsky::MinskyTCL::itemFocusFromItem(), and minsky::MinskyTCL::itemFromItemFocus().
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().
LassoMode::type minsky::Canvas::lassoMode =LassoMode::none |
|
private |
Model minsky::Canvas::model |
Definition at line 103 of file canvas.h.
Referenced by minsky::MinskyTCL::findObject(), minsky::MinskyTCL::listAllInstances(), minsky::VariableBase::local(), minsky::MinskyTCL::openGroupInCanvas(), minsky::MinskyTCL::openModelInCanvas(), and schema3::Minsky::populateMinsky().
bool minsky::Canvas::redrawAll =true |
Exclude<Point> minsky::Canvas::rotateOrigin |
bool minsky::Canvas::rotatingItem =false |
Selection minsky::Canvas::selection |
Definition at line 105 of file canvas.h.
Referenced by minsky::VariableInstanceList::gotoInstance().
double minsky::Canvas::termY |
LassoBox minsky::Canvas::updateRegion {0,0,0,0} |
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().
WirePtr minsky::Canvas::wireFocus |