Minsky
schema3 Namespace Reference

Namespaces

 anonymous_namespace{schema3.cc}
 

Classes

struct  ExcludedMinsky
 working structure, not serialised More...
 
struct  Group
 
struct  IdMap
 
struct  Item
 
struct  ItemBase
 
struct  LockGroup
 
struct  LockGroupFactory
 
class  Minsky
 
struct  MinskyImpl
 
struct  MinskyItemFactory
 
struct  Note
 
struct  PhillipsDiagram
 
struct  PhillipsFlow
 
struct  PublicationItem
 
struct  PublicationTab
 
struct  Schema1Layout
 
struct  Slider
 
struct  Wire
 

Functions

void pack (classdesc::pack_t &b, const civita::XVector &a)
 
void unpack (classdesc::pack_t &b, civita::XVector &a)
 
void pack (classdesc::pack_t &b, const civita::TensorVal &a)
 
void unpack (classdesc::pack_t &b, civita::TensorVal &a)
 
void populateNote (minsky::NoteBase &x, const Note &y)
 
void populateItem (minsky::Item &x, const Item &y)
 
void populateWire (minsky::Wire &x, const Wire &y)
 

Function Documentation

◆ pack() [1/2]

void schema3::pack ( classdesc::pack_t &  b,
const civita::XVector &  a 
)

Definition at line 40 of file schema3.cc.

References minsky::str().

41  {
42  b<<a.name<<a.dimension<<uint64_t(a.size());
43  for (const auto& i: a)
44  b<<civita::str(i,a.dimension.units);
45  }
std::string str(T x)
utility function to create a string representation of a numeric type
Definition: str.h:33
Here is the call graph for this function:

◆ pack() [2/2]

void schema3::pack ( classdesc::pack_t &  b,
const civita::TensorVal &  a 
)

Definition at line 60 of file schema3.cc.

References pack().

61  {
62  b<<uint64_t(a.size());
63  for (auto i: a)
64  b<<i;
65  b<<uint64_t(a.index().size());
66  for (auto i: a.index())
67  b<<uint64_t(i);
68 
69  b<<uint64_t(a.hypercube().xvectors.size());
70  for (const auto& i: a.hypercube().xvectors)
71  pack(b, i);
72  }
void pack(classdesc::pack_t &, const classdesc::string &, classdesc::ref< ecolab::urand > &)
Here is the call graph for this function:

◆ populateItem()

void schema3::populateItem ( minsky::Item x,
const Item y 
)

Definition at line 475 of file schema3.cc.

References minsky::PlotOptions< Base >::applyPlotOptions(), schema3::Item::arg, schema3::Item::assetClasses, schema3::Item::axis, minsky::NoteBase::bookmark, schema3::ItemBase::bookmark, schema3::Item::bookmarks, schema3::Item::buttonDisplay, schema3::Item::currency, schema3::Item::data, schema3::Item::dataOpData, schema3::Item::dimensions, schema3::Item::editorMode, schema3::Item::expression, minsky::flipped(), schema3::ItemBase::height, minsky::Item::iHeight(), minsky::Item::iWidth(), minsky::Item::m_sf, minsky::Item::m_x, minsky::Item::m_y, schema3::Item::miniPlot, minsky::PlotOptions< Base >::name, schema3::Item::palette, populateNote(), schema3::ItemBase::ports, schema3::Item::ravelState, schema3::ItemBase::rotation, minsky::Item::rotation(), schema3::ItemBase::scaleFactor, schema3::Item::showColSlice, schema3::Item::showSlice, schema3::Item::slider, schema2::RavelState::toRavelRavelState(), schema3::Item::variableDisplay, schema3::ItemBase::width, schema3::ItemBase::x, and schema3::ItemBase::y.

Referenced by schema3::Minsky::populateGroup(), schema3::PhillipsDiagram::populatePhillipsDiagram(), and schema3::Minsky::populatePublicationTabs().

476  {
477  populateNote(x,y);
478  x.m_x=y.x;
479  x.m_y=y.y;
480  x.m_sf=y.scaleFactor;
481  x.rotation(y.rotation);
482  x.iWidth(y.width);
483  x.iHeight(y.height);
484  x.bookmark=y.bookmark;
485  if (auto* x1=dynamic_cast<minsky::DataOp*>(&x))
486  {
487  if (y.name)
488  x1->description(*y.name);
489  if (y.dataOpData)
490  x1->data=*y.dataOpData;
491  }
492  if (auto* x1=dynamic_cast<minsky::UserFunction*>(&x))
493  {
494  if (y.name)
495  x1->description(*y.name);
496  if (y.expression)
497  x1->expression=*y.expression;
498  }
499 
500  if (auto* x1=dynamic_cast<minsky::Ravel*>(&x))
501  {
502  if (y.ravelState)
503  {
504  x1->applyState(y.ravelState->toRavelRavelState());
505  x1->redistributeHandles();
506  SchemaHelper::initHandleState(*x1,y.ravelState->toRavelRavelState());
507  }
508 
509  if (y.dimensions)
510  x1->axisDimensions=*y.dimensions;
511  if (y.editorMode && *y.editorMode!=x1->editorMode())
512  x1->toggleEditorMode();
513  x1->flipped=minsky::flipped(y.rotation);
514  }
515  if (auto* x1=dynamic_cast<minsky::Lock*>(&x))
516  {
517  if (y.ravelState)
518  {
519  x1->lockedState=y.ravelState->toRavelRavelState();
520  x1->tooltip(ravel::Ravel::description(x1->lockedState));
521  }
522  }
523  if (auto* x1=dynamic_cast<minsky::VariableBase*>(&x))
524  {
525  if (y.name)
526  x1->name(*y.name);
527  if (y.slider)
528  {
529  x1->sliderStepRel(y.slider->stepRel);
530  x1->enableSlider(y.slider->visible);
531  x1->sliderMin(y.slider->min);
532  x1->sliderMax(y.slider->max);
533  x1->sliderStep(y.slider->step);
534  }
535  x1->miniPlotEnabled(y.miniPlot);
536  // variableValue attributes populated later once variable is homed in its group
537  }
538  if (auto* x1=dynamic_cast<minsky::OperationBase*>(&x))
539  {
540  if (y.axis) x1->axis=*y.axis;
541  if (y.arg) x1->arg=*y.arg;
542  }
543  if (auto* x1=dynamic_cast<minsky::GodleyIcon*>(&x))
544  {
545  std::vector<std::vector<std::string>> data;
546  std::vector<minsky::GodleyAssetClass::AssetClass> assetClasses;
547  if (y.data) data=*y.data;
548  if (y.assetClasses) assetClasses=*y.assetClasses;
549  SchemaHelper::setPrivates(*x1,data,assetClasses);
550  try
551  {
552  x1->table.orderAssetClasses();
553  }
554  catch (const std::exception&) {}
555  if (y.name) x1->table.title=*y.name;
556  if (y.editorMode && *y.editorMode!=x1->editorMode())
557  x1->toggleEditorMode();
558  if (y.variableDisplay)
559  SchemaHelper::setVariableDisplay(*x1, *y.variableDisplay);
560  if (y.buttonDisplay && *y.buttonDisplay!=x1->buttonDisplay())
561  x1->toggleButtons();
562  if (y.currency) x1->currency=*y.currency;
563  }
564  if (auto* x1=dynamic_cast<minsky::PlotWidget*>(&x))
565  {
566  x1->bb.update(*x1);
567  if (y.name) x1->title=*y.name;
568  y.applyPlotOptions(*x1);
569  if (y.palette) x1->palette=*y.palette;
570  if (y.ports.size()>x1->nBoundsPorts)
571  x1->numLines((y.ports.size()-x1->nBoundsPorts)/4);
572  }
573  if (auto* x1=dynamic_cast<minsky::Sheet*>(&x))
574  {
575  if (y.showSlice)
576  x1->showRowSlice=*y.showSlice;
577  if (y.showColSlice)
578  x1->showColSlice=*y.showColSlice;
579  }
580  if (auto* x1=dynamic_cast<minsky::SwitchIcon*>(&x))
581  {
582  x1->flipped=minsky::flipped(y.rotation);
583  if (y.ports.size()>=2)
584  x1->setNumCases(y.ports.size()-2);
585  }
586  if (auto* x1=dynamic_cast<minsky::Group*>(&x))
587  {
588  x1->bb.update(*x1);
589  if (y.name) x1->title=*y.name;
590  if (y.bookmarks)
591  {
592  x1->bookmarks.clear();
593  x1->bookmarks.insert(y.bookmarks->begin(), y.bookmarks->end());
594  }
595  }
596  }
float iHeight() const
Definition: item.h:224
float m_sf
scale factor of item on canvas, or within group
Definition: item.h:174
void populateNote(minsky::NoteBase &x, const Note &y)
Definition: schema3.cc:467
bool flipped(double rotation)
returns if the angle (in degrees) is in the second or third quadrant
Definition: geometry.h:102
float iWidth() const
Definition: item.h:217
bool bookmark
Is this item also a bookmark?
Definition: noteBase.h:33
float m_y
position in canvas, or within group
Definition: item.h:173
float m_x
Definition: item.h:173
double rotation() const
Definition: item.h:211
Here is the call graph for this function:
Here is the caller graph for this function:

◆ populateNote()

void schema3::populateNote ( minsky::NoteBase x,
const Note y 
)

Definition at line 467 of file schema3.cc.

References minsky::NoteBase::detailedText(), schema3::Note::detailedText, minsky::NoteBase::tooltip(), and schema3::Note::tooltip.

Referenced by schema3::Minsky::populateGroup(), populateItem(), and populateWire().

468  {
469  if (y.detailedText && !y.detailedText->empty())
470  x.detailedText(*y.detailedText);
471  if (y.tooltip && !y.tooltip->empty())
472  x.tooltip(*y.tooltip);
473  }
virtual std::string const & tooltip() const
Definition: noteBase.h:36
virtual std::string const & detailedText() const
Definition: noteBase.h:34
Here is the call graph for this function:
Here is the caller graph for this function:

◆ populateWire()

void schema3::populateWire ( minsky::Wire x,
const Wire y 
)

Definition at line 598 of file schema3.cc.

References minsky::Wire::coords(), schema3::Wire::coords, and populateNote().

Referenced by schema3::Minsky::populateGroup(), and schema3::PhillipsDiagram::populatePhillipsDiagram().

599  {
600  populateNote(x,y);
601  if (y.coords)
602  x.coords(*y.coords);
603  }
void populateNote(minsky::NoteBase &x, const Note &y)
Definition: schema3.cc:467
std::vector< float > coords() const
display coordinates
Definition: wire.cc:45
Here is the call graph for this function:
Here is the caller graph for this function:

◆ unpack() [1/2]

void schema3::unpack ( classdesc::pack_t &  b,
civita::XVector &  a 
)

Definition at line 47 of file schema3.cc.

48  {
49  uint64_t size;
50  std::string x;
51  a.clear();
52  b>>a.name>>a.dimension>>size;
53  for (size_t i=0; i<size; ++i)
54  {
55  b>>x;
56  a.push_back(x);
57  }
58  }

◆ unpack() [2/2]

void schema3::unpack ( classdesc::pack_t &  b,
civita::TensorVal &  a 
)

Definition at line 75 of file schema3.cc.

References unpack().

76  {
77  uint64_t sz;
78  b>>sz;
79  vector<double> data;
80  for (size_t i=0; i<sz; ++i)
81  {
82  data.emplace_back();
83  b>>data.back();
84  }
85  b>>sz;
86  set<size_t> index;
87  for (size_t i=0; i<sz; ++i)
88  {
89  uint64_t x;
90  b>>x;
91  index.insert(x);
92  }
93 
94  b>>sz;
95  civita::Hypercube hc;
96 
97  for (size_t i=0; i<sz; ++i)
98  {
99  civita::XVector xv;
100  unpack(b,xv);
101  hc.xvectors.push_back(xv);
102  }
103  assert(std::find_if(index.begin(),index.end(),[&](size_t i){return i>=hc.numElements();})==index.end());
104  a.index(std::move(index)); //NOLINT
105  a.hypercube(std::move(hc)); //dimension data
106  assert(a.size()==data.size());
107  memcpy(a.begin(),data.data(),data.size()*sizeof(data[0]));
108  }
void unpack(classdesc::pack_t &, const classdesc::string &, classdesc::ref< ecolab::urand > &)
Here is the call graph for this function: