int main(int argc, char **argv) { char rbuf[128]; struct epoll_event ev; int op_num = 0; int pfd[2]; int efd[3]; int ec = EXIT_FAILURE; int ret, i, j; parse_args(argc, argv); /* FIXME eventually stdio streams should be harmless */ close(0); logfp = fopen(LOG_FILE, "w+"); if (!logfp) { perror("could not open logfile"); exit(1); } /* redirect stdout and stderr to the log file */ if (dup2(fileno(logfp), 1) < 0) { log_error("dup2(logfp, 1)"); goto out; } if (dup2(fileno(logfp), 2) < 0) { log_error("dup2(logfp, 2)"); goto out; } if (!move_to_cgroup("freezer", freezer, getpid())) { log_error("move_to_cgroup"); exit(2); } ret = pipe(pfd); if (ret < 0) goto out; log("INFO", "pipe read fd: %d, pipe write fd: %d\n", pfd[0], pfd[1]); label(create_efd, ret, ret + 0); ev.events = EPOLLOUT|EPOLLIN|EPOLLET; for (i = 0; i < num_efd; i++) { efd[i] = epoll_create(4); if (efd[i] < 0) { log("FAIL", "efd[i] = epoll_create(3);"); ret = efd[i]; goto out; } if (i == 0) continue; ev.data.fd = efd[i - 1]; ret = epoll_ctl(efd[i], EPOLL_CTL_ADD, ev.data.fd, &ev); if (ret < 0) { log("FAIL", "epoll_ctl(efd[i] (%d), EPOLL_CTL_ADD, ev.data.fd (%d), &ev);", efd[i], ev.data.fd); goto out; } } /* Close the cycle */ ev.data.fd = efd[num_efd - 1]; ret = epoll_ctl(efd[0], EPOLL_CTL_ADD, ev.data.fd, &ev); if (ret < 0) { log("FAIL", "epoll_ctl(efd[num_efd - 1], EPOLL_CTL_ADD, ev.data.fd, &ev);"); goto out; } label(link_pipe, ret, ret + 0); /* * Now put the pipe fds "last" set of the cycle. For example: * * /---------------------------------\ * | | * \- efd[0] <-- efd[1] <-- efd[2] <-/ * | | * | \--> pfd[0] * \----> pfd[1] * * Where foo --> bar means that foo has bar in its set. */ ev.events = EPOLLIN; ev.data.fd = pfd[0]; ret = epoll_ctl(efd[num_efd - 1], EPOLL_CTL_ADD, ev.data.fd, &ev); if (ret < 0) { log("FAIL", "epoll_ctl(efd[num_efd - 1], EPOLL_CTL_ADD, pfd[0], &ev);"); goto out; } ev.events = EPOLLOUT; ev.data.fd = pfd[1]; ret = epoll_ctl(efd[num_efd - 1], EPOLL_CTL_ADD, ev.data.fd, &ev); if (ret < 0) { log("FAIL", "epoll_ctl(efd[num_efd - 1], EPOLL_CTL_ADD, pfd[1], &ev);"); goto out; } label(wait_write, ret, ret + 0); /* * Since it's a cycle of epoll sets, we have to wait on the * other epoll sets to get the event that triggered EPOLLIN * on this set. Start with the epoll fd which will take us the * long way around the cycle: efd[num_efd - 2]. */ /* The index of the previous epoll fd in the cycle */ j = num_efd - 1; for (i = num_efd - 2; i > -1; i--) { /* The index of the previous epoll fd in the cycle */ j = (unsigned int)(i - 1) % ~(num_efd - 1); log("INFO", "Waiting on %d for EPOLLIN on %d\n", efd[i], efd[j]); ret = epoll_wait(efd[i], &ev, 1, 1000); if (ret != 1) { log_error("Expected epoll_wait() to return an event.\n"); goto out; } log("INFO", "Got event: fd: %d eflags: %s\n", ev.data.fd, eflags(ev.events)); if ((ev.data.fd != efd[j]) || !(ev.events & EPOLLIN)) goto out; } /* * Now we expect the actual event indicating it's ok to write * output. */ log("INFO", "Waiting on %d for EPOLLOUT on %d\n", efd[j], pfd[1]); ret = epoll_wait(efd[j], &ev, 1, 1000); if (ret != 1) { log_error("Expected epoll_wait() to return an event.\n"); goto out; } log("INFO", "Got event: fd: %d eflags: %s\n", ev.data.fd, eflags(ev.events)); if ((ev.data.fd != pfd[1]) || !(ev.events & EPOLLOUT)) goto out; label(do_write, ret, write(pfd[1], HELLO, strlen(HELLO) + 1)); if (ret < (int)(strlen(HELLO) + 1)) { log("FAIL", "Unable to write all %zu bytes of \"%s\" to %d\n", strlen(HELLO) + 1, HELLO, pfd[0]); goto out; } label(wait_read, ret, ret + 0); /* The index of the previous epoll fd in the cycle */ j = num_efd - 1; for (i = num_efd - 2; i > -1; i--) { /* The index of the previous epoll fd in the cycle */ j = (unsigned int)(i - 1) % ~(num_efd - 1); log("INFO", "Waiting on %d for EPOLLIN on %d\n", efd[i], efd[j]); ret = epoll_wait(efd[i], &ev, 1, 1000); if (ret != 1) { log_error("Expected epoll_wait() to return an event.\n"); goto out; } log("INFO", "Got event: fd: %d eflags: %s\n", ev.data.fd, eflags(ev.events)); if ((ev.data.fd != efd[j]) || !(ev.events & EPOLLIN)) goto out; } log("INFO", "Waiting on %d for EPOLLIN on %d\n", efd[j], pfd[0]); ret = epoll_wait(efd[j], &ev, 1, 1000); if (ret != 1) { log_error("Expected epoll_wait() to return an event.\n"); goto out; } log("INFO", "Got event: fd: %d eflags: %s\n", ev.data.fd, eflags(ev.events)); if ((ev.data.fd != pfd[0]) || !(ev.events & EPOLLIN)) goto out; label(do_read, ret, ret + 0); ret = read(pfd[0], rbuf, strlen(HELLO) + 1); if (ret < (int)(strlen(HELLO) + 1)) { log("FAIL", "Unable to read all %zu bytes of \"%s\"\n", strlen(HELLO) + 1, HELLO); goto out; } if (strcmp(HELLO, rbuf)) { log("FAIL", "File was corrupted. Expected: \"%s\" Got: \"%s\"\n", HELLO, rbuf); goto out; } log("INFO", "read len ok\n"); log("INFO", "read pipe contents ok\n"); ec = EXIT_SUCCESS; op_num = INT_MAX; out: if (op_num != INT_MAX) { log("FAIL", "error at label %s (op num: %d)\n", labels[op_num], op_num); } for (i = 0; i < num_efd; i++) { ret = close(efd[i]); efd[i] = -1; if (ret < 0) log_error("close(efd[i])"); } if (pfd[0]) { close(pfd[0]); close(pfd[1]); } fflush(logfp); fclose(logfp); exit(ec); }
shape_window(int x,int y,int w,int h,const char *l=0) :Fl_Box(x,y,w,h,l){ box(FL_DOWN_BOX); label("This demo does\nnot work without GL"); }
void DesktopIcon::draw(void) { // draw_box(FL_UP_BOX, FL_BLACK); if(image() && (damage() & FL_DAMAGE_ALL)) { Fl_Image* im = image(); /* center image in the box */ int ix = (w()/2) - (im->w()/2); int iy = (h()/2) - (im->h()/2); ix += x(); iy += y(); /* darker_img is always present if image() is present */ if(is_focused()) darker_img->draw(ix, iy); else im->draw(ix, iy); E_DEBUG(E_STRLOC ": DesktopIcon icon redraw\n"); } if(gsettings->label_draw && (damage() & (FL_DAMAGE_ALL | EDAMAGE_CHILD_LABEL))) { int X = x() + w()-(w()/2)-(lwidth/2); int Y = y() + h() + LABEL_OFFSET; Fl_Color old = fl_color(); if(!gsettings->label_transparent) { fl_color(gsettings->label_background); fl_rectf(X, Y, lwidth, lheight); } int old_font = fl_font(); int old_font_sz = fl_size(); /* draw with icon's font */ fl_font(labelfont(), labelsize()); /* pseudo-shadow */ fl_color(FL_BLACK); fl_draw(label(), X+1, Y+1, lwidth, lheight, align(), 0, 0); fl_color(gsettings->label_foreground); fl_draw(label(), X, Y, lwidth, lheight, align(), 0, 0); /* restore old font */ fl_font(old_font, old_font_sz); if(is_focused()) { /* draw focused box on our way so later this can be used to draw customised boxes */ fl_color(gsettings->label_foreground); fl_line_style(FL_DOT); fl_push_matrix(); fl_begin_loop(); fl_vertex(X, Y); fl_vertex(X + lwidth, Y); fl_vertex(X + lwidth, Y + lheight); fl_vertex(X, Y + lheight); fl_vertex(X, Y); fl_end_loop(); fl_pop_matrix(); /* revert to default line style */ fl_line_style(0); } /* revert to old color whatever that be */ fl_color(old); E_DEBUG(E_STRLOC ": DesktopIcon label redraw\n"); } }
void CCBuilder::setLabel(int x, int y, int newValue) { recolor.replace(label(x, y), newValue); labels[y*w+x] = newValue; didRecolor = true; }
/* static */ wxString wxControlBase::EscapeMnemonics(const wxString& text) { wxString label(text); label.Replace("&", "&&"); return label; }
void JIT::compileLoadVarargs(Instruction* instruction) { int thisValue = instruction[3].u.operand; int arguments = instruction[4].u.operand; int firstFreeRegister = instruction[5].u.operand; JumpList slowCase; JumpList end; bool canOptimize = m_codeBlock->usesArguments() && arguments == m_codeBlock->argumentsRegister() && !m_codeBlock->symbolTable()->slowArguments(); if (canOptimize) { emitLoadTag(arguments, regT1); slowCase.append(branch32(NotEqual, regT1, TrustedImm32(JSValue::EmptyValueTag))); load32(payloadFor(JSStack::ArgumentCount), regT2); slowCase.append(branch32(Above, regT2, TrustedImm32(Arguments::MaxArguments + 1))); // regT2: argumentCountIncludingThis move(regT2, regT3); add32(TrustedImm32(firstFreeRegister + JSStack::CallFrameHeaderSize), regT3); lshift32(TrustedImm32(3), regT3); addPtr(callFrameRegister, regT3); // regT3: newCallFrame slowCase.append(branchPtr(Below, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), regT3)); // Initialize ArgumentCount. store32(regT2, payloadFor(JSStack::ArgumentCount, regT3)); // Initialize 'this'. emitLoad(thisValue, regT1, regT0); store32(regT0, Address(regT3, OBJECT_OFFSETOF(JSValue, u.asBits.payload) + (CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register))))); store32(regT1, Address(regT3, OBJECT_OFFSETOF(JSValue, u.asBits.tag) + (CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register))))); // Copy arguments. neg32(regT2); end.append(branchAdd32(Zero, TrustedImm32(1), regT2)); // regT2: -argumentCount; Label copyLoop = label(); load32(BaseIndex(callFrameRegister, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.payload) +(CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register)))), regT0); load32(BaseIndex(callFrameRegister, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.tag) +(CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register)))), regT1); store32(regT0, BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.payload) +(CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register))))); store32(regT1, BaseIndex(regT3, regT2, TimesEight, OBJECT_OFFSETOF(JSValue, u.asBits.tag) +(CallFrame::thisArgumentOffset() * static_cast<int>(sizeof(Register))))); branchAdd32(NonZero, TrustedImm32(1), regT2).linkTo(copyLoop, this); end.append(jump()); } if (canOptimize) slowCase.link(this); JITStubCall stubCall(this, cti_op_load_varargs); stubCall.addArgument(thisValue); stubCall.addArgument(arguments); stubCall.addArgument(Imm32(firstFreeRegister)); stubCall.call(regT3); if (canOptimize) end.link(this); }
void gdbui_env_dlg(const GdbEnvironInfo * env) { GtkWidget *dlg = gtk_dialog_new_with_buttons(_("Environment settings"), GTK_WINDOW(gdbui_setup.main_window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_OK, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); GtkBox *vbox = GTK_BOX(GTK_DIALOG(dlg)->vbox); GtkWidget *cwd_box = gtk_entry_new(); GtkWidget *path_box = gtk_entry_new(); GtkWidget *args_box = gtk_entry_new(); GtkWidget *dirs_box = gtk_entry_new(); gtk_window_set_transient_for(GTK_WINDOW(dlg), GTK_WINDOW(gdbui_setup.main_window)); gtk_window_set_position(GTK_WINDOW(dlg), GTK_WIN_POS_CENTER); gtk_dialog_set_default_response(GTK_DIALOG(dlg), GTK_RESPONSE_OK); gtk_entry_set_text(GTK_ENTRY(cwd_box), env->cwd ? env->cwd : ""); gtk_entry_set_text(GTK_ENTRY(path_box), env->path ? env->path : ""); gtk_entry_set_text(GTK_ENTRY(args_box), env->args ? env->args : ""); gtk_entry_set_text(GTK_ENTRY(dirs_box), env->dirs ? env->dirs : ""); label(args_box, _("\n Command-line arguments passed to target program:")); label(dirs_box, _("\n Search path for source files:")); label(cwd_box, _("\n Working directory for target program:")); label(path_box, _("\n Search path for executables:")); gtk_widget_show_all(dlg); gtk_widget_set_usize(dlg, (gdk_screen_get_width(gdk_screen_get_default()) / 2) * 1, 0); if (gtk_dialog_run(GTK_DIALOG(dlg)) == GTK_RESPONSE_OK) { const gchar *cwd = gtk_entry_get_text(GTK_ENTRY(cwd_box)); const gchar *path = gtk_entry_get_text(GTK_ENTRY(path_box)); const gchar *args = gtk_entry_get_text(GTK_ENTRY(args_box)); const gchar *dirs = gtk_entry_get_text(GTK_ENTRY(dirs_box)); if (!same_str(cwd, env->cwd)) { gdbio_send_cmd("-environment-cd %s\n", cwd); } if (!same_str(path, env->path)) { gchar *fixed = fixup_path(path); gdbio_send_cmd("-environment-path -r %s\n", fixed); g_free(fixed); } if (!same_str(args, env->args)) { gdbio_send_cmd("-exec-arguments %s\n", args); } if (!same_str(dirs, env->dirs)) { gchar *fixed = fixup_path(dirs); gdbio_send_cmd("-environment-directory -r %s\n", fixed); g_free(fixed); } } gtk_widget_destroy(dlg); }
void ObjectEditor::buildGpuBuffers(ShaderProgram & shaderProgram) { std::cout << "TODO buildGpuBuffers for " << label() << std::endl; }
int main() { int n; Si(n); label(n); return 0; }
static int visit(Agnode_t * n, Agraph_t * map, Stack * sp, sccstate * st) { unsigned int m, min; Agnode_t *t; Agraph_t *subg; Agedge_t *e; min = ++(st->ID); setval(n, min); push(sp, n); #ifdef USE_CGRAPH for (e = agfstout(n->root, n); e; e = agnxtout(n->root, e)) { #else for (e = agfstout(n); e; e = agnxtout(e)) { #endif t = aghead(e); if (getval(t) == 0) m = visit(t, map, sp, st); else m = getval(t); if (m < min) min = m; } if (getval(n) == min) { if (!wantDegenerateComp && (top(sp) == n)) { setval(n, INF); pop(sp); } else { char name[32]; Agraph_t *G = agraphof(n);; sprintf(name, "cluster_%d", (st->Comp)++); subg = agsubg(G, name, TRUE); agbindrec(subg, "scc_graph", sizeof(Agraphinfo_t), TRUE); setrep(subg, agnode(map, name, TRUE)); do { t = pop(sp); agsubnode(subg, t, TRUE); setval(t, INF); setscc(t, subg); st->N_nodes_in_nontriv_SCC++; } while (t != n); #ifdef USE_CGRAPH nodeInduce(subg, map); #else nodeInduce(subg); #endif if (!Silent) agwrite(subg, stdout); } } return min; } static int label(Agnode_t * n, int nodecnt, int *edgecnt) { Agedge_t *e; setval(n, 1); nodecnt++; #ifdef USE_CGRAPH for (e = agfstedge(n->root, n); e; e = agnxtedge(n->root, e, n)) { #else for (e = agfstedge(n); e; e = agnxtedge(e, n)) { #endif (*edgecnt) += 1; if (e->node == n) e = agopp(e); if (!getval(e->node)) nodecnt = label(e->node, nodecnt, edgecnt); } return nodecnt; } static int countComponents(Agraph_t * g, int *max_degree, float *nontree_frac) { int nc = 0; int sum_edges = 0; int sum_nontree = 0; int deg; int n_edges; int n_nodes; Agnode_t *n; #ifdef USE_CGRAPH for (n = agfstnode(g); n; n = agnxtnode(g, n)) { #else for (n = agfstnode(g); n; n = agnxtnode(n)) { #endif if (!getval(n)) { nc++; n_edges = 0; n_nodes = label(n, 0, &n_edges); sum_edges += n_edges; sum_nontree += (n_edges - n_nodes + 1); } } if (max_degree) { int maxd = 0; #ifdef USE_CGRAPH for (n = agfstnode(g); n; n = agnxtnode(g, n)) { deg = agdegree(g, n, TRUE, TRUE); #else for (n = agfstnode(g); n; n = agnxtnode(n)) { deg = agdegree(n, TRUE, TRUE); #endif if (maxd < deg) maxd = deg; setval(n, 0); } *max_degree = maxd; } if (nontree_frac) { if (sum_edges > 0) *nontree_frac = (float) sum_nontree / (float) sum_edges; else *nontree_frac = 0.0; } return nc; } static void process(Agraph_t * G) { Agnode_t *n; Agraph_t *map; int nc = 0; float nontree_frac = 0; int Maxdegree = 0; Stack stack; sccstate state; aginit(G, AGRAPH, "scc_graph", sizeof(Agraphinfo_t), TRUE); aginit(G, AGNODE, "scc_node", sizeof(Agnodeinfo_t), TRUE); state.Comp = state.ID = 0; state.N_nodes_in_nontriv_SCC = 0; if (Verbose) nc = countComponents(G, &Maxdegree, &nontree_frac); initStack(&stack, agnnodes(G) + 1); map = agopen("scc_map", Agdirected, (Agdisc_t *) 0); #ifdef USE_CGRAPH for (n = agfstnode(G); n; n = agnxtnode(G, n)) #else for (n = agfstnode(G); n; n = agnxtnode(n)) #endif if (getval(n) == 0) visit(n, map, &stack, &state); freeStack(&stack); if (!Silent) agwrite(map, stdout); agclose(map); if (Verbose) fprintf(stderr, "%d %d %d %d %.4f %d %.4f\n", agnnodes(G), agnedges(G), nc, state.Comp, state.N_nodes_in_nontriv_SCC / (double) agnnodes(G), Maxdegree, nontree_frac); else fprintf(stderr, "%d nodes, %d edges, %d strong components\n", agnnodes(G), agnedges(G), state.Comp); } static char *useString = "Usage: %s [-sdv?] <files>\n\ -s - silent\n\ -d - allow degenerate components\n\ -v - verbose\n\ -? - print usage\n\ If no files are specified, stdin is used\n"; static void usage(int v) { printf(useString, CmdName); exit(v); }
void WAbstractToggleButton::setText(const std::string text) { label()->setText(text); }
void Graphe::draw(QPainter * qp){ float w= qp->window().width()/100.; float h= qp->window().height()/100.; //w = std::min(w, h); //h = std::min(w,h); //a faire plus tard //qDebug() << w << qPrintable(" ") << h; qp->setBrush(Qt::black); int x, y; int r = 2; //TITLE if(displayTitle) qp->drawText(15, 15, title); //NODES for(int i =0; i<this->n; i++){ noeuds[i].reset(); x = noeuds[i].getx()*w; y= noeuds[i].gety()*h; //qDebug() << i << noeuds[i].getx() << noeuds[i].gety(); qp->drawEllipse(x-r/2, y-r/2, r, r); if(drawLabel){ if(x<w*50.){ if(y<h*50.){ qp->drawText(x-13, y-5, label(i)); }else{ qp->drawText(x-13, y+13, label(i)); } }else{ if(y<h*50.){ qp->drawText(x+5, y-5, label(i)); }else{ qp->drawText(x+5, y+13, label(i)); } } } } float alpha; float thick; float ratio; for(int i =0; i<this->n; i++){ for(int j =0; j<this->n; j++){ if(adj[i][j] > threshold){ if(maxadj!=0){ if(type==GREENRED || type==BLUEPURPLE){ //if adj[i][j]<0.5 maxadj, change alpha, >0.6 ou >0.5change color < 1 change color and thickness ratio = adj[i][j]/maxadj; alpha = (ratio<0.8) ? 255*(adj[i][j]/(0.8*maxadj)) : 255; if(type==GREENRED){ color_r = (ratio<0.5) ? 0 : 255.*(ratio-0.3)/0.7; color_v = (ratio<0.5) ? 175 : 175 - 175*(ratio-0.3)/0.7; color_b = 0; } if(type==BLUEPURPLE){ color_r = (ratio<0.6) ? 40 : 40 + 215.*(ratio-0.5)/0.5; color_v=100; //color_v = (ratio<0.3) ? 175 : 175 - 175*(ratio-0.3)/0.7; color_b = (ratio<0.6) ? 200 : 200 + 55.*(ratio-0.5)/0.5; } thick = (ratio<0.2) ? 0.5 : adj[i][j]/maxadj*2.5; thick = (ratio<0.6) ? thick : adj[i][j]/maxadj*6. - 2.1f; qp->setPen(QPen(QColor(color_r, color_v, color_b, alpha), thick, Qt::SolidLine)); qp->setBrush(Qt::NoBrush); } if(type==BLACKGRAPH){ color_b = 0; color_r=0; color_v = 0; //if adj[i][j]<0.3 maxadj, change alpha, else change thickness (grosso modo) ratio = adj[i][j]/maxadj; alpha = (ratio<0.3) ? 255*(adj[i][j]/(0.3*maxadj)) : 255; thick = (ratio<0.2) ? 0.5 : adj[i][j]/maxadj*5.; qp->setPen(QPen(QColor(color_r, color_v, color_b, alpha), thick, Qt::SolidLine)); qp->setBrush(Qt::NoBrush); } if(i!=j) this->drawArrow(qp, i, j, w, h); } } } } }
void Exo_Entity::internal_load_params() { int name_size = ex_inquire_int(fileId, EX_INQ_MAX_READ_NAME_LENGTH); { std::vector<char> name(name_size + 1); ex_get_name(fileId, exodus_type(), id_, TOPTR(name)); if (name[0] != '\0') { name_ = TOPTR(name); to_lower(name_); } else { name_ = short_label(); name_ += "_"; name_ += to_string(id_); } } numVars = get_num_variables(fileId, exodus_type(), label()); if (numVars) { results_ = new double *[numVars]; SMART_ASSERT(results_ != nullptr); for (int i = 0; i < numVars; ++i) results_[i] = nullptr; } numAttr = get_num_attributes(fileId, exodus_type(), id_, label()); if (numAttr) { attributes_.resize(numAttr); char **names = get_name_array(numAttr, name_size); int err = ex_get_attr_names(fileId, exodus_type(), id_, names); if (err < 0) { ERROR("ExoII_Read::Get_Init_Data(): Failed to get " << label() << " attribute names! Aborting...\n"); exit(1); } for (int vg = 0; vg < numAttr; ++vg) { SMART_ASSERT(names[vg] != nullptr); if (std::strlen(names[vg]) == 0) { std::string name = "attribute_" + to_string(vg + 1); attributeNames.push_back(name); } else if ((int)std::strlen(names[vg]) > name_size) { std::cerr << trmclr::red << "exodiff: ERROR: " << label() << " attribute names appear corrupt\n" << " A length is 0 or greater than " << "name_size(" << name_size << ")\n" << " Here are the names that I received from" << " a call to ex_get_attr_names(...):\n"; for (int k = 1; k <= numAttr; ++k) std::cerr << "\t\t" << k << ") \"" << names[k - 1] << "\"\n"; std::cerr << " Aborting...\n" << trmclr::normal; exit(1); } else { std::string n(names[vg]); to_lower(n); attributeNames.push_back(n); } } free_name_array(names, numAttr); } }
std::string Exo_Entity::Load_Results(int t1, int t2, double proportion, int var_index) { static std::vector<double> results2; SMART_ASSERT(Check_State()); if (fileId < 0) return "exodiff: ERROR: Invalid file id!"; if (id_ == EX_INVALID_ID) return "exodiff: ERROR: Must initialize block parameters first!"; SMART_ASSERT(var_index >= 0 && var_index < numVars); SMART_ASSERT(t1 >= 1 && t1 <= (int)get_num_timesteps(fileId)); SMART_ASSERT(t2 >= 1 && t2 <= (int)get_num_timesteps(fileId)); if (t1 != currentStep) { Free_Results(); currentStep = t1; } if (truth_ == nullptr) { get_truth_table(); } if (truth_[var_index]) { if (!results_[var_index] && numEntity) { results_[var_index] = new double[numEntity]; SMART_ASSERT(results_[var_index] != nullptr); } if (numEntity) { int err = ex_get_var(fileId, t1, exodus_type(), var_index + 1, id_, numEntity, results_[var_index]); if (err < 0) { ERROR("Exo_Entity::Load_Results(): Call to exodus routine" << " returned error value! " << label() << " id = " << id_ << '\n' << "Aborting...\n"); exit(1); } else if (err > 0) { std::ostringstream oss; oss << "WARNING: Number " << err << " returned from call to exodus get variable routine."; return oss.str(); } if (t1 != t2) { results2.resize(numEntity); err = ex_get_var(fileId, t2, exodus_type(), var_index + 1, id_, numEntity, &results2[0]); if (err < 0) { ERROR("Exo_Entity::Load_Results(): Call to exodus routine" << " returned error value! " << label() << " id = " << id_ << '\n' << "Aborting...\n"); exit(1); } double *results1 = results_[var_index]; for (size_t i = 0; i < numEntity; i++) { results1[i] = (1.0 - proportion) * results1[i] + proportion * results2[i]; } } } else return std::string("WARNING: No items in this ") + label(); } else { return std::string("WARNING: Variable not stored in this ") + label(); } return ""; }
void QamTachymeter::drawBackground(QPainter& painter ) { float w, h ; // épaisseur et longueur du trait de graduation QColor black1(15,13,11) ; QColor black2(34,32,27) ; QColor white(210,200,190) ; QColor red(221,65,57) ; QColor yellow(205,185,83) ; QColor green(101,149,112) ; QFont fo1("arial.ttf", 60 ) ; QFont fo2("arial.ttf", 50 ) ; // fond qfiBackground(painter, m_radius[ROTOR]+ 50, 10 ) ; // graduations "Turbine" painter.save() ; painter.rotate( m_start[TURBINE] ) ; for ( int i = 0 ; i <= ( m_max[TURBINE] - m_min[TURBINE] ) ; ++i ) { if ( i % 10 == 0 ) { w = 20 ; h = 70 ; } else if ( i % 5 == 0 ) { w = 10 ; h = 60 ; } else { w = 4 ; h = 40 ; } qfiMarker(painter, white, m_radius[TURBINE] - 10, QSize( w, h ) ) ; painter.rotate( m_step[TURBINE] ) ; } painter.restore() ; // sérigraphie "Turbine" for ( int i = 0 ; i <= ( m_max[TURBINE] - m_min[TURBINE] ) ; i += 10 ) { float alpha = qDegreesToRadians( m_start[TURBINE] + i * m_step[TURBINE] ) ; float r = m_radius[TURBINE] - 120 ; qfiText(painter, fo1, white, QPoint( r * qCos(alpha), r * qSin(alpha) ), QString("%1").arg(i) ) ; } qfiText(painter, fo1, white, QPoint( 0, 0.8 * m_radius[TURBINE] ), label(TURBINE) ) ; qfiText(painter, fo2, white, QPoint( 0, 0.9 * m_radius[TURBINE] ), unit(TURBINE) ) ; // seuils "Turbine" w = 20 ; h = 90 ; painter.save() ; painter.rotate(m_start[TURBINE] + m_step[TURBINE] * lowThreshold(TURBINE) / 1000 ) ; qfiMarker(painter, red, m_radius[TURBINE] - 10, QSize(w, h ) ) ; painter.restore() ; painter.save() ; painter.rotate(m_start[TURBINE] + m_step[TURBINE] * highThreshold(TURBINE) / 1000 ) ; qfiMarker(painter, red, m_radius[TURBINE] - 10, QSize(w, h ) ) ; painter.restore() ; // zones colorées "Turbine" float radius = m_radius[TURBINE] - 80 ; float start = m_start[TURBINE] + m_step[TURBINE] * lowThreshold(TURBINE) / 100 + 4 ; float span = m_step[TURBINE] * ( ( ( highThreshold(TURBINE) - lowThreshold(TURBINE) ) / 1000 ) / 3 - 0.75 ) ; qfiArc(painter, yellow, radius, start, span, 24 ) ; start += span + 4 ; span = m_step[TURBINE] * ( ( ( highThreshold(TURBINE) - lowThreshold(TURBINE) ) / 1000 ) / 3 - 0.5 ) ; qfiArc(painter, green, radius, start, span, 24 ) ; start += span + 4 ; span = m_step[TURBINE] * ( ( ( highThreshold(TURBINE) - lowThreshold(TURBINE) ) / 1000 ) / 3 - 0.8 ) ; qfiArc(painter, yellow, radius, start, span, 24 ) ; // graduations "Rotor" painter.save() ; radius = m_radius[ROTOR] ; qfiArc(painter, white, radius, m_start[ROTOR], m_span[ROTOR], 5 ) ; QPen pen( white ) ; pen.setWidth(1) ; painter.setPen( pen ) ; painter.setBrush( white ) ; painter.rotate( m_start[ROTOR] ) ; for ( int i = 0 ; i <= ( m_max[ROTOR] - m_min[ROTOR] ) ; ++i ) { if ( i % 5 == 0 ) { w = 10 ; h = 60 ; } else { w = 6 ; h = 40 ; } qfiMarker(painter, white, m_radius[ROTOR], QSize(w, h ) ) ; painter.rotate( m_step[ROTOR] ) ; } painter.restore() ; // sérigraphie "Rotor" for ( int i = 0 ; i <= ( m_max[ROTOR] - m_min[ROTOR] ) ; i += 10 ) { float alpha = qDegreesToRadians( m_start[ROTOR] + i * m_step[ROTOR] ) ; float r = m_radius[ROTOR] - 90 ; qfiText(painter, fo2, white, QPoint( r * qCos(alpha), r * qSin(alpha) ), QString("%1").arg(i/10) ) ; } qfiText(painter, fo1, white, QPoint( 0, m_radius[ROTOR] / 4 ), label(ROTOR) ) ; qfiText(painter, fo2, white, QPoint( 0, -m_radius[ROTOR] / 4 ), unit(ROTOR) ) ; // seuils "Rotor" w = 20 ; h = 100 ; painter.save() ; painter.rotate(m_start[ROTOR] + m_step[ROTOR] * lowThreshold(ROTOR) / 10 ) ; qfiMarker(painter, red, m_radius[ROTOR] + 40, QSize(w, h ) ) ; painter.restore() ; painter.save() ; painter.rotate(m_start[ROTOR] + m_step[ROTOR] * highThreshold(ROTOR) / 10 ) ; qfiMarker(painter, red, m_radius[ROTOR] + 40, QSize(w, h ) ) ; painter.restore() ; // zones colorées "Rotor" radius = m_radius[ROTOR] + 25 ; start = m_start[ROTOR] + m_step[ROTOR] * lowThreshold(ROTOR) / 10 + 5 ; span = m_step[ROTOR] * 3.5 ; qfiArc(painter, yellow, radius, start, span, 24 ) ; start += span + 5 ; span = m_step[ROTOR] * ( ( highThreshold(ROTOR) - lowThreshold(ROTOR) ) / 10 - 5.5 ) ; qfiArc(painter, green, radius, start, span, 24 ) ; }
/****************************************************************************** MODULE: object_cloud_shadow_match PURPOSE: Identify the final shadow pixels by doing a geometric cloud and shadow matching which ends in with the maximum cloud and shadow similarity RETURN: 0 on success -1 on error HISTORY: Date Programmer Reason -------- --------------- ------------------------------------- 3/15/2013 Song Guo Original Development NOTES: ******************************************************************************/ int object_cloud_shadow_match ( Input_t *input, float ptm, float t_templ, float t_temph, int cldpix, int sdpix, unsigned char **cloud_mask, unsigned char **shadow_mask, unsigned char **snow_mask, unsigned char **water_mask, unsigned char **final_mask, bool verbose ) { char errstr[MAX_STR_LEN]; int nrows = input->size.l; int ncols = input->size.s; int row; int col = 0; float sun_ele; float sun_ele_rad; float sun_tazi; float sun_tazi_rad; int sub_size = 30; int status; /* Dynamic memory allocation */ unsigned char **cloud_cal; unsigned char **shadow_cal; unsigned char **boundary_test; cloud_cal = (unsigned char **)ias_misc_allocate_2d_array(input->size.l, input->size.s, sizeof(unsigned char)); shadow_cal = (unsigned char **)ias_misc_allocate_2d_array( input->size.l, input->size.s, sizeof(unsigned char)); boundary_test = (unsigned char **)ias_misc_allocate_2d_array( input->size.l, input->size.s, sizeof(unsigned char)); if (cloud_cal == NULL || shadow_cal == NULL || boundary_test == NULL) { sprintf (errstr, "Allocating mask memory"); ERROR (errstr, "cloud/shadow match"); } /* Read in potential mask ... */ /* Solar elevation angle */ sun_ele = 90 - input->meta.sun_zen; sun_ele_rad = (PI / 180.0) * sun_ele; /* Solar azimuth angle */ sun_tazi = input->meta.sun_az - 90; sun_tazi_rad = (PI / 180.0) * sun_tazi; int cloud_counter = 0; int boundary_counter = 0; float revised_ptm; for (row = 0; row < nrows; row++) { for (col = 0; col < ncols; col++) { if (cloud_mask[row][col] == 1) cloud_counter++; /* Boundary layer includes both cloud_mask equals 0 and 1 */ if (cloud_mask[row][col] < 255) { boundary_test[row][col] = 1; boundary_counter++; } else boundary_test[row][col] = 0; } } /* Revised percent of cloud on the scene after plcloud */ revised_ptm = (float)cloud_counter / (float)boundary_counter; if (verbose) { printf("cloud_counter, boundary_counter = %d, %d\n", cloud_counter, boundary_counter); printf("Revised percent of cloud = %f\n", revised_ptm); } /* cloud covers more than 90% of the scene => no match => rest are definite shadows */ if (ptm <= 0.1 || revised_ptm >= 0.90) { for (row = 0; row < nrows; row++) { for (col = 0; col < ncols; col++) { /* No Shadow Match due to too much cloud (>90 percent) */ if (cloud_mask[row][col] == 1) cloud_cal[row][col] = 1; else shadow_cal[row][col] = 1; } } } else { if (verbose) printf("Shadow Match in processing\n"); /* define constants */ float t_similar=0.30; float t_buffer=0.95; /* threshold for matching buffering */ int num_cldoj=9; /* minimum matched cloud object (pixels) */ int num_pix=8; /* number of inward pixes (240m) for cloud base temperature */ float a, b, c, omiga_par, omiga_per; if (verbose) { printf("Set cloud similarity = %.3f\n", t_similar); printf("Set matching buffer = %.3f\n", t_buffer); printf("Shadow match for cloud object >= %d pixels\n", num_cldoj); } int i_step; i_step=rint(2.0*(float)sub_size*tan(sun_ele_rad)); /* move 2 pixel at a time */ /* Get moving direction, the idea is to get the corner rows/cols */ int x_ul = 0; int y_ul = 0; int x_lr = 0; int y_lr = 0; int x_ll = 0; int y_ll = 0; int x_ur = 0; int y_ur = 0; for (row = 0; row < nrows; row++) { for (col = 0; col < ncols; col++) { if (boundary_test[row][col] == 1) { y_ul = row; x_ul = col; goto next1; } } } next1: for (col = ncols - 1; col >= 0; col--) { for (row = 0; row < nrows; row++) { if (boundary_test[row][col] == 1) { y_ur = row; x_ur = col; goto next2; } } } next2: for (col = 0; col < ncols; col++) { for (row = nrows - 1; row >= 0; row--) { if (boundary_test[row][col] == 1) { y_ll = row; x_ll = col; goto next3; } } } next3: for (row = nrows - 1; row >= 0; row--) { for (col = ncols - 1; col >= 0; col--) { if (boundary_test[row][col] == 1) { y_lr = row; x_lr = col; goto next4; } } } next4: /* get view angle geometry */ viewgeo(x_ul,y_ul,x_ur,y_ur,x_ll,y_ll,x_lr,y_lr, &a, &b, &c, &omiga_par, &omiga_per); /* Allocate memory for segment cloud portion */ int *obj_num; obj_num = (int *)calloc(MAX_CLOUD_TYPE, sizeof(int)); cloud_node **cloud; cloud = (cloud_node **)ias_misc_allocate_2d_array(nrows, ncols, sizeof(cloud_node)); int **cloud_first_node; cloud_first_node = (int **)ias_misc_allocate_2d_array(2, MAX_CLOUD_TYPE, sizeof(int)); if (obj_num == NULL || cloud == NULL || cloud_first_node == NULL) { sprintf (errstr, "Allocating memory"); ERROR (errstr, "cloud/shadow match"); return -1; } /* Initialize the cloud nodes */ for (row = 0; row < nrows; row++) { for (col = 0; col <ncols; col++) { cloud[row][col].value = 0; cloud[row][col].row = 0; cloud[row][col].col = 0; cloud[row][col].parent = &cloud[row][col]; cloud[row][col].child = &cloud[row][col]; } } /* Labeling the cloud pixels */ label(cloud_mask, nrows, ncols, cloud, obj_num, cloud_first_node); /* The cloud pixels are not counted as cloud pixels if the total number of cloud pixels is less than 9 within a cloud cluster */ int num; int counter = 0; for (num = 1; num <= num_clouds; num++) { if (obj_num[num] <= MIN_CLOUD_OBJ) obj_num[num] = 0; else counter++; } if (verbose) printf("Num of real clouds = %d\n", counter); /* Cloud_cal pixels are cloud_mask pixels with < 9 pixels removed */ for (row = 0; row < nrows; row++) { for (col = 0; col <ncols; col++) { if ((cloud_mask[row][col] == 1) && (boundary_test[row][col] != 0) && (obj_num[cloud[row][col].value] != 0)) cloud_cal[row][col] = cloud_mask[row][col]; else cloud_cal[row][col] = 0; } } /* Need to read out whole image brightness temperature for band 6 */ int16 **temp; temp = (int16 **)ias_misc_allocate_2d_array(input->size.l, input->size.s, sizeof(int16)); if (!temp) { sprintf (errstr, "Allocating temp memory"); ERROR (errstr, "cloud/shadow match"); } /* Read out thermal band in 2d */ for (row = 0; row < nrows; row++) { if (!GetInputThermLine(input, row)) { sprintf (errstr, "Reading input thermal data for line %d", row); ERROR (errstr,"cloud/shadow match"); } memcpy(&temp[row][0], &input->therm_buf[0], input->size.s * sizeof(int16)); } /* Use iteration to get the optimal move distance, Calulate the moving cloud shadow */ int cloud_type; int **xy_type; int **tmp_xy_type; float **tmp_xys; int **orin_xys; int16 *temp_obj; int16 temp_obj_max = 0; int16 temp_obj_min = 0; int index; float r_obj; float pct_obj; float t_obj; float rate_elapse=6.5; float rate_dlapse=9.8; int max_cl_height; /* Max cloud base height (m) */ int min_cl_height; /* Min cloud base height (m) */ int max_height; int min_height; float record_thresh; float *record_h; int base_h; float *h; float i_xy; int out_all; int match_all; int total_all; float thresh_match; int i; for (cloud_type = 1; cloud_type <= num_clouds; cloud_type++) { if (obj_num[cloud_type] == 0) continue; else { /* Note: matlab array index starts with 1 and C starts with 0, array(3,1) in matlab is equal to array[2][0] in C */ min_cl_height = 200; max_cl_height = 12000; xy_type = (int **)ias_misc_allocate_2d_array(2, obj_num[cloud_type], sizeof(int)); tmp_xy_type = (int **)ias_misc_allocate_2d_array(2, obj_num[cloud_type], sizeof(int)); /* corrected for view angle xys */ tmp_xys = (float **)ias_misc_allocate_2d_array(2, obj_num[cloud_type], sizeof(float)); /* record the original xys */ orin_xys = (int **)ias_misc_allocate_2d_array(2, obj_num[cloud_type], sizeof(int)); if (xy_type == NULL || tmp_xy_type == NULL || tmp_xys == NULL || orin_xys == NULL) { sprintf (errstr, "Allocating cloud memory"); ERROR (errstr, "cloud/shadow match"); } /* Temperature of the cloud object */ temp_obj = malloc(obj_num[cloud_type] * sizeof(int16)); if (temp_obj == NULL) { sprintf (errstr, "Allocating temp_obj memory"); ERROR (errstr, "cloud/shadow match"); } temp_obj_max = 0; temp_obj_min = 0; index = 0; cloud_node *node; node = &cloud[cloud_first_node[0][cloud_type]] [cloud_first_node[1][cloud_type]]; while (node->child != node) { temp_obj[index] = temp[node->row][node->col]; if (temp_obj[index] > temp_obj_max) temp_obj_max = temp_obj[index]; if (temp_obj[index] < temp_obj_min) temp_obj_min = temp_obj[index]; orin_xys[0][index] = node->col; orin_xys[1][index] = node->row; index++; node = node->child; } temp_obj[index] = temp[node->row][node->col]; if (temp_obj[index] > temp_obj_max) temp_obj_max = temp_obj[index]; if (temp_obj[index] < temp_obj_min) temp_obj_min = temp_obj[index]; orin_xys[0][index] = node->col; orin_xys[1][index] = node->row; index++; obj_num[cloud_type] = index; /* the base temperature for cloud assume object is round r_obj is radium of object */ r_obj=sqrt((float)obj_num[cloud_type]/PI); /* number of inward pixes for correct temperature */ pct_obj=((r_obj-(float)num_pix)*(r_obj-(float)num_pix)) / (r_obj * r_obj); if ((pct_obj-1.0) >= MINSIGMA) pct_obj = 1.0;/* pct of edge pixel should be less than 1 */ prctile(temp_obj, obj_num[cloud_type],temp_obj_min, temp_obj_max, 100.0 * pct_obj, &t_obj); /* refine cloud height range (m) */ min_height = (int)rint(10.0*(t_templ-t_obj)/rate_dlapse); max_height = (int)rint(10.0*(t_temph-t_obj)); if (min_cl_height < min_height) min_cl_height = min_height; if (max_cl_height > max_height) max_cl_height = max_height; /* put the edge of the cloud the same value as t_obj */ for (i = 0; i < obj_num[cloud_type]; i++) { if (temp_obj[i] >rint(t_obj)) temp_obj[i]=rint(t_obj); } /* Allocate memory for h and record_h*/ h = malloc(obj_num[cloud_type] * sizeof(float)); record_h = calloc(obj_num[cloud_type], sizeof(float)); if (h == NULL || record_h == NULL) { sprintf (errstr, "Allocating h memory"); ERROR (errstr, "cloud/shadow match"); } /* initialize height and similarity info */ record_thresh=0.0; for (base_h = min_cl_height; base_h <= max_cl_height; base_h+=i_step) { for (i = 0; i < obj_num[cloud_type]; i++) { h[i]=(10.0*(t_obj-(float)temp_obj[i])) / rate_elapse+(float)base_h; } /* Get the true postion of the cloud calculate cloud DEM with initial base height */ mat_truecloud(orin_xys[0], orin_xys[1], obj_num[cloud_type], h, a, b, c, omiga_par, omiga_per, tmp_xys[0], tmp_xys[1]); out_all = 0; match_all = 0; total_all = 0; for (i = 0; i < obj_num[cloud_type]; i++) { i_xy=h[i]/((float)sub_size*tan(sun_ele_rad)); if ((input->meta.sun_az - 180.0) < MINSIGMA) { xy_type[1][i] = rint(tmp_xys[0][i]-i_xy*cos(sun_tazi_rad)); xy_type[0][i] = rint(tmp_xys[1][i]-i_xy*sin(sun_tazi_rad)); } else { xy_type[1][i] = rint(tmp_xys[0][i]+i_xy*cos(sun_tazi_rad)); xy_type[0][i] = rint(tmp_xys[1][i]+i_xy*sin(sun_tazi_rad)); } /* the id that is out of the image */ if (xy_type[0][i] < 0 || xy_type[0][i] >= nrows || xy_type[1][i] < 0 || xy_type[1][i] >= ncols) out_all++; else { if (boundary_test[xy_type[0][i]][xy_type[1][i]] == 0 || (cloud[xy_type[0][i]][xy_type[1][i]].value != cloud_type && (cloud_mask[xy_type[0][i]][xy_type[1][i]]>0 || shadow_mask[xy_type[0][i]][xy_type[1][i]] == 1))) match_all++; if (cloud[xy_type[0][i]][xy_type[1][i]].value != cloud_type) total_all++; } } match_all += out_all; total_all+=out_all; thresh_match=(float)match_all/(float)total_all; if (((thresh_match - t_buffer*record_thresh) >= MINSIGMA) && (base_h < max_cl_height-i_step) && ((record_thresh - 0.95)<MINSIGMA)) { if ((thresh_match - record_thresh) > MINSIGMA) { record_thresh=thresh_match; for (i = 0; i < obj_num[cloud_type]; i++) record_h[i] = h[i]; } } else if ((record_thresh - t_similar) > MINSIGMA) { float i_vir; for (i = 0; i < obj_num[cloud_type]; i++) { i_vir = record_h[i] / ((float)sub_size*tan(sun_ele_rad)); if ((input->meta.sun_az - 180.0) < MINSIGMA) { tmp_xy_type[1][i]=rint(tmp_xys[0][i]- i_vir*cos(sun_tazi_rad)); tmp_xy_type[0][i]=rint(tmp_xys[1][i]- i_vir*sin(sun_tazi_rad)); } else { tmp_xy_type[1][i]=rint(tmp_xys[0][i]+ i_vir*cos(sun_tazi_rad)); tmp_xy_type[0][i]=rint(tmp_xys[1][i]+ i_vir*sin(sun_tazi_rad)); } /* put data within range */ if (tmp_xy_type[0][i]<0) tmp_xy_type[0][i]=0; if (tmp_xy_type[0][i]>=nrows) tmp_xy_type[0][i]=nrows-1; if (tmp_xy_type[1][i]<0) tmp_xy_type[1][i]=0; if (tmp_xy_type[1][i]>=ncols) tmp_xy_type[1][i]=ncols-1; shadow_cal[tmp_xy_type[0][i]][tmp_xy_type[1][i]] = 1; } break; } else { record_thresh=0.0; continue; } } free(h); free(record_h); /* Free all the memory */ status = ias_misc_free_2d_array((void **)xy_type); status = ias_misc_free_2d_array((void **)tmp_xys); status = ias_misc_free_2d_array((void **)orin_xys); free(temp_obj); } } free(obj_num); status = ias_misc_free_2d_array((void **)temp); status = ias_misc_free_2d_array((void **)cloud); IplImage* src = cvCreateImage(cvSize(ncols, nrows), IPL_DEPTH_8U, 1); IplImage* dst = cvCreateImage(cvSize(ncols, nrows), IPL_DEPTH_8U, 1); if (!src || !dst) { sprintf (errstr, "Creating images\n"); ERROR (errstr, "cloud/shadow match"); } int dilation_type = 1; IplConvKernel* element = cvCreateStructuringElementEx( 2*cldpix + 1, 2*cldpix + 1, cldpix, cldpix, dilation_type, 0); for (row = 0; row < nrows; row++) { for (col = 0; col < ncols; col++) { src->imageData[row*ncols+col] = cloud_cal[row][col]; } } cvDilate(src, dst, element, 1); for (row = 0; row < nrows; row++) { for (col = 0; col < ncols; col++) { cloud_cal[row][col] = dst->imageData[row*ncols+col]; } } element = cvCreateStructuringElementEx( 2*sdpix + 1, 2*sdpix + 1, sdpix, sdpix, dilation_type, 0); for (row = 0; row < nrows; row++) { for (col = 0; col < ncols; col++) { src->imageData[row*ncols+col] = shadow_cal[row][col]; } } cvDilate(src, dst, element, 1); for (row = 0; row < nrows; row++) { for (col = 0; col < ncols; col++) { shadow_cal[row][col] = dst->imageData[row*ncols+col]; } } for (row = 0; row < nrows; row++) { for (col = 0; col < ncols; col++) { src->imageData[row*ncols+col] = snow_mask[row][col]; } } cvDilate(src, dst, element, 1); for (row = 0; row < nrows; row++) { for (col = 0; col < ncols; col++) { snow_mask[row][col] = dst->imageData[row*ncols+col]; } } /* Release image memory */ cvReleaseImage(&src); cvReleaseImage(&dst); } /* Use cloud mask as the final output mask */ int cloud_count = 0; int shadow_count = 0; for (row = 0; row < nrows; row++) { for (col = 0; col < ncols; col++) { if (boundary_test[row][col] ==0) final_mask[row][col] = 255; else if (cloud_cal[row][col] == 1) { final_mask[row][col] = 4; cloud_count++; } else if (shadow_cal[row][col] == 1) { final_mask[row][col] = 2; shadow_count++; } else if (snow_mask[row][col] == 1) final_mask[row][col] = 3; else if (water_mask[row][col] == 1) final_mask[row][col] = 1; else final_mask[row][col] = 0; } } /* Release the memory */ status = ias_misc_free_2d_array((void **)cloud_cal); status = ias_misc_free_2d_array((void **)shadow_cal); status = ias_misc_free_2d_array(( void **)boundary_test); if (verbose) { printf("cloud_count, shadow_count, boundary_counter = %d,%d,%d\n", cloud_count, shadow_count, boundary_counter); /* record cloud and cloud shadow percent; */ float cloud_shadow_percent; cloud_shadow_percent = (float)(cloud_count + shadow_count) / (float)boundary_counter; printf("The cloud and shadow percentage is %f\n", cloud_shadow_percent); } return 0; }
void JITCompiler::compileFunction(JITCode& entry, MacroAssemblerCodePtr& entryWithArityCheck) { // === Stage 1 - Function header code generation === // // This code currently matches the old JIT. In the function header we need to // pop the return addres (since we do not allow any recursion on the machine // stack), and perform a fast register file check. // This is the main entry point, without performing an arity check. // FIXME: https://bugs.webkit.org/show_bug.cgi?id=56292 // We'll need to convert the remaining cti_ style calls (specifically the register file // check) which will be dependant on stack layout. (We'd need to account for this in // both normal return code and when jumping to an exception handler). preserveReturnAddressAfterCall(regT2); emitPutToCallFrameHeader(regT2, RegisterFile::ReturnPC); // If we needed to perform an arity check we will already have moved the return address, // so enter after this. Label fromArityCheck(this); // Setup a pointer to the codeblock in the CallFrameHeader. emitPutImmediateToCallFrameHeader(m_codeBlock, RegisterFile::CodeBlock); // Plant a check that sufficient space is available in the RegisterFile. // FIXME: https://bugs.webkit.org/show_bug.cgi?id=56291 addPtr(Imm32(m_codeBlock->m_numCalleeRegisters * sizeof(Register)), callFrameRegister, regT1); Jump registerFileCheck = branchPtr(Below, AbsoluteAddress(m_globalData->interpreter->registerFile().addressOfEnd()), regT1); // Return here after register file check. Label fromRegisterFileCheck = label(); // === Stage 2 - Function body code generation === // // We generate the speculative code path, followed by the non-speculative // code for the function. Next we need to link the two together, making // bail-outs from the speculative path jump to the corresponding point on // the non-speculative one (and generating any code necessary to juggle // register values around, rebox values, and ensure spilled, to match the // non-speculative path's requirements). #if DFG_JIT_BREAK_ON_ENTRY // Handy debug tool! breakpoint(); #endif // First generate the speculative path. SpeculativeJIT speculative(*this); speculative.compile(); // Next, generate the non-speculative path. We pass this a SpeculationCheckIndexIterator // to allow it to check which nodes in the graph may bail out, and may need to reenter the // non-speculative path. SpeculationCheckIndexIterator checkIterator(speculative); NonSpeculativeJIT nonSpeculative(*this); nonSpeculative.compile(checkIterator); // Link the bail-outs from the speculative path to the corresponding entry points into the non-speculative one. linkSpeculationChecks(speculative, nonSpeculative); // === Stage 3 - Function footer code generation === // // Generate code to lookup and jump to exception handlers, to perform the slow // register file check (if the fast one in the function header fails), and // generate the entry point with arity check. // Iterate over the m_calls vector, checking for exception checks, // and linking them to here. unsigned exceptionCheckCount = 0; for (unsigned i = 0; i < m_calls.size(); ++i) { Jump& exceptionCheck = m_calls[i].m_exceptionCheck; if (exceptionCheck.isSet()) { exceptionCheck.link(this); ++exceptionCheckCount; } } // If any exception checks were linked, generate code to lookup a handler. if (exceptionCheckCount) { // lookupExceptionHandler is passed two arguments, exec (the CallFrame*), and // an identifier for the operation that threw the exception, which we can use // to look up handler information. The identifier we use is the return address // of the call out from JIT code that threw the exception; this is still // available on the stack, just below the stack pointer! move(callFrameRegister, argumentRegister0); peek(argumentRegister1, -1); m_calls.append(CallRecord(call(), lookupExceptionHandler)); // lookupExceptionHandler leaves the handler CallFrame* in the returnValueRegister, // and the address of the handler in returnValueRegister2. jump(returnValueRegister2); } // Generate the register file check; if the fast check in the function head fails, // we need to call out to a helper function to check whether more space is available. // FIXME: change this from a cti call to a DFG style operation (normal C calling conventions). registerFileCheck.link(this); move(stackPointerRegister, argumentRegister0); poke(callFrameRegister, OBJECT_OFFSETOF(struct JITStackFrame, callFrame) / sizeof(void*)); Call callRegisterFileCheck = call(); jump(fromRegisterFileCheck); // The fast entry point into a function does not check the correct number of arguments // have been passed to the call (we only use the fast entry point where we can statically // determine the correct number of arguments have been passed, or have already checked). // In cases where an arity check is necessary, we enter here. // FIXME: change this from a cti call to a DFG style operation (normal C calling conventions). Label arityCheck = label(); preserveReturnAddressAfterCall(regT2); emitPutToCallFrameHeader(regT2, RegisterFile::ReturnPC); branch32(Equal, regT1, Imm32(m_codeBlock->m_numParameters)).linkTo(fromArityCheck, this); move(stackPointerRegister, argumentRegister0); poke(callFrameRegister, OBJECT_OFFSETOF(struct JITStackFrame, callFrame) / sizeof(void*)); Call callArityCheck = call(); move(regT0, callFrameRegister); jump(fromArityCheck); // === Stage 4 - Link === // // Link the code, populate data in CodeBlock data structures. LinkBuffer linkBuffer(this, m_globalData->executableAllocator.poolForSize(m_assembler.size()), 0); // Link all calls out from the JIT code to their respective functions. for (unsigned i = 0; i < m_calls.size(); ++i) linkBuffer.link(m_calls[i].m_call, m_calls[i].m_function); if (m_codeBlock->needsCallReturnIndices()) { m_codeBlock->callReturnIndexVector().reserveCapacity(exceptionCheckCount); for (unsigned i = 0; i < m_calls.size(); ++i) { if (m_calls[i].m_exceptionCheck.isSet()) { unsigned returnAddressOffset = linkBuffer.returnAddressOffset(m_calls[i].m_call); unsigned exceptionInfo = m_calls[i].m_exceptionInfo; m_codeBlock->callReturnIndexVector().append(CallReturnOffsetToBytecodeOffset(returnAddressOffset, exceptionInfo)); } } } // FIXME: switch the register file check & arity check over to DFGOpertaion style calls, not JIT stubs. linkBuffer.link(callRegisterFileCheck, cti_register_file_check); linkBuffer.link(callArityCheck, m_codeBlock->m_isConstructor ? cti_op_construct_arityCheck : cti_op_call_arityCheck); entryWithArityCheck = linkBuffer.locationOf(arityCheck); entry = linkBuffer.finalizeCode(); }
KeyEvent MImKeyBinding::toKeyEvent(QKeyEvent::Type eventType, Qt::KeyboardModifiers modifiers) const { return toKeyEventImpl(eventType, modifiers, label()); }
void CMultipleParticleFilter::update(CLaser *Laser) { m_pLaser = Laser; double obs[2], p[2]; for (int n = 0; n < 1; n++){ if (m_pLaser->m_bNodeActive[n]){ std::vector<int> label(m_pLaser->m_LRFClsPoints[n].size(), -1); // クラスタに対応するパーティクルフィルタの番号 int pn = m_ParticleFilter.size(); // 現在のパーティクルフィルタの個数 for (int j = 0; j < m_pLaser->m_LRFClsPoints[n].size(); j++){ // クラスタ代表点 obs[0] = m_pLaser->m_LRFClsPoints[n][j].x; obs[1] = m_pLaser->m_LRFClsPoints[n][j].y; // クラスタ毎に,一番近いパーティクルフィルタを探す double min_r = 1e10; int np = 0; for (vector<CPF>::iterator it = m_ParticleFilter.begin(); it != m_ParticleFilter.end(); ++it, ++np) { p[0] = it->state[0]; p[1] = it->state[1]; double r = sqrt(pow(p[0] - obs[0], 2) + pow(p[1] - obs[1], 2)); if (min_r > r && r < m_min_distance){ min_r = r; label[j] = np; } } // もし,クラスタに対応するパーティクルフィルタがなかったとき if (min_r >= m_min_distance){ label[j] = pn++; } } std::vector<int> flg(pn, -1); // クラスタに対応するパーティクルフィルタの番号 for (int j = 0; j < m_pLaser->m_LRFClsPoints[n].size(); j++){ if (label[j] < 0){ std::cout << "Error" << std::endl; } else if (label[j] < m_ParticleFilter.size()){ obs[0] = m_pLaser->m_LRFClsPoints[n][j].x; obs[1] = m_pLaser->m_LRFClsPoints[n][j].y; m_ParticleFilter[label[j]].SetTarget(obs); m_ParticleFilter[label[j]].update(); } else{ CPF pf; int d = Config::is()->particle_area * 1000; obs[0] = m_pLaser->m_LRFClsPoints[n][j].x; obs[1] = m_pLaser->m_LRFClsPoints[n][j].y; int area[4] = {obs[0]-m_initial_dist/2, obs[1]-m_initial_dist/2, obs[0]+m_initial_dist/2, obs[1]+m_initial_dist/2}; pf.initialize(area); pf.SetTarget(obs); pf.SetID(m_ID++); pf.update(); m_ParticleFilter.push_back(pf); } flg[label[j]] = 1; } int np = 0; for (vector<CPF>::iterator it = m_ParticleFilter.begin(); it != m_ParticleFilter.end(); ++it, ++np) { if (flg[np] < 0) { it->clear(); it = m_ParticleFilter.erase(it); if (it == m_ParticleFilter.end()) break; } } for (int i = 0; i < MAX_TRACKING_OBJECT; i++){ delete m_pLaser->m_pTarget[i]; m_pLaser->m_pTarget[i] = NULL; } np = 0; for (vector<CPF>::iterator it = m_ParticleFilter.begin(); it != m_ParticleFilter.end(); ++it, ++np) { m_pLaser->m_pTarget[np] = new CTarget(); m_pLaser->m_pTarget[np]->id = it->GetID(); m_pLaser->m_pTarget[np]->cnt = it->GetCnt(); m_pLaser->m_pTarget[np]->SetPosi(it->state[0], it->state[1]); } } } }
void blobsSheetAtomization::atomizeParcel ( parcel& p, const scalar deltaT, const vector& vel, const liquidMixture& fuels ) const { const PtrList<volScalarField>& Y = spray_.composition().Y(); label Ns = Y.size(); label cellI = p.cell(); scalar pressure = spray_.p()[cellI]; scalar temperature = spray_.T()[cellI]; scalar Taverage = p.T() + (temperature - p.T())/3.0; scalar Winv = 0.0; for(label i=0; i<Ns; i++) { Winv += Y[i][cellI]/spray_.gasProperties()[i].W(); } scalar R = specie::RR()*Winv; // ideal gas law to evaluate density scalar rhoAverage = pressure/R/Taverage; scalar sigma = fuels.sigma(pressure, p.T(), p.X()); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // The We and Re numbers are to be evaluated using the 1/3 rule. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // scalar rhoFuel = fuels.rho(1.0e+5, p.T(), p.X()); scalar U = mag(p.Urel(vel)); const injectorType& it = spray_.injectors()[label(p.injector())].properties(); vector itPosition(vector::zero); label nHoles = it.nHoles(); if (nHoles > 1) { for(label i=0; i<nHoles;i++) { itPosition += it.position(i); } itPosition /= nHoles; } else { itPosition = it.position(0); } // const vector itPosition = it.position(); scalar lBU = B_ * sqrt ( rhoFuel * sigma * p.d() * cos(angle_*mathematicalConstant::pi/360.0) / sqr(rhoAverage*U) ); scalar pWalk = mag(p.position() - itPosition); if(pWalk > lBU && p.liquidCore() == 1.0) { p.liquidCore() = 0.0; } }
/** ** Draw UI button 'button' on x,y ** ** @param style Button style ** @param flags State of Button (clicked, mouse over...) ** @param x X display position ** @param y Y display position ** @param text text to print on button */ void DrawUIButton(ButtonStyle *style, unsigned flags, int x, int y, //Wyrmgus start // const std::string &text, int player) const std::string &text, int player, int skin_color, int hair_color) //Wyrmgus end { ButtonStyleProperties *p; if (flags & MI_FLAGS_CLICKED) { p = &style->Clicked; } else if (flags & MI_FLAGS_ACTIVE) { p = &style->Hover; } else { p = &style->Default; } // // Image // ButtonStyleProperties *pimage = p; if (!p->Sprite) { // No image. Try hover, selected, then default if ((flags & MI_FLAGS_ACTIVE) && style->Hover.Sprite) { pimage = &style->Hover; } else if (style->Default.Sprite) { pimage = &style->Default; } } if (pimage->Sprite) { pimage->Sprite->Load(); } if (pimage->Sprite) { CPlayerColorGraphic *colorGraphic = dynamic_cast<CPlayerColorGraphic *>(pimage->Sprite); if (colorGraphic && player != -1) { //Wyrmgus start // colorGraphic->DrawPlayerColorFrameClip(player, pimage->Frame, x, y); colorGraphic->DrawPlayerColorFrameClip(player, pimage->Frame, x, y, true, skin_color, hair_color); //Wyrmgus end } else { pimage->Sprite->DrawFrame(pimage->Frame, x, y); } } // // Text // if (!text.empty()) { std::string oldnc; std::string oldrc; GetDefaultTextColors(oldnc, oldrc); CLabel label(*style->Font, (!p->TextNormalColor.empty() ? p->TextNormalColor : !style->TextNormalColor.empty() ? style->TextNormalColor : oldnc), (!p->TextReverseColor.empty() ? p->TextReverseColor : !style->TextReverseColor.empty() ? style->TextReverseColor : oldrc)); if (p->TextAlign == TextAlignCenter || p->TextAlign == TextAlignUndefined) { label.DrawCentered(x + p->TextPos.x, y + p->TextPos.y, text); } else if (p->TextAlign == TextAlignLeft) { label.Draw(x + p->TextPos.x, y + p->TextPos.y, text); } else { label.Draw(x + p->TextPos.x - style->Font->Width(text), y + p->TextPos.y, text); } } // // Border // if (!p->BorderColor) { CColor color(p->BorderColorRGB); //Wyrmgus start /* if (p->BorderColorRGB.R > 0 || p->BorderColorRGB.G > 0 || p->BorderColorRGB.B > 0) { int shift = GameCycle % 0x20; color.R >>= shift / 2; color.G >>= shift / 2; color.B >>= shift / 2; if (shift >= 0x10) { color.R = (p->BorderColorRGB.R > 0) << ((shift - 0x10) / 2); color.G = (p->BorderColorRGB.G > 0) << ((shift - 0x10) / 2); color.B = (p->BorderColorRGB.B > 0) << ((shift - 0x10) / 2); } } */ //Wyrmgus end p->BorderColor = Video.MapRGB(TheScreen->format, color); } if (p->BorderSize) { for (int i = 0; i < p->BorderSize; ++i) { //Wyrmgus start // Video.DrawRectangleClip(p->BorderColor, x - i, y - i, // style->Width + 2 * i, style->Height + 2 * i); Video.DrawRectangleClip(p->BorderColor, x - i - 1, y - i - 1, (style->Width + 2 * i) + 2, (style->Height + 2 * i) + 2); //Wyrmgus end } } }
virtual BSize MinSize() { BString label(_GetLabel()); return BSize(StringWidth(label) + 10, B_H_SCROLL_BAR_HEIGHT); }
App::App() { #if defined(WIN32) && !defined(__MINGW32__) clan::D3DTarget::set_current(); #else clan::OpenGLTarget::set_current(); #endif DisplayWindowDescription win_desc; win_desc.set_allow_resize(true); win_desc.set_title("Font Example Application"); win_desc.set_size(Size( 1000, 700 ), false); window = DisplayWindow(win_desc); slots.connect(window.sig_window_close(), this, &App::on_window_close); slots.connect(window.get_keyboard().sig_key_up(), this, &App::on_input_up); clan::XMLResourceFactory::set_display(); resources = clan::XMLResourceManager::create(clan::XMLResourceDocument("Resources/resources.xml")); canvas = Canvas(window); clan::Texture2D gui_texture = clan::Texture2D(canvas, (int)std::round(250 * canvas.get_pixel_ratio()), (int)std::round(500 * canvas.get_pixel_ratio())); gui_texture.set_pixel_ratio(canvas.get_pixel_ratio()); gui_image = clan::Image(gui_texture, gui_texture.get_size()); clan::FrameBuffer gui_framebuffer = clan::FrameBuffer(canvas); gui_framebuffer.attach_color(0, gui_texture); gui_canvas = clan::Canvas(canvas, gui_framebuffer); clan::FileResourceDocument doc(clan::FileSystem("../../ThemeAero")); clan::ResourceManager resources = clan::FileResourceManager::create(doc); ui_thread = clan::UIThread(resources); root = std::make_shared<clan::TextureWindow>(gui_canvas); root->set_window(window); root->set_viewport(gui_image.get_size()); int offset_x = 10; int offset_y = 8; int width = 220; int small_width = 70; int height = 20; const int gap = 38; auto button_class_system = Theme::create_button(); button_class_system->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width); button_class_system->func_clicked() = clan::bind_member(this, &App::on_button_clicked_class_system); button_class_system->label()->set_text("Class: System"); root->add_child(button_class_system); offset_y += gap; auto button_class_sprite = Theme::create_button(); button_class_sprite->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width); button_class_sprite->func_clicked() = bind_member(this, &App::on_button_clicked_class_sprite); button_class_sprite->label()->set_text("Class: Sprite"); root->add_child(button_class_sprite); offset_y += gap; button_typeface_tahoma = Theme::create_button(); button_typeface_tahoma->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width); button_typeface_tahoma->func_clicked() = bind_member(this, &App::on_button_clicked_typeface_tahoma); button_typeface_tahoma->label()->set_text("Typeface: Tahoma"); root->add_child(button_typeface_tahoma); offset_y += gap; button_typeface_sans = Theme::create_button(); button_typeface_sans->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width); button_typeface_sans->func_clicked() = bind_member(this, &App::on_button_clicked_typeface_sans); button_typeface_sans->label()->set_text("Typeface: Microsoft Sans Serif"); root->add_child(button_typeface_sans); offset_y += gap; button_typeface_bitstream = Theme::create_button(); button_typeface_bitstream->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width); button_typeface_bitstream->func_clicked() = bind_member(this, &App::on_button_clicked_typeface_bitstream); button_typeface_bitstream->label()->set_text("Typeface: Bitstream Vera Sans"); root->add_child(button_typeface_bitstream); offset_y += gap; checkbox_italic = Theme::create_checkbox(); checkbox_italic->style()->set("position: absolute; left:%1px; top:%2px", offset_x, offset_y); checkbox_italic->func_state_changed() = bind_member(this, &App::on_checkbox_state_italic); root->add_child(checkbox_italic); auto label = Theme::create_label(); label->set_text("Italic"); label->style()->set("position: absolute; left:%1px; top:%2px", offset_x + 16, offset_y - 3); root->add_child(label); checkbox_antialias = Theme::create_checkbox(); checkbox_antialias->set_check(true); checkbox_antialias->style()->set("position: absolute; left:%1px; top:%2px", offset_x + 100, offset_y); checkbox_antialias->func_state_changed() = bind_member(this, &App::on_checkbox_state_antialias); root->add_child(checkbox_antialias); label = Theme::create_label(); label->set_text("Anti Alias"); label->style()->set("position: absolute; left:%1px; top:%2px", offset_x + 100+ 16, offset_y - 3); root->add_child(label); offset_y += gap; checkbox_subpixel = Theme::create_checkbox(); checkbox_subpixel->set_check(true); checkbox_subpixel->style()->set("position: absolute; left:%1px; top:%2px", offset_x, offset_y); checkbox_subpixel->func_state_changed() = bind_member(this, &App::on_checkbox_state_subpixel); root->add_child(checkbox_subpixel); label = Theme::create_label(); label->set_text("SubPixel Rendering"); label->style()->set("position: absolute; left:%1px; top:%2px", offset_x + 16, offset_y - 3); root->add_child(label); offset_y += gap; auto button_weight_light = Theme::create_button(); button_weight_light->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, small_width); button_weight_light->func_clicked() = bind_member(this, &App::on_button_clicked_weight_light); button_weight_light->label()->set_text("Light"); root->add_child(button_weight_light); auto button_weight_normal = Theme::create_button(); button_weight_normal->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x + small_width + 5, offset_y, small_width); button_weight_normal->func_clicked() = bind_member(this, &App::on_button_clicked_weight_normal); button_weight_normal->label()->set_text("Normal"); root->add_child(button_weight_normal); auto button_weight_bold = Theme::create_button(); button_weight_bold->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x + (small_width + 5) * 2, offset_y, small_width); button_weight_bold->func_clicked() = bind_member(this, &App::on_button_clicked_weight_bold); button_weight_bold->label()->set_text("Bold"); root->add_child(button_weight_bold); offset_y += gap; auto button_size_16 = Theme::create_button(); button_size_16->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, small_width); button_size_16->func_clicked() = bind_member(this, &App::on_button_clicked_size_16); button_size_16->label()->set_text("Size 16"); root->add_child(button_size_16); auto button_size_32 = Theme::create_button(); button_size_32->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x + small_width + 5, offset_y, small_width); button_size_32->func_clicked() = bind_member(this, &App::on_button_clicked_size_32); button_size_32->label()->set_text("Size 32"); root->add_child(button_size_32); auto button_size_64 = Theme::create_button(); button_size_64->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x + (small_width + 5) * 2, offset_y, small_width); button_size_64->func_clicked() = bind_member(this, &App::on_button_clicked_size_64); button_size_64->label()->set_text("Size 64"); root->add_child(button_size_64); offset_y += gap + 8; lineedit_text = std::make_shared<clan::TextFieldView>(); lineedit_text->style()->set("font: 11px/20px 'Segoe UI'"); lineedit_text->style()->set("margin: 5px"); lineedit_text->style()->set("background: #efefef"); lineedit_text->style()->set("border: 1px solid black"); lineedit_text->style()->set("border-radius: 3px"); lineedit_text->style()->set("padding: 2px 5px 2px 5px"); lineedit_text->style()->set("width: 128px"); lineedit_text->style()->set("box-shadow: 0 0 5px rgba(100,100,200,0.2)"); lineedit_text->style()->set("position: absolute; left:%1px; top:%2px; width:%3px; height:auto;", offset_x, offset_y, width); font_text = "Ω(The quick brown fox 0123456789)"; lineedit_text->set_text(font_text); slots.connect(lineedit_text->sig_selection_changed(), bind_member(this, &App::on_lineedit_changed)); root->add_child(lineedit_text); last_fps = 0.0f; selected_fontclass = font_ttf; font_typeface = "Microsoft Sans Serif"; font_filename = ""; font_desc.set_height(32); font_desc.set_weight(clan::FontWeight::normal); select_font(); small_font = clan::Font("Tahoma", 16); premultiply_src_blend = BlendState(canvas, BlendStateDescription::blend(true)); game_time.reset(); }
// modified explicitly from Fl_Return_Button.cpp void Flu_Button :: draw() { if( type() == FL_HIDDEN_BUTTON ) return; if( !active() ) Fl_Button::color( col ); // draw the link text if( linkBtn ) { fl_draw_box( box(), x(), y(), w(), h(), color() ); labelSize[0] = labelSize[1] = labelSize[2] = labelSize[3] = 0; fl_font( labelfont(), labelsize() ); fl_measure( label(), labelSize[2], labelSize[3], 1 ); labelSize[0] += 2; labelSize[1] += h()/2 - labelsize()/2 - 2; fl_color( labelcolor() ); fl_draw( label(), x()+labelSize[0], y()+labelSize[1], labelSize[2], labelSize[3], FL_ALIGN_LEFT ); if( !overLink || ( overLink && hover ) ) { fl_line_style( FL_SOLID ); fl_line( x()+labelSize[0], y()+labelSize[1]+labelSize[3]-2, x()+labelSize[0]+labelSize[2], y()+labelSize[1]+labelSize[3]-2 ); fl_line_style( 0 ); } return; } Fl_Image *tmp = 0; if( active() && image_follows_value() ) { if( !value() ) { tmp = Fl_Button::image(); Fl_Button::image( Fl_Button::deimage() ); } } else if( active() && value() && downImg ) { tmp = Fl_Button::image(); Fl_Button::image( downImg ); } const char *lbl = label(); if( retBtn ) label(""); if( eBox != FL_NO_BOX && Fl::belowmouse() == this && active() ) { Fl_Boxtype oldbox = box(); box( eBox ); Fl_Button::draw(); box( oldbox ); } else Fl_Button::draw(); if( retBtn ) { int W = h(); if (w()/3 < W) W = w()/3; flu_return_arrow(x()+w()-W-4, y(), W, h()); label( lbl ); draw_label(x(), y(), w()-W+4, h()); } if( tmp ) Fl_Button::image( tmp ); }
Foam::label Foam::UIPstream::read ( const commsTypes commsType, const int fromProcNo, char* buf, const std::streamsize bufSize, const int tag ) { if (debug) { Pout<< "UIPstream::read : starting read from:" << fromProcNo << " tag:" << tag << " wanted size:" << label(bufSize) << " commsType:" << UPstream::commsTypeNames[commsType] << Foam::endl; } if (commsType == blocking || commsType == scheduled) { MPI_Status status; if ( MPI_Recv ( buf, bufSize, MPI_PACKED, procID(fromProcNo), tag, MPI_COMM_WORLD, &status ) ) { FatalErrorIn ( "UIPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "MPI_Recv cannot receive incomming message" << Foam::abort(FatalError); return 0; } // Check size of message read int messageSize; MPI_Get_count(&status, MPI_BYTE, &messageSize); if (debug) { Pout<< "UIPstream::read : finished read from:" << fromProcNo << " tag:" << tag << " read size:" << label(bufSize) << " commsType:" << UPstream::commsTypeNames[commsType] << Foam::endl; } if (messageSize > bufSize) { FatalErrorIn ( "UIPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "buffer (" << label(bufSize) << ") not large enough for incomming message (" << messageSize << ')' << Foam::abort(FatalError); } return messageSize; } else if (commsType == nonBlocking) { MPI_Request request; if ( MPI_Irecv ( buf, bufSize, MPI_PACKED, procID(fromProcNo), tag, MPI_COMM_WORLD, &request ) ) { FatalErrorIn ( "UIPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "MPI_Recv cannot start non-blocking receive" << Foam::abort(FatalError); return 0; } if (debug) { Pout<< "UIPstream::read : started read from:" << fromProcNo << " tag:" << tag << " read size:" << label(bufSize) << " commsType:" << UPstream::commsTypeNames[commsType] << " request:" << PstreamGlobals::outstandingRequests_.size() << Foam::endl; } PstreamGlobals::outstandingRequests_.append(request); // Assume the message is completely received. return bufSize; } else { FatalErrorIn ( "UIPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "Unsupported communications type " << commsType << Foam::abort(FatalError); return 0; } }
bool JITCompiler::compileFunction(JITCode& entry, MacroAssemblerCodePtr& entryWithArityCheck) { SamplingRegion samplingRegion("DFG Backend"); setStartOfCode(); compileEntry(); // === Function header code generation === // This is the main entry point, without performing an arity check. // If we needed to perform an arity check we will already have moved the return address, // so enter after this. Label fromArityCheck(this); // Plant a check that sufficient space is available in the JSStack. // FIXME: https://bugs.webkit.org/show_bug.cgi?id=56291 addPtr(TrustedImm32(m_codeBlock->m_numCalleeRegisters * sizeof(Register)), GPRInfo::callFrameRegister, GPRInfo::regT1); Jump stackCheck = branchPtr(Below, AbsoluteAddress(m_vm->interpreter->stack().addressOfEnd()), GPRInfo::regT1); // Return here after stack check. Label fromStackCheck = label(); // === Function body code generation === SpeculativeJIT speculative(*this); compileBody(speculative); setEndOfMainPath(); // === Function footer code generation === // // Generate code to perform the slow stack check (if the fast one in // the function header fails), and generate the entry point with arity check. // // Generate the stack check; if the fast check in the function head fails, // we need to call out to a helper function to check whether more space is available. // FIXME: change this from a cti call to a DFG style operation (normal C calling conventions). stackCheck.link(this); move(stackPointerRegister, GPRInfo::argumentGPR0); poke(GPRInfo::callFrameRegister, OBJECT_OFFSETOF(struct JITStackFrame, callFrame) / sizeof(void*)); CallBeginToken token; beginCall(CodeOrigin(0), token); Call callStackCheck = call(); notifyCall(callStackCheck, CodeOrigin(0), token); jump(fromStackCheck); // The fast entry point into a function does not check the correct number of arguments // have been passed to the call (we only use the fast entry point where we can statically // determine the correct number of arguments have been passed, or have already checked). // In cases where an arity check is necessary, we enter here. // FIXME: change this from a cti call to a DFG style operation (normal C calling conventions). Label arityCheck = label(); compileEntry(); load32(AssemblyHelpers::payloadFor((VirtualRegister)JSStack::ArgumentCount), GPRInfo::regT1); branch32(AboveOrEqual, GPRInfo::regT1, TrustedImm32(m_codeBlock->numParameters())).linkTo(fromArityCheck, this); move(stackPointerRegister, GPRInfo::argumentGPR0); poke(GPRInfo::callFrameRegister, OBJECT_OFFSETOF(struct JITStackFrame, callFrame) / sizeof(void*)); beginCall(CodeOrigin(0), token); Call callArityCheck = call(); notifyCall(callArityCheck, CodeOrigin(0), token); move(GPRInfo::regT0, GPRInfo::callFrameRegister); jump(fromArityCheck); // Generate slow path code. speculative.runSlowPathGenerators(); compileExceptionHandlers(); linkOSRExits(); // Create OSR entry trampolines if necessary. speculative.createOSREntries(); setEndOfCode(); // === Link === LinkBuffer linkBuffer(*m_vm, this, m_codeBlock, JITCompilationCanFail); if (linkBuffer.didFailToAllocate()) return false; link(linkBuffer); speculative.linkOSREntries(linkBuffer); // FIXME: switch the stack check & arity check over to DFGOpertaion style calls, not JIT stubs. linkBuffer.link(callStackCheck, cti_stack_check); linkBuffer.link(callArityCheck, m_codeBlock->m_isConstructor ? cti_op_construct_arityCheck : cti_op_call_arityCheck); if (shouldShowDisassembly()) m_disassembler->dump(linkBuffer); if (m_graph.m_compilation) m_disassembler->reportToProfiler(m_graph.m_compilation.get(), linkBuffer); entryWithArityCheck = linkBuffer.locationOf(arityCheck); entry = JITCode( linkBuffer.finalizeCodeWithoutDisassembly(), JITCode::DFGJIT); return true; }
console_main_window_t::console_main_window_t(console_window_t *console) : Fl_Double_Window(640, 480), console(console) { label("Cooperative Linux console"); }
Foam::label Foam::IPstream::read ( const commsTypes commsType, const int fromProcNo, char* buf, const std::streamsize bufSize ) { if (commsType == blocking || commsType == scheduled) { MPI_Status status; if ( MPI_Recv ( buf, bufSize, MPI_PACKED, procID(fromProcNo), msgType(), MPI_COMM_WORLD, &status ) ) { FatalErrorIn ( "IPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "MPI_Recv cannot receive incomming message" << Foam::abort(FatalError); return 0; } // Check size of message read label messageSize; MPI_Get_count(&status, MPI_BYTE, &messageSize); if (messageSize > bufSize) { FatalErrorIn ( "IPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "buffer (" << label(bufSize) << ") not large enough for incomming message (" << messageSize << ')' << Foam::abort(FatalError); } return messageSize; } else if (commsType == nonBlocking) { MPI_Request request; if ( MPI_Irecv ( buf, bufSize, MPI_PACKED, procID(fromProcNo), msgType(), MPI_COMM_WORLD, &request ) ) { FatalErrorIn ( "IPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "MPI_Recv cannot start non-blocking receive" << Foam::abort(FatalError); return 0; } PstreamGlobals::IPstream_outstandingRequests_.append(request); return 1; } else { FatalErrorIn ( "IPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "Unsupported communications type " << commsType << Foam::abort(FatalError); return 0; } }
/*static*/ v8::Handle<v8::Value> wxNode_wxButton::_init(const v8::Arguments& args) { v8::HandleScope scope; /* * id: _45056 */ if(args.Length() == 0) { wxNode_wxButton *self = new wxNode_wxButton(); NodeExEvtHandlerImpl* evtHandler = dynamic_cast<NodeExEvtHandlerImpl*>(self); self->wrap(args.This(), self, evtHandler); return args.This(); } /* * id: _45057 */ if(args.Length() == 8 && (args[0]->IsNull() || (args[0]->IsObject() && wxNode_wxWindow::AssignableFrom(args[0]->ToObject()->GetConstructorName()))) && args[1]->IsNumber() && args[2]->IsString() && (args[3]->IsNull() || (args[3]->IsObject() && wxNode_wxPoint::AssignableFrom(args[3]->ToObject()->GetConstructorName()))) && (args[4]->IsNull() || (args[4]->IsObject() && wxNode_wxSize::AssignableFrom(args[4]->ToObject()->GetConstructorName()))) && args[5]->IsNumber() && (args[6]->IsNull() || (args[6]->IsObject() && wxNode_wxValidator::AssignableFrom(args[6]->ToObject()->GetConstructorName()))) && args[7]->IsString()) { wxNode_wxWindow* parent = args[0]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxWindow>(args[0]->ToObject()); /* type: _1000 * */ int id = (int)args[1]->ToInt32()->Value(); /* type: _8725 */ v8::String::AsciiValue label(args[2]->ToString()); /* type: _14975 */ wxNode_wxPoint* pos = args[3]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxPoint>(args[3]->ToObject()); /* type: _20518 */ wxNode_wxSize* size = args[4]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxSize>(args[4]->ToObject()); /* type: _20628 */ long int style = (long int)args[5]->ToInt32()->Value(); /* type: _592 */ wxNode_wxValidator* validator = args[6]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxValidator>(args[6]->ToObject()); /* type: _59247 */ v8::String::AsciiValue name(args[7]->ToString()); /* type: _14975 */ wxNode_wxButton *self = new wxNode_wxButton(parent, id, *label, *pos, *size, style, *validator, *name); NodeExEvtHandlerImpl* evtHandler = dynamic_cast<NodeExEvtHandlerImpl*>(self); self->wrap(args.This(), self, evtHandler); return args.This(); } /* * id: _45057 */ if(args.Length() == 7 && (args[0]->IsNull() || (args[0]->IsObject() && wxNode_wxWindow::AssignableFrom(args[0]->ToObject()->GetConstructorName()))) && args[1]->IsNumber() && args[2]->IsString() && (args[3]->IsNull() || (args[3]->IsObject() && wxNode_wxPoint::AssignableFrom(args[3]->ToObject()->GetConstructorName()))) && (args[4]->IsNull() || (args[4]->IsObject() && wxNode_wxSize::AssignableFrom(args[4]->ToObject()->GetConstructorName()))) && args[5]->IsNumber() && (args[6]->IsNull() || (args[6]->IsObject() && wxNode_wxValidator::AssignableFrom(args[6]->ToObject()->GetConstructorName())))) { wxNode_wxWindow* parent = args[0]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxWindow>(args[0]->ToObject()); /* type: _1000 * */ int id = (int)args[1]->ToInt32()->Value(); /* type: _8725 */ v8::String::AsciiValue label(args[2]->ToString()); /* type: _14975 */ wxNode_wxPoint* pos = args[3]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxPoint>(args[3]->ToObject()); /* type: _20518 */ wxNode_wxSize* size = args[4]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxSize>(args[4]->ToObject()); /* type: _20628 */ long int style = (long int)args[5]->ToInt32()->Value(); /* type: _592 */ wxNode_wxValidator* validator = args[6]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxValidator>(args[6]->ToObject()); /* type: _59247 */ wxNode_wxButton *self = new wxNode_wxButton(parent, id, *label, *pos, *size, style, *validator); NodeExEvtHandlerImpl* evtHandler = dynamic_cast<NodeExEvtHandlerImpl*>(self); self->wrap(args.This(), self, evtHandler); return args.This(); } /* * id: _45057 */ if(args.Length() == 6 && (args[0]->IsNull() || (args[0]->IsObject() && wxNode_wxWindow::AssignableFrom(args[0]->ToObject()->GetConstructorName()))) && args[1]->IsNumber() && args[2]->IsString() && (args[3]->IsNull() || (args[3]->IsObject() && wxNode_wxPoint::AssignableFrom(args[3]->ToObject()->GetConstructorName()))) && (args[4]->IsNull() || (args[4]->IsObject() && wxNode_wxSize::AssignableFrom(args[4]->ToObject()->GetConstructorName()))) && args[5]->IsNumber()) { wxNode_wxWindow* parent = args[0]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxWindow>(args[0]->ToObject()); /* type: _1000 * */ int id = (int)args[1]->ToInt32()->Value(); /* type: _8725 */ v8::String::AsciiValue label(args[2]->ToString()); /* type: _14975 */ wxNode_wxPoint* pos = args[3]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxPoint>(args[3]->ToObject()); /* type: _20518 */ wxNode_wxSize* size = args[4]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxSize>(args[4]->ToObject()); /* type: _20628 */ long int style = (long int)args[5]->ToInt32()->Value(); /* type: _592 */ wxNode_wxButton *self = new wxNode_wxButton(parent, id, *label, *pos, *size, style); NodeExEvtHandlerImpl* evtHandler = dynamic_cast<NodeExEvtHandlerImpl*>(self); self->wrap(args.This(), self, evtHandler); return args.This(); } /* * id: _45057 */ if(args.Length() == 5 && (args[0]->IsNull() || (args[0]->IsObject() && wxNode_wxWindow::AssignableFrom(args[0]->ToObject()->GetConstructorName()))) && args[1]->IsNumber() && args[2]->IsString() && (args[3]->IsNull() || (args[3]->IsObject() && wxNode_wxPoint::AssignableFrom(args[3]->ToObject()->GetConstructorName()))) && (args[4]->IsNull() || (args[4]->IsObject() && wxNode_wxSize::AssignableFrom(args[4]->ToObject()->GetConstructorName())))) { wxNode_wxWindow* parent = args[0]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxWindow>(args[0]->ToObject()); /* type: _1000 * */ int id = (int)args[1]->ToInt32()->Value(); /* type: _8725 */ v8::String::AsciiValue label(args[2]->ToString()); /* type: _14975 */ wxNode_wxPoint* pos = args[3]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxPoint>(args[3]->ToObject()); /* type: _20518 */ wxNode_wxSize* size = args[4]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxSize>(args[4]->ToObject()); /* type: _20628 */ wxNode_wxButton *self = new wxNode_wxButton(parent, id, *label, *pos, *size); NodeExEvtHandlerImpl* evtHandler = dynamic_cast<NodeExEvtHandlerImpl*>(self); self->wrap(args.This(), self, evtHandler); return args.This(); } /* * id: _45057 */ if(args.Length() == 4 && (args[0]->IsNull() || (args[0]->IsObject() && wxNode_wxWindow::AssignableFrom(args[0]->ToObject()->GetConstructorName()))) && args[1]->IsNumber() && args[2]->IsString() && (args[3]->IsNull() || (args[3]->IsObject() && wxNode_wxPoint::AssignableFrom(args[3]->ToObject()->GetConstructorName())))) { wxNode_wxWindow* parent = args[0]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxWindow>(args[0]->ToObject()); /* type: _1000 * */ int id = (int)args[1]->ToInt32()->Value(); /* type: _8725 */ v8::String::AsciiValue label(args[2]->ToString()); /* type: _14975 */ wxNode_wxPoint* pos = args[3]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxPoint>(args[3]->ToObject()); /* type: _20518 */ wxNode_wxButton *self = new wxNode_wxButton(parent, id, *label, *pos); NodeExEvtHandlerImpl* evtHandler = dynamic_cast<NodeExEvtHandlerImpl*>(self); self->wrap(args.This(), self, evtHandler); return args.This(); } /* * id: _45057 */ if(args.Length() == 3 && (args[0]->IsNull() || (args[0]->IsObject() && wxNode_wxWindow::AssignableFrom(args[0]->ToObject()->GetConstructorName()))) && args[1]->IsNumber() && args[2]->IsString()) { wxNode_wxWindow* parent = args[0]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxWindow>(args[0]->ToObject()); /* type: _1000 * */ int id = (int)args[1]->ToInt32()->Value(); /* type: _8725 */ v8::String::AsciiValue label(args[2]->ToString()); /* type: _14975 */ wxNode_wxButton *self = new wxNode_wxButton(parent, id, *label); NodeExEvtHandlerImpl* evtHandler = dynamic_cast<NodeExEvtHandlerImpl*>(self); self->wrap(args.This(), self, evtHandler); return args.This(); } /* * id: _45057 */ if(args.Length() == 2 && (args[0]->IsNull() || (args[0]->IsObject() && wxNode_wxWindow::AssignableFrom(args[0]->ToObject()->GetConstructorName()))) && args[1]->IsNumber()) { wxNode_wxWindow* parent = args[0]->IsNull() ? NULL : wxNodeObject::unwrap<wxNode_wxWindow>(args[0]->ToObject()); /* type: _1000 * */ int id = (int)args[1]->ToInt32()->Value(); /* type: _8725 */ wxNode_wxButton *self = new wxNode_wxButton(parent, id); NodeExEvtHandlerImpl* evtHandler = dynamic_cast<NodeExEvtHandlerImpl*>(self); self->wrap(args.This(), self, evtHandler); return args.This(); } std::ostringstream errStr; errStr << "Could not find matching constructor for arguments (class name: wxButton).\n"; errStr << " arg count: " << args.Length() << "\n"; for(int i = 0; i < args.Length(); i++) { v8::String::AsciiValue argStr(args[i]); errStr << " arg[" << i << "]: " << *argStr << "\n"; } return v8::ThrowException(v8::Exception::TypeError(v8::String::New(errStr.str().c_str()))); }
void HWindow::InitGUI() { fEventList = new HEventList(); fEventList->SetType(BMediaFiles::B_SOUNDS); fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST); BGroupView* view = new BGroupView(); BBox* box = new BBox("", B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP | B_PULSE_NEEDED); BMenu* menu = new BMenu("file"); menu->SetRadioMode(true); menu->SetLabelFromMarked(true); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"), new BMessage(M_NONE_MESSAGE))); menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS), new BMessage(M_OTHER_MESSAGE))); BString label(B_TRANSLATE("Sound file:")); BMenuField* menuField = new BMenuField("filemenu", label, menu); menuField->SetDivider(menuField->StringWidth(label) + 10); BButton* stopbutton = new BButton("stop", B_TRANSLATE("Stop"), new BMessage(M_STOP_MESSAGE)); stopbutton->SetEnabled(false); BButton* playbutton = new BButton("play", B_TRANSLATE("Play"), new BMessage(M_PLAY_MESSAGE)); playbutton->SetEnabled(false); const float kInset = be_control_look->DefaultItemSpacing(); view->SetLayout(new BGroupLayout(B_HORIZONTAL)); view->AddChild(BGroupLayoutBuilder(B_VERTICAL, kInset) .AddGroup(B_HORIZONTAL) .Add(menuField) .AddGlue() .End() .AddGroup(B_HORIZONTAL, kInset) .AddGlue() .Add(playbutton) .Add(stopbutton) .End() .SetInsets(kInset, kInset, kInset, kInset) ); box->AddChild(view); SetLayout(new BGroupLayout(B_HORIZONTAL)); AddChild(BGroupLayoutBuilder(B_VERTICAL) .AddGroup(B_VERTICAL, kInset) .Add(fEventList) .Add(box) .End() .SetInsets(kInset, kInset, kInset, kInset) ); // setup file menu SetupMenuField(); BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>")); if (noneItem != NULL) noneItem->SetMarked(true); }