Commit 695fdc4a authored by schultezub's avatar schultezub

Added Proxy design pattern to AbstractTransferFunction

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@469 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent b854c6c7
......@@ -79,6 +79,12 @@ namespace campvis {
*/
virtual ~AbstractTransferFunction();
/**
* Clones this transfer function.
* \return A clone of this transfer function, caller takes ownership of the pointer.
*/
virtual AbstractTransferFunction* clone() const = 0;
/**
* Deletes the OpenGL texture, hence, this methods has to be called from a thread with a valid OpenGL context!
*/
......
......@@ -49,6 +49,14 @@ namespace campvis {
Geometry1DTransferFunction::~Geometry1DTransferFunction() {
}
Geometry1DTransferFunction* Geometry1DTransferFunction::clone() const {
Geometry1DTransferFunction* toReturn = new Geometry1DTransferFunction(_size.x, _intensityDomain);
for (std::vector<TFGeometry1D*>::const_iterator it = _geometries.begin(); it != _geometries.end(); ++it) {
toReturn->addGeometry((*it)->clone());
}
return toReturn;
}
size_t Geometry1DTransferFunction::getDimensionality() const {
return 1;
}
......
......@@ -54,6 +54,12 @@ namespace campvis {
* Destructor, make sure to delete the OpenGL texture beforehand by calling deinit() with a valid OpenGL context!
*/
virtual ~Geometry1DTransferFunction();
/**
* Clones this transfer function.
* \return A clone of this transfer function, caller takes ownership of the pointer.
*/
virtual Geometry1DTransferFunction* clone() const;
/**
* Returns the dimensionality of the transfer function.
......
......@@ -49,6 +49,14 @@ namespace campvis {
Geometry2DTransferFunction::~Geometry2DTransferFunction() {
}
Geometry2DTransferFunction* Geometry2DTransferFunction::clone() const {
Geometry2DTransferFunction* toReturn = new Geometry2DTransferFunction(_size.xy(), _intensityDomain);
for (std::vector<TFGeometry2D*>::const_iterator it = _geometries.begin(); it != _geometries.end(); ++it) {
toReturn->addGeometry((*it)->clone());
}
return toReturn;
}
size_t Geometry2DTransferFunction::getDimensionality() const {
return 2;
}
......
......@@ -54,6 +54,12 @@ namespace campvis {
* Destructor, make sure to delete the OpenGL texture beforehand by calling deinit() with a valid OpenGL context!
*/
virtual ~Geometry2DTransferFunction();
/**
* Clones this transfer function.
* \return A clone of this transfer function, caller takes ownership of the pointer.
*/
virtual Geometry2DTransferFunction* clone() const;
/**
* Returns the dimensionality of the transfer function.
......
......@@ -50,6 +50,13 @@ namespace campvis {
}
SimpleTransferFunction* SimpleTransferFunction::clone() const {
SimpleTransferFunction* toReturn = new SimpleTransferFunction(_size.x, _intensityDomain);
toReturn->setLeftColor(_leftColor);
toReturn->setRightColor(_rightColor);
return toReturn;
}
size_t SimpleTransferFunction::getDimensionality() const {
return 1;
}
......@@ -100,4 +107,5 @@ namespace campvis {
return _rightColor;
}
}
\ No newline at end of file
......@@ -50,6 +50,12 @@ namespace campvis {
* Destructor, make sure to delete the OpenGL texture beforehand by calling deinit() with a valid OpenGL context!
*/
virtual ~SimpleTransferFunction();
/**
* Clones this transfer function.
* \return A clone of this transfer function, caller takes ownership of the pointer.
*/
virtual SimpleTransferFunction* clone() const;
/**
* Returns the dimensionality of the transfer function.
......
......@@ -51,6 +51,10 @@ namespace campvis {
}
TFGeometry1D* TFGeometry1D::clone() const {
return new TFGeometry1D(_keyPoints);
}
std::vector<TFGeometry1D::KeyPoint>& TFGeometry1D::getKeyPoints() {
return _keyPoints;
}
......
......@@ -67,6 +67,12 @@ namespace campvis {
*/
virtual ~TFGeometry1D();
/**
* Clones this transfer function geometry.
* \return A clone of this transfer function geometry, caller takes ownership of the pointer.
*/
TFGeometry1D* clone() const;
/**
* Returns the vector of KeyPoints.
* \return
......
......@@ -66,6 +66,10 @@ namespace campvis {
}
TFGeometry2D* TFGeometry2D::clone() const {
return new TFGeometry2D(_keyPoints);
}
std::vector<TFGeometry2D::KeyPoint>& TFGeometry2D::getKeyPoints() {
return _keyPoints;
}
......@@ -131,4 +135,5 @@ namespace campvis {
}
}
\ No newline at end of file
......@@ -66,6 +66,12 @@ namespace campvis {
* Virtual destructor
*/
virtual ~TFGeometry2D();
/**
* Clones this transfer function geometry.
* \return A clone of this transfer function geometry, caller takes ownership of the pointer.
*/
TFGeometry2D* clone() const;
/**
* Returns the vector of KeyPoints.
......
......@@ -42,9 +42,9 @@ struct TFParameters2D {
* \return Intensity mapped to transfer function domain for LUT.
*/
float mapIntensityToTFDomain(in vec2 intensityDomain, in float intensity) {
if(intensity <= intensityDomain.x)
if(intensity < intensityDomain.x)
return -1.0;
else if(intensity >= intensityDomain.y)
else if(intensity > intensityDomain.y)
return -1.0;
else
return (intensity - intensityDomain.x) / (intensityDomain.y - intensityDomain.x);
......
......@@ -179,12 +179,15 @@ namespace campvis {
// TODO: replace this hardcoded domain by automatically determined from image min/max values
Geometry1DTransferFunction* tf = new Geometry1DTransferFunction(128, tgt::vec2(0.f, 1.f));
tf->addGeometry(TFGeometry1D::createQuad(tgt::vec2(0.f, 1.f), tgt::col4(0, 0, 0, 0), tgt::col4(255, 255, 255, 255)));
tf->addGeometry(TFGeometry1D::createQuad(tgt::vec2(0.f, 1.f), tgt::col4(0, 0, 0, 255), tgt::col4(255, 255, 255, 255)));
_usFusion1.p_transferFunction.replaceTF(tf);
_usFusion2.p_transferFunction.replaceTF(tf->clone());
_usFusion3.p_transferFunction.replaceTF(tf->clone());
_usFusion4.p_transferFunction.replaceTF(tf->clone());
// TODO: replace this hardcoded domain by automatically determined from image min/max values
Geometry1DTransferFunction* tf2 = new Geometry1DTransferFunction(256, tgt::vec2(0.f, 1.f));
tf2->addGeometry(TFGeometry1D::createQuad(tgt::vec2(0.f, 1.f), tgt::col4(0, 0, 0, 0), tgt::col4(255, 255, 255, 255)));
tf2->addGeometry(TFGeometry1D::createQuad(tgt::vec2(0.f, 1.f), tgt::col4(0, 0, 0, 255), tgt::col4(255, 255, 255, 255)));
_usDVR.p_transferFunction.replaceTF(tf2);
_usDVR.p_targetImageID.setValue("us.dvr");
......
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