void product_stats::refresh() { int type = Choice1->GetSelection(); //0 - by revenue, 1 - by quantity mysqlpp::Query query = conn->query(); wxDateTime start_date = DatePickerCtrl1->GetValue(); wxDateTime end_date = DatePickerCtrl2->GetValue(); wxDateTime mysql_end_date = end_date; mysql_end_date.Add(wxTimeSpan::Day()); switch(type) { case 0: query << "SELECT `name` , SUM( `qty` ) AS `qty`, SUM(`qty`*`price`) AS `money_net`,SUM(`qty`*`price`*`tax`) AS `money_tax`\ FROM `orders_dishes` WHERE `order_id` = ANY (SELECT `id` FROM `orders` \ WHERE `time` > '"<< wx2std(start_date.FormatISODate(),wxConvUI) <<"' AND `time` < '"<< wx2std(mysql_end_date.FormatISODate(),wxConvUI) <<"')\ GROUP BY `name` ORDER BY `money_net` DESC LIMIT " << wx2std(Choice2->GetStringSelection(),wxConvUI); break; case 1: query << "SELECT `name` , SUM( `qty` ) AS `qty`, SUM(`qty`*`price`) AS `money_net`,SUM(`qty`*`price`*`tax`) AS `money_tax`\ FROM `orders_dishes` WHERE `order_id` = ANY (SELECT `id` FROM `orders` \ WHERE `time` > '"<< wx2std(start_date.FormatISODate(),wxConvUI) <<"' AND `time` < '"<< wx2std(mysql_end_date.FormatISODate(),wxConvUI) <<"')\ GROUP BY `name` ORDER BY `qty` DESC LIMIT " << wx2std(Choice2->GetStringSelection(),wxConvUI); break; } mysqlpp::StoreQueryResult res = query.store(); if (res) { wxString info; info << _("Name of the product | Qty | Net | Taxes | Gross\n\n"); wxString infoVerse; mysqlpp::Row row; mysqlpp::StoreQueryResult::size_type i; for (i = 0; i < res.num_rows(); ++i) { row = res[i]; infoVerse.Clear(); std::string name = std::string(row["name"]); int qty = int(row["qty"]); double money_net = round_2(double(row["money_net"])); double money_tax = round_2(double(row["money_tax"])); infoVerse << addSpaces(std2wx(name,wxConvUI),31); wxString temp; temp << qty; infoVerse << addSpaces(temp,8); infoVerse << addSpaces(addZero(money_net),11); infoVerse << addSpaces(addZero(money_tax),12); infoVerse << addZero(money_net + money_tax) << _T("\n"); info << infoVerse; } TextCtrl1->ChangeValue(info); } }
void modes_pre(void) { if(vle_mode_is(CMDLINE_MODE)) { touchwin(status_bar); wrefresh(status_bar); return; } else if(ANY(vle_mode_is, SORT_MODE, CHANGE_MODE, ATTR_MODE)) { return; } else if(vle_mode_is(VIEW_MODE)) { view_pre(); return; } else if(is_in_menu_like_mode()) { menu_pre(); return; } if(!curr_stats.save_msg) { clean_status_bar(); wrefresh(status_bar); } }
/* * Dump DDP statistics structure. */ void ddp_stats(u_long off __unused, const char *name, int af1 __unused) { struct ddpstat ddpstat; if (off == 0) return; kread(off, (char *)&ddpstat, sizeof (ddpstat)); printf("%s:\n", name); ANY(ddpstat.ddps_short, "packet", " with short headers "); ANY(ddpstat.ddps_long, "packet", " with long headers "); ANY(ddpstat.ddps_nosum, "packet", " with no checksum "); ANY(ddpstat.ddps_tooshort, "packet", " too short "); ANY(ddpstat.ddps_badsum, "packet", " with bad checksum "); ANY(ddpstat.ddps_toosmall, "packet", " with not enough data "); ANY(ddpstat.ddps_forward, "packet", " forwarded "); ANY(ddpstat.ddps_encap, "packet", " encapsulated "); ANY(ddpstat.ddps_cantforward, "packet", " rcvd for unreachable dest "); ANY(ddpstat.ddps_nosockspace, "packet", " dropped due to no socket space "); }
int perform_operation(int op, struct object *o) { #ifdef TESLA /* A very simple TESLA assertion. */ TESLA_WITHIN(example_syscall, previously(security_check(ANY(ptr), o, op) == 0)); /* An even simpler assertion! */ TESLA_WITHIN(example_syscall, previously(call(security_check))); /* More simple assertions. */ TESLA_WITHIN(example_syscall, previously(call(hold(o)))); TESLA_WITHIN(example_syscall, previously(returnfrom(hold(o)))); TESLA_WITHIN(example_syscall, eventually(call(release(o)))); /* A simple assertion about struct manipulation. */ TESLA_WITHIN(example_syscall, previously(o->refcount += 1)); /* An example of using high-level TESLA macros. */ TESLA_WITHIN(example_syscall, previously(security_check(ANY(ptr), o, op) == 0) || eventually(log_audit_record(o, op) == 0) ); /* An example of using the lower-level TESLA interface. */ TESLA_GLOBAL(call(example_syscall), returnfrom(example_syscall), TSEQUENCE( get_object(ANY(int), ANY(ptr)) == 0, security_check(ANY(ptr), o, op) == 0, some_helper(op) == 0 || call(never_actually_called), optional(call(void_helper(o))), TESLA_ASSERTION_SITE, returnfrom(release(o)) ) ); #endif return 0; }
/*ARGSUSED*/ void ipxerr_stats(u_long off, const char *name, int af __unused, int proto __unused) { struct ipx_errstat ipx_errstat; int j; int histoprint = 1; int z; if (off == 0) return; kread(off, (char *)&ipx_errstat, sizeof (ipx_errstat)); printf("IPX error statistics:\n"); ANY(ipx_errstat.ipx_es_error, "call", " to ipx_error"); ANY(ipx_errstat.ipx_es_oldshort, "error", " ignored due to insufficient addressing"); ANY(ipx_errstat.ipx_es_oldipx_err, "error request", " in response to error packets"); ANY(ipx_errstat.ipx_es_tooshort, "error packet", " received incomplete"); ANY(ipx_errstat.ipx_es_badcode, "error packet", " received of unknown type"); for(j = 0; j < IPX_ERR_MAX; j ++) { z = ipx_errstat.ipx_es_outhist[j]; if (z && histoprint) { printf("Output Error Histogram:\n"); histoprint = 0; } ipx_erputil(z, ipx_errstat.ipx_es_codes[j]); } histoprint = 1; for(j = 0; j < IPX_ERR_MAX; j ++) { z = ipx_errstat.ipx_es_inhist[j]; if (z && histoprint) { printf("Input Error Histogram:\n"); histoprint = 0; } ipx_erputil(z, ipx_errstat.ipx_es_codes[j]); } }
static void ipx_erputil(int z, int c) { int j; char codebuf[30]; char *name, *where; for(j = 0;; j ++) { if ((name = ipx_errnames[j].name) == 0) break; if (ipx_errnames[j].code == c) break; } if (name == 0) { if (c > 01000) where = "in transit"; else where = "at destination"; sprintf(codebuf, "Unknown IPX error code 0%o", c); name = codebuf; } else where = ipx_errnames[j].where; ANY(z, name, where); }
void modes_post(void) { if(ANY(vle_mode_is, CMDLINE_MODE, SORT_MODE, CHANGE_MODE, ATTR_MODE)) { return; } else if(vle_mode_is(VIEW_MODE)) { view_post(); return; } else if(is_in_menu_like_mode()) { menu_post(); return; } update_screen(curr_stats.need_update); if(curr_stats.save_msg) { status_bar_message(NULL); } if(!vle_mode_is(FILE_INFO_MODE) && curr_view->list_rows > 0) { if(!is_status_bar_multiline()) { update_stat_window(curr_view); ui_ruler_update(curr_view); } } modes_statusbar_update(); }
/* * Dump SPX statistics structure. */ void spx_stats(u_long off, const char *name, int af1 __unused, int proto __unused) { struct spx_istat spx_istat; #define spxstat spx_istat.newstats if (off == 0) return; kread(off, (char *)&spx_istat, sizeof (spx_istat)); printf("%s:\n", name); ANY(spx_istat.nonucn, "connection", " dropped due to no new sockets "); ANY(spx_istat.gonawy, "connection", " terminated due to our end dying"); ANY(spx_istat.nonucn, "connection", " dropped due to inability to connect"); ANY(spx_istat.noconn, "connection", " dropped due to inability to connect"); ANY(spx_istat.notme, "connection", " incompleted due to mismatched id's"); ANY(spx_istat.wrncon, "connection", " dropped due to mismatched id's"); ANY(spx_istat.bdreas, "packet", " dropped out of sequence"); ANY(spx_istat.lstdup, "packet", " duplicating the highest packet"); ANY(spx_istat.notyet, "packet", " refused as exceeding allocation"); ANYl(spxstat.spxs_connattempt, "connection", " initiated"); ANYl(spxstat.spxs_accepts, "connection", " accepted"); ANYl(spxstat.spxs_connects, "connection", " established"); ANYl(spxstat.spxs_drops, "connection", " dropped"); ANYl(spxstat.spxs_conndrops, "embryonic connection", " dropped"); ANYl(spxstat.spxs_closed, "connection", " closed (includes drops)"); ANYl(spxstat.spxs_segstimed, "packet", " where we tried to get rtt"); ANYl(spxstat.spxs_rttupdated, "time", " we got rtt"); ANYl(spxstat.spxs_delack, "delayed ack", " sent"); ANYl(spxstat.spxs_timeoutdrop, "connection", " dropped in rxmt timeout"); ANYl(spxstat.spxs_rexmttimeo, "retransmit timeout", ""); ANYl(spxstat.spxs_persisttimeo, "persist timeout", ""); ANYl(spxstat.spxs_keeptimeo, "keepalive timeout", ""); ANYl(spxstat.spxs_keepprobe, "keepalive probe", " sent"); ANYl(spxstat.spxs_keepdrops, "connection", " dropped in keepalive"); ANYl(spxstat.spxs_sndtotal, "total packet", " sent"); ANYl(spxstat.spxs_sndpack, "data packet", " sent"); ANYl(spxstat.spxs_sndbyte, "data byte", " sent"); ANYl(spxstat.spxs_sndrexmitpack, "data packet", " retransmitted"); ANYl(spxstat.spxs_sndrexmitbyte, "data byte", " retransmitted"); ANYl(spxstat.spxs_sndacks, "ack-only packet", " sent"); ANYl(spxstat.spxs_sndprobe, "window probe", " sent"); ANYl(spxstat.spxs_sndurg, "packet", " sent with URG only"); ANYl(spxstat.spxs_sndwinup, "window update-only packet", " sent"); ANYl(spxstat.spxs_sndctrl, "control (SYN|FIN|RST) packet", " sent"); ANYl(spxstat.spxs_sndvoid, "request", " to send a non-existant packet"); ANYl(spxstat.spxs_rcvtotal, "total packet", " received"); ANYl(spxstat.spxs_rcvpack, "packet", " received in sequence"); ANYl(spxstat.spxs_rcvbyte, "byte", " received in sequence"); ANYl(spxstat.spxs_rcvbadsum, "packet", " received with ccksum errs"); ANYl(spxstat.spxs_rcvbadoff, "packet", " received with bad offset"); ANYl(spxstat.spxs_rcvshort, "packet", " received too short"); ANYl(spxstat.spxs_rcvduppack, "duplicate-only packet", " received"); ANYl(spxstat.spxs_rcvdupbyte, "duplicate-only byte", " received"); ANYl(spxstat.spxs_rcvpartduppack, "packet", " with some duplicate data"); ANYl(spxstat.spxs_rcvpartdupbyte, "dup. byte", " in part-dup. packet"); ANYl(spxstat.spxs_rcvoopack, "out-of-order packet", " received"); ANYl(spxstat.spxs_rcvoobyte, "out-of-order byte", " received"); ANYl(spxstat.spxs_rcvpackafterwin, "packet", " with data after window"); ANYl(spxstat.spxs_rcvbyteafterwin, "byte", " rcvd after window"); ANYl(spxstat.spxs_rcvafterclose, "packet", " rcvd after 'close'"); ANYl(spxstat.spxs_rcvwinprobe, "rcvd window probe packet", ""); ANYl(spxstat.spxs_rcvdupack, "rcvd duplicate ack", ""); ANYl(spxstat.spxs_rcvacktoomuch, "rcvd ack", " for unsent data"); ANYl(spxstat.spxs_rcvackpack, "rcvd ack packet", ""); ANYl(spxstat.spxs_rcvackbyte, "byte", " acked by rcvd acks"); ANYl(spxstat.spxs_rcvwinupd, "rcvd window update packet", ""); }
int main(void) { athrow(ANY()); return 0; }
int is_in_menu_like_mode(void) { return ANY(vle_primary_mode_is, MENU_MODE, FILE_INFO_MODE); }
DEVICE void operator() ( vec3f* aRayOrg, vec3f* aRayDir, const tControlStructure& aGridParameters, const tStorageStructure& aScene, const tMaterialStorageStructure& aMaterialStorage, const tLightSource& aLightSource, vec3f& oRadiance, uint* aSharedMem, int aSeed = 0) { ////////////////////////////////////////////////////////////////////////// //Traversal initialization t_Traverser traverser; t_State state; ////////////////////////////////////////////////////////////////////////// //Integration Initialization CosineHemisphereSampler genDir; t_RNG genRand( 12872141u + aSeed * 426997u + aSeed, 2611909u + aSeed * 14910827u + globalThreadId1D(1887143u) + aSeed, 1010567u + aSeed * 2757577u + globalThreadId1D(45751u) + aSeed, 416191069u); //t_RNG genRand(globalThreadId1D() + RESX * RESY * (*aImageId)); #ifndef GATHERSTATISTICS oRadiance = vec3f::rep(1.f); #else oRadiance.x = 1.f; //number of rays traced oRadiance.y = 0.f; //number of rays active after path termination oRadiance.z = 0.f; //number of intersection tests #endif ////////////////////////////////////////////////////////////////////////// //Integration loop float rayT = FLT_MAX; uint bestHit; //NOTE: Device capability 1.2 or higher required while (ANY(rayT > 0.f))//Termination criteria { #ifndef GATHERSTATISTICS traverser.traverse(aRayOrg, aRayDir, rayT, bestHit, state, aGridParameters, aScene, aSharedMem); #else traverser.traverse(aRayOrg, aRayDir, rayT, bestHit, state, aGridParameters, aScene, aSharedMem, oRadiance); oRadiance.y += 1.f; #endif if ((rayT < FLT_MAX) && (rayT > 0.f)) { bestHit = aScene.indices[bestHit]; vec3f normal = aScene(bestHit).vertices[0]; //register reuse: state.tMax should be edge1 state.tMax = aScene(bestHit).vertices[1]; //register reuse: state.cellId should be edge2 state.cellId = aScene(bestHit).vertices[2]; state.tMax = state.tMax - normal; state.cellId = state.cellId - normal; normal = ~(state.tMax % state.cellId); state.tMax = ~state.tMax; state.cellId = normal % state.tMax; //vec3f::getLocalCoordinates(normal, state.tMax, state.cellId); if (normal.dot(aRayDir[threadId1D()]) > 0.f) { normal = -normal; } float4 diffReflectance = aMaterialStorage.getDiffuseReflectance( aScene.getMaterialId(bestHit)); //float albedo = (diffReflectance.x * 0.222f + // diffReflectance.y * 0.7067f + // diffReflectance.z * 0.0713f); float albedo = 0.5f; float rnum = genRand(); if( rnum < albedo ) { #ifndef GATHERSTATISTICS oRadiance = oRadiance / albedo; //pi is to account for cosine weighted hemisphere sampling oRadiance.x = oRadiance.x * diffReflectance.x * M_PI; oRadiance.y = oRadiance.y * diffReflectance.y * M_PI; oRadiance.z = oRadiance.z * diffReflectance.z * M_PI; #else oRadiance.x += 1.f; #endif //generate new ray aRayOrg[threadId1D()] = aRayOrg[threadId1D()] + rayT * aRayDir[threadId1D()] + normal * 0.001f; vec3f randDir = genDir(genRand(), genRand()); aRayDir[threadId1D()] = state.tMax * randDir.x + state.cellId * randDir.y + normal * randDir.z; rayT = FLT_MAX; } else { //terminate path and save last hit-point aRayDir[threadId1D()] = aRayOrg[threadId1D()] + (rayT - 0.001f) * aRayDir[threadId1D()]; #ifndef GATHERSTATISTICS oRadiance.x = oRadiance.x * diffReflectance.x / (1 - albedo); oRadiance.y = oRadiance.y * diffReflectance.y / (1 - albedo); oRadiance.z = oRadiance.z * diffReflectance.z / (1 - albedo); #endif //save cos between normal and incoming direction aRayOrg[threadId1D()] = normal; rayT = -1.f; } } else if (rayT > 0.f) { #ifndef GATHERSTATISTICS //terminate path oRadiance.x = oRadiance.x * BACKGROUND_R; oRadiance.y = oRadiance.y * BACKGROUND_G; oRadiance.z = oRadiance.z * BACKGROUND_B; #endif rayT = -2.f; }//end if (rayT < FLT_MAX) && (rayT > 0.f) } //end integration loop ////////////////////////////////////////////////////////////////////////// //trace ray to light source //register reuse state.cellId.x should be vec3f surfaceNormal state.cellId = aRayOrg[threadId1D()]; aRayOrg[threadId1D()] = aLightSource.getPoint(genRand(), genRand()); aRayDir[threadId1D()] = aRayDir[threadId1D()] - aRayOrg[threadId1D()]; if (rayT > -2.f) { rayT = FLT_MAX; #ifndef GATHERSTATISTICS oRadiance = oRadiance * max(0.f, -state.cellId.dot(~aRayDir[threadId1D()])); #endif } #ifndef GATHERSTATISTICS traverser.traverseShadowRay(aRayOrg, aRayDir, rayT, bestHit, state, aGridParameters, aScene, aSharedMem); if (rayT >= 0.9999f) { float attenuation = aRayDir[threadId1D()].dot(aRayDir[threadId1D()]); oRadiance = oRadiance * aLightSource.intensity * dcLightSource.getArea() * max(0.f, aLightSource.normal.dot(~aRayDir[threadId1D()])) / attenuation; //oRadiance = oRadiance / aRayDir[threadId1D()].len() / aRayDir[threadId1D()].len() * max(0.f, aLightSource.normal.dot(aRayDir[threadId1D()])); } else if (rayT > -2.f) { //occluded oRadiance = vec3f::rep(0.f); } #else traverser.traverseShadowRay(aRayOrg, aRayDir, rayT, bestHit, state, aGridParameters, aScene, aSharedMem, oRadiance); oRadiance.x += 1.f; oRadiance.y += 1.f; #endif }
WireSyntax::WireSyntax() { SYNTAX("Wire"); DEFINE_VOID("Comment", CHOICE( GLUE( STRING("//"), CHOICE( FIND(AHEAD(CHAR('\n'))), FIND(EOI()) ) ), GLUE( STRING("/*"), REPEAT( CHOICE( INLINE("Comment"), GLUE( NOT(STRING("*/")), ANY() ) ) ), STRING("*/") ) ) ); DEFINE_VOID("Whitespace", REPEAT( CHOICE( RANGE(" \t\n"), INLINE("Comment") ) ) ); DEFINE("Name", REPEAT(1, EXCEPT(" \t\n:;")) ); DEFINE("Value", CHOICE( REF("Atom"), REF("Properties"), REF("Items") ) ); DEFINE("Object", GLUE( REPEAT(0, 1, GLUE( REF("Name"), INLINE("Whitespace"), CHAR(':'), INLINE("Whitespace") ) ), INLINE("Value") ) ); DEFINE("Atom", REPEAT( GLUE( NOT( CHOICE( GLUE( REPEAT(RANGE(" \t")), INLINE("Name"), REPEAT(RANGE(" \t")), CHAR(':') ), GLUE( REPEAT(RANGE(" \t")), RANGE("};,") ), STRING("\n\n") ) ), ANY() ) ) ); DEFINE("Properties", GLUE( CHAR('{'), INLINE("Whitespace"), REPEAT( GLUE( REF("Object"), INLINE("Whitespace"), RANGE(";,"), INLINE("Whitespace") ) ), CHAR('}') ) ); DEFINE("Items", GLUE( CHAR('['), INLINE("Whitespace"), REPEAT( GLUE( REF("Value"), INLINE("Whitespace"), RANGE(";,"), INLINE("Whitespace") ) ), CHAR(']') ) ); ENTRY("Object"); }
int main(int argc, char **argv) { Vals vals; /* the application */ QApplication app(argc, argv); app.setApplicationName(APP_NAME); app.setWindowIcon(QIcon(":/icon")); Window window; /* translations */ QTranslator qtr; if (qtr.load("qt_" + QLocale::system().name(), QTR_PATH)) app.installTranslator(&qtr); QTranslator htr; if (htr.load("H4KvT_" + QLocale::system().name(), ":/")) app.installTranslator(&htr); /* display information */ QTextEdit *text = new QTextEdit; text->setReadOnly(true); text->setLineWrapMode(QTextEdit::NoWrap); text->setToolTip(Window::tr("Drop any file for hashing")); QObject::connect(&window, &Window::idle, text, &QWidget::setEnabled); /* compare hash */ QLineEdit *test = new QLineEdit; HexVal hexval; test->setValidator(&hexval); test->installEventFilter(&window); test->setToolTip(Window::tr("Compare hashes")); QObject::connect(test, &QLineEdit::textChanged, [&](const QString &newValue) { if (vals.name != "") { std::string hashVal = newValue.toStdString(); std::transform(hashVal.begin(), hashVal.end(), hashVal.begin(), ::tolower); std::stringstream html; if (hashVal != "") html << "<style>.h" << hashVal << "{color:green}</style>"; html << "<div style='margin-bottom:2; font-size:27px'><i><b>" << vals.name << "</b></i></div>"; html << "<div style='margin-bottom:7; margin-left:23; font-size:13px'>" << vals.path << "</div>"; if (!ALL(vals,"")) { html << "<div style='font-size:13px'><table>"; if (vals.md5 != "") html << "<tr><td>md5: </td><td class='h" << vals.md5 << "'>" << vals.md5 << "</td</tr>"; if (vals.sha1 != "") html << "<tr><td>sha1: </td><td class='h" << vals.sha1 << "'>" << vals.sha1 << "</td</tr>"; if (vals.sha224 != "") html << "<tr><td>sha224: </td><td class='h" << vals.sha224 << "'>" << vals.sha224 << "</td</tr>"; if (vals.sha256 != "") html << "<tr><td>sha256: </td><td class='h" << vals.sha256 << "'>" << vals.sha256 << "</td</tr>"; if (vals.sha384 != "") html << "<tr><td>sha384: </td><td class='h" << vals.sha384 << "'>" << vals.sha384 << "</td</tr>"; if (vals.sha512 != "") html << "<tr><td>sha512: </td><td class='h" << vals.sha512 << "'>" << vals.sha512 << "</td</tr>"; html << "</table></div>"; } int horizontal = text->horizontalScrollBar()->value(); int vertical = text->verticalScrollBar()->value(); text->setHtml(QString::fromStdString(html.str())); text->horizontalScrollBar()->setValue(horizontal); text->verticalScrollBar()->setValue(vertical); test->setStyleSheet(ANY(vals,hashVal) ? "color:green" : ""); }}); /* error messages */ QLabel *error = new QLabel; error->setStyleSheet("color:red"); /* test or error */ QStackedWidget *stack = new QStackedWidget; delete stack->layout(); stack->setLayout(new Stack); stack->addWidget(error); stack->addWidget(test); stack->setCurrentIndex(1); /* toggle test or error */ QPushButton *hash = new QPushButton(QIcon(":/icon"), ""); hash->setCheckable(true); hash->setChecked(true); hash->setToolTip(Window::tr("Compare hashes")); QObject::connect(hash, &QPushButton::toggled, stack, &QStackedWidget::setCurrentIndex); /* store method */ QSettings settings("H4KvT", "H4KvT"); /* more methods */ bool more; try { settings.setValue("MoreHashingMethods", more = moreOrLess()); } catch (...) { more = settings.value("MoreHashingMethods", false).toBool(); } /* hashing method */ QComboBox *meth = new QComboBox; meth->addItem("md5"); meth->addItem("sha1"); if (more) meth->addItem("sha224"); meth->addItem("sha256"); if (more) meth->addItem("sha384"); meth->addItem("sha512"); meth->setToolTip(Window::tr("Hashing method")); meth->setCurrentText(settings.value("HashingMethod", "md5").toString()); QObject::connect(&window, &Window::idle, meth, &QWidget::setEnabled); QObject::connect(meth, &QComboBox::currentTextChanged, [&](const QString &text) { settings.setValue("HashingMethod", text); }); /* toolbar */ QHBoxLayout *pane = new QHBoxLayout; pane->addWidget(hash, 0, Qt::AlignLeft); pane->addWidget(stack); pane->addWidget(meth, 0, Qt::AlignRight); /* main layout */ QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(text); layout->addLayout(pane); /* the window */ window.centralWidget()->setLayout(layout); window.show(); /* future hashing */ QFutureWatcher<Vals> zu; QObject::connect(&zu, &QFutureWatcher<Vals>::finished, [&]() { Vals valsi = zu.future().result(); window.idle(true); if (valsi.path == "") { error->setText(QString::fromStdString(valsi.name)); hash->setChecked(false); } else { error->clear(); vals += valsi; test->textChanged(test->text()); } }); QObject::connect(meth, &QComboBox::currentTextChanged, [&](const QString &text) { if (vals.name != "") { window.idle(false); zu.setFuture(QtConcurrent::run(&update, text, vals)); }}); QObject::connect(&window, &Window::fileDroped, [&](const QString &name, const QString &path) { window.idle(false); zu.setFuture(QtConcurrent::run(&update, meth->currentText(), Vals(name, path))); }); /* hashing info */ QGraphicsBlurEffect blur; blur.setBlurHints(QGraphicsBlurEffect::AnimationHint); QPropertyAnimation anim(&blur, "blurRadius"); anim.setDuration(2000); anim.setLoopCount(-1); anim.setKeyValueAt(0, 0); anim.setKeyValueAt(0.5, 3); anim.setKeyValueAt(1, 0); QLabel *hashing = new QLabel; hashing->setPixmap(QPixmap(":/icon")); hashing->setAttribute(Qt::WA_TransparentForMouseEvents); hashing->setGraphicsEffect(&blur); hashing->hide(); (new QHBoxLayout(text))->addWidget(hashing, 0, Qt::AlignCenter); QObject::connect(&blur, &QGraphicsBlurEffect::blurRadiusChanged, hashing, static_cast<void(QWidget::*)()>(&QWidget::update)); QObject::connect(&window, &Window::idle, [&](bool idle) { if (idle) { hashing->hide(); anim.stop(); } else { hashing->show(); anim.start(); } }); /* about app */ QMenu about; QAction *action = about.addAction(QIcon(":/icon"), Window::tr("About %1").arg(APP_NAME)); action->setMenuRole(QAction::AboutRole); QObject::connect(action, &QAction::triggered, &window, &Window::about); error->setContextMenuPolicy(Qt::NoContextMenu); hash->setContextMenuPolicy(Qt::NoContextMenu); meth->setContextMenuPolicy(Qt::NoContextMenu); window.setContextMenuPolicy(Qt::CustomContextMenu); QObject::connect(&window, &QWidget::customContextMenuRequested, [&about, &window](const QPoint &pos) { about.popup(window.mapToGlobal(pos)); }); text->setContextMenuPolicy(Qt::CustomContextMenu); QObject::connect(text, &QWidget::customContextMenuRequested, [action, text](const QPoint &pos) { if (QMenu *m = text->createStandardContextMenu()) { m->insertAction(m->insertSeparator(m->actions()[0]), action); m->popup(text->mapToGlobal(pos)); } }); test->setContextMenuPolicy(Qt::CustomContextMenu); QObject::connect(test, &QWidget::customContextMenuRequested, [action, test](const QPoint &pos) { if (QMenu *m = test->createStandardContextMenu()) { m->insertAction(m->insertSeparator(m->actions()[0]), action); m->popup(test->mapToGlobal(pos)); } }); return app.exec(); }
HaxeMessageSyntax::HaxeMessageSyntax() { DEFINE_VOID("SpaceChar", RANGE(" \n\r\t")); DEFINE_VOID("Whitespace", REPEAT(INLINE("SpaceChar"))); specialChar_ = DEFINE("SpecialChar", GLUE( CHAR('&'), KEYWORD("gt lt"), CHAR(';') ) ); gt_ = keywordByName("gt"); lt_ = keywordByName("lt"); value_ = DEFINE("Value", REPEAT(1, CHOICE( REF("SpecialChar"), GLUE( NOT( GLUE( INLINE("Whitespace"), CHAR('<') ) ), ANY() ) ) ) ); typeTip_ = DEFINE("TypeTip", GLUE( STRING("<type>"), INLINE("Whitespace"), REF("Value"), INLINE("Whitespace"), STRING("</type>") ) ); memberName_ = DEFINE("MemberName", REPEAT(1, OTHER('\"'))); memberType_ = DEFINE("MemberType", REPEAT(0, 1, INLINE("Value"))); memberDescription_ = DEFINE("MemberDescription", REPEAT(0, 1, INLINE("Value"))); member_ = DEFINE("Member", GLUE( STRING("<i n=\""), REF("MemberName"), STRING("\"><t>"), REF("MemberType"), STRING("</t><d>"), REF("MemberDescription"), STRING("</d></i>") ) ); membersTip_ = DEFINE("MembersTip", GLUE( STRING("<list>"), REPEAT(1, GLUE( INLINE("Whitespace"), REF("Member") ) ), INLINE("Whitespace"), STRING("</list>") ) ); haxeTip_ = DEFINE("HaxeTip", FIND( GLUE( INLINE("Whitespace"), CHOICE( REF("TypeTip"), REF("MembersTip") ), INLINE("Whitespace") ) ) ); ENTRY("HaxeTip"); }
DEVICE void operator() ( vec3f* aRayOrg, vec3f* aRayDir, const tControlStructure& aGridParameters, const tStorageStructure& aScene, const tMaterialStorageStructure& aMaterialStorage, const tLightSource& aLightSource, vec3f& oRadiance, uint* aSharedMem, int aSeed = 0) { ////////////////////////////////////////////////////////////////////////// //Traversal initialization t_Traverser traverser; t_State state; ////////////////////////////////////////////////////////////////////////// //Integration Initialization CosineHemisphereSampler genDir; t_RNG genRand( 1236789u + globalThreadId1D(), 369u + globalThreadId1D(aSeed), 351288629u + globalThreadId1D(aSeed), 416191069u ); //t_RNG genRand(globalThreadId1D() + RESX * RESY * (*aImageId)); #ifndef GATHERSTATISTICS oRadiance = vec3f::rep(1.f); #else oRadiance.x = 1.f; //number of rays traced oRadiance.y = 0.f; //number of rays active after path termination oRadiance.z = 0.f; //number of intersection tests #endif ////////////////////////////////////////////////////////////////////////// //Integration loop float rayT = FLT_MAX; uint bestHit; uint bounceCount = 0u; //NOTE: Device capability 1.2 or higher required while (ANY(rayT > 0.f))//Termination criteria { #ifndef GATHERSTATISTICS traverser.traverse(aRayOrg, aRayDir, rayT, bestHit, state, aGridParameters, aScene, aSharedMem); #else traverser.traverse(aRayOrg, aRayDir, rayT, bestHit, state, aGridParameters, aScene, aSharedMem, oRadiance); oRadiance.y += 1.f; #endif if ((rayT < FLT_MAX) && (rayT > 0.f)) { bestHit = aScene.indices[bestHit]; vec3f normal = aScene(bestHit).vertices[0]; //register reuse: state.tMax should be edge1 state.tMax = aScene(bestHit).vertices[1]; //register reuse: state.cellId should be edge2 state.cellId = aScene(bestHit).vertices[2]; state.tMax = state.tMax - normal; state.cellId = state.cellId - normal; normal = ~(state.tMax % state.cellId); state.tMax = ~state.tMax; state.cellId = normal % state.tMax; if (normal.dot(aRayDir[threadId1D()]) > 0.f) { normal = -normal; } float4 diffReflectance = aMaterialStorage.getDiffuseReflectance( aScene.getMaterialId(bestHit)); if( bounceCount < 1 ) { ++bounceCount; #ifndef GATHERSTATISTICS oRadiance.x = oRadiance.x * diffReflectance.x; oRadiance.y = oRadiance.y * diffReflectance.y; oRadiance.z = oRadiance.z * diffReflectance.z; #else oRadiance.x += 1.f; #endif //generate new ray aRayOrg[threadId1D()] = aRayOrg[threadId1D()] + rayT * aRayDir[threadId1D()] + normal * EPS; vec3f randDir = genDir(genRand(), genRand()); aRayDir[threadId1D()] = state.tMax * randDir.x + state.cellId * randDir.y + normal * randDir.z; rayT = FLT_MAX; } else { //terminate path and save last hit-point aRayDir[threadId1D()] = aRayOrg[threadId1D()] + (rayT - 0.0001f) * aRayDir[threadId1D()]; #ifndef GATHERSTATISTICS oRadiance.x = oRadiance.x * diffReflectance.x; oRadiance.y = oRadiance.y * diffReflectance.y; oRadiance.z = oRadiance.z * diffReflectance.z; #endif //save normal for later aRayOrg[threadId1D()] = normal; rayT = -1.f; } } else if (rayT > 0.f) { #ifndef GATHERSTATISTICS //terminate path oRadiance.x = oRadiance.x * BACKGROUND_R; oRadiance.y = oRadiance.y * BACKGROUND_G; oRadiance.z = oRadiance.z * BACKGROUND_B; #endif rayT = -2.f; }//end if (rayT < FLT_MAX) && (rayT > 0.f) } //end integration loop ////////////////////////////////////////////////////////////////////////// //trace ray to light source //register reuse state.cellId should be vec3f surfaceNormal state.cellId = aRayOrg[threadId1D()]; aRayOrg[threadId1D()] = aLightSource.getPoint(genRand(), genRand()); aRayDir[threadId1D()] = aRayDir[threadId1D()] - aRayOrg[threadId1D()]; if (rayT > -2.f) { rayT = FLT_MAX; #ifndef GATHERSTATISTICS oRadiance = oRadiance * fabsf(state.cellId.dot(~aRayDir[threadId1D()])); #endif } #ifndef GATHERSTATISTICS traverser.traverseShadowRay(aRayOrg, aRayDir, rayT, bestHit, state, aGridParameters, aScene, aSharedMem); if (rayT >= 0.9999f) { oRadiance = oRadiance * aLightSource.intensity; oRadiance = oRadiance * max(0.f, aLightSource.normal.dot(~aRayDir[threadId1D()])); } else if (rayT > -2.f) { //occluded oRadiance = vec3f::rep(0.f); } #else traverser.traverseShadowRay(aRayOrg, aRayDir, rayT, bestHit, state, aGridParameters, aScene, aSharedMem, oRadiance); oRadiance.x += 1.f; oRadiance.y += 1.f; #endif }