-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Visualize window (prototype)
- Loading branch information
1 parent
59d0594
commit d089a91
Showing
6 changed files
with
94 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "visualizewindow.h" | ||
|
||
#include <QtSvg> | ||
#include <QSvgWidget> | ||
#include <QtWidgets> | ||
|
||
#include <cstdio> | ||
#include <string> | ||
#include <graphviz/cdt.h> | ||
#include <graphviz/cgraph.h> | ||
#include <graphviz/gvc.h> | ||
#include <graphviz/gvplugin.h> | ||
|
||
using namespace std; | ||
|
||
VisualizeWindow::VisualizeWindow(QWidget *parent, string input) | ||
: QMainWindow(parent) | ||
{ | ||
this->setAttribute(::Qt::WA_DeleteOnClose); | ||
tile = new QSvgWidget(this); | ||
setCentralWidget(tile); | ||
GVC_t *gvc= gvContext(); | ||
Agraph_t *g = agmemread((char*)input.c_str()); | ||
gvLayout(gvc, g, "dot"); | ||
#define MAX_SVG_LENGTH ((unsigned int) 200000) | ||
char *svg = (char*) malloc(MAX_SVG_LENGTH); | ||
unsigned int length; | ||
gvRenderData(gvc, g, "svg", &svg, &length); | ||
gvFreeLayout(gvc, g); | ||
agclose(g); | ||
(gvFreeContext(gvc)); | ||
string svg_s = string(svg); | ||
tile->load(QByteArray::fromStdString(svg_s)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef VISUALIZEWINDOW_H | ||
#define VISUALIZEWINDOW_H | ||
|
||
#include <QMainWindow> | ||
#include <QSVgWidget> | ||
#include <string> | ||
|
||
using namespace std; | ||
|
||
class VisualizeWindow : public QMainWindow | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
VisualizeWindow(QWidget *parent, string input); | ||
|
||
private: | ||
QSvgWidget *tile; | ||
}; | ||
|
||
#endif |