DlgDisplayPropertiesImp.cpp

Go to the documentation of this file.
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 #ifndef _PreComp_
00026 # include <algorithm>
00027 # include <boost/bind.hpp>
00028 # include <QDockWidget>
00029 #endif
00030 
00031 #include "DlgDisplayPropertiesImp.h"
00032 #include "DlgMaterialPropertiesImp.h"
00033 #include "DockWindowManager.h"
00034 #include "View3DInventorViewer.h"
00035 #include "View3DInventor.h"
00036 #include "Command.h"
00037 #include "Application.h"
00038 #include "Widgets.h"
00039 #include "Selection.h"
00040 #include "Document.h"
00041 #include "ViewProvider.h"
00042 #include "WaitCursor.h"
00043 #include "SpinBox.h"
00044 
00045 #include <Base/Console.h>
00046 #include <App/Application.h>
00047 #include <App/DocumentObject.h>
00048 #include <App/Material.h>
00049 
00050 using namespace Gui::Dialog;
00051 using namespace std;
00052 
00053 
00054 /* TRANSLATOR Gui::Dialog::DlgDisplayPropertiesImp */
00055 
00056 #if 0 // needed for Qt's lupdate utility
00057     qApp->translate("QDockWidget", "Display properties");
00058 #endif
00059 
00067 DlgDisplayPropertiesImp::DlgDisplayPropertiesImp( QWidget* parent, Qt::WFlags fl )
00068   : QDialog( parent, fl )
00069 {
00070     this->setupUi(this);
00071     textLabel1_3->hide();
00072     changePlot->hide();
00073     buttonLineColor->setModal(false);
00074     buttonColor->setModal(false);
00075 
00076     std::vector<Gui::ViewProvider*> views = getSelection();
00077     setDisplayModes(views);
00078     fillupMaterials();
00079     setMaterial(views);
00080     setColorPlot(views);
00081     setShapeColor(views);
00082     setLineColor(views);
00083     setPointSize(views);
00084     setLineWidth(views);
00085     setTransparency(views);
00086     setLineTransparency(views);
00087 
00088     // embed this dialog into a dockable widget container
00089     Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
00090     QDockWidget* dw = pDockMgr->addDockWindow("Display properties", this, Qt::AllDockWidgetAreas);
00091     dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
00092     dw->setAllowedAreas(Qt::DockWidgetAreas());
00093     dw->setFloating(true);
00094     dw->show();
00095 
00096     Gui::Selection().Attach(this);
00097 
00098     this->connectChangedObject =
00099     Gui::Application::Instance->signalChangedObject.connect(boost::bind
00100         (&DlgDisplayPropertiesImp::slotChangedObject, this, _1, _2));
00101 }
00102 
00106 DlgDisplayPropertiesImp::~DlgDisplayPropertiesImp()
00107 {
00108     // no need to delete child widgets, Qt does it all for us
00109     this->connectChangedObject.disconnect();
00110     Gui::Selection().Detach(this);
00111 }
00112 
00113 void DlgDisplayPropertiesImp::changeEvent(QEvent *e)
00114 {
00115     if (e->type() == QEvent::LanguageChange) {
00116         this->retranslateUi(this);
00117     }
00118     QDialog::changeEvent(e);
00119 }
00120 
00122 void DlgDisplayPropertiesImp::OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
00123                                        Gui::SelectionSingleton::MessageType Reason)
00124 {
00125     if (Reason.Type == SelectionChanges::AddSelection ||
00126         Reason.Type == SelectionChanges::RmvSelection ||
00127         Reason.Type == SelectionChanges::SetSelection ||
00128         Reason.Type == SelectionChanges::ClrSelection) {
00129         std::vector<Gui::ViewProvider*> views = getSelection();
00130         setDisplayModes(views);
00131         setMaterial(views);
00132         setColorPlot(views);
00133         setShapeColor(views);
00134         setLineColor(views);
00135         setPointSize(views);
00136         setLineWidth(views);
00137         setTransparency(views);
00138         setLineTransparency(views);
00139     }
00140 }
00142 
00143 void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj,
00144                                                 const App::Property& prop)
00145 {
00146     // This method gets called if a property of any view provider is changed.
00147     // We pick out all the properties for which we need to update this dialog.
00148     std::vector<Gui::ViewProvider*> Provider = getSelection();
00149     std::vector<Gui::ViewProvider*>::const_iterator vp = std::find_if
00150         (Provider.begin(), Provider.end(), 
00151         std::bind2nd(std::equal_to<Gui::ViewProvider*>(),
00152         const_cast<Gui::ViewProvider*>(&obj)));
00153     if (vp != Provider.end()) {
00154         std::string prop_name = obj.getName(&prop);
00155         if (prop.getTypeId() == App::PropertyColor::getClassTypeId()) {
00156             App::Color value = static_cast<const App::PropertyColor&>(prop).getValue();
00157             if (prop_name == "ShapeColor") {
00158                 bool blocked = buttonColor->blockSignals(true);
00159                 buttonColor->setColor(QColor((int)(255.0f*value.r),
00160                                              (int)(255.0f*value.g),
00161                                              (int)(255.0f*value.b)));
00162                 buttonColor->blockSignals(blocked);
00163             }
00164             else if (prop_name == "LineColor") {
00165                 bool blocked = buttonLineColor->blockSignals(true);
00166                 buttonLineColor->setColor(QColor((int)(255.0f*value.r),
00167                                                  (int)(255.0f*value.g),
00168                                                  (int)(255.0f*value.b)));
00169                 buttonLineColor->blockSignals(blocked);
00170             }
00171         }
00172         else if (prop.getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
00173             long value = static_cast<const App::PropertyInteger&>(prop).getValue();
00174             if (prop_name == "Transparency") {
00175                 bool blocked = spinTransparency->blockSignals(true);
00176                 spinTransparency->setValue(value);
00177                 spinTransparency->blockSignals(blocked);
00178                 blocked = horizontalSlider->blockSignals(true);
00179                 horizontalSlider->setValue(value);
00180                 horizontalSlider->blockSignals(blocked);
00181             }
00182             else if (prop_name == "LineTransparency") {
00183                 bool blocked = spinLineTransparency->blockSignals(true);
00184                 spinLineTransparency->setValue(value);
00185                 spinLineTransparency->blockSignals(blocked);
00186                 blocked = sliderLineTransparency->blockSignals(true);
00187                 sliderLineTransparency->setValue(value);
00188                 sliderLineTransparency->blockSignals(blocked);
00189             }
00190         }
00191         else if (prop.getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
00192             float value = static_cast<const App::PropertyFloat&>(prop).getValue();
00193             if (prop_name == "PointSize") {
00194                 bool blocked = spinPointSize->blockSignals(true);
00195                 spinPointSize->setValue((int)value);
00196                 spinPointSize->blockSignals(blocked);
00197             }
00198             else if (prop_name == "LineWidth") {
00199                 bool blocked = spinLineWidth->blockSignals(true);
00200                 spinLineWidth->setValue((int)value);
00201                 spinLineWidth->blockSignals(blocked);
00202             }
00203         }
00204     }
00205 }
00206 
00210 void DlgDisplayPropertiesImp::reject()
00211 {
00212     // closes the dock window
00213     Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
00214     pDockMgr->removeDockWindow(this);
00215     QDialog::reject();
00216 }
00217 
00221 void DlgDisplayPropertiesImp::on_buttonUserDefinedMaterial_clicked()
00222 {
00223     std::vector<Gui::ViewProvider*> Provider = getSelection();
00224     DlgMaterialPropertiesImp dlg("ShapeMaterial", this);
00225     dlg.setViewProviders(Provider);
00226     dlg.exec();
00227 
00228     buttonColor->setColor(dlg.diffuseColor->color());
00229 }
00230 
00234 void DlgDisplayPropertiesImp::on_buttonColorPlot_clicked()
00235 {
00236     std::vector<Gui::ViewProvider*> Provider = getSelection();
00237     static QPointer<DlgMaterialPropertiesImp> dlg = 0;
00238     if (!dlg)
00239         dlg = new DlgMaterialPropertiesImp("TextureMaterial", this);
00240     dlg->setModal(false);
00241     dlg->setAttribute(Qt::WA_DeleteOnClose);
00242     dlg->setViewProviders(Provider);
00243     dlg->show();
00244 }
00245 
00249 void DlgDisplayPropertiesImp::on_changeMaterial_activated(const QString& material)
00250 {
00251     std::vector<Gui::ViewProvider*> Provider = getSelection();
00252     App::Material mat(Materials[material]);
00253     App::Color diffuseColor = mat.diffuseColor;
00254     buttonColor->setColor(QColor((int)(diffuseColor.r*255.0f), (int)(diffuseColor.g*255.0f), (int)(diffuseColor.b*255.0f)));
00255 
00256     for (std::vector<Gui::ViewProvider*>::iterator It= Provider.begin();It!=Provider.end();It++) {
00257         App::Property* prop = (*It)->getPropertyByName("ShapeMaterial");
00258         if (prop && prop->getTypeId() == App::PropertyMaterial::getClassTypeId()) {
00259             App::PropertyMaterial* ShapeMaterial = (App::PropertyMaterial*)prop;
00260             ShapeMaterial->setValue(mat);
00261         }
00262     }
00263 }
00264 
00268 void DlgDisplayPropertiesImp::on_changeMode_activated(const QString& s)
00269 {
00270     Gui::WaitCursor wc;
00271     std::vector<Gui::ViewProvider*> Provider = getSelection();
00272     for (std::vector<Gui::ViewProvider*>::iterator It= Provider.begin();It!=Provider.end();It++) {
00273         App::Property* prop = (*It)->getPropertyByName("DisplayMode");
00274         if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) {
00275             App::PropertyEnumeration* Display = (App::PropertyEnumeration*)prop;
00276             Display->setValue((const char*)s.toAscii());
00277         }
00278     }
00279 }
00280 
00281 void DlgDisplayPropertiesImp::on_changePlot_activated(const QString&s)
00282 {
00283     Base::Console().Log("Plot = %s\n",(const char*)s.toAscii());
00284 }
00285 
00289 void DlgDisplayPropertiesImp::on_buttonColor_changed()
00290 {
00291     std::vector<Gui::ViewProvider*> Provider = getSelection();
00292     QColor s = buttonColor->color();
00293     App::Color c(s.red()/255.0,s.green()/255.0,s.blue()/255.0);
00294     for (std::vector<Gui::ViewProvider*>::iterator It= Provider.begin();It!=Provider.end();It++) {
00295         App::Property* prop = (*It)->getPropertyByName("ShapeColor");
00296         if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) {
00297             App::PropertyColor* ShapeColor = (App::PropertyColor*)prop;
00298             ShapeColor->setValue(c);
00299         }
00300     }
00301 }
00302 
00306 void DlgDisplayPropertiesImp::on_spinTransparency_valueChanged(int transparency)
00307 {
00308     std::vector<Gui::ViewProvider*> Provider = getSelection();
00309     for (std::vector<Gui::ViewProvider*>::iterator It= Provider.begin();It!=Provider.end();It++) {
00310         App::Property* prop = (*It)->getPropertyByName("Transparency");
00311         if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
00312             App::PropertyInteger* Transparency = (App::PropertyInteger*)prop;
00313             Transparency->setValue(transparency);
00314         }
00315     }
00316 }
00317 
00321 void DlgDisplayPropertiesImp::on_spinPointSize_valueChanged(int pointsize)
00322 {
00323     std::vector<Gui::ViewProvider*> Provider = getSelection();
00324     for (std::vector<Gui::ViewProvider*>::iterator It= Provider.begin();It!=Provider.end();It++) {
00325         App::Property* prop = (*It)->getPropertyByName("PointSize");
00326         if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
00327             App::PropertyFloat* PointSize = (App::PropertyFloat*)prop;
00328             PointSize->setValue((float)pointsize);
00329         }
00330     }
00331 }
00332 
00336 void DlgDisplayPropertiesImp::on_spinLineWidth_valueChanged(int linewidth)
00337 {
00338     std::vector<Gui::ViewProvider*> Provider = getSelection();
00339     for (std::vector<Gui::ViewProvider*>::iterator It= Provider.begin();It!=Provider.end();It++) {
00340         App::Property* prop = (*It)->getPropertyByName("LineWidth");
00341         if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
00342             App::PropertyFloat* LineWidth = (App::PropertyFloat*)prop;
00343             LineWidth->setValue((float)linewidth);
00344         }
00345     }
00346 }
00347 
00348 void DlgDisplayPropertiesImp::on_buttonLineColor_changed()
00349 {
00350     std::vector<Gui::ViewProvider*> Provider = getSelection();
00351     QColor s = buttonLineColor->color();
00352     App::Color c(s.red()/255.0,s.green()/255.0,s.blue()/255.0);
00353     for (std::vector<Gui::ViewProvider*>::iterator It= Provider.begin();It!=Provider.end();It++) {
00354         App::Property* prop = (*It)->getPropertyByName("LineColor");
00355         if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) {
00356             App::PropertyColor* ShapeColor = (App::PropertyColor*)prop;
00357             ShapeColor->setValue(c);
00358         }
00359     }
00360 }
00361 
00362 void DlgDisplayPropertiesImp::on_spinLineTransparency_valueChanged(int transparency)
00363 {
00364     std::vector<Gui::ViewProvider*> Provider = getSelection();
00365     for (std::vector<Gui::ViewProvider*>::iterator It= Provider.begin();It!=Provider.end();It++) {
00366         App::Property* prop = (*It)->getPropertyByName("LineTransparency");
00367         if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
00368             App::PropertyInteger* Transparency = (App::PropertyInteger*)prop;
00369             Transparency->setValue(transparency);
00370         }
00371     }
00372 }
00373 
00374 void DlgDisplayPropertiesImp::setDisplayModes(const std::vector<Gui::ViewProvider*>& views)
00375 {
00376     QStringList commonModes, modes;
00377     for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
00378         App::Property* prop = (*it)->getPropertyByName("DisplayMode");
00379         if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) {
00380             App::PropertyEnumeration* display = static_cast<App::PropertyEnumeration*>(prop);
00381             if (!display->getEnums()) return;
00382             const std::vector<std::string>& value = display->getEnumVector();
00383             if (it == views.begin()) {
00384                 for (std::vector<std::string>::const_iterator jt = value.begin(); jt != value.end(); ++jt)
00385                     commonModes << QLatin1String(jt->c_str());
00386             }
00387             else {
00388                 for (std::vector<std::string>::const_iterator jt = value.begin(); jt != value.end(); ++jt) {
00389                     if (commonModes.contains(QLatin1String(jt->c_str())))
00390                         modes << QLatin1String(jt->c_str());
00391                 }
00392 
00393                 commonModes = modes;
00394                 modes.clear();
00395             }
00396         }
00397     }
00398 
00399     changeMode->clear();
00400     changeMode->addItems(commonModes);
00401     changeMode->setDisabled(commonModes.isEmpty());
00402 
00403     // find the display mode to activate
00404     for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
00405         App::Property* prop = (*it)->getPropertyByName("DisplayMode");
00406         if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) {
00407             App::PropertyEnumeration* display = static_cast<App::PropertyEnumeration*>(prop);
00408             QString activeMode = QString::fromAscii(display->getValueAsString());
00409             int index = changeMode->findText(activeMode);
00410             if (index != -1) {
00411                 changeMode->setCurrentIndex(index);
00412                 break;
00413             }
00414         }
00415     }
00416 }
00417 
00418 void DlgDisplayPropertiesImp::setMaterial(const std::vector<Gui::ViewProvider*>& views)
00419 {
00420     bool material = false;
00421     for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
00422         App::Property* prop = (*it)->getPropertyByName("ShapeMaterial");
00423         if (prop && prop->getTypeId() == App::PropertyMaterial::getClassTypeId()) {
00424             material = true;
00425             break;
00426         }
00427     }
00428 
00429     changeMaterial->setEnabled(material);
00430     buttonUserDefinedMaterial->setEnabled(material);
00431 }
00432 
00433 void DlgDisplayPropertiesImp::setColorPlot(const std::vector<Gui::ViewProvider*>& views)
00434 {
00435     bool material = false;
00436     for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
00437         App::Property* prop = (*it)->getPropertyByName("TextureMaterial");
00438         if (prop && prop->getTypeId() == App::PropertyMaterial::getClassTypeId()) {
00439             material = true;
00440             break;
00441         }
00442     }
00443 
00444     buttonColorPlot->setEnabled(material);
00445 }
00446 
00447 void DlgDisplayPropertiesImp::fillupMaterials()
00448 {
00449     Materials[QLatin1String("Brass")]         = App::Material::BRASS;
00450     Materials[QLatin1String("Bronze")]        = App::Material::BRONZE;
00451     Materials[QLatin1String("Copper")]        = App::Material::COPPER;
00452     Materials[QLatin1String("Gold")]          = App::Material::GOLD;
00453     Materials[QLatin1String("Pewter")]        = App::Material::PEWTER;
00454     Materials[QLatin1String("Plaster")]       = App::Material::PLASTER;
00455     Materials[QLatin1String("Plastic")]       = App::Material::PLASTIC;
00456     Materials[QLatin1String("Silver")]        = App::Material::SILVER;
00457     Materials[QLatin1String("Steel")]         = App::Material::STEEL;
00458     Materials[QLatin1String("Stone")]         = App::Material::STONE;
00459     Materials[QLatin1String("Shiny plastic")] = App::Material::SHINY_PLASTIC;
00460     Materials[QLatin1String("Satin")]         = App::Material::SATIN;
00461     Materials[QLatin1String("Metalized")]     = App::Material::METALIZED;
00462     Materials[QLatin1String("Neon GNC")]      = App::Material::NEON_GNC;
00463     Materials[QLatin1String("Chrome")]        = App::Material::CHROME;
00464     Materials[QLatin1String("Aluminium")]     = App::Material::ALUMINIUM;
00465     Materials[QLatin1String("Obsidian")]      = App::Material::OBSIDIAN;
00466     Materials[QLatin1String("Neon PHC")]      = App::Material::NEON_PHC;
00467     Materials[QLatin1String("Jade")]          = App::Material::JADE;
00468     Materials[QLatin1String("Ruby")]          = App::Material::RUBY;
00469     Materials[QLatin1String("Emerald")]       = App::Material::EMERALD;
00470 
00471     QStringList material = Materials.keys();
00472     material.sort();
00473     changeMaterial->addItem(QLatin1String("Default"));
00474     changeMaterial->addItems(material);
00475     Materials[QLatin1String("Default")]       = App::Material::DEFAULT;
00476 }
00477 
00478 void DlgDisplayPropertiesImp::setShapeColor(const std::vector<Gui::ViewProvider*>& views)
00479 {
00480     bool shapeColor = false;
00481     for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
00482         App::Property* prop = (*it)->getPropertyByName("ShapeColor");
00483         if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) {
00484             App::Color c = static_cast<App::PropertyColor*>(prop)->getValue();
00485             QColor shape;
00486             shape.setRgb((int)(c.r*255.0f), (int)(c.g*255.0f),(int)(c.b*255.0f));
00487             bool blocked = buttonColor->blockSignals(true);
00488             buttonColor->setColor(shape);
00489             buttonColor->blockSignals(blocked);
00490             shapeColor = true;
00491             break;
00492         }
00493     }
00494 
00495     buttonColor->setEnabled(shapeColor);
00496 }
00497 
00498 void DlgDisplayPropertiesImp::setLineColor(const std::vector<Gui::ViewProvider*>& views)
00499 {
00500     bool shapeColor = false;
00501     for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
00502         App::Property* prop = (*it)->getPropertyByName("LineColor");
00503         if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) {
00504             App::Color c = static_cast<App::PropertyColor*>(prop)->getValue();
00505             QColor shape;
00506             shape.setRgb((int)(c.r*255.0f), (int)(c.g*255.0f),(int)(c.b*255.0f));
00507             bool blocked = buttonLineColor->blockSignals(true);
00508             buttonLineColor->setColor(shape);
00509             buttonLineColor->blockSignals(blocked);
00510             shapeColor = true;
00511             break;
00512         }
00513     }
00514 
00515     buttonLineColor->setEnabled(shapeColor);
00516 }
00517 
00518 void DlgDisplayPropertiesImp::setPointSize(const std::vector<Gui::ViewProvider*>& views)
00519 {
00520     bool pointSize = false;
00521     for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
00522         App::Property* prop = (*it)->getPropertyByName("PointSize");
00523         if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
00524             bool blocked = spinPointSize->blockSignals(true);
00525             spinPointSize->setValue((int)static_cast<App::PropertyFloat*>(prop)->getValue());
00526             spinPointSize->blockSignals(blocked);
00527             pointSize = true;
00528             break;
00529         }
00530     }
00531 
00532     spinPointSize->setEnabled(pointSize);
00533 }
00534 
00535 void DlgDisplayPropertiesImp::setLineWidth(const std::vector<Gui::ViewProvider*>& views)
00536 {
00537     bool lineWidth = false;
00538     for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
00539         App::Property* prop = (*it)->getPropertyByName("LineWidth");
00540         if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
00541             bool blocked = spinLineWidth->blockSignals(true);
00542             spinLineWidth->setValue((int)static_cast<App::PropertyFloat*>(prop)->getValue());
00543             spinLineWidth->blockSignals(blocked);
00544             lineWidth = true;
00545             break;
00546         }
00547     }
00548 
00549     spinLineWidth->setEnabled(lineWidth);
00550 }
00551 
00552 void DlgDisplayPropertiesImp::setTransparency(const std::vector<Gui::ViewProvider*>& views)
00553 {
00554     bool transparency = false;
00555     for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
00556         App::Property* prop = (*it)->getPropertyByName("Transparency");
00557         if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
00558             bool blocked = spinTransparency->blockSignals(true);
00559             spinTransparency->setValue(static_cast<App::PropertyInteger*>(prop)->getValue());
00560             spinTransparency->blockSignals(blocked);
00561 
00562             blocked = horizontalSlider->blockSignals(true);
00563             horizontalSlider->setValue(static_cast<App::PropertyInteger*>(prop)->getValue());
00564             horizontalSlider->blockSignals(blocked);
00565             transparency = true;
00566             break;
00567         }
00568     }
00569 
00570     spinTransparency->setEnabled(transparency);
00571     horizontalSlider->setEnabled(transparency);
00572 }
00573 
00574 void DlgDisplayPropertiesImp::setLineTransparency(const std::vector<Gui::ViewProvider*>& views)
00575 {
00576     bool transparency = false;
00577     for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
00578         App::Property* prop = (*it)->getPropertyByName("LineTransparency");
00579         if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
00580             bool blocked = spinLineTransparency->blockSignals(true);
00581             spinLineTransparency->setValue(static_cast<App::PropertyInteger*>(prop)->getValue());
00582             spinLineTransparency->blockSignals(blocked);
00583 
00584             blocked = sliderLineTransparency->blockSignals(true);
00585             sliderLineTransparency->setValue(static_cast<App::PropertyInteger*>(prop)->getValue());
00586             sliderLineTransparency->blockSignals(blocked);
00587             transparency = true;
00588             break;
00589         }
00590     }
00591 
00592     spinLineTransparency->setEnabled(transparency);
00593     sliderLineTransparency->setEnabled(transparency);
00594 }
00595 
00596 std::vector<Gui::ViewProvider*> DlgDisplayPropertiesImp::getSelection() const
00597 {
00598     std::vector<Gui::ViewProvider*> views;
00599 
00600     // get the complete selection
00601     std::vector<SelectionSingleton::SelObj> sel = Selection().getCompleteSelection();
00602     for (std::vector<SelectionSingleton::SelObj>::iterator it = sel.begin(); it != sel.end(); ++it) {
00603         Gui::ViewProvider* view = Application::Instance->getDocument(it->pDoc)->getViewProvider(it->pObject);
00604         views.push_back(view);
00605     }
00606 
00607     return views;
00608 }
00609 
00610 #include "moc_DlgDisplayPropertiesImp.cpp"
00611 

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