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
ViewerProperties.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
53 //=============================================================================
54 //
55 // Property storage Class for glWidgets
56 //
57 //=============================================================================
58
59 #include <ACG/Scenegraph/DrawModes.hh>
60 #include "ViewerProperties.hh"
61
62 namespace Viewer {
63
64 ViewerProperties::ViewerProperties(int _id):
65 currentDrawMode_(ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED),
66 snapshotName_("snap"),
67 snapshotFileType_("png"),
68 snapshotCounter_(0),
69 wZoomFactor_(1.0),
70 wZoomFactorShift_(0.2),
71 wInvert_(false),
72 CCWFront_(true),
73 backgroundColor_(0.0f,0.0f,0.0f,1.0f),
74 locked_(0),
75 backFaceCulling_(false),
76 twoSidedLighting_(false),
77 multisampling_(true),
78 mipmapping_(true),
79 animation_(false),
80 glState_(0),
81 objectMarker_(0),
82 currentViewingDirection_(0),
83 rotationLocked_(false),
84 orthoWidth_(2.0),
85 nearPlane_(0.01),
86 farPlane_(100.0),
87 sceneCenter_(ACG::Vec3d( 0.0, 0.0, 0.0 )),
88 sceneRadius_(1.0),
89 trackballCenter_(ACG::Vec3d( 0.0, 0.0, 0.0 )),
90 trackballRadius_(1.0),
91 stereo_(false),
92 cursorPainter_(0),
93 cursorPoint3D_(ACG::Vec3d(0.0,0.0,0.0)),
94 cursorPositionValid_(false),
95 viewerId_(_id)
96 {
97 settingsSection_ = "Viewer" + QString::number(_id) + "/";
98 }
99
100 ViewerProperties::~ViewerProperties() {
101
102 if ( glState_ != 0 )
103 delete glState_;
104
105 }
106
107 void ViewerProperties::snapshotBaseFileName(const QString& _fname) {
108 snapshotName_ = _fname;
109 snapshotCounter_ = 0;
110 }
111
112 void ViewerProperties::snapshotFileType(const QString& _type) {
113 snapshotFileType_ = _type.trimmed();
114 }
115
116 std::string ViewerProperties::pickMode(){
117
118 std::string mode;
119 emit getPickMode(mode);
120 return mode;
121 }
122
123 void ViewerProperties::pickMode(const std::string& _name){
124 emit setPickMode(_name);
125 }
126
127 Viewer::ActionMode ViewerProperties::actionMode(){
128 Viewer::ActionMode am;
129 emit getActionMode(am);
130 return am;
131 }
132
133 void ViewerProperties::actionMode(const Viewer::ActionMode _am){
134 emit setActionMode(_am);
135 }
136
137 int ViewerProperties::currentViewingDirection(){
138 return currentViewingDirection_;
139 }
140
141 void ViewerProperties::currentViewingDirection(int _dir){
142 currentViewingDirection_ = _dir;
143 }
144
145 bool ViewerProperties::rotationLocked(){
146 return rotationLocked_;
147 }
148
149 void ViewerProperties::rotationLocked(bool _locked){
150 rotationLocked_ = _locked;
151 }
152
153 int ViewerProperties::viewerId() {
154 return viewerId_;
155 }
156
157 void ViewerProperties::viewerId(int _id) {
158 viewerId_ = _id;
159 settingsSection_ = "Viewer" + QString::number(_id) + "/";
160 }
161
162 void ViewerProperties::drawMode(ACG::SceneGraph::DrawModes::DrawMode _mode) {
163 currentDrawMode_ = _mode;
164 emit updated();
165 emit drawModeChanged(viewerId_);
166 }
167
168 ACG::SceneGraph::DrawModes::DrawMode ViewerProperties::drawMode() {
169 return currentDrawMode_;
170 }
171
172 void ViewerProperties::snapshotCounter(const int _counter){
173 snapshotCounter_ = _counter;
174 }
175
176 QString ViewerProperties::snapshotFileType() {
177 return snapshotFileType_;
178 }
179
180 QString ViewerProperties::snapshotName() {
181 return snapshotName_;
182 }
183
184 int ViewerProperties::snapshotCounter() {
185 return snapshotCounter_++;
186 }
187
188 double ViewerProperties::wheelZoomFactor() {
189 return wZoomFactor_;
190 }
191
192 double ViewerProperties::wheelZoomFactorShift() {
193 return wZoomFactorShift_;
194 }
195
196 void ViewerProperties::wheelZoomFactor(double _factor) {
197 wZoomFactor_ = _factor;
198 }
199
200 void ViewerProperties::wheelZoomFactorShift(double _factor) {
201 wZoomFactorShift_ = _factor;
202 }
203
204 bool ViewerProperties::wheelInvert() {
205 return wInvert_;
206 }
207
208 void ViewerProperties::wheelInvert(bool _invert) {
209 wInvert_ = _invert;
210 }
211
212 bool ViewerProperties::isCCWFront(){
213 return CCWFront_;
214 }
215
216 void ViewerProperties::ccwFront() {
217 CCWFront_ = true;
218 emit updated();
219 }
220
221 void ViewerProperties::cwFront() {
222 CCWFront_ = false;
223 emit updated();
224 }
225
226 ACG::Vec4f ViewerProperties::backgroundColor() {
227 return backgroundColor_;
228 }
229
230 QRgb ViewerProperties::backgroundColorRgb(){
231 QColor c;
232 c.setRedF( backgroundColor_[0]);
233 c.setGreenF(backgroundColor_[1]);
234 c.setBlueF( backgroundColor_[2]);
235 c.setAlphaF(backgroundColor_[3]);
236 return c.rgba();
237 }
238
239 QColor ViewerProperties::backgroundQColor(){
240 QColor c;
241 c.setRedF( backgroundColor_[0]);
242 c.setGreenF(backgroundColor_[1]);
243 c.setBlueF( backgroundColor_[2]);
244 c.setAlphaF(backgroundColor_[3]);
245 return c;
246 }
247
248 void ViewerProperties::backgroundColor( ACG::Vec4f _color ) {
249 backgroundColor_ = _color; emit updated();
250 };
251
252 void ViewerProperties::backgroundColor( QRgb _color ) {
253 QColor c(_color);
254 backgroundColor_[0] = c.redF();
255 backgroundColor_[1] = c.greenF();
256 backgroundColor_[2] = c.blueF();
257 backgroundColor_[3] = c.alphaF();
258 emit updated();
259 }
260
261 void ViewerProperties::backgroundColor( QColor _color ) {
262 backgroundColor_[0] = _color.redF();
263 backgroundColor_[1] = _color.greenF();
264 backgroundColor_[2] = _color.blueF();
265 backgroundColor_[3] = _color.alphaF();
266 emit updated();
267 }
268
269 void ViewerProperties::lockUpdate() {
270 locked_++;
271 }
272
273 void ViewerProperties::unLockUpdate(){
274 locked_-- ;
275 if ( locked_ <0 ) {
276 std::cerr << "More unlocks then locks" << std::endl;
277 locked_ = 0;
278 }
279 }
280
281 bool ViewerProperties::updateLocked() {
282 return (locked_ != 0);
283 }
284
285 bool ViewerProperties::backFaceCulling() {
286 return backFaceCulling_;
287 }
288
289 void ViewerProperties::backFaceCulling(bool _state ) {
290 backFaceCulling_ = _state;
291 emit updated();
292 }
293
294 void ViewerProperties::twoSidedLighting(bool _state ) {
295 twoSidedLighting_ = _state;
296 emit updated();
297 }
298
299 bool ViewerProperties::twoSidedLighting() {
300 return twoSidedLighting_;
301 }
302
303 void ViewerProperties::multisampling(bool _state ) {
304 multisampling_ = _state;
305 emit updated();
306 }
307
308 bool ViewerProperties::multisampling() {
309 return multisampling_;
310 }
311
312 void ViewerProperties::mipmapping(bool _state ) {
313 glState_->allow_mipmapping(_state); mipmapping_ = _state; emit updated();
314 }
315
316 bool ViewerProperties::mipmapping() {
317 return mipmapping_;
318 }
319
320 void ViewerProperties::animation(bool _state ) {
321 animation_ = _state;
322 emit updated();
323 }
324
325 bool ViewerProperties::animation() {
326 return animation_;
327 }
328
329 ACG::GLState& ViewerProperties::glState() {
330 return (*glState_);
331 }
332
333 const ACG::GLState& ViewerProperties::glState() const {
334 return (*glState_);
335 }
336
337 void ViewerProperties::setglState(ACG::GLState* _glState) {
338 glState_ = _glState;
339 }
340
341 void ViewerProperties::objectMarker (ViewObjectMarker* _marker) {
342 objectMarker_ = _marker;
343 emit updated();
344 }
345
346 ViewObjectMarker* ViewerProperties::objectMarker() {
347 return objectMarker_;
348 }
349
350 double ViewerProperties::orthoWidth() {
351 return orthoWidth_;
352 }
353
354 void ViewerProperties::orthoWidth(double _width){
355 orthoWidth_ = _width;
356 emit updated();
357 }
358
359 double ViewerProperties::nearPlane(){
360 return nearPlane_;
361 }
362
363 void ViewerProperties::setPlanes( double _near, double _far ) {
364 nearPlane_ = _near;
365 farPlane_ = _far;
366 emit updated();
367 }
368
369 double ViewerProperties::farPlane(){
370 return farPlane_;
371 }
372
373 ACG::Vec3d ViewerProperties::sceneCenter(){
374 return sceneCenter_;
375 }
376
377 void ViewerProperties::sceneCenter(ACG::Vec3d _center){
378 sceneCenter_ = _center;
379 emit updated();
380 }
381
382
383 double ViewerProperties::sceneRadius() {
384 return sceneRadius_;
385 }
386
387 void ViewerProperties::sceneRadius(double _radius ) {
388 sceneRadius_ = _radius;
389 emit updated();}
390
391
392 ACG::Vec3d ViewerProperties::trackballCenter(){
393 return trackballCenter_;
394 }
395
396 void ViewerProperties::trackballCenter(ACG::Vec3d _center){
397 trackballCenter_ = _center;
398 emit updated();
399 }
400
401 double ViewerProperties::trackballRadius() {
402 return trackballRadius_;
403 }
404
405 void ViewerProperties::trackballRadius(double _radius ) {
406 trackballRadius_ = _radius; emit updated();
407 }
408
409 void ViewerProperties::stereo(bool _stereo) {
410 stereo_ = _stereo;
411 emit updated();
412 }
413
414 bool ViewerProperties::stereo() {
415 return stereo_;
416 }
417
418 CursorPainter* ViewerProperties::cursorPainter() {
419 return cursorPainter_;
420 }
421
422 void ViewerProperties::cursorPainter( CursorPainter* _painter ) {
423 cursorPainter_ = _painter;
424 }
425
426 ACG::Vec3d ViewerProperties::cursorPoint3D() {
427 return cursorPoint3D_;
428 }
429
430 void ViewerProperties::cursorPoint3D(ACG::Vec3d _pos) {
431 cursorPoint3D_ = _pos;
432 }
433
434 bool ViewerProperties::cursorPositionValid() {
435 return cursorPositionValid_;
436 }
437
438 void ViewerProperties::cursorPositionValid(bool _valid) {
439 cursorPositionValid_ = _valid;
440 }
441
442
443
444 }
445
ViewerProperties.hh
ACG
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
Viewer
Definition: ViewerProperties.cc:62
ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
Definition: DrawModes.cc:87
ACG::Vec3d
VectorT< double, 3 > Vec3d
Definition: VectorT.hh:127
ACG::GLState
Definition: GLState.hh:220
ViewObjectMarker
Definition: ViewObjectMarker.hh:91
ACG::SceneGraph::DrawModes::DrawMode
Specifies a DrawMode.
Definition: DrawModes.hh:294
OpenMesh::VectorT
Definition: Vector11T.hh:83
CursorPainter
Definition: CursorPainter.hh:74