Documentation


SFFloatGUI.cpp

Go to the documentation of this file.
00001 
00002 //                            SFFloatGUI.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 #include <animal/X3DTK/Qt/objectGUI/WFloatLineEdit.h>
00014 
00015 #include "SFFloatGUI.h"
00016 
00017 namespace X3DTK {
00018 namespace Qt{
00019 
00020 /* 
00021  *  Constructs a SFFloatGUI as a child of 'parent'
00022  */
00023 SFFloatGUI::SFFloatGUI(QString nameOfField, float * floatToEdit, QWidget * parent, const char* name, WFlags fl)
00024 : QWidget(parent, name, fl)
00025 , floatToEdit(floatToEdit)
00026 {
00027     if ( !name )
00028       setName( "SFFloat GUI" );
00029     
00030     // The layout
00031     SFFloatLayout = new QHBoxLayout(this);
00032     SFFloatLayout->setAutoAdd(true);
00033     
00034     // The label
00035     new QLabel(nameOfField, this);
00036     
00037     // the float line edit
00038     editSFFloat = new WFloatLineEdit( this, "editSFFloat" );
00039     editSFFloat->setMinFloatValue( -INFINITY );
00040     editSFFloat->setMaxFloatValue( INFINITY );
00041     
00042     //resize( QSize(124, 41).expandedTo(minimumSizeHint()) );
00043 
00044     // signals and slots connections
00045     connect( editSFFloat, SIGNAL( floatValueChanged(float) ), this, SLOT( changeValue(float) ) );
00046     
00047     setValue();
00048 }
00049 
00050 /*
00051  *  Destroys the object and frees any allocated resources
00052  */
00053 SFFloatGUI::~SFFloatGUI()
00054 {
00055     // no need to delete child widgets, Qt does it all for us
00056 }
00057 
00058 void SFFloatGUI::setValue()
00059 {
00060     editSFFloat->setFloatValue(*floatToEdit);
00061 }
00062 
00063 void SFFloatGUI::changeValue(float f)
00064 {
00065     *floatToEdit = f;
00066     emit changed();
00067 }
00068 } // Qt
00069 } // X3DTK

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