From 3203c3bd3edea94267e99a196fdbf771b2755a3e Mon Sep 17 00:00:00 2001 From: EfremovSI <yefremovsi@mpei.ru> Date: Sat, 20 Apr 2024 16:50:15 +0000 Subject: [PATCH] revert 15fb696925e126dc2a0ce3c442a4b835bd041f1f MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit revert code: вывод гистограммы в формате SVG + хеддер-файлы проекта --- .gitignore | 2 -- hist_proc.h | 7 ------- histogram.h | 9 --------- lab003.cbp | 4 ---- main.cpp | 1 - svg.cpp | 52 ---------------------------------------------------- svg.h | 6 ++++++ text.h | 7 ------- 8 files changed, 6 insertions(+), 82 deletions(-) delete mode 100644 .gitignore delete mode 100644 hist_proc.h delete mode 100644 histogram.h delete mode 100644 text.h diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 4c7473d..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/bin -/obj diff --git a/hist_proc.h b/hist_proc.h deleted file mode 100644 index ae505d2..0000000 --- a/hist_proc.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef HIST_PROC_H_INCLUDED -#define HIST_PROC_H_INCLUDED - -std::vector<size_t> -make_histogram_proc(const std::vector<double> numbers, size_t bin_count, std::vector<size_t> bins); - -#endif // HIST_PROC_H_INCLUDED diff --git a/histogram.h b/histogram.h deleted file mode 100644 index aab82b8..0000000 --- a/histogram.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef HISTOGRAM_H_INCLUDED -#define HISTOGRAM_H_INCLUDED -#include <iostream> -#include <vector> - -std::vector<size_t> -make_histogram(const std::vector<double> numbers, size_t bin_count); - -#endif // HISTOGRAM_H_INCLUDED diff --git a/lab003.cbp b/lab003.cbp index bce77cc..45b22cf 100644 --- a/lab003.cbp +++ b/lab003.cbp @@ -38,10 +38,6 @@ <Unit filename="histogram.h" /> <Unit filename="histogram_internal.h" /> <Unit filename="main.cpp" /> - <Unit filename="svg.cpp" /> - <Unit filename="svg.h"> - <Option target="<{~None~}>" /> - </Unit> <Unit filename="text.cpp" /> <Unit filename="text.h" /> <Extensions> diff --git a/main.cpp b/main.cpp index b71ca3a..97ef452 100644 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,5 @@ #include <iostream> #include <vector> -#include <string> #include <hist_proc.h> #include "histogram.h" #include <text.h> diff --git a/svg.cpp b/svg.cpp index 11e48d9..94f000c 100644 --- a/svg.cpp +++ b/svg.cpp @@ -1,6 +1,5 @@ #include <iostream> #include <vector> -#include <string> #include <svg.h> using namespace std; @@ -20,59 +19,8 @@ svg_end() { cout << "</svg>\n"; } -void -svg_text(double left, double baseline, string text) { - cout << "<text x='"<< left << "' y='"<< baseline << "'> "<< text <<" </text>"; -} - -void -svg_rect(double x, double y, double width, double height){ - cout << "<rect x='"<<x<<"' y='"<<y<<"' width='"<<width<<"' height='"<<height<<"' stroke ='cyan' fill='#fce166' />\n"; -} - void show_histogram_svg(const vector<size_t>& bins) { - const auto IMAGE_WIDTH = 400; - const auto IMAGE_HEIGHT = 300; - const auto TEXT_LEFT = 20; - const auto TEXT_BASELINE = 20; - const auto TEXT_WIDTH = 50; - const auto BIN_HEIGHT = 30; - const auto BLOCK_WIDTH = 10; - const double SCALE = IMAGE_WIDTH - TEXT_WIDTH; svg_begin(400, 300); - - - double max_count = 0; - for (double x: bins) { - if (x > max_count) { - max_count = x; - } - } - double top = 0; - if ((max_count*BLOCK_WIDTH)>SCALE){ - for (size_t bin : bins) { - const double bin_width = SCALE * ( bin / max_count); - svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin)); - svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT); - top += BIN_HEIGHT; - cout << endl; - cout << bin_width; - } - } - else{ - for (size_t bin : bins) { - const double bin_width = BLOCK_WIDTH * bin; - svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bin)); - svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT); - top += BIN_HEIGHT; - cout << endl; - cout << bin_width; -} - } svg_end(); - } - - - diff --git a/svg.h b/svg.h index ac36df3..0c45c32 100644 --- a/svg.h +++ b/svg.h @@ -1,6 +1,12 @@ #ifndef SVG_H_INCLUDED #define SVG_H_INCLUDED +void +svg_begin(double width, double height); + +void +svg_end(); + void show_histogram_svg(const std::vector<size_t>& bins); diff --git a/text.h b/text.h deleted file mode 100644 index a7006f9..0000000 --- a/text.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef TEXT_H_INCLUDED -#define TEXT_H_INCLUDED - -void -show_histogram(size_t bin_count, std::vector<size_t> bins, std::vector<size_t> procent); - -#endif // TEXT_H_INCLUDED