comparison layer/SingleColourLayer.cpp @ 294:919740b20cc9

* Better abbreviation modes for layer names in pane (and input model combo of plugin parameter dialog) * Avoid crash when loading SV file containing model derived from nonexistent model (shouldn't happen of course, but see bug #1771769) * Remember last-used input model in plugin parameter dialog * Don't override a layer colour loaded from a session file with the generated default colour when attaching it to a view
author Chris Cannam
date Fri, 10 Aug 2007 16:36:50 +0000
parents 15b8a4bfe855
children ea37c229a578
comparison
equal deleted inserted replaced
293:15b8a4bfe855 294:919740b20cc9
23 23
24 SingleColourLayer::ColourRefCount 24 SingleColourLayer::ColourRefCount
25 SingleColourLayer::m_colourRefCount; 25 SingleColourLayer::m_colourRefCount;
26 26
27 SingleColourLayer::SingleColourLayer() : 27 SingleColourLayer::SingleColourLayer() :
28 m_colour(0) 28 m_colour(0),
29 m_colourExplicitlySet(false)
29 { 30 {
30 setDefaultColourFor(0); 31 setDefaultColourFor(0);
31 } 32 }
32 33
33 bool 34 bool
115 } 116 }
116 117
117 void 118 void
118 SingleColourLayer::setDefaultColourFor(View *v) 119 SingleColourLayer::setDefaultColourFor(View *v)
119 { 120 {
121 if (m_colourExplicitlySet) return;
122
120 bool dark = false; 123 bool dark = false;
121 if (v) { 124 if (v) {
122 dark = !v->hasLightBackground(); 125 dark = !v->hasLightBackground();
123 } else { 126 } else {
124 QColor bg = QApplication::palette().color(QPalette::Window); 127 QColor bg = QApplication::palette().color(QPalette::Window);
183 } 186 }
184 187
185 void 188 void
186 SingleColourLayer::setBaseColour(int colour) 189 SingleColourLayer::setBaseColour(int colour)
187 { 190 {
191 m_colourExplicitlySet = true;
192
188 if (m_colour == colour) return; 193 if (m_colour == colour) return;
189 194
190 if (m_colourRefCount.find(m_colour) != m_colourRefCount.end() && 195 if (m_colourRefCount.find(m_colour) != m_colourRefCount.end() &&
191 m_colourRefCount[m_colour] > 0) { 196 m_colourRefCount[m_colour] > 0) {
192 m_colourRefCount[m_colour]--; 197 m_colourRefCount[m_colour]--;
268 QString colourName = attributes.value("colourName"); 273 QString colourName = attributes.value("colourName");
269 QString colourSpec = attributes.value("colour"); 274 QString colourSpec = attributes.value("colour");
270 QString darkbg = attributes.value("darkBackground"); 275 QString darkbg = attributes.value("darkBackground");
271 m_colour = ColourDatabase::getInstance()->putStringValues 276 m_colour = ColourDatabase::getInstance()->putStringValues
272 (colourName, colourSpec, darkbg); 277 (colourName, colourSpec, darkbg);
273 } 278 if (m_colourRefCount.find(m_colour) == m_colourRefCount.end()) {
274 279 m_colourRefCount[m_colour] = 1;
280 } else {
281 m_colourRefCount[m_colour]++;
282 }
283 m_colourExplicitlySet = true;
284 flagBaseColourChanged();
285 }
286