00001 /****************************************************************************** 00002 * SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3 * 00003 * (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS * 00004 * * 00005 * This library is free software; you can redistribute it and/or modify it * 00006 * under the terms of the GNU Lesser General Public License as published by * 00007 * the Free Software Foundation; either version 2.1 of the License, or (at * 00008 * your option) any later version. * 00009 * * 00010 * This library is distributed in the hope that it will be useful, but WITHOUT * 00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * 00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * 00013 * for more details. * 00014 * * 00015 * You should have received a copy of the GNU Lesser General Public License * 00016 * along with this library; if not, write to the Free Software Foundation, * 00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 00018 ******************************************************************************* 00019 * SOFA :: Modules * 00020 * * 00021 * Authors: The SOFA Team and external contributors (see Authors.txt) * 00022 * * 00023 * Contact information: contact@sofa-framework.org * 00024 ******************************************************************************/ 00025 // 00026 // C++ Interface: ArticulatedHierarchyController 00027 // 00028 // Description: 00029 // 00030 // 00031 // Author: Pierre-Jean Bensoussan, Digital Trainers (2008) 00032 // 00033 // Copyright: See COPYING file that comes with this distribution 00034 // 00035 // 00036 00037 #ifndef SOFA_COMPONENT_CONTROLLER_ARTICULATEDHIERARCHYCONTROLLER_H 00038 #define SOFA_COMPONENT_CONTROLLER_ARTICULATEDHIERARCHYCONTROLLER_H 00039 00040 #include <sofa/component/controller/Controller.h> 00041 00042 #include <sofa/component/container/ArticulatedHierarchyContainer.h> 00043 #include <sofa/core/objectmodel/BaseObject.h> 00044 #include <sofa/helper/vector.h> 00045 00046 #include <map> 00047 00048 namespace sofa 00049 { 00050 00051 namespace component 00052 { 00053 00054 namespace controller 00055 { 00056 00057 using sofa::component::container::ArticulatedHierarchyContainer; 00058 00067 class ArticulatedHierarchyController : public Controller 00068 { 00069 public: 00070 typedef std::vector< ArticulatedHierarchyContainer::ArticulationCenter * > ArtCenterVec; 00071 typedef ArtCenterVec::iterator ArtCenterVecIt; 00072 typedef std::vector< ArticulatedHierarchyContainer::ArticulationCenter::Articulation * > ArtVec; 00073 typedef ArtVec::iterator ArtVecIt; 00074 00078 ArticulatedHierarchyController(); 00079 00083 virtual ~ArticulatedHierarchyController(){}; 00084 00088 virtual void init(); 00089 00094 00098 void onMouseEvent(core::objectmodel::MouseEvent *); 00099 00103 void onKeyPressedEvent(core::objectmodel::KeypressedEvent *); 00104 00108 void onBeginAnimationStep(void); 00110 00114 virtual void applyController(void); 00115 00116 protected: 00117 Data<sofa::helper::vector< int > > articulationsIndices; 00118 Data<sofa::helper::vector< char > > bindingKeys; 00119 Data< double > angleDelta; 00120 Data< bool > propagateUserInteraction; 00121 00122 sofa::helper::vector< bool > activeArticulations; 00123 std::map<int, sofa::helper::vector< int > > articulationsPropagationChains; 00124 00128 void buildPropagationArticulationsChain(void); 00129 00133 void buildArray(std::vector< int > &, ArticulatedHierarchyContainer::ArticulationCenter::Articulation* , ArticulatedHierarchyContainer::ArticulationCenter* ); 00134 00138 void updateActiveArticulationsIndices(const char); 00139 00144 void dumpActiveArticulations(void) const ; 00145 void dumpArticulationsAndBindingKeys(void) const; 00146 //}@ 00147 00151 void resetControler(void); 00152 00153 00157 enum MouseMode { None=0, BtLeft, BtRight, BtMiddle, Wheel }; 00158 MouseMode mouseMode; 00159 00160 double signFactor; 00161 bool propagationChain; 00162 00163 ArtCenterVec m_artCenterVec; 00164 }; 00165 00166 } // namespace controller 00167 00168 } // namespace component 00169 00170 } // namespace sofa 00171 00172 #endif //SOFA_COMPONENT_CONTROLLER_ARTICULATEDHIERARCHYCONTROLLER_H
1.5.7.1