SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
AppDemoGui.cpp File Reference

UI with the ImGUI framework fully rendered in OpenGL 3+. More...

#include <AppDemoGui.h>
#include <AppCommon.h>
#include <AppDemoSceneID.h>
#include <SLEnums.h>
#include <Utils.h>
#include <SL.h>
#include <CVCapture.h>
#include <CVImage.h>
#include <CVTrackedFeatures.h>
#include <SLAssetManager.h>
#include <SLAnimPlayback.h>
#include <SLGLDepthBuffer.h>
#include <SLGLProgramManager.h>
#include <SLGLShader.h>
#include <SLGLTexture.h>
#include <SLInterface.h>
#include <SLDeviceRotation.h>
#include <SLLightDirect.h>
#include <SLLightRect.h>
#include <SLLightSpot.h>
#include <SLShadowMap.h>
#include <SLMaterial.h>
#include <SLMesh.h>
#include <SLParticleSystem.h>
#include <SLNode.h>
#include <SLScene.h>
#include <SLSceneView.h>
#include <SLSkybox.h>
#include <SLTexColorLUT.h>
#include <SLImGui.h>
#include <SLHorizonNode.h>
#include <SLFileStorage.h>
#include <AverageTiming.h>
#include <bezier.hpp>
#include <imgui.h>
#include <ftplib.h>
#include <HttpUtils.h>
#include <ZipUtils.h>
#include <Profiler.h>
Include dependency graph for AppDemoGui.cpp:

Go to the source code of this file.

Macros

#define IMGUI_DEFINE_MATH_OPERATORS
 

Functions

bool myComboBox (const char *label, int *currIndex, SLVstring &values)
 Combobox that allows to pass the items as a string vector. More...
 
void centerNextWindow (SLSceneView *sv, SLfloat widthPC=0.9f, SLfloat heightPC=0.9f)
 Centers the next ImGui window in the parent. More...
 
int ftpCallbackXfer (off64_t xfered, void *arg)
 
CVCalibration guessCalibration (bool mirroredH, bool mirroredV, CVCameraType camType)
 

Variables

CVTrackedgVideoTracker
 
SLNodegVideoTrackedNode
 
SLGLTexturegTexMRI3D
 
SLNodegDragonModel
 
static auto vectorGetter
 Vector getter callback for combo and listbox with std::vector<std::string> More...
 
static SLNodebern = nullptr
 
static SLNodebalda_stahl = nullptr
 
static SLNodebalda_glas = nullptr
 
static SLNodechrAlt = nullptr
 
static SLNodechrNeu = nullptr
 
static SLTransformNodetransformNode = nullptr
 
off64_t ftpXferSizeMax = 0
 

Detailed Description

UI with the ImGUI framework fully rendered in OpenGL 3+.

Date
Summer 2017
Authors
Marcus Hudritsch
Remarks
Please use clangformat to format the code. See more code style on https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style

Definition in file AppDemoGui.cpp.

Macro Definition Documentation

◆ IMGUI_DEFINE_MATH_OPERATORS

#define IMGUI_DEFINE_MATH_OPERATORS

Definition at line 46 of file AppDemoGui.cpp.

Function Documentation

◆ centerNextWindow()

void centerNextWindow ( SLSceneView sv,
SLfloat  widthPC = 0.9f,
SLfloat  heightPC = 0.9f 
)

Centers the next ImGui window in the parent.

Definition at line 95 of file AppDemoGui.cpp.

98 {
99  SLfloat width = (SLfloat)sv->viewportW() * widthPC;
100  SLfloat height = (SLfloat)sv->viewportH() * heightPC;
101  SLfloat offsetX = ((SLfloat)sv->viewportW() - width) * 0.5f;
102  SLfloat offsetY = ((SLfloat)sv->viewportH() - height) * 0.5f;
103  ImGui::SetNextWindowSize(ImVec2(width, height), ImGuiCond_Always);
104  ImGui::SetNextWindowPos(ImVec2(offsetX, offsetY), ImGuiCond_Always);
105 }
float SLfloat
Definition: SL.h:173
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
SLint viewportH() const
Definition: SLSceneView.h:180
SLint viewportW() const
Definition: SLSceneView.h:179

◆ ftpCallbackXfer()

int ftpCallbackXfer ( off64_t  xfered,
void arg 
)

Definition at line 204 of file AppDemoGui.cpp.

205 {
206  if (ftpXferSizeMax)
207  {
208  int xferedPC = (int)((float)xfered / (float)ftpXferSizeMax * 100.0f);
209  // cout << "Bytes transferred: " << xfered << " (" << xferedPC << ")" << endl;
210  AppCommon::jobProgressNum(xferedPC);
211  }
212  else
213  cout << "Bytes transferred: " << xfered << endl;
214  return xfered ? 1 : 0;
215 }
off64_t ftpXferSizeMax
Definition: AppDemoGui.cpp:200
static int jobProgressNum()
Definition: AppCommon.h:98

◆ guessCalibration()

CVCalibration guessCalibration ( bool  mirroredH,
bool  mirroredV,
CVCameraType  camType 
)

Definition at line 1431 of file AppDemoGui.cpp.

1434 {
1435 #ifndef SL_EMSCRIPTEN
1436  // Try to read device lens and sensor information
1437  string strF = AppCommon::deviceParameter["DeviceLensFocalLength"];
1438  string strW = AppCommon::deviceParameter["DeviceSensorPhysicalSizeW"];
1439  string strH = AppCommon::deviceParameter["DeviceSensorPhysicalSizeH"];
1440  if (!strF.empty() && !strW.empty() && !strH.empty())
1441  {
1442  float devF = strF.empty() ? 0.0f : stof(strF);
1443  float devW = strW.empty() ? 0.0f : stof(strW);
1444  float devH = strH.empty() ? 0.0f : stof(strH);
1445 
1446  // Changes the state to CS_guessed
1447  return CVCalibration(devW,
1448  devH,
1449  devF,
1450  cv::Size(CVCapture::instance()->lastFrame.cols,
1451  CVCapture::instance()->lastFrame.rows),
1452  mirroredH,
1453  mirroredV,
1454  camType,
1456  }
1457  else
1458  {
1459  // make a guess using frame size and a guessed field of view
1460  return CVCalibration(cv::Size(CVCapture::instance()->lastFrame.cols,
1461  CVCapture::instance()->lastFrame.rows),
1462  60.0,
1463  mirroredH,
1464  mirroredV,
1465  camType,
1467  }
1468 #else
1469  return CVCalibration(cv::Size(0, 0),
1470  60.0,
1471  mirroredH,
1472  mirroredV,
1473  camType,
1475 #endif
1476 }
static map< string, string > deviceParameter
Generic device parameter.
Definition: AppCommon.h:101
Live video camera calibration class with OpenCV an OpenCV calibration.
Definition: CVCalibration.h:71
CVMat lastFrame
last frame grabbed in BGR
Definition: CVCapture.h:119
static CVCapture * instance()
Public static instance getter for singleton pattern.
Definition: CVCapture.h:65
static std::string get()
Definition: Utils.cpp:1261

◆ myComboBox()

bool myComboBox ( const char *  label,
int *  currIndex,
SLVstring values 
)

Combobox that allows to pass the items as a string vector.

Definition at line 82 of file AppDemoGui.cpp.

83 {
84  if (values.empty())
85  return false;
86 
87  return ImGui::Combo(label,
88  currIndex,
90  (void*)&values,
91  (int)values.size());
92 }
static auto vectorGetter
Vector getter callback for combo and listbox with std::vector<std::string>
Definition: AppDemoGui.cpp:69

Variable Documentation

◆ balda_glas

SLNode* balda_glas = nullptr
static

Definition at line 137 of file AppDemoGui.cpp.

◆ balda_stahl

SLNode* balda_stahl = nullptr
static

Definition at line 136 of file AppDemoGui.cpp.

◆ bern

SLNode* bern = nullptr
static

Definition at line 135 of file AppDemoGui.cpp.

◆ chrAlt

SLNode* chrAlt = nullptr
static

Definition at line 138 of file AppDemoGui.cpp.

◆ chrNeu

SLNode* chrNeu = nullptr
static

Definition at line 139 of file AppDemoGui.cpp.

◆ ftpXferSizeMax

off64_t ftpXferSizeMax = 0

Definition at line 200 of file AppDemoGui.cpp.

◆ gDragonModel

SLNode* gDragonModel
extern

◆ gTexMRI3D

SLGLTexture* gTexMRI3D
extern

◆ gVideoTrackedNode

SLNode* gVideoTrackedNode
extern

Global pointer to a node that from witch the gVideoTracker changes the pose. it gets updated in the following onUpdateTracking routine

Definition at line 42 of file AppDemoVideo.cpp.

◆ gVideoTracker

CVTracked* gVideoTracker
extern

Global pointer for a gVideoTracker that is set in AppDemoLoad for video scenes It gets updated in the following onUpdateTracking routine

Definition at line 37 of file AppDemoVideo.cpp.

◆ transformNode

SLTransformNode* transformNode = nullptr
static

Definition at line 142 of file AppDemoGui.cpp.

◆ vectorGetter

auto vectorGetter
static
Initial value:
=
[](void* vec, int idx, const char** out_text)
{
auto& vector = *(SLVstring*)vec;
if (idx < 0 || idx >= (int)vector.size())
return false;
*out_text = vector.at((SLuint)idx).c_str();
return true;
}
unsigned int SLuint
Definition: SL.h:171
vector< SLstring > SLVstring
Definition: SL.h:201

Vector getter callback for combo and listbox with std::vector<std::string>

Definition at line 69 of file AppDemoGui.cpp.