Minsky
minsky::Sheet Class Reference

#include <sheet.h>

Inheritance diagram for minsky::Sheet:
Inheritance graph
Collaboration diagram for minsky::Sheet:
Collaboration graph

Private Member Functions

 CLASSDESC_ACCESS (Sheet)
 
double ravelSize () const
 size of ravel in screen coordinates More...
 

Private Attributes

ravel::Ravel inputRavel
 ravel for controlling input value used for populating sheet. Potentially a tensor expression representing ravel manipulation More...
 
civita::TensorPtr value
 
size_t scrollOffset =0
 offset for scrolling through higher ranked inputs More...
 
size_t scrollMax =1
 offset for scrolling through higher ranked inputs More...
 
size_t scrollDelta =0
 offset for scrolling through higher ranked inputs More...
 
std::string sliceIndicator
 offset for scrolling through higher ranked inputs More...
 
bool showRavel =false
 offset for scrolling through higher ranked inputs More...
 
ShowSlice showRowSlice =ShowSlice::head
 whether to elide rows from beginning, end or middle More...
 
ShowSlice showColSlice =ShowSlice::head
 whether to elide columnss from beginning, end or middle More...
 
double ravelX (double xx) const
 ravel coordinate from screen coordinate More...
 
double ravelY (double yy) const
 offset for scrolling through higher ranked inputs More...
 
 Sheet ()
 offset for scrolling through higher ranked inputs More...
 
void operator= (const Sheet &)
 offset for scrolling through higher ranked inputs More...
 
 Sheet (const Sheet &)
 offset for scrolling through higher ranked inputs More...
 
bool onResizeHandle (float x, float y) const override
 offset for scrolling through higher ranked inputs More...
 
void drawResizeHandles (cairo_t *cairo) const override
 offset for scrolling through higher ranked inputs More...
 
bool onRavelButton (float, float) const
 offset for scrolling through higher ranked inputs More...
 
bool inRavel (float, float) const
 offset for scrolling through higher ranked inputs More...
 
bool inItem (float, float) const override
 offset for scrolling through higher ranked inputs More...
 
ClickType::Type clickType (float x, float y) const override
 offset for scrolling through higher ranked inputs More...
 
std::vector< Pointcorners () const override
 offset for scrolling through higher ranked inputs More...
 
bool contains (float x, float y) const override
 offset for scrolling through higher ranked inputs More...
 
bool scrollUp ()
 offset for scrolling through higher ranked inputs More...
 
bool scrollDown ()
 offset for scrolling through higher ranked inputs More...
 
bool onKeyPress (int keySym, const std::string &utf8, int state) override
 offset for scrolling through higher ranked inputs More...
 
void setSliceIndicator ()
 offset for scrolling through higher ranked inputs More...
 
void draw (cairo_t *cairo) const override
 offset for scrolling through higher ranked inputs More...
 
void computeValue ()
 calculates the input value More...
 
void exportAsCSV (const std::string &filename, bool tabular) const
 export the plotted data as a CSV file More...
 

Additional Inherited Members

- Public Member Functions inherited from minsky::ItemT< Sheet >
std::string classType () const override
 
ItemTclone () const override
 
void TCL_obj (classdesc::TCL_obj_t &t, const std::string &d) override
 
void RESTProcess (classdesc::RESTProcess_t &rp, const std::string &d) override
 dummy template definition for use with gui executable More...
 
void RESTProcess (classdesc::RESTProcess_t &rp, const std::string &d) const override
 
void json_pack (classdesc::json_pack_t &j) const override
 
 ItemT ()=default
 
 ItemT (const ItemT &)=default
 
 ItemT (ItemT &&)=delete
 
ItemToperator= (const ItemT &)=default
 
ItemToperator= (ItemT &&)=delete
 
- Public Member Functions inherited from minsky::Item
 Item ()
 
virtual std::weak_ptr< Portports (std::size_t i) const
 callback to be run when item deleted from group More...
 
std::size_t portsSize () const
 number of ports More...
 
float portX (std::size_t i)
 
float portY (std::size_t i)
 
bool contains (const Point &p) const
 
void updateBoundingBox () override
 
void throw_error (const std::string &) const
 mark item on canvas, then throw More...
 
virtual bool ioVar () const
 indicates this is a group I/O variable More...
 
virtual double value () const
 current value of output port More...
 
double rotation () const
 
double rotation (const double &r)
 
std::pair< double, bool > rotationAsRadians () const
 return the rotation as radians, and whether rotation should have additional straight angle added for text that stays upright. More...
 
float iWidth () const
 
float iWidth (const float &w)
 
float iHeight () const
 
float iHeight (const float &h)
 
virtual void flip ()
 rotate icon though 180∘ More...
 
std::string id () const
 return an id uniquely identifying this item More...
 
virtual float x () const
 
virtual float y () const
 
virtual float zoomFactor () const
 
void ensureBBValid () const
 
float width () const
 
float height () const
 
float left () const
 
float right () const
 
float top () const
 
float bottom () const
 
std::string bookmarkId () const
 Id of bookmark associated with this. More...
 
void adjustBookmark () const override
 adjust bookmark list to reflect current configuration More...
 
float resizeHandleSize () const
 resize handles should be at least a percentage if the icon size (#1025) More...
 
virtual bool onItem (float x, float y) const
 returns true if (x,y) is on the icon More...
 
virtual void onMouseDown (float x, float y)
 respond to mouse down events More...
 
virtual void onMouseUp (float x, float y)
 respond to mouse up events More...
 
virtual bool onMouseMotion (float x, float y)
 respond to mouse motion events with button pressed More...
 
virtual bool onMouseOver (float x, float y)
 respond to mouse motion events (hover) without button pressed More...
 
virtual void onMouseLeave ()
 respond to mouse leave events (when mouse leaves item) More...
 
virtual void deleteAttachedWires ()
 delete all attached wires More...
 
virtual bool visible () const
 whether this item is visible on the canvas. More...
 
void moveTo (float x, float y)
 
virtual void resize (const LassoBox &b)
 resize this item on the canvas More...
 
virtual float scaleFactor () const
 factor by which item has been resized More...
 
virtual float scaleFactor (const float &sf)
 
void dummyDraw () const
 draw into a dummy cairo context, for purposes of calculating port positions More...
 
virtual void displayTooltip (cairo_t *, const std::string &) const
 display tooltip text, eg on mouseover More...
 
virtual void updateIcon (double t)
 update display after a step() More...
 
 Item (const Item &)=default
 
Itemoperator= (const Item &)=default
 
virtual ~Item ()
 
void drawPorts (cairo_t *cairo) const
 
virtual std::shared_ptr< PortclosestOutPort (float x, float y) const
 returns closest output port to x,y More...
 
virtual std::shared_ptr< PortclosestInPort (float x, float y) const
 
virtual std::shared_ptr< Itemselect (float x, float y) const
 returns the variable if point (x,y) is within a visible variable icon, null otherwise. More...
 
void RESTProcess (classdesc::RESTProcess_t &rp, const std::string &d) override
 runs the RESTProcess descriptor suitable for this type More...
 
void RESTProcess (classdesc::RESTProcess_t &rp, const std::string &d) const override
 
virtual void displayDelayedTooltip (float x, float y)
 enable extended tooltip help message appropriate for mouse at (x,y) More...
 
virtual void disableDelayedTooltip ()
 
virtual bool editorMode () const
 some items have an editor mode attribute More...
 
virtual void toggleEditorMode ()
 
virtual Units units (bool check=false) const
 compute the dimensional units More...
 
Units checkUnits () const
 perform units consistency checks More...
 
ItemPtr itemPtrFromThis () const
 return a shared_ptr to this More...
 
virtual void destroyFrame ()
 destroy any popup windows associated with this More...
 
- Public Member Functions inherited from minsky::NoteBase
virtual std::string const & detailedText () const
 
virtual std::string const & detailedText (const std::string &x)
 
virtual std::string const & tooltip () const
 
virtual std::string const & tooltip (const std::string &x)
 
virtual ~NoteBase ()=default
 
- Static Public Member Functions inherited from minsky::Item
static void drawSelected (cairo_t *cairo)
 
- Public Attributes inherited from minsky::Item
float m_x =0
 
float m_y =0
 position in canvas, or within group More...
 
float m_sf =1
 scale factor of item on canvas, or within group More...
 
bool onResizeHandles =false
 set to true to indicate mouse is ovcaler resize handles More...
 
bool onBorder =false
 true to indicate mouse hovering over border More...
 
std::string deleteCallback
 
BoundingBox bb
 canvas bounding box. More...
 
- Public Attributes inherited from minsky::NoteBase
bool mouseFocus =false
 true if target of a mouseover More...
 
bool selected =false
 true if selected for cut, copy or group operation More...
 
bool bookmark =false
 Is this item also a bookmark? More...
 
- Static Protected Member Functions inherited from minsky::Item
static void drawResizeHandle (cairo_t *cairo, double x, double y, double sf, double angle)
 
- Protected Attributes inherited from minsky::Item
double m_width =10
 
double m_height =10
 
ItemPortVector m_ports
 
minsky::Item::MemoisedRotator memoisedRotator
 

Detailed Description

Definition at line 32 of file sheet.h.

Constructor & Destructor Documentation

◆ Sheet() [1/2]

Sheet::Sheet ( )

offset for scrolling through higher ranked inputs

Definition at line 44 of file sheet.cc.

45 {
46  m_ports.emplace_back(make_shared<InputPort>(*this));
47  iWidth(100);
48  iHeight(100);
49 }
float iHeight() const
Definition: item.h:224
float iWidth() const
Definition: item.h:217
ItemPortVector m_ports
Definition: item.h:156

◆ Sheet() [2/2]

minsky::Sheet::Sheet ( const Sheet )
inline

offset for scrolling through higher ranked inputs

Definition at line 55 of file sheet.h.

55 {}

Member Function Documentation

◆ CLASSDESC_ACCESS()

minsky::Sheet::CLASSDESC_ACCESS ( Sheet  )
private

◆ clickType()

ClickType::Type Sheet::clickType ( float  x,
float  y 
) const
overridevirtual

offset for scrolling through higher ranked inputs

Reimplemented from minsky::Item.

Definition at line 111 of file sheet.cc.

References minsky::ClickType::inItem, minsky::ClickType::onItem, minsky::ClickType::onResize, and minsky::ClickType::outside.

112 {
113  if (onResizeHandle(x,y)) return ClickType::onResize;
114  if (inItem(x,y)) return ClickType::inItem;
115  const double dx=fabs(x-this->x()), dy=fabs(y-this->y());
116  const double w=0.5*m_width*zoomFactor(), h=0.5*m_height*zoomFactor();
117  if (dx < w && dy < h)
118  return ClickType::onItem;
119  return ClickType::outside;
120 }
bool inItem(float, float) const override
offset for scrolling through higher ranked inputs
Definition: sheet.cc:104
virtual float x() const
Definition: item.cc:107
virtual float y() const
Definition: item.cc:114
double m_height
Definition: item.h:155
virtual float zoomFactor() const
Definition: item.cc:121
double m_width
Definition: item.h:155
bool onResizeHandle(float x, float y) const override
offset for scrolling through higher ranked inputs
Definition: sheet.cc:66

◆ computeValue()

void Sheet::computeValue ( )

calculates the input value

Definition at line 222 of file sheet.cc.

223 {
224  if (m_ports[0] && (value=m_ports[0]->getVariableValue()) && showRavel && inputRavel )
225  {
226  const bool wasEmpty=inputRavel.numHandles()==0;
227  inputRavel.populateFromHypercube(value->hypercube());
228  for (size_t i=0; i<inputRavel.numHandles(); ++i)
229  inputRavel.displayFilterCaliper(i,true);
230  if (wasEmpty)
231  switch (value->rank())
232  {
233  case 0: break;
234  case 1:
235  inputRavel.setOutputHandleIds({0});
236  break;
237  default:
238  inputRavel.setOutputHandleIds({0,1});
239  break;
240  }
241 
242  if (value->rank()>0)
243  {
244  value=inputRavel.hyperSlice(value);
245  if (value->rank()>=2)
246  { // swap first and second axes
247  auto& xv=value->hypercube().xvectors;
248  auto pivot=make_shared<civita::Pivot>();
249  pivot->setArgument(value,{});
250  pivot->setOrientation(vector<string>{xv[1].name,xv[0].name});
251  value=std::move(pivot);
252  }
253  }
254  }
255  if (value && value->rank()>2)
256  {
257  const size_t delta=value->hypercube().xvectors[0].size()*value->hypercube().xvectors[1].size();
258  if (delta!=scrollDelta)
259  {
260  scrollDelta=delta;
261  scrollOffset=0;
262  }
263  }
264  else
266  scrollMax=value? value->size(): 1;
268 }
ravel::Ravel inputRavel
ravel for controlling input value used for populating sheet. Potentially a tensor expression represen...
Definition: sheet.h:36
bool showRavel
offset for scrolling through higher ranked inputs
Definition: sheet.h:81
virtual double value() const
current value of output port
Definition: item.h:209
size_t scrollDelta
offset for scrolling through higher ranked inputs
Definition: sheet.h:47
size_t scrollOffset
offset for scrolling through higher ranked inputs
Definition: sheet.h:46
size_t scrollMax
offset for scrolling through higher ranked inputs
Definition: sheet.h:46
ItemPortVector m_ports
Definition: item.h:156
void setSliceIndicator()
offset for scrolling through higher ranked inputs
Definition: sheet.cc:175

◆ contains()

bool Sheet::contains ( float  x,
float  y 
) const
overridevirtual

offset for scrolling through higher ranked inputs

Reimplemented from minsky::Item.

Definition at line 128 of file sheet.cc.

References minsky::Item::contains().

129 {
130  return Item::contains(x,y) || inRavel(x,y);
131 }
bool inRavel(float, float) const
offset for scrolling through higher ranked inputs
Definition: sheet.cc:96
virtual float x() const
Definition: item.cc:107
virtual float y() const
Definition: item.cc:114
virtual bool contains(float xx, float yy) const
Definition: item.h:196
Here is the call graph for this function:

◆ corners()

std::vector< Point > Sheet::corners ( ) const
overridevirtual

offset for scrolling through higher ranked inputs

Reimplemented from minsky::Item.

Definition at line 122 of file sheet.cc.

123 {
124  const float w=0.5*m_width*zoomFactor(), h=0.5*m_height*zoomFactor();
125  return {{x()-w,y()-h},{x()+w,y()-h},{x()-w,y()+h},{x()+w,y()+h}};
126 }
virtual float x() const
Definition: item.cc:107
virtual float y() const
Definition: item.cc:114
double m_height
Definition: item.h:155
virtual float zoomFactor() const
Definition: item.cc:121
double m_width
Definition: item.h:155

◆ draw()

void Sheet::draw ( cairo_t *  cairo) const
overridevirtual

offset for scrolling through higher ranked inputs

Reimplemented from minsky::Item.

Definition at line 293 of file sheet.cc.

References border, minsky::anonymous_namespace{userFunction.cc}::isnan(), M_PI, minsky::minsky(), minsky::Minsky::requestReset(), minsky::str(), and minsky::trimWS().

294 {
295  auto z=zoomFactor();
296  m_ports[0]->moveTo(x()-0.5*m_width*z,y());
297  if (mouseFocus)
298  {
299  drawPorts(cairo);
300  displayTooltip(cairo,tooltip());
301  // Resize handles always visible on mousefocus. For ticket 92.
302  drawResizeHandles(cairo);
303  }
304 
305  cairo_scale(cairo,z,z);
306 
307  cairo_rectangle(cairo,-0.5*m_width+border,-0.5*m_height+border,m_width-2*border,m_height-2*border);
308  cairo_stroke_preserve(cairo);
309  cairo_rectangle(cairo,-0.5*m_width,-0.5*m_height,m_width,m_height);
310  cairo_stroke_preserve(cairo);
311  // draw border
312  if (onBorder)
313  { // shadow the border when mouse is over it
314  const cairo::CairoSave cs(cairo);
315  cairo_set_source_rgba(cairo,0.5,0.5,0.5,0.5);
316  cairo_set_fill_rule(cairo,CAIRO_FILL_RULE_EVEN_ODD);
317  cairo_fill(cairo);
318  }
319  cairo_new_path(cairo);
320  cairo_rectangle(cairo,-0.5*m_width+border,-0.5*m_height+border,m_width-2*border,m_height-2*border);
321  cairo_clip(cairo);
322 
323  if (selected) drawSelected(cairo);
324 
325  static const regex pangoMarkup("<[^<>]*>");
326  smatch match;
327 
328  try
329  {
330  if (!value || !m_ports[0] || m_ports[0]->numWires()==0) return;
331  Pango pango(cairo);
332  pango.setFontSize(12.0);
333  double x0=-0.5*m_width+border, y0=-0.5*m_height+border;
334  const size_t vertDim=value->rank()>1? 1: 0, horizDim=0;
335 
336  // force evaluate first data item, in case cachedTensorOp updates hypercube
337  if (value->size()>0)
338  (*value)[0];
339 
340  if (value->hypercube().rank()==0)
341  {
342  cairo_move_to(cairo,x0,y0);
343  pango.setMarkup(str((*value)[0]));
344  pango.show();
345  }
346  else
347  {
348  if (value->size()!=scrollMax) minsky().requestReset(); // fix up slice indicator
349 
350  if (!value->hypercube().xvectors[vertDim].name.empty())
351  {
352  const cairo::CairoSave cs(cairo);
353  pango.setMarkup(value->hypercube().xvectors[vertDim].name);
354  x0+=pango.height();
355  cairo_move_to(cairo,x0, -0.5*pango.width());
356  pango.angle=0.5*M_PI;
357  pango.show();
358  pango.angle=0;
359  { // draw vertical grid line
360  const cairo::CairoSave cs(cairo);
361  cairo_set_source_rgba(cairo,0,0,0,0.5);
362  cairo_move_to(cairo,x0,-0.5*m_height);
363  cairo_line_to(cairo,x0,0.5*m_height);
364  cairo_stroke(cairo);
365  }
366  }
367 
368  pango.setMarkup("9999");
369 
370  ClippedPango cpango(cairo);
371  const double rowHeight=cpango.m_height;
372  const double colWidth=cpango.m_width;
373 
374  double x=x0, y=y0; // make sure row labels are aligned with corresponding values. for ticket 1281
375  string format=value->hypercube().xvectors[vertDim].dimension.units;
376 
377  if (value->hypercube().rank()>=2)
378  {
379  y+=2*rowHeight; // allow room for header row
380  if (value->hypercube().rank()>2) // allow room for slice indicator
381  {
382  y+=rowHeight;
383  const cairo::CairoSave cs(cairo);
384  cpango.setMarkup(sliceIndicator);
385  cairo_move_to(cairo,0.5*(x0+colWidth+0.5*m_width-cpango.width()), y0);
386  y0+=cpango.height();
387  cpango.show();
388  }
389  if (!value->hypercube().xvectors[horizDim].name.empty())
390  {
391  const cairo::CairoSave cs(cairo);
392  cpango.setMarkup(value->hypercube().xvectors[horizDim].name);
393  cairo_move_to(cairo,0.5*(x0+colWidth+0.5*m_width-cpango.width()), y0);
394  y0+=cpango.height();
395  cpango.show();
396  }
397 
398  { // draw horizontal grid lines
399  const cairo::CairoSave cs(cairo);
400  cairo_set_source_rgba(cairo,0,0,0,0.5);
401  cairo_move_to(cairo,-0.5*m_width,y0-2.5);
402  cairo_line_to(cairo,0.5*m_width,y0-2.5);
403  cairo_stroke(cairo);
404  cairo_move_to(cairo,x,y0+rowHeight-2.5);
405  cairo_line_to(cairo,0.5*m_width,y0+rowHeight-2.5);
406  cairo_stroke(cairo);
407 
408  }
409  }
410 
411  auto dims=value->hypercube().dims();
412  double dataHeight=m_height;
413  switch (dims.size())
414  {
415  case 0: case 1: break;
416  case 2: dataHeight-=2*(rowHeight+3); break;
417  default: dataHeight-=3*(rowHeight+3); break;
418  }
419  const ElisionRowChecker adjustRowAndFinish(showRowSlice,dataHeight,rowHeight,dims[vertDim]);
420 
421  // draw in label column
422  auto& xv=value->hypercube().xvectors[vertDim];
423  for (size_t i=adjustRowAndFinish.startRow; i<xv.size(); ++i)
424  {
425  if (adjustRowAndFinish(i,y)) break;
426  cairo_move_to(cairo,x,y);
427  auto sliceLabel=trimWS(str(xv[i],format));
428  if (regex_search(sliceLabel,match,pangoMarkup))
429  cpango.setMarkup(sliceLabel);
430  else
431  cpango.setText(sliceLabel);
432  cpango.show();
433  y+=rowHeight;
434  }
435  y=y0;
436  x+=colWidth;
437  if (value->hypercube().rank()==1)
438  {
439  { // draw vertical grid line
440  const cairo::CairoSave cs(cairo);
441  cairo_set_source_rgba(cairo,0,0,0,0.5);
442  cairo_move_to(cairo,x,-0.5*m_height);
443  cairo_line_to(cairo,x,0.5*m_height);
444  cairo_stroke(cairo);
445  }
446  for (size_t i=adjustRowAndFinish.startRow; i<dims[vertDim]; ++i)
447  {
448  if (adjustRowAndFinish(i,y)) break;
449  cairo_move_to(cairo,x,y);
450  auto v=value->atHCIndex(i);
451  if (!std::isnan(v))
452  {
453  cpango.setMarkup(str(v));
454  cpango.show();
455  }
456  y+=rowHeight;
457  }
458  }
459  else
460  {
461  format=value->hypercube().xvectors[horizDim].dimension.units;
462  const ElisionRowChecker adjustColAndFinish(showColSlice,m_width-colWidth,colWidth,dims[horizDim]);
463  for (size_t i=adjustColAndFinish.startRow; i<dims[horizDim]; ++i)
464  {
465  if (adjustColAndFinish(i,x)) break;
466  y=y0;
467  {
468  const cairo::CairoSave cs(cairo);
469  cairo_rectangle(cairo,x,y,colWidth,rowHeight);
470  cairo_clip(cairo);
471  cairo_move_to(cairo,x,y);
472  auto sliceLabel=trimWS(str(value->hypercube().xvectors[horizDim][i],format));
473  if (regex_search(sliceLabel,match,pangoMarkup))
474  cpango.setMarkup(sliceLabel);
475  else
476  cpango.setText(sliceLabel);
477  cpango.show();
478  }
479  { // draw vertical grid line
480  const cairo::CairoSave cs(cairo);
481  cairo_set_source_rgba(cairo,0,0,0,0.5);
482  cairo_move_to(cairo,x-2.5,y0);
483  cairo_line_to(cairo,x-2.5,0.5*m_height);
484  cairo_stroke(cairo);
485  }
486  for (size_t j=adjustRowAndFinish.startRow; j<dims[vertDim]; ++j)
487  {
488  if (adjustRowAndFinish(j,y)) break;
489  y+=rowHeight;
490  cairo_move_to(cairo,x,y);
491  assert(horizDim==0);
492  auto v=value->atHCIndex(i+j*dims[0]+scrollOffset);
493  if (!std::isnan(v))
494  {
495  cpango.setText(str(v));
496  cpango.show();
497  }
498  }
499  x+=colWidth;
500  if (x>0.5*m_width) break;
501  }
502  }
503  // draw grid
504  {
505  const cairo::CairoSave cs(cairo);
506  cairo_set_source_rgba(cairo,0,0,0,0.2);
507  for (y=y0+0.8*rowHeight; y<0.5*m_height; y+=2*rowHeight)
508  {
509  cairo_rectangle(cairo,x0,y,m_width,rowHeight);
510  cairo_fill(cairo);
511  }
512  }
513 
514  }
515  }
516  catch (...) {/* exception most likely invalid variable value */}
517  cairo_reset_clip(cairo);
518  cairo_rectangle(cairo,-0.5*m_width,-0.5*m_height,m_width,m_height);
519  cairo_clip(cairo);
520 }
#define M_PI
some useful geometry types, defined from boost::geometry
Definition: geometry.h:29
void drawPorts(cairo_t *cairo) const
Definition: item.cc:294
const float border
Definition: sheet.cc:40
void requestReset()
Definition: minsky.cc:467
virtual void displayTooltip(cairo_t *, const std::string &) const
display tooltip text, eg on mouseover
Definition: item.cc:398
virtual double value() const
current value of output port
Definition: item.h:209
virtual float x() const
Definition: item.cc:107
std::string sliceIndicator
offset for scrolling through higher ranked inputs
Definition: sheet.h:48
virtual float y() const
Definition: item.cc:114
size_t scrollOffset
offset for scrolling through higher ranked inputs
Definition: sheet.h:46
double m_height
Definition: item.h:155
virtual std::string const & tooltip() const
Definition: noteBase.h:36
size_t scrollMax
offset for scrolling through higher ranked inputs
Definition: sheet.h:46
virtual float zoomFactor() const
Definition: item.cc:121
static void drawSelected(cairo_t *cairo)
Definition: item.cc:308
std::string trimWS(const std::string &s)
Definition: str.h:49
ShowSlice showRowSlice
whether to elide rows from beginning, end or middle
Definition: sheet.h:82
double m_width
Definition: item.h:155
bool onBorder
true to indicate mouse hovering over border
Definition: item.h:176
std::string str(T x)
utility function to create a string representation of a numeric type
Definition: str.h:33
ItemPortVector m_ports
Definition: item.h:156
bool selected
true if selected for cut, copy or group operation
Definition: noteBase.h:32
ShowSlice showColSlice
whether to elide columnss from beginning, end or middle
Definition: sheet.h:83
void drawResizeHandles(cairo_t *cairo) const override
offset for scrolling through higher ranked inputs
Definition: sheet.cc:76
bool mouseFocus
true if target of a mouseover
Definition: noteBase.h:31
Minsky & minsky()
global minsky object
Definition: minskyTCL.cc:51
Here is the call graph for this function:

◆ drawResizeHandles()

void Sheet::drawResizeHandles ( cairo_t *  cairo) const
overridevirtual

offset for scrolling through higher ranked inputs

Reimplemented from minsky::Item.

Definition at line 76 of file sheet.cc.

References M_PI.

77 {
78  auto sf=resizeHandleSize();
79  const float w=0.5f*m_width*zoomFactor(), h=0.5f*m_height*zoomFactor();
80  if (!showRavel)
81  drawResizeHandle(cairo,-w,-h,sf,0);
82  drawResizeHandle(cairo,w,-h,sf,0.5*M_PI);
83  drawResizeHandle(cairo,w,h,sf,0);
84  drawResizeHandle(cairo,-w,h,sf,0.5*M_PI);
85  cairo_stroke(cairo);
86 }
#define M_PI
some useful geometry types, defined from boost::geometry
Definition: geometry.h:29
bool showRavel
offset for scrolling through higher ranked inputs
Definition: sheet.h:81
double m_height
Definition: item.h:155
virtual float zoomFactor() const
Definition: item.cc:121
static void drawResizeHandle(cairo_t *cairo, double x, double y, double sf, double angle)
Definition: item.cc:316
double m_width
Definition: item.h:155
float resizeHandleSize() const
resize handles should be at least a percentage if the icon size (#1025)
Definition: item.h:255

◆ exportAsCSV()

void Sheet::exportAsCSV ( const std::string &  filename,
bool  tabular 
) const

export the plotted data as a CSV file

Parameters
tabular- if true, the longest dimension is split across columns as a horizontal dimension

Definition at line 522 of file sheet.cc.

References minsky::VariableValue::exportAsCSV(), and minsky::VariableType::flow.

523 {
524  if (!value)
525  throw_error("input not defined");
527  vv.exportAsCSV(filename,"",tabular);
528 }
virtual double value() const
current value of output port
Definition: item.h:209
void throw_error(const std::string &) const
mark item on canvas, then throw
Definition: item.cc:86
Here is the call graph for this function:

◆ inItem()

bool Sheet::inItem ( float  xx,
float  yy 
) const
overridevirtual

offset for scrolling through higher ranked inputs

Reimplemented from minsky::Item.

Definition at line 104 of file sheet.cc.

References border.

105 {
106  const double z=zoomFactor();
107  const double w=0.5*m_width*z, h=0.5*m_height*z, b=border*z;
108  return (abs(xx-x())<w-b && abs(yy-y())<h-b) || onRavelButton(xx,yy) || inRavel(xx,yy);
109 }
bool inRavel(float, float) const
offset for scrolling through higher ranked inputs
Definition: sheet.cc:96
const float border
Definition: sheet.cc:40
virtual float x() const
Definition: item.cc:107
virtual float y() const
Definition: item.cc:114
double m_height
Definition: item.h:155
virtual float zoomFactor() const
Definition: item.cc:121
double m_width
Definition: item.h:155
bool onRavelButton(float, float) const
offset for scrolling through higher ranked inputs
Definition: sheet.cc:89

◆ inRavel()

bool Sheet::inRavel ( float  xx,
float  yy 
) const

offset for scrolling through higher ranked inputs

Definition at line 96 of file sheet.cc.

97 {
98  auto dx=xx-x(), dy=yy-y();
99  const float w=0.5*m_width*zoomFactor(), h=0.5*m_height*zoomFactor();
100  return showRavel && inputRavel && (dx<w || dy<h) &&
101  fabs(ravelX(xx))<1.1*inputRavel.radius() && fabs(ravelY(yy))<1.1*inputRavel.radius();
102 }
ravel::Ravel inputRavel
ravel for controlling input value used for populating sheet. Potentially a tensor expression represen...
Definition: sheet.h:36
bool showRavel
offset for scrolling through higher ranked inputs
Definition: sheet.h:81
virtual float x() const
Definition: item.cc:107
virtual float y() const
Definition: item.cc:114
double ravelX(double xx) const
ravel coordinate from screen coordinate
Definition: sheet.cc:56
double m_height
Definition: item.h:155
virtual float zoomFactor() const
Definition: item.cc:121
double m_width
Definition: item.h:155
double ravelY(double yy) const
offset for scrolling through higher ranked inputs
Definition: sheet.cc:61

◆ onKeyPress()

bool Sheet::onKeyPress ( int  keySym,
const std::string &  utf8,
int  state 
)
overridevirtual

offset for scrolling through higher ranked inputs

Reimplemented from minsky::Item.

Definition at line 155 of file sheet.cc.

156 {
157  switch (keySym)
158  {
159  case 0xff52: case 0xff53: case 0xff55: //Right, Up
160  return scrollUp();
161  case 0xff51: case 0xff54: case 0xff56://Left, Down
162  return scrollDown();
163  default:
164  return false;
165  }
166 }
bool scrollUp()
offset for scrolling through higher ranked inputs
Definition: sheet.cc:133
bool scrollDown()
offset for scrolling through higher ranked inputs
Definition: sheet.cc:144

◆ onRavelButton()

bool Sheet::onRavelButton ( float  xx,
float  yy 
) const

offset for scrolling through higher ranked inputs

Definition at line 89 of file sheet.cc.

References border.

90 {
91  const float dx=xx-x(), dy=yy-y();
92  const float w=0.5*m_width*zoomFactor(), h=0.5*m_height*zoomFactor(), b=border*zoomFactor();
93  return inputRavel && dx>=-w && dx<=b-w && dy>=-h && dy<=b-h;
94 }
ravel::Ravel inputRavel
ravel for controlling input value used for populating sheet. Potentially a tensor expression represen...
Definition: sheet.h:36
const float border
Definition: sheet.cc:40
virtual float x() const
Definition: item.cc:107
virtual float y() const
Definition: item.cc:114
double m_height
Definition: item.h:155
virtual float zoomFactor() const
Definition: item.cc:121
double m_width
Definition: item.h:155

◆ onResizeHandle()

bool Sheet::onResizeHandle ( float  x,
float  y 
) const
overridevirtual

offset for scrolling through higher ranked inputs

Reimplemented from minsky::Item.

Definition at line 66 of file sheet.cc.

67 {
68  const float dx=xx-x(), dy=yy-y();
69  const float w=0.5*m_width*zoomFactor(), h=0.5*m_height*zoomFactor();
70  return fabs(dx)>=w-resizeHandleSize() && fabs(dx)<=w+resizeHandleSize() &&
71  fabs(dy)>=h-resizeHandleSize() && fabs(dy)<=h+resizeHandleSize() &&
72  (!inputRavel || dx>0 || dy>0);
73 }
ravel::Ravel inputRavel
ravel for controlling input value used for populating sheet. Potentially a tensor expression represen...
Definition: sheet.h:36
virtual float x() const
Definition: item.cc:107
virtual float y() const
Definition: item.cc:114
double m_height
Definition: item.h:155
virtual float zoomFactor() const
Definition: item.cc:121
double m_width
Definition: item.h:155
float resizeHandleSize() const
resize handles should be at least a percentage if the icon size (#1025)
Definition: item.h:255

◆ operator=()

void minsky::Sheet::operator= ( const Sheet )
inline

offset for scrolling through higher ranked inputs

Definition at line 54 of file sheet.h.

54 {}

◆ ravelSize()

double Sheet::ravelSize ( ) const
private

size of ravel in screen coordinates

Definition at line 51 of file sheet.cc.

52 {
53  return 0.25*std::min(m_width,m_height)*zoomFactor();
54 }
double m_height
Definition: item.h:155
virtual float zoomFactor() const
Definition: item.cc:121
double m_width
Definition: item.h:155

◆ ravelX()

double Sheet::ravelX ( double  xx) const
private

ravel coordinate from screen coordinate

Definition at line 56 of file sheet.cc.

References ravelOffset.

57 {
58  return (xx+(0.5+ravelOffset)*zoomFactor()*m_width-x())*inputRavel.radius()/(zoomFactor()*ravelSize());
59 }
ravel::Ravel inputRavel
ravel for controlling input value used for populating sheet. Potentially a tensor expression represen...
Definition: sheet.h:36
virtual float x() const
Definition: item.cc:107
double ravelSize() const
size of ravel in screen coordinates
Definition: sheet.cc:51
virtual float zoomFactor() const
Definition: item.cc:121
double m_width
Definition: item.h:155
const double ravelOffset
Definition: sheet.cc:42

◆ ravelY()

double Sheet::ravelY ( double  yy) const
private

offset for scrolling through higher ranked inputs

Definition at line 61 of file sheet.cc.

References ravelOffset.

62 {
63  return (yy+(0.5+ravelOffset)*zoomFactor()*m_height-y())*inputRavel.radius()/(zoomFactor()*ravelSize());
64 }
ravel::Ravel inputRavel
ravel for controlling input value used for populating sheet. Potentially a tensor expression represen...
Definition: sheet.h:36
virtual float y() const
Definition: item.cc:114
double ravelSize() const
size of ravel in screen coordinates
Definition: sheet.cc:51
double m_height
Definition: item.h:155
virtual float zoomFactor() const
Definition: item.cc:121
const double ravelOffset
Definition: sheet.cc:42

◆ scrollDown()

bool Sheet::scrollDown ( )

offset for scrolling through higher ranked inputs

Definition at line 144 of file sheet.cc.

145 {
147  {
150  return true;
151  }
152  return false;
153 }
size_t scrollDelta
offset for scrolling through higher ranked inputs
Definition: sheet.h:47
size_t scrollOffset
offset for scrolling through higher ranked inputs
Definition: sheet.h:46
void setSliceIndicator()
offset for scrolling through higher ranked inputs
Definition: sheet.cc:175

◆ scrollUp()

bool Sheet::scrollUp ( )

offset for scrolling through higher ranked inputs

Definition at line 133 of file sheet.cc.

134 {
136  {
139  return true;
140  }
141  return false;
142 }
size_t scrollDelta
offset for scrolling through higher ranked inputs
Definition: sheet.h:47
size_t scrollOffset
offset for scrolling through higher ranked inputs
Definition: sheet.h:46
size_t scrollMax
offset for scrolling through higher ranked inputs
Definition: sheet.h:46
void setSliceIndicator()
offset for scrolling through higher ranked inputs
Definition: sheet.cc:175

◆ setSliceIndicator()

void Sheet::setSliceIndicator ( )

offset for scrolling through higher ranked inputs

Definition at line 175 of file sheet.cc.

References anonymous_namespace{sheet.cc}::formattedStr().

176 {
177  if (!value || value->rank()<=2) return;
178  auto idx=value->hypercube().splitIndex(scrollOffset);
179  sliceIndicator=formattedStr(value->hypercube().xvectors[2], idx[2]);
180  for (size_t i=3; i<idx.size(); ++i)
181  sliceIndicator+=" | "+formattedStr(value->hypercube().xvectors[i], idx[i]);
182 }
virtual double value() const
current value of output port
Definition: item.h:209
std::string sliceIndicator
offset for scrolling through higher ranked inputs
Definition: sheet.h:48
size_t scrollOffset
offset for scrolling through higher ranked inputs
Definition: sheet.h:46
string formattedStr(const XVector &xv, size_t index)
Definition: sheet.cc:169
Here is the call graph for this function:

Member Data Documentation

◆ inputRavel

ravel::Ravel minsky::Sheet::inputRavel
private

ravel for controlling input value used for populating sheet. Potentially a tensor expression representing ravel manipulation

Definition at line 36 of file sheet.h.

◆ scrollDelta

size_t minsky::Sheet::scrollDelta =0
private

offset for scrolling through higher ranked inputs

Definition at line 47 of file sheet.h.

◆ scrollMax

size_t minsky::Sheet::scrollMax =1
private

offset for scrolling through higher ranked inputs

Definition at line 46 of file sheet.h.

◆ scrollOffset

size_t minsky::Sheet::scrollOffset =0
private

offset for scrolling through higher ranked inputs

Definition at line 46 of file sheet.h.

◆ showColSlice

ShowSlice minsky::Sheet::showColSlice =ShowSlice::head

whether to elide columnss from beginning, end or middle

Definition at line 83 of file sheet.h.

◆ showRavel

bool minsky::Sheet::showRavel =false

offset for scrolling through higher ranked inputs

Definition at line 81 of file sheet.h.

◆ showRowSlice

ShowSlice minsky::Sheet::showRowSlice =ShowSlice::head

whether to elide rows from beginning, end or middle

Definition at line 82 of file sheet.h.

◆ sliceIndicator

std::string minsky::Sheet::sliceIndicator
private

offset for scrolling through higher ranked inputs

Definition at line 48 of file sheet.h.

◆ value

civita::TensorPtr minsky::Sheet::value
private

Definition at line 38 of file sheet.h.


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