소스 검색

FIX: Fixed CRLF line endings

Sascha Zelzer 16 년 전
부모
커밋
840d0f50d3

+ 20 - 20
CMakeExternals/ZMQ.cmake

@@ -1,21 +1,21 @@
-#
-# ZMQ
-#
-SET(ZMQ_DEPENDS)
-ctkMacroShouldAddExternalProject(ZMQ_LIBRARIES add_project)
-IF(${add_project})
-  SET(proj ZMQ)
-#   MESSAGE(STATUS "Adding project:${proj}")
-  SET(ZMQ_DEPENDS ${proj})
-  ExternalProject_Add(${proj}
-      GIT_REPOSITORY git://github.com/PatrickCheng/zeromq2.git
-      INSTALL_COMMAND ""
-      CMAKE_GENERATOR ${gen}
-      CMAKE_ARGS
-        ${ep_common_args}
-		-DBUILD_SHARED_LIBS:BOOL=ON 
-		-DZMQ_BUILD_DEVICES:BOOL=ON
-		-DZMQ_BUILD_PERFORMANCE_TESTS:BOOL=ON
-      )
-	  SET(ZMQ_DIR ${ep_build_dir}/${proj})
+#
+# ZMQ
+#
+SET(ZMQ_DEPENDS)
+ctkMacroShouldAddExternalProject(ZMQ_LIBRARIES add_project)
+IF(${add_project})
+  SET(proj ZMQ)
+#   MESSAGE(STATUS "Adding project:${proj}")
+  SET(ZMQ_DEPENDS ${proj})
+  ExternalProject_Add(${proj}
+      GIT_REPOSITORY git://github.com/PatrickCheng/zeromq2.git
+      INSTALL_COMMAND ""
+      CMAKE_GENERATOR ${gen}
+      CMAKE_ARGS
+        ${ep_common_args}
+		-DBUILD_SHARED_LIBS:BOOL=ON 
+		-DZMQ_BUILD_DEVICES:BOOL=ON
+		-DZMQ_BUILD_PERFORMANCE_TESTS:BOOL=ON
+      )
+	  SET(ZMQ_DIR ${ep_build_dir}/${proj})
 ENDIF()

+ 337 - 337
Libs/Visualization/VTK/Core/ctkVTKHistogram.cpp

@@ -1,337 +1,337 @@
-/*=========================================================================
-
-  Library:   CTK
- 
-  Copyright (c) 2010  Kitware Inc.
-
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-
-      http://www.commontk.org/LICENSE
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
- 
-=========================================================================*/
-
-/// Qt includes
-#include <QColor>
-#include <QDebug>
-
-/// CTK includes
-#include "ctkVTKHistogram.h"
-
-/// VTK includes
-#include <vtkDataArray.h>
-#include <vtkIntArray.h>
-#include <vtkMath.h>
-#include <vtkSmartPointer.h>
-
-/// STL include
-#include <limits>
-
-//-----------------------------------------------------------------------------
-class ctkVTKHistogramPrivate: public ctkPrivate<ctkVTKHistogram>
-{
-public:
-  ctkVTKHistogramPrivate();
-  vtkSmartPointer<vtkDataArray> DataArray;
-  vtkSmartPointer<vtkIntArray>  Bins;
-  int                           UserNumberOfBins;
-  int                           Component;
-  mutable double                Range[2];
-  int                           MinBin;
-  int                           MaxBin;
-
-  int computeNumberOfBins()const;
-};
-
-//-----------------------------------------------------------------------------
-ctkVTKHistogramPrivate::ctkVTKHistogramPrivate()
-{
-  this->Bins = vtkSmartPointer<vtkIntArray>::New();
-  this->UserNumberOfBins = -1;
-  this->Component = 0;
-  this->Range[0] = this->Range[1] = 0.;
-  this->MinBin = 0;
-  this->MaxBin = 0;
-}
-
-//-----------------------------------------------------------------------------
-int ctkVTKHistogramPrivate::computeNumberOfBins()const
-{
-  if (this->DataArray.GetPointer() == 0)
-    {
-    return -1;
-    }
-  
-  if (this->DataArray->GetDataType() == VTK_CHAR ||
-      this->DataArray->GetDataType() == VTK_SIGNED_CHAR ||
-      this->DataArray->GetDataType() == VTK_UNSIGNED_CHAR)
-    {
-    this->Range[0] = this->DataArray->GetDataTypeMin();
-    this->Range[1] = this->DataArray->GetDataTypeMax();
-    }
-  else
-    {
-    this->DataArray->GetRange(this->Range, this->Component);
-    if (this->DataArray->GetDataType() == VTK_FLOAT ||
-        this->DataArray->GetDataType() == VTK_DOUBLE)
-      {
-      this->Range[1] += 0.01;
-      }
-    else
-      {
-      this->Range[1] += 1;
-      }
-    }
-  if (this->UserNumberOfBins > 0)
-    {
-    return this->UserNumberOfBins;
-    }
-
-  return static_cast<int>(this->Range[1] - this->Range[0]);
-}
-
-//-----------------------------------------------------------------------------
-ctkVTKHistogram::ctkVTKHistogram(QObject* parentObject)
-  :ctkHistogram(parentObject)
-{
-  CTK_INIT_PRIVATE(ctkVTKHistogram);
-}
-
-//-----------------------------------------------------------------------------
-ctkVTKHistogram::ctkVTKHistogram(vtkDataArray* dataArray, 
-                                 QObject* parentObject)
-  :ctkHistogram(parentObject)
-{
-  CTK_INIT_PRIVATE(ctkVTKHistogram);
-  this->setDataArray(dataArray);
-}
-
-//-----------------------------------------------------------------------------
-ctkVTKHistogram::~ctkVTKHistogram()
-{
-}
-
-//-----------------------------------------------------------------------------
-int ctkVTKHistogram::count()const
-{
-  CTK_D(const ctkVTKHistogram);
-  return d->Bins->GetNumberOfTuples();
-}
-
-//-----------------------------------------------------------------------------
-void ctkVTKHistogram::range(qreal& minRange, qreal& maxRange)const
-{
-  CTK_D(const ctkVTKHistogram);
-  if (d->DataArray.GetPointer() == 0)
-    {
-    Q_ASSERT(d->DataArray.GetPointer());
-    minRange = 1.; // set incorrect values
-    maxRange = 0.;
-    return;
-    }
-  if (d->Range[0] == d->Range[1])
-    {
-    minRange = d->DataArray->GetDataTypeMin();
-    maxRange = d->DataArray->GetDataTypeMax();
-    return;
-    }
-  minRange = d->Range[0];
-  maxRange = d->Range[1];
-} 
-
-//-----------------------------------------------------------------------------
-QVariant ctkVTKHistogram::minValue()const
-{
-  CTK_D(const ctkVTKHistogram);
-  return d->MinBin;
-}
-
-//-----------------------------------------------------------------------------
-QVariant ctkVTKHistogram::maxValue()const
-{
-  CTK_D(const ctkVTKHistogram);
-  return d->MaxBin;
-}
-
-//-----------------------------------------------------------------------------
-ctkControlPoint* ctkVTKHistogram::controlPoint(int index)const
-{
-  CTK_D(const ctkVTKHistogram);
-  ctkHistogramBar* cp = new ctkHistogramBar();
-  cp->P.X = this->indexToPos(index);
-  cp->P.Value = d->Bins->GetValue(index);
-  return cp;
-}
-
-//-----------------------------------------------------------------------------
-QVariant ctkVTKHistogram::value(qreal pos)const
-{
-  CTK_D(const ctkVTKHistogram);
-  QSharedPointer<ctkControlPoint> point(this->controlPoint(this->posToIndex(pos)));
-  return point->value();
-}
-
-//-----------------------------------------------------------------------------
-qreal ctkVTKHistogram::indexToPos(int index)const
-{
-  qreal posRange[2];
-  this->range(posRange[0], posRange[1]);
-  return posRange[0] + index * ((posRange[1] - posRange[0]) / (this->count() - 1));
-}
-
-//-----------------------------------------------------------------------------
-int ctkVTKHistogram::posToIndex(qreal pos)const
-{
-  qreal posRange[2];
-  this->range(posRange[0], posRange[1]);
-  return (pos - posRange[0]) / ((posRange[1] - posRange[0]) / (this->count() - 1));
-}
-
-//-----------------------------------------------------------------------------
-void ctkVTKHistogram::setDataArray(vtkDataArray* newDataArray)
-{
-  CTK_D(ctkVTKHistogram);
-  d->DataArray = newDataArray;
-  this->qvtkReconnect(d->DataArray,vtkCommand::ModifiedEvent,
-                      this, SIGNAL(changed()));
-  emit changed();
-}
-
-//-----------------------------------------------------------------------------
-vtkDataArray* ctkVTKHistogram::dataArray()const
-{
-  CTK_D(const ctkVTKHistogram);
-  return d->DataArray;
-}
-
-//-----------------------------------------------------------------------------
-void ctkVTKHistogram::setComponent(int component)
-{
-  CTK_D(ctkVTKHistogram);
-  d->Component = component;
-  // need rebuild
-}
-
-int ctkVTKHistogram::component()const
-{
-  CTK_D(const ctkVTKHistogram);
-  return d->Component;
-}
-
-//-----------------------------------------------------------------------------
-void ctkVTKHistogram::setNumberOfBins(int number)
-{
-  CTK_D(ctkVTKHistogram);
-  d->UserNumberOfBins = number;
-}
-
-//-----------------------------------------------------------------------------
-template <class T>
-void populateBins(vtkIntArray* bins, const ctkVTKHistogram* histogram)
-{
-  vtkDataArray* scalars = histogram->dataArray();
-  int* binsPtr = bins->WritePointer(0, bins->GetNumberOfTuples());
-
-  // reset bins to 0
-  memset(binsPtr, bins->GetNumberOfTuples()*sizeof(int), 0);
-
-  const vtkIdType componentNumber = scalars->GetNumberOfComponents();
-  const vtkIdType tupleNumber = scalars->GetNumberOfTuples();
-  int component = histogram->component();
-
-  double range[2];
-  histogram->range(range[0], range[1]);
-  T offset = static_cast<T>(range[0]);
-
-  T* ptr = static_cast<T*>(scalars->WriteVoidPointer(0, tupleNumber));
-  T* endPtr = ptr + tupleNumber * componentNumber;
-  ptr += component;
-  for (; ptr < endPtr; ptr += componentNumber)
-    {
-    Q_ASSERT( (static_cast<long long>(*ptr) - offset) == 
-              (static_cast<int>(*ptr) - offset));
-    binsPtr[static_cast<int>(*ptr - offset)]++;
-    }
-}
-
-//-----------------------------------------------------------------------------
-template <class T>
-void populateIrregularBins(vtkIntArray* bins, const ctkVTKHistogram* histogram)
-{
-  vtkDataArray* scalars = histogram->dataArray();
-
-  int* binsPtr = bins->WritePointer(0, bins->GetNumberOfTuples());
-  // reset bins to 0
-  memset(binsPtr, bins->GetNumberOfTuples() * sizeof(int), 0);
-
-  const vtkIdType componentNumber = scalars->GetNumberOfComponents();
-  const vtkIdType tupleNumber = scalars->GetNumberOfTuples();
-  int component = histogram->component();
-
-  double range[2];
-  histogram->range(range[0], range[1]);
-  double offset = range[0];
-
-  double binWidth = 1.;
-  if (range[1] != range[0])
-    {
-    binWidth = static_cast<double>(bins->GetNumberOfTuples()) / (range[1] - range[0]);
-    }
-
-  T* ptr = static_cast<T*>(scalars->WriteVoidPointer(0, tupleNumber));
-  T* endPtr = ptr + tupleNumber * componentNumber;
-  ptr += component;
-  for (; ptr < endPtr; ptr += componentNumber)
-    {
-    if (std::numeric_limits<T>::has_quiet_NaN && 
-        std::numeric_limits<T>::quiet_NaN() == *ptr)
-      {
-      continue;
-      }
-    binsPtr[vtkMath::Floor(((double)*ptr - offset) * binWidth)]++;
-    }
-}
-
-//-----------------------------------------------------------------------------
-void ctkVTKHistogram::build()
-{
-  CTK_D(ctkVTKHistogram);
-  
-  const int binCount = d->computeNumberOfBins();
-
-  d->Bins->SetNumberOfComponents(1);
-  d->Bins->SetNumberOfTuples(binCount);
-
-  if (static_cast<double>(binCount) != (d->Range[1] - d->Range[2]))
-    {
-    switch(d->DataArray->GetDataType())
-      {
-      vtkTemplateMacro(populateIrregularBins<VTK_TT>(d->Bins, this));
-      }
-    }
-  else
-    {
-    switch(d->DataArray->GetDataType())
-      {
-      vtkTemplateMacro(populateBins<VTK_TT>(d->Bins, this));
-      }
-    }
-  // update Min/Max values
-  int* binPtr = d->Bins->GetPointer(0);
-  int* endPtr = d->Bins->GetPointer(binCount-1);
-  d->MinBin = *endPtr;
-  d->MaxBin = *endPtr;
-  for (;binPtr < endPtr; ++binPtr)
-    {
-    d->MinBin = qMin(*binPtr, d->MinBin);
-    d->MaxBin = qMax(*binPtr, d->MaxBin);
-    }
-  emit changed();
-}
+/*=========================================================================
+
+  Library:   CTK
+ 
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ 
+=========================================================================*/
+
+/// Qt includes
+#include <QColor>
+#include <QDebug>
+
+/// CTK includes
+#include "ctkVTKHistogram.h"
+
+/// VTK includes
+#include <vtkDataArray.h>
+#include <vtkIntArray.h>
+#include <vtkMath.h>
+#include <vtkSmartPointer.h>
+
+/// STL include
+#include <limits>
+
+//-----------------------------------------------------------------------------
+class ctkVTKHistogramPrivate: public ctkPrivate<ctkVTKHistogram>
+{
+public:
+  ctkVTKHistogramPrivate();
+  vtkSmartPointer<vtkDataArray> DataArray;
+  vtkSmartPointer<vtkIntArray>  Bins;
+  int                           UserNumberOfBins;
+  int                           Component;
+  mutable double                Range[2];
+  int                           MinBin;
+  int                           MaxBin;
+
+  int computeNumberOfBins()const;
+};
+
+//-----------------------------------------------------------------------------
+ctkVTKHistogramPrivate::ctkVTKHistogramPrivate()
+{
+  this->Bins = vtkSmartPointer<vtkIntArray>::New();
+  this->UserNumberOfBins = -1;
+  this->Component = 0;
+  this->Range[0] = this->Range[1] = 0.;
+  this->MinBin = 0;
+  this->MaxBin = 0;
+}
+
+//-----------------------------------------------------------------------------
+int ctkVTKHistogramPrivate::computeNumberOfBins()const
+{
+  if (this->DataArray.GetPointer() == 0)
+    {
+    return -1;
+    }
+  
+  if (this->DataArray->GetDataType() == VTK_CHAR ||
+      this->DataArray->GetDataType() == VTK_SIGNED_CHAR ||
+      this->DataArray->GetDataType() == VTK_UNSIGNED_CHAR)
+    {
+    this->Range[0] = this->DataArray->GetDataTypeMin();
+    this->Range[1] = this->DataArray->GetDataTypeMax();
+    }
+  else
+    {
+    this->DataArray->GetRange(this->Range, this->Component);
+    if (this->DataArray->GetDataType() == VTK_FLOAT ||
+        this->DataArray->GetDataType() == VTK_DOUBLE)
+      {
+      this->Range[1] += 0.01;
+      }
+    else
+      {
+      this->Range[1] += 1;
+      }
+    }
+  if (this->UserNumberOfBins > 0)
+    {
+    return this->UserNumberOfBins;
+    }
+
+  return static_cast<int>(this->Range[1] - this->Range[0]);
+}
+
+//-----------------------------------------------------------------------------
+ctkVTKHistogram::ctkVTKHistogram(QObject* parentObject)
+  :ctkHistogram(parentObject)
+{
+  CTK_INIT_PRIVATE(ctkVTKHistogram);
+}
+
+//-----------------------------------------------------------------------------
+ctkVTKHistogram::ctkVTKHistogram(vtkDataArray* dataArray, 
+                                 QObject* parentObject)
+  :ctkHistogram(parentObject)
+{
+  CTK_INIT_PRIVATE(ctkVTKHistogram);
+  this->setDataArray(dataArray);
+}
+
+//-----------------------------------------------------------------------------
+ctkVTKHistogram::~ctkVTKHistogram()
+{
+}
+
+//-----------------------------------------------------------------------------
+int ctkVTKHistogram::count()const
+{
+  CTK_D(const ctkVTKHistogram);
+  return d->Bins->GetNumberOfTuples();
+}
+
+//-----------------------------------------------------------------------------
+void ctkVTKHistogram::range(qreal& minRange, qreal& maxRange)const
+{
+  CTK_D(const ctkVTKHistogram);
+  if (d->DataArray.GetPointer() == 0)
+    {
+    Q_ASSERT(d->DataArray.GetPointer());
+    minRange = 1.; // set incorrect values
+    maxRange = 0.;
+    return;
+    }
+  if (d->Range[0] == d->Range[1])
+    {
+    minRange = d->DataArray->GetDataTypeMin();
+    maxRange = d->DataArray->GetDataTypeMax();
+    return;
+    }
+  minRange = d->Range[0];
+  maxRange = d->Range[1];
+} 
+
+//-----------------------------------------------------------------------------
+QVariant ctkVTKHistogram::minValue()const
+{
+  CTK_D(const ctkVTKHistogram);
+  return d->MinBin;
+}
+
+//-----------------------------------------------------------------------------
+QVariant ctkVTKHistogram::maxValue()const
+{
+  CTK_D(const ctkVTKHistogram);
+  return d->MaxBin;
+}
+
+//-----------------------------------------------------------------------------
+ctkControlPoint* ctkVTKHistogram::controlPoint(int index)const
+{
+  CTK_D(const ctkVTKHistogram);
+  ctkHistogramBar* cp = new ctkHistogramBar();
+  cp->P.X = this->indexToPos(index);
+  cp->P.Value = d->Bins->GetValue(index);
+  return cp;
+}
+
+//-----------------------------------------------------------------------------
+QVariant ctkVTKHistogram::value(qreal pos)const
+{
+  CTK_D(const ctkVTKHistogram);
+  QSharedPointer<ctkControlPoint> point(this->controlPoint(this->posToIndex(pos)));
+  return point->value();
+}
+
+//-----------------------------------------------------------------------------
+qreal ctkVTKHistogram::indexToPos(int index)const
+{
+  qreal posRange[2];
+  this->range(posRange[0], posRange[1]);
+  return posRange[0] + index * ((posRange[1] - posRange[0]) / (this->count() - 1));
+}
+
+//-----------------------------------------------------------------------------
+int ctkVTKHistogram::posToIndex(qreal pos)const
+{
+  qreal posRange[2];
+  this->range(posRange[0], posRange[1]);
+  return (pos - posRange[0]) / ((posRange[1] - posRange[0]) / (this->count() - 1));
+}
+
+//-----------------------------------------------------------------------------
+void ctkVTKHistogram::setDataArray(vtkDataArray* newDataArray)
+{
+  CTK_D(ctkVTKHistogram);
+  d->DataArray = newDataArray;
+  this->qvtkReconnect(d->DataArray,vtkCommand::ModifiedEvent,
+                      this, SIGNAL(changed()));
+  emit changed();
+}
+
+//-----------------------------------------------------------------------------
+vtkDataArray* ctkVTKHistogram::dataArray()const
+{
+  CTK_D(const ctkVTKHistogram);
+  return d->DataArray;
+}
+
+//-----------------------------------------------------------------------------
+void ctkVTKHistogram::setComponent(int component)
+{
+  CTK_D(ctkVTKHistogram);
+  d->Component = component;
+  // need rebuild
+}
+
+int ctkVTKHistogram::component()const
+{
+  CTK_D(const ctkVTKHistogram);
+  return d->Component;
+}
+
+//-----------------------------------------------------------------------------
+void ctkVTKHistogram::setNumberOfBins(int number)
+{
+  CTK_D(ctkVTKHistogram);
+  d->UserNumberOfBins = number;
+}
+
+//-----------------------------------------------------------------------------
+template <class T>
+void populateBins(vtkIntArray* bins, const ctkVTKHistogram* histogram)
+{
+  vtkDataArray* scalars = histogram->dataArray();
+  int* binsPtr = bins->WritePointer(0, bins->GetNumberOfTuples());
+
+  // reset bins to 0
+  memset(binsPtr, bins->GetNumberOfTuples()*sizeof(int), 0);
+
+  const vtkIdType componentNumber = scalars->GetNumberOfComponents();
+  const vtkIdType tupleNumber = scalars->GetNumberOfTuples();
+  int component = histogram->component();
+
+  double range[2];
+  histogram->range(range[0], range[1]);
+  T offset = static_cast<T>(range[0]);
+
+  T* ptr = static_cast<T*>(scalars->WriteVoidPointer(0, tupleNumber));
+  T* endPtr = ptr + tupleNumber * componentNumber;
+  ptr += component;
+  for (; ptr < endPtr; ptr += componentNumber)
+    {
+    Q_ASSERT( (static_cast<long long>(*ptr) - offset) == 
+              (static_cast<int>(*ptr) - offset));
+    binsPtr[static_cast<int>(*ptr - offset)]++;
+    }
+}
+
+//-----------------------------------------------------------------------------
+template <class T>
+void populateIrregularBins(vtkIntArray* bins, const ctkVTKHistogram* histogram)
+{
+  vtkDataArray* scalars = histogram->dataArray();
+
+  int* binsPtr = bins->WritePointer(0, bins->GetNumberOfTuples());
+  // reset bins to 0
+  memset(binsPtr, bins->GetNumberOfTuples() * sizeof(int), 0);
+
+  const vtkIdType componentNumber = scalars->GetNumberOfComponents();
+  const vtkIdType tupleNumber = scalars->GetNumberOfTuples();
+  int component = histogram->component();
+
+  double range[2];
+  histogram->range(range[0], range[1]);
+  double offset = range[0];
+
+  double binWidth = 1.;
+  if (range[1] != range[0])
+    {
+    binWidth = static_cast<double>(bins->GetNumberOfTuples()) / (range[1] - range[0]);
+    }
+
+  T* ptr = static_cast<T*>(scalars->WriteVoidPointer(0, tupleNumber));
+  T* endPtr = ptr + tupleNumber * componentNumber;
+  ptr += component;
+  for (; ptr < endPtr; ptr += componentNumber)
+    {
+    if (std::numeric_limits<T>::has_quiet_NaN && 
+        std::numeric_limits<T>::quiet_NaN() == *ptr)
+      {
+      continue;
+      }
+    binsPtr[vtkMath::Floor(((double)*ptr - offset) * binWidth)]++;
+    }
+}
+
+//-----------------------------------------------------------------------------
+void ctkVTKHistogram::build()
+{
+  CTK_D(ctkVTKHistogram);
+  
+  const int binCount = d->computeNumberOfBins();
+
+  d->Bins->SetNumberOfComponents(1);
+  d->Bins->SetNumberOfTuples(binCount);
+
+  if (static_cast<double>(binCount) != (d->Range[1] - d->Range[2]))
+    {
+    switch(d->DataArray->GetDataType())
+      {
+      vtkTemplateMacro(populateIrregularBins<VTK_TT>(d->Bins, this));
+      }
+    }
+  else
+    {
+    switch(d->DataArray->GetDataType())
+      {
+      vtkTemplateMacro(populateBins<VTK_TT>(d->Bins, this));
+      }
+    }
+  // update Min/Max values
+  int* binPtr = d->Bins->GetPointer(0);
+  int* endPtr = d->Bins->GetPointer(binCount-1);
+  d->MinBin = *endPtr;
+  d->MaxBin = *endPtr;
+  for (;binPtr < endPtr; ++binPtr)
+    {
+    d->MinBin = qMin(*binPtr, d->MinBin);
+    d->MaxBin = qMax(*binPtr, d->MaxBin);
+    }
+  emit changed();
+}

+ 222 - 222
Libs/Visualization/VTK/Core/ctkVTKLookupTable.cpp

@@ -1,222 +1,222 @@
-/*=========================================================================
-
-  Library:   CTK
- 
-  Copyright (c) 2010  Kitware Inc.
-
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-
-      http://www.commontk.org/LICENSE
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
- 
-=========================================================================*/
-
-/// Qt includes
-#include <QColor>
-#include <QDebug>
-
-/// CTK includes
-#include "ctkVTKLookupTable.h"
-
-/// VTK includes
-#include <vtkLookupTable.h>
-#include <vtkSmartPointer.h>
-
-//-----------------------------------------------------------------------------
-class ctkVTKLookupTablePrivate: public ctkPrivate<ctkVTKLookupTable>
-{
-public:
-  vtkSmartPointer<vtkLookupTable> LookupTable;
-};
-
-//-----------------------------------------------------------------------------
-ctkVTKLookupTable::ctkVTKLookupTable(QObject* parentObject)
-  :ctkTransferFunction(parentObject)
-{
-  CTK_INIT_PRIVATE(ctkVTKLookupTable);
-}
-
-//-----------------------------------------------------------------------------
-ctkVTKLookupTable::ctkVTKLookupTable(vtkLookupTable* lookupTable, 
-                                     QObject* parentObject)
-  :ctkTransferFunction(parentObject)
-{
-  CTK_INIT_PRIVATE(ctkVTKLookupTable);
-  this->setLookupTable(lookupTable);
-}
-
-//-----------------------------------------------------------------------------
-ctkVTKLookupTable::~ctkVTKLookupTable()
-{
-}
-
-//-----------------------------------------------------------------------------
-int ctkVTKLookupTable::count()const
-{
-  CTK_D(const ctkVTKLookupTable);
-  if (d->LookupTable.GetPointer() == 0)
-    {
-    Q_ASSERT(d->LookupTable.GetPointer());
-    return -1;
-    }
-  return d->LookupTable->GetNumberOfColors();
-}
-
-//-----------------------------------------------------------------------------
-bool ctkVTKLookupTable::isDiscrete()const
-{
-  return true;
-}
-
-//-----------------------------------------------------------------------------
-bool ctkVTKLookupTable::isEditable()const
-{
-  return true;
-}
-
-//-----------------------------------------------------------------------------
-void ctkVTKLookupTable::range(qreal& minRange, qreal& maxRange)const
-{
-  CTK_D(const ctkVTKLookupTable);
-  if (d->LookupTable.GetPointer() == 0)
-    {
-    Q_ASSERT(d->LookupTable.GetPointer());
-    minRange = 1.; // set incorrect values
-    maxRange = 0.;
-    return;
-    }
-  double rangeValues[2];
-  d->LookupTable->GetTableRange(rangeValues);
-  minRange = rangeValues[0];
-  maxRange = rangeValues[1];
-}
-
-//-----------------------------------------------------------------------------
-QVariant ctkVTKLookupTable::minValue()const
-{
-  CTK_D(const ctkVTKLookupTable);
-  if (d->LookupTable.GetPointer() == 0)
-    {
-    Q_ASSERT(d->LookupTable.GetPointer());
-    return QColor();
-    }
-  QColor minValue = QColor::fromHsvF(
-    d->LookupTable->GetHueRange()[0],
-    d->LookupTable->GetSaturationRange()[0],
-    d->LookupTable->GetValueRange()[0],
-    d->LookupTable->GetAlphaRange()[0]);
-  return minValue;
-}
-
-//-----------------------------------------------------------------------------
-QVariant ctkVTKLookupTable::maxValue()const
-{
-  CTK_D(const ctkVTKLookupTable);
-  if (d->LookupTable.GetPointer() == 0)
-    {
-    Q_ASSERT(d->LookupTable.GetPointer());
-    return QColor();
-    }
-  QColor maxValue = QColor::fromHsvF(
-    d->LookupTable->GetHueRange()[1],
-    d->LookupTable->GetSaturationRange()[1],
-    d->LookupTable->GetValueRange()[1],
-    d->LookupTable->GetAlphaRange()[1]);
-  return maxValue;
-}
-
-//-----------------------------------------------------------------------------
-qreal ctkVTKLookupTable::indexToPos(int index)const
-{
-  CTK_D(const ctkVTKLookupTable);
-  double* range = d->LookupTable->GetRange();
-  return range[0] + index * ((range[1] - range[0]) / (d->LookupTable->GetNumberOfColors() - 1));
-}
-
-//-----------------------------------------------------------------------------
-int ctkVTKLookupTable::posToIndex(qreal pos)const
-{
-  CTK_D(const ctkVTKLookupTable);
-  double* range = d->LookupTable->GetRange();
-  return (pos - range[0]) / ((range[1] - range[0]) / (d->LookupTable->GetNumberOfColors() - 1));
-}
-
-//-----------------------------------------------------------------------------
-ctkControlPoint* ctkVTKLookupTable::controlPoint(int index)const
-{
-  CTK_D(const ctkVTKLookupTable);
-  ctkControlPoint* cp = new ctkControlPoint();
-  cp->P.X = this->indexToPos(index);
-  cp->P.Value = this->value(cp->P.X);
-  return cp;
-}
-
-//-----------------------------------------------------------------------------
-QVariant ctkVTKLookupTable::value(qreal pos)const
-{
-  CTK_D(const ctkVTKLookupTable);
-  Q_ASSERT(d->LookupTable.GetPointer());
-  double rgb[3];
-  d->LookupTable->GetColor(pos, rgb);
-  double alpha = d->LookupTable->GetOpacity(pos);
-  return QColor::fromRgbF(rgb[0], rgb[1], rgb[2], alpha);
-}
-
-//-----------------------------------------------------------------------------
-int ctkVTKLookupTable::insertControlPoint(const ctkControlPoint& cp)
-{
-  CTK_D(ctkVTKLookupTable);
-  qDebug() << "ctkVTKLookupTable doesn't support insertControlPoint";
-  return -1;
-}
-
-//-----------------------------------------------------------------------------
-// insert point with value = 0
-int ctkVTKLookupTable::insertControlPoint(qreal pos)
-{
-  // nothing
-  int index = 0;
-
-  return index;
-}
-//-----------------------------------------------------------------------------
-void ctkVTKLookupTable::setControlPointPos(int index, qreal pos)
-{
-  CTK_D(ctkVTKLookupTable);
-  // TODO, inform that nothing is done here.
-  qDebug() << "ctkVTKLookupTable doesn't support setControlPointPos";
-  return;
-}
-
-//-----------------------------------------------------------------------------
-void ctkVTKLookupTable::setControlPointValue(int index, const QVariant& value)
-{
-  CTK_D(ctkVTKLookupTable);
-  Q_ASSERT(value.value<QColor>().isValid());
-  QColor rgba = value.value<QColor>();
-  d->LookupTable->SetTableValue(index, rgba.redF(), rgba.greenF(), rgba.blueF(), rgba.alphaF());
-}
-
-//-----------------------------------------------------------------------------
-void ctkVTKLookupTable::setLookupTable(vtkLookupTable* lookupTable)
-{
-  CTK_D(ctkVTKLookupTable);
-  d->LookupTable = lookupTable;
-  this->qvtkReconnect(d->LookupTable,vtkCommand::ModifiedEvent,
-                      this, SIGNAL(changed()));
-  emit changed();
-}
-
-//-----------------------------------------------------------------------------
-vtkLookupTable* ctkVTKLookupTable::lookupTable()const
-{
-  CTK_D(const ctkVTKLookupTable);
-  return d->LookupTable;
-}
+/*=========================================================================
+
+  Library:   CTK
+ 
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ 
+=========================================================================*/
+
+/// Qt includes
+#include <QColor>
+#include <QDebug>
+
+/// CTK includes
+#include "ctkVTKLookupTable.h"
+
+/// VTK includes
+#include <vtkLookupTable.h>
+#include <vtkSmartPointer.h>
+
+//-----------------------------------------------------------------------------
+class ctkVTKLookupTablePrivate: public ctkPrivate<ctkVTKLookupTable>
+{
+public:
+  vtkSmartPointer<vtkLookupTable> LookupTable;
+};
+
+//-----------------------------------------------------------------------------
+ctkVTKLookupTable::ctkVTKLookupTable(QObject* parentObject)
+  :ctkTransferFunction(parentObject)
+{
+  CTK_INIT_PRIVATE(ctkVTKLookupTable);
+}
+
+//-----------------------------------------------------------------------------
+ctkVTKLookupTable::ctkVTKLookupTable(vtkLookupTable* lookupTable, 
+                                     QObject* parentObject)
+  :ctkTransferFunction(parentObject)
+{
+  CTK_INIT_PRIVATE(ctkVTKLookupTable);
+  this->setLookupTable(lookupTable);
+}
+
+//-----------------------------------------------------------------------------
+ctkVTKLookupTable::~ctkVTKLookupTable()
+{
+}
+
+//-----------------------------------------------------------------------------
+int ctkVTKLookupTable::count()const
+{
+  CTK_D(const ctkVTKLookupTable);
+  if (d->LookupTable.GetPointer() == 0)
+    {
+    Q_ASSERT(d->LookupTable.GetPointer());
+    return -1;
+    }
+  return d->LookupTable->GetNumberOfColors();
+}
+
+//-----------------------------------------------------------------------------
+bool ctkVTKLookupTable::isDiscrete()const
+{
+  return true;
+}
+
+//-----------------------------------------------------------------------------
+bool ctkVTKLookupTable::isEditable()const
+{
+  return true;
+}
+
+//-----------------------------------------------------------------------------
+void ctkVTKLookupTable::range(qreal& minRange, qreal& maxRange)const
+{
+  CTK_D(const ctkVTKLookupTable);
+  if (d->LookupTable.GetPointer() == 0)
+    {
+    Q_ASSERT(d->LookupTable.GetPointer());
+    minRange = 1.; // set incorrect values
+    maxRange = 0.;
+    return;
+    }
+  double rangeValues[2];
+  d->LookupTable->GetTableRange(rangeValues);
+  minRange = rangeValues[0];
+  maxRange = rangeValues[1];
+}
+
+//-----------------------------------------------------------------------------
+QVariant ctkVTKLookupTable::minValue()const
+{
+  CTK_D(const ctkVTKLookupTable);
+  if (d->LookupTable.GetPointer() == 0)
+    {
+    Q_ASSERT(d->LookupTable.GetPointer());
+    return QColor();
+    }
+  QColor minValue = QColor::fromHsvF(
+    d->LookupTable->GetHueRange()[0],
+    d->LookupTable->GetSaturationRange()[0],
+    d->LookupTable->GetValueRange()[0],
+    d->LookupTable->GetAlphaRange()[0]);
+  return minValue;
+}
+
+//-----------------------------------------------------------------------------
+QVariant ctkVTKLookupTable::maxValue()const
+{
+  CTK_D(const ctkVTKLookupTable);
+  if (d->LookupTable.GetPointer() == 0)
+    {
+    Q_ASSERT(d->LookupTable.GetPointer());
+    return QColor();
+    }
+  QColor maxValue = QColor::fromHsvF(
+    d->LookupTable->GetHueRange()[1],
+    d->LookupTable->GetSaturationRange()[1],
+    d->LookupTable->GetValueRange()[1],
+    d->LookupTable->GetAlphaRange()[1]);
+  return maxValue;
+}
+
+//-----------------------------------------------------------------------------
+qreal ctkVTKLookupTable::indexToPos(int index)const
+{
+  CTK_D(const ctkVTKLookupTable);
+  double* range = d->LookupTable->GetRange();
+  return range[0] + index * ((range[1] - range[0]) / (d->LookupTable->GetNumberOfColors() - 1));
+}
+
+//-----------------------------------------------------------------------------
+int ctkVTKLookupTable::posToIndex(qreal pos)const
+{
+  CTK_D(const ctkVTKLookupTable);
+  double* range = d->LookupTable->GetRange();
+  return (pos - range[0]) / ((range[1] - range[0]) / (d->LookupTable->GetNumberOfColors() - 1));
+}
+
+//-----------------------------------------------------------------------------
+ctkControlPoint* ctkVTKLookupTable::controlPoint(int index)const
+{
+  CTK_D(const ctkVTKLookupTable);
+  ctkControlPoint* cp = new ctkControlPoint();
+  cp->P.X = this->indexToPos(index);
+  cp->P.Value = this->value(cp->P.X);
+  return cp;
+}
+
+//-----------------------------------------------------------------------------
+QVariant ctkVTKLookupTable::value(qreal pos)const
+{
+  CTK_D(const ctkVTKLookupTable);
+  Q_ASSERT(d->LookupTable.GetPointer());
+  double rgb[3];
+  d->LookupTable->GetColor(pos, rgb);
+  double alpha = d->LookupTable->GetOpacity(pos);
+  return QColor::fromRgbF(rgb[0], rgb[1], rgb[2], alpha);
+}
+
+//-----------------------------------------------------------------------------
+int ctkVTKLookupTable::insertControlPoint(const ctkControlPoint& cp)
+{
+  CTK_D(ctkVTKLookupTable);
+  qDebug() << "ctkVTKLookupTable doesn't support insertControlPoint";
+  return -1;
+}
+
+//-----------------------------------------------------------------------------
+// insert point with value = 0
+int ctkVTKLookupTable::insertControlPoint(qreal pos)
+{
+  // nothing
+  int index = 0;
+
+  return index;
+}
+//-----------------------------------------------------------------------------
+void ctkVTKLookupTable::setControlPointPos(int index, qreal pos)
+{
+  CTK_D(ctkVTKLookupTable);
+  // TODO, inform that nothing is done here.
+  qDebug() << "ctkVTKLookupTable doesn't support setControlPointPos";
+  return;
+}
+
+//-----------------------------------------------------------------------------
+void ctkVTKLookupTable::setControlPointValue(int index, const QVariant& value)
+{
+  CTK_D(ctkVTKLookupTable);
+  Q_ASSERT(value.value<QColor>().isValid());
+  QColor rgba = value.value<QColor>();
+  d->LookupTable->SetTableValue(index, rgba.redF(), rgba.greenF(), rgba.blueF(), rgba.alphaF());
+}
+
+//-----------------------------------------------------------------------------
+void ctkVTKLookupTable::setLookupTable(vtkLookupTable* lookupTable)
+{
+  CTK_D(ctkVTKLookupTable);
+  d->LookupTable = lookupTable;
+  this->qvtkReconnect(d->LookupTable,vtkCommand::ModifiedEvent,
+                      this, SIGNAL(changed()));
+  emit changed();
+}
+
+//-----------------------------------------------------------------------------
+vtkLookupTable* ctkVTKLookupTable::lookupTable()const
+{
+  CTK_D(const ctkVTKLookupTable);
+  return d->LookupTable;
+}

+ 63 - 63
Libs/Visualization/VTK/Widgets/Testing/Cpp/ctkTransferFunctionWidgetTest5.cpp

@@ -1,63 +1,63 @@
-/*=========================================================================
-
-  Library:   CTK
- 
-  Copyright (c) 2010  Kitware Inc.
-
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-
-      http://www.commontk.org/LICENSE
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
- 
-=========================================================================*/
-
-// Qt includes
-#include <QApplication>
-#include <QSharedPointer>
-#include <QTimer>
-
-// CTK includes
-#include "ctkTransferFunction.h"
-#include "ctkTransferFunctionWidget.h"
-#include "ctkVTKHistogram.h"
-
-// VTK includes
-#include <vtkIntArray.h>
-#include <vtkSmartPointer.h>
-
-// STD includes
-#include <iostream>
-
-//-----------------------------------------------------------------------------
-int ctkTransferFunctionWidgetTest5(int argc, char * argv [] )
-{
-  QApplication app(argc, argv);
-  
-  vtkSmartPointer<vtkIntArray> intArray = 
-    vtkSmartPointer<vtkIntArray>::New();
-  intArray->SetNumberOfComponents(1);
-  intArray->SetNumberOfTuples(2000);
-  for (int i = 0; i < 2000; ++i)
-    {
-    intArray->SetValue(i, qrand() % 30);
-    }
-  QSharedPointer<ctkVTKHistogram> histogram = 
-    QSharedPointer<ctkVTKHistogram>(new ctkVTKHistogram(intArray));
-  histogram->build();
-  ctkTransferFunctionWidget transferFunctionWidget(histogram.data(), 0);
-  // the widget is not really shown here, only when app.exec() is called
-  transferFunctionWidget.show();
-
-  QTimer autoExit;
-  QObject::connect(&autoExit, SIGNAL(timeout()), &app, SLOT(quit()));
-  autoExit.start(1000);
-
-  return app.exec();
-}
+/*=========================================================================
+
+  Library:   CTK
+ 
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ 
+=========================================================================*/
+
+// Qt includes
+#include <QApplication>
+#include <QSharedPointer>
+#include <QTimer>
+
+// CTK includes
+#include "ctkTransferFunction.h"
+#include "ctkTransferFunctionWidget.h"
+#include "ctkVTKHistogram.h"
+
+// VTK includes
+#include <vtkIntArray.h>
+#include <vtkSmartPointer.h>
+
+// STD includes
+#include <iostream>
+
+//-----------------------------------------------------------------------------
+int ctkTransferFunctionWidgetTest5(int argc, char * argv [] )
+{
+  QApplication app(argc, argv);
+  
+  vtkSmartPointer<vtkIntArray> intArray = 
+    vtkSmartPointer<vtkIntArray>::New();
+  intArray->SetNumberOfComponents(1);
+  intArray->SetNumberOfTuples(2000);
+  for (int i = 0; i < 2000; ++i)
+    {
+    intArray->SetValue(i, qrand() % 30);
+    }
+  QSharedPointer<ctkVTKHistogram> histogram = 
+    QSharedPointer<ctkVTKHistogram>(new ctkVTKHistogram(intArray));
+  histogram->build();
+  ctkTransferFunctionWidget transferFunctionWidget(histogram.data(), 0);
+  // the widget is not really shown here, only when app.exec() is called
+  transferFunctionWidget.show();
+
+  QTimer autoExit;
+  QObject::connect(&autoExit, SIGNAL(timeout()), &app, SLOT(quit()));
+  autoExit.start(1000);
+
+  return app.exec();
+}

+ 182 - 182
Libs/Widgets/ctkTransferFunctionWidget.cpp

@@ -1,182 +1,182 @@
-/*=========================================================================
-
-  Library:   CTK
- 
-  Copyright (c) 2010  Kitware Inc.
-
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-
-      http://www.commontk.org/LICENSE
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
- 
-=========================================================================*/
-/// Qt includes
-#include <QDebug>
-//#include <QGLWidget>
-#include <QGraphicsScene>
-#include <QResizeEvent>
-
-/// CTK includes
-#include "ctkHistogram.h"
-#include "ctkTransferFunction.h"
-#include "ctkTransferFunctionWidget.h"
-#include "ctkTransferFunctionScene.h"
-#include "ctkTransferFunctionGradientItem.h"
-#include "ctkTransferFunctionControlPointsItem.h"
-#include "ctkTransferFunctionBarsItem.h"
-
-//-----------------------------------------------------------------------------
-class ctkTransferFunctionWidgetPrivate: public ctkPrivate<ctkTransferFunctionWidget>
-{
-  CTK_DECLARE_PUBLIC(ctkTransferFunctionWidget);
-public:
-  ctkTransferFunctionWidgetPrivate();
-  void init();
-  ctkTransferFunction* TransferFunction;
-};
-
-//-----------------------------------------------------------------------------
-ctkTransferFunctionWidgetPrivate::ctkTransferFunctionWidgetPrivate()
-{
-  this->TransferFunction = 0;
-}
-
-//-----------------------------------------------------------------------------
-void ctkTransferFunctionWidgetPrivate::init()
-{
-  CTK_P(ctkTransferFunctionWidget);
-  p->setScene(new ctkTransferFunctionScene(p));
-  p->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-  p->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-  //p->setViewport(new QGLWidget);
-  p->setRenderHint(QPainter::Antialiasing);
-}
-
-//-----------------------------------------------------------------------------
-ctkTransferFunctionWidget::ctkTransferFunctionWidget(QWidget* parentWidget)
-  :QGraphicsView(parentWidget)
-{
-  CTK_INIT_PRIVATE(ctkTransferFunctionWidget);
-  ctk_d()->init();
-}
-
-//-----------------------------------------------------------------------------
-ctkTransferFunctionWidget::ctkTransferFunctionWidget(
-  ctkTransferFunction* transferFunction, QWidget* parentWidget)
-  :QGraphicsView(parentWidget)
-{
-  CTK_INIT_PRIVATE(ctkTransferFunctionWidget);
-  ctk_d()->init();
-  this->setTransferFunction(transferFunction);
-}
-//-----------------------------------------------------------------------------
-ctkTransferFunctionWidget::~ctkTransferFunctionWidget()
-{
-}
-
-//-----------------------------------------------------------------------------
-void ctkTransferFunctionWidget::setTransferFunction(ctkTransferFunction* transferFunction)
-{
-  CTK_D(ctkTransferFunctionWidget);
-  d->TransferFunction = transferFunction;
-  ctkTransferFunctionScene* tfScene = dynamic_cast<ctkTransferFunctionScene*>(this->scene());
-  Q_ASSERT(tfScene);
-  tfScene->clear();
-  tfScene->setTransferFunction(transferFunction);
-
-  ctkTransferFunctionGradientItem* gradient = 
-    new ctkTransferFunctionGradientItem(transferFunction);
-  //gradient->setRect(tfScene->sceneRect());
-  this->scene()->addItem(gradient);
-
-  if (qobject_cast<ctkHistogram*>(transferFunction) != 0)
-    {
-    gradient->setMask(false);
-    ctkTransferFunctionBarsItem* histogramItem = 
-      new ctkTransferFunctionBarsItem(transferFunction);
-    //controlPoints->setRect(tfScene->sceneRect());
-    this->scene()->addItem(histogramItem);
-    }
-  else
-    {
-    ctkTransferFunctionControlPointsItem* controlPoints = 
-      new ctkTransferFunctionControlPointsItem(transferFunction);
-    //controlPoints->setRect(tfScene->sceneRect());
-    this->scene()->addItem(controlPoints);
-    } 
-}
-
-//-----------------------------------------------------------------------------
-ctkTransferFunction* ctkTransferFunctionWidget::transferFunction()const
-{
-  return ctk_d()->TransferFunction;
-}
-
-//-----------------------------------------------------------------------------
-void ctkTransferFunctionWidget::resizeEvent(QResizeEvent * event)
-{
-  /*
-  QRectF sceneRect(QPointF(0,0),event->size());
-  this->scene()->setSceneRect(sceneRect);
-  foreach(QGraphicsItem * item, this->scene()->items())
-    {
-    ctkTransferFunctionItem* rectItem = 
-      qgraphicsitem_cast<ctkTransferFunctionItem*>(item);
-    if (rectItem)
-      {
-      rectItem->setRect(sceneRect);
-      }
-    }
-  */
-  QMatrix zoomMatrix;
-  zoomMatrix.scale(event->size().width(), event->size().height());
-  bool blocked = this->blockSignals(true);
-  this->setMatrix(zoomMatrix);
-  this->blockSignals(blocked);
-  this->QGraphicsView::resizeEvent(event);
-  // Control points are resized by the view transform, we want
-  // fixed size control points, lines...
-  //this->fitInView(this->scene()->sceneRect());
-  qDebug() << "resize event caught";
-}
-/*
-//-----------------------------------------------------------------------------
-void ctkTransferFunctionWidget::dragEnterEvent ( QDragEnterEvent * event )
-{
-  qDebug() << "drag event caught";
-
-  this->QGraphicsView::dragEnterEvent(event);
-
-}
-
-//-----------------------------------------------------------------------------
-void ctkTransferFunctionWidget::mousePressEvent ( QMouseEvent * event )
-{
-  qDebug() << "press event caught";
-  //One control point is added to the scene
-  // 1 - get position of the mouse
-  qDebug() << "x position " << event->x();
-  qDebug() << "y position " << event->y();
-
-  this->scene()->items()[1]->;
-
-  // 2nd item are the control points
-
-  this->QGraphicsView::mousePressEvent(event);
-}
-
-//-----------------------------------------------------------------------------
-void ctkTransferFunctionWidget::mouseReleaseEvent ( QMouseEvent * event )
-{
-  qDebug() << "release event caught";
-
-  this->QGraphicsView::mouseReleaseEvent(event);
-}
-*/
+/*=========================================================================
+
+  Library:   CTK
+ 
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ 
+=========================================================================*/
+/// Qt includes
+#include <QDebug>
+//#include <QGLWidget>
+#include <QGraphicsScene>
+#include <QResizeEvent>
+
+/// CTK includes
+#include "ctkHistogram.h"
+#include "ctkTransferFunction.h"
+#include "ctkTransferFunctionWidget.h"
+#include "ctkTransferFunctionScene.h"
+#include "ctkTransferFunctionGradientItem.h"
+#include "ctkTransferFunctionControlPointsItem.h"
+#include "ctkTransferFunctionBarsItem.h"
+
+//-----------------------------------------------------------------------------
+class ctkTransferFunctionWidgetPrivate: public ctkPrivate<ctkTransferFunctionWidget>
+{
+  CTK_DECLARE_PUBLIC(ctkTransferFunctionWidget);
+public:
+  ctkTransferFunctionWidgetPrivate();
+  void init();
+  ctkTransferFunction* TransferFunction;
+};
+
+//-----------------------------------------------------------------------------
+ctkTransferFunctionWidgetPrivate::ctkTransferFunctionWidgetPrivate()
+{
+  this->TransferFunction = 0;
+}
+
+//-----------------------------------------------------------------------------
+void ctkTransferFunctionWidgetPrivate::init()
+{
+  CTK_P(ctkTransferFunctionWidget);
+  p->setScene(new ctkTransferFunctionScene(p));
+  p->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+  p->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+  //p->setViewport(new QGLWidget);
+  p->setRenderHint(QPainter::Antialiasing);
+}
+
+//-----------------------------------------------------------------------------
+ctkTransferFunctionWidget::ctkTransferFunctionWidget(QWidget* parentWidget)
+  :QGraphicsView(parentWidget)
+{
+  CTK_INIT_PRIVATE(ctkTransferFunctionWidget);
+  ctk_d()->init();
+}
+
+//-----------------------------------------------------------------------------
+ctkTransferFunctionWidget::ctkTransferFunctionWidget(
+  ctkTransferFunction* transferFunction, QWidget* parentWidget)
+  :QGraphicsView(parentWidget)
+{
+  CTK_INIT_PRIVATE(ctkTransferFunctionWidget);
+  ctk_d()->init();
+  this->setTransferFunction(transferFunction);
+}
+//-----------------------------------------------------------------------------
+ctkTransferFunctionWidget::~ctkTransferFunctionWidget()
+{
+}
+
+//-----------------------------------------------------------------------------
+void ctkTransferFunctionWidget::setTransferFunction(ctkTransferFunction* transferFunction)
+{
+  CTK_D(ctkTransferFunctionWidget);
+  d->TransferFunction = transferFunction;
+  ctkTransferFunctionScene* tfScene = dynamic_cast<ctkTransferFunctionScene*>(this->scene());
+  Q_ASSERT(tfScene);
+  tfScene->clear();
+  tfScene->setTransferFunction(transferFunction);
+
+  ctkTransferFunctionGradientItem* gradient = 
+    new ctkTransferFunctionGradientItem(transferFunction);
+  //gradient->setRect(tfScene->sceneRect());
+  this->scene()->addItem(gradient);
+
+  if (qobject_cast<ctkHistogram*>(transferFunction) != 0)
+    {
+    gradient->setMask(false);
+    ctkTransferFunctionBarsItem* histogramItem = 
+      new ctkTransferFunctionBarsItem(transferFunction);
+    //controlPoints->setRect(tfScene->sceneRect());
+    this->scene()->addItem(histogramItem);
+    }
+  else
+    {
+    ctkTransferFunctionControlPointsItem* controlPoints = 
+      new ctkTransferFunctionControlPointsItem(transferFunction);
+    //controlPoints->setRect(tfScene->sceneRect());
+    this->scene()->addItem(controlPoints);
+    } 
+}
+
+//-----------------------------------------------------------------------------
+ctkTransferFunction* ctkTransferFunctionWidget::transferFunction()const
+{
+  return ctk_d()->TransferFunction;
+}
+
+//-----------------------------------------------------------------------------
+void ctkTransferFunctionWidget::resizeEvent(QResizeEvent * event)
+{
+  /*
+  QRectF sceneRect(QPointF(0,0),event->size());
+  this->scene()->setSceneRect(sceneRect);
+  foreach(QGraphicsItem * item, this->scene()->items())
+    {
+    ctkTransferFunctionItem* rectItem = 
+      qgraphicsitem_cast<ctkTransferFunctionItem*>(item);
+    if (rectItem)
+      {
+      rectItem->setRect(sceneRect);
+      }
+    }
+  */
+  QMatrix zoomMatrix;
+  zoomMatrix.scale(event->size().width(), event->size().height());
+  bool blocked = this->blockSignals(true);
+  this->setMatrix(zoomMatrix);
+  this->blockSignals(blocked);
+  this->QGraphicsView::resizeEvent(event);
+  // Control points are resized by the view transform, we want
+  // fixed size control points, lines...
+  //this->fitInView(this->scene()->sceneRect());
+  qDebug() << "resize event caught";
+}
+/*
+//-----------------------------------------------------------------------------
+void ctkTransferFunctionWidget::dragEnterEvent ( QDragEnterEvent * event )
+{
+  qDebug() << "drag event caught";
+
+  this->QGraphicsView::dragEnterEvent(event);
+
+}
+
+//-----------------------------------------------------------------------------
+void ctkTransferFunctionWidget::mousePressEvent ( QMouseEvent * event )
+{
+  qDebug() << "press event caught";
+  //One control point is added to the scene
+  // 1 - get position of the mouse
+  qDebug() << "x position " << event->x();
+  qDebug() << "y position " << event->y();
+
+  this->scene()->items()[1]->;
+
+  // 2nd item are the control points
+
+  this->QGraphicsView::mousePressEvent(event);
+}
+
+//-----------------------------------------------------------------------------
+void ctkTransferFunctionWidget::mouseReleaseEvent ( QMouseEvent * event )
+{
+  qDebug() << "release event caught";
+
+  this->QGraphicsView::mouseReleaseEvent(event);
+}
+*/

+ 31 - 31
Utilities/QtMobility/QtMobilityGitBranch1.0-win32.patch.in

@@ -1,31 +1,31 @@
---- C:/development/CTK-master-vc9/CMakeExternals/Source/QtMobility/configure_orig.bat	Sun Apr 11 18:17:43 2010
-+++ C:/development/CTK-master-vc9/CMakeExternals/Source/QtMobility/configure.bat	Sun Apr 11 21:19:33 2010
-@@ -60,7 +60,7 @@
- set MOBILITY_MODULES=bearer location contacts multimedia publishsubscribe versit messaging systeminfo serviceframework sensors
- set MOBILITY_MODULES_UNPARSED=
- set VC_TEMPLATE_OPTION=
--set QT_PATH=
-+set QT_PATH=@QT_BINARY_DIR@\
- set QMAKE_CACHE=%BUILD_PATH%\.qmake.cache
- 
- if exist "%QMAKE_CACHE%" del %QMAKE_CACHE%
-@@ -457,10 +457,15 @@
- echo.
- echo Start of compile tests
- REM compile tests go here.
--call :compileTest LBT lbt
--call :compileTest SNAP snap
--call :compileTest OCC occ
--call :compileTest SymbianContactSIM symbiancntsim
-+REM for CTK the compile tests generate errors in Visual Studio -> just disabling them
-+REM call :compileTest LBT lbt
-+echo lbt_enabled = no >> %PROJECT_CONFIG%
-+REM call :compileTest SNAP snap
-+echo snap_enabled = no >> %PROJECT_CONFIG%
-+REM call :compileTest OCC occ
-+echo occ_enabled = no >> %PROJECT_CONFIG%
-+REM call :compileTest SymbianContactSIM symbiancntsim
-+echo symbiancntsim_enabled = no >> %PROJECT_CONFIG%
- echo End of compile tests
- echo.
- echo.
+--- C:/development/CTK-master-vc9/CMakeExternals/Source/QtMobility/configure_orig.bat	Sun Apr 11 18:17:43 2010
++++ C:/development/CTK-master-vc9/CMakeExternals/Source/QtMobility/configure.bat	Sun Apr 11 21:19:33 2010
+@@ -60,7 +60,7 @@
+ set MOBILITY_MODULES=bearer location contacts multimedia publishsubscribe versit messaging systeminfo serviceframework sensors
+ set MOBILITY_MODULES_UNPARSED=
+ set VC_TEMPLATE_OPTION=
+-set QT_PATH=
++set QT_PATH=@QT_BINARY_DIR@\
+ set QMAKE_CACHE=%BUILD_PATH%\.qmake.cache
+ 
+ if exist "%QMAKE_CACHE%" del %QMAKE_CACHE%
+@@ -457,10 +457,15 @@
+ echo.
+ echo Start of compile tests
+ REM compile tests go here.
+-call :compileTest LBT lbt
+-call :compileTest SNAP snap
+-call :compileTest OCC occ
+-call :compileTest SymbianContactSIM symbiancntsim
++REM for CTK the compile tests generate errors in Visual Studio -> just disabling them
++REM call :compileTest LBT lbt
++echo lbt_enabled = no >> %PROJECT_CONFIG%
++REM call :compileTest SNAP snap
++echo snap_enabled = no >> %PROJECT_CONFIG%
++REM call :compileTest OCC occ
++echo occ_enabled = no >> %PROJECT_CONFIG%
++REM call :compileTest SymbianContactSIM symbiancntsim
++echo symbiancntsim_enabled = no >> %PROJECT_CONFIG%
+ echo End of compile tests
+ echo.
+ echo.