diff --git a/Tests/ArrayCoreTest.cpp b/Tests/ArrayCoreTest.cpp index be9376e..2f1f968 100644 --- a/Tests/ArrayCoreTest.cpp +++ b/Tests/ArrayCoreTest.cpp @@ -129,10 +129,7 @@ TEST(ArrayCore, configurator) { config.heatmap.title = "Тестовая матрица"; config.heatmap.colorSc = dv::COLORSCALE_YlGnBu; bool result1 = dv::show(values, "HeatMap", config); - config.typeVisual = dv::VISUALTYPE_SURFACE; - config.surf.title = "This is Surface!!!"; - bool result2 = dv::show(values, "Surface", config); - EXPECT_EQ(result1 && result2, true); + EXPECT_EQ(result1, true); } TEST(ArrayCore, showDefaultSettings) { @@ -165,20 +162,6 @@ TEST(ArrayCore, showHeatMap1_AutoScale) { EXPECT_EQ(result, true); } -TEST(ArrayCore, showSurface) { - EXPECT_EQ(dvs::isPlotlyScriptExists(), true); - vector> values = {{30.3, 40, 98, 76}, {99, 45, 20, 1}, {5, 56, 93, 25}, {45, 23, 90, 2}}; - auto config = dv::Config(); - config.typeVisual = dv::VISUALTYPE_SURFACE; - config.surf.xLabel = "xLabel from Settings"; - config.surf.yLabel = "yLabel from Settings"; - config.surf.zLabel = "zLabel from Settings"; - config.surf.title = "Title from Settings"; - config.surf.colorSc = dv::config_colorscales::COLORSCALE_THERMAL; - bool result = dv::show(values, "showSurface", config); - EXPECT_EQ(result, true); -} - TEST(ArrayCore, showPseudo2D) { int rows = 5; int cols = 3; @@ -360,7 +343,7 @@ TEST(ArrayCore, testMyltiplyHoldOnOff) { dv::holdOn(); dv::show(vec1, "titleHoldOn3"); - dv::show(vec1, "titleHoldOn4"); + dv::show(vec2, "titleHoldOn4"); dv::holdOff(); EXPECT_EQ(v1 && v2, true); diff --git a/Tests/PlotlyLibTest.cpp b/Tests/PlotlyLibTest.cpp index 3c395f3..30c5090 100644 --- a/Tests/PlotlyLibTest.cpp +++ b/Tests/PlotlyLibTest.cpp @@ -9,7 +9,7 @@ TEST(PlotlyMaker, CreateDefaultHeatMapHtmlPageTest) { std::string str_page = "test_page"; auto config = dv::Config(); config.typeVisual = dv::VISUALTYPE_HEATMAP; - bool result = dvs::createHtmlPageWithPlotlyJS(testValues, str_page, config, dv::VISUALTYPE_HEATMAP); + bool result = dvs::createHtmlPageHeatmap(testValues, str_page, config); std::ofstream out("example.html"); if (out.is_open()) { out << str_page.c_str(); @@ -48,15 +48,6 @@ TEST(PlotlyMaker, ShowSunnyHeatMapHtmlPageTest) { EXPECT_EQ(result, true); } -TEST(PlotlyMaker, ShowThermalSurfaceHtmlPageTest) { - std::vector>testValues = {{43, 400, 54, 980}, {200, 36, 400, 55}, {120, 4, 650, 5}}; - std::string str_page = "ThermalSurfacePage"; - auto config = dv::Config(); - config.heatmap.colorSc = dv::config_colorscales::COLORSCALE_THERMAL; - bool result = dvs::showSurfaceInBrowser(testValues, str_page, config); - EXPECT_EQ(result, true); -} - TEST(PlotlyMaker, ShowWarnigJsAbsentPageTest) { dvs::showWarningJsAbsentPage(); } diff --git a/array_core/array_core.h b/array_core/array_core.h index 05338a0..a8d24c4 100644 --- a/array_core/array_core.h +++ b/array_core/array_core.h @@ -93,10 +93,9 @@ bool show(T** data, uint64_t arrRows, uint64_t arrCols, const string& htmlPageNa } bool res = false; if (configuration.typeVisual == VISUALTYPE_AUTO || - configuration.typeVisual == VISUALTYPE_HEATMAP) + configuration.typeVisual == VISUALTYPE_HEATMAP) { res = dvs::showHeatMapInBrowser(vecVecDbl, htmlPageName, configuration); - else if (configuration.typeVisual == VISUALTYPE_SURFACE) - res = dvs::showSurfaceInBrowser(vecVecDbl, htmlPageName, configuration); + } return res; } @@ -122,10 +121,9 @@ bool show(const T* data, uint64_t arrRows, uint64_t arrCols, const string& htmlP } bool res = false; if (configuration.typeVisual == VISUALTYPE_AUTO || - configuration.typeVisual == VISUALTYPE_HEATMAP) + configuration.typeVisual == VISUALTYPE_HEATMAP) { res = dvs::showHeatMapInBrowser(vecVecDbl, htmlPageName, configuration); - else if (configuration.typeVisual == VISUALTYPE_SURFACE) - res = dvs::showSurfaceInBrowser(vecVecDbl, htmlPageName, configuration); + } return res; } @@ -260,8 +258,6 @@ bool show(C const& container_of_containers, const string& htmlPageName, const Co } else if (configuration.typeVisual == VISUALTYPE_AUTO || configuration.typeVisual == VISUALTYPE_HEATMAP) { res = dvs::showHeatMapInBrowser(vecVecDbl, htmlPageName, configuration); - } else if (configuration.typeVisual == VISUALTYPE_SURFACE) { - res = dvs::showSurfaceInBrowser(vecVecDbl, htmlPageName, configuration); } return res; } diff --git a/array_core/configurator.h b/array_core/configurator.h index d104a9c..ba6f215 100644 --- a/array_core/configurator.h +++ b/array_core/configurator.h @@ -8,8 +8,7 @@ namespace dv { enum config_visualizationTypes { VISUALTYPE_AUTO, //if user not forces some specific type it will be recognized by context VISUALTYPE_CHART, - VISUALTYPE_HEATMAP, - VISUALTYPE_SURFACE + VISUALTYPE_HEATMAP }; enum config_colorscales { @@ -52,14 +51,6 @@ struct heatMapSettings : public commonSettings { config_colorscales colorSc; }; -struct surfaceSettings : public commonSettings { - surfaceSettings(): - colorSc(config_colorscales::COLORSCALE_DEFAULT), - zLabel("Z") {} - config_colorscales colorSc; - std::string zLabel; -}; - struct Config { Config(): @@ -67,13 +58,10 @@ struct Config { void reset() { chart = chartSettings(); heatmap = heatMapSettings(); - surf = surfaceSettings(); } chartSettings chart; heatMapSettings heatmap; - surfaceSettings surf; - config_visualizationTypes typeVisual; }; diff --git a/davis_one/davis.cpp b/davis_one/davis.cpp index 82ef5d8..d29c8bc 100644 --- a/davis_one/davis.cpp +++ b/davis_one/davis.cpp @@ -172,14 +172,6 @@ hovertemplate: 'x:%{x}
y:%{y}
val:%{z:.}', colorbar: { title: "" } -}];)"; - - const char kSurfaceTypePart[]=R"( -type: 'surface', -hovertemplate: 'x:%{x}
y:%{y}
z:%{z:.}', -colorbar: { - title: "" -} }];)"; const char kWarningJSLibAbsentPage[] = R"( @@ -1306,29 +1298,6 @@ bool createStringLineChartValues(const vector& xValues, return true; } - - -inline bool heatmap_and_surface(const vector>& values, - const string& title, - const dv::Config& configuration, - dv::config_visualizationTypes typeVisual) { - string page; - if (!createHtmlPageWithPlotlyJS(values, page, configuration, typeVisual)) { - return false; - } - string pageName; - mayBeCreateJsWorkingFolder(); - string titleWithoutSpecialChars = dvs::removeSpecialCharacters(title); - pageName.append("./").append(kOutFolderName).append(titleWithoutSpecialChars).append(".html"); - saveStringToFile(pageName, page); - if (isPlotlyScriptExists()) { - openPlotlyHtml(pageName); - } else { - showWarningJsAbsentPage(); - } - return true;// TODO handle different exceptions -}; - bool getMatrixValuesFromString(const string& in_values, vector>& out_values) { istringstream f_lines(in_values); @@ -1345,10 +1314,9 @@ bool getMatrixValuesFromString(const string& in_values, return true; }; -bool createHtmlPageWithPlotlyJS(const std::vector>& values, - string& page, - const dv::Config& configuration, - dv::config_visualizationTypes typeVisual) { +bool createHtmlPageHeatmap(const std::vector>& values, + string& page, + const dv::Config& configuration) { vector args(ARGS_SIZE, ""); string str_values = ""; if (!checkThatSizesAreTheSame(values)) { @@ -1357,13 +1325,37 @@ bool createHtmlPageWithPlotlyJS(const std::vector>& values, createStringHeatMapValues(values, str_values); args[ARG_VALUES] = str_values; args[ARG_JS_VER] = kPlotlyJsName; + 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"; + } + string paramWHsecond; + if (configuration.heatmap.isFitPlotToWindow) { + if (paramWH == "width") { + paramWHsecond = "height"; + } else if (paramWH == "height") { + paramWHsecond = "width"; + } + } else { + paramWHsecond = paramWH; + } + args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH; + args[ARG_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE] = paramWHsecond; + args[ARG_POINT_LINE_SWITCHER_STYLE] = kHtmlComboboxStyleBlock; + args[ARG_POINT_LINE_SWITCHER_SELECT] = kHtmlComboboxSelectSurfaceMatrixBlock; + args[ARG_POINT_LINE_SWITCHER_UPDATE_FOO] = kHtmlComboboxUpdateSurfaceMatrixFooBlock; + args[ARG_DAVIS_LOGO] = kHtmlDavisLogoHyperlinkBlock; + dv::config_colorscales clrScale; - if (typeVisual == dv::VISUALTYPE_HEATMAP) - clrScale = configuration.heatmap.colorSc; - else if (typeVisual == dv::VISUALTYPE_SURFACE) - clrScale = configuration.surf.colorSc; - else - return false; + clrScale = configuration.heatmap.colorSc; switch (clrScale) { case dv::config_colorscales::COLORSCALE_DEFAULT: args[ARG_COLOR_MAP] = kColorMapDefaultPart; @@ -1396,70 +1388,6 @@ bool createHtmlPageWithPlotlyJS(const std::vector>& values, args[ARG_COLOR_MAP] = kColorMapPortlandPart; break; } - switch (typeVisual) { - 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"; - } - string paramWHsecond; - if (configuration.heatmap.isFitPlotToWindow) { - if (paramWH == "width") { - paramWHsecond = "height"; - } else if (paramWH == "height") { - paramWHsecond = "width"; - } - } else { - paramWHsecond = paramWH; - } - args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH; - args[ARG_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE] = paramWHsecond; - args[ARG_POINT_LINE_SWITCHER_STYLE] = kHtmlComboboxStyleBlock; - args[ARG_POINT_LINE_SWITCHER_SELECT] = kHtmlComboboxSelectSurfaceMatrixBlock; - args[ARG_POINT_LINE_SWITCHER_UPDATE_FOO] = kHtmlComboboxUpdateSurfaceMatrixFooBlock; - args[ARG_DAVIS_LOGO] = kHtmlDavisLogoHyperlinkBlock; - break; - } - 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"; - } - string paramWHsecond; - if (configuration.surf.isFitPlotToWindow) { - if (paramWH == "width") { - paramWHsecond = "height"; - } else if (paramWH == "height") { - paramWHsecond = "width"; - } - } else { - paramWHsecond = paramWH; - } - args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH; - args[ARG_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE] = paramWHsecond; - args[ARG_DAVIS_LOGO] = kHtmlDavisLogoHyperlinkBlock; - break; - } - default: - break; - } make_string(kHtmlModel, args, page); return true; @@ -1467,7 +1395,21 @@ bool createHtmlPageWithPlotlyJS(const std::vector>& values, bool showHeatMapInBrowser(const vector>& values, const string& title, const dv::Config& configuration) { - return heatmap_and_surface(values, title, configuration, dv::VISUALTYPE_HEATMAP); + string page; + if (!createHtmlPageHeatmap(values, page, configuration)) { + return false; + } + string pageName; + mayBeCreateJsWorkingFolder(); + string titleWithoutSpecialChars = dvs::removeSpecialCharacters(title); + pageName.append("./").append(kOutFolderName).append(titleWithoutSpecialChars).append(".html"); + saveStringToFile(pageName, page); + if (isPlotlyScriptExists()) { + openPlotlyHtml(pageName); + } else { + showWarningJsAbsentPage(); + } + return true;// TODO handle different exceptions } bool showHeatMapInBrowser(const string& values, @@ -1548,19 +1490,6 @@ bool showLineChartInBrowser(const string& values, return true; }; -bool showSurfaceInBrowser(const vector>& values, - const string& title, const dv::Config& configuration) { - return heatmap_and_surface(values, title, configuration, dv::VISUALTYPE_SURFACE); -} - -bool showSurfaceInBrowser(const string& values, - const string& title, const dv::Config& configuration) { - vector>surface_values; - getMatrixValuesFromString(values, surface_values); - showSurfaceInBrowser(surface_values, title, configuration); - return true; -} - void showWarningJsAbsentPage() { string out; string davis_dir; diff --git a/davis_one/davis.h b/davis_one/davis.h index 048a6e9..ec869ce 100644 --- a/davis_one/davis.h +++ b/davis_one/davis.h @@ -39,8 +39,7 @@ namespace dv { enum config_visualizationTypes { VISUALTYPE_AUTO, //if user not forces some specific type it will be recognized by context VISUALTYPE_CHART, - VISUALTYPE_HEATMAP, - VISUALTYPE_SURFACE + VISUALTYPE_HEATMAP }; enum config_colorscales { @@ -83,14 +82,6 @@ struct heatMapSettings : public commonSettings { config_colorscales colorSc; }; -struct surfaceSettings : public commonSettings { - surfaceSettings(): - colorSc(config_colorscales::COLORSCALE_DEFAULT), - zLabel("Z") {} - config_colorscales colorSc; - std::string zLabel; -}; - struct Config { Config(): @@ -98,13 +89,10 @@ struct Config { void reset() { chart = chartSettings(); heatmap = heatMapSettings(); - surf = surfaceSettings(); } chartSettings chart; heatMapSettings heatmap; - surfaceSettings surf; - config_visualizationTypes typeVisual; }; @@ -214,7 +202,6 @@ extern const char kColorMapElectricPart[]; extern const char kColorMapPortlandPart[]; extern const char kHeatMapTypePart[]; -extern const char kSurfaceTypePart[]; extern const char kWarningJSLibAbsentPage[]; extern const char kNoFileFoundedPage[]; @@ -442,28 +429,20 @@ using std::vector; using std::istringstream; -bool createHtmlPageWithPlotlyJS(const vector>& values, - string& page, - const dv::Config& configuration, - dv::config_visualizationTypes typeVisual); +bool createHtmlPageHeatmap(const vector>& values, + string& page, + const dv::Config& configuration); bool showHeatMapInBrowser(const vector>& values, const string& title, const dv::Config& configuration); - bool showHeatMapInBrowser(const string& values, const string& title, const dv::Config& configuration); bool showLineChartInBrowser(const vector& values, const string& title, const dv::Config& configuration); bool showLineChartInBrowser(const vector& xValues, const vector& yValues, const string& title, const dv::Config& configuration); - bool showLineChartInBrowser(const string& values, const string& title, const dv::Config& configuration); -bool showSurfaceInBrowser(const vector>& values, const string& title, const dv::Config& configuration); - -bool showSurfaceInBrowser(const string& values, const string& title, const dv::Config& configuration); - void showWarningJsAbsentPage(); - void showReportPage(const string& page, const string& title, const string& svg, const string& description); void showReportFileNotFounded(); @@ -601,10 +580,9 @@ bool show(T** data, uint64_t arrRows, uint64_t arrCols, const string& htmlPageNa } bool res = false; if (configuration.typeVisual == VISUALTYPE_AUTO || - configuration.typeVisual == VISUALTYPE_HEATMAP) + configuration.typeVisual == VISUALTYPE_HEATMAP) { res = dvs::showHeatMapInBrowser(vecVecDbl, htmlPageName, configuration); - else if (configuration.typeVisual == VISUALTYPE_SURFACE) - res = dvs::showSurfaceInBrowser(vecVecDbl, htmlPageName, configuration); + } return res; } @@ -630,10 +608,9 @@ bool show(const T* data, uint64_t arrRows, uint64_t arrCols, const string& htmlP } bool res = false; if (configuration.typeVisual == VISUALTYPE_AUTO || - configuration.typeVisual == VISUALTYPE_HEATMAP) + configuration.typeVisual == VISUALTYPE_HEATMAP) { res = dvs::showHeatMapInBrowser(vecVecDbl, htmlPageName, configuration); - else if (configuration.typeVisual == VISUALTYPE_SURFACE) - res = dvs::showSurfaceInBrowser(vecVecDbl, htmlPageName, configuration); + } return res; } @@ -768,8 +745,6 @@ bool show(C const& container_of_containers, const string& htmlPageName, const Co } else if (configuration.typeVisual == VISUALTYPE_AUTO || configuration.typeVisual == VISUALTYPE_HEATMAP) { res = dvs::showHeatMapInBrowser(vecVecDbl, htmlPageName, configuration); - } else if (configuration.typeVisual == VISUALTYPE_SURFACE) { - res = dvs::showSurfaceInBrowser(vecVecDbl, htmlPageName, configuration); } return res; } diff --git a/gui/davis_gui.cpp b/gui/davis_gui.cpp index 162fe61..687802f 100644 --- a/gui/davis_gui.cpp +++ b/gui/davis_gui.cpp @@ -71,23 +71,10 @@ DavisGUI::DavisGUI(QWidget* parent) mb->setStyleSheet(menuStyle); mb->setFixedSize(QSize(50, 25)); QMenu* menu_root = new QMenu("Menu"); - QMenu* menu_matrix_view = new QMenu("Matrix as"); - menu_root->addMenu(menu_matrix_view); - action_surface = new QAction("surface"); - action_surface->setCheckable(true); - action_heatmap = new QAction("heatmap"); - action_heatmap->setCheckable(true); - action_heatmap->setChecked(true); - connect(action_heatmap, &QAction::triggered, [this]() {action_surface->setChecked(false);}); - connect(action_surface, &QAction::triggered, [this]() {action_heatmap->setChecked(false);}); - menu_matrix_view->setStyleSheet(menuStyle); - menu_matrix_view->addAction(action_surface); - menu_matrix_view->addAction(action_heatmap); - - action_fitPlotToAllWindow = new QAction("Fit graph to window"); - action_fitPlotToAllWindow->setCheckable(true); - menu_root->addAction(action_fitPlotToAllWindow); + action_fitPlotToBrowserWindow = new QAction("Fit graph to window"); + action_fitPlotToBrowserWindow->setCheckable(true); + menu_root->addAction(action_fitPlotToBrowserWindow); action_holidaysSkins = new QAction("Holidays custom skins"); action_holidaysSkins->setCheckable(true); menu_root->addAction(action_holidaysSkins); @@ -231,7 +218,8 @@ void DavisGUI::saveSettings(const QString& fileName) { settings["windowPosX"] = pos().x(); settings["windowPosY"] = pos().y(); settings["isMinStyleWindow"] = m_isMinStyleWindow; - + settings["isUseCustomSkins"] = m_isUseCustomSkins; + settings["isFitGraphToWindow"] = action_fitPlotToBrowserWindow->isChecked(); bool isSaved = jsn::saveJsonObjectToFile(fileName, settings); if (!isSaved) { qWarning("Couldn't save settings file."); @@ -249,7 +237,9 @@ QJsonObject DavisGUI::loadSettings(const QString& fileName) { int y = (screenGeometry.height() - height()) / 2; settings["windowPosX"] = x; settings["windowPosY"] = y; - settings["isMinStyleWindow"] = false;; + settings["isMinStyleWindow"] = false; + settings["isUseCustomSkins"] = false; + settings["isFitGraphToWindow"] = false; } return settings; } @@ -264,6 +254,8 @@ void DavisGUI::applySettings(const QJsonObject& settings) { int x = settings["windowPosX"].toInt(); int y = settings["windowPosY"].toInt(); move(x, y); + action_fitPlotToBrowserWindow->setChecked(settings["isFitGraphToWindow"].toBool()); + action_holidaysSkins->setChecked(settings["isUseCustomSkins"].toBool()); } void DavisGUI::readJsonToPlot(const QString& pathToFile) { @@ -333,7 +325,7 @@ void DavisGUI::readJsonToPlot(const QString& pathToFile) { dv::Config conf; conf.chart.yLabel = attr.value("type").toString().toStdString(); conf.chart.title = attr.value("instrument").toString().toStdString(); - conf.chart.isFitPlotToWindow = action_fitPlotToAllWindow->isChecked(); + conf.chart.isFitPlotToWindow = action_fitPlotToBrowserWindow->isChecked(); dv::show(x_vals, y_vals, dvs::makeUniqueDavisHtmlName(), conf); } return;// выход если это был MATRIX_TO_MATRIX_TYPE @@ -357,9 +349,8 @@ void DavisGUI::readJsonToPlot(const QString& pathToFile) { qDebug() << "MATRIX SIZE: " << matrix_vector.size(); dv::Config conf; - conf.chart.isFitPlotToWindow = action_fitPlotToAllWindow->isChecked(); + conf.chart.isFitPlotToWindow = action_fitPlotToBrowserWindow->isChecked(); conf.heatmap.isFitPlotToWindow = conf.chart.isFitPlotToWindow; - conf.surf.isFitPlotToWindow = conf.chart.isFitPlotToWindow; if (x_vector.empty() == false && y_vector.empty() == false) { dv::show(x_vector.toStdVector(), y_vector.toStdVector(), dvs::makeUniqueDavisHtmlName(), conf); } else if (x_vector.empty() == true && y_vector.empty() == false) { @@ -748,7 +739,7 @@ void DavisGUI::readPlotText(QStringList& str_lines, QString titleTopOfPlotly) { y[i] = data[i][1]; color[i] = data[i][2]; } - dvs::showCloudOfPointsChart(x, y, color, action_fitPlotToAllWindow->isChecked()); + dvs::showCloudOfPointsChart(x, y, color, action_fitPlotToBrowserWindow->isChecked()); return; } @@ -756,21 +747,13 @@ void DavisGUI::readPlotText(QStringList& str_lines, QString titleTopOfPlotly) { if (data.size() == 2 || data[0].size() == 2) { //chartXY dv::Config config; config.chart.title = titleTopOfPlotly.toStdString(); - config.chart.isFitPlotToWindow = action_fitPlotToAllWindow->isChecked(); + config.chart.isFitPlotToWindow = action_fitPlotToBrowserWindow->isChecked(); dv::show(data, dvs::makeUniqueDavisHtmlName(), config); } else if (data.size() > 1 && data[0].size() > 1) { - if (action_heatmap->isChecked()) { - dv::Config config; - config.heatmap.title = titleTopOfPlotly.toStdString(); - config.heatmap.isFitPlotToWindow = action_fitPlotToAllWindow->isChecked(); - dv::show(data, dvs::makeUniqueDavisHtmlName(), config); - } else if (action_surface->isChecked()) { - dv::Config config; - config.surf.title = titleTopOfPlotly.toStdString(); - config.surf.isFitPlotToWindow = action_fitPlotToAllWindow->isChecked(); - config.typeVisual = dv::VISUALTYPE_SURFACE; - dv::show(data, dvs::makeUniqueDavisHtmlName(), config); - } + dv::Config config; + config.heatmap.title = titleTopOfPlotly.toStdString(); + config.heatmap.isFitPlotToWindow = action_fitPlotToBrowserWindow->isChecked(); + dv::show(data, dvs::makeUniqueDavisHtmlName(), config); } else { std::vector showVector; if (data.size() > 1 && data[0].size() == 1) { @@ -785,7 +768,7 @@ void DavisGUI::readPlotText(QStringList& str_lines, QString titleTopOfPlotly) { dv::Config config; config.typeVisual = dv::VISUALTYPE_CHART; config.chart.title = titleTopOfPlotly.toStdString(); - config.chart.isFitPlotToWindow = action_fitPlotToAllWindow->isChecked(); + config.chart.isFitPlotToWindow = action_fitPlotToBrowserWindow->isChecked(); dv::show(showVector, dvs::makeUniqueDavisHtmlName(), config); } } @@ -801,7 +784,7 @@ bool DavisGUI::checkDateTimeVariant(const QStringList& lines) { if (multicharts.empty() == false) { dvs::transponeMatrix(multicharts); - dvs::showMultiChart(dates.toStdString(), multicharts, action_fitPlotToAllWindow->isChecked()); + dvs::showMultiChart(dates.toStdString(), multicharts, action_fitPlotToBrowserWindow->isChecked()); return true; } @@ -809,10 +792,10 @@ bool DavisGUI::checkDateTimeVariant(const QStringList& lines) { return false; if (force.empty() == false) { - dvs::showCloudOfPointsChartStr(dates.toStdString(), values, force, action_fitPlotToAllWindow->isChecked()); + dvs::showCloudOfPointsChartStr(dates.toStdString(), values, force, action_fitPlotToBrowserWindow->isChecked()); return true; } - dvs::showDateTimeChart(dates.toStdString(), values, action_fitPlotToAllWindow->isChecked()); + dvs::showDateTimeChart(dates.toStdString(), values, action_fitPlotToBrowserWindow->isChecked()); return true; } @@ -969,7 +952,7 @@ void DavisGUI::visualizeFiles(const QStringList& file_list) { } } if (dates_list.isEmpty() == false) { - dvs::showMultiChart(dates_list[0].toStdString(), all_values, action_fitPlotToAllWindow->isChecked()); + dvs::showMultiChart(dates_list[0].toStdString(), all_values, action_fitPlotToBrowserWindow->isChecked()); return; } @@ -984,7 +967,7 @@ void DavisGUI::visualizeFiles(const QStringList& file_list) { data.push_back(outY); }; } - dvs::showMultiChart(dvs::vectorToString(x_values), data, action_fitPlotToAllWindow->isChecked()); + dvs::showMultiChart(dvs::vectorToString(x_values), data, action_fitPlotToBrowserWindow->isChecked()); return; } QString filePath = file_list.first(); diff --git a/gui/davis_gui.h b/gui/davis_gui.h index 23c0810..0141f5b 100644 --- a/gui/davis_gui.h +++ b/gui/davis_gui.h @@ -80,7 +80,7 @@ class DavisGUI : public QMainWindow { QPoint m_point; QAction* action_surface; QAction* action_heatmap; - QAction* action_fitPlotToAllWindow; + QAction* action_fitPlotToBrowserWindow; QAction* action_holidaysSkins; About_window* aboutWindow; bool isAboutWindowShowed; @@ -94,6 +94,7 @@ class DavisGUI : public QMainWindow { QLabel* label_gif; bool m_isUseCustomSkins; Skins m_skin; + bool m_isFitGraphToWindow; }; #endif // DAVISGUI_H diff --git a/main.cpp b/main.cpp index 05d78c8..7a663de 100644 --- a/main.cpp +++ b/main.cpp @@ -17,7 +17,6 @@ int main(int argc, char* argv[]) { ("h,help", "davis commands") ("l,linechart", "linechart values", cxxopts::value()) ("m,heatmap", "heatmap values", cxxopts::value()) - ("s,surface", "surface values", cxxopts::value()) ("f,file", "path to input file", cxxopts::value()) ("t,charttype", "chart type", cxxopts::value()) ; @@ -45,11 +44,6 @@ int main(int argc, char* argv[]) { config.typeVisual = dv::VISUALTYPE_HEATMAP; dvs::showHeatMapInBrowser(data, "comand_line_heatmap", config); return EXIT_SUCCESS; - } else if (result.count("surface")) { - config.typeVisual = dv::VISUALTYPE_SURFACE; - auto data = result["surface"].as(); - dvs::showSurfaceInBrowser(data, "comand_line_surface", config); - return EXIT_SUCCESS; } else if (result.count("file")) { auto data_path = result["file"].as(); std::vector> data; diff --git a/plotly_maker/html_parts.cpp b/plotly_maker/html_parts.cpp index cbfccec..b626da4 100644 --- a/plotly_maker/html_parts.cpp +++ b/plotly_maker/html_parts.cpp @@ -135,14 +135,6 @@ hovertemplate: 'x:%{x}
y:%{y}
val:%{z:.}', colorbar: { title: "" } -}];)"; - - const char kSurfaceTypePart[]=R"( -type: 'surface', -hovertemplate: 'x:%{x}
y:%{y}
z:%{z:.}', -colorbar: { - title: "" -} }];)"; const char kWarningJSLibAbsentPage[] = R"( diff --git a/plotly_maker/html_parts.h b/plotly_maker/html_parts.h index 171a896..625f888 100644 --- a/plotly_maker/html_parts.h +++ b/plotly_maker/html_parts.h @@ -94,7 +94,6 @@ extern const char kColorMapElectricPart[]; extern const char kColorMapPortlandPart[]; extern const char kHeatMapTypePart[]; -extern const char kSurfaceTypePart[]; extern const char kWarningJSLibAbsentPage[]; extern const char kNoFileFoundedPage[]; diff --git a/plotly_maker/plotly_maker.cpp b/plotly_maker/plotly_maker.cpp index 04ccc81..fed865c 100644 --- a/plotly_maker/plotly_maker.cpp +++ b/plotly_maker/plotly_maker.cpp @@ -88,29 +88,6 @@ bool createStringLineChartValues(const vector& xValues, return true; } - - -inline bool heatmap_and_surface(const vector>& values, - const string& title, - const dv::Config& configuration, - dv::config_visualizationTypes typeVisual) { - string page; - if (!createHtmlPageWithPlotlyJS(values, page, configuration, typeVisual)) { - return false; - } - string pageName; - mayBeCreateJsWorkingFolder(); - string titleWithoutSpecialChars = dvs::removeSpecialCharacters(title); - pageName.append("./").append(kOutFolderName).append(titleWithoutSpecialChars).append(".html"); - saveStringToFile(pageName, page); - if (isPlotlyScriptExists()) { - openPlotlyHtml(pageName); - } else { - showWarningJsAbsentPage(); - } - return true;// TODO handle different exceptions -}; - bool getMatrixValuesFromString(const string& in_values, vector>& out_values) { istringstream f_lines(in_values); @@ -127,10 +104,9 @@ bool getMatrixValuesFromString(const string& in_values, return true; }; -bool createHtmlPageWithPlotlyJS(const std::vector>& values, - string& page, - const dv::Config& configuration, - dv::config_visualizationTypes typeVisual) { +bool createHtmlPageHeatmap(const std::vector>& values, + string& page, + const dv::Config& configuration) { vector args(ARGS_SIZE, ""); string str_values = ""; if (!checkThatSizesAreTheSame(values)) { @@ -139,13 +115,37 @@ bool createHtmlPageWithPlotlyJS(const std::vector>& values, createStringHeatMapValues(values, str_values); args[ARG_VALUES] = str_values; args[ARG_JS_VER] = kPlotlyJsName; + 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"; + } + string paramWHsecond; + if (configuration.heatmap.isFitPlotToWindow) { + if (paramWH == "width") { + paramWHsecond = "height"; + } else if (paramWH == "height") { + paramWHsecond = "width"; + } + } else { + paramWHsecond = paramWH; + } + args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH; + args[ARG_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE] = paramWHsecond; + args[ARG_POINT_LINE_SWITCHER_STYLE] = kHtmlComboboxStyleBlock; + args[ARG_POINT_LINE_SWITCHER_SELECT] = kHtmlComboboxSelectSurfaceMatrixBlock; + args[ARG_POINT_LINE_SWITCHER_UPDATE_FOO] = kHtmlComboboxUpdateSurfaceMatrixFooBlock; + args[ARG_DAVIS_LOGO] = kHtmlDavisLogoHyperlinkBlock; + dv::config_colorscales clrScale; - if (typeVisual == dv::VISUALTYPE_HEATMAP) - clrScale = configuration.heatmap.colorSc; - else if (typeVisual == dv::VISUALTYPE_SURFACE) - clrScale = configuration.surf.colorSc; - else - return false; + clrScale = configuration.heatmap.colorSc; switch (clrScale) { case dv::config_colorscales::COLORSCALE_DEFAULT: args[ARG_COLOR_MAP] = kColorMapDefaultPart; @@ -178,70 +178,6 @@ bool createHtmlPageWithPlotlyJS(const std::vector>& values, args[ARG_COLOR_MAP] = kColorMapPortlandPart; break; } - switch (typeVisual) { - 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"; - } - string paramWHsecond; - if (configuration.heatmap.isFitPlotToWindow) { - if (paramWH == "width") { - paramWHsecond = "height"; - } else if (paramWH == "height") { - paramWHsecond = "width"; - } - } else { - paramWHsecond = paramWH; - } - args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH; - args[ARG_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE] = paramWHsecond; - args[ARG_POINT_LINE_SWITCHER_STYLE] = kHtmlComboboxStyleBlock; - args[ARG_POINT_LINE_SWITCHER_SELECT] = kHtmlComboboxSelectSurfaceMatrixBlock; - args[ARG_POINT_LINE_SWITCHER_UPDATE_FOO] = kHtmlComboboxUpdateSurfaceMatrixFooBlock; - args[ARG_DAVIS_LOGO] = kHtmlDavisLogoHyperlinkBlock; - break; - } - 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"; - } - string paramWHsecond; - if (configuration.surf.isFitPlotToWindow) { - if (paramWH == "width") { - paramWHsecond = "height"; - } else if (paramWH == "height") { - paramWHsecond = "width"; - } - } else { - paramWHsecond = paramWH; - } - args[ARG_ASPECT_WIDTH_OR_HEIGHT] = paramWH; - args[ARG_ASPECT_WIDTH_OR_HEIGHT_FOR_AUTOSCALE] = paramWHsecond; - args[ARG_DAVIS_LOGO] = kHtmlDavisLogoHyperlinkBlock; - break; - } - default: - break; - } make_string(kHtmlModel, args, page); return true; @@ -249,7 +185,21 @@ bool createHtmlPageWithPlotlyJS(const std::vector>& values, bool showHeatMapInBrowser(const vector>& values, const string& title, const dv::Config& configuration) { - return heatmap_and_surface(values, title, configuration, dv::VISUALTYPE_HEATMAP); + string page; + if (!createHtmlPageHeatmap(values, page, configuration)) { + return false; + } + string pageName; + mayBeCreateJsWorkingFolder(); + string titleWithoutSpecialChars = dvs::removeSpecialCharacters(title); + pageName.append("./").append(kOutFolderName).append(titleWithoutSpecialChars).append(".html"); + saveStringToFile(pageName, page); + if (isPlotlyScriptExists()) { + openPlotlyHtml(pageName); + } else { + showWarningJsAbsentPage(); + } + return true;// TODO handle different exceptions } bool showHeatMapInBrowser(const string& values, @@ -330,19 +280,6 @@ bool showLineChartInBrowser(const string& values, return true; }; -bool showSurfaceInBrowser(const vector>& values, - const string& title, const dv::Config& configuration) { - return heatmap_and_surface(values, title, configuration, dv::VISUALTYPE_SURFACE); -} - -bool showSurfaceInBrowser(const string& values, - const string& title, const dv::Config& configuration) { - vector>surface_values; - getMatrixValuesFromString(values, surface_values); - showSurfaceInBrowser(surface_values, title, configuration); - return true; -} - void showWarningJsAbsentPage() { string out; string davis_dir; diff --git a/plotly_maker/plotly_maker.h b/plotly_maker/plotly_maker.h index b950471..a61d5c1 100644 --- a/plotly_maker/plotly_maker.h +++ b/plotly_maker/plotly_maker.h @@ -17,28 +17,20 @@ using std::vector; using std::istringstream; -bool createHtmlPageWithPlotlyJS(const vector>& values, - string& page, - const dv::Config& configuration, - dv::config_visualizationTypes typeVisual); +bool createHtmlPageHeatmap(const vector>& values, + string& page, + const dv::Config& configuration); bool showHeatMapInBrowser(const vector>& values, const string& title, const dv::Config& configuration); - bool showHeatMapInBrowser(const string& values, const string& title, const dv::Config& configuration); bool showLineChartInBrowser(const vector& values, const string& title, const dv::Config& configuration); bool showLineChartInBrowser(const vector& xValues, const vector& yValues, const string& title, const dv::Config& configuration); - bool showLineChartInBrowser(const string& values, const string& title, const dv::Config& configuration); -bool showSurfaceInBrowser(const vector>& values, const string& title, const dv::Config& configuration); - -bool showSurfaceInBrowser(const string& values, const string& title, const dv::Config& configuration); - void showWarningJsAbsentPage(); - void showReportPage(const string& page, const string& title, const string& svg, const string& description); void showReportFileNotFounded();