diff --git a/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp b/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp index fe7c3d647f1506a5932cfa7cdc88f6f20831bb18..b573468de37e3bc45d078ce2d9dd24e0c64a8e7b 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp @@ -3294,46 +3294,49 @@ void MantidUI::drawColorFillPlots(const QStringList & wsNames, Graph::CurveType int nPlots = wsNames.size(); if ( nPlots > 1 ) { - int nCols = 1; - if ( nPlots >= 16 ) - { - nCols = 4; - } - else if ( nPlots >= 9 ) - { - nCols = 3; - } - else if ( nPlots >= 4 ) - { - nCols = 2; - } - else + QList<MultiLayer*> plots; + for( QStringList::const_iterator cit = wsNames.begin(); cit != wsNames.end(); ++cit ) { - nCols = nPlots; + const bool hidden = true; + MultiLayer* plot = this->drawSingleColorFillPlot(*cit, curveType, NULL, hidden); + if(plot) + plots.append(plot); } - int nRows = nPlots / nCols; - if ( nPlots % nCols != 0 ) + if(!plots.isEmpty()) { - ++nRows; - } + nPlots = plots.size(); - auto tiledWindow = new TiledWindow(appWindow(),"",appWindow()->generateUniqueName("TiledWindow"),nRows,nCols); - appWindow()->addMdiSubWindow(tiledWindow); + int nCols = 1; + if ( nPlots >= 16 ) + nCols = 4; + else if ( nPlots >= 9 ) + nCols = 3; + else if ( nPlots >= 4 ) + nCols = 2; + else + nCols = nPlots; - int row = 0; - int col = 0; - for( QStringList::const_iterator cit = wsNames.begin(); cit != wsNames.end(); ++cit ) - { - const bool hidden = true; - auto plot = this->drawSingleColorFillPlot(*cit, curveType, NULL, hidden); - tiledWindow->addWidget(plot,row,col); - ++col; - if (col == nCols) + int nRows = nPlots / nCols; + if ( nPlots % nCols != 0 ) + ++nRows; + + auto tiledWindow = new TiledWindow(appWindow(),"",appWindow()->generateUniqueName("TiledWindow"),nRows,nCols); + + int row = 0; + int col = 0; + for(auto it = plots.begin(); it != plots.end(); ++it) { - col = 0; - ++row; + tiledWindow->addWidget(*it, row, col); + ++col; + if (col == nCols) + { + col = 0; + ++row; + } } + + appWindow()->addMdiSubWindow(tiledWindow); } } else if ( nPlots == 1 )