Index: experimental/distortionNG/DistortionManipulator.cpp
===================================================================
--- experimental/distortionNG/DistortionManipulator.cpp	(revision 348)
+++ experimental/distortionNG/DistortionManipulator.cpp	(revision 349)
@@ -31,4 +31,6 @@
 	activeManualSetupMode = DISTORTION;
 	activeVisualizationMode = NONE;
+
+	_distortionSet = NULL;
 }
 
@@ -50,9 +52,10 @@
 bool DistortionManipulator::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* obj, osg::NodeVisitor* nv)
 {
-	osgViewer::View* viewer = dynamic_cast<osgViewer::View*>(&aa);
-		if ( viewer )
-		{
-			//osg::notify(osg::ALWAYS)<<"viewer!"<<std::endl;
-		}
+	//osgViewer::View* viewer = dynamic_cast<osgViewer::View*>(&aa);
+	//if ( viewer && !_distortionSet.isValid())
+	//{
+	//	OSG_ALWAYS<<"Fetching valid DistortionSet!"<<std::endl;
+	//	_distortionSet = viewer->getDistortionSet();
+	//}
 
 	switch(ea.getEventType())
@@ -61,5 +64,5 @@
         case(osgGA::GUIEventAdapter::DRAG):
 		{
-			osg::notify(osg::ALWAYS)<<"DRAG!"<<std::endl;
+			OSG_ALWAYS<<"DRAG!"<<std::endl;
 			break;
 		}
@@ -68,5 +71,5 @@
 			if(ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
 			{
-				osg::notify(osg::ALWAYS)<<"mouse click left!"<<std::endl;
+				OSG_ALWAYS<<"mouse click left!"<<std::endl;
 			}
 			break;
@@ -94,5 +97,5 @@
 				}
 
-				osg::notify(osg::ALWAYS)<<"KEY_KP_4 : Setup Mode now "<<activeSetupMode<<std::endl;
+				OSG_ALWAYS<<"KEY_KP_4 : Setup Mode now "<<activeSetupMode<<std::endl;
 				return(true);
 			}
@@ -101,5 +104,5 @@
 
 				activeManualSetupMode = (activeManualSetupMode==DISTORTION?BLENDING:DISTORTION);
-				osg::notify(osg::ALWAYS)<<"KEY_KP_5 : activeManualSetupMode is now "<<activeManualSetupMode<<std::endl;
+				OSG_ALWAYS<<"KEY_KP_5 : activeManualSetupMode is now "<<activeManualSetupMode<<std::endl;
 				return(true);
 			}
@@ -107,5 +110,5 @@
 			{
 				activeDistortionMode = (activeDistortionMode==MESH?TEXCOORDINATES:MESH);
-				osg::notify(osg::ALWAYS)<<"KEY_KP_6 : activeDistortionMode is now "<<activeDistortionMode<<std::endl;
+				OSG_ALWAYS<<"KEY_KP_6 : activeDistortionMode is now "<<activeDistortionMode<<std::endl;
 				return(true);
 			}
@@ -114,14 +117,34 @@
 				switch(activeVisualizationMode)
 				{	
-					case DISTORTION_MESH : activeVisualizationMode = INTENSITY_MAP; break;
-					case INTENSITY_MAP : activeVisualizationMode = NONE; break;
-					case NONE : activeVisualizationMode = DISTORTION_MESH; break;
+					case DISTORTION_MESH : 
+					{
+						activeVisualizationMode = INTENSITY_MAP;
+						showDistortionMesh(true);
+						showIntensityMap(false);
+						break;
+					}
+					case INTENSITY_MAP :
+					{
+						activeVisualizationMode = NONE;
+						showDistortionMesh(false);
+						showIntensityMap(true);
+						break;
+					}
+					case NONE : 
+					{
+						activeVisualizationMode = DISTORTION_MESH;
+						showDistortionMesh(false);
+						showIntensityMap(false);
+						break;
+					}
 				}
-				osg::notify(osg::ALWAYS)<<"KEY_KP_7 : activeVisualizationMode is now "<<activeVisualizationMode<<std::endl;
+
+
+				OSG_ALWAYS<<"KEY_KP_7 : activeVisualizationMode is now "<<activeVisualizationMode<<std::endl;
 				return(true);
 			}
 			if (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Up)	// KP 8: Save distortion set	 via plugin
 			{
-				osg::notify(osg::ALWAYS)<<"KEY_KP_8 : todo: Save DistortionContainer"<<std::endl;
+				OSG_ALWAYS<<"KEY_KP_8 : todo: Save DistortionContainer"<<std::endl;
 				return(true);
 			}
@@ -133,10 +156,10 @@
 		case(osgGA::GUIEventAdapter::FRAME):
 		{
-			//osg::notify(osg::ALWAYS)<<"FRAME!"<<std::endl;
+			//OSG_ALWAYS<<"FRAME!"<<std::endl;
 			break;
 		}
         case (osgGA::GUIEventAdapter::RESIZE):	// todo: adapt distortion mesh to new screen size
 		{
-			osg::notify(osg::ALWAYS)<<"RESIZE!"<<std::endl;
+			OSG_ALWAYS<<"RESIZE!"<<std::endl;
 			break;
 		}
@@ -150,9 +173,55 @@
 void DistortionManipulator::resetIntensityMap()
 {
-	osg::notify(osg::ALWAYS)<<"ToDo: resetIntensityMap()"<<std::endl;
+	if(!_distortionSet.valid())
+		return;
+
+	osg::ref_ptr<osg::Image> image = _distortionSet->getIntensityMap();
+
+	OSG_ALWAYS<<"Reseting IntensityMap Blending."<<std::endl;
+
+	if (!image->isDataContiguous())
+	{
+		OSG_WARN<<"Warning: DistortionManipulator does not support working with non contiguous imagery as blendmaps!"<<std::endl;
+		return;
+	}
+
+	// Fill intensity map with 255 
+	unsigned char* dataPtr = image->data(); 
+	for(unsigned int i=0;i<image->getTotalSizeInBytes();i++)
+	{
+		*dataPtr++ = 255; 
+	}
+	image->dirty();
 }
 
 void DistortionManipulator::resetDistortion()
 {
-	osg::notify(osg::ALWAYS)<<"ToDo: resetDistortion()"<<std::endl;
-}
+	if(!_distortionSet.valid())
+		return;
+
+	OSG_ALWAYS<<"ToDo: resetDistortion()"<<std::endl;
+}
+
+void DistortionManipulator::showDistortionMesh(bool show)
+{
+	OSG_ALWAYS<<"ToDo: showDistortionMesh(bool) is now "<<show<<std::endl;
+
+	// Todo: Stateset muss das von der MeshGeode sein.
+
+   /* osg::PolygonMode* polyModeObj = dynamic_cast<osg::PolygonMode*>(_stateset->getAttribute(osg::StateAttribute::POLYGONMODE));
+    if (!polyModeObj)
+    {
+        polyModeObj = new osg::PolygonMode;
+        _stateset->setAttribute(polyModeObj);
+    }
+ 
+	if(show)
+		polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
+	else
+		polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::FILL);*/
+}
+
+void DistortionManipulator::showIntensityMap(bool show)
+{
+		OSG_ALWAYS<<"ToDo: showIntensityMap(bool) is now "<<show<<std::endl;
+}
