Minsky
minsky::VariablePane Class Reference

#include <variablePane.h>

Inheritance diagram for minsky::VariablePane:
Inheritance graph
Collaboration diagram for minsky::VariablePane:
Collaboration graph

Public Member Functions

 VariablePane ()
 
void select (VariableType::Type x)
 
void deselect (VariableType::Type x)
 
VariablePaneCellcell (unsigned row, unsigned col) override
 return reference to cell row, col. Reference is valid until next call to cell() More...
 
void updateWithHeight (unsigned height)
 update variables from model, given a window of height pixels More...
 
void update ()
 update variables from model, using previous height value More...
 
unsigned numRows () const override
 
unsigned numCols () const override
 
bool evenHeight () const override
 whether cells all have the same height or not More...
 
void moveCursorTo (double, double) override
 move current cursor to x,y More...
 
void mouseDown (float x, float y) override
 
- Public Member Functions inherited from minsky::Grid< VariablePaneCell >
virtual ~Grid ()=default
 
virtual JustificationStruct::Justification justification (unsigned col) const
 justification of col More...
 
void draw ()
 draw the grid More...
 
int colX (double x) const
 column at x in unzoomed coordinates More...
 
int rowY (double y) const
 row at y in unzoomed coordinates More...
 
- Public Member Functions inherited from minsky::PannableTab< VariablePaneBase >
 PannableTab ()
 
 PannableTab (A &arg)
 
void mouseDown (float x, float y) override
 
void mouseUp (float x, float y) override
 
void mouseMove (float x, float y) override
 
void moveTo (float x, float y) override
 
std::vector< float > position () const override
 
void zoom (double x, double y, double z) override
 
double zoomFactor () const override
 
- 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
 
virtual bool hasScrollBars () const
 return whether this window has scrollbars (needed for MacOSX). More...
 
- Public Member Functions inherited from minsky::EventInterface
virtual void controlMouseDown (float x, float y)
 
virtual bool keyPress (const KeyPressArgs &)
 handle key press over current itemFocus, More...
 
virtual bool getItemAt (float x, float y)
 item or wire obtained by get*At() calls More...
 
virtual bool getWireAt (float x, float y)
 item or wire obtained by get*At() calls More...
 

Public Attributes

bool shift =false
 true if shift pressed More...
 
std::set< Typeselection
 
- Public Attributes inherited from minsky::Grid< VariablePaneCell >
std::vector< double > rightColMargin
 coordinates of right and bottom margins of cells. Valid after draw() More...
 
std::vector< double > bottomRowMargin
 
- Public Attributes inherited from minsky::PannableTabBase
float offsx =0
 
float offsy =0
 
double m_zoomFactor =1
 
- 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 (VariablePane)
 
bool redraw (int, int, int width, int height) override
 

Private Attributes

unsigned m_numRows =0
 
unsigned m_numCols =0
 
classdesc::Exclude< std::vector< VariablePaneCell > > vars
 

Additional Inherited Members

- Public Types inherited from minsky::JustificationStruct
enum  Justification { left, right, centre }
 
- Public Types inherited from minsky::VariableType
enum  Type {
  undefined, constant, parameter, flow,
  integral, stock, tempFlow, numVarTypes
}
 
- Static Public Member Functions inherited from minsky::RenderNativeWindow
static double scaleFactor ()
 
- Static Public Member Functions inherited from minsky::VariableType
static std::string typeName (int t)
 
- Static Public Attributes inherited from minsky::RenderNativeWindow
static ecolab::cairo::Colour backgroundColour {0.8,0.8,0.8,1}
 

Detailed Description

Definition at line 51 of file variablePane.h.

Constructor & Destructor Documentation

◆ VariablePane()

Member Function Documentation

◆ cell()

VariablePaneCell & minsky::VariablePane::cell ( unsigned  row,
unsigned  col 
)
overridevirtual

return reference to cell row, col. Reference is valid until next call to cell()

Implements minsky::Grid< VariablePaneCell >.

Definition at line 70 of file variablePane.cc.

References m_numRows, and vars.

Referenced by mouseDown().

71  {
72  auto idx=row+m_numRows*col;
73  if (idx>=vars.size())
74  {
75  static VariablePaneCell emptyCell;
76  return emptyCell;
77  }
78  return vars[idx];
79  }
classdesc::Exclude< std::vector< VariablePaneCell > > vars
Definition: variablePane.h:54
Here is the caller graph for this function:

◆ CLASSDESC_ACCESS()

minsky::VariablePane::CLASSDESC_ACCESS ( VariablePane  )
private

◆ deselect()

void minsky::VariablePane::deselect ( VariableType::Type  x)
inline

Definition at line 62 of file variablePane.h.

References selection.

62 {selection.erase(x);}
std::set< Type > selection
Definition: variablePane.h:59

◆ evenHeight()

bool minsky::VariablePane::evenHeight ( ) const
inlineoverridevirtual

whether cells all have the same height or not

Reimplemented from minsky::Grid< VariablePaneCell >.

Definition at line 70 of file variablePane.h.

70 {return false;}

◆ mouseDown()

void minsky::VariablePane::mouseDown ( float  x,
float  y 
)
inlineoverridevirtual

Reimplemented from minsky::EventInterface.

Definition at line 72 of file variablePane.h.

References cell(), minsky::Grid< VariablePaneCell >::colX(), minsky::VariablePaneCell::emplace(), minsky::PannableTab< Base >::mouseDown(), minsky::PannableTabBase::offsx, minsky::PannableTabBase::offsy, minsky::Grid< VariablePaneCell >::rowY(), and shift.

72  {
74  cell(rowY(y-offsy),colX(x-offsx)).emplace();
75  }
bool shift
true if shift pressed
Definition: variablePane.h:58
void mouseDown(float x, float y) override
Definition: pannableTab.h:44
int colX(double x) const
column at x in unzoomed coordinates
Definition: grid.cc:103
int rowY(double y) const
row at y in unzoomed coordinates
Definition: grid.cc:112
VariablePaneCell & cell(unsigned row, unsigned col) override
return reference to cell row, col. Reference is valid until next call to cell()
Definition: variablePane.cc:70
Here is the call graph for this function:

◆ moveCursorTo()

void minsky::VariablePane::moveCursorTo ( double  x,
double  y 
)
overridevirtual

move current cursor to x,y

Implements minsky::Grid< VariablePaneCell >.

Definition at line 116 of file variablePane.cc.

References minsky::PannableTabBase::offsx, and minsky::PannableTabBase::offsy.

117  {
118  if (surface.get())
119  {
120  cairo_identity_matrix(surface->cairo());
121  cairo_translate(surface->cairo(), x+offsx, y+offsy);
122  }
123  }

◆ numCols()

unsigned minsky::VariablePane::numCols ( ) const
inlineoverridevirtual

Implements minsky::Grid< VariablePaneCell >.

Definition at line 69 of file variablePane.h.

References m_numCols.

69 {return m_numCols;}

◆ numRows()

unsigned minsky::VariablePane::numRows ( ) const
inlineoverridevirtual

Implements minsky::Grid< VariablePaneCell >.

Definition at line 68 of file variablePane.h.

References m_numRows.

68 {return m_numRows;}

◆ redraw()

bool minsky::VariablePane::redraw ( int  ,
int  ,
int  width,
int  height 
)
overrideprivate

Definition at line 105 of file variablePane.cc.

References minsky::Grid< Cell >::draw(), and vars.

106  {
107  if (surface.get()) {
108  cairo_t* cairo=surface->cairo();
109  for (auto& i: vars) i.reset(cairo);
110  cairo_identity_matrix(cairo);
112  }
113  return surface.get();
114  }
classdesc::Exclude< std::vector< VariablePaneCell > > vars
Definition: variablePane.h:54
void draw()
draw the grid
Definition: grid.cc:42
Here is the call graph for this function:

◆ select()

void minsky::VariablePane::select ( VariableType::Type  x)
inline

Definition at line 61 of file variablePane.h.

References selection.

61 {selection.insert(x);}
std::set< Type > selection
Definition: variablePane.h:59

◆ update()

void minsky::VariablePane::update ( )

update variables from model, using previous height value

Definition at line 89 of file variablePane.cc.

References minsky::cminsky(), m_numCols, m_numRows, selection, and vars.

Referenced by updateWithHeight().

90  {
91  if (!m_numRows) return;
92  vars.clear();
93  for (auto& v: cminsky().variableValues)
94  {
95  if (v.first.empty() || selection.contains(v.second->type())==0) continue; // ignore those filtered out
96  vars.emplace_back(*v.second);
97  }
98 
99  m_numCols=vars.size()/m_numRows+1;
100  const unsigned gridSize=m_numRows*m_numCols;
101  while (vars.size()<gridSize) vars.emplace_back();
102  if (surface.get()) surface->requestRedraw(); // TODO, plain requestRedraw doesn't work for Tk here...
103  }
std::set< Type > selection
Definition: variablePane.h:59
const Minsky & cminsky()
const version to help in const correctness
Definition: minsky.h:549
classdesc::Exclude< std::vector< VariablePaneCell > > vars
Definition: variablePane.h:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateWithHeight()

void minsky::VariablePane::updateWithHeight ( unsigned  height)

update variables from model, given a window of height pixels

Definition at line 81 of file variablePane.cc.

References m_numRows, and update().

82  {
83  const unsigned typicalHeight=38;
84  m_numRows=height/typicalHeight;
85  update();
86  }
void update()
update variables from model, using previous height value
Definition: variablePane.cc:89
Here is the call graph for this function:

Member Data Documentation

◆ m_numCols

unsigned minsky::VariablePane::m_numCols =0
private

Definition at line 53 of file variablePane.h.

Referenced by numCols(), and update().

◆ m_numRows

unsigned minsky::VariablePane::m_numRows =0
private

Definition at line 53 of file variablePane.h.

Referenced by cell(), numRows(), update(), and updateWithHeight().

◆ selection

std::set<Type> minsky::VariablePane::selection

Definition at line 59 of file variablePane.h.

Referenced by deselect(), select(), update(), and VariablePane().

◆ shift

bool minsky::VariablePane::shift =false

true if shift pressed

Definition at line 58 of file variablePane.h.

Referenced by mouseDown().

◆ vars

classdesc::Exclude<std::vector<VariablePaneCell> > minsky::VariablePane::vars
private

Definition at line 54 of file variablePane.h.

Referenced by cell(), redraw(), and update().


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