inline static bool isPenValid() { if( !painter ) { qcErrorMsg( QString("Usage of QPen is not allowed at this point!") ); return false; } return true; }
static int mediate( VMGlobals *g, int i ) { if( !globalPainter() ) { qcErrorMsg( QString("Usage of QPen is not allowed at this point!") ); return errFailed; } PyrSlot *stack = g->sp - i + 1; int ret = (*FN)( stack, i > 1 ? stack+1 : 0, g ); return ret; }
void QcScrollArea::setWidget( QObjectProxy *proxy ) { QWidget *w = qobject_cast<QWidget*>( proxy->object() ); if( !w ) { qcErrorMsg( "QcScrollArea::setCanvas: given proxy does not contain a valid widget." ); return; } QScrollArea::setWidget( w ); setWidgetResizable( true ); }
void QcWaveform::load( const QString& filename ) { qcDebugMsg( 1, "QcWaveform::load( filename )" ); SF_INFO new_info; memset( &new_info, 0, sizeof(SF_INFO) ); SNDFILE *new_sf = sf_open( filename.toStdString().c_str(), SFM_READ, &new_info ); if( !new_sf ) { qcErrorMsg(QString("Could not open soundfile: ") + filename); return; } doLoad( new_sf, new_info, 0, new_info.frames ); }
// WARNING: QtCollider::lockLang() must be called before void QtCollider::runLang ( PyrObjectHdr *receiver, PyrSymbol *method, const QList<QVariant> & args, PyrSlot *result ) { VMGlobals *g = gMainVMGlobals; g->canCallOS = true; ++g->sp; SetObject(g->sp, receiver); Q_FOREACH( QVariant var, args ) { ++g->sp; if( !QtCollider::set( g->sp, var ) ) { qcErrorMsg("Failed to write a slot when trying to run interpreter!"); SetNil( g->sp ); } }
void QcWaveform::doLoad( SNDFILE *new_sf, const SF_INFO &new_info, sf_count_t beg, sf_count_t dur ) { // set up soundfile to scale data in range [-1,1] to int range // when reading floating point data as int sf_command( new_sf, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE ); // check beginning and duration validity if( beg < 0 || dur < 1 || beg + dur > new_info.frames ) { qcErrorMsg("Invalid beginning and/or duration."); sf_close( new_sf ); return; } // cleanup previous state // NOTE we have to delete SoundCacheStream before closing the soundfile, as it might be still // loading it // TODO: should SoundCacheStream open the soundfile on its own? delete _cache; if( sf ) sf_close( sf ); sf = new_sf; sfInfo = new_info; _beg = _rangeBeg = beg; _dur = _rangeDur = dur; _rangeEnd = _rangeBeg + _rangeDur; updateFPP(); _cache = new SoundCacheStream(); connect( _cache, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int)) ); connect( _cache, SIGNAL(loadProgress(int)), this, SLOT(update()) ); connect( _cache, SIGNAL(loadingDone()), this, SIGNAL(loadingDone()) ); connect( _cache, SIGNAL(loadingDone()), this, SLOT(redraw()) ); _cache->load( sf, sfInfo, beg, dur, kMaxFramesPerCacheUnit, kMaxRawFrames ); redraw(); }
bool beginPainting( QPainter *p ) { if( painter ) { qcErrorMsg( QString("Painting already in progress!") ); return false; } painter = p; painter->setRenderHint( QPainter::Antialiasing, true ); QColor black( 0,0,0 ); QPen pen( black ); pen.setCapStyle( Qt::FlatCap ); painter->setPen( pen ); painter->setBrush( black ); path = QPainterPath(); return true; }