AGXDynamics  2.35.0.3
QtViewerMainWindow.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGXQT_QTVIEWERMAINWINDOW_H
18 #define AGXQT_QTVIEWERMAINWINDOW_H
19 
20 #include <agxQt/export.h>
21 #include <agx/config/AGX_USE_KEYSHOT.h>
22 #include <agxQt/QtAgxWrapper.h>
23 #include <agxQt/UtilWidgets.h>
24 #include <agxQt/OsgRenderer.h>
27 #include <agxQt/CameraListWidget.h>
28 #include <agxQt/ClipPlaneWidget.h>
35 
36 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
37 #include <agxQt/ui_QtViewerMainWindow.h>
38 #include <QMainWindow>
39 #include <QWidget>
40 #include <QOpenGLContext>
41 #include <QOpenGLFunctions>
42 #include <QObject>
43 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
44 
45 namespace agxQt
46 {
47  class ParticleRenderWidget;
48 
50  // QtAgxViewerMainWindow
52 
55  class AGXQT_EXPORT QtAgxViewerMainWindow : public QMainWindow
56  {
57  Q_OBJECT
58 
59  public:
61  {
62  RES_HD = 0,
63  RES_FULL_HD = 1,
64  RES_4K=2
65  };
66 
67  public:
68  explicit QtAgxViewerMainWindow(QWidget *parent = 0);
69  virtual ~QtAgxViewerMainWindow();
70  OsgRenderer* getRenderer();
71 
72  QtAgxWrapper* getWrapper() { return m_qtagxWrapper; }
73 
74  bool init(agxIO::ArgumentParser* arguments);
75 
76  bool load(const std::string& fn);
77 
78  void expandWindow( int deltaX, int deltaY );
79 
80  signals:
81  void signalChangeDrawMode(int mode);
82  void signalChangeParticleShaderMode(int mode);
83  void signalChangeBackgroundColor(int mode);
84 
85  public slots:
86  // Main
87  void slotCloseApplication();
88  void testSlot();
89  void slotEnableCapture(bool enable);
90  void slotTakeScreenShot();
91 
92  // Simulation
93  void slotJournalTrackReachedEnd();
94  void slotPressCaptureButton();
95  void slotRefreshRendering();
96 
97  private slots:
98  void slotOpenFile(const std::string& overrideFilter = "");
99  void slotSaveSimulationState();
100  void slotOnSimulationLoaded();
101 
102  // Camera config slots
103  void slotOpenConfigFile() { slotOpenFile("Camera configuration (*.cfg)"); }
104  void slotSaveCameraViews();
105  void slotUpdateCameraViewWidget();
106  void slotToggleShowCameraViews(bool);
107 
108  void slotToggleModePolygon();
109  void slotToggleModeWireframe();
110  void slotToggleModePoints();
111  void slotCyclePolygonMode();
112 
113  void slotToggleViewSideDocket(bool);
114 
115  void slotChangeParticleShaderSprites();
116  void slotChangeParticleShaderRotationalSprites();
117  void slotChangeParticleShaderAlphaSprites();
118  void slotIncrementParticleAlpha();
119  void slotDecrementParticleAlpha();
120  void slotUpdateParticleRenderWidget();
121  void slotUpdatePostProcessingBound();
122  void slotOpenDataExporterDialog();
123 
124 
125  void slotSetResolutionHD();
126  void slotSetResolutionFullHD();
127  void slotSetResolution4K();
128  void slotSetResolutionMode( int mode );
129 
130  void slotToggleBackgroundColor( int state );
131  void slotToggleBackgroundGrayGradient();
132  void slotToggleBackgroundWhite();
133  void slotToggleBackgroundWhiteGradient();
134  void slotToggleBackgroundSkyBlue();
135  void slotToggleBackgroundLightBlue();
136  void slotToggleBackgroundBlack();
137 
138  void slotEnableUseAlgoryxLogo(bool enable);
139 
140  // Simulation Structure
141  void slotUpdateSimulationStructure();
142 
143  // Resize
144  void slotSetEnableResize(bool shouldResize);
145  void slotToggleOsgFullscreen();
146 
147  // media generation
148  void slotShowMediaWidget();
149  void slotGenerateVideo();
150 
151  // Keyshot
152  void slotExportCurrentFrameToBip();
153  void slotExportWholeJournalToBipFiles();
154  void slotUpdateKeyshotExporterDialog();
155  void slotOpenKeyshotExporterDialog();
156 
157  // Clip plane updates
158  void slotTranslateClipPlane();
159  void slotDeTranslateClipPlane();
160 
161  // Contact Exporter
162  void slotTranslateBoundX();
163  void slotDeTranslateBoundX();
164  void slotTranslateBoundY();
165  void slotDeTranslateBoundY();
166  void slotUpdateContactExporterWidget();
167  void slotEnableImpactPostProcessing(bool enable);
168 
169  // Info
170  void slotOpenJournalInfo();
171 
172  protected:
173  void setFilenameTitle(const std::string& filename);
174  void setupGui();
175  void initConnectionsGui();
176  void initConnectionsActions();
177  void togglePolgyonRendering(int state);
178 
179  void setupCameraViewMenu();
180  void updateSimulationStructure();
181 
182  virtual void keyPressEvent(QKeyEvent* event);
183  virtual void keyReleaseEvent(QKeyEvent* event);
184  virtual void resizeEvent(QResizeEvent* event);
185 
186  private:
187  void closeEvent(QCloseEvent * event);
188 
190  // Variables
192 
193  protected:
194  // GUI
195  Ui::QtViewerMainWindow * m_ui;
196 
197  // agxQT
198  std::unique_ptr<agxQt::OsgRenderer> m_renderer;
199  std::unique_ptr<agxQt::PlaybackControllerWidget> m_controllerWidget;
200  std::unique_ptr<agxQt::CameraListWidget> m_cameraListWidget;
201  std::unique_ptr<agxQt::VideoCaptureSettingsWidget> m_videoSettingsWidget;
202  std::unique_ptr<agxQt::ParticleRenderWidget> m_particleRenderWidget;
203 #if AGX_USE_KEYSHOT()
204  std::unique_ptr<agxQt::KeyshotExporterDialog> m_keyshotExporterDialog;
205 #endif
206  std::unique_ptr<agxQt::DataExporterDialog> m_contactWriterDialog;
207  std::unique_ptr<agxQt::AnalysisBoundWidget> m_analysisBoundWidget;
208  std::unique_ptr<agxQt::ClipPlaneWidget> m_clipPlaneWidget;
210  std::unique_ptr<agxQt::SimulationStructureWidget> m_treeStructureWidget;
211  std::unique_ptr<agxQt::JournalInfoWidget> m_journalInfoWidget;
213 
214  // Qt
215  QDockWidget* m_playbackDockWidget;
217  QWidget* m_recordWidget;
218  QDockWidget* m_leftDockWidget;
219 
220  // Qt custom actions
223  QAction* m_pauseAction;
229  };
230 }
231 
232 #endif
agxQt::QtAgxViewerMainWindow::m_playbackDockWidget
QDockWidget * m_playbackDockWidget
Definition: QtViewerMainWindow.h:215
PlaybackController.h
agxQt::QtAgxViewerMainWindow::m_isFullScreen
bool m_isFullScreen
Definition: QtViewerMainWindow.h:212
agxQt::QtAgxViewerMainWindow
Main window of the agx application.
Definition: QtViewerMainWindow.h:55
AGXQT_EXPORT
#define AGXQT_EXPORT
agxQt
Contains classes/utility functions for connecting AGX to QT with OSG.
Definition: AnalysisBoundWidget.h:33
agxQt::QtAgxWrapper
Class that wraps SimulationController with an interface that enables QT Gui signals to control the si...
Definition: QtAgxWrapper.h:72
ClipPlaneWidget.h
agxQt::QtAgxViewerMainWindow::m_stepForwardAction
QAction * m_stepForwardAction
Definition: QtViewerMainWindow.h:224
agxQt::QtAgxViewerMainWindow::m_centerSceneAction
QAction * m_centerSceneAction
Definition: QtViewerMainWindow.h:221
agxQt::QtAgxViewerMainWindow::m_saveSimulationStateAction
QAction * m_saveSimulationStateAction
Definition: QtViewerMainWindow.h:228
UtilWidgets.h
agxQt::QtAgxViewerMainWindow::m_clipPlaneWidget
std::unique_ptr< agxQt::ClipPlaneWidget > m_clipPlaneWidget
Definition: QtViewerMainWindow.h:208
agxQt::QtAgxViewerMainWindow::getWrapper
QtAgxWrapper * getWrapper()
Definition: QtViewerMainWindow.h:72
agxQt::QtAgxViewerMainWindow::m_cyclePolyModeAction
QAction * m_cyclePolyModeAction
Definition: QtViewerMainWindow.h:222
AnalysisBoundWidget.h
VideoCaptureSettingsWidget.h
OsgRenderer.h
agxQt::QtAgxViewerMainWindow::m_cameraListWidget
std::unique_ptr< agxQt::CameraListWidget > m_cameraListWidget
Definition: QtViewerMainWindow.h:200
agxQt::QtAgxViewerMainWindow::m_leftDockWidget
QDockWidget * m_leftDockWidget
Definition: QtViewerMainWindow.h:218
export.h
agxQt::QtAgxViewerMainWindow::m_videoSettingsWidget
std::unique_ptr< agxQt::VideoCaptureSettingsWidget > m_videoSettingsWidget
Definition: QtViewerMainWindow.h:201
agxQt::QtAgxViewerMainWindow::m_cameraListDockWidget
DockWidgetWithCloseSignal * m_cameraListDockWidget
Definition: QtViewerMainWindow.h:216
agxQt::QtAgxViewerMainWindow::m_treeStructureWidget
std::unique_ptr< agxQt::SimulationStructureWidget > m_treeStructureWidget
Definition: QtViewerMainWindow.h:210
agxQt::QtAgxViewerMainWindow::m_qtagxWrapper
agx::ref_ptr< QtAgxWrapper > m_qtagxWrapper
Definition: QtViewerMainWindow.h:209
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
agxQt::QtAgxViewerMainWindow::m_analysisBoundWidget
std::unique_ptr< agxQt::AnalysisBoundWidget > m_analysisBoundWidget
Definition: QtViewerMainWindow.h:207
SimulationStructureWidget.h
PushDisableWarnings.h
DockWidgetWithCloseSignal.h
agxQt::OsgRenderer
[0] //! [1]
Definition: OsgRenderer.h:59
agxQt::QtAgxViewerMainWindow::m_controllerWidget
std::unique_ptr< agxQt::PlaybackControllerWidget > m_controllerWidget
Definition: QtViewerMainWindow.h:199
DataExporterDialog.h
KeyshotExporterDialog.h
agxQt::QtAgxViewerMainWindow::m_decrementSpeedAction
QAction * m_decrementSpeedAction
Definition: QtViewerMainWindow.h:227
agxQt::QtAgxViewerMainWindow::m_incrementSpeedAction
QAction * m_incrementSpeedAction
Definition: QtViewerMainWindow.h:226
agxQt::QtAgxViewerMainWindow::m_particleRenderWidget
std::unique_ptr< agxQt::ParticleRenderWidget > m_particleRenderWidget
Definition: QtViewerMainWindow.h:202
agxQt::QtAgxViewerMainWindow::RESOLUTION_MODE
RESOLUTION_MODE
Definition: QtViewerMainWindow.h:60
agxQt::QtAgxViewerMainWindow::m_renderer
std::unique_ptr< agxQt::OsgRenderer > m_renderer
Definition: QtViewerMainWindow.h:198
agxQt::DockWidgetWithCloseSignal
Definition: DockWidgetWithCloseSignal.h:32
agxQt::QtAgxViewerMainWindow::m_recordWidget
QWidget * m_recordWidget
Definition: QtViewerMainWindow.h:217
CameraListWidget.h
agxQt::QtAgxViewerMainWindow::m_ui
Ui::QtViewerMainWindow * m_ui
Definition: QtViewerMainWindow.h:195
agxQt::QtAgxViewerMainWindow::m_stepBackAction
QAction * m_stepBackAction
Definition: QtViewerMainWindow.h:225
agx::init
void AGXPHYSICS_EXPORT init()
Initialize agx.
agxQt::QtAgxViewerMainWindow::m_journalInfoWidget
std::unique_ptr< agxQt::JournalInfoWidget > m_journalInfoWidget
Definition: QtViewerMainWindow.h:211
agxQt::QtAgxViewerMainWindow::m_pauseAction
QAction * m_pauseAction
Definition: QtViewerMainWindow.h:223
agxQt::QtAgxViewerMainWindow::m_contactWriterDialog
std::unique_ptr< agxQt::DataExporterDialog > m_contactWriterDialog
Definition: QtViewerMainWindow.h:206
JournalInfoWidget.h
QtAgxWrapper.h
agxIO::ArgumentParser
A small argument parser class.
Definition: ArgumentParser.h:38
PopDisableWarnings.h