Skip to content

Commit

Permalink
Showing the hourglass cursor when showing the instrument or plotting …
Browse files Browse the repository at this point in the history
…spectra or bins. re #1454
  • Loading branch information
mantid-roman committed Oct 31, 2011
1 parent 8eeaeff commit 0a8be45
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,14 @@ MantidMatrix* MantidUI::importMatrixWorkspace(const QString& wsName, int lower,
*/
void MantidUI::importWorkspace(const QString& wsName, bool showDlg, bool makeVisible)
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
MantidMatrix* mm = importMatrixWorkspace(wsName,-1, -1, showDlg,makeVisible);
appWindow()->addListViewItem(mm);
if (!mm)
{Table * t=importTableWorkspace(wsName,showDlg,makeVisible);
appWindow()->addListViewItem(t);
}
QApplication::restoreOverrideCursor();
}

/** Import the selected workspace, if any. Displays the import dialog.
Expand Down Expand Up @@ -1695,13 +1697,16 @@ InstrumentWindow* MantidUI::getInstrumentView(const QString & wsName, int tab)

void MantidUI::showMantidInstrument(const QString& wsName)
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
InstrumentWindow *insWin = getInstrumentView(wsName);
if (!insWin)
{
QApplication::restoreOverrideCursor();
QMessageBox::critical(appWindow(),"MantidPlot - Error","Instrument view cannot be opened");
return;
}
insWin->show();
QApplication::restoreOverrideCursor();
}

void MantidUI::showMantidInstrument()
Expand Down Expand Up @@ -1878,6 +1883,7 @@ MultiLayer* MantidUI::plotInstrumentSpectrumList(const QString& wsName, std::set

MultiLayer* MantidUI::plotBin(const QString& wsName, int bin, bool errors)
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
MantidMatrix* m = getMantidMatrix(wsName);
if( !m )
{
Expand All @@ -1888,21 +1894,30 @@ MultiLayer* MantidUI::plotBin(const QString& wsName, int bin, bool errors)
{
ws = boost::dynamic_pointer_cast<MatrixWorkspace>(AnalysisDataService::Instance().retrieve(wsName.toStdString()));
}
if( !ws.get() ) return NULL;
if( !ws.get() )
{
QApplication::restoreOverrideCursor();
return NULL;
}

QList<int> binAsList;
binAsList.append(bin);
Table *t = createTableFromBins(wsName, ws, binAsList, errors);
t->askOnCloseEvent(false);
t->setAttribute(Qt::WA_QuitOnClose);
MultiLayer* ml(NULL);
if( !t ) return ml;
if( !t )
{
QApplication::restoreOverrideCursor();
return ml;
}

ml = appWindow()->multilayerPlot(t,t->colNames(),Graph::Line);
Graph *g = ml->activeGraph();
appWindow()->polishGraph(g,Graph::Line);
setUpBinGraph(ml,wsName, ws);
ml->askOnCloseEvent(false);
QApplication::restoreOverrideCursor();
return ml;
}

Expand Down Expand Up @@ -2658,6 +2673,7 @@ MultiLayer* MantidUI::plotSpectraList(const QString& wsName, const std::set<int>
*/
MultiLayer* MantidUI::plotSpectraList(const QMultiMap<QString,int>& toPlot, bool errs, bool distr)
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
UNUSED_ARG(errs);
if (toPlot.size() > 10)
{
Expand All @@ -2670,12 +2686,14 @@ MultiLayer* MantidUI::plotSpectraList(const QMultiMap<QString,int>& toPlot, bool
ask.exec();
if (ask.clickedButton() != confirmButton)
{
QApplication::restoreOverrideCursor();
return NULL;
}
}

if(toPlot.size() == 0)
{
QApplication::restoreOverrideCursor();
return NULL;
}

Expand All @@ -2685,7 +2703,10 @@ MultiLayer* MantidUI::plotSpectraList(const QMultiMap<QString,int>& toPlot, bool
ml->setCloseOnEmpty(true);
Graph *g = ml->activeGraph();
if (!g)
return 0;
{
QApplication::restoreOverrideCursor();
return NULL;
}
connect(g,SIGNAL(curveRemoved()),ml,SLOT(maybeNeedToClose()));
appWindow()->setPreferences(g);
g->newLegend("");
Expand All @@ -2712,6 +2733,7 @@ MultiLayer* MantidUI::plotSpectraList(const QMultiMap<QString,int>& toPlot, bool
if ( g->curves() == 0 )
{
ml->close();
QApplication::restoreOverrideCursor();
return NULL;
}
Mantid::API::MatrixWorkspace_sptr workspace =
Expand Down Expand Up @@ -2754,6 +2776,7 @@ MultiLayer* MantidUI::plotSpectraList(const QMultiMap<QString,int>& toPlot, bool

g->checkValuesInAxisRange(mc);

QApplication::restoreOverrideCursor();
//setUpSpectrumGraph(ml,firstWorkspace);
return ml;
}
Expand Down Expand Up @@ -2929,6 +2952,7 @@ Table* MantidUI::createTableFromSelectedColumns(MantidMatrix *m, bool errs)

MultiLayer* MantidUI::createGraphFromSelectedColumns(MantidMatrix *m, bool errs, bool tableVisible)
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
Table *t = createTableFromSelectedColumns(m,errs);
//t->askOnCloseEvent(false);
if (!t) return NULL;
Expand All @@ -2940,6 +2964,7 @@ MultiLayer* MantidUI::createGraphFromSelectedColumns(MantidMatrix *m, bool errs,
m->setBinGraph(ml,t);
// ml->askOnCloseEvent(false);

QApplication::restoreOverrideCursor();
return ml;
}
/** Saves data to nexus file
Expand Down

0 comments on commit 0a8be45

Please sign in to comment.