Exemple #1
0
MapColor* OgrFileImport::makeColor(OGRStyleToolH tool, const char* color_string)
{
	auto key = QByteArray::fromRawData(color_string, qstrlen(color_string));
	auto color = colors.value(key);
	if (!color)
	{	
		int r, g, b, a;
		auto success = OGR_ST_GetRGBFromString(tool, color_string, &r, &g, &b, &a);
		if (!success)
		{
			color = default_pen_color;
		}
		else if (a > 0)
		{
			color = new MapColor(color_string, map->getNumColors());
			color->setRgb(QColor{ r, g, b });
			color->setCmykFromRgb();
			map->addColor(color, map->getNumColors());
		}
		
		key.detach();
		colors.insert(key, color);
	}
	
	return color;
}
Exemple #2
0
QColor::QColor( int x, int y, int z, Spec colorSpec )
{
    d.d32.argb = Invalid;
    d.d32.pix = Dirt;
    if ( colorSpec == Hsv )
	setHsv( x, y, z );
    else
	setRgb( x, y, z );
}
Exemple #3
0
QColor::QColor( QRgb rgb, uint pixel )
{
    if ( pixel == 0xffffffff ) {
	setRgb( rgb );
    } else {
	d.argb = rgb;
	setPixel( pixel );
    }
}
Exemple #4
0
void tst_QColor::setBlue()
{
    DEPENDS_ON(setRgb());

    QColor c = QColor(Qt::red).toHsv();
    c.setBlue(127);
    QCOMPARE(c.red(), 255);
    QCOMPARE(c.green(), 0);
    QCOMPARE(c.blue(), 127);

    c = QColor(Qt::red).toHsv();
    c.setBlueF(0.5);
    QCOMPARE(c.redF(), qreal(1.0));
    QCOMPARE(c.greenF(), qreal(0.0));
    QVERIFY(veryFuzzyCompare(c.blueF(), 0.5));
}
Exemple #5
0
void QColor::setNamedColor( const QString &name )
{
    if ( name.isEmpty() ) {
	d.argb = 0;
	if ( colormodel == d8 ) {
	    d.d8.invalid = TRUE;
	} else {
	    d.d32.argb = Invalid;
	}
    } else if ( name[0] == '#' ) {
	const QChar *p = name.unicode()+1;
	int len = name.length()-1;
	int r, g, b;
	if ( len == 12 ) {
	    r = (hex2int(p[0]) << 4) + hex2int(p[1]);
	    g = (hex2int(p[4]) << 4) + hex2int(p[5]);
	    b = (hex2int(p[8]) << 4) + hex2int(p[9]);
	} else if ( len == 9 ) {
	    r = (hex2int(p[0]) << 4) + hex2int(p[1]);
	    g = (hex2int(p[3]) << 4) + hex2int(p[4]);
	    b = (hex2int(p[6]) << 4) + hex2int(p[7]);
	} else if ( len == 6 ) {
	    r = (hex2int(p[0]) << 4) + hex2int(p[1]);
	    g = (hex2int(p[2]) << 4) + hex2int(p[3]);
	    b = (hex2int(p[4]) << 4) + hex2int(p[5]);
	} else if ( len == 3 ) {
	    r = (hex2int(p[0]) << 4) + hex2int(p[0]);
	    g = (hex2int(p[1]) << 4) + hex2int(p[1]);
	    b = (hex2int(p[2]) << 4) + hex2int(p[2]);
	} else {
	    r = g = b = -1;
	}
	if ( (uint)r > 255 || (uint)g > 255 || (uint)b > 255 ) {
	    d.d32.argb = Invalid;
	    d.d32.pix = Dirt;
#if defined(QT_CHECK_RANGE)
	    qWarning( "QColor::setNamedColor: could not parse color '%s'",
		      name.local8Bit().data() );
#endif
	} else {
	    setRgb( r, g, b );
	}
    } else {
	setSystemNamedColor( name );
    }
}
Exemple #6
0
void QColor::setHsv( int h, int s, int v )
{
    if ( h < -1 || (uint)s > 255 || (uint)v > 255 ) {
#if defined(QT_CHECK_RANGE)
	qWarning( "QColor::setHsv: HSV parameters out of range" );
#endif
	return;
    }
    int r=v, g=v, b=v;
    if ( s == 0 || h == -1 ) {			// achromatic case
	// Ignore
    } else {					// chromatic case
	if ( (uint)h >= 360 )
	    h %= 360;
	uint f = h%60;
	h /= 60;
	uint p = (uint)(2*v*(255-s)+255)/510;
	uint q, t;
	if ( h&1 ) {
	    q = (uint)(2*v*(15300-s*f)+15300)/30600;
	    switch( h ) {
		case 1: r=(int)q; g=(int)v, b=(int)p; break;
		case 3: r=(int)p; g=(int)q, b=(int)v; break;
		case 5: r=(int)v; g=(int)p, b=(int)q; break;
	    }
	} else {
	    t = (uint)(2*v*(15300-(s*(60-f)))+15300)/30600;
	    switch( h ) {
		case 0: r=(int)v; g=(int)t, b=(int)p; break;
		case 2: r=(int)p; g=(int)v, b=(int)t; break;
		case 4: r=(int)t; g=(int)p, b=(int)v; break;
	    }
	}
    }
    setRgb( r, g, b );
}
Exemple #7
0
OgrFileImport::OgrFileImport(QIODevice* stream, Map* map, MapView* view, bool drawing_from_projected)
 : Importer(stream, map, view)
 , map_srs{ OSRNewSpatialReference(nullptr) }
 , manager{ OGR_SM_Create(nullptr) }
 , drawing_from_projected{ drawing_from_projected }
{
	GdalManager().configure();
	
	setOption(QLatin1String{ "Separate layers" }, QVariant{ false });
	
	auto spec = QByteArray::fromRawData("WGS84", 6);
	auto error = OSRSetWellKnownGeogCS(map_srs.get(), spec);
	if (!map->getGeoreferencing().isLocal() && !error)
	{
		spec = map->getGeoreferencing().getProjectedCRSSpec().toLatin1();
		error = OSRImportFromProj4(map_srs.get(), spec);
	}
	
	if (error)
	{
		addWarning(tr("Unable to setup \"%1\" SRS for GDAL: %2")
		           .arg(QString::fromLatin1(spec), QString::number(error)));
	}
	
	// Reasonable default?
	
	// OGR feature style defaults
	default_pen_color = new MapColor("Black", 0); 
	default_pen_color->setRgb({0.0, 0.0, 0.0});
	default_pen_color->setCmykFromRgb();
	map->addColor(default_pen_color, 0);
	
	auto default_brush_color = new MapColor("Black 50%", 0);
	default_brush_color->setRgb({0.5, 0.5, 0.5});
	default_brush_color->setCmykFromRgb();
	map->addColor(default_brush_color, 1);
	
	default_point_symbol = new PointSymbol();
	default_point_symbol->setName(tr("Point"));
	default_point_symbol->setNumberComponent(0, 1);
	default_point_symbol->setInnerColor(default_pen_color);
	map->addSymbol(default_point_symbol, 0);
	
	default_line_symbol = new LineSymbol();
	default_line_symbol->setName(tr("Line"));
	default_line_symbol->setNumberComponent(0, 2);
	default_line_symbol->setColor(default_pen_color);
	default_line_symbol->setLineWidth(0.1); // (0.1 mm, nearly cosmetic)
	default_line_symbol->setCapStyle(LineSymbol::FlatCap);
	default_line_symbol->setJoinStyle(LineSymbol::MiterJoin);
	map->addSymbol(default_line_symbol, 1);
	
	default_area_symbol = new AreaSymbol();
	default_area_symbol->setName(tr("Area"));
	default_area_symbol->setNumberComponent(0, 3);
	default_area_symbol->setColor(default_brush_color);
	map->addSymbol(default_area_symbol, 2);
	
	default_text_symbol = new TextSymbol();
	default_text_symbol->setName(tr("Text"));
	default_text_symbol->setNumberComponent(0, 4);
	default_text_symbol->setColor(default_pen_color);
	map->addSymbol(default_text_symbol, 3);
}
Exemple #8
0
void tst_QColor::rgb()
{
    DEPENDS_ON(setRgb());
}
Exemple #9
0
void tst_QColor::setAlpha()
{
    DEPENDS_ON(setRgb());
}
Exemple #10
0
void PSMoveForm::on_blueDial_valueChanged(int value)
{
	mRGB.setBlue(value);
	emit setRgb(mRGB);
}
Exemple #11
0
void tst_QColor::green()
{
    DEPENDS_ON(setRgb());
}
Exemple #12
0
void PSMoveForm::on_greenDial_valueChanged(int value)
{
	mRGB.setGreen(value);
	emit setRgb(mRGB);
}
Exemple #13
0
void PSMoveForm::on_redDial_valueChanged(int value)
{
	mRGB.setRed(value);
	emit setRgb(mRGB);
}
Exemple #14
0
WColor::WColor(Wt::GlobalColor name)
{
  switch(name) {
  case Wt::white:       setRgb(0xff, 0xff, 0xff); break;
  case Wt::black:       setRgb(0x00, 0x00, 0x00); break;
  case Wt::red:         setRgb(0xff, 0x00, 0x00); break;
  case Wt::darkRed:     setRgb(0x80, 0x00, 0x00); break;
  case Wt::green:       setRgb(0x00, 0xff, 0x00); break;
  case Wt::darkGreen:   setRgb(0x00, 0x80, 0x00); break;
  case Wt::blue:        setRgb(0x00, 0x00, 0xff); break;
  case Wt::darkBlue:    setRgb(0x00, 0x00, 0x80); break;
  case Wt::cyan:        setRgb(0x00, 0xff, 0xff); break;
  case Wt::darkCyan:    setRgb(0x00, 0x80, 0x80); break;
  case Wt::magenta:     setRgb(0xff, 0x00, 0xff); break;
  case Wt::darkMagenta: setRgb(0x80, 0x00, 0x80); break;
  case Wt::yellow:      setRgb(0xff, 0xff, 0x00); break;
  case Wt::darkYellow:  setRgb(0x80, 0x80, 0x00); break;
  case Wt::gray:        setRgb(0xa0, 0xa0, 0xa4); break;
  case Wt::darkGray:    setRgb(0x80, 0x80, 0x80); break;
  case Wt::lightGray:   setRgb(0xc0, 0xc0, 0xc0); break;
  case Wt::transparent: setRgb(0x00, 0x00, 0x00, 0x00); break;
  }
}
TilePixelValue::TilePixelValue(QRgb rgb)
    : data_(0)
{
    setRgb(rgb);
}
Exemple #16
0
void TColorValue::setPixel(const TPixel32 &src)
{
	setRgb(src.r, src.g, src.b);
	m_m = src.m / 255.0;
}