Commit b11978d4 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - textureMapper module uses old colormapping. colormapper module uses...

[CHANGE] - textureMapper module uses old colormapping. colormapper module uses new colormapping mechanism.
parent 57b40077
......@@ -41,6 +41,12 @@ class WDataTexture3D;
class WCondition;
class WDataSetVector;
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
#define OW_API_DEPRECATED __attribute__((__deprecated__))
#else
#define OW_API_DEPRECATED
#endif /* __GNUC__ */
/**
* Base class for all data set types. This class has a number of subclasses
* specifying the different types of data sets. Two of the dataset types
......@@ -97,6 +103,7 @@ public:
* \return The texture.
* \deprecated
*/
OW_API_DEPRECATED
virtual boost::shared_ptr< WDataTexture3D > getTexture();
/**
......
FILE( GLOB_RECURSE MODULES_SRC "*.cpp" "*.h" )
# Grab module name and setup target directories
GET_FILENAME_COMPONENT( MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME )
SET( MODULE_TARGET_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/modules/${MODULE_NAME} )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
SET( MODULE_DIRNAME ${MODULE_NAME} )
SET( MODULE_NAME "OWmodule_${MODULE_NAME}" ) # prefix all module names with "OWmodule_" to separate them from other libs
# Build module lib
ADD_LIBRARY( ${MODULE_NAME} SHARED ${MODULES_SRC} )
TARGET_LINK_LIBRARIES( ${MODULE_NAME} OWkernel )
IF(MSVC_IDE)
SET_TARGET_PROPERTIES( ${MODULE_NAME} PROPERTIES PREFIX "../")
ENDIF(MSVC_IDE)
# Copy local shaders to module target directory
IF( OW_COPY_SHADERS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/shaders ) # copy shaders only if the user wants it
ADD_CUSTOM_TARGET( ${MODULE_NAME}_CopyShaders
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/shaders ${MODULE_TARGET_DIR}/shaders/
COMMENT "Copy shaders of ${MODULE_NAME}"
)
ADD_DEPENDENCIES( ${MODULE_NAME} ${MODULE_NAME}_CopyShaders )
ENDIF()
# Build unit tests
IF( OW_COMPILE_TESTS )
# This ensures that the test is copied to the module directory
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${MODULE_TARGET_DIR} )
CXXTEST_ADD_TESTS_FROM_LIST( "${MODULES_SRC}"
"OWkernel;${MODULE_NAME}"
)
# Copy fixtures if they exist
IF( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures )
ADD_CUSTOM_TARGET( ${MODULE_NAME}_CopyFixtures
# as the "test" target runs in CMakes temporary build dir, the fixtures need to be placed there too.
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures ${CMAKE_BINARY_DIR}/modules/${MODULE_DIRNAME}/fixtures/
COMMENT "Copy fixtures of ${MODULE_NAME}"
)
ADD_DEPENDENCIES( ${MODULE_NAME} ${MODULE_NAME}_CopyFixtures )
ENDIF( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test/fixtures )
ENDIF( OW_COMPILE_TESTS )
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <string>
#include "../../dataHandler/WDataTexture3D_2.h"
#include "../../graphicsEngine/WGEColormapping.h"
#include "../../kernel/WKernel.h"
#include "WMColormapper.xpm"
#include "WMColormapper.h"
// This line is needed by the module loader to actually find your module.
W_LOADABLE_MODULE( WMColormapper )
WMColormapper::WMColormapper() :
WModule()
{
// initialize
}
WMColormapper::~WMColormapper()
{
// cleanup
removeConnectors();
}
boost::shared_ptr< WModule > WMColormapper::factory() const
{
return boost::shared_ptr< WModule >( new WMColormapper() );
}
const char** WMColormapper::getXPMIcon() const
{
return WMColormapper_xpm;
}
const std::string WMColormapper::getName() const
{
return "Texture Mapper";
}
const std::string WMColormapper::getDescription() const
{
return "Can use the input as a texture that can be mapped to the navslices and so on.";
}
void WMColormapper::connectors()
{
m_input = WModuleInputData< WDataSetSingle >::createAndAdd( shared_from_this(), "input", "Input to apply as texture." );
// call WModules initialization
WModule::connectors();
}
void WMColormapper::properties()
{
m_propCondition = boost::shared_ptr< WCondition >( new WCondition() );
m_replace = m_properties->addProperty( "Keep position",
"If true, new texture on the input connector get placed in the list where the old one was.", true );
WModule::properties();
}
void WMColormapper::moduleMain()
{
// let the main loop awake if the data changes or the properties changed.
m_moduleState.setResetable( true, true );
m_moduleState.add( m_input->getDataChangedCondition() );
m_moduleState.add( m_propCondition );
// signal ready state
ready();
// loop until the module container requests the module to quit
while( !m_shutdownFlag() )
{
// Now, the moduleState variable comes into play. The module can wait for the condition, which gets fired whenever the input receives data
// or an property changes. The main loop now waits until something happens.
debugLog() << "Waiting ...";
m_moduleState.wait();
// woke up since the module is requested to finish
if( m_shutdownFlag() )
{
break;
}
// has the data changed?
if( m_input->handledUpdate() )
{
boost::shared_ptr< WDataSetSingle > dataSet = m_input->getData();
// replace texture instead of removing it?
if ( dataSet && dataSet->isTexture() && m_lastDataSet && m_replace->get( true ) )
{
debugLog() << "Replacing texture \"" << m_lastDataSet->getTexture2()->name()->get() << "\" with \"" <<
dataSet->getTexture2()->name()->get() << "\".";
m_properties->removeProperty( m_lastDataSet->getTexture2()->getProperties() );
m_infoProperties->removeProperty( m_lastDataSet->getTexture2()->getInformationProperties() );
m_properties->addProperty( dataSet->getTexture2()->getProperties() );
m_infoProperties->addProperty( dataSet->getTexture2()->getInformationProperties() );
WGEColormapping::replaceTexture( m_lastDataSet->getTexture2(), dataSet->getTexture2() );
m_lastDataSet = dataSet;
}
else
{
// de-register last input
if ( m_lastDataSet )
{
debugLog() << "Removing previous texture \"" << m_lastDataSet->getTexture2()->name()->get() << "\".";
m_properties->removeProperty( m_lastDataSet->getTexture2()->getProperties() );
m_infoProperties->removeProperty( m_lastDataSet->getTexture2()->getInformationProperties() );
WGEColormapping::deregisterTexture( m_lastDataSet->getTexture2() );
m_lastDataSet.reset();
}
// register only valid data
if( dataSet && dataSet->isTexture() )
{
m_lastDataSet = dataSet;
// register new
debugLog() << "Registering new texture \"" << m_lastDataSet->getTexture2()->name()->get() << "\".";
m_properties->addProperty( m_lastDataSet->getTexture2()->getProperties() );
m_infoProperties->addProperty( m_lastDataSet->getTexture2()->getInformationProperties() );
WGEColormapping::registerTexture( m_lastDataSet->getTexture2() );
}
}
}
}
// remove if module is removed
if ( m_lastDataSet )
{
debugLog() << "Removing previous texture \"" << m_lastDataSet->getTexture2()->name()->get() << "\".";
WGEColormapping::deregisterTexture( m_lastDataSet->getTexture2() );
// NOTE: the props get removed automatically
}
}
void WMColormapper::activate()
{
// deactivate the output if wanted
if ( m_lastDataSet )
{
m_lastDataSet->getTexture2()->active()->set( m_active->get( true ) );
}
// Always call WModule's activate!
WModule::activate();
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WMTEXTUREMAPPER_H
#define WMTEXTUREMAPPER_H
#include <string>
#include "../../kernel/WModule.h"
#include "../../kernel/WModuleInputData.h"
#include "../../common/WPropertyVariable.h"
#include "../../dataHandler/WDataSetSingle.h"
/**
* This module simply registers the given dataset to the texture handling mechanism. This allows all outputs to be shown as a texture.
*
* \ingroup modules
*/
class WMColormapper: public WModule
{
public:
/**
* Standard constructor.
*/
WMColormapper();
/**
* Destructor.
*/
~WMColormapper();
/**
* Gives back the name of this module.
* \return the module's name.
*/
virtual const std::string getName() const;
/**
* Gives back a description of this module.
* \return description of module.
*/
virtual const std::string getDescription() const;
/**
* Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
* should never be initialized or modified in some other way. A simple new instance is required.
*
* \return the prototype used to create every module in OpenWalnut.
*/
virtual boost::shared_ptr< WModule > factory() const;
/**
* Get the icon for this module in XPM format.
*/
virtual const char** getXPMIcon() const;
protected:
/**
* Entry point after loading the module. Runs in separate thread.
*/
virtual void moduleMain();
/**
* Initialize the connectors this module is using.
*/
virtual void connectors();
/**
* Initialize the properties for this module.
*/
virtual void properties();
/**
* Callback for m_active. Overwrite this in your modules to handle m_active changes separately.
*/
virtual void activate();
private:
/**
* A condition used to notify about changes in several properties.
*/
boost::shared_ptr< WCondition > m_propCondition;
boost::shared_ptr< WModuleInputData< WDataSetSingle > > m_input; //!< Input connector required by this module.
/**
* This is a pointer to the dataset the module is currently working on.
*/
boost::shared_ptr< WDataSetSingle > m_lastDataSet;
/**
* If true, the new texture gets placed at the position of the old one in the texture sorter
*/
WPropBool m_replace;
};
#endif // WMTEXTUREMAPPER_H
/* XPM */
static const char * WMColormapper_xpm[] = {
"32 32 255 2",
" c None",
". c #C0C0C0",
"+ c #8D8D8D",
"@ c #C9C9C9",
"# c #A1A1A1",
"$ c #AAA8A8",
"% c #D2D2D2",
"& c #8F8F8F",
"* c #B7B7B7",
"= c #989696",
"- c #A7A7A7",
"; c #9F9F9F",
"> c #969696",
", c #A0A0A0",
"' c #989898",
") c #636363",
"! c #787878",
"~ c #727272",
"{ c #8E8E8E",
"] c #A4A4A4",
"^ c #6C6C6C",
"/ c #828282",
"( c #A5A5A5",
"_ c #7F7F7F",
": c #8B8B8B",
"< c #999999",
"[ c #919191",
"} c #6D6D6D",
"| c #666666",
"1 c #777777",
"2 c #979797",
"3 c #878787",
"4 c #676767",
"5 c #5A5A5A",
"6 c #757575",
"7 c #7A7A7A",
"8 c #848484",
"9 c #888888",
"0 c #808080",
"a c #767676",
"b c #7D7D7D",
"c c #909090",
"d c #686868",
"e c #929292",
"f c #6A6A6A",
"g c #8C8C8C",
"h c #6B6B6B",
"i c #000000",
"j c #1C1C1C",
"k c #414141",
"l c #5B5B5B",
"m c #6E6E6E",
"n c #040404",
"o c #070707",
"p c #0E0E0E",
"q c #494949",
"r c #8A8A8A",
"s c #868686",
"t c #050505",
"u c #181818",
"v c #858585",
"w c #020202",
"x c #131313",
"y c #5E5E5E",
"z c #7C7C7C",
"A c #0D0D0D",
"B c #222222",
"C c #171717",
"D c #060606",
"E c #474747",
"F c #121212",
"G c #090909",
"H c #2B2B2B",
"I c #141414",
"J c #424242",
"K c #898989",
"L c #9A9A9A",
"M c #696969",
"N c #3D3D3D",
"O c #5C5C5C",
"P c #797979",
"Q c #656565",
"R c #797777",
"S c #616161",
"T c #303030",
"U c #0A0A0A",
"V c #0C0C0C",
"W c #323232",
"X c #5F5F5F",
"Y c #DDAF62",
"Z c #D4AC5D",
"` c #C3A457",
" . c #7A6A37",
".. c #16130A",
"+. c #020100",
"@. c #1E1E0E",
"#. c #727536",
"$. c #8A9442",
"%. c #839441",
"&. c #4E832E",
"*. c #006C12",
"=. c #006D12",
"-. c #F4B669",
";. c #E9B365",
">. c #C49A56",
",. c #40341C",
"'. c #030301",
"). c #010100",
"!. c #2F2A15",
"~. c #978B45",
"{. c #A39D4C",
"]. c #989B49",
"^. c #8F9845",
"/. c #849442",
"(. c #5A8832",
"_. c #0E7017",
":. c #C0987D",
"<. c #FDB76C",
"[. c #C08E53",
"}. c #21190E",
"|. c #0A0804",
"1. c #6A582F",
"2. c #B99E53",
"3. c #B9A354",
"4. c #AFA150",
"5. c #A59E4D",
"6. c #9A9B4A",
"7. c #919846",
"8. c #879542",
"9. c #5F6396",
"0. c #7E7388",
"a. c #7E6558",
"b. c #271C12",
"c. c #080603",
"d. c #3C2D1A",
"e. c #BA9151",
"f. c #D7AC5F",
"g. c #CEAA5C",
"h. c #C4A758",
"i. c #BBA555",
"j. c #B0A151",
"k. c #A69E4D",
"l. c #9C9B4A",
"m. c #2344A5",
"n. c #344897",
"o. c #303351",
"p. c #0D0C0F",
"q. c #110E0D",
"r. c #78593B",
"s. c #E9AC64",
"t. c #EEB467",
"u. c #E4B163",
"v. c #DBAE60",
"w. c #D0AB5D",
"x. c #C7A859",
"y. c #BCA556",
"z. c #B2A252",
"A. c #577199",
"B. c #3A5591",
"C. c #111F48",
"D. c #04060D",
"E. c #121421",
"F. c #544F66",
"G. c #9D8281",
"H. c #DEA776",
"I. c #FAB86C",
"J. c #F1B468",
"K. c #E6B165",
"L. c #DCAF61",
"M. c #D2AC5D",
"N. c #C8A859",
"O. c #718691",
"P. c #596E84",
"Q. c #202A38",
"R. c #05070C",
"S. c #0D1834",
"T. c #253C89",
"U. c #4D5998",
"V. c #706C91",
"W. c #958088",
"X. c #D4A278",
"Y. c #FCB86C",
"Z. c #F1B568",
"`. c #E8B265",
" + c #DEAF61",
".+ c #8A9C8B",
"++ c #667672",
"@+ c #1F2528",
"#+ c #060709",
"$+ c #202936",
"%+ c #40598C",
"&+ c #3050A2",
"*+ c #2544A4",
"=+ c #48579B",
"-+ c #6A6993",
";+ c #8D7C8B",
">+ c #C99B7B",
",+ c #FEB86D",
"'+ c #F4B569",
")+ c #B3BF7F",
"!+ c #768162",
"~+ c #242823",
"{+ c #0F1211",
"]+ c #374245",
"^+ c #61778A",
"/+ c #5D7698",
"(+ c #4D689B",
"_+ c #3553A1",
":+ c #2041A6",
"<+ c #42539D",
"[+ c #646694",
"}+ c #86788C",
"|+ c #BE967E",
"1+ c #E7EB71",
"2+ c #959B57",
"3+ c #323522",
"4+ c #26291F",
"5+ c #5C6858",
"6+ c #7E9088",
"7+ c #788D91",
"8+ c #6B8294",
"9+ c #5F7897",
"0+ c #516C9B",
"a+ c #3957A0",
"b+ c #2042A5",
"c+ c #3B509E",
"d+ c #5E6396",
"e+ c #16F146",
"f+ c #88CCAB",
"g+ c #A1A34C",
"h+ c #8E9350",
"i+ c #A7B16F",
"j+ c #A8B684",
"k+ c #96A78B",
"l+ c #85998E",
"m+ c #7A8F90",
"n+ c #6D8593",
"o+ c #617A97",
"p+ c #556F99",
"q+ c #3D5B9F",
"r+ c #2445A5",
"s+ c #00FF00",
"t+ c #00FC00",
"u+ c #00F504",
"v+ c #7DDACE",
"w+ c #F6F971",
"x+ c #DEE57A",
"y+ c #C4CE80",
"z+ c #AFBC84",
"A+ c #99AA8A",
"B+ c #889B8D",
"C+ c #7C9190",
"D+ c #708693",
"E+ c #647C96",
"F+ c #577298",
" . . + @ # $ % & * * = % - ; @ ",
" > , ' ) ! ~ { ] ^ ~ ! / ( _ ) : @ ",
" > < [ } | 1 2 2 1 | } [ ' 3 4 ) ; ",
" 5 6 7 8 9 0 1 1 0 9 8 7 a b 3 _ - ",
" c d ^ e < 9 | | 9 < e ^ | a ' ( % ",
" d f ~ g e 8 } } 8 e g ~ ^ 7 [ / = ",
" b c g ~ ^ 7 [ [ 7 ^ ~ g e 8 } ! * ",
" & c { h | a ' ' a | ^ e < 9 | ~ * ",
" i i i i i i j k l m 6 b 3 3 b a 7 8 9 0 1 ^ & ",
" i i i i i i n o p q r s 4 4 3 ' [ } | 1 2 ] % ",
" i i i i t i i u a v 4 4 3 ' [ } | 1 2 { $ ",
" i i i w i i x y z 3 3 b a 7 8 9 0 1 ~ # ",
" i i i i A n w B l a ' ' a | ^ e < 9 | ! @ ",
" i i i i i i C D x E 4 7 [ [ 7 ^ ~ g e 8 } ) + ",
" i i i i i F G H 1 [ 8 } } 8 e g ~ ^ 7 [ ' . ",
" i i i i i I C J K L v M M v L c f d 6 < , . ",
" i i i C N O 1 < f 8 8 f < P ~ e Q : K R ",
" i i i ",
" i i i ",
"} } ^ S T U V W X ^ } } } } } ",
"Y Z ` ...+.@.#.$.%.&.*.=.*.} ",
"-.;.>.,.'.).!.~.{.].^./.(._.} ",
":.<.[.}.i |.1.2.3.4.5.6.7.8.} ",
"9.0.a.b.c.d.e.f.g.h.i.j.k.l.} ",
"m.n.o.p.q.r.s.t.u.v.w.x.y.z.} ",
"A.B.C.D.E.F.G.H.I.J.K.L.M.N.} ",
"O.P.Q.R.S.T.U.V.W.X.Y.Z.`. +} ",
".+++@+#+$+%+&+*+=+-+;+>+,+'+} ",
")+!+~+{+]+^+/+(+_+:+<+[+}+|+} ",
"1+2+3+4+5+6+7+8+9+0+a+b+c+d+} ",
"e+f+g+h+i+j+k+l+m+n+o+p+q+r+} ",