Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Tests/ArrayCoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

using std::string;
using std::vector;

/*
TEST(ArrayCore, save_to_disk_2d) {
//! 2-dimensional array
int rows = 10;
Expand Down Expand Up @@ -141,13 +141,15 @@ TEST(ArrayCore, showDefaultSettings) {
bool result = dv::show(values, "testDefaultSettings");
EXPECT_EQ(result, true);
}

*/
TEST(ArrayCore, showHeatMap1) {
EXPECT_EQ(dvs::isPlotlyScriptExists(), true);
vector<vector<double>> values = {{30.3, 40, 98, 76}, {99, 45, 20, 1}, {5, 56, 93, 25}, {45, 23, 90, 2}};
auto config = dv::Config();
config.heatmap.title = "Black & White TEST MATRIX";
config.heatmap.colorSc = dv::config_colorscales::COLORSCALE_GRAYSCALE;
config.heatmap.aspectRatioWidth = 2;
config.heatmap.aspectRatioHeight = 3;
bool result = dv::show(values, "showHeatMap_gray", config);
EXPECT_EQ(result, true);
}
Expand Down Expand Up @@ -322,18 +324,20 @@ TEST(ArrayCore, show2ChartsWithHoldOnCustomSettings) {
config.chart.title = "Custom title";
config.chart.xLabel = "Custom xLabel";
config.chart.yLabel = "Custom yLabel";
config.chart.aspectRatioHeight = 1;
config.chart.aspectRatioWidth = 3;
dv::holdOff(config);
EXPECT_EQ(v1 && v2, true);
}

TEST(ArrayCore, testMyltiplyHoldOnOff) {

vector<double> vec1 = {1, 2, 3, 4, 5, 6, 7};
vector<double> vec2 = {3, 4, 5, 6, 7};
vector<double> vec2 = {3, 4, 5, 6, 27};

dv::holdOn();
bool v1 = dv::show(vec1, "titleHoldOn1");
bool v2 = dv::show(vec1, "titleHoldOn2");
bool v2 = dv::show(vec2, "titleHoldOn2");
dv::holdOff();

dv::holdOff();
Expand Down
6 changes: 5 additions & 1 deletion array_core/configurator.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ enum config_colorscales {
struct commonSettings {
commonSettings():
xLabel("X"),
yLabel("Y") {}
yLabel("Y"),
aspectRatioWidth(1),
aspectRatioHeight(1) {}
virtual ~commonSettings() {}
std::string title;
std::string xLabel;
std::string yLabel;
double aspectRatioWidth;
double aspectRatioHeight;
};

struct chartSettings : public commonSettings {
Expand Down
11 changes: 10 additions & 1 deletion array_core/multi_plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,17 @@ void holdOff(const Config& configuration) {
allTracesNames_str.append(filled_trace_name_part);
allChartBlocks_str.append(dvs::allChartBlocks[i]);
}
string paramWH;
if (configuration.chart.aspectRatioWidth > configuration.chart.aspectRatioHeight) {
paramWH = "width";
} else {
paramWH = "height";
}
vector<string> args = {dvs::kPlotlyJsName, allChartBlocks_str, allTracesNames_str,
configuration.chart.title, configuration.chart.xLabel, configuration.chart.yLabel
configuration.chart.title, configuration.chart.xLabel, configuration.chart.yLabel,
dvs::toStringDotSeparator(configuration.chart.aspectRatioWidth),
dvs::toStringDotSeparator(configuration.chart.aspectRatioHeight),
paramWH
};
string multichartPage = dvs::kHtmlMultiChartModel;
string filled_multichartPage = "";
Expand Down
8 changes: 8 additions & 0 deletions common_utils/common_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ string vectorToString(const vector<double>& vec);

string makeUniqueDavisHtmlName();

//! sometimes std::to_string reurn str with ',' as separator what is wrong
template <typename T>
string toStringDotSeparator(T data) {
string str = std::to_string(data);
std::replace(str.begin(), str.end(), ',', '.');
return str;
}

//! save to disk vector<T> data
template <typename T>
bool saveVec(const vector<T>& vec, const string& filename, dv::configSaveToDisk config) {
Expand Down
93 changes: 81 additions & 12 deletions davis_one/davis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ R"(
</head>
<body><div style = "display: flex;
align-items:center;height:100%; width:100%;background:#dddfd4;
justify-content: center;"><div style="height:95%; aspect-ratio: 1/1;"
justify-content: center;"><div style="%11:99%; aspect-ratio: %9/%10;"
id="gd"></div></div>
<script>
%1
Expand Down Expand Up @@ -368,7 +368,7 @@ extern const char kHtmlDateTimeModel[] = R"davis_delimeter(
</head>
<body><div style = "display: flex;
align-items:center;height:100%; width:100%;background:#dddfd4;
justify-content: center;"><div style="height:95%; aspect-ratio: 1/1;"
justify-content: center;"><div style="%6:99%; aspect-ratio: %4/%5;"
id="gd"></div></div>

<script>
Expand Down Expand Up @@ -413,7 +413,7 @@ extern const char kHtmlMultiChartModel[] = R"davis_delimeter(
</head>
<body><div style = "display: flex;
align-items:center;height:100%; width:100%;background:#dddfd4;
justify-content: center;"><div style="height:95%; aspect-ratio: 1/1;"
justify-content: center;"><div style="%9:99%; aspect-ratio: %7/%8;"
id="gd"></div></div>
<script>

Expand Down Expand Up @@ -470,7 +470,7 @@ extern const char kHtmlCloudOfPoints[] = R"davis_delimeter(
</head>
<body><div style = "display: flex;
align-items:center;height:100%; width:100%;background:#dddfd4;
justify-content: center;"><div style="height:95%; aspect-ratio: 1/1;"
justify-content: center;"><div style="%7:99%; aspect-ratio: %5/%6;"
id="gd"></div></div>
<script>
var trace = {
Expand Down Expand Up @@ -1010,24 +1010,39 @@ bool createHtmlPageWithPlotlyJS(const std::vector<std::vector<double>>& values,
break;
}
switch (typeVisual) {
case dv::VISUALTYPE_HEATMAP:
case dv::VISUALTYPE_HEATMAP: {
args[ARG_MATRIX_TYPE] = kHeatMapTypePart;
args[ARG_TITLE] = configuration.heatmap.title;
args[ARG_TITLE_X] = configuration.heatmap.xLabel;
args[ARG_TITLE_Y] = configuration.heatmap.yLabel;
args[ARG_ASPECT_RATIO_WIDTH] = dvs::toStringDotSeparator(configuration.heatmap.aspectRatioWidth);
args[ARG_ASPECT_RATIO_HEIGHT] = dvs::toStringDotSeparator(configuration.heatmap.aspectRatioHeight);
string paramWH;
if (configuration.heatmap.aspectRatioWidth > configuration.heatmap.aspectRatioHeight) {
paramWH = "width";
} else {
paramWH = "height";
}
args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH;
break;
case dv::VISUALTYPE_SURFACE:
}
case dv::VISUALTYPE_SURFACE: {
args[ARG_MATRIX_TYPE] = kSurfaceTypePart;
args[ARG_TITLE] = configuration.surf.title;
args[ARG_TITLE_X] = configuration.surf.xLabel;
args[ARG_TITLE_Y] = configuration.surf.yLabel;
args[ARG_TITLE_Z] = configuration.surf.zLabel;
args[ARG_ASPECT_RATIO_WIDTH] = dvs::toStringDotSeparator(configuration.surf.aspectRatioWidth);
args[ARG_ASPECT_RATIO_HEIGHT] = dvs::toStringDotSeparator(configuration.surf.aspectRatioHeight);
string paramWH;
if (configuration.surf.aspectRatioWidth > configuration.surf.aspectRatioHeight) {
paramWH = "width";
} else {
paramWH = "height";
}
args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH;
break;
case dv::VISUALTYPE_CHART:
args[ARG_TITLE] = configuration.chart.title;
args[ARG_TITLE_X] = configuration.chart.xLabel;
args[ARG_TITLE_Y] = configuration.chart.yLabel;
break;
}
default:
break;
}
Expand Down Expand Up @@ -1069,6 +1084,15 @@ bool showLineChartInBrowser(const vector<double>& xValues, const vector<double>&
args[ARG_TITLE] = configuration.chart.title;
args[ARG_TITLE_X] = configuration.chart.xLabel;
args[ARG_TITLE_Y] = configuration.chart.yLabel;
args[ARG_ASPECT_RATIO_WIDTH] = dvs::toStringDotSeparator(configuration.chart.aspectRatioWidth);
args[ARG_ASPECT_RATIO_HEIGHT] = dvs::toStringDotSeparator(configuration.chart.aspectRatioHeight);
string paramWH;
if (configuration.chart.aspectRatioWidth > configuration.chart.aspectRatioHeight) {
paramWH = "width";
} else {
paramWH = "height";
}
args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH;
make_string(kHtmlModel, args, page);
string pageName;
mayBeCreateJsWorkingFolder();
Expand Down Expand Up @@ -1195,6 +1219,18 @@ void showDateTimeChart(const string& date_time_values,
}

args[ARG_Y_DATE_TIME_VALUES] = values;
args[ARG_DATE_TIME_ASPECT_RATIO_WIDTH] = "1";
args[ARG_DATE_TIME_ASPECT_RATIO_HEIGHT] = "1";
/*
string paramWH;
if(configuration.chart.aspectRatioWidth > configuration.chart.aspectRatioHeight){
paramWH = "width";
}else{
paramWH = "height";
}
*/
string paramWH = "height";
args[ARG_DATE_TIME_ASPECT_WIDTH_OR_HEIGHT] = paramWH;
make_string(kHtmlDateTimeModel, args, out);
saveStringToFile(kReportPagePath, out);
openFileBySystem(kReportPagePath);
Expand Down Expand Up @@ -1236,6 +1272,18 @@ void showCloudOfPointsChart(const vector<double>& xValues,
args[ARG_X_CLOUD_OF_POINTS] = vectorToString(xValues);
args[ARG_Y_CLOUD_OF_POINTS] = vectorToString(yValues);
args[ARG_COLOR_CLOUD_OF_POINTS] = vectorToString(colorValues);
args[ARG_CLOUD_OF_POINTS_ASPECT_RATIO_WIDTH] = "1";
args[ARG_CLOUD_OF_POINTS_ASPECT_RATIO_HEIGHT] = "1";
/*
string paramWH;
if(configuration.chart.aspectRatioWidth > configuration.chart.aspectRatioHeight){
paramWH = "width";
}else{
paramWH = "height";
}
*/
string paramWH = "height";
args[ARG_CLOUD_OF_POINTS_ASPECT_WIDTH_OR_HEIGHT] = paramWH;
make_string(kHtmlCloudOfPoints, args, out);
saveStringToFile(kCloudPagePath, out);
openFileBySystem(kCloudPagePath);
Expand All @@ -1256,6 +1304,18 @@ void showCloudOfPointsChartStr(const std::string& xValues,
args[ARG_X_CLOUD_OF_POINTS] = xValues;
args[ARG_Y_CLOUD_OF_POINTS] = vectorToString(yValues);
args[ARG_COLOR_CLOUD_OF_POINTS] = vectorToString(colorValues);
args[ARG_CLOUD_OF_POINTS_ASPECT_RATIO_WIDTH] = "1";
args[ARG_CLOUD_OF_POINTS_ASPECT_RATIO_HEIGHT] = "1";
/*
string paramWH;
if(configuration.chart.aspectRatioWidth > configuration.chart.aspectRatioHeight){
paramWH = "width";
}else{
paramWH = "height";
}
*/
string paramWH = "height";
args[ARG_CLOUD_OF_POINTS_ASPECT_WIDTH_OR_HEIGHT] = paramWH;
make_string(kHtmlCloudOfPoints, args, out);
saveStringToFile(kCloudPagePath, out);
openFileBySystem(kCloudPagePath);
Expand Down Expand Up @@ -1297,8 +1357,17 @@ void holdOff(const Config& configuration) {
allTracesNames_str.append(filled_trace_name_part);
allChartBlocks_str.append(dvs::allChartBlocks[i]);
}
string paramWH;
if (configuration.chart.aspectRatioWidth > configuration.chart.aspectRatioHeight) {
paramWH = "width";
} else {
paramWH = "height";
}
vector<string> args = {dvs::kPlotlyJsName, allChartBlocks_str, allTracesNames_str,
configuration.chart.title, configuration.chart.xLabel, configuration.chart.yLabel
configuration.chart.title, configuration.chart.xLabel, configuration.chart.yLabel,
dvs::toStringDotSeparator(configuration.chart.aspectRatioWidth),
dvs::toStringDotSeparator(configuration.chart.aspectRatioHeight),
paramWH
};
string multichartPage = dvs::kHtmlMultiChartModel;
string filled_multichartPage = "";
Expand Down
32 changes: 31 additions & 1 deletion davis_one/davis.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ enum config_colorscales {
struct commonSettings {
commonSettings():
xLabel("X"),
yLabel("Y") {}
yLabel("Y"),
aspectRatioWidth(1),
aspectRatioHeight(1) {}
virtual ~commonSettings() {}
std::string title;
std::string xLabel;
std::string yLabel;
double aspectRatioWidth;
double aspectRatioHeight;
};

struct chartSettings : public commonSettings {
Expand Down Expand Up @@ -121,6 +125,9 @@ enum ARGS_INDEX {
ARG_TITLE_Y, //%6
ARG_TITLE_Z, //%7
ARG_JS_VER, //%8
ARG_ASPECT_RATIO_WIDTH, //%9
ARG_ASPECT_RATIO_HEIGHT, //%10
ARG_ASPECT_WIDTH_OR_HEIGHT, //11 "width" if ARG_ASPECT_RATIO_WIDTH > ARG_ASPECT_RATIO_HEIGHT and "height" if not
// ADD NEW ENUM BEFORE THIS COMMENT
ARGS_SIZE
};
Expand All @@ -145,14 +152,26 @@ enum ARGS_DATE_TIME_PAGE_INDEX {
ARG_JS_NAME, //%1
ARG_DATE_TIME_VALUES, //%2
ARG_Y_DATE_TIME_VALUES, //%3
ARG_DATE_TIME_ASPECT_RATIO_WIDTH, //%4
ARG_DATE_TIME_ASPECT_RATIO_HEIGHT, //%5
ARG_DATE_TIME_ASPECT_WIDTH_OR_HEIGHT, //%6 "width" if ARG_ASPECT_RATIO_WIDTH > ARG_ASPECT_RATIO_HEIGHT and "height" if not

// ADD NEW ENUM BEFORE THIS COMMENT
ARGS_DATE_TIME_PAGE_SIZE
};

// currently don't used
enum ARGS_MULTI_CHARTS_PAGE {
ARG_JS_MC_NAME,
ARG_TRACES_BLOCKS,
ARG_DATA_OF_TRACES,
something1,
something2,
something3,
ARG_MC_DATE_TIME_ASPECT_RATIO_WIDTH, //%7
ARG_MC_DATE_TIME_ASPECT_RATIO_HEIGHT, //%8
ARG_MC_DATE_ASPECT_WIDTH_OR_HEIGHT, //%9 "width" if ARG_ASPECT_RATIO_WIDTH > ARG_ASPECT_RATIO_HEIGHT and "height" if not

// ADD NEW ENUM BEFORE THIS COMMENT
ARGS_MULTI_CHARTS_PAGE_SIZE
};
Expand All @@ -162,6 +181,9 @@ enum ARGS_CLOUD_OF_POINTS_PAGE {
ARG_X_CLOUD_OF_POINTS,
ARG_Y_CLOUD_OF_POINTS,
ARG_COLOR_CLOUD_OF_POINTS,
ARG_CLOUD_OF_POINTS_ASPECT_RATIO_WIDTH, //%5
ARG_CLOUD_OF_POINTS_ASPECT_RATIO_HEIGHT, //%6
ARG_CLOUD_OF_POINTS_ASPECT_WIDTH_OR_HEIGHT, //7 "width" if ARG_ASPECT_RATIO_WIDTH > ARG_ASPECT_RATIO_HEIGHT and "height" if not
// ADD NEW ENUM BEFORE THIS COMMENT
ARGS_CLOUD_OF_POINTS_PAGE_SIZE
};
Expand Down Expand Up @@ -254,6 +276,14 @@ string vectorToString(const vector<double>& vec);

string makeUniqueDavisHtmlName();

//! sometimes std::to_string reurn str with ',' as separator what is wrong
template <typename T>
string toStringDotSeparator(T data) {
string str = std::to_string(data);
std::replace(str.begin(), str.end(), ',', '.');
return str;
}

//! save to disk vector<T> data
template <typename T>
bool saveVec(const vector<T>& vec, const string& filename, dv::configSaveToDisk config) {
Expand Down
11 changes: 10 additions & 1 deletion gui/davis_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,8 +889,17 @@ void DavisGUI::visualizeFiles(const QStringList& file_list) {
}
}
}
double aspectW = 1;
double aspectH = 1;
QString paramWH;
if (aspectW > aspectH) {
paramWH = "width";
} else {
paramWH = "height";
}
QString multichartPage = dvs::kHtmlMultiChartModel;
multichartPage = multichartPage.arg(dvs::kPlotlyJsName, all_chart_blocks, all_traces_names, "", "X", "Y");
multichartPage = multichartPage.arg(dvs::kPlotlyJsName, all_chart_blocks, all_traces_names, "", "X", "Y",
QString::number(aspectW), QString::number(aspectH), paramWH);
qDebug() << multichartPage;
dvs::saveStringToFile(dvs::kReportPagePath, multichartPage.toStdString());
dvs::openFileBySystem(dvs::kReportPagePath);
Expand Down
Loading
Loading