Esempio n. 1
0
TestMap::TestMap()
{
	MapCoord coord;
	
	map = new Map();
	
	MapColor* black = new MapColor();
	black->setCmyk(MapColorCmyk(0.0f, 0.0f, 0.0f, 1.0f));
	black->setOpacity(1.0f);
	black->setName("black");
	map->addColor(black, 0);
	
	line_symbol = new LineSymbol();
	line_symbol->setLineWidth(1);
	line_symbol->setColor(black);
	map->addSymbol(line_symbol, 0);
	
	line_object = new PathObject(line_symbol);
	line_object->addCoordinate(MapCoord(10, 10));
	coord = MapCoord(20, 10);
	coord.setCurveStart(true);
	line_object->addCoordinate(coord);
	line_object->addCoordinate(MapCoord(20, 20));
	line_object->addCoordinate(MapCoord(30, 20));
	line_object->addCoordinate(MapCoord(30, 10));
	map->addObject(line_object);
	
	// TODO: fill map with more content as needed
}
Esempio n. 2
0
void ColorDialog::cmykValueChanged()
{
	if (!react_to_changes)
		return;
	
	if (custom_cmyk_option->isChecked())
	{
		color.setCmyk( MapColorCmyk(
		  c_edit->value()/100.0, m_edit->value()/100.0, y_edit->value()/100.0, k_edit->value()/100.0
		) );
		updateWidgets();
		setColorModified(true);
	}
}
Esempio n. 3
0
void MapColorTest::spotColorTest()
{
	QScopedPointer<MapColor> duplicate;
	
	// Initalizing a spot color.
	MapColor spot_cyan(QString::fromLatin1("Cyan"), 0);
	spot_cyan.setSpotColorName(QString::fromLatin1("CYAN"));
	QCOMPARE(spot_cyan.getSpotColorMethod(), MapColor::SpotColor);
	QCOMPARE(spot_cyan.getSpotColorName(), QString(QString::fromLatin1("CYAN")));
	
	spot_cyan.setCmyk(MapColorCmyk(1.0, 0.0, 0.0, 0.0));
	QCOMPARE(spot_cyan.getSpotColorMethod(), MapColor::SpotColor);  // unchanged
	QCOMPARE(spot_cyan.getCmykColorMethod(), MapColor::CustomColor);
	QVERIFY(!spot_cyan.getCmyk().isBlack());
	QVERIFY(!spot_cyan.getCmyk().isWhite());
	QVERIFY(!spot_cyan.getRgb().isBlack());
	QVERIFY(!spot_cyan.getRgb().isWhite());
	
	// Cloning a spot color.
	MapColor spot_cyan_copy(spot_cyan);
	QCOMPARE(spot_cyan_copy, spot_cyan);
	duplicate.reset(spot_cyan_copy.duplicate());
	QCOMPARE(*duplicate, spot_cyan_copy);
	
	// Renaming the clone's spot color name.
	spot_cyan_copy.setSpotColorName(QString::fromLatin1("CYAN2"));
	QCOMPARE(spot_cyan_copy.getSpotColorMethod(), MapColor::SpotColor);
	QCOMPARE(spot_cyan_copy.getSpotColorName(), QString(QString::fromLatin1("CYAN2")));        // new
	QVERIFY(!spot_cyan_copy.equals(spot_cyan, true));
	QCOMPARE(spot_cyan_copy.getCmykColorMethod(), MapColor::CustomColor); // unchanged
	QCOMPARE(spot_cyan_copy.getCmyk(), spot_cyan.getCmyk());              // unchanged
	
	// Setting a composition
	SpotColorComponents composition;
	composition.push_back(SpotColorComponent(&spot_cyan, 1.0));
	spot_cyan_copy.setSpotColorComposition(composition);
	QCOMPARE(spot_cyan_copy.getSpotColorMethod(), MapColor::CustomColor); // new
	QVERIFY(spot_cyan_copy.getSpotColorName() != QLatin1String("CYAN2")); // new
	QCOMPARE(spot_cyan_copy.getCmykColorMethod(), MapColor::CustomColor); // unchanged
	QCOMPARE(spot_cyan_copy.getCmyk(), spot_cyan.getCmyk());              // unchanged
	
	// Determining CMYK from spot colors
	spot_cyan_copy.setCmykFromSpotColors();
	QCOMPARE(spot_cyan_copy.getSpotColorMethod(), MapColor::CustomColor); // unchanged
	QCOMPARE(spot_cyan_copy.getCmykColorMethod(), MapColor::SpotColor);   // new
	QCOMPARE(spot_cyan_copy.getCmyk(), spot_cyan.getCmyk());              // unchanged
	
	// Setting a halftoning
	composition.front().factor = 0.5f;
	spot_cyan_copy.setSpotColorComposition(composition);
	QCOMPARE(spot_cyan_copy.getSpotColorMethod(), MapColor::CustomColor); // unchanged
	QCOMPARE(spot_cyan_copy.getCmykColorMethod(), MapColor::SpotColor);   // unchanged
	QVERIFY(spot_cyan_copy.getCmyk() != spot_cyan.getCmyk());             // new
	QCOMPARE(spot_cyan_copy.getCmyk().c, 0.5f);                           // computed!
	
	// Copy and compare spot color composition
	MapColor compo_copy(spot_cyan_copy);
	QCOMPARE(compo_copy.getSpotColorMethod(), MapColor::CustomColor);
	QCOMPARE(compo_copy.getCmykColorMethod(), MapColor::SpotColor);
	QCOMPARE(compo_copy.getCmyk().c, 0.5f);
	QCOMPARE(compo_copy, spot_cyan_copy);
	duplicate.reset(spot_cyan_copy.duplicate());
	QCOMPARE(*duplicate, spot_cyan_copy);
	
	MapColor spot_yellow(QString::fromLatin1("Yellow"), 8);
	spot_yellow.setCmyk(MapColorCmyk(0.0, 0.0, 1.0, 0.0));
	
	composition.clear();
	composition.push_back(SpotColorComponent(&spot_cyan, 0.8));
	composition.push_back(SpotColorComponent(&spot_yellow, 0.8));
	spot_cyan_copy.setSpotColorComposition(composition);
	composition.clear();
	composition.push_back(SpotColorComponent(&spot_yellow, 0.8));
	composition.push_back(SpotColorComponent(&spot_cyan, 0.8));
	compo_copy.setSpotColorComposition(composition);
	QCOMPARE(compo_copy, spot_cyan_copy); // Equal! Order of compositions doesn't matter.
	
	// Test MapColor::equals() with cloned spot color compositions
	MapColor spot_yellow_copy(spot_yellow);
	composition.front().spot_color = &spot_yellow_copy;
	compo_copy.setSpotColorComposition(composition);
	QVERIFY(compo_copy.equals(spot_cyan_copy, false));
	QVERIFY(compo_copy.equals(spot_cyan_copy, true));
	spot_yellow_copy.setPriority(spot_yellow_copy.getPriority() + 1);
	QVERIFY(compo_copy.equals(spot_cyan_copy, false));
	QVERIFY(!compo_copy.equals(spot_cyan_copy, true));
	
	duplicate.reset(spot_cyan_copy.duplicate());
	QCOMPARE(*duplicate, spot_cyan_copy);
	spot_cyan_copy.setKnockout(!spot_cyan_copy.getKnockout());
	QVERIFY(spot_cyan_copy != *duplicate);
	duplicate.reset(spot_cyan_copy.duplicate());
	QCOMPARE(*duplicate, spot_cyan_copy);
	spot_cyan_copy.setKnockout(!spot_cyan_copy.getKnockout());
	QVERIFY(spot_cyan_copy != *duplicate);
}