Skip to content

Commit

Permalink
FreeCAD-VR: command integration
Browse files Browse the repository at this point in the history
  • Loading branch information
jriegel committed Sep 13, 2014
1 parent 537d7ed commit c0152ee
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/Gui/CMakeLists.txt
Expand Up @@ -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}
Expand Down
32 changes: 32 additions & 0 deletions src/Gui/CommandView.cpp
Expand Up @@ -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
//===========================================================================
Expand Down Expand Up @@ -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());
Expand Down
13 changes: 12 additions & 1 deletion src/Gui/View3DInventor.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions src/Gui/View3DInventorRiftViewer.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -480,4 +484,4 @@ int oculusTest(void)
//return app.exec();
}

#endif //_USE_OCULUS_RIFT_SDK
#endif //BUILD_VR
13 changes: 13 additions & 0 deletions src/Gui/View3DInventorViewer.cpp
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/Gui/View3DInventorViewer.h
Expand Up @@ -310,6 +310,10 @@ class GuiExport View3DInventorViewer : public SoQtViewer, public Gui::SelectionS
*/
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
Expand Down
6 changes: 5 additions & 1 deletion src/Gui/Workbench.cpp
Expand Up @@ -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"
Expand Down

0 comments on commit c0152ee

Please sign in to comment.