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

Use ColorChooserButton fromACG

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12507 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 27506fee
......@@ -81,7 +81,10 @@ void QtColorChooserButton::init() {
void QtColorChooserButton::onClick() {
QColor newColor = QColorDialog::getColor(color_, this, "Pick Color", QColorDialog::ShowAlphaChannel);
if (newColor.isValid()) color_ = newColor;
if (newColor.isValid()) {
color_ = newColor;
emit colorChanged(color_);
}
}
void QtColorChooserButton::paintEvent(QPaintEvent *ev) {
......
......@@ -79,6 +79,9 @@ class QtColorChooserButton: public QPushButton {
public Q_SLOTS:
void onClick();
signals:
void colorChanged(QColor _newcolor );
private:
QColor color_;
};
......
......@@ -174,14 +174,14 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
connect( ui_.colorMaterial, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
connect( ui_.multiSampling, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
connect( ui_.baseColorButton, SIGNAL( clicked() ),
this, SLOT( changeBaseColor() ) );
connect( ui_.ambientColorButton, SIGNAL( clicked() ),
this, SLOT( changeAmbientColor() ) );
connect( ui_.diffuseColorButton, SIGNAL( clicked() ),
this, SLOT( changeDiffuseColor() ) );
connect( ui_.specularColorButton, SIGNAL( clicked() ),
this, SLOT( changeSpecularColor() ) );
connect( ui_.baseColorButton, SIGNAL( colorChanged(QColor) ),
this, SLOT( changeBaseColor(QColor) ) );
connect( ui_.ambientColorButton, SIGNAL( colorChanged(QColor) ),
this, SLOT( changeAmbientColor(QColor) ) );
connect( ui_.diffuseColorButton, SIGNAL( colorChanged(QColor) ),
this, SLOT( changeDiffuseColor(QColor) ) );
connect( ui_.specularColorButton, SIGNAL( colorChanged(QColor) ),
this, SLOT( changeSpecularColor(QColor) ) );
connect( ui_.shininessSlider, SIGNAL( sliderMoved(int) ),
this, SLOT( changeShine(int) ) );
......@@ -271,12 +271,10 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
void
QtMaterialDialog::setButtonColor( QPushButton * _button,
const Vec4f & _color )
QtMaterialDialog::setButtonColor( QtColorChooserButton* _button,
const Vec4f& _color )
{
QPalette p( _button->palette() );
p.setColor( QPalette::Button, convertColor( _color ) );
_button->setPalette( p );
_button->setColor( convertColor( _color ) );
}
......@@ -300,9 +298,9 @@ Vec4f
QtMaterialDialog::convertColor( QColor _color)
{
return Vec4f (_color.redF(),
_color.greenF(),
_color.blueF(),
_color.alphaF() );
_color.greenF(),
_color.blueF(),
_color.alphaF() );
}
......@@ -457,70 +455,41 @@ void QtMaterialDialog::undoChanges()
//-----------------------------------------------------------------------------
void QtMaterialDialog::changeDiffuseColor()
void QtMaterialDialog::changeDiffuseColor(QColor _newColor)
{
bool* ok = 0;
QColor newColor = QColor( QColorDialog::getRgba(convertColor(diffuse_).rgba(), ok, this));
if( newColor.isValid())
{
diffuse_ = convertColor( newColor );
applyChanges();
}
diffuse_ = convertColor( _newColor );
applyChanges();
}
//-----------------------------------------------------------------------------
void QtMaterialDialog::changeAmbientColor()
void QtMaterialDialog::changeAmbientColor(QColor _newColor)
{
bool* ok = 0;
QColor oldColor = convertColor(ambient_);
QColor newColor = QColorDialog::getColor(oldColor, this, "Ambient Color", QColorDialog::ShowAlphaChannel);
ambient_ = convertColor( _newColor );
applyChanges();
if( newColor.isValid())
{
ambient_ = convertColor( newColor );
applyChanges();
}
}
//-----------------------------------------------------------------------------
void QtMaterialDialog::changeSpecularColor()
void QtMaterialDialog::changeSpecularColor(QColor _newColor)
{
bool* ok = 0;
QColor newColor = QColor( QColorDialog::getRgba(convertColor(specular_).rgba(), ok, this));
if( newColor.isValid())
{
specular_ = convertColor( newColor );
applyChanges();
}
specular_ = convertColor( _newColor );
applyChanges();
}
//-----------------------------------------------------------------------------
void QtMaterialDialog::changeBaseColor()
void QtMaterialDialog::changeBaseColor(QColor _newColor)
{
bool* ok = 0;
QColor newColor = QColor( QColorDialog::getRgba(convertColor(color_).rgba(), ok, this));
if( newColor.isValid())
{
color_ = convertColor( newColor );
applyChanges();
}
color_ = convertColor( _newColor );
applyChanges();
}
......
......@@ -107,15 +107,15 @@ private:
QColor convertColor( Vec4f _color);
Vec4f convertColor( QColor _color);
void setButtonColor( QPushButton * _button,
const Vec4f & _color );
void setButtonColor( QtColorChooserButton* _button,
const Vec4f& _color );
private slots:
void changeBaseColor();
void changeAmbientColor();
void changeDiffuseColor();
void changeSpecularColor();
void changeBaseColor(QColor _newColor);
void changeAmbientColor(QColor _newColor);
void changeDiffuseColor(QColor _newColor);
void changeSpecularColor(QColor _newColor);
void changeShine(int _new);
void changePointSize(int _new);
void changeLineWidth(int _new);
......
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QtMaterialDialogUi</class>
<widget class="QWidget" name="QtMaterialDialogUi" >
<property name="geometry" >
<widget class="QWidget" name="QtMaterialDialogUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>621</width>
<width>623</width>
<height>663</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Edit Material</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3" >
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3" >
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title" >
<property name="title">
<string>Material</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<layout class="QGridLayout">
<property name="margin">
<number>9</number>
</property>
<property name="spacing" >
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="1" >
<spacer name="s4" >
<property name="orientation" >
<item row="0" column="1">
<spacer name="s4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
......@@ -52,12 +53,12 @@
</property>
</spacer>
</item>
<item row="1" column="0" >
<item row="1" column="0">
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
......@@ -65,131 +66,131 @@
</property>
</spacer>
</item>
<item row="1" column="1" >
<layout class="QGridLayout" name="l3" >
<property name="margin" >
<item row="1" column="1">
<layout class="QGridLayout" name="l3">
<property name="margin">
<number>0</number>
</property>
<property name="spacing" >
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="QLabel" name="label" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Minimum" >
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<property name="text">
<string>Base Color</string>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QSlider" name="shininessSlider" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
<item row="4" column="0">
<widget class="QSlider" name="shininessSlider">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLabel" name="label_4" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Minimum" >
<item row="3" column="1">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<property name="text">
<string>Specular Color</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QPushButton" name="specularColorButton" >
<property name="text" >
<item row="3" column="0">
<widget class="QtColorChooserButton" name="specularColorButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLabel" name="label_2" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Minimum" >
<item row="1" column="1">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<property name="text">
<string>Ambient Color</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QPushButton" name="diffuseColorButton" >
<property name="text" >
<item row="2" column="0">
<widget class="QtColorChooserButton" name="diffuseColorButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLabel" name="label_3" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Minimum" >
<item row="2" column="1">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<property name="text">
<string>Diffuse Color</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QPushButton" name="baseColorButton" >
<property name="text" >
<item row="0" column="0">
<widget class="QtColorChooserButton" name="baseColorButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QLabel" name="label_5" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Minimum" >
<item row="4" column="1">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<property name="text">
<string>Shininess</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QPushButton" name="ambientColorButton" >
<property name="text" >
<item row="1" column="0">
<widget class="QtColorChooserButton" name="ambientColorButton">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="1" >
<item row="2" column="1">
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
......@@ -197,12 +198,12 @@
</property>
</spacer>
</item>
<item row="1" column="2" >
<spacer name="s3" >
<property name="orientation" >
<item row="1" column="2">
<spacer name="s3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
......@@ -214,75 +215,75 @@
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title" >
<property name="title">
<string>Thickness</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<layout class="QGridLayout">
<property name="margin">
<number>9</number>
</property>
<property name="spacing" >
<property name="spacing">
<number>6</number>
</property>
<item row="1" column="1" >
<layout class="QVBoxLayout" >
<property name="spacing" >
<item row="1" column="1">
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin" >
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" >
<property name="margin" >
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing" >
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QSpinBox" name="pointSizeSpinBox" >
<property name="alignment" >
<item row="0" column="0">
<widget class="QSpinBox" name="pointSizeSpinBox">
<property name="alignment">
<set>Qt::AlignRight</set>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QSpinBox" name="lineWidthSpinBox" >
<property name="alignment" >
<item row="1" column="0">
<widget class="QSpinBox" name="lineWidthSpinBox">
<property name="alignment">
<set>Qt::AlignRight</set>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLabel" name="label_6" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
<item row="0" column="1">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<property name="text">
<string>Point Size</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLabel" name="label_7" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
<item row="1" column="1">
<widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<property name="text">
<string>Line Width</string>
</property>
</widget>
......@@ -290,33 +291,33 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="roundPointsCheckBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
<widget class="QCheckBox" name="roundPointsCheckBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<property name="text">
<string>Round Points</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="lineSmoothCheckBox" >
<property name="text" >
<widget class="QCheckBox" name="lineSmoothCheckBox">
<property name="text">
<string>Smooth Lines</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" >
<item row="1" column="0">
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
......@@ -324,12 +325,12 @@
</property>
</spacer>
</item>
<item row="1" column="2" >