Commit 24198df4 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - now able to suppress colormaps during batch load and extewnded...

[ADD] - now able to suppress colormaps during batch load and extewnded WBatchLoader to return the list of modules loaded.
parent 6981d250
......@@ -26,7 +26,6 @@
#include <vector>
#include "WModule.h"
#include "WDataModule.h"
#include "WModuleContainer.h"
#include "WModuleFactory.h"
......@@ -36,7 +35,8 @@ WBatchLoader::WBatchLoader( std::vector< std::string > fileNames, boost::shared_
WThreadedRunner(),
boost::enable_shared_from_this< WBatchLoader >(),
m_fileNamesToLoad( fileNames ),
m_targetContainer( targetContainer )
m_targetContainer( targetContainer ),
m_suppressColormaps( false )
{
// initialize members
}
......@@ -63,16 +63,36 @@ void WBatchLoader::threadMain()
boost::shared_ptr< WModule > mod = WModuleFactory::getModuleFactory()->create(
WModuleFactory::getModuleFactory()->getPrototypeByName( "Data Module" )
);
WDataModule::SPtr dmod = boost::shared_static_cast< WDataModule >( mod );
dmod->setSuppressColormaps( m_suppressColormaps );
// set the filename
boost::shared_static_cast< WDataModule >( mod )->setFilename( *iter );
dmod->setFilename( *iter );
m_targetContainer->add( mod );
// serialize loading of a couple of data sets
// ignore the case where isCrashed is true
mod->isReadyOrCrashed().wait();
// add module to the list
m_dataModules.push_back( dmod );
}
m_targetContainer->finishedPendingThread( shared_from_this() );
}
WBatchLoader::DataModuleList::ReadTicket WBatchLoader::getDataModuleList() const
{
return m_dataModules.getReadTicket();
}
void WBatchLoader::setSuppressColormaps( bool suppress )
{
m_suppressColormaps = suppress;
}
bool WBatchLoader::getSuppressColormaps() const
{
return m_suppressColormaps;
}
......@@ -32,6 +32,9 @@
#include <boost/shared_ptr.hpp>
#include "../common/WThreadedRunner.h"
#include "../common/WSharedSequenceContainer.h"
#include "WDataModule.h"
#include "WExportKernel.h"
......@@ -44,6 +47,21 @@ class OWKERNEL_EXPORT WBatchLoader: public WThreadedRunner,
public boost::enable_shared_from_this< WBatchLoader >
{
public:
/**
* Shared ptr abbreviation
*/
typedef boost::shared_ptr< WBatchLoader > SPtr;
/**
* Const shared ptr abbreviation
*/
typedef boost::shared_ptr< const WBatchLoader > ConstSPtr;
/**
* The type is used to store the list of data modules
*/
typedef WSharedSequenceContainer< std::vector< WDataModule::SPtr > > DataModuleList;
/**
* Initializes the batchloader but does not start it. Use run().
*
......@@ -62,6 +80,30 @@ public:
*/
virtual void run();
/**
* Returns a ticket to the list of data modules that have been added so far.
*
* \return the ticket
*/
DataModuleList::ReadTicket getDataModuleList() const;
/**
* Allows suppression of colormap registration in data modules. This can be handy if you use data modules in a container to construct more
* complex data sets from multiple input files.
*
* \note call this before run().
*
* \param suppress true if suppress
*/
void setSuppressColormaps( bool suppress = true );
/**
* Checks whether suppression of colormaps is active.
*
* \return true if colormaps are suppressed.
*/
bool getSuppressColormaps() const;
protected:
/**
* Function that has to be overwritten for execution. It gets executed in a separate thread after run()
......@@ -79,6 +121,16 @@ protected:
*/
boost::shared_ptr< WModuleContainer > m_targetContainer;
/**
* The list of modules that have been added.
*/
DataModuleList m_dataModules;
/**
* If true, data modules are instructed to suppress colormap registration.
*/
bool m_suppressColormaps;
private:
};
......
......@@ -39,3 +39,13 @@ MODULE_TYPE WDataModule::getType() const
return MODULE_DATA;
}
void WDataModule::setSuppressColormaps( bool suppress )
{
m_suppressColormaps = suppress;
}
bool WDataModule::getSuppressColormaps() const
{
return m_suppressColormaps;
}
......@@ -89,8 +89,29 @@ public:
*/
virtual boost::filesystem::path getFilename() const = 0;
/**
* Allows suppression of colormap registration in data modules. This can be handy if you use data modules in a container to construct more
* complex data sets from multiple input files.
*
* \note call this before adding and running the module.
*
* \param suppress true if suppress
*/
virtual void setSuppressColormaps( bool suppress = true );
/**
* Checks whether suppression of colormaps is active.
*
* \return true if colormaps are suppressed.
*/
bool getSuppressColormaps() const;
protected:
private:
/**
* If true, data modules are instructed to suppress colormap registration.
*/
bool m_suppressColormaps;
};
#endif // WDATAMODULE_H
......
......@@ -165,14 +165,14 @@ const WBoolFlag& WKernel::isFinishRequested() const
return m_shutdownFlag;
}
void WKernel::loadDataSets( std::vector< std::string > fileNames )
WBatchLoader::SPtr WKernel::loadDataSets( std::vector< std::string > fileNames, bool suppressColormaps )
{
getRootContainer()->loadDataSets( fileNames );
return getRootContainer()->loadDataSets( fileNames, suppressColormaps );
}
void WKernel::loadDataSetsSynchronously( std::vector< std::string > fileNames )
WBatchLoader::SPtr WKernel::loadDataSetsSynchronously( std::vector< std::string > fileNames, bool suppressColormaps )
{
getRootContainer()->loadDataSetsSynchronously( fileNames );
return getRootContainer()->loadDataSetsSynchronously( fileNames, suppressColormaps );
}
boost::shared_ptr< WModule > WKernel::applyModule( boost::shared_ptr< WModule > applyOn, boost::shared_ptr< WModule > prototype )
......
......@@ -33,6 +33,9 @@
#include "../common/WTimer.h"
#include "../common/WLogger.h"
#include "../graphicsEngine/WGraphicsEngine.h"
#include "WBatchLoader.h"
#include "WExportKernel.h"
// forward declarations
......@@ -108,16 +111,24 @@ public:
*
* \param fileNames list of filenames to load. The registered notification handler for the root container will get notified on
* error and success.
* \param suppressColormaps if true, the data modules are instructed to avoid registration of colormaps. This can be very handy if you
* combine multiple data loaders into one new data loader or data set
*
* \return the batch loader responsible for loading. Can be queried for the list of data modules.
*/
void loadDataSets( std::vector< std::string > fileNames );
WBatchLoader::SPtr loadDataSets( std::vector< std::string > fileNames, bool suppressColormaps = false );
/**
* Loads the specified files synchronously.
*
* \param fileNames list of filenames to load. The registered notification handler for the root container will get notified on
* error and success.
* \param suppressColormaps if true, the data modules are instructed to avoid registration of colormaps. This can be very handy if you
* combine multiple data loaders into one new data loader or data set
*
* \return the batch loader responsible for loading. Can be queried for the list of data modules.
*/
void loadDataSetsSynchronously( std::vector< std::string > fileNames );
WBatchLoader::SPtr loadDataSetsSynchronously( std::vector< std::string > fileNames, bool suppressColormaps = false );
/**
* Function combines to modules. This is a simple alias for "getRootContainer()->applyModule". It runs synchronously, which
......
......@@ -423,24 +423,27 @@ boost::shared_ptr< WModule > WModuleContainer::applyModule( boost::shared_ptr< W
return m;
}
boost::shared_ptr< WBatchLoader > WModuleContainer::loadDataSets( std::vector< std::string > fileNames )
WBatchLoader::SPtr WModuleContainer::loadDataSets( std::vector< std::string > fileNames, bool suppressColormaps )
{
// create thread which actually loads the data
boost::shared_ptr< WBatchLoader > t = boost::shared_ptr< WBatchLoader >( new WBatchLoader( fileNames,
boost::shared_static_cast< WModuleContainer >( shared_from_this() ) )
);
t->setSuppressColormaps( suppressColormaps );
t->run();
return t;
}
void WModuleContainer::loadDataSetsSynchronously( std::vector< std::string > fileNames )
WBatchLoader::SPtr WModuleContainer::loadDataSetsSynchronously( std::vector< std::string > fileNames, bool suppressColormaps )
{
// create thread which actually loads the data
boost::shared_ptr< WBatchLoader > t = boost::shared_ptr< WBatchLoader >( new WBatchLoader( fileNames,
boost::shared_static_cast< WModuleContainer >( shared_from_this() ) )
);
t->setSuppressColormaps( suppressColormaps );
t->run();
t->wait();
return t;
}
void WModuleContainer::addPendingThread( boost::shared_ptr< WThreadedRunner > thread )
......
......@@ -43,9 +43,9 @@
#include "WModuleCombinerTypes.h"
#include "WModuleConnectorSignals.h"
#include "WModuleSignals.h"
#include "WBatchLoader.h"
class WThreadedRunner;
class WBatchLoader;
class WDataModule;
#include "WExportKernel.h"
......@@ -195,18 +195,24 @@ public:
*
* \param fileNames list of filenames to load. The registered notification handler for the root container will get notified on
* error and success.
* \param suppressColormaps if true, the data modules are instructed to avoid registration of colormaps. This can be very handy if you
* combine multiple data loaders into one new data loader or data set
*
* \return the loader handling the load operation
*/
boost::shared_ptr< WBatchLoader > loadDataSets( std::vector< std::string > fileNames );
WBatchLoader::SPtr loadDataSets( std::vector< std::string > fileNames, bool suppressColormaps = false );
/**
* Loads the specified files synchronously.
* Loads the specified files synchronously. The returned batchloader can be queried for the list of data modules that have been added.
*
* \param fileNames list of filenames to load. The registered notification handler for the root container will get notified on
* error and success.
* \param suppressColormaps if true, the data modules are instructed to avoid registration of colormaps. This can be very handy if you
* combine multiple data loaders into one new data loader or data set
*
* \return the loader has handled the load operation
*/
void loadDataSetsSynchronously( std::vector< std::string > fileNames );
WBatchLoader::SPtr loadDataSetsSynchronously( std::vector< std::string > fileNames, bool suppressColormaps = false );
/**
* Add the specified thread to the list of pending jobs. Only this ensures, that ALL pending threads get stopped before the
......
......@@ -295,7 +295,10 @@ void WMData::moduleMain()
// textures also provide properties
if( m_dataSet->isTexture() )
{
WGEColormapping::registerTexture( m_dataSet->getTexture(), m_runtimeName->get() );
if( !getSuppressColormaps() )
{
WGEColormapping::registerTexture( m_dataSet->getTexture(), m_runtimeName->get() );
}
m_properties->addProperty( m_dataSet->getTexture()->getProperties() );
m_infoProperties->addProperty( m_dataSet->getTexture()->getInformationProperties() );
}
......@@ -358,7 +361,10 @@ void WMData::moduleMain()
if( m_isTexture )
{
WGEColormapping::registerTexture( m_dataSet->getTexture(), m_runtimeName->get() );
if( !getSuppressColormaps() )
{
WGEColormapping::registerTexture( m_dataSet->getTexture(), m_runtimeName->get() );
}
m_properties->addProperty( m_dataSet->getTexture()->getProperties() );
m_infoProperties->addProperty( m_dataSet->getTexture()->getInformationProperties() );
}
......
......@@ -242,11 +242,11 @@ int WQt4Gui::run()
m_mainWindow->setupGUI();
m_mainWindow->show();
// connect out loader signal with kernel
// connect loader signal with kernel
#ifdef _WIN32
getLoadButtonSignal()->connect( boost::bind( &WKernel::loadDataSetsSynchronously, m_kernel, _1 ) );
getLoadButtonSignal()->connect( boost::bind( &WKernel::loadDataSetsSynchronously, m_kernel, _1, false ) );
#else
getLoadButtonSignal()->connect( boost::bind( &WKernel::loadDataSets, m_kernel, _1 ) );
getLoadButtonSignal()->connect( boost::bind( &WKernel::loadDataSets, m_kernel, _1, false ) );
#endif
// now we are initialized
......
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