1 // Copyright (C) 2010-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "pqSetModeStarter.h"
22 #include <pqServerManagerModel.h>
24 #include <pqApplicationCore.h>
25 #include <pqRenderView.h>
26 #include <pqSettings.h>
29 //-----------------------------------------------------------------------------
30 pqSetModeStarter::pqSetModeStarter(QObject* p/*=0*/)
35 //-----------------------------------------------------------------------------
36 pqSetModeStarter::~pqSetModeStarter()
41 //-----------------------------------------------------------------------------
42 void pqSetModeStarter::onStartup()
44 this->setStandardMode();
47 //-----------------------------------------------------------------------------
48 void pqSetModeStarter::setStandardMode()
50 pqSettings* settings = pqApplicationCore::instance()->settings();
51 settings->beginGroup("renderModule");
52 if (!settings->contains("InteractorStyle/CameraManipulators")) {
53 // Set Post-Pro-like settings
55 pqRenderView::ManipulatorType manips[9];
56 const pqRenderView::ManipulatorType* default3DManips = pqRenderView::getDefault3DManipulatorTypes();
58 // Copy default settings, make changes for Ctrl+MB and MB modes
59 for(int i=0; i<9; i++)
61 manips[i] = default3DManips[i];
64 if (manips[i].Shift == 0 && manips[i].Control == 1) {
65 if (manips[i].Mouse == 1)
66 manips[i].Name = QByteArray("Zoom");
67 else if (manips[i].Mouse == 2)
68 manips[i].Name = QByteArray("Pan");
69 else if (manips[i].Mouse == 3)
70 manips[i].Name = QByteArray("Rotate");
74 if (manips[i].Shift == 0 && manips[i].Control == 0) {
75 if (manips[i].Mouse == 1)
76 manips[i].Name = QByteArray("Rotate");
77 else if (manips[i].Mouse == 2)
78 manips[i].Name = QByteArray("Pan");
79 else if (manips[i].Mouse == 3)
80 manips[i].Name = QByteArray("Zoom");
85 for(int i=0; i<9; i++)
87 strs << QString("Manipulator%1Mouse%2Shift%3Control%4Name%5")
91 .arg(manips[i].Control)
92 .arg(QString(manips[i].Name));
95 settings->setValue("InteractorStyle/CameraManipulators", strs);
99 // Loop through render views and apply the settings
100 QList<pqRenderViewBase*> views =
101 pqApplicationCore::instance()->getServerManagerModel()->
102 findItems<pqRenderViewBase*>();
104 foreach(pqRenderViewBase* view, views) {
105 view->restoreSettings(true);