/*! \reimp */ void QRadioButton::resizeEvent( QResizeEvent* e ) { QButton::resizeEvent(e); int x, w, h; GUIStyle gs = style(); QSize sz = style().exclusiveIndicatorSize(); if ( gs == WindowsStyle ) sz.setWidth(sz.width()+1); x = sz.width() + gutter; w = width() - x; h = height(); QPainter p(this); QRect br = style().itemRect( &p, x, 0, w, h, AlignLeft|AlignVCenter|ShowPrefix, isEnabled(), pixmap(), text() ); if ( autoMask() ) updateMask(); update( br.right(), w, 0, h ); }
void WebGLContext::Clear(GLbitfield mask) { const char funcName[] = "clear"; if (IsContextLost()) return; MakeContextCurrent(); uint32_t m = mask & (LOCAL_GL_COLOR_BUFFER_BIT | LOCAL_GL_DEPTH_BUFFER_BIT | LOCAL_GL_STENCIL_BUFFER_BIT); if (mask != m) return ErrorInvalidValue("%s: invalid mask bits", funcName); if (mask == 0) { GenerateWarning("Calling gl.clear(0) has no effect."); } else if (mRasterizerDiscardEnabled) { GenerateWarning("Calling gl.clear() with RASTERIZER_DISCARD enabled has no effects."); } if (mBoundDrawFramebuffer) { if (!mBoundDrawFramebuffer->ValidateAndInitAttachments(funcName)) return; gl->fClear(mask); return; } else { ClearBackbufferIfNeeded(); } // Ok, we're clearing the default framebuffer/screen. { ScopedMaskWorkaround autoMask(*this); gl->fClear(mask); } Invalidate(); mShouldPresent = true; }
void WebGLContext::DrawElements(GLenum mode, GLsizei count, GLenum type, WebGLintptr byteOffset) { const char funcName[] = "drawElements"; if (IsContextLost()) return; if (!ValidateDrawModeEnum(mode, funcName)) return; MakeContextCurrent(); bool error; ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error); if (error) return; GLuint upperBound = 0; if (!DrawElements_check(count, type, byteOffset, 1, funcName, &upperBound)) return; RunContextLossTimer(); { ScopedMaskWorkaround autoMask(*this); if (gl->IsSupported(gl::GLFeature::draw_range_elements)) { gl->fDrawRangeElements(mode, 0, upperBound, count, type, reinterpret_cast<GLvoid*>(byteOffset)); } else { gl->fDrawElements(mode, count, type, reinterpret_cast<GLvoid*>(byteOffset)); } } Draw_cleanup(funcName); }
void QSlider::reallyMoveSlider( int newPos ) { QRect oldR = sliderRect(); sliderPos = newPos; QRect newR = sliderRect(); //since sliderRect isn't virtual, I know that oldR and newR // are the same size. if ( orient == Horizontal ) { if ( oldR.left() < newR.left() ) oldR.setRight( QMIN ( oldR.right(), newR.left())); else //oldR.right() >= newR.right() oldR.setLeft( QMAX ( oldR.left(), newR.right())); } else { if ( oldR.top() < newR.top() ) oldR.setBottom( QMIN ( oldR.bottom(), newR.top())); else //oldR.bottom() >= newR.bottom() oldR.setTop( QMAX ( oldR.top(), newR.bottom())); } repaint( oldR ); repaint( newR, FALSE ); if ( autoMask() ) updateMask(); }
void WebGLContext::DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, WebGLintptr byteOffset, GLsizei primcount) { const char funcName[] = "drawElementsInstanced"; if (IsContextLost()) return; if (!ValidateDrawModeEnum(mode, funcName)) return; MakeContextCurrent(); bool error; ScopedResolveTexturesForDraw scopedResolve(this, funcName, &error); if (error) return; GLuint upperBound = 0; if (!DrawElements_check(count, type, byteOffset, primcount, funcName, &upperBound)) return; if (!DrawInstanced_check(funcName)) return; RunContextLossTimer(); { ScopedMaskWorkaround autoMask(*this); gl->fDrawElementsInstanced(mode, count, type, reinterpret_cast<GLvoid*>(byteOffset), primcount); } Draw_cleanup(funcName); }
/********************************** T2Fit ************************************ * This is where the work will be done *************************************************************************************/ OSErr T2Fit( FILE *inFile, FILE *outFile ) { OSErr error = noErr; long theTimePt; int i; float *inData, *outData, *T2, *intercept, *chi2, *Smoother; long VolSize, outVolBytes, inVolBytes; float te[ u.inIm.dim.timePts ]; unsigned char *theMask; short rules; u.NumOutImages = 0; VolSize = u.inIm.dim.isoX * u.inIm.dim.isoY * u.inIm.dim.n_slices; inVolBytes = VolSize * get_datasize( T_FLOAT ); outVolBytes = VolSize * get_datasize( u.outIm.data_type ); T2 = (float *)ck_malloc( inVolBytes, "Storage for R2" ); intercept = (float *)ck_malloc( inVolBytes, "Storage for intercept" ); chi2 = (float *)ck_malloc( inVolBytes, "Storage for chi2" ); outData = (float *)ck_malloc( outVolBytes, "Storage for output data" ); inData = (float *)ck_malloc( inVolBytes * u.inIm.dim.timePts, "Storage for input data" ); theMask = (unsigned char*)ck_malloc( VolSize * sizeof( unsigned char ), "Storage for theMask" ); if( u.Smooth ) { Smoother = (float *)ck_malloc( inVolBytes * 2, "Storage for smoothing" ); } // load up te vector if( u.Verbose ) { printf( "TE: " ); } for( i=0; i<u.inIm.dim.timePts; i++ ) { fscanf(u.TEFile ,"%f", &te[i]); if( u.Verbose ) { printf( "%0.3f ", te[i] ); } } // We will do everything in float SetImDatatype( &u.inIm, T_FLOAT ); // Load all of the images into a single matrix for ( theTimePt = 0; theTimePt < u.inIm.dim.timePts; theTimePt++ ) { error = GetSelectedVolume( inFile, &u.inIm, inData+theTimePt*VolSize, theTimePt ); RETURNONERROR; if( u.Smooth ) { vmov( inData+theTimePt*VolSize, 1, Smoother, 1, VolSize, T_FLOAT ); error = gaussSmooth( &u.inIm, Smoother, inData+theTimePt*VolSize, &u.xSmooth, &u.ySmooth, &u.zSmooth ); RETURNONERROR; } RETURNONERROR; } // threshold on first images if( u.autoThresh ) { error = autoMask( inData, theMask, VolSize, &u.threshold, &u.nonNoise, T_FLOAT ); RETURNONERROR; } else if( u.threshold != 0 ) { u.nonNoise = ThreshMask( inData, theMask, VolSize, &u.threshold, T_FLOAT ); } else { u.nonNoise = VolSize; } error = CalcT2( &u.inIm, inData, theMask, te, T2, intercept, chi2 ); RETURNONERROR; free( inData ); error = type_convert( T2, T_FLOAT, outData, u.outIm.data_type, VolSize, &u.outIm.theMinf, &u.outIm.theMaxf, &rules ); if( error && error != CONVERSION_ERROR ) return error; error = ck_fwrite( outData, 1, outVolBytes, outFile ); u.NumOutImages++; RETURNONERROR; error = type_convert( intercept, T_FLOAT, outData, u.outIm.data_type, VolSize, &u.outIm.theMinf, &u.outIm.theMaxf, &rules ); if( error && error != CONVERSION_ERROR ) return error; error = ck_fwrite( outData, 1, outVolBytes, outFile ); u.NumOutImages++; RETURNONERROR; if( u.Smooth ) { free( Smoother ); } // Make R2 image for( i=0; i<VolSize; i++ ) { if( T2[i] !=0 ) { T2[i] = 1/T2[i]; } } error = type_convert( T2, T_FLOAT, outData, u.outIm.data_type, VolSize, &u.outIm.theMinf, &u.outIm.theMaxf, &rules ); if( error && error != CONVERSION_ERROR ) return error; error = ck_fwrite( outData, 1, outVolBytes, outFile ); u.NumOutImages++; RETURNONERROR; error = type_convert( chi2, T_FLOAT, outData, u.outIm.data_type, VolSize, &u.outIm.theMinf, &u.outIm.theMaxf, &rules ); if( error && error != CONVERSION_ERROR ) return error; error = ck_fwrite( outData, 1, outVolBytes, outFile ); u.NumOutImages++; RETURNONERROR; fprintf( u.ProcFile, "Output file contains maps of T2, M0, R2 and chi2\n" ); fprintf( u.ProcFile, "TE's used: " ); for( i=0; i<u.inIm.dim.timePts; i++ ) { fprintf( u.ProcFile, "%0.3f ", te[i] ); } fprintf( u.ProcFile, "\n" ); fprintf( u.ProcFile, "Input data were intensity thresholded at %0.3f\n", u.threshold ); fprintf( u.ProcFile, "Non-Noise Points:\t%ld\n", u.nonNoise ); if( u.Smooth ) { fprintf( u.ProcFile, "Input images were smoothed with a width of %0.3f mm in x, %0.3f mm in y and %0.3f mm in z\n", u.xSmooth, u.ySmooth, u.zSmooth ); } fprintf( stderr, "Output file contains maps of T2, M0, R2 and chi2\n" ); fprintf( stderr, "TE's used: " ); for( i=0; i<u.inIm.dim.timePts; i++ ) { fprintf( stderr, "%0.3f ", te[i] ); } fprintf( stderr, "\n" ); fprintf( stderr, "Input data were intensity thresholded at %0.3f\n", u.threshold ); fprintf( stderr, "Non-Noise Points:\t%ld\n\n", u.nonNoise ); if( u.Smooth ) { fprintf( stderr, "Input images were smoothed with a width of %0.3f mm in x, %0.3f mm in y and %0.3f mm in z\n", u.xSmooth, u.ySmooth, u.zSmooth ); } free( theMask ); free( outData ); free( chi2 ); free( intercept ); free( T2 ); return error; }
/* Set up the layout. */ void QTabWidget::setUpLayout( bool onlyCheck ) { if ( onlyCheck && !d->dirty ) return; // nothing to do if ( !isVisible() ) { d->dirty = TRUE; return; // we'll do it later } QSize t( 0, d->stack->frameWidth() ); if ( d->tabs->isVisibleTo(this) ) t = d->tabs->sizeHint(); int lcw = 0; if ( d->leftCornerWidget && d->leftCornerWidget->isVisible() ) { QSize sz = d->leftCornerWidget->sizeHint(); d->leftCornerWidget->resize(sz); lcw = sz.width(); if ( t.height() > lcw ) lcw = t.height(); } int rcw = 0; if ( d->rightCornerWidget && d->rightCornerWidget->isVisible() ) { QSize sz = d->rightCornerWidget->sizeHint(); d->rightCornerWidget->resize(sz); rcw = sz.width(); if ( t.height() > rcw ) rcw = t.height(); } int tw = width() - lcw - rcw; if ( t.width() > tw ) t.setWidth( tw ); int lw = d->stack->lineWidth(); bool reverse = QApplication::reverseLayout(); int tabx, taby, stacky, exty, exth, overlap; exth = style().pixelMetric( QStyle::PM_TabBarBaseHeight, this ); overlap = style().pixelMetric( QStyle::PM_TabBarBaseOverlap, this ); if ( reverse ) tabx = QMIN( width() - t.width(), width() - t.width() - lw + 2 ) - lcw; else tabx = QMAX( 0, lw - 2 ) + lcw; if ( d->pos == Bottom ) { taby = height() - t.height() - lw; stacky = 0; exty = taby - (exth - overlap); } else { // Top taby = 0; stacky = t.height()-lw + (exth - overlap); exty = taby + t.height() - overlap; } // do alignment int alignment = style().styleHint( QStyle::SH_TabBar_Alignment, this ); if ( alignment != AlignLeft && t.width() < width() ) { if ( alignment == AlignHCenter ) tabx += (width()-lcw-rcw)/2 - t.width()/2; else if ( alignment == AlignRight ) tabx += width() - t.width() - rcw; } d->tabs->setGeometry( tabx, taby, t.width(), t.height() ); d->tabBase->setGeometry( 0, exty, width(), exth ); if ( exth == 0 ) d->tabBase->hide(); else d->tabBase->show(); d->stack->setGeometry( 0, stacky, width(), height() - (exth-overlap) - t.height()+QMAX(0, lw-2)); d->dirty = FALSE; // move cornerwidgets if ( d->leftCornerWidget ) { int y = ( t.height() / 2 ) - ( d->leftCornerWidget->height() / 2 ); int x = ( reverse ? width() - lcw + y : y ); d->leftCornerWidget->move( x, y + taby ); } if ( d->rightCornerWidget ) { int y = ( t.height() / 2 ) - ( d->rightCornerWidget->height() / 2 ); if ( !onlyCheck ) update(); updateGeometry(); if ( autoMask() ) updateMask(); int x = ( reverse ? y : width() - rcw + y ); d->rightCornerWidget->move( x, y + taby ); } }