void applyTransforms(struct trans *tlist, struct GENode *glist) { struct trans *ptl = tlist; struct GENode *pgl = NULL; struct transMatrix m, aux; struct homoCoord start; struct homoCoord end; while(NULL != ptl) { pgl = glist; while(NULL != pgl) { switch(pgl->el.type) { case LINE: initHomoVector(&start, pgl->el.data.line.st.x, pgl->el.data.line.st.y); initHomoVector(&end, pgl->el.data.line.en.x, pgl->el.data.line.en.y); break; default: break; } switch(ptl->tType) { case TRANSLATION: initTranslation(&m, ptl->data.t.tx, ptl->data.t.ty); break; case SCALING: initScale(&m, ptl->data.s.sx, ptl->data.s.sy); if (!(ptl->data.s.px == 0 && ptl->data.s.py == 0)) { initTranslation(&aux, -1*ptl->data.s.px, -1*ptl->data.s.py); matrixProduct(&m, m, aux); initTranslation(&aux, ptl->data.s.px, ptl->data.s.py); matrixProduct(&m, m, aux); } break; case ROTATION: initRotation(&m, ptl->data.r.u); if (!(ptl->data.s.px == 0 && ptl->data.s.py == 0)) { initTranslation(&aux, -1*ptl->data.r.px, -1*ptl->data.r.py); matrixProduct(&m, m, aux); initTranslation(&aux, ptl->data.s.px, ptl->data.s.py); matrixProduct(&m, m, aux); } break; default: break; } matrixVectorProduct(&start, m, start); matrixVectorProduct(&end, m, end); twoDCoord(&pgl->el.data.line.st, start); twoDCoord(&pgl->el.data.line.en, end); pgl = pgl->next; } ptl = ptl->next; } }
UiManager::UiManager(QObject *parent) : QObject(parent),mView(0),mThumbTask(new ThumbTask),mThumbsCount(0) ,mSearchInput(0),mGoogleSearcher(0),mSearchImageIndex(0) { initTranslation(); score = new Score(); connect(mThumbTask->watcher(), SIGNAL(resultReadyAt(int)), this, SLOT(updateThumbItemAt(int))); connect(mThumbTask->watcher(), SIGNAL(finished()), this, SLOT(updateDisplayedThumbList())); }
static inline ovrMatrix4f posefToMatrix4f(const ovrPosef pose) { ovrMatrix4f orientation = quatfToMatrix4f(pose.Orientation); ovrMatrix4f translation = initTranslation(pose.Position); translation.M[0][3] = -translation.M[0][3]; translation.M[1][3] = -translation.M[1][3]; translation.M[2][3] = -translation.M[2][3]; return matrix4fMul(translation, orientation); }
int main(int argc, char *argv[]) { /* Disable rwx memory. This will also ensure full PAX/Grsecurity protections. */ qputenv("QV4_FORCE_INTERPRETER", "1"); qputenv("QT_ENABLE_REGEXP_JIT", "0"); QApplication a(argc, argv); a.setApplicationVersion(QLatin1String("1.1.2")); a.setOrganizationName(QStringLiteral("Ricochet")); #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) a.setWindowIcon(QIcon(QStringLiteral(":/icons/ricochet.svg"))); #endif QScopedPointer<SettingsFile> settings(new SettingsFile); SettingsObject::setDefaultFile(settings.data()); QString error; QLockFile *lock = 0; if (!initSettings(settings.data(), &lock, error)) { QMessageBox::critical(0, qApp->translate("Main", "Ricochet Error"), error); return 1; } QScopedPointer<QLockFile> lockFile(lock); initTranslation(); /* Initialize OpenSSL's allocator */ CRYPTO_malloc_init(); /* Seed the OpenSSL RNG */ if (!SecureRNG::seed()) qFatal("Failed to initialize RNG"); qsrand(SecureRNG::randomInt(UINT_MAX)); /* Tor control manager */ Tor::TorManager *torManager = Tor::TorManager::instance(); torManager->setDataDirectory(QFileInfo(settings->filePath()).path() + QStringLiteral("/tor/")); torControl = torManager->control(); torManager->start(); /* Identities */ identityManager = new IdentityManager; QScopedPointer<IdentityManager> scopedIdentityManager(identityManager); /* Window */ QScopedPointer<MainWindow> w(new MainWindow); if (!w->showUI()) return 1; return a.exec(); }
void NAMESPACE::Trackball::buttonPressed(uint button, uint x, uint y) { if (button == LIBSL_LEFT_BUTTON) { m_Status = m_Status | ROTATING; initRotation(x, y); } else if (button == LIBSL_MIDDLE_BUTTON) { m_Status = m_Status | ZOOMING; initZoom(x, y); } else if (button == LIBSL_RIGHT_BUTTON) { m_Status = m_Status | TRANSLATING; initTranslation(x, y); } }
void Dump::dumpRsol(ScalarField nbound, string fname) { //Compute normalization factor for the partition: int nAtomsTot = 0; for(const auto& sp: e->iInfo.species) nAtomsTot += sp->atpos.size(); const double nFloor = 1e-5/nAtomsTot; //lower cap on densities to prevent Nyquist noise in low density regions ScalarField nAtomicTot; for(const auto& sp: e->iInfo.species) { RadialFunctionG nRadial; logSuspend(); sp->getAtom_nRadial(0,0, nRadial, true); logResume(); for(unsigned atom=0; atom<sp->atpos.size(); atom++) { ScalarField nAtomic = radialFunction(e->gInfo, nRadial, sp->atpos[atom]); double nMin, nMax; callPref(eblas_capMinMax)(e->gInfo.nr, nAtomic->dataPref(), nMin, nMax, nFloor); nAtomicTot += nAtomic; } } ScalarField nboundByAtomic = (nbound*nbound) * inv(nAtomicTot); ScalarField rInv0(ScalarFieldData::alloc(e->gInfo)); { logSuspend(); WignerSeitz ws(e->gInfo.R); logResume(); threadLaunch(set_rInv, e->gInfo.nr, e->gInfo.S, e->gInfo.RTR, &ws, rInv0->data()); } //Compute bound charge 1/r and 1/r^2 expectation values weighted by atom-density partition: FILE* fp = fopen(fname.c_str(), "w"); fprintf(fp, "#Species rMean +/- rSigma [bohrs] (rMean +/- rSigma [Angstrom]) sqrt(Int|nbound^2|) in partition\n"); for(const auto& sp: e->iInfo.species) { RadialFunctionG nRadial; logSuspend(); sp->getAtom_nRadial(0,0, nRadial, true); logResume(); for(unsigned atom=0; atom<sp->atpos.size(); atom++) { ScalarField w = radialFunction(e->gInfo, nRadial, sp->atpos[atom]) * nboundByAtomic; //Get r centered at current atom: ScalarFieldTilde trans; nullToZero(trans, e->gInfo); initTranslation(trans, e->gInfo.R*sp->atpos[atom]); ScalarField rInv = I(trans * J(rInv0), true); //Compute moments: double wNorm = integral(w); double rInvMean = integral(w * rInv) / wNorm; double rInvSqMean = integral(w * rInv * rInv) / wNorm; double rInvSigma = sqrt(rInvSqMean - rInvMean*rInvMean); double rMean = 1./rInvMean; double rSigma = rInvSigma / (rInvMean*rInvMean); //Print stats: fprintf(fp, "Rsol %s %.2lf +/- %.2lf ( %.2lf +/- %.2lf A ) Qrms: %.1le\n", sp->name.c_str(), rMean, rSigma, rMean/Angstrom, rSigma/Angstrom, sqrt(wNorm)); } } fclose(fp); }
/** * Process the mouse press event. * Send out movement initialization signals. */ void InputController3DMove::mousePressEvent(QMouseEvent *event) { if (event->buttons() & Qt::MidButton) { emit initZoom(event->x(),event->y()); m_isButtonPressed=true; } else if (event->buttons() & Qt::LeftButton) { emit initRotation(event->x(),event->y()); m_isButtonPressed=true; } else if(event->buttons() & Qt::RightButton) { emit initTranslation(event->x(),event->y()); m_isButtonPressed=true; } }
int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setApplicationVersion(QLatin1String("1.1.0")); a.setOrganizationName(QStringLiteral("Ricochet")); initTranslation(); #if !defined(Q_OS_WIN) && !defined(Q_OS_MAC) a.setWindowIcon(QIcon(QStringLiteral(":/icons/ricochet.svg"))); #endif QScopedPointer<SettingsFile> settings(new SettingsFile); SettingsObject::setDefaultFile(settings.data()); QString error; QLockFile *lock = 0; if (!initSettings(settings.data(), &lock, error)) { QMessageBox::critical(0, qApp->translate("Main", "Ricochet Error"), error); return 1; } QScopedPointer<QLockFile> lockFile(lock); /* Initialize OpenSSL's allocator */ CRYPTO_malloc_init(); /* Seed the OpenSSL RNG */ if (!SecureRNG::seed()) qFatal("Failed to initialize RNG"); qsrand(SecureRNG::randomInt(UINT_MAX)); /* Tor control manager */ Tor::TorManager *torManager = Tor::TorManager::instance(); torManager->setDataDirectory(QFileInfo(settings->filePath()).path() + QStringLiteral("/tor/")); torControl = torManager->control(); torManager->start(); /* Identities */ identityManager = new IdentityManager; /* Window */ MainWindow w; return a.exec(); }
BaseMainPage::BaseMainPage(QString strTitle, QWidget *parent) : QMainWindow(parent) , m_strTitle(strTitle) , m_nPageIndex(STARTUPPAGE_INDEX) , m_pCtrlPage(0) ,adminFlag(false) ,m_bNavigatorMode(true) ,m_nNavigatorCnt(NAVIGATORCNT) ,m_nCurrentNavigator(0) { ui.setupUi(this); g_pMainWindow = this; initShotCut(); initMachine(); initTranslation(); initTimer(); initPage(); backToPage(); }
Application::Application(int& _argc, char** _argv) : QApplication(_argc, _argv), m_applicationManager(0) { // // Настроим информацию о приложении // setOrganizationName("DimkaNovikov labs."); setOrganizationDomain("dimkanovikov.pro"); setApplicationName("Scenarist"); setApplicationVersion("0.6.0 beta 6"); // // Настроим стиль отображения внешнего вида приложения // setStyle(QStyleFactory::create("Fusion")); // // Загрузим шрифты в базу шрифтов программы, если их там ещё нет // QFontDatabase fontDatabase; fontDatabase.addApplicationFont(":/Fonts/Courier New"); fontDatabase.addApplicationFont(":/Fonts/Courier Prime"); fontDatabase.addApplicationFont(":/Fonts/Courier Prime Bold"); fontDatabase.addApplicationFont(":/Fonts/Courier Prime Italic"); fontDatabase.addApplicationFont(":/Fonts/Courier Prime Bold Italic"); // // Настроим перевод приложения // initTranslation(); // // Настроим таймер определения простоя приложения // m_idleTimer.setInterval(3000); connect(&m_idleTimer, &QTimer::timeout, [=] { if (m_applicationManager != 0) { postEvent(m_applicationManager, new QEvent(QEvent::User)); } }); m_idleTimer.start(); }