Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYModelerFrame.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
22 #include "models/common/3d.h"
23 #include <qvector3d.h>
24 #ifdef _MSC_VER
25  #pragma warning(disable : 4503)
26 #endif
27 
28 #include <math.h>
29 #include <qlayout.h>
30 #include <qstring.h>
31 #include <qcursor.h>
32 #include <qcombobox.h>
33 #include <qcheckbox.h>
34 #include <qlineedit.h>
35 #include <qstatusbar.h>
36 #include <qimage.h>
37 #include <qpixmap.h>
38 #include <qmenu.h>
39 #include <qfiledialog.h>
40 #include <qslider.h>
41 #include <qlabel.h>
42 #include <qprinter.h>
43 #include <qpainter.h>
44 #include <qgroupbox.h>
45 #include <qclipboard.h>
46 #include <qmessagebox.h>
47 #include <qtoolbutton.h>
48 // Added by qt3to4:
49 #include <QResizeEvent>
50 #include <QWheelEvent>
51 #include <QFocusEvent>
52 #include <QMouseEvent>
53 #include <QCloseEvent>
54 #include <QGridLayout>
55 #include <QShowEvent>
56 #include <QKeyEvent>
57 #include <QHBoxLayout>
58 #include <QEvent>
59 #include <QImageWriter>
60 #include <QPrintDialog>
61 
89 #include "TYModelerFrame.h"
90 
91 #define TR(id) OLocalizator::getString("TYModelerFrame", (id))
92 #define IMG(id) OLocalizator::getPicture("TYModelerFrame", (id))
93 
94 // using namespace Qt;
95 
96 // Couleurs
97 static double gridColor[] = {0.59, 0.41, 0.42};
98 static double fontColor[] = {0.1, 0.43, 0.37};
99 static double rendererColor[] = {0.91, 0.91, 0.91};
100 
101 TYModelerFrame::TYModelerFrame(QWidget* parent, const char* name, Qt::WindowFlags f)
102  : QWidget(parent, f), _actionManager(10)
103 {
104  setObjectName(name);
105 
106  setAttribute(Qt::WA_DeleteOnClose);
107 
108  // L'element associe a ce modeler
109  _pElement = NULL;
110 
111  // Flag pour la sauvegarde des settings
112  _firstTimeShown = true;
113 
114  // Init des membres pour les editors
115  _pCurrentEditor = NULL;
117  _editorModeAccepted = false;
118 
119  // Init des membres pour la grille
120  _showGrid = false;
121 
123 
124  _defaultZCoord = 0.0f;
125 
126  // Le focus se fait avec la touche tab ou la souris
127  setFocusPolicy(Qt::StrongFocus);
128 
129  // Pour pouvoir afficher la position courante du curseur
130  setMouseTracking(true);
131 
132  // Layout
133  _pLayout = new QGridLayout();
134  _pLayout->setRowStretch(0, 0);
135  _pLayout->setRowStretch(1, 1);
136  _pLayout->setRowStretch(2, 0);
137  setLayout(_pLayout);
138 
139  // Initialisation des parametres de la grille.
140  _gridDimX = 200;
141  _gridDimY = 200;
142  _gridStep = 5;
143  _gridMagnStep = 1;
144 
145  // Widgets
146  _pCtrlLayout = new QHBoxLayout();
147  _pLayout->addLayout(_pCtrlLayout, 0, 0);
148  _pCtrlLayout->setSpacing(5);
149 
150  // Disambiguate the overloaded signal QComboBox::activated
151  void (QComboBox::*_qComboBox_activated)(int) = &QComboBox::activated;
152 
153  // Combo box type de Vue
154  _pViewTypeBox = new QComboBox(this);
155  _pCtrlLayout->addWidget(_pViewTypeBox, 0);
156  _pViewTypeBox->insertItem(TopView, TR("id_top_view"));
157  _pViewTypeBox->insertItem(BottomView, TR("id_bottom_view"));
158  _pViewTypeBox->insertItem(LeftView, TR("id_left_view"));
159  _pViewTypeBox->insertItem(RightView, TR("id_right_view"));
160  _pViewTypeBox->insertItem(FrontView, TR("id_front_view"));
161  _pViewTypeBox->insertItem(RearView, TR("id_rear_view"));
162  _pViewTypeBox->insertItem(PerspView, TR("id_3d_view"));
163  _pViewTypeBox->insertItem(FreeView, TR("id_free_view"));
164  connect(_pViewTypeBox, _qComboBox_activated, this, &TYModelerFrame::setViewType);
165 
166  // Combo box mode de Rendu
167  _pRenderModeBox = new QComboBox(this);
168  _pCtrlLayout->addWidget(_pRenderModeBox, 0);
169  _pRenderModeBox->insertItem(TYOpenGLRenderer::Points, TR("id_points_mode"));
170  _pRenderModeBox->insertItem(TYOpenGLRenderer::Wireframe, TR("id_wireframe_mode"));
171  _pRenderModeBox->insertItem(TYOpenGLRenderer::Surface, TR("id_surface_mode"));
172  connect(_pRenderModeBox, _qComboBox_activated, this, &TYModelerFrame::setRenderModeSlot);
173 
174  _pCtrlLayout->addSpacing(7);
175 
176  // Btn Fit
177  QToolButton* pFitBtn = new QToolButton(this);
178  pFitBtn->setIcon(QPixmap(IMG("id_icon_fit_btn")));
179  pFitBtn->setText(TR("id_fit_btn"));
180  pFitBtn->setToolTip(TR("id_fit_btn"));
181  pFitBtn->setFixedSize(24, 24);
182  connect(pFitBtn, &QToolButton::clicked, this, &TYModelerFrame::fit);
183  _pCtrlLayout->addWidget(pFitBtn, 0);
184 
185  // Btn Grille
186  _pGridBtn = new QToolButton(this);
187  _pGridBtn->setIcon(QPixmap(IMG("id_icon_grid_btn")));
188  _pGridBtn->setText(TR("id_grid_btn"));
189  _pGridBtn->setToolTip(TR("id_grid_btn"));
190  _pGridBtn->setCheckable(true);
191  _pGridBtn->setChecked(true);
192  _pGridBtn->setFixedSize(24, 24);
193  _pCtrlLayout->addWidget(_pGridBtn, 0);
194  connect(_pGridBtn, &QToolButton::toggled, this, &TYModelerFrame::showGrid);
195 
196  // Btn Show echelle.
197  // L'echelle est mise a jour a la fin de chaque deplacement de camera (cf. TYCameraEditor)
198  _showScale = true;
199  _pShowScale = new QToolButton(this);
200  _pShowScale->setIcon(QPixmap(IMG("id_icon_show_scale_btn")));
201  _pShowScale->setText(TR("id_show_scale_btn"));
202  _pShowScale->setToolTip(TR("id_show_scale_btn"));
203  _pShowScale->setCheckable(true);
204  _pShowScale->setChecked(_showScale);
205  _pShowScale->setFixedSize(24, 24);
206  _pCtrlLayout->addWidget(_pShowScale, 0);
207  connect(_pShowScale, &QToolButton::toggled, this, &TYModelerFrame::showScale);
208 
209  // Btn Grille Magnetique
210  _pSnapGridBtn = new QToolButton(this);
211  _pSnapGridBtn->setIcon(QPixmap(IMG("id_icon_snapgrid_btn")));
212  _pSnapGridBtn->setText(TR("id_snapgrid_btn"));
213  _pSnapGridBtn->setToolTip(TR("id_snapgrid_btn"));
214  _pSnapGridBtn->setCheckable(true);
215  _pSnapGridBtn->setFixedSize(24, 24);
216  _pCtrlLayout->addWidget(_pSnapGridBtn, 0);
217  connect(_pSnapGridBtn, &QToolButton::toggled, this, &TYModelerFrame::setSnapGridActive);
218  setSnapGridActive(true);
219 
220  // Btn set camera coordinates
221  _pSetCameraCoordinatesBtn = new QToolButton(this);
222  _pSetCameraCoordinatesBtn->setIcon(QPixmap(IMG("id_icon_setcameracoordinates_btn")));
223  _pSetCameraCoordinatesBtn->setText(TR("id_setcameracoordinates_btn"));
224  _pSetCameraCoordinatesBtn->setToolTip(TR("id_setcameracoordinates_btn"));
225  _pSetCameraCoordinatesBtn->setFixedSize(24, 24);
227  connect(_pSetCameraCoordinatesBtn, &QToolButton::clicked, this, &TYModelerFrame::setCameraCoordinates);
228 
229  _pCtrlLayout->addSpacing(7);
230 
231  // Btn Screenshot
232  _pScreenShotBtn = new QToolButton(this);
233  _pScreenShotBtn->setIcon(QPixmap(IMG("id_icon_screenshot_btn")));
234  _pScreenShotBtn->setText(TR("id_screenshot_btn"));
235  _pScreenShotBtn->setToolTip(TR("id_screenshot_btn"));
236  _pScreenShotBtn->setFixedSize(24, 24);
237  connect(_pScreenShotBtn, &QToolButton::clicked, this, &TYModelerFrame::screenShot);
238 
239  // Btn Copy
240  _pCopyBtn = new QToolButton(this);
241  _pCopyBtn->setIcon(QPixmap(IMG("id_icon_copy_btn")));
242  _pCopyBtn->setText(TR("id_copy_btn"));
243  _pCopyBtn->setToolTip(TR("id_copy_btn"));
244  _pCopyBtn->setFixedSize(24, 24);
245  connect(_pCopyBtn, &QToolButton::clicked, this, &TYModelerFrame::copy);
246 
247  // Btn Show Sources
248  _pShowSourcesBtn = new QToolButton(this);
249  _pShowSourcesBtn->setIcon(QPixmap(IMG("id_icon_source")));
250  _pShowSourcesBtn->setText(TR("id_show_source_btn"));
251  _pShowSourcesBtn->setToolTip(TR("id_show_source_btn"));
252  _pShowSourcesBtn->setCheckable(true);
253  _pShowSourcesBtn->setChecked(false);
254  _pShowSourcesBtn->setFixedSize(24, 24);
255  _pCtrlLayout->addWidget(_pShowSourcesBtn, 0);
256  connect(_pShowSourcesBtn, &QToolButton::toggled, this, &TYModelerFrame::showSources);
257  showSources();
258 
259  // Btn Show Normals
260  _pShowNormalsBtn = new QToolButton(this);
261  _pShowNormalsBtn->setIcon(QPixmap(IMG("id_icon_normals")));
262  _pShowNormalsBtn->setText(TR("id_show_normals_btn"));
263  _pShowNormalsBtn->setToolTip(TR("id_show_normals_btn"));
264  _pShowNormalsBtn->setCheckable(true);
265  _pShowNormalsBtn->setChecked(false);
266  _pShowNormalsBtn->setFixedSize(24, 24);
267  _pCtrlLayout->addWidget(_pShowNormalsBtn, 0);
268  connect(_pShowNormalsBtn, &QToolButton::toggled, this, &TYModelerFrame::showNormals);
269  showNormals(_pShowNormalsBtn->isChecked());
270 
271  // Btn Show Plafond
272  _pShowPlafondBtn = new QToolButton(this);
273  _pShowPlafondBtn->setIcon(QPixmap(IMG("id_icon_plafond")));
274  _pShowPlafondBtn->setText(TR("id_show_plafond_btn"));
275  _pShowPlafondBtn->setToolTip(TR("id_show_plafond_btn"));
276  _pShowPlafondBtn->setCheckable(true);
277  _pShowPlafondBtn->setChecked(false);
278  _pShowPlafondBtn->setFixedSize(24, 24);
279  _pCtrlLayout->addWidget(_pShowPlafondBtn, 0);
280  connect(_pShowPlafondBtn, &QToolButton::toggled, this, &TYModelerFrame::showPlafond);
281  showPlafond(_pShowPlafondBtn->isChecked());
282 
283  // Btn Show Rayons
284  _pShowRaysBtn = new QToolButton(this);
285  _pShowRaysBtn->setIcon(QPixmap(IMG("id_icon_rays")));
286  _pShowRaysBtn->setText(TR("id_show_rays_btn"));
287  _pShowRaysBtn->setToolTip(TR("id_show_rays_btn"));
288 
289  _pShowRaysBtn->setCheckable(true);
290  _pShowRaysBtn->setChecked(false);
291  _pShowRaysBtn->setFixedSize(24, 24);
292  _pCtrlLayout->addWidget(_pShowRaysBtn, 0);
293  connect(_pShowRaysBtn, &QToolButton::toggled, this, &TYModelerFrame::showRays);
294  showRays(_pShowRaysBtn->isChecked());
295 
296  // Vue graphique
297  _pView = new TYRenderWindowInteractor(this, "vue graphique");
298  _pLayout->addWidget(_pView, 1, 0);
299 
301 
302  // Status bar
303  _pStatusBar = new QStatusBar(this);
304  _pLayout->addWidget(_pStatusBar, 2, 0);
305 
306  // Cameras pour chaque type de vue
307  QVector3D fromTop{0, 10000, 0};
308  QVector3D toTop{0, 0, 0};
309  QVector3D upTop{0, 0, -1};
310  _pOGLCameras[TopView] = new OGLCamera(fromTop, toTop, upTop, 100, 100, PARALLEL);
311 
312  QVector3D fromBottom{0, -10000, 0};
313  QVector3D toBottom{0, 0, 0};
314  QVector3D upBottom{0, 0, -1};
315  _pOGLCameras[BottomView] = new OGLCamera(fromBottom, toBottom, upBottom, 100, 100, PARALLEL);
316 
317  QVector3D fromLeft{-500, 0, 0};
318  QVector3D toLeft{0, 0, 0};
319  QVector3D upLeft{0, 1, 0};
320  _pOGLCameras[LeftView] = new OGLCamera(fromLeft, toLeft, upLeft, 100, 100, PARALLEL);
321 
322  QVector3D fromRight{500, 0, 0};
323  QVector3D toRight{0, 0, 0};
324  QVector3D upRight{0, 1, 0};
325  _pOGLCameras[RightView] = new OGLCamera(fromRight, toRight, upRight, 100, 100, PARALLEL);
326 
327  QVector3D fromFront{0, 0, 500};
328  QVector3D toFront{0, 0, 0};
329  QVector3D upFront{0, 1, 0};
330  _pOGLCameras[FrontView] = new OGLCamera(fromFront, toFront, upFront, 100, 100, PARALLEL);
331 
332  QVector3D fromRear{0, 0, -500};
333  QVector3D toRear{0, 0, 0};
334  QVector3D upRear{0, 1, 0};
335  _pOGLCameras[RearView] = new OGLCamera(fromRear, toRear, upRear, 100, 100, PARALLEL);
336 
337  QVector3D fromPersp{0, 10000, 10000};
338  QVector3D toPersp{0, 0, 0};
339  QVector3D upPersp{0, 1, 0};
340  _pOGLCameras[PerspView] = new OGLCamera(fromPersp, toPersp, upPersp, 100, 100, PERSPECTIVE);
341 
342  QVector3D fromFree{0, 0, 0};
343  QVector3D toFree{0, 0, 0.1};
344  QVector3D upFree{0, 1, 0};
345  _pOGLCameras[FreeView] = new OGLCamera(fromFree, toFree, upFree, 100, 100, FREE);
346 
347  // Triedre XYZ
360 
363  _pOGLTextElementLabelX->setFont(IMG("id_font_bold"));
364  OColor oColor;
365  oColor.r = fontColor[0];
366  oColor.g = fontColor[1];
367  oColor.b = fontColor[2];
370 
373  _pOGLTextElementLabelY->setFont(IMG("id_font_bold"));
376 
379  _pOGLTextElementLabelZ->setFont(IMG("id_font_bold"));
382 
389 
390  // Label
393  _pOGLTextElement->setFont(IMG("id_font_bold"));
394  _pOGLTextElement->setColor(oColor);
397 
398 #ifndef NO_GRID
399  // Construction de la grille
401  _pOGLGridElement->setColor(OColor(gridColor[0], gridColor[1], gridColor[2]));
403  _pOGLGridElement->setIs3D(true);
405 #endif // NO_GRID
406 
407  // Axes de la grille
409  _pOGLLineElementX->setPoint1(QVector3D(-100, 0, 0));
410  _pOGLLineElementX->setPoint2(QVector3D(100, 0, 0));
411  _pOGLLineElementX->setColor(OColor(0, 0, 0));
413  _pOGLLineElementX->setIs3D(true);
415 
417  _pOGLLineElementY->setPoint1(QVector3D(0, -100, 0));
418  _pOGLLineElementY->setPoint2(QVector3D(0, 100, 0));
419  _pOGLLineElementY->setColor(OColor(0, 0, 0));
421  _pOGLLineElementY->setIs3D(true);
423 
426 
427  // Echelle
429  _pOGLScalarBarElement->setPosition(QVector3D(100, 50, 0));
432  _pOGLScalarBarElement->setFont(IMG("id_font"));
434  _pOGLScalarBarElement->setTexts("0", "0", "0");
437 
438  // Lumieres
440  _pLightElement->init(0, OPoint3D(0.0, 400.0, 0.0), 1.0f);
442 
443  // Couleur de fond
444  getRenderer()->setBackground(rendererColor);
445 
446  // Type de rendu
448 
449  _wireframeOnMovingCamera = false;
451 
452  // Gestion du picking
453  _pPicker = new TYElementPicker(this);
454 
455  // Passage en vue de dessus.
457 
458  // Editors
459  _pCameraEditor = new TYCameraEditor(this);
463 
464  // Le pick editor
465  _pPickEditor = new TYPickEditor(this);
467 
468  // Mode d'edition
470 
471  resizeGrid();
472  showGrid(_pGridBtn->isChecked());
473  showScale(_pShowScale->isChecked());
474 
475  // Chargement des preferences
477 
478  showMaximized();
479 }
480 
482 {
483 
484  // Disambiguate the overloaded signal QComboBox::activated
485  void (QComboBox::*_qComboBox_activated)(int) = &QComboBox::activated;
486 
487  disconnect(_pViewTypeBox, _qComboBox_activated, this, &TYModelerFrame::setViewType);
488  disconnect(_pRenderModeBox, _qComboBox_activated, this, &TYModelerFrame::setRenderModeSlot);
489  disconnect(_pGridBtn, &QToolButton::toggled, this, &TYModelerFrame::showGrid);
490  disconnect(_pShowScale, &QToolButton::toggled, this, &TYModelerFrame::showScale);
491  disconnect(_pSnapGridBtn, &QToolButton::toggled, this, &TYModelerFrame::setSnapGridActive);
492  disconnect(_pSetCameraCoordinatesBtn, &QToolButton::clicked, this, &TYModelerFrame::setCameraCoordinates);
493  disconnect(_pScreenShotBtn, &QToolButton::clicked, this, &TYModelerFrame::screenShot);
494  disconnect(_pShowSourcesBtn, &QToolButton::toggled, this, &TYModelerFrame::showSources);
495  disconnect(_pShowNormalsBtn, &QToolButton::toggled, this, &TYModelerFrame::showNormals);
496  disconnect(_pShowPlafondBtn, &QToolButton::toggled, this, &TYModelerFrame::showPlafond);
497  disconnect(_pShowRaysBtn, &QToolButton::toggled, this, &TYModelerFrame::showRays);
499 
500  delete _pCameraEditor;
501  delete _pCameraZoneEditor;
502  delete _pDistanceEditor;
503  delete _pPositionEditor;
504  delete _pPickEditor;
505  delete _pPicker;
506 
507  for (int i = 0; i < NbOfViews; i++)
508  {
509  delete _pOGLCameras[i];
510  _pOGLCameras[i] = NULL;
511  }
512 
514  delete _pOGLLineElementAxeX;
516  delete _pOGLLineElementAxeY;
518  delete _pOGLLineElementAxeZ;
520  delete _pOGLTextElementLabelX;
522  delete _pOGLTextElementLabelY;
524  delete _pOGLTextElementLabelZ;
525 
527  delete _pOGLTextElement;
529  delete _pOGLScalarBarElement;
531  delete _pOGLLineElementX;
533  delete _pOGLLineElementY;
534 
535 #ifndef NO_GRID
537  delete _pOGLGridElement;
538 #endif // NO_GRID
540  delete _pLightElement;
541  delete _pView;
542  _pView = nullptr;
543 }
544 
546 {
547  _pCtrlLayout->addSpacing(7);
548  _pCtrlLayout->addWidget(_pScreenShotBtn, 0);
549  _pCtrlLayout->addWidget(_pCopyBtn, 0);
550 }
551 
553 {
554  return QWidget::close();
555 }
556 
558 {
559  bool ret = false;
560 
561  if (getTYApp()->getCurProjet() && getTYApp()->getCurProjet()->getCurrentCalcul() && _pElement)
562  {
563  // L'element fait-il parti de la selection du calcul courant ?
565  }
566 
567  return ret;
568 }
569 
571 {
572  bool ret = false;
573 
574  if (getTYApp()->getCurProjet() && _pElement)
575  {
576  // On commence directement a partir de l'element lui-meme
577  TYElement* pParent = _pElement;
578 
579  while (pParent)
580  {
581  // Le parent est le projet courant ?
582  if (pParent == getTYApp()->getCurProjet())
583  {
584  ret = true;
585  break;
586  }
587  // Parent du parent
588  pParent = pParent->getParent();
589  }
590  }
591 
592  return ret;
593 }
594 
596 {
597  bool ret = true;
598 
600  {
602  }
603 
604  return ret;
605 }
606 
608 {
609  if (view >= NbOfViews)
610  {
611  return;
612  }
613 
614  // View type
615  _curViewType = view;
616 
617  bool showGridXY = false;
618  bool showGridXZ = false;
619  bool showGridZY = false;
620  QString labelStr;
621 
622  // Pre traitement selon la vue activee
623  switch (view)
624  {
625  case TopView:
626  showGridXZ = _showGrid;
627  labelStr = TR("id_top_view");
628  _pSetCameraCoordinatesBtn->setEnabled(false);
629  break;
630  case BottomView:
631  showGridXZ = _showGrid;
632  labelStr = TR("id_bottom_view");
633  _pSetCameraCoordinatesBtn->setEnabled(false);
634  break;
635  case LeftView:
636  showGridZY = _showGrid;
637  labelStr = TR("id_left_view");
638  _pSetCameraCoordinatesBtn->setEnabled(false);
639  break;
640  case RightView:
641  showGridZY = _showGrid;
642  labelStr = TR("id_right_view");
643  _pSetCameraCoordinatesBtn->setEnabled(false);
644  break;
645  case FrontView:
646  showGridXY = _showGrid;
647  labelStr = TR("id_front_view");
648  _pSetCameraCoordinatesBtn->setEnabled(false);
649  break;
650  case RearView:
651  showGridXY = _showGrid;
652  labelStr = TR("id_rear_view");
653  _pSetCameraCoordinatesBtn->setEnabled(false);
654  break;
655  case PerspView:
656  showGridXZ = _showGrid;
657  labelStr = TR("id_3d_view");
658  _pSetCameraCoordinatesBtn->setEnabled(false);
659  break;
660  case FreeView:
661  showGridXZ = _showGrid;
662  labelStr = TR("id_free_view");
663  _pSetCameraCoordinatesBtn->setEnabled(true);
664  break;
665  default:
666  break;
667  }
668 
669  //_pView->setFocus();
670 
671  // Affichage de la grille correspondant au type de vue
672  setGridLinesActorsVisibility(showGridXY, showGridXZ, showGridZY);
673 
674  // Label
676 
677  // Camera
678  OGLCamera* camera = _pOGLCameras[view];
679  _pView->setActiveCamera(camera);
680 
681  // Update l'element associe a ce modeler
682  if (_pElement)
683  {
684  _pElement->updateGraphicTree();
685  _pElement->getGraphicObject()->update(true);
686  }
687 
689  // Updates
690  updateView();
691 
692  _pViewTypeBox->setCurrentIndex(_curViewType);
694 }
695 
697 {
698  setRenderMode(static_cast<TYOpenGLRenderer::RenderMode>(mode), true);
699 }
700 
702 {
704  {
705  return;
706  }
707 
708  _pView->getRenderer()->setRenderMode(mode);
709 
710  _pRenderModeBox->setCurrentIndex(mode);
711 
712  if (bUpdateGL == true)
713  {
714  _pView->update();
715  }
716 }
717 
719 {
720  if (!_editorModeAccepted)
721  {
722  getPickEditor()->usePopup(true);
723  getPickEditor()->useHighlight(false);
724 
725  if (_pCurrentEditor)
726  {
727  // We want to be sure that Camera will not zoom unwillingly before disconnecting signals
731  }
732 
733  _editorModeAccepted = true;
734 
735  switch (mode)
736  {
737  case CameraMode:
738  // fit();
739  getPickEditor()->useHighlight(true);
741  break;
742  case CameraZoneMode:
743  getPickEditor()->useHighlight(true);
745  break;
746  case DistanceMode:
748  break;
749  case MovingMode:
752  break;
753  case RotationMode:
756  break;
757  case EditionMode:
760  break;
761  case NoMode:
762  default:
763  getPickEditor()->useHighlight(true);
764  _pCurrentEditor = NULL;
765  mode = NoMode;
766  _editorModeAccepted = false;
767  break;
768  }
769  }
770 
771  // On sauve le mode courant
772  _lastEditorMode = mode;
773 
774  // Init
775  if (_pCurrentEditor)
776  {
779  }
780 
781  // Pour la prochaine requete
782  _editorModeAccepted = false;
783 
784  // The bug goes by here...
785  emit(editorModeChanged(mode));
786 }
787 
789 {
790  _showGrid = show;
791 
794 
795  _pGridBtn->setChecked(_showGrid);
796 
798  // Update
800 }
801 
803 {
804  _showSources = _pShowSourcesBtn->isChecked();
805 
808  {
809 
810  TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
811 
814 
815  if (_pElement && _pElement->getGraphicObject())
816  {
817  // Update l'element associe a ce modeler
818  _pElement->getGraphicObject()->update(true);
819 
821 
822  // Update view
823  updateView();
824  }
825 
826  TYApplication::restoreOverrideCursor();
827  }
828 
829  _pShowSourcesBtn->setChecked(_showSources);
830 }
831 
833 {
834  _showRays = show;
836  {
837 
838  TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
839 
841 
842  if (_pElement && _pElement->getGraphicObject())
843  {
844  // Update l'element associe a ce modeler
845  _pElement->getGraphicObject()->update(true);
846 
848 
849  // Update view
850  updateView();
851  }
852 
853  TYApplication::restoreOverrideCursor();
854  }
855 
856  _pShowRaysBtn->setChecked(_showRays);
857 }
858 
859 void TYModelerFrame::setKeepRays(bool keepRays)
860 {
861  _pShowRaysBtn->setEnabled(keepRays);
862 }
863 
865 {
866  _showNormals = show;
867 
869  {
870 
871  TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
872 
874 
875  if (_pElement && _pElement->getGraphicObject())
876  {
877  // Update l'element associe a ce modeler
878  _pElement->getGraphicObject()->update(true);
879 
881 
882  // Update view
883  updateView();
884  }
885 
886  TYApplication::restoreOverrideCursor();
887  }
888 
889  _pShowNormalsBtn->setChecked(_showNormals);
890 }
891 
893 {
894  _showPlafond = !show; // inversion entre l'etat variable et du bouton
895 
897  {
898 
899  TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
900 
902 
903  if (_pElement && _pElement->getGraphicObject())
904  {
905  // Update l'element associe a ce modeler
906  _pElement->getGraphicObject()->update(true);
907 
909 
910  // Update view
911  updateView();
912  }
913 
914  TYApplication::restoreOverrideCursor();
915  }
916 
917  _pShowPlafondBtn->setChecked(!_showPlafond);
918 }
919 
921 {
922  _snapGridActive = state;
923  _pSnapGridBtn->setChecked(_snapGridActive);
924 }
925 
927 {
929  {
930  TYSetCameraCoordinates* pSetCameraCoordinates = new TYSetCameraCoordinates(this);
931  double x = NAN, y = NAN, z = NAN;
933  pSetCameraCoordinates->setXCoord(x);
934  pSetCameraCoordinates->setYCoord(-z);
935  pSetCameraCoordinates->setZCoord(y);
936  pSetCameraCoordinates->exec();
937 
938  if (pSetCameraCoordinates->result() == QDialog::Accepted)
939  {
940  if (_pView->getActiveCamera())
941  {
942  _pView->getActiveCamera()->setTranslation(pSetCameraCoordinates->getXCoord(),
943  pSetCameraCoordinates->getZCoord(),
944  -pSetCameraCoordinates->getYCoord());
945 
946  // Update view
947  updateView();
948  }
949  }
950  }
951 }
952 
954 {
955  QString filename = QFileDialog::getSaveFileName(this, tr("Save Image"), "",
956  tr("Images PNG (*.png);;Images JPEG (*.jpg *.jpeg)"));
957  if (!filename.isEmpty())
958  {
959  // Snap
960  QImage img = _pView->grabFramebuffer();
961 
962  // Save
963  QPixmap pix = QPixmap::fromImage(img);
964  pix.save(filename);
965  }
966 }
967 
969 {
970  // Snap
971  QImage img = _pView->grabFramebuffer();
972 
973  // Copie dans le presse papier
974  QClipboard* clipboard = QApplication::clipboard();
975  clipboard->setImage(img);
976 }
977 
979 {
980  LPTYProjet pProjet = getTYApp()->getCurProjet();
981  LPTYCalcul pCalcul = NULL;
982  if (pProjet)
983  {
984  pCalcul = pProjet->getCurrentCalcul();
985  }
986 
987  // Print dialog
988  TYPrintDialog* pDialog = new TYPrintDialog(this);
989 
990  if (pProjet == NULL)
991  {
992  pDialog->_groupBoxProjet->setEnabled(false);
993  }
994  if (pCalcul == NULL)
995  {
996  pDialog->_groupBoxCalcul->setEnabled(false);
997  }
998 
999  if (_pElement)
1000  {
1001  if (dynamic_cast<TYBatiment*>(_pElement._pObj) != nullptr)
1002  {
1003  pDialog->_groupBoxBatiment->show();
1004  }
1005  else if (dynamic_cast<TYMachine*>(_pElement._pObj) != nullptr)
1006  {
1007  pDialog->_groupBoxMachine->show();
1008  }
1009  else if (dynamic_cast<TYSiteNode*>(_pElement._pObj) != nullptr)
1010  {
1011  pDialog->_groupBoxSite->show();
1012  }
1013  }
1014 
1015  if (pDialog->exec() == QDialog::Accepted)
1016  {
1017  QPrinter* printer = new QPrinter();
1018 
1019  QPrintDialog dialog(printer, this);
1020  if (dialog.exec())
1021  {
1022  QPainter paint(printer);
1023 
1024  double w = double(printer->width());
1025  double h = double(printer->height());
1026  double scalew = w / 700;
1027  double scaleh = h / 700;
1028 
1029  // Snap
1030  QImage img = _pView->grabFramebuffer();
1031  img = img.scaled(int(w * 9 / 10), int(h * 2 / 3), Qt::KeepAspectRatio, Qt::SmoothTransformation);
1032  int x = int(double(printer->width() - img.width()) / 2);
1033  int y = int(double(printer->height() - img.height()) * 1 / 3);
1034  QPixmap pm = QPixmap::fromImage(img);
1035  paint.drawPixmap(x, y, pm);
1036 
1037  paint.setFont(QFont("Times", (int)(10 * scaleh)));
1038  int mid =
1039  int(w / 2) - int(paint.fontMetrics().horizontalAdvance(pDialog->_lineEditTete->text()) / 2);
1040  paint.drawText(mid, 20, pDialog->_lineEditTete->text());
1041 
1042  mid = int(w / 2) - int(paint.fontMetrics().horizontalAdvance(pDialog->_lineEditPied->text()) / 2);
1043  paint.drawText(mid, printer->height() - 20, pDialog->_lineEditPied->text());
1044 
1045  paint.setFont(QFont("Times", (int)(15 * scaleh), QFont::Bold));
1046  mid =
1047  int(w / 2) - int(paint.fontMetrics().horizontalAdvance(pDialog->_lineEditTitre->text()) / 2);
1048  paint.drawText(mid, y - 20, pDialog->_lineEditTitre->text());
1049 
1050  x = int(50 * scalew);
1051  int x1 = int(w / 2);
1052  y = int(double(printer->height()) * 2 / 3 + 20 * scaleh);
1053  int stepy = int(10 * scaleh);
1054  paint.setFont(QFont("Times", (int)(10 * scaleh)));
1055 
1056  if (pProjet)
1057  {
1058  if (pDialog->_checkBoxNomProjet->isChecked())
1059  {
1060  paint.drawText(x, y, TR("id_print_nom_projet"));
1061  paint.drawText(x1, y, pProjet->getName());
1062  y += stepy;
1063  }
1064  if (pDialog->_checkBoxAuteurProjet->isChecked())
1065  {
1066  paint.drawText(x, y, TR("id_print_auteur_projet"));
1067  paint.drawText(x1, y, pProjet->getAuteur());
1068  y += stepy;
1069  }
1070  if (pDialog->_checkBoxDateProjet->isChecked())
1071  {
1072  paint.drawText(x, y, TR("id_print_date_creation"));
1073  paint.drawText(x1, y, pProjet->getDateCreation());
1074  y += stepy;
1075  paint.drawText(x, y, TR("id_print_date_modif"));
1076  paint.drawText(x1, y, pProjet->getDateModif());
1077  y += stepy;
1078  }
1079  if (pDialog->_checkBoxCommentProjet->isChecked())
1080  {
1081  paint.drawText(x, y, TR("id_print_comment"));
1082  paint.drawText(x1, y, pProjet->getComment());
1083  y += stepy;
1084  }
1085  }
1086 
1087  if (pCalcul)
1088  {
1089  y += int(double(stepy) * 1.5);
1090  if (pDialog->_checkBoxNomCalcul->isChecked())
1091  {
1092  paint.drawText(x, y, TR("id_print_nom_calcul"));
1093  paint.drawText(x1, y, pCalcul->getName());
1094  y += stepy;
1095  }
1096  if (pDialog->_checkBoxDateCalcul->isChecked())
1097  {
1098  paint.drawText(x, y, TR("id_print_date_creation"));
1099  paint.drawText(x1, y, pCalcul->getDateCreation());
1100  y += stepy;
1101  paint.drawText(x, y, TR("id_print_date_modif"));
1102  paint.drawText(x1, y, pCalcul->getDateModif());
1103  y += stepy;
1104  }
1105  if (pDialog->_checkBoxCommentCalcul->isChecked())
1106  {
1107  paint.drawText(x, y, TR("id_print_comment"));
1108  paint.drawText(x1, y, pCalcul->getComment());
1109  y += stepy;
1110  }
1111  }
1112 
1113  if (_pElement)
1114  {
1115  y += int(double(stepy) * 1.5);
1116  TYElement* pElement = (TYElement*)_pElement;
1117  if (strcmp(_pElement->getClassName(), "TYBatiment") == 0)
1118  {
1119  TYBatiment* pBatiment = (TYBatiment*)pElement;
1120  if (pDialog->_checkBoxNomBatiment->isChecked())
1121  {
1122  paint.drawText(x, y, TR("id_print_nom_batiment"));
1123  paint.drawText(x1, y, pBatiment->getName());
1124  }
1125  }
1126  else if (strcmp(_pElement->getClassName(), "TYMachine") == 0)
1127  {
1128  TYMachine* pMachine = (TYMachine*)pElement;
1129  if (pDialog->_checkBoxNomMachine->isChecked())
1130  {
1131  paint.drawText(x, y, TR("id_print_nom_machine"));
1132  paint.drawText(x1, y, pMachine->getName());
1133  y += stepy;
1134  }
1135  if (pDialog->_checkBoxConstrMachine->isChecked())
1136  {
1137  paint.drawText(x, y, TR("id_print_constr"));
1138  paint.drawText(x1, y, pMachine->getConstructeur());
1139  y += stepy;
1140  }
1141  if (pDialog->_checkBoxModelMachine->isChecked())
1142  {
1143  paint.drawText(x, y, TR("id_print_model"));
1144  paint.drawText(x1, y, pMachine->getModele());
1145  y += stepy;
1146  }
1147  if (pDialog->_checkBoxCatMachine->isChecked())
1148  {
1149  paint.drawText(x, y, TR("id_print_cat"));
1150  paint.drawText(x1, y, QString().setNum(pMachine->getCategorie()));
1151  y += stepy;
1152  }
1153  if (pDialog->_checkBoxCommentProjet->isChecked())
1154  {
1155  paint.drawText(x, y, TR("id_print_comment"));
1156  paint.drawText(x1, y, pMachine->getCommentaire());
1157  }
1158  }
1159  else
1160  {
1161  TYSiteNode* pSite = dynamic_cast<TYSiteNode*>(pElement);
1162  if (pSite != nullptr)
1163  {
1164  if (pDialog->_checkBoxNomSite->isChecked())
1165  {
1166  paint.drawText(x, y, TR("id_print_nom_site"));
1167  paint.drawText(x1, y, pSite->getName());
1168  }
1169  }
1170  }
1171  }
1172  }
1173 
1174  delete printer;
1175  }
1176 }
1177 
1179 {
1180  if (_pElement)
1181  {
1182  if (_pElement->edit(this) == QDialog::Accepted)
1183  {
1184  emit eltModified(_pElement);
1185  }
1186 
1187  // On update ds ts les cas si un child a ete modifie...
1188  _pElement->getGraphicObject()->update(true);
1190  updateView(false, false);
1191  }
1192 }
1193 
1195 {
1196  // XBH: version simplifiee et +logique...
1197 
1198  OBox boundingBox;
1199  LPTYElementGraphic pTYElementGraphic = pElement->getGraphicObject();
1200 
1201  if (pTYElementGraphic != NULL)
1202  {
1203  boundingBox = pTYElementGraphic->boundingBox();
1204  }
1205 
1206  return boundingBox;
1207 }
1208 
1210 {
1211  OBox globalBoundingBox;
1212  if (_pElement)
1213  {
1214  TYElement* pTYElement = (TYElement*)_pElement;
1215  TYProjet* pTYProjet = dynamic_cast<TYProjet*>(pTYElement);
1216  if (pTYProjet != nullptr)
1217  {
1218  TYSiteNode* pTYSiteNode = (TYSiteNode*)pTYProjet->getSite();
1219  pTYElement = pTYSiteNode;
1220  }
1221 
1222  globalBoundingBox = getBoundingBox(pTYElement);
1223  }
1224  return globalBoundingBox;
1225 }
1226 
1228 {
1229  for (auto camera : _pOGLCameras)
1230  {
1231  camera->setSize(_pView->getViewport().width(), _pView->getViewport().height());
1232  }
1233 
1234  int visibilityStates[9];
1235 
1236  // Sauvegarde des etats de visibilite des objets graphiques
1237  // de "decoration", ils ne doivent pas participer au recadrage
1238 #ifndef NO_GRID
1239  visibilityStates[0] = _pOGLGridElement->getShowGridXY();
1240  visibilityStates[1] = _pOGLGridElement->getShowGridXZ();
1241  visibilityStates[2] = _pOGLGridElement->getShowGridZY();
1242 #endif // NO_GRID
1243 
1244  setGridLinesActorsVisibility(false, false, false);
1245 
1246  visibilityStates[3] = _pOGLLineElementAxeX->getVisibility();
1250  visibilityStates[4] = _pOGLTextElementLabelX->getVisibility();
1252  visibilityStates[5] = _pOGLTextElementLabelY->getVisibility();
1254  visibilityStates[6] = _pOGLTextElementLabelZ->getVisibility();
1256 
1257  visibilityStates[7] = _pOGLLineElementX->getVisibility();
1259  visibilityStates[8] = _pOGLLineElementY->getVisibility();
1261 
1262  // az-- : pour tests reperes machines:
1263  OBox globalBoundingBox = getGlobalBoundingBox();
1264 
1265  float xMin = globalBoundingBox._min._x;
1266  float xMax = globalBoundingBox._max._x;
1267  float yMin = globalBoundingBox._min._y;
1268  float yMax = globalBoundingBox._max._y;
1269  float zMin = globalBoundingBox._min._z;
1270  float zMax = globalBoundingBox._max._z;
1271  float xDist = std::max(abs(xMin), abs(xMax)) * 2;
1272  float yDist = std::max(abs(yMin), abs(yMax)) * 2;
1273  float zDist = std::max(abs(zMin), abs(zMax)) * 2;
1274 
1275  // Cameras pour chaque type de vue
1276  QVector3D fromTop{0, 10000, 0};
1277  QVector3D toTop{0, 0, 0};
1278  QVector3D upTop{0, 0, -1};
1279  _pOGLCameras[TopView]->setFromToUp(fromTop, toTop, upTop);
1281  _pOGLCameras[TopView]->resetZoom(xDist, yDist);
1282 
1283  QVector3D fromBottom{0, -10000, 0};
1284  QVector3D toBottom{0, 0, 0};
1285  QVector3D upBottom{0, 0, 1};
1286  _pOGLCameras[BottomView]->setFromToUp(fromBottom, toBottom, upBottom);
1288  _pOGLCameras[BottomView]->resetZoom(xDist, yDist);
1289 
1290  QVector3D fromLeft{-500, 0, 0};
1291  QVector3D toLeft{0, 0, 0};
1292  QVector3D upLeft{0, 1, 0};
1293  _pOGLCameras[LeftView]->setFromToUp(fromLeft, toLeft, upLeft);
1294  _pOGLCameras[LeftView]->resetZoom(yDist, zDist);
1295 
1296  QVector3D fromRight{500, 0, 0};
1297  QVector3D toRight{0, 0, 0};
1298  QVector3D upRight{0, 1, 0};
1299  _pOGLCameras[RightView]->setFromToUp(fromRight, toRight, upRight);
1300  _pOGLCameras[RightView]->resetZoom(yDist, zDist);
1301 
1302  QVector3D fromFront{0, 0, 500};
1303  QVector3D toFront{0, 0, 0};
1304  QVector3D upFront{0, 1, 0};
1305  _pOGLCameras[FrontView]->setFromToUp(fromFront, toFront, upFront);
1306  _pOGLCameras[FrontView]->resetZoom(xDist, zDist);
1307 
1308  QVector3D fromRear{0, 0, -500};
1309  QVector3D toRear{0, 0, 0};
1310  QVector3D upRear{0, 1, 0};
1311  _pOGLCameras[RearView]->setFromToUp(fromRear, toRear, upRear);
1312  _pOGLCameras[RearView]->resetZoom(xDist, zDist);
1313 
1314  QVector3D fromPersp{0, 1000, 1000};
1315  QVector3D toPersp{0, 0, 0};
1316  QVector3D upPersp{0, 1, 0};
1317  _pOGLCameras[PerspView]->setFromToUp(fromPersp, toPersp, upPersp);
1318  _pOGLCameras[PerspView]->resetZoom(xDist, yDist);
1320  _pOGLCameras[PerspView]->setDistanceStep(30, 70, 30);
1321 
1322  QVector3D fromFree{0, 0, 0};
1323  QVector3D toFree{0, 0, 0.1};
1324  QVector3D upFree{0, 1, 0};
1325  _pOGLCameras[FreeView]->setFromToUp(fromFree, toFree, upFree);
1330 
1331  // Restauration des etats de visibilite des objets graphiques
1332 #ifndef NO_GRID
1333  setGridLinesActorsVisibility(visibilityStates[0], visibilityStates[1], visibilityStates[2]);
1334 #endif // NO_GRID
1335  _pOGLLineElementAxeX->setVisibility(visibilityStates[3]);
1336  _pOGLLineElementAxeY->setVisibility(visibilityStates[3]);
1337  _pOGLLineElementAxeZ->setVisibility(visibilityStates[3]);
1338  _pOGLTextElementLabelX->setVisibility(visibilityStates[4]);
1339  _pOGLTextElementLabelY->setVisibility(visibilityStates[5]);
1340  _pOGLTextElementLabelZ->setVisibility(visibilityStates[6]);
1341  _pOGLLineElementX->setVisibility(visibilityStates[7]);
1342  _pOGLLineElementY->setVisibility(visibilityStates[8]);
1343 
1345  updateView();
1346 }
1347 
1348 void TYModelerFrame::updateView(bool clipping /*=true*/, bool axesAndGrid /*=true*/)
1349 {
1350  OGLCamera* activeCamera = _pView->getActiveCamera();
1351  if (activeCamera)
1352  {
1353  QRect viewport = _pView->getViewport();
1354  activeCamera->setSize(viewport.width(), viewport.height());
1355  if (axesAndGrid)
1356  {
1357  updateAxes();
1358  updateGrid();
1359  updateCurPosInfo(0, 0);
1360  updateScale();
1361  }
1362 
1363  if (clipping)
1364  {
1365  // Update le render mode
1366  setRenderMode(getRenderMode(), false);
1367  }
1368  _pOGLTextElement->setDisplayPosition(7, viewport.height() - 20);
1370  QVector3D(viewport.width() - _pOGLScalarBarElement->getWidth() * 0.5 - 50, 50, 0));
1372 
1373  // RNU
1374  //_pView->getRenderer()->invalidateScene();
1375 
1376  // Update la vue 3D
1377  _pView->update();
1378  }
1379 }
1380 
1382 {
1389 
1390  QVector3D org = _pView->getViewport().displayToWorld(QVector3D(50, 50, 0.1));
1391 
1395 
1396  QVector3D extX, extY, extZ;
1397 
1398  switch (getCurrentView())
1399  {
1400  case TopView:
1401  {
1402  extX = _pView->getViewport().displayToWorld(QVector3D(90, 50, 0.1));
1403  extY = _pView->getViewport().displayToWorld(QVector3D(50, 90, 0.1));
1404  extZ = _pView->getViewport().displayToWorld(QVector3D(50, 50, 40.1));
1408  }
1409  break;
1410  case BottomView:
1411  {
1412  extX = _pView->getViewport().displayToWorld(QVector3D(10, 50, 0.1));
1413  extY = _pView->getViewport().displayToWorld(QVector3D(50, 90, 0.1));
1414  extZ = _pView->getViewport().displayToWorld(QVector3D(50, 50, -40.1));
1418  }
1419  break;
1420  case LeftView:
1421  {
1422  extX = _pView->getViewport().displayToWorld(QVector3D(50, 50, 40.1));
1423  extY = _pView->getViewport().displayToWorld(QVector3D(10, 50, 0.1));
1424  extZ = _pView->getViewport().displayToWorld(QVector3D(50, 90, 0.1));
1428  }
1429  break;
1430  case RightView:
1431  {
1432  extX = _pView->getViewport().displayToWorld(QVector3D(50, 50, -40.1));
1433  extY = _pView->getViewport().displayToWorld(QVector3D(90, 50, 0.1));
1434  extZ = _pView->getViewport().displayToWorld(QVector3D(50, 90, 0.1));
1438  }
1439  break;
1440  case FrontView:
1441  {
1442  extX = _pView->getViewport().displayToWorld(QVector3D(90, 50, 0.1));
1443  extY = _pView->getViewport().displayToWorld(QVector3D(50, 50, 40.1));
1444  extZ = _pView->getViewport().displayToWorld(QVector3D(50, 90, 0.1));
1448  }
1449  break;
1450  case RearView:
1451  {
1452  extX = _pView->getViewport().displayToWorld(QVector3D(10, 50, 0.1));
1453  extY = _pView->getViewport().displayToWorld(QVector3D(50, 50, -40.1));
1454  extZ = _pView->getViewport().displayToWorld(QVector3D(50, 90, 0.1));
1458  }
1459  break;
1460  case PerspView:
1461  case FreeView:
1462  {
1463  QVector3D org2 = _pView->getViewport().displayToWorld(QVector3D(50, 90, 0.1));
1464  double dist = org.distanceToPoint(org2);
1465  extX.setX(org.x() + dist);
1466  extX.setY(org.y());
1467  extX.setZ(org.z());
1468  extY.setX(org.x());
1469  extY.setY(org.y());
1470  extY.setZ(org.z() - dist);
1471  extZ.setX(org.x());
1472  extZ.setY(org.y() + dist);
1473  extZ.setZ(org.z());
1474 
1475  QVector3D dispX = _pView->getViewport().worldToDisplay(extX);
1476  QVector3D dispY = _pView->getViewport().worldToDisplay(extY);
1477  QVector3D dispZ = _pView->getViewport().worldToDisplay(extZ);
1478 
1479  _pOGLTextElementLabelX->setDisplayPosition(dispX.x(), dispX.y());
1480  _pOGLTextElementLabelY->setDisplayPosition(dispY.x(), dispY.y());
1481  _pOGLTextElementLabelZ->setDisplayPosition(dispZ.x(), dispZ.y());
1482  }
1483  break;
1484  }
1485 
1489 }
1490 
1491 void TYModelerFrame::keyPressEvent(QKeyEvent* pEvent)
1492 {
1493  switch (pEvent->key())
1494  {
1495  case Qt::Key_1:
1497  break;
1498  case Qt::Key_2:
1500  break;
1501  case Qt::Key_3:
1503  break;
1504  case Qt::Key_4:
1506  break;
1507  case Qt::Key_5:
1509  break;
1510  case Qt::Key_V:
1512  break;
1513  case Qt::Key_I:
1515  break;
1516  case Qt::Key_G:
1517  showGrid(!_showGrid);
1518  break;
1519  case Qt::Key_R:
1520  {
1521  int nextRenderMode = (getRenderMode() + 1) % TYOpenGLRenderer::NbOfRenderMode;
1522  setRenderMode(static_cast<TYOpenGLRenderer::RenderMode>(nextRenderMode), true);
1523  break;
1524  }
1525  case Qt::Key_W:
1527  break;
1528  case Qt::Key_S:
1530  break;
1531  case Qt::Key_Control:
1532  setSnapGridActive(false);
1533  break;
1534  case Qt::Key_C:
1535  if (pEvent->modifiers() == Qt::ControlModifier)
1536  {
1537  copy();
1538  }
1539  else
1540  {
1542  }
1543  break;
1544  case Qt::Key_F:
1545  case Qt::Key_F5:
1546  fit();
1547  break;
1548  default:
1549  TYApplication::sendEvent(_pView, pEvent);
1550  }
1551 }
1552 
1553 void TYModelerFrame::keyReleaseEvent(QKeyEvent* pEvent)
1554 {
1555  switch (pEvent->key())
1556  {
1557  case Qt::Key_Control:
1558  setSnapGridActive(true);
1559  break;
1560  default:
1561  TYApplication::sendEvent(_pView, pEvent);
1562  }
1563 }
1564 
1565 void TYModelerFrame::mouseMoveEvent(QMouseEvent* pEvent) {}
1566 
1568 {
1569  // On recupere la pos du curseur
1570 
1571  // Calcul des coords
1572  float* pos = new float[3];
1573 
1574  if (computeCurPos(x, y, pos))
1575  {
1576  // Si la grille magnetique est activee
1577  if (getSnapGridActive())
1578  {
1579  TYAbstractSceneEditor::snapToGrid(pos[0], pos[1], pos[2], _gridMagnStep);
1580  }
1581 
1582  // Formatage du msg
1583  QString msg("pos : (%1, %2, %3)");
1584  // On inverse y et z, et -y... (VTK to TY)
1585  msg = msg.arg(pos[0], 0, 'f', 2).arg(-pos[2], 0, 'f', 2).arg(pos[1], 0, 'f', 2);
1586  // Affichage
1587  statusBar()->showMessage(msg);
1588  }
1589  else
1590  {
1591  if (getCurrentView() == FreeView)
1592  {
1593  double x = NAN, y = NAN, z = NAN;
1594  _pView->getActiveCamera()->getTranslation(x, y, z);
1595  QString msg = QString("camera pos : (%1, %2, %3)").arg(x).arg(-z).arg(y);
1596  statusBar()->showMessage(msg);
1597  }
1598  else
1599  {
1600  statusBar()->showMessage("");
1601  }
1602  }
1603 
1604  delete[] pos;
1605 }
1606 
1607 // float* TYModelerFrame::computeCurPos(int x, int y)
1608 bool TYModelerFrame::computeCurPos(int x, int y, float* ret)
1609 {
1610  int view = getCurrentView();
1611  if ((view != PerspView) && (view != FreeView))
1612  {
1613  // Position du curseur
1614  QVector3D pos =
1615  _pView->getViewport().displayToWorld(QVector3D(x, _pView->getViewport().height() - y, 0));
1616  ret[0] = pos.x();
1617  ret[1] = pos.y();
1618  ret[2] = pos.z();
1619 
1620  switch (getCurrentView())
1621  {
1622  case TopView:
1623  ret[1] = 0.0;
1624  break;
1625  case BottomView:
1626  ret[1] = 0.0;
1627  break;
1628  case LeftView:
1629  ret[0] = 0.0;
1630  break;
1631  case RightView:
1632  ret[0] = 0.0;
1633  break;
1634  case FrontView:
1635  ret[2] = 0.0;
1636  break;
1637  case RearView:
1638  ret[2] = 0.0;
1639  break;
1640  }
1641 
1642  return true;
1643  }
1644 
1645  return false;
1646 }
1647 
1649 {
1650  return _defaultZCoord;
1651 }
1652 
1653 void TYModelerFrame::setGridLinesActorsVisibility(bool showGridXY, bool showGridXZ, bool showGridZY)
1654 {
1655 #ifndef NO_GRID
1656  _pOGLGridElement->setShowGridXY(showGridXY);
1657  _pOGLGridElement->setShowGridXZ(showGridXZ);
1658  _pOGLGridElement->setShowGridZY(showGridZY);
1659 #endif // NO_GRID
1660 }
1661 
1662 void TYModelerFrame::wheelEvent(QWheelEvent* pEvent)
1663 {
1664  // Reroute l'event sur le TYRenderWindowInteractor
1665  TYApplication::sendEvent(_pView, pEvent);
1666 }
1667 
1668 void TYModelerFrame::resizeEvent(QResizeEvent* pEvent)
1669 {
1670  // CLM-NT33 : maximized handling and main window title
1671  emit frameResized();
1672  updateView();
1673 }
1674 
1675 void TYModelerFrame::focusInEvent(QFocusEvent* pEvent)
1676 {
1677  updateView();
1678 }
1679 
1680 void TYModelerFrame::showEvent(QShowEvent* pEvent)
1681 {
1682  if (_firstTimeShown)
1683  {
1684  TYPreferenceManager::loadGeometryFromPreferences(metaObject()->className(), this);
1685  _firstTimeShown = false;
1686  }
1687  updateView();
1688 }
1689 
1690 void TYModelerFrame::closeEvent(QCloseEvent* pEvent)
1691 {
1692  TYPreferenceManager::saveGeometryToPreferences(metaObject()->className(), this);
1693  pEvent->accept();
1694  emit frameResized();
1695  emit aboutToClose();
1696 
1697  // CLM-NT35 : Gestion du maximized et titre fenetre principal
1698 }
1699 
1700 void TYModelerFrame::enterEvent(QEvent* pEvent)
1701 {
1702  /* _pView->getRenderer()->invalidateScene();
1703  updateView();
1704  _pView->getRenderer()->invalidateScene();
1705  updateView();*/
1706  emit mouseEnter();
1707 }
1708 
1709 void TYModelerFrame::leaveEvent(QEvent* pEvent)
1710 {
1711  emit mouseLeave();
1712 }
1713 
1715 {
1716  if ((getCurrentView() == PerspView) || (getCurrentView() == FreeView))
1717  {
1718  _pOGLLineElementX->setPoint1(QVector3D(0, 0, _gridDimY / 2));
1719  _pOGLLineElementX->setPoint2(QVector3D(0, 0, -_gridDimY / 2));
1720 
1721  _pOGLLineElementY->setPoint1(QVector3D(_gridDimX / 2, 0, 0));
1722  _pOGLLineElementY->setPoint2(QVector3D(-_gridDimX / 2, 0, 0));
1723  }
1724  else
1725  {
1726  QRect viewport = _pView->getViewport();
1727  int gridXMax = viewport.width();
1728  int gridYMax = viewport.height();
1729  if (gridXMax == 0)
1730  {
1731  gridXMax = 100;
1732  }
1733  if (gridYMax == 0)
1734  {
1735  gridYMax = 100;
1736  }
1737 
1738  // getCenter
1739  QVector3D center = _pView->getViewport().worldToDisplay(QVector3D(0, 0, 0));
1740 
1741  // X
1742  QVector3D xAxisPoint1 = _pView->getViewport().displayToWorld(QVector3D(center.x(), 0, 0));
1743  QVector3D xAxisPoint2 = _pView->getViewport().displayToWorld(QVector3D(center.x(), gridYMax, 0));
1744  _pOGLLineElementX->setPoint1(xAxisPoint1);
1745  if (xAxisPoint1 != xAxisPoint2)
1746  {
1747  _pOGLLineElementX->setPoint2(xAxisPoint2);
1748  }
1749 
1750  // Y
1751  QVector3D yAxisPoint1 = _pView->getViewport().displayToWorld(QVector3D(0, center.y(), 0));
1752  QVector3D yAxisPoint2 = _pView->getViewport().displayToWorld(QVector3D(gridXMax, center.y(), 0));
1753  _pOGLLineElementY->setPoint1(yAxisPoint1);
1754  if (yAxisPoint1 != yAxisPoint2)
1755  {
1756  _pOGLLineElementY->setPoint2(yAxisPoint2);
1757  }
1758  }
1759 }
1760 
1761 void TYModelerFrame::updateElementGraphic(bool force /* = false */)
1762 {
1763  if (_pElement && _pElement->getGraphicObject())
1764  {
1765  _pElement->getGraphicObject()->update(force);
1766  }
1767 }
1768 
1770 {
1774 
1775  _pOGLLineElementX->setColor(OColor(gridColor[0], gridColor[1], gridColor[2]));
1776  _pOGLLineElementY->setColor(OColor(gridColor[0], gridColor[1], gridColor[2]));
1777 }
1778 
1780 {
1781  // Mise a jour de la taille de l'historique de l'Action Manager
1782  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "HistoSize"))
1783  {
1784  _actionManager.setHistorySize(TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "HistoSize"));
1785  }
1786  else
1787  {
1788  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "HistoSize", _actionManager.getHistorySize());
1789  }
1790 
1791  // Mise a jour de l'etat d'activation du delplacement de camera en mode Wireframe
1792  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "WireframeOnMovingCamera"))
1793  {
1795  TYPreferenceManager::getBool(TYDIRPREFERENCEMANAGER, "WireframeOnMovingCamera"));
1796  }
1797  else
1798  {
1799  TYPreferenceManager::setBool(TYDIRPREFERENCEMANAGER, "WireframeOnMovingCamera", false);
1801  }
1802 
1803  // Mise a jour des couleurs a partir des preferences.
1804  // Couleur de fond
1805  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "BackgroundColorR"))
1806  {
1807  float r = NAN, g = NAN, b = NAN;
1808  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "BackgroundColor", r, g, b);
1809  rendererColor[0] = r / 255;
1810  rendererColor[1] = g / 255;
1811  rendererColor[2] = b / 255;
1812  }
1813  else
1814  {
1815  float r = rendererColor[0] * 255;
1816  float g = rendererColor[1] * 255;
1817  float b = rendererColor[2] * 255;
1818  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "BackgroundColor", r, g, b);
1819  }
1820 
1821  getRenderer()->setBackground(rendererColor);
1822 
1823  // Couleur de la grille
1824  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridColorR"))
1825  {
1826  float r = NAN, g = NAN, b = NAN;
1828  gridColor[0] = r / 255;
1829  gridColor[1] = g / 255;
1830  gridColor[2] = b / 255;
1831  }
1832  else
1833  {
1834  float r = gridColor[0] * 255;
1835  float g = gridColor[1] * 255;
1836  float b = gridColor[2] * 255;
1837  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "GridColor", r, g, b);
1838  }
1839 
1840  // Couleur de la police
1841  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "FontColorR"))
1842  {
1843  float r = NAN, g = NAN, b = NAN;
1845  fontColor[0] = r / 255;
1846  fontColor[1] = g / 255;
1847  fontColor[2] = b / 255;
1848  }
1849  else
1850  {
1851  float r = fontColor[0] * 255;
1852  float g = fontColor[1] * 255;
1853  float b = fontColor[2] * 255;
1854  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "FontColor", r, g, b);
1855  }
1856 
1860  _pOGLScalarBarElement->setFontColor(OColor(fontColor[0], fontColor[1], fontColor[2]));
1861 
1862  // Mise a jour de l'eclairage de la scene.
1863  float intensity = 0.83f;
1864  if ((TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "Luminosite")))
1865  {
1866  intensity = TYPreferenceManager::getDouble(TYDIRPREFERENCEMANAGER, "Luminosite");
1867  }
1868  else
1869  {
1870  TYPreferenceManager::setDouble(TYDIRPREFERENCEMANAGER, "Luminosite", intensity);
1871  }
1872 
1873  if (intensity < 0.1f)
1874  {
1875  intensity = 0.1f;
1876  }
1877  _pLightElement->setIntensity(intensity);
1878 
1879  // Mise a jour de la tolerance du picking.
1880  float precisPick = 3.0;
1881  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "PrecisPick"))
1882  {
1883  precisPick = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "PrecisPick");
1884  }
1885  else
1886  {
1887  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "PrecisPick", precisPick);
1888  }
1889  _pPickEditor->setPickTolerance(precisPick);
1891 
1892  // Mise a jour du pas de zoom de la mollette de la souris.
1893  float zoomStep = 1.0f;
1894  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "ZoomStep"))
1895  {
1896  zoomStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "ZoomStep");
1897  }
1898  else
1899  {
1900  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "ZoomStep", zoomStep);
1901  }
1902  _pCameraEditor->setWheelStep(zoomStep);
1903  _pDistanceEditor->setWheelStep(zoomStep);
1904  _pPositionEditor->setWheelStep(zoomStep);
1905 
1906  // Mise a jour du pas de l'angle du positionEditor
1907  float angle = 15.0;
1908  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "Angle"))
1909  {
1910  angle = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "Angle");
1911  }
1912  else
1913  {
1914  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "Angle", angle);
1915  }
1916 
1918 
1919  // en 3D
1920  // bouton gauche
1921  int mouseLeftButtonFunct3D = 3;
1922  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct3D"))
1923  {
1924  mouseLeftButtonFunct3D =
1925  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct3D");
1926  }
1927  else
1928  {
1929  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct3D", mouseLeftButtonFunct3D);
1930  }
1931 
1932  switch (mouseLeftButtonFunct3D)
1933  {
1934  case 0:
1936  break;
1937  case 1:
1939  break;
1940  case 2:
1942  break;
1943  case 3:
1945  break;
1946  }
1947 
1948  // bouton droit
1949  int mouseRightButtonFunct3D = 0;
1950  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct3D"))
1951  {
1952  mouseRightButtonFunct3D =
1953  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct3D");
1954  }
1955  else
1956  {
1957  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct3D",
1958  mouseRightButtonFunct3D);
1959  }
1960 
1961  switch (mouseRightButtonFunct3D)
1962  {
1963  case 0:
1965  break;
1966  case 1:
1968  break;
1969  case 2:
1971  break;
1972  case 3:
1974  break;
1975  }
1976 
1977  // bouton central
1978  int mouseMiddleButtonFunct3D = 2;
1979  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct3D"))
1980  {
1981  mouseMiddleButtonFunct3D =
1982  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct3D");
1983  }
1984  else
1985  {
1986  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct3D",
1987  mouseMiddleButtonFunct3D);
1988  }
1989 
1990  switch (mouseMiddleButtonFunct3D)
1991  {
1992  case 0:
1994  break;
1995  case 1:
1997  break;
1998  case 2:
2000  break;
2001  case 3:
2003  break;
2004  }
2005 
2006  // Mode shift.
2007  // 2D
2008  // bouton gauche
2009  int mouseShiftLeftButtonFunct2D = 1;
2010  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct2D"))
2011  {
2012  mouseShiftLeftButtonFunct2D =
2013  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct2D");
2014  }
2015  else
2016  {
2017  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct2D",
2018  mouseShiftLeftButtonFunct2D);
2019  }
2020 
2021  switch (mouseShiftLeftButtonFunct2D)
2022  {
2023  case 0:
2025  break;
2026  case 1:
2028  break;
2029  }
2030 
2031  // bouton droit
2032  int mouseShiftRightButtonFunct2D = 0;
2033  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct2D"))
2034  {
2035  mouseShiftRightButtonFunct2D =
2036  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct2D");
2037  }
2038  else
2039  {
2040  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct2D",
2041  mouseShiftRightButtonFunct2D);
2042  }
2043 
2044  switch (mouseShiftRightButtonFunct2D)
2045  {
2046  case 0:
2048  break;
2049  case 1:
2051  break;
2052  }
2053 
2054  // en 3D
2055  // bouton gauche
2056  int mouseShiftLeftButtonFunct3D = 1;
2057  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct3D"))
2058  {
2059  mouseShiftLeftButtonFunct3D =
2060  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct3D");
2061  }
2062  else
2063  {
2064  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct3D",
2065  mouseShiftLeftButtonFunct3D);
2066  }
2067 
2068  switch (mouseShiftLeftButtonFunct3D)
2069  {
2070  case 0:
2072  break;
2073  case 1:
2075  break;
2076  case 2:
2078  break;
2079  case 3:
2081  break;
2082  }
2083 
2084  // bouton droit
2085  int mouseShiftRightButtonFunct3D = 2;
2086  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct3D"))
2087  {
2088  mouseShiftRightButtonFunct3D =
2089  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct3D");
2090  }
2091  else
2092  {
2093  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct3D",
2094  mouseShiftRightButtonFunct3D);
2095  }
2096 
2097  switch (mouseShiftRightButtonFunct3D)
2098  {
2099  case 0:
2101  break;
2102  case 1:
2104  break;
2105  case 2:
2107  break;
2108  case 3:
2110  break;
2111  }
2112 
2113  // Force un update de la camera
2115 
2116  // Update de l'editor courant
2117  // setEditorMode(_lastEditorMode); // DTn : Correction du bug #0009661
2118 
2119  // Mets a jour la structure graphique de l'element
2120  updateElementGraphic(true);
2121 
2122  // Refresh
2123  updateView(false);
2124 }
2125 
2127 {
2129  // On passe en mode Wireframe si l'option est activee et qu'on est
2130  // pas deja dans ce mode
2131  if (_wireframeOnMovingCamera && (currentMode != TYOpenGLRenderer::Wireframe))
2132  {
2133  // On conserve le mode courant
2134  _lastRenderMode = currentMode;
2135  // On passe en Wireframe
2137  }
2138 }
2139 
2141 {
2143  {
2144  // On revient dans le mode courant
2146  }
2147 }
2148 
2150 {
2151  if (_showScale)
2152  {
2153  QVector3D pt0 = _pView->getViewport().displayToWorld(QVector3D(0.0, 0.0, 0.1));
2154  QVector3D pt1 = _pView->getViewport().displayToWorld(QVector3D(200.0, 0.0, 0.1));
2155 
2156  double value = pt0.distanceToPoint(pt1);
2157 
2158  int i = floor(log10(value));
2159  int n = floor(value / pow(10, i));
2160  if (n == 3 || n == 4)
2161  {
2162  n = 5;
2163  }
2164  else if (n >= 6 && n <= 9)
2165  {
2166  n = 1;
2167  i++;
2168  }
2169  double distanceInRealWorld = n * pow(10, i);
2170  double distanceInDisplayWorld = 200.0 * distanceInRealWorld / value;
2171  QString max = QString().setNum(distanceInRealWorld, 'g', 3);
2172  QString mid = QString().setNum(distanceInRealWorld / 2, 'g', 3);
2173  _pOGLScalarBarElement->setTexts("0", mid.toStdString(), max.toStdString());
2174  _pOGLScalarBarElement->setSizes(distanceInDisplayWorld, 8);
2175  }
2176 }
2177 
2179 {
2180  _showScale = show;
2181 
2183 
2185  updateView(false, true);
2186 }
2187 
2188 double TYModelerFrame::getDouble(const QString& title, const QString& txt, double min, double max, double val,
2189  bool& ok, int dec)
2190 {
2191  QLocale loc = QLocale(QLocale::English);
2192  TYInputDialog dialog{};
2193  dialog.setLocale(loc); // Will use a dot
2194  dialog.setWindowTitle(title);
2195  dialog.setLabelText(txt);
2196  dialog.setDoubleRange(min, max);
2197  dialog.setTextValue(QString::number(val));
2198  dialog.setDoubleValue(val);
2199  dialog.setDoubleDecimals(dec);
2200  dialog.setInputMode(QInputDialog::TextInput);
2201  ok = dialog.exec();
2202  return dialog.doubleValue();
2203 }
All base classes related to 3D manipulation.
@ PERSPECTIVE
Definition: OGLCamera.h:42
@ PARALLEL
Definition: OGLCamera.h:41
@ FREE
Definition: OGLCamera.h:43
QColor getColor
gestion de l'interaction entre la vue graphique (2D ou 3D) et le clavier et la souris (fichier header...
TYApplication * getTYApp()
Retourne le pointeur sur l'application.
pour l'application Tympan (fichier header)
gestion de l'edition de la camera (fichier header)
#define min(a, b)
gestion de zoom par zone selectionnee (fichier obsolete)(fichier header)
outil de mesure des distances (fichier header)
gestion des elements selectionnes par picking (fichier header)
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:51
outil IHM pour une entrée utilisateur (fichier header)
#define IMG(id)
OBox getBoundingBox(TYElement *pElement)
#define TR(id)
Classe generique pour une fenetre de modeleur (fichier header)
Realise le rendu VTK et le rendu OpenGL (fichier header)
gestion de l'element actionne par picking (fichier header)
gestion de la position selon les modes 'moving', 'rotation', 'edition' (fichier header)
Boite de dialogue des parametres d'impression (fichier header)
const char * name
Repositionnement de la camera en fonction de coordonnees specifiees (fichier header)
Representation graphique d'une source lineique (fichier header)
Representation graphique d'une surface de source (fichier header)
The box class.
Definition: 3d.h:1346
OPoint3D _min
Minimal coordinates of the OBox.
Definition: 3d.h:1423
OPoint3D _max
Maximal coordinates of the OBox.
Definition: 3d.h:1424
Definition: color.h:31
float b
Definition: color.h:33
float r
Definition: color.h:33
float g
Definition: color.h:33
double _y
y coordinate of OCoord3D
Definition: 3d.h:283
double _z
z coordinate of OCoord3D
Definition: 3d.h:284
double _x
x coordinate of OCoord3D
Definition: 3d.h:282
void setFromToUp(const QVector3D &_from, const QVector3D &_to, const QVector3D &_up)
Definition: OGLCamera.cpp:296
void getTranslation(double &x, double &y, double &z)
Definition: OGLCamera.cpp:474
void resetZoom(int w=-1, int h=-1)
Definition: OGLCamera.cpp:417
void resetRotations()
Definition: OGLCamera.cpp:458
void setTranslation(double x, double y, double z)
Definition: OGLCamera.cpp:467
CameraType cameraType() const
Definition: OGLCamera.cpp:92
void setSize(int w, int h)
Definition: OGLCamera.cpp:78
void setDistanceStep(NxReal _magnitudeStepUp, NxReal _magnitudeStepFront, NxReal _magnitudeStepLeft)
Definition: OGLCamera.cpp:237
bool getVisibility()
Definition: OGLElement.h:55
void setVisibility(bool bVisible)
Definition: OGLElement.h:51
void setIs3D(bool bIs3D)
Definition: OGLElement.h:59
void setDisplayPosition(double displayPositionX, double displayPositionY)
Definition: OGLElement.h:46
bool getShowGridXZ()
bool getShowGridZY()
void setShowGridXZ(bool bShow)
void setGridDimX(const float gridDimX)
void setShowGridXY(bool bShow)
bool getShowGridXY()
void setGridDimY(const float gridDimY)
void setColor(const OColor &oColor)
void setShowGridZY(bool bShow)
void setGridStep(const float gridStep)
void setIntensity(const float intensity)
void init(int index, OPoint3D position, float intensity)
void setPoint2(const QVector3D &point2)
void setColor(const OColor &oColor)
void setLineWidth(float lineWidth)
void setPoint1(const QVector3D &point1)
void setSizes(float width, float height)
void setTexts(const std::string &text0, const std::string &text1, const std::string &text2)
void setFontColor(const OColor &oFontColor)
void setFont(const QString &qsFontPath)
void setPosition(const QVector3D &position)
void setColor(const OColor &oColor)
void setTextToDisplay(const QString &qsText)
void setFont(const QString &qsFontPath)
The 3D point class.
Definition: 3d.h:487
virtual const char * getClassName() const
Definition: TYElement.h:248
T * _pObj
The real pointer, must derived IRefCount.
Definition: smartptr.h:307
void setWheelStep(float step=1.0)
Met Ã&#160; jour le pas de zoom de la caméra.
virtual void close()
Appeler apres l'utilisation de l'editor.
static void snapToGrid(float &x, float &y, float &z, float &gridMagnStep)
Methode utilitaire qui adapte les coordonnees d'un point pour que celui-ci soit aligne avec la grille...
virtual void disconnect()
Deconnecte cet editor a l'interactor associe.
virtual void init()
Appeler avant l'utilisation de l'editor.
virtual void connect()
Connecte cet editor a l'interactor associe.
int getHistorySize()
Retourne la taille de l'historique.
void setHistorySize(int size)
Definit la taille de l'historique.
LPTYProjet getCurProjet()
Set/Get du projet courant.
TYCalculManager * getCalculManager()
Get du gestionnaire de calculs.
Definition: TYApplication.h:99
bool askForResetResultat()
Previent l'utilisateur que le resultat va etre efface, si celui-ci est valide.
QString getDateModif() const
Get modification date.
Definition: TYCalcul.h:199
bool isInSelection(TYUUID id)
Tests if the element is present in the selection of this Calculation.
Definition: TYCalcul.cpp:1004
QString getDateCreation() const
Set/Get of creation date.
Definition: TYCalcul.h:185
QString getComment() const
Get comments.
Definition: TYCalcul.h:218
Gestion de l'edition en mode camera.
void setMiddleButtonFunction3D(void(TYCameraEditor::*function)())
void setRightButtonFunction3D(void(TYCameraEditor::*function)())
void setShiftRightButtonFunction3D(void(TYCameraEditor::*function)())
void setNavigationOnViewType(int view)
Switch auto entre navi 2D ou 3D.
void setShiftRightButtonFunction2D(void(TYCameraEditor::*function)())
void setLeftButtonFunction3D(void(TYCameraEditor::*function)())
void setShiftLeftButtonFunction2D(void(TYCameraEditor::*function)())
void stopCameraZoom()
Force l'arrêt du mode zoom de la caméra.
void setShiftLeftButtonFunction3D(void(TYCameraEditor::*function)())
void setWheelStep(float step)
gestion de zoom par zone selectionnee (obsolete)
outil de mesure des distances
static bool _gDrawNormals
Indique si les normals doivent etre visible.
OBox boundingBox() const
static bool _gDrawPlafond
Indique si les plafonds doivent etre visible.
gestion des elements selectionnes par picking
TYElement * getParent() const
Definition: TYElement.h:706
virtual QString getName() const
Definition: TYElement.h:691
QString getModele() const
Definition: TYMachine.h:124
QString getCommentaire() const
Definition: TYMachine.h:139
int getCategorie() const
Definition: TYMachine.h:94
QString getConstructeur() const
Definition: TYMachine.h:109
virtual void wheelEvent(QWheelEvent *pEvent)
QToolButton * _pSnapGridBtn
Button to activate the magnetic grid.
void setSnapGridActive(bool state)
virtual void closeEvent(QCloseEvent *pEvent)
void updateElementGraphic(bool force=false)
virtual void leaveEvent(QEvent *pEvent)
int _curViewType
The type of the current view.
QStatusBar * _pStatusBar
Status bar.
virtual bool computeCurPos(int x, int y, float *pos)
TYCameraEditor * _pCameraEditor
Manages the camera.
void showScale(bool show)
bool _editorModeAccepted
Indicates if the editing mode has been processed.
OGLScalarBarElement * _pOGLScalarBarElement
Graphic object for representing the scale.
QToolButton * _pShowRaysBtn
Button for displaying rays calculated by ray tracing.
virtual void setRenderModeSlot(int mode)
LPTYElement _pElement
A pointer to the element to edit.
void showPlafond(bool show)
QToolButton * _pShowScale
Button for displaying the scale.
virtual void enterEvent(QEvent *pEvent)
TYPositionEditor * _pPositionEditor
Editor for moving elements.
void setEditorModeToCamera()
TYCameraZoneEditor * _pCameraZoneEditor
Editor to define a zoom area for the camera.
OGLTextElement * _pOGLTextElement
2D label to display the type of view.
virtual void resizeEvent(QResizeEvent *pEvent)
TYAbstractSceneEditor * _pCurrentEditor
The current editor.
void setKeepRays(bool keepRays)
virtual ~TYModelerFrame()
void editorModeChanged(int mode)
OGLLineElement * _pOGLLineElementAxeX
Geometry of the Axes.
void setGridLinesActorsVisibility(bool showGridXY, bool showGridXZ, bool showGridZY)
QToolButton * _pShowPlafondBtn
Button for displaying the ceiling of buildings.
void showRays(bool show)
void viewTypeChanged(int)
bool _wireframeOnMovingCamera
Indicates whether to switch to wireframe rendering during camera movement.
QToolButton * _pShowNormalsBtn
Button for displaying normals.
virtual void focusInEvent(QFocusEvent *pEvent)
bool _snapGridActive
Indicates whether or not to activate the magnetic grid.
void setWireframeOnMovingCamera(bool state)
TYActionManager _actionManager
For managing the history.
void aboutToClose()
OGLLightElement * _pLightElement
The default light.
bool getSnapGridActive()
QBoxLayout * _pCtrlLayout
The layout where buttons, etc., are located.
virtual void mouseMoveEvent(QMouseEvent *pEvent)
QGridLayout * _pLayout
The layout of this frame.
QToolButton * _pShowSourcesBtn
Button for displaying point sources.
OGLTextElement * _pOGLTextElementLabelY
virtual void setViewType(int view)
OGLLineElement * _pOGLLineElementX
X and Y axes of the grid.
QStatusBar * statusBar()
QToolButton * _pGridBtn
Button to activate the grid.
bool isElementInCurrentProjet()
OGLGridElement * _pOGLGridElement
TYRenderWindowInteractor * _pView
The graphics window.
void frameResized()
QToolButton * _pCopyBtn
Button for taking a screenshot.
virtual bool close()
virtual float getDefaultZCoord()
Returns default Z coordinate for editors This value will depend on the type of modeler and of the fix...
bool _showPlafond
Indicates whether or not to display or hide the ceiling of buildings.
void showNormals(bool show)
OGLLineElement * _pOGLLineElementAxeZ
QComboBox * _pRenderModeBox
Combo box for rendering mode.
OGLTextElement * _pOGLTextElementLabelX
TYOpenGLRenderer::RenderMode getRenderMode()
bool _showGrid
Indicates whether to display the grid or not.
TYModelerFrame(QWidget *parent=0, const char *name=0, Qt::WindowFlags f=Qt::SubWindow)
bool _showNormals
Indicates whether or not to display or hide normals.
void setCameraCoordinates()
OGLTextElement * _pOGLTextElementLabelZ
bool isElementInCurrentCalcul()
bool askForResetResultat()
bool _showScale
Indicates whether to display the scale or not.
void eltModified(LPTYElement pElt)
int _lastEditorMode
To keep track of the last editing mode.
QToolButton * _pSetCameraCoordinatesBtn
Button to specify camera coordinates.
TYOpenGLRenderer::RenderMode _lastRenderMode
The last current rendering mode.
OGLLineElement * _pOGLLineElementAxeY
void updateCurPosInfo(int x, int y)
float _gridDimX
Grid dimension in X.
float _gridDimY
Grid dimension in Y.
void startMovingRenderMode()
TYElementPicker * _pPicker
For picking.
virtual void setRenderMode(TYOpenGLRenderer::RenderMode mode, bool bUpdateGL)
OGLCamera * _pOGLCameras[NbOfViews]
Cameras for each type of view.
float _gridStep
Grid step.
virtual void updatePreferences()
bool _showRays
Indicates whether or not to display rays.
TYPickEditor * _pPickEditor
Manages the context menu.
OGLLineElement * _pOGLLineElementY
float _gridMagnStep
Magnetic grid step.
QToolButton * _pScreenShotBtn
Button for saving a screenshot.
TYPickEditor * getPickEditor()
virtual void keyPressEvent(QKeyEvent *pEvent)
TYDistanceEditor * _pDistanceEditor
Tools for measuring.
virtual void setEditorMode(int mode)
void showGrid(bool show)
virtual void updateView(bool clipping=true, bool axesAndGrid=true)
virtual void showEvent(QShowEvent *pEvent)
virtual void keyReleaseEvent(QKeyEvent *pEvent)
static double getDouble(const QString &title, const QString &txt, double min, double max, double val, bool &ok, int dec=2)
float _defaultZCoord
Default Z coordinate for editors.
TYOpenGLRenderer * getRenderer()
bool _showSources
Indicates whether or not to display point sources.
QComboBox * _pViewTypeBox
Combo box for selecting the current camera.
void addLight(OGLLightElement *pOGLElementLight)
void addOGLElement(OGLElement *pOGLElement)
void invalidateScene(void)
void removeOGLElement(OGLElement *pOGLElement)
void setBackground(double *bgColor)
void setRenderMode(RenderMode mode)
gestion de l'element actionne par picking
Definition: TYPickEditor.h:40
void usePopup(bool state)
Definition: TYPickEditor.h:104
void setPickTolerance(float tolerance)
Definition: TYPickEditor.h:59
void useHighlight(bool state)
Definition: TYPickEditor.h:97
gestion de la position selon les modes 'moving', 'rotation', 'edition'
void setMode(int mode)
void setPickPointPrecision(float precision)
void setAngleStep(float step)
classe pour une boite de dialogue des parametres d'impression.
Definition: TYPrintDialog.h:51
QGroupBox * _groupBoxSite
Definition: TYPrintDialog.h:80
QCheckBox * _checkBoxCatMachine
Definition: TYPrintDialog.h:73
QCheckBox * _checkBoxDateProjet
Definition: TYPrintDialog.h:64
QCheckBox * _checkBoxNomProjet
Definition: TYPrintDialog.h:65
QCheckBox * _checkBoxNomBatiment
Definition: TYPrintDialog.h:77
QCheckBox * _checkBoxNomSite
Definition: TYPrintDialog.h:75
QCheckBox * _checkBoxDateCalcul
Definition: TYPrintDialog.h:68
QCheckBox * _checkBoxCommentCalcul
Definition: TYPrintDialog.h:67
QGroupBox * _groupBoxMachine
Definition: TYPrintDialog.h:78
QCheckBox * _checkBoxNomCalcul
Definition: TYPrintDialog.h:69
QGroupBox * _groupBoxCalcul
Definition: TYPrintDialog.h:66
QLineEdit * _lineEditPied
Definition: TYPrintDialog.h:83
QLineEdit * _lineEditTete
Definition: TYPrintDialog.h:84
QCheckBox * _checkBoxCommentProjet
Definition: TYPrintDialog.h:62
QCheckBox * _checkBoxNomMachine
Definition: TYPrintDialog.h:72
QCheckBox * _checkBoxModelMachine
Definition: TYPrintDialog.h:74
QGroupBox * _groupBoxProjet
Definition: TYPrintDialog.h:61
QGroupBox * _groupBoxBatiment
Definition: TYPrintDialog.h:79
QLineEdit * _lineEditTitre
Definition: TYPrintDialog.h:86
QCheckBox * _checkBoxAuteurProjet
Definition: TYPrintDialog.h:63
QCheckBox * _checkBoxConstrMachine
Definition: TYPrintDialog.h:71
classe de definition d'un projet.
Definition: TYProjet.h:45
QString getDateModif() const
Get de la date de modification.
Definition: TYProjet.h:131
QString getAuteur() const
Get du nom de l'auteur.
Definition: TYProjet.h:93
QString getComment() const
Get des commentaires.
Definition: TYProjet.h:150
QString getDateCreation() const
Get de la date de creation.
Definition: TYProjet.h:112
LPTYSiteNode getSite()
Get du site.
Definition: TYProjet.h:169
LPTYCalcul getCurrentCalcul()
Set/Get du pointeur du Calcul courant.
Definition: TYProjet.h:426
static bool _gVisible
Indique si toutes les instances sont visibles.
Definition: TYRayGraphic.h:75
QVector3D worldToDisplay(const QVector3D &world) const
QVector3D displayToWorld(const QVector3D &display) const
Le role de cette classe est limite a emettre des signaux pouvant etre utilise pour interagir sur le r...
void mouseMoved(int x, int y, Qt::MouseButtons button, Qt::KeyboardModifiers state)
void setActiveCamera(OGLCamera *pCamera)
const TYRenderViewport & getViewport() const
void showInfos(bool state)
TYOpenGLRenderer * getRenderer()
OGLCamera * getActiveCamera()
Repositionnement de la camera en fonction de coordonnees specifiees.
static bool _gVisible
Indique si toutes les instances sont visibles.
static bool _gVisible
Indique si toutes les instances sont visibles.