NutsnBolts  0.1.0
An extension library for Coin
Loading...
Searching...
No Matches
NbNavigationMode.h
1#ifndef NB_NAVIGATIONMODE_H
2#define NB_NAVIGATIONMODE_H
3
4/**************************************************************************\
5 * Copyright (c) Kongsberg Oil & Gas Technologies AS
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * Neither the name of the copyright holder nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34\**************************************************************************/
35
36#include <Inventor/SbName.h>
37#include <Inventor/SbVec2f.h>
38#include <Inventor/SbVec3f.h>
39#include <Inventor/SbViewportRegion.h>
40
41#include <NutsnBolts/Basic.h>
42#include <NutsnBolts/navigation/NbSubMode.h>
43
44class SbRotation;
45class SoNode;
46class SoCamera;
47class SoEvent;
48
51
53class NbNavigationModeP;
54
55typedef float NbNavigation1DInputValueFunc(void * closure, const NbNavigationMode * mode, const NbNavigationControl * ctrl);
56typedef SbVec2f NbNavigation2DInputValueFunc(void * closure, const NbNavigationMode * mode, const NbNavigationControl * ctrl);
57typedef SbVec3f NbNavigation3DInputValueFunc(void * closure, const NbNavigationMode * mode, const NbNavigationControl * ctrl);
58
59class NB_DLL_API NbNavigationMode {
60 NB_NAVIGATION_MODE_HEADER(NbNavigationMode);
61
62public:
63 static void initClass(void);
64
65 // predefined set of input value functions
66 static float getAbsMouseMovePixelDistance(void * closure, const NbNavigationMode * mode, const NbNavigationControl * ctrl);
67 static float getMouseMoveVerticalPixelDistance(void * closure, const NbNavigationMode * mode, const NbNavigationControl * ctrl);
68 static float getMouseMoveVerticalNormalizedDistance(void * closure, const NbNavigationMode * mode, const NbNavigationControl * ctrl);
69 static float getMouseMoveHorizontalPixelDistance(void * closure, const NbNavigationMode * mode, const NbNavigationControl * ctrl);
70 static float getMouseMoveHorizontalNormalizedDistance(void * closure, const NbNavigationMode * mode, const NbNavigationControl * ctrl);
71 static float getAbsMouseCenterPixelDistance(void * closure, const NbNavigationMode * mode, const NbNavigationControl * ctrl);
72 static float getMouseCenterVerticalPixelDistance(void * closure, const NbNavigationMode * mode, const NbNavigationControl * ctrl);
73 static float getMouseCenterHorizontalPixelDistance(void * closure, const NbNavigationMode * mode, const NbNavigationControl * ctrl);
74 static float getMouseMoveAngle(void * closure, const NbNavigationMode * mode, const NbNavigationControl * ctrl);
75 static float getMouseCenterAngle(void * closure, const NbNavigationMode * mode, const NbNavigationControl * ctrl);
76 static float getMouseMoveCenterAngle(void * closure, const NbNavigationMode * mode, const NbNavigationControl * ctrl);
77
78public:
79 NbNavigationMode(SbName modename);
80 virtual ~NbNavigationMode(void);
81
82 virtual NbNavigationMode * clone(void) const = 0;
83
84 SbName getModeName(void) const;
85
86 void set1DValueFunc(NbNavigation1DInputValueFunc * func, void * closure);
87 NbNavigation1DInputValueFunc * get1DValueFunc(void ** closureptr = NULL) const;
88 void set2DValueFunc(NbNavigation2DInputValueFunc * func, void * closure);
89 NbNavigation2DInputValueFunc * get2DValueFunc(void ** closureptr = NULL) const;
90 void set3DValueFunc(NbNavigation3DInputValueFunc * func, void * closure);
91 NbNavigation3DInputValueFunc * get3DValueFunc(void ** closureptr = NULL) const;
92
93 SbBool processEvent(const SoEvent * event, const NbNavigationControl * ctrl);
94
95 virtual SoNode * getSceneGraph(void);
96
97 virtual SbBool handleEvent(const SoEvent * event, const NbNavigationControl * ctrl) = 0;
98
99 virtual void init(const SoEvent * event, const NbNavigationControl * ctrl);
100 virtual void abort(const SoEvent * event, const NbNavigationControl * ctrl);
101 virtual void finish(const SoEvent * event, const NbNavigationControl * ctrl);
102
103 SbBool isAborted(void) const;
104 SbBool isFinished(void) const;
105
106protected:
107 float get1DValue(const NbNavigationControl * ctrl) const;
108 SbVec2f get2DValue(const NbNavigationControl * ctrl) const;
109 SbVec3f get3DValue(const NbNavigationControl * ctrl) const;
110
111 SbVec2s getInitialPosition(void) const;
112 SbVec2s getPreviousPosition(void) const;
113 SbVec2s getCurrentPosition(void) const;
114
115 SbVec2f getInitialNormalizedPosition(const NbNavigationControl * ctrl) const;
116 SbVec2f getPreviousNormalizedPosition(const NbNavigationControl * ctrl) const;
117 SbVec2f getCurrentNormalizedPosition(const NbNavigationControl * ctrl) const;
118
119 void abort(void);
120 void finish(void);
121
122private:
123 NbNavigationModeP * pimpl;
124
125}; // NbNavigationMode
126
127#endif // !NB_NAVIGATIONMODE_H
Definition NbNavigationControl.h:50
Abstract base class for implementing a navigation submode.
Definition NbNavigationMode.h:59
virtual SbBool handleEvent(const SoEvent *event, const NbNavigationControl *ctrl)=0
Class for managing user-based viewer navigation.
Definition NbNavigationSystem.h:92