Commit 0d57b8da by schurade

[IMPROVE] allow copying from input dataset

parent 681fcdcd
......@@ -123,6 +123,9 @@ void WMPaintTexture::properties()
m_queueAdded = m_properties->addProperty( "Something paint", "", false, m_propCondition );
m_queueAdded->setHidden();
m_buttonCopyFromInput = m_properties->addProperty( "Copy from input", "Copies data from the input dataset into the paint texture",
WPVBaseTypes::PV_TRIGGER_READY, m_propCondition );
m_buttonUpdateOutput = m_properties->addProperty( "Update output", "Updates the output connector",
WPVBaseTypes::PV_TRIGGER_READY, m_propCondition );
}
......@@ -204,6 +207,12 @@ void WMPaintTexture::moduleMain()
WDataHandler::getDefaultSubject()->getChangeCondition()->notify();
}
}
if ( m_buttonCopyFromInput->get( true ) == WPVBaseTypes::PV_TRIGGER_TRIGGERED )
{
copyFromInput();
m_buttonCopyFromInput->set( WPVBaseTypes::PV_TRIGGER_READY, false );
}
}
else // case !dataValid
{
......@@ -354,3 +363,19 @@ void WMPaintTexture::updateOutDataset()
m_outData = boost::shared_ptr< WDataSetScalar >( new WDataSetScalar( vs, grid ) );
m_output->updateData( m_outData );
}
void WMPaintTexture::copyFromInput()
{
m_grid = boost::shared_dynamic_cast< WGridRegular3D >( m_dataSet->getGrid() );
unsigned char* data = m_texture->getImage()->data();
boost::shared_ptr< WValueSet< unsigned char > > vals;
vals = boost::shared_dynamic_cast< WValueSet< unsigned char > >( m_dataSet->getValueSet() );
for ( unsigned int i = 0; i < m_grid->getNbCoordsX() * m_grid->getNbCoordsY() * m_grid->getNbCoordsZ(); ++i )
{
data[i] = vals->getScalar( i );
}
m_texture->dirtyTextureObject();
}
......@@ -144,6 +144,11 @@ private:
void updateOutDataset();
/**
* copies data from the input dataset into the paint texture
*/
void copyFromInput();
/**
* Interpolation?
*/
WPropBool m_painting;
......@@ -234,6 +239,11 @@ private:
boost::shared_ptr< WCondition > m_propCondition;
/**
* copies the input dataset into the paint texture, this allows to continue work
*/
WPropTrigger m_buttonCopyFromInput;
/**
* updates the output connector on demand, as we don't want to do this every paint command
*/
WPropTrigger m_buttonUpdateOutput;
......
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