SLProject  4.3.020
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 49 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 98 of file AppDemoGui.cpp.

101 {
102  SLfloat width = (SLfloat)sv->viewportW() * widthPC;
103  SLfloat height = (SLfloat)sv->viewportH() * heightPC;
104  SLfloat offsetX = ((SLfloat)sv->viewportW() - width) * 0.5f;
105  SLfloat offsetY = ((SLfloat)sv->viewportH() - height) * 0.5f;
106  ImGui::SetNextWindowSize(ImVec2(width, height), ImGuiCond_Always);
107  ImGui::SetNextWindowPos(ImVec2(offsetX, offsetY), ImGuiCond_Always);
108 }
float SLfloat
analog to GLfloat
Definition: SL.h:200
SceneView class represents a dynamic real time 3D view onto the scene.
Definition: SLSceneView.h:69
SLint viewportH() const
Definition: SLSceneView.h:184
SLint viewportW() const
Definition: SLSceneView.h:183

◆ ftpCallbackXfer()

int ftpCallbackXfer ( off64_t  xfered,
void arg 
)

Definition at line 207 of file AppDemoGui.cpp.

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

◆ guessCalibration()

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

Definition at line 1466 of file AppDemoGui.cpp.

1469 {
1470 #ifndef SL_EMSCRIPTEN
1471  // Try to read device lens and sensor information
1472  string strF = AppCommon::deviceParameter["DeviceLensFocalLength"];
1473  string strW = AppCommon::deviceParameter["DeviceSensorPhysicalSizeW"];
1474  string strH = AppCommon::deviceParameter["DeviceSensorPhysicalSizeH"];
1475  if (!strF.empty() && !strW.empty() && !strH.empty())
1476  {
1477  float devF = strF.empty() ? 0.0f : stof(strF);
1478  float devW = strW.empty() ? 0.0f : stof(strW);
1479  float devH = strH.empty() ? 0.0f : stof(strH);
1480 
1481  // Changes the state to CS_guessed
1482  return CVCalibration(devW,
1483  devH,
1484  devF,
1485  cv::Size(CVCapture::instance()->lastFrame.cols,
1486  CVCapture::instance()->lastFrame.rows),
1487  mirroredH,
1488  mirroredV,
1489  camType,
1491  }
1492  else
1493  {
1494  // make a guess using frame size and a guessed field of view
1495  return CVCalibration(cv::Size(CVCapture::instance()->lastFrame.cols,
1496  CVCapture::instance()->lastFrame.rows),
1497  60.0,
1498  mirroredH,
1499  mirroredV,
1500  camType,
1502  }
1503 #else
1504  return CVCalibration(cv::Size(0, 0),
1505  60.0,
1506  mirroredH,
1507  mirroredV,
1508  camType,
1510 #endif
1511 }
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:1258

◆ myComboBox()

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

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

Definition at line 85 of file AppDemoGui.cpp.

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

Variable Documentation

◆ balda_glas

SLNode* balda_glas = nullptr
static

Definition at line 140 of file AppDemoGui.cpp.

◆ balda_stahl

SLNode* balda_stahl = nullptr
static

Definition at line 139 of file AppDemoGui.cpp.

◆ bern

SLNode* bern = nullptr
static

Definition at line 138 of file AppDemoGui.cpp.

◆ chrAlt

SLNode* chrAlt = nullptr
static

Definition at line 141 of file AppDemoGui.cpp.

◆ chrNeu

SLNode* chrNeu = nullptr
static

Definition at line 142 of file AppDemoGui.cpp.

◆ ftpXferSizeMax

off64_t ftpXferSizeMax = 0

Definition at line 203 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 43 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 38 of file AppDemoVideo.cpp.

◆ transformNode

SLTransformNode* transformNode = nullptr
static

Definition at line 145 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
analog to GLuint
Definition: SL.h:198
vector< SLstring > SLVstring
Definition: SL.h:229

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

Definition at line 72 of file AppDemoGui.cpp.