Ignore:
Timestamp:
Mar 4, 2008, 5:27:31 PM (16 years ago)
Author:
garnier
Message:

on avance

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/geant4/visualization/OpenGL/src/G4OpenGLQtViewer.cc

    r733 r735  
    301301  ,fHoldRotateEvent(false)
    302302  ,fAutoMove(false)
    303   ,fEncoderPath("")
    304   ,fTempFolderPath("/temp")
    305303  ,fMovieParametersDialog(NULL)
    306304{
     305  initMovieParameters();
    307306#ifdef GEANT4_QT_DEBUG
    308307  printf("G4OpenGLQtViewer::G4OpenGLQtViewer \n");
     
    21452144 
    21462145
    2147 /** @return if encoder path was not specified, try to guess it.
    2148  * if path was already specified, return it.Else return ""
     2146/** @return encoder path or "" if it does not exist
    21492147 */
    21502148QString G4OpenGLQtViewer::getEncoderPath() {
    21512149
    2152    if (fEncoderPath.isNull())
    2153      fEncoderPath ="";
    2154    if (fEncoderPath.isEmpty()) {
    2155  
    2156      //look for encoderPath
     2150   if (!fEncoderPath.isNull())
     2151    return fEncoderPath ;
     2152   return "";
     2153}
     2154 
     2155
     2156/**
     2157 * set the new encoder path
     2158 * @return "" if correct. The error otherwise
     2159*/
     2160QString G4OpenGLQtViewer::setEncoderPath(QString path) {
     2161  if (path == "") {
     2162    return "Path does not exist";
     2163  }
     2164  QFile *f = new QFile(path);
     2165  if (!f->exists()) {
     2166    return "Path does not exist";
     2167  }
     2168  if (!(f->permissions() & QFile::ExeUser)) {
     2169    return "File exist but is not executable";
     2170  }
     2171  fEncoderPath = path;
     2172  return "";
     2173}
     2174
     2175/**
     2176 * set the temp folder path
     2177 * @return "" if correct. The error otherwise
     2178*/
     2179QString G4OpenGLQtViewer::setTempFolderPath(QString path) {
     2180
     2181  if (path == "") {
     2182    return "Path does not exist";
     2183  }
     2184  QDir *d = new QDir(path);
     2185  if (!d->exists(path)) {
     2186    return "Path does not exist";
     2187  }
     2188
     2189  d->setFilter( QDir::Dirs | QDir::Readable | QDir::Writable );
     2190  QStringList subDirList = d->entryList();
     2191  bool found = false;
     2192
     2193  for (QStringList::ConstIterator it = subDirList.begin() ;(it != subDirList.end()) ; it++) {
     2194    const QString currentDir = *it;
     2195   
     2196    if (currentDir == ".") { // we found it
     2197      found = true;
     2198    }
     2199  }
     2200
     2201  if (!found)
     2202    return "Path exist, but is not write accessible";
     2203 
     2204  fTempFolderPath = path;
     2205  return "";
     2206}
     2207
     2208/** @return the temp folder path or "" if it does not exist
     2209 */
     2210QString G4OpenGLQtViewer::getTempFolderPath() {
     2211  if (!fTempFolderPath.isNull())
     2212    return fTempFolderPath ;
     2213return "";
     2214}
     2215 
     2216/**
     2217 * set the save file name path
     2218 * @return "" if correct. The error otherwise
     2219*/
     2220QString G4OpenGLQtViewer::setSaveFileName(QString path) {
     2221
     2222  if (path == "") {
     2223    return "Path does not exist";
     2224  }
     2225  QDir *d = new QDir(path);
     2226  if (!d->exists(path)) {
     2227    return "Path does not exist";
     2228  }
     2229
     2230  d->setFilter( QDir::Dirs | QDir::Readable | QDir::Writable );
     2231  QStringList subDirList = d->entryList();
     2232  bool found = false;
     2233
     2234  for (QStringList::ConstIterator it = subDirList.begin() ;(it != subDirList.end()) ; it++) {
     2235    const QString currentDir = *it;
     2236   
     2237    if (currentDir == ".") { // we found it
     2238      found = true;
     2239    }
     2240  }
     2241
     2242  if (!found)
     2243    return "Path exist, but is not write accessible";
     2244 
     2245  fSaveFileName = path;
     2246  return "";
     2247}
     2248
     2249/** @return the save file path
     2250 */
     2251QString G4OpenGLQtViewer::getSaveFileName() {
     2252  return fSaveFileName ;
     2253}
     2254
     2255/** Init the movie parameters. Temp dir and encoder path
     2256*/
     2257void G4OpenGLQtViewer::initMovieParameters() {
     2258#ifdef GEANT4_QT_DEBUG
     2259  printf("G4OpenGLQtViewer::--------\n");
     2260#endif
     2261  //init encoder
     2262 
     2263   //look for encoderPath
    21572264     QProcess search;
    21582265     search.setReadChannelMode(QProcess::MergedChannels);
     
    21682275       }
    21692276     }
    2170    }
    2171   return fEncoderPath ;
    2172 }
    2173  
    2174 
    2175 /**
    2176  * set the new encoder path
    2177  * @return "" if correct. The error otherwise
    2178 */
    2179 QString G4OpenGLQtViewer::setEncoderPath(QString path) {
    2180   QFile *f = new QFile(path);
    2181   if (!f->exists()) {
    2182 #ifdef GEANT4_QT_DEBUG
    2183   printf("G4OpenGLQtViewer::setEncoderPath NOT EXIST\n");
    2184 #endif
    2185     return "Path does not exist";
    2186   }
    2187   if (!(f->permissions() & QFile::ExeUser)) {
    2188 #ifdef GEANT4_QT_DEBUG
    2189   printf("G4OpenGLQtViewer::setEncoderPath No WRITE ACCES\n");
    2190 #endif
    2191     return "File exist but is not executable";
    2192   }
    2193   fEncoderPath = path;
    2194   return "";
    2195 }
    2196 
    2197 /**
    2198  * set the temp folder path
    2199  * @return "" if correct. The error otherwise
    2200 */
    2201 QString G4OpenGLQtViewer::setTempFolderPath(QString path) {
    2202 
    2203   QDir *d = new QDir(path);
    2204   if (!d->exists(path)) {
    2205     return "Path does not exist";
    2206   }
    2207 
    2208   d->setFilter( QDir::Dirs | QDir::Readable | QDir::Writable );
    2209   QStringList subDirList = d->entryList();
    2210   bool found = false;
    2211 
    2212   for (QStringList::ConstIterator it = subDirList.begin() ;(it != subDirList.end()) ; it++) {
    2213     const QString currentDir = *it;
    2214    
    2215     if (currentDir == ".") { // we found it
    2216       found = true;
    2217     }
    2218   }
    2219 
    2220   if (!found)
    2221     return "Path exist, but is not write accessible";
    2222  
    2223   fTempFolderPath = path;
    2224   return "";
    2225 }
    2226 
    2227 /** @return the temp folder path
    2228  */
    2229 QString G4OpenGLQtViewer::getTempFolderPath() {
    2230   return fTempFolderPath ;
    2231 }
    2232  
    2233 /**
    2234  * set the save file name path
    2235  * @return "" if correct. The error otherwise
    2236 */
    2237 QString G4OpenGLQtViewer::setSaveFileName(QString path) {
    2238 
    2239   QDir *d = new QDir(path);
    2240   if (!d->exists(path)) {
    2241     return "Path does not exist";
    2242   }
    2243 
    2244   d->setFilter( QDir::Dirs | QDir::Readable | QDir::Writable );
    2245   QStringList subDirList = d->entryList();
    2246   bool found = false;
    2247 
    2248   for (QStringList::ConstIterator it = subDirList.begin() ;(it != subDirList.end()) ; it++) {
    2249     const QString currentDir = *it;
    2250    
    2251     if (currentDir == ".") { // we found it
    2252       found = true;
    2253     }
    2254   }
    2255 
    2256   if (!found)
    2257     return "Path exist, but is not write accessible";
    2258  
    2259   fSaveFileName = path;
    2260   return "";
    2261 }
    2262 
    2263 /** @return the save file path
    2264  */
    2265 QString G4OpenGLQtViewer::getSaveFileName() {
    2266   return fSaveFileName ;
    2267 }
    2268 
    2269  
     2277     setEncoderPath(fEncoderPath);
     2278// init temp folder
     2279  setTempFolderPath(QDir::temp ().absolutePath ());
     2280#ifdef GEANT4_QT_DEBUG
     2281  printf("G4OpenGLQtViewer::--------\n");
     2282#endif
     2283}
    22702284
    22712285
Note: See TracChangeset for help on using the changeset viewer.