Maximum Acyclic Subgraph - Multiple Sequence Alignment
MaximumAcyclicSubgraph
GraphRenderer.h
1 #ifndef GraphRenderer_H_
2 #define GraphRenderer_H_
3 
4 #include <SFML/Graphics.hpp>
5 #include <SFML/Window.hpp>
6 #include <SFML/Graphics/RectangleShape.hpp>
7 #include <vector>
8 #include <string>
9 #include <stdlib.h>
10 #include <cmath>
11 #include <string>
12 #include "colorlist.h"
13 #include "colormap.h"
14 #include "../alignment/Graph.h"
15 #include "../alignment/Edge.h"
16 #include "../alignment/State.h"
17 #include "../alignment/DrawNode.h"
18 #include "ArrowShape.h"
19 #include "FuncArrowShape.h"
20 #include "Button.h"
21 #include "../GameMain/Gamemaster.h"
22 
44  struct TextProps {
45  std::string kmer;
46  sf::Color col;
47  vector<int> pos;
48  int charSize;
49  };
50  protected:
51  std::vector<FuncArrowShape> consistentEdges;
52  std::vector<FuncArrowShape> selectedEdges;
53  std::vector<ArrowShape> rowArrows;
54  std::vector<std::vector<sf::RectangleShape>> rects;
55  std::vector<TextProps> txt;
56  sf::Vector2i hoverPosition;
57  sf::Vector2i clickPosition;
58  sf::Color colorOfClickedNode;
59  unsigned maxNodesPerRow;
60  unsigned maxSequences;
62  float offset;
63  float moveConstant;
64  vector<float> boundary;
65  vector<float> direction;
66 
67  private:
68  bool animate;
69  bool nodeHovered;
70  bool nodeClicked;
71  bool edgeHovered;
72  float AnimationStep;
73  float AnimationSpeed;
74  int hoveredEdgeIndex;
75  vector<DrawNode> new_nodes;
76  vector<DrawNode> old_nodes;
77  sf::View actualView;
78  sf::View defaultView;
79 
80  std::vector<DrawNode> updateDrawNode(vector<Node>& nodeList);
81 
82  void initShapes(const vector<DrawNode>& Nodes, const vector<Node>& nodeList);
83  void setCoords(const vector<DrawNode>& Nodes, const vector<Node>& nodeList);
84 
91  void drawShape(sf::RenderWindow& window);
92 
99  void drawText(sf::RenderWindow& window);
100 
107  void moveWindow(int dir);
108 
116  void showEdges(vector<Node>& nodeList, vector<DrawNode>& Nodes, sf::Vector2f pos, state& gameState);
117 
122  void selectEdge(vector<Node>& nodeList, Gamemaster& gamemaster);
123 
130  void hoverNode(vector<Node>& nodeList, vector<DrawNode>& Nodes, sf::Vector2f pos);
131 
136  void deHoverNode();
137 
144  void hoverEdge(sf::Vector2f pos);
145 
150  void deHoverEdge();
151 
158  void clickNode(vector<Node>& nodeList, vector<DrawNode>& Nodes, sf::Vector2f pos);
159 
164  void deClickNode();
165 
175  Node* positionToNode(sf::Vector2f pos, vector<Node>& nodeList, vector<DrawNode>& Nodes);
176 
184  sf::Vector2f positionToCoords(sf::Vector2f pos);
185 
192  bool isPositionEdge(sf::Vector2f pos);
193 
200  bool isPositionNode(sf::Vector2f pos, vector<DrawNode>& Nodes, vector<Node>& nodeList);
201 
211  public:
212 
221  GraphRenderer(sf::RenderWindow& window, Gamemaster& gamemaster, float xoffset);
222 
227  GraphRenderer();
228 
235  void render(sf::RenderWindow& window, vector<DrawNode>& Nodes, vector<Node>& nodeList);
236 
247  void eventHandler(const sf::Event event, sf::RenderWindow& window, vector<Node>& nodeList,
248  Gamemaster& gamemaster, const sf::Vector2f& mouse_pos);
249 
256  void display_score(sf::RenderWindow& window, const state& gamestate);
257 
264  void update(float delta);
265 
274  void animation(sf::RenderWindow& window, Gamemaster& gamemaster, vector<Node>& nodeList, Button& menuButton);
275 
280  bool getAnimate();
281 
282  void updateBoundaries(const vector<DrawNode>& Nodes);
283 };
284 
285 #endif //GraphRenderer_H_
std::vector< FuncArrowShape > consistentEdges
vector of FuncArrowShapes which represent consistent edges
Definition: GraphRenderer.h:51
std::vector< ArrowShape > rowArrows
vector of ArrowShapes which get drawed only in a row
Definition: GraphRenderer.h:53
void animation(sf::RenderWindow &window, Gamemaster &gamemaster, vector< Node > &nodeList, Button &menuButton)
Definition: GraphRenderer.cc:525
Definition: Node.h:8
float offset
a constant which make a offset on the upper horizontal
Definition: GraphRenderer.h:62
Definition: Gamemaster.h:11
unsigned maxNodesPerRow
an upper bound for the row lengths
Definition: GraphRenderer.h:59
void display_score(sf::RenderWindow &window, const state &gamestate)
Definition: GraphRenderer.cc:86
This class generate a button for the GUI.
Definition: Button.h:13
unsigned maxSequences
an upper boudn for the column lengths
Definition: GraphRenderer.h:60
bool getAnimate()
Definition: GraphRenderer.cc:559
std::vector< TextProps > txt
vector of textproperties to draw Node strings
Definition: GraphRenderer.h:55
vector< float > boundary
a vector which save the maximum amount of nodes in each direction
Definition: GraphRenderer.h:64
std::vector< std::vector< sf::RectangleShape > > rects
vector of vector of rectangles where a rectangle represent a node (with analogue indices) ...
Definition: GraphRenderer.h:54
GraphRenderer()
Definition: GraphRenderer.cc:189
sf::Vector2i clickPosition
a index vector for the actual clicked Node
Definition: GraphRenderer.h:57
void update(float delta)
Definition: GraphRenderer.cc:111
vector< float > direction
a vector of 2 floats which saves the scrolled way of the view
Definition: GraphRenderer.h:65
void eventHandler(const sf::Event event, sf::RenderWindow &window, vector< Node > &nodeList, Gamemaster &gamemaster, const sf::Vector2f &mouse_pos)
Definition: GraphRenderer.cc:35
This state class encapsulates the current game state. It can output possible actions and select them...
Definition: State.h:16
sf::Color colorOfClickedNode
the color of the Node rectangle, which is in the position of the clickPosition
Definition: GraphRenderer.h:58
std::vector< FuncArrowShape > selectedEdges
vector of FuncArrowShapes which represent selected edges
Definition: GraphRenderer.h:52
sf::Vector2i hoverPosition
a index vector for the actual hovered Node
Definition: GraphRenderer.h:56
float moveConstant
a (upper bound) constant which is used to scroll in terms of computer speed
Definition: GraphRenderer.h:63
int sizeConstant
a constant which defines the scale of the visuals
Definition: GraphRenderer.h:61
void render(sf::RenderWindow &window, vector< DrawNode > &Nodes, vector< Node > &nodeList)
Definition: GraphRenderer.cc:10
This Class stores Methods which manipulates a window in terms of a MAS Game-Structure.
Definition: GraphRenderer.h:40