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
FileOfv.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 #include <OpenFlipper/BasePlugin/PluginFunctions.hh>
51 #include <OpenFlipper/common/GlobalOptions.hh>
52
53 #include <OpenMesh/Core/IO/IOManager.hh>
54
55 #if QT_VERSION >= 0x050000
56 #include <QtWidgets>
57 #else
58 #include <QtGui>
59 #endif
60
61 #include "FileOfv.hh"
62
63
64 void FileViewPlugin::initializePlugin() {
65 }
66
67 QString FileViewPlugin::getLoadFilters() {
68 return QString( tr("View definition files ( *.ofv )") );
69 }
70
71 QString FileViewPlugin::getSaveFilters() {
72 return QString( tr("View definition files ( *.ofv )") );
73 }
74
75 DataType FileViewPlugin::supportedType() {
76 return DataType();
77 }
78
79 int FileViewPlugin::loadObject(QString _filename) {
80
81 // Declare variables
82 ACG::Vec3d eye(1.0,1.0,1.0);
83 ACG::Vec3d center(0.0,0.0,0.0);
84 ACG::Vec3d up(1.0,0.0,0.0);
85 ACG::Vec4f background;
86
87 bool e_eye = false;
88 bool e_center = false;
89 bool e_up = false;
90 bool e_background = false;
91
92 QSettings settings(_filename, QSettings::IniFormat);
93 settings.beginGroup("VIEW");
94
95 if(settings.contains("Width") && settings.contains("Height")) {
96 const int width = settings.value("Width").toInt();
97 const int height = settings.value("Height").toInt();
98 std::cerr << "Setting new viewport to " << width << "x" << height << std::endl;
99 }
100
101 if(settings.contains("EyeX")) {
102 eye[0] = settings.value("EyeX").toDouble();
103 eye[1] = settings.value("EyeY").toDouble();
104 eye[2] = settings.value("EyeZ").toDouble();
105 std::cerr << "Setting new eye position to " << eye << std::endl;
106 e_eye = true;
107 }
108
109 if(settings.contains("CenterX")) {
110 center[0] = settings.value("CenterX").toDouble();
111 center[1] = settings.value("CenterY").toDouble();
112 center[2] = settings.value("CenterZ").toDouble();
113 std::cerr << "Setting new scene center to " << center << std::endl;
114 e_center = true;
115 }
116
117 if(settings.contains("UpX")) {
118 up[0] = settings.value("UpX").toDouble();
119 up[1] = settings.value("UpY").toDouble();
120 up[2] = settings.value("UpZ").toDouble();
121 std::cerr << "Setting new up vector to " << up << std::endl;
122 e_up = true;
123 }
124
125
126 if(settings.contains("BackgroundR")) {
127 background[0] = settings.value("BackgroundR").toDouble();
128 background[1] = settings.value("BackgroundG").toDouble();
129 background[2] = settings.value("BackgroundB").toDouble();
130 background[3] = settings.value("BackgroundA").toDouble();
131 std::cerr << "Setting new background color to " << background << std::endl;
132 e_background = true;
133 }
134
135 settings.endGroup();
136
137 // Now set new projection and view
138
139 // LookAt
140 ACG::Vec3d new_eye = e_eye ? eye : PluginFunctions::eyePos();
141 ACG::Vec3d new_center = e_center ? center : PluginFunctions::sceneCenter();
142 ACG::Vec3d new_up = e_up ? up : PluginFunctions::upVector();
143
144 PluginFunctions::lookAt(new_eye, new_center, new_up);
145
146 // Background color
147 if(e_background) {
148 PluginFunctions::setBackColor(background);
149 }
150
151 emit updateView();
152
153 return 0;
154 }
155
156 bool FileViewPlugin::saveObject(int /*_id*/, QString /*_filename*/) {
157
158 return true;
159 }
160
161 #if QT_VERSION < 0x050000
162 Q_EXPORT_PLUGIN2( fileviewplugin , FileViewPlugin );
163 #endif
164
165
PluginFunctions::sceneCenter
const ACG::Vec3d sceneCenter(int _viewer)
Get the current scene center.
Definition: PluginFunctions.cc:782
FileViewPlugin::getSaveFilters
QString getSaveFilters()
Definition: FileOfv.cc:71
FileViewPlugin::supportedType
DataType supportedType()
Return your supported object type( e.g. DATA_TRIANGLE_MESH )
Definition: FileOfv.cc:75
PluginFunctions::setBackColor
void setBackColor(OpenMesh::Vec4f _color)
Set the background color of the examiner widget.
Definition: PluginFunctions.cc:379
PluginFunctions::lookAt
void lookAt(const ACG::Vec3d &_eye, const ACG::Vec3d &_center, const ACG::Vec3d &_up, int _viewer)
Set the look at transformation directly.
Definition: PluginFunctions.cc:703
PluginFunctions::eyePos
ACG::Vec3d eyePos(int _viewer)
Get the current viewer position.
Definition: PluginFunctions.cc:902
OpenMesh::VectorT
Definition: Vector11T.hh:83
FileViewPlugin::initializePlugin
void initializePlugin()
Initialize Plugin.
Definition: FileOfv.cc:64
GlobalOptions.hh
FileViewPlugin
Definition: FileOfv.hh:62
PluginFunctions.hh
DataType
Predefined datatypes.
Definition: DataTypes.hh:96
PluginFunctions::upVector
ACG::Vec3d upVector(int _viewer)
Get the current up vector.
Definition: PluginFunctions.cc:915
FileViewPlugin::getLoadFilters
QString getLoadFilters()
Definition: FileOfv.cc:67