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

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