<commit_before>/* -*-c++-*- Present3D - Copyright (C) 1999-2006 <NAME>
 *
 * This software is open source and may be redistributed and/or modified under  
 * the terms of the GNU General Public License (GPL) version 2.0.
 * The full license is in LICENSE.txt file included with this distribution,.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * include LICENSE.txt for more details.
*/

#include <osgPresentation/SlideShowConstructor>

#include <osg/Geometry>
#include <osg/PolygonOffset>
#include <osg/Geode>
#include <osg/Texture2D>
#include <osg/TextureRectangle>
#include <osg/MatrixTransform>
#include <osg/PositionAttitudeTransform>
#include <osg/TexMat>
#include <osg/ShapeDrawable>
#include <osg/Notify>
#include <osg/io_utils>

#include <osgUtil/TransformCallback>

#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgDB/FileUtils>
#include <osgDB/Input>
#include <osgDB/FileNameUtils>

#include <osgWidget/PdfReader>

#include <osgViewer/ViewerEventHandlers>

#include <osgText/Text>

#include <osgFX/SpecularHighlights>

#include <osgVolume/Volume>
#include <osgVolume/RayTracedTechnique>
#include <osgVolume/FixedFunctionTechnique>

#include <sstream>
#include <algorithm>

#include <osgPresentation/AnimationMaterial>
#include <osgPresentation/PickEventHandler>

#include <osgManipulator/TabBoxDragger>
#include <osgManipulator/TabBoxTrackballDragger>
#include <osgManipulator/TrackballDragger>

using namespace osgPresentation;

class SetToTransparentBin : public osg::NodeVisitor
{
public:

    SetToTransparentBin():
        osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
        
    virtual void appply(osg::Node& node)
    {
        if (node.getStateSet())
        {
            node.getStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON);
            node.getStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
        }
    }
    
    virtual void apply(osg::Geode& geode)
    {
        if (geode.getStateSet())
        {
            geode.getStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON);
            geode.getStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
        }
        for(unsigned int i=0;i<geode.getNumDrawables();++i)
        {
            if (geode.getDrawable(i)->getStateSet())
            {
                geode.getDrawable(i)->getStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON);
                geode.getDrawable(i)->getStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
            }
        }
    }        
};


HUDSettings::HUDSettings(double slideDistance, float eyeOffset, unsigned int leftMask, unsigned int rightMask):
    _slideDistance(slideDistance),
    _eyeOffset(eyeOffset),
    _leftMask(leftMask),
    _rightMask(rightMask)
{
}

HUDSettings::~HUDSettings()
{
}

bool HUDSettings::getModelViewMatrix(osg::Matrix& matrix, osg::NodeVisitor* nv) const
{
    matrix.makeLookAt(osg::Vec3d(0.0,0.0,0.0),osg::Vec3d(0.0,_slideDistance,0.0),osg::Vec3d(0.0,0.0,1.0));

    if (nv->getTraversalMask()==_leftMask)
    {
        matrix.postMultTranslate(osg::Vec3(_eyeOffset,0.0,0.0));
    }
    else if (nv->getTraversalMask()==_rightMask)
    {
        matrix.postMultTranslate(osg::Vec3(-_eyeOffset,0.0,0.0));
    }
    return true;
}

bool HUDSettings::getInverseModelViewMatrix(osg::Matrix& matrix, osg::NodeVisitor* nv) const
{
    osg::Matrix modelView;
    getModelViewMatrix(modelView,nv);
    matrix.invert(modelView);
    return true;
}


HUDTransform::HUDTransform(HUDSettings* hudSettings):
    _hudSettings(hudSettings)
{
    setDataVariance(osg::Object::DYNAMIC);
    setReferenceFrame(osg::Transform::ABSOLUTE_RF);
}

HUDTransform::~HUDTransform() {}

bool HUDTransform::computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
{
    return _hudSettings->getModelViewMatrix(matrix,nv);
}

bool HUDTransform::computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
{
    return _hudSettings->getInverseModelViewMatrix(matrix,nv);
}

SlideShowConstructor::SlideShowConstructor(osgDB::Options* options):
    _options(options)
{
    osg::DisplaySettings* ds = osg::DisplaySettings::instance();
    
    _slideHeight = ds->getScreenHeight();
    _slideWidth = ds->getScreenWidth();
    _slideDistance = ds->getScreenDistance();
    _leftEyeMask = 0x01;
    _rightEyeMask = 0x02;
<commit_msg>Added .get() to fix build<commit_after>/* -*-c++-*- Present3D - Copyright (C) 1999-2006 <NAME>
 *
 * This software is open source and may be redistributed and/or modified under  
 * the terms of the GNU General Public License (GPL) version 2.0.
 * The full license is in LICENSE.txt file included with this distribution,.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * include LICENSE.txt for more details.
*/

#include <osgPresentation/SlideShowConstructor>

#include <osg/Geometry>
#include <osg/PolygonOffset>
#include <osg/Geode>
#include <osg/Texture2D>
#include <osg/TextureRectangle>
#include <osg/MatrixTransform>
#include <osg/PositionAttitudeTransform>
#include <osg/TexMat>
#include <osg/ShapeDrawable>
#include <osg/Notify>
#include <osg/io_utils>

#include <osgUtil/TransformCallback>

#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgDB/FileUtils>
#include <osgDB/Input>
#include <osgDB/FileNameUtils>

#include <osgWidget/PdfReader>

#include <osgViewer/ViewerEventHandlers>

#include <osgText/Text>

#include <osgFX/SpecularHighlights>

#include <osgVolume/Volume>
#include <osgVolume/RayTracedTechnique>
#include <osgVolume/FixedFunctionTechnique>

#include <sstream>
#include <algorithm>

#include <osgPresentation/AnimationMaterial>
#include <osgPresentation/PickEventHandler>

#include <osgManipulator/TabBoxDragger>
#include <osgManipulator/TabBoxTrackballDragger>
#include <osgManipulator/TrackballDragger>

using namespace osgPresentation;

class SetToTransparentBin : public osg::NodeVisitor
{
public:

    SetToTransparentBin():
        osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
        
    virtual void appply(osg::Node& node)
    {
        if (node.getStateSet())
        {
            node.getStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON);
            node.getStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
        }
    }
    
    virtual void apply(osg::Geode& geode)
    {
        if (geode.getStateSet())
        {
            geode.getStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON);
            geode.getStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
        }
        for(unsigned int i=0;i<geode.getNumDrawables();++i)
        {
            if (geode.getDrawable(i)->getStateSet())
            {
                geode.getDrawable(i)->getStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON);
                geode.getDrawable(i)->getStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
            }
        }
    }        
};


HUDSettings::HUDSettings(double slideDistance, float eyeOffset, unsigned int leftMask, unsigned int rightMask):
    _slideDistance(slideDistance),
    _eyeOffset(eyeOffset),
    _leftMask(leftMask),
    _rightMask(rightMask)
{
}

HUDSettings::~HUDSettings()
{
}

bool HUDSettings::getModelViewMatrix(osg::Matrix& matrix, osg::NodeVisitor* nv) const
{
    matrix.makeLookAt(osg::Vec3d(0.0,0.0,0.0),osg::Vec3d(0.0,_slideDistance,0.0),osg::Vec3d(0.0,0.0,1.0));

    if (nv->getTraversalMask()==_leftMask)
    {
        matrix.postMultTranslate(osg::Vec3(_eyeOffset,0.0,0.0));
    }
    else if (nv->getTraversalMask()==_rightMask)
    {
        matrix.postMultTranslate(osg::Vec3(-_eyeOffset,0.0,0.0));
    }
    return true;
}

bool HUDSettings::getInverseModelViewMatrix(osg::Matrix& matrix, osg::NodeVisitor* nv) const
{
    osg::Matrix modelView;
    getModelViewMatrix(modelView,nv);
    matrix.invert(modelView);
    return true;
}


HUDTransform::HUDTransform(HUDSettings* hudSettings):
    _hudSettings(hudSettings)
{
    setDataVariance(osg::Object::DYNAMIC);
    setReferenceFrame(osg::Transform::ABSOLUTE_RF);
}

HUDTransform::~HUDTransform() {}

bool HUDTransform::computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
{
    return _hudSettings->getModelViewMatrix(matrix,nv);
}

bool HUDTransform::computeWorldToLocalMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
{
    return _hudSettings->getInverseModelViewMatrix(matrix,nv);
}

SlideShowConstructor::SlideShowConstructor(osgDB::Options* options):
    _options(options)
{
    const osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
    
    _slideHeight = ds->getScreenHeight();
    _slideWidth = ds->getScreenWidth();
    _slideDistance = ds->getScreenDistance();
    _leftEyeMask = 0x01;
    _rightEyeMask = 0x02;

{'fraction_non_alphanumeric': 0.12922465208747516, 'fraction_numerical': 0.010603048376408217, 'mean_word_length': 4.528083028083028, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 101, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5098186', 'n_tokens_mistral': 3090, 'n_tokens_neox': 3045, 'n_words': 511}