Documentation


SFVector2GUI.cpp

Go to the documentation of this file.
00001 
00002 //                            SFVector2GUI.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 "SFVector2GUI.h"
00017 
00018 namespace X3DTK {
00019 namespace Qt{
00020 
00021 /* 
00022  *  Constructs a SFVector2GUI as a child of 'parent'
00023  */
00024 SFVector2GUI::SFVector2GUI(QString nameOfField, animal::Vec2 * 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     // The layout
00032     SFVector2Layout = new QHBoxLayout(this);
00033     SFVector2Layout->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     
00047     // signals and slots connections
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  *  Destroys the object and frees any allocated resources
00056  */
00057 SFVector2GUI::~SFVector2GUI()
00058 {
00059     // no need to delete child widgets, Qt does it all for us
00060 }
00061 
00062 void SFVector2GUI::setValue()
00063 {
00064     editX->setFloatValue((*Vec2ToEdit)[0]);
00065     editY->setFloatValue((*Vec2ToEdit)[1]);
00066 }
00067 
00068 void SFVector2GUI::changeValueX(float f)
00069 {
00070     (*Vec2ToEdit)[0] = f;
00071     emit changed();
00072 }
00073 void SFVector2GUI::changeValueY(float f)
00074 {
00075     (*Vec2ToEdit)[1] = f;
00076     emit changed();
00077 }
00078 } // Qt
00079 } // X3DTK

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