00001 /* 00002 * lib-controler : Un contrôleur générique de scène 3D. 00003 * Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC 00004 * http://www.sic.sp2mi.univ-poitiers.fr/ 00005 * Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS, 00006 * guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/ 00007 * 00008 * This file is part of lib-controler 00009 * 00010 * This program is free software: you can redistribute it and/or modify 00011 * it under the terms of the GNU Lesser General Public License as published by 00012 * the Free Software Foundation, either version 3 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public License 00021 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00022 */ 00023 00024 //****************************************************************************** 00025 #include "controler.hh" 00026 #include "view-precompile.hh" 00027 #include <cstdlib> 00028 #include <sys/types.h> 00029 #include <sys/stat.h> 00030 #include <fcntl.h> 00031 00032 using namespace std; 00033 //****************************************************************************** 00034 #define DEFAULT_DIRECTORY ".moka" 00035 //****************************************************************************** 00036 CControler::CControler(int ANb, const std::string & AName, 00037 const string & ADirectory) : 00038 // controler-views.hh 00039 FViews (INITIAL_NB_VIEWS), 00040 FLastPrecompile (ANb), 00041 // controler-input-events.hh 00042 FCurrentMode (MODE_DEFAULT), 00043 FCurrentModeOperation(MODE_OPERATION_NONE), 00044 // controler-undo-redo.hh 00045 FUndoOnFile (true), 00046 FNbMaxUndos (100), 00047 FLastFileIndex (0), 00048 FActu (NULL) 00049 { 00050 for (int j=0; j<INITIAL_NB_VIEWS; ++j) 00051 FViews[j] = NULL; 00052 00053 //---------------------------------------------------------------------------- 00054 // Si le répertoire de configuration n'est pas fourni, on le fixe 00055 // par défaut à $(HOME) 00056 if (ADirectory=="") 00057 { 00058 char* home = getenv("HOME"); 00059 00060 // Si la variable PATH existe, on l'analyse: 00061 if (home!=NULL) 00062 FConfigDirectory=string(home)+string("/"); 00063 } 00064 00065 //---------------------------------------------------------------------------- 00066 FConfigDirectory += AName; 00067 00068 // Création du répertoire FConfigDirectory au cas ou il n'existe pas déjà. 00069 #if defined(_MSC_VER) || defined(__MINGW32__) 00070 mkdir(FConfigDirectory.c_str()); 00071 #else 00072 mkdir(FConfigDirectory.c_str(), 0755); 00073 #endif 00074 00075 //---------------------------------------------------------------------------- 00076 00077 // Récupération éventuelle des undo sur fichiers. 00078 recupFromFiles(); 00079 } 00080 //****************************************************************************** 00081 CControler::~CControler() 00082 { 00083 for (vector<CViewPrecompile *>::iterator it = FViews.begin(); 00084 it!=FViews.end(); ++it) 00085 if ( (*it)!=NULL ) 00086 delete (*it); 00087 00088 emptyRedoList(); 00089 } 00090 //****************************************************************************** 00091
1.5.8