DlgSettings3DViewImp.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025
00026 #ifndef _PreComp_
00027 # include <QRegExp>
00028 # include <memory>
00029 #endif
00030
00031 #include "DlgSettings3DViewImp.h"
00032 #include "NavigationStyle.h"
00033 #include "PrefWidgets.h"
00034 #include "ui_MouseButtons.h"
00035 #include <App/Application.h>
00036 #include <Base/Console.h>
00037 #include <Base/Parameter.h>
00038 #include <Base/Tools.h>
00039
00040 using namespace Gui::Dialog;
00041
00042
00043
00048 DlgSettings3DViewImp::DlgSettings3DViewImp(QWidget* parent)
00049 : PreferencePage( parent )
00050 {
00051 this->setupUi(this);
00052 retranslate();
00053 }
00054
00058 DlgSettings3DViewImp::~DlgSettings3DViewImp()
00059 {
00060
00061 }
00062
00063 void DlgSettings3DViewImp::saveSettings()
00064 {
00065
00066
00067 ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
00068 ("User parameter:BaseApp/Preferences/View");
00069 QVariant data = comboNavigationStyle->itemData(comboNavigationStyle->currentIndex(), Qt::UserRole);
00070 hGrp->SetASCII("NavigationStyle", (const char*)data.toByteArray());
00071
00072 int index = comboOrbitStyle->currentIndex();
00073 hGrp->SetInt("OrbitStyle", index);
00074
00075 checkBoxInvertZoom->onSave();
00076 checkBoxAntiAliasing->onSave();
00077 CheckBox_CornerCoordSystem->onSave();
00078 CheckBox_ShowFPS->onSave();
00079 CheckBox_UseAutoRotation->onSave();
00080 FloatSpinBox_EyeDistance->onSave();
00081 checkBoxBacklight->onSave();
00082 backlightColor->onSave();
00083 sliderIntensity->onSave();
00084 radioPerspective->onSave();
00085 radioOrthographic->onSave();
00086 }
00087
00088 void DlgSettings3DViewImp::loadSettings()
00089 {
00090 checkBoxInvertZoom->onRestore();
00091 checkBoxAntiAliasing->onRestore();
00092 CheckBox_CornerCoordSystem->onRestore();
00093 CheckBox_ShowFPS->onRestore();
00094 CheckBox_UseAutoRotation->onRestore();
00095 FloatSpinBox_EyeDistance->onRestore();
00096 checkBoxBacklight->onRestore();
00097 backlightColor->onRestore();
00098 sliderIntensity->onRestore();
00099 radioPerspective->onRestore();
00100 radioOrthographic->onRestore();
00101
00102 ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
00103 ("User parameter:BaseApp/Preferences/View");
00104 std::string model = hGrp->GetASCII("NavigationStyle",CADNavigationStyle::getClassTypeId().getName());
00105 int index = comboNavigationStyle->findData(QByteArray(model.c_str()));
00106 if (index > -1) comboNavigationStyle->setCurrentIndex(index);
00107
00108 index = comboOrbitStyle->currentIndex();
00109 index = hGrp->GetInt("OrbitStyle", index);
00110 index = Base::clamp(index, 0, comboOrbitStyle->count()-1);
00111 comboOrbitStyle->setCurrentIndex(index);
00112 }
00113
00114 void DlgSettings3DViewImp::on_mouseButton_clicked()
00115 {
00116 QDialog dlg(this);
00117 Ui_MouseButtons ui;
00118 ui.setupUi(&dlg);
00119
00120 QVariant data = comboNavigationStyle->itemData(comboNavigationStyle->currentIndex(), Qt::UserRole);
00121 void* instance = Base::Type::createInstanceByName((const char*)data.toByteArray());
00122 std::auto_ptr<UserNavigationStyle> ns(static_cast<UserNavigationStyle*>(instance));
00123 ui.groupBox->setTitle(ui.groupBox->title()+QString::fromAscii(" ")+comboNavigationStyle->currentText());
00124 QString descr;
00125 descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::SELECTION));
00126 ui.selectionLabel->setText(QString::fromAscii("<b>%1</b>").arg(descr));
00127 descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::PANNING));
00128 ui.panningLabel->setText(QString::fromAscii("<b>%1</b>").arg(descr));
00129 descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::DRAGGING));
00130 ui.rotationLabel->setText(QString::fromAscii("<b>%1</b>").arg(descr));
00131 descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::ZOOMING));
00132 ui.zoomingLabel->setText(QString::fromAscii("<b>%1</b>").arg(descr));
00133 dlg.exec();
00134 }
00135
00139 void DlgSettings3DViewImp::changeEvent(QEvent *e)
00140 {
00141 if (e->type() == QEvent::LanguageChange) {
00142 int navigation = comboNavigationStyle->currentIndex();
00143 int orbit = comboOrbitStyle->currentIndex();
00144 retranslateUi(this);
00145 retranslate();
00146 comboNavigationStyle->setCurrentIndex(navigation);
00147 comboOrbitStyle->setCurrentIndex(orbit);
00148 }
00149 else {
00150 QWidget::changeEvent(e);
00151 }
00152 }
00153
00154 void DlgSettings3DViewImp::retranslate()
00155 {
00156 std::vector<Base::Type> types;
00157 Base::Type::getAllDerivedFrom(UserNavigationStyle::getClassTypeId(), types);
00158 comboNavigationStyle->clear();
00159
00160 QRegExp rx(QString::fromAscii("^\\w+::(\\w+)Navigation\\w+$"));
00161 for (std::vector<Base::Type>::iterator it = types.begin(); it != types.end(); ++it) {
00162 if (*it != UserNavigationStyle::getClassTypeId()) {
00163 QString data = QString::fromAscii(it->getName());
00164 QString name = data.mid(data.indexOf(QLatin1String("::"))+2);
00165 if (rx.indexIn(data) > -1) {
00166 name = tr("%1 navigation").arg(rx.cap(1));
00167 }
00168 comboNavigationStyle->addItem(name, data);
00169 }
00170 }
00171 }
00172
00173 #include "moc_DlgSettings3DViewImp.cpp"
00174