00001 #include <qradiobutton.h>
00002
00003 #include <animal/X3DTK/Qt/engineGUI/engineGUI.h>
00004 #include <animal/X3DTK/Qt/objectGUI/WFloatLineEdit.h>
00005 #include <animal/X3DTK/X3D/morphingNode/morphingNode.h>
00006 #include <animal/engine/morphingEngine.inl>
00007
00008 #include "morphingEngineQt.h"
00009
00010 namespace X3DTK{
00011 namespace Qt{
00012
00013 MorphingEngineQt::MorphingEngineQt( AMorphingEngine * morphingEngine)
00014 : MorphingEngineDesigner(0,"main q object")
00015 , morphingEngine(morphingEngine)
00016 {
00017
00018
00019 connect(linearRadioButton,SIGNAL(toggled(bool)),
00020 this, SLOT(toggleLinearMethod(bool)));
00021 connect(CatmullRomRadioButton,SIGNAL(toggled(bool)),
00022 this, SLOT(toggleCatmullRomMethod(bool)));
00023
00024
00025 if (morphingEngine->getInterpolationID())
00026 linearRadioButton->setChecked(false);
00027 else
00028 linearRadioButton->setChecked(true);
00029
00030 wFloatLineEdit1->setMinFloatValue( 0.0 );
00031 wFloatLineEdit1->setMaxFloatValue( 100.0 );
00032 wFloatLineEdit1->setFloatValue( *morphingEngine->getVelocity() );
00033
00034 }
00035
00036 MorphingEngineQt::~MorphingEngineQt()
00037 {
00038
00039 }
00040
00041
00042
00044 void MorphingEngineQt::toggleLinearMethod(bool b)
00045 {
00046 morphingEngine->toggleLinearMethod(b);
00047 emit changed();
00048 }
00049
00050 void MorphingEngineQt::toggleCatmullRomMethod(bool b)
00051 {
00052 morphingEngine->toggleCatmullRomMethod(b);
00053 emit changed();
00054 }
00055
00056 void MorphingEngineQt::setMethodID(int n)
00057 {
00058 if (n ==0)
00059 {
00060 if (!linearRadioButton->isOn()) linearRadioButton->toggle();
00061
00062 }
00063 else if (n==1)
00064 {
00065 if (!CatmullRomRadioButton->isOn()) CatmullRomRadioButton->toggle();
00066
00067 }
00068 emit changed();
00069 }
00070
00071 void MorphingEngineQt::changeVelocity(float v)
00072 {
00073 morphingEngine->setVelocity(v);
00074 emit changed();
00075 }
00076
00078 QWidget * createMorphingNodeQWidget(X3D::MorphingNode * node, QWidget * parent)
00079 {
00080
00081
00082 if (node )
00083 {
00084 MorphingEngineQt * KFEQt = new MorphingEngineQt(node);
00085 KFEQt->reparent(parent, QPoint(0,0));
00086
00087
00088 int n = *node->getInterpolationID();
00089 KFEQt->setMethodID(n);
00090
00091
00092 EngineGUI * engineGUI = static_cast<EngineGUI *>(createEngineNodeQWidget(node, parent));
00093 engineGUI->insertTab(KFEQt, "Morphing",0);
00094 engineGUI->setCurrentPage(0);
00095 QWidget::connect( KFEQt, SIGNAL( changed() ), engineGUI, SLOT(ok()));
00096
00097 return engineGUI;
00098 }
00099
00100 std::cerr<<"Warning createMorphingNodeQWidget(): impossible to create a X3DTK::Qt::EngineGUI because the associated animal::Engine is NULL."<<std::endl;
00101 std::cerr<<" or the MainController is NULL."<<std::endl;
00102 return NULL;
00103 }
00104
00105 }
00106 }
00107