50 #include "ColorPlugin.hh"
52 #if QT_VERSION >= 0x050000
98 QMenu *colorMenu =
new QMenu(tr(
"&Color schemes"));
100 colorMenu->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"format-stroke-color.png"));
101 emit addMenubarAction(colorMenu->menuAction(),
VIEWMENU );
108 QAction* AC_set_Default_color =
new QAction(tr(
"&Default colors"),
this);
109 AC_set_Default_color->setStatusTip(tr(
"Set Default Colors"));
110 AC_set_Default_color->setWhatsThis(tr(
"Set colors to default colors. ")+whatsThis.generateLink());
111 AC_set_Default_color->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"color-default.png"));
112 connect(AC_set_Default_color, SIGNAL(triggered()),
this, SLOT(
setDefaultColor()));
113 colorMenu->addAction(AC_set_Default_color);
115 QAction* AC_set_Presentation_color =
new QAction(tr(
"&Presentation colors"),
this);
116 AC_set_Presentation_color->setStatusTip(tr(
"Set Presentation Colors"));
117 AC_set_Presentation_color->setWhatsThis(tr(
"Set colors to presentation colors. ")+whatsThis.generateLink());
118 AC_set_Presentation_color->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"color-powerpoint.png"));
120 colorMenu->addAction(AC_set_Presentation_color);
122 QAction* AC_set_Paper_color =
new QAction(tr(
"&Paper colors"),
this);
123 AC_set_Paper_color->setStatusTip(tr(
"Set Paper Colors"));
124 AC_set_Paper_color->setWhatsThis(tr(
"Set colors to colors for papers. ")+whatsThis.generateLink());
125 AC_set_Paper_color->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"color-paper.png"));
126 connect(AC_set_Paper_color, SIGNAL(triggered()),
this, SLOT(
setPaperColor()));
127 colorMenu->addAction(AC_set_Paper_color);
133 QToolBar* toolbar =
new QToolBar(tr(
"Color Toolbar"));
134 toolbar->addAction(AC_set_Default_color);
135 toolbar->addAction(AC_set_Presentation_color);
136 toolbar->addAction(AC_set_Paper_color);
137 emit addToolbar( toolbar );
152 emit scriptInfo(
"setDefaultColor()" );
153 emit showStatusMessage( tr(
"Set to default Colors"), 4000 );
165 ambient_color[3] = 1.0f;
166 diffuse_color[3] = 1.0f;
167 specular_color[3] = 1.0f;
198 emit scriptInfo(
"setPresentationColor()" );
199 emit showStatusMessage( tr(
"Set to Presentation Colors"), 4000 );
211 ambient_color[3] = 1.0f;
212 diffuse_color[3] = 1.0f;
213 specular_color[3] = 1.0f;
244 emit scriptInfo(
"setPaperColor()" );
245 emit showStatusMessage( tr(
"Set to Paper Colors"), 4000 );
257 ambient_color[3] = 1.0f;
258 diffuse_color[3] = 1.0f;
259 specular_color[3] = 1.0f;
287 emit scriptInfo(
"setBackgroundColor()" );
288 emit showStatusMessage( tr(
"Set background color"), 4000 );
291 color[0] = _color[0];
292 color[1] = _color[1];
293 color[2] = _color[2];
314 object->materialNode()->set_base_color(tmp);
332 object->materialNode()->set_ambient_color(tmp);
349 object->materialNode()->set_diffuse_color(tmp);
366 object->materialNode()->set_specular_color(tmp);
379 color.setRgbF(_color[0], _color[1], _color[2], _color[3] );
397 QColor color(_color);
415 QRgb rgb = _icon.pixmap(32,32).toImage().pixel(0,0);
432 _color[0] = color.redF();
433 _color[1] = color.greenF();
434 _color[2] = color.blueF();
435 _color[3] = color.alphaF();
445 QPushButton* button =
dynamic_cast< QPushButton*
> ( sender() );
451 QRgb newColor = QColorDialog::getRgba (
getIconColor( button->icon() ) , &ok );
545 color.setRgba( _color );
547 _vector[0] = color.redF();
548 _vector[1] = color.greenF();
549 _vector[2] = color.blueF();
550 _vector[3] = color.alphaF();
564 color.setRgbF(_vector[0], _vector[1], _vector[2], _vector[3] );
566 return (uint) color.rgba();
582 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"backgroundColorDefault") )
584 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"backgroundColorPaper") )
586 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"backgroundColorPresentation") )
589 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"baseColorDefault") )
591 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"baseColorPaper") )
593 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"baseColorPresentation") )
596 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"materialColorDefault") )
598 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"materialColorPaper") )
600 if ( _ini.
get_entry( color,
"ColorPlugin" ,
"materialColorPresentation") )
605 if ( _ini.
get_entry( width,
"ColorPlugin" ,
"lineWidthDefault") )
607 if ( _ini.
get_entry( width,
"ColorPlugin" ,
"lineWidthPaper") )
609 if ( _ini.
get_entry( width,
"ColorPlugin" ,
"lineWidthPresentation") )
623 std::cerr <<
"save to ini file\n";
643 #if QT_VERSION < 0x050000
ColorOptions * optionsWidget_
the options widget to set colors
static const Vec4f default_clear_color
default value for clear color
const QStringList ALL_OBJECTS
Iterable object range.
double lineWidthDefault_
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
void setPresentationColor()
Set the presentation color preset.
void saveIniFileOptions(INIFile &_ini)
Store current color preset to an ini file.
bool getObject(int _identifier, BSplineCurveObject *&_object)
ColorPlugin()
ConstructorOptionsInterface.
OpenMesh::Vec4f baseColorPresentation_
the options widget to set colors
bool initializeOptionsWidget(QWidget *&_widget)
generate an optionsWidget to change color presets
OpenMesh::Vec4f backgroundColorDefault_
the options widget to set colors
void convertColor(uint _color, OpenMesh::Vec4f &_vector)
convert betweeen uint and Vec4f
bool get_entry(QString &_val, const QString &_section, const QString &_key) const
Access to a string entry.
void setBackgroundColor(Vector _color)
Set the backgroundColor.
void set_base_color(const Vec4f &_c)
set the base color
void setBackColor(OpenMesh::Vec4f _color)
Set the background color of the examiner widget.
void add_entry(const QString &_section, const QString &_key, const QString &_value)
Addition / modification of a string entry.
static const Vec4f default_diffuse_color
default value for diffuse color
Class for the handling of simple configuration files.
#define VIEWMENU
The Menu will be added inside the View Menu.
OpenMesh::Vec4f materialColorDefault_
the options widget to set colors
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
void setObjectDiffuseColor(int _objectId, Vector4 _color)
void applyOptions()
Store the changed color presets when the apply Button was hit.
static const Vec4f default_base_color
default value for base color
void setDefaultColor()
set the defaultColor preset
void getColorDialog()
display a color dialog
OpenMesh::Vec4f baseColorPaper_
the options widget to set colors
OpenMesh::Vec4f backgroundColorPaper_
the options widget to set colors
void set_line_width(float _sz)
set line width (default: 1.0)
void pluginsInitialized()
initialize the toolbar and menubar
void set_specular_color(const Vec4f &_s)
set the specular color
double lineWidthPaper_
the options widget to set colors
QRgb getIconColor(QIcon _icon)
get the color from a given icon
a class which provides an link generator for WhatsThisMessages linking to the user doc If you have an...
OpenMesh::Vec4f materialColorPresentation_
the options widget to set colors
QIcon generateIcon(QRgb _color)
generate an icon from a given color
double lineWidthPresentation_
the options widget to set colors
void loadIniFileOptions(INIFile &_ini)
read color preset from ini file
void set_diffuse_color(const Vec4f &_d)
set the diffuse color.
OpenMesh::Vec4f backgroundColorPresentation_
the options widget to set colors
OpenMesh::Vec4f materialColorPaper_
the options widget to set colors
bool section_exists(const QString &_section) const
Check if given section exists in the current INI file.
void setObjectSpecularColor(int _objectId, Vector4 _color)
OpenMesh::Vec4f baseColorDefault_
the options widget to set colors
void setObjectAmbientColor(int _objectId, Vector4 _color)
void setPaperColor()
set the paperColor Preset
VectorT< float, 4 > Vec4f
void setObjectEmissiveColor(int _objectId, Vector4 _color)
void set_ambient_color(const Vec4f &_a)
set the ambient color.