Beispiel #1
0
void Oscilloscope::setZoomLevel( double zoomLevel)
{
	if( zoomLevel < 0.0)
		zoomLevel = 0.0;
	
	else if( zoomLevel > 1.0)
		zoomLevel = 1.0;
	
	KGlobal::config()->setGroup("Oscilloscope");
	KGlobal::config()->writeEntry( "ZoomLevel", zoomLevel);
	
	// We want to maintain the position of the *center* of the view, not the
	// left edge, so have to record time at center of view... We also have to
	// handle the case where the scroll is at the end separately.
	bool wasAtUpperEnd = horizontalScroll->maxValue() == horizontalScroll->value();
	int pageLength = int(oscilloscopeView->width()*sliderTicksPerSecond()/pixelsPerSecond());
	int at_ticks = horizontalScroll->value() + (pageLength/2);
	
	m_zoomLevel = zoomLevel;
	zoomSlider->setValue( int((double(zoomSlider->maxValue())*zoomLevel)+0.5));
	updateScrollbars();
	
	// And restore the center position of the slider
	if(!wasAtUpperEnd)
	{
		int pageLength = int(oscilloscopeView->width()*sliderTicksPerSecond()/pixelsPerSecond());
		horizontalScroll->setValue( at_ticks - (pageLength/2));
		oscilloscopeView->updateView();
	}
}
Beispiel #2
0
int64_t Oscilloscope::scrollTime() const
{
// 	if( b_isPaused || numberOfProbes() == 0)
// 		return 0;

	if( numberOfProbes() == 0) return 0;

	if( horizontalScroll->maxValue() == 0)
	{
		int64_t lengthAsTime = int64_t( oscilloscopeView->width() * LOGIC_UPDATE_RATE / pixelsPerSecond());
		int64_t ret =  m_pSimulator->time() - lengthAsTime;
		if(ret < 0) return 0;
		return ret;
	} else return int64_t( m_oldestProbe->resetTime() + (int64_t(horizontalScroll->value()) * LOGIC_UPDATE_RATE / sliderTicksPerSecond()));
}
Beispiel #3
0
void Oscilloscope::updateScrollbars()
{
	bool wasAtUpperEnd = horizontalScroll->maxValue() == horizontalScroll->value();
	
	const float pps = pixelsPerSecond();
	
	int pageLength = int(oscilloscopeView->width()*sliderTicksPerSecond()/pps);
	int64_t timeAsTicks = time()*sliderTicksPerSecond()/LOGIC_UPDATE_RATE;
	int64_t upper = (timeAsTicks > pageLength) ? (timeAsTicks - pageLength) : 0;
	horizontalScroll->setRange( 0, upper);
	
	horizontalScroll->setPageStep( uint64_t(oscilloscopeView->width()*sliderTicksPerSecond()/pps));
	
	if(wasAtUpperEnd)
	{
		horizontalScroll->setValue( horizontalScroll->maxValue());
		oscilloscopeView->updateView();
	}
}
Beispiel #4
0
void midiConductor::setup(double totalTime, double pixPerSecond)
{
	setPlaybackTime(totalTime);
	pixelsPerSecond(pixPerSecond);
}