[opengtl-commits] [520] initial import of libQtGTL

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 520
Author:   cyrille
Date:     2008-12-07 22:55:58 +0100 (Sun, 07 Dec 2008)

Log Message:
-----------
initial import of libQtGTL

Added Paths:
-----------
    trunk/libQtGTL/CMakeLists.txt
    trunk/libQtGTL/ColorConversions_p.cpp
    trunk/libQtGTL/ColorConversions_p.h
    trunk/libQtGTL/ParametersWidget.cpp
    trunk/libQtGTL/ParametersWidget.h
    trunk/libQtGTL/ParametersWidget_p.cpp
    trunk/libQtGTL/ParametersWidget_p.h
    trunk/libQtGTL/RgbaDialog_p.cpp
    trunk/libQtGTL/RgbaDialog_p.h
    trunk/libQtGTL/SpinBoxSliderConnector_p.cpp
    trunk/libQtGTL/SpinBoxSliderConnector_p.h
    trunk/libQtGTL/TriangleColorSelector_p.cpp
    trunk/libQtGTL/TriangleColorSelector_p.h
    trunk/libQtGTL/UiRgbaDialog.ui
    trunk/libQtGTL/cmake/
    trunk/libQtGTL/cmake/modules/
    trunk/libQtGTL/cmake/modules/FindOpenShiva.cmake

Property Changed:
----------------
    trunk/libQtGTL/


Property changes on: trunk/libQtGTL
___________________________________________________________________
Name: svn:ignore
   + libQtGTL.kdevses
libQtGTL.kdevelop.pcs
libQtGTL.kdevelop.filelist
libQtGTL.kdevelop


Added: trunk/libQtGTL/CMakeLists.txt
===================================================================
--- trunk/libQtGTL/CMakeLists.txt	                        (rev 0)
+++ trunk/libQtGTL/CMakeLists.txt	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,32 @@
+set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
+
+find_package(OpenShiva REQUIRED)
+find_package(Qt4 REQUIRED)
+
+include_directories(${QT_QTGUI_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${OPENSHIVA_INCLUDE_DIR})
+
+set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/)
+
+cmake_minimum_required(VERSION 2.6)
+
+############################### libQtGTL ###############################
+
+set(libQtGTL_SRCS
+  ParametersWidget.cpp
+# Private
+  ColorConversions_p.cpp
+  ParametersWidget_p.cpp
+  SpinBoxSliderConnector_p.cpp
+  TriangleColorSelector_p.cpp
+  RgbaDialog_p.cpp
+  )
+
+qt4_wrap_ui(libQtGTL_SRCS UiRgbaDialog.ui)
+
+qt4_automoc(${libQtGTL_SRCS})
+
+add_library(libQtGTL SHARED ${libQtGTL_SRCS})
+target_link_libraries(libQtGTL ${QT_QTGUI_LIBRARY} ${OPENSHIVA_LIBRARIES} )
+
+install(TARGETS libQtGTL DESTINATION ${LIB_INSTALL_DIR} )
+install( FILES ParametersWidget.h DESTINATION ${INCLUDE_INSTALL_DIR}/QtGTL )

Added: trunk/libQtGTL/ColorConversions_p.cpp
===================================================================
--- trunk/libQtGTL/ColorConversions_p.cpp	                        (rev 0)
+++ trunk/libQtGTL/ColorConversions_p.cpp	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,423 @@
+/*
+ *  Copyright (c) 2005 Boudewijn Rempt <boud@xxxxxxxxxxx>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser General Public License as published
+ *  by the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <cmath>
+
+#include <qglobal.h>
+
+#include "ColorConversions_p.h"
+
+/**
+ * A number of often-used conversions between color models
+ */
+
+void rgb_to_hsv(int R, int G, int B, int *H, int *S, int *V)
+{
+    unsigned int max = R;
+    unsigned int min = R;
+    unsigned char maxValue = 0; // r = 0, g = 1, b = 2
+
+    // find maximum and minimum RGB values
+    if(static_cast<unsigned int>(G) > max) {
+        max = G;
+        maxValue = 1;
+    }
+    
+    if (static_cast<unsigned int>(B) > max)
+    {
+        max = B;
+        maxValue = 2;
+    }
+
+    if(static_cast<unsigned int>(G) < min)
+        min = G;
+        
+    if(static_cast<unsigned int>(B) < min )
+        min = B;
+
+    int delta = max - min;
+    *V = max; // value
+    *S = max ? (510 * delta + max) / ( 2 * max) : 0; // saturation
+    
+    // calc hue
+    if(*S == 0)
+        *H = -1; // undefined hue
+    else
+    {
+        switch(maxValue)
+        {
+        case 0:  // red
+            if(G >= B)
+                *H = (120 * (G - B) + delta) / (2 * delta);
+            else
+                *H = (120 * (G - B + delta) + delta) / (2 * delta) + 300;
+            break;
+        case 1:  // green
+            if(B > R)
+                *H = 120 + (120 * (B - R) + delta) / (2 * delta);
+            else
+                *H = 60 + (120 * (B - R + delta) + delta) / (2 * delta);
+            break;
+        case 2:  // blue
+            if(R > G)
+                *H = 240 + (120 * (R - G) + delta) / (2 * delta);
+            else
+                *H = 180 + (120 * (R - G + delta) + delta) / (2 * delta);
+            break;
+        }
+    }
+}
+
+void hsv_to_rgb(int H, int S, int V, int *R, int *G, int *B)
+{
+    *R = *G = *B = V;
+
+    if (S != 0 && H != -1) { // chromatic
+
+        if (H >= 360) {
+            // angle > 360
+            H %= 360;
+        }
+
+        unsigned int f = H % 60;
+        H /= 60;
+        unsigned int p = static_cast<unsigned int>(2*V*(255-S)+255)/510;
+        unsigned int q, t;
+
+        if (H & 1) {
+            q = static_cast<unsigned int>(2 * V * (15300 - S * f) + 15300) / 30600;
+            switch (H) {
+            case 1:
+                *R = static_cast<int>(q);
+                *G = static_cast<int>(V);
+                *B = static_cast<int>(p);
+                break;
+            case 3:
+                *R = static_cast<int>(p);
+                *G = static_cast<int>(q);
+                *B = static_cast<int>(V);
+                break;
+            case 5:
+                *R = static_cast<int>(V);
+                *G = static_cast<int>(p);
+                *B = static_cast<int>(q);
+                break;
+            }
+        } else {
+            t = static_cast<unsigned int>(2 * V * (15300 - (S * (60 - f))) + 15300) / 30600;
+            switch (H) {
+            case 0:
+                *R = static_cast<int>(V);
+                *G = static_cast<int>(t);
+                *B = static_cast<int>(p);
+                break;
+            case 2:
+                *R = static_cast<int>(p);
+                *G = static_cast<int>(V);
+                *B = static_cast<int>(t);
+                break;
+            case 4:
+                *R = static_cast<int>(t);
+                *G = static_cast<int>(p);
+                *B = static_cast<int>(V);
+                break;
+            }
+        }
+    }
+}
+
+#define EPSILON 1e-6
+#define UNDEFINED_HUE -1
+
+void RGBToHSV(float r, float g, float b, float *h, float *s, float *v)
+{
+    float max = qMax(r, qMax(g, b));
+    float min = qMin(r, qMin(g, b));
+
+    *v = max;
+
+    if (max > EPSILON) {
+        *s = (max - min) / max;
+    } else {
+        *s = 0;
+    }
+
+    if (*s < EPSILON) {
+        *h = UNDEFINED_HUE;
+    } else {
+        float delta = max - min;
+
+        if (r == max) {
+            *h = (g - b) / delta;
+        } else if (g == max) {
+            *h = 2 + (b - r) / delta;
+        } else {
+            *h = 4 + (r - g) / delta;
+        }
+
+        *h *= 60;
+        if (*h < 0) {
+            *h += 360;
+        }
+    }
+}
+
+void HSVToRGB(float h, float s, float v, float *r, float *g, float *b)
+{
+    if (s < EPSILON || h == UNDEFINED_HUE) {
+        // Achromatic case
+
+        *r = v;
+        *g = v;
+        *b = v;
+    } else {
+        float f, p, q, t;
+        int i;
+
+        if (h > 360 - EPSILON) {
+            h -= 360;
+        }
+
+        h /= 60;
+        i = static_cast<int>(floor(h));
+        f = h - i;
+        p = v * (1 - s);
+        q = v * (1 - (s * f));
+        t = v * (1 - (s * (1 - f)));
+
+        switch (i) {
+        case 0:
+            *r = v;
+            *g = t;
+            *b = p;
+            break;
+        case 1:
+            *r = q;
+            *g = v;
+            *b = p;
+            break;
+        case 2:
+            *r = p;
+            *g = v;
+            *b = t;
+            break;
+        case 3:
+            *r = p;
+            *g = q;
+            *b = v;
+            break;
+        case 4:
+            *r = t;
+            *g = p;
+            *b = v;
+            break;
+        case 5:
+            *r = v;
+            *g = p;
+            *b = q;
+            break;
+        }
+    }
+}
+
+void rgb_to_hls(quint8 red, quint8 green, quint8 blue, float * hue, float * lightness, float * saturation)
+{
+    float r = red / 255.0;
+    float g = green / 255.0;
+    float b = blue / 255.0;
+    float h = 0;
+    float l = 0;
+    float s = 0;
+
+    float max, min, delta;
+
+    max = qMax(r, g);
+    max = qMax(max, b);
+    
+    min = qMin(r, g);
+    min = qMin(min, b);
+
+    delta = max - min;
+
+    l = (max + min) / 2;
+
+    if (delta == 0) {
+        // This is a gray, no chroma...
+        h = 0;
+        s = 0;
+    }
+    else {
+        if ( l < 0.5)
+            s = delta / ( max + min );
+        else
+            s = delta / ( 2 - max - min );
+
+        float delta_r, delta_g, delta_b;
+
+        delta_r = (( max - r ) / 6 ) / delta;
+        delta_g = (( max - g ) / 6 ) / delta;
+        delta_b = (( max - b ) / 6 ) / delta;
+
+        if ( r == max )
+            h = delta_b - delta_g;
+        else if ( g == max)
+            h = ( 1.0 / 3 ) + delta_r - delta_b;
+        else if ( b == max)
+            h = ( 2.0 / 3 ) + delta_g - delta_r;
+
+        if (h < 0) h += 1;
+        if (h > 1) h += 1;
+        
+    }
+
+    *hue = h * 360;
+    *saturation = s;
+    *lightness = l;
+}
+
+float hue_value(float n1, float n2, float hue)
+{
+    if (hue > 360 )
+        hue = hue -360;
+    else if (hue < 0 )
+        hue = hue +360;
+    if (hue < 60  )
+        return n1 + (((n2 - n1) * hue) / 60);
+    else if (hue < 180 )
+        return n2;
+    else if (hue < 240 )
+        return n1 + (((n2 - n1) * (240 - hue)) / 60);
+    else return n1;
+}
+
+
+void hls_to_rgb(float h, float l, float s, quint8 * r, quint8 * g, quint8 * b)
+{
+    float m1, m2;
+
+    if (l <= 0.5 )
+        m2 = l * ( 1 + s );
+    else 
+        m2 = l + s - l * s;
+
+    m1 = 2 * l - m2;
+    
+    *r = (quint8)(hue_value(m1, m2, h + 120) * 255 + 0.5);
+    *g = (quint8)(hue_value(m1, m2, h) * 255 + 0.5);
+    *b = (quint8)(hue_value(m1, m2, h - 120) * 255 + 0.5);
+
+}
+
+void rgb_to_hls(quint8 r, quint8 g, quint8 b, int * h, int * l, int * s)
+{
+    float hue, saturation, lightness;
+
+    rgb_to_hls(r, g, b, &hue, &lightness, &saturation);
+    *h = (int)(hue + 0.5);
+    *l = (int)(lightness * 255 + 0.5);
+    *s = (int)(saturation * 255 + 0.5);
+}
+
+void hls_to_rgb(int h, int l, int s, quint8 * r, quint8 * g, quint8 * b)
+{
+    float hue = h;
+    float lightness = l / 255.0;
+    float saturation = s / 255.0;
+
+    hls_to_rgb(hue, lightness, saturation, r, g, b);
+}
+
+/*
+A Fast HSL-to-RGB Transform
+by Ken Fishkin
+from "Graphics Gems", Academic Press, 1990
+*/
+
+void RGBToHSL(float r, float g, float b, float *h, float *s, float *l)
+{
+    float v;
+    float m;
+    float vm;
+    float r2, g2, b2;
+
+    v = qMax(r,g);
+    v = qMax(v,b);
+    m = qMin(r,g);
+    m = qMin(m,b);
+
+    if ((*l = (m + v) / 2.0) <= 0.0) {
+        *h = UNDEFINED_HUE;
+        *s = 0;
+        return;
+    }
+    if ((*s = vm = v - m) > 0.0) {
+        *s /= (*l <= 0.5) ? (v + m ) :
+              (2.0 - v - m) ;
+    } else {
+        *h = UNDEFINED_HUE;
+        return;
+    }
+
+
+    r2 = (v - r) / vm;
+    g2 = (v - g) / vm;
+    b2 = (v - b) / vm;
+
+    if (r == v)
+        *h = (g == m ? 5.0 + b2 : 1.0 - g2);
+    else if (g == v)
+        *h = (b == m ? 1.0 + r2 : 3.0 - b2);
+    else
+        *h = (r == m ? 3.0 + g2 : 5.0 - r2);
+
+    *h *= 60;
+}
+
+void HSLToRGB(float h, float sl, float l, float *r, float *g, float *b)
+
+{
+    float v;
+
+    v = (l <= 0.5) ? (l * (1.0 + sl)) : (l + sl - l * sl);
+    if (v <= 0) {
+        *r = *g = *b = 0.0;
+    } else {
+        float m;
+        float sv;
+        int sextant;
+        float fract, vsf, mid1, mid2;
+
+        m = l + l - v;
+        sv = (v - m ) / v;
+        h /= 60.0;
+        sextant = static_cast<int>(h);    
+        fract = h - sextant;
+        vsf = v * sv * fract;
+        mid1 = m + vsf;
+        mid2 = v - vsf;
+        switch (sextant) {
+        case 0: *r = v; *g = mid1; *b = m; break;
+        case 1: *r = mid2; *g = v; *b = m; break;
+        case 2: *r = m; *g = v; *b = mid1; break;
+        case 3: *r = m; *g = mid2; *b = v; break;
+        case 4: *r = mid1; *g = m; *b = v; break;
+        case 5: *r = v; *g = m; *b = mid2; break;
+        }
+    }
+}
+


Property changes on: trunk/libQtGTL/ColorConversions_p.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/libQtGTL/ColorConversions_p.h
===================================================================
--- trunk/libQtGTL/ColorConversions_p.h	                        (rev 0)
+++ trunk/libQtGTL/ColorConversions_p.h	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,49 @@
+/*
+ *  Copyright (c) 2005 Boudewijn Rempt <boud@xxxxxxxxxxx>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser General Public License as published
+ *  by the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _KIS_CONVERSIONS_H_
+#define _KIS_CONVERSIONS_H_
+
+#include <qglobal.h>
+
+/**
+ * A number of often-used conversions between color models
+ */
+
+// 8-bit integer versions. RGBSL are 0-255, H is 0-360.
+ void rgb_to_hsv(int R, int G, int B, int *H, int *S, int *V);
+ void hsv_to_rgb(int H, int S, int V, int *R, int *G, int *B);
+
+// Floating point versions. RGBSL are 0-1, H is 0-360.
+ void RGBToHSV(float r, float g, float b, float *h, float *s, float *v);
+ void HSVToRGB(float h, float s, float v, float *r, float *g, float *b);
+
+ void RGBToHSL(float r, float g, float b, float *h, float *s, float *l);
+ void HSLToRGB(float h, float sl, float l, float *r, float *g, float *b);
+
+ void rgb_to_hls(quint8 r, quint8 g, quint8 b, float * h, float * l, float * s);
+
+ float hue_value(float n1, float n2, float hue);
+
+ void hls_to_rgb(float h, float l, float s, quint8 * r, quint8 * g, quint8 * b);
+
+ void rgb_to_hls(quint8 r, quint8 g, quint8 b, int * h, int * l, int * s);
+ void hls_to_rgb(int h, int l, int s, quint8 * r, quint8 * g, quint8 * b);
+
+#endif // _KIS_CONVERSIONS_H_
+


Property changes on: trunk/libQtGTL/ColorConversions_p.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/libQtGTL/ParametersWidget.cpp
===================================================================
--- trunk/libQtGTL/ParametersWidget.cpp	                        (rev 0)
+++ trunk/libQtGTL/ParametersWidget.cpp	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,42 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the license.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "ParametersWidget.h"
+
+
+#include "ParametersWidget_p.h"
+
+using namespace QtGTL;
+
+ParametersWidget::ParametersWidget( QWidget* _parent ) : QWidget( _parent ), d(new Private)
+{
+  d->kernel = 0;
+  d->self = this;
+}
+
+ParametersWidget::~ParametersWidget()
+{
+  delete d;
+}
+
+void ParametersWidget::setKernel( OpenShiva::Kernel* _kernel )
+{
+  d->kernel = _kernel;
+  d->regenerateWidget();
+}


Property changes on: trunk/libQtGTL/ParametersWidget.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/libQtGTL/ParametersWidget.h
===================================================================
--- trunk/libQtGTL/ParametersWidget.h	                        (rev 0)
+++ trunk/libQtGTL/ParametersWidget.h	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,42 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the license.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _QTGTL_PARAMETERS_WIDGET_H_
+#define _QTGTL_PARAMETERS_WIDGET_H_
+
+#include <QWidget>
+
+namespace OpenShiva {
+  class Kernel;
+};
+
+namespace QtGTL {
+  class ParametersWidget : public QWidget {
+    public:
+      ParametersWidget( QWidget* );
+      ~ParametersWidget();
+    public:
+      void setKernel( OpenShiva::Kernel* _kernel );
+    private:
+      struct Private;
+      Private* const d;
+  };
+}
+
+#endif


Property changes on: trunk/libQtGTL/ParametersWidget.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/libQtGTL/ParametersWidget_p.cpp
===================================================================
--- trunk/libQtGTL/ParametersWidget_p.cpp	                        (rev 0)
+++ trunk/libQtGTL/ParametersWidget_p.cpp	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,172 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the license.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "ParametersWidget_p.h"
+
+#include <OpenShiva/Kernel.h>
+#include <OpenShiva/KernelMetadata.h>
+#include <GTLCore/Value.h>
+#include <GTLCore/Metadata/Entry.h>
+#include <GTLCore/Metadata/Group.h>
+#include <GTLCore/Metadata/ParameterEntry.h>
+
+#include <QDoubleSpinBox>
+#include <QGridLayout>
+#include <QLabel>
+#include <QTabWidget>
+#include <QSlider>
+
+#include "SpinBoxSliderConnector_p.h"
+
+using namespace QtGTL;
+
+void ParametersWidget::Private::regenerateWidget()
+{
+  delete currentWidget;
+  
+  if( kernel->metadata() and kernel->metadata()->parameters() )
+  {
+    const GTLCore::Metadata::Group* parameters = kernel->metadata()->parameters();
+    // Is tabWidget ?
+    QTabWidget* tabWidget = 0;
+    QWidget* widget = new QWidget();
+    foreach( const GTLCore::Metadata::Entry* entry, parameters->entries() )
+    {
+      if( entry->asGroup() and not entry->asParameterEntry() )
+      {
+        if(not tabWidget )
+        {
+          tabWidget = new QTabWidget( self );
+          widget = new QWidget( );
+          tabWidget->addTab( widget, kernel->name().c_str() );
+        }
+        break;
+      }
+    }
+    // Set the currentWidget
+    if( tabWidget )
+    {
+      currentWidget = tabWidget;
+    } else {
+      currentWidget = widget;
+    }
+    
+    // Create widgets
+    QGridLayout* widgetGridLayout = new QGridLayout(widget);
+    int posInGrid = 0;
+    foreach( const GTLCore::Metadata::Entry* entry, parameters->entries() )
+    {
+      if( const GTLCore::Metadata::ParameterEntry* pe = entry->asParameterEntry() )
+      {
+        createParameterEntryWidget( widget, widgetGridLayout, posInGrid, pe );
+        ++posInGrid;
+      } else if( const GTLCore::Metadata::Group* gr = entry->asGroup() )
+      {
+        Q_ASSERT( tabWidget );
+        QWidget* groupWidget = new QWidget( );
+        QGridLayout* groupWidgetGridLayout = new QGridLayout(groupWidget);
+        int groupPosInGrid = 0;
+        foreach( const GTLCore::Metadata::Entry* groupEntry, gr->entries() )
+        {
+          if( const GTLCore::Metadata::ParameterEntry* gpe = entry->asParameterEntry() )
+          {
+            createParameterEntryWidget( groupWidget, groupWidgetGridLayout, groupPosInGrid, gpe );
+            ++groupPosInGrid;
+          }
+        }
+        tabWidget->addTab( groupWidget, gr->name().c_str() );
+      }
+    }
+    
+  } else {
+    currentWidget = new QLabel( QObject::tr( "No configuration" ), self );
+  }
+  
+}
+
+void ParametersWidget::Private::createParameterEntryWidget( QWidget* _parent, QGridLayout* _gridLayout, int _layoutIndex, const GTLCore::Metadata::ParameterEntry* _parameterEntry )
+{
+  // Label
+  QLabel* label = new QLabel( _parameterEntry->name().c_str(), _parent);
+  _gridLayout->addWidget(label, _layoutIndex, 0, 1, 1);
+  switch( _parameterEntry->widgetType() )
+  {
+    case GTLCore::Metadata::ParameterEntry::IntegerWidget:
+    {
+      // Integer spinbox
+      QSpinBox* spinBox = new QSpinBox(_parent);
+      _gridLayout->addWidget(spinBox, _layoutIndex, 1, 1, 1);
+      
+      // Slider
+      QSlider* horizontalSlider = new QSlider(_parent);
+      horizontalSlider->setOrientation(Qt::Horizontal);
+      _gridLayout->addWidget(horizontalSlider, _layoutIndex, 2, 1, 1);
+      
+      connect( spinBox, SIGNAL(valueChanged(int)), horizontalSlider, SLOT(setValue(int)));
+      connect( horizontalSlider, SIGNAL(valueChanged(int)), spinBox, SLOT(setValue(int)));
+      
+      int min = _parameterEntry->minimumValue().asInt32();
+      int max = _parameterEntry->maximumValue().asInt32();
+      int val = _parameterEntry->defaultValue().asInt32();
+      spinBox->setMinimum( min );
+      spinBox->setMaximum( max );
+      spinBox->setValue( val );
+      horizontalSlider->setMinimum( min );
+      horizontalSlider->setMaximum( max );
+      horizontalSlider->setValue( val );
+    }
+      break;
+    case GTLCore::Metadata::ParameterEntry::FloatWidget:
+    {
+      
+      // Double spinbox
+      QDoubleSpinBox* doubleSpinBox = new QDoubleSpinBox(_parent);
+      _gridLayout->addWidget(doubleSpinBox, _layoutIndex, 1, 1, 1);
+      
+      // Slider
+      QSlider* horizontalSlider = new QSlider(_parent);
+      horizontalSlider->setOrientation(Qt::Horizontal);
+      _gridLayout->addWidget(horizontalSlider, _layoutIndex, 2, 1, 1);
+      horizontalSlider->setMinimum( 0 );
+      horizontalSlider->setMaximum( 1000 );
+      
+      SpinBoxSliderConnector* connector = new SpinBoxSliderConnector( _parent, doubleSpinBox, horizontalSlider);
+      connect( connector, SIGNAL(valueChanged(double)), this, SLOT(updateKernelParameters()));
+      
+      // Set parameters
+      doubleSpinBox->setMinimum( _parameterEntry->minimumValue().asFloat() );
+      doubleSpinBox->setMaximum( _parameterEntry->maximumValue().asFloat() );
+      doubleSpinBox->setValue( _parameterEntry->defaultValue().asFloat() );
+    }
+      break;
+    case GTLCore::Metadata::ParameterEntry::CurveWidget:
+      
+      break;
+    case GTLCore::Metadata::ParameterEntry::RgbColorWidget:
+      
+      break;
+  }
+}
+
+void ParametersWidget::Private::updateKernelParameters()
+{
+}
+
+
+#include "ParametersWidget_p.moc"


Property changes on: trunk/libQtGTL/ParametersWidget_p.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/libQtGTL/ParametersWidget_p.h
===================================================================
--- trunk/libQtGTL/ParametersWidget_p.h	                        (rev 0)
+++ trunk/libQtGTL/ParametersWidget_p.h	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,50 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the license.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "ParametersWidget.h"
+
+#ifndef _QTGTL_PARAMETERS_WIDGET_P_H_
+#define _QTGTL_PARAMETERS_WIDGET_P_H_
+
+class QGridLayout;
+
+namespace GTLCore {
+  namespace Metadata {
+    class ParameterEntry;
+  }
+}
+
+namespace QtGTL {
+  class ParametersWidget::Private : public QObject {
+      Q_OBJECT
+    public:
+      Private() : kernel(0), self(0), currentWidget(0) {}
+      OpenShiva::Kernel* kernel;
+      QWidget* self;
+      QWidget* currentWidget;
+      // Functions
+      void regenerateWidget();
+    private slots:
+      void updateKernelParameters();
+    private:
+      void createParameterEntryWidget( QWidget* _parent, QGridLayout* _gridLayout, int _layoutIndex, const GTLCore::Metadata::ParameterEntry* _parameterEntry );
+  };
+}
+
+#endif


Property changes on: trunk/libQtGTL/ParametersWidget_p.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/libQtGTL/RgbaDialog_p.cpp
===================================================================
--- trunk/libQtGTL/RgbaDialog_p.cpp	                        (rev 0)
+++ trunk/libQtGTL/RgbaDialog_p.cpp	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,60 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the license.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "RgbaDialog_p.h"
+
+#include "SpinBoxSliderConnector_p.h"
+
+#include "ui_UiRgbaDialog.h"
+
+using namespace QtGTL;
+
+RgbaDialog::RgbaDialog( QWidget* _widget ) : QDialog(_widget), m_rgbaDialog( new Ui_RgbaDialog )
+{
+  m_rgbaDialog->setupUi( this );
+  
+  m_connectors[0] = new SpinBoxSliderConnector( this, m_rgbaDialog->doubleSpinBoxRed, m_rgbaDialog->sliderRed );
+  connect( m_connectors[0], SIGNAL(valueChanged(double)), SLOT(spinBoxesValuesChanged()));
+  m_connectors[1] = new SpinBoxSliderConnector( this, m_rgbaDialog->doubleSpinBoxGreen, m_rgbaDialog->sliderGreen );
+  connect( m_connectors[1], SIGNAL(valueChanged(double)), SLOT(spinBoxesValuesChanged()));
+  m_connectors[2] = new SpinBoxSliderConnector( this, m_rgbaDialog->doubleSpinBoxBlue, m_rgbaDialog->sliderBlue );
+  connect( m_connectors[2], SIGNAL(valueChanged(double)), SLOT(spinBoxesValuesChanged()));
+}
+
+RgbaDialog::~RgbaDialog()
+{
+}
+
+QColor RgbaDialog::color()
+{
+  QColor c = m_rgbaDialog->triangleSelector->color();
+  c.setAlpha( m_rgbaDialog->doubleSpinBoxAlpha->value() * 255 );
+  return c;
+}
+
+void RgbaDialog::triangleColorChanged( const QColor& c)
+{
+  m_connectors[0]->setValue( c.red() / 255.0 );
+  m_connectors[1]->setValue( c.green() / 255.0 );
+  m_connectors[2]->setValue( c.blue() / 255.0 );
+}
+void RgbaDialog::spinBoxesValuesChanged()
+{
+  
+}


Property changes on: trunk/libQtGTL/RgbaDialog_p.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/libQtGTL/RgbaDialog_p.h
===================================================================
--- trunk/libQtGTL/RgbaDialog_p.h	                        (rev 0)
+++ trunk/libQtGTL/RgbaDialog_p.h	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,45 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the license.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _RGBA_DIALOG_H_
+#define _RGBA_DIALOG_H_
+
+#include <QDialog>
+
+class Ui_RgbaDialog;
+
+namespace QtGTL {
+
+  class SpinBoxSliderConnector;
+  
+  class RgbaDialog : public QDialog {
+    public:
+      RgbaDialog( QWidget* );
+      ~RgbaDialog();
+      QColor color();
+    private slots:
+      void triangleColorChanged( const QColor& );
+      void spinBoxesValuesChanged();
+    private:
+      Ui_RgbaDialog* m_rgbaDialog;
+      SpinBoxSliderConnector* m_connectors[3];
+  };
+
+}
+#endif


Property changes on: trunk/libQtGTL/RgbaDialog_p.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/libQtGTL/SpinBoxSliderConnector_p.cpp
===================================================================
--- trunk/libQtGTL/SpinBoxSliderConnector_p.cpp	                        (rev 0)
+++ trunk/libQtGTL/SpinBoxSliderConnector_p.cpp	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,58 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "SpinBoxSliderConnector_p.h"
+
+using namespace QtGTL;
+
+#include <QDoubleSpinBox>
+#include <QSlider>
+
+SpinBoxSliderConnector::SpinBoxSliderConnector( QObject* _parent, QDoubleSpinBox* _spinBox, QSlider* _slider ) : QObject( _parent ), m_spinBox( _spinBox ), m_slider( _slider )
+{
+  connect( m_spinBox, SIGNAL(valueChanged( double )), SLOT(spinBoxValueChanged( double ) ) );
+  connect( m_slider, SIGNAL(valueChanged( int )), SLOT(sliderValueChanged( int ) ) );
+}
+
+SpinBoxSliderConnector::~SpinBoxSliderConnector()
+{
+}
+
+void SpinBoxSliderConnector::setValue( double _value )
+{
+  m_spinBox->setValue( _value );
+}
+
+void SpinBoxSliderConnector::spinBoxValueChanged( double _value )
+{
+  bool v = m_slider->blockSignals(true);
+  m_slider->setValue( int(_value * ( m_slider->maximum() - m_slider->minimum() ) / ( m_spinBox->maximum() - m_spinBox->minimum() ) ) );
+  m_slider->blockSignals(v);
+  emit( valueChanged( m_spinBox->value() ) );
+}
+
+void SpinBoxSliderConnector::sliderValueChanged( int _value )
+{
+  bool v = m_spinBox->blockSignals(true);
+  m_spinBox->setValue( _value * ( m_spinBox->maximum() - m_spinBox->minimum() ) / ( m_slider->maximum() - m_slider->minimum() ) );
+  m_spinBox->blockSignals(v);
+  emit( valueChanged( m_spinBox->value() ) );
+}
+
+#include "SpinBoxSliderConnector_p.moc"


Property changes on: trunk/libQtGTL/SpinBoxSliderConnector_p.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/libQtGTL/SpinBoxSliderConnector_p.h
===================================================================
--- trunk/libQtGTL/SpinBoxSliderConnector_p.h	                        (rev 0)
+++ trunk/libQtGTL/SpinBoxSliderConnector_p.h	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,48 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the license.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _SPINBOX_SLIDER_CONNECTOR_HPP_
+#define _SPINBOX_SLIDER_CONNECTOR_HPP_
+
+#include <QObject>
+
+class QDoubleSpinBox;
+class QSlider;
+
+namespace QtGTL {
+
+  class SpinBoxSliderConnector : public QObject {
+      Q_OBJECT
+    public:
+      SpinBoxSliderConnector( QObject* _parent, QDoubleSpinBox* _spinBox, QSlider* _slider );
+      ~SpinBoxSliderConnector();
+      void setValue( double _value );
+    private slots:
+      void spinBoxValueChanged( double _value );
+      void sliderValueChanged( int _value );
+    signals:
+      void valueChanged( double _value );
+    private:
+      QDoubleSpinBox* m_spinBox;
+      QSlider* m_slider;
+  };
+
+}
+
+#endif


Property changes on: trunk/libQtGTL/SpinBoxSliderConnector_p.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/libQtGTL/TriangleColorSelector_p.cpp
===================================================================
--- trunk/libQtGTL/TriangleColorSelector_p.cpp	                        (rev 0)
+++ trunk/libQtGTL/TriangleColorSelector_p.cpp	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,375 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU Lesser General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "TriangleColorSelector_p.h"
+#include <math.h>
+
+#include <QMouseEvent>
+#include <QPainter>
+#include <QPixmap>
+#include "ColorConversions_p.h"
+
+enum CurrentHandle {
+    NoHandle,
+    HueHandle,
+    ValueSaturationHandle };
+
+struct TriangleColorSelector::Private {
+    QPixmap wheelPixmap;
+    QPixmap trianglePixmap;
+    int hue;
+    int saturation;
+    int value;
+    int sizeColorSelector;
+    qreal centerColorSelector;
+    qreal wheelWidthProportion;
+    qreal wheelWidth;
+    qreal wheelNormExt;
+    qreal wheelNormInt;
+    qreal wheelInnerRadius;
+    qreal triangleRadius;
+    qreal triangleLength;
+    qreal triangleHeight;
+    qreal triangleBottom;
+    qreal triangleTop;
+    qreal normExt;
+    qreal normInt;
+    bool updateAllowed;
+    CurrentHandle handle;
+    qreal triangleHandleSize;
+    bool invalidTriangle;
+};
+
+TriangleColorSelector::TriangleColorSelector(QWidget* parent) : QWidget(parent), d(new Private)
+{
+    setMinimumHeight( 100 );
+    setMinimumWidth( 100 );
+    d->hue = 0;
+    d->saturation = 0;
+    d->value = 0;
+    d->updateAllowed = true;
+    setMouseTracking( true );
+    updateTriangleCircleParameters();
+    d->invalidTriangle = true;
+}
+
+TriangleColorSelector::~TriangleColorSelector()
+{
+    delete d;
+}
+
+void TriangleColorSelector::updateTriangleCircleParameters()
+{
+    d->sizeColorSelector = qMin(width(), height());
+    d->centerColorSelector = 0.5 * d->sizeColorSelector;
+    d->wheelWidthProportion = 0.3;
+    d->wheelWidth = d->centerColorSelector * d->wheelWidthProportion;
+    d->wheelNormExt = qAbs( d->centerColorSelector );
+    d->wheelNormInt = qAbs( d->centerColorSelector * (1.0 - d->wheelWidthProportion));
+    d->wheelInnerRadius = d->centerColorSelector * (1.0 - d->wheelWidthProportion);
+    d->triangleRadius = d->wheelInnerRadius * 0.9;
+    d->triangleLength = 3.0 / sqrt(3.0) * d->triangleRadius;
+    d->triangleHeight = d->triangleLength * sqrt(3.0) * 0.5;
+    d->triangleTop = 0.5 * d->sizeColorSelector - d->triangleRadius;
+    d->triangleBottom = d->triangleHeight + d->triangleTop;
+    d->triangleHandleSize = 10.0;
+}
+
+void TriangleColorSelector::paintEvent( QPaintEvent * event )
+{
+    if( d->invalidTriangle )
+    {
+      generateTriangle();
+    }
+    Q_UNUSED(event);
+    QPainter p(this);
+    p.setRenderHint(QPainter::SmoothPixmapTransform);
+    p.setRenderHint(QPainter::Antialiasing);
+    QPointF pos(d->centerColorSelector, d->centerColorSelector);
+    p.translate(QPointF( 0.5*width(), 0.5*height()  ) );
+    // Draw the wheel
+    p.drawPixmap( -pos, d->wheelPixmap );
+    // Draw the triangle
+    p.save();
+    p.rotate( hue() + 150 );
+    p.drawPixmap( -pos , d->trianglePixmap );
+    // Draw selectors
+    p.restore();
+    // Draw value,saturation selector
+    //   Compute coordinates
+    {
+        qreal vs_selector_ypos_ = value() / 255.0;
+        qreal ls_ = (vs_selector_ypos_) * d->triangleLength; // length of the saturation on the triangle
+        qreal vs_selector_xpos_ = ls_ * (saturation() / 255.0 - 0.5);
+        // Draw it
+        p.save();
+        p.setPen( QPen( Qt::white, 1.0) );
+        p.setBrush( color() );
+        p.rotate( hue() + 150 );
+        p.drawEllipse( QRectF( -d->triangleHandleSize*0.5 + vs_selector_xpos_,
+                               -d->triangleHandleSize*0.5 - (d->centerColorSelector - d->triangleTop) + vs_selector_ypos_ * d->triangleHeight,
+                                d->triangleHandleSize , d->triangleHandleSize ));
+    }
+    p.restore();
+    // Draw Hue selector
+    p.save();
+    p.setPen( QPen( Qt::white, 1.0) );
+    p.rotate( hue() - 90 );
+    qreal hueSelectorWidth_ = 0.8;
+    qreal hueSelectorOffset_ = 0.5 *( 1.0 - hueSelectorWidth_) * d->wheelWidth;
+    qreal hueSelectorSize_ = 0.8 * d->wheelWidth;
+    p.drawRect( QRectF( -1.5, -d->centerColorSelector + hueSelectorOffset_, 3.0, hueSelectorSize_ ));
+    p.restore();
+    p.end();
+}
+
+int TriangleColorSelector::hue() const
+{
+    return d->hue;
+}
+
+void TriangleColorSelector::setHue(int h)
+{
+    h = qBound(0, h, 360);
+    d->hue = h;
+    tellColorChanged();
+    d->invalidTriangle = true;
+    update();
+}
+
+int TriangleColorSelector::value() const
+{
+    return d->value;
+}
+
+void TriangleColorSelector::setValue(int v)
+{
+    v = qBound(0, v, 255);
+    d->value = v;
+    tellColorChanged();
+    d->invalidTriangle = true;
+    update();
+}
+
+int TriangleColorSelector::saturation() const
+{
+    return d->saturation;
+}
+
+void TriangleColorSelector::setSaturation(int s)
+{
+    s = qBound(0, s, 255);
+    d->saturation = s;
+    tellColorChanged();
+    d->invalidTriangle = true;
+    update();
+}
+
+void TriangleColorSelector::setHSV(int h, int s, int v)
+{
+    h = qBound(0, h, 360);
+    s = qBound(0, s, 255);
+    v = qBound(0, v, 255);
+    d->hue = h;
+    d->value = v;
+    d->saturation = s;
+    tellColorChanged();
+    d->invalidTriangle = true;
+    update();
+}
+
+QColor TriangleColorSelector::color() const
+{
+    int r,g,b;
+    hsv_to_rgb( d->hue, d->saturation, d->value, &r, &g, &b);
+    return QColor(r,g,b);
+}
+
+void TriangleColorSelector::setQColor(const QColor& c)
+{
+    if(d->updateAllowed)
+    {
+        int hue;
+        rgb_to_hsv( c.red(), c.green(), c.blue(), &hue, &d->saturation, &d->value);
+        if( hue >= 0 && hue <= 360)
+            d->hue = hue;
+        d->invalidTriangle = true;
+        update();
+    }
+}
+
+void TriangleColorSelector::resizeEvent( QResizeEvent * event )
+{
+    QWidget::resizeEvent( event );
+    updateTriangleCircleParameters();
+    generateWheel();
+    d->invalidTriangle = true;
+}
+
+inline qreal pow2(qreal v)
+{
+    return v*v;
+}
+
+void TriangleColorSelector::tellColorChanged()
+{
+    d->updateAllowed = false;
+    emit(colorChanged(color()));
+    d->updateAllowed = true;
+}
+
+void TriangleColorSelector::generateTriangle()
+{
+    QImage img(d->sizeColorSelector, d->sizeColorSelector, QImage::Format_ARGB32_Premultiplied);
+    // Length of triangle
+    int hue_ = hue();
+    
+    for(int y = 0; y < d->sizeColorSelector; y++)
+    {
+        qreal ynormalize = ( d->triangleTop - y ) / ( d->triangleTop - d->triangleBottom );
+        qreal v = 255 * ynormalize;
+        qreal ls_ = (ynormalize) * d->triangleLength;
+        qreal startx_ = d->centerColorSelector - 0.5 * ls_;
+        for(int x = 0; x < d->sizeColorSelector; x++)
+        {
+            qreal s = 255 * (x - startx_) / ls_;
+            if(v < -1.0 || v > 256.0 || s < -1.0 || s > 256.0 )
+            {
+                img.setPixel(x,y, qRgba(0,0,0,0));
+            } else {
+                qreal va = 1.0, sa = 1.0;
+                if( v < 0.0) { va = 1.0 + v; v = 0; }
+                else if( v > 255.0 ) { va = 256.0 - v; v = 255; }
+                if( s < 0.0) { sa = 1.0 + s; s = 0; }
+                else if( s > 255.0 ) { sa = 256.0 - s; s = 255; }
+                int r,g,b;
+                hsv_to_rgb(hue_, (int)s, (int)v, &r, &g, &b);
+                qreal coef = va * sa;
+                if( coef < 0.999)
+                {
+                    img.setPixel(x,y, qRgba( (int)(r * coef), (int)(g * coef), (int)(b * coef), (int)(255 * coef)));
+                } else {
+                    img.setPixel(x,y, qRgba(r, g, b, 255 ));
+                }
+            }
+        }
+    }
+    
+    d->trianglePixmap = QPixmap::fromImage(img);
+    d->invalidTriangle = false;
+}
+
+void TriangleColorSelector::generateWheel()
+{
+    QImage img(d->sizeColorSelector, d->sizeColorSelector, QImage::Format_ARGB32_Premultiplied);
+    for(int y = 0; y < d->sizeColorSelector; y++)
+    {
+        qreal yc = y - d->centerColorSelector;
+        qreal y2 = pow2( yc );
+        for(int x = 0; x < d->sizeColorSelector; x++)
+        {
+            qreal xc = x - d->centerColorSelector;
+            qreal norm = sqrt(pow2( xc ) + y2);
+            if( norm <= d->wheelNormExt + 1.0 && norm >= d->wheelNormInt - 1.0 )
+            {
+                qreal acoef = 1.0;
+                if(norm > d->wheelNormExt ) acoef = (1.0 + d->wheelNormExt - norm);
+                else if(norm < d->wheelNormInt ) acoef = (1.0 - d->wheelNormInt + norm);
+                qreal angle = atan2(yc, xc);
+                int h = (int)((180 * angle / M_PI) + 180);
+                int r,g,b;
+                hsv_to_rgb(h, 255, 255, &r, &g, &b);
+                if( acoef < 0.999)
+                {
+                    img.setPixel(x,y, qRgba( (int)(r * acoef), (int)(g * acoef), (int)(b * acoef), (int)(255 * acoef)));
+                } else {
+                    img.setPixel(x,y, qRgba(r, g, b, 255 ));
+                }
+            } else {
+                img.setPixel(x,y, qRgba(0,0,0,0));
+            }
+        }
+    }
+    d->wheelPixmap = QPixmap::fromImage(img);
+}
+
+void TriangleColorSelector::mouseReleaseEvent( QMouseEvent * event )
+{
+    if(event->button() == Qt::LeftButton)
+    {
+        selectColorAt( event->x(), event->y());
+        d->handle = NoHandle;
+    }
+    QWidget::mouseReleaseEvent( event );
+}
+
+void TriangleColorSelector::mousePressEvent( QMouseEvent * event )
+{
+    if(event->button() == Qt::LeftButton)
+    {
+        d->handle = NoHandle;
+        selectColorAt( event->x(), event->y());
+    }
+    QWidget::mousePressEvent( event );
+}
+
+void TriangleColorSelector::mouseMoveEvent( QMouseEvent * event )
+{
+    if(event->buttons() & Qt::LeftButton)
+    {
+        selectColorAt( event->x(), event->y(), false );
+    }
+    QWidget::mouseMoveEvent( event);
+}
+
+void TriangleColorSelector::selectColorAt(int _x, int _y, bool checkInWheel)
+{
+    Q_UNUSED( checkInWheel );
+    qreal x = _x - 0.5*width();
+    qreal y = _y - 0.5*height();
+    // Check if the click is inside the wheel
+    qreal norm = sqrt( x * x + y * y);
+    if ( ( (norm < d->wheelNormExt) && (norm > d->wheelNormInt) && d->handle == NoHandle )
+         || d->handle == HueHandle ) {
+        d->handle = HueHandle;
+        setHue( (int)(atan2(y, x) * 180 / M_PI ) + 180);
+        update();
+    }
+    else {
+    // Compute the s and v value, if they are in range, use them
+        qreal rotation = -(hue() + 150) * M_PI / 180;
+        qreal cr = cos(rotation);
+        qreal sr = sin(rotation);
+        qreal x1 = x * cr - y * sr; // <- now x1 gives the saturation
+        qreal y1 = x * sr + y * cr; // <- now y1 gives the value
+        y1 += d->wheelNormExt;
+        qreal ynormalize = (d->triangleTop - y1 ) / ( d->triangleTop - d->triangleBottom );
+        if( (ynormalize >= 0.0 && ynormalize <= 1.0 ) || d->handle == ValueSaturationHandle)
+        {
+            d->handle = ValueSaturationHandle;
+            qreal ls_ = (ynormalize) * d->triangleLength; // length of the saturation on the triangle
+            qreal sat = ( x1 / ls_ + 0.5) ;
+            if((sat >= 0.0 && sat <= 1.0) || d->handle == ValueSaturationHandle)
+            {
+                setHSV( d->hue, sat * 255, ynormalize * 255);
+            }
+        }
+        update();
+    }
+}
+
+#include "TriangleColorSelector_p.moc"


Property changes on: trunk/libQtGTL/TriangleColorSelector_p.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/libQtGTL/TriangleColorSelector_p.h
===================================================================
--- trunk/libQtGTL/TriangleColorSelector_p.h	                        (rev 0)
+++ trunk/libQtGTL/TriangleColorSelector_p.h	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,60 @@
+/*
+ *  Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2 of the license.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; see the file COPYING.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _TRIANGLE_COLOR_SELECTOR_H_
+#define _TRIANGLE_COLOR_SELECTOR_H_
+
+#include <QWidget>
+
+class TriangleColorSelector : public QWidget {
+    Q_OBJECT
+    public:
+        TriangleColorSelector(QWidget* parent);
+        ~TriangleColorSelector();
+    protected: // events
+        void paintEvent( QPaintEvent * event );
+        void resizeEvent( QResizeEvent * event );
+        void mouseReleaseEvent( QMouseEvent * event );
+        void mousePressEvent( QMouseEvent * event );
+        void mouseMoveEvent( QMouseEvent * event );
+    public:
+        int hue() const;
+        int value() const;
+        int saturation() const;
+        QColor color() const;
+    public slots:
+        void setHue(int h);
+        void setValue(int v);
+        void setSaturation(int s);
+        void setHSV(int h, int s, int v);
+        void setQColor(const QColor& );
+    signals:
+        void colorChanged(const QColor& );
+    private:
+        void tellColorChanged();
+        void generateTriangle();
+        void generateWheel();
+        void updateTriangleCircleParameters();
+        void selectColorAt(int x, int y, bool checkInWheel = true);
+    private:
+        struct Private;
+        Private* const d;
+};
+
+#endif


Property changes on: trunk/libQtGTL/TriangleColorSelector_p.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/libQtGTL/UiRgbaDialog.ui
===================================================================
--- trunk/libQtGTL/UiRgbaDialog.ui	                        (rev 0)
+++ trunk/libQtGTL/UiRgbaDialog.ui	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,170 @@
+<ui version="4.0" >
+ <class>RgbaDialog</class>
+ <widget class="QDialog" name="RgbaDialog" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>486</width>
+    <height>318</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Dialog</string>
+  </property>
+  <layout class="QHBoxLayout" name="horizontalLayout" >
+   <item>
+    <widget class="TriangleColorSelector" native="1" name="triangleSelector" >
+     <property name="minimumSize" >
+      <size>
+       <width>300</width>
+       <height>300</height>
+      </size>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout" >
+     <item>
+      <layout class="QGridLayout" name="gridLayout" >
+       <item row="1" column="0" colspan="2" >
+        <widget class="QLabel" name="label" >
+         <property name="text" >
+          <string>Red:</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="0" colspan="3" >
+        <widget class="QSlider" name="sliderRed" >
+         <property name="orientation" >
+          <enum>Qt::Horizontal</enum>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="0" colspan="2" >
+        <widget class="QLabel" name="label_2" >
+         <property name="text" >
+          <string>Green:</string>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="1" colspan="2" >
+        <widget class="QDoubleSpinBox" name="doubleSpinBoxGreen" />
+       </item>
+       <item row="4" column="0" colspan="3" >
+        <widget class="QSlider" name="sliderGreen" >
+         <property name="orientation" >
+          <enum>Qt::Horizontal</enum>
+         </property>
+        </widget>
+       </item>
+       <item row="5" column="0" >
+        <widget class="QLabel" name="label_3" >
+         <property name="text" >
+          <string>Blue:</string>
+         </property>
+        </widget>
+       </item>
+       <item row="5" column="1" colspan="2" >
+        <widget class="QDoubleSpinBox" name="doubleSpinBoxBlue" />
+       </item>
+       <item row="6" column="0" colspan="3" >
+        <widget class="QSlider" name="sliderBlue" >
+         <property name="orientation" >
+          <enum>Qt::Horizontal</enum>
+         </property>
+        </widget>
+       </item>
+       <item row="7" column="0" >
+        <widget class="QLabel" name="label_4" >
+         <property name="text" >
+          <string>Alpha:</string>
+         </property>
+        </widget>
+       </item>
+       <item row="7" column="1" colspan="2" >
+        <widget class="QDoubleSpinBox" name="doubleSpinBoxAlpha" />
+       </item>
+       <item row="8" column="0" colspan="3" >
+        <widget class="QSlider" name="sliderAlpha" >
+         <property name="orientation" >
+          <enum>Qt::Horizontal</enum>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="1" colspan="2" >
+        <widget class="QDoubleSpinBox" name="doubleSpinBoxRed" />
+       </item>
+      </layout>
+     </item>
+     <item>
+      <spacer name="verticalSpacer" >
+       <property name="orientation" >
+        <enum>Qt::Vertical</enum>
+       </property>
+       <property name="sizeHint" stdset="0" >
+        <size>
+         <width>20</width>
+         <height>40</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QDialogButtonBox" name="buttonBox" >
+       <property name="orientation" >
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="standardButtons" >
+        <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>TriangleColorSelector</class>
+   <extends>QWidget</extends>
+   <header>TriangleColorSelector_p.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>RgbaDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>RgbaDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

Added: trunk/libQtGTL/cmake/modules/FindOpenShiva.cmake
===================================================================
--- trunk/libQtGTL/cmake/modules/FindOpenShiva.cmake	                        (rev 0)
+++ trunk/libQtGTL/cmake/modules/FindOpenShiva.cmake	2008-12-07 21:55:58 UTC (rev 520)
@@ -0,0 +1,35 @@
+
+INCLUDE(UsePkgConfig)
+PKGCONFIG(OpenShiva _OpenShivaIncDir _OpenShivaLinkDir _OpenShivaLinkFlags _OpenShivaCflags)
+
+set(OPENSHIVA_DEFINITIONS ${_OpenShivaCflags})
+set(OPENSHIVA_LIBRARIES ${_OpenShivaLinkFlags})
+set(OPENSHIVA_INCLUDE_DIR ${_OpenShivaIncDir})
+
+if(OPENSHIVA_DEFINITIONS AND OPENSHIVA_LIBRARIES)
+
+  FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config PATHS /usr/bin/ /usr/local/bin )
+
+  # query pkg-config asking for OpenShiva >= 0.9.7
+  EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=0.9.7 OpenShiva RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
+
+  if(_return_VALUE STREQUAL "0")
+    set(OPENSHIVA_FOUND TRUE)
+    set(HAVE_OPENSHIVA TRUE)
+  else(_return_VALUE STREQUAL "0")
+    message(STATUS "OpenShiva >= 0.9.3 was found")
+  endif(_return_VALUE STREQUAL "0")
+endif(OPENSHIVA_DEFINITIONS AND OPENSHIVA_LIBRARIES)
+
+if (OPENSHIVA_FOUND)
+    if (NOT OPENSHIVA_FIND_QUIETLY)
+        message(STATUS "Found OpenShiva: ${OPENSHIVA_LIBRARIES}")
+    endif (NOT OPENSHIVA_FIND_QUIETLY)
+else (OPENShiva_FOUND)
+    if (NOT OPENSHIVA_FIND_QUIETLY)
+        message(STATUS "OpenShiva was NOT found.")
+    endif (NOT OPENSHIVA_FIND_QUIETLY)
+    if (OPENSHIVA_FIND_REQUIRED)
+        message(FATAL_ERROR "Could NOT find OPENShiva")
+    endif (OPENSHIVA_FIND_REQUIRED)
+endif (OPENSHIVA_FOUND)


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/