Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
optionsWidget.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50
51
52 #include <OpenFlipper/ACGHelper/DrawModeConverter.hh>
53 #include <OpenFlipper/INIFile/INIFile.hh>
54 #include <OpenFlipper/BasePlugin/PluginFunctions.hh>
55 #include <OpenFlipper/common/GlobalOptions.hh>
56 #include <ACG/GL/ShaderCache.hh>
57
58 #include "optionsWidget.hh"
59
60 OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyBinding>& _core, InverseKeyMap& _invKeys, QWidget *parent)
61 : QWidget(parent),
62 plugins_(_plugins),
63 coreKeys_(_core),
64 keys_(_invKeys),
65 progressDialog_(NULL),
66 restartRequired_(false),
67 exitOnClose_(false)
68 {
69 setupUi(this);
70
71 connect(okButton,SIGNAL(clicked()),this,SLOT(slotOk()));
72 connect(applyButton,SIGNAL(clicked()),this,SLOT(slotApply()));
73 connect(cancelButton,SIGNAL(clicked()),this,SLOT(slotCancel()));
74 connect(checkUpdateButton,SIGNAL(clicked()),this,SLOT(slotCheckUpdates()));
75 connect(updateButton,SIGNAL(clicked()),this,SLOT(slotGetUpdates()));
76 updateButton->setEnabled(false);
77
78 // Files
79 connect(pbReloadShaders,SIGNAL(clicked()),this,SLOT(slotReloadShaders()));
80
81 // Viewer Settings
82 connect( restrictFPS, SIGNAL(toggled(bool)), FPS, SLOT(setEnabled(bool)) );
83 connect( viewerList, SIGNAL(currentRowChanged(int)), this, SLOT(updateViewerSettings(int)) );
84 connect( availDrawModes, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(viewerSettingsChanged(QListWidgetItem*)) );
85 connect( projectionBox, SIGNAL(currentIndexChanged(int)), this, SLOT(viewerSettingsChanged(int)));
86 connect( directionBox, SIGNAL(currentIndexChanged(int)), this, SLOT(viewerSettingsChanged(int)));
87 connect( lockRotationBox, SIGNAL(stateChanged(int)), this, SLOT(viewerSettingsChanged(int)));
88
89 // Switch stacked widget of stereo settings
90 connect(stereoOpengl, SIGNAL(clicked()),
91 this, SLOT(switchStackedWidget()));
92 connect(stereoAnaglyph, SIGNAL(clicked()),
93 this, SLOT(switchStackedWidget()));
94 connect(stereoCustomAnaglyph, SIGNAL(clicked()),
95 this, SLOT(switchStackedWidget()));
96
97 connect(focalDistance, SIGNAL(sliderReleased()),
98 this, SLOT(slotPreviewStereoSettings()));
99 connect(eyeDistance, SIGNAL(editingFinished()),
100 this, SLOT(slotPreviewStereoSettings()));
101
102 ACG::SceneGraph::DrawModes::ModeFlagSet mode(2);
103 for (uint i=1; i < 22; i++) {
104 std::vector< QString > dm = drawModeToDescriptions( mode );
105
106 if ( !dm.empty() && dm[0].trimmed() != ""){
107 QListWidgetItem* item = new QListWidgetItem(dm[0]);
108
109 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable);
110
111 item->setCheckState(Qt::Unchecked);
112
113 availDrawModes->addItem( item );
114 }
115
116 mode = mode<<1;
117 }
118
119 defaultProjectionMode_.resize(4);
120 defaultViewingDirections_.resize(4);
121 defaultRotationLocks_.resize(4);
122
123 for ( int i=0; i < PluginFunctions::viewers(); i++ ){
124 viewerList->addItem("Viewer " + QString::number(i+1) );
125 defaultDrawModes_.push_back( ACG::SceneGraph::DrawModes::DEFAULT );
126 }
127
128 pluginOptionsLayout = new QVBoxLayout;
129 pluginOptions->setLayout( pluginOptionsLayout );
130
131 networkMan_ = new QNetworkAccessManager(this);
132
133 // http specific connections
134 connect(networkMan_, SIGNAL(finished(QNetworkReply *)),
135 this, SLOT(httpRequestFinished(QNetworkReply *)));
136 connect(networkMan_,SIGNAL(authenticationRequired(QNetworkReply* , QAuthenticator *)),
137 this,SLOT(authentication(QNetworkReply *, QAuthenticator*)));
138
139 //colordialog
140 connect(backgroundButton, SIGNAL(clicked()), this, SLOT(getBackgroundColor()) );
141 connect(defaultColorButton, SIGNAL(clicked()), this, SLOT(getDefaultColor()) );
142
143 // Clear settings and ini buttons
144 connect(clearSettingsButton, SIGNAL(clicked()), this, SLOT(slotClearSettings()));
145 connect(clearINIButton, SIGNAL(clicked()), this, SLOT(slotClearINI()));
146
147 // Disable update tab if app store compliant build
148 #ifdef OPENFLIPPER_BUILD_APP_STORE_COMPLIANT
149 //tabWidget->setTabEnabled(tabWidget->count()-1,false);
150 tabWidget->removeTab(tabWidget->count()-1);
151 #endif
152 }
153
154 void OptionsWidget::getBackgroundColor(){
155 QColor newColor = QColorDialog::getColor ( OpenFlipperSettings().value("Core/Gui/glViewer/defaultBackgroundColor").value<QColor>() );
156
157 backgroundColor_ = newColor;
158
159 QPixmap color(16,16);
160 color.fill( newColor );
161 backgroundButton->setIcon( QIcon(color) );
162 }
163
164 void OptionsWidget::getDefaultColor(){
165 QColor newColor = QColorDialog::getColor ( OpenFlipper::Options::defaultColor() );
166
167 OpenFlipper::Options::defaultColor( newColor) ;
168
169 QPixmap color(16,16);
170 color.fill( OpenFlipper::Options::defaultColor() );
171 defaultColorButton->setIcon( QIcon(color) );
172 }
173
174 void OptionsWidget::viewerSettingsChanged(QListWidgetItem* /*_item*/){
175 viewerSettingsChanged(0);
176 };
177
178 void OptionsWidget::viewerSettingsChanged(int /*_index*/){
179
180 if ( !updatingViewerSettings_ ){
181 //viewer defaults
182 std::vector< QString > mode;
183
184 for (int i=0; i < availDrawModes->count(); i++)
185 if (availDrawModes->item(i)->checkState() == Qt::Checked)
186 mode.push_back( availDrawModes->item(i)->text() );
187
188 defaultDrawModes_[ viewerList->currentRow() ] = descriptionsToDrawMode(mode);
189 defaultProjectionMode_[ viewerList->currentRow() ] = projectionBox->currentIndex() ;
190 defaultViewingDirections_[ viewerList->currentRow() ] = directionBox->currentIndex();
191 defaultRotationLocks_[ viewerList->currentRow() ] = lockRotationBox->isChecked();
192
193 if ( lockRotationBox->isChecked() )
194 std::cerr << "locked" << std::endl;
195 else
196 std::cerr << "unlocked" << std::endl;
197 }
198 };
199
200 void OptionsWidget::switchStackedWidget() {
201
202 // Show right stacked widget of stereo settings
203 if (stereoCustomAnaglyph->isChecked()) {
204 stackedWidget->setCurrentIndex(0);
205 customAnaGlyphSettings->setVisible(true);
206 } else {
207 stackedWidget->setCurrentIndex(0);
208 customAnaGlyphSettings->setVisible(false);
209 }
210
211 // Preview new settings
212 slotPreviewStereoSettings();
213 }
214
215 void OptionsWidget::slotTranslationIndexChanged(int /*_index*/) {
216 restartRequired_ = true;
217 }
218
219 void OptionsWidget::updateViewerSettings(int _row){
220
221 updatingViewerSettings_ = true;
222
223 for (int i = 0 ; i < availDrawModes->count(); ++i )
224 availDrawModes->item( i )->setCheckState(Qt::Unchecked) ;
225
226 //Check the drawModes from StandardDrawMode
227 std::vector< QString > dm = drawModeToDescriptions( defaultDrawModes_[_row] );
228
229 for (uint i=0; i < dm.size(); i++){
230 if ( !dm.empty() ) {
231 QList< QListWidgetItem* > found = availDrawModes->findItems(dm[i],Qt::MatchExactly);
232 for(int k=0; k < found.count(); k++)
233 (found[k])->setCheckState(Qt::Checked);
234 }
235 }
236
237 if ( defaultProjectionMode_[_row] )
238 projectionBox->setCurrentIndex( 1 );
239 else
240 projectionBox->setCurrentIndex( 0 );
241
242 directionBox->setCurrentIndex( defaultViewingDirections_[_row] );
243
244 lockRotationBox->setChecked( defaultRotationLocks_[_row] );
245
246 updatingViewerSettings_ = false;
247 }
248
249 void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
250
251 //general
252 fullscreen->setChecked( OpenFlipperSettings().value("Core/Gui/fullscreen",false).toBool() );
253 splash->setChecked( OpenFlipperSettings().value("Core/Gui/splash",true).toBool() );
254 toolbox->setChecked( !OpenFlipperSettings().value("Core/Gui/ToolBoxes/hidden",false).toBool() );
255
256 iconSmall->setChecked(false);
257 iconNormal->setChecked(false);
258 iconDefault->setChecked(false);
259
260 switch ( OpenFlipperSettings().value("Core/Toolbar/iconSize",0).toInt() ){
261 case 1 : iconSmall->setChecked(true); break;
262 case 2 : iconNormal->setChecked(true); break;
263 default : iconDefault->setChecked(true); break;
264 }
265
266 loggerHidden->setChecked( OpenFlipper::Options::loggerState() == OpenFlipper::Options::Hidden);
267 loggerNormal->setChecked( OpenFlipper::Options::loggerState() == OpenFlipper::Options::Normal);
268 loggerInScene->setChecked( OpenFlipper::Options::loggerState() == OpenFlipper::Options::InScene);
269 enableLogFile->setChecked( OpenFlipperSettings().value("Core/Log/logFileEnabled",true).toBool() );
270
271 //Files
272 logFile->setText( OpenFlipperSettings().value("Core/Log/logFile").toString() );
273 maxRecentBox->setValue( OpenFlipperSettings().value("Core/File/MaxRecent",15).toInt() );
274 rbReloadShaders->setChecked(OpenFlipperSettings().value("Core/File/ReloadShaders",false).toBool()) ;
275 leShaderOutputDir->setText(OpenFlipperSettings().value("Core/File/ShaderOutputDir","").toString());
276 allTarget->setChecked( OpenFlipperSettings().value("Core/File/AllTarget",false).toBool() );
277
278
279 // UI settings
280 toolBoxOrientation->setCurrentIndex((OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight",true).toBool() ? 0 : 1));
281
282 pickToolbarInScene->setChecked(OpenFlipperSettings().value("Core/Gui/ToolBars/PickToolbarInScene",true).toBool());
283
284 //stereo
285
286 // Grey out OpenGL stereo mode option if not available
287 if(!OpenFlipper::Options::glStereo()) {
288 stereoOpengl->setDisabled(true);
289 } else {
290 stereoOpengl->setChecked(OpenFlipper::Options::stereoMode() == OpenFlipper::Options::OpenGL);
291 }
292
293 stereoAnaglyph->setChecked (OpenFlipper::Options::stereoMode() == OpenFlipper::Options::AnaglyphRedCyan);
294 stereoCustomAnaglyph->setChecked (OpenFlipper::Options::stereoMode() == OpenFlipper::Options::AnaglyphCustom);
295
296 eyeDistance->setValue ( OpenFlipperSettings().value("Core/Stereo/EyeDistance").toDouble() );
297 focalDistance->setValue ( OpenFlipperSettings().value("Core/Stereo/FocalDistance").toDouble() * 1000);
298
299 // Show right stacked widget
300 customAnaGlyphSettings->setVisible(false);
301
302 stackedWidget->setCurrentIndex(0);
303
304 if (stereoCustomAnaglyph->isChecked())
305 customAnaGlyphSettings->setVisible(true);
306
307 std::vector<float> mat = OpenFlipper::Options::anaglyphLeftEyeColorMatrix ();
308 lcm0->setValue (mat[0]);
309 lcm1->setValue (mat[1]);
310 lcm2->setValue (mat[2]);
311 lcm3->setValue (mat[3]);
312 lcm4->setValue (mat[4]);
313 lcm5->setValue (mat[5]);
314 lcm6->setValue (mat[6]);
315 lcm7->setValue (mat[7]);
316 lcm8->setValue (mat[8]);
317
318 mat = OpenFlipper::Options::anaglyphRightEyeColorMatrix ();
319 rcm0->setValue (mat[0]);
320 rcm1->setValue (mat[1]);
321 rcm2->setValue (mat[2]);
322 rcm3->setValue (mat[3]);
323 rcm4->setValue (mat[4]);
324 rcm5->setValue (mat[5]);
325 rcm6->setValue (mat[6]);
326 rcm7->setValue (mat[7]);
327 rcm8->setValue (mat[8]);
328
329 noMousePick->setChecked ( !OpenFlipperSettings().value("Core/Gui/glViewer/stereoMousePick",true).toBool() );
330 nativeMouse->setChecked ( OpenFlipperSettings().value("Core/Gui/glViewer/nativeMouse",false).toBool() );
331
332 // plugin options
333 initPluginOptions();
334
335 // updates
336 updateUser->setText( OpenFlipperSettings().value("Core/Update/UserName","anonymous").toString() );
337 updatePass->setText( OpenFlipperSettings().value("Core/Update/Pass","anonymous").toString() );
338 updateURL->setText( OpenFlipperSettings().value("Core/Update/URL","http://").toString() );
339
340 // debugging
341 slotDebugging->setChecked(OpenFlipper::Options::doSlotDebugging());
342
343 //keyBindings
344 initKeyTree();
345
346 keyTree->disconnect(); //to be sure..disconnect every slot
347
348 connect(keyTree, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
349 this, SLOT(keyTreeItemChanged( QTreeWidgetItem*, QTreeWidgetItem*)) );
350
351 connect(keyTree, SIGNAL(itemDoubleClicked (QTreeWidgetItem*, int)),
352 this, SLOT(keyTreeDoubleClicked( QTreeWidgetItem*, int)) );
353
354
355 connect(shortcutButton, SIGNAL(keyChanged()), this, SLOT(updateShortcut()) );
356 connect(presetsButton, SIGNAL(clicked()), this, SLOT(restoreKeyPresets()) );
357
358
359 //Init Viewer Settings
360 wZoomFactor->setValue( OpenFlipperSettings().value("Core/Mouse/Wheel/ZoomFactor").toDouble() );
361 wZoomFactorShift->setValue( OpenFlipperSettings().value("Core/Mouse/Wheel/ZoomFactorShift").toDouble() );
362 invertMouseWheelBox->setChecked( OpenFlipperSettings().value("Core/Mouse/Wheel/Invert").toBool() );
363
364 wheelBox->setChecked( OpenFlipperSettings().value("Core/Gui/glViewer/showControlWheels").toBool() );
365
366 // Projection settings
367 fieldOfView->setValue(OpenFlipperSettings().value("Core/Projection/FOVY", 45.0).toDouble() );
368
369 restrictFPS->setChecked( OpenFlipperSettings().value("Core/Gui/glViewer/restrictFrameRate",false).toBool() );
370 FPS->setValue( OpenFlipperSettings().value("Core/Gui/glViewer/maxFrameRate",35).toInt() );
371
372 minimalSceneSize->setValue( OpenFlipperSettings().value("Core/Gui/glViewer/minimalSceneSize",0.1).toDouble());
373
374 QPixmap color(16,16);
375 color.fill( OpenFlipperSettings().value("Core/Gui/glViewer/defaultBackgroundColor").value<QColor>() );
376 backgroundColor_ = OpenFlipperSettings().value("Core/Gui/glViewer/defaultBackgroundColor").value<QColor>();
377 backgroundButton->setIcon( QIcon(color) );
378
379 color.fill( OpenFlipper::Options::defaultColor() );
380 defaultColorButton->setIcon( QIcon(color) );
381
382 randomDefaultColor->setChecked( OpenFlipper::Options::randomDefaultColor() );
383
384 viewerList->setCurrentRow(0);
385
386 for ( int i=0; i < PluginFunctions::viewers(); i++ ){
387 defaultDrawModes_[i] = OpenFlipper::Options::defaultDrawMode(i);
388 defaultProjectionMode_[i] = OpenFlipper::Options::defaultPerspectiveProjectionMode(i);
389 defaultViewingDirections_[i] = OpenFlipper::Options::defaultViewingDirection(i);
390 defaultRotationLocks_[i] = OpenFlipper::Options::defaultLockRotation(i);
391 }
392
393 updateViewerSettings(0);
394
395 viewerLayout->setCurrentIndex( OpenFlipper::Options::defaultViewerLayout() );
396
397 if (OpenFlipperSettings().value("Core/Language/Translation","en_US").toString() == "en_US")
398 translation->setCurrentIndex(0);
399 else if (OpenFlipperSettings().value("Core/Language/Translation","en_US").toString() == "de_DE")
400 translation->setCurrentIndex(1);
401 else
402 translation->setCurrentIndex(2);
403
404 // Listen to changes...
405 connect(translation, SIGNAL(currentIndexChanged(int)), this, SLOT(slotTranslationIndexChanged(int)));
406
407 updateVersionsTable();
408
409 }
410
411 void OptionsWidget::updateVersionsTable() {
412
413 updatedPlugins_.clear();
414
415 QString fileName = QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() +
416 ".OpenFlipper" + OpenFlipper::Options::dirSeparator() + "Versions.ini" ;
417
418 INIFile ini;
419
420 ini.connect(fileName,false);
421
422 QString systemString = "";
423
424 if ( OpenFlipper::Options::isWindows() ) {
425 systemString = "VersionWindows";
426 } else if (OpenFlipper::Options::isLinux()) {
427 systemString = "VersionLinux";
428 } else {
429 std::cerr << "Unsupported platform for update" << std::endl;
430 return;
431 }
432
433 updateList->clear();
434 updateList->setRowCount( int(1 + plugins_.size()) );
435 updateList->setColumnCount(3);
436
437 QStringList header;
438
439 header << "Component" << "current Version" << "latest Version" ;
440 updateList->setHorizontalHeaderLabels(header);
441
442 QBrush currentBrush(Qt::white);
443
444 QTableWidgetItem * newItem = 0;
445
446 QString coreVersion;
447
448 if ( ini.is_connected() && ini.get_entry(coreVersion, "Core" , systemString ) ) {
449
450 // Newer Version available
451 if ( isNewer(OpenFlipper::Options::coreVersion(),coreVersion) ) {
452 currentBrush.setColor(Qt::red);
453 updatedPlugins_ << "Core";
454 } else if ( isNewer(coreVersion , OpenFlipper::Options::coreVersion()) )
455 currentBrush.setColor(Qt::blue);
456 else
457 currentBrush.setColor(Qt::green);
458
459 newItem = new QTableWidgetItem( coreVersion );
460
461 } else {
462
463 // No local Information available
464 currentBrush.setColor(Qt::yellow);
465
466 newItem = new QTableWidgetItem( "Not Available" );
467 }
468
469 newItem->setBackground(currentBrush);
470 updateList->setItem(0, 2, newItem);
471
472 newItem = new QTableWidgetItem( OpenFlipper::Options::coreVersion() );
473 newItem->setBackground(currentBrush);
474 updateList->setItem(0, 1, newItem);
475
476 newItem = new QTableWidgetItem( "Core" );
477 newItem->setBackground(currentBrush);
478 updateList->setItem(0, 0, newItem);
479
480
481 for ( uint i = 0 ; i < plugins_.size(); ++i ) {
482 QString latestVersion;
483
484 if ( ini.is_connected() && ini.get_entry(latestVersion, plugins_[i].name , systemString ) ) {
485
486
487 // Newer Version available
488 if ( isNewer(plugins_[i].version,latestVersion) ) {
489 currentBrush.setColor(Qt::red);
490 QFileInfo pluginFile(plugins_[i].path );
491 updatedPlugins_ << pluginFile.fileName();
492 } else if ( isNewer(latestVersion,plugins_[i].version) )
493 currentBrush.setColor(Qt::blue);
494 else
495 currentBrush.setColor(Qt::green);
496
497 newItem = new QTableWidgetItem( latestVersion );
498
499 } else {
500
501 // No local Information available
502 currentBrush.setColor(Qt::yellow);
503
504 newItem = new QTableWidgetItem( "Not Available" );
505 }
506
507 newItem->setBackground(currentBrush);
508 updateList->setItem( i + 1 , 2, newItem);
509
510 newItem = new QTableWidgetItem( plugins_[i].version );
511 newItem->setBackground(currentBrush);
512 updateList->setItem( i + 1 , 1, newItem);
513
514 newItem = new QTableWidgetItem( plugins_[i].name );
515 newItem->setBackground(currentBrush);
516 updateList->setItem( i + 1 , 0, newItem);
517 }
518
519 updateList->resizeColumnsToContents();
520
521 updateButton->setEnabled(!updatedPlugins_.empty());
522
523 }
524
525 void OptionsWidget::initPluginOptions(){
526
527 pluginList->disconnect();
528
529 connect(pluginList, SIGNAL( currentTextChanged(const QString&) ), this, SLOT( slotShowPluginOptions(const QString&) ) );
530
531 //init list of plugins
532 pluginList->clear();
533
534 for ( uint i = 0 ; i < plugins_.size(); ++i )
535 if (plugins_[i].optionsWidget != 0){
536
537 pluginList->addItem( plugins_[i].name );
538 }
539
540 if ( pluginList->count() > 0)
541 pluginList->setCurrentRow(0);
542 }
543
544 void OptionsWidget::slotShowPluginOptions(const QString& _pluginName ){
545
546 //remove old children
547 for (int i = 0; i < pluginOptionsLayout->count(); ++i){
548 QWidget* w = pluginOptionsLayout->itemAt(i)->widget();
549
550 if (w != 0)
551 w->setParent(0);
552
553 pluginOptionsLayout->removeItem( pluginOptionsLayout->itemAt(i) );
554 }
555
556 //find the new optionsWidget
557 for ( uint i = 0 ; i < plugins_.size(); ++i )
558 if (plugins_[i].optionsWidget != 0 && plugins_[i].name == _pluginName){
559
560 pluginOptionsLayout->addWidget( plugins_[i].optionsWidget );
561 pluginOptionsLayout->addStretch();
562 return;
563 }
564 }
565
566 void OptionsWidget::slotApply() {
567
568 //general
569 OpenFlipperSettings().setValue("Core/Gui/fullscreen",fullscreen->isChecked());
570 OpenFlipperSettings().setValue("Core/Gui/splash",splash->isChecked());
571 OpenFlipperSettings().setValue("Core/Gui/ToolBoxes/hidden",!toolbox->isChecked());
572
573 if (loggerHidden->isChecked())
574 OpenFlipper::Options::loggerState( OpenFlipper::Options::Hidden );
575 else if (loggerInScene->isChecked())
576 OpenFlipper::Options::loggerState( OpenFlipper::Options::InScene );
577 else
578 OpenFlipper::Options::loggerState( OpenFlipper::Options::Normal );
579
580 OpenFlipperSettings().setValue("Core/Log/logFileEnabled",enableLogFile->isChecked());
581 OpenFlipperSettings().setValue("Core/Log/logFile",logFile->text());
582
583 OpenFlipperSettings().setValue("Core/File/MaxRecent",maxRecentBox->value() ) ;
584 OpenFlipperSettings().setValue("Core/File/ReloadShaders",rbReloadShaders->isChecked() ) ;
585 ACG::ShaderCache::getInstance()->setTimeCheck(rbReloadShaders->isChecked());
586 OpenFlipperSettings().setValue("Core/File/ShaderOutputDir",leShaderOutputDir->text() ) ;
587 ACG::ShaderCache::getInstance()->setDebugOutputDir(leShaderOutputDir->text().toUtf8());
588
589 OpenFlipperSettings().setValue("Core/File/AllTarget",allTarget->isChecked());
590
591
592 // Toolbox orientation
593 OpenFlipperSettings().setValue("Core/Gui/ToolBoxes/ToolBoxOnTheRight", (toolBoxOrientation->currentIndex() == 0));
594
595 // Render picking toolbar into scene
596 if ( OpenFlipperSettings().value("Core/Gui/ToolBars/PickToolbarInScene",true).toBool() != pickToolbarInScene->isChecked() ) {
597 OpenFlipperSettings().setValue("Core/Gui/ToolBars/PickToolbarInScene", pickToolbarInScene->isChecked());
598 restartRequired_ = true;
599 }
600
601 if ( iconDefault->isChecked() )
602 OpenFlipperSettings().setValue("Core/Toolbar/iconSize", 0);
603 else if ( iconSmall->isChecked() )
604 OpenFlipperSettings().setValue("Core/Toolbar/iconSize", 1);
605 else if ( iconNormal->isChecked() )
606 OpenFlipperSettings().setValue("Core/Toolbar/iconSize", 2);
607
608 //viewer
609 OpenFlipperSettings().setValue("Core/Mouse/Wheel/ZoomFactor", wZoomFactor->value());
610 OpenFlipperSettings().setValue("Core/Mouse/Wheel/ZoomFactorShift", wZoomFactorShift->value());
611 OpenFlipperSettings().setValue("Core/Mouse/Wheel/Invert", invertMouseWheelBox->isChecked());
612
613 // Projection settings
614 OpenFlipperSettings().setValue("Core/Projection/FOVY", fieldOfView->value());
615 OpenFlipperSettings().setValue("Core/Gui/glViewer/minimalSceneSize",minimalSceneSize->value());
616
617 OpenFlipperSettings().setValue("Core/Gui/glViewer/showControlWheels", wheelBox->isChecked() );
618
619 OpenFlipperSettings().setValue("Core/Gui/glViewer/restrictFrameRate", restrictFPS->isChecked());
620 OpenFlipperSettings().setValue("Core/Gui/glViewer/maxFrameRate", FPS->value() );
621
622 OpenFlipper::Options::randomDefaultColor( randomDefaultColor->isChecked() );
623
624 //stereo
625 if (stereoCustomAnaglyph->isChecked ())
626 OpenFlipper::Options::stereoMode(OpenFlipper::Options::AnaglyphCustom);
627 else if (stereoAnaglyph->isChecked ())
628 OpenFlipper::Options::stereoMode(OpenFlipper::Options::AnaglyphRedCyan);
629 else
630 OpenFlipper::Options::stereoMode(OpenFlipper::Options::OpenGL);
631
632 OpenFlipperSettings().setValue("Core/Stereo/EyeDistance",eyeDistance->value ());
633 OpenFlipperSettings().setValue("Core/Stereo/FocalDistance",double(focalDistance->value() / 1000.0));
634
635 std::vector<float> mat (9, 0);
636 mat[0] = lcm0->value ();
637 mat[1] = lcm1->value ();
638 mat[2] = lcm2->value ();
639 mat[3] = lcm3->value ();
640 mat[4] = lcm4->value ();
641 mat[5] = lcm5->value ();
642 mat[6] = lcm6->value ();
643 mat[7] = lcm7->value ();
644 mat[8] = lcm8->value ();
645
646 OpenFlipper::Options::anaglyphLeftEyeColorMatrix (mat);
647
648 mat[0] = rcm0->value ();
649 mat[1] = rcm1->value ();
650 mat[2] = rcm2->value ();
651 mat[3] = rcm3->value ();
652 mat[4] = rcm4->value ();
653 mat[5] = rcm5->value ();
654 mat[6] = rcm6->value ();
655 mat[7] = rcm7->value ();
656 mat[8] = rcm8->value ();
657
658 OpenFlipper::Options::anaglyphRightEyeColorMatrix (mat);
659
660 OpenFlipperSettings().setValue("Core/Gui/glViewer/stereoMousePick",!noMousePick->isChecked ());
661 OpenFlipperSettings().setValue("Core/Gui/glViewer/nativeMouse",nativeMouse->isChecked ());
662
663 // updates
664 OpenFlipperSettings().setValue("Core/Update/UserName", updateUser->text());
665 OpenFlipperSettings().setValue("Core/Update/Pass",updatePass->text());
666 OpenFlipperSettings().setValue("Core/Update/URL",updateURL->text());
667
668 // Debugging
669 OpenFlipper::Options::doSlotDebugging(slotDebugging->isChecked());
670
671 //viewer defaults
672 for (int i=0; i < PluginFunctions::viewers(); i++){
673 OpenFlipper::Options::defaultDrawMode( defaultDrawModes_[i], i );
674 OpenFlipper::Options::defaultPerspectiveProjectionMode( defaultProjectionMode_[i], i );
675 OpenFlipper::Options::defaultViewingDirection( defaultViewingDirections_[i], i );
676 OpenFlipper::Options::defaultLockRotation( defaultRotationLocks_[i], i );
677 }
678
679 OpenFlipper::Options::defaultViewerLayout( viewerLayout->currentIndex() );
680
681 // Restrict fps if desired
682 if(restrictFPS->isChecked()) {
683 OpenFlipperSettings().setValue("Core/Gui/glViewer/restrictFrameRate", true);
684 OpenFlipperSettings().setValue("Core/Gui/glViewer/maxFrameRate",FPS->value());
685 } else {
686 OpenFlipperSettings().setValue("Core/Gui/glViewer/restrictFrameRate", false);
687 }
688
689 // Set background color
690 OpenFlipperSettings().setValue("Core/Gui/glViewer/defaultBackgroundColor", backgroundColor_);
691
692 for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i )
693 PluginFunctions::viewerProperties(i).backgroundColor(ACG::Vec4f(((double) backgroundColor_.redF()),
694 ((double) backgroundColor_.greenF()),
695 ((double) backgroundColor_.blueF()),
696 1.0));
697
698 switch ( translation->currentIndex() ){
699 case 0 : OpenFlipperSettings().setValue("Core/Language/Translation","en_US"); break;
700 case 1 : OpenFlipperSettings().setValue("Core/Language/Translation","de_DE"); break;
701 default: OpenFlipperSettings().setValue("Core/Language/Translation","locale"); break;
702 }
703
704 // Show warning message that restart is required if language or in scene toolbar has been changed...
705 if(restartRequired_) {
706 int restart = QMessageBox::information(this, tr("Restart required!"),
707 tr("The changes will take effect after next restart. Do you want to close OpenFlipper now?"),
708 QMessageBox::Yes | QMessageBox::No);
709
710 if(restart == QMessageBox::Yes) exitOnClose_ = true;
711 }
712
713 applyShortcuts();
714
715 emit applyOptions();
716 emit saveOptions();
717
718 // Make sure all settings are written before we quit!
719 OpenFlipperSettings().sync();
720
721 // Close OpenFlipper if demanded
722 if(exitOnClose_) QCoreApplication::quit();
723 }
724
725 void OptionsWidget::slotOk(){
726 slotApply();
727 hide();
728 }
729
730 void OptionsWidget::slotCancel() {
731 hide();
732 }
733
734 void OptionsWidget::slotCheckUpdates() {
735
736 // http://www.graphics.rwth-aachen.de/restricted/OpenFlipper-SIL/
737
738 downloadType = VERSIONS_FILE;
739 QString ServerMainURL = updateURL->text();
740 if ( !ServerMainURL.endsWith("/") )
741 ServerMainURL += "/";
742
743 ServerMainURL += "Versions.ini";
744
745 startDownload(ServerMainURL);
746 }
747
748 void OptionsWidget::slotGetUpdates() {
749 std::cerr << "Not implemented yet: Get updates" << std::endl;
750 QString url = updateURL->text();
751
752 if ( !url.endsWith("/") )
753 url += "/";
754
755
756 pluginPath_.clear();
757 pluginPath_ = "Plugins/";
758
759 if ( OpenFlipper::Options::isWindows() ) {
760 pluginPath_ += "Windows/";
761 } else if ( OpenFlipper::Options::isLinux() ) {
762 pluginPath_ += "Linux/";
763 } else {
764 std::cerr << "Unknown operating system type, aborting update" << std::endl;
765 return;
766 }
767
768 if ( OpenFlipper::Options::is64bit() ) {
769 pluginPath_ += "64/";
770 } else if ( OpenFlipper::Options::is32bit() ) {
771 pluginPath_ += "32/";
772 } else {
773 std::cerr << "Unknown architecture type, aborting update" << std::endl;
774 return;
775 }
776
777 pluginPath_ += "Release/";
778
779 if ( !updatedPlugins_.empty() && updatedPlugins_[0] == "Core" ) {
780 std::cerr << "Core update not supported!" << std::endl;
781 return;
782 }
783
784 if ( !updatedPlugins_.empty() ) {
785 currentUpdateName_ = updatedPlugins_[0];
786 std::cerr << "Downloading " << (url + pluginPath_ + currentUpdateName_).toStdString() << std::endl;
787 updatedPlugins_.pop_front();
788
789 downloadType = PLUGIN;
790
791 startDownload(url + pluginPath_ + currentUpdateName_);
792 }
793
794 }
795
796 void OptionsWidget::updateComponent() {
797 std::cerr << "Todo : Update component" << std::endl;
798
799
800
801 QString sourceName = QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() +
802 ".OpenFlipper" + OpenFlipper::Options::dirSeparator() + currentUpdateName_ ;
803
804 QString targetName = OpenFlipper::Options::applicationDirStr() + "/" + pluginPath_ + currentUpdateName_;
805
806 QFileInfo sourceFileInfo(sourceName);
807 QFileInfo targetFileInfo(targetName);
808
809 std::cerr << sourceName.toStdString() << std::endl;
810 std::cerr << targetName.toStdString() << std::endl;
811
812 if ( ! sourceFileInfo.exists() ) {
813 statusLabel->setText(tr("Download failed!"));
814 slotGetUpdates();
815 return;
816 } else {
817 if ( ! targetFileInfo.exists() ) {
818 statusLabel->setText(tr("plugin target does not exist"));
819 slotGetUpdates();
820 return;
821 }
822
823 statusLabel->setText(tr("Installing new file"));
824
825 // Remove the old plugin
826 QFile targetFile(targetName);
827 targetFile.remove();
828
829 // copy new to old
830 QFile::copy(sourceName,targetName);
831
832 // remove downloaded file
833 QFile sourceFile(sourceName);
834 sourceFile.remove();
835
836 statusLabel->setText(tr("updated ") + currentUpdateName_);
837 }
838
839 slotGetUpdates();
840 }
841
842 bool OptionsWidget::isNewer(QString _current, QString _latest) {
843
844 QStringList latestVersionParts = _latest.split('.');
845 QStringList currentVersionParts = _current.split('.');
846
847 bool newer = false;
848
849 for ( int i = 0 ; i < latestVersionParts.size(); ++i ) {
850
851 if ( i+1 > currentVersionParts.size() ) {
852 // Versions are identical up to now. But latest version has additional version => updated
853 newer = true;
854 break;
855 }
856
857 bool ok = false;
858 double latest = latestVersionParts[i].toInt(&ok);
859 double current = currentVersionParts[i].toInt(&ok);
860
861 if ( !ok )
862 std::cerr << "Error when parsing version strings!" << std::endl;
863
864 if ( latest > current ) {
865 newer = true;
866 break;
867 }
868 }
869
870 return newer;
871
872 }
873
874 void OptionsWidget::compareVersions() {
875
876 QString fileName = QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() +
877 ".OpenFlipper" + OpenFlipper::Options::dirSeparator() + "Versions.ini" ;
878
879 INIFile ini;
880 if ( ! ini.connect(fileName,false) ) {
881 std::cerr << "Failed to connect to Versions ini file" << std::endl;
882 return;
883 }
884
885 statusLabel->setText(tr("Checking for new versions"));
886
887 bool newerVersionsAvailable = false;
888
889 QString systemString = "";
890 if ( OpenFlipper::Options::isWindows() ) {
891 systemString = "VersionWindows";
892 } else if (OpenFlipper::Options::isLinux()) {
893 systemString = "VersionLinux";
894 } else {
895 std::cerr << "Unsupported platform for update" << std::endl;
896 return;
897 }
898
899 QString coreVersion;
900
901 if ( ini.get_entry(coreVersion, "Core" , systemString )) {
902 if ( isNewer( OpenFlipper::Options::coreVersion(), coreVersion ) ) {
903 newerVersionsAvailable = true;
904 }
905 }
906
907 for ( uint i = 0 ; i < plugins_.size(); ++i ) {
908 QString latestVersion;
909 if ( ini.get_entry(latestVersion, plugins_[i].name , systemString )) {
910 if ( isNewer( plugins_[i].version, latestVersion ) )
911 newerVersionsAvailable = true;
912 }
913 }
914
915 if ( newerVersionsAvailable ) {
916 statusLabel->setText(tr("Updates found"));
917 } else {
918 statusLabel->setText(tr("No updates found"));
919 }
920
921 ini.disconnect();
922
923 updateVersionsTable();
924 }
925
926 void OptionsWidget::slotPreviewStereoSettings(int /*_tmpParam*/) {
927
928 if (stereoCustomAnaglyph->isChecked ())
929 OpenFlipper::Options::stereoMode(OpenFlipper::Options::AnaglyphCustom);
930 else if (stereoAnaglyph->isChecked ())
931 OpenFlipper::Options::stereoMode(OpenFlipper::Options::AnaglyphRedCyan);
932 else
933 OpenFlipper::Options::stereoMode(OpenFlipper::Options::OpenGL);
934
935 OpenFlipperSettings().setValue("Core/Stereo/EyeDistance", eyeDistance->value());
936 OpenFlipperSettings().setValue("Core/Stereo/FocalDistance", double(focalDistance->value() / 1000.0));
937
938
939 // Update all views
940 emit applyOptions();
941 }
942
943 void OptionsWidget::slotClearSettings() {
944
945 OpenFlipperSettings().clear();
946 }
947
948 void OptionsWidget::slotClearINI() {
949
950 QMessageBox::information(this, tr("Restart required!"),
951 tr("The changes will take effect after next restart."));
952
953 OpenFlipper::Options::deleteIniFile(true);
954 }
955
956 void OptionsWidget::slotReloadShaders()
957 {
958 ACG::ShaderCache::getInstance()->clearCache();
959 }
OpenFlipperSettings
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
Definition: GlobalOptions.cc:938
OptionsWidget::updatedPlugins_
QStringList updatedPlugins_
Definition: optionsWidget.hh:240
OptionsWidget::slotGetUpdates
void slotGetUpdates()
Download updates.
Definition: optionsWidget.cc:748
PluginFunctions::viewerProperties
Viewer::ViewerProperties & viewerProperties(int _id)
Get the viewer properties Use this functions to get basic viewer properties such as backgroundcolor o...
Definition: PluginFunctions.cc:613
OptionsWidget::restartRequired_
bool restartRequired_
Definition: optionsWidget.hh:252
ACG::SceneGraph::DrawModes::DEFAULT
DrawMode DEFAULT
use the default (global) draw mode and not the node's own.
Definition: DrawModes.cc:78
INIFile::disconnect
void disconnect()
Remove connection of this object to a file.
Definition: INIFile.cc:128
OptionsWidget::slotClearINI
void slotClearINI()
Clear OpenFlipper INI.
Definition: optionsWidget.cc:948
OptionsWidget::slotReloadShaders
void slotReloadShaders()
Clear the Shader Cache.
Definition: optionsWidget.cc:956
OptionsWidget::startDownload
void startDownload(QString _url)
Starts the download of the given file.
Definition: downloader.cc:57
OptionsWidget::keyTreeItemChanged
void keyTreeItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
keyBinding TreeWidget-Item changed
Definition: keyBindings.cc:75
OptionsWidget::restoreKeyPresets
void restoreKeyPresets()
restore keyBinding Presets
Definition: keyBindings.cc:164
OptionsWidget::pluginPath_
QString pluginPath_
Definition: optionsWidget.hh:244
INIFile::connect
bool connect(const QString &name, const bool create)
Connect INIFile object with given filename.
Definition: INIFile.cc:76
OptionsWidget::isNewer
bool isNewer(QString _current, QString _latest)
Compares two version strings and returns if a newer Version is available.
Definition: optionsWidget.cc:842
OptionsWidget::slotOk
void slotOk()
call slotApply and hide widget
Definition: optionsWidget.cc:725
OptionsWidget::currentUpdateName_
QString currentUpdateName_
Definition: optionsWidget.hh:248
INIFile::get_entry
bool get_entry(QString &_val, const QString &_section, const QString &_key) const
Access to a string entry.
Definition: INIFile.cc:439
OptionsWidget::slotApply
void slotApply()
Update Options and tell others about changed Options.
Definition: optionsWidget.cc:566
OptionsWidget::slotPreviewStereoSettings
void slotPreviewStereoSettings(int _tmpParam=0)
Definition: optionsWidget.cc:926
OptionsWidget::slotCheckUpdates
void slotCheckUpdates()
Checks for updates.
Definition: optionsWidget.cc:734
INIFile::is_connected
bool is_connected() const
Check if object is connected to file.
Definition: INIFile.hh:123
INIFile
Class for the handling of simple configuration files.
Definition: INIFile.hh:105
OptionsWidget::getBackgroundColor
void getBackgroundColor()
open a dialog to determine the color
Definition: optionsWidget.cc:154
OptionsWidget::slotClearSettings
void slotClearSettings()
Clear all OpenFlipper settings.
Definition: optionsWidget.cc:943
OpenMesh::VectorT
Definition: Vector11T.hh:83
PluginFunctions::viewers
int viewers()
Get the number of viewers.
Definition: PluginFunctions.cc:155
ACG::ShaderCache::getInstance
static ShaderCache * getInstance()
Return instance of the ShaderCache singleton.
Definition: ShaderCache.cc:90
GlobalOptions.hh
ACG::ShaderCache::clearCache
void clearCache()
Delete all cached shaders.
Definition: ShaderCache.cc:603
OptionsWidget::slotCancel
void slotCancel()
Only hide widget.
Definition: optionsWidget.cc:730
OpenFlipperQSettings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Definition: OpenFlipperQSettings.cc:53
OpenMesh::Attributes::Normal
Add normals to mesh item (vertices/faces)
Definition: Attributes.hh:87
OptionsWidget::updateVersionsTable
void updateVersionsTable()
Redraws the version table.
Definition: optionsWidget.cc:411
PluginFunctions.hh
OpenFlipperQSettings::setValue
void setValue(const QString &key, const QVariant &value)
Wrapper function which makes it possible to enable Debugging output with -DOPENFLIPPER_SETTINGS_DEBUG...
Definition: OpenFlipperQSettings.cc:68
OptionsWidget::updateShortcut
void updateShortcut()
check if the shortcut exists and add it if not
Definition: keyBindings.cc:91
OptionsWidget::authentication
void authentication(QNetworkReply *_reply, QAuthenticator *_authenticator)
authentication
Definition: downloader.cc:109
OptionsWidget::initKeyTree
void initKeyTree()
init the TreeWidget containing the keyBindings
Definition: keyBindings.cc:201
ACG::ShaderCache::setDebugOutputDir
void setDebugOutputDir(const char *_outputDir)
Enable debug output of generated shaders to specified directory.
Definition: ShaderCache.cc:610
OptionsWidget::keyTreeDoubleClicked
void keyTreeDoubleClicked(QTreeWidgetItem *_item, int col)
doubleclick in the keyTree
Definition: keyBindings.cc:64
OptionsWidget::compareVersions
void compareVersions()
Compares the versions from the downloaded Versions file with the current versions.
Definition: optionsWidget.cc:874
OptionsWidget::viewerSettingsChanged
void viewerSettingsChanged(QListWidgetItem *_item)
remember user changes to viewer properties
Definition: optionsWidget.cc:174
OptionsWidget::switchStackedWidget
void switchStackedWidget()
Switch between the stacked widgets of the stereo settings.
Definition: optionsWidget.cc:200
ACG::ShaderCache::setTimeCheck
void setTimeCheck(bool _on)
enable or disable checking of the time step of each file
Definition: ShaderCache.hh:177
OptionsWidget::applyShortcuts
void applyShortcuts()
check which of the shortcuts changed and inform the core about the change
Definition: keyBindings.cc:128
Viewer::ViewerProperties::backgroundColor
ACG::Vec4f backgroundColor()
Get current background color.
Definition: ViewerProperties.cc:226
OptionsWidget::updateViewerSettings
void updateViewerSettings(int _row)
update the dialog if the selected viewer changes
Definition: optionsWidget.cc:219