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 "SFVector3GUI.h"
00017
00018 namespace X3DTK {
00019 namespace Qt{
00020
00021
00022
00023
00024 SFVector3GUI::SFVector3GUI(QString nameOfField, animal::Vec3 * Vec3ToEdit, QWidget * parent, const char* name, WFlags fl)
00025 : QWidget(parent, name, fl)
00026 , Vec3ToEdit(Vec3ToEdit)
00027 {
00028 if ( !name )
00029 setName( "SFVector3 GUI" );
00030
00031
00032 SFVector3Layout = new QHBoxLayout(this);
00033 SFVector3Layout->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 editZ = new WFloatLineEdit(this, "editZ" );
00048 editZ->setMinFloatValue( -INFINITY );
00049 editZ->setMaxFloatValue( INFINITY );
00050
00051
00052 connect( editX, SIGNAL( floatValueChanged(float) ), this, SLOT( changeValueX(float) ) );
00053 connect( editY, SIGNAL( floatValueChanged(float) ), this, SLOT( changeValueY(float) ) );
00054 connect( editZ, SIGNAL( floatValueChanged(float) ), this, SLOT( changeValueZ(float) ) );
00055
00056 setValue();
00057 }
00058
00059
00060
00061
00062 SFVector3GUI::~SFVector3GUI()
00063 {
00064
00065 }
00066
00067 void SFVector3GUI::setValue()
00068 {
00069 editX->setFloatValue((*Vec3ToEdit)[0]);
00070 editY->setFloatValue((*Vec3ToEdit)[1]);
00071 editZ->setFloatValue((*Vec3ToEdit)[2]);
00072 }
00073
00074 void SFVector3GUI::changeValueX(float f)
00075 {
00076 (*Vec3ToEdit)[0] = f;
00077 emit changed();
00078 }
00079 void SFVector3GUI::changeValueY(float f)
00080 {
00081 (*Vec3ToEdit)[1] = f;
00082 emit changed();
00083 }
00084 void SFVector3GUI::changeValueZ(float f)
00085 {
00086 (*Vec3ToEdit)[2] = f;
00087 emit changed();
00088 }
00089 }
00090 }