forked from dev2dev/Molecules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SLSMoleculeGLViewController.h
86 lines (70 loc) · 3.17 KB
/
SLSMoleculeGLViewController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// SLSMoleculeGLViewController.h
// Molecules
//
// The source code for Molecules is available under a BSD license. See License.txt for details.
//
// Created by Brad Larson on 6/30/2008.
//
// A controller for managing the OpenGL view of the molecule.
#import <UIKit/UIKit.h>
#import <OpenGLES/ES1/gl.h>
#import <QuartzCore/QuartzCore.h>
@class SLSMolecule;
@interface SLSMoleculeGLViewController : UIViewController <UIActionSheetDelegate>
{
// User interface elements
UIActivityIndicatorView *scanningActivityIndicator;
UIProgressView *renderingProgressIndicator;
UILabel *renderingActivityLabel;
UIActionSheet *visualizationActionSheet;
SLSMolecule *moleculeToDisplay;
CATransform3D currentCalculatedMatrix;
BOOL isAutorotating;
BOOL isFirstDrawingOfMolecule, isFrameRenderingFinished;
NSOperationQueue *renderingQueue;
NSTimer *autorotationTimer;
NSUInteger stepsSinceLastRotation;
float accumulatedXRotation, accumulatedYRotation, accumulatedScale, accumulatedXTranslation, accumulatedYTranslation;
// Touch-handling
float startingTouchDistance, previousScale;
float instantObjectScale, instantXRotation, instantYRotation, instantXTranslation, instantYTranslation, instantZTranslation;
CGPoint lastMovementPosition, previousDirectionOfPanning;
BOOL twoFingersAreMoving, pinchGestureUnderway;
float scalingForMovement;
}
@property (readwrite, retain) UIActionSheet *visualizationActionSheet;
@property (readwrite, retain) SLSMolecule *moleculeToDisplay;
@property (readonly) BOOL isFrameRenderingFinished;
// Display indicator control
- (void)showScanningIndicator:(NSNotification *)note;
- (void)updateScanningIndicator:(NSNotification *)note;
- (void)hideScanningIndicator:(NSNotification *)note;
- (void)showRenderingIndicator:(NSNotification *)note;
- (void)updateRenderingIndicator:(NSNotification *)note;
- (void)hideRenderingIndicator:(NSNotification *)note;
// Autorotation of molecule
- (void)startOrStopAutorotation:(id)sender;
- (void)handleAutorotationTimer;
// OpenGL matrix helper methods
- (void)convertMatrix:(GLfloat *)matrix to3DTransform:(CATransform3D *)transform3D;
- (void)convert3DTransform:(CATransform3D *)transform3D toMatrix:(GLfloat *)matrix;
- (void)print3DTransform:(CATransform3D *)transform3D;
- (void)printMatrix:(GLfloat *)fixedPointMatrix;
// OpenGL molecule rendering
- (void)drawView;
- (void)_drawViewByRotatingAroundX:(float)xRotation rotatingAroundY:(float)yRotation scaling:(float)scaleFactor translationInX:(float)xTranslation translationInY:(float)yTranslation;
- (void)drawViewByRotatingAroundX:(float)xRotation rotatingAroundY:(float)yRotation scaling:(float)scaleFactor translationInX:(float)xTranslation translationInY:(float)yTranslation;
- (void)resizeView;
- (void)runOpenGLBenchmarks;
- (void)updateSizeOfGLView:(NSNotification *)note;
// Manage molecule rendering state
- (void)handleFinishOfMoleculeRendering:(NSNotification *)note;
- (UIActionSheet *)actionSheetForVisualizationState;
// Touch handling
- (float)distanceBetweenTouches:(NSSet *)touches;
- (CGPoint)commonDirectionOfTouches:(NSSet *)touches;
- (void)handleTouchesEnding:(NSSet *)touches withEvent:(UIEvent *)event;
// Interface methods
- (IBAction)switchToTableView;
@end