diff --git a/gui_qt/dialogcolorgradation.cpp b/gui_qt/dialogcolorgradation.cpp new file mode 100644 index 0000000..aeda5d4 --- /dev/null +++ b/gui_qt/dialogcolorgradation.cpp @@ -0,0 +1,121 @@ +#include "dialogcolorgradation.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include "baseform.h" + +/**************** Dialog form ****************/ +class FormColorGradation:public BaseForm +{ +public: + FormColorGradation(QWidget* parent, ColorGradation* gradation):BaseForm(parent, true, true) + { + _gradation = gradation; + + addInputDouble("Position", &_layer.start, 0.0, 1.0, 0.01, 0.1); + addInputColor("Color", &_layer.col); + + setLayerCount(gradation->nbparts); + } + + ~FormColorGradation() + { + } + + void layerAddedEvent() + { + /*if (cloudsAddLayer(&_definition) >= 0) + { + BaseForm::layerAddedEvent(); + }*/ + } + + void layerDeletedEvent(int layer) + { + /*cloudsDeleteLayer(&_definition, layer); + + BaseForm::layerDeletedEvent(layer);*/ + } + + void layerSelectedEvent(int layer) + { + _layer = _gradation->parts[layer]; + + BaseForm::layerSelectedEvent(layer); + } + +private: + ColorGradation* _gradation; + ColorGradationPart _layer; +}; + +/**************** Dialog ****************/ +DialogColorGradation::DialogColorGradation(QWidget *parent, ColorGradation* gradation): + QDialog(parent) +{ + QWidget* preview; + BaseForm* form; + + _base = gradation; + _current = colorGradationCreate(); + + setLayout(new QHBoxLayout()); + + preview = new QWidget(this); + layout()->addWidget(preview); + + form = new FormColorGradation(this, &_current); + layout()->addWidget(form); + + /*QObject::connect(button, SIGNAL(clicked()), this, SLOT(accept())); + QObject::connect(button, SIGNAL(clicked()), this, SLOT(revert())); + QObject::connect(button, SIGNAL(clicked()), this, SLOT(reject()));*/ + + setWindowTitle("Paysages 3D - Color gradation editor"); + + revert(); +} + +DialogColorGradation::~DialogColorGradation() +{ +} + +bool DialogColorGradation::getGradation(QWidget* parent, ColorGradation* gradation) +{ + int result; + + DialogColorGradation* dialog = new DialogColorGradation(parent, gradation); + result = dialog->exec(); + + delete dialog; + + return (result != 0) ? true : false; +} + +void DialogColorGradation::closeEvent(QCloseEvent* e) +{ + reject(); +} + +void DialogColorGradation::accept() +{ + *_base = _current; + QDialog::accept(); +} + +void DialogColorGradation::revert() +{ + _current = *_base; + + revertToCurrent(); +} + +void DialogColorGradation::revertToCurrent() +{ +} diff --git a/gui_qt/dialogcolorgradation.h b/gui_qt/dialogcolorgradation.h new file mode 100644 index 0000000..e66ea20 --- /dev/null +++ b/gui_qt/dialogcolorgradation.h @@ -0,0 +1,32 @@ +#ifndef _PAYSAGES_QT_DIALOGCOLORGRADATION_H_ +#define _PAYSAGES_QT_DIALOGCOLORGRADATION_H_ + +#include + +#include "../lib_paysages/color.h" + +class DialogColorGradation : public QDialog +{ + Q_OBJECT +public: + explicit DialogColorGradation(QWidget* parent, ColorGradation* gradation); + ~DialogColorGradation(); + + static bool getGradation(QWidget* parent, ColorGradation* gradation); + +public slots: + virtual void accept(); + void revert(); + +protected: + virtual void closeEvent(QCloseEvent* e); + +private: + void revertToCurrent(); + +private: + ColorGradation* _base; + ColorGradation _current; +}; + +#endif diff --git a/gui_qt/inputcolorgradation.cpp b/gui_qt/inputcolorgradation.cpp index 768a9a9..85e4a7c 100644 --- a/gui_qt/inputcolorgradation.cpp +++ b/gui_qt/inputcolorgradation.cpp @@ -4,7 +4,7 @@ #include #include #include - +#include "dialogcolorgradation.h" #include "tools.h" class ColorGradationPreview:public QWidget @@ -53,10 +53,6 @@ void InputColorGradation::updatePreview() void InputColorGradation::applyValue() { - /*_value->r = ((ColorPreview*)_preview)->col.redF(); - _value->g = ((ColorPreview*)_preview)->col.greenF(); - _value->b = ((ColorPreview*)_preview)->col.blueF(); - _value->a = 1.0;*/ BaseInput::applyValue(); } @@ -67,10 +63,12 @@ void InputColorGradation::revert() void InputColorGradation::editGradation() { - /*QColor col = QColorDialog::getColor(((ColorPreview*)_preview)->col, _control); - if (col.isValid()) + ColorGradation gradation; + + gradation = *_value; + if (DialogColorGradation::getGradation(_preview, &gradation)) { - ((ColorPreview*)_preview)->col = col; + *_value = gradation; applyValue(); - }*/ + } } diff --git a/gui_qt/mainwindow.cpp b/gui_qt/mainwindow.cpp index 071f78e..0c64275 100644 --- a/gui_qt/mainwindow.cpp +++ b/gui_qt/mainwindow.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -95,6 +96,7 @@ MainWindow::MainWindow(QWidget *parent) : setCentralWidget(tabs); setWindowTitle("Paysages 3D"); + setWindowIcon(QIcon("images/logo_32.png")); } void MainWindow::refreshAll() diff --git a/images/logo.svg b/images/logo.svg new file mode 100644 index 0000000..23a0634 --- /dev/null +++ b/images/logo.svg @@ -0,0 +1,277 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + P + 3D + + + + + diff --git a/images/logo_16.png b/images/logo_16.png new file mode 100644 index 0000000..4ef9d48 Binary files /dev/null and b/images/logo_16.png differ diff --git a/images/logo_256.png b/images/logo_256.png new file mode 100644 index 0000000..e2f20d6 Binary files /dev/null and b/images/logo_256.png differ diff --git a/images/logo_32.png b/images/logo_32.png new file mode 100644 index 0000000..233e557 Binary files /dev/null and b/images/logo_32.png differ diff --git a/images/logo_64.png b/images/logo_64.png new file mode 100644 index 0000000..d732bba Binary files /dev/null and b/images/logo_64.png differ diff --git a/lib_paysages/clouds.c b/lib_paysages/clouds.c index dee1f54..658a7e5 100644 --- a/lib_paysages/clouds.c +++ b/lib_paysages/clouds.c @@ -162,7 +162,7 @@ CloudsLayerDefinition cloudsLayerCreateDefinition() result.material.shininess = 2.0; result.transparencydepth = 20.0; result.lighttraversal = 50.0; - result.minimumlight = 0.8; + result.minimumlight = 0.5; result.scaling = 50.0; result.coverage = 0.5; result.noise = noiseCreateGenerator(); diff --git a/lib_paysages/color.c b/lib_paysages/color.c index cef8725..b2360b8 100644 --- a/lib_paysages/color.c +++ b/lib_paysages/color.c @@ -112,7 +112,7 @@ ColorGradation colorGradationCreate() int _part_compare(const void* part1, const void* part2) { - if (((_ColorGradationPart*)part1)->start > ((_ColorGradationPart*)part2)->start) + if (((ColorGradationPart*)part1)->start > ((ColorGradationPart*)part2)->start) { return 1; } @@ -159,7 +159,7 @@ void colorGradationAdd(ColorGradation* gradation, double value, Color* col) if (gradation->nbparts++ > 1) { - qsort(gradation->parts, gradation->nbparts, sizeof(_ColorGradationPart), _part_compare); + qsort(gradation->parts, gradation->nbparts, sizeof(ColorGradationPart), _part_compare); } } } diff --git a/lib_paysages/shared/types.h b/lib_paysages/shared/types.h index ca9a8e3..6b9aafb 100644 --- a/lib_paysages/shared/types.h +++ b/lib_paysages/shared/types.h @@ -47,11 +47,11 @@ typedef struct { double start; Color col; -} _ColorGradationPart; +} ColorGradationPart; typedef struct { int nbparts; - _ColorGradationPart parts[MAX_COLORGRADATION_PARTS]; + ColorGradationPart parts[MAX_COLORGRADATION_PARTS]; } ColorGradation; struct RenderFragment;