Commit 75dbf467 authored by Dirk Wilden's avatar Dirk Wilden
Browse files

added defaultBaseColor / randomBaseColor options

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4368 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f9faedb2
...@@ -103,7 +103,6 @@ Core:: ...@@ -103,7 +103,6 @@ Core::
Core() : Core() :
QObject(), QObject(),
nextBackupId_(0), nextBackupId_(0),
set_random_base_color_(true),
coreWidget_(0) coreWidget_(0)
{ {
//init logFile //init logFile
......
...@@ -699,9 +699,6 @@ private: ...@@ -699,9 +699,6 @@ private:
/// Id for the next backup /// Id for the next backup
int nextBackupId_; int nextBackupId_;
/// Use white or a random color for new objects
bool set_random_base_color_;
/// Logger interfaces between plugins and core logger /// Logger interfaces between plugins and core logger
std::vector<PluginLogger*> loggers_; std::vector<PluginLogger*> loggers_;
......
...@@ -143,9 +143,9 @@ void Core::readApplicationOptions(INIFile& _ini) { ...@@ -143,9 +143,9 @@ void Core::readApplicationOptions(INIFile& _ini) {
//============================================================================ //============================================================================
// Load the random base color setting // Load the random base color setting
//============================================================================ //============================================================================
bool set_random_base_color = true; bool random_base_color = false;
if ( _ini.get_entry( set_random_base_color, "Options" , "SetRandomBaseColor") ) if ( _ini.get_entry( random_base_color, "Options" , "RandomBaseColor") )
set_random_base_color_ = set_random_base_color; OpenFlipper::Options::randomBaseColor( random_base_color );
//============================================================================ //============================================================================
// Load the backface culling setting // Load the backface culling setting
...@@ -218,12 +218,19 @@ void Core::readApplicationOptions(INIFile& _ini) { ...@@ -218,12 +218,19 @@ void Core::readApplicationOptions(INIFile& _ini) {
OpenFlipper::Options::fullScreen(fullScreen); OpenFlipper::Options::fullScreen(fullScreen);
//============================================================================ //============================================================================
// Load the setting for the fullscreen option // Load the setting for the background color option
//============================================================================ //============================================================================
uint backgroundColor = 0; uint backgroundColor = 0;
if ( _ini.get_entry( backgroundColor, "Options" , "DefaultBackgroundColor") ) if ( _ini.get_entry( backgroundColor, "Options" , "DefaultBackgroundColor") )
OpenFlipper::Options::defaultBackgroundColor(QRgb(backgroundColor)); OpenFlipper::Options::defaultBackgroundColor(QRgb(backgroundColor));
//============================================================================
// Load the setting for the object color option
//============================================================================
uint baseColor = 0;
if ( _ini.get_entry( baseColor, "Options" , "DefaultBaseColor") )
OpenFlipper::Options::defaultBaseColor(QRgb(baseColor));
//============================================================================ //============================================================================
// Load the setting for the default Toolbox mode // Load the setting for the default Toolbox mode
//============================================================================ //============================================================================
...@@ -415,7 +422,7 @@ void Core::writeApplicationOptions(INIFile& _ini) { ...@@ -415,7 +422,7 @@ void Core::writeApplicationOptions(INIFile& _ini) {
QString scriptDir = OpenFlipper::Options::currentScriptDirStr().toUtf8(); QString scriptDir = OpenFlipper::Options::currentScriptDirStr().toUtf8();
_ini.add_entry("Options","ScriptDir",scriptDir); _ini.add_entry("Options","ScriptDir",scriptDir);
_ini.add_entry("Options","SetRandomBaseColor",set_random_base_color_); _ini.add_entry("Options","RandomBaseColor", OpenFlipper::Options::randomBaseColor() );
if ( OpenFlipper::Options::gui() ) { if ( OpenFlipper::Options::gui() ) {
...@@ -445,6 +452,7 @@ void Core::writeApplicationOptions(INIFile& _ini) { ...@@ -445,6 +452,7 @@ void Core::writeApplicationOptions(INIFile& _ini) {
_ini.add_entry("Options","FullScreen", OpenFlipper::Options::fullScreen() ); _ini.add_entry("Options","FullScreen", OpenFlipper::Options::fullScreen() );
_ini.add_entry("Options","DefaultBackgroundColor", (uint)OpenFlipper::Options::defaultBackgroundColor().rgba () ); _ini.add_entry("Options","DefaultBackgroundColor", (uint)OpenFlipper::Options::defaultBackgroundColor().rgba () );
_ini.add_entry("Options","DefaultBaseColor", (uint)OpenFlipper::Options::defaultBaseColor().rgba () );
} }
_ini.add_entry("Options","Stereo",OpenFlipper::Options::stereo() ); _ini.add_entry("Options","Stereo",OpenFlipper::Options::stereo() );
......
...@@ -176,14 +176,27 @@ void Core::slotLoad(QString _filename, DataType _type, int& _id) { ...@@ -176,14 +176,27 @@ void Core::slotLoad(QString _filename, DataType _type, int& _id) {
/// Slot gets called after a file-plugin has opened an object /// Slot gets called after a file-plugin has opened an object
void Core::slotObjectOpened ( int _id ) { void Core::slotObjectOpened ( int _id ) {
///@todo Add Globaloption for setRandomBaseColor
// if ( set_random_base_color_ ) // get the opened object
// object->setBaseColor(ACG::Vec4f((float)(rand()%255)/255.0, BaseObjectData* object;
// (float)(rand()%255)/255.0, PluginFunctions::get_object(_id,object);
// (float)(rand()%255)/255.0,
// 1.0 )); if ( OpenFlipper::Options::randomBaseColor() )
// else object->setBaseColor(ACG::Vec4f((float)(rand()%255)/255.0,
// object->setBaseColor(ACG::Vec4f(255,255,255,1)); (float)(rand()%255)/255.0,
(float)(rand()%255)/255.0,
1.0 ));
else{
ACG::Vec4f color;
QColor defColor = OpenFlipper::Options::defaultBaseColor();
color[0] = defColor.redF();
color[1] = defColor.greenF();
color[2] = defColor.blueF();
color[3] = defColor.alphaF();
object->setBaseColor( color );
}
resetScenegraph(); resetScenegraph();
...@@ -195,10 +208,6 @@ void Core::slotLoad(QString _filename, DataType _type, int& _id) { ...@@ -195,10 +208,6 @@ void Core::slotLoad(QString _filename, DataType _type, int& _id) {
backupRequest(_id,"Original Object"); backupRequest(_id,"Original Object");
// get the opened object
BaseObjectData* object;
PluginFunctions::get_object(_id,object);
QString filename = object->path() + OpenFlipper::Options::dirSeparator() + object->name(); QString filename = object->path() + OpenFlipper::Options::dirSeparator() + object->name();
BaseObject* object2; BaseObject* object2;
......
...@@ -143,6 +143,12 @@ static bool splash_ = true; ...@@ -143,6 +143,12 @@ static bool splash_ = true;
/// default background color for the viewer /// default background color for the viewer
static QColor defaultBackgroundColor_ = QColor(0.0,0.0,0.0,0.0); static QColor defaultBackgroundColor_ = QColor(0.0,0.0,0.0,0.0);
/// default base color
static QColor defaultBaseColor_ = QColor(1.0,1.0,1.0,1.0);
/// use random base color
static bool randomBaseColor_ = false;
/// Scripting status /// Scripting status
static bool scripting_ = false; static bool scripting_ = false;
...@@ -574,6 +580,22 @@ QColor defaultBackgroundColor() { ...@@ -574,6 +580,22 @@ QColor defaultBackgroundColor() {
return defaultBackgroundColor_; return defaultBackgroundColor_;
} }
void defaultBaseColor( QColor _color ) {
defaultBaseColor_ = _color;
}
QColor defaultBaseColor() {
return defaultBaseColor_;
}
void randomBaseColor(bool _random) {
randomBaseColor_ = _random;
}
bool randomBaseColor() {
return randomBaseColor_;
}
/// return last used dataType /// return last used dataType
QString lastDataType(){ QString lastDataType(){
return lastDataType_; return lastDataType_;
......
...@@ -479,6 +479,22 @@ void fontsDir(QDir _dir); ...@@ -479,6 +479,22 @@ void fontsDir(QDir _dir);
DLLEXPORT DLLEXPORT
QColor defaultBackgroundColor(); QColor defaultBackgroundColor();
/// Default base color
DLLEXPORT
void defaultBaseColor( QColor _color );
/// Default base color
DLLEXPORT
QColor defaultBaseColor();
/// use randomized base color
DLLEXPORT
void randomBaseColor(bool _random);
/// use randomized base color
DLLEXPORT
bool randomBaseColor();
/** @} */ /** @} */
//=========================================================================== //===========================================================================
......
...@@ -98,6 +98,7 @@ OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyB ...@@ -98,6 +98,7 @@ OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyB
//colordialog //colordialog
connect(backgroundButton, SIGNAL(clicked()), this, SLOT(getBackgroundColor()) ); connect(backgroundButton, SIGNAL(clicked()), this, SLOT(getBackgroundColor()) );
connect(baseColorButton, SIGNAL(clicked()), this, SLOT(getBaseColor()) );
} }
void OptionsWidget::getBackgroundColor(){ void OptionsWidget::getBackgroundColor(){
...@@ -110,6 +111,16 @@ void OptionsWidget::getBackgroundColor(){ ...@@ -110,6 +111,16 @@ void OptionsWidget::getBackgroundColor(){
backgroundButton->setIcon( QIcon(color) ); backgroundButton->setIcon( QIcon(color) );
} }
void OptionsWidget::getBaseColor(){
QColor newColor = QColorDialog::getColor ( OpenFlipper::Options::defaultBaseColor() );
OpenFlipper::Options::defaultBaseColor( newColor) ;
QPixmap color(16,16);
color.fill( OpenFlipper::Options::defaultBaseColor() );
baseColorButton->setIcon( QIcon(color) );
}
void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) { void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
//general //general
...@@ -135,6 +146,11 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) { ...@@ -135,6 +146,11 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
color.fill( OpenFlipper::Options::defaultBackgroundColor() ); color.fill( OpenFlipper::Options::defaultBackgroundColor() );
backgroundButton->setIcon( QIcon(color) ); backgroundButton->setIcon( QIcon(color) );
color.fill( OpenFlipper::Options::defaultBaseColor() );
baseColorButton->setIcon( QIcon(color) );
randomBaseColor->setChecked( OpenFlipper::Options::randomBaseColor() );
// plugin options // plugin options
initPluginOptions(); initPluginOptions();
...@@ -360,6 +376,8 @@ void OptionsWidget::slotApply() { ...@@ -360,6 +376,8 @@ void OptionsWidget::slotApply() {
OpenFlipper::Options::restrictFrameRate( restrictFPS->isChecked() ); OpenFlipper::Options::restrictFrameRate( restrictFPS->isChecked() );
OpenFlipper::Options::maxFrameRate( FPS->value() ); OpenFlipper::Options::maxFrameRate( FPS->value() );
OpenFlipper::Options::randomBaseColor( randomBaseColor->isChecked() );
// updates // updates
OpenFlipper::Options::updateUrl( updateURL->text() ); OpenFlipper::Options::updateUrl( updateURL->text() );
OpenFlipper::Options::updateUsername( updateUser->text() ); OpenFlipper::Options::updateUsername( updateUser->text() );
......
...@@ -77,6 +77,7 @@ private slots: ...@@ -77,6 +77,7 @@ private slots:
/// open a dialog to determine the color /// open a dialog to determine the color
void getBackgroundColor(); void getBackgroundColor();
void getBaseColor();
/// keyBinding TreeWidget-Item changed /// keyBinding TreeWidget-Item changed
void keyTreeItemChanged( QTreeWidgetItem* current, QTreeWidgetItem* previous ); void keyTreeItemChanged( QTreeWidgetItem* current, QTreeWidgetItem* previous );
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>541</width> <width>541</width>
<height>763</height> <height>779</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<string/> <string/>
</property> </property>
<property name="currentIndex" > <property name="currentIndex" >
<number>3</number> <number>2</number>
</property> </property>
<property name="usesScrollButtons" > <property name="usesScrollButtons" >
<bool>true</bool> <bool>true</bool>
...@@ -362,6 +362,13 @@ You can select multiple modes at the same time.</string> ...@@ -362,6 +362,13 @@ You can select multiple modes at the same time.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="baseColorButton" >
<property name="text" >
<string>Default base color</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer_6" > <spacer name="horizontalSpacer_6" >
<property name="orientation" > <property name="orientation" >
...@@ -369,14 +376,21 @@ You can select multiple modes at the same time.</string> ...@@ -369,14 +376,21 @@ You can select multiple modes at the same time.</string>
</property> </property>
<property name="sizeHint" stdset="0" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>40</width> <width>168</width>
<height>20</height> <height>23</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QCheckBox" name="randomBaseColor" >
<property name="text" >
<string>use random base color</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
......
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