Skip to content

Commit

Permalink
Re #6980. Fix calculation of color index.
Browse files Browse the repository at this point in the history
The problem was that the ColorBox had been added, which extended the
number of colours to 24, but the method contained this hard-coded so
the calculation wrapped around too soon. Also if you hit white you then
got 'stuck' at black - now it skips on to the next colour.
I've changed to calling methods on ColorBox instead of magic numbers,
and also streamlined the code in other places.
  • Loading branch information
RussellTaylor committed Oct 24, 2013
1 parent b70f3c2 commit e8a67c6
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions Code/Mantid/MantidPlot/src/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5015,27 +5015,25 @@ void Graph::guessUniqueCurveLayout(int& colorIndex, int& symbolIndex)
}
}

for (int i=0; i<n_curves; i++){
for (int i=0; i<n_curves; ++i)
{
const PlotCurve *c = dynamic_cast<PlotCurve *>(curve(i));
if (c){
int index = ColorBox::colorIndex(c->pen().color());
if (index > colorIndex)
colorIndex = index;
if (c)
{
colorIndex = std::max(ColorBox::colorIndex(c->pen().color()), colorIndex);

QwtSymbol symb = c->symbol();
index = SymbolBox::symbolIndex(symb.style());
if (index > symbolIndex)
symbolIndex = index;
symbolIndex = std::max(SymbolBox::symbolIndex(symb.style()), symbolIndex);
}
}
if (n_curves > 1)
colorIndex = (colorIndex+1)%16;
if (colorIndex == 15) //avoid white invisible curves
colorIndex = 0;
colorIndex = (++colorIndex)%ColorBox::numPredefinedColors();
if (ColorBox::color(colorIndex) == Qt::white) //avoid white invisible curves
++colorIndex;

symbolIndex = (symbolIndex+1)%15;
if (!symbolIndex)
symbolIndex = 1;
symbolIndex = (++symbolIndex)%15;
if (symbolIndex == 0)
++symbolIndex;
}

void Graph::addFitCurve(QwtPlotCurve *c)
Expand Down

0 comments on commit e8a67c6

Please sign in to comment.