// Interpolate table (linearly) to some specific k: // x any y in physical units (to be divided by dx for indices) double XTable::interpolate(double x, double y, const Interpolant2d& interp) const { xdbg << "interpolating " << x << " " << y << " " << std::endl; x /= _dx; y /= _dx; int ixMin, ixMax, iyMin, iyMax; if ( interp.isExactAtNodes() && std::abs(x - std::floor(x+0.01)) < 10.*std::numeric_limits<double>::epsilon()) { // x coord lies right on integer value, no interpolation in x direction ixMin = ixMax = int(std::floor(x+0.01)); } else { ixMin = int(std::ceil(x-interp.xrange())); ixMax = int(std::floor(x+interp.xrange())); } ixMin = std::max(ixMin, -_N/2); ixMax = std::min(ixMax, _N/2-1); if (ixMin > ixMax) return 0.; if ( interp.isExactAtNodes() && std::abs(y - std::floor(y+0.01)) < 10.*std::numeric_limits<double>::epsilon()) { // y coord lies right on integer value, no interpolation in y direction iyMin = iyMax = int(std::floor(y+0.01)); } else { iyMin = int(std::ceil(y-interp.xrange())); iyMax = int(std::floor(y+interp.xrange())); } iyMin = std::max(iyMin, -_N/2); iyMax = std::min(iyMax, _N/2-1); if (iyMin > iyMax) return 0.; double sum = 0.; const InterpolantXY* ixy = dynamic_cast<const InterpolantXY*> (&interp); if (ixy) { // Interpolant is seperable // We have the opportunity to speed up the calculation by // re-using the sums over rows. So we will keep a // cache of them. if (x != _cacheX || ixy != _cacheInterp) { clearCache(); _cacheX = x; _cacheInterp = ixy; } else if (iyMax==iyMin && !_cache.empty()) { // Special case for interpolation on a single iy value: // See if we already have this row in cache: int index = iyMin - _cacheStartY; if (index < 0) index += _N; if (index < int(_cache.size())) // We have it! return _cache[index]; else // Desired row not in cache - kill cache, continue as normal. // (But don't clear xwt, since that's still good.) _cache.clear(); } // Build x factors for interpolant int nx = ixMax - ixMin + 1; // This is also cached if possible. It gets cleared when kx != cacheX above. if (_xwt.empty()) { _xwt.resize(nx); for (int i=0; i<nx; i++) _xwt[i] = ixy->xval1d(i+ixMin-x); } else { assert(int(_xwt.size()) == nx); } // cache always holds sequential y values (no wrap). Throw away // elements until we get to the one we need first std::deque<double>::iterator nextSaved = _cache.begin(); while (nextSaved != _cache.end() && _cacheStartY != iyMin) { _cache.pop_front(); _cacheStartY++; nextSaved = _cache.begin(); } for (int iy = iyMin; iy<=iyMax; iy++) { double sumy = 0.; if (nextSaved != _cache.end()) { // This row is cached sumy = *nextSaved; ++nextSaved; } else { // Need to compute a new row's sum const double* dptr = _array.get() + index(ixMin, iy); std::vector<double>::const_iterator xwt_it = _xwt.begin(); int count = nx; for(; count; --count) sumy += (*xwt_it++) * (*dptr++); assert(xwt_it == _xwt.end()); // Add to back of cache if (_cache.empty()) _cacheStartY = iy; _cache.push_back(sumy); nextSaved = _cache.end(); } sum += sumy * ixy->xval1d(iy-y); } } else { // Interpolant is not seperable, calculate weight at each point for (int iy = iyMin; iy<=iyMax; iy++) { const double* dptr = _array.get() + index(ixMin, iy); for (int ix = ixMin; ix<=ixMax; ++ix, ++dptr) sum += *dptr * interp.xval(ix-x, iy-y); } } return sum; }
void btGImpactCollisionAlgorithm::nihilize(btDispatcher* dispatcher) { clearCache(dispatcher); btActivatingCollisionAlgorithm::nihilize(dispatcher); }
void Territory::insert(Position pos) { allSquaresVec.push_back(pos); allSquares.insert(pos); clearCache(); }
LibraryScanner::LibraryScanner(QWidget* pParentWidget, TrackCollection* collection, UserSettingsPointer pConfig) : m_pCollection(collection), m_libraryHashDao(m_database), m_cueDao(m_database), m_playlistDao(m_database), m_crateDao(m_database), m_directoryDao(m_database), m_analysisDao(m_database, pConfig), m_trackDao(m_database, m_cueDao, m_playlistDao, m_crateDao, m_analysisDao, m_libraryHashDao, pConfig), m_stateSema(1), // only one transaction is possible at a time m_state(IDLE) { // Don't initialize m_database here, we need to do it in run() so the DB // conn is in the right thread. qDebug() << "Starting LibraryScanner thread."; // Move LibraryScanner to its own thread so that our signals/slots will // queue to our event loop. moveToThread(this); m_pool.moveToThread(this); unsigned static id = 0; // the id of this LibraryScanner, for debugging purposes setObjectName(QString("LibraryScanner %1").arg(++id)); m_pool.setMaxThreadCount(kScannerThreadPoolSize); // Listen to signals from our public methods (invoked by other threads) and // connect them to our slots to run the command on the scanner thread. connect(this, SIGNAL(startScan()), this, SLOT(slotStartScan())); // Force the GUI thread's TrackInfoObject cache to be cleared when a library // scan is finished, because we might have modified the database directly // when we detected moved files, and the TIOs corresponding to the moved // files would then have the wrong track location. if (collection != NULL) { // false only during test TrackDAO* dao = &(collection->getTrackDAO()); connect(this, SIGNAL(scanFinished()), dao, SLOT(clearCache())); connect(this, SIGNAL(trackAdded(TrackPointer)), dao, SLOT(databaseTrackAdded(TrackPointer))); connect(this, SIGNAL(tracksMoved(QSet<TrackId>, QSet<TrackId>)), dao, SLOT(databaseTracksMoved(QSet<TrackId>, QSet<TrackId>))); connect(this, SIGNAL(tracksChanged(QSet<TrackId>)), dao, SLOT(databaseTracksChanged(QSet<TrackId>))); } // Parented to pParentWidget so we don't need to delete it. LibraryScannerDlg* pProgress = new LibraryScannerDlg(pParentWidget); connect(this, SIGNAL(progressLoading(QString)), pProgress, SLOT(slotUpdate(QString))); connect(this, SIGNAL(progressHashing(QString)), pProgress, SLOT(slotUpdate(QString))); connect(this, SIGNAL(scanStarted()), pProgress, SLOT(slotScanStarted())); connect(this, SIGNAL(scanFinished()), pProgress, SLOT(slotScanFinished())); connect(pProgress, SIGNAL(scanCancelled()), this, SLOT(slotCancel())); connect(&m_trackDao, SIGNAL(progressVerifyTracksOutside(QString)), pProgress, SLOT(slotUpdate(QString))); connect(&m_trackDao, SIGNAL(progressCoverArt(QString)), pProgress, SLOT(slotUpdateCover(QString))); start(); }
void Territory::remove(Position pos) { removeElement(allSquaresVec, pos); allSquares.erase(pos); clearCache(); }
QgsAbstractGeometry* QgsGeometryCollection::geometryN( int n ) { clearCache(); return mGeometries.value( n ); }
GLES2StateCacheManagerImp::GLES2StateCacheManagerImp(void) { clearCache(); }
void FontManager::setDefaultGlyphLoadFlags(const Flags<FontFace::GlyphLoadFlags>& flags) { clearCache(); m_defaultLoadFlags = flags; }
AbstractDBCacheMap::~AbstractDBCacheMap() { clearCache(); }
void EntityDefinitionManager::updateCache() { clearCache(); for (EntityDefinition* definition : m_definitions) m_cache[definition->name()] = definition; }
void EntityDefinitionManager::clear() { clearCache(); clearGroups(); VectorUtils::clearAndDelete(m_definitions); }
btGImpactCollisionAlgorithm::~btGImpactCollisionAlgorithm() { clearCache(); }
KateSyntaxDocument::~KateSyntaxDocument() { // cleanup, else we have a memory leak! clearCache(); }
int close() { clearCache(); return 0; }
KGpgMe::~KGpgMe() { if (m_ctx) gpgme_release(m_ctx); clearCache(); }
/*! Destroys the image item. */ QDeclarativePaintedItem::~QDeclarativePaintedItem() { clearCache(); }
void QgsGeometryCollection::clear() { qDeleteAll( mGeometries ); mGeometries.clear(); clearCache(); //set bounding box invalid }
/*! \internal */ void QDeclarativePaintedItem::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QDeclarativePaintedItem); const QRect content = boundingRect().toRect(); if (content.width() <= 0 || content.height() <= 0) return; ++inpaint; const QTransform &x = p->deviceTransform(); QTransform xinv = x.inverted(); QRegion effectiveClip; QRegion sysClip = p->paintEngine()->systemClip(); if (xinv.type() <= QTransform::TxScale && sysClip.numRects() < 5) { // simple transform, region gets no more complicated... effectiveClip = xinv.map(sysClip); } else { // do not make complicated regions... effectiveClip = xinv.mapRect(sysClip.boundingRect()); } QRegion topaint = p->clipRegion(); if (topaint.isEmpty()) { if (effectiveClip.isEmpty()) topaint = QRect(0,0,p->device()->width(),p->device()->height()); else topaint = effectiveClip; } else if (!effectiveClip.isEmpty()) { topaint &= effectiveClip; } topaint &= content; QRegion uncached(content); p->setRenderHints(QPainter::SmoothPixmapTransform, d->smooth); int cachesize=0; for (int i=0; i<d->imagecache.count(); ++i) { QRect area = d->imagecache[i]->area; if (topaint.contains(area)) { QRectF target(area.x(), area.y(), area.width(), area.height()); if (!d->cachefrozen) { if (!d->imagecache[i]->dirty.isNull() && topaint.contains(d->imagecache[i]->dirty)) { #ifdef Q_WS_MAC bool oldSmooth = qt_applefontsmoothing_enabled; qt_applefontsmoothing_enabled = false; #endif QPainter qp(&d->imagecache[i]->image); #ifdef Q_WS_MAC qt_applefontsmoothing_enabled = oldSmooth; #endif qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache); qp.translate(-area.x(), -area.y()); qp.scale(d->contentsScale,d->contentsScale); QRect clip = d->imagecache[i]->dirty; QRect sclip(qFloor(clip.x()/d->contentsScale), qFloor(clip.y()/d->contentsScale), qCeil(clip.width()/d->contentsScale+clip.x()/d->contentsScale-qFloor(clip.x()/d->contentsScale)), qCeil(clip.height()/d->contentsScale+clip.y()/d->contentsScale-qFloor(clip.y()/d->contentsScale))); qp.setClipRect(sclip); if (d->fillColor.isValid()){ if(d->fillColor.alpha() < 255){ // ### Might not work outside of raster paintengine QPainter::CompositionMode prev = qp.compositionMode(); qp.setCompositionMode(QPainter::CompositionMode_Source); qp.fillRect(sclip,d->fillColor); qp.setCompositionMode(prev); }else{ qp.fillRect(sclip,d->fillColor); } } drawContents(&qp, sclip); d->imagecache[i]->dirty = QRect(); } } p->drawPixmap(target.toRect(), d->imagecache[i]->image); topaint -= area; d->imagecache[i]->age=0; } else { d->imagecache[i]->age++; } cachesize += area.width()*area.height(); uncached -= area; } if (!topaint.isEmpty()) { if (!d->cachefrozen) { // Find a sensible larger area, otherwise will paint lots of tiny images. QRect biggerrect = topaint.boundingRect().adjusted(-64,-64,128,128); cachesize += biggerrect.width() * biggerrect.height(); while (d->imagecache.count() && cachesize > d->max_imagecache_size) { int oldest=-1; int age=-1; for (int i=0; i<d->imagecache.count(); ++i) { int a = d->imagecache[i]->age; if (a > age) { oldest = i; age = a; } } cachesize -= d->imagecache[oldest]->area.width()*d->imagecache[oldest]->area.height(); uncached += d->imagecache[oldest]->area; delete d->imagecache.takeAt(oldest); } const QRegion bigger = QRegion(biggerrect) & uncached; const QVector<QRect> rects = bigger.rects(); for (int i = 0; i < rects.count(); ++i) { const QRect &r = rects.at(i); QPixmap img(r.size()); if (d->fillColor.isValid()) img.fill(d->fillColor); { #ifdef Q_WS_MAC bool oldSmooth = qt_applefontsmoothing_enabled; qt_applefontsmoothing_enabled = false; #endif QPainter qp(&img); #ifdef Q_WS_MAC qt_applefontsmoothing_enabled = oldSmooth; #endif qp.setRenderHints(QPainter::HighQualityAntialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, d->smoothCache); qp.translate(-r.x(),-r.y()); qp.scale(d->contentsScale,d->contentsScale); QRect sclip(qFloor(r.x()/d->contentsScale), qFloor(r.y()/d->contentsScale), qCeil(r.width()/d->contentsScale+r.x()/d->contentsScale-qFloor(r.x()/d->contentsScale)), qCeil(r.height()/d->contentsScale+r.y()/d->contentsScale-qFloor(r.y()/d->contentsScale))); drawContents(&qp, sclip); } QDeclarativePaintedItemPrivate::ImageCacheItem *newitem = new QDeclarativePaintedItemPrivate::ImageCacheItem; newitem->area = r; newitem->image = img; d->imagecache.append(newitem); p->drawPixmap(r, newitem->image); } } else { const QVector<QRect> rects = uncached.rects(); for (int i = 0; i < rects.count(); ++i) p->fillRect(rects.at(i), Qt::lightGray); } } if (inpaint_clearcache) { clearCache(); inpaint_clearcache = 0; } --inpaint; }
Menu::Menu() { auto dialogsManager = DependencyManager::get<DialogsManager>(); auto accountManager = DependencyManager::get<AccountManager>(); // File/Application menu ---------------------------------- MenuWrapper* fileMenu = addMenu("File"); // File > Login menu items { addActionToQMenuAndActionHash(fileMenu, MenuOption::Login); // connect to the appropriate signal of the AccountManager so that we can change the Login/Logout menu item connect(accountManager.data(), &AccountManager::profileChanged, dialogsManager.data(), &DialogsManager::toggleLoginDialog); connect(accountManager.data(), &AccountManager::logoutComplete, dialogsManager.data(), &DialogsManager::toggleLoginDialog); } // File > Quit addActionToQMenuAndActionHash(fileMenu, MenuOption::Quit, Qt::CTRL | Qt::Key_Q, qApp, SLOT(quit()), QAction::QuitRole); // Edit menu ---------------------------------- MenuWrapper* editMenu = addMenu("Edit"); // Edit > Cut auto cutAction = addActionToQMenuAndActionHash(editMenu, "Cut", QKeySequence::Cut); connect(cutAction, &QAction::triggered, [] { QKeyEvent* keyEvent = new QKeyEvent(QEvent::KeyPress, Qt::Key_X, Qt::ControlModifier); QCoreApplication::postEvent(QCoreApplication::instance(), keyEvent); }); // Edit > Copy auto copyAction = addActionToQMenuAndActionHash(editMenu, "Copy", QKeySequence::Copy); connect(copyAction, &QAction::triggered, [] { QKeyEvent* keyEvent = new QKeyEvent(QEvent::KeyPress, Qt::Key_C, Qt::ControlModifier); QCoreApplication::postEvent(QCoreApplication::instance(), keyEvent); }); // Edit > Paste auto pasteAction = addActionToQMenuAndActionHash(editMenu, "Paste", QKeySequence::Paste); connect(pasteAction, &QAction::triggered, [] { QKeyEvent* keyEvent = new QKeyEvent(QEvent::KeyPress, Qt::Key_V, Qt::ControlModifier); QCoreApplication::postEvent(QCoreApplication::instance(), keyEvent); }); // Edit > Delete auto deleteAction = addActionToQMenuAndActionHash(editMenu, "Delete", QKeySequence::Delete); connect(deleteAction, &QAction::triggered, [] { QKeyEvent* keyEvent = new QKeyEvent(QEvent::KeyPress, Qt::Key_Delete, Qt::ControlModifier); QCoreApplication::postEvent(QCoreApplication::instance(), keyEvent); }); editMenu->addSeparator(); // Edit > Running Scripts auto action = addActionToQMenuAndActionHash(editMenu, MenuOption::RunningScripts, Qt::CTRL | Qt::Key_J); connect(action, &QAction::triggered, [] { if (!qApp->getLoginDialogPoppedUp()) { static const QUrl widgetUrl("hifi/dialogs/RunningScripts.qml"); static const QUrl tabletUrl("hifi/dialogs/TabletRunningScripts.qml"); static const QString name("RunningScripts"); qApp->showDialog(widgetUrl, tabletUrl, name); } }); editMenu->addSeparator(); // Edit > Asset Browser auto assetServerAction = addActionToQMenuAndActionHash(editMenu, MenuOption::AssetServer, Qt::CTRL | Qt::SHIFT | Qt::Key_A, qApp, SLOT(showAssetServerWidget())); { auto nodeList = DependencyManager::get<NodeList>(); QObject::connect(nodeList.data(), &NodeList::canWriteAssetsChanged, assetServerAction, &QAction::setEnabled); assetServerAction->setEnabled(nodeList->getThisNodeCanWriteAssets()); } // Edit > Avatar Packager #ifndef Q_OS_ANDROID action = addActionToQMenuAndActionHash(editMenu, MenuOption::AvatarPackager); connect(action, &QAction::triggered, [] { DependencyManager::get<AvatarPackager>()->open(); }); #endif // Edit > Reload All Content addActionToQMenuAndActionHash(editMenu, MenuOption::ReloadContent, 0, qApp, SLOT(reloadResourceCaches())); // Display menu ---------------------------------- // FIXME - this is not yet matching Alan's spec because it doesn't have // menus for "2D"/"3D" - we need to add support for detecting the appropriate // default 3D display mode addMenu(DisplayPlugin::MENU_PATH()); MenuWrapper* displayModeMenu = addMenu(MenuOption::OutputMenu); QActionGroup* displayModeGroup = new QActionGroup(displayModeMenu); displayModeGroup->setExclusive(true); // View menu ---------------------------------- MenuWrapper* viewMenu = addMenu("View"); QActionGroup* cameraModeGroup = new QActionGroup(viewMenu); // View > [camera group] cameraModeGroup->setExclusive(true); // View > First Person auto firstPersonAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash( viewMenu, MenuOption::FirstPerson, 0, true, qApp, SLOT(cameraMenuChanged()))); firstPersonAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup)); // View > Third Person auto thirdPersonAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash( viewMenu, MenuOption::ThirdPerson, 0, false, qApp, SLOT(cameraMenuChanged()))); thirdPersonAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup)); // View > Mirror auto viewMirrorAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash( viewMenu, MenuOption::FullscreenMirror, 0, false, qApp, SLOT(cameraMenuChanged()))); viewMirrorAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup)); // View > Independent auto viewIndependentAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::IndependentMode, 0, false, qApp, SLOT(cameraMenuChanged()))); viewIndependentAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup)); // View > Entity Camera auto viewEntityCameraAction = cameraModeGroup->addAction(addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::CameraEntityMode, 0, false, qApp, SLOT(cameraMenuChanged()))); viewEntityCameraAction->setProperty(EXCLUSION_GROUP_KEY, QVariant::fromValue(cameraModeGroup)); viewMenu->addSeparator(); // View > Center Player In View addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::CenterPlayerInView, 0, true, qApp, SLOT(rotationModeChanged())); // View > Enter First Person Mode in HMD addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::FirstPersonHMD, 0, true); //TODO: Remove Navigation menu when these functions are included in GoTo menu // Navigate menu ---------------------------------- MenuWrapper* navigateMenu = addMenu("Navigate"); // Navigate > LocationBookmarks related menus -- Note: the LocationBookmarks class adds its own submenus here. auto locationBookmarks = DependencyManager::get<LocationBookmarks>(); locationBookmarks->setupMenus(this, navigateMenu); // Navigate > Copy Address auto addressManager = DependencyManager::get<AddressManager>(); addActionToQMenuAndActionHash(navigateMenu, MenuOption::CopyAddress, 0, addressManager.data(), SLOT(copyAddress())); // Navigate > Copy Path addActionToQMenuAndActionHash(navigateMenu, MenuOption::CopyPath, 0, addressManager.data(), SLOT(copyPath())); // Navigate > Start-up Location MenuWrapper* startupLocationMenu = navigateMenu->addMenu(MenuOption::StartUpLocation); QActionGroup* startupLocatiopnGroup = new QActionGroup(startupLocationMenu); startupLocatiopnGroup->setExclusive(true); startupLocatiopnGroup->addAction(addCheckableActionToQMenuAndActionHash(startupLocationMenu, MenuOption::HomeLocation, 0, false)); startupLocatiopnGroup->addAction(addCheckableActionToQMenuAndActionHash(startupLocationMenu, MenuOption::LastLocation, 0, true)); // Settings menu ---------------------------------- MenuWrapper* settingsMenu = addMenu("Settings"); // Settings > General... action = addActionToQMenuAndActionHash(settingsMenu, MenuOption::Preferences, Qt::CTRL | Qt::Key_G, nullptr, nullptr); connect(action, &QAction::triggered, [] { if (!qApp->getLoginDialogPoppedUp()) { qApp->showDialog(QString("hifi/dialogs/GeneralPreferencesDialog.qml"), QString("hifi/tablet/TabletGeneralPreferences.qml"), "GeneralPreferencesDialog"); } }); // Settings > Controls... action = addActionToQMenuAndActionHash(settingsMenu, "Controls..."); connect(action, &QAction::triggered, [] { auto tablet = DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system"); auto hmd = DependencyManager::get<HMDScriptingInterface>(); tablet->pushOntoStack("hifi/tablet/ControllerSettings.qml"); if (!hmd->getShouldShowTablet()) { hmd->toggleShouldShowTablet(); } }); // Settings > Audio... action = addActionToQMenuAndActionHash(settingsMenu, "Audio..."); connect(action, &QAction::triggered, [] { static const QUrl tabletUrl("hifi/audio/Audio.qml"); auto tablet = DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system"); auto hmd = DependencyManager::get<HMDScriptingInterface>(); tablet->pushOntoStack(tabletUrl); if (!hmd->getShouldShowTablet()) { hmd->toggleShouldShowTablet(); } }); // Settings > Graphics... action = addActionToQMenuAndActionHash(settingsMenu, "Graphics..."); connect(action, &QAction::triggered, [] { qApp->showDialog(QString("hifi/dialogs/GraphicsPreferencesDialog.qml"), QString("hifi/tablet/TabletGraphicsPreferences.qml"), "GraphicsPreferencesDialog"); }); // Settings > Security... action = addActionToQMenuAndActionHash(settingsMenu, "Security..."); connect(action, &QAction::triggered, [] { auto tablet = DependencyManager::get<TabletScriptingInterface>()->getTablet("com.highfidelity.interface.tablet.system"); auto hmd = DependencyManager::get<HMDScriptingInterface>(); tablet->pushOntoStack("hifi/dialogs/security/Security.qml"); if (!hmd->getShouldShowTablet()) { hmd->toggleShouldShowTablet(); } }); // Settings > Developer Menu addCheckableActionToQMenuAndActionHash(settingsMenu, "Developer Menu", 0, false, this, SLOT(toggleDeveloperMenus())); // Settings > Ask to Reset Settings addCheckableActionToQMenuAndActionHash(settingsMenu, MenuOption::AskToResetSettings, 0, false); // Developer menu ---------------------------------- MenuWrapper* developerMenu = addMenu("Developer", "Developer"); // Developer > Scripting >>> MenuWrapper* scriptingOptionsMenu = developerMenu->addMenu("Scripting"); // Developer > Scripting > Console... addActionToQMenuAndActionHash(scriptingOptionsMenu, MenuOption::Console, Qt::CTRL | Qt::ALT | Qt::Key_J, DependencyManager::get<StandAloneJSConsole>().data(), SLOT(toggleConsole()), QAction::NoRole, UNSPECIFIED_POSITION); // Developer > Scripting > API Debugger action = addActionToQMenuAndActionHash(scriptingOptionsMenu, "API Debugger"); connect(action, &QAction::triggered, [] { QUrl defaultScriptsLoc = PathUtils::defaultScriptsLocation(); defaultScriptsLoc.setPath(defaultScriptsLoc.path() + "developer/utilities/tools/currentAPI.js"); DependencyManager::get<ScriptEngines>()->loadScript(defaultScriptsLoc.toString()); }); // Developer > Scripting > Entity Script Server Log auto essLogAction = addActionToQMenuAndActionHash(scriptingOptionsMenu, MenuOption::EntityScriptServerLog, 0, qApp, SLOT(toggleEntityScriptServerLogDialog())); { auto nodeList = DependencyManager::get<NodeList>(); QObject::connect(nodeList.data(), &NodeList::canRezChanged, essLogAction, [essLogAction] { auto nodeList = DependencyManager::get<NodeList>(); essLogAction->setEnabled(nodeList->getThisNodeCanRez()); }); essLogAction->setEnabled(nodeList->getThisNodeCanRez()); } // Developer > Scripting > Script Log (HMD friendly)... addActionToQMenuAndActionHash(scriptingOptionsMenu, "Script Log (HMD friendly)...", Qt::NoButton, qApp, SLOT(showScriptLogs())); // Developer > Scripting > Verbose Logging addCheckableActionToQMenuAndActionHash(scriptingOptionsMenu, MenuOption::VerboseLogging, 0, false, qApp, SLOT(updateVerboseLogging())); // Developer > Scripting > Enable Speech Control API #if defined(Q_OS_MAC) || defined(Q_OS_WIN) auto speechRecognizer = DependencyManager::get<SpeechRecognizer>(); QAction* speechRecognizerAction = addCheckableActionToQMenuAndActionHash(scriptingOptionsMenu, MenuOption::ControlWithSpeech, Qt::CTRL | Qt::SHIFT | Qt::Key_C, speechRecognizer->getEnabled(), speechRecognizer.data(), SLOT(setEnabled(bool)), UNSPECIFIED_POSITION); connect(speechRecognizer.data(), SIGNAL(enabledUpdated(bool)), speechRecognizerAction, SLOT(setChecked(bool))); #endif // Developer > UI >>> MenuWrapper* uiOptionsMenu = developerMenu->addMenu("UI"); action = addCheckableActionToQMenuAndActionHash(uiOptionsMenu, MenuOption::DesktopTabletToToolbar, 0, qApp->getDesktopTabletBecomesToolbarSetting()); // Developer > UI > Show Overlays addCheckableActionToQMenuAndActionHash(uiOptionsMenu, MenuOption::Overlays, 0, true); // Developer > UI > Desktop Tablet Becomes Toolbar connect(action, &QAction::triggered, [action] { qApp->setDesktopTabletBecomesToolbarSetting(action->isChecked()); }); // Developer > UI > HMD Tablet Becomes Toolbar action = addCheckableActionToQMenuAndActionHash(uiOptionsMenu, MenuOption::HMDTabletToToolbar, 0, qApp->getHmdTabletBecomesToolbarSetting()); connect(action, &QAction::triggered, [action] { qApp->setHmdTabletBecomesToolbarSetting(action->isChecked()); }); // Developer > Render >>> MenuWrapper* renderOptionsMenu = developerMenu->addMenu("Render"); action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::AntiAliasing, 0, true); connect(action, &QAction::triggered, [action] { auto renderConfig = qApp->getRenderEngine()->getConfiguration(); if (renderConfig) { auto mainViewJitterCamConfig = renderConfig->getConfig<JitterSample>("RenderMainView.JitterCam"); auto mainViewAntialiasingConfig = renderConfig->getConfig<Antialiasing>("RenderMainView.Antialiasing"); if (mainViewJitterCamConfig && mainViewAntialiasingConfig) { if (action->isChecked()) { mainViewJitterCamConfig->play(); mainViewAntialiasingConfig->setDebugFXAA(false); } else { mainViewJitterCamConfig->none(); mainViewAntialiasingConfig->setDebugFXAA(true); } } } }); action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::Shadows, 0, true); connect(action, &QAction::triggered, [action] { auto renderConfig = qApp->getRenderEngine()->getConfiguration(); if (renderConfig) { auto lightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderMainView.LightingModel"); if (lightingModelConfig) { lightingModelConfig->setShadow(action->isChecked()); } } }); action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::AmbientOcclusion, 0, false); connect(action, &QAction::triggered, [action] { auto renderConfig = qApp->getRenderEngine()->getConfiguration(); if (renderConfig) { auto lightingModelConfig = renderConfig->getConfig<MakeLightingModel>("RenderMainView.LightingModel"); if (lightingModelConfig) { lightingModelConfig->setAmbientOcclusion(action->isChecked()); } } }); addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::WorldAxes); addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::DefaultSkybox, 0, true); // Developer > Render > Throttle FPS If Not Focus addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::ThrottleFPSIfNotFocus, 0, true); // Developer > Render > OpenVR threaded submit addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::OpenVrThreadedSubmit, 0, true); // Developer > Render > Resolution MenuWrapper* resolutionMenu = renderOptionsMenu->addMenu(MenuOption::RenderResolution); QActionGroup* resolutionGroup = new QActionGroup(resolutionMenu); resolutionGroup->setExclusive(true); resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionOne, 0, true)); resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionTwoThird, 0, false)); resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionHalf, 0, false)); resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionThird, 0, false)); resolutionGroup->addAction(addCheckableActionToQMenuAndActionHash(resolutionMenu, MenuOption::RenderResolutionQuarter, 0, false)); //const QString = "Automatic Texture Memory"; //const QString = "64 MB"; //const QString = "256 MB"; //const QString = "512 MB"; //const QString = "1024 MB"; //const QString = "2048 MB"; // Developer > Render > Maximum Texture Memory MenuWrapper* textureMenu = renderOptionsMenu->addMenu(MenuOption::RenderMaxTextureMemory); QActionGroup* textureGroup = new QActionGroup(textureMenu); textureGroup->setExclusive(true); textureGroup->addAction(addCheckableActionToQMenuAndActionHash(textureMenu, MenuOption::RenderMaxTextureAutomatic, 0, true)); textureGroup->addAction(addCheckableActionToQMenuAndActionHash(textureMenu, MenuOption::RenderMaxTexture4MB, 0, false)); textureGroup->addAction(addCheckableActionToQMenuAndActionHash(textureMenu, MenuOption::RenderMaxTexture64MB, 0, false)); textureGroup->addAction(addCheckableActionToQMenuAndActionHash(textureMenu, MenuOption::RenderMaxTexture256MB, 0, false)); textureGroup->addAction(addCheckableActionToQMenuAndActionHash(textureMenu, MenuOption::RenderMaxTexture512MB, 0, false)); textureGroup->addAction(addCheckableActionToQMenuAndActionHash(textureMenu, MenuOption::RenderMaxTexture1024MB, 0, false)); textureGroup->addAction(addCheckableActionToQMenuAndActionHash(textureMenu, MenuOption::RenderMaxTexture2048MB, 0, false)); textureGroup->addAction(addCheckableActionToQMenuAndActionHash(textureMenu, MenuOption::RenderMaxTexture4096MB, 0, false)); textureGroup->addAction(addCheckableActionToQMenuAndActionHash(textureMenu, MenuOption::RenderMaxTexture6144MB, 0, false)); textureGroup->addAction(addCheckableActionToQMenuAndActionHash(textureMenu, MenuOption::RenderMaxTexture8192MB, 0, false)); connect(textureGroup, &QActionGroup::triggered, [textureGroup] { auto checked = textureGroup->checkedAction(); auto text = checked->text(); gpu::Context::Size newMaxTextureMemory { 0 }; if (MenuOption::RenderMaxTexture4MB == text) { newMaxTextureMemory = MB_TO_BYTES(4); } else if (MenuOption::RenderMaxTexture64MB == text) { newMaxTextureMemory = MB_TO_BYTES(64); } else if (MenuOption::RenderMaxTexture256MB == text) { newMaxTextureMemory = MB_TO_BYTES(256); } else if (MenuOption::RenderMaxTexture512MB == text) { newMaxTextureMemory = MB_TO_BYTES(512); } else if (MenuOption::RenderMaxTexture1024MB == text) { newMaxTextureMemory = MB_TO_BYTES(1024); } else if (MenuOption::RenderMaxTexture2048MB == text) { newMaxTextureMemory = MB_TO_BYTES(2048); } else if (MenuOption::RenderMaxTexture4096MB == text) { newMaxTextureMemory = MB_TO_BYTES(4096); } else if (MenuOption::RenderMaxTexture6144MB == text) { newMaxTextureMemory = MB_TO_BYTES(6144); } else if (MenuOption::RenderMaxTexture8192MB == text) { newMaxTextureMemory = MB_TO_BYTES(8192); } gpu::Texture::setAllowedGPUMemoryUsage(newMaxTextureMemory); }); #ifdef Q_OS_WIN // Developer > Render > Enable Sparse Textures { auto action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::SparseTextureManagement, 0, gpu::Texture::getEnableSparseTextures()); connect(action, &QAction::triggered, [&](bool checked) { qDebug() << "[TEXTURE TRANSFER SUPPORT] --- Enable Dynamic Texture Management menu option:" << checked; gpu::Texture::setEnableSparseTextures(checked); }); } #else qDebug() << "[TEXTURE TRANSFER SUPPORT] Incremental Texture Transfer and Dynamic Texture Management not supported on this platform."; #endif { auto action = addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::RenderClearKtxCache); connect(action, &QAction::triggered, []{ Setting::Handle<int>(KTXCache::SETTING_VERSION_NAME, KTXCache::INVALID_VERSION).set(KTXCache::INVALID_VERSION); }); } // Developer > Render > LOD Tools addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, 0, qApp, SLOT(loadLODToolsDialog())); // HACK enable texture decimation { auto action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, "Decimate Textures"); connect(action, &QAction::triggered, [&](bool checked) { DEV_DECIMATE_TEXTURES = checked; }); } addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::ComputeBlendshapes, 0, true, DependencyManager::get<ModelBlender>().data(), SLOT(setComputeBlendshapes(bool))); // Developer > Assets >>> // Menu item is not currently needed but code should be kept in case it proves useful again at some stage. //#define WANT_ASSET_MIGRATION #ifdef WANT_ASSET_MIGRATION MenuWrapper* assetDeveloperMenu = developerMenu->addMenu("Assets"); auto& atpMigrator = ATPAssetMigrator::getInstance(); atpMigrator.setDialogParent(this); addActionToQMenuAndActionHash(assetDeveloperMenu, MenuOption::AssetMigration, 0, &atpMigrator, SLOT(loadEntityServerFile())); #endif // Developer > Avatar >>> MenuWrapper* avatarDebugMenu = developerMenu->addMenu("Avatar"); // Developer > Avatar > Face Tracking MenuWrapper* faceTrackingMenu = avatarDebugMenu->addMenu("Face Tracking"); { QActionGroup* faceTrackerGroup = new QActionGroup(avatarDebugMenu); bool defaultNoFaceTracking = true; #ifdef HAVE_DDE defaultNoFaceTracking = false; #endif QAction* noFaceTracker = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::NoFaceTracking, 0, defaultNoFaceTracking, qApp, SLOT(setActiveFaceTracker())); faceTrackerGroup->addAction(noFaceTracker); #ifdef HAVE_DDE QAction* ddeFaceTracker = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::UseCamera, 0, true, qApp, SLOT(setActiveFaceTracker())); faceTrackerGroup->addAction(ddeFaceTracker); #endif } #ifdef HAVE_DDE faceTrackingMenu->addSeparator(); QAction* binaryEyelidControl = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::BinaryEyelidControl, 0, true); binaryEyelidControl->setVisible(true); // DDE face tracking is on by default QAction* coupleEyelids = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::CoupleEyelids, 0, true); coupleEyelids->setVisible(true); // DDE face tracking is on by default QAction* useAudioForMouth = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::UseAudioForMouth, 0, true); useAudioForMouth->setVisible(true); // DDE face tracking is on by default QAction* ddeFiltering = addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::VelocityFilter, 0, true); ddeFiltering->setVisible(true); // DDE face tracking is on by default QAction* ddeCalibrate = addActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::CalibrateCamera, 0, DependencyManager::get<DdeFaceTracker>().data(), SLOT(calibrate())); ddeCalibrate->setVisible(true); // DDE face tracking is on by default faceTrackingMenu->addSeparator(); addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::MuteFaceTracking, [](bool mute) { FaceTracker::setIsMuted(mute); }, Qt::CTRL | Qt::SHIFT | Qt::Key_F, FaceTracker::isMuted()); addCheckableActionToQMenuAndActionHash(faceTrackingMenu, MenuOption::AutoMuteAudio, 0, false); #endif #ifdef HAVE_IVIEWHMD // Developer > Avatar > Eye Tracking MenuWrapper* eyeTrackingMenu = avatarDebugMenu->addMenu("Eye Tracking"); addCheckableActionToQMenuAndActionHash(eyeTrackingMenu, MenuOption::SMIEyeTracking, 0, false, qApp, SLOT(setActiveEyeTracker())); { MenuWrapper* calibrateEyeTrackingMenu = eyeTrackingMenu->addMenu("Calibrate"); addActionToQMenuAndActionHash(calibrateEyeTrackingMenu, MenuOption::OnePointCalibration, 0, qApp, SLOT(calibrateEyeTracker1Point())); addActionToQMenuAndActionHash(calibrateEyeTrackingMenu, MenuOption::ThreePointCalibration, 0, qApp, SLOT(calibrateEyeTracker3Points())); addActionToQMenuAndActionHash(calibrateEyeTrackingMenu, MenuOption::FivePointCalibration, 0, qApp, SLOT(calibrateEyeTracker5Points())); } addCheckableActionToQMenuAndActionHash(eyeTrackingMenu, MenuOption::SimulateEyeTracking, 0, false, qApp, SLOT(setActiveEyeTracker())); #endif action = addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AvatarReceiveStats, 0, false); connect(action, &QAction::triggered, [this]{ Avatar::setShowReceiveStats(isOptionChecked(MenuOption::AvatarReceiveStats)); }); action = addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ShowBoundingCollisionShapes, 0, false); connect(action, &QAction::triggered, [this]{ Avatar::setShowCollisionShapes(isOptionChecked(MenuOption::ShowBoundingCollisionShapes)); }); action = addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ShowMyLookAtVectors, 0, false); connect(action, &QAction::triggered, [this]{ Avatar::setShowMyLookAtVectors(isOptionChecked(MenuOption::ShowMyLookAtVectors)); }); action = addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ShowOtherLookAtVectors, 0, false); connect(action, &QAction::triggered, [this]{ Avatar::setShowOtherLookAtVectors(isOptionChecked(MenuOption::ShowOtherLookAtVectors)); }); auto avatarManager = DependencyManager::get<AvatarManager>(); auto avatar = avatarManager->getMyAvatar(); action = addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::EnableLookAtSnapping, 0, true); connect(action, &QAction::triggered, [this, avatar]{ avatar->setProperty("lookAtSnappingEnabled", isOptionChecked(MenuOption::EnableLookAtSnapping)); }); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::FixGaze, 0, false); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ToggleHipsFollowing, 0, false, avatar.get(), SLOT(setToggleHips(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawBaseOfSupport, 0, false, avatar.get(), SLOT(setEnableDebugDrawBaseOfSupport(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawDefaultPose, 0, false, avatar.get(), SLOT(setEnableDebugDrawDefaultPose(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawAnimPose, 0, false, avatar.get(), SLOT(setEnableDebugDrawAnimPose(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::AnimDebugDrawPosition, 0, false, avatar.get(), SLOT(setEnableDebugDrawPosition(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::MeshVisible, 0, true, avatar.get(), SLOT(setEnableMeshVisible(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::DisableEyelidAdjustment, 0, false); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::TurnWithHead, 0, false); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::EnableInverseKinematics, 0, true, avatar.get(), SLOT(setEnableInverseKinematics(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderSensorToWorldMatrix, 0, false, avatar.get(), SLOT(setEnableDebugDrawSensorToWorldMatrix(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderIKTargets, 0, false, avatar.get(), SLOT(setEnableDebugDrawIKTargets(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderIKConstraints, 0, false, avatar.get(), SLOT(setEnableDebugDrawIKConstraints(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderIKChains, 0, false, avatar.get(), SLOT(setEnableDebugDrawIKChains(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderDetailedCollision, 0, false, avatar.get(), SLOT(setEnableDebugDrawDetailedCollision(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ActionMotorControl, 0, true, avatar.get(), SLOT(updateMotionBehaviorFromMenu()), UNSPECIFIED_POSITION, "Developer"); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ScriptedMotorControl, 0, true, avatar.get(), SLOT(updateMotionBehaviorFromMenu()), UNSPECIFIED_POSITION, "Developer"); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ShowTrackedObjects, 0, false, qApp, SLOT(setShowTrackedObjects(bool))); addActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::PackageModel, 0, qApp, SLOT(packageModel())); // Developer > Hands >>> MenuWrapper* handOptionsMenu = developerMenu->addMenu("Hands"); addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false, avatar.get(), SLOT(setEnableDebugDrawHandControllers(bool))); // Developer > Entities >>> MenuWrapper* entitiesOptionsMenu = developerMenu->addMenu("Entities"); addActionToQMenuAndActionHash(entitiesOptionsMenu, MenuOption::OctreeStats, 0, qApp, SLOT(loadEntityStatisticsDialog())); addCheckableActionToQMenuAndActionHash(entitiesOptionsMenu, MenuOption::ShowRealtimeEntityStats); // Developer > Network >>> MenuWrapper* networkMenu = developerMenu->addMenu("Network"); action = addActionToQMenuAndActionHash(networkMenu, MenuOption::Networking); connect(action, &QAction::triggered, [] { qApp->showDialog(QString("hifi/dialogs/NetworkingPreferencesDialog.qml"), QString("hifi/tablet/TabletNetworkingPreferences.qml"), "NetworkingPreferencesDialog"); }); addActionToQMenuAndActionHash(networkMenu, MenuOption::ReloadContent, 0, qApp, SLOT(reloadResourceCaches())); addActionToQMenuAndActionHash(networkMenu, MenuOption::ClearDiskCache, 0, DependencyManager::get<AssetClient>().data(), SLOT(clearCache())); addCheckableActionToQMenuAndActionHash(networkMenu, MenuOption::DisableActivityLogger, 0, false, &UserActivityLogger::getInstance(), SLOT(disable(bool))); addActionToQMenuAndActionHash(networkMenu, MenuOption::ShowDSConnectTable, 0, qApp, SLOT(loadDomainConnectionDialog())); #if (PR_BUILD || DEV_BUILD) addCheckableActionToQMenuAndActionHash(networkMenu, MenuOption::SendWrongProtocolVersion, 0, false, qApp, SLOT(sendWrongProtocolVersionsSignature(bool))); { auto nodeList = DependencyManager::get<NodeList>(); addCheckableActionToQMenuAndActionHash(networkMenu, MenuOption::SendWrongDSConnectVersion, 0, false, nodeList.data(), SLOT(toggleSendNewerDSConnectVersion(bool))); } #endif // Developer >> Tests >>> MenuWrapper* testMenu = developerMenu->addMenu("Tests"); addActionToQMenuAndActionHash(testMenu, MenuOption::RunClientScriptTests, 0, dialogsManager.data(), SLOT(showTestingResults())); // Developer > Timing >>> MenuWrapper* timingMenu = developerMenu->addMenu("Timing"); MenuWrapper* perfTimerMenu = timingMenu->addMenu("Performance Timer"); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::DisplayDebugTimingDetails, 0, false, qApp, SLOT(enablePerfStats(bool))); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::OnlyDisplayTopTen, 0, true); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandUpdateTiming, 0, false); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandSimulationTiming, 0, false); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandPhysicsTiming, 0, false); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandMyAvatarTiming, 0, false); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandMyAvatarSimulateTiming, 0, false); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandOtherAvatarTiming, 0, false); addCheckableActionToQMenuAndActionHash(perfTimerMenu, MenuOption::ExpandPaintGLTiming, 0, false); addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::FrameTimer); addActionToQMenuAndActionHash(timingMenu, MenuOption::RunTimingTests, 0, qApp, SLOT(runTests())); addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::PipelineWarnings); addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::LogExtraTimings); addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::SuppressShortTimings); // Developer > Audio >>> MenuWrapper* audioDebugMenu = developerMenu->addMenu("Audio"); action = addActionToQMenuAndActionHash(audioDebugMenu, "Stats..."); connect(action, &QAction::triggered, [] { QUrl defaultScriptsLoc = PathUtils::defaultScriptsLocation(); defaultScriptsLoc.setPath(defaultScriptsLoc.path() + "developer/utilities/audio/stats.js"); DependencyManager::get<ScriptEngines>()->loadScript(defaultScriptsLoc.toString()); }); action = addActionToQMenuAndActionHash(audioDebugMenu, "Buffers..."); connect(action, &QAction::triggered, [] { qApp->showDialog(QString("hifi/dialogs/AudioBuffers.qml"), QString("hifi/tablet/TabletAudioBuffers.qml"), "AudioBuffersDialog"); }); addActionToQMenuAndActionHash(audioDebugMenu, MenuOption::MuteEnvironment, 0, DependencyManager::get<AudioClient>().data(), SLOT(sendMuteEnvironmentPacket())); action = addActionToQMenuAndActionHash(audioDebugMenu, MenuOption::AudioScope); connect(action, &QAction::triggered, [] { QUrl defaultScriptsLoc = PathUtils::defaultScriptsLocation(); defaultScriptsLoc.setPath(defaultScriptsLoc.path() + "developer/utilities/audio/audioScope.js"); DependencyManager::get<ScriptEngines>()->loadScript(defaultScriptsLoc.toString()); }); // Developer > Physics >>> MenuWrapper* physicsOptionsMenu = developerMenu->addMenu("Physics"); { auto drawStatusConfig = qApp->getRenderEngine()->getConfiguration()->getConfig<render::DrawStatus>("RenderMainView.DrawStatus"); addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowOwned, 0, false, drawStatusConfig, SLOT(setShowNetwork(bool))); } addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowBulletWireframe, 0, false, qApp, SLOT(setShowBulletWireframe(bool))); addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowBulletAABBs, 0, false, qApp, SLOT(setShowBulletAABBs(bool))); addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowBulletContactPoints, 0, false, qApp, SLOT(setShowBulletContactPoints(bool))); addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowBulletConstraints, 0, false, qApp, SLOT(setShowBulletConstraints(bool))); addCheckableActionToQMenuAndActionHash(physicsOptionsMenu, MenuOption::PhysicsShowBulletConstraintLimits, 0, false, qApp, SLOT(setShowBulletConstraintLimits(bool))); // Developer > Picking >>> MenuWrapper* pickingOptionsMenu = developerMenu->addMenu("Picking"); addCheckableActionToQMenuAndActionHash(pickingOptionsMenu, MenuOption::ForceCoarsePicking, 0, false, DependencyManager::get<PickManager>().data(), SLOT(setForceCoarsePicking(bool))); // Developer > Crash >>> MenuWrapper* crashMenu = developerMenu->addMenu("Crash"); // Developer > Crash > Display Crash Options addCheckableActionToQMenuAndActionHash(crashMenu, MenuOption::DisplayCrashOptions, 0, true); addActionToQMenuAndActionHash(crashMenu, MenuOption::DeadlockInterface, 0, qApp, SLOT(deadlockApplication())); addActionToQMenuAndActionHash(crashMenu, MenuOption::UnresponsiveInterface, 0, qApp, SLOT(unresponsiveApplication())); action = addActionToQMenuAndActionHash(crashMenu, MenuOption::CrashPureVirtualFunction); connect(action, &QAction::triggered, qApp, []() { crash::pureVirtualCall(); }); action = addActionToQMenuAndActionHash(crashMenu, MenuOption::CrashPureVirtualFunctionThreaded); connect(action, &QAction::triggered, qApp, []() { std::thread(crash::pureVirtualCall).join(); }); action = addActionToQMenuAndActionHash(crashMenu, MenuOption::CrashDoubleFree); connect(action, &QAction::triggered, qApp, []() { crash::doubleFree(); }); action = addActionToQMenuAndActionHash(crashMenu, MenuOption::CrashDoubleFreeThreaded); connect(action, &QAction::triggered, qApp, []() { std::thread(crash::doubleFree).join(); }); action = addActionToQMenuAndActionHash(crashMenu, MenuOption::CrashAbort); connect(action, &QAction::triggered, qApp, []() { crash::doAbort(); }); action = addActionToQMenuAndActionHash(crashMenu, MenuOption::CrashAbortThreaded); connect(action, &QAction::triggered, qApp, []() { std::thread(crash::doAbort).join(); }); action = addActionToQMenuAndActionHash(crashMenu, MenuOption::CrashNullDereference); connect(action, &QAction::triggered, qApp, []() { crash::nullDeref(); }); action = addActionToQMenuAndActionHash(crashMenu, MenuOption::CrashNullDereferenceThreaded); connect(action, &QAction::triggered, qApp, []() { std::thread(crash::nullDeref).join(); }); action = addActionToQMenuAndActionHash(crashMenu, MenuOption::CrashOutOfBoundsVectorAccess); connect(action, &QAction::triggered, qApp, []() { crash::outOfBoundsVectorCrash(); }); action = addActionToQMenuAndActionHash(crashMenu, MenuOption::CrashOutOfBoundsVectorAccessThreaded); connect(action, &QAction::triggered, qApp, []() { std::thread(crash::outOfBoundsVectorCrash).join(); }); action = addActionToQMenuAndActionHash(crashMenu, MenuOption::CrashNewFault); connect(action, &QAction::triggered, qApp, []() { crash::newFault(); }); action = addActionToQMenuAndActionHash(crashMenu, MenuOption::CrashNewFaultThreaded); connect(action, &QAction::triggered, qApp, []() { std::thread(crash::newFault).join(); }); // Developer > Show Statistics addCheckableActionToQMenuAndActionHash(developerMenu, MenuOption::Stats, 0, true); // Developer > Show Animation Statistics addCheckableActionToQMenuAndActionHash(developerMenu, MenuOption::AnimStats); // Developer > Log addActionToQMenuAndActionHash(developerMenu, MenuOption::Log, Qt::CTRL | Qt::SHIFT | Qt::Key_L, qApp, SLOT(toggleLogDialog())); #if 0 /// -------------- REMOVED FOR NOW -------------- addDisabledActionAndSeparator(navigateMenu, "History"); QAction* backAction = addActionToQMenuAndActionHash(navigateMenu, MenuOption::Back, 0, addressManager.data(), SLOT(goBack())); QAction* forwardAction = addActionToQMenuAndActionHash(navigateMenu, MenuOption::Forward, 0, addressManager.data(), SLOT(goForward())); // connect to the AddressManager signal to enable and disable the back and forward menu items connect(addressManager.data(), &AddressManager::goBackPossible, backAction, &QAction::setEnabled); connect(addressManager.data(), &AddressManager::goForwardPossible, forwardAction, &QAction::setEnabled); // set the two actions to start disabled since the stacks are clear on startup backAction->setDisabled(true); forwardAction->setDisabled(true); MenuWrapper* toolsMenu = addMenu("Tools"); addActionToQMenuAndActionHash(toolsMenu, MenuOption::ToolWindow, Qt::CTRL | Qt::ALT | Qt::Key_T, dialogsManager.data(), SLOT(toggleToolWindow()), QAction::NoRole, UNSPECIFIED_POSITION, "Advanced"); addCheckableActionToQMenuAndActionHash(avatarMenu, MenuOption::NamesAboveHeads, 0, true, NULL, NULL, UNSPECIFIED_POSITION, "Advanced"); #endif // Help/Application menu ---------------------------------- MenuWrapper * helpMenu = addMenu("Help"); // Help > About High Fidelity action = addActionToQMenuAndActionHash(helpMenu, "About High Fidelity"); connect(action, &QAction::triggered, [] { qApp->showDialog(QString("hifi/dialogs/AboutDialog.qml"), QString("hifi/dialogs/TabletAboutDialog.qml"), "AboutDialog"); }); helpMenu->addSeparator(); // Help > HiFi Docs action = addActionToQMenuAndActionHash(helpMenu, "Online Documentation"); connect(action, &QAction::triggered, qApp, [] { QDesktopServices::openUrl(QUrl("https://docs.highfidelity.com/")); }); // Help > HiFi Forum action = addActionToQMenuAndActionHash(helpMenu, "Online Forums"); connect(action, &QAction::triggered, qApp, [] { QDesktopServices::openUrl(QUrl("https://forums.highfidelity.com/")); }); // Help > Scripting Reference action = addActionToQMenuAndActionHash(helpMenu, "Online Script Reference"); connect(action, &QAction::triggered, qApp, [] { QDesktopServices::openUrl(QUrl("https://docs.highfidelity.com/api-reference")); }); addActionToQMenuAndActionHash(helpMenu, "Controls Reference", 0, qApp, SLOT(showHelp())); helpMenu->addSeparator(); // Help > Release Notes action = addActionToQMenuAndActionHash(helpMenu, "Release Notes"); connect(action, &QAction::triggered, qApp, [] { QDesktopServices::openUrl(QUrl("http://steamcommunity.com/games/390540/announcements/")); }); // Help > Report a Bug! action = addActionToQMenuAndActionHash(helpMenu, "Report a Bug!"); connect(action, &QAction::triggered, qApp, [] { QDesktopServices::openUrl(QUrl("mailto:[email protected]")); }); }
void QgsLineString::swapXy() { std::swap( mX, mY ); clearCache(); }
BlockFileIO::~BlockFileIO() { clearCache( _cache, _blockSize ); delete[] _cache.data; }
void QgsLineString::setXAt( int index, double x ) { if ( index >= 0 && index < mX.size() ) mX[ index ] = x; clearCache(); }
bool CloseSweep::chromChange(int dbIdx, RecordKeyVector &retList, bool wantScan) { Record *dbRec = _currDbRecs[dbIdx]; bool haveQuery = _currQueryRec != NULL; bool haveDB = dbRec != NULL; if (haveQuery && _currQueryChromName != _prevQueryChromName) { _context->testNameConventions(_currQueryRec); testChromOrder(_currQueryRec); } if (haveDB) { _context->testNameConventions(dbRec); testChromOrder(dbRec); } // the files are on the same chrom if (haveQuery && (!haveDB || _currQueryRec->sameChrom(dbRec))) { //if this is the first time the query's chrom is ahead of the chrom that was in this cache, //then we have to clear the cache. if (!_caches[dbIdx].empty() && queryChromAfterDbRec(_caches[dbIdx].begin()->value())) { clearCache(dbIdx); clearClosestEndPos(dbIdx); } return false; } if (!haveQuery || !haveDB) return false; if (!_caches[dbIdx].empty() && (_caches[dbIdx].begin()->value()->sameChrom(_currQueryRec))) { //the newest DB record's chrom is ahead of the query, but the cache still //has old records on that query's chrom scanCache(dbIdx, retList); finalizeSelections(dbIdx, retList); return true; } // the query is ahead of the database. fast-forward the database to catch-up. if (queryChromAfterDbRec(dbRec)) { string oldDbChrom(dbRec->getChrName()); while (dbRec != NULL && queryChromAfterDbRec(dbRec)) { _dbFRMs[dbIdx]->deleteRecord(dbRec); if (!nextRecord(false, dbIdx)) break; dbRec = _currDbRecs[dbIdx]; const string &newDbChrom = dbRec->getChrName(); if (newDbChrom != oldDbChrom) { testChromOrder(dbRec); oldDbChrom = newDbChrom; } } clearCache(dbIdx); clearClosestEndPos(dbIdx); return false; } // the database is ahead of the query. else { // 1. scan the cache for remaining hits on the query's current chrom. if (wantScan) scanCache(dbIdx, retList); return true; } //control can't reach here, but compiler still wants a return statement. return true; }
void QgsLineString::setYAt( int index, double y ) { if ( index >= 0 && index < mY.size() ) mY[ index ] = y; clearCache(); }
SINT SoundSourceFFmpeg::seekSampleFrame(SINT frameIndex) { DEBUG_ASSERT(isValidFrameIndex(frameIndex)); int ret = 0; qint64 i = 0; struct ffmpegLocationObject *l_STestObj = nullptr; if (frameIndex < 0 || frameIndex < m_lCacheStartFrame) { // Seek to set (start of the stream which is FFmpeg frame 0) // because we are dealing with compressed audio FFmpeg takes // best of to seek that point (in this case 0 Is always there) // in every other case we should provide MIN and MAX tolerance // which we can take. // FFmpeg just just can't take zero as MAX tolerance so we try to // just make some tolerable (which is never used because zero point // should always be there) some number (which is 0xffff 65535) // that is chosen because in WMA frames can be that big and if it's // smaller than the frame we are seeking we can get into error ret = avformat_seek_file(m_pFormatCtx, m_iAudioStream, 0, 0, 0xffff, AVSEEK_FLAG_BACKWARD); if (ret < 0) { qDebug() << "SoundSourceFFmpeg::seek: Can't seek to 0 byte!"; return -1; } clearCache(); m_lCacheStartFrame = 0; m_lCacheEndFrame = 0; m_lCacheLastPos = 0; m_lCacheFramePos = 0; m_lStoredSeekPoint = -1; // Try to find some jump point near to // where we are located so we don't needed // to try guess it if (m_SJumpPoints.size() > 0) { l_STestObj = m_SJumpPoints.first(); if (frameIndex > l_STestObj->startFrame) { for (i = 0; i < m_SJumpPoints.size(); i++) { if (m_SJumpPoints[i]->startFrame >= frameIndex) { if (i > 0) { i--; } m_lCacheFramePos = m_SJumpPoints[i]->startFrame; m_lStoredSeekPoint = m_SJumpPoints[i]->pos; m_SStoredJumpPoint = m_SJumpPoints[i]; break; } } } } if (frameIndex == 0) { // Because we are in the beginning just read cache full // but leave 50 of just in case // -1 one means we are seeking from current position and // filling the cache readFramesToCache((AUDIOSOURCEFFMPEG_CACHESIZE - 50), AUDIOSOURCEFFMPEG_FILL_FROM_CURRENTPOS); } } if (m_lCacheEndFrame <= frameIndex) { // Cache tries to read until it gets to frameIndex // after that we still read 100 FFmpeg frames to memory // so we have good cache to go forward (100) and backward (900) // from the point readFramesToCache(100, frameIndex); } m_currentMixxxFrameIndex = frameIndex; m_bIsSeeked = true; return frameIndex; }
void QgsLineString::append( const QgsLineString *line ) { if ( !line ) { return; } if ( numPoints() < 1 ) { setZMTypeFromSubGeometry( line, QgsWkbTypes::LineString ); } // do not store duplicit points if ( numPoints() > 0 && line->numPoints() > 0 && endPoint() == line->startPoint() ) { mX.pop_back(); mY.pop_back(); if ( is3D() ) { mZ.pop_back(); } if ( isMeasure() ) { mM.pop_back(); } } mX += line->mX; mY += line->mY; if ( is3D() ) { if ( line->is3D() ) { mZ += line->mZ; } else { // if append line does not have z coordinates, fill with NaN to match number of points in final line mZ.insert( mZ.count(), mX.size() - mZ.size(), std::numeric_limits<double>::quiet_NaN() ); } } if ( isMeasure() ) { if ( line->isMeasure() ) { mM += line->mM; } else { // if append line does not have m values, fill with NaN to match number of points in final line mM.insert( mM.count(), mX.size() - mM.size(), std::numeric_limits<double>::quiet_NaN() ); } } clearCache(); //set bounding box invalid }
void PThreadProcessingDevice::clear() { // delete? clearCache(); clearResult(); }
int main(int argc, char **argv) { srand48(time(NULL)); double *cacheClearer = (double*) malloc(100000000); //L3 cahce is less than 100MB int i; for(i = 0; i < 12500000; i++) cacheClearer[i] = 2 * drand48() - 1; char* alg = argv[1]; int m = atoi(argv[2]); int k = atoi(argv[3]); int n = atoi(argv[4]); int threads = atoi(argv[5]); FILE *f = fopen("data.csv","a"); double *A[NUM_SMALL_MATRICES_MAX], *B[NUM_SMALL_MATRICES_MAX], *C[NUM_SMALL_MATRICES_MAX]; // discover how many multiplies are needed int num_matrices = guess_num_matrices(m, k, n); printf("Num matrices required: %d\n", num_matrices); for (i=0; i<num_matrices; i++) { A[i] = (double*) malloc(m * k * sizeof(double)); B[i] = (double*) malloc(k * n * sizeof(double)); C[i] = (double*) malloc(m * n * sizeof(double)); initialize(m, k, n, A[i], B[i], C[i]); } // Time multiplication struct timeval start, end; multiply(m, k, n, A[0], B[0], C[0]); // warmup clearCache(cacheClearer); // clear cache gettimeofday(&start, NULL); for (i=0; i<num_matrices; i++) multiply(m, k, n, A[i], B[i], C[i]); gettimeofday(&end, NULL); // SK: I'm leaving seconds calculation the same, but calculating GFlop/s by scaling by num_matrices double seconds = (end.tv_sec - start.tv_sec) + 1.0e-6 * (end.tv_usec - start.tv_usec); double Gflop_s = num_matrices * 2e-9 * m * k * n / seconds; if (seconds < 0.01) { printf("WARNING: Matrix size may be too small to produce accurate timing data\n"); } fprintf(f,"%s,%d,%d,%d,%d,%f\n", alg, m, k, n, threads, Gflop_s); printf("%s,%d,%d,%d,%d,%f\n", alg, m, k, n, threads, Gflop_s); // check for correctness /* // memset(C, 0, sizeof(double) * m * n); //if commented, this tests C = A*B instead of C += A*B multiply(m, k, n, A, B, C); cblas_dgemm(CblasColMajor,CblasNoTrans,CblasNoTrans, m,n,k, -1, A,m, B,k, 1, C,m); for(i = 0; i < m*k; i++) A[i] = fabs( A[i] ); for(i = 0; i < k*n; i++) B[i] = fabs( B[i] ); for(i = 0; i < m*n; i++) C[i] = fabs( C[i] ); cblas_dgemm(CblasColMajor,CblasNoTrans,CblasNoTrans, m,n,k, -3.0*DBL_EPSILON*n, A,m, B,k, 1, C,m); for(i = 0; i < m*n; i++) { if(C[i] > 0) { printf("FAILURE: error in matrix multiply exceeds an acceptable margin\n"); return -1; } } */ for (i=0; i<num_matrices; i++) free(A[i]); for (i=0; i<num_matrices; i++) free(B[i]); for (i=0; i<num_matrices; i++) free(C[i]); free(cacheClearer); fclose(f); return 0; }
btConvexTriangleCallback::~btConvexTriangleCallback() { clearCache(); m_dispatcher->releaseManifold( m_manifoldPtr ); }
void XTable::clear() { clearCache(); // invalidate any stored interpolations _array.fill(0.); }