Commit 4ec2eb42 authored by Jan Möbius's avatar Jan Möbius

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@2438 383ad7c9-94d9-4d36-a494-682f7c89f535
parents
#== SYSTEM PART -- DON'T TOUCH ==============================================
include $(ACGMAKE)/Config
#==============================================================================
SUBDIRS = $(call find-subdirs)
PACKAGES := qt4 glut glew opengl x11 math ACG2 openmesh2
PROJ_LIBS =
MODULES := moc4 cxx
#== SYSTEM PART -- DON'T TOUCH ==============================================
include $(ACGMAKE)/Rules
#==============================================================================
#include <QtGui>
#include "ColorPlugin.hh"
#include <iostream>
#include <ACG/GL/GLState.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
void ColorPlugin::pluginsInitialized()
{
// color menu
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);;
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");
AC_set_Default_color->setIcon(icon);
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);;
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");
AC_set_Powerpoint_color->setIcon(icon);
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);;
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");
AC_set_Paper_color->setIcon(icon);
connect(AC_set_Paper_color, SIGNAL(triggered()), this, SLOT(setPaperColor()));
colorMenu->addAction(AC_set_Paper_color);
QToolBar* toolbar = new QToolBar("Color Toolbar");
toolbar->addAction(AC_set_Default_color);
toolbar->addAction(AC_set_Powerpoint_color);
toolbar->addAction(AC_set_Paper_color);
emit addToolbar( toolbar );
}
void ColorPlugin::setDefaultColor() {
emit scriptInfo( "setDefaultColor()" );
emit showStatusMessage( "Set to default Colors", 4000 );
OpenMesh::Vec4f back_color,
base_color=OpenMesh::Vec4f(0.0,0.0,0.0,0.0),
ambient_color,
diffuse_color,
specular_color,
mat_color;
float line_width(1.0);
back_color = ACG::GLState::default_clear_color;
base_color = ACG::GLState::default_base_color;
ambient_color = ACG::GLState::default_ambient_color;
diffuse_color = ACG::GLState::default_diffuse_color;
specular_color = ACG::GLState::default_specular_color;
line_width = 1.0;
PluginFunctions::setBackColor(back_color);
// Force an update of 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);
mat->set_ambient_color(ambient_color);
mat->set_diffuse_color(diffuse_color);
mat->set_specular_color(specular_color);
mat->set_line_width(line_width);
}
emit update_view();
}
void ColorPlugin::setPowerpointColor() {
emit scriptInfo( "setPowerpointColor()" );
emit showStatusMessage( "Set to Powerpoint Colors", 4000 );
OpenMesh::Vec4f back_color,
base_color=OpenMesh::Vec4f(0.0,0.0,0.0,0.0),
ambient_color,
diffuse_color,
specular_color,
mat_color;
float line_width(1.0);
back_color = OpenMesh::Vec4f(0.0, 0.188, 0.062, 1.0);
base_color = OpenMesh::Vec4f(0.88, 0.88, 0.188, 1.0);
mat_color = OpenMesh::Vec4f(0.941, 0.439, 0.31, 1.0);
ambient_color = 0.2f * mat_color;
diffuse_color = 0.6f * mat_color;
specular_color = 0.8f * mat_color;
line_width = 1.0;
PluginFunctions::setBackColor(back_color);
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);
mat->set_ambient_color(ambient_color);
mat->set_diffuse_color(diffuse_color);
mat->set_specular_color(specular_color);
mat->set_line_width(line_width);
}
emit update_view();
}
void ColorPlugin::setPaperColor() {
emit scriptInfo( "setPaperColor()" );
emit showStatusMessage( "Set to Paper Colors", 4000 );
OpenMesh::Vec4f back_color,
base_color=OpenMesh::Vec4f(0.0,0.0,0.0,0.0),
ambient_color,
diffuse_color,
specular_color,
mat_color;
float line_width(1.0);
back_color = OpenMesh::Vec4f(1.00, 1.00, 1.00, 1.0);
base_color = OpenMesh::Vec4f(0.00, 0.00, 0.00, 1.0);
mat_color = OpenMesh::Vec4f(0.12, 0.76, 0.62, 1.0);
ambient_color = 0.2f * mat_color;
diffuse_color = 0.5f * mat_color;
specular_color = 0.8f * mat_color;
line_width = 2.0;
PluginFunctions::setBackColor(back_color);
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);
mat->set_ambient_color(ambient_color);
mat->set_diffuse_color(diffuse_color);
mat->set_specular_color(specular_color);
mat->set_line_width(line_width);
}
emit update_view();
}
//-----------------------------------------------------------------------------
void ColorPlugin::setBackgroundColor( Vector _color ) {
ACG::Vec4f color;
color[0] = _color[0];
color[1] = _color[1];
color[2] = _color[2];
color[3] = 1.0;
PluginFunctions::setBackColor(color);
}
Q_EXPORT_PLUGIN2( colorplugin , ColorPlugin );
#ifndef COLORPLUGIN_HH
#define COLORPLUGIN_HH
#include <QObject>
#include <QMenuBar>
#include "ColorPlugin.hh"
#include <ACG/QtWidgets/QtExaminerViewer.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"
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)
signals:
void update_view();
void scriptInfo( QString _functionName );
void addMenu(QMenu* _menu, MenuType _type);
void addToolbar(QToolBar* _toolbar);
void removeToolbar(QToolBar* _toolbar);
void showStatusMessage(QString _message, int _timeout = 0);
private slots:
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")); };
public slots:
void setDefaultColor();
void setPowerpointColor();
void setPaperColor();
/// Set the Background Color
void setBackgroundColor( Vector _color );
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