00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef MODIFYOBJECT_H
00028 #define MODIFYOBJECT_H
00029
00030
00031 #include <sofa/core/objectmodel/BaseObject.h>
00032
00033
00034 #include <sofa/component/topology/PointData.h>
00035 #include <sofa/component/forcefield/SpringForceField.h>
00036 #include <sofa/component/forcefield/JointSpringForceField.h>
00037 #include <sofa/defaulttype/Vec.h>
00038 #include <sofa/defaulttype/VecTypes.h>
00039 #include <sofa/defaulttype/RigidTypes.h>
00040 #include <sofa/simulation/common/Node.h>
00041 #include <sofa/component/misc/Monitor.h>
00042
00043 #include <qglobal.h>
00044 #ifdef SOFA_QT4
00045 #include <QDialog>
00046 #include <Q3ListViewItem>
00047 #include <Q3ListView>
00048 #include <Q3Table>
00049 #include <Q3GroupBox>
00050 #include <Q3TextEdit>
00051 #include <QPushButton>
00052 #include <QTabWidget>
00053 #include <QSpinBox>
00054 #include <Q3CheckListItem>
00055 #else
00056 #include <qdialog.h>
00057 #include <qlistview.h>
00058 #include <qtable.h>
00059 #include <qgroupbox.h>
00060 #include <qtextedit.h>
00061 #include <qtabwidget.h>
00062 #include <qpushbutton.h>
00063 #include <qspinbox.h>
00064 #endif
00065
00066 #include "WFloatLineEdit.h"
00067
00068 #include <qwt_plot.h>
00069
00070 #include <qwt_plot_curve.h>
00071 #include <sofa/gui/qt/DisplayFlagWidget.h>
00072
00073 class QPushButton;
00074
00075 namespace sofa
00076 {
00077
00078 namespace gui
00079 {
00080
00081 namespace qt
00082 {
00083
00084 using sofa::helper::Quater;
00085 using namespace sofa::defaulttype;
00086 using sofa::simulation::Node;
00087
00088 #ifndef SOFA_QT4
00089 typedef QListView Q3ListView;
00090 typedef QListViewItem Q3ListViewItem;
00091 typedef QCheckListItem Q3CheckListItem;
00092 typedef QTable Q3Table;
00093 typedef QGroupBox Q3GroupBox;
00094 typedef QTextEdit Q3TextEdit;
00095 #endif
00096 class ModifyObject : public QDialog
00097 {
00098 Q_OBJECT
00099 public:
00100
00101 ModifyObject(){};
00102 ModifyObject( void *Id, core::objectmodel::Base* node, Q3ListViewItem* item_clicked, QWidget* parent, const char* name= 0, bool modal= FALSE, Qt::WFlags f= 0 );
00103 ~ModifyObject()
00104 {
00105 delete buttonUpdate;
00106 }
00107
00108 void setNode(core::objectmodel::Base* node, Q3ListViewItem* item_clicked=NULL);
00109
00110 bool hideData(core::objectmodel::BaseData* data){ return (!data->isDisplayed()) && HIDE_FLAG;};
00111
00112
00113 public slots:
00114 void updateValues();
00115 void updateTextEdit();
00116 void updateTables();
00117 void saveTables();
00118 void saveTextEdit();
00119 void changeValue();
00120 void changeVisualValue();
00121 void closeNow (){emit(reject());}
00122 void reject (){ emit(dialogClosed(Id)); deleteLater();QDialog::reject();}
00123 void accept (){ updateValues(); emit(dialogClosed(Id)); deleteLater();QDialog::accept();}
00124 void resizeTable(int);
00125
00126 signals:
00127 void objectUpdated();
00128 void dialogClosed(void *);
00129 void transformObject(Node * current_node, double translationX, double translationY, double translationZ,
00130 double rotationX, double rotationY, double rotationZ,
00131 double scale);
00132
00133 protected:
00134
00135
00136 const core::objectmodel::BaseData* getData(const QObject *object);
00137 virtual void closeEvent ( QCloseEvent * ){emit(reject());}
00138 void updateContext( Node *node );
00139
00140 void createGraphMass(QTabWidget *);
00141 void updateHistory();
00142 void updateEnergy();
00143
00144 bool createTable(core::objectmodel::BaseData* field, Q3GroupBox *box=NULL, Q3Table* vectorTable=NULL, Q3Table* vectorTable2=NULL, Q3Table* vectorTable3=NULL );
00145 void storeTable(std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table);
00146
00147
00148 void createVector( core::objectmodel::BaseData* object,const Quater<double> &value, Q3GroupBox *box);
00149 void createVector( core::objectmodel::BaseData* object,const Quater<float> &value, Q3GroupBox *box);
00150
00151
00152 template< int N, class T>
00153 void createVector( core::objectmodel::BaseData* object,const Vec<N,T> &value, Q3GroupBox *box);
00154 template< int N, class T>
00155 void storeVector( unsigned int &index, Data< Vec<N,T> > *ff);
00156 template<class T>
00157 void storeVector( unsigned int &index, Data< Quater<T> > *ff);
00158 template< int N, class T>
00159 void storeVector( unsigned int &index, DataPtr< Vec<N,T> > *ff);
00160 template<class T>
00161 void storeVector( unsigned int &index, DataPtr< Quater<T> > *ff);
00162 template< int N, class T>
00163 void storeVector( unsigned int &index, Vec<N,T> *ff);
00164 template<class T>
00165 void storeVector(unsigned int &index, Quater<T> *ff);
00166
00167 template< class T>
00168 bool createQtTable(Data< sofa::helper::vector< T > > *ff, Q3GroupBox *box, Q3Table* vectorTable );
00169 template<class T>
00170 void storeQtTable(std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, Data< sofa::helper::vector< T > >* ff );
00171
00172 void storeQtTable( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, Data< sofa::helper::vector< std::string > >* ff );
00173
00174
00175 template< class T>
00176 bool createQtTable(DataPtr< sofa::helper::vector< T > > *ff, Q3GroupBox *box, Q3Table* vectorTable );
00177 template< class T>
00178 void storeQtTable(std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, DataPtr< sofa::helper::vector< T > >* ff );
00179
00180 template< int N, class T>
00181 bool createQtTable(Data< sofa::helper::vector< Vec<N,T> > > *ff, Q3GroupBox *box, Q3Table* vectorTable );
00182 template< int N, class T>
00183 void storeQtTable( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, Data< sofa::helper::vector< Vec<N,T> > >* ff );
00184
00185 template< int N, class T>
00186 bool createQtTable(DataPtr< sofa::helper::vector< Vec<N,T> > > *ff, Q3GroupBox *box, Q3Table* vectorTable );
00187 template< int N, class T>
00188 void storeQtTable( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, DataPtr< sofa::helper::vector< Vec<N,T> > >* ff );
00189
00190 template< class T>
00191 bool createQtTable(Data< sofa::component::topology::PointData< T > > *ff, Q3GroupBox *box, Q3Table* vectorTable );
00192 template< class T>
00193 void storeQtTable( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, Data< sofa::component::topology::PointData< T > >* ff );
00194
00195
00196
00197 template< class T>
00198 bool createMonitorQtTable(Data<typename sofa::component::misc::Monitor<T>::MonitorData >* ff, Q3GroupBox *box, Q3Table* vectorTable, Q3Table* vectorTable2, Q3Table* vectorTable3 );
00199 template< class T>
00200 void storeMonitorQtTable( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, Data< typename sofa::component::misc::Monitor<T>::MonitorData >* ff );
00201
00202
00203
00204
00205 template< int N, class T>
00206 bool createQtTable(Data< sofa::helper::vector< RigidCoord<N,T> > > *ff, Q3GroupBox *box, Q3Table* vectorTable, Q3Table* vectorTable2 );
00207 template<class T>
00208 void storeQtRigid3Table( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, Data< sofa::helper::vector< RigidCoord<3,T> > >* ff );
00209 template<class T>
00210 void storeQtRigid2Table( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, Data< sofa::helper::vector< RigidCoord<2,T> > >* ff );
00211
00212
00213 template< int N, class T>
00214 bool createQtTable(Data< sofa::helper::vector< RigidDeriv<N,T> > > *ff, Q3GroupBox *box, Q3Table* vectorTable, Q3Table* vectorTable2 );
00215 template<class T>
00216 void storeQtRigid3Table( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, Data< sofa::helper::vector< RigidDeriv<3,T> > >* ff );
00217 template<class T>
00218 void storeQtRigid2Table( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, Data< sofa::helper::vector< RigidDeriv<2,T> > >* ff );
00219
00220
00221 template< int N, class T>
00222 bool createQtTable(DataPtr< sofa::helper::vector< RigidCoord<N,T> > > *ff, Q3GroupBox *box, Q3Table* vectorTable, Q3Table* vectorTable2 );
00223 template<class T>
00224 void storeQtRigid3Table( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, DataPtr< sofa::helper::vector< RigidCoord<3,T> > >* ff );
00225 template<class T>
00226 void storeQtRigid2Table( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, DataPtr< sofa::helper::vector< RigidCoord<2,T> > >* ff );
00227
00228
00229 template< int N, class T>
00230 bool createQtTable(DataPtr< sofa::helper::vector< RigidDeriv<N,T> > > *ff, Q3GroupBox *box, Q3Table* vectorTable, Q3Table* vectorTable2 );
00231 template<class T>
00232 void storeQtRigid3Table( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, DataPtr< sofa::helper::vector< RigidDeriv<3,T> > >* ff );
00233 template<class T>
00234 void storeQtRigid2Table( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, DataPtr< sofa::helper::vector< RigidDeriv<2,T> > >* ff );
00235
00236
00237 template< int N, class T>
00238 bool createQtSpringTable(Data< sofa::helper::vector< typename sofa::component::forcefield::SpringForceField< StdVectorTypes< Vec<N,T>, Vec<N,T>, T> >::Spring > > *ff, Q3GroupBox *box, Q3Table* vectorTable );
00239 template< int N, class T>
00240 void storeQtSpringTable( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, Data< sofa::helper::vector< typename sofa::component::forcefield::SpringForceField< StdVectorTypes< Vec<N,T>, Vec<N,T>, T> >::Spring > > *ff);
00241
00242
00243 template< class T>
00244 bool createQtRigidSpringTable(Data< sofa::helper::vector< typename sofa::component::forcefield::JointSpringForceField< StdRigidTypes< 3,T > >::Spring > > *ff, Q3GroupBox *box, Q3Table* vectorTable );
00245 template< class T>
00246 void storeQtRigidSpringTable( std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> >::iterator &it_list_table, Data< sofa::helper::vector< typename sofa::component::forcefield::JointSpringForceField< StdRigidTypes<3,T> >::Spring > > *ff );
00247
00248
00249
00250 Q3Table* addResizableTable(Q3GroupBox *box,int size, int column=1);
00251
00252 QWidget *parent;
00253 QTabWidget *dialogTab;
00254 core::objectmodel::Base* node;
00255 Q3ListViewItem * item;
00256 QPushButton *buttonUpdate;
00257 std::vector<std::pair< core::objectmodel::BaseData*, QObject*> > objectGUI;
00258 std::set< const core::objectmodel::BaseData* > setUpdates;
00259 std::list< std::pair< Q3Table*, core::objectmodel::BaseData*> > list_Table;
00260 std::list< std::pair< Q3TextEdit*, core::objectmodel::BaseData*> > list_TextEdit;
00261 std::map< core::objectmodel::BaseData*, int > dataIndexTab;
00262 std::map< QSpinBox*, Q3Table* > resizeMap;
00263 std::set< Q3Table* > setResize;
00264 WFloatLineEdit* transformation[7];
00265
00266 void *Id;
00267 bool visualContentModified;
00268
00269
00270 DisplayFlagWidget *displayFlag;
00271
00272 std::vector< double > history;
00273 std::vector< double > energy_history[3];
00274 QwtPlot *graphEnergy;
00275 QwtPlotCurve *energy_curve[3];
00276 unsigned int counterWidget;
00277
00278 bool HIDE_FLAG;
00279 bool EMPTY_FLAG;
00280 bool RESIZABLE_FLAG;
00281 bool REINIT_FLAG;
00282 };
00283
00284 }
00285
00286 }
00287
00288 }
00289
00290 #endif
00291