User Interaction Chapters 10, 12, 13, 15. Events Events are actions applied to the graph Each node implements its own behavior When node is found to handle.

Slides:



Advertisements
Similar presentations
Benchmark Series Microsoft Access 2010 Level 1
Advertisements

CLINIC MANAGEMENT SYSTEM APPOINTMENT SCHEDULING. How will this start? Any schedules already built will not be carried over to the CMS Portal You will.
Binary Trees CSC 220. Your Observations (so far data structures) Array –Unordered Add, delete, search –Ordered Linked List –??
Multi-threaded applications SE SE-2811 Dr. Mark L. Hornick 2 What SE1011 students are told… When the main() method is called, the instructions.
Introduction to Excel 2007 Part 2: Bar Graphs and Histograms February 5, 2008.
CSI 3120, Exception handling, page 1 Exception and Event Handling Credits Robert W. Sebesta, Concepts of Programming Languages, 8 th ed., 2007 Dr. Nathalie.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
C++ Programming: Program Design Including Data Structures, Fifth Edition Chapter 17: Linked Lists.
Data Structures Using C++ 2E Chapter 11 Binary Trees and B-Trees.
Homework Tips. We will learn What actions are Apply actions to a node or a path Compute 3D bounding box Compute cumulative transformation matrix Insert.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 20: Binary Trees.
Reviewing Common Blocks for St. Agnes Elementary School Teachers by Jenny Chang Feb. 26th, 2007 USC & University Neighborhood Outreach Robotics STEM program.
Chapter 08 Binary Trees and Binary Search Trees © John Urrutia 2013, All Rights Reserved.
E- MAIL APPLICATION CALENDAR MODUL. B ENEFITS OF CALENDAR Calendar sharing. Outlook Web App now enables your users to share their calendars with people.
Chapter 61 Chapter 6 Index Structures for Files. Chapter 62 Indexes Indexes are additional auxiliary access structures with typically provide either faster.
NHD Flow Check. NHDFlowcheck is a utility for geometric network creation and validation of an NHD Flowline feature class that exists in a NHD dataset.
An INTRODUCTION to MICROSOFT ACESS 2000 By Dr. Ennis-Cole.
LabVIEW an Introduction
Tree.
Introduction to Scratch!
Forms - An Overview of Oracle Form Builder v.6.0 Abhishek Parag Prashant Arun.
Adding User Interactivity – Lesson 51 Adding User Interactivity Lesson 5.
Copyright © 2007, Oracle. All rights reserved. Managing Concurrent Requests.
Easy Studierstube Applications with a little help from OpenInventor Gerhard Reitmayr Gerhard Reitmayr Vienna University of Technology Vienna University.
Activities and Intents. Activities Activity is a window that contains the user interface of your application,typically an application has one or more.
Spring 2010CS 2251 Trees Chapter 6. Spring 2010CS 2252 Chapter Objectives Learn to use a tree to represent a hierarchical organization of information.
FLTK Help Session By Richard Yu Gu CS 638 -Graphics Fall, 1999.
KeyListener and Keyboard Events Another type of listener listens for keyboard entry – the KeyListener which generates KeyEvents –to implement KeyListener,
Open Inventor A short introduction. Capabilities of Open Inventor Easy construction of 3D scenes User interaction Animation.
Session Objectives How to Debug PTF test case/Script Session-6 DebuggingSlide 2.
1 VR assignment#2 WTK SDK Introduction By Jin-Bey Yu 2001/11/12.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
This is what we want to draw Extrude Mirror Round Edges.
Graphs – Part II CS 367 – Introduction to Data Structures.
QA and Testing. QA Activity Processes monitoring Standards compliance monitoring Software testing Infrastructure testing Documentation testing Usability.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 17: Linked Lists.
CHAPTER:07 JAVA IDE PROGRAMMING-II Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Object Oriented Programming.  Interface  Event Handling.
More on GLUT Programming Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, September 15, 2003.
11 General Game Programming Approach. The program is event-driven The program is event-driven –Messages = events –So as all windows system (for example.
Chapter 16 – Data Structures and Recursion. Data Structures u Built-in –Array –struct u User developed –linked list –stack –queue –tree Lesson 16.1.
고려대학교 그래픽스 연구실 An Inventor Sampler - The Inventor mentor 고려대학교 그래픽스 연구실 민 성환.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
CHAPTER 6 LESSON B Creating Custom Forms. Lesson B Objectives  Suppress default system messages  Create alerts and messages to provide system feedback.
Open a new Flash File Action Script 2.0. Create a button like you did last lesson and name it Click to Play.
Data Structures Using C++ 2E Chapter 11 Binary Trees.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Applying Actions 강 신 진
Chapter 5 Introduction To Form Builder. Lesson C Objectives  Use sequences to automatically generate primary key values in a form  Create lists of values.
1 DVR SYSTEM User’s Manual Manual Revision : Version 1.0 Release Date : Nov. 2, 2002 ■ SERVER ■ CLIENT.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
LINKED LISTS.
Forms Concepts Triggers Fired when Internal/External events occur
Data Structure and Algorithms
Lectures linked lists Chapter 6 of textbook
Event-driven programming
Privileges Grant and Revoke Grant Diagrams
Privileges Grant and Revoke Grant Diagrams
Programming Abstractions
Lecture 22 Binary Search Trees Chapter 10 of textbook
External Methods Chapter 15 (continued)
Introduction to Events
Data Structures Using C++ 2E
EE 422C Java FX.
Privileges Grant and Revoke Grant Diagrams
Nodes and Groups Lee Young Gun Open Inventor.
Programming Abstractions
1/10/2019 JavaFX Events COSC 330.
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Creating Additional Input Items
Presentation transcript:

User Interaction Chapters 10, 12, 13, 15

Events Events are actions applied to the graph Each node implements its own behavior When node is found to handle the event, the graph traversing stops.

Keyboard Events Create an event node. Create a callback function Add the node to the graph (typically to root) Callback nodes are written to file, but without the event they process Example …

Keyboard Events #include // Callback function void keyEvent(void* userData, SoEventCallback* eventCallBack){ const SoEvent *curEvent = eventCallBack->getEvent(); if(SO_KEY_PRESS_EVENT(curEvent, Q)) { exit(1); } // Main file SoEventCallback* switchEventCallBack = new SoEventCallback; root->addChild(switchEventCallBack); switchEventCallBack->addEventCallback(SoKeyboardEvent::getClassTypeId(), keyEvent, root); switchEventCallBack->removeEventCallback(SoKeyboardEvent::getClassTypeId(), keyEvent, root);

Mouse events Defined similarly to keyboard events –SoMouseButtonEvent and SoLocation2Event However SoWinExaminerViewer blocks the mouse events. To unblock them – check “arrow” button Example …

Selection of nodes SoSelection –Defined in SoSelection.h –Derived from SoGroup –Has a built-in method to handle mouse events –Responses to mouse click on object –Inserted near root (above, below or instead) –Used for manipulators

SoSelection SoSelection * root = new SoSelection; root->addSelectionCallback(selectionCallback, NULL); root->addDeselectionCallback(deselectionCallback, NULL); // // void selectionCallback(void *, SoPath *selectionPath) { SoTranslation *tr = (SoTranslation *)selectionPath->getNodeFromTail( 1); SbVec3f a = tr->translation.getValue(); std::cout<< a.getValue(); }

Sensors Special class of nodes Data sensors –Monitor a part of database and inform the application when that part changes Time sensors –Response to time events (inner events of Inventor)

Data sensors SoFieldSensor (attached to a field) SoNodeSensor (attached to a node) SoPathSensor (attached to a path)

Data sensors - example // Callback that reports whenever the viewer's position changes. static void cameraChangedCB(void *data, SoSensor *) { SoCamera *viewerCamera = (SoCamera *)data; SbVec3f cameraPosition = viewerCamera->position.getValue(); printf("Camera position: (%g,%g,%g)\n", cameraPosition[0], cameraPosition[1], cameraPosition[2]); } // main function SoCamera *camera = myViewer->getCamera(); SoFieldSensor *mySensor = // define callback and its input new SoFieldSensor(cameraChangedCB, camera); // Attach callback to camera position mySensor->attach(&camera->position);

Sequence for Data Sensors // Construct the sensor SoSensor *sensor = new SoSensor( func, data); // Function must be static void func( void *, SoSensor *) // since it obtains pointer to the sensor // Set the priority of the sensor // 0 highest // 100 is default priority (lowest) sensor->setPriority(priority number); // Attach the sensor to a field, node or path sensor->attach(pointer to object);

Using the trigger node and field You can use –getTriggerField(); –getTriggerNode(); –getTriggerPath(); For 0 priority sensors Use setTriggerPathFlag() –Sets trigger path flag to true –Saving path is expensive

Using the trigger node and field // This function prints a message whenever changes are made to the scene graph. // The sensor should be attached to root // Sensor callback function: static void rootChangedCB(void *, SoSensor *s) { // We know the sensor is really a data sensor: SoDataSensor *mySensor = (SoDataSensor *)s; SoNode *changedNode = mySensor->getTriggerNode(); SoField *changedField = mySensor->getTriggerField(); // Print the data printf("The node named '%s' changed\n",changedNode->getName().getString()); if (changedField != NULL) { SbName fieldName; changedNode->getFieldName(changedField, fieldName); printf(" (field %s)\n", fieldName.getString()); } else printf(" (no fields changed)\n"); }

Time sensors SoAlarmSensor –Goes off at a specific time SoTimerSensor –Goes off at intervals

Example // Rotate flag every minute static void raiseFlagCallback(void *data, SoSensor *) { // We know data is really a SoTransform node: SoTransform *flagAngleXform = (SoTransform *)data; // Rotate flag by 90 degrees about the z axis: flagAngleXform->rotation.setValue(SbVec3f(0,0,1), M_PI/2); } // Main function SoTransform *flagXform = new SoTransform; // Create an alarm that will call the flag-raising callback: SoAlarmSensor *myAlarm = new SoAlarmSensor(raiseFlagCallback, flagXform); myAlarm->setTimeFromNow(60.0); myAlarm->schedule();

Time sensors sequence Construct Set the callback Set the timing before scheduling Schedule using schedule() Delete when finished

Setting the timing For alarm: sensor->setTime(time); sensor->setTimerFromNow(time); For timer: Interval: sensor->setInterval(interval); First time (default is now): sensor->setBaseTime(time);

Example Rotate the flag with different frequencies Two frequencies are available –1Hz –10Hz Exchange the frequencies every 5 sec

Example SoRotation *myRotation = new SoRotation; root->addChild(myRotation); root->addChild(myFlag); SoTimerSensor *exchangeSensor = new SoTimerSensor(exchangeFrequencies, rotatingSensor); SoTimerSensor *rotatingSensor = new SoTimerSensor(rotateCallback, myRotation); exchangeSensor ->setInterval(5.0); // once per 5 seconds exchangeSensor ->schedule(); rotatingSensor->setInterval(1.0); //scheduled once per second rotatingSensor->schedule();

Example // This function is called once every 5 seconds, and // reschedules the other sensor. static void exchangeFrequencies(void *data, SoSensor *){ SoTimerSensor *rotatingSensor = (SoTimerSensor *)data; rotatingSensor->unschedule(); if (rotatingSensor->getInterval() == 1.0) rotatingSensor->setInterval(1.0/10.0); else rotatingSensor->setInterval(1.0); rotatingSensor->schedule(); } // This function is called either 10 times/second or once every // second; the scheduling changes every 5 seconds (see below): static void rotateCallback(void *data, SoSensor *){ // Rotate an object... SoRotation *myRotation = (SoRotation *)data; SbRotation currentRotation = myRotation->rotation.getValue(); currentRotation = SbRotation(SbVec3f(0,0,1), M_PI/90.0) *currentRotation; myRotation->rotation.setValue(currentRotation); }