Пример #1
0
ItemSettings::ItemSettings(ItemProperties *prop,QWidget *parent):QWidget(parent,Qt::Tool)
{
    setupUi(this);

    this->prop = prop;

    this->fontColor = prop->fontColor;
    this->penColor = prop->itemPen.color();
    this->brushColor = prop->itemBrush.color();

    QPixmap penColor(45,11);
    penColor.fill(prop->itemPen.color());
    QIcon penIcon(penColor);
    this->pb_penColor->setIcon(penIcon);
    this->pb_penColor->setIconSize(QSize(45,11));
    this->sd_penWidth->setValue(prop->itemPen.width());
    this->cb_penStyle->setCurrentIndex(this->prop->itemPen.style() - 1);

    QPixmap brushColor(45,11);
    brushColor.fill(prop->itemBrush.color());
    QIcon brushIcon(brushColor);
    this->pb_brushColor->setIcon(brushIcon);
    this->pb_brushColor->setIconSize(QSize(45,11));
    this->cb_brushStyle->setCurrentIndex(this->prop->itemBrush.style());

    QPixmap fontColor(45,11);
    fontColor.fill(prop->fontColor);
    QIcon fontIcon(fontColor);
    this->pb_fontColor->setIcon(fontIcon);
    this->pb_fontColor->setIconSize(QSize(45,11));

    connect(pb_penColor,SIGNAL(released()),this,SLOT(setPenColor()));
    connect(pb_brushColor,SIGNAL(released()),this,SLOT(setBrushColor()));
    connect(pb_done,SIGNAL(released()),this,SLOT(saveSettings()));
    connect(pb_selectFont,SIGNAL(released()),this,SLOT(selectFont()));
    connect(pb_fontColor,SIGNAL(released()),this,SLOT(setFontColor()));

    int p_midX = parent->x() + 100;
    int p_midY = parent->y() + 150;

    this->move(p_midX , p_midY) ;

    this->activateWindow();
}
Пример #2
0
QVariant CurvesModel::data(const QModelIndex& index, int role) const
{
    SolvWidget* solv =  solvers->at(index.row());
    QwtPlotCurve * curve = solv->curve;
    QColor col = curve->pen().color();
    int bright = col.red() + 2*col.green() + col.blue();
    QwtSymbol::Style symSty;
    switch(index.column()) {
    case 0:// title
        switch(role) {
        case Qt::DisplayRole :
        case Qt::EditRole:
            return solv->getTitle();
        }
        break;
    case 1:// line color
        switch(role) {
        case Qt::BackgroundRole:
            return QBrush(col);
        case Qt::ForegroundRole:
            if(bright > 600 ) return QBrush(Qt::darkGray);
            return QBrush(Qt::white);
        case Qt::DisplayRole:
            return QVariant(colorName(col));
        case Qt::EditRole:
        case Qt::UserRole:
            return QVariant(col);
        }
        break;
    case 2:// line style
        switch(role) {
        case Qt::DecorationRole:
            return penIcon(solv->curve->pen());
        case Qt::DisplayRole :
            return penStyles[solv->curve->pen().style()];
        case Qt::EditRole :
            return solv->curve->pen().style();
        }
        break;
    case 3:// line width
        switch(role) {
        case Qt::DecorationRole:
            return penIcon(solv->curve->pen());
        case Qt::DisplayRole :
            return QString("%1").arg(solv->curve->pen().widthF(),4,'f',2);
        case Qt::EditRole :
            return solv->curve->pen().widthF();
        }
        break;
    case 4:// symbol style
        if(curve->symbol() == NULL) {
            symSty = QwtSymbol::NoSymbol;
        } else {
            symSty = curve->symbol()->style();
        }
        switch(role) {
        case Qt::EditRole :
            return QVariant(symSty);
        case Qt::DisplayRole :
            return SymbolStyleDelegate::symName(symSty);
        }
        break;
    case 5:// symbol color
        if(curve->symbol() != NULL && curve->symbol()->style() != QwtSymbol::NoSymbol) {
            col= curve->symbol()->pen().color();
        } // default to curve pen color
        switch(role) {
        case Qt::BackgroundRole:
            return QBrush(col);
        case Qt::ForegroundRole:
            if(bright > 600 ) return QBrush(Qt::darkGray);
            return QBrush(Qt::white);
        case Qt::DisplayRole :
            if(curve->symbol() == NULL || curve->symbol()->style() == QwtSymbol::NoSymbol) {
                return ("No Symbol");
            }
            return QVariant(colorName(col)) ;
        case Qt::EditRole:
        case Qt::UserRole:
            return QVariant(col);
        }
        break;
    case 6: // symbol size
        switch(role) {
            //case Qt::DecorationRole:
            //return penIcon(solv->curve->pen());
        case Qt::DisplayRole :
	  if(curve->symbol() != NULL && curve->symbol()->style() != QwtSymbol::NoSymbol ) {
            return QString("%1").arg(curve->symbol()->size().width());
	  }
	  break;
        case Qt::EditRole :
        case Qt::UserRole:
	  if(curve->symbol() != NULL && curve->symbol()->style() != QwtSymbol::NoSymbol ) {
            return curve->symbol()->size().width();
	  }
	  return 7;
        }
    }
    return QVariant();
}