[346] | 1 | /* osgVisual test. distortionNG, experimental. |
---|
| 2 | * |
---|
| 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
| 4 | * of this software and associated documentation files (the "Software"), to deal |
---|
| 5 | * in the Software without restriction, including without limitation the rights |
---|
| 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
| 7 | * copies of the Software, and to permit persons to whom the Software is |
---|
| 8 | * furnished to do so, subject to the following conditions: |
---|
| 9 | * |
---|
| 10 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
| 11 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
| 12 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
| 13 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
| 14 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
| 15 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
| 16 | * THE SOFTWARE. |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | #ifndef OSGGA_DISTORTION_MANIPULATOR |
---|
| 20 | #define OSGGA_DISTORTION_MANIPULATOR 1 |
---|
| 21 | |
---|
[349] | 22 | #include <osgGA/GUIEventHandler> |
---|
[353] | 23 | #include <osg/Referenced> |
---|
| 24 | #include <osg/Switch> |
---|
| 25 | #include <osg/Geometry> |
---|
| 26 | #include <osgUtil/IntersectionVisitor> |
---|
| 27 | #include <osgUtil/LineSegmentIntersector> |
---|
[356] | 28 | #include <osgText/Text> |
---|
[353] | 29 | |
---|
[349] | 30 | #include "DistortionSet.h" |
---|
[346] | 31 | |
---|
| 32 | |
---|
| 33 | namespace osgViewer { |
---|
| 34 | |
---|
[353] | 35 | |
---|
[346] | 36 | class DistortionManipulator : public osgGA::GUIEventHandler |
---|
| 37 | { |
---|
| 38 | public: |
---|
[348] | 39 | enum SetupMode { |
---|
| 40 | DISABLED, |
---|
| 41 | MANUAL, |
---|
| 42 | DELEGATED |
---|
| 43 | }; |
---|
| 44 | enum DistortionMode { |
---|
| 45 | MESH, |
---|
| 46 | TEXCOORDINATES |
---|
| 47 | }; |
---|
| 48 | enum ManualSetupMode { |
---|
| 49 | DISTORTION, |
---|
| 50 | BLENDING |
---|
| 51 | }; |
---|
| 52 | enum VisualizationMode { |
---|
| 53 | DISTORTION_MESH, |
---|
| 54 | INTENSITY_MAP, |
---|
| 55 | NONE |
---|
| 56 | }; |
---|
| 57 | |
---|
| 58 | |
---|
[353] | 59 | DistortionManipulator(DistortionSet* ds); |
---|
[346] | 60 | virtual ~DistortionManipulator(); |
---|
| 61 | |
---|
| 62 | virtual void getUsage(osg::ApplicationUsage& usage) const; |
---|
| 63 | virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv); |
---|
[347] | 64 | |
---|
[349] | 65 | void setDistortionSet(DistortionSet* ds) {_distortionSet = ds;} |
---|
| 66 | |
---|
[353] | 67 | |
---|
| 68 | |
---|
[347] | 69 | private: |
---|
| 70 | void resetIntensityMap(); |
---|
| 71 | void resetDistortion(); |
---|
[349] | 72 | void showDistortionMesh(bool show); |
---|
| 73 | void showIntensityMap(bool show); |
---|
[348] | 74 | |
---|
[353] | 75 | void computeSelectedVertex( osgUtil::LineSegmentIntersector::Intersection& result ); |
---|
| 76 | void createVertexHighlighter(); |
---|
[356] | 77 | void createHUD(); |
---|
| 78 | void updateHUD(); |
---|
[353] | 79 | |
---|
[348] | 80 | SetupMode activeSetupMode; |
---|
| 81 | DistortionMode activeDistortionMode; |
---|
| 82 | ManualSetupMode activeManualSetupMode; |
---|
| 83 | VisualizationMode activeVisualizationMode; |
---|
[349] | 84 | |
---|
| 85 | osg::ref_ptr<DistortionSet> _distortionSet; |
---|
[353] | 86 | |
---|
| 87 | |
---|
| 88 | osg::ref_ptr<osg::Geometry> _highlighter; |
---|
| 89 | osg::observer_ptr<osg::Camera> _camera; |
---|
| 90 | osg::Geometry* _distortionMesh; |
---|
| 91 | const osg::Vec4 _highlightColor; |
---|
[356] | 92 | |
---|
| 93 | // HUD |
---|
| 94 | osg::ref_ptr<osgText::Text> hudSetupMode; |
---|
| 95 | osg::ref_ptr<osgText::Text> hudDistortionMode; |
---|
| 96 | osg::ref_ptr<osgText::Text> hudManualSetupMode; |
---|
| 97 | osg::ref_ptr<osgText::Text> hudVisualizationMode; |
---|
[346] | 98 | }; |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | #endif /* OSGGA_DISTORTION_MANIPULATOR */ |
---|