From 1d79fb1d77bca4b158f612eea9fcbaf81b482399 Mon Sep 17 00:00:00 2001 From: "Alice (KasimovAM)" Date: Sun, 4 Jun 2023 15:56:33 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=BF=D0=BE=D0=BB=D0=BD=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D0=B0=20=D1=81?= =?UTF-8?q?=20svg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ doctest.h | 2 +- histogram.cpp | 2 +- histogram_internal.h | 6 ++++ lab01.cbp | 5 +++ lab01.depend | 23 ++++++++++++++ lab01.layout | 35 ++++++++++++++++++++ main.cpp | 3 +- svg.cpp | 76 ++++++++++++++++++++++++++++++++++++++++++++ svg.h | 9 ++++++ unittest.cbp | 41 ++++++++++++++++++++++++ 11 files changed, 201 insertions(+), 3 deletions(-) create mode 100644 histogram_internal.h create mode 100644 lab01.depend create mode 100644 lab01.layout create mode 100644 svg.cpp create mode 100644 svg.h create mode 100644 unittest.cbp diff --git a/.gitignore b/.gitignore index 4c7473d..4526501 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /bin /obj +/unittest.depend +/unittest.layout diff --git a/doctest.h b/doctest.h index 5c754cd..826f0f5 100644 --- a/doctest.h +++ b/doctest.h @@ -5724,7 +5724,7 @@ namespace { std::tm timeInfo; #ifdef DOCTEST_PLATFORM_WINDOWS - gmtime_s(&timeInfo, &rawtime); +// gmtime_s(&timeInfo, &rawtime); #else // DOCTEST_PLATFORM_WINDOWS gmtime_r(&rawtime, &timeInfo); #endif // DOCTEST_PLATFORM_WINDOWS diff --git a/histogram.cpp b/histogram.cpp index f18a01b..2cfda1a 100644 --- a/histogram.cpp +++ b/histogram.cpp @@ -3,7 +3,7 @@ #include using namespace std; -void find_minmax(const vector &numbers, double &min, double &max) +void find_minmax(vector numbers, double &min, double &max) { min = numbers[0]; max = numbers[0]; diff --git a/histogram_internal.h b/histogram_internal.h new file mode 100644 index 0000000..25954d1 --- /dev/null +++ b/histogram_internal.h @@ -0,0 +1,6 @@ +#ifndef HISTOGRAM_INTERNAL_H_INCLUDED +#define HISTOGRAM_INTERNAL_H_INCLUDED +#include +using namespace std; +void find_minmax(vector numbers, double &min, double &max); +#endif // HISTOGRAM_INTERNAL_H_INCLUDED diff --git a/lab01.cbp b/lab01.cbp index d541ad7..2617c5d 100644 --- a/lab01.cbp +++ b/lab01.cbp @@ -32,7 +32,12 @@ + + + + + diff --git a/lab01.depend b/lab01.depend new file mode 100644 index 0000000..7713bbd --- /dev/null +++ b/lab01.depend @@ -0,0 +1,23 @@ +# depslib dependency file v1.0 +1685290831 source:c:\users\kasma\desktop\lab03\lab01\main.cpp + + + + "histogram.h" + "text.h" + +1685289785 source:c:\users\kasma\desktop\lab03\lab01\text.cpp + + + "text.h" + +1685289785 c:\users\kasma\desktop\lab03\lab01\text.h + +1685291232 c:\users\kasma\desktop\lab03\lab01\histogram.h + + +1685292419 source:c:\users\kasma\desktop\lab03\lab01\histogram.cpp + "histogram.h" + + + diff --git a/lab01.layout b/lab01.layout new file mode 100644 index 0000000..e5e9942 --- /dev/null +++ b/lab01.layout @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/main.cpp b/main.cpp index 4e37020..ac6d23f 100644 --- a/main.cpp +++ b/main.cpp @@ -3,6 +3,7 @@ #include #include "histogram.h" #include "text.h" +#include "svg.h" using namespace std; @@ -31,7 +32,7 @@ int main() { auto in = input_data(); auto bins = make_histogram(in.numbers, in.bin_count); - show_histogram_text(bins, in.bin_count); + show_histogram_svg(bins); getch(); return 0; } diff --git a/svg.cpp b/svg.cpp new file mode 100644 index 0000000..fac3aa4 --- /dev/null +++ b/svg.cpp @@ -0,0 +1,76 @@ +#include +#include +#include +#include +#include +#include "svg.h" +using namespace std; + +void +svg_begin(double width, double height) +{ + cout << "\n"; + cout << "\n"; +} + +void +svg_end() +{ + cout << "\n"; +} + +void +svg_text(double left, double baseline, string text) +{ + cout << "" << text << ""; +} + +void +svg_rect(double x, double y, double width, double height, string stroke = "black", string fill = "black") +{ + cout << ""; + +} + + +void +show_histogram_svg(const vector& 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 auto BLACK = "black"; + const auto RED = "red"; + const auto MAX_WIDTH = IMAGE_WIDTH-TEXT_WIDTH; + + + svg_begin(IMAGE_WIDTH,IMAGE_HEIGHT); + + double top = 0; + double max_count = bins[0]; + for (size_t i = 0; i < bins.size(); i++) + { + if (max_count + +void +show_histogram_svg(const std::vector& bins); + + +#endif // SVG_H_INCLUDED diff --git a/unittest.cbp b/unittest.cbp new file mode 100644 index 0000000..534f497 --- /dev/null +++ b/unittest.cbp @@ -0,0 +1,41 @@ + + + + + +