Commit 8608bca5 authored by Jan Möbius's avatar Jan Möbius
Browse files

Cleanup color plugin

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@2951 383ad7c9-94d9-4d36-a494-682f7c89f535
parent e2820c40
......@@ -11,17 +11,20 @@
void ColorPlugin::pluginsInitialized()
{
// color menu
// =============================================================================
// Add a Menu for color selection
// =============================================================================
QMenu *colorMenu = new QMenu(tr("&Colors"));
QIcon icon;
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"format-stroke-color.png");
colorMenu->setIcon(icon);
emit addMenu( colorMenu, VIEWMENU );
AC_set_Default_color = new QAction(tr("&Default colors"), this);;
// =============================================================================
// Add Menu entries
// =============================================================================
QAction* AC_set_Default_color = new QAction(tr("&Default colors"), this);
AC_set_Default_color->setStatusTip(tr("Set Default Colors"));
AC_set_Default_color->setWhatsThis("Set colors to default colors");
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"flag.png");
......@@ -29,7 +32,7 @@ void ColorPlugin::pluginsInitialized()
connect(AC_set_Default_color, SIGNAL(triggered()), this, SLOT(setDefaultColor()));
colorMenu->addAction(AC_set_Default_color);
AC_set_Powerpoint_color = new QAction(tr("&Powerpoint colors"), this);;
QAction* AC_set_Powerpoint_color = new QAction(tr("&Powerpoint colors"), this);
AC_set_Powerpoint_color->setStatusTip(tr("Set Powerpoint Colors"));
AC_set_Powerpoint_color->setWhatsThis("Set colors to Powerpoint presentation colors");
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"video-projector.png");
......@@ -37,7 +40,7 @@ void ColorPlugin::pluginsInitialized()
connect(AC_set_Powerpoint_color, SIGNAL(triggered()), this, SLOT(setPowerpointColor()));
colorMenu->addAction(AC_set_Powerpoint_color);
AC_set_Paper_color = new QAction(tr("&Paper colors"), this);;
QAction* AC_set_Paper_color = new QAction(tr("&Paper colors"), this);
AC_set_Paper_color->setStatusTip(tr("Set Paper Colors"));
AC_set_Paper_color->setWhatsThis("Set colors to colors for papers");
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"view-pim-news.png");
......@@ -45,6 +48,10 @@ void ColorPlugin::pluginsInitialized()
connect(AC_set_Paper_color, SIGNAL(triggered()), this, SLOT(setPaperColor()));
colorMenu->addAction(AC_set_Paper_color);
// =============================================================================
// Create symbol bar with same contents
// =============================================================================
QToolBar* toolbar = new QToolBar("Color Toolbar");
toolbar->addAction(AC_set_Default_color);
toolbar->addAction(AC_set_Powerpoint_color);
......@@ -55,12 +62,17 @@ void ColorPlugin::pluginsInitialized()
void ColorPlugin::setDefaultColor() {
// =============================================================================
// Give user feedback
// =============================================================================
emit scriptInfo( "setDefaultColor()" );
emit showStatusMessage( "Set to default Colors", 4000 );
// =============================================================================
// Define the new colors
// =============================================================================
OpenMesh::Vec4f back_color,
base_color=OpenMesh::Vec4f(0.0,0.0,0.0,0.0),
base_color,
ambient_color,
diffuse_color,
specular_color,
......@@ -74,9 +86,12 @@ void ColorPlugin::setDefaultColor() {
specular_color = ACG::GLState::default_specular_color;
line_width = 1.0;
// Set background color
PluginFunctions::setBackColor(back_color);
// Force an update of all objects
// =============================================================================
// Apply to all objects
// =============================================================================
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objects_end(); ++o_it) {
MaterialNode* mat = o_it->materialNode();
mat->set_base_color(base_color);
......@@ -91,12 +106,17 @@ void ColorPlugin::setDefaultColor() {
void ColorPlugin::setPowerpointColor() {
// =============================================================================
// Give user feedback
// =============================================================================
emit scriptInfo( "setPowerpointColor()" );
emit showStatusMessage( "Set to Powerpoint Colors", 4000 );
// =============================================================================
// Define the new colors
// =============================================================================
OpenMesh::Vec4f back_color,
base_color=OpenMesh::Vec4f(0.0,0.0,0.0,0.0),
base_color,
ambient_color,
diffuse_color,
specular_color,
......@@ -111,8 +131,12 @@ void ColorPlugin::setPowerpointColor() {
specular_color = 0.8f * mat_color;
line_width = 1.0;
// Set background color
PluginFunctions::setBackColor(back_color);
// =============================================================================
// Apply to all objects
// =============================================================================
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objects_end(); ++o_it) {
MaterialNode* mat = o_it->materialNode();
mat->set_base_color(base_color);
......@@ -127,12 +151,17 @@ void ColorPlugin::setPowerpointColor() {
void ColorPlugin::setPaperColor() {
// =============================================================================
// Give user feedback
// =============================================================================
emit scriptInfo( "setPaperColor()" );
emit showStatusMessage( "Set to Paper Colors", 4000 );
// =============================================================================
// Define the new colors
// =============================================================================
OpenMesh::Vec4f back_color,
base_color=OpenMesh::Vec4f(0.0,0.0,0.0,0.0),
base_color,
ambient_color,
diffuse_color,
specular_color,
......@@ -147,8 +176,12 @@ void ColorPlugin::setPaperColor() {
specular_color = 0.8f * mat_color;
line_width = 2.0;
// Set background color
PluginFunctions::setBackColor(back_color);
// =============================================================================
// Apply to all objects
// =============================================================================
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS) ; o_it != PluginFunctions::objects_end(); ++o_it) {
MaterialNode* mat = o_it->materialNode();
mat->set_base_color(base_color);
......@@ -164,6 +197,9 @@ void ColorPlugin::setPaperColor() {
//-----------------------------------------------------------------------------
void ColorPlugin::setBackgroundColor( Vector _color ) {
emit scriptInfo( "setBackgroundColor()" );
emit showStatusMessage( "Set background color", 4000 );
ACG::Vec4f color;
color[0] = _color[0];
color[1] = _color[1];
......
......@@ -17,12 +17,12 @@
class ColorPlugin : public QObject, BaseInterface, MenuInterface, ScriptInterface, ToolbarInterface, StatusbarInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(MenuInterface)
Q_INTERFACES(ScriptInterface)
Q_INTERFACES(ToolbarInterface)
Q_INTERFACES(StatusbarInterface)
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(MenuInterface)
Q_INTERFACES(ScriptInterface)
Q_INTERFACES(ToolbarInterface)
Q_INTERFACES(StatusbarInterface)
signals:
void update_view();
......@@ -41,25 +41,51 @@ class ColorPlugin : public QObject, BaseInterface, MenuInterface, ScriptInterfac
void pluginsInitialized();
public :
void init();
QString name() { return (QString("Color Plugin")); };
QString description( ) { return (QString("Sets the Default colors e.g. for slides, paper,... snapshots")); };
//===========================================================================
/** @name Scriptable functions to set colors
* @{ */
//===========================================================================
public slots:
/**
* Applies Default colors to the whole scene
*/
void setDefaultColor();
/**
* Applies colors for presentations to the scene
*/
void setPowerpointColor();
/**
* Applies colors for papers
*/
void setPaperColor();
/// Set the Background Color
/**
* Sets the background color of the scene
*/
void setBackgroundColor( Vector _color );
//===========================================================================
/** @name Other scriptable functions
* @{ */
//===========================================================================
public slots:
/**
* Version info of the color plugin
*/
QString version() { return QString("1.0"); };
private :
QAction* AC_set_Default_color;
QAction* AC_set_Powerpoint_color;
QAction* AC_set_Paper_color;
/** @} */
};
#endif //COLORPLUGIN_HH
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment