Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PanoramaControlPlugin.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (C) 2001-2014 by Computer Graphics Group, RWTH Aachen *
5 * www.openflipper.org *
6 * *
7 *--------------------------------------------------------------------------- *
8 * This file is part of OpenFlipper. *
9 * *
10 * OpenFlipper is free software: you can redistribute it and/or modify *
11 * it under the terms of the GNU Lesser General Public License as *
12 * published by the Free Software Foundation, either version 3 of *
13 * the License, or (at your option) any later version with the *
14 * following exceptions: *
15 * *
16 * If other files instantiate templates or use macros *
17 * or inline functions from this file, or you compile this file and *
18 * link it with other files to produce an executable, this file does *
19 * not by itself cause the resulting executable to be covered by the *
20 * GNU Lesser General Public License. This exception does not however *
21 * invalidate any other reasons why the executable file might be *
22 * covered by the GNU Lesser General Public License. *
23 * *
24 * OpenFlipper is distributed in the hope that it will be useful, *
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27 * GNU Lesser General Public License for more details. *
28 * *
29 * You should have received a copy of the GNU LesserGeneral Public *
30 * License along with OpenFlipper. If not, *
31 * see <http://www.gnu.org/licenses/>. *
32 * *
33 \*===========================================================================*/
34 
35 /*===========================================================================*\
36 * *
37 * $Revision: 13354 $ *
38 * $LastChangedBy: moebius $ *
39 * $Date: 2012-01-12 13:39:10 +0100 (Do, 12 Jan 2012) $ *
40 * *
41 \*===========================================================================*/
42 
44 
47 
48 #include <QtGui>
49 
50 #include "PanoramaControlPlugin.hh"
51 
52 
53 PanoramaControlPlugin::PanoramaControlPlugin() :
54  tool_(0)
55 {
56 
57 }
58 
59 void PanoramaControlPlugin::initializePlugin(){
60 
61  tool_ = new PanoramaToolBox();
62 
63  connect(tool_->hFOV , SIGNAL( valueChanged(double) ), this, SLOT( slotValuesChanged(double) ) );
64  connect(tool_->vFOV , SIGNAL( valueChanged(double) ), this, SLOT( slotValuesChanged(double) ) );
65  connect(tool_->cutOff, SIGNAL( valueChanged(double) ), this, SLOT( slotValuesChanged(double) ) );
66 
67  connect(tool_->loadButton, SIGNAL( clicked() ), this, SLOT( slotLoadImage() ) );
68 
69  // Add icon and toolbox
70  QIcon* toolIcon_ = new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"PanoControl.png");
71  emit addToolbox( tr("Panorama Control") , tool_, toolIcon_);
72 
73 }
74 
76 
77  SkyDomeObject* domeObject = 0;
78 
80  {
81  domeObject = PluginFunctions::skyDomeObject(*o_it);
82 
83  // We only take the first one
84  if ( domeObject )
85  break;
86  }
87 
88  // No dome object found, so we have to create one
89  if ( !domeObject ) {
90 
91  // Add empty triangle mesh
92  int domeId = -1;
93  emit addEmptyObject ( DATA_SKYDOME, domeId );
94 
95  domeObject = PluginFunctions::skyDomeObject(domeId);
96  }
97 
98  if ( !domeObject ) {
99  emit log(LOGERR,"Unable to get or create new Sky Dome Object");
100  return;
101  }
102 
103  // Ask user to load the file
104  QString file = QFileDialog::getOpenFileName ( 0, "Load Panorama Image", "", "Images (*.png *.xpm *.jpg)", 0, 0 );
105 
106  // Update the texture file name
107  domeObject->getSkyDome().setTextureFileName(file);
108 
109  // Update the object and its buffers
110  emit updatedObject(domeObject->id(), UPDATE_TEXTURE);
111 
112  // Switch to shader pipeline renderer
113  emit setRenderer(PluginFunctions::activeExaminer(),"Shader Pipeline Renderer Plugin");
114 
115 }
116 
118 
120  {
121  SkyDomeObject* domeObject = PluginFunctions::skyDomeObject(*o_it);
122 
123  if ( domeObject ) {
124  domeObject->getSkyDome().setHorizontalFOV( tool_->hFOV->value() );
125  domeObject->getSkyDome().setVerticalFOV(tool_->vFOV->value() );
126  domeObject->getSkyDome().setTopOffset(tool_->cutOff->value() );
127 
128  // Only first object will be handled for now!
129  break;
130  }
131 
132  }
133 
134  // Only update the view, as only uniforms will change here
135  emit updateView();
136 }
137 
138 #if QT_VERSION < 0x050000
139 Q_EXPORT_PLUGIN2( panoramacontrolplugin , PanoramaControlPlugin );
140 #endif
void slotValuesChanged(double _unused)
Spinboxes changed.
int id() const
Definition: BaseObject.cc:201
unsigned int activeExaminer()
Get the id of the examiner which got the last mouse events.
void setTextureFileName(const QString &_textureFileName)
Defines the texture that will be used.
Definition: SkyDomeType.cc:79
SkyDomeObject * skyDomeObject(int _objectId)
Get a SkyDomeObject from id if possible.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
const UpdateType UPDATE_TEXTURE(UpdateTypeSet(1)<< 11)
Textures have changed.
SkyDome & getSkyDome()
Get all Info for the Object as a string.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
void slotLoadImage()
Button slot iterating over all targets and passing them to the correct functions. ...
#define DATA_SKYDOME
Definition: SkyDome.hh:56