void SetToDefaultValues(RobotState* state) { for (auto& v : Variables(state->model)) { auto position = GetDefaultPosition(state->model, &v); SetVariablePosition(state, &v, position); } }
bool InitRobotState( RobotState* out, const RobotModel* model, bool with_velocities, bool with_accelerations) { RobotState robot_state; out->model = model; int mult = 1; if (with_velocities) { ++mult; } if (with_accelerations) { ++mult; } out->values.resize(mult * GetVariableCount(model)); for (int i = 0; i < GetVariableCount(model); ++i) { out->values[i] = GetDefaultPosition(model, GetVariable(model, i)); } double* data = out->values.data(); out->positions = data; data += GetVariableCount(model); if (with_velocities) { out->velocities = data; data += GetVariableCount(model); } if (with_accelerations) { out->accelerations = data; data += GetVariableCount(model); } out->transforms.resize( GetLinkCount(model) + GetJointCount(model) + GetCollisionBodyCount(model) + GetVisualBodyCount(model)); out->link_transforms = out->transforms.data(); out->joint_transforms = out->link_transforms + GetLinkCount(model); out->link_collision_transforms = out->joint_transforms + GetJointCount(model); out->link_visual_transforms = out->link_collision_transforms + GetCollisionBodyCount(model); out->dirty_links_joint = model->root_joint; out->dirty_collisions_joint = model->root_joint; out->dirty_visuals_joint = model->root_joint; return true; }
/* * border width and size and location are ty... * * 1. We allow the border width of a XmDialogShell child to change * size arbitrarily. * * 2. The border width of the shell widget tracks the child's * at all times, exactly. * * 3. The width of the shell is kept exactly the same as the * width of the child at all times. * * 4. The child is always positioned at the location * (- child_border, - child_border). * * the net result is the child has a border width which is always * what the user asked for; but none of it is ever seen, it's all * clipped by the shell (parent). The user sees the border * of the shell which is the size he set the child's border to. * * In the DEC window manager world the window manager does * exactly the same thing with the window it puts around the shell. * Hence the shell and child have a border width just as the user * set but the window manager overrides that and only a single * pixel border is displayed. In a non-wm environment the child * appears to have a border width, in reality this is the shell * widget border. You wanted to know... */ static void ChangeManaged( Widget wid ) { XmDialogShellWidget shell = (XmDialogShellWidget) wid ; /* * If the child went to unmanaged, call XtPopdown. * If the child went to managed, call XtPopup. */ Widget child; XmWidgetExtData extData = _XmGetWidgetExtData((Widget) shell, XmSHELL_EXTENSION); XmVendorShellExtObject ve = (XmVendorShellExtObject)extData->widget; XmDialogSavvyTrait trait ; if (((child = GetRectObjKid((CompositeWidget) shell)) == NULL) || (child->core.being_destroyed)) return; trait = (XmDialogSavvyTrait) XmeTraitGet((XtPointer) XtClass(child), XmQTdialogShellSavvy) ; /* MANAGED Case first ********/ if (child->core.managed) { XtWidgetGeometry request; Position kidX, kidY; Dimension kidBW; Boolean defaultPosition = True; /* * temporary workaround for setkeyboard focus ||| */ if (child != ve->vendor.old_managed) { XtSetKeyboardFocus((Widget)shell, (Widget)child); ve->vendor.old_managed = (Widget)child; } /* * if the child isn't realized, then we need to realize it * so we have a valid size. It will get created as a result * so we zero out it's position info so it'll * be okay and then restore it. */ if (!XtIsRealized(child)) { kidX = XtX(child); kidY = XtY(child); kidBW = XtBorderWidth(child); XtX(child) = 0; XtY(child) = 0; XtBorderWidth(child) = 0; /* Bug 4102306, This is an additional difference brought forward from motif 1.2 */ if (XtHeight(shell) != XtHeight(child)) { _XmImChangeManaged((Widget)shell); } /* End fix for Bug 4012306 */ XtRealizeWidget(child); XtX(child) = kidX; XtY(child) = kidY; XtBorderWidth(child) = kidBW; } else if (trait) { /* * Move the window to 0,0 * but don't tell the widget. It thinks it's where * the shell is... */ if ((XtX(child) != 0) || (XtY(child) != 0)) XMoveWindow (XtDisplay(child), XtWindow(child), 0, 0); } /* * map callback should occur BEFORE child default positioning * otherwise, widgets such as fileselection using map callback for * correct sizing have default positioning done before the widget * grows to its correct dimensions */ if(shell->core.mapped_when_managed && trait ) { trait->callMapUnmapCB(child, True); /* call Map callback */ } /* * Make sure that the shell has the same common parameters as * its child. Then move the child so that the shell will * correctly surround it. */ request.request_mode = 0; if (trait) { XtVaGetValues(child, XmNdefaultPosition, &defaultPosition, NULL); if (defaultPosition && (ve->vendor.externalReposition)) { defaultPosition = False; XtVaSetValues(child, XmNdefaultPosition, False, NULL); } } if (XtX(child) && trait) { kidX = XtX(child); XtX(child) = 0; } else kidX = XtX(shell); if (XtY(child) && trait) { kidY = XtY(child); XtY(child) = 0; } else kidY = XtY(shell); if (XtBorderWidth(child) && trait) { kidBW = XtBorderWidth(child); XtBorderWidth(child) = 0; } else kidBW = XtBorderWidth(shell); if (XtWidth (child) != XtWidth (shell)) { request.request_mode |= CWWidth; request.width = XtWidth(child); } if (XtHeight (child) + ve->vendor.im_height != XtHeight (shell)) { request.request_mode |= CWHeight; request.height = XtHeight(child) + ve->vendor.im_height; } if (trait) { if (defaultPosition) { GetDefaultPosition(child, XtParent(shell), &request.x, &request.y); if (request.x != kidX) request.request_mode |= CWX; if (request.y != kidY) request.request_mode |= CWY; } else { if (kidX != XtX(shell)) { request.request_mode |= CWX; if (kidX == XmDIALOG_SAVVY_FORCE_ORIGIN) request.x = 0; else request.x = kidX; } if (kidY != XtY(shell)) { request.request_mode |= CWY; if (kidY == XmDIALOG_SAVVY_FORCE_ORIGIN) request.y = 0; else request.y = kidY; } } } else { if (kidX != XtX(shell)) { request.request_mode |= CWX; request.x = kidX; } if (kidY != XtY(shell)) { request.request_mode |= CWY; request.y = kidY; } if (kidBW != XtBorderWidth(shell)) { request.request_mode |= CWBorderWidth; request.border_width = kidBW; } } if (request.request_mode) { unsigned int old_height = ve->vendor.im_height; XtMakeGeometryRequest((Widget) shell, &request, &request); _XmImResize((Widget)shell); if (ve->vendor.im_height != old_height) { request.request_mode = CWHeight; request.height = XtHeight(child) + ve->vendor.im_height; XtMakeGeometryRequest((Widget) shell, &request, &request); _XmImResize((Widget)shell); } } /* * the grab_kind is handled in the popup_callback */ if(shell->core.mapped_when_managed ) { XtPopup ((Widget) shell, XtGrabNone); } } /* * CHILD BEING UNMANAGED */ else { int i, j; /* * Fix for CR5043, CR5758 and CR8825 - * For nested Dialog Shells, it is necessary to unmanage * dialog shell popups of the child of this dialog shell. */ for (i = 0; i < child->core.num_popups; i++) { if (XmIsDialogShell(child->core.popup_list[i])) { XmDialogShellWidget next_shell = (XmDialogShellWidget)(child->core.popup_list[i]); for (j = 0; j < next_shell->composite.num_children; j++) { XtUnmanageChild(next_shell->composite.children[j]); } } } /* End Fix CR5043, CR5758 and CR8825 */ /* * take it down and then tell user */ XtPopdown((Widget) shell); if(trait ) { trait->callMapUnmapCB(child, False); /* call UnMap callback */ } } XmeNavigChangeManaged((Widget) shell); }