Skip to content

Commit

Permalink
Signal event and cluster file loading properly
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianFranzen committed Dec 15, 2015
1 parent df0230c commit 88e4d6c
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 88 deletions.
58 changes: 24 additions & 34 deletions src/neuroscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,12 @@ void NeuroscopeApp::initActions()
connect(doc, SIGNAL(loadFirstDisplay(QList<int>*,bool,bool,bool,bool,bool,bool,bool,QList<int>,QList<int>,QList<int>,QMap<int,bool>&,long,long,QString,bool,int,bool)),this,
SLOT(slotSetUp(QList<int>*,bool,bool,bool,bool,bool,bool,bool,QList<int>,QList<int>,QList<int>,QMap<int,bool>&,long,long,QString,bool,int,bool)));

connect(doc, SIGNAL(clusterFileLoaded(const QString&)),
this, SLOT(slotClusterFileLoaded(const QString&)));

connect(doc, SIGNAL(eventFileLoaded(const QString&)),
this, SLOT(slotEventFileLoaded(const QString&)));

connect(displayChannelPalette, SIGNAL(singleChangeColor(int)),this, SLOT(slotSingleChannelColorUpdate(int)));
connect(spikeChannelPalette, SIGNAL(singleChangeColor(int)),this, SLOT(slotSingleChannelColorUpdate(int)));
connect(displayChannelPalette, SIGNAL(singleChangeColor(int)),spikeChannelPalette, SLOT(updateColor(int)));
Expand Down Expand Up @@ -1091,16 +1097,6 @@ void NeuroscopeApp::openNetworkStream(CerebusTracesProvider::SamplingGroup group
return;
}

// Set up cluster palette
int channelCount = this->doc->getChannelNb();
createClusterPalette("1");
for (int i = 2; i <= channelCount; i++)
addClusterFile(QString::number(i));

// Set up event palette
QString eventFileId = this->doc->lastLoadedProviderName();
createEventPalette(eventFileId);

// Update the spike and event browsing status
updateBrowsingStatus();

Expand Down Expand Up @@ -1163,7 +1159,7 @@ void NeuroscopeApp::updateBrowsingStatus(){
}
}

if (!palette)
if (!palette)
return;
NeuroscopeView* view = activeView();
QStringList::iterator iterator;
Expand Down Expand Up @@ -1451,11 +1447,6 @@ void NeuroscopeApp::slotCreateEventFile(){
QMessageBox::critical (this, tr("Error!"),tr("The selected file name is already opened."));
}
else{
const QString eventFileId = doc->lastLoadedProviderName();
if(eventFileList.isEmpty())
createEventPalette(eventFileId);
else
addEventFile(eventFileId);
eventsModified = true;
QApplication::restoreOverrideCursor();
}
Expand Down Expand Up @@ -2334,7 +2325,7 @@ void NeuroscopeApp::slotTabChange(int index){

/// Added by M.Zugaro to enable automatic forward paging
if ( isStill() ) slotStateChanged("pageOffState"); else slotStateChanged("pageOnState");

QWidget *channelPalette = paletteTabsParent->currentWidget();

if(qobject_cast<ChannelPalette*>(channelPalette)){
Expand Down Expand Up @@ -2864,7 +2855,6 @@ void NeuroscopeApp::loadClusterFiles(const QStringList &urls){
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));

//Loop on the files
int counter = 0;
QStringList::const_iterator iterator;
for(iterator = urls.constBegin();iterator != urls.constEnd();++iterator){
//Create the provider
Expand Down Expand Up @@ -2906,17 +2896,19 @@ void NeuroscopeApp::loadClusterFiles(const QStringList &urls){
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
continue;
}

//Create the cluster palette if need it
counter++;
QString clusterFileId = doc->lastLoadedProviderName();
if(clusterFileList.isEmpty() && counter == 1)
createClusterPalette(clusterFileId);
else addClusterFile(clusterFileId);
}
QApplication::restoreOverrideCursor();
}

/** Updates view, because a new cluster file was loaded. */
void NeuroscopeApp::slotClusterFileLoaded(const QString& fileID) {
// Create the cluster palette if need it
if(clusterFileList.isEmpty())
createClusterPalette(fileID);
else
addClusterFile(fileID);
}

void NeuroscopeApp::createClusterPalette(const QString& clusterFileId)
{
ItemPalette* clusterPalette = new ItemPalette(ItemPalette::CLUSTER,backgroundColor,this,"clusterPanel");
Expand Down Expand Up @@ -3083,7 +3075,6 @@ void NeuroscopeApp::loadEventFiles(const QStringList& urls){
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));

//Loop on the files
int counter = 0;
QStringList::const_iterator iterator;
for(iterator = urls.constBegin();iterator != urls.constEnd();++iterator){
//Create the provider
Expand Down Expand Up @@ -3118,18 +3109,17 @@ void NeuroscopeApp::loadEventFiles(const QStringList& urls){
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
continue;
}

//Create the event palette if need it
counter++;
QString eventFileId = doc->lastLoadedProviderName();
if(eventFileList.isEmpty() && counter == 1)
createEventPalette(eventFileId);
else
addEventFile(eventFileId);
}
QApplication::restoreOverrideCursor();
}

void NeuroscopeApp::slotEventFileLoaded(const QString& fileId) {
//Create the event palette if need it;
if(eventFileList.isEmpty())
createEventPalette(fileId);
else
addEventFile(fileId);
}

void NeuroscopeApp::createEventPalette(const QString& eventFileId){

Expand Down
48 changes: 27 additions & 21 deletions src/neuroscope.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define NEUROSCOPE_H





#include <QDockWidget>
Expand Down Expand Up @@ -199,7 +199,7 @@ class NeuroscopeApp : public QMainWindow
* @return true if at least one cluster file is loaded, false otherwise.
*/
inline bool isClusterFilesLoaded()const{return !clusterFileList.isEmpty();}

/**Tells if there is a position file loaded.
* @return true a position file is loaded, false otherwise.
*/
Expand Down Expand Up @@ -322,15 +322,15 @@ public Q_SLOTS:
*/
void initDisplay(QList<int>* channelsToDisplay,bool autocenterChannels,QList<int> offsets,QList<int> channelGains,
QList<int> selectedChannels,QMap<int,bool>& skipStatus,int rasterHeight=-1,long duration = 1000,long startTime = 0,QString tabLabel = QString());

/**
* queryClose is called by closeEvent
*/
bool queryClose();

void customEvent (QEvent* event);
void closeEvent(QCloseEvent *event);

private Q_SLOTS:

void slotAbout();
Expand All @@ -346,15 +346,21 @@ private Q_SLOTS:
/**Loads one or multiple cluster files.*/
void slotLoadClusterFiles();

/** Updates view, because a new cluster file was loaded. */
void slotClusterFileLoaded(const QString& fileID);

/**Closes the cluster file corresponding to the currently selected cluster group.*/
void slotCloseClusterFile();

/**Loads one or multiple event files.*/
void slotLoadEventFiles();

/**Creates an empty event file.*/
void slotCreateEventFile();


/** Updates view, because a new event file was loaded or created. */
void slotEventFileLoaded(const QString& fileID);

/**Closes the event file corresponding to the currently selected event group.*/
void slotCloseEventFile();

Expand All @@ -363,15 +369,15 @@ private Q_SLOTS:

/**Closes the position file.*/
void slotClosePositionFile();

/**Opens a file from the recent files menu. */
void slotFileOpenRecent(const QString& url);

/**Opens a dialog to display and edit the file properties:
* (number of channels, sampling rate of the dat file and eeg file).
*/
void slotFileProperties();

/**If need it, warns the user that the spike groups have been modified, then closes the actual file and displayss.*/
void slotFileClose();

Expand Down Expand Up @@ -399,7 +405,7 @@ private Q_SLOTS:
* have the same amplification.
*/
void slotShowCalibration();

/**Changes the statusbar contents for the standard label permanently, used to indicate current actions.
* @param text the text that is displayed in the statusbar.
*/
Expand All @@ -409,7 +415,7 @@ private Q_SLOTS:
/*Slots for the tools menu.*/
/**Chooses the tool to select channels, enabling the user to select traces in order to move them.*/
void slotSelect();

/**Chooses the zoom tool, enabling the user to zoom.*/
void slotZoom();

Expand All @@ -420,7 +426,7 @@ private Q_SLOTS:
/**Chooses the selection time tool, enabling the user to select a time frame (subset of the currently shown)
* for which the traces are going to be displayed.*/
void slotSelectTime();

/**Chooses the tool to select an event, enabling the user to select an event in order to move or delete it.*/
void slotSelectEvent();

Expand Down Expand Up @@ -509,13 +515,13 @@ private Q_SLOTS:
/**Selects all the clusters of the current palette except the clusters of artefact and noise
* (clusters 0 and 1 respectively).*/
void slotSelectAllWO01();

/**Sets the mode of presentation in the current display, single or multiple columns.*/
void slotDisplayMode();

/**Displays or hides vertical lines to show the clusters.*/
void slotClustersVerticalLines();

/**Displays or hides a raster to show the clusters.*/
void slotClustersRaster();

Expand All @@ -527,7 +533,7 @@ private Q_SLOTS:

/**Triggers the moves of the selected channels to the discard spike group.*/
void slotDiscardSpikeChannels();

/**The selected channels have been moved to the trash group.
* @param discarded ids of the channels to move to the trash group.
*/
Expand Down Expand Up @@ -676,7 +682,7 @@ private Q_SLOTS:
* @param clustersToSkip new list of clusters to skip while browsing
*/
void slotUpdateClustersToSkip(const QString &groupName, const QList<int>& clustersToSkip);

/**Marks the selected channels has keeped.*/
void slotKeepChannels();

Expand Down Expand Up @@ -742,7 +748,7 @@ private Q_SLOTS:
QAction* addEventToolBarAction;
QAction* positionViewToggle;
QAction* showEventsInPositionView;

QAction* mProperties;
QAction* mLoadClusterFiles;
QAction* mLoadEventFiles;
Expand Down Expand Up @@ -824,7 +830,7 @@ private Q_SLOTS:
* Inititalized in initItemPanel().
*/
ChannelPalette* displayChannelPalette;

/**spikeChannelPalette is the Widget containing the channel list to create the spike groups.
* Inititalized in initItemPanel().
*/
Expand Down Expand Up @@ -868,10 +874,10 @@ private Q_SLOTS:

/**Flag to keep track of group modifications. */
bool groupsModified;

/**Flag to keep track of color modifications. */
bool colorModified;

/**Flag to keep track of event modifications. */
bool eventsModified;

Expand All @@ -898,7 +904,7 @@ private Q_SLOTS:

/**List storing the identifiers of the opened cluster files.*/
QStringList clusterFileList;

/**List storing the identifiers of the opened event files.*/
QStringList eventFileList;

Expand Down
Loading

0 comments on commit 88e4d6c

Please sign in to comment.