Commit f20282de authored by Marlin Frickenschmidt's avatar Marlin Frickenschmidt

+Implemented orthogonal projection mode for coordinate system. Switching...

+Implemented orthogonal projection mode for coordinate system. Switching to/from this new projection mode can be done via the right-click context menu of the coordinate system. This will not change how the scene in the current viewer is rendered.
+Changed the "Lock view" behaviour. Selecting any of the six fixed views from the coordinate system's right-click context menu's "Viewing Direction" will now lock the rotation, and "Free view" will unlock it. It is still possible to use "Lock rotation" to lock the currently selected rotation.
+Fixed small error in Stereo Viewer

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10478 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 4e98aeeb
......@@ -107,7 +107,7 @@ drawCoordsys( GLState& _state) {
// Origin
glColor3f(0.5, 0.5, 0.5);
gluSphere( quadric, sphereRadius, slices, stacks );
// X-Axis
glColor3f(1.0, 0.0, 0.0);
_state.push_modelview_matrix ();
......@@ -232,26 +232,28 @@ draw(GLState& _state , DrawModes::DrawMode /*_drawMode*/)
if ( mode_ == SCREENPOS ) {
int left, bottom, width, height;
double aspect = 1.0;
double aspect = _state.aspect();
_state.get_viewport(left, bottom, width, height);
if (width && height)
aspect = (double)width / (double)height;
// Projection reset
_state.push_projection_matrix();
_state.reset_projection();
_state.perspective(45.0, aspect, 0.8, 20.0);
float posx = left + width - 30.0 ;
float posy = bottom + height - 30.0 ;
Vec3d screenposCenterPoint( posx , posy , 0.0);
if (projectionMode_ == PERSPECTIVE_PROJECTION)
_state.perspective(45.0, aspect, 0.8, 20.0);
else
_state.ortho(-0.5*aspect, 0.5*aspect, -0.5, 0.5, 0.8, 20.0);
_state.push_modelview_matrix();
_state.reset_modelview();
float rel_size = 50.0;
float projdist = sqrt ( (width*height) / rel_size );
float posx = left + width - projdist ;
float posy = bottom + height - projdist ;
// get our desired coordsys position in scene coordinates
pos3D = _state.unproject (Vec3d (posx, posy, 0.5));
_state.pop_modelview_matrix();
......@@ -265,7 +267,7 @@ draw(GLState& _state , DrawModes::DrawMode /*_drawMode*/)
modelview(2,3) = 0.0;
_state.set_modelview (modelview);
_state.translate (pos3D[0], pos3D[1], pos3D[2]-0.3, MULT_FROM_LEFT);
_state.translate (pos3D[0], pos3D[1], pos3D[2], MULT_FROM_LEFT);
// clear the depth buffer behind the coordsys
......@@ -280,7 +282,7 @@ draw(GLState& _state , DrawModes::DrawMode /*_drawMode*/)
// draw coordsys
drawCoordsys(_state);
// set depth buffer to 0 so tah nothing can paint over cordsys
// set depth buffer to 0 so that nothing can paint over cordsys
glDepthRange (0.0, 0.0);
glDepthFunc (GL_ALWAYS);
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
......@@ -320,7 +322,7 @@ draw(GLState& _state , DrawModes::DrawMode /*_drawMode*/)
// Koordinatensystem zeichnen
drawCoordsys(_state);
// set depth buffer to 0 so tah nothing can paint over cordsys
// set depth buffer to 0 so that nothing can paint over cordsys
glDepthRange (0.0, 0.0);
glDepthFunc (GL_ALWAYS);
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
......@@ -350,6 +352,13 @@ setMode(const CoordsysMode _mode)
mode_ = _mode;
}
void
CoordsysNode::
setProjectionMode(const ProjectionMode _mode)
{
projectionMode_ = _mode;
}
void
CoordsysNode::
setPosition(const Vec3f& _pos)
......@@ -364,6 +373,13 @@ getMode() const
return mode_;
}
CoordsysNode::ProjectionMode
CoordsysNode::
getProjectionMode() const
{
return projectionMode_;
}
void
CoordsysNode::pick(GLState& _state, PickTarget _target)
{
......@@ -384,26 +400,29 @@ CoordsysNode::pick(GLState& _state, PickTarget _target)
if ( mode_ == SCREENPOS ) {
int left, bottom, width, height;
double aspect = 1.0;
double aspect = _state.aspect();
_state.get_viewport(left, bottom, width, height);
if (width && height)
aspect = (double)width / (double)height;
// Projection reset
_state.push_projection_matrix();
_state.reset_projection();
_state.perspective(45.0, aspect, 0.8, 20.0);
float posx = left + width - 30.0 ;
float posy = bottom + height - 30.0 ;
Vec3d screenposCenterPoint( posx , posy , 0.0);
if (projectionMode_ == PERSPECTIVE_PROJECTION)
_state.perspective(45.0, aspect, 0.8, 20.0);
else
_state.ortho(-0.5*aspect, 0.5*aspect, -0.5, 0.5, 0.8, 20.0);
_state.push_modelview_matrix();
_state.reset_modelview();
float rel_size = 50.0;
float projdist = sqrt ( (width*height) / rel_size );
float posx = left + width - projdist ;
float posy = bottom + height - projdist ;
// get our desired coordsys position in scene coordinates
pos3D = _state.unproject (Vec3d (posx, posy, 0.5));
_state.pop_modelview_matrix();
......@@ -415,7 +434,7 @@ CoordsysNode::pick(GLState& _state, PickTarget _target)
modelview(2,3) = 0.0;
_state.set_modelview (modelview);
_state.translate (pos3D[0], pos3D[1], pos3D[2]-0.3, MULT_FROM_LEFT);
_state.translate (pos3D[0], pos3D[1], pos3D[2], MULT_FROM_LEFT);
// We don't have access to the pick matrix used during selection buffer picking
// so we can't draw our pick area circle in this case
......
......@@ -81,6 +81,12 @@ class ACGDLLEXPORT CoordsysNode : public BaseNode
public:
/// projection mode
enum ProjectionMode {
ORTHOGRAPHIC_PROJECTION, //!< orthographic
PERSPECTIVE_PROJECTION //!< perspective
};
enum CoordsysMode
{
POSITION, // Draws the Coordsys at the coordsys origin
......@@ -93,9 +99,10 @@ public:
*/
CoordsysNode( BaseNode* _parent=0,
std::string _name="<TextNode>",
CoordsysMode _mode = SCREENPOS )
CoordsysMode _mode = SCREENPOS, ProjectionMode _projectionMode = PERSPECTIVE_PROJECTION)
: BaseNode(_parent, _name),
mode_(_mode) {};
mode_(_mode),
projectionMode_(_projectionMode) {};
/// destructor
~CoordsysNode() {};
......@@ -118,12 +125,18 @@ public:
/// set mode to either POSITION or SCREENPOS
void setMode(const CoordsysMode _mode);
/// set mode to either ORTHOGRAPHIC_PROJECTION or PERSPECTIVE_PROJECTION
void setProjectionMode(const ProjectionMode _mode);
/// set position of the coordsys
void setPosition(const Vec3f& _pos);
/// get current mode
CoordsysMode getMode() const;
/// get current projection mode
ProjectionMode getProjectionMode() const;
private:
void drawCoordsys(GLState& _state);
......@@ -132,6 +145,7 @@ public:
void boundingCircle(std::vector<Vec2f> &_in, Vec2f &_center, float &_radius);
CoordsysMode mode_;
ProjectionMode projectionMode_;
Vec3f pos3f_;
};
......
......@@ -96,6 +96,7 @@
#include <ACG/QtWidgets/QtSceneGraphWidget.hh>
#include <ACG/Scenegraph/DrawModes.hh>
#include <ACG/Scenegraph/CoordsysNode.hh>
#include <OpenFlipper/INIFile/INIFile.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
......@@ -1003,6 +1004,12 @@ public:
/// Toggle projection mode of the active viewer.
void slotContextSwitchProjection();
/// Toggle coordsys projection mode of the active viewer.
ACG::SceneGraph::CoordsysNode::ProjectionMode getCoordsysProjection();
/// Toggle coordsys projection mode of the active viewer.
void slotContextSwitchCoordsysProjection();
/// Toggle projection mode of all viewers to perspective projection
void slotGlobalPerspectiveProjection();
......
......@@ -53,6 +53,7 @@
#include "CoreWidget.hh"
#include <ACG/Scenegraph/CoordsysNode.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
#include <OpenFlipper/widgets/snapshotDialog/SnapshotDialog.hh>
......@@ -169,6 +170,37 @@ void CoreWidget::slotContextSwitchProjection() {
examiner_widgets_[PluginFunctions::activeExaminer()]->toggleProjectionMode();
}
/// Toggle coordsys projection mode of the active viewer
ACG::SceneGraph::CoordsysNode::ProjectionMode CoreWidget::getCoordsysProjection() {
// Find coordsys node
ACG::SceneGraph::BaseNode* node = 0;
node = PluginFunctions::getSceneGraphRootNode()->find("Core Coordsys Node");
if (node != 0) {
return dynamic_cast<ACG::SceneGraph::CoordsysNode*> (node)->getProjectionMode();
} else {
emit statusMessage(QString(tr("getCoordsysProjection(): Could not find coordsys node. Assuming default orthographic projection.")));
return ACG::SceneGraph::CoordsysNode::ORTHOGRAPHIC_PROJECTION;
}
}
/// Toggle coordsys projection mode of the active viewer
void CoreWidget::slotContextSwitchCoordsysProjection() {
// Find coordsys node
ACG::SceneGraph::BaseNode* node = 0;
node = PluginFunctions::getSceneGraphRootNode()->find("Core Coordsys Node");
if (node != 0) {
ACG::SceneGraph::CoordsysNode* cnode = dynamic_cast<ACG::SceneGraph::CoordsysNode*> (node);
if (cnode->getProjectionMode() == ACG::SceneGraph::CoordsysNode::PERSPECTIVE_PROJECTION) {
cnode->setProjectionMode(ACG::SceneGraph::CoordsysNode::ORTHOGRAPHIC_PROJECTION);
}
else {
cnode->setProjectionMode(ACG::SceneGraph::CoordsysNode::PERSPECTIVE_PROJECTION);
}
} else {
emit statusMessage(QString(tr("slotContextSwitchCoordsysProjection(): Could not find coordsys node, thus its projection mode will not be toggled.")));
}
}
/// Toggle projection mode of all viewers to perspective projection
void CoreWidget::slotGlobalPerspectiveProjection() {
for ( int i = 0 ; i < PluginFunctions::viewers() ; ++i )
......@@ -724,11 +756,18 @@ if (_visible)
void CoreWidget::slotSetViewingDirection(QAction* _action) {
PluginFunctions::setFixedView( _action->data().toInt() );
if (_action->data().toInt() != PluginFunctions::VIEW_FREE)
PluginFunctions::allowRotation( false, PluginFunctions::activeExaminer() );
// Update view
examiner_widgets_[PluginFunctions::activeExaminer()]->updateGL();
}
void CoreWidget::slotLockRotation(bool _lock) {
PluginFunctions::allowRotation( !_lock, PluginFunctions::activeExaminer() );
if (!_lock)
PluginFunctions::setFixedView( PluginFunctions::VIEW_FREE );
}
void CoreWidget::moveBack() {
......
......@@ -196,8 +196,6 @@ void glViewer::drawScenePhilipsStereo() {
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, vp_l, vp_b, vp_w, vp_h);
pDepthStencilTexture_.disable();
glClearColor(.5, .4, .3, 0);
// Turn on shader program
pProgram_->use();
......@@ -242,7 +240,7 @@ void glViewer::drawScenePhilipsStereo() {
// ======================================================================================================
// Clear buffers
// ======================================================================================================
glClearColor(.5, .4, .3, 0);
glClearColor(.0, .0, .0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// ======================================================================================================
......
......@@ -1198,7 +1198,6 @@ void ViewControlPlugin::setView(int _mode, int _viewer ) {
break;
}
PluginFunctions::allowRotation(true, _viewer);
updateView();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment