00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef CONTOUR_WIDGET_HPP
00021 #define CONTOUR_WIDGET_HPP
00022
00023 #include <QtGui/QWidget>
00024 #include <QtGui/QSlider>
00025 #include <QtGui/QVBoxLayout>
00026
00027 #include <QVTKWidget.h>
00028 #include <vtkContourFilter.h>
00029 #include <vtkDoubleArray.h>
00030
00031 #include <QRealSpinBox.hpp>
00032
00033 #include <iostream>
00034
00035 class ContourWidget
00036 : public QVBoxLayout
00037 {
00038 Q_OBJECT
00039
00040 private:
00041 QVTKWidget* __window;
00042 vtkContourFilter* __contour;
00043 vtkDoubleArray* __values;
00044
00045 QRealSpinBox* __spinBox;
00046 QSlider* __slider;
00047 public slots:
00048
00049 void setPercentage(int i)
00050 {
00051 if (__spinBox->percentage() != __slider->value()) {
00052 __spinBox->setPercentage(__slider->value());
00053 }
00054 __contour->SetValue(0,__spinBox->value());
00055
00056 }
00057
00058 void setValue(real_t v)
00059 {
00060 if (__spinBox->percentage() != __slider->value()) {
00061 __slider->setValue(__spinBox->percentage());
00062 }
00063 __contour->SetValue(0,v);
00064
00065 }
00066
00067 public:
00068 void set(QVTKWidget* window,
00069 vtkContourFilter* contour,
00070 vtkDoubleArray* value)
00071 {
00072 __window = window;
00073 __contour = contour;
00074 __values = value;
00075 __spinBox->setRange(__values->GetRange()[0], __values->GetRange()[1]);
00076 }
00077
00078 ContourWidget(QWidget* parent = 0)
00079 : QVBoxLayout(parent),
00080 __spinBox(new QRealSpinBox(0., 1., 3, 0.01, parent)),
00081 __slider(new QSlider(Qt::Horizontal, parent))
00082 {
00083
00084
00085 connect(__slider,SIGNAL(valueChanged(int)), this, SLOT(setPercentage(int)) );
00086 connect(__spinBox,SIGNAL(valueChanged(real_t)), this, SLOT(setValue(real_t)));
00087 }
00088
00089 ~ContourWidget()
00090 {
00091 ;
00092 }
00093 };
00094
00095
00096 #endif // CONTOUR_WIDGET_HPP