LayoutWorker.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 #pragma once
25 
26 #include "Layout.h"
28 
29 #include <string>
30 
31 namespace armarx
32 {
33 
34  class LayoutWorker : public QObject
35  {
36  Q_OBJECT
37 
38  public:
39  /**
40  * @brief LayoutWorker Sets state and id as specified. Initializes an empty Graph.
41  * @param state The state which this worker layouts.
42  * @param id The worker's ID for communication with the LayoutController.
43  */
44  LayoutWorker(size_t workerId, QString name, GvcPtr gvContext);
45  ~LayoutWorker() override;
46 
47  signals:
48  /**
49  * @brief buildGraph Tells the StateModelLayoutMediator to build the first version of this graph
50  * @param graph The graph to be filled.
51  */
52  void buildGraph(LockableGraphPtr graph);
53 
54  /**
55  * @brief layoutingFinished Indicates that this worker finished its layout task.
56  */
57  void layoutingFinished();
58 
59  /**
60  * @brief deleteMe To be emitted when this worker ought to be deleted because
61  * its corresponding mediator was deleted.
62  * @param id This worker's id.
63  */
64  void deleteMe(size_t id);
65 
66  public slots:
67  /**
68  * @brief stateDeleted The corresponding state was deleted.
69  */
70  void stateDeleted();
71  /**
72  * @brief layout Starts layouting.
73  * @param layoutAll If true, layout edges and nodes, if false only layout edges.
74  */
75  //TODO: stat immer layoutAll mitzuschleppen könnte es vielleicht möglich sein immer nur
76  //neato auszuführen. Dann müssen allerdings alle schon mal positioniertennodes gepinnt sein.
77  //Außerdem muss neato -n benutzt werden damit positionen in points sind.
78  void layout(bool layoutAll);
79 
80  /**
81  * @brief isConnected Notifies that worker with id workerId is now connected to its mediator.
82  * If workerId is this worker's id, send a pointer to the graphviz graph to the mediator.
83  * @param workerId The id of the worker who is connected.
84  */
85  void isConnected(size_t workerId);
86 
87  private:
88  /**
89  * @brief id ID of this worker. Used for communication with the LayoutController.
90  */
91  size_t id;
92 
93  /**
94  * @brief graph Graph that is layouted by this worker and mutex to lock it.
95  */
96  LockableGraphPtr m_graph;
97 
98  /**
99  * @brief graphvizContext Context needed for layouting. Shared with all other workers.
100  */
101  GvcPtr graphvizContext;
102 
103 
104  /**
105  * @brief layout Layout the graph using the specified algorithm (e.g. dot, neato etc.).
106  * @param algorithm The layout algorithm.
107  */
108  void layoutWithAlgo(std::string algorithm);
109  QString name;
110  };
111 
112 } //namespace armarx
113 
armarx::LayoutWorker
Definition: LayoutWorker.h:34
armarx::GvcPtr
GVC_t * GvcPtr
Definition: Layout.h:39
armarx::LockableGraphPtr
std::shared_ptr< LockableGraph > LockableGraphPtr
Definition: Layout.h:64
armarx::LayoutWorker::layoutingFinished
void layoutingFinished()
layoutingFinished Indicates that this worker finished its layout task.
armarx::LayoutWorker::deleteMe
void deleteMe(size_t id)
deleteMe To be emitted when this worker ought to be deleted because its corresponding mediator was de...
armarx::LayoutWorker::isConnected
void isConnected(size_t workerId)
isConnected Notifies that worker with id workerId is now connected to its mediator.
Definition: LayoutWorker.cpp:130
StateModelLayoutMediator.h
Layout.h
armarx::LayoutWorker::LayoutWorker
LayoutWorker(size_t workerId, QString name, GvcPtr gvContext)
LayoutWorker Sets state and id as specified.
Definition: LayoutWorker.cpp:43
armarx::LayoutWorker::stateDeleted
void stateDeleted()
stateDeleted The corresponding state was deleted.
Definition: LayoutWorker.cpp:104
armarx::LayoutWorker::buildGraph
void buildGraph(LockableGraphPtr graph)
buildGraph Tells the StateModelLayoutMediator to build the first version of this graph
armarx::LayoutWorker::~LayoutWorker
~LayoutWorker() override
Definition: LayoutWorker.cpp:98
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::LayoutWorker::layout
void layout(bool layoutAll)
layout Starts layouting.
Definition: LayoutWorker.cpp:109