OpenMesh
OpenMesh/Apps/Subdivider/SubdivideWidget.hh
00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                               OpenMesh                                    *
00004  *      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openmesh.org                                *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------* 
00008  *  This file is part of OpenMesh.                                           *
00009  *                                                                           *
00010  *  OpenMesh is free software: you can redistribute it and/or modify         * 
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenMesh is distributed in the hope that it will be useful,              *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenMesh.  If not,                                    *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/ 
00034 
00035 /*===========================================================================*\
00036  *                                                                           *             
00037  *   $Revision: 389 $                                                         *
00038  *   $Date: 2011-04-06 09:25:32 +0200 (Mi, 06 Apr 2011) $                   *
00039  *                                                                           *
00040 \*===========================================================================*/
00041 
00042 //=============================================================================
00043 //
00044 //  CLASS SubdivideWidget
00045 //
00046 //=============================================================================
00047 
00048 #ifndef SUBDIVIDEWIDGET_HH
00049 #define SUBDIVIDEWIDGET_HH
00050 
00051 
00052 //== INCLUDES =================================================================
00053 
00054 #include <QTimer>
00055 #include <QMainWindow>
00056 #include <QStatusBar>
00057 #include <OpenMesh/Apps/Subdivider/MeshViewerWidget.hh>
00058 #include <OpenMesh/Tools/Subdivider/Uniform/SubdividerT.hh>
00059 
00060 
00061 
00062 
00063 //== CLASS DEFINITION =========================================================
00064 
00065 class SubdivideWidget : public QWidget
00066 {
00067   Q_OBJECT
00068   
00069 public:
00070 
00071   typedef OpenMesh::Subdivider::Uniform::SubdividerT< Mesh > Subdivider;
00072 
00073   enum SOPType {
00074     SOP_UniformCompositeLoop,
00075     SOP_UniformCompositeSqrt3,
00076     SOP_UniformLoop,
00077     SOP_UniformSqrt3,
00078     SOP_UniformInterpolatingSqrt3,
00079     SOP_ModifiedButterfly,
00080     SOP_Undefined
00081   };
00082 
00083   typedef std::map< SOPType, Subdivider* > SubdividerPool;
00084 
00085 public:
00086    
00088   SubdivideWidget(QWidget* _parent=0, const char* _name=0);
00089 
00091   ~SubdivideWidget() {};
00092 
00093 
00095   bool open_mesh(const char* _filename);
00096 
00097   void keyPressEvent( QKeyEvent *k );
00098 
00100   QStatusBar *status_bar;
00101   void update();
00102 
00103  
00104 private slots:
00105 
00106   void animate_slot(void);
00107   void slot_select_sop(int i);
00108   void subdiv_slot();
00109   void reset_slot();
00110   void save_slot();
00111   void load_slot();
00112 
00113 private:
00114 
00115   // widgets
00116   MeshViewerWidget* viewer_widget_;
00117 
00118   QTimer *timer_;
00119    
00120   int animate_step_;
00121   int max_animate_steps_;
00122   int msecs_;
00123 
00124   // Selected and current subdivision operator
00125   SOPType sel_topo_type; // selected operator
00126   SOPType cur_topo_type; // active operator
00127 
00128   // 
00129   SubdividerPool subdivider_;
00130 
00131 };
00132 
00133 
00134 //=============================================================================
00135 #endif // SUBDIVIDEWIDGET_HH defined
00136 //=============================================================================
00137 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines