Ejemplo n.º 1
0
void TFCompositeModifier::updateComposition_(){

	Selection selection = manager_.getComposition();
	clearLayout_();

	bool recalculate = false;
	M4D::Common::TimeStamp lastChange;
	Editor* editor;
	Composition newComposition;
	Composition::iterator found;
	for(Selection::iterator it = selection.begin(); it != selection.end(); ++it)
	{
		found = composition_.find(*it);
		if(found == composition_.end())
		{
			editor = new Editor(editors_.find(*it)->second);
			newComposition.insert(std::make_pair<TF::Size, Editor*>(
				*it,
				editor)
			);
			recalculate = true;
		}
		else
		{
			lastChange = found->second->editor->lastChange();
			if(found->second->change != lastChange)
			{
				recalculate = true;
				found->second->change = lastChange;
			}
			editor = found->second;
			editor->updateName();

			newComposition.insert(*found);
			composition_.erase(found);
		}

		layout_->addWidget(editor->name);
	}
	layout_->addItem(pushUpSpacer_);

	if(!composition_.empty()) recalculate = true;
	for(Composition::iterator it = composition_.begin(); it != composition_.end(); ++it)
	{
		layout_->removeWidget(it->second->name);
		delete it->second;
	}
	composition_.swap(newComposition);

	if(recalculate) computeResultFunction_();
}
Ejemplo n.º 2
0
void TFCompositeModifier::change_check(){

	if(managing_)
	{
		updateComposition_();
		return;
	}

	bool recalculate = false;
	
	Common::TimeStamp lastChange = palette_->lastPaletteChange();
	if(lastPaletteChange_ != lastChange)
	{
		lastPaletteChange_ = lastChange;
		editors_ = palette_->getEditors();
		//editors_.swap(palette_->getEditors());
		
		bool compositionEnabled = false;
		Composition newComposition;
		Composition::iterator found;
		for(TFPalette::Editors::iterator it = editors_.begin(); it != editors_.end(); ++it)
		{
			if(!it->second->hasAttribute(TFEditor::Composition) &&
				it->second->getDimension() == TF_DIMENSION_1)
			{
				compositionEnabled = true;

				found = composition_.find(it->first);
				if(found != composition_.end())
				{
					newComposition.insert(*found);
					composition_.erase(found);
				}
			}
		}

		if(!composition_.empty()) recalculate = true;
		for(Composition::iterator it = composition_.begin(); it != composition_.end(); ++it)
		{
			layout_->removeWidget(it->second->name);
			delete it->second;
		}
		composition_.swap(newComposition);

		compositeTools_->manageButton->setEnabled(compositionEnabled);
	}

	for(Composition::iterator it = composition_.begin(); it != composition_.end(); ++it)
	{
		lastChange = it->second->editor->lastChange();
		if(it->second->change != lastChange)
		{
			recalculate = true;
			it->second->change = lastChange;
		}
		it->second->updateName();
	}

	if(recalculate) computeResultFunction_();
}