VolumeSettings 4.07 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 Robert Osfield
 *
 * This library is open source and may be redistributed and/or modified under
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 *
 * This library 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
 * OpenSceneGraph Public License for more details.
*/

#ifndef OSGVOLUMESETTINGS
#define OSGVOLUMESETTINGS 1

#include <osg/Object>
#include <osgVolume/Property>

namespace osgVolume {

class OSGVOLUME_EXPORT VolumeSettings : public Property
{
    public:

        VolumeSettings();

        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
        VolumeSettings(const VolumeSettings&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);

        META_Object(osgVolume, VolumeSettings);

        virtual void accept(PropertyVisitor& pv);
        virtual void traverse(PropertyVisitor& pv);

        void setFilename(const std::string& str) { _filename = str; dirty(); }
        const std::string& getFilename() const { return _filename; }

        enum Technique
        {
            FixedFunction,
            RayTraced,
            MultiPass
        };

        void setTechnique(Technique technique) { _technique = technique; dirty(); }
        Technique getTechnique() const { return _technique; }

        enum ShadingModel
        {
            Standard,
            Light,
            Isosurface,
            MaximumIntensityProjection
        };

        void setShadingModel(ShadingModel sm) { _shadingModel = sm; dirty(); }
        ShadingModel getShadingModel() const { return _shadingModel; }

        void setSampleRatio(float sr) { _sampleRatioProperty->setValue(sr); dirty(); }
        float getSampleRatio() const { return _sampleRatioProperty->getValue(); }

        void setSampleRatioWhenMoving(float sr) { _sampleRatioWhenMovingProperty->setValue(sr); dirty(); }
        float getSampleRatioWhenMoving() const { return _sampleRatioWhenMovingProperty->getValue(); }

        void setCutoff(float co);
        float getCutoff() const { return _cutoffProperty->getValue(); }

        void setTransparency(float t) { _transparencyProperty->setValue(t); dirty(); }
        float getTransparency() const { return _transparencyProperty->getValue(); }


        SampleRatioProperty* getSampleRatioProperty() { return _sampleRatioProperty.get(); }
        const SampleRatioProperty* getSampleRatioProperty() const { return _sampleRatioProperty.get(); }

        SampleRatioWhenMovingProperty* getSampleRatioWhenMovingProperty() { return _sampleRatioWhenMovingProperty.get(); }
        const SampleRatioWhenMovingProperty* getSampleRatioWhenMovingProperty() const { return _sampleRatioWhenMovingProperty.get(); }

        AlphaFuncProperty* getCutoffProperty() { return _cutoffProperty.get(); }
        const AlphaFuncProperty* getCutoffProperty() const { return _cutoffProperty.get(); }

        TransparencyProperty* getTransparencyProperty() { return _transparencyProperty.get(); }
        const TransparencyProperty* getTransparencyProperty() const { return _transparencyProperty.get(); }

        IsoSurfaceProperty* getIsoSurfaceProperty() { return _isoSurfaceProperty.get(); }
        const IsoSurfaceProperty* getIsoSurfaceProperty() const { return _isoSurfaceProperty.get(); }

protected:

        virtual ~VolumeSettings() {}

        std::string     _filename;

        Technique       _technique;
        ShadingModel    _shadingModel;

        osg::ref_ptr<SampleRatioProperty>               _sampleRatioProperty;
        osg::ref_ptr<SampleRatioWhenMovingProperty>     _sampleRatioWhenMovingProperty;
        osg::ref_ptr<AlphaFuncProperty>                 _cutoffProperty;
        osg::ref_ptr<TransparencyProperty>              _transparencyProperty;
        osg::ref_ptr<IsoSurfaceProperty>                _isoSurfaceProperty;
};

}

#endif