Minsky
variableInstanceList.cc
Go to the documentation of this file.
1 /*
2  @copyright Steve Keen 2020
3  @author Russell Standish
4  This file is part of Minsky.
5 
6  Minsky is free software: you can redistribute it and/or modify it
7  under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Minsky is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Minsky. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "minsky.h"
21 #include "group.h"
22 #include "selection.h"
23 #include "variableInstanceList.h"
24 #include "variableInstanceList.rcd"
25 #include "variableInstanceList.xcd"
26 #include "minsky_epilogue.h"
27 
28 using namespace std;
29 
30 namespace minsky
31 {
32  // should not really be used, but compiler requuires it
33  VariableInstanceList::VariableInstanceList(): model(*minsky().model) {}
34 
36  model(model)
37  {
39  (&Group::items,
40  [this,&valueId](const Items&, Items::const_iterator i) {
41  if (const auto* v=(*i)->variableCast())
42  if (v->valueId()==valueId)
43  {
44  if (auto controller=v->controller.lock())
45  bookmarks.emplace_back(this->model.x()-controller->left()+50, this->model.y()-controller->top()+50, controller->zoomFactor(),
46  v->name()+"@("+to_string(int(v->x()))+","+to_string(int(v->y()))+")");
47  else
48  bookmarks.emplace_back(this->model.x()-v->left()+50, this->model.y()-v->top()+50, v->zoomFactor(),
49  v->name()+"@("+to_string(int(v->x()))+","+to_string(int(v->y()))+")");
50  items.push_back(*i);
51  }
52  return false;
53  });
54  }
55 
57  if (i<bookmarks.size())
58  {
59  assert(bookmarks.size()==items.size());
63  minsky().resetScroll();
64  }
65  }
66 
67 }
68 
void gotoInstance(std::size_t)
zoom model to instance number in the list
virtual float x() const
Definition: item.cc:107
virtual float y() const
Definition: item.cc:114
STL namespace.
CLASSDESC_ACCESS_EXPLICIT_INSTANTIATION(minsky::VariableInstanceList)
string valueId(const string &name)
construct a valueId from fully qualified name @ name should not be canonicalised
Definition: valueId.cc:75
bool recursiveDo(M GroupItems::*map, O op) const
Perform action heirarchically on elements of map map. If op returns true, the operation terminates...
Definition: group.h:111
Creation and access to the minskyTCL_obj object, which has code to record whenever Minsky&#39;s state cha...
Definition: constMap.h:22
std::vector< ItemPtr > Items
Definition: item.h:366
Canvas canvas
Definition: minsky.h:256
void gotoBookmark_b(const Bookmark &b)
Definition: group.cc:1244
std::vector< ItemPtr > items
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
virtual void resetScroll()
reset main window scroll bars after model has been panned
Definition: minsky.h:453
Selection selection
Definition: canvas.h:105
std::vector< Bookmark > bookmarks
string to_string(CONST84 char *x)
Definition: minskyTCLObj.h:33
Minsky & minsky()
global minsky object
Definition: minskyTCL.cc:51