00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef NEUROSCOPEVIEW_H
00019 #define NEUROSCOPEVIEW_H
00020
00021 #ifdef HAVE_CONFIG_H
00022 #include <config.h>
00023 #endif
00024
00025
00026 #include <kdockwidget.h>
00027 #include <kstatusbar.h>
00028 #include <kprinter.h>
00029
00030
00031 #include <qwidget.h>
00032 #include <qdict.h>
00033 #include <qimage.h>
00034
00035
00036 #include "baseframe.h"
00037 #include "positionview.h"
00038 #include "globaleventsprovider.h"
00039
00040 class NeuroscopeApp;
00041 class TracesProvider;
00042 class ChannelColors;
00043 class ClustersProvider;
00044 class EventsProvider;
00045 class PositionsProvider;
00046 class ItemColors;
00047 class TraceWidget;
00048
00049
00050 #include <iostream>
00051 using namespace std;
00052
00053
00061 class NeuroscopeView : public KDockArea
00062 {
00063 Q_OBJECT
00064 public:
00095 NeuroscopeView(NeuroscopeApp& mainWindow,QString label,long startTime,long duration,QColor backgroundColor,int wflags,KStatusBar * statusBar,QValueList<int>* channelsToDisplay,bool greyScale,
00096 TracesProvider& tracesProvider,bool multiColumns,bool verticalLines,
00097 bool raster,bool waveforms,bool labelsDisplay,int unitGain,int acquisitionGain,ChannelColors* channelColors,
00098 QMap<int,QValueList<int> >* groupsChannels,QMap<int,int>* channelsGroups,
00099 QValueList<int> offsets,QValueList<int> channelGains,QValueList<int> selected,QMap<int,bool> skipStatus,int rasterHeight,QString backgroundImagePath,
00100 QWidget *parent = 0, const char *name=0);
00102 ~NeuroscopeView();
00103
00109 void print(KPrinter* pPrinter,QString filePath,bool whiteBackground);
00110
00115 inline void setGains(int gain,int acquisitionGain ){
00116 emit updateGains(gain,acquisitionGain);
00117 emit drawTraces();
00118 };
00119
00123 inline void updateBackgroundColor(QColor color){emit changeBackgroundColor(color);};
00124
00129 inline void documentFeaturesModified(){emit drawTraces();};
00130
00135 inline void samplingRateModified(long long recordingLength){
00136 emit newSamplingRate(recordingLength);
00137 }
00138
00142 void setChannelNb(int nb);
00143
00145 inline void showAllWidgets(){
00146 dockManager->activate();
00147 emit updateContents();
00148 };
00149
00153 inline void setGreyScale(bool grey){
00154 greyScaleMode = grey;
00155 emit greyScale(grey);
00156 };
00157
00160 inline bool getGreyScale() const {return greyScaleMode;};
00161
00167 void shownChannelsUpdate(const QValueList<int>& channelsToShow);
00168
00172 inline const QValueList<int>& channels() const {return *shownChannels;};
00173
00180 void shownClustersUpdate(QString name,QValueList<int>& clustersToShow);
00181
00188 void shownEventsUpdate(QString name,QValueList<int>& eventsToShow);
00189
00194 void setMultiColumns(bool multiple);
00195
00199 void setClusterVerticalLines(bool lines);
00200
00204 void setClusterRaster(bool raster);
00205
00209 void setClusterWaveforms(bool waveforms);
00210
00214 inline bool getMultiColumns() const {return multiColumns;};
00215
00218 inline bool getClusterVerticalLines() const {return verticalLines;};
00219
00222 inline bool getClusterRaster() const {return raster;};
00223
00226 inline bool getClusterWaveforms() const {return waveforms;};
00227
00232 inline const QValueList<int>* getSelectedClusters(QString name) const{return selectedClusters[name];};
00233
00238 inline const QValueList<int>* getSelectedEvents(QString name) const{return selectedEvents[name];};
00239
00244 inline void setMode(BaseFrame::Mode selectedMode,bool active){
00245 if(selectedMode == 2) selectMode = true;
00246 else selectMode = false;
00247 emit modeToSet(selectedMode,active);
00248 };
00249
00253 inline bool isSelectionTool(){return selectMode;};
00254
00259 inline void singleChannelColorUpdate(int channelId,bool active){emit channelColorUpdate(channelId,active);};
00260
00265 inline void channelGroupColorUpdate(int groupId,bool active){emit groupColorUpdate(groupId,active);};
00266
00269 inline void increaseAllChannelsAmplitude(){emit increaseAllAmplitude();};
00270
00273 inline void decreaseAllChannelsAmplitude(){emit decreaseAllAmplitude();};
00274
00277 inline void increaseSelectedChannelsAmplitude(const QValueList<int> selectedIds){
00278
00279 selectedChannels.clear();
00280 QValueList<int>::const_iterator selectedIterator;
00281 for(selectedIterator = selectedIds.begin(); selectedIterator != selectedIds.end(); ++selectedIterator)
00282 selectedChannels.append(*selectedIterator);
00283
00284 emit increaseAmplitude(selectedIds);
00285 };
00286
00289 inline void decreaseSelectedChannelsAmplitude(const QValueList<int> selectedIds){
00290
00291 selectedChannels.clear();
00292 QValueList<int>::const_iterator selectedIterator;
00293 for(selectedIterator = selectedIds.begin(); selectedIterator != selectedIds.end(); ++selectedIterator)
00294 selectedChannels.append(*selectedIterator);
00295
00296 emit decreaseAmplitude(selectedIds);
00297 };
00298
00300 inline void updateViewContents(){
00301 emit updateDrawing();
00302 };
00303
00307 inline void groupsModified(bool active){emit groupsHaveBeenModified(active);};
00308
00312 inline void selectChannels(const QValueList<int>& selectedIds){
00313 selectedChannels.clear();
00314 QValueList<int>::const_iterator selectedIterator;
00315 for(selectedIterator = selectedIds.begin(); selectedIterator != selectedIds.end(); ++selectedIterator){
00316 selectedChannels.append(*selectedIterator);
00317 }
00318
00319 emit channelsToBeSelected(selectedIds);
00320 };
00321
00325 void resetOffsets(const QValueList<int>& selectedIds);
00326
00330 void resetGains(const QValueList<int>& selectedIds){
00331
00332 selectedChannels.clear();
00333 QValueList<int>::const_iterator selectedIterator;
00334 for(selectedIterator = selectedIds.begin(); selectedIterator != selectedIds.end(); ++selectedIterator)
00335 selectedChannels.append(*selectedIterator);
00336
00337 emit resetChannelGains(selectedChannels);
00338 };
00339
00340
00344 inline const QValueList<int>& getChannelOffset() const{return channelOffsets;};
00345
00349 inline const QValueList<int>& getGains() const{return gains;};
00350
00354 inline const QValueList<int>& getSelectedChannels() const{return selectedChannels;};
00355
00359 inline void setSelectedChannels(const QValueList<int>& selectedIds){
00360
00361 selectedChannels.clear();
00362 QValueList<int>::const_iterator selectedIterator;
00363 for(selectedIterator = selectedIds.begin(); selectedIterator != selectedIds.end(); ++selectedIterator){
00364 selectedChannels.append(*selectedIterator);
00365 }
00366 };
00367
00371 inline void setTabName(QString newLabel){tabLabel = newLabel;};
00372
00376 inline QString getTabName(){return tabLabel;};
00377
00381 inline long getStartTime(){return startTime;};
00382
00386 inline long getTimeWindow(){return timeWindow;};
00387
00391 inline void showLabelsUpdate(bool status){
00392 labelsDisplay = status;
00393 emit showLabels(status);
00394 };
00395
00398 inline bool getLabelStatus() const{return labelsDisplay;};
00399
00405 inline void showCalibration(bool show,bool active){emit displayCalibration(show,active);};
00406
00419 void setClusterProvider(ClustersProvider* clustersProvider,QString name,ItemColors* clusterColors,bool active,
00420 QValueList<int>& clustersToShow,QMap<int, QValueList<int> >* displayGroupsClusterFile,QMap<int,int>* channelsSpikeGroups,
00421 int nbSamplesBefore,int nbSamplesAfter,const QValueList<int>& clustersToSkip);
00422
00427 void removeClusterProvider(QString name,bool active);
00428
00434 inline void clusterColorUpdate(QString name,int clusterId,bool active){emit clusterColorUpdated(name,clusterId,active);};
00435
00437 inline void ignoreWaveformInformation(){ emit clusterWaveformsDisplay(false);};
00438
00440 inline void showNextCluster(){emit nextCluster();};
00441
00443 inline void showPreviousCluster(){emit previousCluster();};
00444
00453 void setEventProvider(EventsProvider* eventsProvider,QString name,ItemColors* eventColors,bool active,
00454 QValueList<int>& eventsToShow,const QValueList<int>& eventsToSkip);
00455
00461 void removeEventProvider(QString name,bool active,bool lastFile);
00462
00468 inline void eventColorUpdate(QString name,int eventId,bool active){emit eventColorUpdated(name,eventId,active);};
00469
00471 inline void showNextEvent(){
00472 emit nextEvent();
00473 };
00474
00476 inline void showPreviousEvent(){
00477 emit previousEvent();
00478 };
00479
00487 void updateEvents(QString providerName,int selectedEventId,float time,float newTime,bool active);
00488
00491 inline void removeEvent(){
00492 emit eventToRemove();
00493 emit updateEventDisplay();
00494 };
00495
00502 void updateEventsAfterRemoval(QString providerName,int eventId,float time,bool active);
00503
00510 void updateEventsAfterAddition(QString providerName,int eventId,float time,bool active);
00511
00518 inline void updateEvents(QString providerName,int eventId,float time,bool active){
00519 emit updateEvents(active,providerName,time);
00520 emit updateEventDisplay();
00521 };
00522
00527 inline void eventToAddProperties(QString providerName,QString eventDescription){emit newEventProperties(providerName,eventDescription);};
00528
00537 void updateSelectedEventsIds(QString providerName,QMap<int,int>& oldNewEventIds,int addedEventId,bool active,bool added);
00538
00543 void removePositionProvider(QString name,bool active);
00544
00548 inline bool isPositionView()const {return isPositionFileShown;};
00549
00560 void addPositionView(PositionsProvider* positionsProvider,QImage backgroundImage,QColor backgroundColor,long startTime,long duration,int width,int height,bool showEvents);
00561
00569 inline void addPositionView(PositionsProvider* positionsProvider,QImage backgroundImage,QColor backgroundColor,int width,int height){
00570 addPositionView(positionsProvider,backgroundImage,backgroundColor,startTime,timeWindow,width,height,eventsInPositionView);
00571 };
00572
00574 void removePositionView();
00575
00579 inline void updateClusterData(bool active){emit clusterProviderUpdated(active);};
00580
00585 inline const QValueList<int>* getClustersNotUsedForBrowsing(QString name) const{return clustersNotUsedForBrowsing[name];};
00586
00591 inline const QValueList<int>* getEventsNotUsedForBrowsing(QString name) const{return eventsNotUsedForBrowsing[name];};
00592
00597 void updateNoneBrowsingEventList(QString providerName,const QValueList<int>& eventsToNotBrowse);
00598
00603 void updateNoneBrowsingClusterList(QString providerName,const QValueList<int>& clustersToNotBrowse);
00604
00608 inline void updateSkipStatus(const QValueList<int>& skippedChannels){emit skipStatusChanged(skippedChannels);};
00609
00611 inline void increaseRasterHeight(){emit increaseTheRasterHeight();};
00612
00614 inline void decreaseRasterHeight(){emit decreaseTheRasterHeight();};
00615
00619 int getRasterHeight();
00620
00624 inline int isEventsInPositionView()const{return eventsInPositionView;};
00625
00626 public slots:
00630 inline void slotChannelsSelected(const QValueList<int>& selectedIds){
00631 selectedChannels.clear();
00632 QValueList<int>::const_iterator selectedIterator;
00633 for(selectedIterator = selectedIds.begin(); selectedIterator != selectedIds.end(); ++selectedIterator)
00634 selectedChannels.append(*selectedIterator);
00635
00636 emit channelsSelected(selectedIds);
00637 };
00638
00643 inline void setStartAndDuration(long start,long duration){
00644 startTime = start;
00645 timeWindow = duration;
00646 emit timeChanged(start,duration);
00647 };
00648
00655 inline void slotEventModified(QString providerName,int selectedEventId,double time,double newTime){
00656 emit eventModified(providerName,selectedEventId,time,newTime);
00657 emit updateEventDisplay();
00658 };
00659
00665 inline void slotEventRemoved(QString providerName,int selectedEventId,double time){
00666 emit eventRemoved(providerName,selectedEventId,time);
00667 emit updateEventDisplay();
00668 };
00669
00675 inline void slotEventAdded(QString providerName,QString addedEventDescription,double time){
00676 emit eventAdded(providerName,addedEventDescription,time);
00677 };
00678
00684 inline void updateWaveformInformation(int nbSamplesBefore, int nbSamplesAfter,bool active){
00685 emit waveformInformationUpdated(nbSamplesBefore,nbSamplesAfter,active);
00686 };
00687
00688
00696 inline void updatePositionInformation(int width, int height,QImage backgroundImage,bool newOrientation,bool active){
00697 emit positionInformationUpdated(width,height,backgroundImage,newOrientation,active);
00698 };
00699
00700
00704 void positionDockClosed(QWidget* view);
00705
00709 void setEventsInPositionView(bool shown);
00710
00715 inline void updateTraceBackgroundImage(QImage traceBackgroundImage,bool active){emit traceBackgroundImageUpdate(traceBackgroundImage,active);};
00716
00717
00718
00719 signals:
00720 void changeBackgroundColor(QColor color);
00721 void updateContents();
00722 void greyScale(bool geyScale);
00723 void clusterWaveformsDisplay(bool waveforms);
00724 void clusterRasterDisplay(bool raster);
00725 void clusterVerticalLinesDisplay(bool lines);
00726 void multiColumnsDisplay(bool multi);
00727 void channelsSelected(const QValueList<int>& selectedIds);
00728 void modeToSet(BaseFrame::Mode selectedMode,bool active);
00729 void showChannels(const QValueList<int>& channelsToShow);
00730 void channelColorUpdate(int channelId,bool active);
00731 void groupColorUpdate(int groupId,bool active);
00732 void increaseAllAmplitude();
00733 void decreaseAllAmplitude();
00734 void increaseAmplitude(const QValueList<int>& selectedIds);
00735 void decreaseAmplitude(const QValueList<int>& selectedIds);
00736 void updateGains(int gain,int acquisitionGain);
00737 void updateDrawing();
00738 void groupsHaveBeenModified(bool);
00739 void channelsToBeSelected(const QValueList<int>& selectedIds);
00740 void resetChannelOffsets(const QMap<int,int>& selectedChannelDefaultOffsets);
00741 void resetChannelGains(const QValueList<int>& selectedChannels);
00742 void drawTraces();
00743 void reset();
00744 void showLabels(bool show);
00745 void displayCalibration(bool show,bool active);
00746 void newClusterProvider(ClustersProvider* clustersProvider,QString name,ItemColors* clusterColors,bool active,
00747 QValueList<int>& clustersToShow,QMap<int, QValueList<int> >* displayGroupsClusterFile,
00748 QMap<int,int>* channelsSpikeGroups,int nbSamplesBefore,int nbSamplesAfter,const QValueList<int>& clustersToSkip);
00749 void newSamplingRate(long long recordingLength);
00750 void clusterProviderRemoved(QString name,bool active);
00751 void showClusters(QString name,QValueList<int>& clustersToShow);
00752 void clusterColorUpdated(QString name,int clusterId,bool active);
00753 void nextCluster();
00754 void previousCluster();
00755 void print(QPainter& printPainter,QPaintDeviceMetrics& metrics,QString filePath,bool whiteBackground);
00756 void newEventProvider(EventsProvider* eventsProvider,QString name,ItemColors* eventColors,bool active,
00757 QValueList<int>& eventsToShow,const QValueList<int>& eventsToSkip);
00758 void eventProviderRemoved(QString name,bool active,bool lastFile);
00759 void showEvents(QString name,QValueList<int>& eventsToShow);
00760 void eventColorUpdated(QString name,int eventId,bool active);
00761 void nextEvent();
00762 void previousEvent();
00763 void eventModified(QString providerName,int selectedEventId,double time,double newTime);
00764 void updateEvents(bool active,QString providerName,double time,double newTime);
00765 void eventToRemove();
00766 void eventRemoved(QString providerName,int selectedEventId,double time);
00767 void updateEvents(bool active,QString providerName,double time);
00768 void newEventProperties(QString providerName,QString eventId);
00769 void eventAdded(QString providerName,QString addedEventDescription,double time);
00770 void updateEvents(QString providerName,QValueList<int>& eventsToShow,bool active);
00771 void waveformInformationUpdated(int nbSamplesBefore,int nbSamplesAfter,bool active);
00772 void positionInformationUpdated(int width, int height,QImage backgroundImage,bool newOrientation,bool active);
00773 void timeChanged(long start,long duration);
00774 void positionViewClosed();
00775 void clusterProviderUpdated(bool active);
00776 void noneBrowsingClusterListUpdated(QString providerName,const QValueList<int>& clustersToNotBrowse);
00777 void noneBrowsingEventListUpdated(QString providerName,const QValueList<int>& eventsToNotBrowse);
00778 void skipStatusChanged(const QValueList<int>& skippedChannels);
00779 void decreaseTheRasterHeight();
00780 void increaseTheRasterHeight();
00781 void updateEventDisplay();
00782 void eventsShownInPositionView(bool shown);
00783 void traceBackgroundImageUpdate(QImage traceBackgroundImage,bool active);
00784
00785 private:
00786
00788 QValueList<int>* shownChannels;
00789
00791 NeuroscopeApp& mainWindow;
00792
00794 bool greyScaleMode;
00795
00799 KDockWidget* mainDock;
00800
00802 bool multiColumns;
00803
00805 bool verticalLines;
00806
00808 bool raster;
00809
00811 bool waveforms;
00812
00814 bool selectMode;
00815
00817 QValueList<int> channelOffsets;
00818
00821 QValueList<int> gains;
00822
00823
00824 QValueList<int> selectedChannels;
00825
00827 QString tabLabel;
00828
00829
00830 long startTime;
00831
00832
00833 long timeWindow;
00834
00836 bool labelsDisplay;
00837
00839 QDict< QValueList<int> > selectedClusters;
00840
00842 QDict< QValueList<int> > selectedEvents;
00843
00845 QDict<QValueList<int> > clustersNotUsedForBrowsing;
00846
00848 QDict<QValueList<int> > eventsNotUsedForBrowsing;
00849
00851 bool isPositionFileShown;
00852
00854 PositionView* positionView;
00855
00857 TraceWidget* traceWidget;
00858
00860 GlobalEventsProvider globalEventProvider;
00861
00863 bool eventsInPositionView;
00864 };
00865
00866 #endif // NEUROSCOPEVIEW_H