FreeCAD-VR: command integration

This commit is contained in:
jriegel 2014-09-13 10:18:52 +02:00
parent 537d7edfd8
commit c0152eeb68
7 changed files with 75 additions and 7 deletions

View File

@ -8,9 +8,9 @@ if (FREECAD_USE_3DCONNEXION)
add_definitions(-D_USE_3DCONNEXION_SDK)
endif(FREECAD_USE_3DCONNEXION)
if (OCULUS_FOUND)
add_definitions(-D_USE_OCULUS_RIFT_SDK )
endif(OCULUS_FOUND)
if (BUILD_VR)
add_definitions(-DBUILD_VR )
endif(BUILD_VR)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}

View File

@ -1408,6 +1408,37 @@ bool StdViewDockUndockFullscreen::isActive(void)
return false;
}
//===========================================================================
// Std_ViewVR
//===========================================================================
DEF_STD_CMD_A(StdCmdViewVR);
StdCmdViewVR::StdCmdViewVR()
: Command("Std_ViewVR")
{
sGroup = QT_TR_NOOP("Standard-View");
sMenuText = QT_TR_NOOP("FreeCAD-VR");
sToolTipText = QT_TR_NOOP("Extend the FreeCAD 3D Window to a Oculus Rift");
sWhatsThis = "Std_ViewVR";
sStatusTip = QT_TR_NOOP("Extend the FreeCAD 3D Window to a Oculus Rift");
sPixmap = "view-zoom-all";
eType = Alter3DView;
}
void StdCmdViewVR::activated(int iMsg)
{
//doCommand(Command::Gui,"Gui.activeDocument().activeView().fitAll()");
doCommand(Command::Gui,"Gui.SendMsgToActiveView(\"ViewVR\")");
}
bool StdCmdViewVR::isActive(void)
{
return getGuiApplication()->sendHasMsgToActiveView("ViewVR");
}
//===========================================================================
// Std_ViewScreenShot
//===========================================================================
@ -2453,6 +2484,7 @@ void CreateViewStdCommands(void)
rcCmdMgr.addCommand(new StdCmdViewTop());
rcCmdMgr.addCommand(new StdCmdViewAxo());
rcCmdMgr.addCommand(new StdCmdViewFitAll());
rcCmdMgr.addCommand(new StdCmdViewVR());
rcCmdMgr.addCommand(new StdCmdViewFitSelection());
rcCmdMgr.addCommand(new StdCmdViewRotateLeft());
rcCmdMgr.addCommand(new StdCmdViewRotateRight());

View File

@ -366,7 +366,7 @@ void View3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M
_viewer->turnDeltaDimensionsOn();
else
_viewer->turnDeltaDimensionsOff();
}
}
else{
unsigned long col1 = rGrp.GetUnsigned("BackgroundColor",3940932863UL);
unsigned long col2 = rGrp.GetUnsigned("BackgroundColor2",859006463UL); // default color (dark blue)
@ -545,6 +545,11 @@ bool View3DInventor::onMsg(const char* pMsg, const char** ppReturn)
_viewer->viewAll();
return true;
}
else if (strcmp("ViewVR",pMsg) == 0) {
// call the VR portion of the viewer
_viewer->viewVR();
return true;
}
else if(strcmp("ViewSelection",pMsg) == 0) {
_viewer->viewSelection();
return true;
@ -728,6 +733,12 @@ bool View3DInventor::onHasMsg(const char* pMsg) const
return true;
else if(strcmp("ViewFit",pMsg) == 0)
return true;
else if(strcmp("ViewVR",pMsg) == 0)
#ifdef BUILD_VR
return true;
#elif
return false;
#endif
else if(strcmp("ViewSelection",pMsg) == 0)
return true;
else if(strcmp("ViewBottom",pMsg) == 0)

View File

@ -33,7 +33,11 @@
#include "PreCompiled.h"
#if _USE_OCULUS_RIFT_SDK
#if BUILD_VR
#ifndef OCULUS_FOUND
# error "Build VR without the Oculus SDK makes no sense at all"
#endif
#define USE_SO_OFFSCREEN_RENDERER
//#define USE_FRAMEBUFFER
@ -480,4 +484,4 @@ int oculusTest(void)
//return app.exec();
}
#endif //_USE_OCULUS_RIFT_SDK
#endif //BUILD_VR

View File

@ -1636,6 +1636,19 @@ void View3DInventorViewer::animatedViewAll(int steps, int ms)
}
}
#if BUILD_VR
extern int oculusTest(void);
#endif
void View3DInventorViewer::viewVR(void)
{
#if BUILD_VR
oculusTest();
#endif
}
void View3DInventorViewer::boxZoom(const SbBox2s& box)
{
navigation->boxZoom(box);

View File

@ -310,6 +310,10 @@ public:
*/
void viewAll();
void viewAll(float factor);
/// Breaks out a VR window for a Rift
void viewVR(void);
/**
* Reposition the current camera so we can see all selected objects
* of the scene. Therefore we search for all SOFCSelection nodes, if

View File

@ -487,7 +487,11 @@ MenuItem* StdWorkbench::setupMenuBar() const
*view << "Std_ViewCreate" << "Std_OrthographicCamera" << "Std_PerspectiveCamera" << "Separator"
<< stdviews << "Std_FreezeViews" << "Std_DrawStyle" << "Separator" << view3d << zoom
<< "Std_ViewDockUndockFullscreen" << "Std_AxisCross" << "Std_ToggleClipPlane"
<< "Std_TextureMapping" << "Separator" << visu
<< "Std_TextureMapping"
#ifdef BUILD_VR
<< "Std_ViewVR"
#endif
<< "Separator" << visu
<< "Std_ToggleVisibility" << "Std_ToggleNavigation"
<< "Std_SetAppearance" << "Std_RandomColor" << "Separator"
<< "Std_MeasureDistance" << "Separator"