void r_gaussian(real y, real x) { r_set(y, x); r_mul(y, y); r_flipsign(y, y); r_exp(y, y); }
/* * Drag a moving XOR box(w,h) that tracks relative to the mouse * until the button comes up. The starting x and y represent * the location of the upper left hand corner of the rectangle * relative to the mouse position. This relative distance should * be maintained. A constraining rectangle is also given. The * box should not be able to be dragged out of the contraining * rectangle. */ void gr_dragbox(WORD w, WORD h, WORD sx, WORD sy, GRECT *pc, WORD *pdx, WORD *pdy) { WORD offx, offy, down; GRECT o; wm_update(TRUE); gr_setup(BLACK); gr_clamp(sx+1, sy+1, 0, 0, &offx, &offy); r_set(&o, sx, sy, w, h); /* get box's x,y from */ /* mouse's x,y then */ /* constrain result */ do { o.g_x = xrat - offx; o.g_y = yrat - offy; rc_constrain(pc, &o); down = gr_wait(&o, &gl_rzero); } while (down); *pdx = o.g_x; *pdy = o.g_y; wm_update(FALSE); } /* gr_dragbox */
string AmSipDialog::getRoute() { string r_set(""); for(vector<string>::iterator it = route.begin(); it != route.end(); it++) { r_set += "Route: " + *it + "\r\n"; } return r_set; }
static void gr_draw(WORD have2box, GRECT *po, GRECT *poff) { GRECT t; gsx_xbox(po); if (have2box) { r_set(&t, po->g_x + poff->g_x, po->g_y + poff->g_y, po->g_w + poff->g_w, po->g_h + poff->g_h ); gsx_xbox(&t); } }
void w_barcalc(WORD isvert, WORD space, WORD sl_value, WORD sl_size, WORD min_sld, GRECT *ptv, GRECT *pth) { if (sl_size == -1) sl_size = min_sld; else sl_size = max(min_sld, mul_div(sl_size, space, 1000) ); sl_value = mul_div(space - sl_size, sl_value, 1000); #if 0 /* anemic slidebars */ if (isvert) r_set(ptv, 3, sl_value, gl_wbox-6, sl_size); else r_set(pth, sl_value, 2, sl_size, gl_hbox-4); #else if (isvert) r_set(ptv, 0, sl_value, gl_wbox, sl_size); else r_set(pth, sl_value, 0, sl_size, gl_hbox); #endif }
void gr_movebox(WORD w, WORD h, WORD srcx, WORD srcy, WORD dstx, WORD dsty) { register WORD signx, signy; WORD cnt; WORD xstep, ystep; GRECT t; r_set(&t, srcx, srcy, w, h); signx = (srcx < dstx) ? -1 : 1; signy = (srcy < dsty) ? -1 : 1; gr_scale(signx*(srcx-dstx), signy*(srcy-dsty), &cnt, &xstep, &ystep); gr_2box(FALSE, cnt, &t, signx*xstep, signy*ystep, FALSE); }
/* * Stretch the free corner of an XOR box(w,h) that is pinned at * another corner based on mouse movement until the button comes * up. Also draw a second box offset from the stretching box. */ void gr_rubwind(WORD xorigin, WORD yorigin, WORD wmin, WORD hmin, GRECT *poff, WORD *pwend, WORD *phend) { WORD down; GRECT o; wm_update(TRUE); gr_setup(BLACK); r_set(&o, xorigin, yorigin, 0, 0); /* clamp size of rubber */ /* box to no smaller */ /* than wmin, hmin */ do { gr_clamp(o.g_x, o.g_y, wmin, hmin, &o.g_w, &o.g_h); down = gr_wait(&o, poff); } while (down); *pwend = o.g_w; *phend = o.g_h; wm_update(FALSE); } /* gr_rubwind */
void glob_opt() { parameter *paras; cryStruct *oriCS; int i; paras = (parameter*)malloc(sizeof(parameter)); r_set(paras); init_rand(paras); oriCS = new_CS(paras); init_oriCS(oriCS, paras); if(paras->adaptive == 1) adaptive(paras, oriCS); else if((paras->algoGlob >= 1) && (paras->algoGlob <= 19)) { if(paras->run == 1) pso_opt_serial(paras, oriCS); else if(paras->run == 11) pso_opt(paras, oriCS); } del_CS(oriCS, paras); for(i=0; i < paras->nType; i++) free(paras->type[i]); for(i=0; i < paras->nRmFile; i++) free(paras->rmFile[i]); free(paras->type); free(paras->charge); free(paras->rmFile); free(paras); return; }
static void fm_build(LONG tree, WORD haveicon, WORD nummsg, WORD mlenmsg, WORD numbut, WORD mlenbut) { register WORD i; GRECT al, ic, bt, ms; OBJECT *obj; r_set(&al, 0, 0, 1+INTER_WSPACE, 1+INTER_HSPACE); r_set(&ms, 1 + INTER_WSPACE, 1 + INTER_HSPACE, mlenmsg, 1); if (haveicon) { r_set(&ic, 1+INTER_WSPACE, 1+INTER_HSPACE, 4, 4); al.g_w += ic.g_w + INTER_WSPACE + 1; al.g_h += ic.g_h + INTER_HSPACE + 1; ms.g_x = ic.g_x + ic.g_w + INTER_WSPACE + 1; } r_set(&bt, 1+INTER_WSPACE, 2+INTER_HSPACE+max(nummsg, 1), mlenbut, 1); if (haveicon && nummsg < 2) { bt.g_y += 1; } if (mlenmsg + al.g_w > numbut * mlenbut + (numbut-1) + 1+INTER_WSPACE) { al.g_w += mlenmsg + INTER_WSPACE + 1; bt.g_x = (al.g_w - numbut * mlenbut - (numbut-1)) / 2; } else { al.g_w = numbut * mlenbut + (numbut-1) + 2 * (1+INTER_WSPACE); } al.g_h = max(al.g_h, 2 + (2 * INTER_HSPACE) + nummsg + 2); /* init. root object */ ob_setxywh(tree, ROOT, &al); for(i=0, obj=(OBJECT *)tree; i<NUM_ALOBJS; i++, obj++) obj->ob_next = obj->ob_head = obj->ob_tail = -1; /* add icon object */ if (haveicon) { ob_setxywh(tree, 1, &ic); ob_add(tree, ROOT, 1); } /* add msg objects */ for(i=0; i<nummsg; i++) { ob_setxywh(tree, MSGOFF+i, &ms); ms.g_y++; ob_add(tree, ROOT, MSGOFF+i); } /* add button objects */ for(i=0, obj=((OBJECT *)tree)+BUTOFF; i<numbut; i++, obj++) { obj->ob_flags = SELECTABLE | EXIT; obj->ob_state = NORMAL; ob_setxywh(tree, BUTOFF+i, &bt); bt.g_x += mlenbut + 1; ob_add(tree, ROOT, BUTOFF+i); } /* set last object flag */ (--obj)->ob_flags |= LASTOB; }
static void hctl_window(WORD w_handle, WORD mx, WORD my) { GRECT t, f, pt; WINDOW *pwin = &D.w_win[w_handle]; WORD x, y, w, h; WORD wm, hm; WORD kind; WORD cpt, message; LONG tree; message = 0; x = y = w = h = 0; if ( (w_handle == gl_wtop) || ( (pwin->w_flags & VF_SUBWIN) && (D.w_win[gl_wtop].w_flags & VF_SUBWIN) ) ) { /* * went down on active window so handle control points */ w_bldactive(w_handle); tree = gl_awind; cpt = ob_find(gl_awind, 0, 10, mx, my); w_getsize(WS_CURR, w_handle, &t); r_get(&t, &x, &y, &w, &h); kind = pwin->w_kind; switch(cpt) { case W_CLOSER: if ( kind & HOTCLOSE ) { message = WM_CLOSED; break; } /* else fall thru */ case W_FULLER: if ( gr_watchbox(gl_awind, cpt, SELECTED, NORMAL) ) { message = (cpt == W_CLOSER) ? WM_CLOSED : WM_FULLED; ob_change(gl_awind, cpt, NORMAL, TRUE); } break; case W_NAME: if ( kind & MOVER ) { /* prevent the mover gadget from being moved completely offscreen */ r_set(&f, 0, gl_hbox, gl_rscreen.g_w + w - gl_wbox - 6, MAX_COORDINATE); gr_dragbox(w, h, x, y, &f, &x, &y); message = WM_MOVED; } break; case W_SIZER: if (kind & SIZER) { w_getsize(WS_WORK, w_handle, &t); t.g_x -= x; t.g_y -= y; t.g_w -= w; t.g_h -= h; wm = gl_wchar; hm = gl_hchar; if (kind & (LFARROW | RTARROW | HSLIDE)) wm = gl_wbox * 7; if (kind & (UPARROW | DNARROW | VSLIDE)) hm = gl_hbox * 7; gr_rubwind(x, y, wm, hm, &t, &w, &h); message = WM_SIZED; } break; case W_HSLIDE: case W_VSLIDE: ob_actxywh(tree, cpt + 1, &pt); if (inside(mx, my, &pt)) { cpt = (cpt==W_HSLIDE) ? W_HELEV : W_VELEV; goto doelev; } /* fix up cpt for index into gl_wa[] */ if (cpt == W_HSLIDE) { if ( !(mx < pt.g_x) ) cpt += 1; } else { if ( !(my < pt.g_y) ) cpt += 1; } /* fall thru */ case W_UPARROW: case W_DNARROW: case W_LFARROW: case W_RTARROW: message = WM_ARROWED; x = gl_wa[cpt - W_UPARROW]; break; case W_HELEV: case W_VELEV: doelev: message = (cpt == W_HELEV) ? WM_HSLID : WM_VSLID; x = gr_slidebox(gl_awind, cpt - 1, cpt, (cpt == W_VELEV)); /* slide is 1 less than elev */ break; } } else { perform_untop(gl_wtop); /* * went down on inactive window so tell ap. to bring it to top */ message = WM_TOPPED; } ct_msgup(message, pwin->w_owner, w_handle, x, y, w, h); }