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 "view-precompile.hh"
00027
00028 TMode CControler::getMode() const
00029 { return FCurrentMode; }
00030
00031 void CControler::setMode(TMode AMode)
00032 {
00033 if (AMode == FCurrentMode)
00034 return;
00035
00036
00037 exitMode();
00038
00039
00040 FCurrentMode = AMode;
00041
00042
00043 onEnterMode();
00044 }
00045
00046 void CControler::toggleMode(TMode AMode)
00047 {
00048 if (AMode == FCurrentMode) setMode(MODE_DEFAULT);
00049 else setMode(AMode);
00050 }
00051
00052 void CControler::exitMode()
00053 {
00054
00055 operationModeStop(0,0);
00056
00057
00058 onExitMode();
00059
00060
00061 FCurrentMode = MODE_DEFAULT;
00062 }
00063
00064 void CControler::onEnterMode()
00065 {
00066 switch (FCurrentMode)
00067 {
00068 case MODE_SELECTION: modeSelectionBegin(); break;
00069 }
00070 }
00071
00072 void CControler::onExitMode()
00073 {
00074 switch (FCurrentMode)
00075 {
00076 case MODE_SELECTION: modeSelectionEnd(); break;
00077 }
00078 }
00079
00080 void CControler::onOperationModeStart()
00081 {
00082 switch (FCurrentMode)
00083 {
00084 case MODE_SELECTION:
00085 FCurrentModeOperation = MODE_OPERATION_SELECTION;
00086 modeSelectionOperationStart();
00087 break;
00088 }
00089 }
00090
00091 void CControler::onOperationModeMove()
00092 {
00093 switch (FCurrentModeOperation)
00094 {
00095 case MODE_OPERATION_SELECTION : modeSelectionOperationMove ();
00096 break;
00097 case MODE_OPERATION_SCENE_TRANSLATION: modeSceneTranslationOperationMove();
00098 break;
00099 case MODE_OPERATION_SCENE_ROTATION : modeSceneRotationOperationMove ();
00100 break;
00101 case MODE_OPERATION_SCENE_SCALE : modeSceneScaleOperationMove ();
00102 break;
00103 }
00104 }
00105
00106 void CControler::onOperationModeStop()
00107 {
00108 switch (FCurrentModeOperation)
00109 {
00110 case MODE_OPERATION_SELECTION : modeSelectionOperationStop(); break;
00111 case MODE_OPERATION_SCENE_TRANSLATION:
00112 case MODE_OPERATION_SCENE_ROTATION :
00113 case MODE_OPERATION_SCENE_SCALE : modeSceneTransformationOperationStop();
00114 break;
00115 }
00116 }
00117
00118 void CControler::operationModeStart(TViewId AViewId, int Ax, int Ay)
00119 {
00120 if (FCurrentModeOperation!=MODE_OPERATION_NONE)
00121 operationModeStop(FLastX, FLastY);
00122
00123 assert(FViews[AViewId] != NULL);
00124
00125 FCurrentViewId = AViewId;
00126 FFirstX = FLastX = Ax; FDeltaX = 0;
00127 FFirstY = FLastY = Ay; FDeltaY = 0;
00128
00129
00130 onOperationModeStart();
00131 }
00132
00133 void CControler::operationModeMove(int Ax, int Ay)
00134 {
00135 if (FCurrentModeOperation==MODE_OPERATION_NONE) return;
00136
00137 FLastX = Ax; FDeltaX = FLastX - FFirstX;
00138 FLastY = Ay; FDeltaY = FLastY - FFirstY;
00139
00140
00141 onOperationModeMove();
00142 }
00143
00144 void CControler::operationModeStop(int Ax, int Ay)
00145 {
00146 if (FCurrentModeOperation==MODE_OPERATION_NONE) return;
00147
00148 FLastX = Ax; FDeltaX = FLastX - FFirstX;
00149 FLastY = Ay; FDeltaY = FLastY - FFirstY;
00150
00151
00152 onOperationModeStop();
00153
00154
00155
00156 FCurrentModeOperation = MODE_OPERATION_NONE;
00157 }
00158
00159 void CControler::operationModeIndependentStart( TModeOperation AOperation,
00160 TViewId AViewId,
00161 int Ax, int Ay )
00162 {
00163 if ( FCurrentModeOperation!=MODE_OPERATION_NONE ||
00164 ( AOperation!=MODE_OPERATION_SCENE_TRANSLATION &&
00165 AOperation!=MODE_OPERATION_SCENE_ROTATION &&
00166 AOperation!=MODE_OPERATION_SCENE_SCALE ))
00167 return;
00168
00169 FCurrentModeOperation = AOperation;
00170
00171 FCurrentViewId = AViewId;
00172
00173 FFirstX = FLastX = Ax; FDeltaX = 0;
00174 FFirstY = FLastY = Ay; FDeltaY = 0;
00175
00176 CViewPrecompile* view = FViews[FCurrentViewId];
00177 assert(view != NULL);
00178
00179 FMemoEyePosition = view->getEyePosition();
00180 FMemoAimedPosition = view->getAimedPosition();
00181
00182 view->unproject(FFirstX, FFirstY, FFirst3D);
00183 }
00184