-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlibmadeline.cc
53 lines (41 loc) · 1.51 KB
/
libmadeline.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <string>
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include "madeline/src/DrawingMetrics.h"
#include "madeline/src/Parser.h"
#include "madeline/src/PedigreeSet.h"
std::string pedigree_SVG(emscripten::val header,
emscripten::val content,
emscripten::val labels)
{
DrawingMetrics::setColor(true);
DrawingMetrics::setEmbeddedState(true);
DrawingMetrics::setNoLabelTruncation(true);
DrawingMetrics::setScalableState(false);
if (emscripten::vecFromJSArray<std::string>(header).size() == 0 ||
emscripten::vecFromJSArray<std::string>(header).size() == 0)
{
return std::string();
} // if
Parser dataTableParser;
dataTableParser.from_string(emscripten::vecFromJSArray<std::string>(header),
emscripten::vecFromJSArray<std::string>(content));
DataTable* const dataTable = dataTableParser.getTable(0);
if (dataTable->getTableType() == DataTable::PEDIGREE)
{
PedigreeSet pedigreeSet;
std::string sortField = "";
dataTable->toggleColumnsForPedigree(emscripten::vecFromJSArray<std::string>(labels));
pedigreeSet.addPedigreesFromDataTable(dataTable, 0, sortField);
return pedigreeSet.draw(dataTable);
} // if
return std::string();
} // pedigree_SVG
EMSCRIPTEN_BINDINGS(stl_wrappers)
{
emscripten::register_vector<std::string>("VectorString");
}
EMSCRIPTEN_BINDINGS(module)
{
emscripten::function("draw", &pedigree_SVG);
}