Source
xxxxxxxxxx
QwtLinearColorMap* colorMap = new QwtLinearColorMap(QColor("#000000"), QColor("#FFFFFF"));
//# QPOptions.cc: Qwt implementation of generic PlotOption classes.
//# Copyright (C) 2008
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library 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 Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: aips2-request@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
//# $Id: $
using namespace casacore;
namespace casa {
/////////////////////////
// QPCOLOR DEFINITIONS //
/////////////////////////
QPColor::QPColor() : m_color() { }
QPColor::QPColor(const String& color) : m_color() {
setAsHexadecimalOrName(color); }
QPColor::QPColor(const QColor& c) : m_color(c) { }
QPColor::QPColor(const PlotColor& color) : m_color() {
operator=(color);
}
QPColor::QPColor(const PlotColorPtr color) : m_color() {
if(!color.null()) operator=(*color);
}
QPColor::QPColor(const QPColor& color) : PlotColor(), m_color(color.asQColor()) { }
QPColor::~QPColor() { }
String QPColor::asHexadecimal() const {
String hex = m_color.name().toStdString();
if(hex.size() > 0 && hex[0] == '#') hex.erase(0, 1);
return hex;
}
String QPColor::asName() const {
// there has to be a better way to do this?
QStringList colors = QColor::colorNames();
QColor color;
QString name = m_color.name();
for(int i = 0; i < colors.size(); i++) {
color.setNamedColor(colors[i]);
if(color.name() == name) return colors[i].toStdString();
}
return "";
}
void QPColor::setAsHexadecimalOrName(const String& str) {
QString name = m_color.name();
// three possibilities: a name (i.e. "black"), a hex value (i.e. "000000"),
// or a #'ed hex value (i.e. "#000000"). QColor::setNamedColor can
// natively handle the first and third, so just check for second.
String hex = str;
if(hex.size() == 6 && ((hex[0] >= '0' && hex[0] <= '9') ||
(hex[0] >= 'A' && hex[0] <= 'F') || (hex[0] >= 'a' && hex[0] <= 'f'))) {
bool isHex = true;
// hopefully no color names also fit this pattern..
for(unsigned int i = 1; i < hex.size(); i++) {
if(!((hex[i] >= '0' && hex[i] <= '9') ||