Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYModelerFrame.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 #ifdef _MSC_VER
22  #pragma warning(disable : 4503)
23 #endif
24 
25 #include <math.h>
26 #include <qlayout.h>
27 #include <qstring.h>
28 #include <qcursor.h>
29 #include <qcombobox.h>
30 #include <qcheckbox.h>
31 #include <qlineedit.h>
32 #include <qstatusbar.h>
33 #include <qimage.h>
34 #include <qpixmap.h>
35 #include <qmenu.h>
36 #include <qfiledialog.h>
37 #include <qslider.h>
38 #include <qlabel.h>
39 #include <qprinter.h>
40 #include <qpainter.h>
41 #include <qgroupbox.h>
42 #include <qclipboard.h>
43 #include <qmessagebox.h>
44 #include <qtoolbutton.h>
45 // Added by qt3to4:
46 #include <QResizeEvent>
47 #include <QWheelEvent>
48 #include <QFocusEvent>
49 #include <QMouseEvent>
50 #include <QCloseEvent>
51 #include <QGridLayout>
52 #include <QShowEvent>
53 #include <QKeyEvent>
54 #include <QHBoxLayout>
55 #include <QEvent>
56 #include <QImageWriter>
57 #include <QPrintDialog>
58 
87 #include "TYModelerFrame.h"
88 
89 #define TR(id) OLocalizator::getString("TYModelerFrame", (id))
90 #define IMG(id) OLocalizator::getPicture("TYModelerFrame", (id))
91 
92 using namespace Qt;
93 
94 // Couleurs
95 static double gridColor[] = {0.59, 0.41, 0.42};
96 static double fontColor[] = {0.1, 0.43, 0.37};
97 static double rendererColor[] = {0.91, 0.91, 0.91};
98 
99 TYModelerFrame::TYModelerFrame(QWidget* parent, const char* name, Qt::WindowFlags f)
100  : QWidget(parent, f), _actionManager(10)
101 {
102  setObjectName(name);
103 
104  setAttribute(Qt::WA_DeleteOnClose);
105 
106  // L'element associe a ce modeler
107  _pElement = NULL;
108 
109  // Flag pour la sauvegarde des settings
110  _firstTimeShown = true;
111 
112  // Init des membres pour les editors
113  _pCurrentEditor = NULL;
115  _editorModeAccepted = false;
116 
117  // Init des membres pour la grille
118  _showGrid = false;
119 
121 
122  // Le focus se fait avec la touche tab ou la souris
123  setFocusPolicy(StrongFocus);
124 
125  // Pour pouvoir afficher la position courante du curseur
126  setMouseTracking(true);
127 
128  // Layout
129  _pLayout = new QGridLayout();
130  _pLayout->setRowStretch(0, 0);
131  _pLayout->setRowStretch(1, 1);
132  _pLayout->setRowStretch(2, 0);
133  setLayout(_pLayout);
134 
135  // Initialisation des parametres de la grille.
136  _gridDimX = 200;
137  _gridDimY = 200;
138  _gridStep = 5;
139  _gridMagnStep = 1;
140 
141  // Widgets
142  _pCtrlLayout = new QHBoxLayout();
143  _pLayout->addLayout(_pCtrlLayout, 0, 0);
144  _pCtrlLayout->setSpacing(5);
145 
146  // Disambiguate the overloaded signal QComboBox::activated
147  void (QComboBox::*_qComboBox_activated)(int) = &QComboBox::activated;
148 
149  // Combo box type de Vue
150  _pViewTypeBox = new QComboBox(this);
151  _pCtrlLayout->addWidget(_pViewTypeBox, 0);
152  _pViewTypeBox->insertItem(TopView, TR("id_top_view"));
153  _pViewTypeBox->insertItem(LeftView, TR("id_left_view"));
154  _pViewTypeBox->insertItem(FrontView, TR("id_front_view"));
155  _pViewTypeBox->insertItem(PerspView, TR("id_3d_view"));
156  _pViewTypeBox->insertItem(FreeView, TR("id_free_view"));
157  connect(_pViewTypeBox, _qComboBox_activated, this, &TYModelerFrame::setViewType);
158 
159  // Combo box mode de Rendu
160  _pRenderModeBox = new QComboBox(this);
161  _pCtrlLayout->addWidget(_pRenderModeBox, 0);
162  _pRenderModeBox->insertItem(Points, TR("id_points_mode"));
163  _pRenderModeBox->insertItem(Wireframe, TR("id_wireframe_mode"));
164  _pRenderModeBox->insertItem(Surface, TR("id_surface_mode"));
165  connect(_pRenderModeBox, _qComboBox_activated, this, &TYModelerFrame::setRenderModeSlot);
166 
167  _pCtrlLayout->addSpacing(7);
168 
169  // Btn Fit
170  QToolButton* pFitBtn = new QToolButton(this);
171  pFitBtn->setIcon(QPixmap(IMG("id_icon_fit_btn")));
172  pFitBtn->setText(TR("id_fit_btn"));
173  pFitBtn->setToolTip(TR("id_fit_btn"));
174  pFitBtn->setFixedSize(24, 24);
175  connect(pFitBtn, &QToolButton::clicked, this, &TYModelerFrame::fit);
176  _pCtrlLayout->addWidget(pFitBtn, 0);
177 
178  // Btn Grille
179  _pGridBtn = new QToolButton(this);
180  _pGridBtn->setIcon(QPixmap(IMG("id_icon_grid_btn")));
181  _pGridBtn->setText(TR("id_grid_btn"));
182  _pGridBtn->setToolTip(TR("id_grid_btn"));
183  _pGridBtn->setCheckable(true);
184  _pGridBtn->setChecked(true);
185  _pGridBtn->setFixedSize(24, 24);
186  _pCtrlLayout->addWidget(_pGridBtn, 0);
187  connect(_pGridBtn, &QToolButton::toggled, this, &TYModelerFrame::showGrid);
188 
189  // Btn Show echelle.
190  // L'echelle est mise a jour a la fin de chaque deplacement de camera (cf. TYCameraEditor)
191  _showScale = true;
192  _pShowScale = new QToolButton(this);
193  _pShowScale->setIcon(QPixmap(IMG("id_icon_show_scale_btn")));
194  _pShowScale->setText(TR("id_show_scale_btn"));
195  _pShowScale->setToolTip(TR("id_show_scale_btn"));
196  _pShowScale->setCheckable(true);
197  _pShowScale->setChecked(_showScale);
198  _pShowScale->setFixedSize(24, 24);
199  _pCtrlLayout->addWidget(_pShowScale, 0);
200  connect(_pShowScale, &QToolButton::toggled, this, &TYModelerFrame::showScale);
201 
202  // Btn Grille Magnetique
203  _pSnapGridBtn = new QToolButton(this);
204  _pSnapGridBtn->setIcon(QPixmap(IMG("id_icon_snapgrid_btn")));
205  _pSnapGridBtn->setText(TR("id_snapgrid_btn"));
206  _pSnapGridBtn->setToolTip(TR("id_snapgrid_btn"));
207  _pSnapGridBtn->setCheckable(true);
208  _pSnapGridBtn->setFixedSize(24, 24);
209  _pCtrlLayout->addWidget(_pSnapGridBtn, 0);
210  connect(_pSnapGridBtn, &QToolButton::toggled, this, &TYModelerFrame::setSnapGridActive);
211  setSnapGridActive(true);
212 
213  // Btn set camera coordinates
214  _pSetCameraCoordinatesBtn = new QToolButton(this);
215  _pSetCameraCoordinatesBtn->setIcon(QPixmap(IMG("id_icon_setcameracoordinates_btn")));
216  _pSetCameraCoordinatesBtn->setText(TR("id_setcameracoordinates_btn"));
217  _pSetCameraCoordinatesBtn->setToolTip(TR("id_setcameracoordinates_btn"));
218  _pSetCameraCoordinatesBtn->setFixedSize(24, 24);
220  connect(_pSetCameraCoordinatesBtn, &QToolButton::clicked, this, &TYModelerFrame::setCameraCoordinates);
221 
222  _pCtrlLayout->addSpacing(7);
223 
224  // Btn d'edition de l'element
225  QToolButton* pEditEltBtn = new QToolButton(this);
226  pEditEltBtn->setIcon(QPixmap(IMG("id_icon_editeelt_btn")));
227  pEditEltBtn->setText(TR("id_editelt_btn"));
228  pEditEltBtn->setToolTip(TR("id_editelt_btn"));
229  pEditEltBtn->setFixedSize(24, 24);
230  _pCtrlLayout->addWidget(pEditEltBtn, 0);
231  connect(pEditEltBtn, &QToolButton::clicked, this, &TYModelerFrame::editElement);
232 
233  _pCtrlLayout->addSpacing(7);
234 
235  // Btn Screenshot
236  _pScreenShotBtn = new QToolButton(this);
237  _pScreenShotBtn->setIcon(QPixmap(IMG("id_icon_screenshot_btn")));
238  _pScreenShotBtn->setText(TR("id_screenshot_btn"));
239  _pScreenShotBtn->setToolTip(TR("id_screenshot_btn"));
240  _pScreenShotBtn->setFixedSize(24, 24);
241  connect(_pScreenShotBtn, &QToolButton::clicked, this, &TYModelerFrame::screenShot);
242  _pCtrlLayout->addWidget(_pScreenShotBtn, 0);
243 
244  // Btn Copy
245  QToolButton* pCopyBtn = new QToolButton(this);
246  pCopyBtn->setIcon(QPixmap(IMG("id_icon_copy_btn")));
247  pCopyBtn->setText(TR("id_copy_btn"));
248  pCopyBtn->setToolTip(TR("id_copy_btn"));
249  pCopyBtn->setFixedSize(24, 24);
250  connect(pCopyBtn, &QToolButton::clicked, this, &TYModelerFrame::copy);
251  _pCtrlLayout->addWidget(pCopyBtn, 0);
252 
253  _pCtrlLayout->addSpacing(7);
254 
255  // Btn Show Sources
256  _pShowSourcesBtn = new QToolButton(this);
257  _pShowSourcesBtn->setIcon(QPixmap(IMG("id_icon_source")));
258  _pShowSourcesBtn->setText(TR("id_show_source_btn"));
259  _pShowSourcesBtn->setToolTip(TR("id_show_source_btn"));
260  _pShowSourcesBtn->setCheckable(true);
261  _pShowSourcesBtn->setChecked(false);
262  _pShowSourcesBtn->setFixedSize(24, 24);
263  _pCtrlLayout->addWidget(_pShowSourcesBtn, 0);
264  connect(_pShowSourcesBtn, &QToolButton::toggled, this, &TYModelerFrame::showSources);
265  showSources();
266 
267  // Btn Show Normals
268  _pShowNormalsBtn = new QToolButton(this);
269  _pShowNormalsBtn->setIcon(QPixmap(IMG("id_icon_normals")));
270  _pShowNormalsBtn->setText(TR("id_show_normals_btn"));
271  _pShowNormalsBtn->setToolTip(TR("id_show_normals_btn"));
272  _pShowNormalsBtn->setCheckable(true);
273  _pShowNormalsBtn->setChecked(false);
274  _pShowNormalsBtn->setFixedSize(24, 24);
275  _pCtrlLayout->addWidget(_pShowNormalsBtn, 0);
276  connect(_pShowNormalsBtn, &QToolButton::toggled, this, &TYModelerFrame::showNormals);
277  showNormals(_pShowNormalsBtn->isChecked());
278 
279  // Btn Show Plafond
280  _pShowPlafondBtn = new QToolButton(this);
281  _pShowPlafondBtn->setIcon(QPixmap(IMG("id_icon_plafond")));
282  _pShowPlafondBtn->setText(TR("id_show_plafond_btn"));
283  _pShowPlafondBtn->setToolTip(TR("id_show_plafond_btn"));
284  _pShowPlafondBtn->setCheckable(true);
285  _pShowPlafondBtn->setChecked(false);
286  _pShowPlafondBtn->setFixedSize(24, 24);
287  _pCtrlLayout->addWidget(_pShowPlafondBtn, 0);
288  connect(_pShowPlafondBtn, &QToolButton::toggled, this, &TYModelerFrame::showPlafond);
289  showPlafond(_pShowPlafondBtn->isChecked());
290 
291  // Btn Show Rayons
292  _pShowRaysBtn = new QToolButton(this);
293  _pShowRaysBtn->setIcon(QPixmap(IMG("id_icon_rays")));
294  _pShowRaysBtn->setText(TR("id_show_rays_btn"));
295  _pShowRaysBtn->setToolTip(TR("id_show_rays_btn"));
296 
297  _pShowRaysBtn->setCheckable(true);
298  _pShowRaysBtn->setChecked(false);
299  _pShowRaysBtn->setFixedSize(24, 24);
300  _pCtrlLayout->addWidget(_pShowRaysBtn, 0);
301  connect(_pShowRaysBtn, &QToolButton::toggled, this, &TYModelerFrame::showRays);
302  showRays(_pShowRaysBtn->isChecked());
303 
304  // Vue graphique
305  _pView = new TYRenderWindowInteractor(this, "vue graphique");
306  _pLayout->addWidget(_pView, 1, 0);
307 
309 
310  // Status bar
311  _pStatusBar = new QStatusBar(this);
312  _pLayout->addWidget(_pStatusBar, 2, 0);
313 
314  // Cameras pour chaque type de vue
315  NxReal fromTop[3] = {0, 500, 0};
316  NxReal toTop[3] = {0, 0, 0};
317  NxReal upTop[3] = {0, 0, -1};
318  _pOGLCameras[TopView] = new OGLCamera(fromTop, toTop, upTop, 100, 100, PARALLEL);
319 
320  NxReal fromLeft[3] = {-500, 0, 0};
321  NxReal toLeft[3] = {0, 0, 0};
322  NxReal upLeft[3] = {0, 1, 0};
323  _pOGLCameras[LeftView] = new OGLCamera(fromLeft, toLeft, upLeft, 100, 100, PARALLEL);
324 
325  NxReal fromFront[3] = {0, 0, 500};
326  NxReal toFront[3] = {0, 0, 0};
327  NxReal upFront[3] = {0, 1, 0};
328  _pOGLCameras[FrontView] = new OGLCamera(fromFront, toFront, upFront, 100, 100, PARALLEL);
329 
330  NxReal fromPersp[3] = {0, 10000, 10000};
331  NxReal toPersp[3] = {0, 0, 0};
332  NxReal upPersp[3] = {0, 1, 0};
333  _pOGLCameras[PerspView] = new OGLCamera(fromPersp, toPersp, upPersp, 100, 100, PERSPECTIVE);
334 
335  NxReal fromFree[3] = {0, 0, 0};
336  NxReal toFree[3] = {0, 0, 0.1};
337  NxReal upFree[3] = {0, 1, 0};
338  _pOGLCameras[FreeView] = new OGLCamera(fromFree, toFree, upFree, 100, 100, FREE);
339 
340  // Triedre XYZ
353 
356  _pOGLTextElementLabelX->setFont(IMG("id_font_bold"));
357  OColor oColor;
358  oColor.r = fontColor[0];
359  oColor.g = fontColor[1];
360  oColor.b = fontColor[2];
363 
366  _pOGLTextElementLabelY->setFont(IMG("id_font_bold"));
369 
372  _pOGLTextElementLabelZ->setFont(IMG("id_font_bold"));
375 
382 
383  // Label
386  _pOGLTextElement->setFont(IMG("id_font_bold"));
387  _pOGLTextElement->setColor(oColor);
390 
391 #ifndef NO_GRID
392  // Construction de la grille
394  _pOGLGridElement->setColor(OColor(gridColor[0], gridColor[1], gridColor[2]));
396  _pOGLGridElement->setIs3D(true);
398 #endif // NO_GRID
399 
400  // Axes de la grille
402  _pOGLLineElementX->setPoint1(OPoint3D(-100, 0, 0));
403  _pOGLLineElementX->setPoint2(OPoint3D(100, 0, 0));
404  _pOGLLineElementX->setColor(OColor(0, 0, 0));
406  _pOGLLineElementX->setIs3D(true);
408 
410  _pOGLLineElementY->setPoint1(OPoint3D(0, -100, 0));
411  _pOGLLineElementY->setPoint2(OPoint3D(0, 100, 0));
412  _pOGLLineElementY->setColor(OColor(0, 0, 0));
414  _pOGLLineElementY->setIs3D(true);
416 
419 
420  // Echelle
425  _pOGLScalarBarElement->setFont(IMG("id_font"));
427  _pOGLScalarBarElement->setTexts("0", "0", "0");
430 
431  // Lumieres
433  _pLightElement->init(0, OPoint3D(0.0, 400.0, 0.0), 1.0f);
435 
436  // Couleur de fond
437  getRenderer()->setBackground(rendererColor);
438 
439  // Type de rendu
440  setRenderMode(Surface, true);
441 
442  _wireframeOnMovingCamera = false;
444 
445  // Gestion du picking
446  _pPicker = new TYElementPicker(this);
447 
448  // Init chaque view
449  for (int i = 0; i < NbOfViews; i++)
450  {
451  setViewType(i);
452  }
453 
454  // Editors
455  _pCameraEditor = new TYCameraEditor(this);
459 
460  // Le pick editor
461  _pPickEditor = new TYPickEditor(this);
463 
464  // Mode d'edition
466 
467  // Init chaque view
468  // for (int i = 0; i < NbOfViews; i++)
469  // {
470  // setViewType(i);
471  // }
472 
473  resizeGrid();
474  showGrid(_pGridBtn->isChecked());
475  showScale(_pShowScale->isChecked());
476 
478 
479  // Chargement des preferences
481 
482  showMaximized();
483  _pOGLTextElement->setDisplayPosition(5, rect().bottom() - rect().top());
484 }
485 
487 {
488 
489  // Disambiguate the overloaded signal QComboBox::activated
490  void (QComboBox::*_qComboBox_activated)(int) = &QComboBox::activated;
491 
492  disconnect(_pViewTypeBox, _qComboBox_activated, this, &TYModelerFrame::setViewType);
493  disconnect(_pRenderModeBox, _qComboBox_activated, this, &TYModelerFrame::setRenderModeSlot);
494  disconnect(_pGridBtn, &QToolButton::toggled, this, &TYModelerFrame::showGrid);
495  disconnect(_pShowScale, &QToolButton::toggled, this, &TYModelerFrame::showScale);
496  disconnect(_pSnapGridBtn, &QToolButton::toggled, this, &TYModelerFrame::setSnapGridActive);
497  disconnect(_pSetCameraCoordinatesBtn, &QToolButton::clicked, this, &TYModelerFrame::setCameraCoordinates);
498  disconnect(_pScreenShotBtn, &QToolButton::clicked, this, &TYModelerFrame::screenShot);
499  disconnect(_pShowSourcesBtn, &QToolButton::toggled, this, &TYModelerFrame::showSources);
500  disconnect(_pShowNormalsBtn, &QToolButton::toggled, this, &TYModelerFrame::showNormals);
501  disconnect(_pShowPlafondBtn, &QToolButton::toggled, this, &TYModelerFrame::showPlafond);
502  disconnect(_pShowRaysBtn, &QToolButton::toggled, this, &TYModelerFrame::showRays);
504 
505  delete _pCameraEditor;
506  delete _pCameraZoneEditor;
507  delete _pDistanceEditor;
508  delete _pPositionEditor;
509  delete _pPickEditor;
510  delete _pPicker;
511 
512  for (int i = 0; i < NbOfViews; i++)
513  {
514  delete _pOGLCameras[i];
515  _pOGLCameras[i] = NULL;
516  }
517 
519  delete _pOGLLineElementAxeX;
521  delete _pOGLLineElementAxeY;
523  delete _pOGLLineElementAxeZ;
525  delete _pOGLTextElementLabelX;
527  delete _pOGLTextElementLabelY;
529  delete _pOGLTextElementLabelZ;
530 
532  delete _pOGLTextElement;
534  delete _pOGLScalarBarElement;
536  delete _pOGLLineElementX;
538  delete _pOGLLineElementY;
539 
540 #ifndef NO_GRID
542  delete _pOGLGridElement;
543 #endif // NO_GRID
545  delete _pLightElement;
546  delete _pView;
547  _pView = nullptr;
548 }
549 
551 {
552  return QWidget::close();
553 }
554 
556 {
557  bool ret = false;
558 
559  if (getTYApp()->getCurProjet() && getTYApp()->getCurProjet()->getCurrentCalcul() && _pElement)
560  {
561  // L'element fait-il parti de la selection du calcul courant ?
563  }
564 
565  return ret;
566 }
567 
569 {
570  bool ret = false;
571 
572  if (getTYApp()->getCurProjet() && _pElement)
573  {
574  // On commence directement a partir de l'element lui-meme
575  TYElement* pParent = _pElement;
576 
577  while (pParent)
578  {
579  // Le parent est le projet courant ?
580  if (pParent == getTYApp()->getCurProjet())
581  {
582  ret = true;
583  break;
584  }
585  // Parent du parent
586  pParent = pParent->getParent();
587  }
588  }
589 
590  return ret;
591 }
592 
594 {
595  bool ret = true;
596 
598  {
600  }
601 
602  return ret;
603 }
604 
606 {
607  if (view >= NbOfViews)
608  {
609  return;
610  }
611 
612  // View type
613  _curViewType = view;
614 
615  bool showGridXY = false;
616  bool showGridXZ = false;
617  bool showGridZY = false;
618  QString labelStr;
619 
620  // Pre traitement selon la vue activee
621  switch (view)
622  {
623  case TopView:
624  showGridXZ = _showGrid;
625  labelStr = TR("id_top_view");
626  _pSetCameraCoordinatesBtn->setEnabled(false);
627  break;
628  case LeftView:
629  showGridZY = _showGrid;
630  labelStr = TR("id_left_view");
631  _pSetCameraCoordinatesBtn->setEnabled(false);
632  break;
633  case FrontView:
634  showGridXY = _showGrid;
635  labelStr = TR("id_front_view");
636  _pSetCameraCoordinatesBtn->setEnabled(false);
637  break;
638  case PerspView:
639  showGridXZ = _showGrid;
640  labelStr = TR("id_3d_view");
641  _pSetCameraCoordinatesBtn->setEnabled(false);
642  break;
643  case FreeView:
644  showGridXZ = _showGrid;
645  labelStr = TR("id_free_view");
646  _pSetCameraCoordinatesBtn->setEnabled(true);
647  break;
648  default:
649  break;
650  }
651 
652  //_pView->setFocus();
653 
654  // Affichage de la grille correspondant au type de vue
655  setGridLinesActorsVisibility(showGridXY, showGridXZ, showGridZY);
656 
657  // Label
659 
660  // Camera
662  getRenderer()->init(_pView->width(), _pView->height());
663 
664  // Update l'element associe a ce modeler
665  if (_pElement)
666  {
667  _pElement->updateGraphicTree();
668  _pElement->getGraphicObject()->update(true);
669  }
670 
672  // Updates
673  updateView();
674 
675  _pViewTypeBox->setCurrentIndex(_curViewType);
677 }
678 
680 {
681  setRenderMode(mode, true);
682 }
683 
684 void TYModelerFrame::setRenderMode(int mode, bool bUpdateGL)
685 {
686  if (mode >= NbOfRenderMode)
687  {
688  return;
689  }
690 
691  // Mode
692  _curRenderMode = mode;
693 
694  if (mode == Points)
695  {
696  glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
697  }
698  else if (mode == Wireframe)
699  {
700  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
701  }
702  else if (mode == Surface)
703  {
704  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
705  }
706  else if (mode == Flat)
707  {
708  glShadeModel(GL_FLAT);
709  }
710  else if (mode == Gouraud)
711  {
712  glShadeModel(GL_SMOOTH);
713  }
714 
715  _pRenderModeBox->setCurrentIndex(_curRenderMode);
716 
717  if (bUpdateGL == true)
718  {
719  _pView->updateGL();
720  }
721 }
722 
724 {
725  if (!_editorModeAccepted)
726  {
727  getPickEditor()->usePopup(true);
728  getPickEditor()->useHighlight(false);
729 
730  if (_pCurrentEditor)
731  {
734  }
735 
736  _editorModeAccepted = true;
737 
738  switch (mode)
739  {
740  case CameraMode:
741  // fit();
742  getPickEditor()->useHighlight(true);
744  break;
745  case CameraZoneMode:
746  getPickEditor()->useHighlight(true);
748  break;
749  case DistanceMode:
751  break;
752  case MovingMode:
755  break;
756  case RotationMode:
759  break;
760  case EditionMode:
763  break;
764  case NoMode:
765  default:
766  getPickEditor()->useHighlight(true);
767  _pCurrentEditor = NULL;
768  mode = NoMode;
769  _editorModeAccepted = false;
770  break;
771  }
772  }
773 
774  // On sauve le mode courant
775  _lastEditorMode = mode;
776 
777  // Init
778  if (_pCurrentEditor)
779  {
782  }
783 
784  // Pour la prochaine requete
785  _editorModeAccepted = false;
786 
787  // The bug goes by here...
788  emit(editorModeChanged(mode));
789 }
790 
792 {
793  _showGrid = show;
794 
797 
798  _pGridBtn->setChecked(_showGrid);
799 
801  // Update
803 }
804 
806 {
807  _showSources = _pShowSourcesBtn->isChecked();
808 
811  {
812 
813  TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
814 
817 
818  if (_pElement && _pElement->getGraphicObject())
819  {
820  // Update l'element associe a ce modeler
821  _pElement->getGraphicObject()->update(true);
822 
824 
825  // Update view
826  updateView();
827  }
828 
829  TYApplication::restoreOverrideCursor();
830  }
831 
832  _pShowSourcesBtn->setChecked(_showSources);
833 }
834 
836 {
837  _showRays = show;
839  {
840 
841  TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
842 
844 
845  if (_pElement && _pElement->getGraphicObject())
846  {
847  // Update l'element associe a ce modeler
848  _pElement->getGraphicObject()->update(true);
849 
851 
852  // Update view
853  updateView();
854  }
855 
856  TYApplication::restoreOverrideCursor();
857  }
858 
859  _pShowRaysBtn->setChecked(_showRays);
860 }
861 
863 {
864  _showNormals = show;
865 
867  {
868 
869  TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
870 
872 
873  if (_pElement && _pElement->getGraphicObject())
874  {
875  // Update l'element associe a ce modeler
876  _pElement->getGraphicObject()->update(true);
877 
879 
880  // Update view
881  updateView();
882  }
883 
884  TYApplication::restoreOverrideCursor();
885  }
886 
887  _pShowNormalsBtn->setChecked(_showNormals);
888 }
889 
891 {
892  _showPlafond = !show; // inversion entre l'etat variable et du bouton
893 
895  {
896 
897  TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
898 
900 
901  if (_pElement && _pElement->getGraphicObject())
902  {
903  // Update l'element associe a ce modeler
904  _pElement->getGraphicObject()->update(true);
905 
907 
908  // Update view
909  updateView();
910  }
911 
912  TYApplication::restoreOverrideCursor();
913  }
914 
915  _pShowPlafondBtn->setChecked(!_showPlafond);
916 }
917 
919 {
920  _snapGridActive = state;
921  _pSnapGridBtn->setChecked(_snapGridActive);
922 }
923 
925 {
926  if ((getRenderer()->getActiveCamera()) && (getRenderer()->getActiveCamera()->m_eCameraType == FREE))
927  {
928  TYSetCameraCoordinates* pSetCameraCoordinates = new TYSetCameraCoordinates(this);
929  double x = NAN, y = NAN, z = NAN;
931  pSetCameraCoordinates->setXCoord(x);
932  pSetCameraCoordinates->setYCoord(-z);
933  pSetCameraCoordinates->setZCoord(y);
934  pSetCameraCoordinates->exec();
935 
936  if (pSetCameraCoordinates->result() == QDialog::Accepted)
937  {
938  if (getRenderer()->getActiveCamera())
939  {
940  getRenderer()->getActiveCamera()->setTranslation(pSetCameraCoordinates->getXCoord(),
941  pSetCameraCoordinates->getZCoord(),
942  -pSetCameraCoordinates->getYCoord());
943 
944  // Update view
945  updateView();
946  }
947  }
948  }
949 }
950 
952 {
953  QMenu* pMenu = new QMenu(NULL);
954 
955  QHash<QAction*, QString> formats;
956 
957  for (unsigned int i = 0; i < QImageWriter::supportedImageFormats().count(); i++)
958  {
959  QString str = QString(QImageWriter::supportedImageFormats().at(i));
960  formats.insert(pMenu->addAction(QString("%1...").arg(str)), QString(str));
961  }
962 
963  pMenu->setMouseTracking(true);
964  QAction* id = pMenu->exec(_pScreenShotBtn->mapToGlobal(QPoint(0, _pScreenShotBtn->height() + 1)));
965 
966  if (id)
967  {
968  QString format = formats[id];
969 
970  QString filename =
971  QFileDialog::getSaveFileName(this, "", QString(), QString("*.%1").arg(format.toLower()));
972  if (!filename.isEmpty())
973  {
974  // Prefixe
975  if (!filename.endsWith(format.toLower()))
976  {
977  filename += "." + format.toLower();
978  }
979 
980  // Restauration des deux buffers
981  _pView->repaint();
982  _pView->repaint();
983  qApp->processEvents();
984 
985  // Snap
986  QImage img = _pView->grabFrameBuffer();
987 
988  // Save
989  QPixmap pix = QPixmap::fromImage(img);
990  pix.save(filename, format.toLatin1().data(), 80); // qualite 80 (de 0 a 100)
991  }
992  }
993 
994  delete pMenu;
995 }
996 
998 {
999  // Snap
1000  QImage img = _pView->grabFrameBuffer();
1001 
1002  // Copie dans le presse papier
1003  QClipboard* clipboard = QApplication::clipboard();
1004  clipboard->setImage(img);
1005 }
1006 
1008 {
1009  LPTYProjet pProjet = getTYApp()->getCurProjet();
1010  LPTYCalcul pCalcul = NULL;
1011  if (pProjet)
1012  {
1013  pCalcul = pProjet->getCurrentCalcul();
1014  }
1015 
1016  // Print dialog
1017  TYPrintDialog* pDialog = new TYPrintDialog(this);
1018 
1019  if (pProjet == NULL)
1020  {
1021  pDialog->_groupBoxProjet->setEnabled(false);
1022  }
1023  if (pCalcul == NULL)
1024  {
1025  pDialog->_groupBoxCalcul->setEnabled(false);
1026  }
1027 
1028  if (_pElement)
1029  {
1030  if (dynamic_cast<TYBatiment*>(_pElement._pObj) != nullptr)
1031  {
1032  pDialog->_groupBoxBatiment->show();
1033  }
1034  else if (dynamic_cast<TYMachine*>(_pElement._pObj) != nullptr)
1035  {
1036  pDialog->_groupBoxMachine->show();
1037  }
1038  else if (dynamic_cast<TYSiteNode*>(_pElement._pObj) != nullptr)
1039  {
1040  pDialog->_groupBoxSite->show();
1041  }
1042  }
1043 
1044  if (pDialog->exec() == QDialog::Accepted)
1045  {
1046  QPrinter* printer = new QPrinter();
1047 
1048  QPrintDialog dialog(printer, this);
1049  if (dialog.exec())
1050  {
1051  QPainter paint(printer);
1052 
1053  double w = double(printer->width());
1054  double h = double(printer->height());
1055  double scalew = w / 700;
1056  double scaleh = h / 700;
1057 
1058  // Snap
1059  QImage img = _pView->grabFrameBuffer();
1060  img = img.scaled(int(w * 9 / 10), int(h * 2 / 3), Qt::KeepAspectRatio, Qt::SmoothTransformation);
1061  int x = int(double(printer->width() - img.width()) / 2);
1062  int y = int(double(printer->height() - img.height()) * 1 / 3);
1063  QPixmap pm = QPixmap::fromImage(img);
1064  paint.drawPixmap(x, y, pm);
1065 
1066  paint.setFont(QFont("Times", (int)(10 * scaleh)));
1067  int mid =
1068  int(w / 2) - int(paint.fontMetrics().horizontalAdvance(pDialog->_lineEditTete->text()) / 2);
1069  paint.drawText(mid, 20, pDialog->_lineEditTete->text());
1070 
1071  mid = int(w / 2) - int(paint.fontMetrics().horizontalAdvance(pDialog->_lineEditPied->text()) / 2);
1072  paint.drawText(mid, printer->height() - 20, pDialog->_lineEditPied->text());
1073 
1074  paint.setFont(QFont("Times", (int)(15 * scaleh), QFont::Bold));
1075  mid =
1076  int(w / 2) - int(paint.fontMetrics().horizontalAdvance(pDialog->_lineEditTitre->text()) / 2);
1077  paint.drawText(mid, y - 20, pDialog->_lineEditTitre->text());
1078 
1079  x = int(50 * scalew);
1080  int x1 = int(w / 2);
1081  y = int(double(printer->height()) * 2 / 3 + 20 * scaleh);
1082  int stepy = int(10 * scaleh);
1083  paint.setFont(QFont("Times", (int)(10 * scaleh)));
1084 
1085  if (pProjet)
1086  {
1087  if (pDialog->_checkBoxNomProjet->isChecked())
1088  {
1089  paint.drawText(x, y, TR("id_print_nom_projet"));
1090  paint.drawText(x1, y, pProjet->getName());
1091  y += stepy;
1092  }
1093  if (pDialog->_checkBoxAuteurProjet->isChecked())
1094  {
1095  paint.drawText(x, y, TR("id_print_auteur_projet"));
1096  paint.drawText(x1, y, pProjet->getAuteur());
1097  y += stepy;
1098  }
1099  if (pDialog->_checkBoxDateProjet->isChecked())
1100  {
1101  paint.drawText(x, y, TR("id_print_date_creation"));
1102  paint.drawText(x1, y, pProjet->getDateCreation());
1103  y += stepy;
1104  paint.drawText(x, y, TR("id_print_date_modif"));
1105  paint.drawText(x1, y, pProjet->getDateModif());
1106  y += stepy;
1107  }
1108  if (pDialog->_checkBoxCommentProjet->isChecked())
1109  {
1110  paint.drawText(x, y, TR("id_print_comment"));
1111  paint.drawText(x1, y, pProjet->getComment());
1112  y += stepy;
1113  }
1114  }
1115 
1116  if (pCalcul)
1117  {
1118  y += int(double(stepy) * 1.5);
1119  if (pDialog->_checkBoxNomCalcul->isChecked())
1120  {
1121  paint.drawText(x, y, TR("id_print_nom_calcul"));
1122  paint.drawText(x1, y, pCalcul->getName());
1123  y += stepy;
1124  }
1125  if (pDialog->_checkBoxDateCalcul->isChecked())
1126  {
1127  paint.drawText(x, y, TR("id_print_date_creation"));
1128  paint.drawText(x1, y, pCalcul->getDateCreation());
1129  y += stepy;
1130  paint.drawText(x, y, TR("id_print_date_modif"));
1131  paint.drawText(x1, y, pCalcul->getDateModif());
1132  y += stepy;
1133  }
1134  if (pDialog->_checkBoxCommentCalcul->isChecked())
1135  {
1136  paint.drawText(x, y, TR("id_print_comment"));
1137  paint.drawText(x1, y, pCalcul->getComment());
1138  y += stepy;
1139  }
1140  }
1141 
1142  if (_pElement)
1143  {
1144  y += int(double(stepy) * 1.5);
1145  TYElement* pElement = (TYElement*)_pElement;
1146  if (strcmp(_pElement->getClassName(), "TYBatiment") == 0)
1147  {
1148  TYBatiment* pBatiment = (TYBatiment*)pElement;
1149  if (pDialog->_checkBoxNomBatiment->isChecked())
1150  {
1151  paint.drawText(x, y, TR("id_print_nom_batiment"));
1152  paint.drawText(x1, y, pBatiment->getName());
1153  }
1154  }
1155  else if (strcmp(_pElement->getClassName(), "TYMachine") == 0)
1156  {
1157  TYMachine* pMachine = (TYMachine*)pElement;
1158  if (pDialog->_checkBoxNomMachine->isChecked())
1159  {
1160  paint.drawText(x, y, TR("id_print_nom_machine"));
1161  paint.drawText(x1, y, pMachine->getName());
1162  y += stepy;
1163  }
1164  if (pDialog->_checkBoxConstrMachine->isChecked())
1165  {
1166  paint.drawText(x, y, TR("id_print_constr"));
1167  paint.drawText(x1, y, pMachine->getConstructeur());
1168  y += stepy;
1169  }
1170  if (pDialog->_checkBoxModelMachine->isChecked())
1171  {
1172  paint.drawText(x, y, TR("id_print_model"));
1173  paint.drawText(x1, y, pMachine->getModele());
1174  y += stepy;
1175  }
1176  if (pDialog->_checkBoxCatMachine->isChecked())
1177  {
1178  paint.drawText(x, y, TR("id_print_cat"));
1179  paint.drawText(x1, y, QString().setNum(pMachine->getCategorie()));
1180  y += stepy;
1181  }
1182  if (pDialog->_checkBoxCommentProjet->isChecked())
1183  {
1184  paint.drawText(x, y, TR("id_print_comment"));
1185  paint.drawText(x1, y, pMachine->getCommentaire());
1186  }
1187  }
1188  else
1189  {
1190  TYSiteNode* pSite = dynamic_cast<TYSiteNode*>(pElement);
1191  if (pSite != nullptr)
1192  {
1193  if (pDialog->_checkBoxNomSite->isChecked())
1194  {
1195  paint.drawText(x, y, TR("id_print_nom_site"));
1196  paint.drawText(x1, y, pSite->getName());
1197  }
1198  }
1199  }
1200  }
1201  }
1202 
1203  delete printer;
1204  }
1205 }
1206 
1208 {
1209  if (_pElement)
1210  {
1211  if (_pElement->edit(this) == QDialog::Accepted)
1212  {
1213  emit eltModified(_pElement);
1214  }
1215 
1216  // On update ds ts les cas si un child a ete modifie...
1217  _pElement->getGraphicObject()->update(true);
1219  updateView(false, false);
1220  }
1221 }
1222 
1224 {
1225  // XBH: version simplifiee et +logique...
1226 
1227  OBox boundingBox;
1228  LPTYElementGraphic pTYElementGraphic = pElement->getGraphicObject();
1229 
1230  if (pTYElementGraphic != NULL)
1231  {
1232  pTYElementGraphic->computeBoundingBox();
1233  boundingBox = pTYElementGraphic->GetBox();
1234  }
1235 
1236  return boundingBox;
1237 }
1238 
1240 {
1241  OBox globalBoundingBox;
1242  if (_pElement)
1243  {
1244  TYElement* pTYElement = (TYElement*)_pElement;
1245  TYProjet* pTYProjet = dynamic_cast<TYProjet*>(pTYElement);
1246  if (pTYProjet != nullptr)
1247  {
1248  TYSiteNode* pTYSiteNode = (TYSiteNode*)pTYProjet->getSite();
1249  pTYElement = pTYSiteNode;
1250  }
1251 
1252  globalBoundingBox = getBoundingBox(pTYElement);
1253  }
1254  return globalBoundingBox;
1255 }
1256 
1258 {
1259  int visibilityStates[9];
1260 
1261  // Sauvegarde des etats de visibilite des objets graphiques
1262  // de "decoration", ils ne doivent pas participer au recadrage
1263 #ifndef NO_GRID
1264  visibilityStates[0] = _pOGLGridElement->getShowGridXY();
1265  visibilityStates[1] = _pOGLGridElement->getShowGridXZ();
1266  visibilityStates[2] = _pOGLGridElement->getShowGridZY();
1267 #endif // NO_GRID
1268 
1269  setGridLinesActorsVisibility(false, false, false);
1270 
1271  visibilityStates[3] = _pOGLLineElementAxeX->getVisibility();
1275  visibilityStates[4] = _pOGLTextElementLabelX->getVisibility();
1277  visibilityStates[5] = _pOGLTextElementLabelY->getVisibility();
1279  visibilityStates[6] = _pOGLTextElementLabelZ->getVisibility();
1281 
1282  visibilityStates[7] = _pOGLLineElementX->getVisibility();
1284  visibilityStates[8] = _pOGLLineElementY->getVisibility();
1286 
1287  // az-- : pour tests reperes machines:
1288  OBox globalBoundingBox = getGlobalBoundingBox();
1289 
1290  float xMin = globalBoundingBox._min._x;
1291  float xMax = globalBoundingBox._max._x;
1292  float yMin = globalBoundingBox._min._y;
1293  float yMax = globalBoundingBox._max._y;
1294  float zMin = globalBoundingBox._min._z;
1295  float zMax = globalBoundingBox._max._z;
1296  float xDist = max(abs(xMin), abs(xMax)) * 2;
1297  float yDist = max(abs(yMin), abs(yMax)) * 2;
1298  float zDist = max(abs(zMin), abs(zMax)) * 2;
1299 
1300  // Cameras pour chaque type de vue
1301  NxReal fromTop[3] = {0, 500, 0};
1302  NxReal toTop[3] = {0, 0, 0};
1303  NxReal upTop[3] = {0, 0, -1};
1304  _pOGLCameras[TopView]->setFromToUp(fromTop, toTop, upTop);
1306  _pOGLCameras[TopView]->resetZoom(xDist, yDist);
1307 
1308  NxReal fromLeft[3] = {-500, 0, 0};
1309  NxReal toLeft[3] = {0, 0, 0};
1310  NxReal upLeft[3] = {0, 1, 0};
1311  _pOGLCameras[LeftView]->setFromToUp(fromLeft, toLeft, upLeft);
1312  _pOGLCameras[LeftView]->resetZoom(yDist, zDist);
1313 
1314  NxReal fromFront[3] = {0, 0, 500};
1315  NxReal toFront[3] = {0, 0, 0};
1316  NxReal upFront[3] = {0, 1, 0};
1317  _pOGLCameras[FrontView]->setFromToUp(fromFront, toFront, upFront);
1318  _pOGLCameras[FrontView]->resetZoom(xDist, zDist);
1319 
1320  NxReal fromPersp[3] = {0, 1000, 1000};
1321  NxReal toPersp[3] = {0, 0, 0};
1322  NxReal upPersp[3] = {0, 1, 0};
1323  _pOGLCameras[PerspView]->setFromToUp(fromPersp, toPersp, upPersp);
1324  _pOGLCameras[PerspView]->resetZoom(xDist, yDist);
1326  _pOGLCameras[PerspView]->setDistanceStep(30, 70, 30);
1327 
1328  NxReal fromFree[3] = {0, 0, 0};
1329  NxReal toFree[3] = {0, 0, 0.1};
1330  NxReal upFree[3] = {0, 1, 0};
1331  _pOGLCameras[FreeView]->setFromToUp(fromFree, toFree, upFree);
1336 
1337  // Restauration des etats de visibilite des objets graphiques
1338 #ifndef NO_GRID
1339  setGridLinesActorsVisibility(visibilityStates[0], visibilityStates[1], visibilityStates[2]);
1340 #endif // NO_GRID
1341  _pOGLLineElementAxeX->setVisibility(visibilityStates[3]);
1342  _pOGLLineElementAxeY->setVisibility(visibilityStates[3]);
1343  _pOGLLineElementAxeZ->setVisibility(visibilityStates[3]);
1344  _pOGLTextElementLabelX->setVisibility(visibilityStates[4]);
1345  _pOGLTextElementLabelY->setVisibility(visibilityStates[5]);
1346  _pOGLTextElementLabelZ->setVisibility(visibilityStates[6]);
1347  _pOGLLineElementX->setVisibility(visibilityStates[7]);
1348  _pOGLLineElementY->setVisibility(visibilityStates[8]);
1349 
1351  updateView();
1352 }
1353 
1354 void TYModelerFrame::updateView(bool clipping /*=true*/, bool axesAndGrid /*=true*/)
1355 {
1356  // first look at to update camera positions
1357  if (getRenderer()->getActiveCamera())
1358  {
1360  glMatrixMode(GL_MODELVIEW);
1361 
1362  if (axesAndGrid)
1363  {
1364  updateAxes();
1365  updateGrid();
1366  updateCurPosInfo();
1367  updateScale();
1368  }
1369 
1370  if (clipping)
1371  {
1372  // Update le render mode
1373  setRenderMode(getRenderMode(), false);
1374  }
1375 
1376  _pOGLTextElement->setDisplayPosition(7, rect().bottom() - rect().top() - 88);
1377  _pOGLScalarBarElement->setPosition(OPoint3D(rect().right() - rect().left() - 100, 50, 0));
1379 
1380  // RNU
1381  //_pView->getRenderer()->updateDisplayList();
1382 
1383  // Update la vue 3D
1384  _pView->updateGL();
1385  }
1386 }
1387 
1389 {
1396 
1397  NxVec3 org = OGLCamera::displayToWorld(NxVec3(50, 50, 0.1));
1398  OCoord3D origine(org.x, org.y, org.z);
1399 
1400  _pOGLLineElementAxeX->setPoint1(OPoint3D(org.x, org.y, org.z));
1401  _pOGLLineElementAxeY->setPoint1(OPoint3D(org.x, org.y, org.z));
1402  _pOGLLineElementAxeZ->setPoint1(OPoint3D(org.x, org.y, org.z));
1403 
1404  NxVec3 extX, extY, extZ;
1405 
1406  switch (getCurrentView())
1407  {
1408  case TopView:
1409  {
1410  extX = OGLCamera::displayToWorld(NxVec3(90, 50, 0.1));
1411  extY = OGLCamera::displayToWorld(NxVec3(50, 90, 0.1));
1412  extZ = OGLCamera::displayToWorld(NxVec3(50, 50, 40.1));
1416  }
1417  break;
1418  case LeftView:
1419  {
1420  extX = OGLCamera::displayToWorld(NxVec3(50, 50, 40.1));
1421  extY = OGLCamera::displayToWorld(NxVec3(10, 50, 0.1));
1422  extZ = OGLCamera::displayToWorld(NxVec3(50, 90, 0.1));
1426  }
1427  break;
1428  case FrontView:
1429  {
1430  extX = OGLCamera::displayToWorld(NxVec3(90, 50, 0.1));
1431  extY = OGLCamera::displayToWorld(NxVec3(50, 50, 40.1));
1432  extZ = OGLCamera::displayToWorld(NxVec3(50, 90, 0.1));
1436  }
1437  break;
1438  case PerspView:
1439  case FreeView:
1440  {
1441  NxVec3 org2 = OGLCamera::displayToWorld(NxVec3(50, 90, 0.1));
1442  double dist = org.distance(org2);
1443  extX.x = org.x + dist;
1444  extX.y = org.y;
1445  extX.z = org.z;
1446  extY.x = org.x;
1447  extY.y = org.y;
1448  extY.z = org.z - dist;
1449  extZ.x = org.x;
1450  extZ.y = org.y + dist;
1451  extZ.z = org.z;
1452 
1453  NxVec3 dispX = OGLCamera::worldToDisplay(extX);
1454  NxVec3 dispY = OGLCamera::worldToDisplay(extY);
1455  NxVec3 dispZ = OGLCamera::worldToDisplay(extZ);
1456 
1460  }
1461  break;
1462  }
1463 
1464  OPoint3D extremiteX(extX.x, extX.y, extX.z);
1465  OPoint3D extremiteY(extY.x, extY.y, extY.z);
1466  OPoint3D extremiteZ(extZ.x, extZ.y, extZ.z);
1467 
1468  _pOGLLineElementAxeX->setPoint2(extremiteX);
1469  _pOGLLineElementAxeY->setPoint2(extremiteY);
1470  _pOGLLineElementAxeZ->setPoint2(extremiteZ);
1471 }
1472 
1473 void TYModelerFrame::keyPressEvent(QKeyEvent* pEvent)
1474 {
1475  switch (pEvent->key())
1476  {
1477  case Qt::Key_1:
1479  break;
1480  case Qt::Key_2:
1482  break;
1483  case Qt::Key_3:
1485  break;
1486  case Qt::Key_4:
1488  break;
1489  case Qt::Key_5:
1491  break;
1492  case Qt::Key_V:
1494  break;
1495  case Qt::Key_I:
1497  break;
1498  case Qt::Key_G:
1499  showGrid(!_showGrid);
1500  break;
1501  case Qt::Key_R:
1502  setRenderMode((getRenderMode() + 1) % NbOfRenderMode, true);
1503  break;
1504  case Qt::Key_W:
1505  setRenderMode(Wireframe, true);
1506  break;
1507  case Qt::Key_S:
1508  setRenderMode(Surface, true);
1509  break;
1510  case Qt::Key_Control:
1511  setSnapGridActive(false);
1512  break;
1513  case Qt::Key_C:
1514  if (pEvent->modifiers() == Qt::ControlModifier)
1515  {
1516  copy();
1517  }
1518  else
1519  {
1521  }
1522  break;
1523  case Qt::Key_F:
1524  case Qt::Key_F5:
1525  fit();
1526  break;
1527  default:
1528  TYApplication::sendEvent(_pView, pEvent);
1529  }
1530 }
1531 
1532 void TYModelerFrame::keyReleaseEvent(QKeyEvent* pEvent)
1533 {
1534  switch (pEvent->key())
1535  {
1536  case Qt::Key_Control:
1537  setSnapGridActive(true);
1538  break;
1539  default:
1540  TYApplication::sendEvent(_pView, pEvent);
1541  }
1542 }
1543 
1544 void TYModelerFrame::mouseMoveEvent(QMouseEvent* pEvent) {}
1545 
1547 {
1548  // On recupere la pos du curseur
1549  QPoint curPos = _pView->mapFromGlobal(QCursor::pos());
1550 
1551  // Calcul des coords
1552  float* pos = new float[3];
1553 
1554  if (computeCurPos(curPos.x(), curPos.y(), pos))
1555  {
1556  // Si la grille magnetique est activee
1557  if (getSnapGridActive())
1558  {
1559  TYAbstractSceneEditor::snapToGrid(pos[0], pos[1], pos[2], _gridMagnStep);
1560  }
1561 
1562  // Formatage du msg
1563  QString msg("pos : (%1, %2, %3)");
1564  // On inverse y et z, et -y... (VTK to TY)
1565  msg = msg.arg(pos[0], 0, 'f', 2).arg(-pos[2], 0, 'f', 2).arg(pos[1], 0, 'f', 2);
1566  // Affichage
1567  statusBar()->showMessage(msg);
1568  }
1569  else
1570  {
1571  if (getCurrentView() == FreeView)
1572  {
1573  double x = NAN, y = NAN, z = NAN;
1575  QString msg = QString("camera pos : (%1, %2, %3)").arg(x).arg(-z).arg(y);
1576  statusBar()->showMessage(msg);
1577  }
1578  else
1579  {
1580  statusBar()->showMessage("");
1581  }
1582  }
1583 
1584  delete[] pos;
1585 }
1586 
1587 // float* TYModelerFrame::computeCurPos(int x, int y)
1588 bool TYModelerFrame::computeCurPos(int x, int y, float* ret)
1589 {
1590  int view = getCurrentView();
1591  if ((view != PerspView) && (view != FreeView))
1592  {
1593  // Position du curseur
1594  NxVec3 pos = OGLCamera::displayToWorld(NxVec3(x, _pView->height() - y, 0));
1595  ret[0] = pos.x;
1596  ret[1] = pos.y;
1597  ret[2] = pos.z;
1598 
1599  switch (getCurrentView())
1600  {
1601  case TopView:
1602  ret[1] = 0.0;
1603  break;
1604  case LeftView:
1605  ret[0] = 0.0;
1606  break;
1607  case FrontView:
1608  ret[2] = 0.0;
1609  break;
1610  }
1611 
1612  return true;
1613  }
1614 
1615  return false;
1616 }
1617 
1618 void TYModelerFrame::setGridLinesActorsVisibility(bool showGridXY, bool showGridXZ, bool showGridZY)
1619 {
1620 #ifndef NO_GRID
1621  _pOGLGridElement->setShowGridXY(showGridXY);
1622  _pOGLGridElement->setShowGridXZ(showGridXZ);
1623  _pOGLGridElement->setShowGridZY(showGridZY);
1624 #endif // NO_GRID
1625 }
1626 
1627 void TYModelerFrame::wheelEvent(QWheelEvent* pEvent)
1628 {
1629  // Reroute l'event sur le TYRenderWindowInteractor
1630  TYApplication::sendEvent(_pView, pEvent);
1631 }
1632 
1633 void TYModelerFrame::resizeEvent(QResizeEvent* pEvent)
1634 {
1635  /* _pView->getRenderer()->updateDisplayList();
1636  updateView();
1637  _pView->getRenderer()->updateDisplayList();*/
1638  updateView();
1639 
1640  // CLM-NT33 : Gestion du maximized et titre fenetre principal
1641  emit frameResized();
1642 }
1643 
1644 void TYModelerFrame::focusInEvent(QFocusEvent* pEvent)
1645 {
1646  /* _pView->getRenderer()->updateDisplayList();
1647  updateView();
1648  _pView->getRenderer()->updateDisplayList();*/
1649  updateView();
1650 }
1651 
1652 void TYModelerFrame::showEvent(QShowEvent* pEvent)
1653 {
1654  if (_firstTimeShown)
1655  {
1656  TYPreferenceManager::loadGeometryFromPreferences(metaObject()->className(), this);
1657  _firstTimeShown = false;
1658  }
1659  /* _pView->getRenderer()->updateDisplayList();
1660  updateView();
1661  _pView->getRenderer()->updateDisplayList();*/
1662  updateView();
1663 }
1664 
1665 void TYModelerFrame::closeEvent(QCloseEvent* pEvent)
1666 {
1667  TYPreferenceManager::saveGeometryToPreferences(metaObject()->className(), this);
1668  pEvent->accept();
1669  emit frameResized();
1670  emit aboutToClose();
1671 
1672  // CLM-NT35 : Gestion du maximized et titre fenetre principal
1673 }
1674 
1675 void TYModelerFrame::enterEvent(QEvent* pEvent)
1676 {
1677  /* _pView->getRenderer()->updateDisplayList();
1678  updateView();
1679  _pView->getRenderer()->updateDisplayList();
1680  updateView();*/
1681  emit mouseEnter();
1682 }
1683 
1684 void TYModelerFrame::leaveEvent(QEvent* pEvent)
1685 {
1686  emit mouseLeave();
1687 }
1688 
1690 {
1691  if ((getCurrentView() == PerspView) || (getCurrentView() == FreeView))
1692  {
1695 
1698  }
1699  else
1700  {
1701  int gridXMax = _pView->width();
1702  int gridYMax = _pView->height();
1703  if (gridXMax == 0)
1704  {
1705  gridXMax = 100;
1706  }
1707  if (gridYMax == 0)
1708  {
1709  gridYMax = 100;
1710  }
1711 
1712  // getCenter
1713  NxVec3 center = OGLCamera::worldToDisplay(NxVec3(0, 0, 0));
1714 
1715  // X
1716  NxVec3 posX = OGLCamera::displayToWorld(NxVec3(center.x, 0, 0));
1717  NxVec3 posX2 = OGLCamera::displayToWorld(NxVec3(center.x, gridYMax, 0));
1718  OPoint3D pt1(posX.x, posX.y, posX.z);
1720  OPoint3D pt2(posX2.x, posX2.y, posX2.z);
1721  if ((pt1._x != pt2._x) || (pt1._y != pt2._y) || (pt1._z != pt2._z))
1722  {
1723  _pOGLLineElementX->setPoint2(OPoint3D(posX2.x, posX2.y, posX2.z));
1724  OVector3D vecX(pt1, pt2);
1725  }
1726 
1727  // Y
1728  NxVec3 posY = OGLCamera::displayToWorld(NxVec3(0, center.y, 0));
1729  NxVec3 posY2 = OGLCamera::displayToWorld(NxVec3(gridXMax, center.y, 0));
1730  pt1.setCoords(posY.x, posY.y, posY.z);
1732  pt2.setCoords(posY2.x, posY2.y, posY2.z);
1733  if ((pt1._x != pt2._x) || (pt1._y != pt2._y) || (pt1._z != pt2._z))
1734  {
1736  OVector3D vecY(pt1, pt2);
1737  }
1738  }
1739 }
1740 
1741 void TYModelerFrame::updateElementGraphic(bool force /* = false */)
1742 {
1743  if (_pElement && _pElement->getGraphicObject())
1744  {
1745  _pElement->getGraphicObject()->update(force);
1746  }
1747 }
1748 
1750 {
1754 
1755  _pOGLLineElementX->setColor(OColor(gridColor[0], gridColor[1], gridColor[2]));
1756  _pOGLLineElementY->setColor(OColor(gridColor[0], gridColor[1], gridColor[2]));
1757 }
1758 
1760 {
1761  // Mise a jour de la taille de l'historique de l'Action Manager
1762  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "HistoSize"))
1763  {
1764  _actionManager.setHistorySize(TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "HistoSize"));
1765  }
1766  else
1767  {
1768  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "HistoSize", _actionManager.getHistorySize());
1769  }
1770 
1771  // Mise a jour de l'etat d'activation du delplacement de camera en mode Wireframe
1772  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "WireframeOnMovingCamera"))
1773  {
1775  TYPreferenceManager::getBool(TYDIRPREFERENCEMANAGER, "WireframeOnMovingCamera"));
1776  }
1777  else
1778  {
1779  TYPreferenceManager::setBool(TYDIRPREFERENCEMANAGER, "WireframeOnMovingCamera", false);
1781  }
1782 
1783  // Mise a jour des couleurs a partir des preferences.
1784  // Couleur de fond
1785  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "BackgroundColorR"))
1786  {
1787  float r = NAN, g = NAN, b = NAN;
1788  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "BackgroundColor", r, g, b);
1789  rendererColor[0] = r / 255;
1790  rendererColor[1] = g / 255;
1791  rendererColor[2] = b / 255;
1792  }
1793  else
1794  {
1795  float r = rendererColor[0] * 255;
1796  float g = rendererColor[1] * 255;
1797  float b = rendererColor[2] * 255;
1798  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "BackgroundColor", r, g, b);
1799  }
1800 
1801  getRenderer()->setBackground(rendererColor);
1802 
1803  // Couleur de la grille
1804  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridColorR"))
1805  {
1806  float r = NAN, g = NAN, b = NAN;
1807  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "GridColor", r, g, b);
1808  gridColor[0] = r / 255;
1809  gridColor[1] = g / 255;
1810  gridColor[2] = b / 255;
1811  }
1812  else
1813  {
1814  float r = gridColor[0] * 255;
1815  float g = gridColor[1] * 255;
1816  float b = gridColor[2] * 255;
1817  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "GridColor", r, g, b);
1818  }
1819 
1820  // Couleur de la police
1821  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "FontColorR"))
1822  {
1823  float r = NAN, g = NAN, b = NAN;
1824  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "FontColor", r, g, b);
1825  fontColor[0] = r / 255;
1826  fontColor[1] = g / 255;
1827  fontColor[2] = b / 255;
1828  }
1829  else
1830  {
1831  float r = fontColor[0] * 255;
1832  float g = fontColor[1] * 255;
1833  float b = fontColor[2] * 255;
1834  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "FontColor", r, g, b);
1835  }
1836 
1840  _pOGLScalarBarElement->setFontColor(OColor(fontColor[0], fontColor[1], fontColor[2]));
1841 
1842  // Mise a jour de l'eclairage de la scene.
1843  float intensity = 0.83f;
1844  if ((TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "Luminosite")))
1845  {
1846  intensity = TYPreferenceManager::getDouble(TYDIRPREFERENCEMANAGER, "Luminosite");
1847  }
1848  else
1849  {
1850  TYPreferenceManager::setDouble(TYDIRPREFERENCEMANAGER, "Luminosite", intensity);
1851  }
1852 
1853  if (intensity < 0.1f)
1854  {
1855  intensity = 0.1f;
1856  }
1857  _pLightElement->setIntensity(intensity);
1858 
1859  // Mise a jour de la tolerance du picking.
1860  float precisPick = 3.0;
1861  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "PrecisPick"))
1862  {
1863  precisPick = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "PrecisPick");
1864  }
1865  else
1866  {
1867  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "PrecisPick", precisPick);
1868  }
1869  _pPickEditor->setPickTolerance(precisPick);
1871 
1872  // Mise a jour du pas de zoom de la mollette de la souris.
1873  float zoomStep = 0.2f;
1874  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "ZoomStep"))
1875  {
1876  zoomStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "ZoomStep");
1877  }
1878  else
1879  {
1880  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "ZoomStep", zoomStep);
1881  }
1882  _pCameraEditor->setWheelStep(zoomStep);
1883 
1884  // Mise a jour du pas de l'angle du positionEditor
1885  float angle = 15.0;
1886  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "Angle"))
1887  {
1888  angle = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "Angle");
1889  }
1890  else
1891  {
1892  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "Angle", angle);
1893  }
1894 
1896 
1897  // Mise a jour des fonctions attachees a la souris.
1898  // 2D
1899  // bouton gauche
1900  int mouseLeftButtonFunct2D = 1;
1901  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct2D"))
1902  {
1903  mouseLeftButtonFunct2D =
1904  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct2D");
1905  }
1906 
1907  else
1908  {
1909  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct2D", mouseLeftButtonFunct2D);
1910  }
1911 
1912  switch (mouseLeftButtonFunct2D)
1913  {
1914  case 0:
1916  break;
1917  case 1:
1919  break;
1920  }
1921 
1922  // bouton droit
1923  int mouseRightButtonFunct2D = 0;
1924  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct2D"))
1925  {
1926  mouseRightButtonFunct2D =
1927  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct2D");
1928  }
1929  else
1930  {
1931  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct2D",
1932  mouseRightButtonFunct2D);
1933  }
1934 
1935  switch (mouseRightButtonFunct2D)
1936  {
1937  case 0:
1939  break;
1940  case 1:
1942  break;
1943  }
1944 
1945  // bouton central
1946  int mouseMiddleButtonFunct2D = 0;
1947  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct2D"))
1948  {
1949  mouseMiddleButtonFunct2D =
1950  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct2D");
1951  }
1952  else
1953  {
1954  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct2D",
1955  mouseMiddleButtonFunct2D);
1956  }
1957 
1958  switch (mouseMiddleButtonFunct2D)
1959  {
1960  case 0:
1962  break;
1963  case 1:
1965  break;
1966  }
1967 
1968  // en 3D
1969  // bouton gauche
1970  int mouseLeftButtonFunct3D = 3;
1971  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct3D"))
1972  {
1973  mouseLeftButtonFunct3D =
1974  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct3D");
1975  }
1976  else
1977  {
1978  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct3D", mouseLeftButtonFunct3D);
1979  }
1980 
1981  switch (mouseLeftButtonFunct3D)
1982  {
1983  case 0:
1985  break;
1986  case 1:
1988  break;
1989  case 2:
1991  break;
1992  case 3:
1994  break;
1995  }
1996 
1997  // bouton droit
1998  int mouseRightButtonFunct3D = 0;
1999  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct3D"))
2000  {
2001  mouseRightButtonFunct3D =
2002  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct3D");
2003  }
2004  else
2005  {
2006  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct3D",
2007  mouseRightButtonFunct3D);
2008  }
2009 
2010  switch (mouseRightButtonFunct3D)
2011  {
2012  case 0:
2014  break;
2015  case 1:
2017  break;
2018  case 2:
2020  break;
2021  case 3:
2023  break;
2024  }
2025 
2026  // bouton central
2027  int mouseMiddleButtonFunct3D = 2;
2028  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct3D"))
2029  {
2030  mouseMiddleButtonFunct3D =
2031  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct3D");
2032  }
2033  else
2034  {
2035  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct3D",
2036  mouseMiddleButtonFunct3D);
2037  }
2038 
2039  switch (mouseMiddleButtonFunct3D)
2040  {
2041  case 0:
2043  break;
2044  case 1:
2046  break;
2047  case 2:
2049  break;
2050  case 3:
2052  break;
2053  }
2054 
2055  // Mode shift.
2056  // 2D
2057  // bouton gauche
2058  int mouseShiftLeftButtonFunct2D = 1;
2059  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct2D"))
2060  {
2061  mouseShiftLeftButtonFunct2D =
2062  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct2D");
2063  }
2064  else
2065  {
2066  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct2D",
2067  mouseShiftLeftButtonFunct2D);
2068  }
2069 
2070  switch (mouseShiftLeftButtonFunct2D)
2071  {
2072  case 0:
2074  break;
2075  case 1:
2077  break;
2078  }
2079 
2080  // bouton droit
2081  int mouseShiftRightButtonFunct2D = 0;
2082  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct2D"))
2083  {
2084  mouseShiftRightButtonFunct2D =
2085  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct2D");
2086  }
2087  else
2088  {
2089  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct2D",
2090  mouseShiftRightButtonFunct2D);
2091  }
2092 
2093  switch (mouseShiftRightButtonFunct2D)
2094  {
2095  case 0:
2097  break;
2098  case 1:
2100  break;
2101  }
2102 
2103  // en 3D
2104  // bouton gauche
2105  int mouseShiftLeftButtonFunct3D = 1;
2106  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct3D"))
2107  {
2108  mouseShiftLeftButtonFunct3D =
2109  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct3D");
2110  }
2111  else
2112  {
2113  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct3D",
2114  mouseShiftLeftButtonFunct3D);
2115  }
2116 
2117  switch (mouseShiftLeftButtonFunct3D)
2118  {
2119  case 0:
2121  break;
2122  case 1:
2124  break;
2125  case 2:
2127  break;
2128  case 3:
2130  break;
2131  }
2132 
2133  // bouton droit
2134  int mouseShiftRightButtonFunct3D = 2;
2135  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct3D"))
2136  {
2137  mouseShiftRightButtonFunct3D =
2138  TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct3D");
2139  }
2140  else
2141  {
2142  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct3D",
2143  mouseShiftRightButtonFunct3D);
2144  }
2145 
2146  switch (mouseShiftRightButtonFunct3D)
2147  {
2148  case 0:
2150  break;
2151  case 1:
2153  break;
2154  case 2:
2156  break;
2157  case 3:
2159  break;
2160  }
2161 
2162  // Force un update de la camera
2164 
2165  // Update de l'editor courant
2166  // setEditorMode(_lastEditorMode); // DTn : Correction du bug #0009661
2167 
2168  // Mets a jour la structure graphique de l'element
2169  updateElementGraphic(true);
2170 
2171  // Refresh
2172  updateView(false);
2173 }
2174 
2176 {
2177  // On passe en mode Wireframe si l'option est activee et qu'on est
2178  // pas deja dans ce mode
2180  {
2181  // On conserve le mode courant
2183  // On passe en Wireframe
2184  setRenderMode(Wireframe, false);
2185  }
2186 }
2187 
2189 {
2191  {
2192  // On revient dans le mode courant
2194  }
2195 }
2196 
2198 {
2199  if (_showScale)
2200  {
2201  NxVec3 val3D = OGLCamera::displayToWorld(NxVec3(0.0, 0.0, 0.1));
2202  TYPoint pt0(val3D.x, val3D.y, val3D.z);
2203  val3D = OGLCamera::displayToWorld(NxVec3(10, 0.0, 0.1));
2204  TYPoint pt1(val3D.x, val3D.y, val3D.z);
2205 
2206  OVector3D vect(pt0, pt1);
2207  double value = vect.norme();
2208 
2209  QString max = QString().setNum(value * 10, 'f', 1);
2210  QString mid = QString().setNum(value * 10 / 2, 'f', 1);
2211 
2212  _pOGLScalarBarElement->setTexts("0", mid.toStdString(), max.toStdString());
2213  }
2214 }
2215 
2217 {
2218  _showScale = show;
2219 
2221 
2223  updateView(false, true);
2224 }
2225 
2226 double TYModelerFrame::getDouble(const QString& title, const QString& txt, double min, double max, double val,
2227  bool& ok, int dec)
2228 {
2229  QLocale loc = QLocale(QLocale::English);
2230  TYInputDialog dialog = TYInputDialog();
2231  dialog.setLocale(loc); // Will use a dot
2232  dialog.setWindowTitle(title);
2233  dialog.setLabelText(txt);
2234  dialog.setDoubleRange(min, max);
2235  dialog.setTextValue(QString::number(val));
2236  dialog.setDoubleValue(val);
2237  dialog.setDoubleDecimals(dec);
2238  dialog.setInputMode(QInputDialog::TextInput);
2239  ok = dialog.exec();
2240  return dialog.doubleValue();
2241 }
#define NxReal
Definition: NxVec3.h:20
@ PERSPECTIVE
Definition: OGLCamera.h:40
@ PARALLEL
Definition: OGLCamera.h:39
@ FREE
Definition: OGLCamera.h:41
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:52
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)
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)
int id
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)
Definition: NxVec3.h:23
NxReal z
Definition: NxVec3.h:80
NxReal y
Definition: NxVec3.h:80
NxReal distance(const NxVec3 &) const
Definition: NxVec3.cpp:199
NxReal x
Definition: NxVec3.h:80
The box class.
Definition: 3d.h:1294
OPoint3D _min
Minimal coordinates of the OBox.
Definition: 3d.h:1371
OPoint3D _max
Maximal coordinates of the OBox.
Definition: 3d.h:1372
Definition: color.h:31
float b
Definition: color.h:33
float r
Definition: color.h:33
float g
Definition: color.h:33
The 3D coordinate class.
Definition: 3d.h:226
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 setCoords(double x, double y, double z)
Sets the coordinates as an array of double.
Definition: 3d.cpp:76
static NxVec3 displayToWorld(NxVec3 display)
Definition: OGLCamera.cpp:699
void getTranslation(double &x, double &y, double &z)
Definition: OGLCamera.cpp:854
void lookAt()
Definition: OGLCamera.cpp:80
static NxVec3 worldToDisplay(NxVec3 world)
Definition: OGLCamera.cpp:722
void resetZoom(int w=-1, int h=-1)
Definition: OGLCamera.cpp:800
void resetRotations()
Definition: OGLCamera.cpp:840
void setTranslation(double x, double y, double z)
Definition: OGLCamera.cpp:848
void setFromToUp(NxReal *_from, NxReal *_to, NxReal *_up)
Definition: OGLCamera.cpp:600
void setDistanceStep(NxReal _magnitudeStepUp, NxReal _magnitudeStepFront, NxReal _magnitudeStepLeft)
Definition: OGLCamera.cpp:545
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 setPoint1(const OPoint3D &point1)
void setColor(const OColor &oColor)
void setLineWidth(float lineWidth)
void setPoint2(const OPoint3D &point2)
void setSizes(float width, float height)
void setTexts(const std::string &text0, const std::string &text1, const std::string &text2)
void setPosition(const OPoint3D &position)
void setFontColor(const OColor &oFontColor)
void setFont(const QString &qsFontPath)
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:249
The 3D vector class.
Definition: 3d.h:298
double norme() const
Computes the length of this vector.
Definition: 3d.cpp:215
T * _pObj
The real pointer, must derived IRefCount.
Definition: smartptr.h:307
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:1003
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 setLeftButtonFunction2D(void(TYCameraEditor::*function)())
void setNavigationOnViewType(int view)
Switch auto entre navi 2D ou 3D.
void setMiddleButtonFunction2D(void(TYCameraEditor::*function)())
void setRightButtonFunction2D(void(TYCameraEditor::*function)())
void setShiftRightButtonFunction2D(void(TYCameraEditor::*function)())
void setLeftButtonFunction3D(void(TYCameraEditor::*function)())
void setShiftLeftButtonFunction2D(void(TYCameraEditor::*function)())
void setShiftLeftButtonFunction3D(void(TYCameraEditor::*function)())
void setWheelStep(float step)
gestion de zoom par zone selectionnee (obsolete)
outil de mesure des distances
virtual void computeBoundingBox()
static bool _gDrawNormals
Indique si les normals doivent etre visible.
static bool _gDrawPlafond
Indique si les plafonds doivent etre visible.
gestion des elements selectionnes par picking
TYElement * getParent() const
Definition: TYElement.h:699
virtual QString getName() const
Definition: TYElement.h:684
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
Bouton d'activation de la grille magnetique.
void setSnapGridActive(bool state)
virtual void closeEvent(QCloseEvent *pEvent)
void updateElementGraphic(bool force=false)
virtual void leaveEvent(QEvent *pEvent)
int _curViewType
Le type de la vue courante.
QStatusBar * _pStatusBar
Barre d'etat.
virtual bool computeCurPos(int x, int y, float *pos)
TYCameraEditor * _pCameraEditor
Gere la camera.
void showScale(bool show)
bool _editorModeAccepted
Indique si le mode d'edition a ete traite.
OGLScalarBarElement * _pOGLScalarBarElement
Objet graphique pour la representation de l'echelle.
QToolButton * _pShowRaysBtn
Bouton pour l'affichage des rayons calcules par le lance de rayons.
virtual void setRenderModeSlot(int mode)
LPTYElement _pElement
Un pointeur sur l'element a editer.
void showPlafond(bool show)
QToolButton * _pShowScale
Bouton pour l'affichage de l'echelle.
virtual void enterEvent(QEvent *pEvent)
TYPositionEditor * _pPositionEditor
Editor pour deplacer les elements.
void setEditorModeToCamera()
TYCameraZoneEditor * _pCameraZoneEditor
Editor pour definir une zone de zoom pour la camera.
OGLTextElement * _pOGLTextElement
Label 2D pour afficher le type de la vue.
virtual void resizeEvent(QResizeEvent *pEvent)
TYAbstractSceneEditor * _pCurrentEditor
L'editor courant.
virtual ~TYModelerFrame()
void editorModeChanged(int mode)
OGLLineElement * _pOGLLineElementAxeX
La geometrie des Axes.
void setGridLinesActorsVisibility(bool showGridXY, bool showGridXZ, bool showGridZY)
QToolButton * _pShowPlafondBtn
Bouton pour l'affichage des normals.
void showRays(bool show)
void viewTypeChanged(int)
virtual void setRenderMode(int mode, bool bUpdateGL)
bool _wireframeOnMovingCamera
Indique si on passe en rendu wireframe lors de deplacement de camera.
QToolButton * _pShowNormalsBtn
Bouton pour l'affichage des normals.
virtual void focusInEvent(QFocusEvent *pEvent)
bool _snapGridActive
Indique si on active ou non la grille magnetique.
void setWireframeOnMovingCamera(bool state)
int _lastRenderMode
Le dernier mode de rendu courant.
TYActionManager _actionManager
Pour la gestion de l'historique.
void aboutToClose()
OGLLightElement * _pLightElement
La lumiere par default.
bool getSnapGridActive()
QBoxLayout * _pCtrlLayout
Le layout ou se trouvent les boutons, etc.
virtual void mouseMoveEvent(QMouseEvent *pEvent)
QGridLayout * _pLayout
Le layout de cette frame.
QToolButton * _pShowSourcesBtn
Bouton pour l'affichage des sources ponctuelles.
OGLTextElement * _pOGLTextElementLabelY
virtual void setViewType(int view)
OGLLineElement * _pOGLLineElementX
Axes X et Y de la grille.
QStatusBar * statusBar()
QToolButton * _pGridBtn
Bouton d'activation de la grille.
bool isElementInCurrentProjet()
OGLGridElement * _pOGLGridElement
TYRenderWindowInteractor * _pView
La fenetre graphique.
void frameResized()
virtual bool close()
bool _showPlafond
Indique si on affiche ou masque les normals.
void showNormals(bool show)
OGLLineElement * _pOGLLineElementAxeZ
QComboBox * _pRenderModeBox
Combo box pour le mode de rendu.
OGLTextElement * _pOGLTextElementLabelX
bool _showGrid
Indique si on affiche ou non la grille.
TYModelerFrame(QWidget *parent=0, const char *name=0, Qt::WindowFlags f=Qt::SubWindow)
bool _showNormals
Indique si on affiche ou masque les normals.
void setCameraCoordinates()
OGLTextElement * _pOGLTextElementLabelZ
bool isElementInCurrentCalcul()
bool askForResetResultat()
bool _showScale
Indique si on affiche ou pas l'echelle.
void eltModified(LPTYElement pElt)
int _lastEditorMode
Pour conserver le dernier mode d'edition.
QToolButton * _pSetCameraCoordinatesBtn
Bouton de specification des coordonnees de la camera.
int _curRenderMode
Le mode de rendu courant.
OGLLineElement * _pOGLLineElementAxeY
float _gridDimX
Dimension de la grille en X.
float _gridDimY
Dimension de la grille en Y.
void startMovingRenderMode()
TYElementPicker * _pPicker
Pour le picking.
OGLCamera * _pOGLCameras[NbOfViews]
Les cameras pour chaque type de vue.
float _gridStep
Pas de la grille.
virtual void updatePreferences()
bool _showRays
Indique si on affiche ou pas les rayons.
TYPickEditor * _pPickEditor
Gere le menu contextuel.
OGLLineElement * _pOGLLineElementY
float _gridMagnStep
Pas de la grille magnetique.
QToolButton * _pScreenShotBtn
Bouton pour effectuer une capture d'ecran.
TYPickEditor * getPickEditor()
virtual void keyPressEvent(QKeyEvent *pEvent)
TYDistanceEditor * _pDistanceEditor
Outils pour mesurer.
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)
TYOpenGLRenderer * getRenderer()
bool _showSources
Indique si on affiche ou pas les sources ponctuelles.
QComboBox * _pViewTypeBox
Combo box pour la selection de la camera courante.
void updateDisplayList(void)
void addLight(OGLLightElement *pOGLElementLight)
void addOGLElement(OGLElement *pOGLElement)
void removeOGLElement(OGLElement *pOGLElement)
void setBackground(double *bgColor)
void setActiveCamera(OGLCamera *pCamera)
void init(int width, int height)
OGLCamera * getActiveCamera()
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:52
QGroupBox * _groupBoxSite
Definition: TYPrintDialog.h:81
QCheckBox * _checkBoxCatMachine
Definition: TYPrintDialog.h:74
QCheckBox * _checkBoxDateProjet
Definition: TYPrintDialog.h:65
QCheckBox * _checkBoxNomProjet
Definition: TYPrintDialog.h:66
QCheckBox * _checkBoxNomBatiment
Definition: TYPrintDialog.h:78
QCheckBox * _checkBoxNomSite
Definition: TYPrintDialog.h:76
QCheckBox * _checkBoxDateCalcul
Definition: TYPrintDialog.h:69
QCheckBox * _checkBoxCommentCalcul
Definition: TYPrintDialog.h:68
QGroupBox * _groupBoxMachine
Definition: TYPrintDialog.h:79
QCheckBox * _checkBoxNomCalcul
Definition: TYPrintDialog.h:70
QGroupBox * _groupBoxCalcul
Definition: TYPrintDialog.h:67
QLineEdit * _lineEditPied
Definition: TYPrintDialog.h:84
QLineEdit * _lineEditTete
Definition: TYPrintDialog.h:85
QCheckBox * _checkBoxCommentProjet
Definition: TYPrintDialog.h:63
QCheckBox * _checkBoxNomMachine
Definition: TYPrintDialog.h:73
QCheckBox * _checkBoxModelMachine
Definition: TYPrintDialog.h:75
QGroupBox * _groupBoxProjet
Definition: TYPrintDialog.h:62
QGroupBox * _groupBoxBatiment
Definition: TYPrintDialog.h:80
QLineEdit * _lineEditTitre
Definition: TYPrintDialog.h:87
QCheckBox * _checkBoxAuteurProjet
Definition: TYPrintDialog.h:64
QCheckBox * _checkBoxConstrMachine
Definition: TYPrintDialog.h:72
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
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)
virtual void updateGL()
void showInfos(bool state)
TYOpenGLRenderer * getRenderer()
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.