GraphTool  1.0
Tool for analyzing and graphically visualizing code dependencies for Ericsson.
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
main_controller.h
1 
8 #ifndef GUI_GRAPH_CONTROLLER_H_
9 #define GUI_GRAPH_CONTROLLER_H_
10 
11 // Qt-imports
12 #include <QStringList>
13 #include <QString>
14 #include <QObject>
15 #include <QStandardItemModel>
16 
17 
18 // General imports
19 #include <algorithm>
20 #include <assert.h>
21 #include <sstream>
22 #include <unistd.h>
23 #include <map>
24 #include <string>
25 
26 // Local includes
27 #include "linkler.h"
28 #include "linkler_diff.h"
29 #include "xmlparser.h"
30 #include "filterparser.h"
31 #include "graph_exporter.h"
32 #include "swu.h"
33 #include "module.h"
34 #include "hide_action.h"
35 #include "edge_type_filter.h"
36 #include "dependency_degree_filter.h"
37 #include "run_block_filter.h"
38 #include "noop_action.h"
39 #include "graph_filter.h"
40 #include "node_exclusion_filter.h"
41 #include "diff_filter.h"
42 #include "regex_filter.h"
43 #include "graph_filter_list.h"
44 #include "set_property_action.h"
45 #include "swu_graph_builder.h"
46 #include "module_graph_builder.h"
47 #include "graph_model.h"
48 #include "module_graph_model.h"
49 #include "swu_graph_model.h"
50 #include "filter_model.h"
51 #include "mem_type.h"
52 
53 
54 class MainController : public QObject {
55  Q_OBJECT
56 
57  public:
58 
63 
67  virtual ~MainController();
68 
71  typedef SWUGraphModel GraphModel;
73 
78  std::vector<std::string> excluded_nodes();
79 
84  QStringList get_run_blocks();
85 
90  bool was_any_node_focused();
91 
96  void reinclude_excluded_node(std::string name);
97 
102 
106  void undo_focused();
107 
112  void add_to_focused(std::string name);
113 
118  void load_from_xml(std::string file_name);
119 
124  void load_diff_from_xml(std::string file_name);
125 
130  bool save_to_graphviz(std::string file_name);
131 
137 
144  GraphModel* treeModel(bool dependents, bool dependencies);
145 
146 
152 
158 
163  bool is_expanded(std::string item_name);
164 
170  bool has_item(std::string item_name);
171 
176  bool has_pre_layout_filters();
177 
183 
189  void set_linkler(Linkler* linkler, bool free = true);
190 
195  unsigned int num_nodes();
196 
202  GraphType::node_value_type item(std::string name);
203 
208  std::string focus_item() const;
209 
214  int graph_width() const;
215 
220  int graph_height() const;
221 
227  void set_dependents(bool dependents);
228 
234  void set_dependencies(bool dependencies);
235 
241  void set_layout_type(std::string layout_type, bool relayout = true);
242 
248  void import_filters(std::string file_path, bool clear = true);
249 
254  void export_filters(std::string file_path);
255 
261  void import_conditional_formattings(std::string file_path, bool clear = true);
262 
267  void export_conditional_formattings(std::string file_path);
268 
273  GraphFilterList<GraphType>& pre_filters() { return pre_filters_; }
274 
279  GraphFilterList<GraphType>& post_filters() { return post_filters_; }
280 
281 
286  QStandardItemModel* post_filter_model();
287 
292  QStandardItemModel* pre_filter_model();
293 
294 
295  private: // private methods
300  void rebuild_graph(bool lay = true);
301 
305  void layout();
306 
311  void graph_item(std::pair<std::string, bool> node);
312 
319  QStandardItemModel* filter_model(GraphFilterList<GraphType>& list, bool formatting_options);
320 
326  void remove_filter(std::string filter_name, GraphFilterList<GraphType>& filters);
327 
340  void insert_filter(std::string name,
341  std::string type,
342  bool hide,
343  bool inverted_b,
344  bool enabled,
345  std::string color,
346  std::string opacity,
347  std::map<std::string, std::string> params,
348  GraphFilterList<GraphType>& filters);
349 
353  void update_filters();
354 
359  bool contract_recursively(std::string item_name, std::string search_name);
360 
361 
362  public slots:
368  void search(std::string search_term, std::string search_type);
369 
378  bool expand_item(std::string expand_item_, bool last, bool emit = true, bool update_focus = false, bool recursively = false);
379 
387  bool contract_item(std::string item_name, bool last, bool emit = true);
388 
393  void focus_item(std::string item_name);
394 
400  void exclude_item(std::string item_name, bool last);
401 
407  void remove_pre_filter(std::string filter_name, bool last = true);
408 
414  void remove_post_filter(std::string filter_name, bool last = true);
415 
428  void insert_pre_filter(
429  std::string name,
430  std::string type,
431  bool hide,
432  bool inverted_b,
433  bool enabled,
434  std::string color,
435  std::string opacity,
436  std::map<std::string,std::string> params,
437  bool last);
438 
451  void insert_post_filter(
452  std::string name,
453  std::string type,
454  bool hide,
455  bool inverted_b,
456  bool enabled,
457  std::string color,
458  std::string opacity,
459  std::map<std::string,std::string> params,
460  bool last);
474  void update_pre_filter(
475  std::string name,
476  std::string type,
477  bool hide,
478  bool inverted_b,
479  bool enabled,
480  std::string color,
481  std::string opacity,
482  std::map<std::string,std::string> params,
483  bool last);
497  void update_post_filter(
498  std::string name,
499  std::string type,
500  bool hide,
501  bool inverted_b,
502  bool enabled,
503  std::string color,
504  std::string opacity,
505  std::map<std::string,std::string> params,
506  bool last);
507 
511  void reset_all_pre_filters();
512 
516  void reset_all_post_filters();
517 
518  signals:
524  void graphChanged(std::string focus_node = "", bool reset_zoom = false);
525 
526  void unknownItem(std::string item_name);
527 
531  void graphEmpty();
532 
537  void duplicateFilterName(std::string filter_name);
542  void invalidFilterName(std::string filter_name);
546  void postFilterModelChanged();
550  void preFilterModelChanged();
551 
552  private:
554  Linkler* linkler_;
555 
557  GraphType emptyGraph;
558 
560  GraphBuilder current_graph_builder_;
561 
564  GraphBuilder full_graph_builder_;
565 
567  std::string focus_item_;
568 
571  std::set< std::pair<std::string, bool> > expanded_items_;
572 
573  // Should dependents be included
574  bool dependents_;
575 
576  // Should dependencies be included
577  bool dependencies_;
578 
579  // Layout type
580  std::string layout_type_;
581 
583  GraphFilterList<GraphType> pre_filters_;
584 
586  GraphFilterList<GraphType> post_filters_;
587 
589  LinklerDiff* linklerDiff_;
590 
591  // Graph height
592  int graph_height_;
593 
594  // Graph width
595  int graph_width_;
596 
598  std::vector<std::string> previously_focused_items_;
599 
601  GraphProperties<GraphType> properties_;
602 
604  bool property_lock_;
605 
606 };
607 
608 #endif
void reset_all_post_filters()
Definition: main_controller.cc:658
Definition: swu_graph_builder.h:22
void import_filters(std::string file_path, bool clear=true)
Definition: main_controller.cc:752
void undo_focused()
Definition: main_controller.cc:329
void remove_post_filter(std::string filter_name, bool last=true)
Definition: main_controller.cc:476
void graphChanged(std::string focus_node="", bool reset_zoom=false)
Definition: graph_builder.h:4
void insert_post_filter(std::string name, std::string type, bool hide, bool inverted_b, bool enabled, std::string color, std::string opacity, std::map< std::string, std::string > params, bool last)
Definition: main_controller.cc:510
QStringList get_run_blocks()
Definition: main_controller.cc:161
bool has_item(std::string item_name)
Definition: main_controller.cc:291
void reinclude_all_excluded_nodes()
Definition: main_controller.cc:324
GraphModel * emptyModel()
Definition: main_controller.cc:445
bool expand_item(std::string expand_item_, bool last, bool emit=true, bool update_focus=false, bool recursively=false)
Definition: main_controller.cc:172
void export_filters(std::string file_path)
Definition: main_controller.cc:781
GraphFilterList< GraphType > & post_filters()
Definition: main_controller.h:279
void remove_pre_filter(std::string filter_name, bool last=true)
Definition: main_controller.cc:469
void export_conditional_formattings(std::string file_path)
Definition: main_controller.cc:810
QStandardItemModel * pre_filter_model()
Definition: main_controller.cc:819
bool contract_item(std::string item_name, bool last, bool emit=true)
Contract an item, that is remove it from expanded items.
Definition: main_controller.cc:207
std::vector< std::string > excluded_nodes()
Definition: main_controller.cc:735
GraphType::node_value_type item(std::string name)
Definition: main_controller.cc:687
int graph_width() const
Get graph width.
Definition: main_controller.cc:681
void duplicateFilterName(std::string filter_name)
void invalidFilterName(std::string filter_name)
Definition: linkler.h:20
void load_diff_from_xml(std::string file_name)
Definition: main_controller.cc:79
void insert_pre_filter(std::string name, std::string type, bool hide, bool inverted_b, bool enabled, std::string color, std::string opacity, std::map< std::string, std::string > params, bool last)
Definition: main_controller.cc:490
void set_layout_type(std::string layout_type, bool relayout=true)
Definition: main_controller.cc:703
bool has_pre_layout_filters()
Definition: main_controller.cc:665
QStandardItemModel * post_filter_model()
Definition: main_controller.cc:815
void import_conditional_formattings(std::string file_path, bool clear=true)
Definition: main_controller.cc:786
bool has_post_layout_filters()
Check if it has pre layout filters.
Definition: main_controller.cc:670
GraphModel * graphModel()
Definition: main_controller.cc:407
void search(std::string search_term, std::string search_type)
Definition: main_controller.cc:134
void add_to_focused(std::string name)
Definition: main_controller.cc:306
void update_post_filter(std::string name, std::string type, bool hide, bool inverted_b, bool enabled, std::string color, std::string opacity, std::map< std::string, std::string > params, bool last)
Definition: main_controller.cc:636
Definition: graph_filter_list.h:16
Definition: linkler_diff.h:14
bool save_to_graphviz(std::string file_name)
Definition: main_controller.cc:120
MainController()
Definition: main_controller.cc:3
bool is_expanded(std::string item_name)
Definition: main_controller.cc:285
void exclude_item(std::string item_name, bool last)
Definition: main_controller.cc:459
Definition: graph_properties.h:7
GraphModel * treeModel(bool dependents, bool dependencies)
Definition: main_controller.cc:424
virtual ~MainController()
Definition: main_controller.cc:27
Definition: swu.h:27
GraphFilterList< GraphType > & pre_filters()
Definition: main_controller.h:273
int graph_height() const
Get graph height.
Definition: main_controller.cc:684
void set_dependencies(bool dependencies)
Definition: main_controller.cc:697
unsigned int num_nodes()
Definition: main_controller.cc:674
void reinclude_excluded_node(std::string name)
Definition: main_controller.cc:319
Definition: main_controller.h:54
GraphModel * fullModel()
Definition: main_controller.cc:451
Definition: swu_graph_model.h:24
void set_dependents(bool dependents)
Definition: main_controller.cc:691
bool was_any_node_focused()
Definition: main_controller.cc:748
void set_linkler(Linkler *linkler, bool free=true)
Definition: main_controller.cc:711
void load_from_xml(std::string file_name)
Definition: main_controller.cc:45
SWUGraphBuilder GraphBuilder
Typedefs to make the application more generalized.
Definition: main_controller.h:70
void reset_all_pre_filters()
Definition: main_controller.cc:650
std::string focus_item() const
Definition: main_controller.cc:678
void update_pre_filter(std::string name, std::string type, bool hide, bool inverted_b, bool enabled, std::string color, std::string opacity, std::map< std::string, std::string > params, bool last)
Definition: main_controller.cc:622