bool SlimServerInfo::Init(SlimCLI *cliRef) { DEBUGF(""); // get cli and references sorted out cli = cliRef; SlimServerAddr = cli->GetSlimServerAddress(); cliPort = cli->GetCliPort(); cli->EmitCliInfo(QString("Getting Database info")); QByteArray cmd = QByteArray("serverstatus\n" ); if(!cli->SendBlockingCommand(cmd)) return false; if( !ProcessServerInfo(cli->GetResponse()) ) return false; if( !SetupDevices()) { DEBUGF("NO DEVICE FOUND FROM THIS MAC"); return false; } DEBUGF("READ DATAFILE"); if( !ReadDataFile() ) refreshImageFromServer(); else checkRefreshDate(); // see if we need to update the database DEBUGF("RETURNING"); return true; }
/* * readErrorMsgData - do just that */ static void readErrorMsgData( void ) { vi_rc rc; rc = ReadDataFile( "errmsg.dat", &errorList, errmsg_alloc, errmsg_save, true ); if( rc != ERR_NO_ERR ) { return; } readMsgData = true; } /* readErrorMsgData */
BOOL ClientInfoManager::InstallModule( LPCTSTR clientid, LPCTSTR moduleName ) { tstring modname = moduleName; makeLower(modname); tstring datFilepath; if (! ClientmodManager::GetInstanceRef().GetModuleDatFilepath(modname.c_str(), datFilepath)) { errorLog(_T("no such clientmodule [%s]"), moduleName); return FALSE; } CommData sendData; sendData.SetMsgID(MSGID_INSTALL_MODULE); sendData.SetData(_T("modname"), moduleName); if (! ReadDataFile(datFilepath.c_str(), sendData)) { errorLog(_T("read datafile failed[%s]"), datFilepath.c_str()); return FALSE; } MSGSERIALID requestInstallModMsgID = CommManager::GetInstanceRef().AddToSendMessage(clientid, sendData, TRUE); if (INVALID_MSGSERIALID == requestInstallModMsgID) { errorLog(_T("send msg to install mod[%s] in [%s] failed"), moduleName, clientid); return FALSE; } BOOL bPushOK = FALSE; m_infoMapSection.Enter(); { ClientBaseInfoMap::iterator iter = m_clientBaseInfoMap.find(clientid); if (iter != m_clientBaseInfoMap.end()) { iter->second.installModMsgIDMap[moduleName] = requestInstallModMsgID; bPushOK = TRUE; } } m_infoMapSection.Leave(); if (bPushOK) { infoLog(_T("send install msg OK. install mod[%s] to [%s]"), moduleName, clientid); } else { errorLog(_T("send install msg OK.id=%I64u. but no info for client[%s]"), requestInstallModMsgID, clientid); } return TRUE; }
/* * readKeyData - do just that */ static vi_rc readKeyData( void ) { vi_rc rc; if( keysRead ) { return( ERR_NO_ERR ); } rc = ReadDataFile( "keys.dat", &charTokens, key_alloc, key_save ); if( rc != ERR_NO_ERR ) { return( rc ); } keysRead = TRUE; return( ERR_NO_ERR ); } /* readKeyData */
/* * Called when ckicking on button Browse: * Select a new data file, and load it on request */ void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxCommandEvent& event ) { wxString fullfilename = GetDataFilename(); wxString wildcard; wildcard.Printf( _("PCB Calculator data file (*.%s)|*.%s"), GetChars( DataFileNameExt ), GetChars( DataFileNameExt ) ); wxFileDialog dlg( m_panelRegulators, _("Select a PCB Calculator data file"), wxEmptyString, fullfilename, wildcard, wxFD_OPEN ); if (dlg.ShowModal() == wxID_CANCEL) return; fullfilename = dlg.GetPath(); if( fullfilename == GetDataFilename() ) return; SetDataFilename( fullfilename ); if( wxFileExists( fullfilename ) && m_RegulatorList.GetCount() > 0 ) // Read file { if( wxMessageBox( _("Do you want to load this file and replace current regulator list?" ) ) != wxID_OK ) return; } if( ReadDataFile() ) { m_RegulatorListChanged = false; m_choiceRegulatorSelector->Clear(); m_choiceRegulatorSelector->Append( m_RegulatorList.GetRegList() ); SelectLastSelectedRegulator(); } else { wxString msg; msg.Printf( _("Unable to read data file <%s>"), GetChars( fullfilename ) ); wxMessageBox( msg ); } }
int main(void){ int i=0; person_t student[NUM_OF_PERSON]; printf("起動オプションを選択してください。\n1:ランダムデータファイルの生成\n2:データ読み込み・ソート\n3:ランダムデータ作成+ソート結果を表示(ファイル出力しない)\n"); scanf("%d",&i); if(i==1){ printf("作成したデータは同階層のdata.csvに保存されます。\n"); DataRandomize(student); if(WriteDataFile(student) == 0){ NumberAssign(student); ScoreAverage(student); printf("作成データ\n"); DataDisplay(student); } }else if(i==2){ if(ReadDataFile(student) == 0){ NumberAssign(student); ScoreAverage(student); printf("読込データ\n"); DataDisplay(student); DataBubbleSort(student); printf("ソート結果\n"); DataDisplay(student); printf("番号・平均を含んだソート結果をresult.csvに保存しますか?"); if(YesOrNo() == 1) WriteSortFile(student); } }else if(i==3){ NumberAssign(student); DataRandomize(student); ScoreAverage(student); printf("作成データ\n"); DataDisplay(student); DataBubbleSort(student); printf("ソート結果\n"); DataDisplay(student); }else{ printf("1、2、3のいずれかを入力してください。\n"); } return 0; }
void MainInitialize(char *fname, SpaceballControlStruct *scs, SpaceballAppDataStruct *app, float *CTM, PointStr *World) { /* * Initialize the Spaceball data structures */ scs->sbDominant = FALSE; scs->sbAllowTranslation = TRUE; scs->sbAllowRotation = TRUE; scs->sbScale = (float)1.0; scs->appData = (void *)(app); app->CTM = (float *)CTM; app->redraw = TRUE; /* * Read in the data file containing the objects */ ReadDataFile(fname, &Spw_Points, &Spw_Edges, &Spw_Polygons, &Spw_NPoints, &Spw_NEdges, &Spw_NPolygons, World); /* * Create scratch array of drawing points */ if ((Spw_DrawPoints = (PointStr *) malloc (Spw_NPoints * sizeof(PointStr))) == NULL) { printf ("Couldn't alloc Spw_DrawPoints arrar\n"); exit(1); } /* * Translate the scene to the center of the window, set center * of rotation */ app->center.Coord[0] = ((World[0].Coord[0] + World[1].Coord[0]) / (float)2.0); app->centerRot.Coord[1] = app->center.Coord[1] = ((World[0].Coord[1] + World[1].Coord[1]) / (float)2.0); app->centerRot.Coord[2] = app->center.Coord[2] = (float)0.0; app->centerRot.Coord[0] = (Spw_WindowWidth / (float)2.0); app->centerRot.Coord[1] = (Spw_WindowHeight / (float)2.0); /* * Initialize the transformation matrix */ SPW_MakeIdentityMatrix((float(*)[4])CTM); SPW_MakeTranslationMatrix((float(*)[4])CTM, app->center.Coord); /* * Open the main drawing window, map window */ CreateWidgetWindow(0, 0, Spw_WindowHeight, Spw_WindowWidth, "Widget World"); Spw_Foreground = Spw_Black; Spw_Background = Spw_White; } /* end of MainInitialize */
int main(int argc, char *argv[]) { int nDataVals, nStoredDataVals, nSavedRows; int nPixels_psf; int startDataRow, endDataRow; int nParamsTot, nFreeParams; int nDegFreedom; double *xVals, *yVals, *yWeights, *maskVals; double *xVals_psf, *yVals_psf; int weightMode = WEIGHTS_ARE_SIGMAS; FILE *outputFile_ptr; ModelObject *theModel; double *paramsVect; double *paramErrs; vector<mp_par> paramLimits; vector<int> FunctionBlockIndices; bool maskAllocated = false; bool paramLimitsExist = false; vector<mp_par> parameterInfo; int status, fitStatus; vector<string> functionList; vector<double> parameterList; commandOptions options; configOptions userConfigOptions; SolverResults resultsFromSolver; string nloptSolverName; vector<string> programHeader; string progNameVersion = "profilefit "; /* PROCESS COMMAND-LINE: */ /* First, set up the options structure: */ options.configFileName = DEFAULT_CONFIG_FILE; options.dataFileName = ""; options.modelOutputFileName = DEFAULT_MODEL_OUTPUT_FILE; options.noDataFile = true; options.noConfigFile = true; options.psfPresent = false; options.dataAreMagnitudes = true; // default: assumes we usually fit mu(R) profiles options.zeroPoint = 0.0; options.startDataRow = 0; options.endDataRow = -1; // default value indicating "last row in data file" options.noErrors = true; options.noMask = true; options.maskFormat = MASK_ZERO_IS_GOOD; options.ftol = DEFAULT_FTOL; options.ftolSet = false; options.printChiSquaredOnly = false; options.solver = MPFIT_SOLVER; options.nloptSolverName = "NM"; // default value = Nelder-Mead Simplex options.doBootstrap = false; options.bootstrapIterations = 0; options.subsamplingFlag = false; options.saveBestProfile = false; options.saveBestFitParams = true; options.outputParameterFileName = DEFAULT_1D_OUTPUT_PARAMETER_FILE; options.verbose = 1; options.nloptSolverName = ""; options.rngSeed = 0; progNameVersion += VERSION_STRING; MakeOutputHeader(&programHeader, progNameVersion, argc, argv); ProcessInput(argc, argv, &options); if (options.noDataFile) { printf("*** WARNING: No data to fit!\n\n"); return -1; } /* Read configuration file */ if (! FileExists(options.configFileName.c_str())) { printf("\n*** WARNING: Unable to find or open configuration file \"%s\"!\n\n", options.configFileName.c_str()); return -1; } status = ReadConfigFile(options.configFileName, false, functionList, parameterList, paramLimits, FunctionBlockIndices, paramLimitsExist, userConfigOptions); if (status < 0) { printf("\n*** WARNING: Problem in processing config file!\n\n"); return -1; } /* GET THE DATA: */ nDataVals = CountDataLines(options.dataFileName); if ((nDataVals < 1) || (nDataVals > MAX_N_DATA_VALS)) { /* file has no data *or* too much data (or an integer overflow occured in CountDataLines) */ printf("Something wrong: input file %s has too few or too many data points\n", options.dataFileName.c_str()); printf("(nDataVals = %d)\n", nDataVals); exit(1); } printf("Data file \"%s\": %d data points\n", options.dataFileName.c_str(), nDataVals); /* Set default end data row (if not specified) and check for reasonable values: */ startDataRow = options.startDataRow; endDataRow = options.endDataRow; if (endDataRow == -1) endDataRow = nDataVals - 1; if ( (startDataRow < 0) || (startDataRow >= nDataVals) ) { printf("Starting data row (\"--x1\") must be >= 1 and <= number of rows in data file (%d)!\n", nDataVals); exit(-1); } if ( (endDataRow <= startDataRow) || (endDataRow >= nDataVals) ) { printf("Ending data row (\"--x2\") must be >= starting data row and <= number of rows in data file (%d)!\n", nDataVals); exit(-1); } /* Allocate data vectors: */ nStoredDataVals = endDataRow - startDataRow + 1; xVals = (double *)calloc( (size_t)nStoredDataVals, sizeof(double) ); yVals = (double *)calloc( (size_t)nStoredDataVals, sizeof(double) ); if ( (xVals == NULL) || (yVals == NULL) ) { fprintf(stderr, "\nFailure to allocate memory for input data!\n"); exit(-1); } if (options.noErrors) yWeights = NULL; else yWeights = (double *)calloc( (size_t)nStoredDataVals, sizeof(double) ); if (options.noMask) maskVals = NULL; else { maskVals = (double *)calloc( (size_t)nStoredDataVals, sizeof(double) ); maskAllocated = true; } /* Read in data */ nSavedRows = ReadDataFile(options.dataFileName, startDataRow, endDataRow, xVals, yVals, yWeights, maskVals); if (nSavedRows > nStoredDataVals) { fprintf(stderr, "\nMore data rows saved (%d) than we allocated space for (%d)!\n", nSavedRows, nStoredDataVals); exit(-1); } if (options.noErrors) { // OK, we previously had yWeights = NULL to tell ReadDataFile() to skip // the third column (if any); now we need to have a yWeights vector with // all weights = 1.0 yWeights = (double *)calloc( (size_t)nStoredDataVals, sizeof(double) ); for (int i = 0; i < nStoredDataVals; i++) yWeights[i] = 1.0; } /* Read in PSF profile, if supplied */ if (options.psfPresent) { nPixels_psf = CountDataLines(options.psfFileName); if ((nPixels_psf < 1) || (nPixels_psf > MAX_N_DATA_VALS)) { /* file has no data *or* too much data (or an integer overflow occured in CountDataLines) */ printf("Something wrong: input PSF file %s has too few or too many data points\n", options.psfFileName.c_str()); printf("(nPixels_psf (# of PSF points) = %d)\n", nPixels_psf); exit(1); } printf("PSF file \"%s\": %d data points\n", options.psfFileName.c_str(), nPixels_psf); /* Set default end data row (if not specified) and check for reasonable values: */ startDataRow = 0; endDataRow = nPixels_psf - 1; xVals_psf = (double *)calloc( (size_t)nPixels_psf, sizeof(double) ); yVals_psf = (double *)calloc( (size_t)nPixels_psf, sizeof(double) ); if ( (xVals_psf == NULL) || (yVals_psf == NULL) ) { fprintf(stderr, "\nFailure to allocate memory for PSF data!\n"); exit(-1); } nSavedRows = ReadDataFile(options.psfFileName, startDataRow, endDataRow, xVals_psf, yVals_psf, NULL, NULL); if (nSavedRows > nStoredDataVals) { fprintf(stderr, "\nMore PSF rows saved (%d) than we allocated space for (%d)!\n", nSavedRows, nPixels_psf); exit(-1); } } /* Set up the model object */ theModel = new ModelObject1d(); /* Add functions to the model object */ printf("Adding functions to model object...\n"); status = AddFunctions1d(theModel, functionList, FunctionBlockIndices); if (status < 0) { printf("*** WARNING: Failure in AddFunctions!\n\n"); exit(-1); } theModel->SetZeroPoint(options.zeroPoint); // Set up parameter vector(s), now that we know how many total parameters // there will be nParamsTot = nFreeParams = theModel->GetNParams(); printf("\t%d total parameters\n", nParamsTot); paramsVect = (double *) malloc(nParamsTot * sizeof(double)); for (int i = 0; i < nParamsTot; i++) paramsVect[i] = parameterList[i]; paramErrs = (double *) malloc(nParamsTot * sizeof(double)); /* Add image data, errors, and mask to the model object */ // "true" = input yVals data are magnitudes, not intensities theModel->AddDataVectors(nStoredDataVals, xVals, yVals, options.dataAreMagnitudes); theModel->AddErrorVector1D(nStoredDataVals, yWeights, WEIGHTS_ARE_SIGMAS); if (maskAllocated) { status = theModel->AddMaskVector1D(nStoredDataVals, maskVals, options.maskFormat); if (status < 0) { fprintf(stderr, "*** ERROR: Failure in ModelObject::AddMaskVector1D!\n\n"); exit(-1); } } // Add PSF vector, if present, and thereby enable convolution if (options.psfPresent) { status = theModel->AddPSFVector1D(nPixels_psf, xVals_psf, yVals_psf); if (status < 0) { fprintf(stderr, "*** ERROR: Failure in ModelObject::AddPSFVector1D!\n\n"); exit(-1); } } theModel->FinalSetupForFitting(); // calls ApplyMask(), VetDataVector() theModel->PrintDescription(); // Parameter limits and other info: printf("Setting up parameter information vector ...\n"); mp_par newParamLimit; for (int i = 0; i < nParamsTot; i++) { memset(&newParamLimit, 0, sizeof(mp_par)); newParamLimit.fixed = paramLimits[i].fixed; if (paramLimits[i].fixed == 1) { printf("Fixed parameter detected (i = %d)\n", i); nFreeParams--; } newParamLimit.limited[0] = paramLimits[i].limited[0]; newParamLimit.limited[1] = paramLimits[i].limited[1]; newParamLimit.limits[0] = paramLimits[i].limits[0]; newParamLimit.limits[1] = paramLimits[i].limits[1]; parameterInfo.push_back(newParamLimit); } nDegFreedom = theModel->GetNValidPixels() - nFreeParams; printf("%d free parameters (%d degrees of freedom)\n", nFreeParams, nDegFreedom); // tell ModelObject about parameterInfo (mainly useful for printing-related methods) theModel->AddParameterInfo(parameterInfo); // OK, now we either print chi^2 value for the input parameters and quit, or // else call one of the solvers! if (options.printChiSquaredOnly) { printf("\n"); fitStatus = 1; PrintFitStatistic(paramsVect, theModel, nFreeParams); printf("\n"); // turn off saveing of parameter file options.saveBestFitParams = false; } else { // DO THE FIT! fitStatus = DispatchToSolver(options.solver, nParamsTot, nFreeParams, nStoredDataVals, paramsVect, parameterInfo, theModel, options.ftol, paramLimitsExist, options.verbose, &resultsFromSolver, options.nloptSolverName, options.rngSeed); PrintResults(paramsVect, theModel, nFreeParams, fitStatus, resultsFromSolver); } // OPTIONAL HANDLING OF BOOTSTRAP RESAMPLING HERE if ((options.doBootstrap) && (options.bootstrapIterations > 0)) { printf("\nNow doing bootstrap resampling (%d iterations) to estimate errors...\n", options.bootstrapIterations); printf("[NOT YET PROPERLY IMPLEMENTED!]\n"); BootstrapErrors(paramsVect, parameterInfo, paramLimitsExist, theModel, options.ftol, options.bootstrapIterations, nFreeParams); } if (options.saveBestFitParams) { printf("Saving best-fit parameters in file \"%s\"\n", options.outputParameterFileName.c_str()); string progNameVer = "profilefit "; progNameVer += VERSION_STRING; SaveParameters(paramsVect, theModel, options.outputParameterFileName, programHeader, nFreeParams, options.solver, fitStatus, resultsFromSolver); } if (options.saveBestProfile) { theModel->CreateModelImage(paramsVect); double *modelProfile = (double *) calloc((size_t)nStoredDataVals, sizeof(double)); int nPts = theModel->GetModelVector(modelProfile); if (nPts == nStoredDataVals) { printf("Saving model profile to %s...\n", options.modelOutputFileName.c_str()); outputFile_ptr = fopen(options.modelOutputFileName.c_str(), "w"); for (int i = 0; i < nPts; i++) { fprintf(outputFile_ptr, "\t%f\t%f\n", xVals[i], modelProfile[i]); } fclose(outputFile_ptr); printf("Done.\n"); } else { printf("WARNING -- MISMATCH BETWEEN nStoredDataVals (main) and nDataVals (ModelObject1d)!\n"); printf("NO PROFILE SAVED!\n"); } free(modelProfile); } // Free up memory free(xVals); free(yVals); free(yWeights); if (maskAllocated) free(maskVals); if (options.psfPresent) { free(xVals_psf); free(yVals_psf); } free(paramsVect); free(paramErrs); delete theModel; printf("All done!\n\n"); return 0; }
// using namespace std; int _tmain(int argc, _TCHAR* argv[]) { wcout << L"StatisGA:" << endl; // setlocale( LC_ALL, "chs" ); // wstring test = L"ищ"; // wcout << test<<endl; wstring InitialParaFile = L"Para.txt"; wstring OutpuParaFile = L"Para.txt"; bool bMode = false; wcout << L"Choose mode: 0 for Train(default); 1 for test" << endl; wcin >> bMode; NumCharact NCharact; wstring InputDataFile = L"399300"; //if (true == bMode) //{ // wcout << L"Input data file name:"; // wcin >> InputDataFile; //} //wchar_t CurrentPath[1024]; //GetCurrentDirectory(1024, CurrentPath); vector<vector<double>> OriginalDataArray; vector<wstring> DateArray; ReadDataFile(DateArray, OriginalDataArray, InputDataFile); int DataStart = 150; double StartValue = 0; if (true == bMode) { DataStart = 0; // wcout << L"Input Start value:"; // wcin >> StartValue; } int CyclePara = 1; NCharact.DataPreprocess(CyclePara, DataStart, StartValue, OriginalDataArray); NCharact.TrainFactorLength = 30; NCharact.FactorNumber = 14; NCharact.CheckSize = 2; const int CalcuNumberK = 6; NCharact.FactorRange = 10901; const int TolerantRange = 250; const int TolerantNumber = 2; __int64 GANumber = 1000100000;// wstringstream FileNameStream; FileNameStream << InputDataFile << L"_" << NCharact.FactorNumber << L"_" << TolerantRange << L"_" << TolerantNumber << CyclePara << L".txt";//<< L"750.txt";// InitialParaFile = FileNameStream.str(); OutpuParaFile = FileNameStream.str(); FileNameStream.clear(); NCharact.InitTrainArray(CalcuNumberK, TolerantRange, TolerantNumber, InitialParaFile); if (false == bMode) { int NThreads = omp_get_num_procs() - 1; int NOut = 100000; unsigned __int64 nn = 0; vector<vector<int>> SingleTrainArray; #ifndef _DEBUG #pragma omp parallel for num_threads(NThreads) firstprivate(SingleTrainArray) //, TargetPointResultArray) #endif for (__int64 n = __int64(GANumber * 0.0); n < GANumber; n++) { double NPercent = double(nn) / GANumber; int TrainFactorIndex = n % NCharact.TrainFactorLength; NCharact.GAFunction(NPercent, TrainFactorIndex, SingleTrainArray, CalcuNumberK); vector<double> JudgeElement(2, 0.0); NCharact.ANOVA2(CalcuNumberK, TolerantRange, TolerantNumber, SingleTrainArray, JudgeElement); #pragma omp critical { NCharact.GAReprocess(NPercent, TrainFactorIndex, SingleTrainArray, JudgeElement); if(0 == nn % NOut) { wcout << nn << L" "; NCharact.OutputParaFile(OutpuParaFile); } nn++; } } } else { NCharact.TestLatestData(DateArray, TolerantRange, CalcuNumberK, 450); } /* const int HistogOxLength = 20; const int HistogDataLength = 20; const int HistogSize = 4; NCharact.HistogCoOx.insert(NCharact.HistogCoOx.end(), HistogOxLength, 0.0); vector<int> HistogTemp(HistogDataLength, 0); NCharact.HistogData.insert(NCharact.HistogData.end(), HistogSize, HistogTemp); NCharact.GenerateHistogDistr(CheckSize, TargetPointResultArray); */ OriginalDataArray.clear(); DateArray.clear(); NCharact.DataClear(); string tempstring; cout << endl << "end."; cin >> tempstring; return 0; }
PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : PCB_CALCULATOR_FRAME_BASE( aParent ) { SetKiway( this, aKiway ); m_currTransLine = NULL; m_currTransLineType = DEFAULT_TYPE; m_currAttenuator = NULL; m_RegulatorListChanged = false; m_Config = GetNewConfig( Pgm().App().GetAppName() ); // Populate transline list ordered like in dialog menu list const static TRANSLINE_TYPE_ID tltype_list[8] = { MICROSTRIP_TYPE, CPW_TYPE, GROUNDED_CPW_TYPE, RECTWAVEGUIDE_TYPE, COAX_TYPE, C_MICROSTRIP_TYPE, STRIPLINE_TYPE, TWISTEDPAIR_TYPE }; for( int ii = 0; ii < 8; ii++ ) m_transline_list.push_back( new TRANSLINE_IDENT( tltype_list[ii] ) ); // Populate attenuator list ordered like in dialog menu list m_attenuator_list.push_back( new ATTENUATOR_PI() ); m_attenuator_list.push_back( new ATTENUATOR_TEE() ); m_attenuator_list.push_back( new ATTENUATOR_BRIDGE() ); m_attenuator_list.push_back( new ATTENUATOR_SPLITTER() ); m_currAttenuator = m_attenuator_list[0]; ReadConfig(); ReadDataFile(); TranslineTypeSelection( m_currTransLineType ); m_TranslineSelection->SetSelection( m_currTransLineType ); TW_Init(); SetAttenuator( m_AttenuatorsSelection->GetSelection() ); ToleranceSelection( m_rbToleranceSelection->GetSelection() ); BoardClassesUpdateData( m_BoardClassesUnitsSelector->GetUnitScale() ); ElectricalSpacingUpdateData( m_ElectricalSpacingUnitsSelector->GetUnitScale() ); m_choiceRegulatorSelector->Append( m_RegulatorList.GetRegList() ); SelectLastSelectedRegulator(); // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( icon_pcbcalculator_xpm ) ); SetIcon( icon ); GetSizer()->SetSizeHints( this ); // Set previous size and position SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); if( m_FramePos == wxDefaultPosition ) Centre(); }
MenuManager::MenuManager(int width, int height) { float bufWidth; // Buffer width float bufHeight; // Buffer height float halfSWidth; // Screen width float halfSHeight; // Screen height RECT backDest={0}; int backWidth = 0; int backHeight = 0; BOOL found = FALSE; int i; mIsActive = FALSE; mCurMenu = 0; mCurPage = 0; mTargetId = FalconNullId; mpResDimensions = NULL; ReadDataFile("art\\ckptart\\menu.dat"); ShiAssert(mpResDimensions); // No dimension information in the data file! backWidth = 0; backHeight = 0; for(i = 0; i < mTotalRes; i++) { if(!found && mpResDimensions[i].xRes == width && mpResDimensions[i].yRes == height) { backDest.top = mpResDimensions[i].mDimensions.top; backDest.left = mpResDimensions[i].mDimensions.left; backDest.bottom = mpResDimensions[i].mDimensions.bottom; backDest.right = mpResDimensions[i].mDimensions.right; found = TRUE; } else if(!found && mpResDimensions[i].xRes < width && mpResDimensions[i].xRes > backWidth && mpResDimensions[i].yRes < height && mpResDimensions[i].yRes > backHeight) { backWidth = mpResDimensions[i].xRes; backHeight = mpResDimensions[i].yRes; backDest.top = mpResDimensions[i].mDimensions.top; backDest.left = mpResDimensions[i].mDimensions.left; backDest.bottom = mpResDimensions[i].mDimensions.bottom; backDest.right = mpResDimensions[i].mDimensions.right; } } bufWidth = (float)backDest.right - (float)backDest.left + 1.0F; bufHeight = (float)backDest.bottom - (float)backDest.top + 1.0F; mDestRect.top = backDest.top; mDestRect.left = backDest.left; mDestRect.bottom = FloatToInt32(mDestRect.top + bufHeight); mDestRect.right = FloatToInt32(mDestRect.left + bufWidth); halfSWidth = (float) DisplayOptions.DispWidth * 0.5F; halfSHeight = (float) DisplayOptions.DispHeight * 0.5F; mLeft = (mDestRect.left - halfSWidth) / halfSWidth; mRight = (mDestRect.right - halfSWidth) / halfSWidth; mTop = -(mDestRect.top - halfSHeight) / halfSHeight; mBottom = -(mDestRect.bottom - halfSHeight) / halfSHeight; }
static int LoadShaderInPlace( struct Shader * ret ) { unsigned char * VertexText; unsigned char * FragmentText; GLint compiled; VertexText = ReadDataFile( ret->VertexName ); if( !VertexText ) { fprintf( stderr, "Error: Could not open vertex shader: %s\n", ret->VertexName ); return 1; } FragmentText = ReadDataFile( ret->FragmentName ); if( !FragmentText ) { fprintf( stderr, "Error: Could not open fragment shader: %s\n", ret->FragmentName ); free( VertexText ); return 1; } ret->vertex = glCreateShader(GL_VERTEX_SHADER); ret->fragment = glCreateShader(GL_FRAGMENT_SHADER); GLint vl = strlen( VertexText ); GLint fl = strlen( FragmentText ); glShaderSource(ret->vertex, 1, (const GLchar **)&VertexText, &vl ); glShaderSource(ret->fragment, 1, (const GLchar **)&FragmentText, &fl ); glCompileShader(ret->vertex); glGetShaderiv(ret->vertex, GL_COMPILE_STATUS, &compiled); if(!compiled) { fprintf( stderr, "Error: Could not compile vertex shader: %s\n", ret->VertexName ); ShaderErrorPrint( ret->vertex ); goto cancel; } glCompileShader(ret->fragment); glGetShaderiv(ret->fragment, GL_COMPILE_STATUS, &compiled); if(!compiled) { fprintf( stderr, "Error: Could not compile fragment shader: %s\n", ret->FragmentName ); ShaderErrorPrint( ret->fragment ); goto cancel; } ret->program = glCreateProgram(); glAttachShader(ret->program, ret->vertex); glAttachShader(ret->program, ret->fragment); // glBindAttribLocation(shaderProgram, 0, "InVertex"); glLinkProgram(ret->program); GLint IsLinked; glGetProgramiv(ret->program, GL_LINK_STATUS, (GLint *)&IsLinked); if(!IsLinked) { fprintf( stderr, "Error: Could not link shader: %s + %s\n", ret->VertexName, ret->FragmentName ); GLint maxlen; glGetProgramiv(ret->program, GL_INFO_LOG_LENGTH, &maxlen); if( maxlen > 0 ) { char * log = malloc( maxlen ); glGetProgramInfoLog(ret->program, maxlen, &maxlen, log); fprintf( stderr, "%s\n", log ); free( log ); } goto cancel_with_program; } free( VertexText ); free( FragmentText ); return 0; //Happy! cancel_with_program: glDetachShader(ret->program, ret->vertex); glDetachShader(ret->program, ret->fragment ); glDeleteShader(ret->program); cancel: free( VertexText ); free( FragmentText ); glDeleteShader( ret->vertex ); glDeleteShader( ret->fragment ); return 1; }