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 #pragma once
43 
44 
45 
52 #include "OpenFlipper/BasePlugin/INIInterface.hh"
53 
54 #include <QObject>
55 #include <QMenuBar>
56 
57 #include "widgets/ColorOptions.hh"
58 
59 
60 
62 {
63 
64  Q_OBJECT
65 
66  Q_INTERFACES(BaseInterface)
67  Q_INTERFACES(MenuInterface)
68  Q_INTERFACES(ScriptInterface)
69  Q_INTERFACES(ToolbarInterface)
70  Q_INTERFACES(StatusbarInterface)
71  Q_INTERFACES(OptionsInterface)
72  Q_INTERFACES(INIInterface)
73 
74  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Color")
75 
76  signals:
77  // BaseInterface
78  void updateView();
79 
80  // ScriptInterface
81  void scriptInfo( QString _functionName );
82 
83  // MenuInterface
84  void addMenubarAction(QAction* _action, QString _type );
85 
86  // ToolbarInterface
87  void addToolbar(QToolBar* _toolbar);
88  void removeToolbar(QToolBar* _toolbar);
89 
90  // StatusbarInterface
91  void showStatusMessage(QString _message, int _timeout = 0);
92 
93  private slots:
94 
95  // BaseInterface
96  void pluginsInitialized();
97 
98  // OptionsInterface
99  void applyOptions();
100 
101  // INIInterface
102  void loadIniFileOptions(INIFile& _ini);
103  void saveIniFileOptions(INIFile& _ini);
104 
105  public :
106 
107  // OptionsInterface
108  bool initializeOptionsWidget(QWidget*& _widget);
109 
110  // BaseInterface
111  QString name() { return (QString("Color Plugin")); };
112  QString description( ) { return (tr("Sets the Default colors e.g. for slides, paper,... snapshots")); };
113 
115  ColorPlugin();
116 
117 
118  //===========================================================================
121  //===========================================================================
122 
123  private:
126 
128  QIcon generateIcon(QRgb _color);
129 
131  QIcon generateIcon(OpenMesh::Vec4f _color);
132 
134  QRgb getIconColor(QIcon _icon);
135 
137  void setNewColor(QIcon _icon, OpenMesh::Vec4f& _color);
138 
140  void convertColor(uint _color, OpenMesh::Vec4f& _vector);
141 
143  uint convertColor(OpenMesh::Vec4f& _vector);
144 
145  //internal storage of colors
149 
151 
152  private slots:
154  void getColorDialog();
155 
158  //===========================================================================
161  //===========================================================================
162 
163  public slots:
167  void setDefaultColor();
168 
172  void setPresentationColor();
173 
177  void setPaperColor();
178 
182  void setBackgroundColor( Vector _color );
183 
187  void setObjectEmissiveColor(int _objectId , Vector4 _color);
188 
192  void setObjectAmbientColor(int _objectId , Vector4 _color);
193 
197  void setObjectDiffuseColor(int _objectId , Vector4 _color);
198 
202  void setObjectSpecularColor(int _objectId , Vector4 _color);
203 
206  //===========================================================================
209  //===========================================================================
210 
211  public slots:
212 
216  QString version() { return QString("1.0"); };
217 
219 };
220 
221 
void saveIniFileOptions(INIFile &_ini)
Store current color preset to an ini file.
Definition: ColorPlugin.cc:612
OpenMesh::Vec4f baseColorDefault_
the options widget to set colors
Definition: ColorPlugin.hh:147
OpenMesh::Vec4f backgroundColorPaper_
the options widget to set colors
Definition: ColorPlugin.hh:146
Options Dialog interface.
Add a toolbox to OpenFlipper.
Interface for all plugins which provide entries to the main menubar.
OpenMesh::Vec4f materialColorDefault_
the options widget to set colors
Definition: ColorPlugin.hh:148
double lineWidthPresentation_
the options widget to set colors
Definition: ColorPlugin.hh:150
void convertColor(uint _color, OpenMesh::Vec4f &_vector)
convert betweeen uint and Vec4f
Definition: ColorPlugin.cc:532
ColorPlugin()
ConstructorOptionsInterface.
Definition: ColorPlugin.cc:56
OpenMesh::Vec4f baseColorPresentation_
the options widget to set colors
Definition: ColorPlugin.hh:147
OpenMesh::Vec4f backgroundColorDefault_
the options widget to set colors
Definition: ColorPlugin.hh:146
void setNewColor(QIcon _icon, OpenMesh::Vec4f &_color)
set the color of a color vector to the one in the given icon
Definition: ColorPlugin.cc:418
QString name()
Return a name for the plugin.
Definition: ColorPlugin.hh:111
void setPaperColor()
set the paperColor Preset
Definition: ColorPlugin.cc:229
void setBackgroundColor(Vector _color)
Set the backgroundColor.
Definition: ColorPlugin.cc:276
QIcon generateIcon(QRgb _color)
generate an icon from a given color
Definition: ColorPlugin.cc:385
double lineWidthPaper_
the options widget to set colors
Definition: ColorPlugin.hh:150
void applyOptions()
Store the changed color presets when the apply Button was hit.
Definition: ColorPlugin.cc:505
void loadIniFileOptions(INIFile &_ini)
read color preset from ini file
Definition: ColorPlugin.cc:566
QString version()
Definition: ColorPlugin.hh:216
void setObjectEmissiveColor(int _objectId, Vector4 _color)
Definition: ColorPlugin.cc:296
void getColorDialog()
display a color dialog
Definition: ColorPlugin.cc:433
QRgb getIconColor(QIcon _icon)
get the color from a given icon
Definition: ColorPlugin.cc:403
void setDefaultColor()
set the defaultColor preset
Definition: ColorPlugin.cc:137
QString description()
Return a description of what the plugin is doing.
Definition: ColorPlugin.hh:112
OpenMesh::Vec4f materialColorPresentation_
the options widget to set colors
Definition: ColorPlugin.hh:148
Control OpenFlippers status bar.
void pluginsInitialized()
initialize the toolbar and menubar
Definition: ColorPlugin.cc:83
void setObjectSpecularColor(int _objectId, Vector4 _color)
Definition: ColorPlugin.cc:349
void setObjectAmbientColor(int _objectId, Vector4 _color)
Definition: ColorPlugin.cc:315
ColorOptions * optionsWidget_
the options widget to set colors
Definition: ColorPlugin.hh:125
bool initializeOptionsWidget(QWidget *&_widget)
generate an optionsWidget to change color presets
Definition: ColorPlugin.cc:457
Interface class for Plugins which have to store information in ini files.
Definition: INIInterface.hh:60
Class for the handling of simple configuration files.
Definition: INIFile.hh:99
OpenMesh::Vec4f backgroundColorPresentation_
the options widget to set colors
Definition: ColorPlugin.hh:146
OpenMesh::Vec4f materialColorPaper_
the options widget to set colors
Definition: ColorPlugin.hh:148
Interface for all Plugins which provide scriptable Functions.
void setObjectDiffuseColor(int _objectId, Vector4 _color)
Definition: ColorPlugin.cc:332
OpenMesh::Vec4f baseColorPaper_
the options widget to set colors
Definition: ColorPlugin.hh:147
void setPresentationColor()
Set the presentation color preset.
Definition: ColorPlugin.cc:183
Interface class from which all plugins have to be created.
double lineWidthDefault_
the options widget to set colors
Definition: ColorPlugin.hh:150