AGX Dynamics  2.37.2.0
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>
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  void slotUpdateRendering();
125 
126  void slotSetResolutionHD();
127  void slotSetResolutionFullHD();
128  void slotSetResolution4K();
129  void slotSetResolutionMode( int mode );
130 
131  void slotToggleBackgroundColor( int state );
132  void slotToggleBackgroundGrayGradient();
133  void slotToggleBackgroundWhite();
134  void slotToggleBackgroundWhiteGradient();
135  void slotToggleBackgroundSkyBlue();
136  void slotToggleBackgroundLightBlue();
137  void slotToggleBackgroundBlack();
138 
139  void slotEnableUseAlgoryxLogo(bool enable);
140 
141  // Simulation Structure
142  void slotUpdateSimulationStructure();
143 
144  // Resize
145  void slotSetEnableResize(bool shouldResize);
146  void slotToggleOsgFullscreen();
147 
148  // media generation
149  void slotShowMediaWidget();
150  void slotGenerateVideo();
151 
152  // Keyshot
153  void slotExportCurrentFrameToBip();
154  void slotExportWholeJournalToBipFiles();
155  void slotUpdateKeyshotExporterDialog();
156  void slotOpenKeyshotExporterDialog();
157 
158  // Clip plane updates
159  void slotTranslateClipPlane();
160  void slotDeTranslateClipPlane();
161  void slotEnableOrthographicCamera(bool enable);
162  void slotUpdateCameraFromViewPreset(int viewIndex);
163  void slotUpdateCameraFromClipPlane();
164 
165  // Contact Exporter
166  void slotTranslateBoundX();
167  void slotDeTranslateBoundX();
168  void slotTranslateBoundY();
169  void slotDeTranslateBoundY();
170  void slotUpdateContactExporterWidget();
171  void slotEnableImpactPostProcessing(bool enable);
172 
173  // Info
174  void slotOpenJournalInfo();
175 
176  protected:
177  void setFilenameTitle(const std::string& filename);
178  void setupGui();
179  void initConnectionsGui();
180  void initConnectionsActions();
181  void togglePolgyonRendering(int state);
182 
183  void setupCameraViewMenu();
184  void updateSimulationStructure();
185 
186  virtual void keyPressEvent(QKeyEvent* event);
187  virtual void keyReleaseEvent(QKeyEvent* event);
188  virtual void resizeEvent(QResizeEvent* event);
189 
190  private:
191  void closeEvent(QCloseEvent * event);
192 
194  // Variables
196 
197  protected:
198  // GUI
199  Ui::QtViewerMainWindow * m_ui;
200 
201  // agxQT
202  std::unique_ptr<agxQt::OsgRenderer> m_renderer;
203  std::unique_ptr<agxQt::PlaybackControllerWidget> m_controllerWidget;
204  std::unique_ptr<agxQt::CameraListWidget> m_cameraListWidget;
205  std::unique_ptr<agxQt::VideoCaptureSettingsWidget> m_videoSettingsWidget;
206  std::unique_ptr<agxQt::ParticleRenderWidget> m_particleRenderWidget;
207 #ifdef MOC_AGX_USE_KEYSHOT
208  std::unique_ptr<agxQt::KeyshotExporterDialog> m_keyshotExporterDialog;
209 #endif
210  std::unique_ptr<agxQt::DataExporterDialog> m_contactWriterDialog;
211  std::unique_ptr<agxQt::AnalysisBoundWidget> m_analysisBoundWidget;
212  std::unique_ptr<agxQt::ClipPlaneWidget> m_clipPlaneWidget;
214  std::unique_ptr<agxQt::SimulationStructureWidget> m_treeStructureWidget;
215  std::unique_ptr<agxQt::JournalInfoWidget> m_journalInfoWidget;
217 
218  // Qt
219  QDockWidget* m_playbackDockWidget;
221  QWidget* m_recordWidget;
222  QDockWidget* m_leftDockWidget;
223 
224  // Qt custom actions
227  QAction* m_pauseAction;
233  };
234 }
235 
236 #endif
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API...
#define AGXQT_EXPORT
Ui::QtViewerMainWindow * m_ui
Contains classes/utility functions for connecting AGX to QT with OSG.
std::unique_ptr< agxQt::OsgRenderer > m_renderer
A small argument parser class.
[0] //! [1]
Definition: OsgRenderer.h:56
std::unique_ptr< agxQt::PlaybackControllerWidget > m_controllerWidget
std::unique_ptr< agxQt::ParticleRenderWidget > m_particleRenderWidget
agx::ref_ptr< QtAgxWrapper > m_qtagxWrapper
std::unique_ptr< agxQt::DataExporterDialog > m_contactWriterDialog
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
std::unique_ptr< agxQt::CameraListWidget > m_cameraListWidget
DockWidgetWithCloseSignal * m_cameraListDockWidget
std::unique_ptr< agxQt::JournalInfoWidget > m_journalInfoWidget
std::unique_ptr< agxQt::VideoCaptureSettingsWidget > m_videoSettingsWidget
Main window of the agx application.
std::unique_ptr< agxQt::SimulationStructureWidget > m_treeStructureWidget
Class that wraps SimulationController with an interface that enables QT Gui signals to control the si...
Definition: QtAgxWrapper.h:70
std::unique_ptr< agxQt::ClipPlaneWidget > m_clipPlaneWidget
std::unique_ptr< agxQt::AnalysisBoundWidget > m_analysisBoundWidget