Skip to content

Commit 4e2e925

Browse files
committed
deleting "surface" in code is done
1 parent 72e56b1 commit 4e2e925

File tree

13 files changed

+141
-381
lines changed

13 files changed

+141
-381
lines changed

Tests/ArrayCoreTest.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@ TEST(ArrayCore, configurator) {
129129
config.heatmap.title = "Тестовая матрица";
130130
config.heatmap.colorSc = dv::COLORSCALE_YlGnBu;
131131
bool result1 = dv::show(values, "HeatMap", config);
132-
config.typeVisual = dv::VISUALTYPE_SURFACE;
133-
config.surf.title = "This is Surface!!!";
134-
bool result2 = dv::show(values, "Surface", config);
135-
EXPECT_EQ(result1 && result2, true);
132+
EXPECT_EQ(result1, true);
136133
}
137134

138135
TEST(ArrayCore, showDefaultSettings) {
@@ -165,20 +162,6 @@ TEST(ArrayCore, showHeatMap1_AutoScale) {
165162
EXPECT_EQ(result, true);
166163
}
167164

168-
TEST(ArrayCore, showSurface) {
169-
EXPECT_EQ(dvs::isPlotlyScriptExists(), true);
170-
vector<vector<double>> values = {{30.3, 40, 98, 76}, {99, 45, 20, 1}, {5, 56, 93, 25}, {45, 23, 90, 2}};
171-
auto config = dv::Config();
172-
config.typeVisual = dv::VISUALTYPE_SURFACE;
173-
config.surf.xLabel = "xLabel from Settings";
174-
config.surf.yLabel = "yLabel from Settings";
175-
config.surf.zLabel = "zLabel from Settings";
176-
config.surf.title = "Title from Settings";
177-
config.surf.colorSc = dv::config_colorscales::COLORSCALE_THERMAL;
178-
bool result = dv::show(values, "showSurface", config);
179-
EXPECT_EQ(result, true);
180-
}
181-
182165
TEST(ArrayCore, showPseudo2D) {
183166
int rows = 5;
184167
int cols = 3;
@@ -360,7 +343,7 @@ TEST(ArrayCore, testMyltiplyHoldOnOff) {
360343

361344
dv::holdOn();
362345
dv::show(vec1, "titleHoldOn3");
363-
dv::show(vec1, "titleHoldOn4");
346+
dv::show(vec2, "titleHoldOn4");
364347
dv::holdOff();
365348

366349
EXPECT_EQ(v1 && v2, true);

Tests/PlotlyLibTest.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ TEST(PlotlyMaker, CreateDefaultHeatMapHtmlPageTest) {
99
std::string str_page = "test_page";
1010
auto config = dv::Config();
1111
config.typeVisual = dv::VISUALTYPE_HEATMAP;
12-
bool result = dvs::createHtmlPageWithPlotlyJS(testValues, str_page, config, dv::VISUALTYPE_HEATMAP);
12+
bool result = dvs::createHtmlPageHeatmap(testValues, str_page, config);
1313
std::ofstream out("example.html");
1414
if (out.is_open()) {
1515
out << str_page.c_str();
@@ -48,15 +48,6 @@ TEST(PlotlyMaker, ShowSunnyHeatMapHtmlPageTest) {
4848
EXPECT_EQ(result, true);
4949
}
5050

51-
TEST(PlotlyMaker, ShowThermalSurfaceHtmlPageTest) {
52-
std::vector<std::vector<double>>testValues = {{43, 400, 54, 980}, {200, 36, 400, 55}, {120, 4, 650, 5}};
53-
std::string str_page = "ThermalSurfacePage";
54-
auto config = dv::Config();
55-
config.heatmap.colorSc = dv::config_colorscales::COLORSCALE_THERMAL;
56-
bool result = dvs::showSurfaceInBrowser(testValues, str_page, config);
57-
EXPECT_EQ(result, true);
58-
}
59-
6051
TEST(PlotlyMaker, ShowWarnigJsAbsentPageTest) {
6152
dvs::showWarningJsAbsentPage();
6253
}

array_core/array_core.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,9 @@ bool show(T** data, uint64_t arrRows, uint64_t arrCols, const string& htmlPageNa
9393
}
9494
bool res = false;
9595
if (configuration.typeVisual == VISUALTYPE_AUTO ||
96-
configuration.typeVisual == VISUALTYPE_HEATMAP)
96+
configuration.typeVisual == VISUALTYPE_HEATMAP) {
9797
res = dvs::showHeatMapInBrowser(vecVecDbl, htmlPageName, configuration);
98-
else if (configuration.typeVisual == VISUALTYPE_SURFACE)
99-
res = dvs::showSurfaceInBrowser(vecVecDbl, htmlPageName, configuration);
98+
}
10099
return res;
101100
}
102101

@@ -122,10 +121,9 @@ bool show(const T* data, uint64_t arrRows, uint64_t arrCols, const string& htmlP
122121
}
123122
bool res = false;
124123
if (configuration.typeVisual == VISUALTYPE_AUTO ||
125-
configuration.typeVisual == VISUALTYPE_HEATMAP)
124+
configuration.typeVisual == VISUALTYPE_HEATMAP) {
126125
res = dvs::showHeatMapInBrowser(vecVecDbl, htmlPageName, configuration);
127-
else if (configuration.typeVisual == VISUALTYPE_SURFACE)
128-
res = dvs::showSurfaceInBrowser(vecVecDbl, htmlPageName, configuration);
126+
}
129127
return res;
130128
}
131129

@@ -260,8 +258,6 @@ bool show(C const& container_of_containers, const string& htmlPageName, const Co
260258
} else if (configuration.typeVisual == VISUALTYPE_AUTO ||
261259
configuration.typeVisual == VISUALTYPE_HEATMAP) {
262260
res = dvs::showHeatMapInBrowser(vecVecDbl, htmlPageName, configuration);
263-
} else if (configuration.typeVisual == VISUALTYPE_SURFACE) {
264-
res = dvs::showSurfaceInBrowser(vecVecDbl, htmlPageName, configuration);
265261
}
266262
return res;
267263
}

array_core/configurator.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ namespace dv {
88
enum config_visualizationTypes {
99
VISUALTYPE_AUTO, //if user not forces some specific type it will be recognized by context
1010
VISUALTYPE_CHART,
11-
VISUALTYPE_HEATMAP,
12-
VISUALTYPE_SURFACE
11+
VISUALTYPE_HEATMAP
1312
};
1413

1514
enum config_colorscales {
@@ -52,28 +51,17 @@ struct heatMapSettings : public commonSettings {
5251
config_colorscales colorSc;
5352
};
5453

55-
struct surfaceSettings : public commonSettings {
56-
surfaceSettings():
57-
colorSc(config_colorscales::COLORSCALE_DEFAULT),
58-
zLabel("Z") {}
59-
config_colorscales colorSc;
60-
std::string zLabel;
61-
};
62-
6354

6455
struct Config {
6556
Config():
6657
typeVisual(VISUALTYPE_AUTO) {}
6758
void reset() {
6859
chart = chartSettings();
6960
heatmap = heatMapSettings();
70-
surf = surfaceSettings();
7161
}
7262

7363
chartSettings chart;
7464
heatMapSettings heatmap;
75-
surfaceSettings surf;
76-
7765
config_visualizationTypes typeVisual;
7866
};
7967

davis_one/davis.cpp

Lines changed: 48 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,6 @@ hovertemplate: 'x:%{x} <br>y:%{y} <br>val:%{z:.}<extra></extra>',
172172
colorbar: {
173173
title: ""
174174
}
175-
}];)";
176-
177-
const char kSurfaceTypePart[]=R"(
178-
type: 'surface',
179-
hovertemplate: 'x:%{x} <br>y:%{y} <br>z:%{z:.}<extra></extra>',
180-
colorbar: {
181-
title: ""
182-
}
183175
}];)";
184176

185177
const char kWarningJSLibAbsentPage[] = R"(
@@ -1306,29 +1298,6 @@ bool createStringLineChartValues(const vector<double>& xValues,
13061298
return true;
13071299
}
13081300

1309-
1310-
1311-
inline bool heatmap_and_surface(const vector<vector<double>>& values,
1312-
const string& title,
1313-
const dv::Config& configuration,
1314-
dv::config_visualizationTypes typeVisual) {
1315-
string page;
1316-
if (!createHtmlPageWithPlotlyJS(values, page, configuration, typeVisual)) {
1317-
return false;
1318-
}
1319-
string pageName;
1320-
mayBeCreateJsWorkingFolder();
1321-
string titleWithoutSpecialChars = dvs::removeSpecialCharacters(title);
1322-
pageName.append("./").append(kOutFolderName).append(titleWithoutSpecialChars).append(".html");
1323-
saveStringToFile(pageName, page);
1324-
if (isPlotlyScriptExists()) {
1325-
openPlotlyHtml(pageName);
1326-
} else {
1327-
showWarningJsAbsentPage();
1328-
}
1329-
return true;// TODO handle different exceptions
1330-
};
1331-
13321301
bool getMatrixValuesFromString(const string& in_values,
13331302
vector<vector<double>>& out_values) {
13341303
istringstream f_lines(in_values);
@@ -1345,10 +1314,9 @@ bool getMatrixValuesFromString(const string& in_values,
13451314
return true;
13461315
};
13471316

1348-
bool createHtmlPageWithPlotlyJS(const std::vector<std::vector<double>>& values,
1349-
string& page,
1350-
const dv::Config& configuration,
1351-
dv::config_visualizationTypes typeVisual) {
1317+
bool createHtmlPageHeatmap(const std::vector<std::vector<double>>& values,
1318+
string& page,
1319+
const dv::Config& configuration) {
13521320
vector<string> args(ARGS_SIZE, "");
13531321
string str_values = "";
13541322
if (!checkThatSizesAreTheSame(values)) {
@@ -1357,13 +1325,37 @@ bool createHtmlPageWithPlotlyJS(const std::vector<std::vector<double>>& values,
13571325
createStringHeatMapValues(values, str_values);
13581326
args[ARG_VALUES] = str_values;
13591327
args[ARG_JS_VER] = kPlotlyJsName;
1328+
args[ARG_MATRIX_TYPE] = kHeatMapTypePart;
1329+
args[ARG_TITLE] = configuration.heatmap.title;
1330+
args[ARG_TITLE_X] = configuration.heatmap.xLabel;
1331+
args[ARG_TITLE_Y] = configuration.heatmap.yLabel;
1332+
args[ARG_ASPECT_RATIO_WIDTH] = dvs::toStringDotSeparator(configuration.heatmap.aspectRatioWidth);
1333+
args[ARG_ASPECT_RATIO_HEIGHT] = dvs::toStringDotSeparator(configuration.heatmap.aspectRatioHeight);
1334+
string paramWH;
1335+
if (configuration.heatmap.aspectRatioWidth > configuration.heatmap.aspectRatioHeight) {
1336+
paramWH = "width";
1337+
} else {
1338+
paramWH = "height";
1339+
}
1340+
string paramWHsecond;
1341+
if (configuration.heatmap.isFitPlotToWindow) {
1342+
if (paramWH == "width") {
1343+
paramWHsecond = "height";
1344+
} else if (paramWH == "height") {
1345+
paramWHsecond = "width";
1346+
}
1347+
} else {
1348+
paramWHsecond = paramWH;
1349+
}
1350+
args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH;
1351+
args[ARG_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE] = paramWHsecond;
1352+
args[ARG_POINT_LINE_SWITCHER_STYLE] = kHtmlComboboxStyleBlock;
1353+
args[ARG_POINT_LINE_SWITCHER_SELECT] = kHtmlComboboxSelectSurfaceMatrixBlock;
1354+
args[ARG_POINT_LINE_SWITCHER_UPDATE_FOO] = kHtmlComboboxUpdateSurfaceMatrixFooBlock;
1355+
args[ARG_DAVIS_LOGO] = kHtmlDavisLogoHyperlinkBlock;
1356+
13601357
dv::config_colorscales clrScale;
1361-
if (typeVisual == dv::VISUALTYPE_HEATMAP)
1362-
clrScale = configuration.heatmap.colorSc;
1363-
else if (typeVisual == dv::VISUALTYPE_SURFACE)
1364-
clrScale = configuration.surf.colorSc;
1365-
else
1366-
return false;
1358+
clrScale = configuration.heatmap.colorSc;
13671359
switch (clrScale) {
13681360
case dv::config_colorscales::COLORSCALE_DEFAULT:
13691361
args[ARG_COLOR_MAP] = kColorMapDefaultPart;
@@ -1396,78 +1388,28 @@ bool createHtmlPageWithPlotlyJS(const std::vector<std::vector<double>>& values,
13961388
args[ARG_COLOR_MAP] = kColorMapPortlandPart;
13971389
break;
13981390
}
1399-
switch (typeVisual) {
1400-
case dv::VISUALTYPE_HEATMAP: {
1401-
args[ARG_MATRIX_TYPE] = kHeatMapTypePart;
1402-
args[ARG_TITLE] = configuration.heatmap.title;
1403-
args[ARG_TITLE_X] = configuration.heatmap.xLabel;
1404-
args[ARG_TITLE_Y] = configuration.heatmap.yLabel;
1405-
args[ARG_ASPECT_RATIO_WIDTH] = dvs::toStringDotSeparator(configuration.heatmap.aspectRatioWidth);
1406-
args[ARG_ASPECT_RATIO_HEIGHT] = dvs::toStringDotSeparator(configuration.heatmap.aspectRatioHeight);
1407-
string paramWH;
1408-
if (configuration.heatmap.aspectRatioWidth > configuration.heatmap.aspectRatioHeight) {
1409-
paramWH = "width";
1410-
} else {
1411-
paramWH = "height";
1412-
}
1413-
string paramWHsecond;
1414-
if (configuration.heatmap.isFitPlotToWindow) {
1415-
if (paramWH == "width") {
1416-
paramWHsecond = "height";
1417-
} else if (paramWH == "height") {
1418-
paramWHsecond = "width";
1419-
}
1420-
} else {
1421-
paramWHsecond = paramWH;
1422-
}
1423-
args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH;
1424-
args[ARG_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE] = paramWHsecond;
1425-
args[ARG_POINT_LINE_SWITCHER_STYLE] = kHtmlComboboxStyleBlock;
1426-
args[ARG_POINT_LINE_SWITCHER_SELECT] = kHtmlComboboxSelectSurfaceMatrixBlock;
1427-
args[ARG_POINT_LINE_SWITCHER_UPDATE_FOO] = kHtmlComboboxUpdateSurfaceMatrixFooBlock;
1428-
args[ARG_DAVIS_LOGO] = kHtmlDavisLogoHyperlinkBlock;
1429-
break;
1430-
}
1431-
case dv::VISUALTYPE_SURFACE: {
1432-
args[ARG_MATRIX_TYPE] = kSurfaceTypePart;
1433-
args[ARG_TITLE] = configuration.surf.title;
1434-
args[ARG_TITLE_X] = configuration.surf.xLabel;
1435-
args[ARG_TITLE_Y] = configuration.surf.yLabel;
1436-
args[ARG_TITLE_Z] = configuration.surf.zLabel;
1437-
args[ARG_ASPECT_RATIO_WIDTH] = dvs::toStringDotSeparator(configuration.surf.aspectRatioWidth);
1438-
args[ARG_ASPECT_RATIO_HEIGHT] = dvs::toStringDotSeparator(configuration.surf.aspectRatioHeight);
1439-
string paramWH;
1440-
if (configuration.surf.aspectRatioWidth > configuration.surf.aspectRatioHeight) {
1441-
paramWH = "width";
1442-
} else {
1443-
paramWH = "height";
1444-
}
1445-
string paramWHsecond;
1446-
if (configuration.surf.isFitPlotToWindow) {
1447-
if (paramWH == "width") {
1448-
paramWHsecond = "height";
1449-
} else if (paramWH == "height") {
1450-
paramWHsecond = "width";
1451-
}
1452-
} else {
1453-
paramWHsecond = paramWH;
1454-
}
1455-
args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH;
1456-
args[ARG_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE] = paramWHsecond;
1457-
args[ARG_DAVIS_LOGO] = kHtmlDavisLogoHyperlinkBlock;
1458-
break;
1459-
}
1460-
default:
1461-
break;
1462-
}
14631391

14641392
make_string(kHtmlModel, args, page);
14651393
return true;
14661394
}
14671395

14681396
bool showHeatMapInBrowser(const vector<vector<double>>& values,
14691397
const string& title, const dv::Config& configuration) {
1470-
return heatmap_and_surface(values, title, configuration, dv::VISUALTYPE_HEATMAP);
1398+
string page;
1399+
if (!createHtmlPageHeatmap(values, page, configuration)) {
1400+
return false;
1401+
}
1402+
string pageName;
1403+
mayBeCreateJsWorkingFolder();
1404+
string titleWithoutSpecialChars = dvs::removeSpecialCharacters(title);
1405+
pageName.append("./").append(kOutFolderName).append(titleWithoutSpecialChars).append(".html");
1406+
saveStringToFile(pageName, page);
1407+
if (isPlotlyScriptExists()) {
1408+
openPlotlyHtml(pageName);
1409+
} else {
1410+
showWarningJsAbsentPage();
1411+
}
1412+
return true;// TODO handle different exceptions
14711413
}
14721414

14731415
bool showHeatMapInBrowser(const string& values,
@@ -1548,19 +1490,6 @@ bool showLineChartInBrowser(const string& values,
15481490
return true;
15491491
};
15501492

1551-
bool showSurfaceInBrowser(const vector<vector<double>>& values,
1552-
const string& title, const dv::Config& configuration) {
1553-
return heatmap_and_surface(values, title, configuration, dv::VISUALTYPE_SURFACE);
1554-
}
1555-
1556-
bool showSurfaceInBrowser(const string& values,
1557-
const string& title, const dv::Config& configuration) {
1558-
vector<vector<double>>surface_values;
1559-
getMatrixValuesFromString(values, surface_values);
1560-
showSurfaceInBrowser(surface_values, title, configuration);
1561-
return true;
1562-
}
1563-
15641493
void showWarningJsAbsentPage() {
15651494
string out;
15661495
string davis_dir;

0 commit comments

Comments
 (0)