ColorPlugin.hh 7.24 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2 3 4 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
*                                                                            *
*                              OpenFlipper                                   *
*      Copyright (C) 2001-2010 by Computer Graphics Group, RWTH Aachen       *
*                           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
#ifndef COLORPLUGIN_HH
#define COLORPLUGIN_HH

#include <QObject>
#include <QMenuBar>
#include "ColorPlugin.hh"

50 51 52 53
#include "ColorOptions.hh"

#include "OpenFlipper/INIFile/INIFile.hh"

54 55 56 57 58 59
#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"
60 61
#include "OpenFlipper/BasePlugin/OptionsInterface.hh"
#include "OpenFlipper/BasePlugin/INIInterface.hh"
62

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 76

  signals:
77
    // BaseInterface
78
    void updateView();
79

80
    // ScriptInterface
Jan Möbius's avatar
Jan Möbius committed
81
    void scriptInfo( QString _functionName );
82

83
    // MenuInterface
84
    void addMenubarAction(QAction* _action, QString _type );
85

86
    // ToolbarInterface
Jan Möbius's avatar
Jan Möbius committed
87 88
    void addToolbar(QToolBar* _toolbar);
    void removeToolbar(QToolBar* _toolbar);
89

90
    // StatusbarInterface
Jan Möbius's avatar
Jan Möbius committed
91 92
    void showStatusMessage(QString _message, int _timeout = 0);

93
  private slots:
Jan Möbius's avatar
Jan Möbius committed
94

95
    // BaseInterface
Jan Möbius's avatar
Jan Möbius committed
96 97
    void pluginsInitialized();

98 99 100 101 102 103 104
    // OptionsInterface
    void applyOptions();

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

Jan Möbius's avatar
Jan Möbius committed
105
  public :
106

107 108
    // OptionsInterface
    bool initializeOptionsWidget(QWidget*& _widget);
Jan Möbius's avatar
Jan Möbius committed
109

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

114 115 116 117 118 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
    /// Constructor
    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
158 159 160
  //===========================================================================
  /** @name Scriptable functions to set colors
    * @{ */
161 162
  //===========================================================================

Jan Möbius's avatar
Jan Möbius committed
163 164 165 166 167
  public slots:
    /**
     * Applies Default colors to the whole scene
     */
    void setDefaultColor();
168

Jan Möbius's avatar
Jan Möbius committed
169 170 171
    /**
     * Applies colors for presentations to the scene
     */
172
    void setPresentationColor();
173

Jan Möbius's avatar
Jan Möbius committed
174 175 176 177 178 179 180 181 182 183
    /**
     * Applies colors for papers
     */
    void setPaperColor();

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

184 185
  /** @} */

Jan Möbius's avatar
Jan Möbius committed
186 187 188
  //===========================================================================
  /** @name Other scriptable functions
   * @{ */
189 190
  //===========================================================================

Jan Möbius's avatar
Jan Möbius committed
191
  public slots:
192

Jan Möbius's avatar
Jan Möbius committed
193 194 195 196
    /**
     * Version info of the color plugin
     */
    QString version() { return QString("1.0"); };
197

Jan Möbius's avatar
Jan Möbius committed
198
  /** @} */
199 200 201
};

#endif //COLORPLUGIN_HH