| 1 |
/* |
| 2 |
* |
| 3 |
* Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* Further, this software is distributed without any warranty that it is |
| 16 |
* free of the rightful claim of any third person regarding infringement |
| 17 |
* or the like. Any license provided herein, whether implied or |
| 18 |
* otherwise, applies only to this software file. Patent licenses, if |
| 19 |
* any, provided herein do not apply to combinations of this program with |
| 20 |
* other software, or any other product whatsoever. |
| 21 |
* |
| 22 |
* You should have received a copy of the GNU Lesser General Public |
| 23 |
* License along with this library; if not, write to the Free Software |
| 24 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 25 |
* |
| 26 |
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, |
| 27 |
* Mountain View, CA 94043, or: |
| 28 |
* |
| 29 |
* http://www.sgi.com |
| 30 |
* |
| 31 |
* For further information regarding this notice, see: |
| 32 |
* |
| 33 |
* http://oss.sgi.com/projects/GenInfo/NoticeExplan/ |
| 34 |
* |
| 35 |
*/ |
| 36 |
|
| 37 |
/* |
| 38 |
* Copyright (C) 1990,91 Silicon Graphics, Inc. |
| 39 |
* |
| 40 |
_______________________________________________________________________ |
| 41 |
______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 42 |
| |
| 43 |
| $Revision: 1.3 $ |
| 44 |
| |
| 45 |
| Classes : SoXtPlaneViewer |
| 46 |
| |
| 47 |
| Author(s) : Alain Dumesny |
| 48 |
| |
| 49 |
______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 50 |
_______________________________________________________________________ |
| 51 |
*/ |
| 52 |
|
| 53 |
#include <cmath> |
| 54 |
#include <inttypes.h> |
| 55 |
#include <X11/Intrinsic.h> |
| 56 |
#include <X11/Xlib.h> |
| 57 |
#include <X11/keysym.h> |
| 58 |
|
| 59 |
#include <Inventor/SbPList.h> |
| 60 |
#include <Inventor/nodes/SoOrthographicCamera.h> |
| 61 |
#include <Inventor/nodes/SoPerspectiveCamera.h> |
| 62 |
#include <Inventor/Xt/SoXtCursors.h> |
| 63 |
#include <Inventor/Xt/viewers/SoXtPlaneViewer.h> |
| 64 |
#include <Inventor/Xt/SoXtIcons.h> |
| 65 |
#include <Inventor/Xt/SoXtResource.h> |
| 66 |
#include "SoXtBitmapButton.h" |
| 67 |
#include <GL/gl.h> |
| 68 |
|
| 69 |
/* |
| 70 |
* Defines |
| 71 |
*/ |
| 72 |
|
| 73 |
enum ViewerModes { |
| 74 |
PICK_MODE, |
| 75 |
VIEW_MODE, |
| 76 |
DOLLY_MODE_ACTIVE, |
| 77 |
PAN_MODE, |
| 78 |
PAN_MODE_ACTIVE, |
| 79 |
ROLL_MODE_ACTIVE, |
| 80 |
SEEK_MODE |
| 81 |
}; |
| 82 |
|
| 83 |
// list of custom push buttons |
| 84 |
enum { |
| 85 |
X_PUSH = 0, |
| 86 |
Y_PUSH, |
| 87 |
Z_PUSH, |
| 88 |
CAM_PUSH, |
| 89 |
PUSH_NUM |
| 90 |
}; |
| 91 |
|
| 92 |
|
| 93 |
// Resources for labels. |
| 94 |
typedef struct { |
| 95 |
char *planeViewer; |
| 96 |
char *transX; |
| 97 |
char *transY; |
| 98 |
char *planeViewerPreferenceSheet; |
| 99 |
char *dolly; |
| 100 |
char *zoom; |
| 101 |
} RES_LABELS; |
| 102 |
static RES_LABELS rl; |
| 103 |
static char *defaultLabel[]={ |
| 104 |
"Plane Viewer", |
| 105 |
"transX", |
| 106 |
"transY", |
| 107 |
"Plane Viewer Preference Sheet", |
| 108 |
"Dolly", |
| 109 |
"Zoom" |
| 110 |
}; |
| 111 |
|
| 112 |
|
| 113 |
//////////////////////////////////////////////////////////////////////// |
| 114 |
// |
| 115 |
// Public constructor - build the widget right now |
| 116 |
// |
| 117 |
SoXtPlaneViewer::SoXtPlaneViewer( |
| 118 |
Widget parent, |
| 119 |
const char *name, |
| 120 |
SbBool buildInsideParent, |
| 121 |
SoXtFullViewer::BuildFlag b, |
| 122 |
SoXtViewer::Type t) |
| 123 |
: SoXtFullViewer( |
| 124 |
parent, |
| 125 |
name, |
| 126 |
buildInsideParent, |
| 127 |
b, |
| 128 |
t, |
| 129 |
FALSE) // tell base class not to build just yet |
| 130 |
// |
| 131 |
//////////////////////////////////////////////////////////////////////// |
| 132 |
{ |
| 133 |
// In this case, render area is what the app wants, so buildNow = TRUE |
| 134 |
constructorCommon(TRUE); |
| 135 |
} |
| 136 |
|
| 137 |
//////////////////////////////////////////////////////////////////////// |
| 138 |
// |
| 139 |
// SoEXTENDER constructor - the subclass tells us whether to build or not |
| 140 |
// |
| 141 |
SoXtPlaneViewer::SoXtPlaneViewer( |
| 142 |
Widget parent, |
| 143 |
const char *name, |
| 144 |
SbBool buildInsideParent, |
| 145 |
SoXtFullViewer::BuildFlag b, |
| 146 |
SoXtViewer::Type t, |
| 147 |
SbBool buildNow) |
| 148 |
: SoXtFullViewer( |
| 149 |
parent, |
| 150 |
name, |
| 151 |
buildInsideParent, |
| 152 |
b, |
| 153 |
t, |
| 154 |
FALSE) // tell base class not to build just yet |
| 155 |
// |
| 156 |
//////////////////////////////////////////////////////////////////////// |
| 157 |
{ |
| 158 |
// In this case, render area may be what the app wants, |
| 159 |
// or it may want a subclass of render area. Pass along buildNow |
| 160 |
// as it was passed to us. |
| 161 |
constructorCommon(buildNow); |
| 162 |
} |
| 163 |
|
| 164 |
//////////////////////////////////////////////////////////////////////// |
| 165 |
// |
| 166 |
// Called by the constructors |
| 167 |
// |
| 168 |
// private |
| 169 |
// |
| 170 |
void |
| 171 |
SoXtPlaneViewer::constructorCommon(SbBool buildNow) |
| 172 |
// |
| 173 |
//////////////////////////////////////////////////////////////////////// |
| 174 |
{ |
| 175 |
// init local vars |
| 176 |
mode = isViewing() ? VIEW_MODE : PICK_MODE; |
| 177 |
createdCursors = FALSE; |
| 178 |
transCursor = dollyCursor = seekCursor = 0; |
| 179 |
setSize( SbVec2s(520, 470) ); // default size |
| 180 |
setClassName("SoXtPlaneViewer"); |
| 181 |
|
| 182 |
// Initialize buttonList. |
| 183 |
for (int i=0; i<PUSH_NUM; i++) |
| 184 |
buttonList[i] = NULL; |
| 185 |
|
| 186 |
// Build the widget tree, and let SoXtComponent know about our base widget. |
| 187 |
if (buildNow) { |
| 188 |
Widget w = buildWidget(getParentWidget()); |
| 189 |
setBaseWidget(w); |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
//////////////////////////////////////////////////////////////////////// |
| 194 |
// |
| 195 |
// Description: |
| 196 |
// Destructor. |
| 197 |
// |
| 198 |
// Use: public |
| 199 |
|
| 200 |
SoXtPlaneViewer::~SoXtPlaneViewer() |
| 201 |
// |
| 202 |
//////////////////////////////////////////////////////////////////////// |
| 203 |
{ |
| 204 |
for (int i=0; i<PUSH_NUM; i++) |
| 205 |
delete buttonList[i]; |
| 206 |
|
| 207 |
// free the viewer cursors |
| 208 |
Display *display = getDisplay(); |
| 209 |
if (display) { |
| 210 |
if (transCursor) XFreeCursor(display, transCursor); |
| 211 |
if (dollyCursor) XFreeCursor(display, dollyCursor); |
| 212 |
if (seekCursor) XFreeCursor(display, seekCursor); |
| 213 |
} |
| 214 |
} |
| 215 |
|
| 216 |
//////////////////////////////////////////////////////////////////////// |
| 217 |
// |
| 218 |
// Description: |
| 219 |
// Build the parent class widget, then add buttons. |
| 220 |
// |
| 221 |
// Use: protected |
| 222 |
Widget |
| 223 |
SoXtPlaneViewer::buildWidget(Widget parent) |
| 224 |
// |
| 225 |
//////////////////////////////////////////////////////////////////////// |
| 226 |
{ |
| 227 |
SoXtResource xp(parent); |
| 228 |
if (!xp.getResource( "planeViewer", "PlaneViewer", rl.planeViewer )) |
| 229 |
rl.planeViewer = defaultLabel[0]; |
| 230 |
setPopupMenuString( rl.planeViewer ); |
| 231 |
|
| 232 |
// Create the root widget and register it with a class name |
| 233 |
Widget w = SoXtFullViewer::buildWidget(parent); |
| 234 |
|
| 235 |
// get resources... |
| 236 |
|
| 237 |
SoXtResource xr(w); |
| 238 |
if (!xr.getResource( "transX", "TransX", rl.transX )) |
| 239 |
rl.transX = defaultLabel[1]; |
| 240 |
if (!xr.getResource( "transY", "TransY", rl.transY )) |
| 241 |
rl.transY = defaultLabel[2]; |
| 242 |
if (!xr.getResource( "planeViewerPreferenceSheet","PlaneViewerPreferenceSheet",rl.planeViewerPreferenceSheet )) |
| 243 |
rl.planeViewerPreferenceSheet = defaultLabel[3]; |
| 244 |
if (!xr.getResource( "dolly", "Dolly", rl.dolly )) |
| 245 |
rl.dolly = defaultLabel[4]; |
| 246 |
if (!xr.getResource( "zoom", "Zoom", rl.zoom )) |
| 247 |
rl.zoom = defaultLabel[5]; |
| 248 |
|
| 249 |
// assign decoration titles |
| 250 |
setBottomWheelString( rl.transX ); |
| 251 |
setLeftWheelString( rl. transY ); |
| 252 |
setPrefSheetString( rl.planeViewerPreferenceSheet ); |
| 253 |
|
| 254 |
return w; |
| 255 |
} |
| 256 |
|
| 257 |
//////////////////////////////////////////////////////////////////////// |
| 258 |
// |
| 259 |
// Description: |
| 260 |
// add our own button to the existing list |
| 261 |
// |
| 262 |
// Use: virtual protected |
| 263 |
void |
| 264 |
SoXtPlaneViewer::createViewerButtons(Widget parent) |
| 265 |
// |
| 266 |
//////////////////////////////////////////////////////////////////////// |
| 267 |
{ |
| 268 |
// get the default buttons |
| 269 |
SoXtFullViewer::createViewerButtons(parent); |
| 270 |
|
| 271 |
// allocate the custom buttons |
| 272 |
for (int i=0; i<PUSH_NUM; i++) { |
| 273 |
buttonList[i] = new SoXtBitmapButton(parent, FALSE); |
| 274 |
Widget w = buttonList[i]->getWidget(); |
| 275 |
XtVaSetValues(w, XmNuserData, this, NULL); |
| 276 |
XtAddCallback(w, XmNactivateCallback, |
| 277 |
(XtCallbackProc) SoXtPlaneViewer::pushButtonCB, (XtPointer) (unsigned long) i); |
| 278 |
|
| 279 |
// add this button to the list... |
| 280 |
viewerButtonWidgets->append(w); |
| 281 |
} |
| 282 |
|
| 283 |
// set the button images |
| 284 |
buttonList[X_PUSH]->setIcon(so_xt_X_bits, so_xt_icon_width, so_xt_icon_height); |
| 285 |
buttonList[Y_PUSH]->setIcon(so_xt_Y_bits, so_xt_icon_width, so_xt_icon_height); |
| 286 |
buttonList[Z_PUSH]->setIcon(so_xt_Z_bits, so_xt_icon_width, so_xt_icon_height); |
| 287 |
buttonList[CAM_PUSH]->setIcon(so_xt_persp_bits, so_xt_icon_width, so_xt_icon_height); |
| 288 |
} |
| 289 |
|
| 290 |
|
| 291 |
//////////////////////////////////////////////////////////////////////// |
| 292 |
// |
| 293 |
// Description: |
| 294 |
// Call the base class and sets the correct cursor on the window |
| 295 |
// |
| 296 |
// Use: virtual public |
| 297 |
void |
| 298 |
SoXtPlaneViewer::setViewing(SbBool flag) |
| 299 |
// |
| 300 |
//////////////////////////////////////////////////////////////////////// |
| 301 |
{ |
| 302 |
if (flag == viewingFlag) |
| 303 |
return; |
| 304 |
|
| 305 |
// call the base class |
| 306 |
SoXtFullViewer::setViewing(flag); |
| 307 |
|
| 308 |
switchMode(isViewing() ? VIEW_MODE : PICK_MODE); |
| 309 |
} |
| 310 |
|
| 311 |
//////////////////////////////////////////////////////////////////////// |
| 312 |
// |
| 313 |
// Description: |
| 314 |
// Enables/Disable the viewer cursor on the window. |
| 315 |
// |
| 316 |
// Use: virtual public |
| 317 |
void |
| 318 |
SoXtPlaneViewer::setCursorEnabled(SbBool flag) |
| 319 |
// |
| 320 |
//////////////////////////////////////////////////////////////////////// |
| 321 |
{ |
| 322 |
if (flag == cursorEnabledFlag) |
| 323 |
return; |
| 324 |
|
| 325 |
cursorEnabledFlag = flag; |
| 326 |
|
| 327 |
if (! isViewing()) |
| 328 |
return; |
| 329 |
|
| 330 |
updateCursor(); |
| 331 |
} |
| 332 |
|
| 333 |
//////////////////////////////////////////////////////////////////////// |
| 334 |
// |
| 335 |
// Description: |
| 336 |
// Call the parent class and change the right thumbwheel label. |
| 337 |
// |
| 338 |
// Use: virtual public |
| 339 |
void |
| 340 |
SoXtPlaneViewer::setCamera(SoCamera *newCamera) |
| 341 |
// |
| 342 |
//////////////////////////////////////////////////////////////////////// |
| 343 |
{ |
| 344 |
if (camera == newCamera) |
| 345 |
return; |
| 346 |
|
| 347 |
// set the right thumbwheel label and toggle button image based on |
| 348 |
// the camera type |
| 349 |
if (newCamera != NULL && (camera == NULL || |
| 350 |
newCamera->getTypeId() != camera->getTypeId())) { |
| 351 |
if (newCamera->isOfType(SoOrthographicCamera::getClassTypeId())) { |
| 352 |
if (buttonList[CAM_PUSH]) |
| 353 |
buttonList[CAM_PUSH]->setIcon(so_xt_ortho_bits, |
| 354 |
so_xt_icon_width, so_xt_icon_height); |
| 355 |
setRightWheelString( rl.zoom ); |
| 356 |
} |
| 357 |
else { |
| 358 |
if (buttonList[CAM_PUSH]) |
| 359 |
buttonList[CAM_PUSH]->setIcon(so_xt_persp_bits, |
| 360 |
so_xt_icon_width, so_xt_icon_height); |
| 361 |
setRightWheelString( rl.dolly ); |
| 362 |
} |
| 363 |
} |
| 364 |
|
| 365 |
// call parent class |
| 366 |
SoXtFullViewer::setCamera(newCamera); |
| 367 |
} |
| 368 |
|
| 369 |
//////////////////////////////////////////////////////////////////////// |
| 370 |
// |
| 371 |
// Description: |
| 372 |
// Process the given event to do viewing stuff |
| 373 |
// |
| 374 |
// Use: virtual protected |
| 375 |
void |
| 376 |
SoXtPlaneViewer::processEvent(XAnyEvent *xe) |
| 377 |
// |
| 378 |
//////////////////////////////////////////////////////////////////////// |
| 379 |
{ |
| 380 |
if ( processCommonEvents(xe) ) |
| 381 |
return; |
| 382 |
|
| 383 |
if (!createdCursors) |
| 384 |
updateCursor(); |
| 385 |
|
| 386 |
XButtonEvent *be; |
| 387 |
XMotionEvent *me; |
| 388 |
XKeyEvent *ke; |
| 389 |
XCrossingEvent *ce; |
| 390 |
KeySym keysym; |
| 391 |
|
| 392 |
SbVec2s raSize = getGlxSize(); |
| 393 |
|
| 394 |
switch(xe->type) { |
| 395 |
case ButtonPress: |
| 396 |
case ButtonRelease: |
| 397 |
be = (XButtonEvent *)xe; |
| 398 |
if (be->button != Button1 && be->button != Button2) |
| 399 |
break; |
| 400 |
|
| 401 |
locator[0] = be->x; |
| 402 |
locator[1] = raSize[1] - be->y; |
| 403 |
if (mode == SEEK_MODE) { |
| 404 |
if (xe->type == ButtonPress) |
| 405 |
seekToPoint(locator); |
| 406 |
} |
| 407 |
else { |
| 408 |
if (xe->type == ButtonPress) |
| 409 |
interactiveCountInc(); |
| 410 |
else // ButtonRelease |
| 411 |
interactiveCountDec(); |
| 412 |
updateViewerMode(be->state); |
| 413 |
} |
| 414 |
break; |
| 415 |
|
| 416 |
case KeyPress: |
| 417 |
case KeyRelease: |
| 418 |
ke = (XKeyEvent *)xe; |
| 419 |
keysym = XLookupKeysym(ke, 0); |
| 420 |
|
| 421 |
locator[0] = ke->x; |
| 422 |
locator[1] = raSize[1] - ke->y; |
| 423 |
if (keysym == XK_Control_L || keysym == XK_Control_R) |
| 424 |
updateViewerMode(ke->state); |
| 425 |
break; |
| 426 |
|
| 427 |
case MotionNotify: |
| 428 |
me = (XMotionEvent *)xe; |
| 429 |
switch (mode) { |
| 430 |
case DOLLY_MODE_ACTIVE: |
| 431 |
dollyCamera( SbVec2s(me->x, raSize[1] - me->y) ); |
| 432 |
break; |
| 433 |
case PAN_MODE_ACTIVE: |
| 434 |
translateCamera(SbVec2f(me->x/float(raSize[0]), (raSize[1] - me->y)/float(raSize[1]))); |
| 435 |
break; |
| 436 |
case ROLL_MODE_ACTIVE: |
| 437 |
rollCamera( SbVec2s(me->x, raSize[1] - me->y) ); |
| 438 |
break; |
| 439 |
} |
| 440 |
break; |
| 441 |
|
| 442 |
case LeaveNotify: |
| 443 |
case EnterNotify: |
| 444 |
ce = (XCrossingEvent *)xe; |
| 445 |
// |
| 446 |
// because the application might use Ctrl-key for motif menu |
| 447 |
// accelerators we might not receive a key-up event, so make sure |
| 448 |
// to reset any Ctrl mode if we loose focus, but don't do anything |
| 449 |
// if Ctrl-key is not down (nothing to do) or if a mouse button |
| 450 |
// is down (we will get another leaveNotify). |
| 451 |
// |
| 452 |
if (! (ce->state & ControlMask)) |
| 453 |
break; |
| 454 |
if (ce->state & Button1Mask || ce->state & Button2Mask) |
| 455 |
break; |
| 456 |
if (xe->type == LeaveNotify) |
| 457 |
switchMode(VIEW_MODE); |
| 458 |
else |
| 459 |
updateViewerMode(ce->state); |
| 460 |
break; |
| 461 |
} |
| 462 |
} |
| 463 |
|
| 464 |
//////////////////////////////////////////////////////////////////////// |
| 465 |
// |
| 466 |
// Description: |
| 467 |
// sets the viewer mode based on what keys and buttons are being pressed |
| 468 |
// |
| 469 |
// Use: private |
| 470 |
void |
| 471 |
SoXtPlaneViewer::updateViewerMode(unsigned int state) |
| 472 |
// |
| 473 |
//////////////////////////////////////////////////////////////////////// |
| 474 |
{ |
| 475 |
// ??? WARNING - this routine ONLY works because of |
| 476 |
// ??? SoXtViewer::updateEventState() which is called for us |
| 477 |
// ??? by SoXtViewer::processCommonEvents(). |
| 478 |
// ??? (XEvent state for button and modifier keys is not updated |
| 479 |
// ??? until after the event is received. WEIRD) |
| 480 |
|
| 481 |
// LEFT+MIDDLE down |
| 482 |
if (state & Button1Mask && state & Button2Mask) { |
| 483 |
switchMode(DOLLY_MODE_ACTIVE); |
| 484 |
} |
| 485 |
|
| 486 |
// LEFT down |
| 487 |
else if (state & Button1Mask) { |
| 488 |
if (state & ControlMask) |
| 489 |
switchMode(PAN_MODE_ACTIVE); |
| 490 |
else |
| 491 |
switchMode(DOLLY_MODE_ACTIVE); |
| 492 |
} |
| 493 |
|
| 494 |
// MIDDLE DOWN |
| 495 |
else if (state & Button2Mask) { |
| 496 |
if (state & ControlMask) |
| 497 |
switchMode(ROLL_MODE_ACTIVE); |
| 498 |
else |
| 499 |
switchMode(PAN_MODE_ACTIVE); |
| 500 |
} |
| 501 |
|
| 502 |
// no buttons down... |
| 503 |
else { |
| 504 |
if (state & ControlMask) |
| 505 |
switchMode(PAN_MODE); |
| 506 |
else |
| 507 |
switchMode(VIEW_MODE); |
| 508 |
} |
| 509 |
} |
| 510 |
|
| 511 |
//////////////////////////////////////////////////////////////////////// |
| 512 |
// |
| 513 |
// Description: |
| 514 |
// switches to the specified viewer mode |
| 515 |
// |
| 516 |
// Use: private |
| 517 |
void |
| 518 |
SoXtPlaneViewer::switchMode(int newMode) |
| 519 |
// |
| 520 |
//////////////////////////////////////////////////////////////////////// |
| 521 |
{ |
| 522 |
Widget raWidget = getRenderAreaWidget(); |
| 523 |
|
| 524 |
// assing new mode |
| 525 |
SbBool redrawNeeded = FALSE; |
| 526 |
int prevMode = mode; |
| 527 |
mode = newMode; |
| 528 |
|
| 529 |
// update the cursor |
| 530 |
updateCursor(); |
| 531 |
|
| 532 |
// check the old viewer mode for redraw need |
| 533 |
if (prevMode == ROLL_MODE_ACTIVE) |
| 534 |
redrawNeeded = TRUE; |
| 535 |
|
| 536 |
// switch to new viewer mode |
| 537 |
switch (newMode) { |
| 538 |
case PICK_MODE: |
| 539 |
if (raWidget && XtWindow(raWidget)) { |
| 540 |
// ???? is if are going into PICK mode and some of our |
| 541 |
// mouse buttons are still down, make sure to decrement |
| 542 |
// interactive count correctly (correct draw style). One |
| 543 |
// for the LEFT and one for MIDDLE mouse. |
| 544 |
Window root_return, child_return; |
| 545 |
int root_x_return, root_y_return; |
| 546 |
int win_x_return, win_y_return; |
| 547 |
unsigned int mask_return; |
| 548 |
XQueryPointer(XtDisplay(raWidget), XtWindow(raWidget), |
| 549 |
&root_return, &child_return, |
| 550 |
&root_x_return, &root_y_return, &win_x_return, |
| 551 |
&win_y_return, &mask_return); |
| 552 |
if (mask_return & Button1Mask && prevMode != SEEK_MODE) |
| 553 |
interactiveCountDec(); |
| 554 |
if (mask_return & Button2Mask && prevMode != SEEK_MODE) |
| 555 |
interactiveCountDec(); |
| 556 |
} |
| 557 |
break; |
| 558 |
|
| 559 |
case PAN_MODE_ACTIVE: |
| 560 |
{ |
| 561 |
// Figure out the focal plane |
| 562 |
SbMatrix mx; |
| 563 |
mx = camera->orientation.getValue(); |
| 564 |
SbVec3f forward(-mx[2][0], -mx[2][1], -mx[2][2]); |
| 565 |
SbVec3f fp = camera->position.getValue() + |
| 566 |
forward * camera->focalDistance.getValue(); |
| 567 |
focalplane = SbPlane(forward, fp); |
| 568 |
|
| 569 |
// map mouse starting position onto the panning plane |
| 570 |
SbVec2s raSize = getGlxSize(); |
| 571 |
SbViewVolume cameraVolume; |
| 572 |
SbLine line; |
| 573 |
cameraVolume = camera->getViewVolume(raSize[0]/float(raSize[1])); |
| 574 |
cameraVolume.projectPointToLine( |
| 575 |
SbVec2f(locator[0]/float(raSize[0]), locator[1]/float(raSize[1])), line); |
| 576 |
focalplane.intersect(line, locator3D); |
| 577 |
} |
| 578 |
break; |
| 579 |
|
| 580 |
case ROLL_MODE_ACTIVE: |
| 581 |
redrawNeeded = TRUE; |
| 582 |
break; |
| 583 |
} |
| 584 |
|
| 585 |
if (redrawNeeded) |
| 586 |
scheduleRedraw(); |
| 587 |
} |
| 588 |
|
| 589 |
//////////////////////////////////////////////////////////////////////// |
| 590 |
// |
| 591 |
// Description: |
| 592 |
// switches to the specified viewer mode |
| 593 |
// |
| 594 |
// Use: private |
| 595 |
void |
| 596 |
SoXtPlaneViewer::updateCursor() |
| 597 |
// |
| 598 |
//////////////////////////////////////////////////////////////////////// |
| 599 |
{ |
| 600 |
Widget w = getRenderAreaWidget(); |
| 601 |
Display *display = w ? XtDisplay(w) : NULL; |
| 602 |
Window window = w ? XtWindow(w) : 0; |
| 603 |
|
| 604 |
if (! window) |
| 605 |
return; |
| 606 |
|
| 607 |
if (! createdCursors) |
| 608 |
defineCursors(); |
| 609 |
|
| 610 |
// the viewer cursor are not enabled, then we don't set a new cursor. |
| 611 |
// Instead erase the old viewer cursor. |
| 612 |
if (! cursorEnabledFlag) { |
| 613 |
XUndefineCursor(display, window); |
| 614 |
return; |
| 615 |
} |
| 616 |
|
| 617 |
// ...else set the right cursor for the viewer mode.... |
| 618 |
switch(mode) { |
| 619 |
case PICK_MODE: |
| 620 |
case ROLL_MODE_ACTIVE: |
| 621 |
XUndefineCursor(display, window); |
| 622 |
break; |
| 623 |
|
| 624 |
case VIEW_MODE: |
| 625 |
case DOLLY_MODE_ACTIVE: |
| 626 |
XDefineCursor(display, window, dollyCursor); |
| 627 |
break; |
| 628 |
|
| 629 |
case PAN_MODE: |
| 630 |
case PAN_MODE_ACTIVE: |
| 631 |
XDefineCursor(display, window, transCursor); |
| 632 |
break; |
| 633 |
|
| 634 |
case SEEK_MODE: |
| 635 |
XDefineCursor(display, window, seekCursor); |
| 636 |
break; |
| 637 |
} |
| 638 |
} |
| 639 |
|
| 640 |
//////////////////////////////////////////////////////////////////////// |
| 641 |
// |
| 642 |
// Description: |
| 643 |
// draws viewer feedback during a render area redraw of the scene. |
| 644 |
// |
| 645 |
// Use: virtual protected |
| 646 |
void |
| 647 |
SoXtPlaneViewer::actualRedraw() |
| 648 |
// |
| 649 |
//////////////////////////////////////////////////////////////////////// |
| 650 |
{ |
| 651 |
// have the base class draw the scene |
| 652 |
SoXtFullViewer::actualRedraw(); |
| 653 |
|
| 654 |
// now draw the viewer feedback |
| 655 |
if (isViewing() && mode == ROLL_MODE_ACTIVE) { |
| 656 |
|
| 657 |
setFeedbackOrthoProjection(getGlxSize()); |
| 658 |
|
| 659 |
drawViewerRollFeedback(getGlxSize()/2, locator); |
| 660 |
|
| 661 |
// now restore state |
| 662 |
restoreGLStateAfterFeedback(); |
| 663 |
} |
| 664 |
} |
| 665 |
|
| 666 |
//////////////////////////////////////////////////////////////////////// |
| 667 |
// |
| 668 |
// Description: |
| 669 |
// Call the base class and sets the correct cursor on the window |
| 670 |
// |
| 671 |
// Use: virtual protected |
| 672 |
void |
| 673 |
SoXtPlaneViewer::setSeekMode(SbBool flag) |
| 674 |
// |
| 675 |
//////////////////////////////////////////////////////////////////////// |
| 676 |
{ |
| 677 |
if ( !isViewing() ) |
| 678 |
return; |
| 679 |
|
| 680 |
// call the base class |
| 681 |
SoXtFullViewer::setSeekMode(flag); |
| 682 |
|
| 683 |
mode = isSeekMode() ? SEEK_MODE : VIEW_MODE; |
| 684 |
|
| 685 |
updateCursor(); |
| 686 |
} |
| 687 |
|
| 688 |
//////////////////////////////////////////////////////////////////////// |
| 689 |
// |
| 690 |
// Description: |
| 691 |
// Redefine this routine to add some viewer specific stuff. |
| 692 |
// |
| 693 |
// Use: virtual protected |
| 694 |
void |
| 695 |
SoXtPlaneViewer::createPrefSheet() |
| 696 |
// |
| 697 |
//////////////////////////////////////////////////////////////////////// |
| 698 |
{ |
| 699 |
// create the preference sheet shell and form widget |
| 700 |
Widget shell, form; |
| 701 |
createPrefSheetShellAndForm(shell, form); |
| 702 |
|
| 703 |
// create all of the parts |
| 704 |
Widget widgetList[20]; |
| 705 |
int num = 0; |
| 706 |
createDefaultPrefSheetParts(widgetList, num, form); |
| 707 |
|
| 708 |
layoutPartsAndMapPrefSheet(widgetList, num, form, shell); |
| 709 |
} |
| 710 |
|
| 711 |
//////////////////////////////////////////////////////////////////////// |
| 712 |
// |
| 713 |
// Description: |
| 714 |
// Redefine this to keep the same camera rotation when seeking |
| 715 |
// |
| 716 |
// Use: virtual protected |
| 717 |
|
| 718 |
void |
| 719 |
SoXtPlaneViewer::computeSeekFinalOrientation() |
| 720 |
// |
| 721 |
//////////////////////////////////////////////////////////////////////// |
| 722 |
{ |
| 723 |
newCamOrientation = camera->orientation.getValue(); |
| 724 |
} |
| 725 |
|
| 726 |
//////////////////////////////////////////////////////////////////////// |
| 727 |
// |
| 728 |
// Description: |
| 729 |
// Brings the viewer help card (called by "?" push button) |
| 730 |
// |
| 731 |
// Use: virtual protected |
| 732 |
void |
| 733 |
SoXtPlaneViewer::openViewerHelpCard() |
| 734 |
// |
| 735 |
//////////////////////////////////////////////////////////////////////// |
| 736 |
{ |
| 737 |
// tell the base class to open the file for us |
| 738 |
openHelpCard("SoXtPlaneViewer.help"); |
| 739 |
} |
| 740 |
|
| 741 |
//////////////////////////////////////////////////////////////////////// |
| 742 |
// |
| 743 |
// Description: |
| 744 |
// Translate the camera right/left (called by thumb wheel). |
| 745 |
// |
| 746 |
// Use: virtual protected |
| 747 |
|
| 748 |
void |
| 749 |
SoXtPlaneViewer::bottomWheelMotion(float newVal) |
| 750 |
// |
| 751 |
//////////////////////////////////////////////////////////////////////// |
| 752 |
{ |
| 753 |
if (camera == NULL) |
| 754 |
return; |
| 755 |
|
| 756 |
// get camera right vector and translate camera by given amount |
| 757 |
SbMatrix mx; |
| 758 |
mx = camera->orientation.getValue(); |
| 759 |
SbVec3f rightVector(mx[0][0], mx[0][1], mx[0][2]); |
| 760 |
float dist = transXspeed * (bottomWheelVal - newVal); |
| 761 |
camera->position = camera->position.getValue() + dist * rightVector; |
| 762 |
|
| 763 |
bottomWheelVal = newVal; |
| 764 |
} |
| 765 |
|
| 766 |
//////////////////////////////////////////////////////////////////////// |
| 767 |
// |
| 768 |
// Description: |
| 769 |
// Translate the camera up/down (called by thumb wheel). |
| 770 |
// |
| 771 |
// Use: virtual protected |
| 772 |
|
| 773 |
void |
| 774 |
SoXtPlaneViewer::leftWheelMotion(float newVal) |
| 775 |
// |
| 776 |
//////////////////////////////////////////////////////////////////////// |
| 777 |
{ |
| 778 |
if (camera == NULL) |
| 779 |
return; |
| 780 |
|
| 781 |
// get camera up vector and translate camera by given amount |
| 782 |
SbMatrix mx; |
| 783 |
mx = camera->orientation.getValue(); |
| 784 |
SbVec3f upVector(mx[1][0], mx[1][1], mx[1][2]); |
| 785 |
float dist = transYspeed * (leftWheelVal - newVal); |
| 786 |
camera->position = camera->position.getValue() + dist * upVector; |
| 787 |
|
| 788 |
leftWheelVal = newVal; |
| 789 |
} |
| 790 |
|
| 791 |
//////////////////////////////////////////////////////////////////////// |
| 792 |
// |
| 793 |
// Description: |
| 794 |
// Moves the camera closer/further away from the plane of interest |
| 795 |
// (perspective camera case), else change the camera height (orthographic |
| 796 |
// camera case). |
| 797 |
// |
| 798 |
// Use: virtual protected |
| 799 |
|
| 800 |
void |
| 801 |
SoXtPlaneViewer::rightWheelMotion(float newVal) |
| 802 |
// |
| 803 |
//////////////////////////////////////////////////////////////////////// |
| 804 |
{ |
| 805 |
if (camera == NULL) |
| 806 |
return; |
| 807 |
|
| 808 |
if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) { |
| 809 |
// change the ortho camera height |
| 810 |
SoOrthographicCamera *cam = (SoOrthographicCamera *) camera; |
| 811 |
cam->height = cam->height.getValue() * powf(2.0, newVal - rightWheelVal); |
| 812 |
} |
| 813 |
else { |
| 814 |
// shorter/grow the focal distance given the wheel rotation |
| 815 |
float focalDistance = camera->focalDistance.getValue();; |
| 816 |
float newFocalDist = focalDistance; |
| 817 |
newFocalDist *= powf(2.0, newVal - rightWheelVal); |
| 818 |
|
| 819 |
// finally reposition the camera |
| 820 |
SbMatrix mx; |
| 821 |
mx = camera->orientation.getValue(); |
| 822 |
SbVec3f forward(-mx[2][0], -mx[2][1], -mx[2][2]); |
| 823 |
camera->position = camera->position.getValue() + |
| 824 |
(focalDistance - newFocalDist) * forward; |
| 825 |
camera->focalDistance = newFocalDist; |
| 826 |
} |
| 827 |
|
| 828 |
rightWheelVal = newVal; |
| 829 |
} |
| 830 |
|
| 831 |
//////////////////////////////////////////////////////////////////////// |
| 832 |
// |
| 833 |
// Description: |
| 834 |
// This routine is used to define cursors (can only be called after |
| 835 |
// window has been realized). |
| 836 |
// |
| 837 |
// Use: private |
| 838 |
|
| 839 |
void |
| 840 |
SoXtPlaneViewer::defineCursors() |
| 841 |
// |
| 842 |
//////////////////////////////////////////////////////////////////////// |
| 843 |
{ |
| 844 |
XColor foreground; |
| 845 |
Pixmap source; |
| 846 |
Display *display = getDisplay(); |
| 847 |
Drawable d = DefaultRootWindow(display); |
| 848 |
|
| 849 |
// set color |
| 850 |
foreground.red = 65535; |
| 851 |
foreground.green = foreground.blue = 0; |
| 852 |
|
| 853 |
// view plane translate cursor |
| 854 |
source = XCreateBitmapFromData(display, d, |
| 855 |
so_xt_flat_hand_bits, so_xt_flat_hand_width, so_xt_flat_hand_height); |
| 856 |
transCursor = XCreatePixmapCursor(display, source, source, |
| 857 |
&foreground, &foreground, so_xt_flat_hand_x_hot, so_xt_flat_hand_y_hot); |
| 858 |
XFreePixmap(display, source); |
| 859 |
|
| 860 |
// dolly cursor |
| 861 |
source = XCreateBitmapFromData(display, d, |
| 862 |
so_xt_pointing_hand_bits, so_xt_pointing_hand_width, so_xt_pointing_hand_height); |
| 863 |
dollyCursor = XCreatePixmapCursor(display, source, source, |
| 864 |
&foreground, &foreground, so_xt_pointing_hand_x_hot, so_xt_pointing_hand_y_hot); |
| 865 |
XFreePixmap(display, source); |
| 866 |
|
| 867 |
// seek cursor |
| 868 |
source = XCreateBitmapFromData(display, d, |
| 869 |
so_xt_target_bits, so_xt_target_width, so_xt_target_height); |
| 870 |
seekCursor = XCreatePixmapCursor(display, source, source, |
| 871 |
&foreground, &foreground, so_xt_target_x_hot, so_xt_target_y_hot); |
| 872 |
XFreePixmap(display, source); |
| 873 |
|
| 874 |
createdCursors = TRUE; |
| 875 |
} |
| 876 |
|
| 877 |
//////////////////////////////////////////////////////////////////////// |
| 878 |
// |
| 879 |
// Description: |
| 880 |
// Rolls the camera around it's forward direction given the new mouse |
| 881 |
// location. |
| 882 |
// |
| 883 |
// Use: private |
| 884 |
|
| 885 |
void |
| 886 |
SoXtPlaneViewer::rollCamera(const SbVec2s &newLocator) |
| 887 |
// |
| 888 |
//////////////////////////////////////////////////////////////////////// |
| 889 |
{ |
| 890 |
if (camera == NULL) |
| 891 |
return; |
| 892 |
|
| 893 |
SbVec2s center = getGlxSize()/2; |
| 894 |
SbVec2s p1, p2; |
| 895 |
float angle; |
| 896 |
|
| 897 |
// get angle of rotation |
| 898 |
p1 = locator - center; |
| 899 |
p2 = newLocator - center; |
| 900 |
// checking needed so that NaN won't occur |
| 901 |
angle = (p2[0]==0 && p2[1]==0) ? 0 : atan2(p2[1], p2[0]); |
| 902 |
angle -= (p1[0]==0 && p1[1]==0) ? 0 : atan2(p1[1], p1[0]); |
| 903 |
|
| 904 |
// now find the rotation and rotate camera |
| 905 |
SbVec3f axis(0, 0, -1); |
| 906 |
SbRotation rot; |
| 907 |
rot.setValue(axis, angle); |
| 908 |
camera->orientation = rot * camera->orientation.getValue(); |
| 909 |
|
| 910 |
locator = newLocator; |
| 911 |
} |
| 912 |
|
| 913 |
//////////////////////////////////////////////////////////////////////// |
| 914 |
// |
| 915 |
// Description: |
| 916 |
// Moves the camera into the plane defined by the camera forward vector |
| 917 |
// and the focal point to follow the new mouse location. |
| 918 |
// |
| 919 |
// Use: private |
| 920 |
|
| 921 |
void |
| 922 |
SoXtPlaneViewer::translateCamera(const SbVec2f &newLocator) |
| 923 |
// |
| 924 |
//////////////////////////////////////////////////////////////////////// |
| 925 |
{ |
| 926 |
if (camera == NULL) |
| 927 |
return; |
| 928 |
|
| 929 |
// map new mouse location into the camera focal plane |
| 930 |
SbViewVolume cameraVolume; |
| 931 |
SbLine line; |
| 932 |
SbVec3f newLocator3D; |
| 933 |
SbVec2s raSize = getGlxSize(); |
| 934 |
cameraVolume = camera->getViewVolume(raSize[0]/float(raSize[1])); |
| 935 |
cameraVolume.projectPointToLine(newLocator, line); |
| 936 |
focalplane.intersect(line, newLocator3D); |
| 937 |
|
| 938 |
// move the camera by the delta 3D position amount |
| 939 |
camera->position = camera->position.getValue() + |
| 940 |
(locator3D - newLocator3D); |
| 941 |
|
| 942 |
// You would think we would have to set locator3D to |
| 943 |
// newLocator3D here. But we don't, because moving the camera |
| 944 |
// essentially makes locator3D equal to newLocator3D in the |
| 945 |
// transformed space, and we will project the next newLocator3D in |
| 946 |
// this transformed space. |
| 947 |
} |
| 948 |
|
| 949 |
//////////////////////////////////////////////////////////////////////// |
| 950 |
// |
| 951 |
// Description: |
| 952 |
// Moves the camera forward/backward based on the new mouse potion. |
| 953 |
// (perspective camera), else change the camera height (orthographic |
| 954 |
// camera case). |
| 955 |
// |
| 956 |
// Use: private |
| 957 |
|
| 958 |
void |
| 959 |
SoXtPlaneViewer::dollyCamera(const SbVec2s &newLocator) |
| 960 |
// |
| 961 |
//////////////////////////////////////////////////////////////////////// |
| 962 |
{ |
| 963 |
if (camera == NULL) |
| 964 |
return; |
| 965 |
|
| 966 |
// moving the mouse up/down will move the camera futher/closer. |
| 967 |
// moving the camera sideway will not move the camera at all |
| 968 |
float d = (newLocator[1] - locator[1]) / 40.0; |
| 969 |
|
| 970 |
if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) { |
| 971 |
// change the ortho camera height |
| 972 |
SoOrthographicCamera *cam = (SoOrthographicCamera *) camera; |
| 973 |
cam->height = cam->height.getValue() * powf(2.0, d); |
| 974 |
} |
| 975 |
else { |
| 976 |
// shorter/grow the focal distance given the mouse move |
| 977 |
float focalDistance = camera->focalDistance.getValue();; |
| 978 |
float newFocalDist = focalDistance * powf(2.0, d); |
| 979 |
|
| 980 |
// finally reposition the camera |
| 981 |
SbMatrix mx; |
| 982 |
mx = camera->orientation.getValue(); |
| 983 |
SbVec3f forward(-mx[2][0], -mx[2][1], -mx[2][2]); |
| 984 |
camera->position = camera->position.getValue() + |
| 985 |
(focalDistance - newFocalDist) * forward; |
| 986 |
camera->focalDistance = newFocalDist; |
| 987 |
} |
| 988 |
|
| 989 |
locator = newLocator; |
| 990 |
} |
| 991 |
|
| 992 |
//////////////////////////////////////////////////////////////////////// |
| 993 |
// |
| 994 |
// Description: |
| 995 |
// Moves the camera to be aligned with the given plane |
| 996 |
// |
| 997 |
// Use: private |
| 998 |
|
| 999 |
void |
| 1000 |
SoXtPlaneViewer::setPlane(const SbVec3f &newNormal, const SbVec3f &newRight) |
| 1001 |
// |
| 1002 |
//////////////////////////////////////////////////////////////////////// |
| 1003 |
{ |
| 1004 |
if (camera == NULL) |
| 1005 |
return; |
| 1006 |
|
| 1007 |
// get center of rotation |
| 1008 |
SbRotation camRot = camera->orientation.getValue(); |
| 1009 |
float radius = camera->focalDistance.getValue(); |
| 1010 |
SbMatrix mx; |
| 1011 |
mx = camRot; |
| 1012 |
SbVec3f forward( -mx[2][0], -mx[2][1], -mx[2][2]); |
| 1013 |
SbVec3f center = camera->position.getValue() |
| 1014 |
+ radius * forward; |
| 1015 |
|
| 1016 |
// rotate the camera to be aligned with the new plane normal |
| 1017 |
SbRotation rot( -forward, newNormal); |
| 1018 |
camRot = camRot * rot; |
| 1019 |
|
| 1020 |
// rotate the camera to be aligned with new right direction |
| 1021 |
mx = camRot; |
| 1022 |
SbVec3f right(mx[0][0], mx[0][1], mx[0][2]); |
| 1023 |
rot.setValue(right, newRight); |
| 1024 |
camRot = camRot * rot; |
| 1025 |
camera->orientation = camRot; |
| 1026 |
|
| 1027 |
// reposition camera to look at pt of interest |
| 1028 |
mx = camRot; |
| 1029 |
forward.setValue( -mx[2][0], -mx[2][1], -mx[2][2]); |
| 1030 |
camera->position = center - radius * forward; |
| 1031 |
} |
| 1032 |
|
| 1033 |
//////////////////////////////////////////////////////////////////////// |
| 1034 |
// |
| 1035 |
// Description: |
| 1036 |
// Called by the bottom and left thumbwheels to compute the |
| 1037 |
// translation factors (how fast should we translate given a wheel |
| 1038 |
// rotation). |
| 1039 |
// |
| 1040 |
// Use: private |
| 1041 |
|
| 1042 |
void |
| 1043 |
SoXtPlaneViewer::computeTranslateValues() |
| 1044 |
// |
| 1045 |
//////////////////////////////////////////////////////////////////////// |
| 1046 |
{ |
| 1047 |
if (camera == NULL) |
| 1048 |
return; |
| 1049 |
|
| 1050 |
float height; |
| 1051 |
|
| 1052 |
if (camera->isOfType(SoPerspectiveCamera::getClassTypeId())) { |
| 1053 |
float angle = ((SoPerspectiveCamera *)camera)->heightAngle.getValue(); |
| 1054 |
float dist = camera->focalDistance.getValue(); |
| 1055 |
height = dist * tanf(angle); |
| 1056 |
} |
| 1057 |
else if (camera->isOfType(SoOrthographicCamera::getClassTypeId())) |
| 1058 |
height = ((SoOrthographicCamera *)camera)->height.getValue(); |
| 1059 |
|
| 1060 |
transYspeed = height / 2; |
| 1061 |
transXspeed = transYspeed * camera->aspectRatio.getValue(); |
| 1062 |
} |
| 1063 |
|
| 1064 |
// |
| 1065 |
// redefine those generic virtual functions |
| 1066 |
// |
| 1067 |
const char * |
| 1068 |
SoXtPlaneViewer::getDefaultWidgetName() const |
| 1069 |
{ return "SoXtPlaneViewer"; } |
| 1070 |
|
| 1071 |
const char * |
| 1072 |
SoXtPlaneViewer::getDefaultTitle() const |
| 1073 |
{ return rl.planeViewer; } |
| 1074 |
|
| 1075 |
const char * |
| 1076 |
SoXtPlaneViewer::getDefaultIconTitle() const |
| 1077 |
{ return rl.planeViewer; } |
| 1078 |
|
| 1079 |
|
| 1080 |
void |
| 1081 |
SoXtPlaneViewer::bottomWheelStart() |
| 1082 |
{ |
| 1083 |
interactiveCountInc(); |
| 1084 |
computeTranslateValues(); |
| 1085 |
} |
| 1086 |
|
| 1087 |
void |
| 1088 |
SoXtPlaneViewer::leftWheelStart() |
| 1089 |
{ |
| 1090 |
interactiveCountInc(); |
| 1091 |
computeTranslateValues(); |
| 1092 |
} |
| 1093 |
|
| 1094 |
|
| 1095 |
// |
| 1096 |
//////////////////////////////////////////////////////////////////////// |
| 1097 |
// static callbacks stubs |
| 1098 |
//////////////////////////////////////////////////////////////////////// |
| 1099 |
// |
| 1100 |
|
| 1101 |
|
| 1102 |
// |
| 1103 |
// viewer push button callbacks |
| 1104 |
// |
| 1105 |
void |
| 1106 |
SoXtPlaneViewer::pushButtonCB(Widget w, int id, void *) |
| 1107 |
{ |
| 1108 |
SoXtPlaneViewer *v; |
| 1109 |
XtVaGetValues(w, XmNuserData, &v, NULL); |
| 1110 |
|
| 1111 |
switch (id) { |
| 1112 |
case X_PUSH: v->setPlane( SbVec3f(1, 0, 0), SbVec3f(0, 0, -1) ); break; |
| 1113 |
case Y_PUSH: v->setPlane( SbVec3f(0, 1, 0), SbVec3f(1, 0, 0) ); break; |
| 1114 |
case Z_PUSH: v->setPlane( SbVec3f(0, 0, 1), SbVec3f(1, 0, 0) ); break; |
| 1115 |
case CAM_PUSH: v->toggleCameraType(); break; |
| 1116 |
} |
| 1117 |
} |