123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- namespace igl
- {
- namespace anttweakbar
- {
- class ReTwBar;
- }
- };
- namespace tinyxml2
- {
- class XMLDocument;
- };
- namespace igl
- {
- namespace xml
- {
-
- // namespace
- // {
-
- // IGL_INLINE bool save_ReAntTweakBar(::igl::anttweakbar::ReTwBar* bar, const char* file_name);
-
-
- IGL_INLINE bool save_ReAntTweakBar(::igl::anttweakbar::ReTwBar* bar, const char* file_name)
- {
- const char * name_chars = TwGetBarName(bar->bar);
- std::string name = std::string(name_chars) + "_AntTweakBar";
-
- const std::vector< ::igl::anttweakbar::ReTwRWItem>& rw_items = bar->get_rw_items();
- for(std::vector< ::igl::anttweakbar::ReTwRWItem>::const_iterator it = rw_items.begin(); it != rw_items.end(); it++)
- {
- std::string val = bar->get_value_as_string(it->var,it->type);
-
- ::igl::serialize_xml(val,it->name,file_name,false,false);
- }
-
- char var[REANTTWEAKBAR_MAX_CB_VAR_SIZE];
-
- const std::vector< ::igl::anttweakbar::ReTwCBItem>& cb_items = bar->get_cb_items();
- for(std::vector< ::igl::anttweakbar::ReTwCBItem>::const_iterator it = cb_items.begin(); it != cb_items.end(); it++)
- {
- TwType type = it->type;
-
- TwGetVarCallback getCallback = it->getCallback;
- void * clientData = it->clientData;
-
-
-
- getCallback(var,clientData);
-
- std::string val = bar->get_value_as_string(var,type);
-
- ::igl::serialize_xml(val,it->name,file_name,false,false);
- }
-
- return true;
- }
-
-
-
- IGL_INLINE bool load_ReAntTweakBar(::igl::anttweakbar::ReTwBar* bar, const char *file_name)
- {
- char type_str[REANTTWEAKBAR_MAX_WORD];
- char value_str[REANTTWEAKBAR_MAX_WORD];
- TwType type;
-
- const char * name_chars = TwGetBarName(bar->bar);
- std::string name = std::string(name_chars) + "_AntTweakBar";
-
- const std::vector< ::igl::anttweakbar::ReTwRWItem>& rw_items = bar->get_rw_items();
- for(std::vector< ::igl::anttweakbar::ReTwRWItem>::const_iterator it = rw_items.begin(); it != rw_items.end(); it++)
- {
- char* val;
-
- ::igl::deserialize_xml(val,it->name,file_name);
- sscanf(val,"%s %[^\n]",type_str,value_str);
-
- if(!bar->type_from_string(type_str,type))
- {
- printf("ERROR: %s type not found... Skipping...\n",type_str);
- continue;
- }
-
- bar->set_value_from_string(it->name.c_str(),type,value_str);
- delete[] val;
- }
-
- const std::vector< ::igl::anttweakbar::ReTwCBItem>& cb_items = bar->get_cb_items();
- for(std::vector< ::igl::anttweakbar::ReTwCBItem>::const_iterator it = cb_items.begin(); it != cb_items.end(); it++)
- {
- char* val;
-
- ::igl::deserialize_xml(val,it->name,file_name);
- sscanf(val,"%s %[^\n]",type_str,value_str);
-
- if(!bar->type_from_string(type_str,type))
- {
- printf("ERROR: %s type not found... Skipping...\n",type_str);
- continue;
- }
-
- bar->set_value_from_string(it->name.c_str(),type,value_str);
- delete[] val;
- }
-
- return true;
- }
-
-
-
- }
- }
|