source: experimental/distortionNG/DistortionManipulator.h @ 363

Last change on this file since 363 was 356, checked in by Torben Dannhauer, 12 years ago
File size: 2.9 KB
Line 
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
22#include <osgGA/GUIEventHandler>
23#include <osg/Referenced>
24#include <osg/Switch>
25#include <osg/Geometry>
26#include <osgUtil/IntersectionVisitor>
27#include <osgUtil/LineSegmentIntersector>
28#include <osgText/Text>
29
30#include "DistortionSet.h"
31
32
33namespace osgViewer {
34
35
36class DistortionManipulator : public osgGA::GUIEventHandler
37{
38public:
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
59        DistortionManipulator(DistortionSet* ds);
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);
64
65        void setDistortionSet(DistortionSet* ds) {_distortionSet = ds;}
66
67       
68
69private:
70        void resetIntensityMap();
71        void resetDistortion();
72        void showDistortionMesh(bool show);
73        void showIntensityMap(bool show);
74
75        void computeSelectedVertex( osgUtil::LineSegmentIntersector::Intersection& result );
76        void createVertexHighlighter();
77        void createHUD();
78        void updateHUD();
79
80        SetupMode activeSetupMode;
81        DistortionMode activeDistortionMode;
82        ManualSetupMode activeManualSetupMode;
83        VisualizationMode activeVisualizationMode;
84
85        osg::ref_ptr<DistortionSet> _distortionSet;
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;
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;
98};
99
100
101}
102
103#endif /* OSGGA_DISTORTION_MANIPULATOR */
Note: See TracBrowser for help on using the repository browser.