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
46 #include <OpenFlipper/BasePlugin/BaseInterface.hh>
47 #include <OpenFlipper/BasePlugin/MenuInterface.hh>
48 #include <OpenFlipper/BasePlugin/ScriptInterface.hh>
49 #include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
50 #include "OpenFlipper/BasePlugin/StatusbarInterface.hh"
51 #include "OpenFlipper/BasePlugin/OptionsInterface.hh"
52 #include "OpenFlipper/BasePlugin/INIInterface.hh"
53
54 #include <QObject>
55 #include <QMenuBar>
56
57 #include "widgets/ColorOptions.hh"
58
59
60
61 class ColorPlugin : public QObject, BaseInterface, MenuInterface, ScriptInterface, ToolbarInterface, StatusbarInterface, OptionsInterface, INIInterface
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:
125 ColorOptions* optionsWidget_;
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
146 OpenMesh::Vec4f backgroundColorDefault_, backgroundColorPaper_, backgroundColorPresentation_;
147 OpenMesh::Vec4f baseColorDefault_, baseColorPaper_, baseColorPresentation_;
148 OpenMesh::Vec4f materialColorDefault_, materialColorPaper_, materialColorPresentation_;
149
150 double lineWidthDefault_, lineWidthPaper_, lineWidthPresentation_;
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
ScriptInterface.hh
ColorPlugin::saveIniFileOptions
void saveIniFileOptions(INIFile &_ini)
Store current color preset to an ini file.
Definition: ColorPlugin.cc:612
ColorPlugin::baseColorDefault_
OpenMesh::Vec4f baseColorDefault_
the options widget to set colors
Definition: ColorPlugin.hh:147
ColorPlugin::backgroundColorPaper_
OpenMesh::Vec4f backgroundColorPaper_
the options widget to set colors
Definition: ColorPlugin.hh:146
OptionsInterface
Options Dialog interface.
Definition: OptionsInterface.hh:58
ToolbarInterface
Add a toolbox to OpenFlipper.
Definition: ToolbarInterface.hh:62
MenuInterface
Interface for all plugins which provide entries to the main menubar.
Definition: MenuInterface.hh:81
ColorPlugin::materialColorDefault_
OpenMesh::Vec4f materialColorDefault_
the options widget to set colors
Definition: ColorPlugin.hh:148
ColorPlugin::lineWidthPresentation_
double lineWidthPresentation_
the options widget to set colors
Definition: ColorPlugin.hh:150
ColorPlugin::convertColor
void convertColor(uint _color, OpenMesh::Vec4f &_vector)
convert betweeen uint and Vec4f
Definition: ColorPlugin.cc:532
ColorPlugin::ColorPlugin
ColorPlugin()
ConstructorOptionsInterface.
Definition: ColorPlugin.cc:56
OpenMesh::VectorT< float, 4 >
ColorPlugin::baseColorPresentation_
OpenMesh::Vec4f baseColorPresentation_
the options widget to set colors
Definition: ColorPlugin.hh:147
ColorPlugin::backgroundColorDefault_
OpenMesh::Vec4f backgroundColorDefault_
the options widget to set colors
Definition: ColorPlugin.hh:146
ColorPlugin::setNewColor
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
ColorPlugin::name
QString name()
Return a name for the plugin.
Definition: ColorPlugin.hh:111
ColorPlugin::setPaperColor
void setPaperColor()
set the paperColor Preset
Definition: ColorPlugin.cc:229
MenuInterface.hh
ColorPlugin::setBackgroundColor
void setBackgroundColor(Vector _color)
Set the backgroundColor.
Definition: ColorPlugin.cc:276
ColorPlugin::generateIcon
QIcon generateIcon(QRgb _color)
generate an icon from a given color
Definition: ColorPlugin.cc:385
ColorPlugin::lineWidthPaper_
double lineWidthPaper_
the options widget to set colors
Definition: ColorPlugin.hh:150
ColorPlugin::applyOptions
void applyOptions()
Store the changed color presets when the apply Button was hit.
Definition: ColorPlugin.cc:505
ColorPlugin::loadIniFileOptions
void loadIniFileOptions(INIFile &_ini)
read color preset from ini file
Definition: ColorPlugin.cc:566
ColorPlugin::version
QString version()
Definition: ColorPlugin.hh:216
ColorPlugin::setObjectEmissiveColor
void setObjectEmissiveColor(int _objectId, Vector4 _color)
Definition: ColorPlugin.cc:296
ToolbarInterface.hh
ColorPlugin::getColorDialog
void getColorDialog()
display a color dialog
Definition: ColorPlugin.cc:433
ColorPlugin::getIconColor
QRgb getIconColor(QIcon _icon)
get the color from a given icon
Definition: ColorPlugin.cc:403
ColorPlugin::setDefaultColor
void setDefaultColor()
set the defaultColor preset
Definition: ColorPlugin.cc:137
ColorPlugin::description
QString description()
Return a description of what the plugin is doing.
Definition: ColorPlugin.hh:112
ColorPlugin::materialColorPresentation_
OpenMesh::Vec4f materialColorPresentation_
the options widget to set colors
Definition: ColorPlugin.hh:148
StatusbarInterface
Control OpenFlippers status bar.
Definition: StatusbarInterface.hh:81
ColorPlugin::pluginsInitialized
void pluginsInitialized()
initialize the toolbar and menubar
Definition: ColorPlugin.cc:83
ColorPlugin::setObjectSpecularColor
void setObjectSpecularColor(int _objectId, Vector4 _color)
Definition: ColorPlugin.cc:349
ColorPlugin::setObjectAmbientColor
void setObjectAmbientColor(int _objectId, Vector4 _color)
Definition: ColorPlugin.cc:315
ColorPlugin::optionsWidget_
ColorOptions * optionsWidget_
the options widget to set colors
Definition: ColorPlugin.hh:125
ColorPlugin::initializeOptionsWidget
bool initializeOptionsWidget(QWidget *&_widget)
generate an optionsWidget to change color presets
Definition: ColorPlugin.cc:457
OptionsInterface.hh
INIInterface
Interface class for Plugins which have to store information in ini files.
Definition: INIInterface.hh:60
ColorOptions
Definition: ColorOptions.hh:49
ColorPlugin
Definition: ColorPlugin.hh:61
INIFile
Class for the handling of simple configuration files.
Definition: INIFile.hh:99
ColorPlugin::backgroundColorPresentation_
OpenMesh::Vec4f backgroundColorPresentation_
the options widget to set colors
Definition: ColorPlugin.hh:146
ColorPlugin::materialColorPaper_
OpenMesh::Vec4f materialColorPaper_
the options widget to set colors
Definition: ColorPlugin.hh:148
ScriptInterface
Interface for all Plugins which provide scriptable Functions.
Definition: ScriptInterface.hh:58
ColorPlugin::setObjectDiffuseColor
void setObjectDiffuseColor(int _objectId, Vector4 _color)
Definition: ColorPlugin.cc:332
ColorPlugin::baseColorPaper_
OpenMesh::Vec4f baseColorPaper_
the options widget to set colors
Definition: ColorPlugin.hh:147
StatusbarInterface.hh
ColorPlugin::setPresentationColor
void setPresentationColor()
Set the presentation color preset.
Definition: ColorPlugin.cc:183
BaseInterface
Interface class from which all plugins have to be created.
Definition: BaseInterface.hh:65
BaseInterface.hh
ColorPlugin::lineWidthDefault_
double lineWidthDefault_
the options widget to set colors
Definition: ColorPlugin.hh:150