void StrokeSelection::changeColorStyle(int styleIndex)
{
	TTool *tool = TTool::getApplication()->getCurrentTool()->getTool();
	if (!tool)
		return;
	TVectorImageP img(tool->getImage(true));
	if (!img)
		return;
	TPalette *palette = img->getPalette();
	TColorStyle *cs = palette->getStyle(styleIndex);
	if (!cs->isStrokeStyle())
		return;
	if (m_indexes.empty())
		return;

	UndoSetStrokeStyle *undo = new UndoSetStrokeStyle(img, styleIndex);
	std::set<int>::iterator it;
	for (it = m_indexes.begin(); it != m_indexes.end(); ++it) {
		int index = *it;
		assert(0 <= index && index < (int)img->getStrokeCount());
		TStroke *stroke = img->getStroke(index);
		undo->addStroke(stroke);
		stroke->setStyle(styleIndex);
	}

	tool->notifyImageChanged();
	TUndoManager::manager()->add(undo);
}
示例#2
0
void tglDraw(const TVectorRenderData &rd, const TStroke *s)
{
	assert(s);
	if (!s)
		return;

	const TStroke &stroke = *s;

	// initialize information for aaliasing
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);
	glEnable(GL_LINE_SMOOTH);

	// it's necessary to do line function of pixel size ?
	glLineWidth((float)1.0);

	assert(rd.m_palette);
	TStrokeProp *prop = stroke.getProp(/*rd.m_palette*/);
	/////questo codice stava dentro tstroke::getprop/////////
	TColorStyle *style = rd.m_palette->getStyle(stroke->getStyle() /*m_imp->m_styleId*/);
	if (!style->isStrokeStyle() || style->isEnabled() == false) {
		prop = 0;
	} else {
		if (!prop || style != prop->getColorStyle()) {
			stroke->setProp(style->makeStrokeProp(stroke));
			prop = stroke->getProp();
		}
	}
	///
	//---------------------
	if (prop)
		prop->draw(rd);
	//---------------------

	tglColor(TPixel32::White);

	glDisable(GL_BLEND);
	glDisable(GL_LINE_SMOOTH);
}