QVariant MashStepTableModel::data( const QModelIndex& index, int role ) const { MashStep* row; unitDisplay unit; unitScale scale; int col = index.column(); if( mashObs == 0 ) return QVariant(); // Ensure the row is ok. if( index.row() >= (int)(steps.size()) ) { Brewtarget::logW(tr("Bad model index. row = %1").arg(index.row())); return QVariant(); } else row = steps[index.row()]; // Make sure we only respond to the DisplayRole role. if( role != Qt::DisplayRole ) return QVariant(); switch( col ) { case MASHSTEPNAMECOL: return QVariant(row->name()); case MASHSTEPTYPECOL: return QVariant(row->typeStringTr()); case MASHSTEPAMOUNTCOL: unit = displayUnit(col); scale = displayScale(col); return (row->type() == MashStep::Decoction) ? QVariant( Brewtarget::displayAmount(row->decoctionAmount_l(), Units::liters, 3, unit, scale ) ) : QVariant( Brewtarget::displayAmount(row->infuseAmount_l(), Units::liters, 3, unit, scale) ); case MASHSTEPTEMPCOL: unit = displayUnit(col); return (row->type() == MashStep::Decoction) ? QVariant("---") : QVariant( Brewtarget::displayAmount(row->infuseTemp_c(), Units::celsius, 3, unit, noScale) ); case MASHSTEPTARGETTEMPCOL: unit = displayUnit(col); return QVariant( Brewtarget::displayAmount(row->stepTemp_c(), Units::celsius,3, unit, noScale) ); case MASHSTEPTIMECOL: scale = displayScale(col); return QVariant( Brewtarget::displayAmount(row->stepTime_min(), Units::minutes,0,noUnit,scale) ); default : Brewtarget::logW(tr("Bad column: %1").arg(index.column())); return QVariant(); } }
void DOFFilter::drawFullscreen() { mGlslProg->uniform("uRenderedTexture", 0); mGlslProg->uniform("uDepthTexture", 1); mGlslProg->uniform("uFocalDepth", mManualFocalDepth); mGlslProg->uniform("uMaxBlur", mMaxBlur * displayScale()); #ifdef ADVANCED_SHADER mGlslProg->uniform("uRenderedTextureWidth", (float)mSceneFBO->getWidth()); mGlslProg->uniform("uRenderedTextureHeight", (float)mSceneFBO->getHeight()); mGlslProg->uniform("uUseAutofocus", mUseAutofocus); mGlslProg->uniform("uAutofocusCenter", mAutofocusCenter); mGlslProg->uniform("uNumRings", mNumRings); mGlslProg->uniform("uNumSamples", mNumSamples); mGlslProg->uniform("uHighlightThreshold", mHighlightThreshold); mGlslProg->uniform("uHighlightGain", mHighlightGain); mGlslProg->uniform("uBokehEdgeBias", mBokehEdgeBias); mGlslProg->uniform("uBokehFringe", mBokehFringe); mGlslProg->uniform("uAperture", mAperture / displayScale()); #else mGlslProg->uniform("uAspectRatio", getWindowAspectRatio()); mGlslProg->uniform("uAperture", mAperture / displayScale() / 15); #endif gl::ScopedTextureBind tex0(mSceneFBO->getColorTexture(), 0); gl::ScopedTextureBind tex1(mSceneFBO->getDepthTexture(), 1); const gl::ScopedViewport scopedViewport(ivec2(0), toPixels(getWindowSize())); const gl::ScopedMatrices scopedMatrices; gl::setMatricesWindow(toPixels(getWindowSize())); gl::translate(toPixels(getWindowSize() / 2)); gl::scale(toPixels(getWindowSize())); gl::disableDepthRead(); gl::disableDepthWrite(); gl::clear(Color::black()); mQuadBatch->draw(); }
void MashStepTableModel::contextMenu(const QPoint &point) { QObject* calledBy = sender(); QHeaderView* hView = qobject_cast<QHeaderView*>(calledBy); int selected = hView->logicalIndexAt(point); unitDisplay currentUnit; unitScale currentScale; // Since we need to call generateVolumeMenu() two different ways, we need // to figure out the currentUnit and Scale here currentUnit = displayUnit(selected); currentScale = displayScale(selected); QMenu* menu; QAction* invoked; switch(selected) { case MASHSTEPAMOUNTCOL: menu = Brewtarget::setupVolumeMenu(parentTableWidget,currentUnit, currentScale); break; case MASHSTEPTEMPCOL: case MASHSTEPTARGETTEMPCOL: menu = Brewtarget::setupTemperatureMenu(parentTableWidget,currentUnit); break; case MASHSTEPTIMECOL: menu = Brewtarget::setupTimeMenu(parentTableWidget,currentScale); break; default: return; } invoked = menu->exec(hView->mapToGlobal(point)); if ( invoked == 0 ) return; QWidget* pMenu = invoked->parentWidget(); if ( pMenu == menu ) setDisplayUnit(selected,(unitDisplay)invoked->data().toInt()); else setDisplayScale(selected,(unitScale)invoked->data().toInt()); }