@@ -27,7 +27,7 @@ void AppManager::setup() {
27
27
// kinectManager = new KinectManager();
28
28
// Depth thresholds for the kinect are set here.
29
29
30
- kinectManager = new KinectManager ( 255 , 90 , 20 );
30
+ kinectManager = new KinectManagerSimple ( );
31
31
32
32
// zero timeOfLastUpdate tracker
33
33
timeOfLastUpdate = elapsedTimeInSeconds ();
@@ -58,6 +58,11 @@ void AppManager::setup() {
58
58
59
59
kinectHandWavy = new KinectHandWavy (m_serialShapeIOManager, kinectManager);
60
60
applications[" kinectHandWavy" ] = kinectHandWavy;
61
+
62
+ // Telepresence mode takes 16 bit thresholding values as parameters here.
63
+ telepresence = new Telepresence (m_serialShapeIOManager, kinectManager,
64
+ 255 * 256 , 140 * 256 , cam);
65
+ applications[" telepresence" ] = telepresence;
61
66
62
67
equationMode = new EquationMode (m_serialShapeIOManager);
63
68
applications[" equationMode" ] = equationMode;
@@ -71,28 +76,61 @@ void AppManager::setup() {
71
76
ambientWave = new AmbientWave (m_serialShapeIOManager);
72
77
applications[" AmbientWave" ] = ambientWave;
73
78
79
+ // Set up the order of the applications in the order vector
80
+ applicationOrder.push_back (" videoPlayer" );
81
+ applicationOrder.push_back (" waveModeContours" );
82
+ applicationOrder.push_back (" equationMode" );
83
+ applicationOrder.push_back (" telepresence" );
84
+ applicationOrder.push_back (" kinectHandWavy" );
85
+ applicationOrder.push_back (" AmbientWave" );
86
+ applicationOrder.push_back (" singlePinDebug" );
87
+ applicationOrder.push_back (" axisChecker" );
88
+ applicationOrder.push_back (" mqttTransmission" );
89
+
74
90
// innitialize GUI
75
91
gui.setup (" modes:" );
76
- gui.setPosition (5 , 35 );
92
+ gui.setPosition (5 , 20 );
77
93
78
94
// IMPORTANT: ofxGui uses raw pointers to ofxButton, so an automatic resize
79
95
// of modeButtons will invalidate all existing pointers stored in gui.
80
96
// DO NOT .push_back MORE THAN applications.size()!!!!
81
97
modeButtons.reserve (applications.size ());
82
-
83
- for (map<string, Application *>::iterator iter = applications.begin (); iter != applications.end (); iter++) {
84
- Application *app = iter->second ;
85
-
86
- modeButtons.push_back (ofxButton ());
87
- modeNames.push_back (iter->first );
88
- auto p_button = modeButtons.back ().setup (app->getName ());
89
- gui.add (p_button);
90
-
91
- // shape display heights, if they are accessible
92
- }
98
+
99
+ int appIndex = 1 ; // Initialize an index for iteration
100
+
101
+ // Iterate over the applicationOrder vector and add the corresponding app to the GUI
102
+ for (const auto & appName : applicationOrder) {
103
+ Application *app = applications[appName];
104
+
105
+ modeButtons.push_back (ofxButton ());
106
+ modeNames.push_back (appName);
107
+
108
+ // Construct the new button name with the index prepended
109
+ std::string buttonName = std::to_string (appIndex) + " : " + app->getName ();
110
+ auto p_button = modeButtons.back ().setup (buttonName);
111
+ gui.add (p_button);
112
+
113
+ appIndex++;
114
+ }
115
+
116
+ // Collapse the GUI panel for now to make room for the new graphical buttons.
117
+ gui.minimize ();
93
118
94
119
// set default application
95
120
setCurrentApplication (" mqttTransmission" );
121
+
122
+ // *** Rectangular button setup ***
123
+ // Load a font for the button text.
124
+ ofTrueTypeFont::setGlobalDpi (72 );
125
+ displayFont20.load (" SourceSans3-Regular.ttf" , 20 );
126
+
127
+ // Set up the buttons by creating an ofRectangle for each application
128
+ for (int i = 0 ; i < applicationOrder.size (); i++){
129
+ ofRectangle button;
130
+ button.set (20 , 60 + 65 *i, 240 , 50 );
131
+ applicationButtons.push_back (button);
132
+ }
133
+
96
134
}
97
135
98
136
// initialize the shape display and set up shape display helper objects
@@ -229,7 +267,7 @@ void AppManager::draw() {
229
267
230
268
// draw text
231
269
int menuLeftCoordinate = 21 ;
232
- int menuHeight = 350 ;
270
+ int menuHeight = 680 ;
233
271
string title = currentApplication->getName () + (showDebugGui ? " - Debug" : " " );
234
272
ofDrawBitmapString (title, menuLeftCoordinate, menuHeight);
235
273
menuHeight += 30 ;
@@ -245,12 +283,45 @@ void AppManager::draw() {
245
283
menuHeight += 30 ;
246
284
247
285
// if there isn't already a debug gui, draw some more information
248
- if (!showDebugGui || currentApplication == applications[" water " ] || currentApplication == applications[" stretchy" ]) {
286
+ if (!showDebugGui || currentApplication == applications[" waveModeContours " ] || currentApplication == applications[" stretchy" ]) {
249
287
ofDrawBitmapString (currentApplication->appInstructionsText (),menuLeftCoordinate, menuHeight);
250
288
menuHeight += 20 ;
251
289
}
252
290
253
291
gui.draw ();
292
+
293
+ // Draw the rectangular buttons for each application.
294
+ for (int i = 0 ; i < applicationButtons.size (); i++){
295
+ if (applications[applicationOrder[i]] == currentApplication){
296
+ // Green for the current application
297
+ ofSetColor (ofColor::seaGreen);
298
+ } else if (applicationSwitchBlocked && applications[applicationOrder[i]] == applications[lastSelectedApplicationName]){
299
+ // Dark green for the target application during the transition, so that there is immediate button feedback.
300
+ ofSetColor (ofColor::darkGreen);
301
+ } else {
302
+ // Dark blue for the unselected applications.
303
+ ofSetColor (ofColor::midnightBlue);
304
+ }
305
+ // Draw a rounded rectangle for the application button with a 20 pixel radius.
306
+ ofDrawRectRounded (applicationButtons[i], 20 );
307
+
308
+ // Make a stroke around the current application button
309
+ if (applications[applicationOrder[i]] == currentApplication){
310
+ ofSetColor (ofColor::white);
311
+ ofNoFill ();
312
+ ofSetLineWidth (2 );
313
+ ofDrawRectRounded (applicationButtons[i], 20 );
314
+ ofFill ();
315
+ }
316
+
317
+ // Make a string with the name of the application with the loop index plus one prepended.
318
+ Application *app = applications[applicationOrder[i]];
319
+ string applicationOrderString = ofToString (i+1 ) + " : " + app->getName ();
320
+
321
+ // Add label for application button
322
+ ofSetColor (ofColor::white);
323
+ displayFont20.drawString (applicationOrderString, applicationButtons[i].x + 25 , applicationButtons[i].y + 30 );
324
+ }
254
325
255
326
// draw shape and color I/O images
256
327
@@ -356,20 +427,13 @@ void AppManager::keyPressed(int key) {
356
427
showDebugGui = !showDebugGui;
357
428
} else if (key == ' ' ) {
358
429
paused = !paused;
359
- } else if (key > ' 0' && key <= ' 9' && (key - ' 0' ) < applications.size ()) {
360
- int num = key - ' 0' ;
361
- for (map<string, Application *>::iterator iter = applications.begin (); iter != applications.end (); iter++) {
362
- // skip over empty entries created by checks
363
- if (iter->second == nullptr )
364
- continue ;
365
- num--;
366
- // num == 0 when iter gets to the Nth app
367
- if (num == 0 ) {
368
- setCurrentApplication (iter->first );
369
- break ;
370
- }
371
- }
372
- }
430
+ } else if (key > ' 0' && key <= ' 9' ) {
431
+ int num = key - ' 0' ;
432
+ if (num > 0 && num <= applicationOrder.size ()) {
433
+ setCurrentApplication (applicationOrder[num - 1 ]);
434
+ lastSelectedApplicationName = applicationOrder[num - 1 ];
435
+ }
436
+ }
373
437
/* else if (key == '1') {
374
438
setCurrentApplication("mqttTransmission");
375
439
} else if (key == '2') {
@@ -397,7 +461,17 @@ void AppManager::keyPressed(int key) {
397
461
void AppManager::keyReleased (int key) {};
398
462
void AppManager::mouseMoved (int x, int y) {};
399
463
void AppManager::mouseDragged (int x, int y, int button) {};
400
- void AppManager::mousePressed (int x, int y, int button) {};
464
+ void AppManager::mousePressed (int x, int y, int button) {
465
+ // Check if any of the application buttons were clicked
466
+ for (int i = 0 ; i < applicationButtons.size (); i++){
467
+ if (applicationButtons[i].inside (x, y)){
468
+ // Set the current application to the one that was clicked.
469
+ setCurrentApplication (applicationOrder[i]);
470
+ // Also set the last selected application, so that the button can be highlighted during the transition to the new application.
471
+ lastSelectedApplicationName = applicationOrder[i];
472
+ }
473
+ }
474
+ };
401
475
void AppManager::mouseReleased (int x, int y, int button) {};
402
476
void AppManager::windowResized (int w, int h) {};
403
477
void AppManager::gotMessage (ofMessage msg) {};
0 commit comments