00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "controler.hh"
00026 #include "operations.hh"
00027 #include "view-precompile.hh"
00028
00029 #include <cassert>
00030 #include <cstring>
00031 using namespace std;
00032
00033 bool CControler::canApplyOperation(const COperation& )
00034 {
00035 return true;
00036 }
00037
00038 bool CControler::applyOperation(const COperation& )
00039 {
00040 return false;
00041 }
00042
00043 #ifdef NO_ACCENTED_CHARS
00044 char CControler::unaccent(char AChar) const
00045 {
00046 static const char* from = "àâÀÂéèëêÉÈËÊîïÎÏôÔùûÙÛ";
00047 static const char* to = "aaAAeeeeEEEEiiIIoOuuUU";
00048
00049 char* pos = strchr(from, AChar);
00050
00051 if (pos != NULL)
00052 return * (to - from + pos);
00053
00054 return AChar;
00055 }
00056 #endif // NO_ACCENTED_CHARS
00057
00058 string CControler::treatAccent(const string& AString) const
00059 {
00060 string result = AString;
00061
00062 #ifdef NO_ACCENTED_CHARS
00063 for (unsigned int i=0; i<result.length(); ++i)
00064 result[i] = unaccent(result[i]);
00065
00066 #endif // NO_ACCENTED_CHARS
00067
00068 return result;
00069 }
00070
00071 string CControler::getMessage() const
00072 {
00073 return treatAccent(FMessage);
00074 }
00075
00076 bool CControler::lookAtOrigin(TViewId AView)
00077 {
00078 getParameterAimedPosition(AView)->setLookAt(0,0);
00079 getParameterAimedPosition(AView)->setLookAt(1,0);
00080 getParameterAimedPosition(AView)->setLookAt(2,0);
00081 return true;
00082 }
00083
00084 bool CControler::lookAtMouseClick(TViewId AView, int x, int y)
00085 {
00086 CViewPrecompile * view = FViews[AView];
00087
00088 if (view != NULL)
00089 {
00090 float res[3];
00091 view -> unproject(x,y,res);
00092
00093 CParameterAimedPosition * aimed_pos = getParameterAimedPosition(AView);
00094 aimed_pos -> setLookAt(0,res[0]);
00095 aimed_pos -> setLookAt(1,res[1]);
00096 aimed_pos -> setLookAt(2,res[2]);
00097 return true;
00098 }
00099 return false;
00100 }
00101