~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to arts/tools/fftscopeview.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
    Copyright ( C ) 2000-2001 Stefan Westerfeld
 
4
                              <stefan@space.twc.de>
 
5
                    2003 Arnold Krille <arnold@arnoldarts.de>
 
6
 
 
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.
 
11
 
 
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.
 
16
 
 
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.
 
20
 
 
21
    */
 
22
 
 
23
#include "fftscopeview.h"
 
24
 
 
25
#include <qlayout.h>
 
26
#include <qcursor.h>
 
27
#include <qtimer.h>
 
28
#include <kaction.h>
 
29
#include <kpopupmenu.h>
 
30
#include <kartswidget.h>
 
31
#include <kdebug.h>
 
32
#include <klocale.h>
 
33
#include <kiconloader.h>
 
34
 
 
35
#include "artsactions.h"
 
36
 
 
37
using namespace std;
 
38
using namespace Arts;
 
39
 
 
40
FFTScopeView::FFTScopeView( SimpleSoundServer server, QWidget* parent )
 
41
        : Template_ArtsView( parent )
 
42
        , server( server )
 
43
        , scopeData( 0 )
 
44
{
 
45
kdDebug()<<k_funcinfo<<endl;
 
46
        this->setCaption( i18n( "FFT Scope View" ) );
 
47
        this->setIcon( MainBarIcon( "artsfftscope", 32 ) );
 
48
        /*
 
49
           create a stereo fft scope on the server and push it into the
 
50
           effect chain
 
51
        */
 
52
        {
 
53
                scopefx = DynamicCast( server.createObject( "Arts::StereoFFTScope" ) );
 
54
                assert( !scopefx.isNull() );
 
55
                scopefx.start();
 
56
 
 
57
                // put it into the effect chain
 
58
                effectID = server.outstack().insertBottom( scopefx,"FFT Scope" );
 
59
        }
 
60
 
 
61
        updateScopeData();
 
62
        QBoxLayout * l = new QHBoxLayout(  this );
 
63
        l->setAutoAdd( TRUE );
 
64
 
 
65
        for ( unsigned int i=0;i<scopeData->size();i++ )
 
66
        {
 
67
                LevelMeter tmp;
 
68
                tmp.count( 20 );
 
69
                scopeScales.push_back( tmp );
 
70
                scopeDraw.push_back( 0.0 );
 
71
                KArtsWidget *w = new KArtsWidget( tmp, this );
 
72
                aw.push_back( w );
 
73
        }
 
74
 
 
75
        l->activate();
 
76
        show();
 
77
 
 
78
        updatetimer = new QTimer( this );
 
79
        updatetimer->start( 100 );
 
80
        connect( updatetimer,SIGNAL( timeout() ),this,SLOT( updateScope() ) );
 
81
 
 
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() );
 
90
 
 
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() ) );
 
97
}
 
98
 
 
99
FFTScopeView::~FFTScopeView() {
 
100
kdDebug()<<"FFTScopeView::~FFTScopeView()"<<endl;
 
101
        updatetimer->stop();
 
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;
 
105
}
 
106
 
 
107
void FFTScopeView::updateScopeData() {
 
108
        if ( scopeData ) delete scopeData;
 
109
        scopeData = scopefx.scope();
 
110
}
 
111
 
 
112
void FFTScopeView::updateScope() {
 
113
        updateScopeData();
 
114
 
 
115
        for ( unsigned int i=0;i<scopeData->size();i++ )
 
116
        {
 
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 ] );
 
121
        }
 
122
}
 
123
 
 
124
void FFTScopeView::mousePressEvent( QMouseEvent* ev ) {
 
125
        if ( Qt::RightButton == ev->button() /*|| Qt::LeftButton == ev->button()*/ )
 
126
                _menu->exec(  QCursor::pos() );
 
127
}
 
128
 
 
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 );
 
133
}
 
134
 
 
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 );
 
139
}
 
140
 
 
141
void FFTScopeView::setStyle( Arts::LevelMeterStyle style ) {
 
142
        for ( uint i=0; i<scopeScales.size(); i++ )
 
143
                scopeScales[ i ].style( style );
 
144
}
 
145
 
 
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 ); }
 
152
 
 
153
#include <kinputdialog.h>
 
154
 
 
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 );
 
159
}
 
160
 
 
161
#include "fftscopeview.moc"
 
162
// vim: sw=4 ts=4
 
163