GuiObject::GuiObject( string_hash type, GuiObject* parent, float32_t pos_x, float32_t pos_y, float32_t width, float32_t height,bool pos_abs, bool size_abs, Valign val, Halign hal ) : _parent(parent), _node( this, parent->getChildren() ), _pos_x(pos_x), _pos_y(pos_y), _width(width), _height(height), _abs_pos_x(0), _abs_pos_y(0), _abs_width(0), _abs_height(0), _typeid(type), _pos_abs(pos_abs), _size_abs(size_abs), _valign(val), _halign(hal) { updatePixelPosition(); updatePixelSize(); }
/** Key events listening function. */ int listen() { int done = 0; int newWidth, newHeight; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: if (event.key.keysym.sym == SDLK_ESCAPE) done = 1; break; case SDL_VIDEORESIZE: newWidth = event.resize.w; newHeight = event.resize.h; // Create a new window screen = SDL_SetVideoMode(newWidth, newHeight, 16, SDL_HWSURFACE|SDL_RESIZABLE|SDL_DOUBLEBUF); if (!screen) { printf("Unable to set %dx%d video: %s\n", WIDTH, HEIGHT, SDL_GetError()); exit(EXIT_FAILURE); } updatePixelSize(newWidth, newHeight); // Create pixel surfaces int i, j; for (i = 0; i < SIZEX; i++) { for (j = 0; j < SIZEY; j++) { // Surface SDL_FreeSurface(pixel[i][j].surface); pixel[i][j].surface = SDL_CreateRGBSurface(SDL_HWSURFACE, pixel[i][j].pixelWidth, pixel[i][j].pixelHeight, 32,0,0,0,0); if (pixel[i][j].surface == NULL) { fprintf(stderr, "Error while loading surface for pixel [%d, %d]: %s", i, j, SDL_GetError()); exit(EXIT_FAILURE); } } } clearScreen(); break; case SDL_QUIT: done = 1; break; default: break; } } return done; }
RayCloudPlot::RayCloudPlot(QQuickItem *parent) : Plot3DBase(parent) , m_start(NDArrayTyped<float>({0})) , m_end(NDArrayTyped<float>({0})) , m_raycloud(new RayCloud()) , m_linewidthParam(new QParameter("linewidth", 10.0f)) , m_pixelSize(new QParameter("pixelSize", QVector2D(1.0, 1.0))) { QMap<QString,QString> props; props.insert("start", "start"); props.insert("end", "end"); registerProperties(props); // entity()->addComponent(m_raycloud); entity()->addComponent(makeMaterial()); connect(this, &QQuickItem::widthChanged, this, &RayCloudPlot::updatePixelSize); connect(this, &QQuickItem::heightChanged, this, &RayCloudPlot::updatePixelSize); updatePixelSize(); }