@@ -172,14 +172,6 @@ hovertemplate: 'x:%{x} <br>y:%{y} <br>val:%{z:.}<extra></extra>',
172
172
colorbar: {
173
173
title: ""
174
174
}
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
- }
183
175
}];)" ;
184
176
185
177
const char kWarningJSLibAbsentPage [] = R"(
@@ -1306,29 +1298,6 @@ bool createStringLineChartValues(const vector<double>& xValues,
1306
1298
return true ;
1307
1299
}
1308
1300
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
-
1332
1301
bool getMatrixValuesFromString (const string& in_values,
1333
1302
vector<vector<double >>& out_values) {
1334
1303
istringstream f_lines (in_values);
@@ -1345,10 +1314,10 @@ bool getMatrixValuesFromString(const string& in_values,
1345
1314
return true ;
1346
1315
};
1347
1316
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,
1320
+ dv::config_visualizationTypes typeVisual) {
1352
1321
vector<string> args (ARGS_SIZE, " " );
1353
1322
string str_values = " " ;
1354
1323
if (!checkThatSizesAreTheSame (values)) {
@@ -1357,13 +1326,37 @@ bool createHtmlPageWithPlotlyJS(const std::vector<std::vector<double>>& values,
1357
1326
createStringHeatMapValues (values, str_values);
1358
1327
args[ARG_VALUES] = str_values;
1359
1328
args[ARG_JS_VER] = kPlotlyJsName ;
1329
+ args[ARG_MATRIX_TYPE] = kHeatMapTypePart ;
1330
+ args[ARG_TITLE] = configuration.heatmap .title ;
1331
+ args[ARG_TITLE_X] = configuration.heatmap .xLabel ;
1332
+ args[ARG_TITLE_Y] = configuration.heatmap .yLabel ;
1333
+ args[ARG_ASPECT_RATIO_WIDTH] = dvs::toStringDotSeparator (configuration.heatmap .aspectRatioWidth );
1334
+ args[ARG_ASPECT_RATIO_HEIGHT] = dvs::toStringDotSeparator (configuration.heatmap .aspectRatioHeight );
1335
+ string paramWH;
1336
+ if (configuration.heatmap .aspectRatioWidth > configuration.heatmap .aspectRatioHeight ) {
1337
+ paramWH = " width" ;
1338
+ } else {
1339
+ paramWH = " height" ;
1340
+ }
1341
+ string paramWHsecond;
1342
+ if (configuration.heatmap .isFitPlotToWindow ) {
1343
+ if (paramWH == " width" ) {
1344
+ paramWHsecond = " height" ;
1345
+ } else if (paramWH == " height" ) {
1346
+ paramWHsecond = " width" ;
1347
+ }
1348
+ } else {
1349
+ paramWHsecond = paramWH;
1350
+ }
1351
+ args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH;
1352
+ args[ARG_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE] = paramWHsecond;
1353
+ args[ARG_POINT_LINE_SWITCHER_STYLE] = kHtmlComboboxStyleBlock ;
1354
+ args[ARG_POINT_LINE_SWITCHER_SELECT] = kHtmlComboboxSelectSurfaceMatrixBlock ;
1355
+ args[ARG_POINT_LINE_SWITCHER_UPDATE_FOO] = kHtmlComboboxUpdateSurfaceMatrixFooBlock ;
1356
+ args[ARG_DAVIS_LOGO] = kHtmlDavisLogoHyperlinkBlock ;
1357
+
1360
1358
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 ;
1359
+ clrScale = configuration.heatmap .colorSc ;
1367
1360
switch (clrScale) {
1368
1361
case dv::config_colorscales::COLORSCALE_DEFAULT:
1369
1362
args[ARG_COLOR_MAP] = kColorMapDefaultPart ;
@@ -1396,78 +1389,28 @@ bool createHtmlPageWithPlotlyJS(const std::vector<std::vector<double>>& values,
1396
1389
args[ARG_COLOR_MAP] = kColorMapPortlandPart ;
1397
1390
break ;
1398
1391
}
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
- }
1463
1392
1464
1393
make_string (kHtmlModel , args, page);
1465
1394
return true ;
1466
1395
}
1467
1396
1468
1397
bool showHeatMapInBrowser (const vector<vector<double >>& values,
1469
1398
const string& title, const dv::Config& configuration) {
1470
- return heatmap_and_surface (values, title, configuration, dv::VISUALTYPE_HEATMAP);
1399
+ string page;
1400
+ if (!createHtmlPageHeatmap (values, page, configuration, dv::VISUALTYPE_HEATMAP)) {
1401
+ return false ;
1402
+ }
1403
+ string pageName;
1404
+ mayBeCreateJsWorkingFolder ();
1405
+ string titleWithoutSpecialChars = dvs::removeSpecialCharacters (title);
1406
+ pageName.append (" ./" ).append (kOutFolderName ).append (titleWithoutSpecialChars).append (" .html" );
1407
+ saveStringToFile (pageName, page);
1408
+ if (isPlotlyScriptExists ()) {
1409
+ openPlotlyHtml (pageName);
1410
+ } else {
1411
+ showWarningJsAbsentPage ();
1412
+ }
1413
+ return true ;// TODO handle different exceptions
1471
1414
}
1472
1415
1473
1416
bool showHeatMapInBrowser (const string& values,
@@ -1548,19 +1491,6 @@ bool showLineChartInBrowser(const string& values,
1548
1491
return true ;
1549
1492
};
1550
1493
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
-
1564
1494
void showWarningJsAbsentPage () {
1565
1495
string out;
1566
1496
string davis_dir;
0 commit comments