22 #include <QTextStream> 23 #include <QApplication> 32 m_colourExplicitlySet(false),
33 m_defaultColourSet(false)
62 PropertyList list = Layer::getProperties();
63 list.push_back(
"Colour");
70 if (name ==
"Colour")
return tr(
"Colour");
77 if (name ==
"Colour")
return ColourProperty;
78 return InvalidProperty;
89 int *min,
int *max,
int *deflt)
const 93 int garbage0, garbage1, garbage2;
94 if (!min) min = &garbage0;
95 if (!max) max = &garbage1;
96 if (!deflt) deflt = &garbage2;
98 if (name ==
"Colour") {
106 val = Layer::getPropertyRangeAndValue(name, min, max, deflt);
116 if (name ==
"Colour") {
118 if (value >= 0 && value < db->getColourCount()) {
122 return tr(
"<unknown>");
134 if (name ==
"Colour") {
142 #ifdef DEBUG_COLOUR_SELECTION 154 QColor bg = QApplication::palette().color(QPalette::Window);
155 if (bg.red() + bg.green() + bg.blue() < 384) dark =
true;
167 #ifdef DEBUG_COLOUR_SELECTION 168 cerr <<
"hint = " << hint <<
", impose = " << impose << endl;
171 #ifdef DEBUG_COLOUR_SELECTION 172 cerr <<
"(from ctor)" << endl;
176 if (hint >= 0 && impose) {
183 int bestCount = 0, bestColour = -1;
196 #ifdef DEBUG_COLOUR_SELECTION 197 cerr <<
"index = " << index <<
", count = " << count;
200 if (bestColour < 0 || count < bestCount) {
203 #ifdef DEBUG_COLOUR_SELECTION 208 #ifdef DEBUG_COLOUR_SELECTION 261 std::vector<QColor> s;
264 for (
int i = 0; i < 3; ++i) {
265 int red = base.red() + ((bg.red() - base.red()) * (i + 1)) / 4;
266 int green = base.green() + ((bg.green() - base.green()) * (i + 1)) / 4;
267 int blue = base.blue() + ((bg.blue() - base.blue()) * (i + 1)) / 4;
268 s.push_back(QColor(red, green, blue));
275 QString indent, QString extraAttributes)
const 279 QString colourName, colourSpec, darkbg;
281 (
m_colour, colourName, colourSpec, darkbg);
283 s += QString(
"colourName=\"%1\" " 285 "darkBackground=\"%3\" ")
290 Layer::toXml(stream, indent, extraAttributes +
" " + s);
296 QString colourName = attributes.value(
"colourName");
297 QString colourSpec = attributes.value(
"colour");
298 QString darkbg = attributes.value(
"darkBackground");
301 (colourName, colourSpec, darkbg);
310 #ifdef DEBUG_COLOUR_SELECTION 311 SVDEBUG <<
"SingleColourLayer::setProperties: changing colour from " <<
m_colour <<
" to " << colour << endl;
QString getColourName(int c) const
virtual void setDefaultColourFor(View *v)
virtual void flagBaseColourChanged()
virtual QPixmap getLayerPresentationPixmap(QSize size) const
virtual QColor getForeground() const
virtual void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
Convert the layer's data (though not those of the model it refers to) into XML for file output.
bool m_colourExplicitlySet
QPixmap getExamplePixmap(int index, QSize size) const
void getStringValues(int index, QString &colourName, QString &colourSpec, QString &darkbg) const
virtual void setBaseColour(int)
Set the colour used to draw primary items in the layer.
virtual ~SingleColourLayer()
virtual void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
Convert the layer's data (though not those of the model it refers to) into XML for file output.
bool useDarkBackground(int c) const
virtual bool hasLightBackground() const
int putStringValues(QString colourName, QString colourSpec, QString darkbg)
virtual QColor getForegroundQColor(View *v) const
virtual int getDefaultColourHint(bool, bool &)
virtual QColor getBaseQColor() const
std::vector< QColor > getPartialShades(View *v) const
static ColourRefCount m_colourRefCount
virtual QString getPropertyLabel(const PropertyName &) const
virtual QColor getBackgroundQColor(View *v) const
void layerParametersChanged()
virtual QString getPropertyGroupName(const PropertyName &) const
virtual void setProperties(const QXmlAttributes &attributes)
Set the particular properties of a layer (those specific to the subclass) from a set of XML attribute...
virtual bool hasLightBackground() const
Return true if the layer currently has a dark colour on a light background, false if it has a light c...
int getColourCount() const
virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const
virtual RangeMapper * getNewPropertyRangeMapper(const PropertyName &) const
View is the base class of widgets that display one or more overlaid views of data against a horizonta...
virtual QString getPropertyValueLabel(const PropertyName &, int value) const
std::map< int, int > ColourRefCount
void getColourPropertyRange(int *min, int *max) const
virtual PropertyList getProperties() const
virtual QColor getBackground() const
virtual PropertyType getPropertyType(const PropertyName &) const
virtual int getBaseColour() const
Retrieve the current primary drawing colour, as a ColourDatabase index value.
static ColourDatabase * getInstance()
virtual void setProperty(const PropertyName &, int value)
QColor getColour(int c) const