Documentation


x3dTransformQt.cpp

Go to the documentation of this file.
00001 
00002 //                            x3dTransformQt.cpp                              //
00004 
00005 #include <animal/X3DTK/Qt/mainControllerGUI/MainController.h>
00006 
00007 #include "x3dTransformQt.h"
00008 
00009 namespace X3DTK
00010 {
00011   namespace Qt
00012   {
00013 
00014     X3DTransformQt::X3DTransformQt( X3D::FrameNode * frameNode,
00015                                     FieldList & fieldList,
00016                                     QWidget* parent)
00017         : ObjectGUI(fieldList, parent)//, MC)
00018         , frameNode(frameNode)
00019     {
00020 
00021 //       QWidget::connect( this, SIGNAL( changed() ), MC, SLOT(computeBbox()));
00022 //       QWidget::connect( this, SIGNAL( changed() ), MC, SLOT(display()));
00023       connect(this, SIGNAL( changed() ), this, SLOT( update()));
00024     }
00025 
00026     void X3DTransformQt::update()
00027     {
00028       frameNode->updateFrameNode();
00029     }
00030 
00032     QWidget * createTransformQWidget(X3D::Transform * node, QWidget * parent)
00033     {
00034       //std::cerr<<"createTransformQWidget"<<std::endl;
00035 
00036       // parent is the child of the scrollview, child of the QDialog, child of the MC !!
00037       // (See in MainController::createQWidgetController(...))
00038       MainController * MC = dynamic_cast<MainController *>(parent->parent()->parent()->parent());
00039       if (node && MC)
00040       {
00041         // The associated FrameNode
00042         X3D::FrameNode * frameNode = NULL;
00043 
00044         // Search if Transform has already its associated FrameNode and if the only one
00045         MFNode childList = node->getChildList();
00046         for(MFNode::iterator it =  childList.begin() ; it !=  childList.end() ; ++it)
00047         {
00048           if (X3D::FrameNode * FN = dynamic_cast<X3D::FrameNode *>(*it))
00049             if (!frameNode)
00050               frameNode = FN;
00051             else
00052             {
00053               std::cerr<<"Warning createTransformQWidget(): impossible to create a X3DTK::Qt::X3DTransformQt because there is not only one associated X3DTK::X3D::FrameNode"<<std::endl;
00054               return NULL;
00055             }
00056         }
00057         if (!frameNode)
00058         {
00059           frameNode = new X3D::FrameNode();
00060           MC->addNode(frameNode);
00061         }
00062 
00063         // The list of all the fields to control in the GUI
00064         FieldList fieldList;
00065 
00066         //Translation field
00067         fieldList.push_back(new X3DSFVec3f("Translation", &frameNode->translation));
00068 
00069         //Rotation field
00070         fieldList.push_back(new X3DSFRotation("Rotation (angle in radian)", &frameNode->rotation));
00071 
00072         //Scale field
00073         fieldList.push_back(new X3DSFVec3f("Scale", &frameNode->scale));
00074 
00075         //Scale orientation field
00076         fieldList.push_back(new X3DSFRotation("Scale orientation (angle in radian)", &frameNode->scaleOrientation));
00077 
00078         //Center field
00079         fieldList.push_back(new X3DSFVec3f("Center", &frameNode->center));
00080 
00081         // The GUI generated with the field list
00082         //ObjectGUI objectGUI(fieldList, parent, s1);
00083 
00084         // The GUI corresponding to a X3DTK::X3D::Transform
00085         X3DTransformQt * X3DTransformGUI = new X3DTransformQt(frameNode, fieldList, parent);
00086         X3DTransformGUI->setTabLabel(X3DTransformGUI->page(0), QString("Transform"));
00087 
00088         // Connection to refresh the display
00089         //         QWidget::connect( X3DTransformGUI, SIGNAL(changed()), MC, SLOT(computeBbox()));
00090         //         QWidget::connect( X3DTransformGUI, SIGNAL(changed()), MC, SLOT(display()));
00091 
00092         return X3DTransformGUI;
00093       }
00094       else
00095       {
00096         std::cerr<<"Warning createTransformQWidget(): impossible to create a X3DTK::Qt::X3DTransformQt because the associated X3D::Transform is NULL."<<std::endl;
00097         std::cerr<<"        or the QWidget Parent is not a MainController"<<std::endl;
00098       }
00099       return NULL;
00100     }
00101 
00102   } // Qt
00103 } // X3DTK

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