debug/src/neuroscope.h

00001 /***************************************************************************
00002                           neuroscope.h  -  description
00003                              -------------------
00004     begin                : Wed Feb 25 19:05:25 EST 2004
00005     copyright            : (C) 2004 by Lynn Hazan
00006     email                : lynn.hazan.myrealbox.com
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 NEUROSCOPE_H
00019 #define NEUROSCOPE_H
00020  
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include <config.h>
00024 #endif
00025 
00026 // include files for KDE 
00027 #include <kapp.h>
00028 #include <klocale.h>
00029 #include <kdockwidget.h>
00030 #include <kaccel.h>
00031 #include <kaction.h>
00032 #include <kurl.h>
00033 #include <kcolorbutton.h>
00034 #include <kdeprint/kprintdialogpage.h>
00035 #include <kpopupmenu.h>
00036 
00037 //QT include files
00038 #include <qcheckbox.h>
00039 
00040 //application specific include files
00041 #include "neuroscopeview.h"
00042 
00043 // forward declaration of the Neuroscope classes
00044 class NeuroscopeDoc;
00045 class PrefDialog;
00046 class PropertiesDialog;
00047 class ChannelPalette;
00048 class ItemPalette;
00049 
00056 class NeuroscopeApp : public KDockMainWindow
00057 {
00058   Q_OBJECT
00059 
00060   friend class NeuroscopeView;
00061 
00062   public:
00065     NeuroscopeApp();
00066     ~NeuroscopeApp();
00067 
00071     void openDocumentFile(const KURL& url=0);
00072     
00076     NeuroscopeDoc* getDocument() const;
00077 
00081     NeuroscopeView* activeView();
00082 
00094     void setFileProperties(QString channelNb,QString SR,QString resolution,QString offset,QString voltageRange,
00095                           QString amplification,QString screenGain,QString timeWindow);
00096 
00120     void displayFileProperties(int channelNb,double SR,int resolution,int offset,int voltageRange,int amplification,
00121                               float screenGain,int currentNbSamples,int currentPeakIndex,double videoSamplingRate,
00122                               int width, int height, QString backgroundImage,int rotation,int flip,
00123                               double acquisitionSystemSamplingRate,bool isaDatFile,bool positionsBackground,QString traceBackgroundImage);
00124 
00126    void resizePalettePanel();
00127 
00144    void createDisplay(QValueList<int>* channelsToDisplay,bool verticalLines,bool raster,bool waveforms,bool showLabels,
00145                        bool multipleColumns,bool greyMode,QValueList<int> offsets,QValueList<int> channelGains,
00146                        QValueList<int> selectedChannels,long startTime,long duration,int rasterHeight,QString tabLabel = "");
00147 
00152    void createClusterPalette(QString clusterFileId);
00153 
00158    void addClusterFile(QString clusterFileId);
00159    
00164    void createEventPalette(QString eventFileId);
00165 
00170    void addEventFile(QString eventFileId);
00171 
00174    ItemPalette* getEventPalette();
00175 
00179    inline QColor getBackgroundColor()const{return backgroundColor;}   ;
00180 
00182    inline void positionFileLoaded(){
00183     isPositionFileLoaded = true;
00184     slotStateChanged("positionState");
00185    };
00186       
00190    inline bool isClusterFilesLoaded()const{return !clusterFileList.isEmpty();};   
00191     
00195    inline bool isApositionFileLoaded()const{return isPositionFileLoaded;};   
00196    
00197   public slots:
00198 
00205   void slotEventModified(QString providerName,int selectedEventId,double time,double newTime);
00206 
00209   void removeEvent();
00210 
00216   void slotEventRemoved(QString providerName,int selectedEventId,double time);
00217   
00220   void addEvent();
00221 
00225   void slotEventGroupSelected(QString eventGroupName);
00226 
00232   void slotEventAdded(QString providerName,QString addedEventDescription,double time);
00233 
00235   inline void positionViewClosed(){positionViewToggle->setChecked(false);};
00236 
00239   inline void slotNoClustersToBrowse(){slotStateChanged("noClusterBrowsingState");};
00240 
00243   inline void slotClustersToBrowse(){slotStateChanged("clusterBrowsingState");};
00244 
00247   inline void slotNoEventsToBrowse(){slotStateChanged("noEventBrowsingState");};
00248   
00251   inline void slotEventsToBrowse(){slotStateChanged("eventBrowsingState");};
00252 
00253   protected:
00255     void initActions();
00258     void initStatusBar();
00259        
00271     void initDisplay(QValueList<int>* channelsToDisplay,QValueList<int> offsets,QValueList<int> channelGains,
00272                     QValueList<int> selectedChannels,QMap<int,bool>& skipStatus,int rasterHeight=-1,long duration = 1000,long startTime = 0,QString tabLabel = "");
00273     
00276     virtual bool queryClose();
00277     
00282     virtual bool queryExit();
00283     
00288     virtual void saveProperties(KConfig* config);
00289     
00295     virtual void readProperties(KConfig* config);
00296 
00297     
00298     void customEvent (QCustomEvent* event);
00299     
00300   private slots:
00302     void slotFileOpen();
00303 
00305     void slotLoadClusterFiles();
00306 
00308     void slotCloseClusterFile();
00309     
00311     void slotLoadEventFiles();
00312 
00314     void slotCreateEventFile();
00315     
00317     void slotCloseEventFile();
00318 
00320     void slotLoadPositionFile();
00321 
00323     void slotClosePositionFile();
00324     
00326     void slotFileOpenRecent(const KURL& url);
00327 
00331     void slotFileProperties();
00332     
00334     void slotFileClose();
00335 
00337     void slotFilePrint();
00338 
00342     void slotFileQuit();
00343 
00345     void slotViewMainToolBar();
00346 
00349     void slotViewToolBar();
00350 
00353     void slotViewStatusBar();
00354 
00356     void slotViewParameterBar();
00357 
00361     void slotShowCalibration();
00362     
00366     void slotStatusMsg(const QString &text);
00367 
00369     void slotKeyBindings();
00370 
00371     /*Slots for the tools menu.*/
00373     void slotSelect();
00374     
00376     void slotZoom();
00377 
00380     void slotMeasure();
00381 
00384     void slotSelectTime();
00385     
00387     void slotSelectEvent();
00388 
00390     void executePreferencesDlg();
00391 
00393     void applyPreferences();
00394 
00396     void initializePreferences();
00397 
00401     void slotSingleChannelColorUpdate(int channelId);
00402 
00406     void slotChannelGroupColorUpdate(int groupId);
00407 
00411     //void slotChannelsColorUpdate(QValueList<int> selectedChannels);
00412 
00414     void slotApplyDisplayColor();
00415 
00417     void slotApplySpikeColor();
00418           
00422     void slotUpdateShownChannels(const QValueList<int>& selectedChannels);
00423 
00427     void slotUpdateHiddenChannels(const QValueList<int>& hiddenChannels);
00428 
00433     void slotDefaultSetUp(QMap<int,int>& channelDefaultOffsets,QMap<int,bool>& skipStatus);
00434 
00454     void slotSetUp(QValueList<int>* channelsToDisplay,bool verticalLines,bool raster,bool waveforms,bool showLabels,bool multipleColumns,
00455                    bool greyMode,QValueList<int> offsets,QValueList<int> channelGains,QValueList<int> selectedChannels,QMap<int,bool>& skipStatus,
00456                    long startTime,long duration,QString tabLabel,bool positionView,int rasterHeight,bool showEventsInPositionView);
00457                                                        
00459     void slotSetGreyScale();
00460 
00462     void slotCreateGroup();
00463 
00465     void slotSelectAll();
00466 
00468     void slotDeselectAll();
00469 
00472     void slotSelectAllWO01();
00473     
00475     void slotDisplayMode();
00476 
00478     void slotClustersVerticalLines();
00479     
00481     void slotClustersRaster();
00482 
00484     void slotClustersWaveforms();
00485 
00487     void slotDiscardChannels();
00488 
00490     void slotDiscardSpikeChannels();
00491     
00495     void slotChannelsDiscarded(const QValueList<int>& discarded);
00496    
00498     void slotShowChannels();
00499 
00501     void slotHideChannels();
00502 
00504     void slotTabChange(QWidget* widget);
00505 
00507     void slotPaletteTabChange(QWidget* widget);
00508 
00510     void slotDisplayClose();
00511 
00513    void slotRenameActiveDisplay();
00514 
00517    void slotNewDisplay();
00518 
00520    void slotEditMode();
00521 
00523    void slotSynchronize();
00524 
00526    void slotGroupsModified();
00527 
00531    void slotSelectChannelsInPalette(const QValueList<int>& selectedIds);
00532 
00535    inline void slotIncreaseAllChannelsAmplitude(){activeView()->increaseAllChannelsAmplitude();};
00536 
00539    inline void slotDecreaseAllChannelsAmplitude(){activeView()->decreaseAllChannelsAmplitude();};
00540    
00543    void slotIncreaseSelectedChannelsAmplitude();
00544 
00547    void slotDecreaseSelectedChannelsAmplitude();
00548 
00553    void slotChannelsSelected(const QValueList<int>& selectedIds);
00554 
00556    void slotResetOffsets();
00557 
00559    void slotResetGains();
00560    
00563    void saveSession();
00564 
00568    void slotSessionSaveAs();
00569 
00571    void slotShowLabels();
00572 
00577    void slotClusterColorUpdate(int clusterId,QString groupName);
00578 
00582    void slotUpdateShownClusters(const QMap<QString,QValueList<int> >& selection);
00583    
00585    void slotShowNextCluster();
00586 
00588    void slotShowPreviousCluster();
00589 
00594    void slotEventColorUpdate(int eventId,QString groupName);
00595 
00599    void slotUpdateShownEvents(const QMap<QString,QValueList<int> >& selection);
00600 
00602    void slotShowNextEvent();
00603 
00605    void slotShowPreviousEvent();
00606 
00608    void slotUndo();
00609    
00611    void slotRedo();
00612 
00614    void slotAddEventAboutToShow();
00615 
00620    void slotAddEventActivated(int index);
00621    
00626    void slotAddEventButtonActivated(int index);
00627 
00629    void slotShowPositionView();
00630 
00635    void slotUpdateEventsToSkip(QString groupName,const QValueList<int>& eventsToSkip);
00636 
00641    void slotUpdateClustersToSkip(QString groupName,const QValueList<int>& clustersToSkip);
00642     
00644    void slotKeepChannels();
00645 
00647    void slotSkipChannels();
00648   
00649    /*Sets the current channel offsets has the default offsets.*/
00650    void slotSetDefaultOffsets();
00651    
00652    /*Resets the channel default offsets to zero.*/
00653    void slotResetDefaultOffsets();
00654    
00658    void slotDrawTimeLine();
00659    
00661    void slotIncreaseRasterHeight();
00662    
00664    void slotDecreaseRasterHeight();
00665    
00667    void slotShowEventsInPositionView();
00668    
00669   private:
00671     KConfig *config;
00672  
00676     NeuroscopeDoc *doc;
00677 
00679     PrefDialog* prefDialog;
00680 
00681     //Action and toolbar pointers
00682     KRecentFilesAction* fileOpenRecent;
00683     KToggleAction* viewMainToolBar;
00684     KToggleAction* viewToolBar;
00685     KToggleAction* viewStatusBar;
00686     KToggleAction* viewParameterBar;
00687     KToggleAction* greyScale;
00688     KToggleAction* displayMode;
00689     KToggleAction* clusterVerticalLines;
00690     KToggleAction* clusterRaster;
00691     KToggleAction* clusterWaveforms;
00692     KToggleAction* editMode;
00693     KToggleAction* showHideLabels;
00694     KToggleAction* calibrationBar;
00695     KPopupMenu* addEventPopup;
00696     KSelectAction* addEventMenu;
00697     KToolBarPopupAction* addEventToolBarAction;
00698     KToggleAction* positionViewToggle;
00699     KToggleAction* showEventsInPositionView;
00700     
00702     int displayCount;
00703 
00707     KDockWidget* mainDock;
00708 
00711     KDockWidget* displayPanel;
00712 
00715     KDockWidget* spikePanel;
00716 
00720     ChannelPalette* displayChannelPalette;
00721     
00725     ChannelPalette* spikeChannelPalette;
00726 
00730     KDockTabGroup* tabsParent;
00731 
00735     KDockTabGroup* paletteTabsParent;
00736 
00740     KDockWidget* palettePanel;
00741 
00743     bool isInit;
00744 
00746     int channelNbDefault;
00747 
00749     double datSamplingRateDefault;
00750 
00752     double eegSamplingRateDefault;
00753 
00755     float screenGainDefault;
00756 
00758     int voltageRangeDefault;
00759 
00761     int amplificationDefault;
00762 
00764     bool groupsModified;    
00765     
00767     bool colorModified;
00768     
00770     bool eventsModified;
00771 
00773     int initialOffsetDefault;
00774 
00776     int resolutionDefault;
00777 
00779     PropertiesDialog* propertiesDialog;
00780 
00782     QColor backgroundColor;
00783 
00785     bool select;
00786 
00788     QString filePath;
00789 
00791     long initialTimeWindow;
00792 
00794     KPrinter* printer;
00795 
00797     QValueList<QString> clusterFileList;
00798     
00800     QValueList<QString> eventFileList;
00801 
00803     bool displayPaletteHeaders;
00804 
00806     int eventPosition;
00807 
00809     int clusterPosition;
00810 
00812     int currentNbUndo;
00813 
00815     int currentNbRedo;
00816 
00818     int eventIndex;
00819     
00821     int buttonEventIndex;
00822 
00824     QString eventLabelToCreate;
00825 
00827    QString eventProvider;
00828 
00830    bool undoRedoInprocess;
00831 
00833    int nbSamplesDefault;
00835    int peakIndexDefault;
00836 
00838    double videoSamplingRateDefault;
00839 
00841    int videoWidthDefault;
00843    int videoHeightDefault;
00845    QString backgroundImageDefault;
00846    
00848    QString traceBackgroundImageDefault;
00849    
00851    int rotationDefault;
00853    int flipDefault;
00854 
00856    bool isPositionFileLoaded;
00857    
00859    bool drawPositionsOnBackgroundDefault;
00860 
00861   //Functions
00862   
00864    void initItemPanel();
00865 
00867    void resetState();
00868 
00872    void loadClusterFiles(KURL::List urls);
00873 
00877    void loadEventFiles(KURL::List urls);   
00878 
00882    void loadPositionFile(KURL url);
00883    
00884  class printDialogPage : public KPrintDialogPage{
00885   public:
00886    inline printDialogPage(QWidget* parent = 0,const char* name = 0): KPrintDialogPage(parent,name){
00887     setTitle(i18n("Background Color"));
00888     backgroundColor = new QCheckBox("Use white background",this);
00889     backgroundColor->adjustSize();
00890    };
00891 
00892     inline void getOptions(QMap<QString,QString>& opts,bool incldef){
00893       opts["kde-neuroscope-backgroundColor"] = (backgroundColor->isChecked() ? "1" : "-1");
00894     };
00895 
00896     inline void setOptions(const QMap<QString,QString>& opts){
00897      backgroundColor->setChecked(opts["kde-neuroscope-backgroundColor"] == "1"); 
00898     };
00899 
00900     inline bool isValid(QString& message){return true;};
00901 
00902   private:
00903     QCheckBox* backgroundColor;
00904   };
00905  
00907   void updateBrowsingStatus();
00908 };
00909 
00910 #endif // NEUROSCOPE_H

Generated on Mon Sep 17 20:47:30 2007 for NeuroScope by  doxygen 1.5.1