Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYCameraEditor.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012> <EDF-R&D> <FRANCE>
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10  * See the GNU General Public License for more details.
11  * You should have received a copy of the GNU General Public License along
12  * with this program; if not, write to the Free Software Foundation, Inc.,
13  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
14  */
15 
21 #include <math.h>
22 #include <qtimer.h>
23 #include <qcursor.h>
24 
32 #include "TYCameraEditor.h"
33 
34 using namespace Qt;
35 
37 {
38  _firstCall = true;
39 
45 
51 
57 
63 
64  _mouseEventActive = false;
65  _keyEventActive = 0;
67  setSensitivity(10.0);
68  setWheelStep(1.0);
69 
70  _bKeyUp = false;
71  _bKeyDown = false;
72  _bKeyLeft = false;
73  _bKeyRight = false;
74  _bKeyPageUp = false;
75  _bKeyPageDown = false;
76  _bKeyShift = false;
77 
78  _pStepTimer = new QTimer(this);
79  Q_CHECK_PTR(_pStepTimer);
80 
82  Q_CHECK_PTR(_pCurrentCamera);
83 
84  _zoomStep = 2.0f;
85  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "CameraZoomStep"))
86  {
87  _zoomStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "CameraZoomStep");
88  }
89  else
90  {
91  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "CameraZoomStep", _zoomStep);
92  }
93 
94  _translateStep = 5.0f;
95  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "CameraTranslateStep"))
96  {
97  _translateStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "CameraTranslateStep");
98  }
99  else
100  {
101  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "CameraTranslateStep", _translateStep);
102  }
103 
104  _rotateStep = 10.0f;
105  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "CameraRotateStep"))
106  {
107  _rotateStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "CameraRotateStep");
108  }
109  else
110  {
111  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "CameraRotateStep", _rotateStep);
112  }
113 
114  // Pour la mise a jour de l'orientation et la position des axes et de la grille
115  QObject::connect(this, &TYCameraEditor::cameraUpdated, pModeler, &TYModelerFrame::updateAxes);
116  QObject::connect(this, &TYCameraEditor::cameraUpdated, pModeler, &TYModelerFrame::updateGrid);
117  // Pour le passage en mode wireframe lors du deplacement de la cam si l'option est active
118  QObject::connect(this, &TYCameraEditor::startMovingCamera, pModeler,
120  QObject::connect(this, &TYCameraEditor::stopMovingCamera, pModeler,
122  // L'echelle est mise a jour a la fin de chaque deplacement de camera
123  QObject::connect(this, &TYCameraEditor::stopMovingCamera, pModeler, &TYModelerFrame::updateScale);
124 
126 }
127 
129 
131 {
132  if (function == NULL)
133  {
135  }
136  else
137  {
138  _leftButtonFunction = function;
139  }
140 }
141 
143 {
144  if (function == NULL)
145  {
147  }
148  else
149  {
150  _middleButtonFunction = function;
151  }
152 }
153 
155 {
156  if (function == NULL)
157  {
159  }
160  else
161  {
162  _rightButtonFunction = function;
163  }
164 }
165 
167 {
168  if (function == NULL)
169  {
171  }
172  else
173  {
174  _shiftLeftButtonFunction = function;
175  }
176 }
177 
179 {
180  if (function == NULL)
181  {
183  }
184  else
185  {
186  _shiftRightButtonFunction = function;
187  }
188 }
189 
191 {
192  if (function == NULL)
193  {
195  }
196  else
197  {
198  _leftButtonFunction2D = function;
199  }
200 }
201 
203 {
204  if (function == NULL)
205  {
207  }
208  else
209  {
210  _middleButtonFunction2D = function;
211  }
212 }
213 
215 {
216  if (function == NULL)
217  {
219  }
220  else
221  {
222  _rightButtonFunction2D = function;
223  }
224 }
225 
227 {
228  if (function == NULL)
229  {
231  }
232  else
233  {
234  _shiftLeftButtonFunction2D = function;
235  }
236 }
237 
239 {
240  if (function == NULL)
241  {
243  }
244  else
245  {
246  _shiftRightButtonFunction2D = function;
247  }
248 }
249 
251 {
252  if (function == NULL)
253  {
255  }
256  else
257  {
258  _leftButtonFunction3D = function;
259  }
260 }
261 
263 {
264  if (function == NULL)
265  {
267  }
268  else
269  {
270  _middleButtonFunction3D = function;
271  }
272 }
273 
275 {
276  if (function == NULL)
277  {
279  }
280  else
281  {
282  _rightButtonFunction3D = function;
283  }
284 }
285 
287 {
288  if (function == NULL)
289  {
291  }
292  else
293  {
294  _shiftLeftButtonFunction3D = function;
295  }
296 }
297 
299 {
300  if (function == NULL)
301  {
303  }
304  else
305  {
306  _shiftRightButtonFunction3D = function;
307  }
308 }
309 
311 {
312  if (function == NULL)
313  {
315  }
316  else
317  {
318  _leftButtonFunctionFree = function;
319  }
320 }
321 
323 {
324  if (function == NULL)
325  {
327  }
328  else
329  {
330  _middleButtonFunctionFree = function;
331  }
332 }
333 
335 {
336  if (function == NULL)
337  {
339  }
340  else
341  {
342  _rightButtonFunctionFree = function;
343  }
344 }
345 
347 {
348  if (function == NULL)
349  {
351  }
352  else
353  {
354  _shiftLeftButtonFunctionFree = function;
355  }
356 }
357 
359 {
360  if (function == NULL)
361  {
363  }
364  else
365  {
367  }
368 }
369 
371 {
373  {
374  // Update la cam courante
376  switch (key)
377  {
378  case Qt::Key_Shift:
379  {
380  _bKeyShift = true;
381  _keyEventActive++;
382  if (_keyEventActive > 1)
383  {
384  return;
385  }
386  else
387  {
388  QObject::connect(_pStepTimer, &QTimer::timeout, this,
390  }
391  }
392  break;
393  case Qt::Key_Up:
394  {
395  _bKeyUp = true;
396  _keyEventActive++;
397  if (_keyEventActive > 1)
398  {
399  return;
400  }
401  else
402  {
403  QObject::connect(_pStepTimer, &QTimer::timeout, this,
405  }
406  }
407  break;
408  case Qt::Key_Down:
409  {
410  _bKeyDown = true;
411  _keyEventActive++;
412  if (_keyEventActive > 1)
413  {
414  return;
415  }
416  else
417  {
418  QObject::connect(_pStepTimer, &QTimer::timeout, this,
420  }
421  }
422  break;
423  case Qt::Key_Left:
424  {
425  _bKeyLeft = true;
426  _keyEventActive++;
427  if (_keyEventActive > 1)
428  {
429  return;
430  }
431  else
432  {
433  QObject::connect(_pStepTimer, &QTimer::timeout, this,
435  }
436  }
437  break;
438  case Qt::Key_Right:
439  {
440  _bKeyRight = true;
441  _keyEventActive++;
442  if (_keyEventActive > 1)
443  {
444  return;
445  }
446  else
447  {
448  QObject::connect(_pStepTimer, &QTimer::timeout, this,
450  }
451  }
452  break;
453  case Qt::Key_PageUp:
454  {
455  _bKeyPageUp = true;
456  _keyEventActive++;
457  if (_keyEventActive > 1)
458  {
459  return;
460  }
461  else
462  {
463  QObject::connect(_pStepTimer, &QTimer::timeout, this,
465  }
466  }
467  break;
468  case Qt::Key_PageDown:
469  {
470  _bKeyPageDown = true;
471  _keyEventActive++;
472  if (_keyEventActive > 1)
473  {
474  return;
475  }
476  else
477  {
478  QObject::connect(_pStepTimer, &QTimer::timeout, this,
480  }
481  }
482  break;
483  }
484 
485  if (_keyEventActive > 0)
486  {
487  _firstCall = true;
489  emit startMovingCamera();
490  }
491  }
492 }
493 
495 {
497  {
498  if (_keyEventActive > 0)
499  {
500  _keyEventActive--;
501  switch (key)
502  {
503  case Qt::Key_Shift:
504  {
505  _bKeyShift = false;
506  }
507  break;
508  case Qt::Key_Up:
509  {
510  _bKeyUp = false;
511  }
512  break;
513  case Qt::Key_Down:
514  {
515  _bKeyDown = false;
516  }
517  break;
518  case Qt::Key_Left:
519  {
520  _bKeyLeft = false;
521  }
522  break;
523  case Qt::Key_Right:
524  {
525  _bKeyRight = false;
526  }
527  break;
528  case Qt::Key_PageUp:
529  {
530  _bKeyPageUp = false;
531  }
532  break;
533  case Qt::Key_PageDown:
534  {
535  _bKeyPageDown = false;
536  }
537  break;
538  }
539 
540  if (_keyEventActive == 0)
541  {
542  if (!_mouseEventActive)
543  {
544  _pStepTimer->stop();
545  QObject::disconnect(_pStepTimer, 0, this, 0);
546 
547  emit stopMovingCamera();
548  }
549  }
550  }
551  }
552 }
553 
554 void TYCameraEditor::slotMousePressed(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
555 {
556  if (_mouseEventActive)
557  {
558  return;
559  }
560 
561  // Update la cam courante
563 
565  {
567  }
568  else
569  {
570  _pCurrentCamera->setDistanceStep(30, 70, 30);
571  }
572 
573  if (button & LeftButton)
574  {
575  // Left mouse button
576  _mouseEventActive = true;
577 
578  if (state & ShiftModifier)
579  {
580  // With Shift button
581  QObject::connect(_pStepTimer, &QTimer::timeout, this, _shiftLeftButtonFunction);
582  }
583  else
584  {
585  // Without shift button
586  QObject::connect(_pStepTimer, &QTimer::timeout, this, _leftButtonFunction);
587  }
588  }
589  else if (button & MiddleButton)
590  {
591  // Middle mouse button
592  _mouseEventActive = true;
593  QObject::connect(_pStepTimer, &QTimer::timeout, this, _middleButtonFunction);
594  }
595  else if (button & RightButton)
596  {
597  // Right mouse button
598  _mouseEventActive = true;
599 
600  if (state & ShiftModifier)
601  {
602  // With Shift button
603  QObject::connect(_pStepTimer, &QTimer::timeout, this, _shiftRightButtonFunction);
604  }
605  else
606  {
607  // Without Shift button
608  QObject::connect(_pStepTimer, &QTimer::timeout, this, _rightButtonFunction);
609  }
610  }
611 
612  if (_mouseEventActive)
613  {
614  _currentMousePos[0] = x;
615  _currentMousePos[1] = y;
616  _lastMousePos[0] = x;
617  _lastMousePos[1] = y;
618  _firstCall = true;
620 
621  emit startMovingCamera();
622  }
623 }
624 
625 void TYCameraEditor::slotMouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
626 {
627  if (_mouseEventActive)
628  {
629  _mouseEventActive = false;
630  if (_keyEventActive == 0)
631  {
632  _pStepTimer->stop();
633  QObject::disconnect(_pStepTimer, 0, this, 0);
634 
635  emit stopMovingCamera();
636  }
637  }
638 }
639 
640 void TYCameraEditor::slotMouseMoved(int x, int y, Qt::MouseButtons button, Qt::KeyboardModifiers state)
641 {
642  _currentMousePos[0] = x;
643  _currentMousePos[1] = y;
644 }
645 
646 void TYCameraEditor::slotWheeled(int x, int y, int delta, Qt::KeyboardModifiers state)
647 {
649  {
650  // Update la cam courante
652  _pCurrentCamera->setDistanceStep(30, 70, 30);
653 
654  _currentMousePos[0] = x;
655  _currentMousePos[1] = y;
656 
657  _lastMousePos[0] = _currentMousePos[0] + int(delta * _wheelStep);
658  _lastMousePos[1] = _currentMousePos[1] + int(delta * _wheelStep);
659 
660  // Update la cam courante
662 
663  cameraZoom();
664 
665  emit stopMovingCamera();
666  }
667 }
668 
670 {
672 }
673 
675 {
676  if (view == TYModelerFrame::PerspView)
677  {
679  }
680  else if (view == TYModelerFrame::FreeView)
681  {
683  }
684  else
685  {
687  }
688 }
689 
691 {
697 }
698 
700 {
706 }
707 
709 {
715 }
716 
718 {
719  float xf = NAN;
720  float yf = NAN;
721 
722  // do nothing if mouse is still on the same pos
723  if ((_currentMousePos[0] == _lastMousePos[0]) && (_currentMousePos[1] == _lastMousePos[1]))
724  {
725  return;
726  }
727 
728  // first time we do some preprocessing
729  if (_firstCall)
730  {
731  QSize size = _pInteractor->size();
732  double vp[4];
733  if (_pCurrentCamera)
734  {
736 
737  _deltaAzimuth = -20.0 / ((vp[2] - vp[0]) * size.width());
738  _deltaElevation = -20.0 / ((vp[3] - vp[1]) * size.height());
739  }
740  }
741 
742  if (_pCurrentCamera)
743  {
746 
749  }
750 
751  if (!_firstCall)
752  {
753  }
754  else
755  {
756  _firstCall = false;
757  }
758 
759  emit cameraUpdated();
760 
761  // update
763 
764  // save mouse pos
767 }
768 
770 {
771  double viewFocus[4];
772  double motionVector[3];
773 
774  // do nothing if mouse is still on the same pos
775  if ((_currentMousePos[0] == _lastMousePos[0]) && (_currentMousePos[1] == _lastMousePos[1]))
776  {
777  return;
778  }
779 
780  if (_pCurrentCamera)
781  {
783  {
784  if ((_currentMousePos[0] - _lastMousePos[0]) > 0)
785  {
787  }
788  if ((_currentMousePos[0] - _lastMousePos[0]) < 0)
789  {
791  }
792  if ((_currentMousePos[1] - _lastMousePos[1]) > 0)
793  {
795  }
796  if ((_currentMousePos[1] - _lastMousePos[1]) < 0)
797  {
799  }
800  }
801  else
802  {
804  viewFocus[0] = ret.x;
805  viewFocus[1] = ret.y;
806  viewFocus[2] = ret.z;
807  double focalDepth = viewFocus[2];
809  float(_pInteractor->width() / 2.0 + (_currentMousePos[0] - _lastMousePos[0])),
810  float(_pInteractor->height() / 2.0 - (_currentMousePos[1] - _lastMousePos[1])), focalDepth));
811 
812  motionVector[0] = _trackballFactor / 10.0 * (_pCurrentCamera->to.x - retNew.x);
813  motionVector[1] = _trackballFactor / 10.0 * (_pCurrentCamera->to.y - retNew.y);
814  motionVector[2] = _trackballFactor / 10.0 * (_pCurrentCamera->to.z - retNew.z);
815 
816  _pCurrentCamera->to.x += motionVector[0];
817  _pCurrentCamera->to.y += motionVector[1];
818  _pCurrentCamera->to.z += motionVector[2];
819 
820  _pCurrentCamera->from.x += motionVector[0];
821  _pCurrentCamera->from.y += motionVector[1];
822  _pCurrentCamera->from.z += motionVector[2];
823  }
824  }
825 
826  emit cameraUpdated();
827 
828  // update
830 
831  // save mouse pos
834 }
835 
837 {
838  if (_pCurrentCamera)
839  {
840  if (_bKeyShift)
841  {
843  }
844  else
845  {
847  }
848 
850  if (_bKeyUp)
851  {
853  }
854  if (_bKeyDown)
855  {
857  }
858  if (_bKeyLeft)
859  {
861  }
862  if (_bKeyRight)
863  {
865  }
866  if (_bKeyPageUp)
867  {
869  }
870  if (_bKeyPageDown)
871  {
873  }
874  }
875 
876  emit cameraUpdated();
877 
878  // update
880 }
881 
883 {
884  float yf = NAN;
885 
886  // do nothing if mouse is still on the same y position
887  if (_currentMousePos[1] == _lastMousePos[1])
888  {
889  return;
890  }
891 
892  yf = float(_currentMousePos[1] - _lastMousePos[1]) / float(_pInteractor->height()) * _trackballFactor;
893  // if yf < 0, we need to be between 0..1
894  yf = pow(1.1f, yf);
895 
896  if (_pCurrentCamera)
897  {
898  _pCurrentCamera->zoom(1 / yf);
899  }
900 
901  emit cameraUpdated();
902 
903  // update
904  _pModeler->updateView(false); //, _pModeler->getShowGrid());
905 
906  // save mouse pos
909 }
910 
912 {
913  float angle = NAN;
914 
915  // do nothing if mouse is still on the same pos
916  if ((_currentMousePos[0] == _lastMousePos[0]) && (_currentMousePos[1] == _lastMousePos[1]))
917  {
918  return;
919  }
920 
921  if (_pCurrentCamera)
922  {
923  // first time we do some preprocessing
924  if (_firstCall)
925  {
926  _renCenter[0] = _pCurrentCamera->getCenter(_pInteractor->width(), _pInteractor->height()).x;
927  _renCenter[1] = _pCurrentCamera->getCenter(_pInteractor->width(), _pInteractor->height()).y;
928  _renCenter[2] = _pCurrentCamera->getCenter(_pInteractor->width(), _pInteractor->height()).z;
929  _firstCall = false;
930  }
931 
932  // calculate the angle in radians and roll the camera
933  int diffX1 = _currentMousePos[0] - int(_renCenter[0]);
934  int diffY1 = _currentMousePos[1] - int(_renCenter[1]);
935  int diffX2 = _lastMousePos[0] - int(_renCenter[0]);
936  int diffY2 = _lastMousePos[1] - int(_renCenter[1]);
937 
938  double a1 = atan2(double(diffY1), double(diffX1));
939  double a2 = atan2(double(diffY2), double(diffX2));
940  angle = (a2 - a1) / (2.0 * 3.1415926535) * 360.0 / 10.0 * _trackballFactor;
941 
942  _pCurrentCamera->roll(angle);
943 
944  emit cameraUpdated();
945  }
946 
947  // update
949 
950  // save mouse pos
953 }
954 
956 
957 void TYCameraEditor::cameraZoneZoom(const float focalPoint2D[3], double factor)
958 {
959  double viewFocus[4];
960  double d[3];
961 
962  if (_pCurrentCamera)
963  {
967 
969  viewFocus[0] = ret.x;
970  viewFocus[1] = ret.y;
971  viewFocus[2] = ret.z;
972  double focalDepth = viewFocus[2];
973  NxVec3 retNew = OGLCamera::displayToWorld(NxVec3(focalPoint2D[0], focalPoint2D[1], focalDepth));
974 
975  _pCurrentCamera->to.x = retNew.x;
976  _pCurrentCamera->to.y = retNew.y;
977  _pCurrentCamera->to.z = retNew.z;
978 
979  _pCurrentCamera->from.x = retNew.x + d[0];
980  _pCurrentCamera->from.y = retNew.y + d[1];
981  _pCurrentCamera->from.z = retNew.z + d[2];
982 
983  _pCurrentCamera->zoom(1 / factor);
984  }
985 
986  emit cameraUpdated();
987 
988  // update
989  _pModeler->updateView(false);
990 }
991 
993 {
994  if (_pCurrentCamera)
995  {
997  }
998 
999  emit cameraUpdated();
1000 
1001  // update
1002  _pModeler->updateView();
1003 }
1005 {
1006  if (_pCurrentCamera)
1007  {
1009  }
1010 
1011  emit cameraUpdated();
1012 
1013  // update
1014  _pModeler->updateView();
1015 }
1017 {
1018  if (_pCurrentCamera)
1019  {
1021  }
1022 
1023  emit cameraUpdated();
1024 
1025  // update
1026  _pModeler->updateView();
1027 }
1029 {
1031 
1032  emit cameraUpdated();
1033 
1034  // update
1035  _pModeler->updateView();
1036 }
1038 {
1039  NxVec3 motionVector;
1040 
1041  if (_pCurrentCamera)
1042  {
1043  motionVector.x = 0;
1044  motionVector.y = 1;
1045  motionVector.z = 0;
1046  motionVector.normalize();
1047  motionVector *= _translateStep;
1048 
1049  _pCurrentCamera->to.x += motionVector.x;
1050  _pCurrentCamera->to.y += motionVector.y;
1051  _pCurrentCamera->to.z += motionVector.z;
1052 
1053  _pCurrentCamera->from.x += motionVector.x;
1054  _pCurrentCamera->from.y += motionVector.y;
1055  _pCurrentCamera->from.z += motionVector.z;
1056  }
1057 
1058  emit cameraUpdated();
1059 
1060  // update
1061  _pModeler->updateView();
1062 }
1063 
1065 {
1066  NxVec3 motionVector;
1067 
1068  if (_pCurrentCamera)
1069  {
1070  motionVector.x = 0;
1071  motionVector.y = 1;
1072  motionVector.z = 0;
1073  motionVector.normalize();
1074  motionVector *= _translateStep;
1075 
1076  _pCurrentCamera->to.x -= motionVector.x;
1077  _pCurrentCamera->to.y -= motionVector.y;
1078  _pCurrentCamera->to.z -= motionVector.z;
1079 
1080  _pCurrentCamera->from.x -= motionVector.x;
1081  _pCurrentCamera->from.y -= motionVector.y;
1082  _pCurrentCamera->from.z -= motionVector.z;
1083  }
1084 
1085  emit cameraUpdated();
1086 
1087  // update
1088  _pModeler->updateView();
1089 }
1091 {
1092  NxVec3 motionVector;
1093 
1094  if (_pCurrentCamera)
1095  {
1096  motionVector.x = _pCurrentCamera->from.x - _pCurrentCamera->to.x;
1097  motionVector.y = _pCurrentCamera->from.y - _pCurrentCamera->to.y;
1098  motionVector.z = _pCurrentCamera->from.z - _pCurrentCamera->to.z;
1099  motionVector = motionVector.cross(NxVec3(0, 1, 0));
1100  motionVector.normalize();
1101  motionVector *= _translateStep;
1102 
1103  _pCurrentCamera->to.x += motionVector.x;
1104  _pCurrentCamera->to.y += motionVector.y;
1105  _pCurrentCamera->to.z += motionVector.z;
1106 
1107  _pCurrentCamera->from.x += motionVector.x;
1108  _pCurrentCamera->from.y += motionVector.y;
1109  _pCurrentCamera->from.z += motionVector.z;
1110  }
1111 
1112  emit cameraUpdated();
1113 
1114  // update
1115  _pModeler->updateView();
1116 }
1118 {
1119  NxVec3 motionVector;
1120 
1121  if (_pCurrentCamera)
1122  {
1123  motionVector.x = _pCurrentCamera->from.x - _pCurrentCamera->to.x;
1124  motionVector.y = _pCurrentCamera->from.y - _pCurrentCamera->to.y;
1125  motionVector.z = _pCurrentCamera->from.z - _pCurrentCamera->to.z;
1126  motionVector = motionVector.cross(NxVec3(0, 1, 0));
1127  motionVector.normalize();
1128  motionVector *= _translateStep;
1129 
1130  _pCurrentCamera->to.x -= motionVector.x;
1131  _pCurrentCamera->to.y -= motionVector.y;
1132  _pCurrentCamera->to.z -= motionVector.z;
1133 
1134  _pCurrentCamera->from.x -= motionVector.x;
1135  _pCurrentCamera->from.y -= motionVector.y;
1136  _pCurrentCamera->from.z -= motionVector.z;
1137  }
1138 
1139  emit cameraUpdated();
1140 
1141  // update
1142  _pModeler->updateView();
1143 }
1145 {
1146  if (_pCurrentCamera)
1147  {
1149  }
1150 
1151  emit cameraUpdated();
1152 
1153  // update
1154  _pModeler->updateView();
1155 }
1157 {
1158  if (_pCurrentCamera)
1159  {
1161  }
1162 
1163  emit cameraUpdated();
1164 
1165  // update
1166  _pModeler->updateView();
1167 }
All base classes related to 3D manipulation.
@ PERSPECTIVE
Definition: OGLCamera.h:40
gestion de l'edition de la camera (fichier header)
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:52
Classe generique pour une fenetre de modeleur (fichier header)
Le role de cette classe est limite a emettre des signaux pouvant etre utilise pour interagir sur le r...
Definition: NxVec3.h:23
NxReal z
Definition: NxVec3.h:80
void cross(const NxVec3 &left, const NxVec3 &right)
Definition: NxVec3.cpp:207
NxReal normalize()
Definition: NxVec3.cpp:159
NxReal y
Definition: NxVec3.h:80
NxReal x
Definition: NxVec3.h:80
void getViewPort(double *vp)
Definition: OGLCamera.cpp:739
NxVec3 getCenter(int sizeX, int sizeY)
Definition: OGLCamera.cpp:749
void moveDown()
Definition: OGLCamera.cpp:195
void elevation(NxReal _angle)
Definition: OGLCamera.cpp:788
static NxVec3 displayToWorld(NxVec3 display)
Definition: OGLCamera.cpp:699
void azimuth(NxReal _angle)
Definition: OGLCamera.cpp:782
void roll(NxReal _angle)
Definition: OGLCamera.cpp:794
void zoom(double zoomFactor)
Definition: OGLCamera.cpp:761
static NxVec3 worldToDisplay(NxVec3 world)
Definition: OGLCamera.cpp:722
void moveRight()
Definition: OGLCamera.cpp:223
void calculateStepVectors()
Definition: OGLCamera.cpp:670
void moveLeft()
Definition: OGLCamera.cpp:209
NxVec3 from
Definition: OGLCamera.h:122
NxVec3 to
Definition: OGLCamera.h:123
CameraType m_eCameraType
Definition: OGLCamera.h:142
void setDistanceStep(NxReal _magnitudeStepUp, NxReal _magnitudeStepFront, NxReal _magnitudeStepLeft)
Definition: OGLCamera.cpp:545
void moveBack()
Definition: OGLCamera.cpp:167
void moveFront()
Definition: OGLCamera.cpp:153
void moveUp()
Definition: OGLCamera.cpp:181
Classe abstraite pour la gestion de l'interaction entre la vue graphique (2D ou 3D) et le clavier et ...
TYModelerFrame * _pModeler
Le modeler associe a cet editor.
TYRenderWindowInteractor * _pInteractor
La vue graphique associee a cet editor.
Gestion de l'edition en mode camera.
QTimer * _pStepTimer
void setMiddleButtonFunction(void(TYCameraEditor::*function)())
void setRightButtonFunctionFree(void(TYCameraEditor::*function)())
void(TYCameraEditor::* _shiftLeftButtonFunctionFree)()
void(TYCameraEditor::* _shiftRightButtonFunction)()
void setRightButtonFunction(void(TYCameraEditor::*function)())
void stopMovingCamera()
Indique la fin du deplacement de la camera.
void(TYCameraEditor::* _shiftRightButtonFunction3D)()
void setMiddleButtonFunction3D(void(TYCameraEditor::*function)())
void startMovingCamera()
Indique le debut du deplacement de la camera.
void(TYCameraEditor::* _middleButtonFunction2D)()
virtual void slotMouseReleased(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
void setToNavigationFree()
void setRightButtonFunction3D(void(TYCameraEditor::*function)())
OGLCamera * _pCurrentCamera
void setShiftRightButtonFunction3D(void(TYCameraEditor::*function)())
void(TYCameraEditor::* _middleButtonFunction)()
virtual void slotMouseMoved(int x, int y, Qt::MouseButtons button, Qt::KeyboardModifiers state)
virtual void slotKeyPressed(int key)
void setLeftButtonFunctionFree(void(TYCameraEditor::*function)())
void setLeftButtonFunction2D(void(TYCameraEditor::*function)())
void cameraUpdated()
Indique que la position ou l'orientation de la camera a ete modifiee.
void setNavigationOnViewType(int view)
Switch auto entre navi 2D ou 3D.
void(TYCameraEditor::* _shiftRightButtonFunction2D)()
void cameraStepTranslateUp()
float _renCenter[3]
void setShiftRightButtonFunctionFree(void(TYCameraEditor::*function)())
void(TYCameraEditor::* _shiftLeftButtonFunction2D)()
void(TYCameraEditor::* _leftButtonFunction2D)()
void setMiddleButtonFunction2D(void(TYCameraEditor::*function)())
void cameraStepRotateRight()
void(TYCameraEditor::* _rightButtonFunction2D)()
void(TYCameraEditor::* _shiftLeftButtonFunction3D)()
void setInteractionTime(int time)
void setRightButtonFunction2D(void(TYCameraEditor::*function)())
void(TYCameraEditor::* _rightButtonFunction3D)()
void(TYCameraEditor::* _leftButtonFunction3D)()
void setShiftLeftButtonFunctionFree(void(TYCameraEditor::*function)())
void setShiftRightButtonFunction2D(void(TYCameraEditor::*function)())
void cameraStepTranslateRight()
virtual void slotWheeled(int x, int y, int delta, Qt::KeyboardModifiers state)
void(TYCameraEditor::* _leftButtonFunctionFree)()
virtual void slotKeyReleased(int key)
void(TYCameraEditor::* _leftButtonFunction)()
void setLeftButtonFunction3D(void(TYCameraEditor::*function)())
void setShiftLeftButtonFunction2D(void(TYCameraEditor::*function)())
void(TYCameraEditor::* _shiftLeftButtonFunction)()
TYCameraEditor(TYModelerFrame *pModeler)
void cameraStepTranslateDown()
void setMiddleButtonFunctionFree(void(TYCameraEditor::*function)())
void(TYCameraEditor::* _rightButtonFunction)()
void setShiftLeftButtonFunction3D(void(TYCameraEditor::*function)())
int _currentMousePos[2]
void(TYCameraEditor::* _rightButtonFunctionFree)()
void setSensitivity(float t)
void setShiftRightButtonFunction(void(TYCameraEditor::*function)())
void cameraStepTranslateLeft()
void setShiftLeftButtonFunction(void(TYCameraEditor::*function)())
void(TYCameraEditor::* _middleButtonFunction3D)()
virtual void slotMousePressed(int x, int y, Qt::MouseButton button, Qt::KeyboardModifiers state)
void(TYCameraEditor::* _middleButtonFunctionFree)()
void setLeftButtonFunction(void(TYCameraEditor::*function)())
void cameraZoneZoom(const float focalPoint2D[3], double factor)
virtual void slotViewTypeChanged(int view)
void(TYCameraEditor::* _shiftRightButtonFunctionFree)()
void setWheelStep(float step)
Classe generique pour une fenetre de modeleur.
void startMovingRenderMode()
virtual void updateView(bool clipping=true, bool axesAndGrid=true)
OGLCamera * getActiveCamera()
TYOpenGLRenderer * getRenderer()