void DrImage::SlitScan(){ int NStep = 1; pngwriter ImageOut[NStep]; for(int f=0;f<NStep;f++){ char cImage[160]; sprintf(cImage,"Image%05u.png",f); ImageOut[f] = new pngwriter(NWidth,NHeight,1.0,cImage); } for(int f=0;f<NFile;f++){ fprintf(stderr,"Elaborating %lf %%\r",f/(double)NFile*100.); ReLoad(FileList[f]); int wInit = f; if(wInit >= NWidth) break;//wInit -= NWidth; for(int w=wInit;w<NWidth;w++){ int f1 = 0; for(int h=0;h<NHeight;h++){ //int set = f + h*NFile; ImageOut[f1].plot(w,h,data[0][h*NWidth + w],data[1][h*NWidth + w],data[2][h*NWidth + w]); } } } for(int s=0;s<NStep;s++){ ImageOut[s].close(); } printf("\n"); }
############################################################################################################################ */ void keyboardDown(unsigned char key, int x, int y) { /* **************************************************************************************************************************** */ if (key>='A' && key<='Z') key+='a'-'A'; /* **************************************************************************************************************************** */ switch (key) { case 13: FindConfiguration(); break; case 'f': glutFullScreen(); break; case 'h': HelpMessage(); break; case 'i': InnerIterate(); break; case 'l': AngleLimits = !AngleLimits; if (AngleLimits) fprintf(stderr, "Angle Limits: ON\n"); else fprintf(stderr, "Angle Limits: OFF\n"); break; case 27: case 'q': case 'x': exit(0); break; case 'r': ReLoad(); break; case 'w': glutReshapeWindow(1024, 768); glutPositionWindow(100, 100); break; default: break; }
int gxConfig::ChangeConfigLine(const gxString &string_to_replace, const gxString &string_to_insert, int check_case, int append_lines) // This function is used to replace strings in the config file. // Returns the number of strings processed or zero if an error occurs. { const int MAX_LINE = 1024; // Maximum characters per line char LineBuffer[MAX_LINE]; char rawLineBuffer[MAX_LINE]; gxString LineData; gxString appendLineBuffer; gxConfig list; int i, j; int offset = 0; int num_processed = 0; DiskFileB infile(FileName.c_str(), DiskFileB::df_READONLY, DiskFileB::df_NO_CREATE); if(!infile) return 0; // Cannot open the file while(!infile.df_EOF()) { // Read in the file line by line // Clear the buffers for(i = 0; i < MAX_LINE; i++) LineBuffer[i] = '\0'; for(i = 0; i < MAX_LINE; i++) rawLineBuffer[i] = '\0'; LineData.DeleteAt(0, LineData.length()); offset = 0; // Reset string offset if(infile.df_GetLine(rawLineBuffer, MAX_LINE) != DiskFileB::df_NO_ERROR) { break; // Error reading file } // Filter each line of text for(i = 0, j = 0; i < MAX_LINE; i++) { if((rawLineBuffer[i] == '\r') || (rawLineBuffer[i] == '\n')) break; LineBuffer[j++] = rawLineBuffer[i]; } // Detect backslashes used to mark the continuation of a line if((LineBuffer[strlen(LineBuffer)-1] == '\\') && (append_lines == 1)) { appendLineBuffer += LineBuffer; appendLineBuffer += '\n'; // Insert LF after the backslash continue; // Goto the top of loop and append next line } if(appendLineBuffer.length() > 0) { // Append the next line appendLineBuffer += LineBuffer; LineData = appendLineBuffer; appendLineBuffer.DeleteAt(0, appendLineBuffer.length()); } else LineData = LineBuffer; // Get rid of EOF marker if((strcmp(LineData.c_str(), "\0") == 0) && (infile.df_EOF())) break; // Routine to replace a line // ----------------------------------------------------------- if(check_case) { // Find entire match checking the case of the string offset = LineData.Find((char *)string_to_replace.c_str(), string_to_replace.length(), 0); } else { offset = LineData.IFind((char *)string_to_replace.c_str(), string_to_replace.length(), 0); } if(offset == -1) { // The configurable parameter was not found list.Add(LineData); // Store the line and continue continue; } int parm_id_offset = LineData.Find(parm_ID.c_str()); if(parm_id_offset == -1) { // This is not a configurable parameter list.Add(LineData); // Store the line and continue continue; } offset += string_to_replace.length(); // Ensure the complete string is matched before modifying the parameter if((LineData[offset] == ' ') || (LineData[offset] == parm_ID[0])) { LineData.DeleteAt(offset, (LineData.length() - offset)); LineData.InsertAt(offset, parm_ID.c_str()); // Insert parameter ID string LineData.InsertAt(++offset, string_to_insert); num_processed++; // Record number of string processed for this file } list.Add(LineData); // Store all the lines and continue } infile.df_Close(); // Close the input file // If any strings were replaced in the file, rewrite the file // ----------------------------------------------------------- if(num_processed > 0) { char *EndOfLineSequence; DiskFileB outfile(FileName.c_str(), DiskFileB::df_READWRITE, DiskFileB::df_CREATE); if(!outfile) return 0; // Cannot open the file #if defined (__WIN32__) || defined(__DOS__) EndOfLineSequence = "\r\n"; #else EndOfLineSequence = "\n"; #endif gxConfigListNode *list_ptr = (gxConfigListNode *)list.GetHead(); while(list_ptr) { if(list_ptr->data) { if(outfile.df_Write(list_ptr->node_data.c_str(), list_ptr->node_data.length()) != DiskFileB::df_NO_ERROR) { break; // Error writing to the file } if(outfile.df_Write(EndOfLineSequence, strlen(EndOfLineSequence)) != DiskFileB::df_NO_ERROR) { break; // Error writing to the file } } list_ptr = (gxConfigListNode *)list_ptr->next; } outfile.df_Close(); // Close the output file // Make the changes to the config list in already in memory ReLoad(); } list.ClearList(); return num_processed; }