diff --git a/ChangeLog b/ChangeLog index 874ae534..32870666 100644 --- a/ChangeLog +++ b/ChangeLog @@ -48,6 +48,10 @@ FIXED warning messages FIXED db data tag reading error FIXED usage of BOOST >= 1.38.0 FIXED the extraction of the time resolution for the mud data format, since MUD_getHistFsPerBin seems sometimes to return just crap. +CHANGED fit range decimal precision handling of PMsrHandler improved (MUSR-150 request). It is now + handling up to 4 decimal places. +CHANGED musredit: now it is keeping the directory from which the last msr-file has been loaded. This directory is + used when a new open dialog is called. CHANGED another attempt to get proper zooming/unzooming. This time I tried to disentangle the rather messy PMusrCanvas class. Most of the checks seems to work, though still for non-muSR style, musrview is crashing once in a while which seems to come from root rather than musrview. I will try to investigate that on root macro level. diff --git a/src/classes/PMsrHandler.cpp b/src/classes/PMsrHandler.cpp index decba739..05fd4e3d 100644 --- a/src/classes/PMsrHandler.cpp +++ b/src/classes/PMsrHandler.cpp @@ -830,7 +830,7 @@ Int_t PMsrHandler::WriteMsrLogFile(const Bool_t messages) if (fRuns[runNo].GetFitRange(j) == -1) break; fout.width(8); - fout.precision(2); + fout.precision(NeededPrecision(fRuns[runNo].GetFitRange(j))); fout << left << fixed << fRuns[runNo].GetFitRange(j); } fout << endl; @@ -1510,7 +1510,7 @@ Int_t PMsrHandler::WriteMsrFile(const Char_t *filename, map *co if (fRuns[i].GetFitRange(j) == -1) break; fout.width(8); - fout.precision(2); + fout.precision(NeededPrecision(fRuns[i].GetFitRange(j))); fout << left << fixed << fRuns[i].GetFitRange(j); } fout << endl; @@ -4591,4 +4591,39 @@ Bool_t PMsrHandler::CheckAddRunParameters() return result; } +//-------------------------------------------------------------------------- +// NeededPrecision (private) +//-------------------------------------------------------------------------- +/** + *

Calculates the needed precision of Double_t values for WriteMsrLogFile and WriteMsrFile of the fit range. + * If a precision of > 4 decimal places is needed, a warning is placed and a value of 4 is returned. + * + * \param dval value for which the precision has to be estimated + * + * return: + * needed precision fo the fit-range + */ +UInt_t PMsrHandler::NeededPrecision(Double_t dval) +{ + UInt_t prec=0; + + Int_t ival = static_cast(round(dval*1.0e4)); + + if ((ival % 10) != 0) + prec = 4; + else if ((ival % 100) != 0) + prec = 3; + else if ((ival % 1000) != 0) + prec = 2; + else if ((ival % 10000) != 0) + prec = 1; + else if (static_cast(ival)-dval*1.0e4 > 0.1) { + prec = 4; + cerr << endl << ">> PMsrHandler::NeededPrecision(): **WARNING** fit range value = " << dval << ", is asking for a rediculous resolution."; + cerr << endl << ">> Will limit the precision to 4 decimal places, only." << endl; + } + + return prec; +} + // end --------------------------------------------------------------------- diff --git a/src/include/PMsrHandler.h b/src/include/PMsrHandler.h index 74d81aae..9dd5baa9 100644 --- a/src/include/PMsrHandler.h +++ b/src/include/PMsrHandler.h @@ -138,6 +138,8 @@ class PMsrHandler virtual void InitFourierParameterStructure(PMsrFourierStructure &fourier); virtual Bool_t FilterNumber(TString str, const Char_t *filter, Int_t offset, Int_t &no); + + virtual UInt_t NeededPrecision(Double_t dval); }; #endif // _PMSRHANDLER_H_ diff --git a/src/musredit/PTextEdit.cpp b/src/musredit/PTextEdit.cpp index 736ee9e4..aac56340 100644 --- a/src/musredit/PTextEdit.cpp +++ b/src/musredit/PTextEdit.cpp @@ -133,6 +133,8 @@ PTextEdit::PTextEdit( QWidget *parent, Qt::WindowFlags f ) } connect( fTabWidget, SIGNAL( currentChanged(QWidget*) ), this, SLOT( applyFontSettings(QWidget*) )); + + fLastDirInUse = fAdmin->getDefaultSavePath(); } //---------------------------------------------------------------------------------------------------- @@ -822,7 +824,7 @@ void PTextEdit::fileNew() void PTextEdit::fileOpen() { QStringList flns = QFileDialog::getOpenFileNames( this, tr("Open msr-/mlog-File"), - fAdmin->getDefaultSavePath(), + fLastDirInUse, tr( "msr-Files (*.msr);;msr-Files (*.msr *.mlog);;All Files (*)" )); QStringList::Iterator it = flns.begin(); @@ -830,6 +832,12 @@ void PTextEdit::fileOpen() QString tabFln; bool alreadyOpen = false; + // if flns are present, keep the corresponding directory + if (flns.size() > 0) { + finfo1.setFile(flns.at(0)); + fLastDirInUse = finfo1.absoluteFilePath(); + } + while( it != flns.end() ) { // check if the file is not already open finfo1.setFile(*it); @@ -2046,6 +2054,8 @@ void PTextEdit::musrView() str = *fFilenames.find( currentEditor() ); cmd += str + "\" &"; +qDebug() << endl << cmd << endl; + system(cmd.toLatin1()); } diff --git a/src/musredit/PTextEdit.h b/src/musredit/PTextEdit.h index a4e4d868..243b3f7d 100644 --- a/src/musredit/PTextEdit.h +++ b/src/musredit/PTextEdit.h @@ -146,6 +146,7 @@ private: QFileSystemWatcher *fFileSystemWatcher; ///< checks if msr-files are changing on the disk while being open in musredit. bool fFileSystemWatcherActive; ///< flag to enable/disable the file system watcher QTimer fFileSystemWatcherTimeout; ///< timer used to re-enable file system watcher. Needed to delay the re-enabling + QString fLastDirInUse; ///< string holding the path from where the last file was loaded. QAction *fMusrT0Action;