bool CollisionObject2D::_set(const StringName& p_name, const Variant& p_value) { String name=p_name; if (name=="shape_count") { shapes.resize(p_value); _update_shapes(); _change_notify(); } else if (name.begins_with("shapes/")) { int idx=name.get_slice("/",1).to_int(); String what=name.get_slice("/",2); if (what=="shape") set_shape(idx,RefPtr(p_value)); else if (what=="transform") set_shape_transform(idx,p_value); else if (what=="trigger") set_shape_as_trigger(idx,p_value); } else return false; return true; }
static void reparent(client_t *c, strut_t *s) { XSetWindowAttributes pattr; geom_t f; f = frame_geom(c); pattr.override_redirect = True; pattr.background_pixel = bg.pixel; pattr.border_pixel = bd.pixel; pattr.event_mask = SubMask|ButtonPressMask|ExposureMask|EnterWindowMask; c->frame = XCreateWindow(dpy, root, f.x, f.y, f.w, f.h, BW(c), DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &pattr); #ifdef SHAPE if (shape) { XShapeSelectInput(dpy, c->win, ShapeNotifyMask); set_shape(c); } #endif #ifdef XFT c->xftdraw = XftDrawCreate(dpy, (Drawable)c->frame, DefaultVisual(dpy, DefaultScreen(dpy)), DefaultColormap(dpy, DefaultScreen(dpy))); #endif XAddToSaveSet(dpy, c->win); XSelectInput(dpy, c->win, ColormapChangeMask|PropertyChangeMask); XSetWindowBorderWidth(dpy, c->win, 0); XResizeWindow(dpy, c->win, c->geom.w, c->geom.h); XReparentWindow(dpy, c->win, c->frame, 0, frame_height(c)); send_config(c); }
bool Portal::_set(const StringName &p_name, const Variant &p_value) { if (p_name == "shape") { PoolVector<float> src_coords = p_value; Vector<Point2> points; int src_coords_size = src_coords.size(); ERR_FAIL_COND_V(src_coords_size % 2, false); points.resize(src_coords_size / 2); for (int i = 0; i < points.size(); i++) { points[i].x = src_coords[i * 2 + 0]; points[i].y = src_coords[i * 2 + 1]; set_shape(points); } } else if (p_name == "enabled") { set_enabled(p_value); } else if (p_name == "disable_distance") { set_disable_distance(p_value); } else if (p_name == "disabled_color") { set_disabled_color(p_value); } else if (p_name == "connect_range") { set_connect_range(p_value); } else return false; return true; }
Board::Board(const std::string &shape) : width(0), height(0), initial_blank_count(0), current_blank_count(0), initial_board(), current_board() { set_shape(shape); }
ImplicitObject::ImplicitObject(void) : GeometricObject(), type(1), center(0.0), s0(1), s1(1), s2(1) { set_shape(type); }
ImplicitObject::ImplicitObject(int type, Point3D center, float s0, float s1, float s2) : GeometricObject(), type(type), center(center), s0(s0), s1(s1), s2(s2) { set_shape(type); }
Board::Board(const char *shape) : width(0), height(0), initial_blank_count(0), current_blank_count(0), initial_board(), current_board() { if (shape != NULL) set_shape(shape); }
Portal::Portal() { portal = VisualServer::get_singleton()->portal_create(); Vector<Point2> points; points.push_back(Point2(-1, 1)); points.push_back(Point2(1, 1)); points.push_back(Point2(1, -1)); points.push_back(Point2(-1, -1)); set_shape(points); // default shape set_connect_range(0.8); set_disable_distance(50); set_enabled(true); set_base(portal); }
bool Board::set_shape_by_file(const char *file_name) { std::fstream fs; fs.open(file_name, std::ios::in); if (!fs.is_open()) { std::string message = "failed to open the file: "; message += file_name; throw std::ios_base::failure(message); } std::string shape; char line[max_file_line_length]; while (fs.getline(line, sizeof(line))) { shape += line; shape += "\n"; } fs.close(); return set_shape(shape); }
bool CollisionObject2D::_set(const StringName &p_name, const Variant &p_value) { String name = p_name; if (name.begins_with("shapes/")) { int idx = name.get_slicec('/', 1).to_int(); String what = name.get_slicec('/', 2); if (what == "shape") { if (idx >= shapes.size()) add_shape(RefPtr(p_value)); else set_shape(idx, RefPtr(p_value)); } else if (what == "transform") set_shape_transform(idx, p_value); else if (what == "trigger") set_shape_as_trigger(idx, p_value); } else return false; return true; }
void CollisionShape::make_convex_from_brothers() { Node *p = get_parent(); if (!p) return; for (int i = 0; i < p->get_child_count(); i++) { Node *n = p->get_child(i); MeshInstance *mi = Object::cast_to<MeshInstance>(n); if (mi) { Ref<Mesh> m = mi->get_mesh(); if (m.is_valid()) { Ref<Shape> s = m->create_convex_shape(); set_shape(s); } } } }
PhysInput::PhysInput(QWidget* parent, Rectangle rect, bool editable): QWidget(parent) { this->setLayout(new QHBoxLayout); x_widget = new LineEditDist(); y_widget = new LineEditDist(); width_widget = new LineEditDist(); height_widget = new LineEditDist(); x_widget->setEnabled(editable); y_widget->setEnabled(editable); width_widget->setEnabled(editable); height_widget->setEnabled(editable); this->layout()->addWidget(new QLabel(tr("x position:"))); this->layout()->addWidget(x_widget); this->layout()->addWidget(new QLabel(tr("y position:"))); this->layout()->addWidget(y_widget); this->layout()->addWidget(new QLabel(tr("width:"))); this->layout()->addWidget(width_widget); this->layout()->addWidget(new QLabel(tr("height:"))); this->layout()->addWidget(height_widget); set_shape(rect); }
void handle_event(XEvent *ev) { client *c = owner(ev->xany.window); #ifdef DEBUG_EVENTS if(ev->type != Expose && ev->type != MotionNotify && !(ev->type == ConfigureNotify && ev->xconfigure.window != root)) /* this makes the output slightly more manageable */ printf(NAME ": handle_event(): got %s\n\twindow: 0x%X (%s)\n", event_name(ev), (unsigned int) ev->xany.window, c ? c->name : ((ev->xany.window == root) ? "root" : "unknown")); #endif if((evh && evh(ev)) || button_handle_event(ev) || ewmh_handle_event(ev) || screens_handle_event(ev)) { #ifdef DEBUG_EVENTS if(ev->type != Expose && ev->type != MotionNotify && (ev->type != ConfigureNotify && ev->xconfigure.window != root)) printf(NAME ": handle_event(): external event handler claimed last event\n"); #endif return; } if(c) { if(!has_child(c->parent, c->window) && ev->type != DestroyNotify && ev->type != UnmapNotify) return; switch(ev->type) { case UnmapNotify: if(c->window == ev->xunmap.window) { #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling UnmapNotify event\n\twindow: 0x%X (%s)\n", (unsigned int) c->window, c->name); #endif if(has_child(c->parent, c->window)) { client_deparent(c); set_wm_state(c->window, WithdrawnState); } client_remove(c); ewmh_update_clist(); } return; case PropertyNotify: if(ev->xproperty.atom == XA_WM_NAME) { #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling PropertyNotify event\n\twindow: 0x%X (%s)\n\tproperty: XA_WM_NAME\n", (unsigned int) c->window, c->name); #endif if(c->name != no_title) XFree(c->name); #ifdef USE_XFT if(xftfont) XftDrawDestroy(c->title_draw); #endif XFreePixmap(dpy, c->title_pixmap); XFetchName(dpy, c->window, &c->name); client_update_name(c); XClearWindow(dpy, c->title); if(evh == wlist_handle_event) { XClearWindow(dpy, c->wlist_item); wlist_item_draw(c); } } if(ev->xproperty.atom == XA_WM_NORMAL_HINTS) { #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling PropertyNotify event\n\twindow: 0x%X (%s)\n\tproperty: XA_WM_NORMAL_HINTS\n", (unsigned int) c->window, c->name); #endif get_normal_hints(c); } return; case ClientMessage: if(ev->xclient.message_type == xa_wm_change_state && ev->xclient.data.l[0] == IconicState) { #ifdef DEBUG_EVENTS printf(NAME ": handling ClientMessage event\n\twindow: 0x%X (%s)\n", (unsigned int) c->window, c->name); #endif client_iconify(c); return; } break; /* we might later need this event */ case EnterNotify: if(c != current && !(c->flags & CLICK_FOCUS) && !click_focus && ev->xcrossing.mode != NotifyGrab && ev->xcrossing.mode != NotifyUngrab && ev->xcrossing.detail != NotifyInferior && (ev->xcrossing.window == c->parent || ev->xcrossing.window == c->wlist_item) && ev->xcrossing.send_event == False) { #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling EnterNotify event\n\twindow: 0x%X (%s)\n", (unsigned int) c->window, c->name); #endif client_focus(c, true); } return; case Expose: if(ev->xexpose.count == 0 && evh == wlist_handle_event && c && ev->xexpose.window == c->wlist_item) wlist_item_draw(c); return; case ButtonPress: #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling ButtonPress event\n\twindow: 0x%X (%s)\n", (unsigned int) c->window, c->name); #endif if(c != current) client_focus(c, true); XAllowEvents(dpy, ReplayPointer, CurrentTime); if(ev->xbutton.window != c->window) { if(lastclick + doubleclick_time > ev->xbutton.time && lastbutton == ev->xbutton.button && lastclick_client == c) { client_action(c, buttonaction(ev->xbutton.button, true), ev); lastclick = 0; lastclick_client = NULL; lastbutton = None; return; } lastclick = ev->xbutton.time; lastclick_client = c; lastbutton = ev->xbutton.button; client_action(c, buttonaction(ev->xbutton.button, false), ev); } else if(click_raise) client_raise(c); return; case FocusIn: /* we ignore pointer events, these happen if the input focus is on the root window */ if(allow_focus_stealing && c != current && ev->xfocus.mode != NotifyGrab && ev->xfocus.mode != NotifyUngrab && ev->xfocus.detail != NotifyPointer) { #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling FocusIn event\n\twindow: 0x%X (%s)\n", (unsigned int) c->window, c->name); #endif client_focus(c, false); } return; case FocusOut: if(c == current && ev->xfocus.mode != NotifyGrab && ev->xfocus.mode != NotifyUngrab && ev->xfocus.detail != NotifyInferior) { #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling FocusOut event\n\twindow: 0x%X (%s)\n", (unsigned int) c->window, c->name); #endif if(allow_focus_stealing && ev->xfocus.detail != NotifyAncestor) { #ifdef DEBUG_EVENTS printf("\tfocus lost\n"); #endif client_focus(NULL, false); /* we do this so windows that aren't managed can take focus */ } else { #ifdef DEBUG_EVENTS printf("\tre-focussing this window\n"); #endif take_focus(c); } } return; #ifdef USE_SHAPE default: if(ev->type == shape_event) { #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling ShapeNotify event\n\twindow 0x%X (%s)\n", (unsigned int) c->window, c->name); #endif set_shape(c); return; } #endif } } switch(ev->type) { case MapRequest: c = owner(ev->xmaprequest.window); #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling MapRequest event\n\twindow: 0x%X (%s)\n", (unsigned int) ev->xmaprequest.window, c ? c->name : "unknown"); #endif if(c) { if(c->flags & ICONIC && has_child(c->parent, c->window)) { client_restore(c); if(focus_new) client_focus(c, true); } } else if(has_child(root, ev->xmaprequest.window)) client_add(ev->xmaprequest.window, false); return; case DestroyNotify: c = owner(ev->xdestroywindow.window); if(c) if(c->window == ev->xdestroywindow.window) { #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling DestroyNotify event\n\twindow 0x%X (%s)\n", (unsigned int) c->window, c->name); #endif client_remove(c); } return; case ConfigureRequest: c = owner(ev->xconfigurerequest.window); #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling ConfigureRequest event\n\twindow 0x%X (%s)\n", (unsigned int) ev->xconfigurerequest.window, c ? c->name : "unknown"); #endif if(correct_center) screens_correct_center(&ev->xconfigurerequest.x, &ev->xconfigurerequest.y, &ev->xconfigurerequest.width, &ev->xconfigurerequest.height); if(c) { if(!has_child(c->parent, c->window)) return; if(ev->xconfigurerequest.value_mask & CWX) c->x = ev->xconfigurerequest.x - gxo(c, false); if(ev->xconfigurerequest.value_mask & CWY) c->y = ev->xconfigurerequest.y - gyo(c, false); if(ev->xconfigurerequest.value_mask & CWWidth) c->width = ev->xconfigurerequest.width; if(ev->xconfigurerequest.value_mask & CWHeight) c->height = ev->xconfigurerequest.height; client_update(c); #ifdef DEBUG printf(NAME ": handle_event(): reconfigured client 0x%X (%s) to %ix%i+%i+%i\n", (unsigned int) c->window, c->name, c->width, c->height, c->x, c->y); #endif } else if(has_child(root, ev->xconfigurerequest.window)) { XWindowChanges wc; wc.sibling = ev->xconfigurerequest.above; wc.stack_mode = ev->xconfigurerequest.detail; wc.x = ev->xconfigurerequest.x; wc.y = ev->xconfigurerequest.y; wc.width = ev->xconfigurerequest.width; wc.height = ev->xconfigurerequest.height; XConfigureWindow(dpy, ev->xconfigurerequest.window, ev->xconfigurerequest.value_mask, &wc); } return; case MapNotify: if(correct_center_unmanaged && ev->xany.window == root && !owner(ev->xmap.window)) { #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling MapNotify event\n\twindow 0x%X (unknown)\n", (unsigned int) ev->xmap.window); #endif window_correct_center(ev->xmap.window); } return; case MappingNotify: if(ev->xmapping.request != MappingPointer) { #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling MappingNotify event\n"); #endif keys_ungrab(); XRefreshKeyboardMapping(&ev->xmapping); keys_update(); } return; case KeyPress: #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling KeyPress event\n"); #endif client_action(current, keyaction(ev), ev); return; case ButtonPress: if(ev->xbutton.window != root) return; #ifdef DEBUG_EVENTS printf(NAME ": handle_event(): handling ButtonPress event\n"); #endif if(lastclick + doubleclick_time > ev->xbutton.time && lastbutton == ev->xbutton.button && lastclick_client == NULL) { client_action(current, root_buttonaction(ev->xbutton.button, true), ev); lastclick = 0; lastclick_client = NULL; lastbutton = None; return; } lastclick = ev->xbutton.time; lastclick_client = NULL; lastbutton = ev->xbutton.button; client_action(current, root_buttonaction(ev->xbutton.button, false), ev); return; case ClientMessage: if(ev->xclient.message_type == xa_internal_message) { if(((Atom) ev->xclient.data.l[0]) == xa_quit) { #ifdef DEBUG printf(NAME ": handle_event(): quit message received\n"); #endif exit(0); } if(((Atom) ev->xclient.data.l[0]) == xa_reinit) { #ifdef DEBUG printf(NAME ": handle_event(): reinitialize message received\n"); #endif cfg_reinitialize(); } } } }
/* * LeftEll is the piece that looks like this * * ## * ## * #### * * It's also known as "L", "gun", or "right gun". */ SDLLeftEll::SDLLeftEll(SDL_Surface *surface_in) : SDLShape() { set_shape(new LeftEll()); set_surface(surface_in); set_color(SDL_MapRGB(surface_in->format, 0xFF, 0x8C, 0x31)); }
OZWindow(const TaskLook &task_look, const AirspaceLook &airspace_look) :roz(task_look, airspace_look, airspace_renderer_settings), oz(NULL) { projection.SetGeoLocation(location); set_shape(ObservationZone::Shape::LINE); }
OZWindow(const TaskLook &task_look, const AirspaceLook &airspace_look) :roz(task_look, airspace_look), oz(NULL) { projection.SetGeoLocation(location); set_shape(ObservationZonePoint::LINE); }
void BedShapePanel::build_panel(ConfigOptionPoints* default_pt) { // on_change(nullptr); auto box = new wxStaticBox(this, wxID_ANY, _(L("Shape"))); auto sbsizer = new wxStaticBoxSizer(box, wxVERTICAL); // shape options m_shape_options_book = new wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxSize(300, -1), wxCHB_TOP); sbsizer->Add(m_shape_options_book); auto optgroup = init_shape_options_page(_(L("Rectangular"))); ConfigOptionDef def; def.type = coPoints; def.default_value = new ConfigOptionPoints{ Pointf(200, 200) }; def.label = L("Size"); def.tooltip = L("Size in X and Y of the rectangular plate."); Option option(def, "rect_size"); optgroup->append_single_option_line(option); def.type = coPoints; def.default_value = new ConfigOptionPoints{ Pointf(0, 0) }; def.label = L("Origin"); def.tooltip = L("Distance of the 0,0 G-code coordinate from the front left corner of the rectangle."); option = Option(def, "rect_origin"); optgroup->append_single_option_line(option); optgroup = init_shape_options_page(_(L("Circular"))); def.type = coFloat; def.default_value = new ConfigOptionFloat(200); def.sidetext = L("mm"); def.label = L("Diameter"); def.tooltip = L("Diameter of the print bed. It is assumed that origin (0,0) is located in the center."); option = Option(def, "diameter"); optgroup->append_single_option_line(option); optgroup = init_shape_options_page(_(L("Custom"))); Line line{ "", "" }; line.full_width = 1; line.widget = [this](wxWindow* parent) { auto btn = new wxButton(parent, wxID_ANY, _(L("Load shape from STL...")), wxDefaultPosition, wxDefaultSize); auto sizer = new wxBoxSizer(wxHORIZONTAL); sizer->Add(btn); btn->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { load_stl(); })); return sizer; }; optgroup->append_line(line); Bind(wxEVT_CHOICEBOOK_PAGE_CHANGED, ([this](wxCommandEvent e) { update_shape(); })); // right pane with preview canvas m_canvas = new Bed_2D(this); m_canvas->m_bed_shape = default_pt->values; // main sizer auto top_sizer = new wxBoxSizer(wxHORIZONTAL); top_sizer->Add(sbsizer, 0, wxEXPAND | wxLeft | wxTOP | wxBOTTOM, 10); if (m_canvas) top_sizer->Add(m_canvas, 1, wxEXPAND | wxALL, 10) ; SetSizerAndFit(top_sizer); set_shape(default_pt); update_preview(); }
/* * RightSlant is the piece that looks like this * * #### * #### * * This piece is also known as "inverted N", or "S". */ SDLRightSlant::SDLRightSlant(SDL_Surface *surface_in) : SDLShape() { set_shape(new RightSlant()); set_surface(surface_in); set_color(SDL_MapRGB(surface_in->format, 0x73, 0xFF, 0x31)); }
bool Board::set_shape(const std::string &shape) { return set_shape(shape.c_str()); }