Moka controlers
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerator
Friends
Macros
controler.cc
Go to the documentation of this file.
1
/*
2
* lib-controler : Un contrôleur générique de scène 3D.
3
* Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC
4
* http://www.sic.sp2mi.univ-poitiers.fr/
5
* Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS,
6
* guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/
7
*
8
* This file is part of lib-controler
9
*
10
* This program is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU Lesser General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
*
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Lesser General Public License for more details.
19
*
20
* You should have received a copy of the GNU Lesser General Public License
21
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
*/
23
24
//******************************************************************************
25
#include "
controler.hh
"
26
#include "
view-precompile.hh
"
27
#include <cstdlib>
28
#include <sys/types.h>
29
#include <sys/stat.h>
30
#include <fcntl.h>
31
32
#ifdef _WINDOWS
33
#include <direct.h>
34
#endif
35
36
using namespace
std;
37
//******************************************************************************
38
#define DEFAULT_DIRECTORY ".moka"
39
//******************************************************************************
40
CControler::CControler
(
int
ANb,
const
std::string & AName,
41
const
string
& ADirectory) :
42
// controler-views.hh
43
FViews
(
INITIAL_NB_VIEWS
),
44
FLastPrecompile
(ANb),
45
// controler-input-events.hh
46
FCurrentMode
(
MODE_DEFAULT
),
47
FCurrentModeOperation
(
MODE_OPERATION_NONE
),
48
// controler-undo-redo.hh
49
FUndoOnFile
(true),
50
FNbMaxUndos
(100),
51
FLastFileIndex
(0),
52
FActu
(NULL)
53
{
54
for
(
int
j=0; j<
INITIAL_NB_VIEWS
; ++j)
55
FViews
[j] = NULL;
56
57
//----------------------------------------------------------------------------
58
// Si le répertoire de configuration n'est pas fourni, on le fixe
59
// par défaut à $(HOME)
60
if
(ADirectory==
""
)
61
{
62
char
* home = getenv(
"HOME"
);
63
64
// Si la variable PATH existe, on l'analyse:
65
if
(home!=NULL)
66
FConfigDirectory
=string(home)+string(
"/"
);
67
}
68
69
//----------------------------------------------------------------------------
70
FConfigDirectory
+= AName;
71
72
// Création du répertoire FConfigDirectory au cas ou il n'existe pas déjà.
73
#ifdef _WINDOWS
74
_mkdir(
FConfigDirectory
.c_str());
75
#else
76
#if defined(_MSC_VER) || defined(__MINGW32__)
77
mkdir(
FConfigDirectory
.c_str());
78
#else
79
mkdir(
FConfigDirectory
.c_str(), 0755);
80
#endif
81
#endif
82
83
//----------------------------------------------------------------------------
84
85
// Récupération éventuelle des undo sur fichiers.
86
recupFromFiles
();
87
}
88
//******************************************************************************
89
CControler::~CControler
()
90
{
91
for
(vector<CViewPrecompile *>::iterator it =
FViews
.begin();
92
it!=
FViews
.end(); ++it)
93
if
( (*it)!=NULL )
94
delete
(*it);
95
96
emptyRedoList
();
97
}
98
//******************************************************************************
99
lib-controler
controler.cc
Generated on Tue Apr 9 2013 09:51:16 for Moka controlers by
1.8.2