ColorPlugin.hh 7.84 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2 3
*                                                                            *
*                              OpenFlipper                                   *
Jan Möbius's avatar
Jan Möbius committed
4
*      Copyright (C) 2001-2014 by Computer Graphics Group, RWTH Aachen       *
Jan Möbius's avatar
Jan Möbius committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
*                           www.openflipper.org                              *
*                                                                            *
*--------------------------------------------------------------------------- *
*  This file is part of OpenFlipper.                                         *
*                                                                            *
*  OpenFlipper is free software: you can redistribute it and/or modify       *
*  it under the terms of the GNU Lesser General Public License as            *
*  published by the Free Software Foundation, either version 3 of            *
*  the License, or (at your option) any later version with the               *
*  following exceptions:                                                     *
*                                                                            *
*  If other files instantiate templates or use macros                        *
*  or inline functions from this file, or you compile this file and          *
*  link it with other files to produce an executable, this file does         *
*  not by itself cause the resulting executable to be covered by the         *
*  GNU Lesser General Public License. This exception does not however        *
*  invalidate any other reasons why the executable file might be             *
*  covered by the GNU Lesser General Public License.                         *
*                                                                            *
*  OpenFlipper is distributed in the hope that it will be useful,            *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of            *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
*  GNU Lesser General Public License for more details.                       *
*                                                                            *
*  You should have received a copy of the GNU LesserGeneral Public           *
*  License along with OpenFlipper. If not,                                   *
*  see <http://www.gnu.org/licenses/>.                                       *
*                                                                            *
33 34 35
\*===========================================================================*/

/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
36 37 38 39 40
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
41
\*===========================================================================*/
Jan Möbius's avatar
Jan Möbius committed
42

43 44 45 46 47 48 49 50 51
#ifndef COLORPLUGIN_HH
#define COLORPLUGIN_HH

#include <OpenFlipper/common/Types.hh>
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/MenuInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/ToolbarInterface.hh>
#include "OpenFlipper/BasePlugin/StatusbarInterface.hh"
52 53
#include "OpenFlipper/BasePlugin/OptionsInterface.hh"
#include "OpenFlipper/BasePlugin/INIInterface.hh"
54

55 56 57 58 59 60 61 62
#include <QObject>
#include <QMenuBar>
#include "ColorPlugin.hh"

#include "ColorOptions.hh"

#include "OpenFlipper/INIFile/INIFile.hh"

63
class ColorPlugin : public QObject, BaseInterface, MenuInterface, ScriptInterface, ToolbarInterface, StatusbarInterface, OptionsInterface, INIInterface
64
{
Jan Möbius's avatar
Jan Möbius committed
65 66 67 68 69 70 71 72 73 74
  
  Q_OBJECT

  Q_INTERFACES(BaseInterface)
  Q_INTERFACES(MenuInterface)
  Q_INTERFACES(ScriptInterface)
  Q_INTERFACES(ToolbarInterface)
  Q_INTERFACES(StatusbarInterface)
  Q_INTERFACES(OptionsInterface)
  Q_INTERFACES(INIInterface)
Jan Möbius's avatar
Jan Möbius committed
75

Matthias Möller's avatar
Matthias Möller committed
76 77 78 79
#if QT_VERSION >= 0x050000
  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-Color")
#endif

Jan Möbius's avatar
Jan Möbius committed
80
  signals:
81
    // BaseInterface
82
    void updateView();
83

84
    // ScriptInterface
Jan Möbius's avatar
Jan Möbius committed
85
    void scriptInfo( QString _functionName );
86

87
    // MenuInterface
88
    void addMenubarAction(QAction* _action, QString _type );
89

90
    // ToolbarInterface
Jan Möbius's avatar
Jan Möbius committed
91 92
    void addToolbar(QToolBar* _toolbar);
    void removeToolbar(QToolBar* _toolbar);
93

94
    // StatusbarInterface
Jan Möbius's avatar
Jan Möbius committed
95 96
    void showStatusMessage(QString _message, int _timeout = 0);

97
  private slots:
Jan Möbius's avatar
Jan Möbius committed
98

99
    // BaseInterface
Jan Möbius's avatar
Jan Möbius committed
100 101
    void pluginsInitialized();

102 103 104 105 106 107 108
    // OptionsInterface
    void applyOptions();

    // INIInterface
    void loadIniFileOptions(INIFile& _ini);
    void saveIniFileOptions(INIFile& _ini);

Jan Möbius's avatar
Jan Möbius committed
109
  public :
110

111 112
    // OptionsInterface
    bool initializeOptionsWidget(QWidget*& _widget);
Jan Möbius's avatar
Jan Möbius committed
113

114
    // BaseInterface
Jan Möbius's avatar
Jan Möbius committed
115
    QString name() { return (QString("Color Plugin")); };
Jan Möbius's avatar
Jan Möbius committed
116
    QString description( ) { return (tr("Sets the Default colors e.g. for slides, paper,... snapshots")); };
Jan Möbius's avatar
Jan Möbius committed
117

Matthias Möller's avatar
Matthias Möller committed
118
    /// ConstructorOptionsInterface
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
    ColorPlugin();


  //===========================================================================
  /** @name Show Colors in Options and Store them in INI files
    * @{ */
  //===========================================================================

  private:
    /// the options widget to set colors
    ColorOptions* optionsWidget_;

    /// generate an icon from a given color
    QIcon generateIcon(QRgb _color);

    /// generate an icon from a given color
    QIcon generateIcon(OpenMesh::Vec4f _color);

    /// get the color from a given icon
    QRgb getIconColor(QIcon _icon);

    /// set the color of a color vector to the one in the given icon
    void setNewColor(QIcon _icon, OpenMesh::Vec4f& _color);

    /// convert betweeen uint and Vec4f
    void convertColor(uint _color, OpenMesh::Vec4f& _vector);

    /// convert betweeen uint and Vec4f
    uint convertColor(OpenMesh::Vec4f& _vector);

    //internal storage of colors
    OpenMesh::Vec4f backgroundColorDefault_, backgroundColorPaper_, backgroundColorPresentation_;
    OpenMesh::Vec4f baseColorDefault_, baseColorPaper_, baseColorPresentation_;
    OpenMesh::Vec4f materialColorDefault_, materialColorPaper_, materialColorPresentation_;

    double lineWidthDefault_, lineWidthPaper_, lineWidthPresentation_;

  private slots:
    /// display a color dialog
    void getColorDialog();

  /** @} */

Jan Möbius's avatar
Jan Möbius committed
162 163 164
  //===========================================================================
  /** @name Scriptable functions to set colors
    * @{ */
165 166
  //===========================================================================

Jan Möbius's avatar
Jan Möbius committed
167 168 169 170 171
  public slots:
    /**
     * Applies Default colors to the whole scene
     */
    void setDefaultColor();
172

Jan Möbius's avatar
Jan Möbius committed
173 174 175
    /**
     * Applies colors for presentations to the scene
     */
176
    void setPresentationColor();
177

Jan Möbius's avatar
Jan Möbius committed
178 179 180 181 182 183 184 185 186 187
    /**
     * Applies colors for papers
     */
    void setPaperColor();

    /**
     * Sets the background color of the scene
    */
    void setBackgroundColor( Vector _color );

188 189
    /**
     * Sets the emissive color of an object
190 191 192
     */
    void setObjectEmissiveColor(int _objectId , Vector4 _color);

193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
    /**
     * Sets the ambient color of an object
     */
    void setObjectAmbientColor(int _objectId , Vector4 _color);

    /**
     * Sets the diffuse color of an object
     */
    void setObjectDiffuseColor(int _objectId , Vector4 _color);

    /**
     * Sets the specular color of an object
     */
    void setObjectSpecularColor(int _objectId , Vector4 _color);

208 209
  /** @} */

Jan Möbius's avatar
Jan Möbius committed
210 211 212
  //===========================================================================
  /** @name Other scriptable functions
   * @{ */
213 214
  //===========================================================================

Jan Möbius's avatar
Jan Möbius committed
215
  public slots:
216

Jan Möbius's avatar
Jan Möbius committed
217 218 219 220
    /**
     * Version info of the color plugin
     */
    QString version() { return QString("1.0"); };
221

Jan Möbius's avatar
Jan Möbius committed
222
  /** @} */
223 224 225
};

#endif //COLORPLUGIN_HH