// ###################################################################### GenericFrame RasterInputSeries::readFrame() { if (itsFrameNumber < 0) LFATAL("frame number is %d, but readFrame() requires a " "non-negative frame number", itsFrameNumber); // figure out the file name to use: const std::string fname(computeInputFileName(itsStem, itsFrameNumber)); // check if we've already read that file; if so, then return an // empty image if (fname == itsPrevFilename) { LINFO("repeated input file skipped: %s", fname.c_str()); return GenericFrame(); } // check whether the file exists; if not, then return an empty image: if (!Raster::fileExists(fname, itsRasterFileFormat.getVal())) { LINFO("no such file: %s", fname.c_str()); return GenericFrame(); } // load the image: const GenericFrame ima = Raster::ReadFrame(fname, itsRasterFileFormat.getVal()); itsPrevFilename = fname; textLog(itsLogFile.getVal(), "ReadFrame", fname); return ima; }
void MyFrame::OnShowUsage(wxCommandEvent& event) { wxLogTextCtrl textLog(m_logCtrl); wxLog* oldTarget = wxLog::SetActiveTarget(& textLog); wxLog::GetActiveTarget()->Flush(); wxGetApp().m_parser.Usage(); wxLog::SetActiveTarget(oldTarget); }
//------------------------------------------------------------------ // // WriteTimeStampEntry(..) // // Params: // log - Text to log // // Writes entry to text file include the time stamp // //------------------------------------------------------------------ void CDebugLog::WriteTimeStampEntry(const std::string& log) { if (m_bInit) { time_t rawTime; struct tm timeinfo; char buffer[32]; time(&rawTime); localtime_s(&timeinfo, &rawTime); strftime(buffer, 32, "%H:%M:%S", &timeinfo); // Replace the new line tag std::string textLog(buffer); textLog[textLog.length() - 1] = ' '; textLog += "- "; m_fileStream << textLog << log << "\n"; } }
bool MyApp::ProcessCommandLine(MyFrame* frame) { bool success = TRUE; wxLogTextCtrl textLog(frame->m_logCtrl); wxLog* oldTarget = wxLog::SetActiveTarget(& textLog); Log(m_cmdLine); int retValue = m_parser.Parse(); if (retValue == -1) { // Help message m_parser.Usage(); success = FALSE; } else if (retValue > 0) { // Syntax error Log(wxT("Sorry, syntax error.")); success = FALSE; } else { if (m_parser.Found(wxT("h"))) { m_parser.Usage(); success = FALSE; } else { m_batchMode = m_parser.Found(wxT("b")); // command line OK. Find option values. if (!m_parser.Found(wxT("i"), & m_inputFilename)) { Log(wxT("You must supply an input filename.")); m_batchMode = FALSE; success = FALSE; } if (!m_parser.Found(wxT("o"), & m_outputFilename)) { Log(wxT("You must supply an output filename.")); m_batchMode = FALSE; success = FALSE; } if (!m_parser.Found(wxT("t"), & m_text)) { Log(wxT("You must supply some text to add.")); success = FALSE; m_batchMode = FALSE; } m_parser.Found(wxT("f"), & m_fontFaceName); m_parser.Found(wxT("p"), & m_fontPointSize); long x = 0, y = 0; m_parser.Found(wxT("x"), & x); m_parser.Found(wxT("y"), & y); m_textPosition = wxPoint(x, y); wxString colourStr; if (m_parser.Found(wxT("fcol"), & colourStr)) { m_textForegroundColour = wxHexStringToColour(colourStr); } if (m_parser.Found(wxT("bcol"), & colourStr)) { m_textBackgroundColour = wxHexStringToColour(colourStr); } m_parser.Found(wxT("m"), & m_scaleFactor); // Find switches m_verbose = m_parser.Found(wxT("v")); m_centre = m_parser.Found(wxT("c")); m_rightJustify = m_parser.Found(wxT("r")); m_antialias = m_parser.Found(wxT("a")); if (m_parser.Found(wxT("bo"))) m_fontWeight = wxBOLD; if (m_parser.Found(wxT("it"))) m_fontStyle = wxITALIC; } } if (success) { success = MakeSplash(); } wxLog::GetActiveTarget()->Flush(); wxLog::SetActiveTarget(oldTarget); return success; }