VAPOR3 3.9.4
Manip.h
Go to the documentation of this file.
1//************************************************************************
2// *
3// Copyright (C) 2004 *
4// University Corporation for Atmospheric Research *
5// All Rights Reserved *
6// *
7//************************************************************************/
8//
9// File: Manip.h
10//
11// Author: Alan Norton
12// Scott Pearse
13// National Center for Atmospheric Research
14// PO 3000, Boulder, Colorado
15//
16// Date: Vapor3 implementation - May 2018
17// Vapor2 implementation - November 2005
18//
19// Description: Defines the pure virtual Manip class
20// Subclasses of this class provide in-scene manipulators
21// for positioning and setting properties of objects
22// in the scene.
23
24#ifndef MANIP_H
25#define MANIP_H
26
27#include <vapor/glutil.h>
28#include "vapor/Transform.h"
29
30// Handle diameter in pixels:
31#define HANDLE_DIAMETER 15
32//#define HANDLE_DIAMETER 3
33namespace VAPoR {
34
35struct GLManager;
36
37// class Visualizer;
38// class DataStatus;
49class Manip {
50public:
51 Manip(GLManager *glManager) : _glManager(glManager){};
52 virtual ~Manip() {}
53
55 virtual void Render() = 0;
56
62
71 virtual void Update(std::vector<double> llc, std::vector<double> urc, std::vector<double> minExtents, std::vector<double> maxExtents, VAPoR::Transform *rpTransform, VAPoR::Transform *dmTransform,
72 bool constrain) = 0;
73
77 virtual bool MouseEvent(int buttonNum, std::vector<double> screenCoords, double handleMidpoint[3], bool release = false) = 0;
78
82 virtual void GetBox(std::vector<double> &llc, std::vector<double> &urc) const = 0;
83
84protected:
87
91 virtual int _mouseIsOverHandle(const double screenCoords[2], double handleMid[3]) const = 0;
92
95
98 void _drawCubeFaces(double *extents, bool isSelected);
99
102
108 virtual void _mousePress(double screenCoords[2], double handleMidpoint[3], int buttonNum) = 0;
109
113 virtual void _mouseDrag(double screenCoords[2], double handleMidpoint[3]) = 0;
114
119 virtual void _mouseRelease(double screenCoords[2]) = 0;
120
123 virtual void _stretchCorners(double corners[8][3]) const = 0;
124
129 double _handleMid[3];
130 double _selection[6];
131 double _extents[6];
133 static const float _faceSelectionColor[4];
134 static const float _unselectedFaceColor[4];
135};
136
143
148public:
151 virtual void Render();
152
154 virtual void Update(std::vector<double> llc, std::vector<double> urc, std::vector<double> minExtents, std::vector<double> maxExtents, VAPoR::Transform *rpTransform, VAPoR::Transform *dmTransform,
155 bool constrain);
156
158 virtual bool MouseEvent(int buttonNum, std::vector<double> screenCoords, double handleMidpoint[3], bool release = false);
159
161 virtual void GetBox(std::vector<double> &llc, std::vector<double> &urc) const;
162
163private:
168 int _mouseIsOverHandle(const double screenCoords[2], double handleMid[3]) const;
169
173
176 virtual void _captureMouseDown(int handleNum, int buttonNum, const double strHandleMid[3]);
177
182 bool startHandleSlide(const double mouseCoords[2], int handleNum);
183
188 void setMouseDown(bool downUp) { _mouseDownHere = downUp; }
189
198 bool projectPointToLine(const double mouseCoords[2], double projCoords[2]);
199
208 bool pixelToVector(double winCoords[2], double dirVec[3], const double strHandleMid[3], double mouseWorldPos[3] = NULL);
209
211 virtual void drawBoxFaces() const;
212
221 virtual bool pointIsOnQuad(double cor1[3], double cor2[3], double cor3[3], double cor4[3], const double pickPt[2]) const;
222
227 virtual int pointIsOnBox(double corners[8][3], const double pkPt[2]) const;
228
229 double getPixelSize() const;
230
233 void transformMatrix(VAPoR::Transform *transform, std::vector<double> parentScales = {1, 1, 1});
234
237 void deScaleExtents(double *extents) const;
238
241 void deScaleExtents(double extents[8][3]) const;
242
247 void deScaleScalarOnAxis(float &scalar, int axis) const;
248
255 void drawHitBox(double winCoord1[2], double winCoord2[2], double winCoord3[2], double winCoord4[2]) const;
256
261 void drawHandleConnector(int handleNum, double *handleExtents, double *extents);
262
268 void makeHandleExtents(int handleNum, double *handleExtents, int octant, double *extents);
269
272
275 void drawCubeFaces(double *handleExtents, bool isSelected);
276
283 int makeHandleFaces(int handleNum, double handle[8][3], int octant, const double *boxExtents) const;
284
286
292 bool _projectPointToWin(const double cubeCoords[3], double winCoords[2]) const;
293
294 void _mousePress(double screenCoords[2], double handleMidpoint[3], int buttonNum);
295 void _mouseDrag(double screenCoords[2], double handleMidpoint[3]);
296 void _mouseRelease(double screenCoords[2]);
297 void _stretchCorners(double corners[8][3]) const;
298 void _translateCorners(double corners[8][3]) const;
299 void _moveMinusXCorners(double corners[8][3]) const;
300 void _moveMinusYCorners(double corners[8][3]) const;
301 void _moveMinusZCorners(double corners[8][3]) const;
302 void _movePlusXCorners(double corners[8][3]) const;
303 void _movePlusYCorners(double corners[8][3]) const;
304 void _movePlusZCorners(double corners[8][3]) const;
305 void _constrainExtents();
306
307 bool _isStretching;
308 bool _constrain;
309 double _handleSizeInScene;
310 double _cameraPosition[3];
311 double _modelViewMatrix[16];
312 double _projectionMatrix[16];
313 int _windowSize[2];
314 VAPoR::Transform *_rpTransform;
315 VAPoR::Transform *_dmTransform;
316
317 // screen coords where mouse is pressed:
318 float _mouseDownPoint[2];
319
320 // unit vector in direction of handle
321 float _handleProjVec[2];
322
323 bool _mouseDownHere;
324
325 // Vector from camera to handle, when mouse is initially clicked.
326 double _initialSelectionRay[3];
327
328 // Following only used by rotating manip subclasses:
329 double _tempRotation;
330 int _tempRotAxis;
331};
332}; // namespace VAPoR
333
334#endif // MANIP_H
A class that supports manipulators in in a VAPOR Visualizer.
Definition: Manip.h:49
virtual void _stretchCorners(double corners[8][3]) const =0
int _selectedHandle
Definition: Manip.h:127
virtual void _mouseRelease(double screenCoords[2])=0
param[in] screenCoords - coordinates of the cursor upon mose release
virtual void Render()=0
Pure virtual function renders the geometry of the Manip.
static const float _unselectedFaceColor[4]
Definition: Manip.h:134
static const float _faceSelectionColor[4]
Definition: Manip.h:133
virtual void _mouseDrag(double screenCoords[2], double handleMidpoint[3])=0
double _cameraPosition[3]
Definition: Manip.h:132
virtual int _mouseIsOverHandle(const double screenCoords[2], double handleMid[3]) const =0
void _drawCubeFaces(double *extents, bool isSelected)
double _dragDistance
Definition: Manip.h:128
Manip(GLManager *glManager)
Definition: Manip.h:51
int _buttonNum
Definition: Manip.h:126
GLManager * _glManager
Definition: Manip.h:125
virtual void Update(std::vector< double > llc, std::vector< double > urc, std::vector< double > minExtents, std::vector< double > maxExtents, VAPoR::Transform *rpTransform, VAPoR::Transform *dmTransform, bool constrain)=0
double _handleMid[3]
Definition: Manip.h:129
virtual bool MouseEvent(int buttonNum, std::vector< double > screenCoords, double handleMidpoint[3], bool release=false)=0
double _extents[6]
Definition: Manip.h:131
virtual void _mousePress(double screenCoords[2], double handleMidpoint[3], int buttonNum)=0
virtual ~Manip()
Definition: Manip.h:52
virtual void GetBox(std::vector< double > &llc, std::vector< double > &urc) const =0
double _selection[6]
Definition: Manip.h:130
class that indicates location and direction of view
Definition: Transform.h:22
A Manip subclass for manipulators that stretch and translate.
Definition: Manip.h:147
TranslateStretchManip(GLManager *glManager)
virtual void Update(std::vector< double > llc, std::vector< double > urc, std::vector< double > minExtents, std::vector< double > maxExtents, VAPoR::Transform *rpTransform, VAPoR::Transform *dmTransform, bool constrain)
virtual void GetBox(std::vector< double > &llc, std::vector< double > &urc) const
virtual ~TranslateStretchManip()
Definition: Manip.h:150
virtual void Render()
Pure virtual function renders the geometry of the Manip.
virtual bool MouseEvent(int buttonNum, std::vector< double > screenCoords, double handleMidpoint[3], bool release=false)
Contains references to context scope OpenGL data.
Definition: GLManager.h:18