source: experimental/distortionNG/DistortionManipulator.cpp @ 347

Last change on this file since 347 was 347, checked in by Torben Dannhauer, 13 years ago
File size: 4.5 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#include "DistortionManipulator.h"
20
21#include<osgViewer/Viewer>
22
23using namespace osg;
24using namespace osgViewer;
25
26
27DistortionManipulator::DistortionManipulator()
28{
29}
30
31DistortionManipulator::~DistortionManipulator()
32{
33}
34
35void DistortionManipulator::getUsage(osg::ApplicationUsage& usage) const
36{
37    usage.addKeyboardMouseBinding("Keypad 7","Show distortion mesh / intensity map / none.");
38        usage.addKeyboardMouseBinding("Keypad 8","Save distortion set.");       // via plugin
39        usage.addKeyboardMouseBinding("Keypad 4","Toggles Setup Mode between DISABLED, MANUAL & DELEGATED.");
40        usage.addKeyboardMouseBinding("Keypad 5","MANUAL Mode: Toggle between blending & distortion setup.");
41        usage.addKeyboardMouseBinding("Keypad 6","MANUAL Mode: Toggle if distortion drags affect mesh or rtt texture coordinates.");    // Defaults to Mesh
42        usage.addKeyboardMouseBinding("Keypad 1","Reset distortion.");
43        usage.addKeyboardMouseBinding("Keypad 2","Reset intensity blending.");
44}
45
46bool DistortionManipulator::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor* nv)
47{
48        osgViewer::View* viewer = dynamic_cast<osgViewer::View*>(&aa);
49                if ( viewer )
50                {
51                        //osg::notify(osg::ALWAYS)<<"viewer!"<<std::endl;
52                }
53
54        switch(ea.getEventType())
55    {
56        case(osgGA::GUIEventAdapter::MOVE):
57        case(osgGA::GUIEventAdapter::DRAG):
58                {
59                        osg::notify(osg::ALWAYS)<<"DRAG!"<<std::endl;
60                        break;
61                }
62        case(osgGA::GUIEventAdapter::PUSH):
63        case(osgGA::GUIEventAdapter::RELEASE):
64        case(osgGA::GUIEventAdapter::KEYDOWN):
65                {
66                        if (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_End)    // KP 1: reset distortion
67                        {
68                                resetDistortion();
69                                return(true);
70                        }
71                        if (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Down)   // KP 2: reset intensity map
72                        {
73                                resetIntensityMap();
74                                return(true);
75                        }
76                        if (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Left)   // KP 4: Toggles Setup Mode between DISABLED, MANUAL & DELEGATED.
77                        {
78                                osg::notify(osg::ALWAYS)<<"KEY_KP_4"<<std::endl;
79                                return(true);
80                        }
81                        if (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Begin)  // KP 5: MANUAL Mode: Toggle between blending & distortion setup.
82                        {
83                                osg::notify(osg::ALWAYS)<<"KEY_KP_5"<<std::endl;
84                                return(true);
85                        }
86                        if (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Right)  // KP 6: MANUAL Mode: Toggle if distortion drags affect mesh or rtt texture coordinates -> defaults to Mesh
87                        {
88                                osg::notify(osg::ALWAYS)<<"KEY_KP_6"<<std::endl;
89                                return(true);
90                        }
91                        if (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Home)   // KP 7: Show distortion mesh / intensity map / none.
92                        {
93                                osg::notify(osg::ALWAYS)<<"KEY_KP_7"<<std::endl;
94                                return(true);
95                        }
96                        if (ea.getKey()==osgGA::GUIEventAdapter::KEY_KP_Up)     // KP 8: Save distortion set     via plugin
97                        {
98                                osg::notify(osg::ALWAYS)<<"KEY_KP_8"<<std::endl;
99                                return(true);
100                        }
101                       
102
103                        return false;   // Event ignored
104                }
105        case(osgGA::GUIEventAdapter::KEYUP):
106                case(osgGA::GUIEventAdapter::FRAME):
107                {
108                        //osg::notify(osg::ALWAYS)<<"FRAME!"<<std::endl;
109                        break;
110                }
111        case (osgGA::GUIEventAdapter::RESIZE):  // todo: adapt distortion mesh to new screen size
112                {
113                        osg::notify(osg::ALWAYS)<<"RESIZE!"<<std::endl;
114                        break;
115                }
116
117        default:
118            return false;
119    }
120    return false;
121}
122
123void DistortionManipulator::resetIntensityMap()
124{
125        osg::notify(osg::ALWAYS)<<"ToDo: resetIntensityMap()"<<std::endl;
126}
127
128void DistortionManipulator::resetDistortion()
129{
130        osg::notify(osg::ALWAYS)<<"ToDo: resetDistortion()"<<std::endl;
131}
Note: See TracBrowser for help on using the repository browser.