Hosted by: BerliOS Developer Logo

OpenMBV C++ Interface

BerliOS Project Page
/home/user/MBSimWindows/openmbv/openmbvcppinterface/openmbvcppinterface/dynamiccoloredbody.h
00001 /*
00002     OpenMBV - Open Multi Body Viewer.
00003     Copyright (C) 2009 Markus Friedrich
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 #ifndef _OPENMBV_DYNAMICCOLOREDBODY_H_
00021 #define _OPENMBV_DYNAMICCOLOREDBODY_H_
00022 
00023 #include <openmbvcppinterface/body.h>
00024 #include <mbxmlutilstinyxml/utils.h>
00025 
00026 namespace OpenMBV {
00027 
00029   class DynamicColoredBody : public Body {
00030     protected:
00031       ScalarParameter minimalColorValue, maximalColorValue;
00032       ScalarParameter staticColor;
00033       double dynamicColor;
00034       VectorParameter diffuseColor;
00035       ScalarParameter transparency;
00036 
00037       ~DynamicColoredBody();
00038     public:
00039       DynamicColoredBody();
00040 
00045       void setMinimalColorValue(const ScalarParameter min) {
00046         set(minimalColorValue,min);
00047       }
00048 
00049       double getMinimalColorValue() { return get(minimalColorValue); }
00050 
00054       void setMaximalColorValue(const ScalarParameter max) {
00055         set(maximalColorValue,max);
00056       }
00057 
00058       double getMaximalColorValue() { return get(maximalColorValue); }
00059 
00065       void setStaticColor(const ScalarParameter col) {
00066         MBXMLUtils::Deprecated::registerMessage("setStaticColor is deprecated, use setDiffuseColor instead.");
00067         set(staticColor,col);
00068       }
00069 
00071       double getStaticColor(bool internalDoNotUse=true) {
00072         if(internalDoNotUse)
00073           MBXMLUtils::Deprecated::registerMessage("getStaticColor is deprecated, use getDiffuseColor instead.");
00074         return get(staticColor);
00075       }
00076 
00081       void setDynamicColor(const double col) {
00082         dynamicColor=col;
00083       }
00084 
00085       double getDynamicColor() { return dynamicColor; }
00086 
00091       void setDiffuseColor(const VectorParameter &hsv) {
00092         if(hsv.getParamStr()=="" && hsv.getValue().size()!=3) throw std::runtime_error("the dimension does not match");
00093         set(diffuseColor,hsv);
00094       }
00095 
00096       void setDiffuseColor(const std::vector<double> &hsv) {
00097         if(hsv.size()!=3) throw std::runtime_error("the diemension does not match");
00098         set(diffuseColor,hsv);
00099       }
00100 
00101       void setDiffuseColor(double h, double s, double v) {
00102         std::vector<double> hsv;
00103         hsv.push_back(h);
00104         hsv.push_back(s);
00105         hsv.push_back(v);
00106         diffuseColor=hsv;
00107       }
00108 
00109       std::vector<double> getDiffuseColor() { return get(diffuseColor); }
00110 
00112       void setTransparency(ScalarParameter t) {
00113         set(transparency,t);
00114       }
00115 
00116       double getTransparency() { return get(transparency); }
00117 
00119       virtual void initializeUsingXML(MBXMLUtils::TiXmlElement *element);
00120 
00121       MBXMLUtils::TiXmlElement* writeXMLFile(MBXMLUtils::TiXmlNode *parent);
00122   };
00123 
00124 }
00125 
00126 #endif