00001 #ifndef IGUANA_GL_BROWSERS_IG_TWIG_CONFIG_ELEMENT_H
00002 # define IGUANA_GL_BROWSERS_IG_TWIG_CONFIG_ELEMENT_H
00003
00004
00005
00006 #include "Iguana/GLBrowsers/interface/config.h"
00007 #include "Iguana/Framework/interface/IgExtension.h"
00008 #include <string>
00009 #include <vector>
00010 #include <map>
00011
00012
00013
00014
00015
00016 class SoMaterial;
00017 class SoDrawStyle;
00018 class SoNode;
00019
00020
00021
00022
00023
00024 class IGUANA_GL_BROWSERS_API IgTwigConfigElement : public IgExtension
00025 {
00026 IG_DECLARE_STATE_ELEMENT (IgTwigConfigElement);
00027 public:
00028 IgTwigConfigElement (IgState* state);
00029 ~IgTwigConfigElement ();
00030
00031 void setMaterialType (const std::string& type="Default");
00032 void setDrawStyleType (const std::string& type="Default");
00033 void setVisibilityType (const std::string& type="Default");
00034
00035 const std::string& getMaterialType () const;
00036 const std::string& getDrawStyleType () const;
00037 const std::string& getVisibilityType () const;
00038
00039 SoMaterial* material (const std::string& name,
00040 const std::string& type="") const;
00041 SoDrawStyle* drawStyle (const std::string& name,
00042 const std::string& type="") const;
00043 bool visibility (const std::string& name,
00044 const std::string& type="") const;
00045
00046 void addMaterial (const std::string& name, SoMaterial* material,
00047 const std::string& type="");
00048 void addDrawStyle (const std::string& name, SoDrawStyle* style,
00049 const std::string& type="");
00050 void addVisibility (const std::string& name, bool visibility,
00051 const std::string& type="");
00052
00053 void replaceMaterial (SoNode* node, const std::string& name,
00054 const std::string& type="") const;
00055 void replaceDrawStyle (SoNode* node, const std::string& name,
00056 const std::string& type="") const;
00057 private:
00058 void init ();
00059 void initMaterial ();
00060 void initDrawStyle ();
00061 void initVisibility ();
00062
00063 void addMaterialAlias (const std::string& alias, const std::string& to,
00064 const std::string& type="");
00065 void addDrawStyleAlias (const std::string& alias, const std::string& to,
00066 const std::string& type="");
00067 SoMaterial* findMaterial (const std::string& name,
00068 const std::string& type="")const;
00069 SoDrawStyle* findDrawStyle (const std::string& name,
00070 const std::string& type="")const;
00071 bool findVisibility (const std::string& name,
00072 const std::string& type="")const;
00073 void replaceMaterial_ (SoNode* oldNode, const SoMaterial* newNode) const;
00074 void replaceDrawStyle_ (SoNode* oldNode, const SoDrawStyle* newNode) const;
00075
00076 IgState* m_state;
00077 std::string m_materialType;
00078 std::string m_drawStyleType;
00079 std::string m_visibilityType;
00080
00081 typedef std::pair<std::string, SoMaterial*> MaterialInfo;
00082 typedef std::pair<std::string, SoDrawStyle*> DrawStyleInfo;
00083 typedef std::pair<std::string, bool> VisibilityInfo;
00084 typedef std::vector<MaterialInfo> Material;
00085 typedef std::vector<DrawStyleInfo> DrawStyle;
00086 typedef std::vector<VisibilityInfo> Visibility;
00087 typedef std::map<std::string,Material> MaterialMap;
00088 typedef std::map<std::string,DrawStyle> DrawStyleMap;
00089 typedef std::map<std::string,Visibility> VisibilityMap;
00090
00091 MaterialMap m_material;
00092 DrawStyleMap m_drawStyle;
00093 VisibilityMap m_visibility;
00094 };
00095
00096
00097
00098
00099 #endif // IGUANA_GL_BROWSERS_IG_TWIG_CONFIG_ELEMENT_H