Ignore:
Timestamp:
Apr 21, 2012, 1:33:14 PM (12 years ago)
Author:
Torben Dannhauer
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • experimental/distortionNG/DistortionManipulator.cpp

    r348 r349  
    3131        activeManualSetupMode = DISTORTION;
    3232        activeVisualizationMode = NONE;
     33
     34        _distortionSet = NULL;
    3335}
    3436
     
    5052bool DistortionManipulator::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* obj, osg::NodeVisitor* nv)
    5153{
    52         osgViewer::View* viewer = dynamic_cast<osgViewer::View*>(&aa);
    53                 if ( viewer )
    54                 {
    55                         //osg::notify(osg::ALWAYS)<<"viewer!"<<std::endl;
    56                 }
     54        //osgViewer::View* viewer = dynamic_cast<osgViewer::View*>(&aa);
     55        //if ( viewer && !_distortionSet.isValid())
     56        //{
     57        //      OSG_ALWAYS<<"Fetching valid DistortionSet!"<<std::endl;
     58        //      _distortionSet = viewer->getDistortionSet();
     59        //}
    5760
    5861        switch(ea.getEventType())
     
    6164        case(osgGA::GUIEventAdapter::DRAG):
    6265                {
    63                         osg::notify(osg::ALWAYS)<<"DRAG!"<<std::endl;
     66                        OSG_ALWAYS<<"DRAG!"<<std::endl;
    6467                        break;
    6568                }
     
    6871                        if(ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
    6972                        {
    70                                 osg::notify(osg::ALWAYS)<<"mouse click left!"<<std::endl;
     73                                OSG_ALWAYS<<"mouse click left!"<<std::endl;
    7174                        }
    7275                        break;
     
    9497                                }
    9598
    96                                 osg::notify(osg::ALWAYS)<<"KEY_KP_4 : Setup Mode now "<<activeSetupMode<<std::endl;
     99                                OSG_ALWAYS<<"KEY_KP_4 : Setup Mode now "<<activeSetupMode<<std::endl;
    97100                                return(true);
    98101                        }
     
    101104
    102105                                activeManualSetupMode = (activeManualSetupMode==DISTORTION?BLENDING:DISTORTION);
    103                                 osg::notify(osg::ALWAYS)<<"KEY_KP_5 : activeManualSetupMode is now "<<activeManualSetupMode<<std::endl;
     106                                OSG_ALWAYS<<"KEY_KP_5 : activeManualSetupMode is now "<<activeManualSetupMode<<std::endl;
    104107                                return(true);
    105108                        }
     
    107110                        {
    108111                                activeDistortionMode = (activeDistortionMode==MESH?TEXCOORDINATES:MESH);
    109                                 osg::notify(osg::ALWAYS)<<"KEY_KP_6 : activeDistortionMode is now "<<activeDistortionMode<<std::endl;
     112                                OSG_ALWAYS<<"KEY_KP_6 : activeDistortionMode is now "<<activeDistortionMode<<std::endl;
    110113                                return(true);
    111114                        }
     
    114117                                switch(activeVisualizationMode)
    115118                                {       
    116                                         case DISTORTION_MESH : activeVisualizationMode = INTENSITY_MAP; break;
    117                                         case INTENSITY_MAP : activeVisualizationMode = NONE; break;
    118                                         case NONE : activeVisualizationMode = DISTORTION_MESH; break;
     119                                        case DISTORTION_MESH :
     120                                        {
     121                                                activeVisualizationMode = INTENSITY_MAP;
     122                                                showDistortionMesh(true);
     123                                                showIntensityMap(false);
     124                                                break;
     125                                        }
     126                                        case INTENSITY_MAP :
     127                                        {
     128                                                activeVisualizationMode = NONE;
     129                                                showDistortionMesh(false);
     130                                                showIntensityMap(true);
     131                                                break;
     132                                        }
     133                                        case NONE :
     134                                        {
     135                                                activeVisualizationMode = DISTORTION_MESH;
     136                                                showDistortionMesh(false);
     137                                                showIntensityMap(false);
     138                                                break;
     139                                        }
    119140                                }
    120                                 osg::notify(osg::ALWAYS)<<"KEY_KP_7 : activeVisualizationMode is now "<<activeVisualizationMode<<std::endl;
     141
     142
     143                                OSG_ALWAYS<<"KEY_KP_7 : activeVisualizationMode is now "<<activeVisualizationMode<<std::endl;
    121144                                return(true);
    122145                        }
    123146                        if (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Up)     // KP 8: Save distortion set     via plugin
    124147                        {
    125                                 osg::notify(osg::ALWAYS)<<"KEY_KP_8 : todo: Save DistortionContainer"<<std::endl;
     148                                OSG_ALWAYS<<"KEY_KP_8 : todo: Save DistortionContainer"<<std::endl;
    126149                                return(true);
    127150                        }
     
    133156                case(osgGA::GUIEventAdapter::FRAME):
    134157                {
    135                         //osg::notify(osg::ALWAYS)<<"FRAME!"<<std::endl;
     158                        //OSG_ALWAYS<<"FRAME!"<<std::endl;
    136159                        break;
    137160                }
    138161        case (osgGA::GUIEventAdapter::RESIZE):  // todo: adapt distortion mesh to new screen size
    139162                {
    140                         osg::notify(osg::ALWAYS)<<"RESIZE!"<<std::endl;
     163                        OSG_ALWAYS<<"RESIZE!"<<std::endl;
    141164                        break;
    142165                }
     
    150173void DistortionManipulator::resetIntensityMap()
    151174{
    152         osg::notify(osg::ALWAYS)<<"ToDo: resetIntensityMap()"<<std::endl;
     175        if(!_distortionSet.valid())
     176                return;
     177
     178        osg::ref_ptr<osg::Image> image = _distortionSet->getIntensityMap();
     179
     180        OSG_ALWAYS<<"Reseting IntensityMap Blending."<<std::endl;
     181
     182        if (!image->isDataContiguous())
     183        {
     184                OSG_WARN<<"Warning: DistortionManipulator does not support working with non contiguous imagery as blendmaps!"<<std::endl;
     185                return;
     186        }
     187
     188        // Fill intensity map with 255
     189        unsigned char* dataPtr = image->data();
     190        for(unsigned int i=0;i<image->getTotalSizeInBytes();i++)
     191        {
     192                *dataPtr++ = 255;
     193        }
     194        image->dirty();
    153195}
    154196
    155197void DistortionManipulator::resetDistortion()
    156198{
    157         osg::notify(osg::ALWAYS)<<"ToDo: resetDistortion()"<<std::endl;
    158 }
     199        if(!_distortionSet.valid())
     200                return;
     201
     202        OSG_ALWAYS<<"ToDo: resetDistortion()"<<std::endl;
     203}
     204
     205void DistortionManipulator::showDistortionMesh(bool show)
     206{
     207        OSG_ALWAYS<<"ToDo: showDistortionMesh(bool) is now "<<show<<std::endl;
     208
     209        // Todo: Stateset muss das von der MeshGeode sein.
     210
     211   /* osg::PolygonMode* polyModeObj = dynamic_cast<osg::PolygonMode*>(_stateset->getAttribute(osg::StateAttribute::POLYGONMODE));
     212    if (!polyModeObj)
     213    {
     214        polyModeObj = new osg::PolygonMode;
     215        _stateset->setAttribute(polyModeObj);
     216    }
     217 
     218        if(show)
     219                polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
     220        else
     221                polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::FILL);*/
     222}
     223
     224void DistortionManipulator::showIntensityMap(bool show)
     225{
     226                OSG_ALWAYS<<"ToDo: showIntensityMap(bool) is now "<<show<<std::endl;
     227}
Note: See TracChangeset for help on using the changeset viewer.