From de18073b6990a786260effb24b25b14246e545f4 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Thu, 7 Nov 2019 14:01:21 +0000 Subject: [PATCH 1/5] + ci pipeline --- .ci/clang-tidy.sh | 32 ++++++++++++++++++++++ .gitlab-ci.yml | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 .ci/clang-tidy.sh create mode 100644 .gitlab-ci.yml diff --git a/.ci/clang-tidy.sh b/.ci/clang-tidy.sh new file mode 100644 index 0000000..eae5b12 --- /dev/null +++ b/.ci/clang-tidy.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +echo "Doing clang-tidy..." +bool=false +# explicitly set IFS to contain only a line feed +IFS=' +' +filelist="$(find . -not \( -path './client/cpptoml/*' -prune \) -type f ! -name "$(printf "*\n*")")" +for file in $filelist; do + if echo "$file" | grep -q -E ".*\.cpp$" ; then + #Extra check missing dependencies due to clang-tidy doesn't toggle exit code. + clang_tidy_lib_check="$(clang-tidy -warnings-as-errors='*' -header-filter='.*,-cpptoml.hpp' -checks='*,-llvm-header-guard,-fuchsia-statically-constructed-objects,-fuchsia-default-arguments,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init' "$file" -- -I. -std=c++14 2>&1)" + for tidy_line in $clang_tidy_lib_check; do + echo "$tidy_line" | grep -q -v -E "^Error while processing*" + if [ $? -eq 1 ]; then + bool=true + fi + echo "$tidy_line" | grep -q -v -E ".* error: .*" + if [ $? -eq 1 ]; then + bool=true + fi + echo "$tidy_line" + done + fi +done +if $bool; then + exit 1 +else + echo "No clang-tidy errors found." +fi + +exit 0 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..32d0eb7 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,68 @@ +--- + +image: samueldebruyn/debian-git:latest + +stages: + - style + - test + - build + + +clang_tidy: + image: jhasse/clang-tidy + stage: style + tags: + - docker-ci + script: + - sh .ci/clang-tidy.sh; + +make_test: + stage: test + tags: + - docker-ci + script: + - apt-get update + - apt-get install -y g++ make cmake clang-tidy libfltk1.3 libfltk1.3-dev + - mkdir current + - ls | grep -v current | xargs mv -t current + - git clone https://github.com/catchorg/Catch2.git + - cd Catch2 + - cmake -Bbuild -H. -DBUILD_TESTING=OFF + - cmake --build build/ --target install + - cd .. + - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.repo.digitech.hs-emden-leer.de/link/projekte/ws19/vkvm-new/library.git + - mkdir library/build + - cd library/build + - cmake .. + - make + - cd ../../current + - mkdir build + - cd build + - cmake .. + - make + - make test + +cmake_build: + stage: build + tags: + - docker-ci + script: + - apt-get update + - apt-get install -y g++ make cmake clang-tidy libfltk1.3 libfltk1.3-dev + - mkdir current + - ls | grep -v current | xargs mv -t current + - git clone https://github.com/catchorg/Catch2.git + - cd Catch2 + - cmake -Bbuild -H. -DBUILD_TESTING=OFF + - cmake --build build/ --target install + - cd .. + - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.repo.digitech.hs-emden-leer.de/link/projekte/ws19/vkvm-new/library.git + - mkdir library/build + - cd library/build + - cmake .. + - make + - cd ../../current + - mkdir build + - cd build + - cmake .. + - make \ No newline at end of file From 24a7b22878cf297957551dbf1fcf18410e940ef1 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Tue, 12 Nov 2019 11:12:08 +0000 Subject: [PATCH 2/5] ~ CI: clang_tidy step now contains catch2 & fltk --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 32d0eb7..033cd86 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,7 +9,7 @@ stages: clang_tidy: - image: jhasse/clang-tidy + image: joethei/clang_tidy stage: style tags: - docker-ci From f85ff6b45a660107f0fc743a536aacad3f338975 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Tue, 12 Nov 2019 11:41:30 +0000 Subject: [PATCH 3/5] ~ default argument calls are now allowed --- .ci/clang-tidy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/clang-tidy.sh b/.ci/clang-tidy.sh index eae5b12..c20c8fb 100644 --- a/.ci/clang-tidy.sh +++ b/.ci/clang-tidy.sh @@ -9,7 +9,7 @@ filelist="$(find . -not \( -path './client/cpptoml/*' -prune \) -type f ! -name for file in $filelist; do if echo "$file" | grep -q -E ".*\.cpp$" ; then #Extra check missing dependencies due to clang-tidy doesn't toggle exit code. - clang_tidy_lib_check="$(clang-tidy -warnings-as-errors='*' -header-filter='.*,-cpptoml.hpp' -checks='*,-llvm-header-guard,-fuchsia-statically-constructed-objects,-fuchsia-default-arguments,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init' "$file" -- -I. -std=c++14 2>&1)" + clang_tidy_lib_check="$(clang-tidy -warnings-as-errors='*' -header-filter='.*,-cpptoml.hpp' -checks='*,-llvm-header-guard,-fuchsia-statically-constructed-objects,-fuchsia-default-arguments,-fuchsia-default-argument-calls,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init' "$file" -- -I. -std=c++14 2>&1)" for tidy_line in $clang_tidy_lib_check; do echo "$tidy_line" | grep -q -v -E "^Error while processing*" if [ $? -eq 1 ]; then From ea4c9187583c15d8bd59d67b89d1f1342cc79874 Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Tue, 12 Nov 2019 15:20:24 +0100 Subject: [PATCH 4/5] ~ clang-tidy checks all files now --- .ci/clang-tidy.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.ci/clang-tidy.sh b/.ci/clang-tidy.sh index c20c8fb..913c79a 100644 --- a/.ci/clang-tidy.sh +++ b/.ci/clang-tidy.sh @@ -5,11 +5,11 @@ bool=false # explicitly set IFS to contain only a line feed IFS=' ' -filelist="$(find . -not \( -path './client/cpptoml/*' -prune \) -type f ! -name "$(printf "*\n*")")" +filelist="$(find . -not \( -path './*build*' -prune \) -type f ! -name "$(printf "*\n*")")" for file in $filelist; do - if echo "$file" | grep -q -E ".*\.cpp$" ; then + if echo "$file" | grep -q -E ".*(\.cpp|\.h|\.hpp)$" ; then #Extra check missing dependencies due to clang-tidy doesn't toggle exit code. - clang_tidy_lib_check="$(clang-tidy -warnings-as-errors='*' -header-filter='.*,-cpptoml.hpp' -checks='*,-llvm-header-guard,-fuchsia-statically-constructed-objects,-fuchsia-default-arguments,-fuchsia-default-argument-calls,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init' "$file" -- -I. -std=c++14 2>&1)" + clang_tidy_lib_check="$(clang-tidy -warnings-as-errors='*' -header-filter='.*,-cpptoml.hpp' -checks='*,-llvm-header-guard,-fuchsia-statically-constructed-objects,-fuchsia-default-arguments,-fuchsia-default-arguments-calls,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-constant-array-index,-bugprone-narrowing-conversions,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-type-reinterpret-cast,-hicpp-signed-bitwise,-bugprone-exception-escape,-cppcoreguidelines-pro-type-member-init,-cppcoreguidelines-pro-type-cstyle-cast,-hicpp-member-init' "$file" -- -I. -std=c++14 2>&1)" for tidy_line in $clang_tidy_lib_check; do echo "$tidy_line" | grep -q -v -E "^Error while processing*" if [ $? -eq 1 ]; then From 2a6a0afd1a5f0ef0a167ad854cf265e070dee3ab Mon Sep 17 00:00:00 2001 From: chenhuan Date: Thu, 14 Nov 2019 11:54:47 +0100 Subject: [PATCH 5/5] 1.remake show the bild 2.the GUI can show a bild with the colormap 3.Kommentar 4.connect with library --- main/main.cpp | 121 +++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 66 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index 934eceb..4ffe6c7 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2,85 +2,75 @@ #include #include #include -#include #include #include +#include "vkvm.hpp" + #define window_height 600 #define window_width 800 -//Statusbar**************************************/ +/**************************************[[l***************************************/ -/** The class inherits a char *text from the Fl_Box. It also shows the window-resolution and the mouse-position. - * @param text: A pointer to a char-array, that can contain a text like a status or whatever you want. - * @parameter x: The mouse-position on the x-axis. - * @parameter y: The mouse-position on the y-axis: - * @parameter w: The width of a single pixel, - * @parameter h: The height of a single pixel. - */ -class Statusbar: public Fl_Box { +//Es ist Class fuer Status +class Status_Leiste : public Fl_Box { char *text; public: - /** The constructor of Statusbar has to get additional parameters. - * @param x: The mouse-position on the x-axis. - * @param y: The mouse-position on the y-axis: - * @param w: The width of a single pixel, - * @param h: The height of a single pixel. - */ - Statusbar(int x, int y, int w, int h, char *text) : +//Konstruktor + Status_Leiste(int x, int y, int w, int h, char *text) : Fl_Box(x, y, w, h,text) { this->text = text; }; void set_text(char *text) { this->text = text; } - //An exampel to show, how the content of the text can be changed. + //nur zu Beispiel, zu zeigen, dass der Inhalt von Status einfach geaendert werden kann. void change_text(){ if(text=="status0") set_text("status1"); else set_text("status0"); } - //This function refreshes the statusbar + //der neue Inhalt von Status zeigen void refresh_label(){ this->label(text); } }; -//Image**************************************/ -/** The Image-class draws the bitmap that it get from the Shared Memory. - * @param *buf: A pointer to the bitmap, that the image-class has to draw. Three chars are needed to get the RGB-value of a pixel, so the size equals window_height * window_width * 3. - */ +//Pixel ist ein neue Class fuer ein Pixel +class Bild : public Fl_Widget { + uchar *buf;//Bitmap fuer das Bild, es braucht 3 char um ein Pixel zu erklaren(RGB), deshalb die Groesse von buf ist window_height * window_width * 3 -class Image : public Fl_Widget { - uchar *buf; - - //Function to draw a bitmap + //buf ist das Bitmap fuer das Bild, x,y fuer Postion in Window, w, h, bedeutet height und width void draw() { fl_draw_image(buf, x(), y(), w(), h()); } - /** The constructor of the image class, get additional - * @param x: The mouse-position on the x-axis. - * @param y: The mouse-position on the y-axis: - * @param w: The width of a single pixel, - * @param h: The height of a single pixel. - */ public: - /*Constructor*/ - Image(int x, int y, int w, int h) : +//Konstruktor + Bild(int x, int y, int w, int h) : Fl_Widget(x, y, w, h, 0) { buf = new uchar[w * h * 3]; - /*Just an example.*/ +//nur als Beispiel for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { buf[(j + (i * w)) * 3 + 1] = 0xff; } } } -/*A function to change the colors of the image-class. The colors are changing in this order: green, blue, red*/ + +//die Farbe vom Bild aendern(Die Reihenfolge: gruen, rot, blau, gruen ) void change_color() { + for (int i = 0; i < h(); i++) { + for (int j = 0; j < w(); j++) { + vkvm::Color c = vkvm::getPixel(j,i); + buf[(i * w() + j) * 3 + 0] = c.getRed(); + buf[(i * w() + j) * 3 + 1] = c.getGreen(); + buf[(i * w() + j) * 3 + 2] = c.getBlue(); + } + } + /* for (int j = 1; j < w() * h() * 3; j++) { if (buf[j] == 0xff) { buf[j] = 0; @@ -89,24 +79,18 @@ public: } if (buf[2] == 0xff) buf[w() * h() * 3 - 1] = 0xff; + */ } }; -//My_Window*************************************/ -/** The My_Windows-class generates a window, within the window it recognizes the curretn mouse-position. - * It also recognizes if a button is pushed on the keyboard or the mouse. Furthermore the class depict the - * content of the Image-class and provides functions to refresh it. - * @parame x The mouse-position on the x-axis. - * @parame y The mouse-position on the y-axis. - * @parame button The button that was pushed last. - */ + class My_Window : public Fl_Window { int x, y, button; - /*Function to handle the input*/ +//die Inputs von Maus und Tastatur behandln int handle(int e) { switch (e) { - /*Mousebutton*/ +//Druck vom Maus behandln case FL_PUSH: if (Fl::event_button() == FL_LEFT_MOUSE) { std::cout << "Mouse:left" << std::endl; @@ -116,7 +100,7 @@ class My_Window : public Fl_Window { std::cout << "Mouse:middle" << std::endl; } return 1; - /*Mousebutton and movement*/ +//Druck und Bewegung vom Maus behandln case FL_DRAG: x = Fl::event_x(); y = Fl::event_y(); @@ -129,52 +113,57 @@ class My_Window : public Fl_Window { std::cout << "Mouse:middle" << std::endl; } return 1; - /*Mousemovement*/ +//Bewegung vom Maus behandln case FL_MOVE: x = Fl::event_x(); y = Fl::event_y(); std::cout << "Postion X:" << x << " Postion Y:" << y << std::endl; return 1; - /*keyboardbutton*/ +//Druck von der Tastator behandln case FL_KEYBOARD: button = Fl::event_button(); - std::cout << "Keyboard:" << (unsigned short) button << std::endl; + std::cout << "Keyboard:" << (unsigned short) button << " down"<redraw(); - Fl::repeat_timeout(0.5, refresh_image, pointer);//nach 0.5 sec refresh_bild(pointer) anrufen. Here pointer ist wie ein Parameter +//draw() wird regelmaessig anrufen +void refresh_bild(void *pointer) { + ((Bild *) pointer)->redraw(); + Fl::repeat_timeout(0.5, refresh_bild, pointer);//nach 0.5 sec refresh_bild(pointer) anrufen. Here pointer ist wie ein Parameter } +//die Farbe von Pixels regekmaessig aendern void change_color(void *pointer) { - ((Image *) pointer)->change_color(); + ((Bild *) pointer)->change_color(); Fl::repeat_timeout(1, change_color, pointer); } -void refresh_statusbar(void *pointer) { - ((Statusbar **) pointer)[0]->refresh_label(); - Fl::repeat_timeout(0.5, refresh_statusbar, pointer); +//refresh_status() von Status0 wird regelmaessig anrufen +void refresh_status_leiste(void *pointer) { + ((Status_Leiste **) pointer)[0]->refresh_label(); + Fl::repeat_timeout(0.5, refresh_status_leiste, pointer); } +//der Inhalt von Status0 regekmaessig aendern void change_status(void *pointer) { ((Status_Leiste **) pointer)[0]->change_text(); Fl::repeat_timeout(1, change_status, pointer); } - -//main*************************************/ -/** - * The main function initializes all needed classes and executes the functions. - */ +// main int main(int argc, char **argv) { + vkvm::initialize(0); + My_Window *window = new My_Window(window_width, window_height, "example"); Status_Leiste *status[5]; window->begin(); @@ -191,4 +180,4 @@ int main(int argc, char **argv) { window->end(); window->show(argc, argv); return Fl::run(); -}main \ No newline at end of file +} \ No newline at end of file