Skip to content

Commit 8250a53

Browse files
committed
добавлен код
1 parent 015c92c commit 8250a53

File tree

8 files changed

+581
-0
lines changed

8 files changed

+581
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/gl2ps"]
2+
path = lib/gl2ps
3+
url = https://gitlab.onelab.info/gl2ps/gl2ps.git

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,51 @@
11
# easy_plot_cpp
22
Простая библиотека C++ для рисования графиков
3+
4+
### Описание
5+
6+
Данная библиотека позволяет рисовать простые графики.
7+
Пример:
8+
![example_0 example](img/example_0.png)
9+
10+
### Как установить?
11+
12+
* Инструкция для *Code::Blocks* и компилятора *mingw*
13+
14+
Подключить библиотеку *freeglut* или *freeglut_static*, а также *opengl32*, *winmm*, *gdi32*.
15+
Подключить в проекте заголовочный файл *include/easy_plot.hpp*
16+
Указать С++11 или выше
17+
18+
Для проверки можно запустить код:
19+
20+
```C++
21+
#include "easy_plot.hpp"
22+
23+
int main(int argc, char* argv[]) {
24+
easy_plot::init(&argc, argv);
25+
26+
std::vector<double> x = {0,1,0,1,2,0,1};
27+
easy_plot::plot("X", x);
28+
29+
// ставим красный цвет линии
30+
std::vector<double> y = {0,2,3,4,2,0,1};
31+
easy_plot::plot("Y", y, easy_plot::LineSpec(1,0,0));
32+
33+
std::vector<double> x2 = {0,2,6,7,8,10,12};
34+
easy_plot::plot("XY", x2, y, easy_plot::LineSpec(1,1,0));
35+
36+
// выводим три графика в одном
37+
easy_plot::plot<double>("Y1Y2Y3", 3, x, easy_plot::LineSpec(1,0,0), x2, easy_plot::LineSpec(1,0,1), y, easy_plot::LineSpec(0,1,0));
38+
39+
while(true) {
40+
std::this_thread::yield();
41+
}
42+
return 0;
43+
}
44+
```
45+
46+
### Полезные ссылки
47+
48+
* *GLUT* (https://www.opengl.org/resources/libraries/glut/)[https://www.opengl.org/resources/libraries/glut/]
49+
* *FreeGLUT* (http://freeglut.sourceforge.net/)[http://freeglut.sourceforge.net/]
50+
* *GL2PS* (http://www.geuz.org/gl2ps/)[http://www.geuz.org/gl2ps/]
51+
* *GL2PS gitlab* (https://gitlab.onelab.info/gl2ps/gl2ps)[https://gitlab.onelab.info/gl2ps/gl2ps]
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
2+
<CodeBlocks_project_file>
3+
<FileVersion major="1" minor="6" />
4+
<Project>
5+
<Option title="example_opengl" />
6+
<Option pch_mode="2" />
7+
<Option compiler="mingw_64_7_3_0" />
8+
<Build>
9+
<Target title="Debug">
10+
<Option output="bin/Debug/example_opengl" prefix_auto="1" extension_auto="1" />
11+
<Option object_output="obj/Debug/" />
12+
<Option type="1" />
13+
<Option compiler="mingw_64_7_3_0" />
14+
<Compiler>
15+
<Add option="-g" />
16+
</Compiler>
17+
</Target>
18+
<Target title="Release">
19+
<Option output="bin/Release/example_opengl" prefix_auto="1" extension_auto="1" />
20+
<Option object_output="obj/Release/" />
21+
<Option type="1" />
22+
<Option compiler="mingw_64_7_3_0" />
23+
<Compiler>
24+
<Add option="-O2" />
25+
<Add option="-std=c++11" />
26+
<Add option="-DFREEGLUT_STATIC" />
27+
<Add directory="../../lib/gl2ps" />
28+
<Add directory="../../lib/mingw/freeglut-MinGW-3.0.0-1.mp/freeglut/include" />
29+
<Add directory="../../lib/mingw/freeglut-MinGW-3.0.0-1.mp/freeglut/lib/x64" />
30+
<Add directory="../../include" />
31+
</Compiler>
32+
<Linker>
33+
<Add option="-s" />
34+
<Add library="freeglut_static" />
35+
<Add library="opengl32" />
36+
<Add library="winmm" />
37+
<Add library="gdi32" />
38+
<Add directory="../../lib/gl2ps" />
39+
<Add directory="../../lib/mingw/freeglut-MinGW-3.0.0-1.mp/freeglut/lib/x64" />
40+
<Add directory="../../include" />
41+
</Linker>
42+
</Target>
43+
</Build>
44+
<Compiler>
45+
<Add option="-Wall" />
46+
<Add option="-fexceptions" />
47+
</Compiler>
48+
<Unit filename="../../include/easy_plot.cpp" />
49+
<Unit filename="../../include/easy_plot.hpp" />
50+
<Unit filename="../../lib/gl2ps/gl2ps.c">
51+
<Option compilerVar="CC" />
52+
</Unit>
53+
<Unit filename="../../lib/gl2ps/gl2ps.h" />
54+
<Unit filename="main.cpp" />
55+
<Extensions>
56+
<code_completion />
57+
<envvars />
58+
<debugger />
59+
<lib_finder disable_auto="1" />
60+
</Extensions>
61+
</Project>
62+
</CodeBlocks_project_file>

code_blocks/example_opengl/main.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include <iostream>
2+
#include "easy_plot.hpp"
3+
4+
using namespace std;
5+
6+
int main(int argc, char* argv[]) {
7+
cout << "Hello world!" << endl;
8+
9+
easy_plot::init(&argc, argv);
10+
std::vector<double> test1_x = {0,1,0,1,2,0,1};
11+
easy_plot::plot("test1", test1_x);
12+
13+
std::vector<double> test2_x = {0,2,3,4,2,0,1};
14+
easy_plot::plot("test2", test2_x);
15+
16+
std::vector<double> test3_x = {0,2,6,7,8,10,12};
17+
easy_plot::plot("test3", test3_x, test2_x, easy_plot::LineSpec(1,1,0));
18+
19+
easy_plot::plot<double>("test4", 3, test1_x, easy_plot::LineSpec(1,0,0), test2_x, easy_plot::LineSpec(1,0,1), test3_x, easy_plot::LineSpec(0,1,0));
20+
21+
while(true) {
22+
std::this_thread::yield();
23+
}
24+
return 0;
25+
}

img/example_0.png

1.71 KB
Loading

include/easy_plot.cpp

Whitespace-only changes.

0 commit comments

Comments
 (0)