Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

qwavmonowaveview.h

00001 /***************************************************************************
00002                           soneframedview.h  -  description
00003                              -------------------
00004     begin                : Sat Nov 9 2002
00005     copyright            : (C) 2002 by Peter Eschler
00006     email                : eschler@users.sourceforge.net
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef QwavMONOWAVEVIEW_H_
00019 #define QwavMONOWAVEVIEW_H_
00020 
00021 //---------------------------------------------------------------------------
00022 // Includes: Qt
00023 //---------------------------------------------------------------------------
00024 
00025 #include <qwidget.h>
00026 #include <qlayout.h>
00027 #include <qlabel.h>
00028 #include <qlineedit.h>
00029 #include <qpushbutton.h>
00030 #include <qslider.h>
00031 #include <qscrollbar.h>
00032 
00033 //---------------------------------------------------------------------------
00034 // Includes: project
00035 //---------------------------------------------------------------------------
00036 
00037 #include "qwavdefines.h"
00038 #include "qwavexceptions.h"
00039 #include "qwavwaveviewinterface.h"
00040 #include "qwavwaveview.h"
00041 
00042 //---------------------------------------------------------------------------
00043 // Includes: Qwt
00044 //---------------------------------------------------------------------------
00045 
00046 #include "qwt_slider.h"
00047 #include "qwt_scale.h"
00048 
00049 
00050 //---------------------------------------------------------------------------
00051 // Includes: system
00052 //---------------------------------------------------------------------------
00053 
00054 #include <string>
00055 
00056 //---------------------------------------------------------------------------
00057 // Forward declarations
00058 //---------------------------------------------------------------------------
00059 
00060 Qwav_USING_NAMESPACE
00061 
00062 Qwav_BEGIN_NAMESPACE
00063 
00064 // class QwavWaveView;
00065 class QwavWaveDataInterface;
00066 
00067 //---------------------------------------------------------------------------
00068 // Class: QwavMonoWaveView
00069 //---------------------------------------------------------------------------
00070    
00078 class QWAV_EXPORTIMPORT QwavMonoWaveView 
00079   : public QWidget, 
00080     public QwavWaveViewInterface
00081 {
00082     Q_OBJECT
00083     
00084 public:
00085 
00086     /*---------------------------------------------------------------------*/
00090     QwavMonoWaveView(QwavWaveDataInterface* waveData,
00091                  QWidget*           parent,
00092                  const char*        name=0,
00093                  int                wflags=0  );
00094                    
00095     QwavMonoWaveView(const string&  filename,
00096                  QWidget*       parent,
00097                  const char*    name=0   ) 
00098            throw(InvalidNrOfChannels,
00099              FileOpenError,
00100              FileReadError);
00101 
00102     virtual ~QwavMonoWaveView();
00103 
00107     /*---------------------------------------------------------------------*/
00112     virtual void update(QwavMonoWaveView* pSender);
00113 
00117     /*---------------------------------------------------------------------*/
00121     inline int              addLayer       (QwavViewLayer* layer);
00122     inline QwavViewLayer*   getLayer       (const string& name)  ;    
00123     inline QwavViewLayer*   getLayer       (uint index)          ;
00124     inline uint             getNrOfLayers  (void)         const  ;
00125     inline QPixmap*         getBackbuf     (void)                ;
00126 
00130     /*---------------------------------------------------------------------*/
00134     inline int          sample2Pixel   (long  sample) const;
00135     inline long         pixel2Sample   (int   pixel)  const;
00136     
00137     inline bool         isSampleVisible(long sample)  const;
00138     inline const int    nrOfPixels     (void)         const;
00139 
00140     inline double       zoomFac        (void)         const;
00141     inline double       zoomYFac       (void)         const;
00142     inline double       maxZoomFac     (void)         const;  
00143 
00144     inline const ulong  firstSample    (void)         const;
00145     inline const long   lastSample     (void)         const;    
00146     inline const long   samplesVisible (void)         const;
00147   
00148     inline void setPeakInterpolator(QwavPeakInterpolator* s);
00149     inline QwavPeakInterpolator* peakInterpolator() const;
00150     
00154     /*---------------------------------------------------------------------*/
00158     inline  void                setPosition(const ulong sample);
00159     inline const ulong&        position() const               ;
00160 
00164     /*---------------------------------------------------------------------*/
00168     inline uint           addSelection     (const QwavSelection& s);
00169     inline uint           getNrOfSelections(void)         const;
00170     inline const QwavSelection& getSelection(uint index=0)const;
00171     inline QwavSelection& getSelection     (uint index=0)      ;
00172     inline int            isSelectionBegin (int pixel )        ;
00173     inline int            isSelectionEnd   (int pixel )        ;
00174     inline int            activeSelection  (void)         const;
00175     inline void           clearSelections  (void)              ;
00176 
00179     inline const State&   state            (void) const;
00180 
00181 signals:
00182     void           selBeginChanged(long sample);     
00183     void           selEndChanged  (long sample);     
00184     void           zoomFacChanged (double fac );     
00185     void           positionChanged(ulong sample);  
00186     void           firstSampleChanged(ulong sample);
00187     
00188 public slots:
00189     void activatePeakLayer(bool);
00190     void activateAverageLayer(bool);
00191     void activateZeroLineLayer(bool);
00192 
00193     /*---------------------------------------------------------------------*/
00197     inline void           setBgColor       (const QColor& c);
00198     inline const QColor&  bgColor          (void) const     ;
00199     inline void           setPeakColor     (const QColor& c);
00200     inline const QColor&  peakColor        (void) const     ;
00201     inline void           setAvgColor      (const QColor& c);
00202     inline const QColor&  avgColor         (void) const     ;
00203     
00206     /*---------------------------------------------------------------------*/
00210     inline void           setSamplesVisible(const long& newVal);
00211     inline void           setZoomFac       (double zoomFac)    ;
00212     inline void           setZoomYFac      (double zoomYFac)   ; 
00213     inline void           setFirstSample   (ulong sample)       ;
00214     inline void           setChannel       (uint channel=1)    ;
00215     inline uint           channel          (void) const        ;
00216     inline void           scrollBy         (int pixel);
00219 protected slots: // Protected slots
00220 
00221     void onZoomFacChanged(double);    
00222     void onZoomFacInQwavWaveViewChanged(double);
00223     void onZoomFacEntered();
00224 
00225     void onPeakColor();
00226     void onBgColor();
00227     void onHScrollBarChanged(int);
00228     void onSelChanged(long);
00229     void onFirstSampleChanged(ulong);
00230     
00231 private:
00232     void initWidgets(QwavWaveDataInterface*);
00233     void updatePosScale();
00234 
00235     QwavWaveDataInterface* _waveData;
00236     QwavWaveView*      _waveView;       
00237     QVBoxLayout*   _vLayout;
00238     QHBoxLayout*   _hLayout;
00239     QLabel*        _lblSize;
00240     QLabel*        _lblSampleRate;
00241     QwtSlider*     _slZoomFac;     
00242     QwtSlider*     _slZoomYFac;    
00243     QwtScale*      _scPowerScale;  
00244     QwtScale*      _scPosScale;
00245     QLineEdit*     _leVisibleSamples;
00246     QLineEdit*     _leZoomFac;     
00247     QLineEdit*     _leScrollValue;
00248     QLabel*        _lblSelection;
00249     QLabel*        _lblWidth;
00250     QLabel*        _lblVisibleSamples;
00251     QLabel*        _lblZoomFac;    
00252     QPushButton*   _btnPeakColor;
00253     QPushButton*   _btnBgColor;
00254     QPushButton*   _btnPeakLayer;
00255     QPushButton*   _btnAverageLayer;
00256     QPushButton*   _btnZeroLineLayer;
00257     QScrollBar*    _hScrollBar;
00258 
00259 protected: // Protected methods
00260 
00261     virtual void      resizeEvent          (QResizeEvent* e); 
00262     void              updateHorScrollBar   ();
00263 //     
00264 //     virtual void      paintEvent           (QPaintEvent*  e); 
00265 //     inline void       mousePressEvent      (QMouseEvent*  e); 
00266 //     inline void       mouseMoveEvent       (QMouseEvent*  e); 
00267 //     inline void       mouseReleaseEvent    (QMouseEvent*  e); 
00268 //  inline void       mouseDoubleClickEvent(QMouseEvent*  e); 
00269 //     inline void       wheelEvent           (QWheelEvent*  e); 
00270 //     inline void       keyPressEvent        (QKeyEvent*    e);
00271 //     inline void       setState             (State s)        ;        
00272 //     inline void       initLayers()                          ;    
00273     
00274 };
00275 
00276 //---------------------------------------------------------------------------
00277 // Method: waveData
00278 //---------------------------------------------------------------------------
00279 
00280 // QwavWaveDataInterface* QwavMonoWaveView::waveData() const
00281 // {
00282 //     return _waveData;
00283 // }
00284 
00285 int QwavMonoWaveView::addLayer(QwavViewLayer* layer)
00286 {
00287     return _waveView->addLayer(layer);
00288 }
00289 
00290 QwavViewLayer* QwavMonoWaveView::getLayer(const string& name)
00291 {
00292     return _waveView->getLayer(name);
00293 }
00294 
00295 QwavViewLayer* QwavMonoWaveView::getLayer(uint index)
00296 {
00297     return _waveView->getLayer(index);
00298 }
00299 
00300 uint QwavMonoWaveView::getNrOfLayers(void) const
00301 {
00302     return _waveView->getNrOfLayers();
00303 }
00304 
00305 QPixmap* QwavMonoWaveView::getBackbuf(void)
00306 {
00307     return _waveView->getBackbuf();
00308 }
00309 
00310 int  QwavMonoWaveView::sample2Pixel(long  sample) const
00311 {
00312     return _waveView->sample2Pixel(sample);
00313 }
00314 
00315 long QwavMonoWaveView::pixel2Sample(int   pixel) const
00316 {
00317     return _waveView->pixel2Sample(pixel);
00318 }
00319 
00320 bool QwavMonoWaveView::isSampleVisible(long sample) const
00321 {
00322     return _waveView->isSampleVisible(sample);
00323 }
00324 
00325 const int QwavMonoWaveView::nrOfPixels(void) const
00326 {
00327     return _waveView->nrOfPixels();
00328 }
00329 
00330 double  QwavMonoWaveView::zoomFac(void) const
00331 {
00332     return _waveView->zoomFac();
00333 }
00334 
00335 double  QwavMonoWaveView::zoomYFac(void) const
00336 {
00337     return _waveView->zoomYFac();
00338 }
00339 
00340 double  QwavMonoWaveView::maxZoomFac(void) const
00341 {
00342     return _waveView->maxZoomFac();
00343 }
00344 
00345 const ulong QwavMonoWaveView::firstSample(void) const
00346 {
00347     return _waveView->firstSample();
00348 }
00349 
00350 const long  QwavMonoWaveView::lastSample(void) const
00351 {
00352     return _waveView->lastSample();
00353 }
00354 
00355 const long QwavMonoWaveView::samplesVisible(void) const
00356 {
00357     return _waveView->samplesVisible();
00358 }
00359 
00360 void QwavMonoWaveView::setPeakInterpolator(QwavPeakInterpolator* s)
00361 {
00362     _waveView->setPeakInterpolator(s);
00363 }
00364 
00365 QwavPeakInterpolator* QwavMonoWaveView::peakInterpolator() const
00366 {
00367     return _waveView->peakInterpolator();
00368 }
00369     
00370 uint QwavMonoWaveView::addSelection(const QwavSelection& s)
00371 {
00372     return _waveView->addSelection(s);
00373 }
00374 
00375 uint QwavMonoWaveView::getNrOfSelections(void) const
00376 {
00377     return _waveView->getNrOfSelections();
00378 }
00379 
00380 const QwavSelection& QwavMonoWaveView::getSelection(uint index)const
00381 {
00382     return _waveView->getSelection(index);
00383 }
00384 
00385 QwavSelection& QwavMonoWaveView::getSelection(uint index)
00386 {
00387     return _waveView->getSelection(index);
00388 }
00389 
00390 int QwavMonoWaveView::isSelectionBegin(int pixel)
00391 {
00392     return _waveView->isSelectionBegin(pixel);
00393 }
00394 
00395 int QwavMonoWaveView::isSelectionEnd(int pixel)
00396 {
00397     return _waveView->isSelectionEnd(pixel);
00398 }
00399 
00400 int QwavMonoWaveView::activeSelection(void) const
00401 {
00402     return _waveView->activeSelection();
00403 }
00404 
00405 void QwavMonoWaveView::clearSelections(void)
00406 {
00407     _waveView->clearSelections();
00408 }
00409 
00410 const QwavWaveViewInterface::State& QwavMonoWaveView::state(void) const
00411 {
00412     return _waveView->state();
00413 }
00414 
00415 void QwavMonoWaveView::setBgColor(const QColor& c)
00416 {
00417     _waveView->setBgColor(c);
00418 }
00419 
00420 const QColor&  QwavMonoWaveView::bgColor(void) const
00421 {
00422     return _waveView->bgColor();
00423 }
00424 
00425 void QwavMonoWaveView::setPeakColor(const QColor& c)
00426 {
00427     _waveView->setPeakColor(c);
00428 }
00429 
00430 const QColor&  QwavMonoWaveView::peakColor(void) const
00431 {
00432     return _waveView->peakColor();
00433 }
00434 
00435 void QwavMonoWaveView::setAvgColor(const QColor& c)
00436 {
00437     _waveView->setAvgColor(c);
00438 }
00439 
00440 
00441 const QColor&  QwavMonoWaveView::avgColor(void) const
00442 {
00443     return _waveView->avgColor();
00444 }
00445 
00446 void QwavMonoWaveView::setSamplesVisible(const long& newVal)
00447 {
00448     _waveView->setSamplesVisible(newVal);
00449 }
00450 
00451 void QwavMonoWaveView::setZoomFac(double zoomFac)    
00452 {
00453     _waveView->setZoomFac(zoomFac);
00454 }
00455 
00456 void QwavMonoWaveView::setZoomYFac(double zoomYFac) 
00457 {
00458     _waveView->setZoomYFac(zoomYFac);
00459 }
00460 
00461 void QwavMonoWaveView::setFirstSample(ulong sample)       
00462 {
00463     _waveView->setFirstSample(sample);
00464 }
00465 
00466 void QwavMonoWaveView::setChannel(uint channel)    
00467 {
00468     _waveView->setChannel(channel);
00469 }
00470 
00471 uint QwavMonoWaveView::channel(void) const        
00472 {
00473     return _waveView->channel();
00474 }
00475 
00476 void QwavMonoWaveView::scrollBy         (int pixel)
00477 {
00478     _waveView->scrollBy(pixel);
00479 }
00480 
00481 
00482 void QwavMonoWaveView::setPosition(const ulong sample)
00483 {
00484     _waveView->setPosition(sample);
00485 }
00486 
00487 const ulong& QwavMonoWaveView::position() const
00488 {
00489     return _waveView->position();
00490 }
00491 
00492 
00493 Qwav_END_NAMESPACE
00494 
00495 
00496 #endif  // QwavMONOWAVEVIEW_H_

Generated on Mon Jan 20 00:24:54 2003 for Qwav by doxygen1.2.16