void PreferencesWindow::Update()
{
	myIsUpdating = true;

	Preferences* pref = AppConfig::GetInstance()->GetPreferences();

	GeoDataView* gdv = myVizMng->GetGeoDataVew();
	myUI->reductionSlider->setValue(myVizMng->GetPointReductionFactor());

	myUI->labelFontSizeBox->setValue(pref->GetPlotLabelFontSize());

	myPlotBackgroundButton->setChosenColor(pref->GetPlotBackgroundColor());
	myPlotForegroundButton->setChosenColor(pref->GetPlotForegroundColor());
	myPlotDataDefaultButton->setChosenColor(pref->GetPlotDefaultDataColor());

	myUI->plotLegendChoice->setChecked(pref->GetPlotLegend());
	myUI->plotPointsChoice->setChecked(pref->GetPlotPoints());

	myPlotColorWidget->setModel(pref->GetPlotColorModel());

	myUI->plotGroupingBox->setCurrentIndex(pref->GetGroupingTagId());
	myUI->plotSourceBox->setCurrentIndex(pref->GetGroupingSubset());

	myUI->scaleSlider->setValue((int)pref->GetDepthScale());

	myIsUpdating = false;
}
void PreferencesWindow::OnOkButtonClick()
{
	Preferences* pref = AppConfig::GetInstance()->GetPreferences();

	// Commit changes.
	GeoDataView* gdv = myVizMng->GetGeoDataVew();
	NavigationView* mr = myVizMng->GetNavigationView();
	myVizMng->SetPointReductionFactor(myUI->reductionSlider->value());

	pref->SetPlotLabelFontSize(myUI->labelFontSizeBox->value());

	pref->SetPlotForegroundColor(myPlotForegroundButton->chosenColor());
	pref->SetPlotBackgroundColor(myPlotBackgroundButton->chosenColor());
	pref->SetPlotDefaultDataColor(myPlotDataDefaultButton->chosenColor());


	pref->SetPlotLegend(myUI->plotLegendChoice->isChecked());
	pref->SetPlotPoints(myUI->plotPointsChoice->isChecked());

	DataSet::SubsetType subset = (DataSet::SubsetType)myUI->plotSourceBox->currentIndex();
	DataSetInfo::TagId tagId = (DataSetInfo::TagId)myUI->plotGroupingBox->currentIndex();

	pref->SetGroupingSubset(subset);
	pref->SetGroupingTagId(tagId);

	pref->SetDepthScale(myUI->scaleSlider->value());
	myVizMng->UpdateDepthScale();

	Utils::UpdateColorTransferFunction(pref->GetPlotColorTransferFunction(), pref->GetPlotColorModel());

	myVizMng->GetDataSet()->UpdateGroups(tagId, subset);

	VtkDataManager::GetInstance()->Update(DataSet::FilteredData);

	myVizMng->Update();
	hide();
}