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 #include "SFVector4GUI.h"
00016
00017 namespace X3DTK {
00018 namespace Qt{
00019
00020
00021
00022
00023 SFVector4GUI::SFVector4GUI(QString nameOfField, animal::Vec4 * Vec4ToEdit, QWidget * parent, const char* name, WFlags fl)
00024 : QWidget(parent, name, fl)
00025 , Vec4ToEdit(Vec4ToEdit)
00026 {
00027 if ( !name )
00028 setName( "SFVector4 GUI" );
00029
00030
00031 SFVector4Layout = new QHBoxLayout(this);
00032 SFVector4Layout->setAutoAdd(true);
00033
00034
00035 new QLabel(nameOfField, this);
00036
00037
00038 editX = new WFloatLineEdit(this, "editX" );
00039 editX->setMinFloatValue( -INFINITY );
00040 editX->setMaxFloatValue( INFINITY );
00041
00042 editY = new WFloatLineEdit(this, "editY" );
00043 editY->setMinFloatValue( -INFINITY );
00044 editY->setMaxFloatValue( INFINITY );
00045
00046 editZ = new WFloatLineEdit(this, "editZ" );
00047 editZ->setMinFloatValue( -INFINITY );
00048 editZ->setMaxFloatValue( INFINITY );
00049
00050 editA = new WFloatLineEdit(this, "editA" );
00051 editA->setMinFloatValue( -INFINITY );
00052 editA->setMaxFloatValue( INFINITY );
00053
00054
00055 connect( editX, SIGNAL( floatValueChanged(float) ), this, SLOT( changeValueX(float) ) );
00056 connect( editY, SIGNAL( floatValueChanged(float) ), this, SLOT( changeValueY(float) ) );
00057 connect( editZ, SIGNAL( floatValueChanged(float) ), this, SLOT( changeValueZ(float) ) );
00058 connect( editA, SIGNAL( floatValueChanged(float) ), this, SLOT( changeValueA(float) ) );
00059
00060 setValue();
00061 }
00062
00063
00064
00065
00066 SFVector4GUI::~SFVector4GUI()
00067 {
00068
00069 }
00070
00071 void SFVector4GUI::setValue()
00072 {
00073 editX->setFloatValue((*Vec4ToEdit)[0]);
00074 editY->setFloatValue((*Vec4ToEdit)[1]);
00075 editZ->setFloatValue((*Vec4ToEdit)[2]);
00076 editA->setFloatValue((*Vec4ToEdit)[3]);
00077 }
00078
00079 void SFVector4GUI::changeValueX(float f)
00080 {
00081 (*Vec4ToEdit)[0] = f;
00082 emit changed();
00083 }
00084 void SFVector4GUI::changeValueY(float f)
00085 {
00086 (*Vec4ToEdit)[1] = f;
00087 emit changed();
00088 }
00089 void SFVector4GUI::changeValueZ(float f)
00090 {
00091 (*Vec4ToEdit)[2] = f;
00092 emit changed();
00093 }
00094 void SFVector4GUI::changeValueA(float f)
00095 {
00096 (*Vec4ToEdit)[3] = f;
00097 emit changed();
00098 }
00099 }
00100 }