00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef TRACEWIDGET_H
00019 #define TRACEWIDGET_H
00020
00021
00022 #include <qwidget.h>
00023 #include <qvbox.h>
00024 #include <qspinbox.h>
00025 #include <qvalidator.h>
00026 #include <qlineedit.h>
00027 #include <qlabel.h>
00028 #include <qscrollbar.h>
00029 #include <qhbox.h>
00030 #include <qpainter.h>
00031 #include <qstyle.h>
00032
00033
00034 #include <kstatusbar.h>
00035
00036
00037 #include "traceview.h"
00038
00039
00040 #include <math.h>
00041
00042 class TracesProvider;
00043 class BaseFrame;
00044 class ChannelColors;
00045
00050 class TraceWidget : public QVBox {
00051 Q_OBJECT
00052
00053 public:
00087 TraceWidget(long startTime,long duration,bool greyScale,TracesProvider& tracesProvider,bool multiColumns,bool verticalLines,
00088 bool raster,bool waveforms,bool labelsDisplay,QValueList<int>& channelsToDisplay,int gain,int acquisitionGain,ChannelColors* channelColors,
00089 QMap<int, QValueList<int> >* groupsChannels,QMap<int,int>* channelsGroups,QValueList<int>& channelOffsets,
00090 QValueList<int>& gains,const QValueList<int>& skippedChannels,int rasterHeight,QImage backgroundImage, QWidget* parent=0, const char* name=0,QColor backgroundColor = Qt::black,
00091 KStatusBar* statusBar = 0L,int minSize = 0, int maxSize = 4000, int windowTopLeft = -500,
00092 int windowBottomRight = 1001, int border = 0);
00093
00094 ~TraceWidget();
00095
00096
00099 inline long timeFrameWidth() const {
00100 return timeWindow;
00101 };
00102
00105 inline long timeFrameStart() const {
00106 return startTime;
00107 };
00108
00110 inline void installEventFilter(const QObject* filterObject){
00111 QObject::installEventFilter(filterObject);
00112 view.installEventFilter(filterObject);
00113 };
00114
00115 public slots:
00116
00118 void changeBackgroundColor(QColor color);
00119
00123 void setGreyScale(bool grey);
00124
00128 void moveToTime(long time);
00129
00134 inline void setMultiColumns(bool multiple){view.setMultiColumns(multiple);};
00135
00139 inline void setClusterVerticalLines(bool lines){view.setClusterVerticalLines(lines);};
00140
00144 inline void setClusterRaster(bool raster){
00145 view.setClusterRaster(raster);
00146 };
00147
00151 inline void setClusterWaveforms(bool waveforms){view.setClusterWaveforms(waveforms);};
00152
00156 inline void slotChannelsSelected(const QValueList<int>& selectedIds) {emit channelsSelected(selectedIds);};
00157
00162 virtual inline void setMode(BaseFrame::Mode selectedMode,bool active){view.setMode(selectedMode,active);};
00163
00168 inline void showChannels(const QValueList<int>& channelsToShow){
00169 view.showChannels(channelsToShow);
00170 };
00171
00178 inline void showClusters(QString name,QValueList<int>& clustersToShow){
00179 view.showClusters(name,clustersToShow);
00180 };
00181
00188 inline void showEvents(QString name,QValueList<int>& eventsToShow){
00189 view.showEvents(name,eventsToShow);
00190 };
00191
00196 inline void channelColorUpdate(int channelId,bool active){view.channelColorUpdate(channelId,active);};
00197
00203 inline void clusterColorUpdate(QString name,int clusterId,bool active){view.clusterColorUpdate(name,clusterId,active);};
00204
00210 inline void eventColorUpdate(QString name,int eventId,bool active){view.eventColorUpdate(name,eventId,active);};
00211
00216 inline void groupColorUpdate(int groupId,bool active){view.groupColorUpdate(groupId,active);};
00217
00220 inline void increaseAllChannelsAmplitude(){view.increaseAllAmplitude();};
00221
00224 inline void decreaseAllChannelsAmplitude(){view.decreaseAllAmplitude();};
00225
00229 inline void increaseSelectedChannelsAmplitude(const QValueList<int>& channelIds){view.increaseSelectedChannelsAmplitude(channelIds);};
00230
00234 inline void decreaseSelectedChannelsAmplitude(const QValueList<int>& channelIds){view.decreaseSelectedChannelsAmplitude(channelIds);};
00235
00240 inline void setGains(int gain,int acquisitionGain){view.setGains(gain,acquisitionGain);};
00241
00243 inline void updateDrawing(){view.updateDrawing();};
00244
00246 inline void updateContents(){view.update();};
00247
00251 inline void groupsModified(bool active){view.groupsModified(active);};
00252
00256 inline void selectChannels(const QValueList<int>& selectedIds){view.selectChannels(selectedIds);};
00257
00261 inline void resetOffsets(const QMap<int,int>& selectedChannelDefaultOffsets){view.resetOffsets(selectedChannelDefaultOffsets);};
00262
00266 void resetGains(const QValueList<int>& selectedChannels){view.resetGains(selectedChannels);};
00267
00269 inline void drawTraces(){view.displayTimeFrame(startTime,timeWindow);};
00270
00272 inline void reset(){view.reset();};
00273
00277 inline void showLabels(bool show){view.showHideLabels(show);};
00278
00284 void slotSetStartAndDuration(long time,long duration);
00285
00291 inline void showCalibration(bool show,bool active){view.showCalibration(show,active);};
00292
00298 void samplingRateModified(long long length);
00299
00312 inline void addClusterProvider(ClustersProvider* clustersProvider,QString name,ItemColors* clusterColors,bool active,
00313 QValueList<int>& clustersToShow,QMap<int, QValueList<int> >* displayGroupsClusterFile,
00314 QMap<int,int>* channelsSpikeGroups,int nbSamplesBefore,int nbSamplesAfter,const QValueList<int>& clustersToSkip){
00315 view.addClusterProvider(clustersProvider,name,clusterColors,active,clustersToShow,displayGroupsClusterFile,
00316 channelsSpikeGroups,nbSamplesBefore,nbSamplesAfter,clustersToSkip);
00317 };
00318
00323 inline void removeClusterProvider(QString name,bool active){
00324 view.removeClusterProvider(name,active);
00325 };
00326
00335 inline void addEventProvider(EventsProvider* eventsProvider,QString name,ItemColors* eventColors,bool active,
00336 QValueList<int>& eventsToShow,const QValueList<int>& eventsToNotBrowse){
00337 view.addEventProvider(eventsProvider,name,eventColors,active,eventsToShow,eventsToNotBrowse);
00338 };
00339
00340
00345 inline void removeEventProvider(QString name,bool active){
00346 view.removeEventProvider(name,active);
00347 };
00348
00355 inline void print(QPainter& printPainter,QPaintDeviceMetrics& metrics,QString filePath,bool whiteBackground){
00356
00357 QRect textRec = QRect(printPainter.viewport().left() + 5 ,printPainter.viewport().height() - 20,printPainter.viewport().width() - 5,20);
00358 QFont f("Helvetica",8);
00359 printPainter.setFont(f);
00360 printPainter.setPen(black);
00361 printPainter.drawText(textRec,Qt::AlignAuto | Qt::AlignVCenter,
00362 QString("File: %1 Start time: %2 min %3 s %4 ms, Duration: %5 ms").arg(filePath).arg(startMinute->value()).arg(startSecond->value()).arg(startMilisecond->value()).arg(duration->displayText()));
00363
00364
00365 QRect newViewport = QRect(printPainter.viewport().left(),printPainter.viewport().top(),printPainter.viewport().width(),printPainter.viewport().height());
00366 newViewport.setBottom(printPainter.viewport().bottom() - 20);
00367 printPainter.setViewport(newViewport);
00368 view.print(printPainter,metrics,whiteBackground);
00369 printPainter.resetXForm();
00370 };
00371
00373 inline void showNextCluster(){view.showNextCluster();};
00374
00376 inline void showPreviousCluster(){view.showPreviousCluster();};
00377
00379 inline void showNextEvent(){view.showNextEvent();};
00380
00382 inline void showPreviousEvent(){view.showPreviousEvent();};
00383
00390 inline void slotEventModified(QString providerName,int selectedEventId,double time,double newTime){
00391 emit eventModified(providerName,selectedEventId,time,newTime);
00392 };
00393
00399 inline void slotEventRemoved(QString providerName,int selectedEventId,double time){
00400 emit eventRemoved(providerName,selectedEventId,time);
00401 };
00402
00409 inline void updateEvents(bool active,QString providerName,double time,double newTime){
00410 long eventTime = static_cast<long>(floor(0.5 + time));
00411 long newEventTime = static_cast<long>(floor(0.5 + newTime));
00412 if((eventTime >= startTime && eventTime <= (startTime + timeWindow)) ||
00413 (newEventTime >= startTime && newEventTime <= (startTime + timeWindow))) view.updateEvents(providerName,active);
00414 };
00415
00418 inline void removeEvent(){view.removeEvent();};
00419
00425 inline void updateEvents(bool active,QString providerName,double time){
00426 long eventTime = static_cast<long>(floor(0.5 + time));
00427 if((eventTime >= startTime && eventTime <= (startTime + timeWindow))) view.updateEvents(providerName,active);
00428 };
00429
00434 inline void eventToAddProperties(QString providerName,QString eventDescription){
00435 view.eventToAddProperties(providerName,eventDescription);
00436 };
00437
00443 inline void slotEventAdded(QString providerName,QString addedEventDescription,double time){
00444 emit eventAdded(providerName,addedEventDescription,time);
00445 };
00446
00452 inline void updateEvents(QString providerName,QValueList<int>& eventsToShow,bool active){
00453 view.updateEvents(providerName,eventsToShow,active);
00454 };
00455
00461 inline void updateWaveformInformation(int nbSamplesBefore, int nbSamplesAfter,bool active){
00462 view.updateWaveformInformation(nbSamplesBefore,nbSamplesAfter,active);
00463 };
00464
00468 inline void updateClusterData(bool active){view.updateClusterData(active);};
00469
00474 inline void updateNoneBrowsingEventList(QString providerName,const QValueList<int>& eventsToNotBrowse){
00475 view.updateNoneBrowsingEventList(providerName,eventsToNotBrowse);
00476 };
00477
00482 inline void updateNoneBrowsingClusterList(QString providerName,const QValueList<int>& clustersToNotBrowse){
00483 view.updateNoneBrowsingClusterList(providerName,clustersToNotBrowse);
00484 };
00485
00490 virtual inline void dockBeingClosed(){emit parentDockBeingClosed(this);};
00491
00499 inline void updateClusters(QString name,QValueList<int>& clustersToShow,ItemColors* clusterColors,bool active){
00500 view.updateClusters(name,clustersToShow,clusterColors,active);
00501 };
00502
00506 inline void updateSkipStatus(const QValueList<int>& skippedChannels){view.skipStatusChanged(skippedChannels);};
00507
00509 inline void increaseRasterHeight(){view.increaseRatio();};
00510
00512 inline void decreaseRasterHeight(){view.decreaseRatio();};
00513
00517 inline int getRasterHeight(){return view.getRasterHeight();};
00518
00526 inline void slotEventsAvailable(QDict<EventData>& eventsData,QMap<QString, QValueList<int> >& selectedEvents,QDict<ItemColors>& providerItemColors,QObject* initiator,double samplingRate) {
00527 emit eventsAvailable(eventsData,selectedEvents,providerItemColors,initiator,samplingRate);
00528 };
00529
00535 inline void getCurrentEventInformation(long startTime,long endTime,QObject* initiator){view.getCurrentEventInformation(startTime,endTime,initiator);};
00536
00541 inline void traceBackgroundImageUpdate(QImage traceBackgroundImage,bool active){
00542 view.traceBackgroundImageUpdate(traceBackgroundImage,active);
00543 };
00544
00545 signals:
00546 void channelsSelected(const QValueList<int>& selectedIds);
00547
00552 void updateStartAndDuration(long startTime,long timeWindow);
00553
00560 void eventModified(QString providerName,int selectedEventId,double time,double newTime);
00561
00567 void eventRemoved(QString providerName,int selectedEventId,double time);
00568
00574 void eventAdded(QString providerName,QString addedEventDescription,double time);
00575
00579 void parentDockBeingClosed(QWidget* viewWidget);
00580
00588 void eventsAvailable(QDict<EventData>& eventsData,QMap<QString, QValueList<int> >& selectedEvents,QDict<ItemColors>& providerItemColors,QObject* initiator,double samplingRate);
00589
00590 protected:
00591
00595 void keyPressEvent(QKeyEvent* event);
00596
00597 private:
00598
00599
00601 void initSelectionWidgets();
00602
00603 private slots:
00605 void slotStartMinuteTimeUpdated(int start);
00606
00608 void slotStartSecondTimeUpdated(int start);
00609
00611 void slotStartMilisecondTimeUpdated(int start);
00612
00614 void slotDurationUpdated();
00615
00617 void slotScrollBarUpdated();
00618
00619 private:
00623 long timeWindow;
00624
00626 TraceView view;
00627
00631 long startTime;
00632
00635 QSpinBox* startMinute;
00636
00639 QSpinBox* startSecond;
00640
00643 QSpinBox* startMilisecond;
00644
00647 QLineEdit* duration;
00648
00649 static const QString INITIAL_TRACES_TIME_WINDOW;
00650
00651 QIntValidator validator;
00652
00653 QLabel* durationLabel;
00654 QLabel* startLabel;
00655
00657 bool isInit;
00658
00659 QScrollBar* scrollBar;
00660
00662 long long recordingLength;
00663
00665 long lineStep;
00666
00668 long pageStep;
00669
00671 QHBox* selectionWidgets;
00672
00674 int minutePart;
00675
00677 int secondPart;
00678
00680 int milisecondPart;
00681
00683 bool updateView;
00684
00686
00690 void correctStartTime();
00691
00692 };
00693
00694
00695 #endif