Version: 9.16.0
LinkMatrix.hxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
2//
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, or (at your option) any later version.
7//
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.
12//
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
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef _LINKMATRIX_HXX_
21#define _LINKMATRIX_HXX_
22
23#include <vector>
24#include <set>
25#include <map>
26#include <list>
27
28namespace YACS
29{
30 namespace ENGINE
31 {
32 class OutPort;
33 class InPort;
34 class OutGate;
35 class InGate;
36 }
37
38 namespace HMI
39 {
40 class AbstractSceneItem;
41 class SceneItem;
42 class SceneComposedNodeItem;
43 class SceneLinkItem;
44 class QtGuiContext;
45
46 class LNode
47 {
48 public:
49 LNode(int x, int y) : _x(x), _y(y) {};
50 LNode(std::pair<int,int> m) : _x(m.first), _y(m.second) {};
51 virtual ~LNode() {};
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;
57 protected:
58 int _x;
59 int _y;
60 };
61
62 typedef std::list<LNode> LNodePath;
63
64 struct linkdef
65 {
66 std::pair<int,int> from;
67 std::pair<int,int> to;
69 };
70
71 struct linkPoint
72 {
73 double x;
74 double y;
75 };
76
77 typedef std::list<linkPoint> LinkPath;
78
80 {
81 public:
83 virtual ~LinkMatrix();
84 void compute();
85 void addRowCols();
86 void explore(AbstractSceneItem *child, bool setObstacle=false);
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();
96 void incrementCost(LNodePath lnp);
97
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; };
101
102 protected:
104 int _im;
105 int _jm;
106 double _pas;
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;
115 };
116 }
117}
118
119#endif
int getX() const
Definition: LinkMatrix.hxx:52
LNode(std::pair< int, int > m)
Definition: LinkMatrix.hxx:50
double distance(const LNode &o) const
Definition: LinkMatrix.cxx:42
bool isEqual(const LNode &o) const
Definition: LinkMatrix.hxx:55
virtual ~LNode()
Definition: LinkMatrix.hxx:51
LNode(int x, int y)
Definition: LinkMatrix.hxx:49
int getY() const
Definition: LinkMatrix.hxx:53
std::pair< int, int > getPos() const
Definition: LinkMatrix.hxx:54
std::list< linkdef > getListOfCtrlLinkDef()
Definition: LinkMatrix.cxx:241
SceneComposedNodeItem * _bloc
Definition: LinkMatrix.hxx:103
std::list< linkdef > getListOfDataLinkDef()
Definition: LinkMatrix.cxx:262
std::vector< double > _ym
Definition: LinkMatrix.hxx:110
void getBoundingBox(SceneItem *obstacle, int margin, bool setObstacle=false)
Definition: LinkMatrix.cxx:364
std::pair< int, int > cellTo(YACS::ENGINE::InPort *inp)
Definition: LinkMatrix.cxx:178
void defineCost(AbstractSceneItem *child)
LinkMatrix(SceneComposedNodeItem *bloc)
Definition: LinkMatrix.cxx:50
LinkPath getPath(LNodePath lnp)
Definition: LinkMatrix.cxx:283
QtGuiContext * _context
Definition: LinkMatrix.hxx:114
std::vector< int > _cost
Definition: LinkMatrix.hxx:113
std::vector< double > _xm
Definition: LinkMatrix.hxx:109
std::set< double > _sxm
Definition: LinkMatrix.hxx:107
std::map< double, int > _y2j
Definition: LinkMatrix.hxx:112
std::set< double > _sym
Definition: LinkMatrix.hxx:108
void incrementCost(LNodePath lnp)
Definition: LinkMatrix.cxx:319
std::map< double, int > _x2i
Definition: LinkMatrix.hxx:111
void explore(AbstractSceneItem *child, bool setObstacle=false)
Definition: LinkMatrix.cxx:340
std::pair< int, int > cellFrom(YACS::ENGINE::OutPort *outp)
Definition: LinkMatrix.cxx:115
int cost(int i, int j) const
Definition: LinkMatrix.hxx:98
std::list< LNode > LNodePath
Definition: LinkMatrix.hxx:62
std::list< linkPoint > LinkPath
Definition: LinkMatrix.hxx:77
YACS::HMI::SceneLinkItem * item
Definition: LinkMatrix.hxx:68
std::pair< int, int > from
Definition: LinkMatrix.hxx:66
std::pair< int, int > to
Definition: LinkMatrix.hxx:67