From 21cc2ddcb40e68d6c1d58df7b7a113ffe64a43b0 Mon Sep 17 00:00:00 2001
From: Isaak Lim <Isaak.Lim@rwth-aachen.de>
Date: Fri, 8 Jun 2012 11:54:33 +0000
Subject: [PATCH] When the viewer's projection mode (orthographic/perspective)
 is switched, the coordinate system node now switches to the same mode.

Note: The projection mode of the coordinate system node can still be set individually

closes #870

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14719 383ad7c9-94d9-4d36-a494-682f7c89f535
---
 widgets/glWidget/QtBaseViewer.cc | 22 ++++++++++++++++++++++
 widgets/glWidget/QtBaseViewer.hh |  3 +++
 2 files changed, 25 insertions(+)

diff --git a/widgets/glWidget/QtBaseViewer.cc b/widgets/glWidget/QtBaseViewer.cc
index 47658735..6c9abc2a 100644
--- a/widgets/glWidget/QtBaseViewer.cc
+++ b/widgets/glWidget/QtBaseViewer.cc
@@ -333,6 +333,26 @@ void glViewer::trackMouse(bool _track)
 
 //-----------------------------------------------------------------------------
 
+void glViewer::setCoordSysProjection(ProjectionMode _mode) {
+  // Find coordsys node
+  ACG::SceneGraph::BaseNode* node = 0;
+  node = PluginFunctions::getSceneGraphRootNode()->find("Core Coordsys Node");
+
+  // set the projection mode for the coordinate system node
+  if (node != 0) {
+    ACG::SceneGraph::CoordsysNode* cnode = dynamic_cast<ACG::SceneGraph::CoordsysNode*> (node);
+    if (_mode ==  ORTHOGRAPHIC_PROJECTION) {
+      cnode->setProjectionMode(ACG::SceneGraph::CoordsysNode::ORTHOGRAPHIC_PROJECTION);
+    } else {
+      cnode->setProjectionMode(ACG::SceneGraph::CoordsysNode::PERSPECTIVE_PROJECTION);
+    }
+  }
+}
+
+
+//-----------------------------------------------------------------------------
+
+
 void glViewer::perspectiveProjection()
 {
   projectionMode(PERSPECTIVE_PROJECTION);
@@ -367,6 +387,8 @@ void glViewer::projectionMode(ProjectionMode _p)
 
   updateProjectionMatrix();
 
+  setCoordSysProjection(_p);
+
   emit viewChanged();
 }
 
diff --git a/widgets/glWidget/QtBaseViewer.hh b/widgets/glWidget/QtBaseViewer.hh
index 44420efb..466313c4 100644
--- a/widgets/glWidget/QtBaseViewer.hh
+++ b/widgets/glWidget/QtBaseViewer.hh
@@ -59,6 +59,7 @@
 
 #include <ACG/GL/GLState.hh>
 #include <ACG/Scenegraph/SceneGraph.hh>
+#include <ACG/Scenegraph/CoordsysNode.hh>
 #include <ACG/QtWidgets/QtSceneGraphWidget.hh>
 
 #include <ACG/ShaderUtils/GLSLShader.hh>
@@ -493,6 +494,8 @@ private:
   void drawScene();
   // helper called by drawScene().
   void drawScene_mono();
+  /// helper function for setting the projection mode of the coordinate system node
+  void setCoordSysProjection(glViewer::ProjectionMode _mode);
 
   
 
-- 
GitLab