3
Copyright ( C ) 2000-2001 Stefan Westerfeld
5
2003 Arnold Krille <arnold@arnoldarts.de>
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
( at your option ) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
#include "fftscopeview.h"
29
#include <kpopupmenu.h>
30
#include <kartswidget.h>
33
#include <kiconloader.h>
35
#include "artsactions.h"
40
FFTScopeView::FFTScopeView( SimpleSoundServer server, QWidget* parent )
41
: Template_ArtsView( parent )
45
kdDebug()<<k_funcinfo<<endl;
46
this->setCaption( i18n( "FFT Scope View" ) );
47
this->setIcon( MainBarIcon( "artsfftscope", 32 ) );
49
create a stereo fft scope on the server and push it into the
53
scopefx = DynamicCast( server.createObject( "Arts::StereoFFTScope" ) );
54
assert( !scopefx.isNull() );
57
// put it into the effect chain
58
effectID = server.outstack().insertBottom( scopefx,"FFT Scope" );
62
QBoxLayout * l = new QHBoxLayout( this );
63
l->setAutoAdd( TRUE );
65
for ( unsigned int i=0;i<scopeData->size();i++ )
69
scopeScales.push_back( tmp );
70
scopeDraw.push_back( 0.0 );
71
KArtsWidget *w = new KArtsWidget( tmp, this );
78
updatetimer = new QTimer( this );
79
updatetimer->start( 100 );
80
connect( updatetimer,SIGNAL( timeout() ),this,SLOT( updateScope() ) );
82
_artsactions = new ArtsActions( 0, 0, this );
83
_moreBars = ArtsActions::actionMoreBars( this, SLOT( moreBars() ), 0 );
84
_lessBars = ArtsActions::actionLessBars( this, SLOT( lessBars() ), 0 );
85
_menu = new KPopupMenu( 0 );
86
_moreBars->plug( _menu ); _lessBars->plug( _menu );
87
_substyle = new KAction( i18n( "Substyle" ), "", KShortcut(), this, SLOT( substyle() ), this );
88
_substyle->plug( _menu );
89
_menu->insertItem( i18n("VU-Style"), _artsactions->stylemenu() );
91
connect( _artsactions, SIGNAL( styleNormal() ), this, SLOT( styleNormalBars() ) );
92
connect( _artsactions, SIGNAL( styleFire() ), this, SLOT( styleFireBars() ) );
93
connect( _artsactions, SIGNAL( styleLine() ), this, SLOT( styleLineBars() ) );
94
connect( _artsactions, SIGNAL( styleLED() ), this, SLOT( styleLEDs() ) );
95
connect( _artsactions, SIGNAL( styleAnalog() ), this, SLOT( styleAnalog() ) );
96
connect( _artsactions, SIGNAL( styleSmall() ), this, SLOT( styleSmall() ) );
99
FFTScopeView::~FFTScopeView() {
100
kdDebug()<<"FFTScopeView::~FFTScopeView()"<<endl;
102
for ( int i=int( aw.size() )-1; i>=0; i-- ) { scopeScales[ i ].hide(); delete aw[ i ]; aw.pop_back(); scopeScales.pop_back(); }
103
server.outstack().remove( effectID );
104
kdDebug()<<"FFTScopeView is gone..."<<endl;
107
void FFTScopeView::updateScopeData() {
108
if ( scopeData ) delete scopeData;
109
scopeData = scopefx.scope();
112
void FFTScopeView::updateScope() {
115
for ( unsigned int i=0;i<scopeData->size();i++ )
117
// scopeDraw[ i ] /= 1.25;
118
// if ( ( *scopeData )[ i ] > scopeDraw[ i ] ) scopeDraw[ i ] = ( *scopeData )[ i ];
119
scopeDraw[ i ] = ( *scopeData )[ i ];
120
scopeScales[ i ].invalue( scopeDraw[ i ] );
124
void FFTScopeView::mousePressEvent( QMouseEvent* ev ) {
125
if ( Qt::RightButton == ev->button() /*|| Qt::LeftButton == ev->button()*/ )
126
_menu->exec( QCursor::pos() );
129
void FFTScopeView::moreBars() {
130
int bars = scopeScales[ 0 ].count() + 10;
131
for ( unsigned int i=0;i<scopeData->size();i++ )
132
scopeScales[ i ].count( bars );
135
void FFTScopeView::lessBars() {
136
int bars = scopeScales[ 0 ].count() - 10;
137
for ( unsigned int i=0;i<scopeData->size();i++ )
138
scopeScales[ i ].count( bars );
141
void FFTScopeView::setStyle( Arts::LevelMeterStyle style ) {
142
for ( uint i=0; i<scopeScales.size(); i++ )
143
scopeScales[ i ].style( style );
146
void FFTScopeView::styleNormalBars() { setStyle( Arts::lmNormalBars ); }
147
void FFTScopeView::styleFireBars() { setStyle( Arts::lmFireBars ); }
148
void FFTScopeView::styleLineBars() { setStyle( Arts::lmLineBars ); }
149
void FFTScopeView::styleLEDs() { setStyle( Arts::lmLEDs ); }
150
void FFTScopeView::styleAnalog() { setStyle( Arts::lmAnalog ); }
151
void FFTScopeView::styleSmall() { setStyle( Arts::lmSmall ); }
153
#include <kinputdialog.h>
155
void FFTScopeView::substyle() {
156
int _substyle = KInputDialog::getInteger( i18n("Substyle"), i18n("Please enter substyle:"), 0, 0, 10, 1, 0, this );
157
for ( unsigned int i=0; i<scopeData->size(); i++ )
158
scopeScales[ i ].substyle( _substyle );
161
#include "fftscopeview.moc"