00001
00002
00004
00005 #include<iostream>
00006 #include<cmath>
00007 #ifdef _WIN32
00008 #define INFINITY 0x7FFFFFFF
00009 #endif
00010
00011 #include <qlabel.h>
00012 #include <qlayout.h>
00013
00014 #include <animal/X3DTK/Qt/objectGUI/WFloatLineEdit.h>
00015
00016 #include "X3DSFVec2fGUI.h"
00017
00018 namespace X3DTK {
00019 namespace Qt{
00020
00021
00022
00023
00024 X3DSFVec2fGUI::X3DSFVec2fGUI(QString nameOfField, X3DTK::SFVec2f * Vec2ToEdit, QWidget * parent, const char* name, WFlags fl)
00025 : QWidget(parent, name, fl)
00026 , Vec2ToEdit(Vec2ToEdit)
00027 {
00028 if ( !name )
00029 setName( "SFVector2 GUI" );
00030
00031
00032 SFVector2Layout = new QHBoxLayout(this);
00033 SFVector2Layout->setAutoAdd(true);
00034
00035
00036 new QLabel(nameOfField, this);
00037
00038
00039 editX = new WFloatLineEdit(this, "editX" );
00040 editX->setMinFloatValue( -INFINITY );
00041 editX->setMaxFloatValue( INFINITY );
00042
00043 editY = new WFloatLineEdit(this, "editY" );
00044 editY->setMinFloatValue( -INFINITY );
00045 editY->setMaxFloatValue( INFINITY );
00046
00047
00048 connect( editX, SIGNAL( floatValueChanged(float) ), this, SLOT( changeValueX(float) ) );
00049 connect( editY, SIGNAL( floatValueChanged(float) ), this, SLOT( changeValueY(float) ) );
00050
00051 setValue();
00052 }
00053
00054
00055
00056
00057 X3DSFVec2fGUI::~X3DSFVec2fGUI()
00058 {
00059
00060 }
00061
00062 void X3DSFVec2fGUI::setValue()
00063 {
00064 editX->setFloatValue((*Vec2ToEdit).x);
00065 editY->setFloatValue((*Vec2ToEdit).y);
00066 }
00067
00068 void X3DSFVec2fGUI::changeValueX(float f)
00069 {
00070 (*Vec2ToEdit).x = f;
00071 emit changed();
00072 }
00073 void X3DSFVec2fGUI::changeValueY(float f)
00074 {
00075 (*Vec2ToEdit).y = f;
00076 emit changed();
00077 }
00078 }
00079 }