Developer Documentation
ColorPlugin.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 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #ifndef COLORPLUGIN_HH
51 #define COLORPLUGIN_HH
52 
60 #include "OpenFlipper/BasePlugin/INIInterface.hh"
61 
62 #include <QObject>
63 #include <QMenuBar>
64 #include "ColorPlugin.hh"
65 
66 #include "ColorOptions.hh"
67 
68 #include "OpenFlipper/INIFile/INIFile.hh"
69 
71 {
72 
73  Q_OBJECT
74 
75  Q_INTERFACES(BaseInterface)
76  Q_INTERFACES(MenuInterface)
77  Q_INTERFACES(ScriptInterface)
78  Q_INTERFACES(ToolbarInterface)
79  Q_INTERFACES(StatusbarInterface)
80  Q_INTERFACES(OptionsInterface)
81  Q_INTERFACES(INIInterface)
82 
83 #if QT_VERSION >= 0x050000
84  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Color")
85 #endif
86 
87  signals:
88  // BaseInterface
89  void updateView();
90 
91  // ScriptInterface
92  void scriptInfo( QString _functionName );
93 
94  // MenuInterface
95  void addMenubarAction(QAction* _action, QString _type );
96 
97  // ToolbarInterface
98  void addToolbar(QToolBar* _toolbar);
99  void removeToolbar(QToolBar* _toolbar);
100 
101  // StatusbarInterface
102  void showStatusMessage(QString _message, int _timeout = 0);
103 
104  private slots:
105 
106  // BaseInterface
107  void pluginsInitialized();
108 
109  // OptionsInterface
110  void applyOptions();
111 
112  // INIInterface
113  void loadIniFileOptions(INIFile& _ini);
114  void saveIniFileOptions(INIFile& _ini);
115 
116  public :
117 
118  // OptionsInterface
119  bool initializeOptionsWidget(QWidget*& _widget);
120 
121  // BaseInterface
122  QString name() { return (QString("Color Plugin")); };
123  QString description( ) { return (tr("Sets the Default colors e.g. for slides, paper,... snapshots")); };
124 
126  ColorPlugin();
127 
128 
129  //===========================================================================
132  //===========================================================================
133 
134  private:
137 
139  QIcon generateIcon(QRgb _color);
140 
142  QIcon generateIcon(OpenMesh::Vec4f _color);
143 
145  QRgb getIconColor(QIcon _icon);
146 
148  void setNewColor(QIcon _icon, OpenMesh::Vec4f& _color);
149 
151  void convertColor(uint _color, OpenMesh::Vec4f& _vector);
152 
154  uint convertColor(OpenMesh::Vec4f& _vector);
155 
156  //internal storage of colors
160 
162 
163  private slots:
165  void getColorDialog();
166 
169  //===========================================================================
172  //===========================================================================
173 
174  public slots:
178  void setDefaultColor();
179 
183  void setPresentationColor();
184 
188  void setPaperColor();
189 
193  void setBackgroundColor( Vector _color );
194 
198  void setObjectEmissiveColor(int _objectId , Vector4 _color);
199 
203  void setObjectAmbientColor(int _objectId , Vector4 _color);
204 
208  void setObjectDiffuseColor(int _objectId , Vector4 _color);
209 
213  void setObjectSpecularColor(int _objectId , Vector4 _color);
214 
217  //===========================================================================
220  //===========================================================================
221 
222  public slots:
223 
227  QString version() { return QString("1.0"); };
228 
230 };
231 
232 #endif //COLORPLUGIN_HH
Options Dialog interface.
double lineWidthPresentation_
the options widget to set colors
Definition: ColorPlugin.hh:161
void pluginsInitialized()
initialize the toolbar and menubar
Definition: ColorPlugin.cc:93
OpenMesh::Vec4f baseColorPresentation_
the options widget to set colors
Definition: ColorPlugin.hh:158
void saveIniFileOptions(INIFile &_ini)
Store current color preset to an ini file.
Definition: ColorPlugin.cc:622
Control OpenFlippers status bar.
OpenMesh::Vec4f materialColorDefault_
the options widget to set colors
Definition: ColorPlugin.hh:159
double lineWidthDefault_
the options widget to set colors
Definition: ColorPlugin.hh:161
OpenMesh::Vec4f backgroundColorPresentation_
the options widget to set colors
Definition: ColorPlugin.hh:157
double lineWidthPaper_
the options widget to set colors
Definition: ColorPlugin.hh:161
OpenMesh::Vec4f materialColorPresentation_
the options widget to set colors
Definition: ColorPlugin.hh:159
void setPresentationColor()
Set the presentation color preset.
Definition: ColorPlugin.cc:193
void setPaperColor()
set the paperColor Preset
Definition: ColorPlugin.cc:239
ColorOptions * optionsWidget_
the options widget to set colors
Definition: ColorPlugin.hh:136
void setObjectAmbientColor(int _objectId, Vector4 _color)
Definition: ColorPlugin.cc:325
Interface for all Plugins which provide scriptable Functions.
Interface class for Plugins which have to store information in ini files.
Definition: INIInterface.hh:81
Interface class from which all plugins have to be created.
void convertColor(uint _color, OpenMesh::Vec4f &_vector)
convert betweeen uint and Vec4f
Definition: ColorPlugin.cc:542
void getColorDialog()
display a color dialog
Definition: ColorPlugin.cc:443
bool initializeOptionsWidget(QWidget *&_widget)
generate an optionsWidget to change color presets
Definition: ColorPlugin.cc:467
void setNewColor(QIcon _icon, OpenMesh::Vec4f &_color)
set the color of a color vector to the one in the given icon
Definition: ColorPlugin.cc:428
OpenMesh::Vec4f backgroundColorPaper_
the options widget to set colors
Definition: ColorPlugin.hh:157
Interface for all plugins which provide entries to the main menubar.
ColorPlugin()
ConstructorOptionsInterface.
Definition: ColorPlugin.cc:66
void applyOptions()
Store the changed color presets when the apply Button was hit.
Definition: ColorPlugin.cc:515
Class for the handling of simple configuration files.
Definition: INIFile.hh:105
void setDefaultColor()
set the defaultColor preset
Definition: ColorPlugin.cc:147
OpenMesh::Vec4f backgroundColorDefault_
the options widget to set colors
Definition: ColorPlugin.hh:157
void loadIniFileOptions(INIFile &_ini)
read color preset from ini file
Definition: ColorPlugin.cc:576
QRgb getIconColor(QIcon _icon)
get the color from a given icon
Definition: ColorPlugin.cc:413
QIcon generateIcon(QRgb _color)
generate an icon from a given color
Definition: ColorPlugin.cc:395
void setObjectDiffuseColor(int _objectId, Vector4 _color)
Definition: ColorPlugin.cc:342
QString version()
Definition: ColorPlugin.hh:227
void setObjectEmissiveColor(int _objectId, Vector4 _color)
Definition: ColorPlugin.cc:306
OpenMesh::Vec4f materialColorPaper_
the options widget to set colors
Definition: ColorPlugin.hh:159
QString name()
Return a name for the plugin.
Definition: ColorPlugin.hh:122
OpenMesh::Vec4f baseColorPaper_
the options widget to set colors
Definition: ColorPlugin.hh:158
OpenMesh::Vec4f baseColorDefault_
the options widget to set colors
Definition: ColorPlugin.hh:158
QString description()
Return a description of what the plugin is doing.
Definition: ColorPlugin.hh:123
void setBackgroundColor(Vector _color)
Set the backgroundColor.
Definition: ColorPlugin.cc:286
Add a toolbox to OpenFlipper.
void setObjectSpecularColor(int _objectId, Vector4 _color)
Definition: ColorPlugin.cc:359