Code_TYMPAN  4.2.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 
22 #ifdef _MSC_VER
23 #pragma warning(disable: 4503)
24 #endif
25 
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 
85 #include "TYModelerFrame.h"
86 
87 #define TR(id) OLocalizator::getString("TYModelerFrame", (id))
88 #define IMG(id) OLocalizator::getPicture("TYModelerFrame", (id))
89 
90 using namespace Qt;
91 
92 // Couleurs
93 static double gridColor[] = { 0.59, 0.41, 0.42 };
94 static double fontColor[] = { 0.1, 0.43, 0.37 };
95 static double rendererColor[] = { 0.91, 0.91, 0.91 };
96 
97 
98 TYModelerFrame::TYModelerFrame(QWidget* parent, const char* name, Qt::WindowFlags f)
99  : QWidget(parent, f), _actionManager(10)
100 {
101  setObjectName(name);
102 
103  setAttribute(Qt::WA_DeleteOnClose);
104 
105  // L'element associe a ce modeler
106  _pElement = NULL;
107 
108  // Flag pour la sauvegarde des settings
109  _firstTimeShown = true;
110 
111  // Init des membres pour les editors
112  _pCurrentEditor = NULL;
114  _editorModeAccepted = false;
115 
116  // Init des membres pour la grille
117  _showGrid = false;
118 
120 
121  // Le focus se fait avec la touche tab ou la souris
122  setFocusPolicy(StrongFocus);
123 
124  // Pour pouvoir afficher la position courante du curseur
125  setMouseTracking(true);
126 
127  // Layout
128  _pLayout = new QGridLayout();
129  _pLayout->setRowStretch(0, 0);
130  _pLayout->setRowStretch(1, 1);
131  _pLayout->setRowStretch(2, 0);
132  setLayout(_pLayout);
133 
134  // Initialisation des parametres de la grille.
135  _gridDimX = 200; _gridDimY = 200; _gridStep = 5;
136 
137  // Widgets
138  _pCtrlLayout = new QHBoxLayout();
139  _pLayout->addLayout(_pCtrlLayout, 0, 0);
140  _pCtrlLayout->setSpacing(5);
141 
142  // Disambiguate the overloaded signal QComboBox::activated
143  void (QComboBox:: * _qComboBox_activated)(int) = &QComboBox::activated;
144 
145  // Combo box type de Vue
146  _pViewTypeBox = new QComboBox(this);
147  _pCtrlLayout->addWidget(_pViewTypeBox, 0);
148  _pViewTypeBox->insertItem(TopView, TR("id_top_view"));
149  _pViewTypeBox->insertItem(LeftView, TR("id_left_view"));
150  _pViewTypeBox->insertItem(FrontView, TR("id_front_view"));
151  _pViewTypeBox->insertItem(PerspView, TR("id_3d_view"));
152  _pViewTypeBox->insertItem(FreeView, TR("id_free_view"));
153  connect(_pViewTypeBox, _qComboBox_activated, this, &TYModelerFrame::setViewType);
154 
155  // Combo box mode de Rendu
156  _pRenderModeBox = new QComboBox(this);
157  _pCtrlLayout->addWidget(_pRenderModeBox, 0);
158  _pRenderModeBox->insertItem(Points, TR("id_points_mode"));
159  _pRenderModeBox->insertItem(Wireframe, TR("id_wireframe_mode"));
160  _pRenderModeBox->insertItem(Surface, TR("id_surface_mode"));
161  connect(_pRenderModeBox, _qComboBox_activated, this, &TYModelerFrame::setRenderModeSlot);
162 
163  _pCtrlLayout->addSpacing(7);
164 
165  // Btn Fit
166  QToolButton* pFitBtn = new QToolButton(this);
167  pFitBtn->setIcon(QPixmap(IMG("id_icon_fit_btn")));
168  pFitBtn->setText(TR("id_fit_btn"));
169  pFitBtn->setToolTip(TR("id_fit_btn"));
170  pFitBtn->setFixedSize(24, 24);
171  connect(pFitBtn, &QToolButton::clicked, this, &TYModelerFrame::fit);
172  _pCtrlLayout->addWidget(pFitBtn, 0);
173 
174  // Btn Grille
175  _pGridBtn = new QToolButton(this);
176  _pGridBtn->setIcon(QPixmap(IMG("id_icon_grid_btn")));
177  _pGridBtn->setText(TR("id_grid_btn"));
178  _pGridBtn->setToolTip(TR("id_grid_btn"));
179  _pGridBtn->setCheckable(true);
180  _pGridBtn->setChecked(true);
181  _pGridBtn->setFixedSize(24, 24);
182  _pCtrlLayout->addWidget(_pGridBtn, 0);
183  connect(_pGridBtn, &QToolButton::toggled, this, &TYModelerFrame::showGrid);
184 
185  // Btn Show echelle.
186  // L'echelle est mise a jour a la fin de chaque deplacement de camera (cf. TYCameraEditor)
187  _showScale = true;
188  _pShowScale = new QToolButton(this);
189  _pShowScale->setIcon(QPixmap(IMG("id_icon_show_scale_btn")));
190  _pShowScale->setText(TR("id_show_scale_btn"));
191  _pShowScale->setToolTip(TR("id_show_scale_btn"));
192  _pShowScale->setCheckable(true);
193  _pShowScale->setChecked(_showScale);
194  _pShowScale->setFixedSize(24, 24);
195  _pCtrlLayout->addWidget(_pShowScale, 0);
196  connect(_pShowScale, &QToolButton::toggled, this, &TYModelerFrame::showScale);
197 
198  // Btn Grille Magnetique
199  _pSnapGridBtn = new QToolButton(this);
200  _pSnapGridBtn->setIcon(QPixmap(IMG("id_icon_snapgrid_btn")));
201  _pSnapGridBtn->setText(TR("id_snapgrid_btn"));
202  _pSnapGridBtn->setToolTip(TR("id_snapgrid_btn"));
203  _pSnapGridBtn->setCheckable(true);
204  _pSnapGridBtn->setFixedSize(24, 24);
205  _pCtrlLayout->addWidget(_pSnapGridBtn, 0);
206  connect(_pSnapGridBtn, &QToolButton::toggled, this, &TYModelerFrame::setSnapGridActive);
207  setSnapGridActive(true);
208 
209  // Btn set camera coordinates
210  _pSetCameraCoordinatesBtn = new QToolButton(this);
211  _pSetCameraCoordinatesBtn->setIcon(QPixmap(IMG("id_icon_setcameracoordinates_btn")));
212  _pSetCameraCoordinatesBtn->setText(TR("id_setcameracoordinates_btn"));
213  _pSetCameraCoordinatesBtn->setToolTip(TR("id_setcameracoordinates_btn"));
214  _pSetCameraCoordinatesBtn->setFixedSize(24, 24);
216  connect(_pSetCameraCoordinatesBtn, &QToolButton::clicked, this, &TYModelerFrame::setCameraCoordinates);
217 
218  _pCtrlLayout->addSpacing(7);
219 
220  // Btn d'edition de l'element
221  QToolButton* pEditEltBtn = new QToolButton(this);
222  pEditEltBtn->setIcon(QPixmap(IMG("id_icon_editeelt_btn")));
223  pEditEltBtn->setText(TR("id_editelt_btn"));
224  pEditEltBtn->setToolTip(TR("id_editelt_btn"));
225  pEditEltBtn->setFixedSize(24, 24);
226  _pCtrlLayout->addWidget(pEditEltBtn, 0);
227  connect(pEditEltBtn, &QToolButton::clicked, this, &TYModelerFrame::editElement);
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  _pCtrlLayout->addWidget(_pScreenShotBtn, 0);
239 
240  // Btn Copy
241  QToolButton* pCopyBtn = new QToolButton(this);
242  pCopyBtn->setIcon(QPixmap(IMG("id_icon_copy_btn")));
243  pCopyBtn->setText(TR("id_copy_btn"));
244  pCopyBtn->setToolTip(TR("id_copy_btn"));
245  pCopyBtn->setFixedSize(24, 24);
246  connect(pCopyBtn, &QToolButton::clicked, this, &TYModelerFrame::copy);
247  _pCtrlLayout->addWidget(pCopyBtn, 0);
248 
249  _pCtrlLayout->addSpacing(7);
250 
251  // Btn Show Sources
252  _pShowSourcesBtn = new QToolButton(this);
253  _pShowSourcesBtn->setIcon(QPixmap(IMG("id_icon_source")));
254  _pShowSourcesBtn->setText(TR("id_show_source_btn"));
255  _pShowSourcesBtn->setToolTip(TR("id_show_source_btn"));
256  _pShowSourcesBtn->setCheckable(true);
257  _pShowSourcesBtn->setChecked(false);
258  _pShowSourcesBtn->setFixedSize(24, 24);
259  _pCtrlLayout->addWidget(_pShowSourcesBtn, 0);
260  connect(_pShowSourcesBtn, &QToolButton::toggled, this, &TYModelerFrame::showSources);
261  showSources(_pShowSourcesBtn->isChecked());
262 
263  // Btn Show Normals
264  _pShowNormalsBtn = new QToolButton(this);
265  _pShowNormalsBtn->setIcon(QPixmap(IMG("id_icon_normals")));
266  _pShowNormalsBtn->setText(TR("id_show_normals_btn"));
267  _pShowNormalsBtn->setToolTip(TR("id_show_normals_btn"));
268  _pShowNormalsBtn->setCheckable(true);
269  _pShowNormalsBtn->setChecked(false);
270  _pShowNormalsBtn->setFixedSize(24, 24);
271  _pCtrlLayout->addWidget(_pShowNormalsBtn, 0);
272  connect(_pShowNormalsBtn, &QToolButton::toggled, this, &TYModelerFrame::showNormals);
273  showNormals(_pShowNormalsBtn->isChecked());
274 
275  // Btn Show Plafond
276  _pShowPlafondBtn = new QToolButton(this);
277  _pShowPlafondBtn->setIcon(QPixmap(IMG("id_icon_plafond")));
278  _pShowPlafondBtn->setText(TR("id_show_plafond_btn"));
279  _pShowPlafondBtn->setToolTip(TR("id_show_plafond_btn"));
280  _pShowPlafondBtn->setCheckable(true);
281  _pShowPlafondBtn->setChecked(false);
282  _pShowPlafondBtn->setFixedSize(24, 24);
283  _pCtrlLayout->addWidget(_pShowPlafondBtn, 0);
284  connect(_pShowPlafondBtn, &QToolButton::toggled, this, &TYModelerFrame::showPlafond);
285  showPlafond(_pShowPlafondBtn->isChecked());
286 
287  // Btn Show Rayons
288  _pShowRaysBtn = new QToolButton(this);
289  _pShowRaysBtn->setIcon(QPixmap(IMG("id_icon_rays")));
290  _pShowRaysBtn->setText(TR("id_show_rays_btn"));
291  _pShowRaysBtn->setToolTip(TR("id_show_rays_btn"));
292 
293  _pShowRaysBtn->setCheckable(true);
294  _pShowRaysBtn->setChecked(false);
295  _pShowRaysBtn->setFixedSize(24, 24);
296  _pCtrlLayout->addWidget(_pShowRaysBtn, 0);
297  connect(_pShowRaysBtn, &QToolButton::toggled, this, &TYModelerFrame::showRays);
298  showRays(_pShowRaysBtn->isChecked());
299 
300  // Vue graphique
301  _pView = new TYRenderWindowInteractor(this, "vue graphique");
302  _pLayout->addWidget(_pView, 1, 0);
303 
305 
306  // Status bar
307  _pStatusBar = new QStatusBar(this);
308  _pLayout->addWidget(_pStatusBar, 2, 0);
309 
310  // Cameras pour chaque type de vue
311  NxReal fromTop[3] = { 0, 500, 0 };
312  NxReal toTop[3] = { 0, 0, 0 };
313  NxReal upTop[3] = { 0, 0, -1 };
314  _pOGLCameras[TopView] = new OGLCamera(fromTop, toTop, upTop, 100, 100, PARALLEL);
315 
316  NxReal fromLeft[3] = { -500, 0, 0 };
317  NxReal toLeft[3] = { 0, 0, 0 };
318  NxReal upLeft[3] = { 0, 1, 0 };
319  _pOGLCameras[LeftView] = new OGLCamera(fromLeft, toLeft, upLeft, 100, 100, PARALLEL);
320 
321  NxReal fromFront[3] = { 0, 0, 500 };
322  NxReal toFront[3] = { 0, 0, 0 };
323  NxReal upFront[3] = { 0, 1, 0 };
324  _pOGLCameras[FrontView] = new OGLCamera(fromFront, toFront, upFront, 100, 100, PARALLEL);
325 
326  NxReal fromPersp[3] = { 0, 10000, 10000 };
327  NxReal toPersp[3] = { 0, 0, 0 };
328  NxReal upPersp[3] = { 0, 1, 0 };
329  _pOGLCameras[PerspView] = new OGLCamera(fromPersp, toPersp, upPersp, 100, 100, PERSPECTIVE);
330 
331  NxReal fromFree[3] = { 0, 0, 0 };
332  NxReal toFree[3] = { 0, 0, 0.1 };
333  NxReal upFree[3] = { 0, 1, 0 };
334  _pOGLCameras[FreeView] = new OGLCamera(fromFree, toFree, upFree, 100, 100, FREE);
335 
336  // Triedre XYZ
349 
352  _pOGLTextElementLabelX->setFont(IMG("id_font_bold"));
353  OColor oColor;
354  oColor.r = fontColor[0];
355  oColor.g = fontColor[1];
356  oColor.b = fontColor[2];
359 
362  _pOGLTextElementLabelY->setFont(IMG("id_font_bold"));
365 
368  _pOGLTextElementLabelZ->setFont(IMG("id_font_bold"));
371 
372  _pView->getRenderer()->addOGLElement(_pOGLLineElementAxeX);
373  _pView->getRenderer()->addOGLElement(_pOGLLineElementAxeY);
374  _pView->getRenderer()->addOGLElement(_pOGLLineElementAxeZ);
375  _pView->getRenderer()->addOGLElement(_pOGLTextElementLabelX);
376  _pView->getRenderer()->addOGLElement(_pOGLTextElementLabelY);
377  _pView->getRenderer()->addOGLElement(_pOGLTextElementLabelZ);
378 
379  // Label
382  _pOGLTextElement->setFont(IMG("id_font_bold"));
383  _pOGLTextElement->setColor(oColor);
385  _pView->getRenderer()->addOGLElement(_pOGLTextElement);
386 
387 #ifndef NO_GRID
388  // Construction de la grille
390  _pOGLGridElement->setColor(OColor(gridColor[0], gridColor[1], gridColor[2]));
392  _pOGLGridElement->setIs3D(true);
393  _pView->getRenderer()->addOGLElement(_pOGLGridElement);
394 #endif//NO_GRID
395 
396  // Axes de la grille
398  _pOGLLineElementX->setPoint1(OPoint3D(-100, 0, 0));
399  _pOGLLineElementX->setPoint2(OPoint3D(100, 0, 0));
400  _pOGLLineElementX->setColor(OColor(0, 0, 0));
402  _pOGLLineElementX->setIs3D(true);
404 
406  _pOGLLineElementY->setPoint1(OPoint3D(0, -100, 0));
407  _pOGLLineElementY->setPoint2(OPoint3D(0, 100, 0));
408  _pOGLLineElementY->setColor(OColor(0, 0, 0));
410  _pOGLLineElementY->setIs3D(true);
412 
413  _pView->getRenderer()->addOGLElement(_pOGLLineElementX);
414  _pView->getRenderer()->addOGLElement(_pOGLLineElementY);
415 
416  // Echelle
421  _pOGLScalarBarElement->setFont(IMG("id_font"));
423  _pOGLScalarBarElement->setTexts("0", "0", "0");
425  _pView->getRenderer()->addOGLElement(_pOGLScalarBarElement);
426 
427  // Lumieres
429  _pLightElement->init(0, OPoint3D(0.0, 400.0, 0.0), 1.0f);
430  _pView->getRenderer()->addLight(_pLightElement);
431 
432 
433  // Couleur de fond
434  getRenderer()->setBackground(rendererColor);
435 
436  // Type de rendu
437  setRenderMode(Surface, true);
438 
439  _wireframeOnMovingCamera = false;
441 
442  // Gestion du picking
443  _pPicker = new TYElementPicker(this);
444 
445  // Init chaque view
446  for (int i = 0; i < NbOfViews; i++)
447  {
448  setViewType(i);
449  }
450 
451  // Editors
452  _pCameraEditor = new TYCameraEditor(this);
455 
456  // Le pick editor
457  _pPickEditor = new TYPickEditor(this);
459 
460  // Mode d'edition
462 
463  // Init chaque view
464  // for (int i = 0; i < NbOfViews; i++)
465  // {
466  // setViewType(i);
467  // }
468 
469  resizeGrid();
470  showGrid(_pGridBtn->isChecked());
471  showScale(_pShowScale->isChecked());
472 
474 
475  // Chargement des preferences
477 
478  showMaximized();
479  _pOGLTextElement->setDisplayPosition(5, rect().bottom() - rect().top());
480 }
481 
482 
484 {
485 
486  // Disambiguate the overloaded signal QComboBox::activated
487  void (QComboBox:: * _qComboBox_activated)(int) = &QComboBox::activated;
488 
489  disconnect(_pViewTypeBox, _qComboBox_activated, this, &TYModelerFrame::setViewType);
490  disconnect(_pRenderModeBox, _qComboBox_activated, this, &TYModelerFrame::setRenderModeSlot);
491  disconnect(_pGridBtn, &QToolButton::toggled, this, &TYModelerFrame::showGrid);
492  disconnect(_pShowScale, &QToolButton::toggled, this, &TYModelerFrame::showScale);
493  disconnect(_pSnapGridBtn, &QToolButton::toggled, this, &TYModelerFrame::setSnapGridActive);
494  disconnect(_pSetCameraCoordinatesBtn, &QToolButton::clicked, this, &TYModelerFrame::setCameraCoordinates);
495  disconnect(_pScreenShotBtn, &QToolButton::clicked, this, &TYModelerFrame::screenShot);
496  disconnect(_pShowSourcesBtn, &QToolButton::toggled, this, &TYModelerFrame::showSources);
497  disconnect(_pShowNormalsBtn, &QToolButton::toggled, this, &TYModelerFrame::showNormals);
498  disconnect(_pShowPlafondBtn, &QToolButton::toggled, this, &TYModelerFrame::showPlafond);
499  disconnect(_pShowRaysBtn, &QToolButton::toggled, this, &TYModelerFrame::showRays);
501 
502 
503  delete _pCameraEditor;
504  delete _pDistanceEditor;
505  delete _pPositionEditor;
506  delete _pPickEditor;
507  delete _pPicker;
508 
509  for (int i = 0; i < NbOfViews; i++)
510  {
511  delete _pOGLCameras[i];
512  _pOGLCameras[i] = NULL;
513  }
514 
516  delete _pOGLLineElementAxeX;
518  delete _pOGLLineElementAxeY;
520  delete _pOGLLineElementAxeZ;
522  delete _pOGLTextElementLabelX;
524  delete _pOGLTextElementLabelY;
526  delete _pOGLTextElementLabelZ;
527 
529  delete _pOGLTextElement;
531  delete _pOGLScalarBarElement;
533  delete _pOGLLineElementX;
535  delete _pOGLLineElementY;
536 
537 
538 
539 #ifndef NO_GRID
541  delete _pOGLGridElement;
542 #endif// NO_GRID
544  delete _pLightElement;
545 }
546 
548 {
549  return QWidget::close();
550 }
551 
553 {
554  bool ret = false;
555 
556  if (getTYApp()->getCurProjet() && getTYApp()->getCurProjet()->getCurrentCalcul() && _pElement)
557  {
558  // L'element fait-il parti de la selection du calcul courant ?
560  }
561 
562  return ret;
563 }
564 
566 {
567  bool ret = false;
568 
569  if (getTYApp()->getCurProjet() && _pElement)
570  {
571  // On commence directement a partir de l'element lui-meme
572  TYElement* pParent = _pElement;
573 
574  while (pParent)
575  {
576  // Le parent est le projet courant ?
577  if (pParent == getTYApp()->getCurProjet())
578  {
579  ret = true;
580  break;
581  }
582  // Parent du parent
583  pParent = pParent->getParent();
584  }
585  }
586 
587  return ret;
588 }
589 
591 {
592  bool ret = true;
593 
595  {
597  }
598 
599  return ret;
600 }
601 
603 {
604  if (view >= NbOfViews) { return; }
605 
606  // View type
607  _curViewType = view;
608 
609  bool showGridXY = false;
610  bool showGridXZ = false;
611  bool showGridZY = false;
612  QString labelStr;
613 
614  // Pre traitement selon la vue activee
615  switch (view)
616  {
617  case TopView:
618  showGridXZ = _showGrid;
619  labelStr = TR("id_top_view");
620  _pSetCameraCoordinatesBtn->setEnabled(false);
621  break;
622  case LeftView:
623  showGridZY = _showGrid;
624  labelStr = TR("id_left_view");
625  _pSetCameraCoordinatesBtn->setEnabled(false);
626  break;
627  case FrontView:
628  showGridXY = _showGrid;
629  labelStr = TR("id_front_view");
630  _pSetCameraCoordinatesBtn->setEnabled(false);
631  break;
632  case PerspView:
633  showGridXZ = _showGrid;
634  labelStr = TR("id_3d_view");
635  _pSetCameraCoordinatesBtn->setEnabled(false);
636  break;
637  case FreeView:
638  showGridXZ = _showGrid;
639  labelStr = TR("id_free_view");
640  _pSetCameraCoordinatesBtn->setEnabled(true);
641  break;
642  default: break;
643  }
644 
645  //_pView->setFocus();
646 
647  // Affichage de la grille correspondant au type de vue
648  setGridLinesActorsVisibility(showGridXY, showGridXZ, showGridZY);
649 
650  // Label
652 
653  // Camera
655  getRenderer()->init(_pView->width(), _pView->height());
656 
657  // Update l'element associe a ce modeler
658  if (_pElement)
659  {
660  _pElement->updateGraphicTree();
661  _pElement->getGraphicObject()->update(true);
662  }
663 
665  // Updates
666  updateView();
667 
668  _pViewTypeBox->setCurrentIndex(_curViewType);
670 }
671 
673 {
674  setRenderMode(mode, true);
675 }
676 
677 
678 void TYModelerFrame::setRenderMode(int mode, bool bUpdateGL)
679 {
680  if (mode >= NbOfRenderMode) { return; }
681 
682  // Mode
683  _curRenderMode = mode;
684 
685  if (mode == Points)
686  {
687  glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
688  }
689  else if (mode == Wireframe)
690  {
691  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
692  }
693  else if (mode == Surface)
694  {
695  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
696  }
697  else if (mode == Flat)
698  {
699  glShadeModel(GL_FLAT);
700  }
701  else if (mode == Gouraud)
702  {
703  glShadeModel(GL_SMOOTH);
704  }
705 
706  _pRenderModeBox->setCurrentIndex(_curRenderMode);
707 
708  if (bUpdateGL == true)
709  {
710  _pView->updateGL();
711  }
712 }
713 
715 {
716  if (!_editorModeAccepted)
717  {
718  getPickEditor()->usePopup(true);
719  getPickEditor()->useHighlight(false);
720 
721  if (_pCurrentEditor)
722  {
725  }
726 
727  _editorModeAccepted = true;
728 
729  switch (mode)
730  {
731  case CameraMode:
732  //fit();
733  getPickEditor()->useHighlight(true);
735  break;
736  case DistanceMode:
738  break;
739  case MovingMode:
742  break;
743  case RotationMode:
746  break;
747  case EditionMode:
750  break;
751  case NoMode:
752  default:
753  getPickEditor()->useHighlight(true);
754  _pCurrentEditor = NULL;
755  mode = NoMode;
756  _editorModeAccepted = false;
757  break;
758  }
759  }
760 
761  // On sauve le mode courant
762  _lastEditorMode = mode;
763 
764  // Init
765  if (_pCurrentEditor)
766  {
769  }
770 
771  // Pour la prochaine requete
772  _editorModeAccepted = false;
773 
774  // The bug goes by here...
775  emit(editorModeChanged(mode));
776 
777 }
778 
780 {
781  _showGrid = show;
782 
785 
786  _pGridBtn->setChecked(_showGrid);
787 
789  // Update
791 }
792 
794 {
795  _showSources = show;
796 
799  {
800 
801  TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
802 
805 
806  if (_pElement && _pElement->getGraphicObject())
807  {
808  // Update l'element associe a ce modeler
809  _pElement->getGraphicObject()->update(true);
810 
812 
813  // Update view
814  updateView();
815 
816  }
817 
818  TYApplication::restoreOverrideCursor();
819  }
820 
821  _pShowSourcesBtn->setChecked(_showSources);
822 }
823 
825 {
826  _showRays = show;
828  {
829 
830  TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
831 
833 
834  if (_pElement && _pElement->getGraphicObject())
835  {
836  // Update l'element associe a ce modeler
837  _pElement->getGraphicObject()->update(true);
838 
840 
841  // Update view
842  updateView();
843  }
844 
845  TYApplication::restoreOverrideCursor();
846  }
847 
848  _pShowRaysBtn->setChecked(_showRays);
849 }
850 
852 {
853  _showNormals = show;
854 
856  {
857 
858  TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
859 
861 
862  if (_pElement && _pElement->getGraphicObject())
863  {
864  // Update l'element associe a ce modeler
865  _pElement->getGraphicObject()->update(true);
866 
868 
869  // Update view
870  updateView();
871  }
872 
873  TYApplication::restoreOverrideCursor();
874  }
875 
876  _pShowNormalsBtn->setChecked(_showNormals);
877 
878 }
879 
881 {
882  _showPlafond = !show; // inversion entre l'etat variable et du bouton
883 
885  {
886 
887  TYApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
888 
890 
891  if (_pElement && _pElement->getGraphicObject())
892  {
893  // Update l'element associe a ce modeler
894  _pElement->getGraphicObject()->update(true);
895 
897 
898  // Update view
899  updateView();
900  }
901 
902  TYApplication::restoreOverrideCursor();
903  }
904 
905  _pShowPlafondBtn->setChecked(!_showPlafond);
906 
907 }
908 
909 
911 {
912  _snapGridActive = state;
913  _pSnapGridBtn->setChecked(_snapGridActive);
914 }
915 
916 
918 {
919  if ((getRenderer()->getActiveCamera()) && (getRenderer()->getActiveCamera()->m_eCameraType == FREE))
920  {
921  TYSetCameraCoordinates* pSetCameraCoordinates = new TYSetCameraCoordinates(this);
922  double x, y, z;
924  pSetCameraCoordinates->setXCoord(x);
925  pSetCameraCoordinates->setYCoord(-z);
926  pSetCameraCoordinates->setZCoord(y);
927  pSetCameraCoordinates->exec();
928 
929  if (pSetCameraCoordinates->result() == QDialog::Accepted)
930  {
931  if (getRenderer()->getActiveCamera())
932  {
933  getRenderer()->getActiveCamera()->setTranslation(pSetCameraCoordinates->getXCoord(), pSetCameraCoordinates->getZCoord(), -pSetCameraCoordinates->getYCoord());
934 
935  // Update view
936  updateView();
937  }
938  }
939  }
940 }
941 
943 {
944  QMenu* pMenu = new QMenu(NULL);
945 
946  QHash<QAction*, QString> formats;
947 
948  for (unsigned int i = 0; i < QImageWriter::supportedImageFormats().count(); i++)
949  {
950  QString str = QString(QImageWriter::supportedImageFormats().at(i));
951  formats.insert(pMenu->addAction(QString("%1...").arg(str)), QString(str));
952  }
953 
954  pMenu->setMouseTracking(true);
955  QAction* id = pMenu->exec(_pScreenShotBtn->mapToGlobal(QPoint(0, _pScreenShotBtn->height() + 1)));
956 
957  if (id)
958  {
959  QString format = formats[id];
960 
961  QString filename = QFileDialog::getSaveFileName(this, "", QString::null, QString("*.%1").arg(format.toLower()));
962  if (!filename.isEmpty())
963  {
964  // Prefixe
965  if (!filename.endsWith(format.toLower()))
966  {
967  filename += "." + format.toLower();
968  }
969 
970  // Restauration des deux buffers
971  _pView->repaint(); _pView->repaint();
972  if (qApp->hasPendingEvents())
973  {
974  qApp->processEvents();
975  }
976 
977  // Snap
978  QImage img = _pView->grabFrameBuffer();
979 
980  // Save
981  QPixmap pix = QPixmap::fromImage(img);
982  pix.save(filename, format.toLatin1().data(), 80); // qualite 80 (de 0 a 100)
983  }
984  }
985 
986  delete pMenu;
987 }
988 
990 {
991  // Snap
992  QImage img = _pView->grabFrameBuffer();
993 
994  // Copie dans le presse papier
995  QClipboard* clipboard = QApplication::clipboard();
996  clipboard->setImage(img);
997 }
998 
1000 {
1001  LPTYProjet pProjet = getTYApp()->getCurProjet();
1002  LPTYCalcul pCalcul = NULL;
1003  if (pProjet) { pCalcul = pProjet->getCurrentCalcul(); }
1004 
1005  // Print dialog
1006  TYPrintDialog* pDialog = new TYPrintDialog(this);
1007 
1008  if (pProjet == NULL)
1009  {
1010  pDialog->_groupBoxProjet->setEnabled(false);
1011  }
1012  if (pCalcul == NULL)
1013  {
1014  pDialog->_groupBoxCalcul->setEnabled(false);
1015  }
1016 
1017  if (_pElement)
1018  {
1019  if (dynamic_cast<TYBatiment*>(_pElement._pObj) != nullptr)
1020  {
1021  pDialog->_groupBoxBatiment->show();
1022  }
1023  else if (dynamic_cast<TYMachine*>(_pElement._pObj) != nullptr)
1024  {
1025  pDialog->_groupBoxMachine->show();
1026  }
1027  else if (dynamic_cast<TYSiteNode*>(_pElement._pObj) != nullptr)
1028  {
1029  pDialog->_groupBoxSite->show();
1030  }
1031  }
1032 
1033  if (pDialog->exec() == QDialog::Accepted)
1034  {
1035  QPrinter* printer = new QPrinter();
1036 
1037  QPrintDialog dialog(printer, this);
1038  if (dialog.exec())
1039  {
1040  QPainter paint(printer);
1041 
1042  double w = double(printer->width());
1043  double h = double(printer->height());
1044  double scalew = w / 700;
1045  double scaleh = h / 700;
1046 
1047  // Snap
1048  QImage img = _pView->grabFrameBuffer();
1049  img = img.scaled(int(w * 9 / 10), int(h * 2 / 3), Qt::KeepAspectRatio, Qt::SmoothTransformation);
1050  int x = int(double(printer->width() - img.width()) / 2);
1051  int y = int(double(printer->height() - img.height()) * 1 / 3);
1052  QPixmap pm = QPixmap::fromImage(img);
1053  paint.drawPixmap(x, y, pm);
1054 
1055  paint.setFont(QFont("Times", (int)(10 * scaleh)));
1056  int mid = int(w / 2) - int(paint.fontMetrics().width(pDialog->_lineEditTete->text()) / 2);
1057  paint.drawText(mid, 20, pDialog->_lineEditTete->text());
1058 
1059  mid = int(w / 2) - int(paint.fontMetrics().width(pDialog->_lineEditPied->text()) / 2);
1060  paint.drawText(mid, printer->height() - 20, pDialog->_lineEditPied->text());
1061 
1062  paint.setFont(QFont("Times", (int)(15 * scaleh), QFont::Bold));
1063  mid = int(w / 2) - int(paint.fontMetrics().width(pDialog->_lineEditTitre->text()) / 2);
1064  paint.drawText(mid, y - 20, pDialog->_lineEditTitre->text());
1065 
1066  x = int(50 * scalew);
1067  int x1 = int(w / 2);
1068  y = int(double(printer->height()) * 2 / 3 + 20 * scaleh);
1069  int stepy = int(10 * scaleh);
1070  paint.setFont(QFont("Times", (int)(10 * scaleh)));
1071 
1072  if (pProjet)
1073  {
1074  if (pDialog->_checkBoxNomProjet->isChecked())
1075  {
1076  paint.drawText(x, y, TR("id_print_nom_projet"));
1077  paint.drawText(x1, y, pProjet->getName());
1078  y += stepy;
1079  }
1080  if (pDialog->_checkBoxAuteurProjet->isChecked())
1081  {
1082  paint.drawText(x, y, TR("id_print_auteur_projet"));
1083  paint.drawText(x1, y, pProjet->getAuteur());
1084  y += stepy;
1085  }
1086  if (pDialog->_checkBoxDateProjet->isChecked())
1087  {
1088  paint.drawText(x, y, TR("id_print_date_creation"));
1089  paint.drawText(x1, y, pProjet->getDateCreation());
1090  y += stepy;
1091  paint.drawText(x, y, TR("id_print_date_modif"));
1092  paint.drawText(x1, y, pProjet->getDateModif());
1093  y += stepy;
1094  }
1095  if (pDialog->_checkBoxCommentProjet->isChecked())
1096  {
1097  paint.drawText(x, y, TR("id_print_comment"));
1098  paint.drawText(x1, y, pProjet->getComment());
1099  y += stepy;
1100  }
1101  }
1102 
1103  if (pCalcul)
1104  {
1105  y += int(double(stepy) * 1.5);
1106  if (pDialog->_checkBoxNomCalcul->isChecked())
1107  {
1108  paint.drawText(x, y, TR("id_print_nom_calcul"));
1109  paint.drawText(x1, y, pCalcul->getName());
1110  y += stepy;
1111  }
1112  if (pDialog->_checkBoxDateCalcul->isChecked())
1113  {
1114  paint.drawText(x, y, TR("id_print_date_creation"));
1115  paint.drawText(x1, y, pCalcul->getDateCreation());
1116  y += stepy;
1117  paint.drawText(x, y, TR("id_print_date_modif"));
1118  paint.drawText(x1, y, pCalcul->getDateModif());
1119  y += stepy;
1120  }
1121  if (pDialog->_checkBoxCommentCalcul->isChecked())
1122  {
1123  paint.drawText(x, y, TR("id_print_comment"));
1124  paint.drawText(x1, y, pCalcul->getComment());
1125  y += stepy;
1126  }
1127  }
1128 
1129  if (_pElement)
1130  {
1131  y += int(double(stepy) * 1.5);
1132  TYElement* pElement = (TYElement*)_pElement;
1133  if (strcmp(_pElement->getClassName(), "TYBatiment") == 0)
1134  {
1135  TYBatiment* pBatiment = (TYBatiment*)pElement;
1136  if (pDialog->_checkBoxNomBatiment->isChecked())
1137  {
1138  paint.drawText(x, y, TR("id_print_nom_batiment"));
1139  paint.drawText(x1, y, pBatiment->getName());
1140  }
1141  }
1142  else if (strcmp(_pElement->getClassName(), "TYMachine") == 0)
1143  {
1144  TYMachine* pMachine = (TYMachine*)pElement;
1145  if (pDialog->_checkBoxNomMachine->isChecked())
1146  {
1147  paint.drawText(x, y, TR("id_print_nom_machine"));
1148  paint.drawText(x1, y, pMachine->getName());
1149  y += stepy;
1150  }
1151  if (pDialog->_checkBoxConstrMachine->isChecked())
1152  {
1153  paint.drawText(x, y, TR("id_print_constr"));
1154  paint.drawText(x1, y, pMachine->getConstructeur());
1155  y += stepy;
1156  }
1157  if (pDialog->_checkBoxModelMachine->isChecked())
1158  {
1159  paint.drawText(x, y, TR("id_print_model"));
1160  paint.drawText(x1, y, pMachine->getModele());
1161  y += stepy;
1162  }
1163  if (pDialog->_checkBoxCatMachine->isChecked())
1164  {
1165  paint.drawText(x, y, TR("id_print_cat"));
1166  paint.drawText(x1, y, QString().setNum(pMachine->getCategorie()));
1167  y += stepy;
1168  }
1169  if (pDialog->_checkBoxCommentProjet->isChecked())
1170  {
1171  paint.drawText(x, y, TR("id_print_comment"));
1172  paint.drawText(x1, y, pMachine->getCommentaire());
1173  }
1174  }
1175  else
1176  {
1177  TYSiteNode* pSite = dynamic_cast<TYSiteNode*>(pElement);
1178  if (pSite != nullptr)
1179  {
1180  if (pDialog->_checkBoxNomSite->isChecked())
1181  {
1182  paint.drawText(x, y, TR("id_print_nom_site"));
1183  paint.drawText(x1, y, pSite->getName());
1184  }
1185  }
1186  }
1187  }
1188  }
1189 
1190  delete printer;
1191  }
1192 }
1193 
1195 {
1196  if (_pElement)
1197  {
1198  if (_pElement->edit(this) == QDialog::Accepted)
1199  {
1200  emit eltModified(_pElement);
1201  }
1202 
1203  // On update ds ts les cas si un child a ete modifie...
1204  _pElement->getGraphicObject()->update(true);
1206  updateView(false, false);
1207  }
1208 }
1209 
1211 {
1212  // XBH: version simplifiee et +logique...
1213 
1214  OBox boundingBox;
1215  TYElementGraphic* pTYElementGraphic = pElement->getGraphicObject();
1216 
1217  if (pTYElementGraphic != NULL)
1218  {
1219  pTYElementGraphic->computeBoundingBox();
1220  boundingBox = pTYElementGraphic->GetBox();
1221  }
1222 
1223  return boundingBox;
1224 }
1225 
1227 {
1228  OBox globalBoundingBox;
1229  if (_pElement)
1230  {
1231  TYElement* pTYElement = (TYElement*)_pElement;
1232  TYProjet* pTYProjet = dynamic_cast<TYProjet*>(pTYElement);
1233  if (pTYProjet != nullptr)
1234  {
1235  TYSiteNode* pTYSiteNode = (TYSiteNode*)pTYProjet->getSite();
1236  pTYElement = pTYSiteNode;
1237  }
1238 
1239  globalBoundingBox = getBoundingBox(pTYElement);
1240  }
1241  return globalBoundingBox;
1242 }
1243 
1245 {
1246  int visibilityStates[9];
1247 
1248  // Sauvegarde des etats de visibilite des objets graphiques
1249  // de "decoration", ils ne doivent pas participer au recadrage
1250 #ifndef NO_GRID
1251  visibilityStates[0] = _pOGLGridElement->getShowGridXY();
1252  visibilityStates[1] = _pOGLGridElement->getShowGridXZ();
1253  visibilityStates[2] = _pOGLGridElement->getShowGridZY();
1254 #endif//NO_GRID
1255 
1256  setGridLinesActorsVisibility(false, false, false);
1257 
1258  visibilityStates[3] = _pOGLLineElementAxeX->getVisibility();
1262  visibilityStates[4] = _pOGLTextElementLabelX->getVisibility();
1264  visibilityStates[5] = _pOGLTextElementLabelY->getVisibility();
1266  visibilityStates[6] = _pOGLTextElementLabelZ->getVisibility();
1268 
1269  visibilityStates[7] = _pOGLLineElementX->getVisibility();
1271  visibilityStates[8] = _pOGLLineElementY->getVisibility();
1273 
1274  //az-- : pour tests reperes machines:
1275  OBox globalBoundingBox = getGlobalBoundingBox();
1276 
1277  float xMin = globalBoundingBox._min._x;
1278  float xMax = globalBoundingBox._max._x;
1279  float yMin = globalBoundingBox._min._y;
1280  float yMax = globalBoundingBox._max._y;
1281  float zMin = globalBoundingBox._min._z;
1282  float zMax = globalBoundingBox._max._z;
1283  float xDist = max(abs(xMin), abs(xMax)) * 2;
1284  float yDist = max(abs(yMin), abs(yMax)) * 2;
1285  float zDist = max(abs(zMin), abs(zMax)) * 2;
1286 
1287  // Cameras pour chaque type de vue
1288  NxReal fromTop[3] = { 0, 500, 0 };
1289  NxReal toTop[3] = { 0, 0, 0 };
1290  NxReal upTop[3] = { 0, 0, -1 };
1291  _pOGLCameras[TopView]->setFromToUp(fromTop, toTop, upTop);
1293  _pOGLCameras[TopView]->resetZoom(xDist, yDist);
1294 
1295  NxReal fromLeft[3] = { -500, 0, 0 };
1296  NxReal toLeft[3] = { 0, 0, 0 };
1297  NxReal upLeft[3] = { 0, 1, 0 };
1298  _pOGLCameras[LeftView]->setFromToUp(fromLeft, toLeft, upLeft);
1299  _pOGLCameras[LeftView]->resetZoom(yDist, zDist);
1300 
1301  NxReal fromFront[3] = { 0, 0, 500 };
1302  NxReal toFront[3] = { 0, 0, 0 };
1303  NxReal upFront[3] = { 0, 1, 0 };
1304  _pOGLCameras[FrontView]->setFromToUp(fromFront, toFront, upFront);
1305  _pOGLCameras[FrontView]->resetZoom(xDist, zDist);
1306 
1307  NxReal fromPersp[3] = { 0, 1000, 1000 };
1308  NxReal toPersp[3] = { 0, 0, 0 };
1309  NxReal upPersp[3] = { 0, 1, 0 };
1310  _pOGLCameras[PerspView]->setFromToUp(fromPersp, toPersp, upPersp);
1311  _pOGLCameras[PerspView]->resetZoom(xDist, yDist);
1313  _pOGLCameras[PerspView]->setDistanceStep(30, 70, 30);
1314 
1315  NxReal fromFree[3] = { 0, 0, 0 };
1316  NxReal toFree[3] = { 0, 0, 0.1 };
1317  NxReal upFree[3] = { 0, 1, 0 };
1318  _pOGLCameras[FreeView]->setFromToUp(fromFree, toFree, upFree);
1323 
1324 
1325  // Restauration des etats de visibilite des objets graphiques
1326 #ifndef NO_GRID
1327  setGridLinesActorsVisibility(visibilityStates[0], visibilityStates[1], visibilityStates[2]);
1328 #endif//NO_GRID
1329  _pOGLLineElementAxeX->setVisibility(visibilityStates[3]);
1330  _pOGLLineElementAxeY->setVisibility(visibilityStates[3]);
1331  _pOGLLineElementAxeZ->setVisibility(visibilityStates[3]);
1332  _pOGLTextElementLabelX->setVisibility(visibilityStates[4]);
1333  _pOGLTextElementLabelY->setVisibility(visibilityStates[5]);
1334  _pOGLTextElementLabelZ->setVisibility(visibilityStates[6]);
1335  _pOGLLineElementX->setVisibility(visibilityStates[7]);
1336  _pOGLLineElementY->setVisibility(visibilityStates[8]);
1337 
1339  updateView();
1340 }
1341 
1342 void TYModelerFrame::updateView(bool clipping /*=true*/, bool axesAndGrid /*=true*/)
1343 {
1344  //first look at to update camera positions
1345  if (getRenderer()->getActiveCamera())
1346  {
1348  glMatrixMode(GL_MODELVIEW);
1349 
1350  if (axesAndGrid)
1351  {
1352  updateAxes();
1353  updateGrid();
1354  updateCurPosInfo();
1355  updateScale();
1356  }
1357 
1358  if (clipping)
1359  {
1360  // Update le render mode
1361  setRenderMode(getRenderMode(), false);
1362  }
1363 
1364  _pOGLTextElement->setDisplayPosition(7, rect().bottom() - rect().top() - 88);
1365  _pOGLScalarBarElement->setPosition(OPoint3D(rect().right() - rect().left() - 100, 50, 0));
1367 
1368  //RNU
1369  //_pView->getRenderer()->updateDisplayList();
1370 
1371  // Update la vue 3D
1372  _pView->updateGL();
1373  }
1374 }
1375 
1377 {
1384 
1385  NxVec3 org = OGLCamera::displayToWorld(NxVec3(50, 50, 0.1));
1386  OCoord3D origine(org.x, org.y, org.z);
1387 
1388  _pOGLLineElementAxeX->setPoint1(OPoint3D(org.x, org.y, org.z));
1389  _pOGLLineElementAxeY->setPoint1(OPoint3D(org.x, org.y, org.z));
1390  _pOGLLineElementAxeZ->setPoint1(OPoint3D(org.x, org.y, org.z));
1391 
1392  NxVec3 extX, extY, extZ;
1393 
1394  switch (getCurrentView())
1395  {
1396  case TopView:
1397  {
1398  extX = OGLCamera::displayToWorld(NxVec3(90, 50, 0.1));
1399  extY = OGLCamera::displayToWorld(NxVec3(50, 90, 0.1));
1400  extZ = OGLCamera::displayToWorld(NxVec3(50, 50, 40.1));
1404  }
1405  break;
1406  case LeftView:
1407  {
1408  extX = OGLCamera::displayToWorld(NxVec3(50, 50, 40.1));
1409  extY = OGLCamera::displayToWorld(NxVec3(10, 50, 0.1));
1410  extZ = OGLCamera::displayToWorld(NxVec3(50, 90, 0.1));
1414  }
1415  break;
1416  case FrontView:
1417  {
1418  extX = OGLCamera::displayToWorld(NxVec3(90, 50, 0.1));
1419  extY = OGLCamera::displayToWorld(NxVec3(50, 50, 40.1));
1420  extZ = OGLCamera::displayToWorld(NxVec3(50, 90, 0.1));
1424  }
1425  break;
1426  case PerspView:
1427  case FreeView:
1428  {
1429  NxVec3 org2 = OGLCamera::displayToWorld(NxVec3(50, 90, 0.1));
1430  double dist = org.distance(org2);
1431  extX.x = org.x + dist;
1432  extX.y = org.y;
1433  extX.z = org.z;
1434  extY.x = org.x;
1435  extY.y = org.y;
1436  extY.z = org.z - dist;
1437  extZ.x = org.x;
1438  extZ.y = org.y + dist;
1439  extZ.z = org.z;
1440 
1441  NxVec3 dispX = OGLCamera::worldToDisplay(extX);
1442  NxVec3 dispY = OGLCamera::worldToDisplay(extY);
1443  NxVec3 dispZ = OGLCamera::worldToDisplay(extZ);
1444 
1448  }
1449  break;
1450  }
1451 
1452  OPoint3D extremiteX(extX.x, extX.y, extX.z);
1453  OPoint3D extremiteY(extY.x, extY.y, extY.z);
1454  OPoint3D extremiteZ(extZ.x, extZ.y, extZ.z);
1455 
1456  _pOGLLineElementAxeX->setPoint2(extremiteX);
1457  _pOGLLineElementAxeY->setPoint2(extremiteY);
1458  _pOGLLineElementAxeZ->setPoint2(extremiteZ);
1459 }
1460 
1461 void TYModelerFrame::keyPressEvent(QKeyEvent* pEvent)
1462 {
1463  switch (pEvent->key())
1464  {
1465  case Qt::Key_1: setViewType(TopView); break;
1466  case Qt::Key_2: setViewType(LeftView); break;
1467  case Qt::Key_3: setViewType(FrontView); break;
1468  case Qt::Key_4: setViewType(PerspView); break;
1469  case Qt::Key_5: setViewType(FreeView); break;
1470  case Qt::Key_V: setViewType((getCurrentView() + 1) % NbOfViews); break;
1471  case Qt::Key_I: _pView->showInfos(!_pView->getShowInfos()); break;
1472  case Qt::Key_G: showGrid(!_showGrid); break;
1473  case Qt::Key_R: setRenderMode((getRenderMode() + 1) % NbOfRenderMode, true); break;
1474  case Qt::Key_W: setRenderMode(Wireframe, true); break;
1475  case Qt::Key_S: setRenderMode(Surface, true); break;
1476  case Qt::Key_Control: setSnapGridActive(false); break;
1477  case Qt::Key_C: if (pEvent->modifiers() == Qt::ControlModifier) { copy(); }
1478  else { setEditorModeToCamera(); }
1479  break;
1480  case Qt::Key_F:
1481  case Qt::Key_F5: fit(); break;
1482  default: TYApplication::sendEvent(_pView, pEvent);
1483  }
1484 }
1485 
1486 void TYModelerFrame::keyReleaseEvent(QKeyEvent* pEvent)
1487 {
1488  switch (pEvent->key())
1489  {
1490  case Qt::Key_Control: setSnapGridActive(true); break;
1491  default: TYApplication::sendEvent(_pView, pEvent);
1492  }
1493 }
1494 
1495 void TYModelerFrame::mouseMoveEvent(QMouseEvent* pEvent)
1496 {
1497 }
1498 
1500 {
1501  // On recupere la pos du curseur
1502  QPoint curPos = _pView->mapFromGlobal(QCursor::pos());
1503 
1504  // Calcul des coords
1505  float* pos = new float[3];
1506 
1507  if (computeCurPos(curPos.x(), curPos.y(), pos))
1508  {
1509  // Si la grille magnetique est activee
1510  if (getSnapGridActive())
1511  {
1512  TYAbstractSceneEditor::snapToGrid(pos[0], pos[1], pos[2]);
1513  }
1514 
1515  // Formatage du msg
1516  QString msg("pos : (%1, %2, %3)");
1517  // On inverse y et z, et -y... (VTK to TY)
1518  msg = msg.arg(pos[0], 0, 'f', 2).arg(-pos[2], 0, 'f', 2).arg(pos[1], 0, 'f', 2);
1519  // Affichage
1520  statusBar()->showMessage(msg);
1521  }
1522  else
1523  {
1524  if (getCurrentView() == FreeView)
1525  {
1526  double x, y, z;
1528  QString msg = QString("camera pos : (%1, %2, %3)").arg(x).arg(-z).arg(y);
1529  statusBar()->showMessage(msg);
1530  }
1531  else
1532  {
1533  statusBar()->showMessage("");
1534  }
1535  }
1536 
1537  delete[] pos;
1538 }
1539 
1540 //float* TYModelerFrame::computeCurPos(int x, int y)
1541 bool TYModelerFrame::computeCurPos(int x, int y, float* ret)
1542 {
1543  int view = getCurrentView();
1544  if ((view != PerspView) && (view != FreeView))
1545  {
1546  // Position du curseur
1547  NxVec3 pos = OGLCamera::displayToWorld(NxVec3(x, _pView->height() - y, 0));
1548  ret[0] = pos.x;
1549  ret[1] = pos.y;
1550  ret[2] = pos.z;
1551 
1552  switch (getCurrentView())
1553  {
1554  case TopView: ret[1] = 0.0; break;
1555  case LeftView: ret[0] = 0.0; break;
1556  case FrontView: ret[2] = 0.0; break;
1557  }
1558 
1559  return true;
1560  }
1561 
1562  return false;
1563 }
1564 
1565 void TYModelerFrame::setGridLinesActorsVisibility(bool showGridXY, bool showGridXZ, bool showGridZY)
1566 {
1567 #ifndef NO_GRID
1568  _pOGLGridElement->setShowGridXY(showGridXY);
1569  _pOGLGridElement->setShowGridXZ(showGridXZ);
1570  _pOGLGridElement->setShowGridZY(showGridZY);
1571 #endif//NO_GRID
1572 }
1573 
1574 void TYModelerFrame::wheelEvent(QWheelEvent* pEvent)
1575 {
1576  // Reroute l'event sur le TYRenderWindowInteractor
1577  TYApplication::sendEvent(_pView, pEvent);
1578 }
1579 
1580 void TYModelerFrame::resizeEvent(QResizeEvent* pEvent)
1581 {
1582  /* _pView->getRenderer()->updateDisplayList();
1583  updateView();
1584  _pView->getRenderer()->updateDisplayList();*/
1585  updateView();
1586 
1587  // CLM-NT33 : Gestion du maximized et titre fenetre principal
1588  emit frameResized();
1589 }
1590 
1591 void TYModelerFrame::focusInEvent(QFocusEvent* pEvent)
1592 {
1593  /* _pView->getRenderer()->updateDisplayList();
1594  updateView();
1595  _pView->getRenderer()->updateDisplayList();*/
1596  updateView();
1597 }
1598 
1599 void TYModelerFrame::showEvent(QShowEvent* pEvent)
1600 {
1601  if (_firstTimeShown)
1602  {
1603  TYPreferenceManager::loadGeometryFromPreferences(metaObject()->className(), this);
1604  _firstTimeShown = false;
1605  }
1606  /* _pView->getRenderer()->updateDisplayList();
1607  updateView();
1608  _pView->getRenderer()->updateDisplayList();*/
1609  updateView();
1610 }
1611 
1612 void TYModelerFrame::closeEvent(QCloseEvent* pEvent)
1613 {
1614  TYPreferenceManager::saveGeometryToPreferences(metaObject()->className(), this);
1615  pEvent->accept();
1616  emit frameResized();
1617  emit aboutToClose();
1618 
1619  // CLM-NT35 : Gestion du maximized et titre fenetre principal
1620 
1621 }
1622 
1623 void TYModelerFrame::enterEvent(QEvent* pEvent)
1624 {
1625  /* _pView->getRenderer()->updateDisplayList();
1626  updateView();
1627  _pView->getRenderer()->updateDisplayList();
1628  updateView();*/
1629  emit mouseEnter();
1630 }
1631 
1632 void TYModelerFrame::leaveEvent(QEvent* pEvent)
1633 {
1634  emit mouseLeave();
1635 }
1636 
1638 {
1639  if ((getCurrentView() == PerspView) || (getCurrentView() == FreeView))
1640  {
1643 
1646  }
1647  else
1648  {
1649  int gridXMax = _pView->width();
1650  int gridYMax = _pView->height();
1651  if (gridXMax == 0) { gridXMax = 100; }
1652  if (gridYMax == 0) { gridYMax = 100; }
1653 
1654  //getCenter
1655  NxVec3 center = OGLCamera::worldToDisplay(NxVec3(0, 0, 0));
1656 
1657  //X
1658  NxVec3 posX = OGLCamera::displayToWorld(NxVec3(center.x, 0, 0));
1659  NxVec3 posX2 = OGLCamera::displayToWorld(NxVec3(center.x, gridYMax, 0));
1660  OPoint3D pt1(posX.x, posX.y, posX.z);
1662  OPoint3D pt2(posX2.x, posX2.y, posX2.z);
1663  if ((pt1._x != pt2._x) || (pt1._y != pt2._y) || (pt1._z != pt2._z))
1664  {
1665  _pOGLLineElementX->setPoint2(OPoint3D(posX2.x, posX2.y, posX2.z));
1666  OVector3D vecX(pt1, pt2);
1667  }
1668 
1669  //Y
1670  NxVec3 posY = OGLCamera::displayToWorld(NxVec3(0, center.y, 0));
1671  NxVec3 posY2 = OGLCamera::displayToWorld(NxVec3(gridXMax, center.y, 0));
1672  pt1.setCoords(posY.x, posY.y, posY.z);
1674  pt2.setCoords(posY2.x, posY2.y, posY2.z);
1675  if ((pt1._x != pt2._x) || (pt1._y != pt2._y) || (pt1._z != pt2._z))
1676  {
1678  OVector3D vecY(pt1, pt2);
1679  }
1680  }
1681 }
1682 
1683 void TYModelerFrame::updateElementGraphic(bool force /* = false */)
1684 {
1685  if (_pElement && _pElement->getGraphicObject())
1686  {
1687  _pElement->getGraphicObject()->update(force);
1688  }
1689 }
1690 
1692 {
1696 
1697  _pOGLLineElementX->setColor(OColor(gridColor[0], gridColor[1], gridColor[2]));
1698  _pOGLLineElementY->setColor(OColor(gridColor[0], gridColor[1], gridColor[2]));
1699 }
1700 
1702 {
1703  // Mise a jour de la taille de l'historique de l'Action Manager
1704  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "HistoSize"))
1705  {
1706  _actionManager.setHistorySize(TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "HistoSize"));
1707  }
1708  else
1709  {
1710  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "HistoSize", _actionManager.getHistorySize());
1711  }
1712 
1713  // Mise a jour de l'etat d'activation du delplacement de camera en mode Wireframe
1714  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "WireframeOnMovingCamera"))
1715  {
1716  setWireframeOnMovingCamera(TYPreferenceManager::getBool(TYDIRPREFERENCEMANAGER, "WireframeOnMovingCamera"));
1717  }
1718  else
1719  {
1720  TYPreferenceManager::setBool(TYDIRPREFERENCEMANAGER, "WireframeOnMovingCamera", false);
1722  }
1723 
1724  // Mise a jour des couleurs a partir des preferences.
1725  // Couleur de fond
1726  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "BackgroundColorR"))
1727  {
1728  float r, g, b;
1729  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "BackgroundColor", r, g, b);
1730  rendererColor[0] = r / 255;
1731  rendererColor[1] = g / 255;
1732  rendererColor[2] = b / 255;
1733  }
1734  else
1735  {
1736  float r = rendererColor[0] * 255;
1737  float g = rendererColor[1] * 255;
1738  float b = rendererColor[2] * 255;
1739  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "BackgroundColor", r, g, b);
1740  }
1741 
1742  getRenderer()->setBackground(rendererColor);
1743 
1744  // Couleur de la grille
1745  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "GridColorR"))
1746  {
1747  float r, g, b;
1748  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "GridColor", r, g, b);
1749  gridColor[0] = r / 255;
1750  gridColor[1] = g / 255;
1751  gridColor[2] = b / 255;
1752  }
1753  else
1754  {
1755  float r = gridColor[0] * 255;
1756  float g = gridColor[1] * 255;
1757  float b = gridColor[2] * 255;
1758  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "GridColor", r, g, b);
1759  }
1760 
1761  // Couleur de la police
1762  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "FontColorR"))
1763  {
1764  float r, g, b;
1765  TYPreferenceManager::getColor(TYDIRPREFERENCEMANAGER, "FontColor", r, g, b);
1766  fontColor[0] = r / 255;
1767  fontColor[1] = g / 255;
1768  fontColor[2] = b / 255;
1769  }
1770  else
1771  {
1772  float r = fontColor[0] * 255;
1773  float g = fontColor[1] * 255;
1774  float b = fontColor[2] * 255;
1775  TYPreferenceManager::setColor(TYDIRPREFERENCEMANAGER, "FontColor", r, g, b);
1776  }
1777 
1781  _pOGLScalarBarElement->setFontColor(OColor(fontColor[0], fontColor[1], fontColor[2]));
1782 
1783  // Mise a jour de l'eclairage de la scene.
1784  float intensity = 0.83f;
1785  if ((TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "Luminosite")))
1786  {
1787  intensity = TYPreferenceManager::getDouble(TYDIRPREFERENCEMANAGER, "Luminosite");
1788  }
1789  else
1790  {
1791  TYPreferenceManager::setDouble(TYDIRPREFERENCEMANAGER, "Luminosite", intensity);
1792  }
1793 
1794  if (intensity < 0.1f) { intensity = 0.1f; }
1795  _pLightElement->setIntensity(intensity);
1796 
1797  // Mise a jour de la tolerance du picking.
1798  float precisPick = 3.0;
1799  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "PrecisPick"))
1800  {
1801  precisPick = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "PrecisPick");
1802  }
1803  else
1804  {
1805  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "PrecisPick", precisPick);
1806  }
1807  _pPickEditor->setPickTolerance(precisPick);
1809 
1810  // Mise a jour du pas de zoom de la mollette de la souris.
1811  float zoomStep = 0.2f;
1812  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "ZoomStep"))
1813  {
1814  zoomStep = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "ZoomStep");
1815  }
1816  else
1817  {
1818  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "ZoomStep", zoomStep);
1819  }
1820  _pCameraEditor->setWheelStep(zoomStep);
1821 
1822  // Mise a jour du pas de l'angle du positionEditor
1823  float angle = 15.0;
1824  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "Angle"))
1825  {
1826  angle = TYPreferenceManager::getFloat(TYDIRPREFERENCEMANAGER, "Angle");
1827  }
1828  else
1829  {
1830  TYPreferenceManager::setFloat(TYDIRPREFERENCEMANAGER, "Angle", angle);
1831  }
1832 
1834 
1835  // Mise a jour des fonctions attachees a la souris.
1836  // 2D
1837  // bouton gauche
1838  int mouseLeftButtonFunct2D = 1;
1839  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct2D"))
1840  {
1841  mouseLeftButtonFunct2D = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct2D");
1842  }
1843 
1844  else
1845  {
1846  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct2D", mouseLeftButtonFunct2D);
1847  }
1848 
1849  switch (mouseLeftButtonFunct2D)
1850  {
1853  }
1854 
1855  // bouton droit
1856  int mouseRightButtonFunct2D = 0;
1857  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct2D"))
1858  {
1859  mouseRightButtonFunct2D = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct2D");
1860  }
1861  else
1862  {
1863  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct2D", mouseRightButtonFunct2D);
1864  }
1865 
1866  switch (mouseRightButtonFunct2D)
1867  {
1870  }
1871 
1872 
1873  // bouton central
1874  int mouseMiddleButtonFunct2D = 0;
1875  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct2D"))
1876  {
1877  mouseMiddleButtonFunct2D = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct2D");
1878  }
1879  else
1880  {
1881  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct2D", mouseMiddleButtonFunct2D);
1882  }
1883 
1884  switch (mouseMiddleButtonFunct2D)
1885  {
1888  }
1889 
1890 
1891  // en 3D
1892  // bouton gauche
1893  int mouseLeftButtonFunct3D = 3;
1894  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct3D"))
1895  {
1896  mouseLeftButtonFunct3D = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct3D");
1897  }
1898  else
1899  {
1900  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseLeftButtonFunct3D", mouseLeftButtonFunct3D);
1901  }
1902 
1903  switch (mouseLeftButtonFunct3D)
1904  {
1909  }
1910 
1911 
1912  // bouton droit
1913  int mouseRightButtonFunct3D = 0;
1914  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct3D"))
1915  {
1916  mouseRightButtonFunct3D = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct3D");
1917  }
1918  else
1919  {
1920  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseRightButtonFunct3D", mouseRightButtonFunct3D);
1921  }
1922 
1923  switch (mouseRightButtonFunct3D)
1924  {
1929  }
1930 
1931 
1932  // bouton central
1933  int mouseMiddleButtonFunct3D = 2;
1934  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct3D"))
1935  {
1936  mouseMiddleButtonFunct3D = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct3D");
1937  }
1938  else
1939  {
1940  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseMiddleButtonFunct3D", mouseMiddleButtonFunct3D);
1941  }
1942 
1943  switch (mouseMiddleButtonFunct3D)
1944  {
1949  }
1950 
1951  // Mode shift.
1952  // 2D
1953  // bouton gauche
1954  int mouseShiftLeftButtonFunct2D = 1;
1955  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct2D"))
1956  {
1957  mouseShiftLeftButtonFunct2D = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct2D");
1958  }
1959  else
1960  {
1961  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct2D", mouseShiftLeftButtonFunct2D);
1962  }
1963 
1964  switch (mouseShiftLeftButtonFunct2D)
1965  {
1968  }
1969 
1970 
1971  // bouton droit
1972  int mouseShiftRightButtonFunct2D = 0;
1973  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct2D"))
1974  {
1975  mouseShiftRightButtonFunct2D = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct2D");
1976  }
1977  else
1978  {
1979  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct2D", mouseShiftRightButtonFunct2D);
1980  }
1981 
1982  switch (mouseShiftRightButtonFunct2D)
1983  {
1986  }
1987 
1988 
1989  // en 3D
1990  // bouton gauche
1991  int mouseShiftLeftButtonFunct3D = 1;
1992  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct3D"))
1993  {
1994  mouseShiftLeftButtonFunct3D = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct3D");
1995  }
1996  else
1997  {
1998  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseShiftLeftButtonFunct3D", mouseShiftLeftButtonFunct3D);
1999  }
2000 
2001  switch (mouseShiftLeftButtonFunct3D)
2002  {
2007  }
2008 
2009 
2010  // bouton droit
2011  int mouseShiftRightButtonFunct3D = 2;
2012  if (TYPreferenceManager::exists(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct3D"))
2013  {
2014  mouseShiftRightButtonFunct3D = TYPreferenceManager::getInt(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct3D");
2015  }
2016  else
2017  {
2018  TYPreferenceManager::setInt(TYDIRPREFERENCEMANAGER, "MouseShiftRightButtonFunct3D", mouseShiftRightButtonFunct3D);
2019  }
2020 
2021  switch (mouseShiftRightButtonFunct3D)
2022  {
2027  }
2028 
2029  // Force un update de la camera
2031 
2032  // Update de l'editor courant
2033  // setEditorMode(_lastEditorMode); // DTn : Correction du bug #0009661
2034 
2035  // Mets a jour la structure graphique de l'element
2036  updateElementGraphic(true);
2037 
2038  // Refresh
2039  updateView(false);
2040 }
2041 
2043 {
2044  // On passe en mode Wireframe si l'option est activee et qu'on est
2045  // pas deja dans ce mode
2047  {
2048  // On conserve le mode courant
2050  // On passe en Wireframe
2051  setRenderMode(Wireframe, false);
2052  }
2053 }
2054 
2056 {
2058  {
2059  // On revient dans le mode courant
2061  }
2062 }
2063 
2065 {
2066  if (_showScale)
2067  {
2068  NxVec3 val3D = OGLCamera::displayToWorld(NxVec3(0.0, 0.0, 0.1));
2069  TYPoint pt0(val3D.x, val3D.y, val3D.z);
2070  val3D = OGLCamera::displayToWorld(NxVec3(10, 0.0, 0.1));
2071  TYPoint pt1(val3D.x, val3D.y, val3D.z);
2072 
2073  OVector3D vect(pt0, pt1);
2074  double value = vect.norme();
2075 
2076  QString max = QString().setNum(value * 10, 'f', 1);
2077  QString mid = QString().setNum(value * 10 / 2, 'f', 1);
2078 
2079  _pOGLScalarBarElement->setTexts("0", mid.toStdString(), max.toStdString());
2080  }
2081 }
2082 
2084 {
2085  _showScale = show;
2086 
2088 
2090  updateView(false, true);
2091 }
2092 
2093 
void setMiddleButtonFunction3D(void(TYCameraEditor::*function)())
virtual void focusInEvent(QFocusEvent *pEvent)
QGroupBox * _groupBoxProjet
Definition: TYPrintDialog.h:61
TYCameraEditor * _pCameraEditor
Gere la camera.
QCheckBox * _checkBoxAuteurProjet
Definition: TYPrintDialog.h:63
QToolButton * _pSetCameraCoordinatesBtn
Bouton de specification des coordonnees de la camera.
void setGridDimY(const float gridDimY)
void showGrid(bool show)
QToolButton * _pShowSourcesBtn
Bouton pour l&#39;affichage des sources ponctuelles.
outil de mesure des distances
virtual bool close()
The 3D vector class.
Definition: 3d.h:296
void setMode(int mode)
virtual void enterEvent(QEvent *pEvent)
NxReal y
Definition: NxVec3.h:80
Definition: NxVec3.h:22
QString getComment() const
Get des commentaires.
Definition: TYCalcul.h:181
gestion de la position selon les modes &#39;moving&#39;, &#39;rotation&#39;, &#39;edition&#39;
void getTranslation(double &x, double &y, double &z)
Definition: OGLCamera.cpp:838
OPoint3D _max
Maximal coordinates of the OBox.
Definition: 3d.h:1368
gestion des elements selectionnes par picking (fichier header)
static bool _gDrawNormals
Indique si les normals doivent etre visible.
static bool _gVisible
Indique si toutes les instances sont visibles.
Definition: TYRayGraphic.h:51
void showNormals(bool show)
void setSnapGridActive(bool state)
int _curViewType
Le type de la vue courante.
void setTexts(const std::string &text0, const std::string &text1, const std::string &text2)
TYRenderWindowInteractor * _pView
La fenetre graphique.
void lookAt()
Definition: OGLCamera.cpp:78
float r
Definition: color.h:33
Gestion de l&#39;edition en mode camera.
bool isElementInCurrentProjet()
const char * name
void setCameraCoordinates()
virtual void init()
Appeler avant l&#39;utilisation de l&#39;editor.
void init(int width, int height)
void setIs3D(bool bIs3D)
Definition: OGLElement.h:46
float b
Definition: color.h:33
void showPlafond(bool show)
void eltModified(LPTYElement pElt)
void setTranslation(double x, double y, double z)
Definition: OGLCamera.cpp:832
QCheckBox * _checkBoxNomBatiment
Definition: TYPrintDialog.h:77
OGLLineElement * _pOGLLineElementY
Representation graphique d&#39;une source lineique (fichier header)
QToolButton * _pScreenShotBtn
Bouton pour effectuer une capture d&#39;ecran.
QComboBox * _pRenderModeBox
Combo box pour le mode de rendu.
virtual void updateView(bool clipping=true, bool axesAndGrid=true)
QCheckBox * _checkBoxNomProjet
Definition: TYPrintDialog.h:65
QCheckBox * _checkBoxCommentCalcul
Definition: TYPrintDialog.h:67
QLineEdit * _lineEditTitre
Definition: TYPrintDialog.h:86
void setPoint2(const OPoint3D &point2)
static bool _gVisible
Indique si toutes les instances sont visibles.
Boite de dialogue des parametres d&#39;impression (fichier header)
void setWheelStep(float step)
virtual void setViewType(int view)
void frameResized()
bool _showScale
Indique si on affiche ou pas l&#39;echelle.
bool _showSources
Indique si on affiche ou pas les sources ponctuelles.
virtual void updateGL()
bool _showRays
Indique si on affiche ou pas les rayons.
#define TYDIRPREFERENCEMANAGER
Definition: TYElement.h:54
gestion de l&#39;element actionne par picking (fichier header)
Definition: OGLCamera.h:37
TYPositionEditor * _pPositionEditor
Editor pour deplacer les elements.
void setFont(const QString &qsFontPath)
void setGridStep(const float gridStep)
Repositionnement de la camera en fonction de coordonnees specifiees.
virtual ~TYModelerFrame()
classe de definition d&#39;un projet.
Definition: TYProjet.h:46
virtual void keyPressEvent(QKeyEvent *pEvent)
bool _showPlafond
Indique si on affiche ou masque les normals.
static NxVec3 worldToDisplay(NxVec3 world)
Definition: OGLCamera.cpp:709
bool askForResetResultat()
Previent l&#39;utilisateur que le resultat va etre efface, si celui-ci est valide.
#define NxReal
Definition: NxVec3.h:20
QToolButton * _pGridBtn
Bouton d&#39;activation de la grille.
virtual void setEditorMode(int mode)
pour l&#39;application Tympan (fichier header)
Le role de cette classe est limite a emettre des signaux pouvant etre utilise pour interagir sur le r...
#define IMG(id)
OGLCamera * getActiveCamera()
void setLeftButtonFunction2D(void(TYCameraEditor::*function)())
OGLLineElement * _pOGLLineElementX
Axes X et Y de la grille.
int getCategorie() const
Definition: TYMachine.h:87
virtual void close()
Appeler apres l&#39;utilisation de l&#39;editor.
void setBackground(double *bgColor)
void setShowGridXY(bool bShow)
double norme() const
Computes the length of this vector.
Definition: 3d.cpp:237
void updateDisplayList(void)
void setTextToDisplay(const QString &qsText)
static NxVec3 displayToWorld(NxVec3 display)
Definition: OGLCamera.cpp:686
QComboBox * _pViewTypeBox
Combo box pour la selection de la camera courante.
void setFromToUp(NxReal *_from, NxReal *_to, NxReal *_up)
Definition: OGLCamera.cpp:580
void useHighlight(bool state)
Definition: TYPickEditor.h:85
QString getDateModif() const
Get de la date de modification.
Definition: TYProjet.h:121
virtual void keyReleaseEvent(QKeyEvent *pEvent)
virtual void showEvent(QShowEvent *pEvent)
OGLLineElement * _pOGLLineElementAxeX
La geometrie des Axes.
float _gridStep
Pas de la grille.
QCheckBox * _checkBoxCommentProjet
Definition: TYPrintDialog.h:62
void setGridDimX(const float gridDimX)
void setLeftButtonFunction3D(void(TYCameraEditor::*function)())
virtual void leaveEvent(QEvent *pEvent)
void setRightButtonFunction3D(void(TYCameraEditor::*function)())
bool _editorModeAccepted
Indique si le mode d&#39;edition a ete traite.
void setPickPointPrecision(float precision)
QStatusBar * _pStatusBar
Barre d&#39;etat.
Classe generique pour une fenetre de modeleur (fichier header)
float _gridDimY
Dimension de la grille en Y.
QCheckBox * _checkBoxCatMachine
Definition: TYPrintDialog.h:73
bool getSnapGridActive()
void setCoords(double x, double y, double z)
Sets the coordinates as an array of double.
Definition: 3d.cpp:83
The box class.
Definition: 3d.h:1292
TYActionManager _actionManager
Pour la gestion de l&#39;historique.
OGLTextElement * _pOGLTextElement
Label 2D pour afficher le type de la vue.
TYPickEditor * _pPickEditor
Gere le menu contextuel.
#define TR(id)
virtual void disconnect()
Deconnecte cet editor a l&#39;interactor associe.
OGLGridElement * _pOGLGridElement
bool getShowGridZY()
QGroupBox * _groupBoxMachine
Definition: TYPrintDialog.h:78
void setFontColor(const OColor &oFontColor)
OGLTextElement * _pOGLTextElementLabelX
void setWireframeOnMovingCamera(bool state)
void setPickTolerance(float tolerance)
Definition: TYPickEditor.h:58
TYModelerFrame(QWidget *parent=0, const char *name=0, Qt::WindowFlags f=0)
void init(int index, OPoint3D position, float intensity)
TYElement * getParent() const
Definition: TYElement.h:656
virtual void closeEvent(QCloseEvent *pEvent)
QToolButton * _pShowRaysBtn
Bouton pour l&#39;affichage des rayons calcules par le lance de rayons.
void aboutToClose()
void showInfos(bool state)
void setPosition(const OPoint3D &position)
gestion de l&#39;element actionne par picking
Definition: TYPickEditor.h:41
void setMiddleButtonFunction2D(void(TYCameraEditor::*function)())
QToolButton * _pShowScale
Bouton pour l&#39;affichage de l&#39;echelle.
void resetRotations()
Definition: OGLCamera.cpp:824
TYPickEditor * getPickEditor()
TYOpenGLRenderer * getRenderer()
void updateElementGraphic(bool force=false)
double _y
y coordinate of OCoord3D
Definition: 3d.h:281
void setActiveCamera(OGLCamera *pCamera)
bool getShowGridXZ()
double _x
x coordinate of OCoord3D
Definition: 3d.h:280
gestion de la position selon les modes &#39;moving&#39;, &#39;rotation&#39;, &#39;edition&#39; (fichier header) ...
OGLCamera * _pOGLCameras[NbOfViews]
Les cameras pour chaque type de vue.
QString getDateCreation() const
Set/Get de la date de creation.
Definition: TYCalcul.h:160
bool getVisibility()
Definition: OGLElement.h:45
int _lastRenderMode
Le dernier mode de rendu courant.
void setHistorySize(int size)
Definit la taille de l&#39;historique.
QString getCommentaire() const
Definition: TYMachine.h:114
void resetZoom(int w=-1, int h=-1)
Definition: OGLCamera.cpp:786
OPoint3D _min
Minimal coordinates of the OBox.
Definition: 3d.h:1367
QToolButton * _pSnapGridBtn
Bouton d&#39;activation de la grille magnetique.
TYOpenGLRenderer * getRenderer()
OGLLineElement * _pOGLLineElementAxeY
QToolButton * _pShowPlafondBtn
Bouton pour l&#39;affichage des normals.
void setFont(const QString &qsFontPath)
bool _showGrid
Indique si on affiche ou non la grille.
OGLLineElement * _pOGLLineElementAxeZ
LPTYProjet getCurProjet()
Set/Get du projet courant.
Definition: TYApplication.h:99
QString getComment() const
Get des commentaires.
Definition: TYProjet.h:134
virtual void connect()
Connecte cet editor a l&#39;interactor associe.
NxReal x
Definition: NxVec3.h:80
gestion de l&#39;edition de la camera (fichier header)
virtual void setRenderMode(int mode, bool bUpdateGL)
bool _showNormals
Indique si on affiche ou masque les normals.
OGLTextElement * _pOGLTextElementLabelZ
virtual const char * getClassName() const
Definition: TYElement.h:248
void setColor(const OColor &oColor)
void setIntensity(const float intensity)
OGLScalarBarElement * _pOGLScalarBarElement
Objet graphique pour la representation de l&#39;echelle.
void editorModeChanged(int mode)
T * _pObj
The real pointer, must derived IRefCount.
Definition: smartptr.h:285
gestion des elements selectionnes par picking
bool _snapGridActive
Indique si on active ou non la grille magnetique.
int getHistorySize()
Retourne la taille de l&#39;historique.
Repositionnement de la camera en fonction de coordonnees specifiees (fichier header) ...
void setLineWidth(float lineWidth)
QCheckBox * _checkBoxNomCalcul
Definition: TYPrintDialog.h:69
QString getAuteur() const
Get du nom de l&#39;auteur.
Definition: TYProjet.h:95
void setColor(const OColor &oColor)
int id
QStatusBar * statusBar()
int _curRenderMode
Le mode de rendu courant.
void startMovingRenderMode()
virtual void setRenderModeSlot(int mode)
void setShiftLeftButtonFunction3D(void(TYCameraEditor::*function)())
void setSizes(float width, float height)
QCheckBox * _checkBoxDateCalcul
Definition: TYPrintDialog.h:68
void showScale(bool show)
QLineEdit * _lineEditPied
Definition: TYPrintDialog.h:83
void setShowGridXZ(bool bShow)
LPTYCalcul getCurrentCalcul()
Set/Get du pointeur du Calcul courant.
Definition: TYProjet.h:361
QCheckBox * _checkBoxModelMachine
Definition: TYPrintDialog.h:74
LPTYElement _pElement
Un pointeur sur l&#39;element a editer.
virtual void mouseMoveEvent(QMouseEvent *pEvent)
static bool _gVisible
Indique si toutes les instances sont visibles.
QGridLayout * _pLayout
Le layout de cette frame.
void removeOGLElement(OGLElement *pOGLElement)
Definition: color.h:30
OBox getBoundingBox(TYElement *pElement)
void setDisplayPosition(double displayPositionX, double displayPositionY)
Definition: OGLElement.h:43
static void snapToGrid(float &x, float &y, float &z)
Methode utilitaire qui adapte les coordonnees d&#39;un point pour que celui-ci soit aligne avec la grille...
void setEditorModeToCamera()
bool getShowGridXY()
NxReal z
Definition: NxVec3.h:80
classe graphique pour un element de base
void setGridLinesActorsVisibility(bool showGridXY, bool showGridXZ, bool showGridZY)
static bool _gDrawPlafond
Indique si les plafonds doivent etre visible.
void viewTypeChanged(int)
void mouseMoved(int x, int y, Qt::MouseButtons button, Qt::KeyboardModifiers state)
QGroupBox * _groupBoxSite
Definition: TYPrintDialog.h:80
QBoxLayout * _pCtrlLayout
Le layout ou se trouvent les boutons, etc.
virtual bool computeCurPos(int x, int y, float *pos)
LPTYSiteNode getSite()
Get du site.
Definition: TYProjet.h:147
virtual void computeBoundingBox()
void setAngleStep(float step)
The 3D point class.
Definition: 3d.h:484
void setShiftRightButtonFunction2D(void(TYCameraEditor::*function)())
QString getModele() const
Definition: TYMachine.h:105
QLineEdit * _lineEditTete
Definition: TYPrintDialog.h:84
virtual void resizeEvent(QResizeEvent *pEvent)
OGLLightElement * _pLightElement
La lumiere par default.
void setDistanceStep(NxReal _magnitudeStepUp, NxReal _magnitudeStepFront, NxReal _magnitudeStepLeft)
Definition: OGLCamera.cpp:526
double _z
z coordinate of OCoord3D
Definition: 3d.h:282
Representation graphique d&#39;une surface de source (fichier header)
void setPoint1(const OPoint3D &point1)
void setShiftLeftButtonFunction2D(void(TYCameraEditor::*function)())
virtual QString getName() const
Definition: TYElement.h:647
bool askForResetResultat()
virtual void updatePreferences()
bool _wireframeOnMovingCamera
Indique si on passe en rendu wireframe lors de deplacement de camera.
int _lastEditorMode
Pour conserver le dernier mode d&#39;edition.
void setShowGridZY(bool bShow)
The 3D coordinate class.
Definition: 3d.h:229
void setNavigationOnViewType(int view)
Switch auto entre navi 2D ou 3D.
QString getDateModif() const
Get de la date de modification.
Definition: TYCalcul.h:168
QString getConstructeur() const
Definition: TYMachine.h:96
bool isInSelection(TYUUID id)
Test si l&#39;element est present dans la selection de ce Calcul.
Definition: TYCalcul.cpp:907
void showRays(bool show)
TYApplication * getTYApp()
Retourne le pointeur sur l&#39;application.
void setColor(const OColor &oColor)
QCheckBox * _checkBoxConstrMachine
Definition: TYPrintDialog.h:71
void usePopup(bool state)
Definition: TYPickEditor.h:89
void showSources(bool show)
bool isElementInCurrentCalcul()
QString getDateCreation() const
Get de la date de creation.
Definition: TYProjet.h:108
NxReal distance(const NxVec3 &) const
Definition: NxVec3.cpp:218
gestion de l&#39;interaction entre la vue graphique (2D ou 3D) et le clavier et la souris (fichier header...
QGroupBox * _groupBoxCalcul
Definition: TYPrintDialog.h:66
float g
Definition: color.h:33
TYCalculManager * getCalculManager()
Get du gestionnaire de calculs.
Definition: TYApplication.h:93
QCheckBox * _checkBoxNomMachine
Definition: TYPrintDialog.h:72
void setShiftRightButtonFunction3D(void(TYCameraEditor::*function)())
void setRightButtonFunction2D(void(TYCameraEditor::*function)())
outil de mesure des distances (fichier header)
virtual void wheelEvent(QWheelEvent *pEvent)
TYElementPicker * _pPicker
Pour le picking.
TYDistanceEditor * _pDistanceEditor
Outils pour mesurer.
QCheckBox * _checkBoxNomSite
Definition: TYPrintDialog.h:75
QToolButton * _pShowNormalsBtn
Bouton pour l&#39;affichage des normals.
TYAbstractSceneEditor * _pCurrentEditor
L&#39;editor courant.
QGroupBox * _groupBoxBatiment
Definition: TYPrintDialog.h:79
classe pour une boite de dialogue des parametres d&#39;impression.
Definition: TYPrintDialog.h:51
void setVisibility(bool bVisible)
Definition: OGLElement.h:44
QCheckBox * _checkBoxDateProjet
Definition: TYPrintDialog.h:64
OGLTextElement * _pOGLTextElementLabelY
float _gridDimX
Dimension de la grille en X.