-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add class holding settings for error bars. Re #2657.
Very simple class of attributes and getters & setters, pulled out of QwtErrorPlotCurve.
- Loading branch information
1 parent
6b8b7ff
commit ad3d3b3
Showing
4 changed files
with
160 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#include "ErrorBarSettings.h" | ||
|
||
/** Constructor. | ||
* Sets defaults of black lines having width 1.0 and caps of length 10, | ||
* that show on both sides of the symbol but don't draw through it. | ||
*/ | ||
ErrorBarSettings::ErrorBarSettings() | ||
: m_cap(10), m_plus(true), m_minus(true), m_through(false), | ||
m_width(1.0), m_color(Qt::black) | ||
{} | ||
|
||
/// Return the length of the cap decoration on the error bars | ||
int ErrorBarSettings::capLength() const | ||
{ | ||
return m_cap; | ||
} | ||
|
||
/// Set the length of the cap decoration on the error bars | ||
void ErrorBarSettings::setCapLength(int t) | ||
{ | ||
m_cap = t; | ||
} | ||
|
||
/// Returns the width of the error bar lines. Overridden in QwtErrorPlotCurve. | ||
double ErrorBarSettings::width() const | ||
{ | ||
return m_width; | ||
} | ||
|
||
/// Sets the width of the error bar lines. Overridden in QwtErrorPlotCurve. | ||
void ErrorBarSettings::setWidth(double w) | ||
{ | ||
m_width = w; | ||
} | ||
|
||
/// Returns the color of the error bars. Overridden in QwtErrorPlotCurve. | ||
QColor ErrorBarSettings::color() const | ||
{ | ||
return m_color; | ||
} | ||
|
||
/// Sets the color of the error bars. Overridden in QwtErrorPlotCurve. | ||
void ErrorBarSettings::setColor(const QColor& c) | ||
{ | ||
m_color = c; | ||
} | ||
|
||
/// Returns whether the error bar lines are drawn through any symbol | ||
bool ErrorBarSettings::throughSymbol() const | ||
{ | ||
return m_through; | ||
} | ||
|
||
/// Sets whether to draw through any symbol | ||
void ErrorBarSettings::drawThroughSymbol(bool yes) | ||
{ | ||
m_through=yes; | ||
} | ||
|
||
/// Returns whether these error bars will be drawn on the positive side | ||
bool ErrorBarSettings::plusSide() const | ||
{ | ||
return m_plus; | ||
} | ||
|
||
/// Set whether these error bars will be drawn on the positive side | ||
void ErrorBarSettings::drawPlusSide(bool yes) | ||
{ | ||
m_plus=yes; | ||
} | ||
|
||
/// Returns whether these error bars will be drawn on the negative side | ||
bool ErrorBarSettings::minusSide() const | ||
{ | ||
return m_minus; | ||
} | ||
|
||
/// Set whether these error bars will be drawn on the negative side | ||
void ErrorBarSettings::drawMinusSide(bool yes) | ||
{ | ||
m_minus=yes; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#ifndef ERRORBARSETTINGS_H | ||
#define ERRORBARSETTINGS_H | ||
|
||
#include <QColor> | ||
|
||
/** Holds the settings for how a set of error bars are to be drawn. | ||
Copyright © 2012 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
class ErrorBarSettings | ||
{ | ||
public: | ||
ErrorBarSettings(); | ||
|
||
int capLength() const; | ||
void setCapLength(int t); | ||
|
||
virtual double width() const; | ||
virtual void setWidth(double w); | ||
|
||
virtual QColor color() const; | ||
virtual void setColor(const QColor& c); | ||
|
||
bool throughSymbol() const; | ||
void drawThroughSymbol(bool yes); | ||
|
||
bool plusSide() const; | ||
void drawPlusSide(bool yes); | ||
|
||
bool minusSide() const; | ||
void drawMinusSide(bool yes); | ||
|
||
private: | ||
int m_cap; ///< Length of the bar cap decoration | ||
bool m_plus; ///< Whether to draw these errors on the positive side | ||
bool m_minus; ///< Whether to draw these errors on the negative side | ||
bool m_through; ///< Whether to draw through any symbol on the curve | ||
|
||
double m_width; ///< Width of the error bars (only used for Mantid error bars) | ||
QColor m_color; ///< Color of the error bars (only used for Mantid error bars) | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters