@@ -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,9 @@ 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) {
1352
1320
vector<string> args (ARGS_SIZE, " " );
1353
1321
string str_values = " " ;
1354
1322
if (!checkThatSizesAreTheSame (values)) {
@@ -1357,13 +1325,37 @@ bool createHtmlPageWithPlotlyJS(const std::vector<std::vector<double>>& values,
1357
1325
createStringHeatMapValues (values, str_values);
1358
1326
args[ARG_VALUES] = str_values;
1359
1327
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
+
1360
1357
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 ;
1367
1359
switch (clrScale) {
1368
1360
case dv::config_colorscales::COLORSCALE_DEFAULT:
1369
1361
args[ARG_COLOR_MAP] = kColorMapDefaultPart ;
@@ -1396,78 +1388,28 @@ bool createHtmlPageWithPlotlyJS(const std::vector<std::vector<double>>& values,
1396
1388
args[ARG_COLOR_MAP] = kColorMapPortlandPart ;
1397
1389
break ;
1398
1390
}
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
1391
1464
1392
make_string (kHtmlModel , args, page);
1465
1393
return true ;
1466
1394
}
1467
1395
1468
1396
bool showHeatMapInBrowser (const vector<vector<double >>& values,
1469
1397
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
1471
1413
}
1472
1414
1473
1415
bool showHeatMapInBrowser (const string& values,
@@ -1548,19 +1490,6 @@ bool showLineChartInBrowser(const string& values,
1548
1490
return true ;
1549
1491
};
1550
1492
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
1493
void showWarningJsAbsentPage () {
1565
1494
string out;
1566
1495
string davis_dir;
0 commit comments