Commit ba495b1a authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[MERGE]

parents 4a811e28 e6f264fa
......@@ -65,6 +65,18 @@ void WPathHelper::setBasePaths( boost::filesystem::path appPath, boost::filesyst
m_modulePath = m_libPath / "openwalnut";
}
void WPathHelper::setBasePathsOSXBundle( boost::filesystem::path appPath, boost::filesystem::path homePath )
{
//W_ASSERT( appPath.substr( size()-sizeof( "MacOS" ), sizeof( "MacOS" ) ) == "MacOS" );
m_appPath = appPath;
m_homePath = homePath;
m_sharePath = m_appPath / "../Resources/openwalnut";
m_docPath = m_appPath / "../Resources/doc";
m_configPath = m_appPath / "../Resources/openwalnut";
m_libPath = m_appPath / "../lib"; // TODO(mario): what is this for?
m_modulePath = m_appPath / "../Resources/modules";
}
boost::filesystem::path WPathHelper::getAppPath()
{
return getPathHelper()->m_appPath;
......
......@@ -56,7 +56,7 @@ public:
static boost::shared_ptr< WPathHelper > getPathHelper();
/**
* Set the current application path. This should be called only once. The home path hereby is NOT the users home. It is an directory, where
* Set the current application path. This should be called only once. The home path hereby is NOT the users home. It is a directory, where
* OW can write user specific data. A good default here is to specify USERHOME/.OpenWalnut for example.
*
* \param appPath the application path
......@@ -64,6 +64,15 @@ public:
*/
void setBasePaths( boost::filesystem::path appPath, boost::filesystem::path homePath );
/**
* Set the current application path. This should be called only once. The home path hereby is NOT the users home. It is a directory, where
* OW can write user specific data. A good default here is to specify USERHOME/.OpenWalnut for example.
*
* \param appPath the application path
* \param homePath the OW home path
*/
void setBasePathsOSXBundle( boost::filesystem::path appPath, boost::filesystem::path homePath );
/**
* The path where the binary file resides in. This is for example /usr/bin.
*
......
......@@ -33,7 +33,7 @@
#include "WPropertyTypes.h"
/**
* This is a dynamic property list. With its help, user can dynamically add items.
* This is a dynamic property list. With its help, users can dynamically add items.
*
* \tparam T This is a property type. The list will then contain several of these properties.
*/
......
......@@ -55,13 +55,15 @@ private:
/**
* comparison by isovalue
* \param rhs entry to compare t
* \returns true if this->iso <= rhs.iso
*/
bool operator <= ( const Entry &rhs ) const
{
return iso <= rhs.iso;
}
double iso; //< the isovalue
/** the isovalue */
double iso;
};
/**
......@@ -80,13 +82,15 @@ private:
/**
* comparison operator to check for changes
* \param rhs ColorEntry to compare to
* \returns true if rhs equals this
*/
bool operator==( const ColorEntry& rhs ) const
{
return iso == rhs.iso && color == rhs.color;
}
WColor color; //< holds the current color at isovalue Entry::iso
/** holds the current color at isovalue Entry::iso */
WColor color;
};
/**
......@@ -108,13 +112,15 @@ private:
/**
* comparison operator to check for changes
* \param rhs AlphaEntry to compare to
* \returns true if rhs is equal to this
*/
bool operator==( const AlphaEntry& rhs ) const
{
return iso == rhs.iso && alpha == rhs.alpha;
}
double alpha; //< holds the current alpha at isovalue Entry::iso
/** holds the current alpha at isovalue Entry::iso */
double alpha;
};
/**
......@@ -123,17 +129,24 @@ private:
template<typename T>
struct LessPred
{
/** constructs a predicate that compares for less than iso
* \param iso: used iso value
*/
explicit LessPred( double iso ) : iso( iso )
{
}
/** isovalue-based comparison */
/** isovalue-based comparison
* \param t the object to compare to
* \returns true if iso is less than t.iso
*/
bool operator()( const T& t )
{
return iso < t.iso;
}
double iso; //< the isovalue to compare to
/** the isovalue to compare to */
double iso;
};
public:
......@@ -142,13 +155,19 @@ public:
{
}
/** deep copy constructor */
/** deep copy constructor
* \param rhs the value to histogram
*/
WTransferFunction( const WTransferFunction &rhs )
: colors( rhs.colors ), alphas( rhs.alphas ), isomin( rhs.isomin ), isomax( rhs.isomax ), histogram( rhs.histogram )
{
}
/** deep copy operator */
/** deep copy operator
* \param rhs the value to copy
* \returns reference to current object
* \returns reference to current object
*/
WTransferFunction& operator=( const WTransferFunction &rhs )
{
this->colors = rhs.colors;
......@@ -168,6 +187,7 @@ public:
/**
* \returns negated result of operator==
* \param rhs the value to compare with
*/
bool operator!=( const WTransferFunction &rhs ) const;
......@@ -176,31 +196,54 @@ public:
{
}
/**
* \returns the number of alpha points
*/
size_t numAlphas() const
{
return alphas.size();
}
/**
* \returns the number of color points
*/
size_t numColors() const
{
return colors.size();
}
/**
* \param i the index of the point to query
* \returns the alpha values position/isovalue at index i
*/
double getAlphaIsovalue( size_t i ) const
{
return alphas.at( i ).iso;
}
/**
* \param i the index of the point to query
* \returns the color values position/isovalue at index i
*/
double getColorIsovalue( size_t i ) const
{
return colors.at( i ).iso;
}
/**
* \param i the index to query
* \returns the alpha value at index i
*/
double getAlpha( size_t i ) const
{
return alphas.at( i ).alpha;
}
/**
* \param i the index to query
* \returns the color at index i
*/
const WColor& getColor( size_t i ) const
{
return colors.at( i ).color;
......@@ -208,11 +251,15 @@ public:
/**
* insert a new color point
* \param iso the new iso value
* \param color the new color at the given iso value
*/
void addColor( double iso, const WColor& color );
/**
* insert a new alpha point
* \param iso the new iso value
* \param alpha the new alpha value at the given iso value
*/
void addAlpha( double iso, double alpha );
......@@ -222,6 +269,8 @@ public:
* This should be changed in the future to be handled in a different
* way. A good option would be to introduce an object encapsulating
* a transfer function and histogram information.
*
* \param data the histogram data between isomin and isomax
*/
void setHistogram( std::vector< double > & data )
{
......@@ -236,6 +285,10 @@ public:
histogram.clear();
}
/**
* returns the histogram
* \returns a reference to the internal representation of the histogram
*/
const std::vector< double >& getHistogram() const
{
return histogram;
......@@ -243,10 +296,12 @@ public:
/**
* sample/render the transfer function linearly between min and max in an RGBA texture.
* \param array pointer to an allocated data structure
* \param width is the number of RGBA samples.
* \param min the lowest value to be sampled
* \param max the hightes value to be sampled
* \post array contains the sampled data
* \pre array is allocated and has space for width elements
*/
void sample1DTransferFunction( unsigned char*array, int width, double min, double max ) const;
......@@ -258,14 +313,21 @@ public:
*/
static WTransferFunction createFromRGBA( unsigned char const * const rgba, size_t size );
private:
std::vector<ColorEntry> colors; //< sorted list of colors
std::vector<AlphaEntry> alphas; //< sorted list of alpha values
/** sorted list of colors */
std::vector<ColorEntry> colors;
double isomin; //< smallest iso value
double isomax; //< largest iso value
/** sorted list of alpha values */
std::vector<AlphaEntry> alphas;
std::vector< double > histogram; //< store a histogram. This is used for property-handling only
// and does not change the transfer function at all.
/** the smallest used iso value */
double isomin;
/** the largest used iso value */
double isomax;
/** stores a histogram. This is used for property-handling only
* and does not change the transfer function at all.
*/
std::vector< double > histogram;
friend std::ostream& operator << ( std::ostream& out, const WTransferFunction& tf );
};
......@@ -275,7 +337,7 @@ private:
* This code should only be used for debugging and you should not realy on the interface.
* \param tf The transfer function to output
* \param out The stream to which we write
* \returns reference to \param out
* \returns reference to out
*/
std::ostream& operator << ( std::ostream& out, const WTransferFunction& tf );
......
......@@ -28,6 +28,7 @@
#include <map>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include "datastructures/WValueSetHistogram.h"
......@@ -41,6 +42,16 @@
class OWDATAHANDLER_EXPORT WDataSetScalar : public WDataSetSingle // NOLINT
{
public:
/**
* shared_ptr abbreviation
*/
typedef boost::shared_ptr< WDataSetScalar > SPtr;
/**
* const shared_ptr abbreviation
*/
typedef boost::shared_ptr< const WDataSetScalar > ConstSPtr;
/**
* Constructs an instance out of an appropriate value set and a grid.
* Computes the maximum an minimum values stored as member variables.
......
......@@ -87,7 +87,7 @@ WGEViewer::WGEViewer( std::string name, osg::ref_ptr<osg::Referenced> wdata, int
case( WGECamera::ORTHOGRAPHIC ):
m_pickHandler = new WPickHandler( name );
m_View->addEventHandler( m_pickHandler );
if( name != std::string( "main" ) )
if( name != std::string( "Main View" ) )
break;
case( WGECamera::PERSPECTIVE ):
// camera manipulator
......
......@@ -168,7 +168,7 @@ boost::shared_ptr< WGEViewer > WGraphicsEngine::getViewerByName( std::string nam
boost::shared_ptr< WGEViewer > WGraphicsEngine::getViewer()
{
boost::mutex::scoped_lock lock( m_viewersLock );
return m_viewers[ "main" ];
return m_viewers[ "Main View" ];
}
bool WGraphicsEngine::isRunning()
......
......@@ -185,7 +185,7 @@ void WPickHandler::pick( osgViewer::View* view, const osgGA::GUIEventAdapter& ea
updatePickInfoModifierKeys( &pickInfo );
// if we are in another viewer than the main view we just need the pixel position
if( m_viewerName != "" && m_viewerName != "main" )
if( m_viewerName != "" && m_viewerName != "Main View" )
{
pickInfo = WPickInfo( "", m_viewerName, m_startPick.getPickPosition(), std::make_pair( x, y ),
m_startPick.getModifierKey(), m_mouseButton, m_startPick.getPickNormal() );
......
......@@ -124,7 +124,7 @@ WROIBox::WROIBox( WPosition minPos, WPosition maxPos ) :
boost::shared_ptr< WGraphicsEngine > ge = WGraphicsEngine::getGraphicsEngine();
assert( ge );
boost::shared_ptr< WGEViewer > viewer = ge->getViewerByName( "main" );
boost::shared_ptr< WGEViewer > viewer = ge->getViewerByName( "Main View" );
assert( viewer );
m_viewer = viewer;
m_pickHandler = m_viewer->getPickHandler();
......
......@@ -56,7 +56,7 @@ WROISphere::WROISphere( WPosition position, float radius ) :
{
boost::shared_ptr< WGraphicsEngine > ge = WGraphicsEngine::getGraphicsEngine();
assert( ge );
boost::shared_ptr< WGEViewer > viewer = ge->getViewerByName( "main" );
boost::shared_ptr< WGEViewer > viewer = ge->getViewerByName( "Main View" );
assert( viewer );
m_viewer = viewer;
m_pickHandler = m_viewer->getPickHandler();
......
......@@ -107,6 +107,7 @@ public:
* \param mat the matrix transforming the vertices from canonical space
* \param vals the values at the vertices
* \param isoValue The surface will run through all positions with this value.
* \param progress parent's WProgressCombiner. May be empty if no status report is requested
*
* \return the created triangle mesh
*/
......
......@@ -171,6 +171,7 @@ public:
*
* \param offscreen use this offscreen node to add your texture pass'
* \param gbuffer the input textures you should use
* \returns shared pointer to the created instance
*/
virtual SPtr create( osg::ref_ptr< WGEOffscreenRenderNode > offscreen, const PostprocessorInput& gbuffer ) const = 0;
......
......@@ -60,6 +60,7 @@ public:
*
* \param offscreen use this offscreen node to add your texture pass'
* \param gbuffer the input textures you should use
* \returns shared pointer to the created instance
*/
virtual WGEPostprocessor::SPtr create( osg::ref_ptr< WGEOffscreenRenderNode > offscreen, const PostprocessorInput& gbuffer ) const;
protected:
......
......@@ -60,6 +60,7 @@ public:
*
* \param offscreen use this offscreen node to add your texture pass'
* \param gbuffer the input textures you should use
* \returns shared pointer to the created insteance
*/
virtual WGEPostprocessor::SPtr create( osg::ref_ptr< WGEOffscreenRenderNode > offscreen, const PostprocessorInput& gbuffer ) const;
protected:
......
......@@ -86,6 +86,7 @@ public:
*
* \param offscreen use this offscreen node to add your texture pass'
* \param gbuffer the input textures you should use
* \returns shared pointer to the created instance
*/
virtual WGEPostprocessor::SPtr create( osg::ref_ptr< WGEOffscreenRenderNode > offscreen,
const PostprocessorInput& gbuffer ) const;
......
......@@ -90,6 +90,7 @@ public:
*
* \param offscreen use this offscreen node to add your texture pass'
* \param gbuffer the input textures you should use
* \returns shared pointer to the created insteance
*/
virtual WGEPostprocessor::SPtr create( osg::ref_ptr< WGEOffscreenRenderNode > offscreen,
const PostprocessorInput& gbuffer ) const;
......
......@@ -37,7 +37,7 @@ class WROIBoxTest : public CxxTest::TestSuite
public:
/**
* I would like to test instantiation here, but WROIBox needs nearly a complete
* running GUI and GE with the "main" viewer. This seemed to much effort for
* running GUI and GE with the "Main View" viewer. This seemed to much effort for
* this small test to me.
*/
void testInstantiation( void )
......
......@@ -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;
}
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