Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
igl::anttweakbar Namespace Reference

Classes

class  ReTwBar
 
struct  ReTwCBItem
 
struct  ReTwRWItem
 

Functions

IGL_INLINE int cocoa_key_to_anttweakbar_key (int key)
 
TwType ReTwDefineEnum (const char *name, const TwEnumVal *enumValues, unsigned int nbValues)
 
TwType ReTwDefineEnumFromString (const char *name, const char *enumString)
 

Function Documentation

◆ cocoa_key_to_anttweakbar_key()

IGL_INLINE int igl::anttweakbar::cocoa_key_to_anttweakbar_key ( int  key)
13{
14 // I've left commented the AntTweakBar key codes that correspond to keys I
15 // don't have on my keyboard. Please fill this in if you have those keys
16 switch(key)
17 {
18 case 127:
19 return TW_KEY_BACKSPACE;
20 case 9:
21 return TW_KEY_TAB;
22 //TW_KEY_CLEAR = 0x0c,
23 case 3://ENTER
24 case 13:
25 return TW_KEY_RETURN;
26 case 27:
27 return TW_KEY_ESCAPE;
28 case 32:
29 return TW_KEY_SPACE;
30 // IN A GLUT APP 40 is (
31 //case 40:
32 case 63272:
33 return TW_KEY_DELETE;
34 case 63232:
35 return TW_KEY_UP;
36 case 63233:
37 return TW_KEY_DOWN;
38 case 63235:
39 return TW_KEY_RIGHT;
40 case 63234:
41 return TW_KEY_LEFT;
42 //TW_KEY_INSERT,
43 //TW_KEY_HOME,
44 //TW_KEY_END,
45 //TW_KEY_PAGE_UP,
46 //TW_KEY_PAGE_DOWN,
47 case 63236:
48 return TW_KEY_F1;
49 case 63237:
50 return TW_KEY_F2;
51 case 63238:
52 return TW_KEY_F3;
53 case 63239:
54 return TW_KEY_F4;
55 case 63240:
56 return TW_KEY_F5;
57 case 63241:
58 return TW_KEY_F6;
59 case 63242:
60 return TW_KEY_F7;
61 case 63243:
62 return TW_KEY_F8;
63 case 63244:
64 return TW_KEY_F9;
65 case 63245:
66 return TW_KEY_F10;
67 case 63246:
68 return TW_KEY_F11;
69 case 63247:
70 return TW_KEY_F12;
71 case 63248:
72 return TW_KEY_F13;
73 case 63249:
74 return TW_KEY_F14;
75 case 63250:
76 return TW_KEY_F15;
77 default:
78 break;
79 }
80 return key;
81}

◆ ReTwDefineEnum()

IGL_INLINE TwType igl::anttweakbar::ReTwDefineEnum ( const char *  name,
const TwEnumVal *  enumValues,
unsigned int  nbValues 
)
29{
30 using namespace std;
31 // copy enum valus into vector
32 std::vector<TwEnumVal> enum_vals;
33 enum_vals.resize(nbValues);
34 for(unsigned int j = 0; j<nbValues;j++)
35 {
36 enum_vals[j] = enumValues[j];
37 }
38 TwType type = TwDefineEnum(name,enumValues,nbValues);
39
40 ReTw_custom_types[type] =
41 std::pair<const char *,std::vector<TwEnumVal> >(name,enum_vals);
42
43 return type;
44}
std::map< TwType, std::pair< const char *, std::vector< TwEnumVal > > > ReTw_custom_types
Definition ReAntTweakBar.cpp:22
STL namespace.

References anonymous_namespace{ReAntTweakBar.cpp}::ReTw_custom_types.

Referenced by ReTwDefineEnumFromString().

+ Here is the caller graph for this function:

◆ ReTwDefineEnumFromString()

IGL_INLINE TwType igl::anttweakbar::ReTwDefineEnumFromString ( const char *  name,
const char *  enumString 
)
49{
50 // Taken directly from TwMgr.cpp, just replace TwDefineEnum with
51 // ReTwDefineEnum
52 using namespace std;
53 {
54 if (_EnumString == NULL)
55 return ReTwDefineEnum(_Name, NULL, 0);
56
57 // split enumString
58 stringstream EnumStream(_EnumString);
59 string Label;
60 vector<string> Labels;
61 while( getline(EnumStream, Label, ',') ) {
62 // trim Label
63 size_t Start = Label.find_first_not_of(" \n\r\t");
64 size_t End = Label.find_last_not_of(" \n\r\t");
65 if( Start==string::npos || End==string::npos )
66 Label = "";
67 else
68 Label = Label.substr(Start, (End-Start)+1);
69 // store Label
70 Labels.push_back(Label);
71 }
72 // create TwEnumVal array
73 vector<TwEnumVal> Vals(Labels.size());
74 for( int i=0; i<(int)Labels.size(); i++ )
75 {
76 Vals[i].Value = i;
77 // Wrong:
78 //Vals[i].Label = Labels[i].c_str();
79 // Allocate char on heap
80 // http://stackoverflow.com/a/10050258/148668
81 char * c_label = new char[Labels[i].length()+1];
82 std::strcpy(c_label, Labels[i].c_str());
83 Vals[i].Label = c_label;
84 }
85
86 const TwType type =
87 ReTwDefineEnum(_Name, Vals.empty() ?
88 NULL :
89 &(Vals[0]), (unsigned int)Vals.size());
90 return type;
91 }
92}
TwType ReTwDefineEnum(const char *name, const TwEnumVal *enumValues, unsigned int nbValues)
Definition ReAntTweakBar.cpp:25

References ReTwDefineEnum().

+ Here is the call graph for this function: