42 #include "ColorPlugin.hh" 47 #include <OpenFlipper/BasePlugin/WhatsThisGenerator.hh> 49 #include <ACG/Scenegraph/MaterialNode.hh> 88 QMenu *colorMenu =
new QMenu(tr(
"&Color schemes"));
90 colorMenu->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"format-stroke-color.png"));
91 emit addMenubarAction(colorMenu->menuAction(),
VIEWMENU );
98 QAction* AC_set_Default_color =
new QAction(tr(
"&Default colors"),
this);
99 AC_set_Default_color->setStatusTip(tr(
"Set Default Colors"));
100 AC_set_Default_color->setWhatsThis(tr(
"Set colors to default colors. ")+whatsThis.generateLink());
101 AC_set_Default_color->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"color-default.png"));
102 connect(AC_set_Default_color, SIGNAL(triggered()),
this, SLOT(
setDefaultColor()));
103 colorMenu->addAction(AC_set_Default_color);
105 QAction* AC_set_Presentation_color =
new QAction(tr(
"&Presentation colors"),
this);
106 AC_set_Presentation_color->setStatusTip(tr(
"Set Presentation Colors"));
107 AC_set_Presentation_color->setWhatsThis(tr(
"Set colors to presentation colors. ")+whatsThis.generateLink());
108 AC_set_Presentation_color->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"color-powerpoint.png"));
110 colorMenu->addAction(AC_set_Presentation_color);
112 QAction* AC_set_Paper_color =
new QAction(tr(
"&Paper colors"),
this);
113 AC_set_Paper_color->setStatusTip(tr(
"Set Paper Colors"));
114 AC_set_Paper_color->setWhatsThis(tr(
"Set colors to colors for papers. ")+whatsThis.generateLink());
115 AC_set_Paper_color->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"color-paper.png"));
116 connect(AC_set_Paper_color, SIGNAL(triggered()),
this, SLOT(
setPaperColor()));
117 colorMenu->addAction(AC_set_Paper_color);
123 QToolBar* toolbar =
new QToolBar(tr(
"Color Toolbar"));
124 toolbar->addAction(AC_set_Default_color);
125 toolbar->addAction(AC_set_Presentation_color);
126 toolbar->addAction(AC_set_Paper_color);
127 emit addToolbar( toolbar );
142 emit scriptInfo(
"setDefaultColor()" );
143 emit showStatusMessage( tr(
"Set to default Colors"), 4000 );
155 ambient_color[3] = 1.0f;
156 diffuse_color[3] = 1.0f;
157 specular_color[3] = 1.0f;
188 emit scriptInfo(
"setPresentationColor()" );
189 emit showStatusMessage( tr(
"Set to Presentation Colors"), 4000 );
201 ambient_color[3] = 1.0f;
202 diffuse_color[3] = 1.0f;
203 specular_color[3] = 1.0f;
234 emit scriptInfo(
"setPaperColor()" );
235 emit showStatusMessage( tr(
"Set to Paper Colors"), 4000 );
247 ambient_color[3] = 1.0f;
248 diffuse_color[3] = 1.0f;
249 specular_color[3] = 1.0f;
277 emit scriptInfo(
"setBackgroundColor()" );
278 emit showStatusMessage( tr(
"Set background color"), 4000 );
281 color[0] = _color[0];
282 color[1] = _color[1];
283 color[2] = _color[2];
304 object->materialNode()->set_base_color(tmp);
322 object->materialNode()->set_ambient_color(tmp);
339 object->materialNode()->set_diffuse_color(tmp);
356 object->materialNode()->set_specular_color(tmp);
369 color.setRgbF(_color[0], _color[1], _color[2], _color[3] );
387 QColor color(_color);
405 QRgb rgb = _icon.pixmap(32,32).toImage().pixel(0,0);
422 _color[0] = color.redF();
423 _color[1] = color.greenF();
424 _color[2] = color.blueF();
425 _color[3] = color.alphaF();
435 QPushButton* button =
dynamic_cast< QPushButton*
> ( sender() );
441 QRgb newColor = QColorDialog::getRgba (
getIconColor( button->icon() ) , &ok );
535 color.setRgba( _color );
537 _vector[0] = color.redF();
538 _vector[1] = color.greenF();
539 _vector[2] = color.blueF();
540 _vector[3] = color.alphaF();
554 color.setRgbF(_vector[0], _vector[1], _vector[2], _vector[3] );
556 return (uint) color.rgba();
572 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"backgroundColorDefault") )
574 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"backgroundColorPaper") )
576 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"backgroundColorPresentation") )
579 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"baseColorDefault") )
581 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"baseColorPaper") )
583 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"baseColorPresentation") )
586 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"materialColorDefault") )
588 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"materialColorPaper") )
590 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"materialColorPresentation") )
595 if ( _ini.
get_entry( width,
"ColorPlugin" ,
"lineWidthDefault") )
597 if ( _ini.
get_entry( width,
"ColorPlugin" ,
"lineWidthPaper") )
599 if ( _ini.
get_entry( width,
"ColorPlugin" ,
"lineWidthPresentation") )
613 std::cerr <<
"save to ini file\n";
QRgb getIconColor(QIcon _icon)
get the color from a given icon
void set_diffuse_color(const Vec4f &_d)
set the diffuse color.
OpenMesh::Vec4f baseColorPresentation_
the options widget to set colors
double lineWidthDefault_
the options widget to set colors
void setPaperColor()
set the paperColor Preset
OpenMesh::Vec4f materialColorDefault_
the options widget to set colors
void setObjectEmissiveColor(int _objectId, Vector4 _color)
void set_specular_color(const Vec4f &_s)
set the specular color
VectorT< float, 4 > Vec4f
void setPresentationColor()
Set the presentation color preset.
OpenMesh::Vec4f materialColorPaper_
the options widget to set colors
ColorOptions * optionsWidget_
the options widget to set colors
bool section_exists(const QString &_section) const
Check if given section exists in the current INI file.
OpenMesh::Vec4f materialColorPresentation_
the options widget to set colors
OpenMesh::Vec4f backgroundColorPaper_
the options widget to set colors
OpenMesh::Vec4f baseColorPaper_
the options widget to set colors
const QStringList ALL_OBJECTS
Iterable object range.
void setBackColor(OpenMesh::Vec4f _color)
Set the background color of the examiner widget.
ColorPlugin()
ConstructorOptionsInterface.
OpenMesh::Vec4f backgroundColorDefault_
the options widget to set colors
void setObjectSpecularColor(int _objectId, Vector4 _color)
void saveIniFileOptions(INIFile &_ini)
Store current color preset to an ini file.
void getColorDialog()
display a color dialog
static const Vec4f default_clear_color
default value for clear color
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
bool initializeOptionsWidget(QWidget *&_widget)
generate an optionsWidget to change color presets
static const Vec4f default_base_color
default value for base color
void set_line_width(float _sz)
set line width (default: 1.0)
static const Vec4f default_diffuse_color
default value for diffuse color
QIcon generateIcon(QRgb _color)
generate an icon from a given color
double lineWidthPresentation_
the options widget to set colors
void convertColor(uint _color, OpenMesh::Vec4f &_vector)
convert betweeen uint and Vec4f
OpenMesh::Vec4f backgroundColorPresentation_
the options widget to set colors
void setBackgroundColor(Vector _color)
Set the backgroundColor.
#define VIEWMENU
The Menu will be added inside the View Menu.
void setObjectDiffuseColor(int _objectId, Vector4 _color)
void applyOptions()
Store the changed color presets when the apply Button was hit.
void set_ambient_color(const Vec4f &_a)
set the ambient color.
void add_entry(const QString &_section, const QString &_key, const QString &_value)
Addition / modification of a string entry.
OpenMesh::Vec4f baseColorDefault_
the options widget to set colors
void setNewColor(QIcon _icon, OpenMesh::Vec4f &_color)
set the color of a color vector to the one in the given icon
double lineWidthPaper_
the options widget to set colors
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
a class which provides an link generator for WhatsThisMessages linking to the user doc If you have an...
void setDefaultColor()
set the defaultColor preset
void set_base_color(const Vec4f &_c)
set the base color ( Same as set_emission(const Vec4f& _c) )
void loadIniFileOptions(INIFile &_ini)
read color preset from ini file
void pluginsInitialized()
initialize the toolbar and menubar
void setObjectAmbientColor(int _objectId, Vector4 _color)
Class for the handling of simple configuration files.
bool get_entry(QString &_val, const QString &_section, const QString &_key) const
Access to a string entry.