void Doc_plugin_interface::getCurrentLayerProperties(QColor *c, DPI::LineWidth *w, DPI::LineType *t){
    RS_Pen pen = docGr->getActiveLayer()->getPen();
    RS_Color col = pen.getColor();
    c->setRgb(col.red(), col.green(), col.blue());
    *w = static_cast<DPI::LineWidth>(pen.getWidth());
    *t = static_cast<DPI::LineType>(pen.getLineType());
}
void Doc_plugin_interface::getCurrentLayerProperties(QColor *c, QString *w, QString *t){
    RS_Pen pen = docGr->getActiveLayer()->getPen();
    RS_Color col = pen.getColor();
    c->setRgb(col.red(), col.green(), col.blue());
    w->clear();
    w->append(Converter.lw2str(pen.getWidth()));
    t->clear();
    t->append(Converter.lt2str(pen.getLineType()));
}
Esempio n. 3
0
void RS_GraphicView::setBackground(const RS_Color& bg) {
	background = bg;

	// bright background:
	if (bg.red()+bg.green()+bg.blue()>380) {
		foreground = RS_Color(0,0,0);
	} else {
		foreground = RS_Color(255,255,255);
	}
}
Esempio n. 4
0
int ConvertColor(gdImagePtr i, RS_Color& c)
{
    return gdImageColorAllocateAlpha(i, c.red(), c.green(), c.blue(), 127 - c.alpha()/2 );
}
Esempio n. 5
0
bool GeometryAdapter::EvalColor(const MdfModel::MdfString& exprstr, RS_Color& rscolor)
{
    // TODO: needs an expression processor argument to eval expressions

    // string is in the form "AARRGGBB"
    const wchar_t* scolor = exprstr.c_str();

    size_t len = wcslen(scolor);
    unsigned int color = 0;
    bool isConst = false;

    // try to check if the expression is constant
    int status = 0;
    if (len == 0)
    {
        // error or a color was not set
        // use transparent black which indicates "not set"
        rscolor = RS_Color(RS_Color::EMPTY_COLOR_RGBA);
        return true;
    }
    else if (len == 8)
    {
        status = swscanf(scolor, L"%8X", &color);
    }
    else if (len == 6)
    {
        status = swscanf(scolor, L"%6X", &color);

        // there was no alpha specified in the constant string, add it
        color |= 0xFF000000;
    }

    if (status != 1)
    {
        // if not constant try to evaluate as expression
        if (!m_exec)
        {
            _ASSERT(false);
            rscolor = RS_Color(0x000000FF);
            return true;
        }

        FdoExpression* expr = ObtainFdoExpression(&exprstr);

        // make sure we have a parsed expression
        if (!expr)
        {
            _ASSERT(false);
            rscolor = RS_Color(0x000000FF);
            return false;
        }

        try
        {
            FdoPtr<FdoLiteralValue> lval = m_exec->Evaluate(expr);
            color = (unsigned int)ExpressionHelper::GetAsInt32(lval.p);
        }
        catch (FdoException* e)
        {
            ProcessStylizerException(e, __LINE__, __WFILE__);
            rscolor = RS_Color(0x000000FF);
            return false;
        }
        catch (...)
        {
            return false;
        }
    }
    else
    {
        isConst = true;
    }

    rscolor.alpha() =  color >> 24;
    rscolor.red()   = (color >> 16) & 0xFF;
    rscolor.green() = (color >>  8) & 0xFF;
    rscolor.blue()  =  color        & 0xFF;

    return isConst;
}