Changeset 349 for experimental/distortionNG/DistortionManipulator.cpp
- Timestamp:
- Apr 21, 2012, 1:33:14 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
experimental/distortionNG/DistortionManipulator.cpp
r348 r349 31 31 activeManualSetupMode = DISTORTION; 32 32 activeVisualizationMode = NONE; 33 34 _distortionSet = NULL; 33 35 } 34 36 … … 50 52 bool DistortionManipulator::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object* obj, osg::NodeVisitor* nv) 51 53 { 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 //} 57 60 58 61 switch(ea.getEventType()) … … 61 64 case(osgGA::GUIEventAdapter::DRAG): 62 65 { 63 osg::notify(osg::ALWAYS)<<"DRAG!"<<std::endl;66 OSG_ALWAYS<<"DRAG!"<<std::endl; 64 67 break; 65 68 } … … 68 71 if(ea.getButton() == osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON) 69 72 { 70 osg::notify(osg::ALWAYS)<<"mouse click left!"<<std::endl;73 OSG_ALWAYS<<"mouse click left!"<<std::endl; 71 74 } 72 75 break; … … 94 97 } 95 98 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; 97 100 return(true); 98 101 } … … 101 104 102 105 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; 104 107 return(true); 105 108 } … … 107 110 { 108 111 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; 110 113 return(true); 111 114 } … … 114 117 switch(activeVisualizationMode) 115 118 { 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 } 119 140 } 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; 121 144 return(true); 122 145 } 123 146 if (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Up) // KP 8: Save distortion set via plugin 124 147 { 125 osg::notify(osg::ALWAYS)<<"KEY_KP_8 : todo: Save DistortionContainer"<<std::endl;148 OSG_ALWAYS<<"KEY_KP_8 : todo: Save DistortionContainer"<<std::endl; 126 149 return(true); 127 150 } … … 133 156 case(osgGA::GUIEventAdapter::FRAME): 134 157 { 135 // osg::notify(osg::ALWAYS)<<"FRAME!"<<std::endl;158 //OSG_ALWAYS<<"FRAME!"<<std::endl; 136 159 break; 137 160 } 138 161 case (osgGA::GUIEventAdapter::RESIZE): // todo: adapt distortion mesh to new screen size 139 162 { 140 osg::notify(osg::ALWAYS)<<"RESIZE!"<<std::endl;163 OSG_ALWAYS<<"RESIZE!"<<std::endl; 141 164 break; 142 165 } … … 150 173 void DistortionManipulator::resetIntensityMap() 151 174 { 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(); 153 195 } 154 196 155 197 void DistortionManipulator::resetDistortion() 156 198 { 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 205 void 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 224 void 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.