CModelManager::CModelManager() { TRACE("CModelManager::CModelManager"); // create URL to the IFC-schema in the programs folder int step = 1; while (step) { char* localdir = new char[200 *step]; int size = GetModuleFileName(NULL, localdir, 200); if (size <= ((200 * step) - 30)) { m_SchemaFile = new char[200 * step + 20]; CString dirstr(localdir, size); dirstr.Delete(dirstr.ReverseFind('\\'), size - dirstr.ReverseFind('\\')); sprintf(m_SchemaFile, "%s\\IFC2x3_TC1.exp", dirstr.GetBuffer()); step = 0; } else step++; free(localdir); } }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { /* input: -[string] directory, output: -[double array] population sizes. -[double array] remaining lifetime. */ if (nrhs <= 3) { std::uint32_t S(0), R(0); const mwSize *dims = mxGetDimensions(prhs[0]); size_t strlen = dims[1] + 1; char *dir = (char*)malloc(sizeof(char)*strlen); mxGetString(prhs[0], dir, strlen); std::string dirstr(dir); free(dir); size_t RRtmp1(0), RRtmp2(0); if (nrhs == 2) { RRtmp1 = (size_t)mxGetScalar(prhs[1]); RRtmp2 = RRtmp1; } if (nrhs == 3) { RRtmp1 = (size_t)mxGetScalar(prhs[1]); RRtmp2 = (size_t)mxGetScalar(prhs[2]); } const size_t RR1 = RRtmp1; const size_t RR2 = RRtmp2; std::string fnamev1 = dirstr + "/segment_pop.dat"; std::string fnamev2 = dirstr + "/segment_pop.v2.dat"; std::string fname; size_t vers = 0; if (fexists(fnamev1)) { vers = 1; fname = fnamev1; } else if (fexists(fnamev2)) { vers = 2; fname = fnamev2; } //mexPrintf("%s\n", fname.c_str()); std::uint16_t L; std::vector<double> pops; std::vector<double> rlft; if (fexists(fname)) { //mexPrintf("Loading..."); FILE *file = fopen(fname.c_str(), "rb"); if (vers == 2) { fread(&R, sizeof(std::uint32_t), 1, file); //mexPrintf("R = %d\n", R); for (size_t r = 0; r < R; r++) { fread(&S, sizeof(std::uint32_t), 1, file); for (size_t s = 0; s < S; s++) { if (pops.size() == pops.max_size() - 1) { break; } L = 0; fread(&L, sizeof(std::uint16_t), 1, file); std::uint16_t *data = new std::uint16_t[L](); fread(data, sizeof(std::uint16_t), L, file); bool useable = true; if (nrhs == 1 || (r >= RR1 && r <= RR2)) { for (size_t lftm = 1; lftm < L; lftm++) { double sim = std::min(data[lftm], data[lftm - 1]) / sqrt(data[lftm] * data[lftm - 1]); if (sim < 0.7071){ useable = false; } } if (useable) { for (size_t lftm = 0; lftm < L; lftm++) { pops.push_back((double)data[lftm]); rlft.push_back((double)L - lftm); } } } delete[] data; } if (nrhs >= 2 && r == RR2) { break; } } } else { fread(&S, sizeof(std::uint32_t), 1, file); fread(&R, sizeof(std::uint32_t), 1, file); for (size_t s = 0; s < S; s++) { if (pops.size() == pops.max_size() - 1) { break; } L = 0; fread(&L, sizeof(std::uint16_t), 1, file); std::uint16_t *data = new std::uint16_t[L](); fread(data, sizeof(std::uint16_t), L, file); bool useable = true; for (size_t lftm = 1; lftm < L; lftm++) { double sim = std::min(data[lftm], data[lftm - 1]) / sqrt(data[lftm] * data[lftm - 1]); if (sim < 0.7071){ useable = false; } } if (useable) { for (size_t lftm = 0; lftm < L; lftm++) { pops.push_back((double)data[lftm]); rlft.push_back((double)L - lftm); } } delete[] data; } } fclose(file); plhs[0] = mxCreateNumericMatrix(1, pops.size(), mxDOUBLE_CLASS, mxREAL); double* popout = (double*)mxGetData(plhs[0]); memcpy(popout, &pops[0], sizeof(double)*pops.size()); plhs[1] = mxCreateNumericMatrix(1, rlft.size(), mxDOUBLE_CLASS, mxREAL); double* rlftout = (double*)mxGetData(plhs[1]); memcpy(rlftout, &rlft[0], sizeof(double)*rlft.size()); //mexPrintf("Load Complete\n"); } else { plhs[0] = mxCreateLogicalScalar(0); mexPrintf("File Does Not Exists.\n"); } } else { mexPrintf("Wrong Number of Input Arguments.\n"); plhs[0] = mxCreateLogicalScalar(0); } }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { /* input: -[string] directory, output: -[double array] crowd population sizes. -[double array] crowd population lifetimes. */ if (nrhs == 1) { std::uint32_t S(0), R(0); const mwSize *dims = mxGetDimensions(prhs[0]); size_t strlen = dims[1] + 1; char *dir = (char*)malloc(sizeof(char)*strlen); mxGetString(prhs[0], dir, strlen); std::string dirstr(dir); free(dir); //mexPrintf("[%d, %d]\n", LR, UR); //mexPrintf("%s\n", dirstr.c_str()); std::string fname = dirstr + "/segment_pop.dat"; mexPrintf("%s\n", fname.c_str()); std::uint16_t L; std::vector<double> pops; std::vector<double> lifetimes; if (fexists(fname)) { mexPrintf("Loading..."); FILE *file = fopen(fname.c_str(), "rb"); fread(&S, sizeof(std::uint32_t), 1, file); fread(&R, sizeof(std::uint32_t), 1, file); size_t ss = 0; for (size_t s = 0; s < S; s++) { if (pops.size() == pops.max_size() - 1) { break; } L = 0; fread(&L, sizeof(std::uint16_t), 1, file); std::uint16_t *data = new std::uint16_t[L](); fread(data, sizeof(std::uint16_t), L, file); bool useable = true; for (size_t lftm = 1; lftm < L; lftm++) { double sim = std::min(data[lftm], data[lftm - 1]) / sqrt(data[lftm] * data[lftm - 1]); if (sim < 0.7071){ useable = false; } } if (useable) { double maxpop = 0; pops.push_back(data[0]); lifetimes.push_back(L); } delete[] data; } fclose(file); plhs[0] = mxCreateNumericMatrix(1, pops.size(), mxDOUBLE_CLASS, mxREAL); plhs[1] = mxCreateNumericMatrix(1, lifetimes.size(), mxDOUBLE_CLASS, mxREAL); double* popout = (double*)mxGetData(plhs[0]); memcpy(popout, &pops[0], sizeof(double)*pops.size()); double* poplftms = (double*)mxGetData(plhs[1]); memcpy(poplftms, &lifetimes[0], sizeof(double)*lifetimes.size()); mexPrintf("Load Complete\n"); } else { plhs[0] = mxCreateLogicalScalar(0); mexPrintf("File Does Not Exists.\n"); } } else { mexPrintf("Wrong Number of Input Arguments.\n"); plhs[0] = mxCreateLogicalScalar(0); } }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { /* input: -[string] directory, output: -[double array] rms pop. -[double array] mean pop. -[double array[ total change in pop. -[double array] crowd lifetime. */ if (nrhs == 1) { std::uint32_t S(0), R(0); const mwSize *dims = mxGetDimensions(prhs[0]); size_t strlen = dims[1] + 1; char *dir = (char*)malloc(sizeof(char)*strlen); mxGetString(prhs[0], dir, strlen); std::string dirstr(dir); free(dir); mexPrintf("%s\n", dirstr.c_str()); std::string fnamev1 = dirstr + "/segment_pop.dat"; std::string fnamev2 = dirstr + "/segment_pop.v2.dat"; std::string fname; size_t vers = 0; if (fexists(fnamev1)) { vers = 1; fname = fnamev1; } else if (fexists(fnamev2)) { vers = 2; fname = fnamev2; } std::uint16_t L; std::vector<double> rmspops; std::vector<double> meanpops; std::vector<double> totcpops; std::vector<double> lifetimes; if (fexists(fname)) { mexPrintf("Loading..."); FILE *file = fopen(fname.c_str(), "rb"); if (vers == 1) { fread(&S, sizeof(std::uint32_t), 1, file); fread(&R, sizeof(std::uint32_t), 1, file); size_t ss = 0; for (size_t s = 0; s < S; s++) { if (rmspops.size() == rmspops.max_size() - 1) { break; } L = 0; fread(&L, sizeof(std::uint16_t), 1, file); std::uint16_t *data = new std::uint16_t[L](); fread(data, sizeof(std::uint16_t), L, file); bool useable = true; double rms = 0; double tot = 0; for (size_t lftm = 1; lftm < L; lftm++) { double sim = std::min(data[lftm], data[lftm - 1]) / sqrt(data[lftm] * data[lftm - 1]); rms += pow((double)(data[lftm] - data[lftm-1]), 2.); tot += (double) (data[lftm] - data[0]); if (sim < 0.7071){ useable = false; } } if (useable) { rms /= (double) L; tot /= (double)(L - 1); rmspops.push_back(sqrt(L)); meanpops.push_back(tot); totcpops.push_back((double)(data[L - 1] - data[0])); lifetimes.push_back(L); } delete[] data; } } else if (vers == 2) { fread(&R, sizeof(std::uint32_t), 1, file); for (size_t r = 0; r < R; r++) { fread(&S, sizeof(std::uint32_t), 1, file); for (size_t s = 0; s < S; s++) { if (rmspops.size() == rmspops.max_size() - 1) { break; } L = 0; fread(&L, sizeof(std::uint16_t), 1, file); std::uint16_t *data = new std::uint16_t[L](); fread(data, sizeof(std::uint16_t), L, file); bool useable = true; double rms = 0; double tot = 0; for (size_t lftm = 1; lftm < L; lftm++) { double sim = std::min(data[lftm], data[lftm - 1]) / sqrt(data[lftm] * data[lftm - 1]); rms += pow((double)(data[lftm] - data[0]), 2.); tot += (double)(data[lftm] - data[lftm-1]); if (sim < 0.7071){ useable = false; } } if (useable) { rms /= (double) L; tot /= (double)(L - 1); rmspops.push_back(sqrt(rms)); meanpops.push_back(tot); totcpops.push_back((double)(data[L - 1] - data[0])); lifetimes.push_back(L); } delete[] data; } } } fclose(file); plhs[0] = mxCreateNumericMatrix(1, rmspops.size(), mxDOUBLE_CLASS, mxREAL); double* popout = (double*)mxGetData(plhs[0]); memcpy(popout, &rmspops[0], sizeof(double)*rmspops.size()); plhs[1] = mxCreateNumericMatrix(1, meanpops.size(), mxDOUBLE_CLASS, mxREAL); double* mpopout = (double*)mxGetData(plhs[1]); memcpy(mpopout, &meanpops[0], sizeof(double)*meanpops.size()); plhs[2] = mxCreateNumericMatrix(1, totcpops.size(), mxDOUBLE_CLASS, mxREAL); double* tcpopout = (double*)mxGetData(plhs[2]); memcpy(tcpopout, &totcpops[0], sizeof(double)*totcpops.size()); plhs[3] = mxCreateNumericMatrix(1, lifetimes.size(), mxDOUBLE_CLASS, mxREAL); double* lftmout = (double*)mxGetData(plhs[3]); memcpy(lftmout, &lifetimes[0], sizeof(double)*lifetimes.size()); mexPrintf("Load Complete\n"); } else { plhs[0] = mxCreateLogicalScalar(0); mexPrintf("File Does Not Exists.\n"); } } else { mexPrintf("Wrong Number of Input Arguments.\n"); plhs[0] = mxCreateLogicalScalar(0); } }
void EditorFont::SetColorFromIni(HWND hwndedit, wyWChar directory[], wyBool isinfotab) { COLORREF color,bgcolor=RGB(255,255,255),forecolor,backcolor; wyString dirstr(directory); //Change Margin color forecolor = wyIni::IniGetInt(GENERALPREFA, "NumberMarginFgColor", RGB(0,0,0), dirstr.GetString()); backcolor = wyIni::IniGetInt(GENERALPREFA, "NumberMarginBgColor", DEF_MARGINNUMBER, dirstr.GetString()); SendMessage(hwndedit, SCI_STYLESETFORE,STYLE_LINENUMBER,forecolor); SendMessage(hwndedit,SCI_STYLESETBACK,STYLE_LINENUMBER,backcolor); //Change selection color backcolor = wyIni::IniGetInt(GENERALPREFA, "SelectionBgColor", DEF_TEXTSELECTION, dirstr.GetString()); SendMessage(hwndedit,SCI_SETSELBACK,1,backcolor); bgcolor=wyIni::IniGetInt(GENERALPREFA, "EditorBgColor", DEF_BKGNDEDITORCOLOR, dirstr.GetString()); SendMessage( hwndedit, SCI_STYLESETBACK, STYLE_DEFAULT, (LPARAM)bgcolor); SendMessage( hwndedit, SCI_SETCARETFORE,bgcolor ^ 0xFFFFFF,0); //Change Caret color in editor window color = wyIni::IniGetInt(GENERALPREFA, "NormalColor", DEF_NORMALCOLOR, dirstr.GetString()); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_QUOTEDIDENTIFIER, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_QUOTEDIDENTIFIER, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_QUOTEDIDENTIFIER, FALSE); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_IDENTIFIER, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_IDENTIFIER, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_IDENTIFIER, FALSE); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_VARIABLE, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_VARIABLE, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_VARIABLE, FALSE); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_SYSTEMVARIABLE, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_SYSTEMVARIABLE, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_SYSTEMVARIABLE, FALSE); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_KNOWNSYSTEMVARIABLE, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_KNOWNSYSTEMVARIABLE, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_KNOWNSYSTEMVARIABLE, FALSE); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_DATABASEOBJECT, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_DATABASEOBJECT, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_DATABASEOBJECT, FALSE); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_PROCEDUREKEYWORD, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_PROCEDUREKEYWORD, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_PROCEDUREKEYWORD, FALSE); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_DEFAULT, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_DEFAULT, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_DEFAULT, FALSE); color = wyIni::IniGetInt(GENERALPREFA, "CommentColor", DEF_COMMENTCOLOR, dirstr.GetString()); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_COMMENTLINE, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_COMMENTLINE, bgcolor); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_COMMENT, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_COMMENT, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_COMMENT, TRUE); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_COMMENTLINE, TRUE); color = wyIni::IniGetInt(GENERALPREFA, "HiddenCmdColor", DEF_COMMENTCOLOR, dirstr.GetString()); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_HIDDENCOMMAND, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_HIDDENCOMMAND, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_HIDDENCOMMAND, TRUE); //In info tab, no highlighting for string literals if(isinfotab == wyTrue) color = wyIni::IniGetInt(GENERALPREFA, "NormalColor", DEF_NORMALCOLOR, dirstr.GetString()); else color = wyIni::IniGetInt(GENERALPREFA, "StringColor", DEF_STRINGCOLOR, dirstr.GetString()); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_STRING, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_STRING, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_STRING, TRUE); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_SQSTRING, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_SQSTRING, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_SQSTRING, TRUE); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_DQSTRING, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_DQSTRING, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_DQSTRING, TRUE); color = wyIni::IniGetInt( GENERALPREFA, "KeywordColor", DEF_KEYWORDCOLOR, dirstr.GetString() ); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_KEYWORD, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_KEYWORD, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_KEYWORD, TRUE); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_MAJORKEYWORD, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_MAJORKEYWORD, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_MAJORKEYWORD, TRUE); color = wyIni::IniGetInt( GENERALPREFA, "FunctionColor", DEF_FUNCTIONCOLOR, dirstr.GetString()); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_FUNCTION, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_FUNCTION, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_FUNCTION, TRUE); color = wyIni::IniGetInt( GENERALPREFA, "OperatorColor", DEF_OPERATORCOLOR, dirstr.GetString()); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_OPERATOR, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_OPERATOR, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_OPERATOR, TRUE); color = wyIni::IniGetInt( GENERALPREFA, "NumberColor", DEF_NORMALCOLOR, dirstr.GetString()); SendMessage(hwndedit, SCI_STYLESETFORE, SCE_MYSQL_NUMBER, color); SendMessage(hwndedit, SCI_STYLESETBACK, SCE_MYSQL_NUMBER, bgcolor); SendMessage(hwndedit, SCI_STYLESETBOLD, SCE_MYSQL_NUMBER, FALSE); }
void Win::LoadInterfaceGraphics() { //cout << "Win::LoadInterfaceGraphics()" << endl; bool dir_exists = true; BString dirstr( "/boot/home/config/settings/Themis/interface/" ); BDirectory dir( dirstr.String() ); if( dir.InitCheck() != B_OK ) { dir_exists = false; //cout << "/boot/home/config/settings/Themis/interface/ does not exist" << endl; } // load the icons either from bitmap-file or if not present, from internal // icon hexdumps located in "ThemisIcons.h" // initialize all bitmaps with NULL for( int i=0; i < 10; i++ ) bitmaps[i] = NULL; // the array with file-names const char* names[9]; // 4-pic bitmap names[0] = "button_back.png"; names[1] = "button_forward.png"; names[2] = "button_stop.png"; names[3] = "button_home.png"; names[4] = "button_newtab.png"; // 3-pic bitmap names[5] = "button_reload.png"; names[6] = "button_go.png"; names[7] = "button_closetabview.png"; // 1-pic bitmap names[8] = "icon_document.png"; names[9] = "icon_document_empty.png"; // the array with pointers to the hexdumps const unsigned char* hexp[10]; // 4-pic bitmap hexp[0] = button_back_hex; hexp[1] = button_forward_hex; hexp[2] = button_stop_hex; hexp[3] = button_home_hex; hexp[4] = button_newtab_hex; // 3-pic bitmap hexp[5] = button_reload_hex; hexp[6] = button_go_hex; hexp[7] = button_closetabview_hex; // 1-pic bitmap hexp[8] = icon_document_hex; hexp[9] = icon_document_empty_hex; // a tempstring :D // ( i had to move this below the 2 char arrays .. otherwise i got a // seqm viol. and tstr was initialized with hexp[9] .. // dunno if i did some very lousy coding mistakes or if sth is playing me a trick ) BString tstr( dirstr.String() ); for( int i = 0; i < 10; i++ ) { //cout << "bitmap " << i << ": "; if( dir_exists == true ) { //cout << "loading from file" << endl; // load from file tstr.SetTo( dirstr.String() ); if( ( bitmaps[i] = BTranslationUtils::GetBitmapFile( ( tstr += names[i] ).String() ) ) == 0 ) cout << "loading from bitmap-file failed" << endl; } if( bitmaps[i] == NULL ) { // load from hexdump //cout << "loading from hexdump" << endl; if( i <= 4 ) { bitmaps[i] = new BBitmap( BRect( 0,0,63,15 ), B_RGB32 ); memcpy( bitmaps[i]->Bits(), hexp[i], 4096 ); } if( i >= 5 && i <= 7 ) { bitmaps[i] = new BBitmap( BRect( 0,0,47,15 ), B_RGB32 ); memcpy( bitmaps[i]->Bits(), hexp[i], 3072 ); } if( i == 8 || i == 9 ) { bitmaps[i] = new BBitmap( BRect( 0,0,15,15 ), B_RGB32 ); memcpy( bitmaps[i]->Bits(), hexp[i], 1024 ); } } } }