void ScubaObject::BuildMesh(TimeValue t) { int segs, smooth, hsegs; float radius,height,pie1, pie2,r2; int doPie, genUVs,con; // Start the validity interval at forever and widdle it down. FixHeight(pblock,t,(pmapParam?pmapParam->GetHWnd():NULL),increate); ivalid = FOREVER; pblock->GetValue(PB_RADIUS,t,radius,ivalid); pblock->GetValue(PB_CENTERS,t,con,ivalid); pblock->GetValue(PB_HEIGHT,t,height,ivalid); r2=2.0f*radius; if (con) height+=(height<0.0f?-r2:r2); pblock->GetValue(PB_SIDES,t,segs,ivalid); pblock->GetValue(PB_HSEGS,t,hsegs,ivalid); pblock->GetValue(PB_SMOOTHON,t,smooth,ivalid); pblock->GetValue(PB_SLICEFROM,t,pie1,ivalid); pblock->GetValue(PB_SLICETO,t,pie2,ivalid); pblock->GetValue(PB_SLICEON,t,doPie,ivalid); pblock->GetValue(PB_GENUVS,t,genUVs,ivalid); LimitValue(radius, MIN_RADIUS, MAX_RADIUS); LimitValue(height, MIN_HEIGHT, MAX_HEIGHT); LimitValue(hsegs, MIN_SEGMENTS, MAX_SEGMENTS); LimitValue(segs, MIN_SIDES, MAX_SIDES); LimitValue(smooth, 0, 1); // sides, smooth, cylrad BuildScubaMesh(mesh, segs, smooth, hsegs, doPie,radius, height, pie1, pie2, genUVs, GetUsePhysicalScaleUVs()); }
INT_PTR ScubaHeightDlgProc::DlgProc( TimeValue t,IParamMap *map,HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) { switch (msg) { case WM_INITDIALOG: { mhWnd = hWnd; Update(); break; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_GENTEXTURE: Update(); break; case IDC_REAL_WORLD_MAP_SCALE: { BOOL check = IsDlgButtonChecked(hWnd, IDC_REAL_WORLD_MAP_SCALE); theHold.Begin(); ob->SetUsePhysicalScaleUVs(check); theHold.Accept(GetString(IDS_DS_PARAMCHG)); ob->ip->RedrawViews(ob->ip->GetTime()); break; } } case CC_SPINNER_CHANGE: switch ( LOWORD(wParam) ) { case IDC_SC_HEIGHTSPIN: FixHeight(ob->pblock,t,hWnd,ob->increate); return TRUE; } } return FALSE; }
static void RotateRight(pNode& p) { pNode a = p; pNode b = a->Left; pNode R = a->Right; pNode L = b->Left; pNode C = b->Right; a->Left = C; a->Right = R; b->Left = L; b->Right = a; FixHeight(a); Recalc(a); FixHeight(b); Recalc(b); p = b; }
static void Balance(pNode& p) { if (!p) return; FixHeight(p); if (BalanceFactor(p) == 2) { if (BalanceFactor(p->Right) < 0) RotateRight(p->Right); RotateLeft(p); } if (BalanceFactor(p) == -2) { if (BalanceFactor(p->Left) > 0) RotateLeft(p->Left); RotateRight(p); } }
/** Resize a client window (mouse initiated). */ void ResizeClient(ClientNode *np, BorderActionType action, int startx, int starty) { XEvent event; int oldx, oldy; int oldw, oldh; int gwidth, gheight; int lastgwidth, lastgheight; int delta; int north, south, east, west; int ratio, minr, maxr; Assert(np); if(!(np->state.border & BORDER_RESIZE)) { return; } if(JUNLIKELY(!GrabMouseForResize(action))) { Debug("ResizeClient: could not grab mouse"); return; } if(np->state.status & STAT_SHADED) { action &= ~(BA_RESIZE_N | BA_RESIZE_S); } np->controller = ResizeController; shouldStopResize = 0; oldx = np->x; oldy = np->y; oldw = np->width; oldh = np->height; gwidth = (np->width - np->baseWidth) / np->xinc; gheight = (np->height - np->baseHeight) / np->yinc; GetBorderSize(np, &north, &south, &east, &west); startx += np->x - west; starty += np->y - north; CreateResizeWindow(np); UpdateResizeWindow(np, gwidth, gheight); if(!(GetMouseMask() & (Button1Mask | Button3Mask))) { StopResize(np); return; } for(;;) { WaitForEvent(&event); if(shouldStopResize) { np->controller = NULL; return; } switch(event.type) { case ButtonRelease: if( event.xbutton.button == Button1 || event.xbutton.button == Button3) { StopResize(np); return; } break; case MotionNotify: SetMousePosition(event.xmotion.x_root, event.xmotion.y_root); DiscardMotionEvents(&event, np->window); if(action & BA_RESIZE_N) { delta = (event.xmotion.y - starty) / np->yinc; delta *= np->yinc; if(oldh - delta >= np->minHeight && (oldh - delta <= np->maxHeight || delta > 0)) { np->height = oldh - delta; np->y = oldy + delta; } if(!(action & (BA_RESIZE_E | BA_RESIZE_W))) { FixWidth(np); } } if(action & BA_RESIZE_S) { delta = (event.xmotion.y - starty) / np->yinc; delta *= np->yinc; np->height = oldh + delta; np->height = Max(np->height, np->minHeight); np->height = Min(np->height, np->maxHeight); if(!(action & (BA_RESIZE_E | BA_RESIZE_W))) { FixWidth(np); } } if(action & BA_RESIZE_E) { delta = (event.xmotion.x - startx) / np->xinc; delta *= np->xinc; np->width = oldw + delta; np->width = Max(np->width, np->minWidth); np->width = Min(np->width, np->maxWidth); if(!(action & (BA_RESIZE_N | BA_RESIZE_S))) { FixHeight(np); } } if(action & BA_RESIZE_W) { delta = (event.xmotion.x - startx) / np->xinc; delta *= np->xinc; if(oldw - delta >= np->minWidth && (oldw - delta <= np->maxWidth || delta > 0)) { np->width = oldw - delta; np->x = oldx + delta; } if(!(action & (BA_RESIZE_N | BA_RESIZE_S))) { FixHeight(np); } } if(np->sizeFlags & PAspect) { if((action & (BA_RESIZE_N | BA_RESIZE_S)) && (action & (BA_RESIZE_E | BA_RESIZE_W))) { /* Fixed point with a 16-bit fraction. */ ratio = (np->width << 16) / np->height; minr = (np->aspect.minx << 16) / np->aspect.miny; if(ratio < minr) { delta = np->width; np->width = (np->height * minr) >> 16; if(action & BA_RESIZE_W) { np->x -= np->width - delta; } } maxr = (np->aspect.maxx << 16) / np->aspect.maxy; if(ratio > maxr) { delta = np->height; np->height = (np->width << 16) / maxr; if(action & BA_RESIZE_N) { np->y -= np->height - delta; } } } } lastgwidth = gwidth; lastgheight = gheight; gwidth = (np->width - np->baseWidth) / np->xinc; gheight = (np->height - np->baseHeight) / np->yinc; if(lastgheight != gheight || lastgwidth != gwidth) { if(np->state.status & (STAT_HMAX | STAT_VMAX)) { np->state.status &= ~(STAT_HMAX | STAT_VMAX); WriteState(np); SendConfigureEvent(np); } UpdateResizeWindow(np, gwidth, gheight); if(resizeMode == RESIZE_OUTLINE) { ClearOutline(); if(np->state.status & STAT_SHADED) { DrawOutline(np->x - west, np->y - north, np->width + west + east, north + south); } else { DrawOutline(np->x - west, np->y - north, np->width + west + east, np->height + north + south); } } else { ResetRoundedRectWindow(np->parent); if(np->state.status & STAT_SHADED) { ShapeRoundedRectWindow(np->parent, np->width + east + west, north + south); JXMoveResizeWindow(display, np->parent, np->x - west, np->y - north, np->width + west + east, north + south); } else { ShapeRoundedRectWindow(np->parent, np->width + east + west, np->height + north + south); JXMoveResizeWindow(display, np->parent, np->x - west, np->y - north, np->width + west + east, np->height + north + south); } JXMoveResizeWindow(display, np->window, west, north, np->width, np->height); SendConfigureEvent(np); } UpdatePager(); } break; default: break; }