@@ -172,14 +172,6 @@ hovertemplate: 'x:%{x} <br>y:%{y} <br>val:%{z:.}<extra></extra>',
172172colorbar: {
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
185177const 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-
13321301bool 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
14681396bool 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
14731415bool 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-
15641493void showWarningJsAbsentPage () {
15651494 string out;
15661495 string davis_dir;
0 commit comments