[opengtl-commits] [534] * introduce the QtGTL libray for interfaces with QImages

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


Revision: 534
Author:   cyrille
Date:     2008-12-09 20:03:30 +0100 (Tue, 09 Dec 2008)

Log Message:
-----------
* introduce the QtGTL libray for interfaces with QImages
* rename libQtShiva to QtShiva, QtShiva to qShiva, QtCTL to qCTL
* introduce Proxy to connect parameters widgets to kernel values
* revamp the ui of qShiva to use tabs and a parameters tabs

Modified Paths:
--------------
    trunk/libQtGTL/CMakeLists.txt
    trunk/libQtGTL/QtShiva/CMakeLists.txt
    trunk/libQtGTL/QtShiva/ParametersWidget.cpp
    trunk/libQtGTL/QtShiva/ParametersWidget_p.cpp
    trunk/libQtGTL/QtShiva/ParametersWidget_p.h
    trunk/libQtGTL/examples/QtCTL/CMakeLists.txt
    trunk/libQtGTL/examples/QtCTL/QtCTL.cpp
    trunk/libQtGTL/examples/QtShiva/CMakeLists.txt
    trunk/libQtGTL/examples/QtShiva/MainWindow.ui
    trunk/libQtGTL/examples/QtShiva/QtShiva.cpp
    trunk/libQtGTL/examples/QtShiva/QtShiva.h
    trunk/libQtGTL/examples/QtShiva/main.cpp

Added Paths:
-----------
    trunk/libQtGTL/QtGTL/
    trunk/libQtGTL/QtGTL/CMakeLists.txt
    trunk/libQtGTL/QtGTL/QImageBuffer.cpp
    trunk/libQtGTL/QtGTL/QImageBuffer.h
    trunk/libQtGTL/QtGTL/QImageImage.cpp
    trunk/libQtGTL/QtGTL/QImageImage.h
    trunk/libQtGTL/QtShiva/
    trunk/libQtGTL/QtShiva/Proxy_p.cpp
    trunk/libQtGTL/QtShiva/Proxy_p.h
    trunk/libQtGTL/cmake/modules/FindGTLCore.cmake
    trunk/libQtGTL/examples/CMakeLists.txt

Removed Paths:
-------------
    trunk/libQtGTL/examples/QtShiva/QtGTL.h
    trunk/libQtGTL/libQtShiva/


Modified: trunk/libQtGTL/CMakeLists.txt
===================================================================
--- trunk/libQtGTL/CMakeLists.txt	2008-12-09 18:59:07 UTC (rev 533)
+++ trunk/libQtGTL/CMakeLists.txt	2008-12-09 19:03:30 UTC (rev 534)
@@ -6,5 +6,9 @@
 
 cmake_minimum_required(VERSION 2.6)
 
-add_subdirectory( libQtShiva )
+include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
 
+add_subdirectory( examples )
+add_subdirectory( QtShiva )
+add_subdirectory( QtGTL )
+


Property changes on: trunk/libQtGTL/QtGTL
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: trunk/libQtGTL/QtGTL/CMakeLists.txt
===================================================================
--- trunk/libQtGTL/QtGTL/CMakeLists.txt	                        (rev 0)
+++ trunk/libQtGTL/QtGTL/CMakeLists.txt	2008-12-09 19:03:30 UTC (rev 534)
@@ -0,0 +1,19 @@
+
+find_package(GTLCore REQUIRED)
+
+include_directories(${QT_QTGUI_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${GTLCORE_INCLUDE_DIR})
+
+############################### libQtShiva ###############################
+
+set(libQtGTL_SRCS
+    QImageBuffer.cpp
+    QImageImage.cpp
+  )
+
+qt4_automoc(${libQtShiva_SRCS})
+
+add_library(QtGTL SHARED ${libQtGTL_SRCS})
+target_link_libraries(QtGTL ${QT_QTGUI_LIBRARY} ${OPENSHIVA_LIBRARIES} )
+
+install(TARGETS QtGTL DESTINATION ${LIB_INSTALL_DIR} )
+install( FILES QImageBuffer.h QImageImage.h DESTINATION ${INCLUDE_INSTALL_DIR}/QtGTL )

Added: trunk/libQtGTL/QtGTL/QImageBuffer.cpp
===================================================================
--- trunk/libQtGTL/QtGTL/QImageBuffer.cpp	                        (rev 0)
+++ trunk/libQtGTL/QtGTL/QImageBuffer.cpp	2008-12-09 19:03:30 UTC (rev 534)
@@ -0,0 +1,59 @@
+/*
+ *  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 "QImageBuffer.h"
+
+#include <QImage>
+
+using namespace QtGTL;
+
+struct QImageBuffer::Private {
+  Private( const QImage& _image) : image(_image)
+  {
+  }
+  QImage image;
+};
+
+QImageBuffer::QImageBuffer(const QImage& img) : d(new Private(img))
+{
+}
+
+QImageBuffer::~QImageBuffer()
+{
+}
+    
+char * QImageBuffer::rawData()
+{
+  return (char*)d->image.bits();
+}
+    
+const char * QImageBuffer::rawData() const
+{
+  return (const char*)d->image.bits();
+}
+    
+int QImageBuffer::size() const
+{
+  return d->image.numBytes();
+}
+    
+const QImage& QImageBuffer::image() const
+{
+  return d->image;
+}

Added: trunk/libQtGTL/QtGTL/QImageBuffer.h
===================================================================
--- trunk/libQtGTL/QtGTL/QImageBuffer.h	                        (rev 0)
+++ trunk/libQtGTL/QtGTL/QImageBuffer.h	2008-12-09 19:03:30 UTC (rev 534)
@@ -0,0 +1,46 @@
+/*
+ *  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_QIMAGEBUFFER_H_
+#define _QTGTL_QIMAGEBUFFER_H_
+
+#include <QImage>
+#include <GTLCore/Buffer.h>
+
+namespace QtGTL {
+  /**
+   * @ingroup QtGTL
+   * 
+   * This class allow to wrap a QImage inside a \ref GTLCore::Buffer
+   */
+  class QImageBuffer : public GTLCore::Buffer {
+    public:
+      QImageBuffer(const QImage& img);
+      ~QImageBuffer();
+      virtual char * rawData();
+      virtual const char * rawData() const;
+      virtual int size() const;
+      const QImage& image() const;
+    private:
+      struct Private;
+      Private* const d;
+  };
+}
+
+#endif

Added: trunk/libQtGTL/QtGTL/QImageImage.cpp
===================================================================
--- trunk/libQtGTL/QtGTL/QImageImage.cpp	                        (rev 0)
+++ trunk/libQtGTL/QtGTL/QImageImage.cpp	2008-12-09 19:03:30 UTC (rev 534)
@@ -0,0 +1,57 @@
+/*
+ *  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 "QImageImage.h"
+
+#include <QImage>
+
+#include "QImageBuffer.h"
+
+#include <GTLCore/PixelDescription.h>
+#include <GTLCore/Type.h>
+
+using namespace QtGTL;
+
+QImageImage::QImageImage(const QImage& img) : BufferImage( img.width(), img.height(), new QImageBuffer( img ), imageToPixelDescription( img ) )
+{
+}
+
+QImageImage::~QImageImage()
+{
+}
+
+const QImage& QImageImage::image() const
+{
+  return static_cast<const QImageBuffer*>(buffer())->image();
+}
+
+GTLCore::PixelDescription QImageImage::imageToPixelDescription( const QImage& img )
+{
+  switch( img.format())
+  {
+    case QImage::Format_RGB32:
+      return GTLCore::PixelDescription( GTLCore::Type::UnsignedInteger8, 4 );
+    case QImage::Format_ARGB32:
+      return GTLCore::PixelDescription( GTLCore::Type::UnsignedInteger8, 4 );
+    case QImage::Format_RGB888:
+      return GTLCore::PixelDescription( GTLCore::Type::UnsignedInteger8, 3 );
+    default:
+      qFatal("Unsupported QImage");
+  }
+}

Added: trunk/libQtGTL/QtGTL/QImageImage.h
===================================================================
--- trunk/libQtGTL/QtGTL/QImageImage.h	                        (rev 0)
+++ trunk/libQtGTL/QtGTL/QImageImage.h	2008-12-09 19:03:30 UTC (rev 534)
@@ -0,0 +1,43 @@
+/*
+ *  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 _QIMAGE_IMAGE_H_
+#define _QIMAGE_IMAGE_H_
+
+#include <GTLCore/BufferImage.h>
+
+class QImage;
+
+namespace QtGTL {
+  /**
+   * @ingroup QtGTL
+   * 
+   * This class allow to embed a QImage inside a \ref GTLCore::Image .
+   */
+  class QImageImage : public GTLCore::BufferImage {
+    public:
+      QImageImage(const QImage& img);
+      ~QImageImage();
+      const QImage& image() const;
+    private:
+      GTLCore::PixelDescription imageToPixelDescription( const QImage& img );
+  };
+}
+
+#endif

Copied: trunk/libQtGTL/QtShiva (from rev 528, trunk/libQtGTL/libQtShiva)

Modified: trunk/libQtGTL/QtShiva/CMakeLists.txt
===================================================================
--- trunk/libQtGTL/libQtShiva/CMakeLists.txt	2008-12-07 22:11:59 UTC (rev 528)
+++ trunk/libQtGTL/QtShiva/CMakeLists.txt	2008-12-09 19:03:30 UTC (rev 534)
@@ -19,8 +19,8 @@
 
 qt4_automoc(${libQtShiva_SRCS})
 
-add_library(libQtShiva SHARED ${libQtShiva_SRCS})
-target_link_libraries(libQtShiva ${QT_QTGUI_LIBRARY} ${OPENSHIVA_LIBRARIES} )
+add_library( QtShiva SHARED ${libQtShiva_SRCS})
+target_link_libraries( QtShiva ${QT_QTGUI_LIBRARY} ${OPENSHIVA_LIBRARIES} )
 
-install(TARGETS libQtShiva DESTINATION ${LIB_INSTALL_DIR} )
+install(TARGETS QtShiva DESTINATION ${LIB_INSTALL_DIR} )
 install( FILES ParametersWidget.h DESTINATION ${INCLUDE_INSTALL_DIR}/QtGTL )

Modified: trunk/libQtGTL/QtShiva/ParametersWidget.cpp
===================================================================
--- trunk/libQtGTL/libQtShiva/ParametersWidget.cpp	2008-12-07 22:11:59 UTC (rev 528)
+++ trunk/libQtGTL/QtShiva/ParametersWidget.cpp	2008-12-09 19:03:30 UTC (rev 534)
@@ -19,6 +19,7 @@
 
 #include "ParametersWidget.h"
 
+#include <QGridLayout>
 
 #include "ParametersWidget_p.h"
 
@@ -28,6 +29,8 @@
 {
   d->kernel = 0;
   d->self = this;
+  d->selfLayout = new QGridLayout( this );
+  d->selfLayout->setRowStretch( 1, 10 );
 }
 
 ParametersWidget::~ParametersWidget()

Modified: trunk/libQtGTL/QtShiva/ParametersWidget_p.cpp
===================================================================
--- trunk/libQtGTL/libQtShiva/ParametersWidget_p.cpp	2008-12-07 22:11:59 UTC (rev 528)
+++ trunk/libQtGTL/QtShiva/ParametersWidget_p.cpp	2008-12-09 19:03:30 UTC (rev 534)
@@ -98,6 +98,9 @@
     currentWidget = new QLabel( QObject::tr( "No configuration" ), self );
   }
   
+  currentWidget->setVisible( true );
+  selfLayout->addWidget(currentWidget, 0, 0, 1, 1);
+  
 }
 
 void ParametersWidget::Private::createParameterEntryWidget( QWidget* _parent, QGridLayout* _gridLayout, int _layoutIndex, const GTLCore::Metadata::ParameterEntry* _parameterEntry )
@@ -138,6 +141,7 @@
       // Double spinbox
       QDoubleSpinBox* doubleSpinBox = new QDoubleSpinBox(_parent);
       _gridLayout->addWidget(doubleSpinBox, _layoutIndex, 1, 1, 1);
+      doubleSpinBox->setSingleStep( 0.1 );
       
       // Slider
       QSlider* horizontalSlider = new QSlider(_parent);
@@ -166,7 +170,7 @@
 
 void ParametersWidget::Private::updateKernelParameters()
 {
+  
 }
 
-
 #include "ParametersWidget_p.moc"

Modified: trunk/libQtGTL/QtShiva/ParametersWidget_p.h
===================================================================
--- trunk/libQtGTL/libQtShiva/ParametersWidget_p.h	2008-12-07 22:11:59 UTC (rev 528)
+++ trunk/libQtGTL/QtShiva/ParametersWidget_p.h	2008-12-09 19:03:30 UTC (rev 534)
@@ -38,6 +38,7 @@
       OpenShiva::Kernel* kernel;
       QWidget* self;
       QWidget* currentWidget;
+      QGridLayout* selfLayout;
       // Functions
       void regenerateWidget();
     private slots:

Added: trunk/libQtGTL/QtShiva/Proxy_p.cpp
===================================================================
--- trunk/libQtGTL/QtShiva/Proxy_p.cpp	                        (rev 0)
+++ trunk/libQtGTL/QtShiva/Proxy_p.cpp	2008-12-09 19:03:30 UTC (rev 534)
@@ -0,0 +1,43 @@
+/*
+ *  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 "Proxy_p.h"
+
+#include <OpenShiva/Kernel.h>
+
+Proxy::Proxy( QObject* parent, const GTLCore::String& _name, OpenShiva::Kernel* _kernel ) : QObject( parent ), m_name(_name), m_kernel( _kernel )
+{
+  
+}
+
+Proxy::~Proxy()
+{
+}
+
+void Proxy::setInt( int v )
+{
+  _kernel->setParameter( m_name, v );
+}
+
+void Proxy::setFloatValue( float v )
+{
+  _kernel->setParameter( m_name, v );
+}
+
+#include "Proxy_p.moc"


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

Added: trunk/libQtGTL/QtShiva/Proxy_p.h
===================================================================
--- trunk/libQtGTL/QtShiva/Proxy_p.h	                        (rev 0)
+++ trunk/libQtGTL/QtShiva/Proxy_p.h	2008-12-09 19:03:30 UTC (rev 534)
@@ -0,0 +1,44 @@
+/*
+ *  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 _QTSHIVA_PROXY_P_H_
+#define _QTSHIVA_PROXY_P_H_
+
+#include <GTLCore/String.h>
+
+namespace OpenShiva {
+  class Kernel;
+}
+
+namespace QtShiva {
+  class Proxy : public QObject {
+    Q_OBJECT
+    public:
+      Proxy( QObject* parent, const GTLCore::String& _name, OpenShiva::Kernel* _kernel );
+      ~Proxy();
+    public slots:
+      void setInt( int );
+      void setFloatValue( float );
+    private:
+      GTLCore::String m_name;
+      OpenShiva::Kernel* m_kernel;
+  };
+}
+
+#endif


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

Added: trunk/libQtGTL/cmake/modules/FindGTLCore.cmake
===================================================================
--- trunk/libQtGTL/cmake/modules/FindGTLCore.cmake	                        (rev 0)
+++ trunk/libQtGTL/cmake/modules/FindGTLCore.cmake	2008-12-09 19:03:30 UTC (rev 534)
@@ -0,0 +1,36 @@
+     
+
+INCLUDE(UsePkgConfig)
+PKGCONFIG(GTLCore _GTLCoreIncDir _GTLCoreLinkDir _GTLCoreLinkFlags _GTLCoreCflags)
+
+set(GTLCORE_DEFINITIONS ${_GTLCoreCflags})
+set(GTLCORE_LIBRARIES ${_GTLCoreLinkFlags})
+set(GTLCORE_INCLUDE_DIR ${_GTLCoreIncDir})
+
+if(GTLCORE_DEFINITIONS AND GTLCORE_LIBRARIES)
+
+  FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config PATHS /usr/bin/ /usr/local/bin )
+
+  # query pkg-config asking for GTLCore == 0.9.2
+  EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=0.9.3 GTLCore RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull )
+
+  if(_return_VALUE STREQUAL "0")
+    set(GTLCORE_FOUND TRUE)
+    set(HAVE_GTLCORE TRUE)
+  else(_return_VALUE STREQUAL "0")
+    message(STATUS "GTLCore >= 0.9.3 was found")
+  endif(_return_VALUE STREQUAL "0")
+endif(GTLCORE_DEFINITIONS AND GTLCORE_LIBRARIES)
+
+if (GTLCORE_FOUND)
+    if (NOT GTLCore_FIND_QUIETLY)
+        message(STATUS "Found GTLCORE: ${GTLCORE_LIBRARIES}")
+    endif (NOT GTLCore_FIND_QUIETLY)
+else (GTLCORE_FOUND)
+    if (NOT GTLCore_FIND_QUIETLY)
+        message(STATUS "GTLCore was NOT found.")
+    endif (NOT GTLCore_FIND_QUIETLY)
+    if (GTLCore_FIND_REQUIRED)
+        message(FATAL_ERROR "Could NOT find GTLCORE")
+    endif (GTLCore_FIND_REQUIRED)
+endif (GTLCORE_FOUND)

Added: trunk/libQtGTL/examples/CMakeLists.txt
===================================================================
--- trunk/libQtGTL/examples/CMakeLists.txt	                        (rev 0)
+++ trunk/libQtGTL/examples/CMakeLists.txt	2008-12-09 19:03:30 UTC (rev 534)
@@ -0,0 +1,2 @@
+add_subdirectory( QtCTL )
+add_subdirectory( QtShiva )
\ No newline at end of file

Modified: trunk/libQtGTL/examples/QtCTL/CMakeLists.txt
===================================================================
--- trunk/libQtGTL/examples/QtCTL/CMakeLists.txt	2008-12-09 18:59:07 UTC (rev 533)
+++ trunk/libQtGTL/examples/QtCTL/CMakeLists.txt	2008-12-09 19:03:30 UTC (rev 534)
@@ -1,7 +1,5 @@
-set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
 
 find_package(OpenCTL REQUIRED)
-find_package(Qt4 REQUIRED)
 
 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
 
@@ -21,7 +19,7 @@
 
 qt4_automoc(${Qt_CTL_SRCS})
 
-add_executable(QtCTL ${Qt_CTL_SRCS})
+add_executable(qCTL ${Qt_CTL_SRCS})
 # set_target_properties( QtCTL PROPERTIES COMPILE_FLAGS ${OPENCTL_COMPILE_FLAGS})
-target_link_libraries(QtCTL ${QT_LIBRARY_DIR} ${QT_QTGUI_LIBRARY} ${OPENCTL_LIBRARIES})
-install(TARGETS QtCTL DESTINATION ${BIN_INSTALL_DIR} )
+target_link_libraries(qCTL ${QT_LIBRARY_DIR} ${QT_QTGUI_LIBRARY} ${OPENCTL_LIBRARIES} QtGTL)
+# install(TARGETS QtCTL DESTINATION ${BIN_INSTALL_DIR} )

Modified: trunk/libQtGTL/examples/QtCTL/QtCTL.cpp
===================================================================
--- trunk/libQtGTL/examples/QtCTL/QtCTL.cpp	2008-12-09 18:59:07 UTC (rev 533)
+++ trunk/libQtGTL/examples/QtCTL/QtCTL.cpp	2008-12-09 19:03:30 UTC (rev 534)
@@ -33,18 +33,8 @@
 #include <GTLCore/Buffer.h>
 #include <GTLCore/Type.h>
 
-class QImageBuffer : public GTLCore::Buffer {
-  public:
-    QImageBuffer(QImage& img) : image(img) { }
-    ~QImageBuffer() {}
-    virtual char * rawData() { return (char*)image.bits(); }
-    virtual const char * rawData() const { return (const char*)image.bits(); }
-    virtual int size() const { return image.numBytes(); }
-  private:
-    QImage& image;
-};
+#include "QtGTL/QImageBuffer.h"
 
-
 QtCTL::QtCTL()
 {
   m_mainWindow = new Ui_MainWindow;
@@ -106,7 +96,7 @@
     OpenCTL::Program program( "apply", &p, GTLCore::PixelDescription( GTLCore::Type::UnsignedInteger8, 4));
     if(program.initialised())
     {
-      QImageBuffer buffer(currentImage);
+      QtGTL::QImageBuffer buffer(currentImage);
       program.apply(buffer,buffer);
       refreshImageViewer();
     } else {

Modified: trunk/libQtGTL/examples/QtShiva/CMakeLists.txt
===================================================================
--- trunk/libQtGTL/examples/QtShiva/CMakeLists.txt	2008-12-09 18:59:07 UTC (rev 533)
+++ trunk/libQtGTL/examples/QtShiva/CMakeLists.txt	2008-12-09 19:03:30 UTC (rev 534)
@@ -1,7 +1,5 @@
-set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
 
 find_package(OpenShiva REQUIRED)
-find_package(Qt4 REQUIRED)
 
 set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
 
@@ -21,6 +19,6 @@
 
 qt4_automoc(${Qt_SHIVA_SRCS})
 
-add_executable(QtShiva ${Qt_SHIVA_SRCS})
-target_link_libraries(QtShiva ${QT_LIBRARY_DIR} ${QT_QTGUI_LIBRARY} ${OPENSHIVA_LIBRARIES})
-install(TARGETS QtShiva DESTINATION ${BIN_INSTALL_DIR} )
+add_executable(qShiva ${Qt_SHIVA_SRCS} )
+target_link_libraries(qShiva ${QT_LIBRARY_DIR} ${QT_QTGUI_LIBRARY} ${OPENSHIVA_LIBRARIES} QtGTL QtShiva)
+# install(TARGETS QtShiva DESTINATION ${BIN_INSTALL_DIR} )

Modified: trunk/libQtGTL/examples/QtShiva/MainWindow.ui
===================================================================
--- trunk/libQtGTL/examples/QtShiva/MainWindow.ui	2008-12-09 18:59:07 UTC (rev 533)
+++ trunk/libQtGTL/examples/QtShiva/MainWindow.ui	2008-12-09 19:03:30 UTC (rev 534)
@@ -6,132 +6,167 @@
     <x>0</x>
     <y>0</y>
     <width>872</width>
-    <height>587</height>
+    <height>702</height>
    </rect>
   </property>
   <property name="windowTitle" >
    <string>Form</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout" >
-   <item row="0" column="0" >
-    <widget class="QSplitter" name="splitter_2" >
-     <property name="orientation" >
-      <enum>Qt::Horizontal</enum>
+  <layout class="QHBoxLayout" name="horizontalLayout_3" >
+   <item>
+    <widget class="QLabel" name="imageViewer" >
+     <property name="text" >
+      <string>No Image</string>
      </property>
-     <widget class="QLabel" name="imageViewer" >
-      <property name="text" >
-       <string>No Image</string>
-      </property>
-      <property name="alignment" >
-       <set>Qt::AlignCenter</set>
-      </property>
-     </widget>
-     <widget class="QSplitter" name="splitter" >
-      <property name="orientation" >
-       <enum>Qt::Vertical</enum>
-      </property>
-      <widget class="QWidget" name="layoutWidget" >
-       <layout class="QVBoxLayout" name="verticalLayout" >
-        <item>
-         <widget class="QListWidget" name="listImages" />
-        </item>
-        <item>
-         <layout class="QHBoxLayout" name="horizontalLayout_2" >
-          <item>
-           <widget class="QPushButton" name="buttonAdd" >
-            <property name="text" >
-             <string>Add</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QPushButton" name="buttonRemove" >
-            <property name="text" >
-             <string>Remove</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <spacer name="horizontalSpacer_2" >
-            <property name="orientation" >
-             <enum>Qt::Horizontal</enum>
-            </property>
-            <property name="sizeHint" stdset="0" >
-             <size>
-              <width>40</width>
-              <height>20</height>
-             </size>
-            </property>
-           </spacer>
-          </item>
-         </layout>
-        </item>
-       </layout>
-      </widget>
-      <widget class="QWidget" name="layoutWidget" >
-       <layout class="QVBoxLayout" name="verticalLayout_2" >
-        <item>
-         <widget class="QTextEdit" name="ctlCodeEditor" >
-          <property name="html" >
-           <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd";>
+     <property name="alignment" >
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout_3" >
+     <item>
+      <widget class="QTabWidget" name="tabWidget" >
+       <property name="currentIndex" >
+        <number>0</number>
+       </property>
+       <widget class="QWidget" name="tab" >
+        <attribute name="title" >
+         <string>Source</string>
+        </attribute>
+        <layout class="QVBoxLayout" name="verticalLayout_2" >
+         <item>
+          <widget class="QTextEdit" name="ctlCodeEditor" >
+           <property name="html" >
+            <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd";>
 &lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
 p, li { white-space: pre-wrap; }
 &lt;/style>&lt;/head>&lt;body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;">
-&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-family:'Sans Serif'; font-size:10pt;">kernel PlainGenerator&lt;/span>&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&amp;lt;&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">  parameters: &amp;lt;&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">   blueness: &amp;lt; &lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">     type: float;&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">     minValue: 0;&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">     maxValue: 1.0;&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">     defaultValue: 0.5;&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">     &amp;gt;;&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> &amp;gt;;&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&amp;gt;;&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;">kernel PlainGenerator&lt;/p>
 &lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;">{&lt;/p>
 &lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;">  void evaluatePixel(out pixel result)&lt;/p>
 &lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;">  {&lt;/p>
-&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;">    result[0] = 0.5;&lt;/p>
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;">    result[0] = &lt;span style=" font-family:'DejaVu Sans'; font-size:9pt;">blueness&lt;/span>;&lt;/p>
 &lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;">  }&lt;/p>
 &lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;">}&lt;/p>
 &lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;">&lt;/p>&lt;/body>&lt;/html></string>
-          </property>
-          <property name="acceptRichText" >
-           <bool>false</bool>
-          </property>
-         </widget>
-        </item>
-        <item>
-         <layout class="QHBoxLayout" name="horizontalLayout" >
-          <item>
-           <widget class="QPushButton" name="buttonApply" >
-            <property name="text" >
-             <string>Apply</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <widget class="QPushButton" name="buttonRefresh" >
-            <property name="enabled" >
-             <bool>true</bool>
-            </property>
-            <property name="text" >
-             <string>Refresh</string>
-            </property>
-           </widget>
-          </item>
-          <item>
-           <spacer name="horizontalSpacer" >
-            <property name="orientation" >
-             <enum>Qt::Horizontal</enum>
-            </property>
-            <property name="sizeHint" stdset="0" >
-             <size>
-              <width>40</width>
-              <height>20</height>
-             </size>
-            </property>
-           </spacer>
-          </item>
-         </layout>
-        </item>
-       </layout>
+           </property>
+           <property name="acceptRichText" >
+            <bool>false</bool>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </widget>
+       <widget class="QWidget" name="tab_2" >
+        <attribute name="title" >
+         <string>Images</string>
+        </attribute>
+        <layout class="QVBoxLayout" name="verticalLayout" >
+         <item>
+          <widget class="QListWidget" name="listImages" />
+         </item>
+         <item>
+          <layout class="QHBoxLayout" name="horizontalLayout_2" >
+           <item>
+            <widget class="QPushButton" name="buttonAdd" >
+             <property name="text" >
+              <string>Add</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QPushButton" name="buttonRemove" >
+             <property name="text" >
+              <string>Remove</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <spacer name="horizontalSpacer_2" >
+             <property name="orientation" >
+              <enum>Qt::Horizontal</enum>
+             </property>
+             <property name="sizeHint" stdset="0" >
+              <size>
+               <width>40</width>
+               <height>20</height>
+              </size>
+             </property>
+            </spacer>
+           </item>
+          </layout>
+         </item>
+        </layout>
+       </widget>
+       <widget class="QWidget" name="widget" >
+        <attribute name="title" >
+         <string>Parameters</string>
+        </attribute>
+        <layout class="QGridLayout" name="gridLayout" >
+         <item row="0" column="0" >
+          <widget class="QtShiva::ParametersWidget" native="1" name="parametersWidget" />
+         </item>
+        </layout>
+       </widget>
       </widget>
-     </widget>
-    </widget>
+     </item>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout" >
+       <item>
+        <widget class="QPushButton" name="buttonApply" >
+         <property name="text" >
+          <string>Apply</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QPushButton" name="buttonRefresh" >
+         <property name="enabled" >
+          <bool>true</bool>
+         </property>
+         <property name="text" >
+          <string>Refresh</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="horizontalSpacer" >
+         <property name="orientation" >
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeHint" stdset="0" >
+          <size>
+           <width>40</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </item>
+    </layout>
    </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>QtShiva::ParametersWidget</class>
+   <extends>QWidget</extends>
+   <header>QtShiva/ParametersWidget.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
  <resources/>
  <connections/>
 </ui>

Deleted: trunk/libQtGTL/examples/QtShiva/QtGTL.h
===================================================================
--- trunk/libQtGTL/examples/QtShiva/QtGTL.h	2008-12-09 18:59:07 UTC (rev 533)
+++ trunk/libQtGTL/examples/QtShiva/QtGTL.h	2008-12-09 19:03:30 UTC (rev 534)
@@ -1,46 +0,0 @@
-
-#ifndef _QTGTL_H_
-#define _QTGTL_H_
-
-#include <QImage>
-#include <GTLCore/Buffer.h>
-#include <GTLCore/BufferImage.h>
-
-class QImageBuffer : public GTLCore::Buffer {
-  public:
-    QImageBuffer(const QImage& img) : m_image(img) { }
-    ~QImageBuffer() {}
-    virtual char * rawData() { return (char*)m_image.bits(); }
-    virtual const char * rawData() const { return (const char*)m_image.bits(); }
-    virtual int size() const { return m_image.numBytes(); }
-    QImage image() const { return m_image; }
-  private:
-    QImage m_image;
-};
-
-class QImageImage : public GTLCore::BufferImage {
-  public:
-    QImageImage(const QImage& img) : BufferImage( img.width(), img.height(), new QImageBuffer( img ), imageToPixelDescription( img ) )
-    {
-    }
-    ~QImageImage() {}
-    QImage image() const { return static_cast<const QImageBuffer*>(buffer())->image(); }
-  private:
-    GTLCore::PixelDescription imageToPixelDescription( const QImage& img )
-    {
-      switch( img.format())
-      {
-        case QImage::Format_RGB32:
-          return GTLCore::PixelDescription( GTLCore::Type::UnsignedInteger8, 4 );
-        case QImage::Format_ARGB32:
-          return GTLCore::PixelDescription( GTLCore::Type::UnsignedInteger8, 4 );
-        case QImage::Format_RGB888:
-          return GTLCore::PixelDescription( GTLCore::Type::UnsignedInteger8, 3 );
-        default:
-          qFatal("Unsupported QImage");
-      }
-    }
-};
-
-
-#endif

Modified: trunk/libQtGTL/examples/QtShiva/QtShiva.cpp
===================================================================
--- trunk/libQtGTL/examples/QtShiva/QtShiva.cpp	2008-12-09 18:59:07 UTC (rev 533)
+++ trunk/libQtGTL/examples/QtShiva/QtShiva.cpp	2008-12-09 19:03:30 UTC (rev 534)
@@ -33,11 +33,12 @@
 #include <GTLCore/RegionF.h>
 #include <GTLCore/Type.h>
 
-#include "QtGTL.h"
+#include "QtGTL/QImageImage.h"
 
-QtShiva::QtShiva()
+qShiva::qShiva()
 {
   m_mainWindow = new Ui_MainWindow;
+  m_kernel = new OpenShiva::Kernel( 4 );
   QWidget* widget = new QWidget;
   m_mainWindow->setupUi(widget);
   setCentralWidget(widget);
@@ -45,20 +46,22 @@
   connect(m_mainWindow->buttonRemove, SIGNAL(released()), SLOT(remove()));
   connect(m_mainWindow->buttonApply, SIGNAL(released()), SLOT(apply()));
   connect(m_mainWindow->buttonRefresh, SIGNAL(released()), SLOT(refreshImageViewer()));
+  connect(m_mainWindow->ctlCodeEditor, SIGNAL(textChanged()), SLOT(sourceChanged()));
+  sourceChanged();
 }
 
-QtShiva::~QtShiva()
+qShiva::~qShiva()
 {
   delete m_mainWindow;
 }
 
-void QtShiva::refreshImageViewer()
+void qShiva::refreshImageViewer()
 {
   QPixmap pm = QPixmap::fromImage(currentImage);
   m_mainWindow->imageViewer->setPixmap(pm.scaled( m_mainWindow->imageViewer->size(), Qt::KeepAspectRatio));
 }
 
-void QtShiva::add()
+void qShiva::add()
 {
   QString fileName = QFileDialog::getOpenFileName(this);
   if (fileName.isEmpty()) return;
@@ -67,7 +70,7 @@
   m_mainWindow->listImages->addItem( lwi );
 }
 
-void QtShiva::remove()
+void qShiva::remove()
 {
   delete m_mainWindow->listImages->currentItem();
 }
@@ -79,11 +82,17 @@
   return v;
 }
 
-void QtShiva::apply()
+void qShiva::sourceChanged()
 {
+  m_kernel->setSource( m_mainWindow->ctlCodeEditor->toPlainText().toAscii().data());
+  m_mainWindow->parametersWidget->setKernel( m_kernel );
+}
+
+void qShiva::apply()
+{
   GTLCore::PixelDescription pixel( GTLCore::Type::Float, 3 );
-  OpenShiva::Kernel p("", 4);
-  p.setSource( m_mainWindow->ctlCodeEditor->toPlainText().toAscii ().data());
+  OpenShiva::Kernel p( 4);
+  p.setSource( m_mainWindow->ctlCodeEditor->toPlainText().toAscii().data());
   p.compile();
   if(p.isCompiled())
   {
@@ -93,15 +102,15 @@
       QString fileName = m_mainWindow->listImages->item( k )->data( Qt::UserRole ).toString();
       QImage img;
       if (not img.load(fileName)) {
-        QMessageBox::warning(this, tr("QtShiva"),
+        QMessageBox::warning(this, tr("qShiva"),
                               tr("Cannot read image %1..")
                               .arg(fileName));
         return;
       }
-      GTLCore::AbstractImage* iImage = new QImageImage( img );
+      GTLCore::AbstractImage* iImage = new QtGTL::QImageImage( img );
       inputImages.push_back( iImage );
     }
-    QImageImage image( QImage( 1000, 1000, QImage::Format_RGB32) );
+    QtGTL::QImageImage image( QImage( 1000, 1000, QImage::Format_RGB32) );
     p.evaluatePixeles( GTLCore::Region(0,0, 1000,1000), inputImages, &image );
     currentImage = image.image();
     for( std::list<GTLCore::AbstractImage*>::iterator it = inputImages.begin();
@@ -111,7 +120,7 @@
     }
     refreshImageViewer();
   } else {
-    QMessageBox::critical(this, tr("QtShiva"), tr("Compilation error: %1").arg( p.compilationErrorsMessage().c_str() ));
+    QMessageBox::critical(this, tr("qShiva"), tr("Compilation error: %1").arg( p.compilationErrorsMessage().c_str() ));
   }
 }
 

Modified: trunk/libQtGTL/examples/QtShiva/QtShiva.h
===================================================================
--- trunk/libQtGTL/examples/QtShiva/QtShiva.h	2008-12-09 18:59:07 UTC (rev 533)
+++ trunk/libQtGTL/examples/QtShiva/QtShiva.h	2008-12-09 19:03:30 UTC (rev 534)
@@ -26,23 +26,29 @@
 
 class Ui_MainWindow;
 
-class QtShiva:public QMainWindow
+namespace OpenShiva {
+  class Kernel;
+}
+
+class qShiva : public QMainWindow
 {
   Q_OBJECT
   public:
-    QtShiva();
-    ~QtShiva();
+    qShiva();
+    ~qShiva();
 
   private slots:
     void add();
     void remove();
     void apply();
     void refreshImageViewer();
+    void sourceChanged();
   private:
 //     void loadFile(const QString &fileName);
   private:
     Ui_MainWindow* m_mainWindow;
     QImage currentImage;
+    OpenShiva::Kernel* m_kernel;
 };
 
 #endif

Modified: trunk/libQtGTL/examples/QtShiva/main.cpp
===================================================================
--- trunk/libQtGTL/examples/QtShiva/main.cpp	2008-12-09 18:59:07 UTC (rev 533)
+++ trunk/libQtGTL/examples/QtShiva/main.cpp	2008-12-09 19:03:30 UTC (rev 534)
@@ -23,7 +23,7 @@
 int main(int argc, char *argv[])
 {
       QApplication app(argc, argv);
-      QtShiva * mw = new QtShiva();
+      qShiva * mw = new qShiva();
       mw->show();
       return app.exec();
 }


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