-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
140 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
#ifndef DAVIS_HPP | ||
#define DAVIS_HPP | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <cstdlib> | ||
#include "plotly_maker/plotly_maker.h" | ||
|
||
namespace { | ||
|
||
using std::string; | ||
using std::vector; | ||
|
||
constexpr char davis[] = "davis --"; | ||
constexpr char prefix[] = "=\""; | ||
constexpr char postfix[] = "\""; | ||
constexpr char command_heatmap[] = "heatmap"; | ||
constexpr char command_surface[] = "surface"; | ||
constexpr char command_line_chart[] = "linechart"; | ||
|
||
void runDavisBySystem(const string& args) { | ||
system(args.c_str()); | ||
} | ||
void makeStringFromValues(const vector<double> in_values, | ||
string& out_values) { | ||
for (size_t i = 0; i < in_values.size(); ++i) { | ||
std::string value = std::to_string(in_values[i]); | ||
out_values.append(value); | ||
if (i != in_values.size() - 1) { | ||
out_values.append(","); | ||
} | ||
} | ||
|
||
} | ||
void makeArgs(const davis::showSettings& settings, | ||
const vector<vector<double>>& values, string& out) { | ||
|
||
switch (settings.visualType) { | ||
case davis::visualizationTypes::CHART: | ||
break; | ||
case davis::visualizationTypes::HEATMAP: | ||
//duplicated code | ||
out.append(davis); | ||
out.append(command_heatmap); | ||
out.append(prefix); | ||
for (size_t i = 0; i < values.size(); ++i) { | ||
makeStringFromValues(values[i], out); | ||
if (i != values.size() - 1) | ||
out.append(";"); | ||
} | ||
out.append(postfix); | ||
break; | ||
case davis::visualizationTypes::SURFACE: | ||
//duplicated code | ||
out.append(davis); | ||
out.append(command_surface); | ||
out.append(prefix); | ||
for (size_t i = 0; i < values.size(); ++i) { | ||
makeStringFromValues(values[i], out); | ||
if (i != values.size() - 1) | ||
out.append(";"); | ||
} | ||
out.append(postfix); | ||
break; | ||
} | ||
} | ||
|
||
void makeArgs(const davis::showSettings& settings, | ||
vector<double>& values, string& out) { | ||
|
||
switch (settings.visualType) { | ||
case davis::visualizationTypes::CHART: | ||
out.append(davis); | ||
out.append(command_line_chart); | ||
out.append(prefix); | ||
makeStringFromValues(values, out); | ||
out.append(postfix); | ||
break; | ||
case davis::visualizationTypes::HEATMAP: | ||
break; | ||
case davis::visualizationTypes::SURFACE: | ||
break; | ||
} | ||
} | ||
|
||
} | ||
|
||
namespace dv { | ||
|
||
void show(const davis::showSettings& settings, | ||
vector<vector<double>>& values); | ||
void show(const davis::showSettings& settings, | ||
vector<double>& values); | ||
|
||
void show(const davis::showSettings& settings, | ||
vector<double>& values) { | ||
string args; | ||
makeArgs(settings, values, args); | ||
runDavisBySystem(args); | ||
} | ||
|
||
void show(const davis::showSettings& settings, | ||
vector<vector<double>>& values) { | ||
string args; | ||
makeArgs(settings, values, args); | ||
runDavisBySystem(args); | ||
} | ||
|
||
} | ||
|
||
#endif // DAVIS_HPP |
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,14 @@ | ||
#include "davis.h" | ||
|
||
int main(int argc, char* argv[]) { | ||
davis::showSettings settings; | ||
settings.visualType = davis::visualizationTypes::CHART; | ||
vector<double>v = {8.0, 8.0, 9, 0, 55}; | ||
vector<vector<double>>hm = {{8.0, 8.0, 9, 0, 55}, {5.0, 18.0, 0.9, 50, 15}}; | ||
dv::show(settings, v); | ||
settings.visualType = davis::visualizationTypes::HEATMAP; | ||
dv::show(settings, hm); | ||
settings.visualType = davis::visualizationTypes::SURFACE; | ||
dv::show(settings, hm); | ||
return EXIT_SUCCESS; | ||
} |
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