AGX Dynamics  2.37.2.0
KeyshotExporterDialog.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_KEYSHOTEXPORTERDIALOG_H
18 #define AGXQT_KEYSHOTEXPORTERDIALOG_H
19 
20 #include <agx/config/AGX_USE_KEYSHOT.h>
21 #include <agx/TimeStamp.h>
22 #include <agx/agx.h>
23 #include <agx/String.h>
25 #include <agxQt/export.h>
26 #include <iostream>
28 
29 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
30 #include <QWidget>
31 #include <QThread>
32 #include <agxQt/ui_KeyshotExporterDialog.h>
33 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
34 
35 // The moc-compiler (Qt User Interface Compiler version 5.15.2) can't find the
36 // preprocessor definition AGX_USE_KEYSHOT(). We here use a simpler preprocessor
37 // definition that we define with CMake, see the CMakeList file.
38 #ifndef MOC_AGX_USE_KEYSHOT
39 #if AGX_USE_KEYSHOT()
40 #define MOC_AGX_USE_KEYSHOT
41 #endif
42 #endif
43 
44 #ifdef MOC_AGX_USE_KEYSHOT
45 
46 namespace agxQt
47 {
48  class KeyshotWriterThread;
49  class QtAgxWrapper;
50  class CameraDescription;
51  class ParticleSystemRenderUtility;
52 
53  // Time settings struct. Used in the export function for exporting data in time intervals.
54  struct KeyshotTimeSettings
55  {
56  agx::Real startTime;
57  agx::Real endTime;
58  agx::Int fps;
59  bool useSnapShot;
60  };
61 
65  class AGXQT_EXPORT KeyshotExporterDialog : public QWidget
66  {
67  Q_OBJECT
68 
69  public:
70  explicit KeyshotExporterDialog(QWidget *parent = 0);
71  virtual ~KeyshotExporterDialog();
72 
73  void init();
74  void updateJournal(agxQt::QtAgxWrapper * wrapper);
75 
76  bool verifyAgainstActiveJournal();
77 
78  public slots:
79  void slotUpdateSlider(int);
80  void slotUpdateTimeLeft(double);
81  void slotStartThread();
82  void slotStopThread();
83  void slotWriteCompleted();
84  void slotUseSnapshotBoxChecked();
85  void slotTimeSettingsChanged();
86  void synchronizeGUIFromUpdatedJournal();
87  void updateGUI();
88 
89  protected:
90  agx::UInt verifyFPS(agx::UInt fps);
91 
93  // Variables
95  private:
96  Ui::KeyshotExporterDialog * m_ui;
97  KeyshotWriterThread * m_writerThread;
98  agx::Real m_startTime;
99  agx::Real m_endTime;
100  agx::Int m_fps;
101  bool m_useTimeSnapShot;
103  agxQt::QtAgxWrapper* m_wrapper;
104  };
105 
106  class AGXQT_EXPORT KeyshotWriterThread : public QThread
107  {
108  Q_OBJECT
109 
110  public:
111  KeyshotWriterThread(agxQt::QtAgxWrapper * wrapper, const agxQt::KeyshotTimeSettings& timeSettings);
112 
114  void update(agxQt::QtAgxWrapper * wrapper);
115 
117  void setTimeSettings(const agxQt::KeyshotTimeSettings& timeSettings);
118 
120  void reset();
121 
122  public slots:
123  void slotAbortThread();
124 
125  signals:
126  void update(int);
127  void updateTimeLeft(double);
128 
129  protected:
130  void run();
131 
133  // Variables
135  public:
136  bool m_shouldAbort;
137  bool m_running;
138  protected:
139  agxQt::KeyshotTimeSettings m_timeSettings;
140  agxQt::QtAgxWrapper* m_wrapper;
141  };
142 
143  class AGXQT_EXPORT KeyshotBipFilesWrtier
144  {
145  public:
146  typedef std::function<bool(int, double)> StepforwardCallback;
147 
149  static bool writeBipFilesFromJournal(
150  const agx::String& journalFilename,
151  const agx::String& sessionName,
152  agxQt::CameraDescription* camera,
153  const agxQt::KeyshotTimeSettings& timeSettings,
155  StepforwardCallback callback);
156 
157  private:
158  static bool _writeBipFilesFromJournal(
159  const agx::String& journalFilename,
160  const agx::String& sessionName,
161  agxQt::CameraDescription* camera,
162  const agxQt::KeyshotTimeSettings& timeSettings,
164  StepforwardCallback callback);
165  };
166 }
167 
168 #endif
169 #endif
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API...
#define AGXQT_EXPORT
This utility class is used for post processing of the particle system drawable representation, such as alpha rendering and velocity color.
Definition: QtOSGUtils.h:212
Contains classes/utility functions for connecting AGX to QT with OSG.
int32_t Int
Definition: Integer.h:35
uint32_t UInt
Definition: Integer.h:34
Class that describes an abstract camera and it&#39;s properties.
double Real
Definition: Real.h:42
Class that wraps SimulationController with an interface that enables QT Gui signals to control the si...
Definition: QtAgxWrapper.h:70