Documentation


SFVector4GUI.cpp

Go to the documentation of this file.
00001 
00002 //                            SFVector4GUI.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 #include "SFVector4GUI.h"
00016 
00017 namespace X3DTK {
00018 namespace Qt{
00019 
00020 /* 
00021  *  Constructs a SFVector4GUI as a child of 'parent'
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     // The layout
00031     SFVector4Layout = new QHBoxLayout(this);
00032     SFVector4Layout->setAutoAdd(true);
00033     
00034     // The label
00035     new QLabel(nameOfField, this);
00036     
00037     // the x line edit
00038     editX = new WFloatLineEdit(this, "editX" );
00039     editX->setMinFloatValue( -INFINITY );
00040     editX->setMaxFloatValue( INFINITY );
00041     // the y line edit
00042     editY = new WFloatLineEdit(this, "editY" );
00043     editY->setMinFloatValue( -INFINITY );
00044     editY->setMaxFloatValue( INFINITY );
00045     // the y line edit
00046     editZ = new WFloatLineEdit(this, "editZ" );
00047     editZ->setMinFloatValue( -INFINITY );
00048     editZ->setMaxFloatValue( INFINITY );
00049     // the a (angle) line edit
00050     editA = new WFloatLineEdit(this, "editA" );
00051     editA->setMinFloatValue( -INFINITY );
00052     editA->setMaxFloatValue( INFINITY );
00053     
00054     // signals and slots connections
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  *  Destroys the object and frees any allocated resources
00065  */
00066 SFVector4GUI::~SFVector4GUI()
00067 {
00068     // no need to delete child widgets, Qt does it all for us
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 } // Qt
00100 } // X3DTK

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