MCPcopy Create free account
hub / github.com/KDE/labplot / render

Method render

src/tools/ColorMapsManager.cpp:95–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95void ColorMapsManager::render(QPixmap& pixmap, const QString& name) {
96 if (name.isEmpty())
97 return;
98
99 if (!m_colors.contains(name)) {
100 for (const auto& name : collectionNames())
101 colorMapNames(name);
102 }
103
104 // convert from the string RGB represetation to QColor
105 m_colormap.clear();
106 for (auto& rgb : m_colors[name]) {
107 QStringList rgbValues = rgb.split(QLatin1Char(','));
108 if (rgbValues.count() == 3)
109 m_colormap << QColor(rgbValues.at(0).toInt(), rgbValues.at(1).toInt(), rgbValues.at(2).toInt());
110 else if (rgbValues.count() == 4)
111 m_colormap << QColor(rgbValues.at(1).toInt(), rgbValues.at(2).toInt(), rgbValues.at(3).toInt());
112 }
113
114 // render the preview pixmap
115 int height = 80;
116 int width = 200;
117 int count = m_colormap.count();
118 pixmap = QPixmap(width, height);
119 QPainter p(&pixmap);
120 int i = 0;
121 for (auto& color : m_colormap) {
122 p.setPen(color);
123 p.setBrush(color);
124 p.drawRect(i * width / count, 0, width / count, height);
125 ++i;
126 }
127}
128
129/**
130 * @brief Processes the json metadata file that contains the list of colormap collections.

Callers 11

CFloatingDragPreviewMethod · 0.80
collectionChangedMethod · 0.80
colorMapChangedMethod · 0.80
previewPixmapMethod · 0.80
exportPaintMethod · 0.80
printMethod · 0.80
updateImageMethod · 0.80
exportPaintMethod · 0.80
printMethod · 0.80
setColumnsMethod · 0.80

Calls 9

splitMethod · 0.80
setPenMethod · 0.80
setBrushMethod · 0.80
QPixmapClass · 0.70
QColorClass · 0.50
isEmptyMethod · 0.45
containsMethod · 0.45
clearMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected