2009-02-04 21:51:12 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 Robert Osfield
|
2009-01-14 23:16:29 +08:00
|
|
|
*
|
2009-02-04 21:51:12 +08:00
|
|
|
* 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
|
2009-01-14 23:16:29 +08:00
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
2009-02-04 21:51:12 +08:00
|
|
|
*
|
2009-01-14 23:16:29 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2009-02-04 21:51:12 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2009-01-14 23:16:29 +08:00
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OSGVOLUME_PROPERTY
|
|
|
|
#define OSGVOLUME_PROPERTY 1
|
|
|
|
|
|
|
|
#include <osg/TransferFunction>
|
2009-01-15 23:57:04 +08:00
|
|
|
#include <osg/Uniform>
|
2009-01-20 20:39:26 +08:00
|
|
|
#include <osg/AlphaFunc>
|
2009-01-14 23:16:29 +08:00
|
|
|
|
2009-01-21 01:41:45 +08:00
|
|
|
#include <osgGA/GUIEventHandler>
|
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
#include <osgVolume/Export>
|
|
|
|
|
|
|
|
namespace osgVolume {
|
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
// forward decarle
|
|
|
|
class Property;
|
|
|
|
class CompositeProperty;
|
2009-01-21 19:46:03 +08:00
|
|
|
class SwitchProperty;
|
2009-01-15 23:57:04 +08:00
|
|
|
class TransferFunctionProperty;
|
|
|
|
class ScalarProperty;
|
|
|
|
class IsoSurfaceProperty;
|
|
|
|
class MaximumIntensityProjectionProperty;
|
|
|
|
class LightingProperty;
|
|
|
|
class AlphaFuncProperty;
|
2013-12-10 18:43:48 +08:00
|
|
|
class SampleRatioProperty;
|
2013-12-12 17:53:24 +08:00
|
|
|
class SampleRatioWhenMovingProperty;
|
2009-01-20 21:50:57 +08:00
|
|
|
class SampleDensityProperty;
|
2011-03-17 23:37:39 +08:00
|
|
|
class SampleDensityWhenMovingProperty;
|
2009-01-20 21:50:57 +08:00
|
|
|
class TransparencyProperty;
|
2014-03-19 02:14:15 +08:00
|
|
|
class ExteriorTransparencyFactorProperty;
|
2014-07-05 00:45:05 +08:00
|
|
|
class VolumeSettings;
|
2009-01-15 23:57:04 +08:00
|
|
|
|
2009-01-21 19:46:03 +08:00
|
|
|
class OSGVOLUME_EXPORT PropertyVisitor
|
2009-01-15 23:57:04 +08:00
|
|
|
{
|
|
|
|
public:
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-21 19:46:03 +08:00
|
|
|
PropertyVisitor(bool traverseOnlyActiveChildren=true);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
virtual ~PropertyVisitor() {}
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2014-07-05 00:45:05 +08:00
|
|
|
virtual void apply(Property&);
|
2009-01-21 19:46:03 +08:00
|
|
|
virtual void apply(CompositeProperty&);
|
|
|
|
virtual void apply(SwitchProperty&);
|
2014-07-05 00:45:05 +08:00
|
|
|
virtual void apply(TransferFunctionProperty&);
|
|
|
|
virtual void apply(ScalarProperty&);
|
|
|
|
virtual void apply(IsoSurfaceProperty&);
|
|
|
|
virtual void apply(AlphaFuncProperty&);
|
|
|
|
virtual void apply(MaximumIntensityProjectionProperty&);
|
|
|
|
virtual void apply(LightingProperty&);
|
|
|
|
virtual void apply(SampleRatioProperty&);
|
|
|
|
virtual void apply(SampleRatioWhenMovingProperty&);
|
|
|
|
virtual void apply(SampleDensityProperty&);
|
|
|
|
virtual void apply(SampleDensityWhenMovingProperty&);
|
|
|
|
virtual void apply(TransparencyProperty&);
|
|
|
|
virtual void apply(ExteriorTransparencyFactorProperty&);
|
|
|
|
virtual void apply(VolumeSettings&);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-21 19:46:03 +08:00
|
|
|
bool _traverseOnlyActiveChildren;
|
2009-01-15 23:57:04 +08:00
|
|
|
};
|
|
|
|
|
2009-01-16 19:27:20 +08:00
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
class OSGVOLUME_EXPORT Property : public osg::Object
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
Property();
|
|
|
|
|
|
|
|
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
|
|
|
Property(const Property&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
META_Object(osgVolume, Property);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2014-08-26 00:56:47 +08:00
|
|
|
void dirty() { ++_modifiedCount; }
|
|
|
|
|
|
|
|
void setModifiedCount(unsigned int c) { _modifiedCount = c; }
|
|
|
|
unsigned int getModifiedCount() const { return _modifiedCount; }
|
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
2016-06-08 16:46:58 +08:00
|
|
|
virtual void traverse(PropertyVisitor& /*pv*/) {}
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual ~Property();
|
2014-08-26 00:56:47 +08:00
|
|
|
|
|
|
|
unsigned int _modifiedCount;
|
2009-01-14 23:16:29 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class OSGVOLUME_EXPORT CompositeProperty : public Property
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
CompositeProperty();
|
|
|
|
|
|
|
|
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
|
|
|
CompositeProperty(const CompositeProperty& compositeProperty,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
META_Object(osgVolume, CompositeProperty);
|
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
|
|
|
|
2014-07-05 00:45:05 +08:00
|
|
|
virtual void traverse(PropertyVisitor& pv)
|
|
|
|
{
|
|
|
|
for(Properties::iterator itr = _properties.begin();
|
|
|
|
itr != _properties.end();
|
|
|
|
++itr)
|
|
|
|
{
|
|
|
|
(*itr)->accept(pv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
void clear();
|
|
|
|
|
|
|
|
typedef std::vector< osg::ref_ptr<Property> > Properties;
|
|
|
|
|
|
|
|
void setProperty(unsigned int i, Property* property) { if (i>=_properties.size()) _properties.resize(i+1); _properties[i] = property; }
|
|
|
|
|
2015-10-22 21:42:19 +08:00
|
|
|
template<class T> void setProperty(unsigned int i, const osg::ref_ptr<T>& p) { setProperty(i, p.get()); }
|
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
Property* getProperty(unsigned int i) { return i<_properties.size() ? _properties[i].get() : 0; }
|
|
|
|
|
|
|
|
const Property* getProperty(unsigned int i) const { return i<_properties.size() ? _properties[i].get() : 0; }
|
|
|
|
|
2014-08-26 00:56:47 +08:00
|
|
|
void addProperty(Property* property) { _properties.push_back(property); dirty(); }
|
2009-01-14 23:16:29 +08:00
|
|
|
|
2015-10-22 21:42:19 +08:00
|
|
|
template<class T> void addProperty(const osg::ref_ptr<T>& p) { addProperty(p.get()); }
|
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
void removeProperty(unsigned int i) { _properties.erase(_properties.begin()+i); }
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
unsigned int getNumProperties() const { return _properties.size(); }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual ~CompositeProperty() {}
|
|
|
|
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
Properties _properties;
|
|
|
|
};
|
|
|
|
|
2009-01-21 19:46:03 +08:00
|
|
|
|
|
|
|
class OSGVOLUME_EXPORT SwitchProperty : public CompositeProperty
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
SwitchProperty();
|
|
|
|
|
|
|
|
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
|
|
|
SwitchProperty(const SwitchProperty& switchProperty,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-21 19:46:03 +08:00
|
|
|
META_Object(osgVolume, SwitchProperty);
|
|
|
|
|
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
|
|
|
|
2014-07-05 00:45:05 +08:00
|
|
|
virtual void traverse(PropertyVisitor& pv)
|
|
|
|
{
|
|
|
|
if (pv._traverseOnlyActiveChildren)
|
|
|
|
{
|
|
|
|
if (_activeProperty>=0 && static_cast<unsigned int>(_activeProperty)<=getNumProperties())
|
|
|
|
{
|
|
|
|
_properties[_activeProperty]->accept(pv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CompositeProperty::traverse(pv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-21 19:46:03 +08:00
|
|
|
/** Set which child property is active.
|
|
|
|
* -1 disables all children.*/
|
2014-08-26 00:56:47 +08:00
|
|
|
void setActiveProperty(int i) { _activeProperty = i; dirty(); }
|
2009-01-21 19:46:03 +08:00
|
|
|
|
|
|
|
/** Get the active property.*/
|
|
|
|
int getActiveProperty() const { return _activeProperty; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual ~SwitchProperty() {}
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-21 19:46:03 +08:00
|
|
|
int _activeProperty;
|
|
|
|
};
|
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
class OSGVOLUME_EXPORT TransferFunctionProperty : public Property
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
TransferFunctionProperty(osg::TransferFunction* tf = 0);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
2009-01-15 23:57:04 +08:00
|
|
|
TransferFunctionProperty(const TransferFunctionProperty& tfp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
META_Object(osgVolume, TransferFunctionProperty);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
|
|
|
|
|
|
|
/** Set the transfer function.*/
|
|
|
|
void setTransferFunction(osg::TransferFunction* tf) { _tf = tf; }
|
|
|
|
|
|
|
|
/** Get the transfer function.*/
|
|
|
|
osg::TransferFunction* getTransferFunction() { return _tf.get(); }
|
|
|
|
|
|
|
|
/** Get the const transfer function.*/
|
|
|
|
const osg::TransferFunction* getTransferFunction() const { return _tf.get(); }
|
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
protected:
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
virtual ~TransferFunctionProperty() {}
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
osg::ref_ptr<osg::TransferFunction> _tf;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
|
|
|
|
class OSGVOLUME_EXPORT ScalarProperty : public Property
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
ScalarProperty(const std::string& scaleName, float value);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
ScalarProperty(const ScalarProperty& scalarProperty,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
META_Object(osgVolume, ScalarProperty);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
|
|
|
|
|
|
|
/** Set the value.*/
|
2014-08-26 00:56:47 +08:00
|
|
|
virtual void setValue(float v) { _uniform->set(v); dirty(); }
|
2009-01-15 23:57:04 +08:00
|
|
|
|
|
|
|
/** Get the value.*/
|
|
|
|
float getValue() const { float v; _uniform->get(v); return v; }
|
|
|
|
|
|
|
|
/** Get the underlying uniform.*/
|
|
|
|
osg::Uniform* getUniform() { return _uniform.get(); }
|
|
|
|
|
|
|
|
/** Get the underlying uniform.*/
|
|
|
|
const osg::Uniform* getUniform() const { return _uniform.get(); }
|
|
|
|
|
|
|
|
protected:
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
virtual ~ScalarProperty() {}
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-30 18:55:28 +08:00
|
|
|
ScalarProperty();
|
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
osg::ref_ptr<osg::Uniform> _uniform;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class OSGVOLUME_EXPORT IsoSurfaceProperty : public ScalarProperty
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-11-30 22:21:45 +08:00
|
|
|
IsoSurfaceProperty(float value=1.0f);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
IsoSurfaceProperty(const IsoSurfaceProperty& isp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
META_Object(osgVolume, IsoSurfaceProperty);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
|
|
|
|
|
|
|
protected:
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
virtual ~IsoSurfaceProperty() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class OSGVOLUME_EXPORT AlphaFuncProperty : public ScalarProperty
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-11-30 22:21:45 +08:00
|
|
|
AlphaFuncProperty(float value=1.0f);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
AlphaFuncProperty(const AlphaFuncProperty& isp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
META_Object(osgVolume, AlphaFuncProperty);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
|
|
|
|
2009-01-20 20:39:26 +08:00
|
|
|
virtual void setValue(float v);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-20 20:39:26 +08:00
|
|
|
osg::AlphaFunc* getAlphaFunc() { return _alphaFunc.get(); }
|
|
|
|
|
|
|
|
const osg::AlphaFunc* getAlphaFunc() const { return _alphaFunc.get(); }
|
|
|
|
|
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
protected:
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
virtual ~AlphaFuncProperty() {}
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-20 20:39:26 +08:00
|
|
|
osg::ref_ptr<osg::AlphaFunc> _alphaFunc;
|
2009-01-15 23:57:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class OSGVOLUME_EXPORT MaximumIntensityProjectionProperty : public Property
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
MaximumIntensityProjectionProperty();
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
MaximumIntensityProjectionProperty(const MaximumIntensityProjectionProperty& mipp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
META_Object(osgVolume, MaximumIntensityProjectionProperty);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
|
|
|
|
|
|
|
protected:
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
virtual ~MaximumIntensityProjectionProperty() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class OSGVOLUME_EXPORT LightingProperty : public Property
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
LightingProperty();
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
LightingProperty(const LightingProperty& mipp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
META_Object(osgVolume, LightingProperty);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
|
|
|
|
|
|
|
protected:
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-15 23:57:04 +08:00
|
|
|
virtual ~LightingProperty() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-03-17 23:37:39 +08:00
|
|
|
/** Sample density to use when the volume is static relative to the eye point or when moving if no SampleDensityWhenMovingProperty is assigned.*/
|
2009-01-20 21:50:57 +08:00
|
|
|
class OSGVOLUME_EXPORT SampleDensityProperty : public ScalarProperty
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-11-30 22:21:45 +08:00
|
|
|
SampleDensityProperty(float value=1.0f);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-20 21:50:57 +08:00
|
|
|
SampleDensityProperty(const SampleDensityProperty& isp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-20 21:50:57 +08:00
|
|
|
META_Object(osgVolume, SampleDensityProperty);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-20 21:50:57 +08:00
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
|
|
|
|
|
|
|
protected:
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-20 21:50:57 +08:00
|
|
|
virtual ~SampleDensityProperty() {}
|
|
|
|
};
|
|
|
|
|
2011-03-17 23:37:39 +08:00
|
|
|
/** Sample density to use when the volume is moving relative to the eye point.*/
|
|
|
|
class OSGVOLUME_EXPORT SampleDensityWhenMovingProperty : public ScalarProperty
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-11-30 22:21:45 +08:00
|
|
|
SampleDensityWhenMovingProperty(float value=1.0f);
|
2011-03-17 23:37:39 +08:00
|
|
|
|
|
|
|
SampleDensityWhenMovingProperty(const SampleDensityWhenMovingProperty& isp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
|
|
|
|
|
|
|
META_Object(osgVolume, SampleDensityWhenMovingProperty);
|
|
|
|
|
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual ~SampleDensityWhenMovingProperty() {}
|
|
|
|
};
|
|
|
|
|
2013-12-12 17:53:24 +08:00
|
|
|
/** Sample ratioto use when the volume is static relative to the eye point or when moving if no SampleRatioWhenMovingProperty is assigned.*/
|
2013-12-10 18:43:48 +08:00
|
|
|
class OSGVOLUME_EXPORT SampleRatioProperty : public ScalarProperty
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
SampleRatioProperty(float value=1.0f);
|
|
|
|
|
|
|
|
SampleRatioProperty(const SampleRatioProperty& isp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
|
|
|
|
|
|
|
META_Object(osgVolume, SampleRatioProperty);
|
|
|
|
|
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual ~SampleRatioProperty() {}
|
|
|
|
};
|
|
|
|
|
2013-12-12 17:53:24 +08:00
|
|
|
/** Sample density to use when the volume is moving relative to the eye point.*/
|
|
|
|
class OSGVOLUME_EXPORT SampleRatioWhenMovingProperty : public ScalarProperty
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
SampleRatioWhenMovingProperty(float value=1.0f);
|
|
|
|
|
|
|
|
SampleRatioWhenMovingProperty(const SampleRatioWhenMovingProperty& isp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
|
|
|
|
|
|
|
META_Object(osgVolume, SampleRatioWhenMovingProperty);
|
|
|
|
|
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual ~SampleRatioWhenMovingProperty() {}
|
|
|
|
};
|
|
|
|
|
2013-12-10 18:43:48 +08:00
|
|
|
|
2009-01-20 21:50:57 +08:00
|
|
|
class OSGVOLUME_EXPORT TransparencyProperty : public ScalarProperty
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2012-11-30 22:21:45 +08:00
|
|
|
TransparencyProperty(float value=1.0f);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-20 21:50:57 +08:00
|
|
|
TransparencyProperty(const TransparencyProperty& isp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-20 21:50:57 +08:00
|
|
|
META_Object(osgVolume, TransparencyProperty);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-20 21:50:57 +08:00
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
|
|
|
|
|
|
|
protected:
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-20 21:50:57 +08:00
|
|
|
virtual ~TransparencyProperty() {}
|
|
|
|
};
|
|
|
|
|
2014-03-19 02:14:15 +08:00
|
|
|
class OSGVOLUME_EXPORT ExteriorTransparencyFactorProperty : public ScalarProperty
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
ExteriorTransparencyFactorProperty(float value=0.0f);
|
|
|
|
|
|
|
|
ExteriorTransparencyFactorProperty(const ExteriorTransparencyFactorProperty& isp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
|
|
|
|
|
|
|
META_Object(osgVolume, ExteriorTransparencyFactorProperty);
|
|
|
|
|
|
|
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual ~ExteriorTransparencyFactorProperty() {}
|
|
|
|
};
|
|
|
|
|
2009-01-20 21:50:57 +08:00
|
|
|
|
2009-01-16 19:27:20 +08:00
|
|
|
class OSGVOLUME_EXPORT CollectPropertiesVisitor : public osgVolume::PropertyVisitor
|
|
|
|
{
|
|
|
|
public:
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-21 19:46:03 +08:00
|
|
|
CollectPropertiesVisitor(bool traverseOnlyActiveChildren=true);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-21 19:46:03 +08:00
|
|
|
virtual void apply(TransferFunctionProperty&);
|
2009-01-16 19:27:20 +08:00
|
|
|
virtual void apply(ScalarProperty&);
|
|
|
|
virtual void apply(IsoSurfaceProperty& iso);
|
|
|
|
virtual void apply(AlphaFuncProperty& af);
|
|
|
|
virtual void apply(MaximumIntensityProjectionProperty& mip);
|
|
|
|
virtual void apply(LightingProperty& lp);
|
2009-01-20 21:50:57 +08:00
|
|
|
virtual void apply(SampleDensityProperty& sdp);
|
2011-03-17 23:37:39 +08:00
|
|
|
virtual void apply(SampleDensityWhenMovingProperty& sdp);
|
2013-12-10 18:43:48 +08:00
|
|
|
virtual void apply(SampleRatioProperty& sdp);
|
2013-12-12 17:53:24 +08:00
|
|
|
virtual void apply(SampleRatioWhenMovingProperty& sdp);
|
2009-01-20 21:50:57 +08:00
|
|
|
virtual void apply(TransparencyProperty& tp);
|
2014-03-19 02:14:15 +08:00
|
|
|
virtual void apply(ExteriorTransparencyFactorProperty& tp);
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-21 19:46:03 +08:00
|
|
|
osg::ref_ptr<TransferFunctionProperty> _tfProperty;
|
|
|
|
osg::ref_ptr<IsoSurfaceProperty> _isoProperty;
|
|
|
|
osg::ref_ptr<AlphaFuncProperty> _afProperty;
|
|
|
|
osg::ref_ptr<MaximumIntensityProjectionProperty> _mipProperty;
|
|
|
|
osg::ref_ptr<LightingProperty> _lightingProperty;
|
|
|
|
osg::ref_ptr<SampleDensityProperty> _sampleDensityProperty;
|
2011-03-17 23:37:39 +08:00
|
|
|
osg::ref_ptr<SampleDensityWhenMovingProperty> _sampleDensityWhenMovingProperty;
|
2013-12-10 18:43:48 +08:00
|
|
|
osg::ref_ptr<SampleRatioProperty> _sampleRatioProperty;
|
2013-12-12 17:53:24 +08:00
|
|
|
osg::ref_ptr<SampleRatioWhenMovingProperty> _sampleRatioWhenMovingProperty;
|
2009-01-21 19:46:03 +08:00
|
|
|
osg::ref_ptr<TransparencyProperty> _transparencyProperty;
|
2014-03-19 02:14:15 +08:00
|
|
|
osg::ref_ptr<ExteriorTransparencyFactorProperty> _exteriorTransparencyFactorProperty;
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-16 19:27:20 +08:00
|
|
|
};
|
|
|
|
|
2009-01-23 17:24:34 +08:00
|
|
|
class OSGVOLUME_EXPORT PropertyAdjustmentCallback : public osgGA::GUIEventHandler, public osg::StateSet::Callback
|
2009-01-21 01:41:45 +08:00
|
|
|
{
|
|
|
|
public:
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-21 01:41:45 +08:00
|
|
|
PropertyAdjustmentCallback();
|
|
|
|
|
2011-05-06 20:30:21 +08:00
|
|
|
PropertyAdjustmentCallback(const PropertyAdjustmentCallback&,const osg::CopyOp&);
|
2009-01-21 01:41:45 +08:00
|
|
|
|
2014-06-06 00:26:13 +08:00
|
|
|
META_Object(osgVolume, PropertyAdjustmentCallback);
|
|
|
|
|
2016-02-15 20:37:05 +08:00
|
|
|
virtual NodeCallback* asNodeCallback() { return osg::NodeCallback::asNodeCallback(); }
|
|
|
|
virtual const NodeCallback* asNodeCallback() const { return osg::NodeCallback::asNodeCallback(); }
|
|
|
|
|
2016-02-17 23:09:14 +08:00
|
|
|
virtual DrawableEventCallback* asDrawableEventCallback() { return osg::DrawableEventCallback::asDrawableEventCallback(); }
|
|
|
|
virtual const DrawableEventCallback* asDrawableEventCallback() const { return osg::DrawableEventCallback::asDrawableEventCallback(); }
|
|
|
|
|
2016-10-07 21:45:33 +08:00
|
|
|
virtual osgGA::EventHandler* asEventHandler() { return osgGA::EventHandler::asEventHandler(); }
|
|
|
|
virtual const osgGA::EventHandler* asEventHandler() const { return osgGA::EventHandler::asEventHandler(); }
|
|
|
|
|
2014-06-06 00:26:13 +08:00
|
|
|
virtual bool run(osg::Object* object, osg::Object* data) { return osgGA::GUIEventHandler::run(object, data); }
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-21 19:46:03 +08:00
|
|
|
void setKeyEventCycleForward(int key) { _cyleForwardKey = key; }
|
2010-05-18 18:12:30 +08:00
|
|
|
int getKeyEventCycleForward() const { return _cyleForwardKey; }
|
2009-01-21 19:46:03 +08:00
|
|
|
|
|
|
|
void setKeyEventCycleBackward(int key) { _cyleBackwardKey = key; }
|
2010-05-18 18:12:30 +08:00
|
|
|
int getKeyEventCycleBackward() const { return _cyleBackwardKey; }
|
2009-01-21 19:46:03 +08:00
|
|
|
|
2009-02-04 21:51:12 +08:00
|
|
|
void setKeyEventActivatesTransparencyAdjustment(int key) { _transparencyKey = key; }
|
|
|
|
int getKeyEventActivatesTransparencyAdjustment() const { return _transparencyKey; }
|
2009-01-21 01:41:45 +08:00
|
|
|
|
2014-03-19 02:14:15 +08:00
|
|
|
void setKeyEventActivatesExteriorTransparencyFactorAdjustment(int key) { _exteriorTransparencyFactorKey = key; }
|
|
|
|
int getKeyEventActivatesExteriorTransparencyFactorAdjustment() const { return _exteriorTransparencyFactorKey; }
|
|
|
|
|
2009-01-21 01:41:45 +08:00
|
|
|
void setKeyEventActivatesSampleDensityAdjustment(int key) { _sampleDensityKey = key; }
|
2010-05-18 18:12:30 +08:00
|
|
|
int getKeyEventActivatesSampleDensityAdjustment() const { return _sampleDensityKey; }
|
2009-01-21 01:41:45 +08:00
|
|
|
|
|
|
|
void setKeyEventActivatesAlphaFuncAdjustment(int key) { _alphaFuncKey = key; }
|
|
|
|
int getKeyEventActivatesAlphaFuncAdjustment() const { return _alphaFuncKey; }
|
|
|
|
|
|
|
|
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter&, osg::Object* object, osg::NodeVisitor*);
|
2009-01-21 19:46:03 +08:00
|
|
|
|
|
|
|
int _cyleForwardKey;
|
|
|
|
int _cyleBackwardKey;
|
2009-01-21 01:41:45 +08:00
|
|
|
int _transparencyKey;
|
2014-03-19 02:14:15 +08:00
|
|
|
int _exteriorTransparencyFactorKey;
|
2009-01-21 01:41:45 +08:00
|
|
|
int _alphaFuncKey;
|
|
|
|
int _sampleDensityKey;
|
2009-02-04 21:51:12 +08:00
|
|
|
|
2009-01-21 01:41:45 +08:00
|
|
|
bool _updateTransparency;
|
2014-03-19 02:14:15 +08:00
|
|
|
bool _updateExteriorTransparencyFactor;
|
2009-01-21 01:41:45 +08:00
|
|
|
bool _updateAlphaCutOff;
|
|
|
|
bool _updateSampleDensity;
|
|
|
|
};
|
2009-01-21 19:46:03 +08:00
|
|
|
|
2009-01-14 23:16:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|