Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
2bd42a93db
|
@ -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 './*build*' -prune \) -type f ! -name "$(printf "*\n*")")"
|
||||
for file in $filelist; do
|
||||
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-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
|
||||
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
|
|
@ -0,0 +1,68 @@
|
|||
---
|
||||
|
||||
image: samueldebruyn/debian-git:latest
|
||||
|
||||
stages:
|
||||
- style
|
||||
- test
|
||||
- build
|
||||
|
||||
|
||||
clang_tidy:
|
||||
image: joethei/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
|
195
main/main.cpp
195
main/main.cpp
|
@ -1,70 +1,199 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <Fl/Fl.H>
|
||||
#include <FL/Fl_Box.H>
|
||||
#include <Fl/Fl_Box.H>
|
||||
#include <FL/Fl_Window.H>
|
||||
#include <FL/fl_draw.H>
|
||||
|
||||
#include "vkvm.hpp"
|
||||
|
||||
|
||||
#define window_height 600
|
||||
#define window_width 800
|
||||
|
||||
/*****************************************************************************/
|
||||
/* This class provides a view to copy the offscreen surface to */
|
||||
//Statusbar**************************************/
|
||||
|
||||
int color_map[window_width][window_height];
|
||||
class My_Window : public Fl_Window{
|
||||
int x,y,button;
|
||||
int handle(int e)
|
||||
{
|
||||
/** 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.
|
||||
*/
|
||||
|
||||
switch (e)
|
||||
{
|
||||
class Statusbar : 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) :
|
||||
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.
|
||||
void change_text(){
|
||||
if(text=="status0")
|
||||
set_text("status1");
|
||||
else
|
||||
set_text("status0");
|
||||
}
|
||||
//This function refreshes the statusbar.
|
||||
void refresh_label(){
|
||||
this->label(text);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//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*/
|
||||
int handle(int e) {
|
||||
switch (e) {
|
||||
/*Mousebutton*/
|
||||
case FL_PUSH:
|
||||
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
||||
std::cout << "Mouse:left" << std::endl;
|
||||
} else if (Fl::event_button() == FL_RIGHT_MOUSE) {
|
||||
std::cout << "Mouse:right" << std::endl;
|
||||
} else {
|
||||
std::cout << "Mouse:middle" << std::endl;
|
||||
}
|
||||
return 1;
|
||||
/*Mousebutton and movement*/
|
||||
case FL_DRAG:
|
||||
x = Fl::event_x();
|
||||
y = Fl::event_y();
|
||||
std::cout << "Postion X:" << x << " Postion Y:" << y << std::endl;
|
||||
if (Fl::event_button() == FL_LEFT_MOUSE) {
|
||||
std::cout << "Mouse:left" << std::endl;
|
||||
} else if (Fl::event_button() == FL_RIGHT_MOUSE) {
|
||||
std::cout << "Mouse:right" << std::endl;
|
||||
} else {
|
||||
std::cout << "Mouse:middle" << std::endl;
|
||||
}
|
||||
return 1;
|
||||
/*Mousemovement*/
|
||||
case FL_MOVE:
|
||||
x = Fl::event_x();
|
||||
y = Fl::event_y();
|
||||
std::cout<<"Postion X:"<< x <<" Postion Y:"<< y <<std::endl;
|
||||
std::cout << "Postion X:" << x << " Postion Y:" << y << std::endl;
|
||||
return 1;
|
||||
/*keyboardbutton*/
|
||||
case FL_KEYBOARD:
|
||||
button = Fl::event_button();
|
||||
std::cout<<"Keyboard:"<< (unsigned short)button <<std::endl;
|
||||
std::cout << "Keyboard:" << (unsigned short) button << " down"<<std::endl;
|
||||
return 1;
|
||||
case FL_KEYUP:
|
||||
button = Fl::event_button();
|
||||
std::cout << "Keyboard:" << (unsigned short) button << " up"<<std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public:
|
||||
My_Window(int x, int y, const char *l ) : Fl_Window(x,y,l){};
|
||||
My_Window(int x, int y, const char *l) : Fl_Window(x, y, l) {}
|
||||
};
|
||||
|
||||
class Pixel : public Fl_Widget {
|
||||
Fl_Color color;
|
||||
void draw(){
|
||||
fl_draw_box(static_cast<Fl_Boxtype>(1), x(), y(), w(), h(), color);
|
||||
|
||||
//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.
|
||||
*/
|
||||
|
||||
class Image : public Fl_Widget {
|
||||
uchar *buf;
|
||||
//Function to draw a bitmap
|
||||
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:
|
||||
Pixel(int x,int y,int w,int h,int RGB) :
|
||||
Fl_Widget(x,y,w,h,0) {
|
||||
this->color = fl_rgb_color((uchar)((RGB&0xff000000)>>24),(uchar)((RGB&0xff0000)>>16),(uchar)((RGB&0xff00)>>8));
|
||||
|
||||
Image(int x, int y, int w, int h) :
|
||||
Fl_Widget(x, y, w, h, 0) {
|
||||
buf = new uchar[w * h * 3];
|
||||
/*Just an example.*/
|
||||
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. It reads the colors from the Shared Memory-Class*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
/*Functions to refresh the image.*/
|
||||
void refresh_image(void *pointer) {
|
||||
((Image *) pointer)->redraw();
|
||||
Fl::repeat_timeout(0.5, refresh_image, pointer);//nach 0.5 sec refresh_image(pointer) anrufen. Here pointer ist wie ein Parameter
|
||||
}
|
||||
|
||||
void change_color(void *pointer) {
|
||||
((Image *) 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);
|
||||
}
|
||||
|
||||
void change_status(void *pointer) {
|
||||
((Statusbar **) pointer)[0]->change_text();
|
||||
Fl::repeat_timeout(1, change_status, pointer);
|
||||
}
|
||||
//main*************************************/
|
||||
/**
|
||||
* The main function initializes all needed classes and executes the functions.
|
||||
*/
|
||||
int main(int argc, char **argv) {
|
||||
for(int i=0;i<100;i++){
|
||||
for (int j = 0; j < 100 ; j++) {
|
||||
color_map[i][j]=0xff000000;
|
||||
}
|
||||
}
|
||||
My_Window* window = new My_Window(window_width, window_height, "example");
|
||||
vkvm::initialize(0);
|
||||
|
||||
My_Window *window = new My_Window(window_width, window_height, "example");
|
||||
Statusbar *status[5];
|
||||
window->begin();
|
||||
for(int i=0;i<100;i++){
|
||||
for (int j = 0; j < 100 ; j++) {
|
||||
new Pixel(i,j,1,1,color_map[i][j]);
|
||||
}
|
||||
}
|
||||
Image *image = new Image(0, 30, window_width, window_height - 30);
|
||||
status[0] = new Statusbar(0, 0, 60, 30, "status0");
|
||||
status[1] = new Statusbar(60, 0, 60, 30, "status1");
|
||||
status[2] = new Statusbar(120, 0, 60, 30, "status2");
|
||||
status[3] = new Statusbar(180, 0, 60, 30, "status3");
|
||||
status[4] = new Statusbar(240, 0, 60, 30, "status4");
|
||||
Fl::repeat_timeout(0.5, refresh_image, image);
|
||||
Fl::repeat_timeout(1, change_color, image);
|
||||
Fl::repeat_timeout(0.5, refresh_statusbar, status);
|
||||
Fl::repeat_timeout(1, change_status, status);
|
||||
window->end();
|
||||
window->show(argc,argv);
|
||||
window->show(argc, argv);
|
||||
return Fl::run();
|
||||
} // main
|
||||
}
|
Loading…
Reference in New Issue