Commit 42467dc3 by reichenbach

[FIX #411] fixed offset in nav slices, fixed texture matrix, added function for…

[FIX #411] fixed offset in nav slices, fixed texture matrix, added function for copying texture properties
parent 0577df7d
......@@ -32,7 +32,7 @@ WDataTexture3D::WDataTexture3D( boost::shared_ptr< WValueSetBase > valueSet, boo
WGETexture3D( static_cast< float >( valueSet->getMaximumValue() - valueSet->getMinimumValue() ),
static_cast< float >( valueSet->getMinimumValue() ) ),
m_valueSet( valueSet ),
m_boundingBox( grid->getBoundingBoxIncludingBorder() )
m_boundingBox( grid->getVoxelBoundingBox() )
{
// initialize members
setTextureSize( grid->getNbCoordsX(), grid->getNbCoordsY(), grid->getNbCoordsZ() );
......@@ -61,9 +61,9 @@ WDataTexture3D::WDataTexture3D( boost::shared_ptr< WValueSetBase > valueSet, boo
// Move to voxel center. This scaling is NOT included in the grid's transform, so we need to add it here
WMatrix4d offset = WMatrix4d::identity();
offset( 0, 3 ) = 0.5 / grid->getNbCoordsX();
offset( 1, 3 ) = 0.5 / grid->getNbCoordsY();
offset( 2, 3 ) = 0.5 / grid->getNbCoordsZ();
offset( 3, 0 ) = 0.5 / grid->getNbCoordsX();
offset( 3, 1 ) = 0.5 / grid->getNbCoordsY();
offset( 3, 2 ) = 0.5 / grid->getNbCoordsZ();
transformation()->set( invert( static_cast< WMatrix4d >( grid->getTransform() ) ) * scale * offset );
......
......@@ -278,6 +278,13 @@ public:
*/
virtual WBoundingBox getBoundingBox() const;
/**
* Copy the values of all properties except the texture transformation into the properties of this texture.
*
* \param from The texture to copy property values from.
*/
virtual void copyPropertiesExceptTransformation( osg::ref_ptr< WGETexture< TextureType > > const& from );
protected:
/**
* Handles all property updates. Called by m_propCondition.
......@@ -775,6 +782,29 @@ WBoundingBox WGETexture< TextureType >::getBoundingBox() const
}
template < typename TextureType >
void WGETexture< TextureType >::copyPropertiesExceptTransformation( osg::ref_ptr< WGETexture< TextureType > > const& from )
{
m_name->set( from->m_name->get() );
m_sortIdx->set( from->m_sortIdx->get() );
m_min->set( from->m_min->get() );
m_scale->set( from->m_scale->get() );
m_alpha->set( from->m_alpha->get() );
m_clipZero->set( from->m_clipZero->get() );
m_thresholdEnabled->set( from->m_thresholdEnabled->get() );
m_thresholdLower->set( from->m_thresholdLower->get() );
m_thresholdUpper->set( from->m_thresholdUpper->get() );
m_windowEnabled->set( from->m_windowEnabled->get() );
m_window->set( from->m_window->get() );
m_interpolation->set( from->m_interpolation->get() );
m_colorMapSelectionsList = from->m_colorMapSelectionsList;
m_colorMap->set( from->m_colorMap->get() );
m_active->set( from->m_active->get() );
}
template < typename TextureType >
WPVBaseTypes::PV_INT WGETexture< TextureType >::getUnsetSortIndex()
{
return std::numeric_limits< WPVBaseTypes::PV_INT >::max();
......
......@@ -333,10 +333,11 @@ void WMData::matrixUpdate()
// Update the m_dataSet
m_dataSet = m_dataSetAsSingle->clone( newGrid );
// Update textures? Keep trakc of old
// carry over old properties (i.e. colormap) except for the new transform
if( m_dataSet->isTexture() && m_dataSet->getTexture() )
{
m_dataSet->getTexture()->getProperties()->set( m_dataSetAsSingle->getTexture()->getProperties() );
m_dataSet->getTexture()->copyPropertiesExceptTransformation( m_dataSetAsSingle->getTexture() );
}
m_dataSetAsSingle = boost::dynamic_pointer_cast< WDataSetSingle >( m_dataSet );
......
......@@ -53,8 +53,7 @@
W_LOADABLE_MODULE( WMNavigationSlices )
WMNavigationSlices::WMNavigationSlices():
WModule(),
m_first( true )
WModule()
{
}
......@@ -154,14 +153,10 @@ void WMNavigationSlices::initOSG()
m_yPos->setHidden( false );
m_zPos->setHidden( false );
// if this is done the first time, set the slices to the center of the dataset
if( m_first )
{
m_first = false;
m_xPos->setRecommendedValue( midBB[0] );
m_yPos->setRecommendedValue( midBB[1] );
m_zPos->setRecommendedValue( midBB[2] );
}
// always update slice positions if they happen to be outside the bounding box (i.e. after shrinking the box)
m_xPos->setRecommendedValue( midBB[0] );
m_yPos->setRecommendedValue( midBB[1] );
m_zPos->setRecommendedValue( midBB[2] );
///////////////////////////////////////////////////////////////////////////////////////////////
// Navigation View Setup
......
......@@ -225,11 +225,6 @@ private:
WPropBool m_showonY; //!< indicates whether the vector should be shown on slice Y
WPropBool m_showonZ; //!< indicates whether the vector should be shown on slice Z
/**
* If true, the nav slices get positioned in the middle of the first dataset.
*/
bool m_first;
};
#endif // WMNAVIGATIONSLICES_H
......
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