static void keyboard( unsigned char key, int , int ) { int winId = glutGetWindow(); Visualize *currWindow = _windows[winId - 1]; bool signflag = GetSignFlag(); bool fieldflag = GetFieldFlag(); bool meshflag = GetMeshFlag(); bool cellflag = GetCellFlag(); bool gradflag = GetGradientFlag(); bool borderflag = GetBorderFlag(); switch ( key ) { case '-': // Zoom out currWindow->d_angle++; break; case '+': // Zoom in currWindow->d_angle--; break; case 'd': // Show/hide distance field if (fieldflag == true) SetFieldFlag(false); else SetFieldFlag(true); break; case 's': // Toggle signed/unsigned distance field if (signflag == true) SetSignFlag(false); else SetSignFlag(true); break; case 'm': // Show/hide Mesh if (meshflag == true) SetMeshFlag(false); else SetMeshFlag(true); break; case 'c': // Show/hide cell centers if (cellflag == true) SetCellFlag(false); else SetCellFlag(true); break; case 'g': // Show/hide gradients if (gradflag == true) SetGradientFlag(false); else SetGradientFlag(true); break; case 'b': // Show/hide border flags if (borderflag == true) SetBorderFlag(false); else SetBorderFlag(true); break; case 'w': // Display regenerated surface and save it into a file if (newsurf != NULL) { Visualize *window2 = new Visualize(newsurf); glutDisplayFunc(display_cb); // register Display Function glutKeyboardFunc(keyboard); // register Keyboard Handler glutMouseWheelFunc(mouseWheel); // register scrollwheel handler glutSpecialFunc(SpecialInput); // register arrow keys glutMotionFunc(mouse_cb); // Save regenerated surface into a file std::string ext; DistIO::CutExt( _fileName, _fileName, ext ); newsurf->name(_fileName + "_NET"); newsurf->save(_fileName + "_NET" + ext); // Save Distance field into a file DistIO::GetInstance()->SaveDistField (distObj); } break; case 'f': // Save Distance field into a file DistIO::GetInstance()->SaveDistField (distObj); break; default: break; } glutPostRedisplay(); }
_SEntityDefProperties* CDefParser::ReadProperty(SEntityDef* pDef, TiXmlElement* node) { _SEntityDefProperties* pProp = new _SEntityDefProperties; pProp->m_name.assign(node->Value()); TiXmlElement* field_attri = node->FirstChildElement("Type"); if(field_attri) { const char* szTypeName = field_attri->GetText(); VTYPE vt = GetVTypeByStr(szTypeName); if(vt != V_TYPE_ERR) { pProp->m_nType = vt; } //else if(strcmp(szTypeName, "ARRAY") == 0) //{ // //array of ***特殊处理 //} else { //未定义的类型 ThrowException(-1, "Property '%s' has unsupported type: '%s'.", pProp->m_name.c_str(), szTypeName); } } //Flags pProp->m_nFlags = 0; field_attri = node->FirstChildElement("Flags"); if(field_attri) { const char* _szFlag = field_attri->GetText(); if(UpperStrCmp(_szFlag, "BASE")) { SetBaseFlag(pProp->m_nFlags); } else if(UpperStrCmp(_szFlag, "BASE_AND_CLIENT")) { SetBaseFlag(pProp->m_nFlags); SetClientFlag(pProp->m_nFlags); } else if(UpperStrCmp(_szFlag, "CELL")) { SetCellFlag(pProp->m_nFlags); } else if(UpperStrCmp(_szFlag, "CELL_AND_CLIENT")) { SetCellFlag(pProp->m_nFlags); SetClientFlag(pProp->m_nFlags); pDef->m_bHasCellClient = true; } else if(UpperStrCmp(_szFlag, "ALL_CLIENTS")) { SetCellFlag(pProp->m_nFlags); SetClientFlag(pProp->m_nFlags); SetOtherClientsFlag(pProp->m_nFlags); pDef->m_bHasCellClient = true; } else if(UpperStrCmp(_szFlag, "OTHER_CLIENTS")) { //注意和all_clients的区别 SetCellFlag(pProp->m_nFlags); //setClientFlag(pProp->m_nFlags); SetOtherClientsFlag(pProp->m_nFlags); //pDef->m_bHasCellClient = false; } else { ThrowException(-1, "unknown properties flag:%s", _szFlag); } } //该字段是否base和cell共有的字段 field_attri = node->FirstChildElement("BaseAndCell"); if(field_attri) { if(UpperStrCmp(field_attri->GetText(), "TRUE")) { SetCellFlag(pProp->m_nFlags); SetBaseFlag(pProp->m_nFlags); } } //该字段是否保存到数据库 field_attri = node->FirstChildElement("Persistent"); if(field_attri) { if(UpperStrCmp(field_attri->GetText(), "TRUE")) { pProp->m_bSaveDb = true; //cell属性不能有存盘标记(除非是cell和base共有的属性) if(IsCellFlag(pProp->m_nFlags) && !IsBaseFlag(pProp->m_nFlags)) { ThrowException(-1, "CELL(but Base) properties cant set Persistent to TRUE"); } } else { pProp->m_bSaveDb = false; } } else { pProp->m_bSaveDb = false; } //该字段是否有缺省值 field_attri = node->FirstChildElement("Default"); if(field_attri) { pProp->m_defaultValue.assign(field_attri->GetText()); } else { pProp->m_defaultValue.assign(""); } //该字段是否创建唯一索引 field_attri = node->FirstChildElement("UniqueIndex"); if(field_attri) { if(pDef->m_strUniqueIndex.empty()) { pDef->m_strUniqueIndex.assign(node->Value()); } else { //多个字段申明了唯一索引 ThrowException(-1, "At least two properties set unique_index, '%s' vs '%s'", \ pDef->m_strUniqueIndex.c_str(), node->Value()); } } return pProp; }