AGX Dynamics  2.35.0.1
KeyshotExporterDialog.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_KEYSHOTEXPORTERDIALOG_H
18 #define AGXQT_KEYSHOTEXPORTERDIALOG_H
19 
20 #include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
21 #include <QWidget>
22 #include <QThread>
23 #include <agxQt/ui_KeyshotExporterDialog.h>
24 #include <agx/PopDisableWarnings.h> // End of disabled warnings.
25 
26 #include <agx/config/AGX_USE_KEYSHOT.h>
27 #include <agx/TimeStamp.h>
28 #include <agx/agx.h>
29 #include <agx/String.h>
31 #include <agxQt/export.h>
32 #include <iostream>
34 
35 #if AGX_USE_KEYSHOT()
36 
37 namespace agxQt
38 {
39  class KeyshotWriterThread;
40  class QtAgxWrapper;
41  class CameraDescription;
42  class ParticleSystemRenderUtility;
43 
44  // Time settings struct. Used in the export function for exporting data in time intervals.
45  struct KeyshotTimeSettings
46  {
47  agx::Real startTime;
48  agx::Real endTime;
49  agx::Int fps;
50  bool useSnapShot;
51  };
52 
56  class AGXQT_EXPORT KeyshotExporterDialog : public QWidget
57  {
58  Q_OBJECT
59 
60  public:
61  explicit KeyshotExporterDialog(QWidget *parent = 0);
62  virtual ~KeyshotExporterDialog();
63 
64  void init();
65  void updateJournal(agxQt::QtAgxWrapper * wrapper);
66 
67  bool verifyAgainstActiveJournal();
68 
69  public slots:
70  void slotUpdateSlider(int);
71  void slotUpdateTimeLeft(double);
72  void slotStartThread();
73  void slotStopThread();
74  void slotWriteCompleted();
75  void slotUseSnapshotBoxChecked();
76  void slotTimeSettingsChanged();
77  void synchronizeGUIFromUpdatedJournal();
78  void updateGUI();
79 
80  protected:
81  agx::UInt verifyFPS(agx::UInt fps);
82 
84  // Variables
86  private:
87  Ui::KeyshotExporterDialog * m_ui;
88  KeyshotWriterThread * m_writerThread;
89  agx::Real m_startTime;
90  agx::Real m_endTime;
91  agx::Int m_fps;
92  bool m_useTimeSnapShot;
94  agxQt::QtAgxWrapper* m_wrapper;
95  };
96 
97  class AGXQT_EXPORT KeyshotWriterThread : public QThread
98  {
99  Q_OBJECT
100 
101  public:
102  KeyshotWriterThread(agxQt::QtAgxWrapper * wrapper, const agxQt::KeyshotTimeSettings& timeSettings);
103 
105  void update(agxQt::QtAgxWrapper * wrapper);
106 
108  void setTimeSettings(const agxQt::KeyshotTimeSettings& timeSettings);
109 
111  void reset();
112 
113  public slots:
114  void slotAbortThread();
115 
116  signals:
117  void update(int);
118  void updateTimeLeft(double);
119 
120  protected:
121  void run();
122 
124  // Variables
126  public:
127  bool m_shouldAbort;
128  bool m_running;
129  protected:
130  agxQt::KeyshotTimeSettings m_timeSettings;
131  agxQt::QtAgxWrapper* m_wrapper;
132  };
133 
134  class AGXQT_EXPORT KeyshotBipFilesWrtier
135  {
136  public:
137  typedef std::function<bool(int, double)> StepforwardCallback;
138 
140  static bool writeBipFilesFromJournal(
141  const agx::String& journalFilename,
142  const agx::String& sessionName,
143  agxQt::CameraDescription* camera,
144  const agxQt::KeyshotTimeSettings& timeSettings,
146  StepforwardCallback callback);
147 
148  private:
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 }
158 
159 #endif
160 #endif
#define AGXQT_EXPORT
Class that describes an abstract camera and it's properties.
This utility class is used for post processing of the particle system drawable representation,...
Definition: QtOSGUtils.h:212
Class that wraps SimulationController with an interface that enables QT Gui signals to control the si...
Definition: QtAgxWrapper.h:73
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
double Real
Definition: Real.h:42
void AGXPHYSICS_EXPORT init()
Initialize agx.