1 // Copyright (C) 2006-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef _LINKMATRIX_HXX_
21 #define _LINKMATRIX_HXX_
40 class AbstractSceneItem;
42 class SceneComposedNodeItem;
49 LNode(int x, int y) : _x(x), _y(y) {};
50 LNode(std::pair<int,int> m) : _x(m.first), _y(m.second) {};
52 inline int getX() const {return _x; };
53 inline int getY() const {return _y; };
54 inline std::pair<int,int> getPos() const { return std::pair<int,int>(_x, _y); };
55 inline bool isEqual(const LNode& o) const { return ((_x == o._x) && (_y == o._y)); };
56 double distance(const LNode& o) const;
62 typedef std::list<LNode> LNodePath;
66 std::pair<int,int> from;
67 std::pair<int,int> to;
68 YACS::HMI::SceneLinkItem* item;
77 typedef std::list<linkPoint> LinkPath;
82 LinkMatrix(SceneComposedNodeItem* bloc);
83 virtual ~LinkMatrix();
86 void explore(AbstractSceneItem *child, bool setObstacle=false);
87 void defineCost(AbstractSceneItem *child);
88 void getBoundingBox(SceneItem *obstacle, int margin, bool setObstacle=false);
89 std::pair<int,int> cellFrom(YACS::ENGINE::OutPort* outp);
90 std::pair<int,int> cellFrom(YACS::ENGINE::OutGate* outp);
91 std::pair<int,int> cellTo(YACS::ENGINE::InPort* inp);
92 std::pair<int,int> cellTo(YACS::ENGINE::InGate* inp);
93 std::list<linkdef> getListOfCtrlLinkDef();
94 std::list<linkdef> getListOfDataLinkDef();
95 LinkPath getPath(LNodePath lnp);
96 void incrementCost(LNodePath lnp);
98 inline int cost(int i, int j) const { return _cost[i*_jm +j]; };
99 inline int imax() const { return _im; };
100 inline int jmax() const { return _jm; };
103 SceneComposedNodeItem* _bloc;
107 std::set<double> _sxm;
108 std::set<double> _sym;
109 std::vector<double> _xm;
110 std::vector<double> _ym;
111 std::map<double,int> _x2i;
112 std::map<double,int> _y2j;
113 std::vector<int> _cost;
114 QtGuiContext* _context;