Back to index

salome-paravis  6.5.0
pqSetModeStarter.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "pqSetModeStarter.h"
00021 
00022 #include <pqServerManagerModel.h>
00023 
00024 #include <pqApplicationCore.h>
00025 #include <pqRenderView.h>
00026 #include <pqSettings.h>
00027 
00028 
00029 //-----------------------------------------------------------------------------
00030 pqSetModeStarter::pqSetModeStarter(QObject* p/*=0*/)
00031   : QObject(p)
00032 {
00033 }
00034 
00035 //-----------------------------------------------------------------------------
00036 pqSetModeStarter::~pqSetModeStarter()
00037 {
00038 }
00039 
00040 
00041 //-----------------------------------------------------------------------------
00042 void pqSetModeStarter::onStartup()
00043 {
00044   this->setStandardMode();
00045 }
00046 
00047 //-----------------------------------------------------------------------------
00048 void pqSetModeStarter::setStandardMode()
00049 {
00050   pqSettings* settings = pqApplicationCore::instance()->settings();
00051   settings->beginGroup("renderModule");
00052   if (!settings->contains("InteractorStyle/CameraManipulators")) {
00053     // Set Post-Pro-like settings
00054     QStringList strs;
00055     pqRenderView::ManipulatorType manips[9];
00056     const pqRenderView::ManipulatorType* default3DManips = pqRenderView::getDefaultManipulatorTypes();
00057 
00058     // Copy default settings, make changes for Ctrl+MB and MB modes
00059     for(int i=0; i<9; i++)
00060       {
00061        manips[i] = default3DManips[i];
00062 
00063        // Ctrl+MB
00064        if (manips[i].Shift == 0 && manips[i].Control == 1) {
00065          if (manips[i].Mouse == 1)
00066            manips[i].Name = QByteArray("Zoom");
00067          else  if (manips[i].Mouse == 2)
00068            manips[i].Name = QByteArray("Pan");
00069          else  if (manips[i].Mouse == 3)
00070            manips[i].Name = QByteArray("Rotate");
00071        }
00072 
00073        // MB only
00074        if (manips[i].Shift == 0 && manips[i].Control == 0) {
00075          if (manips[i].Mouse == 1)
00076            manips[i].Name = QByteArray("Rotate");
00077          else  if (manips[i].Mouse == 2)
00078            manips[i].Name = QByteArray("Pan");
00079          else  if (manips[i].Mouse == 3)
00080            manips[i].Name = QByteArray("Zoom");
00081        }
00082       }
00083 
00084     // Save settings
00085     for(int i=0; i<9; i++)
00086       {
00087        strs << QString("Manipulator%1Mouse%2Shift%3Control%4Name%5")
00088          .arg(i+1)
00089          .arg(manips[i].Mouse)
00090          .arg(manips[i].Shift)
00091          .arg(manips[i].Control)
00092          .arg(QString(manips[i].Name));
00093       }
00094       
00095     settings->setValue("InteractorStyle/CameraManipulators", strs);
00096   }
00097   settings->endGroup();
00098 
00099   // Loop through render views and apply the settings
00100   QList<pqRenderViewBase*> views =
00101     pqApplicationCore::instance()->getServerManagerModel()->
00102     findItems<pqRenderViewBase*>();
00103 
00104   foreach(pqRenderViewBase* view, views) {
00105     view->restoreSettings(true);
00106   }
00107 }