左侧数据树 色板属性添加颜色与色板名称显示。
This commit is contained in:
parent
5dde02103b
commit
b391a7e959
|
|
@ -390,6 +390,32 @@ void QtColorSchemeComboBoxPropertyManager::setEnumIcons(QtProperty *property, co
|
||||||
|
|
||||||
emit propertyChanged(property);
|
emit propertyChanged(property);
|
||||||
}
|
}
|
||||||
|
QPixmap QtColorSchemeComboBoxPropertyManager::getColorLabelPixmap(const QVector<QtColorItem> &colorList, int colorNumber)
|
||||||
|
{
|
||||||
|
int w = 64, h = 32;
|
||||||
|
QPixmap pixmap(w, h);
|
||||||
|
QBrush brush(QColor(255, 0, 0));
|
||||||
|
pixmap.fill(QColor(255, 0, 0));
|
||||||
|
|
||||||
|
//QVector<QtColorItem> newColorList=paiInpolation(colorList,colorNumber);
|
||||||
|
|
||||||
|
|
||||||
|
QPainter painter;
|
||||||
|
painter.begin(&pixmap);
|
||||||
|
float colorStep = colorNumber * 1. / w;
|
||||||
|
QPen Pen;
|
||||||
|
for (int x = 0; x < w; x++)
|
||||||
|
{
|
||||||
|
// 色标位置
|
||||||
|
int clrIndex = (int)((x)* colorStep);
|
||||||
|
if (colorList.size() <= x) break;
|
||||||
|
Pen.setColor(QColor(colorList[clrIndex].color));
|
||||||
|
painter.setPen(Pen);
|
||||||
|
painter.drawLine(x, 0, x, h - 1);
|
||||||
|
}
|
||||||
|
painter.end();
|
||||||
|
return pixmap;
|
||||||
|
}
|
||||||
void QtColorSchemeComboBoxPropertyManager::setLinear(QtProperty *property)
|
void QtColorSchemeComboBoxPropertyManager::setLinear(QtProperty *property)
|
||||||
{
|
{
|
||||||
QStringList enumNames;
|
QStringList enumNames;
|
||||||
|
|
@ -408,20 +434,20 @@ void QtColorSchemeComboBoxPropertyManager::setLinear(QtProperty *property)
|
||||||
|
|
||||||
for(int i = 0 ; i < nCount; i++)
|
for(int i = 0 ; i < nCount; i++)
|
||||||
{
|
{
|
||||||
enumNames.push_back(QString::number(i));
|
enumNames.push_back(colorList.at(i).schemeName);
|
||||||
//colorMap.
|
//colorMap.
|
||||||
// QPixmap pix(rectSize);
|
QPixmap pix = getColorLabelPixmap(colorList.at(i).colorList, colorList.at(i).colorList.count());
|
||||||
// pix.fill(Qt::white);
|
// pix.fill(Qt::white);
|
||||||
// QBrush brush(Qt::black);
|
// QBrush brush(Qt::black);
|
||||||
// QPen pen(brush,2, linears.at(i));
|
// QPen pen(brush,2, linears.at(i));
|
||||||
// QPainter painter(&pix);
|
// QPainter painter(&pix);
|
||||||
// painter.setPen(pen);
|
// painter.setPen(pen);
|
||||||
// painter.drawLine(2,7,500,7);
|
// painter.drawLine(2,7,500,7);
|
||||||
//enumIcons[i] = QIcon(pix);
|
enumIcons[i] = QIcon(pix);
|
||||||
}
|
}
|
||||||
|
|
||||||
setEnumNames(property, enumNames);
|
setEnumNames(property, enumNames);
|
||||||
//setEnumIcons(property, enumIcons);
|
setEnumIcons(property, enumIcons);
|
||||||
|
|
||||||
}
|
}
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ protected:
|
||||||
bool IsColorScheme(const QtProperty *property) const;
|
bool IsColorScheme(const QtProperty *property) const;
|
||||||
virtual void initializeProperty(QtProperty *property);
|
virtual void initializeProperty(QtProperty *property);
|
||||||
virtual void uninitializeProperty(QtProperty *property);
|
virtual void uninitializeProperty(QtProperty *property);
|
||||||
|
|
||||||
|
QPixmap getColorLabelPixmap(const QVector<QtColorItem> &colorList, int colorNumber);
|
||||||
private:
|
private:
|
||||||
QScopedPointer<QtColorSchemeComboBoxPropertyManagerPrivate> d_ptr;
|
QScopedPointer<QtColorSchemeComboBoxPropertyManagerPrivate> d_ptr;
|
||||||
Q_DECLARE_PRIVATE(QtColorSchemeComboBoxPropertyManager)
|
Q_DECLARE_PRIVATE(QtColorSchemeComboBoxPropertyManager)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user