source: experimental/distortionNG/DistortionManipulator.h @ 417

Last change on this file since 417 was 381, checked in by Torben Dannhauer, 12 years ago
File size: 3.4 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 "DistortionSetupStrategy.h"
31#include "DistortionSet.h"
32
33class extViewer;
34
35namespace osgViewer {
36
37
38class DistortionManipulator : public osgGA::GUIEventHandler
39{
40public:
41        enum SetupMode {
42                DISABLED,
43                MANUAL,
44                DELEGATED
45        };
46        enum DistortionMode {
47                MESH,
48                TEXCOORDINATES
49        };
50        enum ManualSetupMode {
51                DISTORTION,
52                BLENDING
53        };
54        enum VisualizationMode {
55                DISTORTION_MESH,
56                INTENSITY_MAP,
57                NONE
58        };
59
60
61        DistortionManipulator(extViewer* viewer, DistortionSet* ds);
62        virtual ~DistortionManipulator();
63
64        virtual void getUsage(osg::ApplicationUsage& usage) const;
65    virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv);
66
67        void setDistortionSet(DistortionSet* ds) {_distortionSet = ds;}
68
69        void setDistortionSetupStrategy(DistortionSetupStrategy* strategy)      {_delegatedDistortionSetupStrategy = strategy;}
70
71private:
72        void resetIntensityMap();
73        void resetDistortion();
74        void showDistortionMesh(bool show);
75        void showIntensityMap(bool show);
76
77        void computeSelectedVertex( osgUtil::LineSegmentIntersector::Intersection& result );
78        void createVertexHighlighter();
79        void createHUD();
80        void updateHUD();
81
82        void updateDistortionSetup();
83        void updateDistortionViewProjectionMatrix();
84        void updateDistortionMesh();
85
86
87        SetupMode activeSetupMode;
88        DistortionMode activeDistortionMode;
89        ManualSetupMode activeManualSetupMode;
90        VisualizationMode activeVisualizationMode;
91
92        osg::ref_ptr<DistortionSet> _distortionSet;
93        osg::ref_ptr<DistortionSetupStrategy> _delegatedDistortionSetupStrategy;
94
95        osg::ref_ptr<osg::Geometry> _highlighter;
96    osg::observer_ptr<osg::Camera> _camera;
97        osg::observer_ptr<extViewer> _viewer;
98        osg::Geometry* _distortionMesh;
99        const osg::Vec4 _highlightColor;
100       
101        //LF Screen Resolution
102        unsigned int _screenPixWidth, _screenPixHeight;
103       
104
105        // HUD
106        osg::ref_ptr<osgText::Text> hudSetupMode;
107        osg::ref_ptr<osgText::Text> hudDistortionMode;
108        osg::ref_ptr<osgText::Text> hudManualSetupMode;
109        osg::ref_ptr<osgText::Text> hudVisualizationMode;
110};
111
112
113}
114
115#endif /* OSGGA_DISTORTION_MANIPULATOR */
Note: See TracBrowser for help on using the repository browser.