DlgSettingsMeshView.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2009 Werner Mayer <wmayer[at]users.sourceforge.net>     *
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 "DlgSettingsMeshView.h"
00027 #include "ViewProvider.h"
00028 #include <Gui/PrefWidgets.h>
00029 #include <Gui/Application.h>
00030 #include <Gui/Document.h>
00031 #include <App/Application.h>
00032 #include <App/Document.h>
00033 #include <Base/Console.h>
00034 
00035 using namespace MeshGui;
00036 
00040 DlgSettingsMeshView::DlgSettingsMeshView(QWidget* parent)
00041   : PreferencePage(parent)
00042 {
00043     this->setupUi(this);
00044     labelBackfaceColor->hide();
00045     buttonBackfaceColor->hide();
00046 }
00047 
00051 DlgSettingsMeshView::~DlgSettingsMeshView()
00052 {
00053     // no need to delete child widgets, Qt does it all for us
00054 }
00055 
00056 void DlgSettingsMeshView::saveSettings()
00057 {
00058     checkboxRendering->onSave();
00059     checkboxBoundbox->onSave();
00060     buttonMeshColor->onSave();
00061     buttonLineColor->onSave();
00062     buttonBackfaceColor->onSave();
00063     spinMeshTransparency->onSave();
00064     spinLineTransparency->onSave();
00065     checkboxNormal->onSave();
00066     spinboxAngle->onSave();
00067 
00068     bool twoside = checkboxRendering->isChecked();
00069     double angle = 0.0;
00070     if (checkboxNormal->isChecked()) {
00071         angle = spinboxAngle->value();
00072     }
00073 
00074     // search for Mesh view providers and apply the new settings
00075     std::vector<App::Document*> docs = App::GetApplication().getDocuments();
00076     for (std::vector<App::Document*>::iterator it = docs.begin(); it != docs.end(); ++it) {
00077         Gui::Document* doc = Gui::Application::Instance->getDocument(*it);
00078         std::vector<Gui::ViewProvider*> views = doc->getViewProvidersOfType(ViewProviderMesh::getClassTypeId());
00079         for (std::vector<Gui::ViewProvider*>::iterator jt = views.begin(); jt != views.end(); ++jt) {
00080             ViewProviderMesh* meshview = static_cast<ViewProviderMesh*>(*jt);
00081             if (twoside) meshview->Lighting.setValue(1);
00082             else meshview->Lighting.setValue((long)0);
00083             meshview->CreaseAngle.setValue(angle);
00084         }
00085     }
00086 }
00087 
00088 void DlgSettingsMeshView::loadSettings()
00089 {
00090     Base::Reference<ParameterGrp> hGrp = Gui::WindowParameter::getDefaultParameter();
00091     hGrp = hGrp->GetGroup("View");
00092     if (!hGrp->GetBool("EnablePreselection",true) &&
00093         !hGrp->GetBool("EnableSelection",true))
00094         checkboxBoundbox->setDisabled(true);
00095     checkboxRendering->onRestore();
00096     checkboxBoundbox->onRestore();
00097     buttonMeshColor->onRestore();
00098     buttonLineColor->onRestore();
00099     buttonBackfaceColor->onRestore();
00100     spinMeshTransparency->onRestore();
00101     spinLineTransparency->onRestore();
00102     checkboxNormal->onRestore();
00103     spinboxAngle->onRestore();
00104 }
00105 
00109 void DlgSettingsMeshView::changeEvent(QEvent *e)
00110 {
00111     if (e->type() == QEvent::LanguageChange) {
00112         retranslateUi(this);
00113     }
00114     else {
00115         QWidget::changeEvent(e);
00116     }
00117 }
00118 
00119 #include "moc_DlgSettingsMeshView.cpp"

Generated on Wed Nov 23 19:00:07 2011 for FreeCAD by  doxygen 1.6.1