00001 /*************************************************************************** 00002 * Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de> * 00003 * * 00004 * This file is part of the FreeCAD CAx development system. * 00005 * * 00006 * This library is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Library General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00014 * GNU Library General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Library General Public * 00017 * License along with this library; see the file COPYING.LIB. If not, * 00018 * write to the Free Software Foundation, Inc., 59 Temple Place, * 00019 * Suite 330, Boston, MA 02111-1307, USA * 00020 * * 00021 ***************************************************************************/ 00022 00023 00024 #include "PreCompiled.h" 00025 00026 #include <QMessageBox> 00027 #include "DlgSettings3DViewPartImp.h" 00028 #include "ui_DlgSettings3DViewPart.h" 00029 00030 #include "ViewProvider.h" 00031 #include <Gui/PrefWidgets.h> 00032 #include <Gui/Application.h> 00033 #include <Gui/Document.h> 00034 #include <App/Application.h> 00035 #include <App/Document.h> 00036 #include <Base/Console.h> 00037 00038 using namespace PartGui; 00039 00044 DlgSettings3DViewPart::DlgSettings3DViewPart(QWidget* parent) 00045 : PreferencePage(parent), ui(new Ui_DlgSettings3DViewPart), checkValue(false) 00046 { 00047 ui->setupUi(this); 00048 } 00049 00053 DlgSettings3DViewPart::~DlgSettings3DViewPart() 00054 { 00055 // no need to delete child widgets, Qt does it all for us 00056 } 00057 00058 void DlgSettings3DViewPart::on_maxDeviation_valueChanged(double v) 00059 { 00060 if (!this->isVisible()) 00061 return; 00062 if (v < 0.01 && !checkValue) { 00063 checkValue = true; 00064 QMessageBox::warning(this, tr("Deviation"), 00065 tr("Setting a too small deviation causes the tessellation to take longer" 00066 "and thus freezes or slows down the GUI.")); 00067 } 00068 } 00069 00070 void DlgSettings3DViewPart::saveSettings() 00071 { 00072 ui->maxDeviation->onSave(); 00073 ui->prefCheckBox8->onSave(); 00074 ui->prefCheckBox3->onSave(); 00075 00076 // search for Part view providers and apply the new settings 00077 std::vector<App::Document*> docs = App::GetApplication().getDocuments(); 00078 for (std::vector<App::Document*>::iterator it = docs.begin(); it != docs.end(); ++it) { 00079 Gui::Document* doc = Gui::Application::Instance->getDocument(*it); 00080 std::vector<Gui::ViewProvider*> views = doc->getViewProvidersOfType(ViewProviderPart::getClassTypeId()); 00081 for (std::vector<Gui::ViewProvider*>::iterator jt = views.begin(); jt != views.end(); ++jt) { 00082 static_cast<ViewProviderPart*>(*jt)->reload(); 00083 } 00084 } 00085 } 00086 00087 void DlgSettings3DViewPart::loadSettings() 00088 { 00089 ui->maxDeviation->onRestore(); 00090 ui->prefCheckBox8->onRestore(); 00091 ui->prefCheckBox3->onRestore(); 00092 } 00093 00097 void DlgSettings3DViewPart::changeEvent(QEvent *e) 00098 { 00099 if (e->type() == QEvent::LanguageChange) { 00100 ui->retranslateUi(this); 00101 } 00102 else { 00103 QWidget::changeEvent(e); 00104 } 00105 } 00106 00107 #include "moc_DlgSettings3DViewPartImp.cpp"