Documentation


SFVector3GUI.cpp

Go to the documentation of this file.
00001 
00002 //                            SFVector3GUI.cpp                                //
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  *  Constructs a SFVector3GUI as a child of 'parent'
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     // The layout
00032     SFVector3Layout = new QHBoxLayout(this);
00033     SFVector3Layout->setAutoAdd(true);
00034     
00035     // The label
00036     new QLabel(nameOfField, this);
00037     
00038     // the x line edit
00039     editX = new WFloatLineEdit(this, "editX" );
00040     editX->setMinFloatValue( -INFINITY );
00041     editX->setMaxFloatValue( INFINITY );
00042     // the y line edit
00043     editY = new WFloatLineEdit(this, "editY" );
00044     editY->setMinFloatValue( -INFINITY );
00045     editY->setMaxFloatValue( INFINITY );
00046     // the y line edit
00047     editZ = new WFloatLineEdit(this, "editZ" );
00048     editZ->setMinFloatValue( -INFINITY );
00049     editZ->setMaxFloatValue( INFINITY );
00050     
00051     // signals and slots connections
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  *  Destroys the object and frees any allocated resources
00061  */
00062 SFVector3GUI::~SFVector3GUI()
00063 {
00064     // no need to delete child widgets, Qt does it all for us
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 } // Qt
00090 } // X3DTK

Generated on Thu Dec 23 13:52:27 2004 by doxygen 1.3.6