annotate engine/core/model/structures/layer.cpp @ 181:56ac89189bc4

fixed time handling in fife: - the time scaling method was unreliable when changing the time factors (jumping in the moment of the change) - replaced much calls to SDL_GetTicks with TimerManager::instance()->getTime() - some other time related cleanup
author spq@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 31 Jan 2009 04:15:43 +0000
parents 64e7fe3d4288
children 51cc05d862f2
rev   line source
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 /***************************************************************************
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2 * Copyright (C) 2005-2008 by the FIFE team *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 * http://www.fifengine.de *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 * This file is part of FIFE. *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 6
diff changeset
6 * FIFE is free software; you can redistribute it and/or *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 6
diff changeset
7 * modify it under the terms of the GNU Lesser General Public *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 6
diff changeset
8 * License as published by the Free Software Foundation; either *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 6
diff changeset
9 * version 2.1 of the License, or (at your option) any later version. *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 6
diff changeset
11 * This library is distributed in the hope that it will be useful, *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 6
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 6
diff changeset
14 * Lesser General Public License for more details. *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 6
diff changeset
16 * You should have received a copy of the GNU Lesser General Public *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 6
diff changeset
17 * License along with this library; if not, write to the *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 * Free Software Foundation, Inc., *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 6
diff changeset
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 ***************************************************************************/
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 // Standard C++ library includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 // 3rd party library includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25 #include <SDL.h>
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 // FIFE includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 // These includes are split up in two parts, separated by one empty line
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 // First block: files included from the FIFE root src directory
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 // Second block: files included from the same folder
92
746df66978da * Fix by Sleek & GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 91
diff changeset
31 #include "util/log/logger.h"
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32 #include "util/structures/purge.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 #include "layer.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 #include "instance.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 #include "map.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 #include "instancetree.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39 namespace FIFE {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40
92
746df66978da * Fix by Sleek & GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 91
diff changeset
41 static Logger _log(LM_STRUCTURES);
746df66978da * Fix by Sleek & GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 91
diff changeset
42
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 Layer::Layer(const std::string& identifier, Map* map, CellGrid* grid)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 : m_id(identifier),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 m_map(map),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 m_instances_visibility(true),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 m_instanceTree(new InstanceTree()),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
48 m_grid(grid),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 m_pathingstrategy(CELL_EDGES_ONLY),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 m_changelisteners(),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 m_changedinstances(),
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52 m_changed(false) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 Layer::~Layer() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56 purge(m_instances);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57 delete m_instanceTree;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60 bool Layer::hasInstances() const {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 return !m_instances.empty();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64 Instance* Layer::createInstance(Object* object, const ModelCoordinate& p, const std::string& id) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65 ExactModelCoordinate emc(static_cast<double>(p.x), static_cast<double>(p.y), static_cast<double>(p.z));
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66 return createInstance(object, emc, id);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68
92
746df66978da * Fix by Sleek & GreyGhost
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 91
diff changeset
69 Instance* Layer::createInstance(Object* object, const ExactModelCoordinate& p, const std::string& id) {
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
70 Location l;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 l.setLayer(this);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 l.setExactLayerCoordinates(p);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74 Instance* instance = new Instance(object, l, id);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75 m_instances.push_back(instance);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76 m_instanceTree->addInstance(instance);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78 std::vector<LayerChangeListener*>::iterator i = m_changelisteners.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79 while (i != m_changelisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80 (*i)->onInstanceCreate(this, instance);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83 m_changed = true;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84 return instance;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
85 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
86
90
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
87 bool Layer::addInstance(Instance* instance, const ExactModelCoordinate& p){
91
e7b55b2b398f Corrected Layer::addInstance() to return appropriate bool. Added the function to layer.i for swig
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 90
diff changeset
88 if( !instance ){
90
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
89 FL_ERR(_log, "Tried to add an instance to layer, but given instance is invalid");
91
e7b55b2b398f Corrected Layer::addInstance() to return appropriate bool. Added the function to layer.i for swig
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 90
diff changeset
90 return false;
e7b55b2b398f Corrected Layer::addInstance() to return appropriate bool. Added the function to layer.i for swig
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 90
diff changeset
91 }
e7b55b2b398f Corrected Layer::addInstance() to return appropriate bool. Added the function to layer.i for swig
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 90
diff changeset
92
90
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
93 Location l;
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
94 l.setLayer(this);
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
95 l.setExactLayerCoordinates(p);
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
96
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
97 m_instances.push_back(instance);
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
98 m_instanceTree->addInstance(instance);
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
99
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
100 std::vector<LayerChangeListener*>::iterator i = m_changelisteners.begin();
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
101 while (i != m_changelisteners.end()) {
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
102 (*i)->onInstanceCreate(this, instance);
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
103 ++i;
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
104 }
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
105 m_changed = true;
91
e7b55b2b398f Corrected Layer::addInstance() to return appropriate bool. Added the function to layer.i for swig
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 90
diff changeset
106 return true;
90
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
107 }
9855464762c1 Layer::addInstance for moving instances around layers. Useful when we have multi-level buildings.
Sleek@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
108
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
109 void Layer::deleteInstance(Instance* instance) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
110 std::vector<LayerChangeListener*>::iterator i = m_changelisteners.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111 while (i != m_changelisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112 (*i)->onInstanceDelete(this, instance);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
114 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116 std::vector<Instance*>::iterator it = m_instances.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117 for(; it != m_instances.end(); ++it) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118 if(*it == instance) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 m_instanceTree->removeInstance(*it);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 delete *it;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121 m_instances.erase(it);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 break;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
124 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
125 m_changed = true;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
127
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
128 Instance* Layer::getInstance(const std::string& id) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
129 std::vector<Instance*>::iterator it = m_instances.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
130 for(; it != m_instances.end(); ++it) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
131 if((*it)->getId() == id)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
132 return *it;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
133 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135 throw NotFound(id);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
137
99
64e7fe3d4288 - added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 92
diff changeset
138 std::vector<Instance*> Layer::getInstances(const std::string& id) {
64e7fe3d4288 - added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 92
diff changeset
139 std::vector<Instance*> matching_instances;
64e7fe3d4288 - added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 92
diff changeset
140 std::vector<Instance*>::iterator it = m_instances.begin();
64e7fe3d4288 - added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 92
diff changeset
141 for(; it != m_instances.end(); ++it) {
64e7fe3d4288 - added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 92
diff changeset
142 if((*it)->getId() == id)
64e7fe3d4288 - added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 92
diff changeset
143 matching_instances.push_back(*it);
64e7fe3d4288 - added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 92
diff changeset
144 }
64e7fe3d4288 - added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 92
diff changeset
145 return matching_instances;
64e7fe3d4288 - added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 92
diff changeset
146 }
64e7fe3d4288 - added possibility to change instance ids
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 92
diff changeset
147
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 void Layer::getMinMaxCoordinates(ModelCoordinate& min, ModelCoordinate& max, const Layer* layer) const {
6
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
149 if (!layer) {
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150 layer = this;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
151 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
152
6
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
153 bool first_found = false;
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
154 for (std::vector<Instance*>::const_iterator i = m_instances.begin(); i != m_instances.end(); ++i) {
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
155 if (!first_found) {
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
156 min = m_instances.front()->getLocationRef().getLayerCoordinates(layer);
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
157 max = min;
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
158 first_found = true;
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
159 } else {
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
160 ModelCoordinate coord = (*i)->getLocationRef().getLayerCoordinates(layer);
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
161
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
162 if(coord.x < min.x) {
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
163 min.x = coord.x;
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
164 }
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
165
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
166 if(coord.x > max.x) {
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
167 max.x = coord.x;
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
168 }
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
169
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
170 if(coord.y < min.y) {
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
171 min.y = coord.y;
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
172 }
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
173
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
174 if(coord.y > max.y) {
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
175 max.y = coord.y;
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
176 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
177 }
6
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
178 }
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
179 if (!first_found) {
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
180 min = ModelCoordinate();
61fdc090b0d4 both techdemo maps are now loaded correctly. Still segfaulting when scripts end
jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
181 max = min;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
182 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
184
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185 void Layer::setInstancesVisible(bool vis) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
186 m_instances_visibility = vis;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
187 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
188 void Layer::toggleInstancesVisible() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
189 m_instances_visibility = !m_instances_visibility;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
190 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
191
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
192 bool Layer::cellContainsBlockingInstance(const ModelCoordinate& cellCoordinate) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
193 std::list<Instance*> adjacentInstances;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
194 m_instanceTree->findInstances(cellCoordinate, 0, 0, adjacentInstances);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
195 bool blockingInstance = false;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
196 for(std::list<Instance*>::const_iterator j = adjacentInstances.begin(); j != adjacentInstances.end(); ++j) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
197 if((*j)->getObject()->isBlocking() && (*j)->getLocationRef().getLayerCoordinates() == cellCoordinate) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
198 blockingInstance = true;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
199 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
200 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
201 return blockingInstance;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
202 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
203
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
204 bool Layer::update() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
205 m_changedinstances.clear();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
206 std::vector<Instance*>::iterator it = m_instances.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
207 for(; it != m_instances.end(); ++it) {
181
56ac89189bc4 fixed time handling in fife:
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 99
diff changeset
208 if ((*it)->update() != ICHANGE_NO_CHANGES) {
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
209 m_changedinstances.push_back(*it);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
210 m_changed = true;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
211 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
212 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
213 if (!m_changedinstances.empty()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
214 std::vector<LayerChangeListener*>::iterator i = m_changelisteners.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
215 while (i != m_changelisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
216 (*i)->onLayerChanged(this, m_changedinstances);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
217 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
218 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
219 //std::cout << "Layer named " << Id() << " changed = 1\n";
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
220 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
221 //std::cout << "Layer named " << Id() << " changed = 0\n";
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
222 bool retval = m_changed;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
223 m_changed = false;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
224 return retval;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
225 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
226
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
227 void Layer::addChangeListener(LayerChangeListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
228 m_changelisteners.push_back(listener);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
229 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
230
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
231 void Layer::removeChangeListener(LayerChangeListener* listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
232 std::vector<LayerChangeListener*>::iterator i = m_changelisteners.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
233 while (i != m_changelisteners.end()) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
234 if ((*i) == listener) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
235 m_changelisteners.erase(i);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
236 return;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
237 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
238 ++i;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
239 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
240 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
241 } // FIFE