Developer Documentation
QtMaterialDialog.hh
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 // CLASS QtMaterialDialog
45 //
46 //=============================================================================
47 
48 
49 #pragma once
50 
51 
52 //== INCLUDES =================================================================
53 
54 
55 #include "ui_QtMaterialDialogUi.h"
56 
57 #include "../Math/VectorT.hh"
58 #include "../GL/gl.hh"
59 
60 #include <QColor>
61 #include <QDialog>
62 
63 //== FORWARDDECLARATIONS ======================================================
64 
65 
66 namespace ACG {
67  namespace SceneGraph {
68  class MaterialNode;
69  class BaseNode;
70  }
71 }
72 
73 
74 //== NAMESPACE ================================================================
75 
76 
77 namespace ACG {
78 namespace QtWidgets {
79 
80 
81 //== CLASS DEFINITION =========================================================
82 
83 
84 class ACGDLLEXPORT QtMaterialDialog : public QDialog
85 {
86  Q_OBJECT
87 
88 public:
89 
90  QtMaterialDialog( QWidget * _parent,
91  SceneGraph::MaterialNode * _node );
92 
93  ~QtMaterialDialog() {}
94 
95 
96 signals:
97 
98  void signalNodeChanged( ACG::SceneGraph::BaseNode * _node );
99 
100 private:
101 
102 
103  QColor convertColor( Vec4f _color);
104  Vec4f convertColor( QColor _color);
105 
106  void setButtonColor( QtColorChooserButton* _button,
107  const Vec4f& _color );
108 
109 private slots:
110 
111  void changeBaseColor(QColor _newColor);
112  void changeAmbientColor(QColor _newColor);
113  void changeDiffuseColor(QColor _newColor);
114  void changeSpecularColor(QColor _newColor);
115  void changeOverlayColor(QColor _newColor);
116  void changeShine(int _new);
117  void changePointSize(double _new);
118  void changeLineWidth(double _new);
119  void changeRoundPoints(bool _b);
120  void changeLineSmooth(bool _b);
121  void changeBackfaceCulling(bool _b);
122  void changeAlphaTest(bool _b);
123  void changeAlphaValue(int _new);
124  void changeBlending(bool _b);
125  void changeBlendingParam1(const QString& _name);
126  void changeBlendingParam2(const QString& _name);
127  void changeColorMaterial(bool _b);
128  void changeMultiSampling(bool _b);
129 
130  void changeActive(bool toggle);
131 
132  void enableProperty();
133  void enableProperty(int i);
134  void enableProperty(double d);
135 
136  QString paramToStr(GLenum param);
137 
138  void applyChanges();
139  void undoChanges();
140 
141  void reject();
142 
143 private:
144 
145 
146 
147  unsigned int applyProperties_;
148 
149  Vec4f color_, bak_color_,
150  ambient_, bak_ambient_,
151  diffuse_, bak_diffuse_,
152  specular_, bak_specular_,
153  overlay_, bak_overlay_;
154  float shine_, bak_shine_;
155  float point_size_, bak_point_size_;
156  float line_width_, bak_line_width_;
157  bool round_points_, bak_round_points_;
158  bool line_smooth_, bak_line_smooth_;
159  bool backfaceCulling_, bak_backfaceCulling_;
160  bool alphaTest_, bak_alphaTest_;
161  float alphaValue_, bak_alphaValue_;
162  bool blending_, bak_blending_;
163  GLenum blendParam1_, bak_blendParam1_;
164  GLenum blendParam2_, bak_blendParam2_;
165  bool colorMaterial_, bak_colorMaterial_;
166  bool multiSampling_, bak_multiSampling_;
167 
168  bool baseColorActive_, bak_baseColorActive_;
169  bool materialActive_, bak_materialActive_;
170  bool pointSizeActive_, bak_pointSizeActive_;
171  bool lineWidthActive_, bak_lineWidthActive_;
172  bool roundPointsActive_, bak_roundPointsActive_;
173  bool lineSmoothActive_, bak_lineSmoothActive_;
174  bool alphaTestActive_, bak_alphaTestActive_;
175  bool blendingActive_, bak_blendingActive_;
176  bool backfaceCullingActive_, bak_backfaceCullingActive_;
177  bool colorMaterialActive_, bak_colorMaterialActive_;
178  bool multiSamplingActive_, bak_multiSamplingActive_;
179 
180  SceneGraph::MaterialNode * node_;
181 
182  Ui::QtMaterialDialogUi ui_;
183 
184 };
185 
186 
187 //=============================================================================
188 } // namespace QtWidgets
189 } // namespace ACG
190 //=============================================================================
191 
Namespace providing different geometric functions concerning angles.