void slider_impl::paint(graphics_context& aGraphicsContext) const { scoped_units su(*this, UnitsPixels); rect rectBarBox = bar_box(); colour ink = background_colour().light(0x80) ? background_colour().darker(0x80) : background_colour().lighter(0x80); aGraphicsContext.fill_rounded_rect(rectBarBox, 2.0, ink); rectBarBox.deflate(size{1.0, 1.0}); aGraphicsContext.fill_rounded_rect(rectBarBox, 2.0, ink.mid(background_colour())); rect rectValue = rectBarBox; rectValue.cx = rectValue.width() * normalized_value(); if (normalized_value() > 0.0) aGraphicsContext.fill_rounded_rect(rectValue, 2.0, app::instance().current_style().selection_colour()); rect rectIndicator = indicator_box(); colour indicatorColour = foreground_colour(); if (iDragOffset != boost::none) { if (indicatorColour.light(0x40)) indicatorColour.darken(0x40); else indicatorColour.lighten(0x40); } colour indicatorBorderColour = indicatorColour.darker(0x40); indicatorColour.lighten(0x40); aGraphicsContext.fill_circle(rectIndicator.centre(), rectIndicator.width() / 2.0, indicatorBorderColour); aGraphicsContext.fill_circle(rectIndicator.centre(), rectIndicator.width() / 2.0 - 1.0, indicatorColour); }
int main(int argc, char **argv) { int r; progname = argv[0]; opts(argc, argv); job_init(); prot_init(); r = make_server_socket(host_addr, port); if (r == -1) twarnx("make_server_socket()"), exit(111); if (user) su(user); if (detach) daemonize(); event_init(); set_sig_handlers(); nudge_fd_limit(); unbrake((evh) h_accept); event_dispatch(); twarnx("got here for some reason"); return 0; }
size slider_impl::minimum_size(const optional_size& aAvailableSpace) const { if (has_minimum_size()) return widget::minimum_size(aAvailableSpace); scoped_units su(*this, UnitsPixels); return convert_units(*this, su.saved_units(), size{ 96, 16 }); }
void SVD::reorder() { Int i,j,k,s,inc=1; Doub sw; VecDoub su(m), sv(n); do { inc *= 3; inc++; } while (inc <= n); do { inc /= 3; for (i=inc;i<n;i++) { sw = w[i]; for (k=0;k<m;k++) su[k] = u[k][i]; for (k=0;k<n;k++) sv[k] = v[k][i]; j = i; while (w[j-inc] < sw) { w[j] = w[j-inc]; for (k=0;k<m;k++) u[k][j] = u[k][j-inc]; for (k=0;k<n;k++) v[k][j] = v[k][j-inc]; j -= inc; if (j < inc) break; } w[j] = sw; for (k=0;k<m;k++) u[k][j] = su[k]; for (k=0;k<n;k++) v[k][j] = sv[k]; } } while (inc > 1); for (k=0;k<n;k++) { s=0; for (i=0;i<m;i++) if (u[i][k] < 0.) s++; for (j=0;j<n;j++) if (v[j][k] < 0.) s++; if (s > (m+n)/2) { for (i=0;i<m;i++) u[i][k] = -u[i][k]; for (j=0;j<n;j++) v[j][k] = -v[j][k]; } } }
void restore( char *gisbase, char *grass_version ) { int num_restored; char tmp[2048]; char *verstr = strdup( grass_version ); char *grass_major = strtok( verstr, "." ); char *grass_minor = strtok( 0, "." ); char *grass_revision = strtok( 0, "." ); int major = strtol( grass_major, 0, 10 ), minor = strtol( grass_minor, 0, 10 ), revision = strtol( grass_revision, 0, 10 ); free( verstr ); fwrite( "Restoring...", 1, 12, stdout ); if ( major == 6 && minor <= 0 ) { num_restored = restore_entries_gisman( gisbase ); if ( VERBOSE ) fprintf( stdout, "\nRestored entries for GIS Manager: %i\n", num_restored ); } num_restored = restore_html( gisbase ); if ( VERBOSE ) fprintf( stdout, "\nRestored links in index.hml: %i\n", num_restored ); if ( num_restored > 0 ) { if ( VERBOSE ) sprintf( tmp, "cp -f %s %s/etc/dm/menu.tcl ; chmod a+r %s/etc/dm/menu.tcl ; \t\t\t\t\t\t\tcp -f %s %s/docs/html/index.html ; chmod a+r %s/docs/html/index.html", TMP_GISMAN, gisbase, gisbase, TMP_HTML, gisbase, gisbase ); else sprintf( tmp, "cp -f %s %s/etc/dm/menu.tcl ; chmod a+r %s/etc/dm/menu.tcl &> %s ; \t\t\t\t\t\t\tcp -f %s %s/docs/html/index.html ; chmod a+r %s/docs/html/index.html", TMP_GISMAN, gisbase, gisbase, TMP_NULL, TMP_HTML, gisbase, gisbase ); su( gisbase, tmp ); } if ( num_restored == 0 ) print_error( -26, "could not find anything to restore.\n" ); else print_done( ); return; }
size image_widget::minimum_size(const optional_size& aAvailableSpace) const { if (has_minimum_size()) return widget::minimum_size(aAvailableSpace); scoped_units su(*this, UnitsPixels); size result = iTexture.extents(); return convert_units(*this, su.saved_units(), result); }
size colour_picker_dialog::yz_picker::minimum_size(const optional_size& aAvailableSpace) const { if (has_minimum_size()) return framed_widget::minimum_size(aAvailableSpace); scoped_units su(*this, UnitsPixels); size result = framed_widget::minimum_size(aAvailableSpace); result += size{ 256, 256 }; return result; }
int main(int argc, char **argv) { int r, l; struct event_base *ev_base; struct job binlog_jobs = {}; progname = argv[0]; opts(argc, argv); if (detach && binlog_dir) { if (binlog_dir[0] != '/') { warnx("The -b option requires an absolute path when used with -d."); usage("Path is not absolute", binlog_dir); } } job_init(); prot_init(); /* We want to make sure that only one beanstalkd tries to use the binlog * directory at a time. So acquire a lock now and never release it. */ if (binlog_dir) { r = binlog_lock(); if (!r) twarnx("failed to lock binlog dir %s", binlog_dir), exit(10); } r = make_server_socket(host_addr, port); if (r == -1) twarnx("make_server_socket()"), exit(111); l = r; if (user) su(user); ev_base = event_init(); set_sig_handlers(); nudge_fd_limit(); r = listen(l, 1024); if (r == -1) twarn("listen()"); accept_handler = (evh)h_accept; unbrake(); binlog_jobs.prev = binlog_jobs.next = &binlog_jobs; binlog_init(&binlog_jobs); prot_replay_binlog(&binlog_jobs); if (detach) { daemonize(); event_reinit(ev_base); } event_dispatch(); twarnx("event_dispatch error"); binlog_shutdown(); return 0; }
int main(){ int i = 0; printf("请输入一个数字"); scanf("%d",&i); scanf("%*[^\n]"); scanf("%*c"); // sushu(i); printf("%d\n",su(i)); if(su(i)){ printf("是素数\n"); } else{ printf("不是素数\n"); } /* for(i = 3;i<= 50;i++){ sushu(i); } */ return 0; }
bool Privileges::isDba() { XSqlQuery su("SELECT isDBA() AS issuper;"); su.exec(); if (su.first()) return su.value("issuper").toBool(); else if (su.lastError().type() != QSqlError::NoError) qWarning("SQL error in Privileges::isDba(): %s", qPrintable(su.lastError().text())); return false; }
int main(){ int c, d, u, n; n = recebe(); c = sc(n); d = sd(n); u = su(n); print(c); print(d); print(u); }
int main(int argc, const char *argv[]) { int x = atoi(argv[1]); int y = atoi(argv[2]); stu_t st = {add, 10, 4}; a[0] = add; f[0] = add; printf("%d\n", st.aa(st.i, st.j)); printf("%d\n", a[0](st.i, st.j)); printf("%d\n", f[0](x, y)); printf("%d\n", su(x, y, add)); return 0; }
void colour_picker_dialog::x_picker::paint(graphics_context& aGraphicsContext) const { framed_widget::paint(aGraphicsContext); scoped_units su(*this, UnitsPixels); rect cr = client_rect(false); for (uint32_t x = 0; x < cr.height(); ++x) { double nx = x / (cr.height() - 1.0); rect line{ cr.top_left() + point{ 0.0, cr.height() - x - 1.0 }, size{ cr.width(), 1.0 } }; if (iParent.mode() == ModeHSV) { hsv_colour hsvColour{ nx * 359.0, 1.0, 1.0 }; aGraphicsContext.fill_rect(line, hsvColour.to_rgb()); } } }
void toolbar_button::paint(graphics_context& aGraphicsContext) const { if (!iAction.is_separator()) push_button::paint(aGraphicsContext); else { scoped_units su(*this, aGraphicsContext, UnitsPixels); rect line = client_rect(); line.deflate(0, std::floor(client_rect().height() / 6.0)); line.cx = 1.0; colour ink = (has_foreground_colour() ? foreground_colour() : app::instance().current_style().foreground_colour()); aGraphicsContext.fill_rect(line, ink.darker(0x40)); ++line.x; aGraphicsContext.fill_rect(line, ink.lighter(0x40)); } }
void menu_item_widget::paint(graphics_context& aGraphicsContext) const { if (iMenuItem.type() != i_menu_item::Action || !iMenuItem.action().is_separator()) { widget::paint(aGraphicsContext); if (iMenuItem.type() == i_menu_item::SubMenu && iMenu.type() == i_menu::Popup) { bool openSubMenu = (iMenuItem.type() == i_menu_item::SubMenu && iMenuItem.sub_menu().is_open()); colour ink = openSubMenu ? app::instance().current_style().selection_colour() : background_colour().light() ? background_colour().darker(0x80) : background_colour().lighter(0x80); if (iSubMenuArrow == boost::none || iSubMenuArrow->first != ink) { const uint8_t sArrowImagePattern[9][6] { { 0, 0, 0, 0, 0, 0 }, { 0, 1, 0, 0, 0, 0 }, { 0, 1, 1, 0, 0, 0 }, { 0, 1, 1, 1, 0, 0 }, { 0, 1, 1, 1, 1, 0 }, { 0, 1, 1, 1, 0, 0 }, { 0, 1, 1, 0, 0, 0 }, { 0, 1, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0 }, }; iSubMenuArrow = std::make_pair(ink, image{ "neogfx::menu_item_widget::" + ink.to_string(), sArrowImagePattern, { { 0, colour{} },{ 1, ink } } }); } rect rect = client_rect(false); aGraphicsContext.draw_texture( point{ rect.right() - iGap + std::floor((iGap - iSubMenuArrow->second.extents().cx) / 2.0), std::floor((rect.height() - iSubMenuArrow->second.extents().cy) / 2.0) }, iSubMenuArrow->second); } } else { scoped_units su(*this, aGraphicsContext, UnitsPixels); rect line = client_rect(false); ++line.y; line.cy = 1.0; line.x += (iIconSize + iGap * 2.0); line.cx -= (iIconSize + iGap * 3.0); colour ink = background_colour().light() ? background_colour().darker(0x60) : background_colour().lighter(0x60); ink.set_alpha(0x80); aGraphicsContext.fill_rect(line, ink); } }
int runCommand(){ int i = 0; int argc = splitString(textBuffer, ' '); for(i =0;i<argc;i++){argv[i]=stringArray[i];} if(k_strcmp(argv[0], "")==0){} else if(k_strcmp(argv[0], "clear")==0){ clearScreen(); typeOffset = 0;} else if(k_strcmp(argv[0], "history")==0){ printHistory();} else if(k_strcmp(argv[0], "pong")==0){ pong();} else if(k_strcmp(argv[0], "help")==0){ listCommands();} else if(k_strcmp(argv[0], "welcome")==0){ welcome();} else if(k_strcmp(argv[0], "splash")==0){ splash();} else if(k_strcmp(argv[0], "ls")==0){ ls(argc, argv); } else if(k_strcmp(argv[0], "cat")==0){ cat(argc, argv); } else if(k_strcmp(argv[0], "rm")==0){ rm(argc, argv); } else if(k_strcmp(argv[0], "chmod")==0){ chmod(argc, argv); } else if(k_strcmp(argv[0], "te")==0){ te(argc, argv); } else if(k_strcmp(argv[0], "cp")==0){ cp(argc, argv); } else if(k_strcmp(argv[0], "diff")==0){ diff(argc, argv); } else if(k_strcmp(argv[0], "wc")==0){ wc(argc, argv); } else if(k_strcmp(argv[0], "su")==0){ su(argc, argv); } else if(k_strcmp(argv[0], "chown")==0){ chown(argc, argv); } else if(k_strcmp(argv[0], "echo")==0){ echo(argc, argv); } else if(k_strcmp(argv[0], "adduser")==0){ adduser(argc, argv); } else if(k_strcmp(argv[0], "deluser")==0){ deluser(argc, argv); } else if(k_strcmp(argv[0], "listus")==0){ listus(); } else if(k_strcmp(argv[0], "passwd")==0){ passwd(argc, argv); } else if(k_strcmp(argv[0], "mkdir")==0){ mkdir(argc, argv); } else if(k_strcmp(argv[0], "rmdir")==0){ rmdir(argc, argv); } else if(k_strcmp(argv[0], "cd")==0){ cd(argc, argv); } else if(k_strcmp(argv[0], "pwd")==0){ pwd(argc, argv); } else if(k_strcmp(argv[0], "mv")==0){ mv(argc, argv); } // else check files else { printToConsole("Error: Unknown command '"); printToConsole(argv[0]); printToConsole("'\n"); } return 0; }
int main(int argc, char **argv) { int r; Srv s = {}; s.wal.filesz = Filesizedef; struct job list = {}; progname = argv[0]; opts(argc, argv, &s.wal); if (verbose) { printf("pid %d\n", getpid()); } r = make_server_socket(host_addr, port); if (r == -1) twarnx("make_server_socket()"), exit(111); s.sock.fd = r; prot_init(); if (user) su(user); set_sig_handlers(); if (s.wal.use) { // We want to make sure that only one beanstalkd tries // to use the wal directory at a time. So acquire a lock // now and never release it. if (!waldirlock(&s.wal)) { twarnx("failed to lock wal dir %s", s.wal.dir); exit(10); } list.prev = list.next = &list; walinit(&s.wal, &list); prot_replay(&s, &list); } srv(&s); return 0; }
int main() { long long int a; char ch[1024], c; do { printf("请输入一个自然数:"); while (!scanf("%lld", &a) || a < 0) { gets(ch); printf("错误!输入一个非负整数:"); } if (a <= 1) printf("0和1既不是素数也不是合数。\n"); else su(a); printf("\n输入y继续查询,否则结束...\n"); getchar(); c = getchar(); } while (c == 'y'); printf("\n--END--"); return 0; }
bool mail_identity::update_db() { db_cnx db; try { sql_stream ss("SELECT 1 FROM identities WHERE email_addr=:p1", db); ss << m_orig_email_addr; if (!ss.eos()) { sql_stream su("UPDATE identities SET email_addr=:p1, username=:p2, xface=:p3, signature=:p4, restricted=:r, root_tag=nullif(:t,0) WHERE email_addr=:p5", db); su << m_email_addr << m_name << m_xface << m_signature << m_is_restricted << m_root_tag_id; su << m_orig_email_addr; } else { sql_stream si("INSERT INTO identities(email_addr,username,xface,signature,restricted,root_tag) VALUES (:p1,:p2,:p3,:p4,:p5,nullif(:p6,0))", db); si << m_email_addr << m_name << m_xface << m_signature << m_is_restricted << m_root_tag_id; } m_orig_email_addr = m_email_addr; } catch(db_excpt& p) { DBEXCPT(p); return false; } return true; }
void image_widget::paint(graphics_context& aGraphicsContext) const { if (iTexture.is_empty()) return; scoped_units su(*this, UnitsPixels); rect placementRect(point{}, iTexture.extents()); if (iAspectRatio == aspect_ratio::Stretch) { placementRect.cx = client_rect().width(); placementRect.cy = client_rect().height(); } else if (placementRect.width() >= placementRect.height()) { switch (iAspectRatio) { case aspect_ratio::Ignore: if (placementRect.width() > client_rect().width()) placementRect.cx = client_rect().width(); if (placementRect.height() > client_rect().height()) placementRect.cy = client_rect().height(); break; case aspect_ratio::Keep: if (placementRect.width() > client_rect().width()) { placementRect.cx = client_rect().width(); placementRect.cy = placementRect.cx * iTexture.extents().cy / iTexture.extents().cx; } if (placementRect.height() > client_rect().height()) { placementRect.cy = client_rect().height(); placementRect.cx = placementRect.cy * iTexture.extents().cx / iTexture.extents().cy; } break; case aspect_ratio::KeepExpanding: if (placementRect.height() > client_rect().height()) { placementRect.cy = client_rect().height(); placementRect.cx = placementRect.cy * iTexture.extents().cx / iTexture.extents().cy; } break; } } else { switch (iAspectRatio) { case aspect_ratio::Ignore: if (placementRect.width() > client_rect().width()) placementRect.cx = client_rect().width(); if (placementRect.height() > client_rect().height()) placementRect.cy = client_rect().height(); break; case aspect_ratio::Keep: if (placementRect.height() > client_rect().height()) { placementRect.cy = client_rect().height(); placementRect.cx = placementRect.cy * iTexture.extents().cx / iTexture.extents().cy; } if (placementRect.width() > client_rect().width()) { placementRect.cx = client_rect().width(); placementRect.cy = placementRect.cx * iTexture.extents().cy / iTexture.extents().cx; } break; case aspect_ratio::KeepExpanding: if (placementRect.width() > client_rect().width()) { placementRect.cx = client_rect().width(); placementRect.cy = placementRect.cx * iTexture.extents().cy / iTexture.extents().cx; } break; } } switch (iPlacement) { case cardinal_placement::NorthWest: placementRect.position() = point{}; break; case cardinal_placement::North: placementRect.position() = point{ std::floor((client_rect().width() - placementRect.cx) / 2.0), 0.0 }; break; case cardinal_placement::NorthEast: placementRect.position() = point{ client_rect().width() - placementRect.width(), 0.0 }; break; case cardinal_placement::West: placementRect.position() = point{ 0.0, std::floor((client_rect().height() - placementRect.cy) / 2.0) }; break; case cardinal_placement::Centre: placementRect.position() = point{ std::floor((client_rect().width() - placementRect.cx) / 2.0), std::floor((client_rect().height() - placementRect.cy) / 2.0) }; break; case cardinal_placement::East: placementRect.position() = point{ client_rect().width() - placementRect.width(), std::floor((client_rect().height() - placementRect.cy) / 2.0) }; break; case cardinal_placement::SouthWest: placementRect.position() = point{ 0.0, client_rect().height() - placementRect.height() }; break; case cardinal_placement::South: placementRect.position() = point{ std::floor((client_rect().width() - placementRect.cx) / 2.0), client_rect().height() - placementRect.height() }; break; case cardinal_placement::SouthEast: placementRect.position() = point{ client_rect().width() - placementRect.width(), client_rect().height() - placementRect.height() }; break; } if (effectively_disabled()) aGraphicsContext.set_monochrome(true); aGraphicsContext.draw_texture(placementRect, iTexture, effectively_disabled() ? colour(0xFF, 0xFF, 0xFF, 0x80) : optional_colour()); aGraphicsContext.set_monochrome(false); }
void yhsurface(double xyzr[MAXATOMS][XYZRWIDTH], double* ljepsilon, size_t natm, double tott, double dt, Mat<>& phitotx, Mat<>& surfu, int iloop, double& area, double& volume, double& attint, double alpha, int iadi, int igfin) { size_t nx = comdata.nx, ny = comdata.ny, nz = comdata.nz; double xl = comdata.xleft, yl = comdata.yleft, zl = comdata.zleft; std::valarray<double> atom_x(natm), atom_y(natm), atom_z(natm), atom_r(natm); for (size_t i = 0; i < natm; ++i) { atom_x[i] = xyzr[i][0]; atom_y[i] = xyzr[i][1]; atom_z[i] = xyzr[i][2]; atom_r[i] = xyzr[i][3]; } Mat<> su(surfu), g(surfu); initial(xl, yl, zl, natm, atom_x,atom_y, atom_z, atom_r, g, su); if (iloop > 1 && igfin == 1) su = surfu; double rcfactor = (lj.ffmodel == 1) ? 1.0 : pow(2.0, 1.0/6.0); std::valarray<double> sigma(atom_r); std::valarray<double> seta12(natm), seta6(natm), epsilon(natm); if (lj.ffmodel == 1) { for (size_t i = 0; i < natm; ++i) { sigma[i] = atom_r[i] + lj.sigmas; if (lj.vdwdispersion != 0) { double se = sigma[i]/(atom_r[i] + lj.prob); epsilon[i] = pow( pow(se, 12.0) - 2.0*pow(se, 6.0) , -1.0); } seta12[i] = lj.iosetar*lj.vdwdispersion*epsilon[i]; seta6[i] = 2.0*lj.iosetaa*lj.vdwdispersion*epsilon[i]; } } else { for (size_t i = 0; i < natm; ++i) { sigma[i] = sqrt(4.0*atom_r[i]*lj.sigmas); if (lj.vdwdispersion != 0) { epsilon[i] = sqrt(ljepsilon[i]*lj.epsilonw); seta12[i] = 4.0*epsilon[i]; seta6[i] = 4.0*epsilon[i]; } } } Mat<> potr(nx,ny,nz), pota(nx,ny,nz); potIntegral(rcfactor, natm, atom_x, atom_y, atom_z, seta12, seta6, epsilon, sigma, g, potr, pota); if (lj.iwca == 1) potr = 0; for (size_t i = 0; i < phitotx.size(); ++i) { phitotx[i] = -lj.conms - phitotx[i] + lj.roro*(potr[i] + pota[i]); } if (iadi == 0 || iloop > 1) { int nt = ceil(tott/dt) + 1; upwinding(dt, nt, g, su, phitotx); } else { std::cerr << "ADI not implemented..." << std::endl; exit(1); } if (iloop > 1) { for (size_t i = 0; i < surfu.size(); ++i) { surfu[i] = surfu[i]*alpha + su[i]*(1.0 - alpha); } su = surfu; } else { surfu = su; } volume = volumeIntegration(su); std::cout << "volume = " << volume << std::endl; Mat<> fintegr(nx,ny,nz); double dx = comdata.deltax, dy = comdata.deltay, dz = comdata.deltaz; for (size_t x = 2; x < nx; ++x) { for (size_t y = 2; y < ny; ++y) { for (size_t z = 2; z < nz; ++z) { double sux = su(x+1,y,z) - su(x-1,y,z); double suy = su(x,y+1,z) - su(x,y-1,z); double suz = su(x,y,z+1) - su(x,y,z-1); fintegr(x,y,z) = sqrt(dot(sux/(2.0*dx), suy/(2.0*dy), suz/(2.0*dz))); } } } area = volumeIntegration(fintegr); std::cout << "area = " << area << std::endl; potIntegral(rcfactor, natm, atom_x, atom_y, atom_z, seta12, seta6, epsilon, sigma, g, potr, pota); if (lj.iwca == 1) { for (size_t i = 0; i < fintegr.size(); ++i) { fintegr[i] = pota[i]*(1e3 - su[i]); } } else { for (size_t i = 0; i < fintegr.size(); ++i) { fintegr[i] = (pota[i] + potr[i])*(1e3 - su[i]); } } attint = volumeIntegration(fintegr); std::cout << "attint = " << attint << std::endl; }
double ScrSpinBox::valueFromText ( const QString & text ) const { //Get all our units strings //CB: Replaced by new CommonStrings versions // QString trStrPT=unitGetStrFromIndex(SC_PT); // QString trStrMM=unitGetStrFromIndex(SC_MM); // QString trStrIN=unitGetStrFromIndex(SC_IN); // QString trStrP =unitGetStrFromIndex(SC_P); // QString trStrCM=unitGetStrFromIndex(SC_CM); // QString trStrC =unitGetStrFromIndex(SC_C); // QString strPT=unitGetUntranslatedStrFromIndex(SC_PT); // QString strMM=unitGetUntranslatedStrFromIndex(SC_MM); // QString strIN=unitGetUntranslatedStrFromIndex(SC_IN); // QString strP =unitGetUntranslatedStrFromIndex(SC_P); // QString strCM=unitGetUntranslatedStrFromIndex(SC_CM); // QString strC =unitGetUntranslatedStrFromIndex(SC_C); //Get a copy for use QString ts = text.trimmed(); //Find our suffix QString su(unitGetStrFromIndex(m_unitIndex)); //Replace our pica XpY.Z format with (X*12+Y.Z)pt if (CommonStrings::trStrP.localeAwareCompare(CommonStrings::strP)!=0) ts.replace(CommonStrings::trStrP, CommonStrings::strP); QRegExp rxP; if (m_unitIndex==SC_PICAS) rxP.setPattern("\\b(\\d+)"+CommonStrings::strP+"?(\\d+\\.?\\d*)?\\b"); else rxP.setPattern("\\b(\\d+)"+CommonStrings::strP+"(\\d+\\.?\\d*)?\\b"); int posP = 0; while (posP >= 0) { // qDebug() << "#"; posP = rxP.indexIn(ts, posP); if (posP >= 0) { // qDebug() << rxP.cap(1); // qDebug() << rxP.cap(2); QString replacement = QString("%1%2").arg(rxP.cap(1).toDouble()*(static_cast<double>(unitGetBaseFromIndex(SC_PICAS))) + rxP.cap(2).toDouble()).arg(CommonStrings::strPT); ts.replace(posP, rxP.cap(0).length(), replacement); // qDebug() << ts; } } // qDebug() << "##" << ts; ts.replace(",", "."); ts.replace("%", ""); ts.replace("°", ""); ts.replace(FinishTag, ""); ts = ts.trimmed(); if (ts.endsWith(su)) ts = ts.left(ts.length()-su.length()); int pos = ts.length(); while (pos > 0) { pos = ts.lastIndexOf(".", pos); if (pos >= 0) { if (pos < static_cast<int>(ts.length())) { if (!ts[pos+1].isDigit()) ts.insert(pos+1, "0 "); } pos--; } } if (ts.endsWith(".")) ts.append("0"); //CB FParser doesn't handle unicode well/at all. //So, instead of just getting the translated strings and //sticking them in as variables in the parser, if they are //not the same as the untranslated version, then we replace them. //We lose the ability for now to have some strings in languages //that might use them in variables. //To return to previous functionality, remove the follow replacement ifs, //S&R in the trStr* assignments trStrPT->strPT and remove the current str* ones. //IE, send the translated strings through to the regexp. if (CommonStrings::trStrPT.localeAwareCompare(CommonStrings::strPT)!=0) ts.replace(CommonStrings::trStrPT, CommonStrings::strPT); if (CommonStrings::trStrMM.localeAwareCompare(CommonStrings::strMM)!=0) ts.replace(CommonStrings::trStrMM, CommonStrings::strMM); if (CommonStrings::trStrIN.localeAwareCompare(CommonStrings::strIN)!=0) ts.replace(CommonStrings::trStrIN, CommonStrings::strIN); if (CommonStrings::trStrCM.localeAwareCompare(CommonStrings::strCM)!=0) ts.replace(CommonStrings::trStrCM, CommonStrings::strCM); if (CommonStrings::trStrC.localeAwareCompare(CommonStrings::trStrC)!=0) ts.replace(CommonStrings::trStrC, CommonStrings::strC); //Replace in our typed text all of the units strings with *unitstring QRegExp rx("\\b(\\d+)\\s*("+CommonStrings::strPT+"|"+CommonStrings::strMM+"|"+CommonStrings::strC+"|"+CommonStrings::strCM+"|"+CommonStrings::strIN+")\\b"); pos = 0; while (pos >= 0) { pos = rx.indexIn(ts, pos); if (pos >= 0) { QString replacement = rx.cap(1) + "*" + rx.cap(2); ts.replace(pos, rx.cap(0).length(), replacement); } } //Add in the fparser constants using our unit strings, and the conversion factors. FunctionParser fp; // setFPConstants(fp); fp.AddConstant(CommonStrings::strPT.toStdString(), value2value(1.0, SC_PT, m_unitIndex)); fp.AddConstant(CommonStrings::strMM.toStdString(), value2value(1.0, SC_MM, m_unitIndex)); fp.AddConstant(CommonStrings::strIN.toStdString(), value2value(1.0, SC_IN, m_unitIndex)); fp.AddConstant(CommonStrings::strP.toStdString(), value2value(1.0, SC_P, m_unitIndex)); fp.AddConstant(CommonStrings::strCM.toStdString(), value2value(1.0, SC_CM, m_unitIndex)); fp.AddConstant(CommonStrings::strC.toStdString(), value2value(1.0, SC_C, m_unitIndex)); fp.AddConstant("old", value()); if (m_constants) { QMap<QString, double>::ConstIterator itend = m_constants->constEnd(); QMap<QString, double>::ConstIterator it = m_constants->constBegin(); while(it != itend) { fp.AddConstant(it.key().toStdString(), it.value() * unitGetRatioFromIndex(m_unitIndex)); ++it; } } int ret = fp.Parse(ts.toStdString(), "", true); // qDebug() << "fp return =" << ret; if (ret >= 0) return 0; double erg = fp.Eval(NULL); // qDebug() << "fp value =" << erg; return erg; }
// caller must free() the result char *GetText(EditCtrl *w) { ScopedMem<WCHAR> su(GetTextW(w)); return str::conv::ToUtf8(su.Get()); }
void bin_install( char *package, char *gisbase, char *bins, char *pkg_short_name, int pkg_major, int pkg_minor, int pkg_revision, char *grass_version ) { char tmp[2048]; char dir[2048]; char install_cmd[2048]; char post_cmd[2048]; int error = stat( gisbase, &buf.st_dev ); struct stat buf; FILE *f; char *verstr; char *grass_major; char *grass_minor; char *grass_revision; int major, minor, revision; if ( error < 0 ) { print_error( -5, "installation directory invalid: %s\n", strerror( *(int*)(__errno_location( )) ) ); } sprintf( GINSTALL_DST, "GINSTALL_DST=%s", gisbase ); putenv( GINSTALL_DST ); sprintf( tmp, "%s/include", gisbase ); sprintf( GINSTALL_INC, "GINSTALL_INC=%s", tmp ); putenv( GINSTALL_INC ); sprintf( tmp, "%s/lib", gisbase ); sprintf( GINSTALL_LIB, "GINSTALL_LIB=%s", tmp ); putenv( GINSTALL_LIB ); sprintf( GEM_GRASS_DIR, "GEM_GRASS_DIR=%s", gisbase ); putenv( GEM_GRASS_DIR ); verstr = strdup( grass_version ); grass_major = strtok( verstr, "." ); grass_minor = strtok( 0, "." ); grass_revision = strtok( 0, "." ); major = strtol( grass_major, 0, 10 ); minor = strtol( grass_minor, 0, 10 ); revision = strtol( grass_revision, 0, 10 ); free( verstr ); atexit( &exit_tmp ); sprintf( dir, "%s/%s", basename( package ), bins ); error = chdir( dir ); if ( error < 0 ) { print_error( -2, "extension file binaries in '%s' not accessible: %s\n", package, strerror( *(int*)(__errno_location( )) ) ); } sprintf( GEM_EXT_NAME, "GEM_EXT_NAME=%s", pkg_short_name ); putenv( GEM_EXT_NAME ); sprintf( tmp, "%i.%i.%i", pkg_major, pkg_minor, pkg_revision ); sprintf( GEM_EXT_VERSION, "GEM_EXT_VERSION=%s", tmp ); putenv( GEM_EXT_VERSION ); dump_html( "../description", TMP_DESCR ); dump_html( "../info", TMP_INFO ); dump_html( "../depends", TMP_DEPS ); dump_html( "../bugs", TMP_BUGS ); dump_html( "../authors", TMP_AUTHORS ); sprintf( GEM_EXT_DESCR, "GEM_EXT_DESCR=%s", TMP_DESCR ); putenv( GEM_EXT_DESCR ); sprintf( GEM_EXT_INFO, "GEM_EXT_INFO=%s", TMP_INFO ); putenv( GEM_EXT_INFO ); sprintf( GEM_EXT_DEPS, "GEM_EXT_DEPS=%s", TMP_DEPS ); putenv( GEM_EXT_DEPS ); sprintf( GEM_EXT_BUGS, "GEM_EXT_BUGS=%s", TMP_BUGS ); putenv( GEM_EXT_BUGS ); sprintf( GEM_EXT_AUTHORS, "GEM_EXT_AUTHORS=%s", TMP_AUTHORS ); putenv( GEM_EXT_AUTHORS ); atexit( &exit_tmp ); check_dependencies( package, gisbase, grass_version ); fwrite( "Installing...", 1, 13, stdout ); f = (FILE*)fopen( "../uninstall", "r" ); if ( f == 0 ) { print_warning( "error checking for uninstall script: %s\n \t\t\t\tUninstalling this extension may leave orphaned files on your system", strerror( *(int*)(__errno_location( )) ) ); } else { if ( VERBOSE ) { sprintf( tmp, "cp -vf ../uninstall %s/etc/uninstall.%s ;", gisbase, pkg_short_name ); strcpy( UNINSTALL_CMD, tmp ); } else { sprintf( tmp, "cp -f ../uninstall %s/etc/uninstall.%s &> %s ;", gisbase, pkg_short_name, TMP_NULL ); strcpy( UNINSTALL_CMD, tmp ); } fclose( f ); } register_extension( gisbase, bins, pkg_short_name, pkg_major, pkg_minor, pkg_revision ); check_dependencies( package, gisbase, grass_version ); if ( major == 6 && minor <= 0 ) register_entries_gisman( pkg_short_name, gisbase ); register_entries_gisman2( pkg_short_name, gisbase ); register_html( pkg_short_name, gisbase, pkg_major, pkg_minor, pkg_revision ); if ( VERBOSE ) { fprintf( stdout, "Running '%s install':\n", MAKE_CMD ); sprintf( install_cmd, "bin/%s -f Makefile install ; \t\t\t\t\tcp -vf %s %s/etc/extensions.db ; chmod -v a+r %s/etc/extensions.db ;", MAKE_CMD, TMPDB, gisbase, gisbase ); } else sprintf( install_cmd, "bin/%s -f Makefile -s install &> %s ; \t\t\t\t\tcp -f %s %s/etc/extensions.db &> %s ; chmod a+r %s/etc/extensions.db &> %s ;", MAKE_CMD, TMP_NULL, TMPDB, gisbase, TMP_NULL, gisbase, TMP_NULL ); if ( VERBOSE ) memcpy( post_cmd, "sh ../post", 11 ); else sprintf( post_cmd, "sh ../post &> %s", TMP_NULL ); sprintf( tmp, "%s %s %s %s %s %s", install_cmd, UNINSTALL_CMD, GISMAN_CMD, GISMAN2_CMD, HTML_CMD, post_cmd ); su( gisbase, tmp ); print_done( ); return; }
void process(const char *fn) { FILE *fp; smk s; char outfile[256]; unsigned char b[4]; int i,j,k; unsigned long temp_u; /* all and video info */ unsigned long w, h, f; double usf; unsigned long total_frame_size; /* audio info */ unsigned char a_t, a_c[7], a_d[7]; unsigned long a_r[7]; unsigned char num_tracks = 0; unsigned char **audio_data[7]; unsigned long *audio_size[7]; unsigned long total_audio_size[7] = {0}; unsigned long total_total_audio_size = 0; unsigned char *pal,*frame; unsigned long cur_frame; printf("--------\nsmk2avi processing %s...\n",fn); /* open the smk file */ s = smk_open_file(fn,SMK_MODE_MEMORY); if (s == NULL) goto error; /* get some info about the file */ smk_info_all(s, NULL, &f, &usf); smk_info_video(s, &w, &h, NULL); smk_info_audio(s, &a_t, a_c, a_d, a_r); printf("\t\t\twidth: %u, height: %u, usec/frame: %lf, frames: %u\n",w,h,usf,f); total_frame_size = w * h * 3; /* make 2 passes through the file. first one is to pull all the audio tracks only. */ smk_enable_all(s,a_t); for (i = 0; i < 7; i ++) { if (a_t & (1 << i)) { audio_size[i] = malloc(f * sizeof(unsigned long)); audio_data[i] = malloc(f * sizeof(unsigned char*)); num_tracks ++; } else { audio_size[i] = NULL; audio_data[i] = NULL; } } printf("\tAudio processing frame: "); smk_first(s); for (cur_frame = 0; cur_frame < f; cur_frame ++) { printf("%u... ",cur_frame); fflush(stdout); for (i = 0; i < 7; i ++) { if (audio_size[i] != NULL) { audio_size[i][cur_frame] = smk_get_audio_size(s,i); total_audio_size[i] += smk_get_audio_size(s,i); total_total_audio_size += smk_get_audio_size(s,i); audio_data[i][cur_frame] = malloc(audio_size[i][cur_frame]); memcpy(audio_data[i][cur_frame],smk_get_audio(s,i),audio_size[i][cur_frame]); } } smk_next(s); } printf("done!\n"); smk_enable_all(s,SMK_VIDEO_TRACK); sprintf(outfile,"%s.avi",fn); fp = fopen(outfile,"wb"); printf("Writing AVI file...\n"); // riff header w("RIFF",4); temp_u = 4 + 4 + (8 + 64 + 124 + (num_tracks * 102)) + 8 + (4 + ((total_frame_size + 8) * f) + ( (num_tracks * 8) + total_total_audio_size)); lu(temp_u); w("AVI ",4); { // avi header list LIST; temp_u = 8 + 64 + 124 + (num_tracks * 102); lu(temp_u); w("hdrl",4); { // avi header w("avih",4); lu(56); { lu( (unsigned long)usf ); // microsec per frame temp_u = total_frame_size + total_total_audio_size; lu( temp_u ); // max bytes per sec lu( 1 ); // padding granularity lu( 0 ); // flags lu( f ); // total frames lu( 0 ); // initial frames temp_u = num_tracks + 1; lu( temp_u ); // streams temp_u = total_frame_size + total_total_audio_size; lu( temp_u ); // suggested buf size lu( w ); // width lu( h ); // height lu( 0 ); // reserved (0-3) lu( 0 ); lu( 0 ); lu( 0 ); } // stream list: video stream puts("Video stream header list"); LIST lu(116); w("strl",4); { w("strh",4); lu(56); { w("vids",4); // fourcc type w("DIB ",4); // fourcc handler lu(0); // flags lu(0); // priority + language lu(0); // init frames lu ((unsigned long)usf); // scale lu( 1000000 ); // rate lu(0); // start temp_u = (unsigned long) ((double)f * 100000.0 / usf); lu( temp_u ); // length (time in seconds ?) lu(total_frame_size); // suggested bufsize lu(-1); // quality lu(total_frame_size); // samplesize lu(0); // rcFrame su(w); su(h); // rcFrame: right, bottom } w("strf",4); lu(40); { lu(40); // size lu(w); // width lu(h); // height su(1); // planes su(24); // bpp lu(0); // compression lu(total_frame_size); // total image frame size lu(0); // xpels/meter lu(0); // ypels/meter lu(0); // colors used lu(0); // colors important } } // stream list: audio stream(s) for (i = 0; i < 7; i++) { if (audio_size[i] != NULL) { printf("-> Audio header %d, %dhz, %d bits, %d channels\n",i,a_r[i],a_d[i],a_c[i]); LIST lu(94); w("strl",4); w("strh",4); lu(56); { w("auds",4); // fourcc lu(0); // handler (pcm) lu(0); // flags lu(0); // priority + language lu(0); // initial frames lu( a_c[i]); // scale temp_u = a_r[i] * a_c[i]; lu( temp_u ); // framerate lu(0); // start temp_u = (unsigned long) ((double)f * 100000.0 / usf); lu( temp_u ); // time in seconds temp_u = total_audio_size[i] / a_c[i]; lu( temp_u ); // sugg. buf size lu(-1); // quality temp_u = total_audio_size[i]; lu(temp_u); // sample size lu(0); // rect ?? lu(0); // rect ?? } w("strf",4); lu(18); { su(1); // format su(a_c[i]); // channels lu(a_r[i]); // samples/sec temp_u = a_c[i] * a_r[i] * (a_d[i] / 8); // avg bytes/sec lu(temp_u); temp_u = a_c[i] * (a_d[i] / 8); // avg bytes/sec su(temp_u); su(a_d[i]); su(0); } } } } smk_first(s); printf("\tVideo processing frame:\n"); // movie data LIST temp_u = 4 + ((total_frame_size + 8) * f) + ( (num_tracks * 8) + total_total_audio_size); lu(temp_u); w("movi",4); for (i = 0; i < f; i ++) { w("00db",4); lu(total_frame_size); frame = smk_get_video(s); pal = smk_get_palette(s); if (frame == NULL || pal == NULL) goto error; for (j = h - 1; j >= 0; j--) { for (k = 0; k < w; k++) { w(&pal[frame[(j * w) + k] * 3 + 2],1); w(&pal[frame[(j * w) + k] * 3 + 1],1); w(&pal[frame[(j * w) + k] * 3],1); } } printf("%u...",i); fflush(stdout); smk_next(s); } printf("done!\n"); k = 0; for (i = 0; i < 7; i++) { if (audio_size[i] != NULL) { k ++; sprintf(b,"%02uwb",k); w(b,4); temp_u = total_audio_size[i]; lu(temp_u); for (j = 0; j < f; j++) { w(audio_data[i][j],audio_size[i][j]); } } } } fclose(fp); smk_close(s); printf("done.\n--------\n"); return; error: fclose(fp); smk_close(s); printf("!!HAD ERRORS!!\n--------\n"); return; }
void uninstall( char *package, char *pkg_short_name, char *gisbase, char *grass_version ) { char tmp[2048]; char script[2048]; int error; struct stat buf; int no_script; char *verstr; char *grass_major; char *grass_minor; char *grass_revision; int major, minor, revision; fwrite( "Un-installing...", 1, 16, stdout ); sprintf( UNINSTALL_BASE, "UNINSTALL_BASE=%s", gisbase ); putenv( UNINSTALL_BASE ); verstr = strdup( grass_version ); grass_major = strtok( verstr, "." ); grass_minor = strtok( 0, "." ); grass_revision = strtok( 0, "." ); major = strtol( grass_major, 0, 10 ); minor = strtol( grass_minor, 0, 10 ); revision = strtol( grass_revision, 0, 10 ); free( verstr ); atexit( &exit_tmp ); deregister_extension( package, pkg_short_name, gisbase ); if ( major == 6 && minor <= 0 ) { error = deregister_entries_gisman( pkg_short_name, gisbase ); if ( error == -1 ) { print_warning( "GIS Manager menu entries could not be removed.\n" ); memcpy( GISMAN_CMD, "", 1 ); } if ( error == 0 ) { print_warning( "no entries found to remove from GIS Manager.\n" ); memcpy( GISMAN_CMD, "", 1 ); } } deregister_entries_gisman2( pkg_short_name, gisbase ); deregister_html( pkg_short_name, gisbase ); sprintf( script, "%s/etc/uninstall.%s", gisbase, pkg_short_name ); no_script = 0; error = stat( script, &buf.st_dev ); if ( error < 0 ) { print_warning( "no uninstall script available for this extension.\n \t\t\tUnneeded files may have been left on your system.\n" ); no_script = 1; } if ( no_script ) { print_warning( "error checking for uninstall script: %s\n \t\t\t\tUninstalling this extension may leave orphaned files on your system", strerror( *(int*)(__errno_location( )) ) ); } else if ( VERBOSE ) { sprintf( tmp, "sh %s ; rm -vf %s ; \t\t\t\t\t \t\trm -vrf %s/docs/extensions/%s ; rm -vf %s/etc/dm/gem-entries/%s ; \t\t\t\t\t\t\tcp -vf %s %s/etc/extensions.db ; chmod -v a+r %s/etc/extensions.db ;", script, script, gisbase, pkg_short_name, gisbase, pkg_short_name, TMPDB, gisbase, gisbase ); strcpy( UNINSTALL_CMD, tmp ); } else { sprintf( tmp, "sh %s &> %s ; rm -vf %s &> %s ; \t\t\t\t\t \t\trm -vrf %s/docs/extensions/%s &> %s ; rm -vf %s/etc/dm/gem-entries/%s &> %s ; \t\t\t\t\t\t\tcp -vf %s %s/etc/extensions.db &> %s ; chmod -v a+r %s/etc/extensions.db &> %s ;", script, TMP_NULL, script, TMP_NULL, gisbase, pkg_short_name, TMP_NULL, gisbase, pkg_short_name, TMP_NULL, TMPDB, gisbase, TMP_NULL, gisbase, TMP_NULL ); strcpy( UNINSTALL_CMD, tmp ); } sprintf( tmp, "%s %s %s", UNINSTALL_CMD, GISMAN_CMD, HTML_CMD ); su( gisbase, tmp ); print_done( ); return; }
void colour_picker_dialog::init() { scoped_units su(static_cast<framed_widget&>(*this), UnitsPixels); static const std::set<colour> sBasicColours { colour::AliceBlue, colour::AntiqueWhite, colour::Aquamarine, colour::Azure, colour::Beige, colour::Bisque, colour::Black, colour::BlanchedAlmond, colour::Blue, colour::BlueViolet, colour::Brown, colour::Burlywood, colour::CadetBlue, colour::Chartreuse, colour::Chocolate, colour::Coral, colour::CornflowerBlue, colour::Cornsilk, colour::Cyan, colour::DarkBlue, colour::DarkCyan, colour::DarkGoldenrod, colour::DarkGray, colour::DarkGreen, colour::DarkKhaki, colour::DarkMagenta, colour::DarkOliveGreen, colour::DarkOrange, colour::DarkOrchid, colour::DarkRed, colour::DarkSalmon, colour::DarkSeaGreen, colour::DarkSlateBlue, colour::DarkSlateGray, colour::DarkTurquoise, colour::DarkViolet, colour::DebianRed, colour::DeepPink, colour::DeepSkyBlue, colour::DimGray, colour::DodgerBlue, colour::Firebrick, colour::FloralWhite, colour::ForestGreen, colour::Gainsboro, colour::GhostWhite, colour::Gold, colour::Goldenrod, colour::Gray, colour::Green, colour::GreenYellow, colour::Honeydew, colour::HotPink, colour::IndianRed, colour::Ivory, colour::Khaki, colour::Lavender, colour::LavenderBlush, colour::LawnGreen, colour::LemonChiffon, colour::LightBlue, colour::LightCoral, colour::LightCyan, colour::LightGoldenrod, colour::LightGoldenrodYellow, colour::LightGray, colour::LightGreen, colour::LightPink, colour::LightSalmon, colour::LightSeaGreen, colour::LightSkyBlue, colour::LightSlateBlue, colour::LightSlateGray, colour::LightSteelBlue, colour::LightYellow, colour::LimeGreen, colour::Linen, colour::Magenta, colour::Maroon, colour::MediumAquamarine, colour::MediumBlue, colour::MediumOrchid, colour::MediumPurple, colour::MediumSeaGreen, colour::MediumSlateBlue, colour::MediumSpringGreen, colour::MediumTurquoise, colour::MediumVioletRed, colour::MidnightBlue, colour::MintCream, colour::MistyRose, colour::Moccasin, colour::NavajoWhite, colour::Navy, colour::NavyBlue, colour::OldLace, colour::OliveDrab, colour::Orange, colour::OrangeRed, colour::Orchid, colour::PaleGoldenrod, colour::PaleGreen, colour::PaleTurquoise, colour::PaleVioletRed, colour::PapayaWhip, colour::PeachPuff, colour::Peru, colour::Pink, colour::Plum, colour::PowderBlue, colour::Purple, colour::Red, colour::RosyBrown, colour::RoyalBlue, colour::SaddleBrown, colour::Salmon, colour::SandyBrown, colour::SeaGreen, colour::Seashell, colour::Sienna, colour::SkyBlue, colour::SlateBlue, colour::SlateGray, colour::Snow, colour::SpringGreen, colour::SteelBlue, colour::Tan, colour::Thistle, colour::Tomato, colour::Turquoise, colour::Violet, colour::VioletRed, colour::Wheat, colour::White, colour::WhiteSmoke, colour::Yellow, colour::YellowGreen }; set_margins(neogfx::margins{16.0}); iLayout.set_margins(neogfx::margins{}); iLayout.set_spacing(16.0); iLayout2.set_margins(neogfx::margins{}); iLayout2.set_spacing(16.0); iRightLayout.set_spacing(16.0); iRightTopLayout.set_spacing(16.0); iRightBottomLayout.set_spacing(8.0); iChannelLayout.set_spacing(8.0); iH.first.label().text().set_text("&Hue:"); iH.second.set_size_policy(size_policy::Minimum); iH.second.text_box().set_hint("000000"); iH.second.set_minimum(0); iH.second.set_maximum(360); iH.second.set_step(1); iS.first.label().text().set_text("&Sat:"); iS.second.set_size_policy(size_policy::Minimum); iS.second.text_box().set_hint("000000"); iS.second.set_minimum(0); iS.second.set_maximum(100); iS.second.set_step(1); iV.first.label().text().set_text("&Val:"); iV.second.set_size_policy(size_policy::Minimum); iV.second.text_box().set_hint("000000"); iV.second.set_minimum(0); iV.second.set_maximum(100); iV.second.set_step(1); iR.first.label().text().set_text("&Red:"); iR.second.set_size_policy(size_policy::Minimum); iR.second.text_box().set_hint("000000"); iR.second.set_minimum(0); iR.second.set_maximum(255); iR.second.set_step(1); iG.first.label().text().set_text("&Green:"); iG.second.set_size_policy(size_policy::Minimum); iG.second.text_box().set_hint("000000"); iG.second.set_minimum(0); iG.second.set_maximum(255); iG.second.set_step(1); iB.first.label().text().set_text("&Blue:"); iB.second.set_size_policy(size_policy::Minimum); iB.second.text_box().set_hint("000000"); iB.second.set_minimum(0); iB.second.set_maximum(255); iB.second.set_step(1); iA.first.label().text().set_text("&Alpha:"); iA.second.set_size_policy(size_policy::Minimum); iA.second.text_box().set_hint("000000"); iA.second.set_minimum(0); iA.second.set_maximum(255); iA.second.set_step(1); iRgb.first.text().set_text("&#:"); iRgb.second.set_size_policy(size_policy::Minimum); iRgb.second.set_hint("000000"); iChannelLayout.set_dimensions(4, 4); iChannelLayout.add_item(iH.first); iChannelLayout.add_item(iH.second); iChannelLayout.add_item(iR.first); iChannelLayout.add_item(iR.second); iChannelLayout.add_item(iS.first); iChannelLayout.add_item(iS.second); iChannelLayout.add_item(iG.first); iChannelLayout.add_item(iG.second); iChannelLayout.add_item(iV.first); iChannelLayout.add_item(iV.second); iChannelLayout.add_item(iB.first); iChannelLayout.add_item(iB.second); iChannelLayout.add_item(iRgb.first); iChannelLayout.add_item(iRgb.second); iChannelLayout.add_item(iA.first); iChannelLayout.add_item(iA.second); iBasicColoursLayout.set_dimensions(12, 12); for (auto const& basicColour : sBasicColours) iBasicColoursLayout.add_item(std::make_shared<colour_box>(*this, basicColour)); iCustomColoursLayout.set_dimensions(2, 12); for (uint32_t i = 0; i < 24; ++i) iCustomColoursLayout.add_item(std::make_shared<colour_box>(*this, colour::White)); button_box().add_button(dialog_button_box::Ok); button_box().add_button(dialog_button_box::Cancel); resize(minimum_size()); rect desktopRect{ app::instance().surface_manager().desktop_rect(surface()) }; move_surface((desktopRect.extents() - surface_size()) / 2.0); }
//------------------------------------------------------------------------------ //! void ParametricPatch::evalCubic( const Vec2f& uv, Vec3f& pos, Vec3f& normal ) const { float um1 = (1.0f-uv.x); float um2 = um1*um1; float um3 = um2*um1; float u1 = uv.x; float u2 = u1*u1; float u3 = u2*u1; float vm1 = (1.0f-uv.y); float vm2 = vm1*vm1; float vm3 = vm2*vm1; float v1 = uv.y; float v2 = v1*v1; float v3 = v2*v1; float uc[4]; uc[0] = um3; uc[1] = um2*u1*3.0f; uc[2] = um1*u2*3.0f; uc[3] = u3; float vc[4]; vc[0] = vm3; vc[1] = vm2*v1*3.0f; vc[2] = vm1*v2*3.0f; vc[3] = v3; float ud[4]; ud[0] = um2*-3.0f; ud[1] = um1*(3.0f-9.0f*u1); ud[2] = (6.0f-9.0f*u1)*u1; ud[3] = u2*3.0f; float vd[4]; vd[0] = vm2*-3.0f; vd[1] = vm1*(3.0f-9.0f*v1); vd[2] = (6.0f-9.0f*v1)*v1; vd[3] = v2*3.0f; Vec3f p(0.0f); Vec3f su(0.0f); Vec3f sv(0.0f); const Vec3f* b = _b; for( uint j = 0; j < 4; ++j ) { Vec3f cp(0.0f); Vec3f csu(0.0f); for( uint i = 0; i < 4; ++i, ++b ) { cp += (*b)*(uc[i]); csu += (*b)*(ud[i]); } p += cp*vc[j]; su += csu*vc[j]; sv += cp*vd[j]; } pos = p; // Normal computation. Vec3f dir = su.cross( sv ); float len = dir.length(); // FIXME: should have a better more general solution. if( len < 1e-5 ) { normal = (_b[10]-_b[15]).cross( su ).getNormalized(); } else { normal = dir / len; } }