AGX Dynamics  2.38.0.2
QtViewerMainWindow.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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>
36 
37 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
38 #include <agxQt/ui_QtViewerMainWindow.h>
39 #include <QMainWindow>
40 #include <QWidget>
41 #include <QOpenGLContext>
42 #include <QOpenGLFunctions>
43 #include <QObject>
44 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
45 
46 namespace agxQt
47 {
48  class ParticleRenderWidget;
49 
51  // QtAgxViewerMainWindow
53 
56  class AGXQT_EXPORT QtAgxViewerMainWindow : public QMainWindow
57  {
58  Q_OBJECT
59 
60  public:
62  {
63  RES_HD = 0,
64  RES_FULL_HD = 1,
65  RES_4K=2
66  };
67 
68  public:
69  explicit QtAgxViewerMainWindow(QWidget *parent = 0);
70  virtual ~QtAgxViewerMainWindow();
71  OsgRenderer* getRenderer();
72 
73  QtAgxWrapper* getWrapper() { return m_qtagxWrapper; }
74 
75  bool init(agxIO::ArgumentParser* arguments);
76 
77  bool load(const std::string& fn);
78 
79  void expandWindow( int deltaX, int deltaY );
80 
81  signals:
82  void signalChangeDrawMode(int mode);
83  void signalChangeParticleShaderMode(int mode);
84  void signalChangeBackgroundColor(int mode);
85 
86  public slots:
87  // Main
88  void slotCloseApplication();
89  void testSlot();
90  void slotEnableCapture(bool enable);
91  void slotTakeScreenShot();
92 
93  // Simulation
94  void slotJournalTrackReachedEnd();
95  void slotPressCaptureButton();
96  void slotRefreshRendering();
97 
98  private slots:
99  void slotOpenFile(const std::string& overrideFilter = "");
100  void slotSaveSimulationState();
101  void slotOnSimulationLoaded();
102 
103  // Camera config slots
104  void slotOpenConfigFile() { slotOpenFile("Camera configuration (*.cfg)"); }
105  void slotSaveCameraViews();
106  void slotUpdateCameraViewWidget();
107  void slotToggleShowCameraViews(bool);
108 
109  void slotToggleModePolygon();
110  void slotToggleModeWireframe();
111  void slotToggleModePoints();
112  void slotCyclePolygonMode();
113 
114  void slotToggleViewSideDocket(bool);
115 
116  void slotChangeParticleShaderSprites();
117  void slotChangeParticleShaderRotationalSprites();
118  void slotChangeParticleShaderAlphaSprites();
119  void slotIncrementParticleAlpha();
120  void slotDecrementParticleAlpha();
121  void slotUpdateParticleRenderWidget();
122  void slotUpdatePostProcessingBound();
123  void slotOpenDataExporterDialog();
124 
125  void slotUpdateRendering();
126 
127  void slotSetResolutionHD();
128  void slotSetResolutionFullHD();
129  void slotSetResolution4K();
130  void slotSetResolutionMode( int mode );
131 
132  void slotToggleBackgroundColor( int state );
133  void slotToggleBackgroundGrayGradient();
134  void slotToggleBackgroundWhite();
135  void slotToggleBackgroundWhiteGradient();
136  void slotToggleBackgroundSkyBlue();
137  void slotToggleBackgroundLightBlue();
138  void slotToggleBackgroundBlack();
139 
140  void slotEnableUseAlgoryxLogo(bool enable);
141 
142  // Simulation Structure
143  void slotUpdateSimulationStructure();
144 
145  // Resize
146  void slotSetEnableResize(bool shouldResize);
147  void slotToggleOsgFullscreen();
148 
149  // media generation
150  void slotShowMediaWidget();
151  void slotGenerateVideo();
152 
153  // Keyshot
154  void slotExportCurrentFrameToBip();
155  void slotExportWholeJournalToBipFiles();
156  void slotUpdateKeyshotExporterDialog();
157  void slotOpenKeyshotExporterDialog();
158 
159  // Clip plane updates
160  void slotTranslateClipPlane();
161  void slotDeTranslateClipPlane();
162  void slotEnableOrthographicCamera(bool enable);
163  void slotUpdateCameraFromViewPreset(int viewIndex);
164  void slotUpdateCameraFromClipPlane();
165 
166  // Contact Exporter
167  void slotTranslateBoundX();
168  void slotDeTranslateBoundX();
169  void slotTranslateBoundY();
170  void slotDeTranslateBoundY();
171  void slotUpdateContactExporterWidget();
172  void slotEnableImpactPostProcessing(bool enable);
173 
174  // Info
175  void slotOpenJournalInfo();
176 
177  protected:
178  void setFilenameTitle(const std::string& filename);
179  void setupGui();
180  void initConnectionsGui();
181  void initConnectionsActions();
182  void togglePolgyonRendering(int state);
183 
184  void setupCameraViewMenu();
185  void updateSimulationStructure();
186 
187  virtual void keyPressEvent(QKeyEvent* event);
188  virtual void keyReleaseEvent(QKeyEvent* event);
189  virtual void resizeEvent(QResizeEvent* event);
190 
191  private:
192  void closeEvent(QCloseEvent * event);
193 
195  // Variables
197 
198  protected:
199  // GUI
200  Ui::QtViewerMainWindow * m_ui;
201 
202  // agxQT
203  std::unique_ptr<agxQt::OsgRenderer> m_renderer;
204  std::unique_ptr<agxQt::PlaybackControllerWidget> m_controllerWidget;
205  std::unique_ptr<agxQt::CameraListWidget> m_cameraListWidget;
206  std::unique_ptr<agxQt::VideoCaptureSettingsWidget> m_videoSettingsWidget;
207  std::unique_ptr<agxQt::ParticleRenderWidget> m_particleRenderWidget;
208 #ifdef MOC_AGX_USE_KEYSHOT
209  std::unique_ptr<agxQt::KeyshotExporterDialog> m_keyshotExporterDialog;
210 #endif
211  std::unique_ptr<agxQt::DataExporterDialog> m_contactWriterDialog;
212  std::unique_ptr<agxQt::AnalysisBoundWidget> m_analysisBoundWidget;
213  std::unique_ptr<agxQt::ClipPlaneWidget> m_clipPlaneWidget;
214  std::unique_ptr<agxQt::MeasurementAxesWidget> m_measurementAxesWidget;
216  std::unique_ptr<agxQt::SimulationStructureWidget> m_treeStructureWidget;
217  std::unique_ptr<agxQt::JournalInfoWidget> m_journalInfoWidget;
219 
220  // Qt
221  QDockWidget* m_playbackDockWidget;
223  QWidget* m_recordWidget;
224  QDockWidget* m_leftDockWidget;
225 
226  // Qt custom actions
229  QAction* m_pauseAction;
235  };
236 }
237 
238 #endif
agxQt::QtAgxViewerMainWindow::m_playbackDockWidget
QDockWidget * m_playbackDockWidget
Definition: QtViewerMainWindow.h:221
agxQt::QtAgxViewerMainWindow::m_measurementAxesWidget
std::unique_ptr< agxQt::MeasurementAxesWidget > m_measurementAxesWidget
Definition: QtViewerMainWindow.h:214
PlaybackController.h
agxQt::QtAgxViewerMainWindow::m_isFullScreen
bool m_isFullScreen
Definition: QtViewerMainWindow.h:218
agxQt::QtAgxViewerMainWindow
Main window of the agx application.
Definition: QtViewerMainWindow.h:56
AGXQT_EXPORT
#define AGXQT_EXPORT
agxQt
Contains classes/utility functions for connecting AGX to QT with OSG.
Definition: AnalysisBoundWidget.h:30
agxQt::QtAgxWrapper
Class that wraps SimulationController with an interface that enables QT Gui signals to control the si...
Definition: QtAgxWrapper.h:70
ClipPlaneWidget.h
agxQt::QtAgxViewerMainWindow::m_stepForwardAction
QAction * m_stepForwardAction
Definition: QtViewerMainWindow.h:230
agxQt::QtAgxViewerMainWindow::m_centerSceneAction
QAction * m_centerSceneAction
Definition: QtViewerMainWindow.h:227
agxQt::QtAgxViewerMainWindow::m_saveSimulationStateAction
QAction * m_saveSimulationStateAction
Definition: QtViewerMainWindow.h:234
UtilWidgets.h
agxQt::QtAgxViewerMainWindow::m_clipPlaneWidget
std::unique_ptr< agxQt::ClipPlaneWidget > m_clipPlaneWidget
Definition: QtViewerMainWindow.h:213
agxQt::QtAgxViewerMainWindow::getWrapper
QtAgxWrapper * getWrapper()
Definition: QtViewerMainWindow.h:73
agxQt::QtAgxViewerMainWindow::m_cyclePolyModeAction
QAction * m_cyclePolyModeAction
Definition: QtViewerMainWindow.h:228
AnalysisBoundWidget.h
VideoCaptureSettingsWidget.h
OsgRenderer.h
agxQt::QtAgxViewerMainWindow::m_cameraListWidget
std::unique_ptr< agxQt::CameraListWidget > m_cameraListWidget
Definition: QtViewerMainWindow.h:205
agxQt::QtAgxViewerMainWindow::m_leftDockWidget
QDockWidget * m_leftDockWidget
Definition: QtViewerMainWindow.h:224
export.h
agxQt::QtAgxViewerMainWindow::m_videoSettingsWidget
std::unique_ptr< agxQt::VideoCaptureSettingsWidget > m_videoSettingsWidget
Definition: QtViewerMainWindow.h:206
agxQt::QtAgxViewerMainWindow::m_cameraListDockWidget
DockWidgetWithCloseSignal * m_cameraListDockWidget
Definition: QtViewerMainWindow.h:222
agxQt::QtAgxViewerMainWindow::m_treeStructureWidget
std::unique_ptr< agxQt::SimulationStructureWidget > m_treeStructureWidget
Definition: QtViewerMainWindow.h:216
agxQt::QtAgxViewerMainWindow::m_qtagxWrapper
agx::ref_ptr< QtAgxWrapper > m_qtagxWrapper
Definition: QtViewerMainWindow.h:215
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:212
SimulationStructureWidget.h
PushDisableWarnings.h
DockWidgetWithCloseSignal.h
agxQt::OsgRenderer
[0] //! [1]
Definition: OsgRenderer.h:56
agxQt::QtAgxViewerMainWindow::m_controllerWidget
std::unique_ptr< agxQt::PlaybackControllerWidget > m_controllerWidget
Definition: QtViewerMainWindow.h:204
DataExporterDialog.h
KeyshotExporterDialog.h
agxQt::QtAgxViewerMainWindow::m_decrementSpeedAction
QAction * m_decrementSpeedAction
Definition: QtViewerMainWindow.h:233
agxQt::QtAgxViewerMainWindow::m_incrementSpeedAction
QAction * m_incrementSpeedAction
Definition: QtViewerMainWindow.h:232
agxQt::QtAgxViewerMainWindow::m_particleRenderWidget
std::unique_ptr< agxQt::ParticleRenderWidget > m_particleRenderWidget
Definition: QtViewerMainWindow.h:207
agxQt::QtAgxViewerMainWindow::RESOLUTION_MODE
RESOLUTION_MODE
Definition: QtViewerMainWindow.h:61
agxQt::QtAgxViewerMainWindow::m_renderer
std::unique_ptr< agxQt::OsgRenderer > m_renderer
Definition: QtViewerMainWindow.h:203
MeasurementAxesWidget.h
agxQt::DockWidgetWithCloseSignal
Definition: DockWidgetWithCloseSignal.h:32
agxQt::QtAgxViewerMainWindow::m_recordWidget
QWidget * m_recordWidget
Definition: QtViewerMainWindow.h:223
CameraListWidget.h
agxQt::QtAgxViewerMainWindow::m_ui
Ui::QtViewerMainWindow * m_ui
Definition: QtViewerMainWindow.h:200
agxQt::QtAgxViewerMainWindow::m_stepBackAction
QAction * m_stepBackAction
Definition: QtViewerMainWindow.h:231
agx::init
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API.
agxQt::QtAgxViewerMainWindow::m_journalInfoWidget
std::unique_ptr< agxQt::JournalInfoWidget > m_journalInfoWidget
Definition: QtViewerMainWindow.h:217
agxQt::QtAgxViewerMainWindow::m_pauseAction
QAction * m_pauseAction
Definition: QtViewerMainWindow.h:229
agxQt::QtAgxViewerMainWindow::m_contactWriterDialog
std::unique_ptr< agxQt::DataExporterDialog > m_contactWriterDialog
Definition: QtViewerMainWindow.h:211
JournalInfoWidget.h
QtAgxWrapper.h
agxIO::ArgumentParser
A small argument parser class.
Definition: ArgumentParser.h:38
PopDisableWarnings.h